@fabiofiorita/porcelain 0.65.2 → 0.65.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -7
- package/package.json +1 -1
- package/server/src/cli/main.mjs +2699 -2564
- package/web/dist/assets/_paired-BGQByqTx.js +1 -0
- package/web/dist/assets/_paired-C-OPMHd_.js +1 -0
- package/web/dist/assets/_paired-DR1ndZmE.js +1 -0
- package/web/dist/assets/_paired-qSHXbKkl.js +1 -0
- package/web/dist/assets/_section-D25X_IP_.js +1 -0
- package/web/dist/assets/_worktreeId-2AckLnuR.js +1 -0
- package/web/dist/assets/_worktreeId-Cfr9rr3q.js +1 -0
- package/web/dist/assets/_worktreeId-DR1ndZmE.js +1 -0
- package/web/dist/assets/_worktreeId-qSHXbKkl.js +1 -0
- package/web/dist/assets/access-CnKxJMA6.js +1 -0
- package/web/dist/assets/connected-workspace-DDQUa7Bv.js +1 -0
- package/web/dist/assets/desktop-actions-C6IPObdg.js +11 -0
- package/web/dist/assets/{edit-file-DOZdUUk9.js → edit-file-CqSI_R_G.js} +35 -35
- package/web/dist/assets/{file-editor-DvHSzrST.js → file-editor-CY822nHE.js} +14 -14
- package/web/dist/assets/files-Dq4t9_xQ.js +17 -0
- package/web/dist/assets/git-actions-BrTzG9I2.js +1345 -0
- package/web/dist/assets/{index-Cia9YleJ.js → index-D5KKCKKt.js} +4 -4
- package/web/dist/assets/index-DddS8Xzd.css +2 -0
- package/web/dist/assets/lazyRouteComponent-BpzFu5o7.js +1 -0
- package/web/dist/assets/link-B0k0Dw1r.js +1 -0
- package/web/dist/assets/pair-D3O7jbtO.js +1 -0
- package/web/dist/assets/pair-DR1ndZmE.js +1 -0
- package/web/dist/assets/search-CVF8YG8C.js +1 -0
- package/web/dist/assets/useRouterState-GGrtXzjn.js +1 -0
- package/web/dist/assets/workspace-error-CpgoRLTX.js +1 -0
- package/web/dist/assets/workspace-pending-CSj0ENeH.js +1 -0
- package/web/dist/index.html +10 -13
- package/web/dist/assets/_paired-B3CMUVff.js +0 -1
- package/web/dist/assets/_paired-B8xCvrtN.js +0 -1
- package/web/dist/assets/_paired-YiNqIqrL.js +0 -1
- package/web/dist/assets/_paired-rl3uQlkr.js +0 -1
- package/web/dist/assets/_section-DJ3o28t3.js +0 -1
- package/web/dist/assets/_worktreeId-B3CMUVff.js +0 -1
- package/web/dist/assets/_worktreeId-B8xCvrtN.js +0 -1
- package/web/dist/assets/_worktreeId-DS7C0JfB.js +0 -1
- package/web/dist/assets/_worktreeId-DzWffY3l.js +0 -1
- package/web/dist/assets/access-yiNkcsHW.js +0 -1
- package/web/dist/assets/connected-workspace-HwRJynH2.js +0 -1
- package/web/dist/assets/desktop-UhAM-aem.js +0 -14
- package/web/dist/assets/desktop-actions-_GPqaBVU.js +0 -12
- package/web/dist/assets/files-DGG-rGAk.js +0 -4
- package/web/dist/assets/git-actions-PSyqF5Ms.js +0 -1345
- package/web/dist/assets/index-DUPxq0qw.css +0 -2
- package/web/dist/assets/lazyRouteComponent-C0cxtC0x.js +0 -1
- package/web/dist/assets/link-Cr7ETqcH.js +0 -1
- package/web/dist/assets/pair-B3CMUVff.js +0 -1
- package/web/dist/assets/pair-pADUBfPY.js +0 -1
- package/web/dist/assets/preferences-gCf_-ng1.js +0 -1
- package/web/dist/assets/review-diagram-CK76VybL.js +0 -7
- package/web/dist/assets/review-diagram-DLioOiRN.css +0 -1
- package/web/dist/assets/search-YI2tNMg7.js +0 -1
- package/web/dist/assets/server-CO1nBw31.js +0 -1
- package/web/dist/assets/useRouterState-DpORzQ8V.js +0 -1
- package/web/dist/assets/workspace-error-DILP6VTh.js +0 -1
- package/web/dist/assets/workspace-pending-6RKmflS9.js +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$a as t,$i as n,A as r,Bi as i,Cn as a,D as o,Di as s,Ds as c,Et as l,Fi as u,Ft as d,Ga as f,Gl as p,Hi as m,It as h,J as g,Ja as _,Ji as v,Ka as y,Ki as b,Lo as x,Lt as S,M as C,Mi as w,Ni as T,Nl as E,Nt as D,Pi as O,Pt as k,Q as A,Qa as j,Qr as M,Rc as N,Ri as P,Ro as F,Rt as I,S as L,So as R,V as z,Wa as B,Xa as V,Xi as H,Xo as U,Z as W,Zr as G,_o as K,_s as q,ai as J,au as ee,b as Y,bo as te,bs as ne,ca as re,cu as ie,di as ae,do as oe,ei as se,eu as ce,fl as le,gc as ue,il as de,jc as fe,jt as pe,ki as X,ma as me,nt as he,nu as ge,oi as _e,oo as ve,q as ye,qo as be,ri as xe,rl as Se,sc as Ce,su as we,ti as Te,ui as Ee,uo as De,wt as Oe,x as ke,xs as Ae,z as je}from"./files-Dq4t9_xQ.js";import{$ as Me,An as Ne,On as Pe,Tn as Fe,_n as Ie,a as Le,d as Re,et as ze,f as Be,ft as Ve,ht as He,i as Ue,kn as We,mt as Ge,nt as Ke,o as qe,pt as Je,r as Ye,rt as Xe,s as Ze,vn as Qe,wt as $e}from"./access-CnKxJMA6.js";import{i as et,n as tt}from"./link-B0k0Dw1r.js";import{$ as nt,$n as rt,$t as it,An as at,At as ot,Bt as st,C as ct,Cn as lt,Ct as ut,D as dt,Dt as ft,En as pt,Et as mt,F as ht,Fn as gt,Ft as _t,G as vt,Gt as yt,H as bt,Ht as xt,I as St,In as Ct,It as wt,J as Tt,K as Et,Kt as Dt,L as Ot,Lt as kt,M as At,Mn as jt,Mt,N as Nt,Nt as Pt,O as Ft,Ot as It,P as Lt,Pn as Rt,Pt as zt,Q as Bt,Qn as Vt,Qt as Ht,R as Ut,Rn as Wt,Rt as Gt,S as Kt,Sn as qt,St as Jt,Tn as Yt,Tt as Xt,U as Zt,Ut as Qt,V as $t,Vt as en,W as tn,Wt as nn,X as rn,Xt as an,Y as on,Z as sn,Zt as cn,_ as ln,_n as un,_t as dn,at as fn,b as pn,bn as mn,bt as hn,cn as gn,ct as _n,d as vn,dn as yn,dt as bn,en as xn,er as Sn,et as Cn,ft as wn,g as Tn,gn as En,gt as Dn,h as On,ht as kn,it as An,j as jn,jn as Mn,jt as Nn,k as Pn,kt as Fn,l as In,ln as Ln,lt as Rn,m as zn,mn as Bn,mt as Vn,n as Hn,nn as Un,nt as Wn,on as Gn,ot as Kn,pn as qn,pt as Jn,q as Yn,qt as Xn,rn as Zn,rt as Qn,s as $n,sn as er,tn as tr,tr as nr,tt as rr,un as ir,ut as ar,v as or,vn as sr,vt as cr,wn as lr,wt as ur,x as dr,xn as fr,y as pr,yn as mr,yt as hr,zn as gr,zt as _r}from"./edit-file-CqSI_R_G.js";import{$ as vr,$t as yr,A as br,At as xr,B as Sr,Bt as Cr,C as wr,Cn as Tr,D as Er,E as Dr,F as Or,Ft as kr,G as Ar,Gt as jr,H as Mr,Ht as Nr,It as Pr,J as Fr,Jt as Ir,K as Lr,Kt as Rr,Lt as zr,Mt as Br,N as Vr,Nt as Hr,O as Ur,Ot as Wr,P as Gr,Pt as Kr,Qt as qr,Rt as Jr,S as Yr,Sn as Xr,T as Zr,Tt as Qr,U as $r,Ut as ei,V as ti,Vt as ni,W as ri,Wt as ii,X as ai,Xt as oi,Y as si,Yt as ci,Z as li,Zt as ui,_ as di,_n as fi,_t as pi,a as mi,an as hi,at as gi,b as _i,bn as vi,c as yi,cn as bi,ct as xi,dn as Si,en as Ci,et as wi,f as Ti,fn as Ei,gt as Di,h as Oi,hn as ki,ht as Ai,i as ji,in as Mi,it as Ni,jt as Pi,k as Fi,kt as Ii,ln as Li,m as Ri,mn as zi,mt as Bi,n as Vi,nn as Hi,nt as Ui,o as Wi,ot as Gi,p as Ki,pn as qi,q as Ji,qt as Yi,r as Xi,rn as Zi,rt as Qi,s as $i,st as ea,t as ta,tn as na,tt as ra,un as ia,v as aa,vn as oa,w as sa,wn as ca,wt as la,x as ua,xn as da,y as fa,yn as pa,z as ma,zt as ha}from"./git-actions-BrTzG9I2.js";import{n as ga,t as _a}from"./cloneFileDiffMetadata-zVRGqYgv.js";import{n as va,t as ya}from"./search-CVF8YG8C.js";var ba={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};ba.node;var xa=d(ba),Sa={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};Sa.node;var Ca=d(Sa),wa={name:`chevrons-down-up`,size:24,node:[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]};wa.node;var Ta=d(wa),Ea={name:`chevrons-up-down`,size:24,node:[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]};Ea.node;var Da=d(Ea),Oa={name:`circle-minus`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]],aliases:[`minus-circle`]};Oa.node;var ka=d(Oa),Aa={name:`circle-x`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-circle`]};Aa.node;var ja=d(Aa),Ma={name:`columns-2`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]],aliases:[`columns`]};Ma.node;var Na=d(Ma),Pa={name:`compass`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}]]};Pa.node;var Fa=d(Pa),Ia={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};Ia.node;var La=d(Ia),Ra={name:`external-link`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]};Ra.node;var za=d(Ra),Ba={name:`file-question-mark`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}]],aliases:[`file-question`]};Ba.node;var Va=d(Ba),Ha={name:`file-text`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]};Ha.node;var Ua=d(Ha),Wa={name:`file`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]};Wa.node;var Ga=d(Wa),Ka={name:`files`,size:24,node:[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]};Ka.node;var qa=d(Ka),Ja={name:`flask-conical`,size:24,node:[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]};Ja.node;var Ya=d(Ja),Xa={name:`git-graph`,size:24,node:[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M5 9v6`,key:`158jrl`}],[`circle`,{cx:`5`,cy:`18`,r:`3`,key:`104gr9`}],[`path`,{d:`M12 3v18`,key:`108xh3`}],[`circle`,{cx:`19`,cy:`6`,r:`3`,key:`108a5v`}],[`path`,{d:`M16 15.7A9 9 0 0 0 19 9`,key:`1e3vqb`}]]};Xa.node;var Za=d(Xa),Qa={name:`git-merge`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]};Qa.node;var $a=d(Qa),eo={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};eo.node;var to=d(eo),no={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};no.node;var ro=d(no),io={name:`list-x`,size:24,node:[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M11 12H3`,key:`51ecnj`}],[`path`,{d:`M16 19H3`,key:`zzsher`}],[`path`,{d:`m15.5 9.5 5 5`,key:`ytk86i`}],[`path`,{d:`m20.5 9.5-5 5`,key:`17o44f`}]]};io.node;var ao=d(io),oo={name:`message-square-plus`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]};oo.node;var so=d(oo),co={name:`message-square`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]};co.node;var lo=d(co),uo={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};uo.node;var fo=d(uo),po={name:`panel-right`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]};po.node;var mo=d(po),ho={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};ho.node;var go=d(ho),_o={name:`square-x`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-square`]};_o.node;var vo=d(_o),yo={name:`user`,size:24,node:[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]};yo.node;var bo=d(yo);function xo({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function So(e,t){let n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:Co(n,e.startContentIndex)}}function Co(e,t){let n=e.unifiedLineStart;for(let r=0;r<t;r++){let t=e.hunkContent[r];n+=t.type===`context`?t.lines:t.deletions+t.additions}return n}var Z=Ee();function wo({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:r,renderHeaderFilenameSuffix:i,renderHeaderMetadata:a,renderAnnotation:o,renderGutterUtility:s,renderMergeConflictUtility:c,lineAnnotations:l,getHoveredLine:u,getInstance:d,getAnnotationSlotName:f=yn}){let p=n?.(e),m=r?.(e),h=i?.(e),g=a?.(e);return(0,Z.jsxs)(Z.Fragment,{children:[p==null?(0,Z.jsxs)(Z.Fragment,{children:[m!=null&&(0,Z.jsx)(`div`,{slot:`header-prefix`,children:m}),h!=null&&(0,Z.jsx)(`div`,{slot:`header-filename-suffix`,children:h}),g!=null&&(0,Z.jsx)(`div`,{slot:`header-metadata`,children:g})]}):(0,Z.jsx)(`div`,{slot:En,children:p}),o!=null&&l?.map((e,t)=>(0,Z.jsx)(`div`,{slot:f(e),children:o(e)},t)),t!=null&&c!=null&&d!=null&&t.map(t=>{if(t==null)return;let n=To(t,e);return(0,Z.jsx)(`div`,{slot:n,style:Ct,children:c(t,d)},n)}),s!=null&&(0,Z.jsx)(`div`,{slot:`gutter-utility-slot`,style:gt,children:s(u)})]})}function To(e,t){let n=So(e,t);return n==null?void 0:xo({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex})}function Eo(e,t){return e==null||t==null?e===t:e.header!==t.header||e.footer!==t.footer?!1:Do(e.items,t.items)}function Do(e,t){if(e==null||t==null)return e===t;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r==null||i==null||r.id!==i.id||r.type!==i.type||r.element!==i.element||r.instance!==i.instance||r.version!==i.version)return!1}return!0}function Oo(e,t,n){let r=document.createElement(`div`);return r.style.display=`flow-root`,e===`header`?(r.setAttribute(Bn,``),t.before(r)):(r.setAttribute(qn,``),t.after(r)),n?.observe(r),r}function ko(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Ao(e){let t=window.devicePixelRatio??1;return Math.round(e*t)/t}async function jo(e,t=300){let n;try{await Promise.race([e(),new Promise(e=>{n=setTimeout(e,t)})])}finally{n!=null&&clearTimeout(n)}}function Mo({fileDiff:e,metrics:t,disableFileHeader:n,hunkSeparators:r,expandUnchanged:i,expandedHunks:a,collapsedContextThreshold:o,canHydratePartialDiff:s}){let c=wt(t,n),l=c,u=i?!0:a,d=e.hunks.length-1;for(let n=0;n<e.hunks.length;n++){let i=e.hunks[n];if(i==null)throw Error(`computeEstimatedDiffHeights: invalid hunk index`);let a=mt({isPartial:e.isPartial,rangeSize:i.collapsedBefore,expandedHunks:u,hunkIndex:n,collapsedContextThreshold:o}),f=(a.fromStart+a.fromEnd)*t.lineHeight;if(c+=f,l+=f,a.collapsedLines>0){let e=It({type:r,metrics:t,hunkIndex:n,hunkSpecs:i.hunkSpecs})?.totalHeight??0;c+=e,l+=e}c+=i.splitLineCount*t.lineHeight,l+=i.unifiedLineCount*t.lineHeight;let p=No(i);c+=p.split*t.lineHeight,l+=p.unified*t.lineHeight;let m=n===d?Nn({fileDiff:e,hunkIndex:n,expandedHunks:u,collapsedContextThreshold:o,errorPrefix:`computeEstimatedDiffHeights`}):void 0;if(m!=null){let e=(m.fromStart+m.fromEnd)*t.lineHeight;if(c+=e,l+=e,m.collapsedLines>0){let e=Mt({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}else if(n===d&&e.isPartial&&s){let e=Mt({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}if(e.hunks.length>0){let e=kt(t);c+=e,l+=e}return{splitHeight:c,unifiedHeight:l}}function No(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 Po(e,t)}function Po(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 Fo({oldFile:e,newFile:t},n){if(e!==void 0||t!==void 0){if(e===void 0||t===void 0)throw Error(`${n}: Pass null for an intentionally missing oldFile or newFile side`);if(e===null){if(t===null)throw Error(`${n}: You must pass oldFile, newFile, or both`);return{oldFile:e,newFile:t}}return{oldFile:e,newFile:t}}}function Io(e){return e===``?[]:e.split(Rt)}function Lo(e,t,n){let r=e===`clone`?_a(t):t;if(!r.isPartial)throw Error(`hydratePartialDiff: fileDiff must be partial`);switch(r.type){case`change`:case`rename-changed`:return Ro(r,Bo(r,n),Vo(r,n));case`rename-pure`:{let e=Vo(r,n);Ho(r,n);let t=Io(e.contents);return r.isPartial=!1,r.deletionLines=t,r.additionLines=t,Wo(r,null,e),r}}throw Error(`hydratePartialDiff: ${r.type} diffs cannot be hydrated from loaded files`)}function Ro(e,t,n){let r=Io(t.contents),i=Io(n.contents),{hunks:a,splitLineCount:o,unifiedLineCount:s}=zo(e.hunks,i.length);return e.hunks=a,e.splitLineCount=o,e.unifiedLineCount=s,e.isPartial=!1,e.deletionLines=r,e.additionLines=i,Wo(e,t,n),e}function zo(e,t){let n=0,r=0,i=0,a=[];for(let t of e){let e=Math.max(t.additionStart-1,0),o=Math.max(t.deletionStart-1,0),s=e,c=o,l=0,u=0,d=0,f=0,p=[];for(let e of t.hunkContent){if(e.type===`context`){p.push({...e,additionLineIndex:s,deletionLineIndex:c}),s+=e.lines,c+=e.lines,d+=e.lines,f+=e.lines;continue}p.push({...e,additionLineIndex:s,deletionLineIndex:c}),s+=e.additions,c+=e.deletions,l+=e.additions,u+=e.deletions,d+=Math.max(e.additions,e.deletions),f+=e.additions+e.deletions}let m=Math.max(ir(t.additionStart,t.additionCount)-i,0);a.push({...t,collapsedBefore:m,additionLineIndex:e,deletionLineIndex:o,additionLines:l,deletionLines:u,hunkContent:p,splitLineStart:n+m,unifiedLineStart:r+m,splitLineCount:d,unifiedLineCount:f}),n+=m+d,r+=m+f,i=Ln(t.additionStart,t.additionCount)}if(a.length>0){let e=a[a.length-1],i=Ln(e.additionStart,e.additionCount),o=Math.max(t-i,0);n+=o,r+=o}return{hunks:a,splitLineCount:n,unifiedLineCount:r}}function Bo(e,t){if(t.oldFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile`);return t.oldFile}function Vo(e,t){if(t.newFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires newFile`);return t.newFile}function Ho(e,t){if(t.oldFile!==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile to be null`)}function Uo(e,t,n){return e.cacheKey==null?Go(t,n):`${e.cacheKey}:hydrated`}function Wo(e,t,n){let r=Uo(e,t,n);if(r==null){delete e.cacheKey;return}e.cacheKey=r}function Go(e,t){return e!=null&&t!=null?e.cacheKey!=null&&t.cacheKey!=null?Hi(`hydrated-files`,e.cacheKey,t.cacheKey):void 0:e?.cacheKey??t?.cacheKey}var Ko=`/dev/null`;function qo(e,t,n,r=!1){if(e===null&&t===null)throw Error(`parseDiffFromFile: You must pass oldFile, newFile, or both`);let i=e??Jo(),a=t??Jo(),o=ut(i.name,a.name,i.contents,a.contents,i.header,a.header,n),s=na(o,{cacheKey:(()=>{let n=e?.cacheKey,r=t?.cacheKey;return n!=null&&r!=null?Hi(`diff`,n,r):void 0})(),oldFile:i,newFile:a,throwOnError:r});if(s==null)throw Error(`parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?`);e===null?(s.type=`new`,s.prevName=void 0):t===null&&(s.type=`deleted`,s.prevName=void 0);let c=t?.lang??(t===null?e?.lang:void 0);return c!=null&&(s.lang=c),s}function Jo(){return{name:Ko,contents:``}}var Yo=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 Xo(e,t){let n=qo({name:e.prevName??e.name,contents:e.deletionLines.join(``)},{name:e.name,contents:e.additionLines.join(``),lang:e.lang},t);return{hunks:n.hunks,splitLineCount:n.splitLineCount,unifiedLineCount:n.unifiedLineCount,additionLines:n.additionLines,deletionLines:n.deletionLines,type:n.type}}function Zo(e,t){let n=Math.max(e,1),r=Array.from({length:n},(e,t)=>`${` `.repeat(t+1)}\n`).join(``);return r===t&&(r=Array.from({length:n},(e,t)=>`\u0000${` `.repeat(t)}\n`).join(``)),r}function Qo(e){for(let t of e)if(t.trim().length>0)return!1;return!0}function $o(e,t){return t.length>0&&t.length<e.deletionLines.length&&Qo(t)}function es(e,t,n){let r=e.deletionLines.join(``),i=Zo(t.length,r),a=qo({name:e.prevName??e.name,contents:r},{name:e.name,contents:i,lang:e.lang},n);return{hunks:a.hunks,splitLineCount:a.splitLineCount,unifiedLineCount:a.unifiedLineCount,additionLines:t,deletionLines:a.deletionLines,type:a.type}}function ts(e,t){return es(e,[``],t)}function ns(e,t){if(e.additionLines.length===0)return ts(e,t);if($o(e,e.additionLines))return es(e,e.additionLines,t);let n=e.additionLines,r=Xo(e,t);return is(r,n),r}function rs(e){return e.length>1&&e.at(-1)===``}function is(e,t){if(!rs(t))return;let n=t.length-e.additionLines.length;if(n<=0)return;let r=e.additionLines.length,i=e.hunks.at(-1);if(i!=null&&Ln(i.additionStart,i.additionCount)===r){for(let a of i.hunkContent)if(a.type===`change`&&a.additions<a.deletions&&a.additionLineIndex+a.additions===r){e.additionLines=t,a.additions+=n,i.additionCount+=n,i.additionLines+=n,ms(e);return}}}function as(e,t,n){if(e.isPartial||e.deletionLines.length!==e.additionLines.length)return os(e,Xo(e,n));let r=Array.from(t);if(r.length===0)return os(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type});for(let t of r){let r=e.additionLines[t],i=e.deletionLines[t];if(r==null||i==null||ur(r)===ur(i))return os(e,Xo(e,n))}let i=ss(e,r);if(i.size===0)return os(e,Xo(e,n));for(let t of i)if(!ls(e,t,n))return os(e,Xo(e,n));return ms(e),Pt(e)?os(e,Xo(e,n)):os(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type})}function os(e,t){return Object.assign(e,t),t}function ss(e,t){let n=new Set;for(let r of t){let t=cs(e,r);if(t==null)return new Set;n.add(t)}return n}function cs(e,t){for(let[n,r]of e.hunks.entries()){let e=r.additionLineIndex+r.additionCount;if(t>=r.additionLineIndex&&t<e)return n}}function ls(e,t,n){let r=e.hunks[t];if(r==null)return!1;let i=e.deletionLines.slice(r.deletionLineIndex,r.deletionLineIndex+r.deletionCount),a=e.additionLines.slice(r.additionLineIndex,r.additionLineIndex+r.additionCount),o=qo({name:e.prevName??e.name,contents:i.join(``)},{name:e.name,contents:a.join(``),lang:e.lang},{...n,context:0}),s=o.hunks[0];return s==null||o.hunks.length!==1?!1:(ds(r,s),us(e,t),!0)}function us(e,t){let n=e.hunks[t];if(n==null)return;if(t!==e.hunks.length-1){n.noEOFCRAdditions=!1,n.noEOFCRDeletions=!1;return}let r=e.additionLines.at(-1),i=e.deletionLines.at(-1);n.noEOFCRAdditions=r!=null&&r!==``&&!r.endsWith(`
|
|
2
|
+
`),n.noEOFCRDeletions=i!=null&&i!==``&&!i.endsWith(`
|
|
3
|
+
`)}function ds(e,t){let n=e.additionLineIndex,r=e.deletionLineIndex;e.hunkContent=t.hunkContent.map(e=>fs(e,n,r)),e.additionLineIndex=n+t.additionLineIndex,e.additionStart+=t.additionLineIndex,e.additionCount=t.additionCount,e.additionLines=t.additionLines,t.deletionLineIndex>=0&&(e.deletionLineIndex=r+t.deletionLineIndex,e.deletionStart+=t.deletionLineIndex),e.deletionCount=t.deletionCount,e.deletionLines=t.deletionLines,e.noEOFCRAdditions=t.noEOFCRAdditions,e.noEOFCRDeletions=t.noEOFCRDeletions,ps(e)}function fs(e,t,n){return{...e,additionLineIndex:e.additionLineIndex+t,deletionLineIndex:e.deletionLineIndex+n}}function ps(e){let t=0,n=0;for(let r of e.hunkContent)r.type===`context`?(t+=r.lines,n+=r.lines):(t+=Math.max(r.additions,r.deletions),n+=r.additions+r.deletions);e.splitLineCount=t,e.unifiedLineCount=n}function ms(e){let t=0,n=0,r=0;for(let i of e.hunks)i.collapsedBefore=Math.max(ir(i.additionStart,i.additionCount)-r,0),i.splitLineStart=t+i.collapsedBefore,i.unifiedLineStart=n+i.collapsedBefore,ps(i),t+=i.collapsedBefore+i.splitLineCount,n+=i.collapsedBefore+i.unifiedLineCount,r=Ln(i.additionStart,i.additionCount);if(e.hunks.length>0){let r=e.hunks[e.hunks.length-1],i=Math.max(e.additionLines.length-Ln(r.additionStart,r.additionCount),0);t+=i,n+=i}e.splitLineCount=t,e.unifiedLineCount=n}var hs=new WeakMap;function gs(e){return e.length>1&&e[e.length-1]===``?e.slice(0,-1):e}function _s(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;let i=e.length,a=t.length;for(;i>r&&a>r&&e[i-1]===t[a-1];)i--,a--;if(r!==i||r!==a)return{start:r,deletionEnd:i,additionEnd:a}}function vs(e,t){let n=e.hunks,r=e.additionLines,i=gs(r),a=i===r?e:{...e,additionLines:i},o=Os(n,Ds(a,t),e.deletionLines.length),s=js(a,o);if(e.additionLines=i,e.hunks=s,e.editSessionDirty=!0,Vs(e),is(e,r),Ps(n,e.hunks))return{regions:o.map(e=>e.previousSpan)}}function ys(e,t,n,r){let i=Array.from(new Set(t)).filter(t=>t>=0&&t<e.additionLines.length).sort((e,t)=>e-t);if(i.length===0)return;let{hunks:a}=e,o,s=0;for(let t of i){for(;s<a.length;){let e=a[s];if(t<Ls(e)+e.additionCount)break;s++}let r=a[s],i=r==null?void 0:Ls(r);if(i==null||t<i||o!=null&&o!==s)return vs(e,n);o=s}if(o!=null){if(bs(e,i,o,r,n)){e.editSessionDirty=!0;return}return vs(e,n)}}function bs(e,t,n,r,i){if(r==null||i?.ignoreWhitespace===!0||i?.stripTrailingCr===!0)return!1;let a=xs(e),o=e.hunks[n];if(o.hunkContent.some(Ss))return!1;for(let n of t){let t=r.get(n),i=e.additionLines[n];if(t==null||i==null||a.has(t)||a.has(i))return!1;let s=!1;for(let e of o.hunkContent)if(e.type===`change`&&e.additions===e.deletions&&n>=e.additionLineIndex&&n<e.additionLineIndex+e.additions){s=!0;break}if(!s)return!1}return!0}function xs(e){let t=hs.get(e);if(t?.lines===e.deletionLines)return t.set;let n=new Set(e.deletionLines);return hs.set(e,{lines:e.deletionLines,set:n}),n}function Ss(e){return e?.type===`change`&&(e.additions===0||e.deletions===0)}function Cs(e,t){let n=new Map,{regions:r}=t;for(let t=0;t<=r.length;t++){let i=r[t-1],a=r[t],o=t===0?e.get(0):i==null?void 0:e.get(i.lastIndex+1),s=a==null?void 0:e.get(a.firstIndex),c=o?.fromStart??0,l=s?.fromEnd??0;(c>0||l>0)&&n.set(t,{fromStart:c,fromEnd:l})}return n}function ws(e,t,n){let r=[];if(e.isPartial)return r;for(let[i,a]of e.hunks.entries()){let o=mt({isPartial:e.isPartial,rangeSize:a.collapsedBefore,expandedHunks:t,hunkIndex:i,collapsedContextThreshold:n});if(o.rangeSize<=n)continue;let s=Rs(a),c=s-o.rangeSize;o.fromStart>0&&r.push([c,c+o.fromStart]),o.fromEnd>0&&r.push([s-o.fromEnd,s])}let i=Nn({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:`captureExpansionAnchors`});if(i!=null&&i.fromStart>0&&i.rangeSize>n){let t=e.hunks[e.hunks.length-1],n=Rs(t)+t.deletionCount;r.push([n,n+i.fromStart])}return r}function Ts(e,t){let n=new Map;if(t.length===0)return n;let r=(e,r,i)=>{if(i<=r)return;let a=0,o=0;for(let[e,n]of t)n<=r||e>=i||(e<=r&&(a=Math.max(a,Math.min(n,i)-r)),n>=i&&(o=Math.max(o,i-Math.max(e,r))));(a>0||o>0)&&n.set(e,{fromStart:a,fromEnd:o})};for(let[t,n]of e.hunks.entries()){let e=Rs(n);r(t,e-Math.max(n.collapsedBefore,0),e)}let i=e.hunks[e.hunks.length-1];return i!=null&&!e.isPartial&&e.deletionLines.length>0&&r(e.hunks.length,Rs(i)+i.deletionCount,e.deletionLines.length),n}function Es(e,t){return e.editSessionDirty===!0&&(delete e.editSessionDirty,Object.assign(e,e.additionLines.length<=1&&e.additionLines.join(``)===``?Xo(e,t):ns(e,t)),!0)}function Ds(e,t){if(_s(e.deletionLines,e.additionLines)==null)return[];let n=qo({name:e.prevName??e.name,contents:e.deletionLines.join(``)},{name:e.name,contents:e.additionLines.join(``),lang:e.lang},t),r=[],i=0,a=0;for(let e of n.hunks){let t=e.additionCount>0?e.additionLineIndex-i:e.deletionLineIndex-a;i+=t,a+=t;for(let t of e.hunkContent){if(t.type===`context`){i+=t.lines,a+=t.lines;continue}let e=fs(t,0,0);e.additions===0&&(e.additionLineIndex=i),e.deletions===0&&(e.deletionLineIndex=a),r.push(e),i+=e.additions,a+=e.deletions}}return r}function Os(e,t,n){let r=e.map((e,t)=>{let n=Rs(e);return{deletionStart:n,deletionEnd:n+e.deletionCount,blocks:[],previousSpan:{firstIndex:t,lastIndex:t}}}),i=[],a=0;for(let e of t){let t=e.deletionLineIndex,o=t+e.deletions;for(;a<r.length&&r[a].deletionEnd<t;)i.push(r[a]),a++;let s=i.length>0&&ks(t,o,i[i.length-1])?i.pop():void 0;for(;a<r.length&&r[a].deletionStart<=o;)s=As(s,r[a]),a++;if(s==null){let c=t,l=o;if((e.deletions===0||e.additions===0)&&n>e.deletions){let e=i[i.length-1]?.deletionEnd??0,s=r[a]?.deletionStart??n;t>e?c--:o<s&&l++}s={deletionStart:c,deletionEnd:l,blocks:[],previousSpan:void 0}}s.deletionStart=Math.min(s.deletionStart,t),s.deletionEnd=Math.max(s.deletionEnd,o),s.blocks.push(e),i.push(s)}for(;a<r.length;)i.push(r[a]),a++;return i}function ks(e,t,n){return e<=n.deletionEnd&&t>=n.deletionStart}function As(e,t){return e==null?t:(e.deletionStart=Math.min(e.deletionStart,t.deletionStart),e.deletionEnd=Math.max(e.deletionEnd,t.deletionEnd),e.blocks.push(...t.blocks),t.previousSpan!=null&&(e.previousSpan??={...t.previousSpan},e.previousSpan.firstIndex=Math.min(e.previousSpan.firstIndex,t.previousSpan.firstIndex),e.previousSpan.lastIndex=Math.max(e.previousSpan.lastIndex,t.previousSpan.lastIndex)),e)}function js(e,t){let n=[],r=0,i=0;for(let a of t){let t=a.deletionStart-r;if(t<0)throw Error(`buildRegionHunks: overlapping old-side regions`);r+=t,i+=t;let o=i,s=[];for(let e of a.blocks){let t=e.deletionLineIndex-r,n=e.additionLineIndex-i;if(t<0||t!==n)throw Error(`buildRegionHunks: canonical block context mismatch`);Ns(s,t,i,r),r+=t,i+=n,s.push({...e}),r+=e.deletions,i+=e.additions}let c=a.deletionEnd-r;if(c<0)throw Error(`buildRegionHunks: block exceeds its old-side region`);Ns(s,c,i,r),r+=c,i+=c,n.push(Ms(e,{additionStart:o,additionEnd:i,deletionStart:a.deletionStart,deletionEnd:a.deletionEnd},s))}if(e.deletionLines.length-r!==e.additionLines.length-i)throw Error(`buildRegionHunks: trailing context mismatch`);return n}function Ms(e,t,n){let r=t.additionEnd-t.additionStart,i=t.deletionEnd-t.deletionStart,a=0,o=0;for(let e of n)e.type===`change`&&(a+=e.additions,o+=e.deletions);let s={collapsedBefore:0,additionStart:zs(t.additionStart,r),additionCount:r,additionLines:a,additionLineIndex:Bs(t.additionStart,r),deletionStart:zs(t.deletionStart,i),deletionCount:i,deletionLines:o,deletionLineIndex:Bs(t.deletionStart,i),hunkContent:n,hunkSpecs:`@@ -${zs(t.deletionStart,i)},${i} +${zs(t.additionStart,r)},${r} @@`,splitLineStart:0,splitLineCount:0,unifiedLineStart:0,unifiedLineCount:0,noEOFCRAdditions:!1,noEOFCRDeletions:!1};return ps(s),s}function Ns(e,t,n,r){t>0&&e.push({type:`context`,lines:t,additionLineIndex:n,deletionLineIndex:r})}function Ps(e,t){if(e.length!==t.length)return!0;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(Rs(r)!==Rs(i)||r.deletionCount!==i.deletionCount||Ls(r)!==Ls(i)||r.additionCount!==i.additionCount||r.splitLineCount!==i.splitLineCount||!Fs(r,i))return!0}return!1}function Fs(e,t){let n=Is(e),r=Is(t);for(;;){let e=n.next(),t=r.next();if(e.done===!0||t.done===!0)return e.done===t.done;if(e.value[0]!==t.value[0]||e.value[1]!==t.value[1])return!1}}function*Is(e){for(let t of e.hunkContent){if(t.type===`context`){for(let e=0;e<t.lines;e++)yield[t.deletionLineIndex+e,t.additionLineIndex+e];continue}let e=Math.max(t.deletions,t.additions);for(let n=0;n<e;n++)yield[n<t.deletions?t.deletionLineIndex+n:void 0,n<t.additions?t.additionLineIndex+n:void 0]}}function Ls(e){return ir(e.additionStart,e.additionCount)}function Rs(e){return ir(e.deletionStart,e.deletionCount)}function zs(e,t){return t===0?e:e+1}function Bs(e,t){return t===0?e-1:e}function Vs(e){ms(e);for(let t=0;t<e.hunks.length;t++)us(e,t)}function Hs(e){return yt({tagName:`div`,properties:{"data-content-buffer":``,"data-buffer-size":e,style:`grid-row: span ${e};min-height:calc(${e} * 1lh)`}})}function Us(e){return yt({tagName:`div`,children:[yt({tagName:`span`,children:[Xn(`No newline at end of file`)]})],properties:{"data-no-newline":``,"data-line-type":e,"data-column-content":``}})}function Ws(e){return yt({tagName:`div`,children:[Dt({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 Gs({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(yt({tagName:`div`,children:[Xn(t)],properties:{"data-separator-wrapper":``}})),(e===`line-info`||e===`line-info-basic`)&&t!=null){let e=[];n!=null&&(r?(a||(e.push(Ws(`up`)),s++),o||(e.push(Ws(`down`)),s++)):(e.push(Ws(!a&&!o?`both`:a?`down`:`up`)),s++)),e.push(yt({tagName:`div`,children:[yt({tagName:`span`,children:[Xn(t)],properties:{"data-unmodified-lines":``}})],properties:{"data-separator-content":``}})),r&&n!=null&&e.push(yt({tagName:`div`,children:[Xn(`Expand all`)],properties:{role:`button`,"data-expand-button":``,"data-expand-all-button":``}})),c.push(yt({tagName:`div`,children:e,properties:{"data-separator-wrapper":``,"data-separator-multi-button":s>1?``:void 0}}))}return e===`custom`&&i!=null&&c.push(yt({tagName:`slot`,properties:{name:i}})),yt({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 Ks(e,t){return`hunk-separator-${e}-${t}`}function qs(e){let t=e.at(-1);return t==null?0:Math.max(Ln(t.additionStart,t.additionCount),Ln(t.deletionStart,t.deletionCount))}var Js=-1,Ys=class{options;annotationSlotName;onRenderUpdate;workerManager;__id=`diff-hunks-renderer:${++Js}`;highlighter;diff;expandedHunks=new Map;deletionAnnotations={};additionAnnotations={};computedLangs=[`text`];renderCache;pendingHighlightResult;pendingStructuralRows;editSessionActive=!1;constructor(e={theme:qt},t=yn,n,r){this.options=e,this.annotationSlotName=t,this.onRenderUpdate=n,this.workerManager=r,r?.isWorkingPool()!==!0&&(this.highlighter=Un(e.theme??qt)?Ht():void 0)}cleanUp(){this.recycle(),this.expandedHunks.clear(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.highlighter=void 0,this.diff=void 0,this.clearRenderCache(),this.additionAnnotations={},this.deletionAnnotations={},this.workerManager?.cleanUpTasks(this),this.endEditSession()}beginEditSession(e,t){let{editSessionActive:n,renderCache:r}=this;if(this.editSessionActive=!0,n||(this.pendingHighlightResult=void 0),this.diff=e,!e.isPartial&&e.additionLines.length===0){Object.assign(e,ts(e,this.options.parseDiffOptions)),this.markEditSessionPass(e),this.clearRenderCache();return}if(r==null||n&&r.diff===e)return;let{options:i}=this.getRenderOptions(e),a=r.diff===e,o=t!=null&&en(r.diff,t),{result:s}=r;if(!r.highlighted||s==null||!_r(r.options,i)||!a&&!o){this.clearRenderCache();return}a||(this.renderCache={diff:e,options:i,highlighted:!0,result:{...s,code:{...s.code,additionLines:[...s.code.additionLines]}},renderRange:r.renderRange})}endEditSession(){this.editSessionActive=!1,this.pendingHighlightResult=void 0}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}refreshHighlightedResult(){let{diff:e,renderCache:t,workerManager:n}=this;return e==null||t==null||!en(t.diff,e)||Gt(e)||cc(e,this.getTokenizeMaxLength())?Promise.resolve():!this.editSessionActive&&n?.isWorkingPool()===!0&&e.cacheKey!=null?(n.evictDiffFromCache(e.cacheKey),n.primeDiffHighlightCache(e).then(()=>{this.applyRefreshedResult(e,n.getDiffResultCache(e))}).catch(e=>this.onHighlightError(e))):this.asyncHighlight(e).then(t=>this.applyRefreshedResult(e,t)).catch(e=>this.onHighlightError(e))}applyRefreshedResult(e,t){let{diff:n,renderCache:r}=this;if(t==null||n==null||r==null||!en(n,e)||!en(r.diff,e)||this.editSessionActive)return;let{options:i}=this.getRenderOptions(n);_r(i,t.options)&&(this.pendingHighlightResult={diff:n,options:t.options,highlighted:!0,result:t.result},this.onRenderUpdate?.())}get diffCache(){return this.renderCache?.diff??this.diff}clearRenderCache(){this.renderCache=void 0,this.pendingHighlightResult=void 0,this.pendingStructuralRows=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)??mr}getExpandedHunksMap(){return this.expandedHunks}setExpandedHunksMap(e){this.expandedHunks=e}setLineAnnotations(e){this.additionAnnotations={},this.deletionAnnotations={};for(let t of e){let e=(()=>{switch(t.side){case`deletions`:return this.deletionAnnotations;case`additions`:return this.additionAnnotations}})(),n=e[t.lineNumber]??[];e[t.lineNumber]=n,n.push(t)}}updateRenderCache(e,t,n=!1){this.pendingStructuralRows=void 0;let{renderCache:r}=this;if(r==null)return!1;let{result:i,diff:a}=r;if(i==null)return!1;if(a.isPartial)throw Error(`Could not update render cache for partial diff`);let o=i.code.additionLines,s=this.pendingStructuralRows=n?new Map:void 0,c=[],l=new Map;for(let[t,n]of e){let e=o[t]?.properties??{},r=n.map(e=>e[2]).join(``),i=t<a.additionLines.length,u=i?a.additionLines[t]??``:``,d=ur(u);s==null&&i&&(a.additionLines[t]=Wn(u,r),d!==r&&(c.push(t),l.set(t,u)));let f={type:`element`,tagName:`div`,properties:{"data-line":e[`data-line`]??t+1,"data-line-index":e[`data-line-index`]??t,"data-line-type":e[`data-line-type`]??`context`},children:n.map(([e,t,n])=>e===0&&t===``?n===``?{type:`element`,tagName:`br`,properties:{},children:[]}:{type:`text`,value:n}:{type:`element`,tagName:`span`,properties:{"data-char":e,style:`color:${t};`},children:[{type:`text`,value:n}]})};s==null?o[t]=f:s.set(t,f)}let u=!1;if(c.length>0){if(this.editSessionActive){if(a.additionLines.length<=1&&a.additionLines.join(``)===``)this.applyRecomputePreservingSessionType(a,ts(a,this.options.parseDiffOptions)),u=!0;else if($o(a,a.additionLines))this.applyRecomputePreservingSessionType(a,es(a,a.additionLines,this.options.parseDiffOptions)),u=!0;else{let e=ys(a,c,this.options.parseDiffOptions,l);this.applyExpansionRemap(e),u=e!=null}}else Object.assign(a,as(a,c,this.options.parseDiffOptions))}return i.baseThemeType=t,r.isDirty=!0,u}applyExpansionRemap(e){e!=null&&(this.expandedHunks=Cs(this.expandedHunks,e))}applyDocumentChange(e){let{pendingStructuralRows:t,renderCache:n}=this;if(this.pendingStructuralRows=void 0,n==null)return;let{diff:r,result:i}=n;if(i==null)return;if(r.isPartial)throw Error(`Could not apply document change for partial diff`);let{additionLines:a}=r;if(r.additionLines=oc(e),i.code.additionLines=ic(a,r.additionLines,i.code.additionLines,e),r.additionLines.length<=1&&r.additionLines.join(``)===``?(this.applyRecomputePreservingSessionType(r,ts(r,this.options.parseDiffOptions)),i.code.additionLines[0]=ac(0,e.getLineText(0))):this.editSessionActive?this.applySessionDocumentChange(r):Object.assign(r,ns(r,this.options.parseDiffOptions)),t!=null)for(let[e,n]of t)e<i.code.additionLines.length&&(i.code.additionLines[e]=n);n.isDirty=!0}applySessionDocumentChange(e){let{parseDiffOptions:t}=this.options,n=e.additionLines;if($o(e,n)){this.applyRecomputePreservingSessionType(e,es(e,n,t));return}this.applyExpansionRemap(vs(e,t))}applyRecomputePreservingSessionType(e,t){let n=this.editSessionActive?e.type:void 0;Object.assign(e,t),n!=null&&(e.type=n),this.markEditSessionPass(e)}markEditSessionPass(e){this.editSessionActive&&(e.editSessionDirty=!0)}getUnifiedLineDecoration({lineType:e}){return{gutterLineType:e,contentProperties:{"data-line-type":e}}}getSplitLineDecoration({side:e,type:t}){let n=t===`change`?e===`deletions`?`change-deletion`:`change-addition`:t;return{gutterLineType:n,contentProperties:{"data-line-type":n}}}createAnnotationElement=e=>rr(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=qt,headerRenderMode:g=`default`,tokenizeMaxLineLength:_=1e3,tokenizeMaxLength:v=lt,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 it(sn(this.computedLangs,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}hydrate(e){if(e==null)return;this.diff=e;let{options:t}=this.getRenderOptions(e),n=cc(e,this.getTokenizeMaxLength()),r=this.workerManager?.getDiffResultCache(e);r!=null&&!_r(t,r.options)&&(r=void 0),this.renderCache??={diff:e,hydrated:!0,highlighted:!n&&!Gt(e),options:t,result:n?void 0:r?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!n&&this.workerManager.highlightDiffAST(this,this.diff):this.highlighter??(this.computedLangs=sc(e),this.initializeHighlighter())}getLocalHighlightTheme(){return this.workerManager?.getDiffRenderOptions().theme??this.options.theme??qt}getEffectiveCodeOptions(){let e=this.workerManager?.isWorkingPool()===!0?this.workerManager.getDiffRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:e?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0){let e=this.workerManager.getDiffRenderOptions();return this.editSessionActive&&e.useTokenTransformer!==!0?{...e,useTokenTransformer:!0}:e}let{theme:e,tokenizeMaxLineLength:t,lineDiffType:n,maxLineDiffLength:r}=this.getOptionsWithDefaults();return{theme:e,useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:t,lineDiffType:n,maxLineDiffLength:r}})();this.getOptionsWithDefaults();let{renderCache:n}=this;return n?.result==null||!en(e,n.diff)||!_r(t,n.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}getDiffForNextRender(e){let{options:t}=this.getRenderOptions(e);if(this.getReadyRenderResult(e,t)!=null||this.renderCache==null)return e;if(en(this.renderCache.diff,e))return this.renderCache.diff;let n=!(e.additionLines.length>0||e.deletionLines.length>0)||Gt(e)||cc(e,this.getTokenizeMaxLength());return this.canRenderDiff(e,t,n)?e:this.renderCache.diff}canRenderDiff(e,t,n){let{renderCache:r}=this;return r==null||en(r.diff,e)?!0:n?r.result==null&&r.hydrated!==!0||this.workerManager?.isWorkingPool()===!0||this.highlighter!=null&&Un(t.theme):r.result==null&&r.hydrated!==!0?!0:!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?!r.highlighted:this.highlighter!=null&&Un(t.theme)}renderDiff(e=this.diff,t=mn){if(this.diff=e,e==null){this.pendingHighlightResult=void 0;return}let{expandUnchanged:n,collapsedContextThreshold:r}=this.getOptionsWithDefaults(),{options:i,forceHighlight:a}=this.getRenderOptions(e),o=this.getReadyRenderResult(e,i);this.pendingHighlightResult=void 0,o!=null&&(this.renderCache={...o,diff:e,renderRange:void 0},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||Gt(e)||cc(e,this.getTokenizeMaxLength()),l=this.canRenderDiff(e,i,c),u=!en(e,this.renderCache.diff),d=!Qn(this.renderCache.renderRange,t);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0){let o=this.renderCache.result==null&&this.renderCache.highlighted&&!c&&!u&&rn(t);l&&!o&&(c||this.renderCache.result==null||!this.renderCache.highlighted&&(u||d))&&(this.renderCache.diff=e,this.renderCache.options=i,this.renderCache.highlighted=!1,(this.renderCache.result==null||u||d||a)&&(this.renderCache.result=this.workerManager.getPlainDiffAST(e,t.startingLine,t.totalLines,rn(t)||n?!0:this.expandedHunks,r)),this.renderCache.renderRange=t),!c&&s&&(!this.renderCache.highlighted||a)&&this.workerManager.highlightDiffAST(this,e)}else{this.computedLangs=sc(e),this.highlighter??=Ht();let t=this.highlighter!=null&&Un(i.theme),n=this.highlighter!=null&&er(this.computedLangs),r=!c&&n;if(l&&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.applyHighlightResult(e,t,n,!c)})}return this.renderCache.result==null?void 0:this.processDiffResult(this.renderCache.diff,t,this.renderCache.result)}async asyncRender(e,t=mn){this.diff=e;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 Bt({type:`diff`,diffIndicators:r,disableBackground:i,disableLineNumbers:a,overflow:o,split:e,totalLines:t,customProperties:n})}async asyncHighlight(e){let t=cc(e,this.getTokenizeMaxLength());this.computedLangs=t?[`text`]:sc(e);let n=this.highlighter!=null&&Un(this.getLocalHighlightTheme()),r=t||this.highlighter!=null&&er(this.computedLangs);return(this.highlighter==null||!n||!r)&&(this.highlighter=await this.initializeHighlighter()),this.renderDiffWithHighlighter(e,this.highlighter,t)}renderDiffWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e),{collapsedContextThreshold:i}=this.getOptionsWithDefaults(),a=Jt(e,t,r,{forcePlainText:n,expandedHunks:n?!0:void 0,collapsedContextThreshold:i});if(this.editSessionActive&&e.additionLines.length===1&&e.additionLines[0]===``&&a.code.additionLines[0]==null){let t;if(Xt({diff:e,diffStyle:`both`,expandedHunks:n?!0:void 0,collapsedContextThreshold:i,callback:({additionLine:e})=>{if(e?.lineIndex===0)return t=e,!0}}),t==null)throw Error(`DiffHunksRenderer: missing empty addition line`);a.code.additionLines[0]=ac(0,``,t.unifiedLineIndex,t.splitLineIndex)}return{result:a,options:r}}onHighlightSuccess(e,t,n,r=!0){this.editSessionActive||this.applyHighlightResult(e,t,n,r)}applyHighlightResult(e,t,n,r=!0){let{diff:i,renderCache:a}=this;i!=null&&a!=null&&en(i,e)&&_r(n,this.getRenderOptions(i).options)&&(a.result!=null&&a.highlighted&&_r(a.options,n)&&en(a.diff,i)||(this.pendingHighlightResult={diff:i,options:n,highlighted:r,result:t},this.onRenderUpdate?.()))}getMatchingWorkerResultCache(e,t){if(this.editSessionActive)return;let n=this.workerManager?.getDiffResultCache(e);if(n!=null&&_r(t,n.options))return n}getReadyRenderResult(e,t){let{pendingHighlightResult:n}=this;if(n!=null&&en(n.diff,e)&&_r(n.options,t))return n;let r=this.getMatchingWorkerResultCache(e,t);if(!(r==null||this.hasHighlightedRenderCache(e,t)))return{diff:e,highlighted:!0,...r}}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&en(e,n.diff)&&_r(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}processDiffResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let{diffStyle:a,disableFileHeader:o,expandUnchanged:s,expansionLineCount:c,collapsedContextThreshold:l,hunkSeparators:u}=this.getOptionsWithDefaults(),d=this.renderCache?.isDirty??!1,f=a===`unified`,p=lc(e,this.options.loadDiffFiles!=null),m=!e.isPartial||p,h=[],g=[],_=[],v=[],{additionLines:y,deletionLines:b}=n,x={rowCount:0,hunkSeparators:u,additionsContentAST:h,deletionsContentAST:g,unifiedContentAST:_,unifiedGutterAST:nn(),deletionsGutterAST:nn(),additionsGutterAST:nn(),expansionLineCount:c,hunkData:v,incrementRowCount(e=1){x.rowCount+=e},pushToGutter(e,t){switch(e){case`unified`:x.unifiedGutterAST.children.push(t);break;case`deletions`:x.deletionsGutterAST.children.push(t);break;case`additions`:x.additionsGutterAST.children.push(t)}}},S=ot({fileDiff:e,errorPrefix:`DiffHunksRenderer.processDiffResult`}),C={size:0,side:void 0,increment(){this.size+=1},flush(){if(a!==`unified`){if(this.size<=0||this.side==null){this.side=void 0,this.size=0;return}this.side===`additions`?(x.pushToGutter(`additions`,xt(void 0,`buffer`,this.size)),h?.push(Hs(this.size))):(x.pushToGutter(`deletions`,xt(void 0,`buffer`,this.size)),g?.push(Hs(this.size))),this.size=0,this.side=void 0}}},w=(e,t,n,r,i)=>{x.pushToGutter(e,Qt(t,n,r,i))};function T(e){C.flush(),a===`unified`?tc(`unified`,e,x):(tc(`deletions`,e,x),tc(`additions`,e,x))}this.pushFileLevelAnnotations(e,a,t,x),Xt({diff:e,diffStyle:a,startingLine:t.startingLine,totalLines:t.totalLines,expandedHunks:s?!0:this.expandedHunks,collapsedContextThreshold:l,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,additionLine:o,deletionLine:s,type:c})=>{let l=s==null?o.splitLineIndex:s.splitLineIndex,f=o==null?s.unifiedLineIndex:o.unifiedLineIndex;a===`split`&&c!==`change`&&C.flush(),r>0&&T({hunkIndex:t,collapsedLines:r,rangeSize:Math.max(n?.collapsedBefore??0,0),hunkSpecs:n?.hunkSpecs,isFirstHunk:t===0,isLastHunk:!1,isExpandable:m});let h=a===`unified`?f:l,g={type:c,hunkIndex:t,lineIndex:h,unifiedLineIndex:f,splitLineIndex:l,deletionLine:s,additionLine:o};if(a===`unified`){let n=this.getUnifiedInjectedRowsForLine?.(g);n?.before!=null&&Qs(n.before,x);let r=s==null?void 0:b[s.lineIndex],i=o==null?void 0:y[o.lineIndex];if(r==null&&i==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let a=c===`change`?o==null?`change-deletion`:`change-addition`:c,u=this.getUnifiedLineDecoration({type:c,lineType:a,additionLineIndex:o?.lineIndex,deletionLineIndex:s?.lineIndex});w(`unified`,u.gutterLineType,o==null?s.lineNumber:o.lineNumber,`${f},${l}`,u.gutterProperties),i==null?r!=null&&(r=nc(r,u.contentProperties,d&&s!=null?{"data-line":s.lineNumber,"data-line-index":`${f},${l}`}:void 0)):i=nc(i,u.contentProperties,d&&o!=null?{"data-line":o.lineNumber,"data-line-index":`${f},${l}`}:void 0),ec({diffStyle:`unified`,type:c,deletionLine:r,additionLine:i,unifiedSpan:this.getAnnotations(`unified`,s?.lineNumber,o?.lineNumber,t,h),createAnnotationElement:e=>this.createAnnotationElement(e),context:x}),n?.after!=null&&Qs(n.after,x)}else{let n=this.getSplitInjectedRowsForLine?.(g);n?.before!=null&&$s(n.before,x,C);let r=s==null?void 0:b[s.lineIndex],i=o==null?void 0:y[o.lineIndex],a=this.getSplitLineDecoration({side:`deletions`,type:c,lineIndex:s?.lineIndex}),u=this.getSplitLineDecoration({side:`additions`,type:c,lineIndex:o?.lineIndex});if(r==null&&i==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let f=(()=>{if(c===`change`){if(i==null)return`additions`;if(r==null)return`deletions`}})();f==null?c===`change`&&C.flush():(C.side!=null&&C.side!==f&&C.flush(),C.side=f,C.increment());let p=this.getAnnotations(`split`,s?.lineNumber,o?.lineNumber,t,h);if(p!=null&&C.size>0&&C.flush(),s!=null){let e=nc(r,a.contentProperties,d?{"data-line":s.lineNumber,"data-line-index":`${s.unifiedLineIndex},${l}`}:void 0);w(`deletions`,a.gutterLineType,s.lineNumber,`${s.unifiedLineIndex},${l}`,a.gutterProperties),e!=null&&(r=e)}if(o!=null){let e=nc(i,u.contentProperties,d?{"data-line":o.lineNumber,"data-line-index":`${o.unifiedLineIndex},${l}`}:void 0);w(`additions`,u.gutterLineType,o.lineNumber,`${o.unifiedLineIndex},${l}`,u.gutterProperties),e!=null&&(i=e)}ec({diffStyle:`split`,type:c,additionLine:i,deletionLine:r,...p,createAnnotationElement:e=>this.createAnnotationElement(e),context:x}),n?.after!=null&&$s(n.after,x,C)}let _=a===`split`&&n!=null&&l===n.splitLineStart+n.splitLineCount-1,v=t===e.hunks.length-1&&n!=null&&(a===`split`?l===n.splitLineStart+n.splitLineCount-1:f===n.unifiedLineStart+n.unifiedLineCount-1),E=_?n.noEOFCRDeletions:!1,D=_?n.noEOFCRAdditions:!1,O=(s?.noEOFCR??!1)||E,k=(o?.noEOFCR??!1)||D;if(k||O){if(a===`split`&&C.flush(),O){let e=c===`context`||c===`context-expanded`?c:`change-deletion`;a===`unified`?(x.unifiedContentAST.push(Us(e)),x.pushToGutter(`unified`,xt(e,`metadata`,1))):(x.deletionsContentAST.push(Us(e)),x.pushToGutter(`deletions`,xt(e,`metadata`,1)),k||(x.pushToGutter(`additions`,xt(void 0,`buffer`,1)),x.additionsContentAST.push(Hs(1))))}if(k){let e=c===`context`||c===`context-expanded`?c:`change-addition`;a===`unified`?(x.unifiedContentAST.push(Us(e)),x.pushToGutter(`unified`,xt(e,`metadata`,1))):(x.additionsContentAST.push(Us(e)),x.pushToGutter(`additions`,xt(e,`metadata`,1)),O||(x.pushToGutter(`deletions`,xt(void 0,`buffer`,1)),x.deletionsContentAST.push(Hs(1))))}x.incrementRowCount(1)}u!==`simple`&&u!==`metadata`&&(i>0||v&&p)&&T({hunkIndex:c===`context-expanded`?t:t+1,collapsedLines:v&&p?`unknown`:i,rangeSize:S,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:m}),x.incrementRowCount(1)}}),a===`split`&&C.flush();let E=Math.max(qs(e.hunks),e.additionLines.length??0,e.deletionLines.length??0),D=t.bufferBefore>0||t.bufferAfter>0,O=!f&&e.type!==`deleted`,k=!f&&e.type!==`new`,A=x.rowCount>0||D;h=O&&A?h:void 0,g=k&&A?g:void 0,_=f&&A?_:void 0;let j=this.createPreElement(g!=null&&h!=null,E);return{fileDiff:e,unifiedGutterAST:f&&A?x.unifiedGutterAST.children:void 0,unifiedContentAST:_,deletionsGutterAST:k&&A?x.deletionsGutterAST.children:void 0,deletionsContentAST:g,additionsGutterAST:O&&A?x.additionsGutterAST.children:void 0,additionsContentAST:h,hunkData:v,preNode:j,themeStyles:r,baseThemeType:i,headerElement:o?void 0:this.renderHeader(e),totalLines:E,rowCount:x.rowCount,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:``}}renderCodeAST(e,t){let n=e===`unified`?t.unifiedGutterAST:e===`deletions`?t.deletionsGutterAST:t.additionsGutterAST,r=e===`unified`?t.unifiedContentAST:e===`deletions`?t.deletionsContentAST:t.additionsContentAST;if(n==null||r==null)return;let i=nn(n);return i.properties.style=`grid-row: span ${t.rowCount}`,[i,Cn(r,t.rowCount)]}renderFullAST(e,t=[]){let n=this.getOptionsWithDefaults().hunkSeparators===`line-info`,r=this.renderCodeAST(`unified`,e);if(r!=null)return t.push(yt({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(yt({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(yt({tagName:`code`,children:a,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-additions":``}})),{...e.preNode,children:t}}renderFullHTML(e,t=[]){return Zn(this.renderFullAST(e,t))}renderPartialHTML(e,t){return Zn(t==null?e:yt({tagName:`code`,children:e,properties:{"data-code":``,"data-container-size":this.getOptionsWithDefaults().hunkSeparators===`line-info`?``:void 0,[`data-${t}`]:``}}))}pushFileLevelAnnotations(e,t,n,r){if(!bn(n))return;let i=e.type===`new`?[]:this.getAnnotationNames(Rn(this.deletionAnnotations)),a=e.type===`deleted`?[]:this.getAnnotationNames(Rn(this.additionAnnotations));if(i.length===0&&a.length===0)return;let{createAnnotationElement:o}=this;if(t===`unified`){ec({diffStyle:t,type:`context`,unifiedSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:i.concat(a)},createAnnotationElement:o,context:r});return}ec({diffStyle:t,type:`context`,deletionSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:i},additionSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:a},createAnnotationElement:o,context:r})}getAnnotations(e,t,n,r,i){let a={type:`annotation`,hunkIndex:r,lineIndex:i,annotations:[]};if(t!=null)for(let e of this.deletionAnnotations[t]??[])a.annotations.push(this.annotationSlotName(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(this.annotationSlotName(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}}getAnnotationNames(e){return e?.map(e=>this.annotationSlotName(e))??[]}renderHeader(e){let{headerRenderMode:t,stickyHeader:n}=this.getOptionsWithDefaults();return nt({fileOrDiff:e,mode:t,stickyHeader:n})}},Xs=new Intl.PluralRules(`en-US`);function Zs(e){return`${e} unmodified line${Xs.select(e)===`one`?``:`s`}`}function Qs(e,t){for(let n of e)t.unifiedContentAST.push(n.content),t.pushToGutter(`unified`,n.gutter),t.incrementRowCount(1)}function $s(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 ec({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`,xt(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`,xt(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`,xt(e,`annotation`,1)),l=!0}}l&&c.incrementRowCount(1)}function tc(e,{hunkIndex:t,collapsedLines:n,rangeSize:r,hunkSpecs:i,isFirstHunk:a,isLastHunk:o,isExpandable:s},c){if(typeof n==`number`&&n<=0)return;let l=e===`unified`?c.unifiedContentAST:e===`deletions`?c.deletionsContentAST:c.additionsContentAST;if(c.hunkSeparators===`metadata`){i!=null&&(c.pushToGutter(e,Gs({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),l.push(Gs({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1));return}if(c.hunkSeparators===`simple`){t>0&&(c.pushToGutter(e,Gs({type:`simple`,isFirstHunk:a,isLastHunk:!1})),l.push(Gs({type:`simple`,isFirstHunk:a,isLastHunk:!1})),e!==`additions`&&c.incrementRowCount(1));return}let u=Ks(e,t),d=r>c.expansionLineCount,f=s?t:void 0,p=typeof n==`number`?Zs(n):`More unchanged context may be available`;c.pushToGutter(e,Gs({type:c.hunkSeparators,content:p,expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),l.push(Gs({type:c.hunkSeparators,content:p,expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1),c.hunkData.push({slotName:u,hunkIndex:t,lines:typeof n==`number`?n:0,lineCountKnown:typeof n==`number`,type:e,expandable:s?{up:!a,down:!o,chunked:d}:void 0})}function nc(e,t,n){return e==null||e.type!==`element`||t==null&&n==null?e:{...e,properties:{...e.properties,...t,...n}}}function rc(e){return e.length>0&&e[e.length-1]===``?e.length-1:e.length}function ic(e,t,n,r){let i=rc(e),a=rc(t),o=Math.min(i,a),s=0;for(;s<o&&e[s]===t[s];)s++;let c=0;for(;c<o-s&&e[i-1-c]===t[a-1-c];)c++;let l=Array(t.length);for(let e=0;e<s;e++)l[e]=n[e];for(let e=0;e<c;e++)l[a-1-e]=n[i-1-e];i<e.length&&a<t.length&&(l[t.length-1]=n[e.length-1]);for(let e=s;e<t.length;e++)l[e]??=ac(e,r.getLineText(e));return l}function ac(e,t,n=e,r=e){return{type:`element`,tagName:`div`,properties:{"data-line":e+1,"data-line-index":`${n},${r}`,"data-line-type":`context`},children:[{type:`element`,tagName:`span`,properties:{"data-char":0},children:[{type:`text`,value:t}]}]}}function oc(e){let t=[];for(let n=0;n<e.lineCount;n++)t.push(e.getLineText(n,!0));return t}function sc(e){if(e.lang!=null)return[e.lang];let t=an(e.prevName??e.name),n=an(e.name);return t===n?[n]:[t,n]}function cc(e,t){return Math.max(e.additionLines.length,e.deletionLines.length)>t}function lc(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function uc(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function dc(e,t){return e.slotName===t.slotName&&e.hunkIndex===t.hunkIndex&&e.lines===t.lines&&e.lineCountKnown===t.lineCountKnown&&e.type===t.type&&e.expandable?.chunked===t.expandable?.chunked&&e.expandable?.up===t.expandable?.up&&e.expandable?.down===t.expandable?.down}function fc(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:ht(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,diffStyle:e?.diffStyle,diffIndicators:e?.diffIndicators,disableBackground:e?.disableBackground,hunkSeparators:typeof e?.hunkSeparators==`function`?`custom`:e?.hunkSeparators,expandUnchanged:e?.expandUnchanged,loadDiffFiles:e?.loadDiffFiles,collapsedContextThreshold:e?.collapsedContextThreshold,lineDiffType:e?.lineDiffType,maxLineDiffLength:e?.maxLineDiffLength,expansionLineCount:e?.expansionLineCount,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}function pc(e){return e.isPartial&&(e.type===`change`||e.type===`rename-changed`||e.type===`rename-pure`)}function mc(e){let t={...e};return delete t.cacheKey,t}function hc(e,t){if(e.isPartial||t.isPartial)throw Error(`FileDiff.shouldResetEditorForExternalDiff: diffs must be fully hydrated`);let n=e.lang??an(e.name),r=t.lang??an(t.name),i=e.type!==`new`,a=t.type!==`new`;return e.name!==t.name||n!==r||i!==a||e.deletionLines.length!==t.deletionLines.length||e.deletionLines.some((e,n)=>e!==t.deletionLines[n])}function gc(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function _c(e,t){let{oldFile:n}=e;return n==null?t.type===`new`:t.type!==`new`&&n.name===(t.prevName??t.name)&&gc(n.lines,t.deletionLines)}var vc=-1,yc=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file-diff:${++vc}`;type=`file-diff`;fileContainer;spriteSVG;pre;codeUnified;codeDeletions;codeAdditions;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;headerElement;headerPrefix;headerFilenameSuffix;headerMetadata;headerCustom;separatorCache=new Map;errorWrapper;placeHolder;hunksRenderer;resizeManager;scrollSyncManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;deletionFile;additionFile;fileDiff;editSession;renderedDiff;renderRange;pendingFiles;appliedPreAttributes;headerCache={lastRenderedHTML:void 0,html:void 0,fileDiff:void 0};lastRowCount;mounted=!1;enabled=!0;editor;refreshViewTimeout;lineStateRefreshPending=!1;deferredSelectedLines;deferredEditorActiveLine;constructor(e={theme:qt},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new An,this.scrollSyncManager=new Yo,this.interactionManager=new fn(`diff`,Kn(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()};getTheme(){return this.workerManager?.getDiffRenderOptions().theme??this.options.theme??qt}getHunksRendererOptions(e){return fc(e)}createHunksRenderer(e){return new Ys(this.getHunksRendererOptions(e),this.getAnnotationSlotName,this.handleHighlightRender,this.workerManager)}getLineIndex=(e,t=`additions`)=>this.getLineIndexForDiff(this.getDiffForLineIndex(),e,t);getDiffForLineIndex(){return this.getRenderedDiff()}getLineIndexForDiff(e,t,n){if(e==null)return;let r=e.hunks.at(-1),i,a;hunkIterator:for(let o of e.hunks){let e=n===`deletions`?o.deletionStart:o.additionStart,s=n===`deletions`?o.deletionCount:o.additionCount,c=ir(e,s)+1,l=o.splitLineStart,u=o.unifiedLineStart;if(t<c){let e=c-t;i=Math.max(u-e,0),a=Math.max(l-e,0);break hunkIterator}if(t>=c+s){if(o===r){let e=t-(c+s);i=u+o.unifiedLineCount+e,a=l+o.splitLineCount+e;break hunkIterator}continue}for(let e of o.hunkContent)if(e.type===`context`){if(t<c+e.lines){let e=t-c;a=l+e,i=u+e;break hunkIterator}c+=e.lines,l+=e.lines,u+=e.lines}else{let r=n===`deletions`?e.deletions:e.additions;if(t<c+r){let r=t-c;i=u+(n===`additions`?e.deletions:0)+r,a=l+r;break hunkIterator}c+=r,l+=Math.max(e.deletions,e.additions),u+=e.deletions+e.additions}break hunkIterator}if(i!=null&&a!=null)return[i,a]}setOptions(e){e!=null&&(this.options=e,this.clearReusableHeader(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(Kn(this.options,typeof this.options.hunkSeparators==`function`||(this.options.hunkSeparators??`line-info`)===`line-info`||this.options.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0,this.getLineIndex))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??`system`)!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme==`string`||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType!==t&&(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!cn(this.appliedThemeCSS.theme,this.getTheme())}getHoveredLine=()=>this.interactionManager.getHoveredLine();getAnnotationSlotName=e=>Ot(this.editSession?.annotations,e,yn);getLatestAnnotations(){return this.editSession?.annotations?.current??this.lineAnnotations}isNewAnnotations(e){let t=this.editSession?.annotations;return e===this.lineAnnotations?!1:t==null||e!==t.provided&&e!==t.current}setLineAnnotations(e){let t=this.editSession?.annotations;if(t==null){this.lineAnnotations=e;return}this.isNewAnnotations(e)&&(this.lineAnnotations=e,Ut(t,e,yn))}syncEditSessionAnnotationsFromEditor(e){let t=this.editSession?.annotations;return t==null||e===t.current?!1:(t.current=e,this.hunksRenderer.setLineAnnotations(e),this.renderAnnotations(),!0)}canPartiallyRender(e,t,n){return!(e||t||n||typeof this.options.hunkSeparators==`function`)}setSelectedLines(e,t){this.lineStateRefreshPending?this.deferredSelectedLines=[e,t]:this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.lineStateRefreshPending?this.deferredEditorActiveLine=[e,t]:this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??`additions`})}flushDeferredLineState(){let{deferredEditorActiveLine:e,deferredSelectedLines:t}=this;this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,e!=null&&this.setEditorActiveLine(...e),t!=null&&this.interactionManager.setSelection(...t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{diffStyle:e=`split`,overflow:t=`scroll`}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:t===`wrap`,columnVariables:this.shouldApplyColumnVariables(t)?`apply`:`measure`}),t===`scroll`&&e===`split`?this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp(),this.managersDirty=!1}shouldApplyColumnVariables(e){return typeof this.options.hunkSeparators==`function`||e===`scroll`&&(this.getLatestAnnotations().length>0||this.pre?.hasAttribute(`data-has-merge-conflict`)===!0)}getCodeScrollLeft(){return Math.max(this.codeUnified?.scrollLeft??0,this.codeDeletions?.scrollLeft??0,this.codeAdditions?.scrollLeft??0)}setCodeScrollLeft(e){this.codeUnified!=null&&(this.codeUnified.scrollLeft=e),this.codeAdditions!=null&&(this.codeAdditions.scrollLeft=e),this.codeDeletions!=null&&(this.codeDeletions.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.hunksRenderer.getEffectiveCodeOptions()}}cleanUp(e=!1){let{editor:t}=this;kn(this.handleEditSessionRender),this.emitPostRender(!0),t?.cleanUp(e?`recycle`:`discard`),e||(this.editor=void 0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,e||(this.pendingFiles=void 0),this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,this.headerCache.lastRenderedHTML=void 0,e||this.clearReusableHeader(),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,e?this.hunksRenderer.recycle():(this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.editSession=void 0,this.renderedDiff=void 0,this.deletionFile=void 0,this.additionFile=void 0),this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate({fileContainer:e,prerenderedHTML:t,preventEmit:n=!1,lineAnnotations:r,fileDiff:i,...a}){if(!this.enabled)throw Error(`FileDiff.hydrate: attempting to call hydrate after cleaned up`);if(this.fileContainer!=null)throw Error(`FileDiff.hydrate: hydrate can only be called before the instance has rendered or hydrated`);let o=Fo(a,`FileDiff.hydrate`),s=o?.oldFile,c=o?.newFile;this.hydrateElements(e,t);let l=this.editor!=null;l||wc(this.pre,Sc({fileDiff:i,oldFile:s,newFile:c}),this.options.collapsed)||Tc(this.headerElement,Cc({fileDiff:i,oldFile:s,newFile:c}),this.options.disableFileHeader)?this.render({...a,fileContainer:e,lineAnnotations:r,fileDiff:i,forceRender:l||a.forceRender,preventEmit:!0}):this.hydrationSetup({fileDiff:i,lineAnnotations:r,...o}),n||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),Pn(e,t);for(let t of e.shadowRoot?.children??[]){if(t instanceof SVGElement){this.spriteSVG=t;continue}if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t;for(let e of t.children)e instanceof HTMLElement&&e.tagName.toLowerCase()===`code`&&(`deletions`in e.dataset&&(this.codeDeletions=e),`additions`in e.dataset&&(this.codeAdditions=e),`unified`in e.dataset&&(this.codeUnified=e));continue}if(`diffsHeader`in t.dataset){this.headerElement=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)){this.themeCSSStyle=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)){this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent;continue}}}this.pre!=null&&(this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute(`data-dehydrated`)),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({fileDiff:e,oldFile:t,newFile:n,lineAnnotations:r}){this.lineAnnotations=r??this.lineAnnotations,this.additionFile=n,this.deletionFile=t,this.fileDiff=e??(t!==void 0&&n!==void 0?qo(t,n,this.options.parseDiffOptions):void 0),this.pre!=null&&(this.syncInteractionOptions(),this.hunksRenderer.hydrate(this.fileDiff),this.renderedDiff=this.fileDiff,this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||this.render({forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.hunksRenderer.clearRenderCache(),this.rerender()}handleExpandHunk=(e,t,n)=>{this.expandHunk(e,t,n)};expandHunk=(e,t,n)=>{this.hunksRenderer.expandHunk(e,t,n),this.loadFilesIfNecessary(),this.rerender()};loadFilesIfNecessary(){let{fileDiff:e,options:{loadDiffFiles:t}}=this;if(e==null||t==null||!pc(e)||this.pendingFiles?.fileDiff===e)return;let n=this.loadFilesForDiff(e,t),r=this.pendingFiles={fileDiff:e,promise:n};r.promise=n.finally(()=>{this.pendingFiles===r&&(this.pendingFiles=void 0)})}async loadFilesForDiff(e,t){try{let n=await t(e);if(!this.enabled||this.fileDiff!==e)return;await this.handleFilesLoaded(e,n)}catch(e){if(this.options.disableErrorHandling===!0)throw e;console.error(e)}}async handleFilesLoaded(e,t){if(this.fileDiff===e&&e.isPartial){if(Lo(`merge`,e,t),this.setHydratedState(t),this.startHydratedEditSession(e)){this.rerender();return}await jo(()=>this.primeHighlightCache(e)),this.enabled&&this.fileDiff===e&&this.rerender()}}startHydratedEditSession(e){if(e.isPartial)throw Error(`FileDiff.startHydratedEditSession: diffs cannot be partial for editing`);if(this.fileDiff!==e)return!1;let{editor:t}=this;return this.editSession?.outgoingDiff==null?t==null||this.editSession!=null?!1:(this.installEditSession(e,t.__getDocumentContents(bc(e)),t.__getDocumentSessionState()),!0):(this.installEditSession(e),!0)}updateExternalDiff(e,t){if(en(this.fileDiff,e))return!1;let n=this.editSession?.outgoingDiff??this.editSession?.diff;return this.fileDiff=e,n==null?this.editor!=null&&(e.isPartial?this.loadFilesIfNecessary():this.installEditSession(e,this.editor.__getDocumentContents(bc(e)),this.editor.__getDocumentSessionState())):(e.isPartial?this.loadFilesIfNecessary():this.installEditSession(e),this.editSession!=null&&(this.editSession.outgoingDiff=n)),this.editSession?.annotations!=null&&t!=null&&(this.lineAnnotations=t,this.editSession.annotations=St(t,yn,this.editSession.annotations)),!0}installEditSession(e,t,n){let r=e.additionLines.join(``),i=t==null?void 0:Io(t.contents),a=n!=null&&_c(n,e);if(n!=null&&!a)throw Error(`FileDiff: retained session cannot resume against a different old file`);if(t!=null&&t.contents!==r&&!a)throw Error(`FileDiff: retained edits are missing their diff session state`);let o=t==null||t.name===e.name&&t.lang===e.lang&&t.contents===r,s=mc(e);t!=null&&i!=null&&!o&&(s.name=t.name,s.lang=t.lang),a&&n!=null&&i!=null&&(s.additionLines=i,s.type=n.type,s.hunks=n.hunks,s.editSessionDirty=!0,ms(s)),this.editSession={diff:s,annotations:this.editSession?.annotations??St(this.lineAnnotations,yn),outgoingDiff:this.editSession?.outgoingDiff},this.hunksRenderer.beginEditSession(s,o&&!a?e:void 0)}setHydratedState(e){this.deletionFile=e.oldFile,this.additionFile=e.newFile,this.workerManager?.cleanUpTasks(this.hunksRenderer),this.hunksRenderer.clearRenderCache()}render({fileDiff:e,deferManagers:t=!1,forceRender:n=!1,preventEmit:r=!1,lineAnnotations:i,fileContainer:a,containerWrapper:o,renderRange:s,...c}){if(!this.enabled)throw Error(`FileDiff.render: attempting to call render after cleaned up`);let l=Fo(c,`FileDiff.render`),u=l?.oldFile,d=l?.newFile;this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:f=!1,themeType:p=`system`,expandUnchanged:m=!1}=this.options,h=f?void 0:s,g=this.hasThemeChanged(),_=l!=null,v=_&&(!xc(u,this.deletionFile)||!xc(d,this.additionFile)),y=e!=null&&!en(e,this.fileDiff),b=i!=null&&(i.length>0||this.getLatestAnnotations().length>0)&&this.isNewAnnotations(i);if(!f&&Qn(h,this.renderRange)&&!n&&!b&&!g&&(e!=null&&!y||e==null&&!v)){let e=this.applyCachedThemeState(p);return e&&this.finalizeRender(),e}let x;e==null&&_&&(v||this.fileDiff==null)&&(x=qo(l.oldFile,l.newFile,this.options.parseDiffOptions));let{renderRange:S}=this;this.renderRange=h,_?(this.deletionFile=u,this.additionFile=d):e!=null&&(this.deletionFile=void 0,this.additionFile=void 0),e!=null&&y?this.updateExternalDiff(e,i):x!=null&&(y=!0,this.updateExternalDiff(x,i)),y&&this.clearReusableHeader(),i!=null&&this.setLineAnnotations(i);let C=this.getLatestDiff();if(C==null)return!1;C.editSessionDirty===!0&&this.shouldSelfHealEditSession()&&(Es(C,this.options.parseDiffOptions),this.hunksRenderer.refreshHighlightedResult()),m&&this.loadFilesIfNecessary(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.hunksRenderer.setLineAnnotations(this.getLatestAnnotations());let{disableErrorHandling:w=!1,disableFileHeader:T=!1}=this.options;if(T&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.headerCache.lastRenderedHTML=void 0),this.clearHeaderSlots()),a=this.getOrCreateFileContainer(a,o),this.applyCachedThemeState(p),f){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let e=this.hunksRenderer.renderDiff(C,pt);e!=null&&this.applyThemeState(a,e.themeStyles,p,e.baseThemeType),e?.headerElement!=null&&this.applyHeaderToDOM(e.headerElement,a,e.fileDiff),this.renderSeparators([]),this.renderedDiff=e?.fileDiff??C,this.injectUnsafeCSS()}catch(e){if(w)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return this.finalizeRender(),r||this.emitPostRender(),!0}try{let e=this.getOrCreatePreNode(a);if(!(this.canPartiallyRender(n,b,v||y||g||!en(this.renderedDiff,C))&&this.applyPartialRender({fileDiff:C,previousRenderRange:S,renderRange:h}))){let t=this.hunksRenderer.renderDiff(C,h);if(t==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.isWorkingPool()&&this.workerManager.initialize().catch(()=>{}).then(()=>this.rerender()),!1;this.applyThemeState(a,t.themeStyles,p,t.baseThemeType),t.headerElement!=null&&this.applyHeaderToDOM(t.headerElement,a,t.fileDiff),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.renderedDiff=t.fileDiff}this.applyBuffers(e,h),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,t||this.flushManagers(),this.finalizeRender(),this.editor!=null&&this.syncRenderViewToEditor()}catch(e){if(w)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return r||this.emitPostRender(),!0}finalizeRender(){}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)}getLatestDiff(e=this.fileDiff){return this.editSession?.diff??e}getRenderedDiff(){return this.renderedDiff}syncRenderViewToEditor(){let{editor:e,fileContainer:t}=this,n=this.getLatestAnnotations(),r=this.computeEditorRenderRange(this.renderRange),i=this.getLatestDiff();if(e==null||t==null||i==null||i.isPartial)return;let a=a=>{if(!this.enabled||this.editor!==e||this.fileContainer!==t||this.getLatestDiff()!==i)return;let o=this.editSession?.outgoingDiff,s=this.fileDiff,c=o!=null&&s!=null&&o!==i,l=c?hc(o,s):!1;e.__syncRenderView({highlighter:a,fileContainer:t,fileDiff:i,lineAnnotations:n,renderRange:r,externalDocument:c,resetHistory:l})},o=this.getTheme(),s=i.lang??an(i.name),c=Ht({theme:o,lang:s});c==null?it({themes:Gn(o),langs:[`text`,s],preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter}).then(a):a(c)}computeEditorRenderRange(e){let t=this.getLatestDiff();if(e==null||t==null||rn(e))return e;let{diffStyle:n=`split`,expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a,o;return Xt({diff:t,diffStyle:n,startingLine:e.startingLine,totalLines:e.totalLines,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({additionLine:e})=>{e!=null&&(a??=e.lineNumber,o=e.lineNumber)}}),a==null||o==null?{...e,startingLine:0,totalLines:0}:{...e,startingLine:a-1,totalLines:o-a+1}}__acknowledgeDocumentUpdate(){this.editSession!=null&&(this.editSession.outgoingDiff=void 0)}__acceptEditorChange(e){let{lineAnnotations:t}=e;t!=null&&this.syncEditSessionAnnotationsFromEditor(t)}emitEditChange(e){let{onEditChange:t}=this.options;t?.(e)}__captureDocumentSessionState(e=!0){let{fileDiff:t,editSession:{diff:n,outgoingDiff:r}={}}=this;if(r!=null&&t!=null){if(!t.isPartial&&hc(r,t))return;n=r}if(!(n==null||n.isPartial))return{diffSession:{oldFile:n.type===`new`?null:{name:n.prevName??n.name,lines:e?[...n.deletionLines]:n.deletionLines},type:n.type,hunks:e?ga(n.hunks):n.hunks},hasChanges:n.editSessionDirty===!0}}__attachEditor(e){if(this.type!==`file-diff`)throw Error(`FileDiff.__attachEditor: cannot attach an editor to a "${this.type}" diff`);if(this.editor!=null)throw Error(`FileDiff.__attachEditor: an editor is already attached`);let t=()=>{this.editor=void 0,this.finishEditSession()};try{return this.resumeEditorRendering(e),t}catch(e){throw t(),e}}__resumeEditor(e){if(this.editor!==e)throw Error(`FileDiff.__resumeEditor: editor association changed`);this.resumeEditorRendering(e)}resumeEditorRendering(e){let{fileDiff:t}=this,n=this.editSession?.outgoingDiff;n!=null&&t!=null&&!t.isPartial&&this.editSession?.diff===n&&this.installEditSession(t);let r=this.editSession==null&&t!=null&&!t.isPartial?t:void 0;r==null?this.editSession!=null&&this.hunksRenderer.beginEditSession(this.editSession.diff):this.installEditSession(r,e.__getDocumentContents(bc(r)),e.__getDocumentSessionState()),this.editor=e,this.fileDiff?.isPartial===!0&&this.loadFilesIfNecessary();let i=this.editSession?.diff;this.hunksRenderer.editorRenderReady()?(i!=null&&this.hunksRenderer.diffCache===i&&(this.renderedDiff=i),this.syncRenderViewToEditor()):this.rerender()}finishEditSession(){this.hunksRenderer.endEditSession(),this.finalizeEditSessionHunks()}__completeEditSession(e,t){this.settleEditSession(t===`install`,e)}settleEditSession(e,t){let{editSession:n,fileDiff:r,lineAnnotations:i}=this;if(n==null||r==null)return;let{diff:a,annotations:o}=n;if(this.editor!=null)throw Error(`FileDiff.__completeEditSession: detach the editor before completing the session`);this.hunksRenderer.endEditSession(),this.finalizeEditSessionHunks();let s=o?.current,c,l=null,u=null,d=!1,f;if(t==null)throw Error(`FileDiff.__completeEditSession: editor is required for completion`);let p=_a(a),m={name:p.name,contents:p.additionLines.join(``)};p.lang!=null&&(m.lang=p.lang);let h={fileDiff:p,editor:t,originalFileDiff:r,oldFile:p.type===`new`?null:{name:p.prevName??p.name,contents:p.deletionLines.join(``)},newFile:m,lineAnnotations:s,originalLineAnnotations:i};Object.freeze(h);try{if(t.__emitEditComplete(h),this.options.onEditComplete?.(h)===`accept`){if(p.cacheKey!=null&&p.cacheKey===r.cacheKey)throw Error(`FileDiff.__completeEditSession: an accepted diff must not reuse the replaced diff cacheKey`);c=p,l=h.oldFile,u=h.newFile}}catch(e){d=!0,f=e}if(e&&c!=null&&(this.fileDiff=c,this.additionFile!=null&&(this.deletionFile=l,this.additionFile=u),s!=null&&(this.lineAnnotations=s)),this.editSession=void 0,e&&this.fileContainer!=null&&this.rerender(),d)throw f}finalizeEditSessionHunks(){let e=this.getLatestDiff();if(e==null||e.editSessionDirty!==!0)return!1;let{collapsedContextThreshold:t=1}=this.options,n=ws(e,this.hunksRenderer.getExpandedHunksMap(),t);return Es(e,this.options.parseDiffOptions),this.hunksRenderer.setExpandedHunksMap(Ts(e,n)),this.hunksRenderer.refreshHighlightedResult(),this.escalateEditSessionRender(),!0}applyDocumentChange(e,t){let n=this.editSession?.diff;if(n==null)throw Error(`FileDiff.applyDocumentChange: requires an active edit session`);this.detachAdditionLines(),this.hunksRenderer.beginEditSession(n),this.hunksRenderer.applyDocumentChange(e),t!=null&&this.syncEditSessionAnnotationsFromEditor(t),this.rerender(),this.interactionManager.setSelectionDirty()}updateRenderCache(e,t,n={}){let r=this.editSession?.diff;if(r==null)throw Error(`FileDiff.updateRenderCache: requires an active edit session`);this.detachAdditionLines(),this.hunksRenderer.beginEditSession(r);let{shouldRefreshDiffsView:i,lineCountChangeInFlight:a}=n;if(this.hunksRenderer.updateRenderCache(e,t,a)){this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!0,this.escalateEditSessionRender();return}i===!0&&(this.refreshViewTimeout!=null&&clearTimeout(this.refreshViewTimeout),this.lineStateRefreshPending=!0,this.refreshViewTimeout=setTimeout(()=>{this.refreshViewTimeout=void 0,this.options.diffStyle===`split`?this.refreshSplitDiffView():this.refreshUnifiedDiffView(),this.flushDeferredLineState()},150))}detachAdditionLines(){let e=this.editSession?.diff,{fileDiff:t}=this;e!=null&&(e.additionLines===t?.additionLines||e.additionLines===e.deletionLines)&&(e.additionLines=[...e.additionLines])}isLineRenderable(e){let t=this.getRenderedDiff();if(t==null)return!0;let{expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options;return zt({fileDiff:t,lineNumber:e,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r})}getNearestRenderableLine(e,t){let n=this.getRenderedDiff();if(n==null)return e;let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options;return Fn({fileDiff:n,lineNumber:e,direction:t,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i})}revealLine(e){let t=this.getRenderedDiff(),{expandUnchanged:n=!1,collapsedContextThreshold:r=1,expansionLineCount:i=100}=this.options;if(t==null||t.isPartial||n)return!1;let a=this.hunksRenderer.getExpandedHunksMap();for(let[n,o]of t.hunks.entries()){let[s,c]=ft(o);if(e<s){let c=mt({isPartial:t.isPartial,rangeSize:o.collapsedBefore,expandedHunks:a,hunkIndex:n,collapsedContextThreshold:r}),l=s-c.rangeSize;if(c.renderAll||e<l+c.fromStart||e>=s-c.fromEnd)return!1;let u=e-(l+c.fromStart)+1,d=s-c.fromEnd-e;return u<=d?this.expandHunk(n,`up`,u+i):this.expandHunk(n,`down`,d+i),!0}if(e<c)return!1}let o=Nn({fileDiff:t,hunkIndex:t.hunks.length-1,expandedHunks:a,collapsedContextThreshold:r,errorPrefix:`FileDiff.revealLine`});if(o==null||o.renderAll)return!1;let s=t.hunks[t.hunks.length-1],[,c]=ft(s);return e<c+o.fromStart||e>=c+o.rangeSize?!1:(this.expandHunk(t.hunks.length,`up`,e-(c+o.fromStart)+1+i),!0)}shouldSelfHealEditSession(){return this.editor==null}escalateEditSessionRender(){Dn(this.handleEditSessionRender)}handleEditSessionRender=()=>{this.rerender(),this.flushDeferredLineState()};removeRenderedCode(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:`open`});this.placeHolder=document.createElement(`div`),this.placeHolder.dataset.placeholder=``,e.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty(`height`,`${e}px`),!0}async primeHighlightCache(e=this.fileDiff){let{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||Gt(e))return;let n=this.options.tokenizeMaxLength??1e5;Math.max(e.additionLines.length,e.deletionLines.length)>n||await t.primeDiffHighlightCache(e).catch(e=>{console.error(e)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.headerCache.lastRenderedHTML=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||!dc(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,n=this.getLatestAnnotations();if(t!=null&&n.length>0)for(let[r,i]of n.entries()){let n=this.getAnnotationSlotName(i),a=`${r}-${n}`,o=this.annotationCache.get(a);if(o==null||!uc(i,o.annotation)){o?.element.remove();let e=t(i);if(e==null)continue;o={element:Yn(n),annotation:i},o.element.appendChild(e),this.fileContainer.appendChild(o.element),this.annotationCache.set(a,o)}e.delete(a)}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=Et();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}getOrCreateFileContainer(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return n!=null&&i&&this.editor?.__captureFocusForDOMReplacement(),i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.headerCache.lastRenderedHTML=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:wn(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):wn(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=on;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});return this.pre==null?(this.pre=document.createElement(`pre`),this.appliedPreAttributes=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(this.editor?.__captureFocusForDOMReplacement(),t.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(e){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(let t of Array.from(e.children))t instanceof HTMLElement&&(t.hasAttribute(`data-unified`)?this.codeUnified=t:t.hasAttribute(`data-deletions`)?this.codeDeletions=t:t.hasAttribute(`data-additions`)&&(this.codeAdditions=t))}applyHeaderToDOM(e,t,n){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let{headerCache:{fileDiff:r,html:i,lastRenderedHTML:a}}=this,o=(n!==this.editSession?.diff&&en(r,n)?i:void 0)??Zn(e);if(this.headerCache.html=o,this.headerCache.fileDiff=n,o!==a){let e=document.createElement(`div`);e.innerHTML=o;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.headerCache.lastRenderedHTML=o}if(this.isContainerManaged)return;let{renderCustomHeader:s,renderHeaderPrefix:c,renderHeaderFilenameSuffix:l,renderHeaderMetadata:u}=this.options;if(s!=null){let e=s(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,En,e),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0;return}let d=c?.(n)??void 0,f=l?.(n)??void 0,p=u?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,jt,d),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,at,f),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,Mn,p),this.headerCustom?.remove(),this.headerCustom=void 0}clearReusableHeader(){this.headerCache.html=void 0,this.headerCache.fileDiff=void 0}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}injectUnsafeCSS(){let{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===``){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}(this.unsafeCSSStyle?.parentNode!==t||this.appliedUnsafeCSS!==e)&&(this.unsafeCSSStyle??=vt(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=Zt(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.getTheme(),s=typeof o==`string`?o:{...o},c=tn(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=At({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:bt(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=$t(this.themeCSSStyle.textContent??``,tn(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&jn()}applyHunksToDOM(e,t){this.shouldGuardRebuildScroll()?Nt(e,()=>this.replaceCodeColumns(e,t)):this.replaceCodeColumns(e,t)}applyCodeColumnsInPlace(e,t,n){let r=this.getColumnPair(e);if(r==null)return!1;let i=Ec(t[0]),a=Ec(t[1]);return i==null||a==null?!1:(r.gutter.innerHTML=Zn(i),r.content.innerHTML=Zn(a),n!==this.lastRowCount&&(r.gutter.style.setProperty(`grid-row`,`span ${n}`),r.content.style.setProperty(`grid-row`,`span ${n}`)),!0)}replaceCodeColumns(e,t){let{overflow:n=`scroll`}=this.options,r=(this.options.hunkSeparators??`line-info`)===`line-info`,i=n===`wrap`?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let a=!1,o=[],s=this.hunksRenderer.renderCodeAST(`unified`,t),c=this.hunksRenderer.renderCodeAST(`deletions`,t),l=this.hunksRenderer.renderCodeAST(`additions`,t);this.editor?.__captureFocusForDOMReplacement(),s==null?c!=null||l!=null?(c==null?(this.codeDeletions?.remove(),this.codeDeletions=void 0):(a=this.codeDeletions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=Lt({code:this.codeDeletions,columnType:`deletions`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeDeletions,c,t.rowCount)||(this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(c)),o.push(this.codeDeletions)),l==null?(this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=a||this.codeAdditions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=Lt({code:this.codeAdditions,columnType:`additions`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeAdditions,l,t.rowCount)||(this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(l)),o.push(this.codeAdditions))):(this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=this.codeUnified==null||this.codeAdditions!=null||this.codeDeletions!=null,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.codeUnified=Lt({code:this.codeUnified,columnType:`unified`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeUnified,s,t.rowCount)||(this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(s)),o.push(this.codeUnified)),o.length===0?e.textContent=``:a&&e.replaceChildren(...o),this.lastRowCount=t.rowCount}applyPartialRender({fileDiff:e,previousRenderRange:t,renderRange:n}){let{pre:r,codeUnified:i,codeAdditions:a,codeDeletions:o,options:{diffStyle:s=`split`}}=this;if(r==null||t==null||n==null||!Number.isFinite(t.totalLines)||!Number.isFinite(n.totalLines)||this.lastRowCount==null)return!1;let c=this.getCodeColumns(s,i,o,a);if(c==null)return!1;let l=t.startingLine,u=n.startingLine,d=l+t.totalLines,f=u+n.totalLines,p=Math.max(l,u),m=Math.min(d,f);if(m<=p)return!1;let h=Math.max(0,p-l),g=Math.max(0,d-m),_=this.trimColumns({columns:c,trimStart:h,trimEnd:g,previousStart:l,overlapStart:p,overlapEnd:m,diffStyle:s});if(_<0)throw Error(`FileDiff.applyPartialRender: failed to trim to overlap`);if(this.lastRowCount<_)throw Error(`FileDiff.applyPartialRender: trimmed beyond DOM row count`);let v=this.lastRowCount-_,y=(t,n)=>{if(!(n<=0))return this.hunksRenderer.renderDiff(e,{startingLine:t,totalLines:n,bufferBefore:0,bufferAfter:0})},b=y(u,Math.max(p-u,0));if(b==null&&u<p)return!1;let x=y(m,Math.max(f-m,0));if(x==null&&f>m)return!1;let S=(e,t)=>{if(e!=null){if(s===`unified`&&!Array.isArray(c))this.insertPartialHTML(s,c,e,t);else if(s===`split`&&Array.isArray(c))this.insertPartialHTML(s,c,e,t);else throw Error(`FileDiff.applyPartialRender.applyChunk: invalid chunk application`);v+=e.rowCount,this.renderedDiff=e.fileDiff}};return this.cleanupErrorWrapper(),S(b,`afterbegin`),S(x,`beforeend`),this.lastRowCount!==v&&(this.applyRowSpan(s,c,v),this.lastRowCount=v),!0}insertPartialHTML(e,t,n,r){if(e===`unified`&&!Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`unified`,n);this.renderPartialColumn(t,e,r)}else if(e===`split`&&Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`deletions`,n),i=this.hunksRenderer.renderCodeAST(`additions`,n);this.renderPartialColumn(t[0],e,r),this.renderPartialColumn(t[1],i,r)}else throw Error(`FileDiff.insertPartialHTML: Invalid argument composition`)}refreshSplitDiffView(){let e=this.getLatestDiff();if(this.options.diffStyle!==`split`||e==null)return;let t=this.hunksRenderer.renderDiff(e,this.renderRange);if(t==null)return;let n=this.getCodeColumns(`split`,this.codeUnified,this.codeDeletions,this.codeAdditions);if(!Array.isArray(n))return;let r=(e,n)=>{if(n==null)return;let r=this.hunksRenderer.renderCodeAST(e,t),i=Ec(r?.[0]),a=Ec(r?.[1]);for(let[e,t]of[[n.gutter,i],[n.content,a]])if(t!=null&&e.childElementCount===t.length)for(let n=0;n<t.length;n++){let r=e.children[n],i=t[n].properties[`data-line-type`];i!=null&&r.dataset.lineType!==i&&(r.dataset.lineType=i)}};r(`deletions`,n[0]),r(`additions`,n[1]),this.renderedDiff=t.fileDiff}refreshUnifiedDiffView(){let e=this.getLatestDiff();if(this.options.diffStyle!==`unified`||e==null)return;let t=this.hunksRenderer.renderDiff(e,this.renderRange);if(t==null)return;let n=this.getCodeColumns(`unified`,this.codeUnified,this.codeDeletions,this.codeAdditions);if(n==null||Array.isArray(n))return;let r=this.hunksRenderer.renderCodeAST(`unified`,t),i=Ec(r?.[0]),a=Ec(r?.[1]),o=()=>{for(let[e,t]of[[n.gutter,i],[n.content,a]])t!=null&&(e.innerHTML=Zn(t));t.rowCount!==this.lastRowCount&&(this.applyRowSpan(`unified`,n,t.rowCount),this.lastRowCount=t.rowCount),this.renderedDiff=t.fileDiff};this.shouldGuardRebuildScroll()?Nt(this.pre,o):o(),this.renderSeparators(t.hunkData),this.managersDirty=!0,this.flushManagers(),this.syncRenderViewToEditor()}renderPartialColumn(e,t,n){if(e==null||t==null)return;let r=Ec(t[0]),i=Ec(t[1]);if(r==null||i==null)throw Error(`FileDiff.insertPartialHTML: Unexpected AST structure`);let a=i.at(0);n===`beforeend`&&a?.type===`element`&&typeof a.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(a.properties[`data-buffer-size`],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],r,i,!0);let o=i.at(-1);n===`afterbegin`&&o?.type===`element`&&typeof o.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(o.properties[`data-buffer-size`],e.content.children[0],e.gutter.children[0],r,i,!1),e.gutter.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(r)),e.content.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(i))}mergeBuffersIfNecessary(e,t,n,r,i,a){if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))return;let o=this.getBufferSize(t.dataset);o!=null&&(a?(r.shift(),i.shift()):(r.pop(),i.pop()),this.updateBufferSize(t,o+e),this.updateBufferSize(n,o+e))}applyRowSpan(e,t,n){let r=e=>{e!=null&&(e.gutter.style.setProperty(`grid-row`,`span ${n}`),e.content.style.setProperty(`grid-row`,`span ${n}`))};if(e===`unified`&&!Array.isArray(t))r(t);else if(e===`split`&&Array.isArray(t))r(t[0]),r(t[1]);else throw Error(`dun fuuuuked up`)}trimColumnRows(e,t,n){let r=0,i=0,a=0,o=!1,s=n>=0;if(e==null)return 0;let c=Array.from(e.content.children),l=Array.from(e.gutter.children);if(c.length!==l.length)throw Error(`FileDiff.trimColumnRows: columns do not match`);for(;a<c.length&&!(t<=0&&!s&&!o);){let e=l[a],u=c[a];if(a++,!(e instanceof HTMLElement)||!(u instanceof HTMLElement))throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: invalid row elements`);if(o&&(o=!1,e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset||e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset)){e.remove(),u.remove(),i++;continue}if(`lineIndex`in e.dataset&&`lineIndex`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),t>0&&(t--,t===0&&(o=!0)),i++),r++;continue}if(`separator`in e.dataset&&`separator`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`buffer`&&`contentBuffer`in u.dataset){let a=this.getBufferSize(u.dataset);if(a==null)throw Error(`FileDiff.trimColumnRows: invalid element`);if(t>0){let n=Math.min(t,a),r=a-n;r>0?(this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=n):(e.remove(),u.remove(),i+=a),t-=n,t===0&&r===0&&(o=!0)}else if(s){let t=r,o=r+a-1;if(n<=t)e.remove(),u.remove(),i+=a;else if(n<=o){let t=o-n+1,r=a-t;this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=t}}r+=a;continue}throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: unknown row elements`)}return i}trimColumns({columns:e,diffStyle:t,overlapEnd:n,overlapStart:r,previousStart:i,trimEnd:a,trimStart:o}){let s=Math.max(0,r-i),c=n-i;if(c<0)throw Error(`FileDiff.trimColumns: overlap ends before previous`);let l=o>0,u=a>0;if(!l&&!u)return 0;let d=l?s:0,f=u?c:-1;if(t===`unified`&&!Array.isArray(e))return this.trimColumnRows(e,d,f);if(t===`split`&&Array.isArray(e)){let t=this.trimColumnRows(e[0],d,f),n=this.trimColumnRows(e[1],d,f);if(e[0]!=null&&e[1]!=null&&t!==n)throw Error(`FileDiff.trimColumns: split columns out of sync`);return e[0]==null?n:t}throw console.error({diffStyle:t,columns:e}),Error(`FileDiff.trimColumns: Invalid columns for diffType`)}getBufferSize(e){let t=Number.parseInt(e?.bufferSize??``,10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty(`grid-row`,`span ${t}`),e.style.setProperty(`min-height`,`calc(${t} * 1lh)`)}getColumnPair(e){if(e==null)return;let t=e.children[0],n=e.children[1];if(t instanceof HTMLElement&&n instanceof HTMLElement&&t.dataset.gutter!=null&&n.dataset.content!=null)return{gutter:t,content:n}}getCodeColumns(e,t,n,r){if(e===`unified`)return this.getColumnPair(t);{let e=this.getColumnPair(n),t=this.getColumnPair(r);return e!=null||t!=null?[e,t]:void 0}}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore??(this.bufferBefore=document.createElement(`div`),this.bufferBefore.dataset.virtualizerBuffer=`before`,e.before(this.bufferBefore)),this.bufferBefore.style.setProperty(`height`,`${t.bufferBefore}px`),this.bufferBefore.style.setProperty(`contain`,`strict`)):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter??(this.bufferAfter=document.createElement(`div`),this.bufferAfter.dataset.virtualizerBuffer=`after`,e.after(this.bufferAfter)),this.bufferAfter.style.setProperty(`height`,`${t.bufferAfter}px`),this.bufferAfter.style.setProperty(`contain`,`strict`)):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyPreNodeAttributes(e,{additionsContentAST:t,deletionsContentAST:n,totalLines:r},i){let{diffIndicators:a=`bars`,disableBackground:o=!1,disableLineNumbers:s=!1,overflow:c=`scroll`,diffStyle:l=`split`}=this.options,u={type:`diff`,diffIndicators:a,disableBackground:o,disableLineNumbers:s,overflow:c,split:l!==`unified`&&t!=null&&n!=null,totalLines:r,customProperties:i};Tt(u,this.appliedPreAttributes)||(Ft(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 bc(e){return{name:e.name,lang:e.lang,contents:e.additionLines.join(``)}}function xc(e,t){return e==null||t==null?e==null&&t==null:st(e,t)}function Sc({fileDiff:e,oldFile:t,newFile:n}){return e!=null&&e.hunks.length>0||t!=null||n!=null}function Cc({fileDiff:e,oldFile:t,newFile:n}){return e!=null||t!=null||n!=null}function wc(e,t,n=!1){return!n&&e==null&&t}function Tc(e,t,n=!1){return e==null&&t&&!n}function Ec(e){if(e!=null&&e.type===`element`)return e.children??[]}var Dc=3e3,Oc=new Map,kc=-1,Ac=class extends yc{__id=`little-virtualized-file-diff:${++kc}`;renderType=`virtualized`;top;height=0;metrics;cache={heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0,fileAnnotationHeight:0,ghostTextRows:Oc,ghostTextRowsByIndex:new Map};isVisible=!1;isSetup=!1;virtualizer;layoutDirty=!0;forceRenderOverride;currentCollapsed;pendingHydratedDiff;pendingExpansions;pendingRender;constructor(e,t,n,r,i=!1){super(e,r,i),this.virtualizer=t,this.metrics=_t(n)}setMetrics(e,t=!1){let n=_t(e);(t||!cr(this.metrics,n))&&(this.metrics=n,this.resetLayoutCache({includeEstimatedHeights:!0}))}setLineAnnotations(e){this.syncLineAnnotations(e)&&this.resetLayoutCache({includeEstimatedHeights:!1})}syncLineAnnotations(e){return e==null||!this.isNewAnnotations(e)||e.length===0&&this.getLatestAnnotations().length===0?!1:(super.setLineAnnotations(e),!0)}syncEditSessionAnnotationsFromEditor(e){return super.syncEditSessionAnnotationsFromEditor(e)?(this.resetLayoutCache({includeEstimatedHeights:!1}),!0):!1}setFileAnnotationHeight(e){let t=this.cache.fileAnnotationHeight;return e!==t&&(this.cache.fileAnnotationHeight=e,this.cache.measuredHeightDeltaTotal+=e-t,!0)}hasFileAnnotations(e){let t=this.getLatestAnnotations();return ar(t)?t.some(t=>t.lineNumber===0?e.type===`new`?t.side===`additions`:e.type!==`deleted`||t.side===`deletions`:!1):!1}getLineHeight(e,t=!1){return this.getEstimatedLineHeight(t)+(this.cache.heightDeltas.get(e)??0)}getEstimatedLineHeight(e=!1){let t=e?2:1;return this.metrics.lineHeight*t}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!dn(t,e),r=n&&Rc(t,e);super.setOptions(e),r&&this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:zc(t,e)}),n&&(this.forceRenderOverride=!0),n&&this.isSimpleMode()&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache({forceSimpleRecompute:e=!1,includeEstimatedHeights:t=!1,resetRenderRange:n=!0}={}){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heightDeltas.clear(),this.cache.measuredHeightDeltaTotal=0,this.cache.ghostTextRows=Oc,this.cache.ghostTextRowsByIndex.size>0&&this.cache.ghostTextRowsByIndex.clear(),this.invalidateDerivedLayoutCache(t,n),e&&this.isSimpleMode()&&this.computeApproximateSize()}invalidateDerivedLayoutCache(e,t=!0){this.layoutDirty=!0,this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.cache.totalLines!==0&&(this.cache.totalLines=0),e&&(this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0),this.renderRange!=null&&t&&(this.renderRange=void 0)}applyGhostTextRows(e,t){let{cache:{heightDeltas:n,ghostTextRows:r,ghostTextRowsByIndex:i},metrics:{lineHeight:a}}=this;if(r===t)return!1;let o=this.getDiffStyle(),s=new Map;for(let[n,r]of t){let t=this.getLineIndexForDiff(e,n+1,`additions`);t!=null&&s.set(o===`split`?t[1]:t[0],r)}let c=!1;for(let e of new Set([...i.keys(),...s.keys()])){let t=((s.get(e)??0)-(i.get(e)??0))*a;if(t===0)continue;let r=(n.get(e)??0)+t;r===0?n.delete(e):n.set(e,r),this.cache.measuredHeightDeltaTotal+=t,c=!0}return this.cache.ghostTextRows=t,this.cache.ghostTextRowsByIndex=s,c}reconcileHeights(){let e=!1,{options:{overflow:t=`scroll`},cache:{ghostTextRowsByIndex:n},metrics:{lineHeight:r}}=this,i=this.getRenderedDiff();if(this.fileContainer==null||i==null)return this.height!==0&&(e=!0),this.height=0,e;this.top=this.getVirtualizedTop(),e=this.applyGhostTextRows(i,this.editor?.__getGhostTextRows()??Oc);let a=this.getLatestAnnotations();if(t===`scroll`&&a.length===0&&!this.isResizeDebuggingEnabled())return e&&this.computeApproximateSize(!0),e;let o=this.getDiffStyle(),s=o===`split`?[this.codeDeletions,this.codeAdditions]:[this.codeUnified],c=this.hasFileAnnotations(i);if(this.renderRange!=null&&c&&bn(this.renderRange)){let t=jc(s)??0;this.setFileAnnotationHeight(t)&&(e=!0)}else!c&&this.setFileAnnotationHeight(0)&&(e=!0);for(let t of s){if(t==null)continue;let i=t.children[1];if(!(i instanceof HTMLElement))continue;let a=o===`split`&&t===this.codeDeletions;for(let t of i.children){if(!(t instanceof HTMLElement))continue;let i=t.dataset.lineIndex;if(i==null)continue;let s=Uc(i,o),c=n.get(s)??0;if(a&&c>0)continue;let l=t.getBoundingClientRect().height+c*r,u=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(u=!0),l+=t.nextElementSibling.getBoundingClientRect().height);let d=this.getEstimatedLineHeight(u),f=this.cache.heightDeltas.get(s)??0,p=l-d;p!==f&&(e=!0,this.cache.measuredHeightDeltaTotal+=p-f,p===0?this.cache.heightDeltas.delete(s):this.cache.heightDeltas.set(s,p))}}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer!=null&&(e&&(this.top=this.getVirtualizedTop()),this.render());flushManagers(){super.flushManagers(),this.lineStateRefreshPending&&this.flushDeferredLineState()}updateCodeViewLayout(e,t,n,r){let i=!1,a=!1,{pendingExpansions:o,pendingHydratedDiff:s,options:{collapsed:c=!1}}=this;if(s!=null&&(this.pendingHydratedDiff=void 0,s.expectedDiff===e&&(Object.assign(e,s.nextDiff),this.setHydratedState(s.files),this.startHydratedEditSession(e),this.forceRenderOverride=!0,i=!0,a=!0)),o!=null){this.pendingExpansions=void 0;for(let{hunkIndex:e,direction:t,expansionLineCountOverride:n}of o)this.hunksRenderer.expandHunk(e,t,n),this.forceRenderOverride=!0,a=!0}let l=this.updateExternalDiff(e,r),{pendingRenderDiff:u,layoutDiffChanged:d,renderedDiffChanged:f,annotationsChanged:p}=this.updatePendingRender(e,r);return!this.forceRenderOverride&&(l||f||p)&&(this.forceRenderOverride=!0),(n?.resetDiffLayoutCache===!0||d||p)&&(i=!0),(d||n?.resetDiffLayoutCache===!0&&n.includeEstimatedDiffHeights)&&(a=!0),n?.metrics!=null&&(this.metrics=_t(n.metrics),i=!0,a=!0),this.currentCollapsed!==c&&(this.currentCollapsed=c,i=!0),i?this.resetLayoutCache({includeEstimatedHeights:a}):a&&this.invalidateDerivedLayoutCache(!0),this.top=t,this.computeApproximateSize(!1,u),this.height}getLinePosition(e,t=`additions`){let n=this.getLayoutDiff();if(n==null||e<1)return;let r=this.getLineIndexForDiff(n,e,t);if(r==null)return;let{disableFileHeader:i=!1,expandUnchanged:a=!1,collapsed:o=!1,collapsedContextThreshold:s=1}=this.options,c=this.getDiffStyle(),l=this.getHunkSeparatorType(),u=c===`split`?r[1]:r[0];this.approximateLayoutCheckpoints(n);let d=wt(this.metrics,i),f=this.getLayoutCheckpointBeforeLineIndex(u),p=f?.top??d+this.cache.fileAnnotationHeight;if(o)return{top:d,height:0};let m;return Xt({diff:n,diffStyle:c,startingLine:f?.renderedLineIndex??0,expandedHunks:a?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:s,callback:({hunkIndex:e,hunk:t,collapsedBefore:n,collapsedAfter:r,deletionLine:i,additionLine:a})=>{let o=c===`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=It({type:l,metrics:this.metrics,hunkIndex:e,hunkSpecs:t?.hunkSpecs});if(r!=null){if(p+=r.gapBefore,u>=o-n&&u<o)return m={top:p,height:r.height},!0;p+=r.height+r.gapAfter}}let s=this.getLineHeight(o,(a?.noEOFCR??!1)||(i?.noEOFCR??!1));if(o===u)return m={top:p,height:s},!0;if(p+=s,r>0){let e=Mt({type:l,metrics:this.metrics});if(e!=null){if(u>o&&u<=o+r)return m={top:p+e.gapBefore,height:e.height},!0;p+=e.totalHeight}}return!1}}),m}getEditorViewport(){return this.virtualizer.type===`simple`?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){let t=this.getLayoutDiff();if(t==null)return;let{disableFileHeader:n=!1,expandUnchanged:r=!1,collapsed:i=!1,collapsedContextThreshold:a=1}=this.options;if(i)return;let o=this.getDiffStyle(),s=this.getHunkSeparatorType();this.approximateLayoutCheckpoints(t);let c=this.getLayoutCheckpointBeforeTop(e),l=c?.top??wt(this.metrics,n)+this.cache.fileAnnotationHeight,u;return Xt({diff:t,diffStyle:o,startingLine:c?.renderedLineIndex??0,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:a,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,deletionLine:a,additionLine:c})=>{let d=o===`split`?c?.splitLineIndex??a?.splitLineIndex:c?.unifiedLineIndex??a?.unifiedLineIndex;if(d==null)throw Error(`VirtualizedFileDiff.getNumericScrollAnchor: missing line index data`);if(r>0){let e=It({type:s,metrics:this.metrics,hunkIndex:t,hunkSpecs:n?.hunkSpecs});e!=null&&(l+=e.totalHeight)}if(l>=e&&(a==null?c!=null&&(u={lineNumber:c.lineNumber,side:`additions`,top:l}):u={lineNumber:a.lineNumber,side:`deletions`,top:l},u!=null))return!0;let f=this.getLineHeight(d,(c?.noEOFCR??!1)||(a?.noEOFCR??!1));if(l+=f,i>0){let e=Mt({type:s,metrics:this.metrics});e!=null&&(l+=e.totalHeight)}return!1}}),u}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){let t=this.getLayoutDiff();if(this.top==null||t==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let n=e==null?this.renderRange:this.computeRenderRangeFromWindow(t,this.top,e);if(n==null)return;let{bufferBefore:r,bufferAfter:i,totalLines:a}=n,o=0;if(a===0){let t=e??this.virtualizer.getWindowSpecs();this.top<t.top&&(o=i)}return{topOffset:this.top+r+o,height:this.height-(r+i)}}cleanUp(e=!1){let t=this.cache.ghostTextRows.size>0;t&&(this.layoutDirty=!0);let n=e&&this.isAdvancedMode()&&this.fileContainer!=null&&(t||!en(this.getRenderedDiff(),this.getLatestDiff()));this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||(this.resetLayoutCache({includeEstimatedHeights:!0}),this.pendingExpansions=void 0,this.pendingHydratedDiff=void 0),this.pendingRender=void 0,this.isSetup=!1,super.cleanUp(e),n&&this.virtualizer.instanceChanged(this,!0)}expandHunk=(e,t,n)=>{this.fileDiff!=null&&(this.isAdvancedMode()?(this.pendingExpansions??=[],this.pendingExpansions.push({hunkIndex:e,direction:t,expansionLineCountOverride:n})):(this.hunksRenderer.expandHunk(e,t,n),this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()),this.loadFilesIfNecessary(),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))};async handleFilesLoaded(e,t){if(this.fileDiff===e&&e.isPartial){if(this.isAdvancedMode()){let n=Lo(`clone`,e,t);if(await jo(()=>this.primeHighlightCache(n)),!this.enabled||this.fileDiff!==e)return;this.pendingHydratedDiff={expectedDiff:e,nextDiff:n,files:t}}else{if(Lo(`merge`,e,t),this.setHydratedState(t),!this.startHydratedEditSession(e)&&(await jo(()=>this.primeHighlightCache(e)),!this.enabled||this.fileDiff!==e))return;this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}}loadFilesIfNecessary(){if(this.pendingHydratedDiff!=null){if(this.pendingHydratedDiff.expectedDiff===this.fileDiff)return;this.pendingHydratedDiff=void 0}super.loadFilesIfNecessary()}isLineRenderable(e){if(super.isLineRenderable(e))return!0;let{pendingExpansions:t}=this,n=this.getRenderedDiff();if(t==null||t.length===0||n==null)return!1;let{expansionLineCount:r=100,collapsedContextThreshold:i=1}=this.options,a=new Map(this.hunksRenderer.getExpandedHunksMap());for(let e of t){let t={...a.get(e.hunkIndex)??{fromStart:0,fromEnd:0}},n=e.expansionLineCountOverride??r;(e.direction===`up`||e.direction===`both`)&&(t.fromStart+=n),(e.direction===`down`||e.direction===`both`)&&(t.fromEnd+=n),a.set(e.hunkIndex,t)}return zt({fileDiff:n,lineNumber:e,expandedHunks:a,collapsedContextThreshold:i})}invalidateEditSessionLayout(){this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1}),this.isSimpleMode()||this.computeApproximateSize(!0),this.getSimpleVirtualizer()?.requestHeightReconcile(this)}escalateEditSessionRender(){this.invalidateEditSessionLayout(),this.enabled&&this.fileDiff!=null&&(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))}shouldSelfHealEditSession(){return!this.isAdvancedMode()&&super.shouldSelfHealEditSession()}setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){if(!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null)return;let e=this.getLatestDiff(),t=e==null?void 0:this.hunksRenderer.getDiffForNextRender(e);this.isSimpleMode()&&(this.pendingRender=void 0),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!en(this.getRenderedDiff(),t))}syncGhostTextRows(){let e=this.getAdvancedVirtualizer();e==null?this.getSimpleVirtualizer()?.requestHeightReconcile(this):(e.capturePendingLayoutAnchor(),this.layoutDirty=!0,e.instanceChanged(this,!0))}applyDocumentChange(e,t,n=!1){let{renderRange:r}=this;this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1});let i=this.getRenderedDiff();if(!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&r!=null&&i!=null){let e=this.virtualizer.getWindowSpecs(),t=this.computeRenderRangeFromWindow(i,this.top??0,e);t.bufferAfter!==r.bufferAfter&&this.updateBuffers(t)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}computeApproximateSize(e=!1,t=this.getLayoutDiff()){let n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;let r=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.cache.totalLines=0,t==null){this.layoutDirty=!1;return}this.applyGhostTextRows(t,this.editor?.__getGhostTextRows()??Oc);let{disableFileHeader:i=!1,collapsed:a=!1}=this.options,o=wt(this.metrics,i);if(this.height+=o,a){this.layoutDirty=!1;return}this.height=this.getActiveEstimatedHeight(t)+this.cache.measuredHeightDeltaTotal,n&&!r&&this.validateComputedHeight(t),this.layoutDirty=!1}getLayoutDiff(){return this.pendingRender?.diff??this.getRenderedDiff()}getActiveEstimatedHeight(e=this.getLayoutDiff()){this.ensureEstimatedDiffHeights(e);let t=this.getDiffStyle()===`split`?this.cache.estimatedSplitHeight:this.cache.estimatedUnifiedHeight;if(t==null)throw Error(`VirtualizedFileDiff.getActiveEstimatedHeight: missing estimated height`);return t}ensureEstimatedDiffHeights(e=this.getLayoutDiff()){if(e==null){this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0;return}if(this.cache.estimatedSplitHeight!=null&&this.cache.estimatedUnifiedHeight!=null)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,{splitHeight:i,unifiedHeight:a}=Mo({fileDiff:e,metrics:this.metrics,disableFileHeader:t,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:n,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r,canHydratePartialDiff:Bc(e,this.options.loadDiffFiles!=null)});this.cache.estimatedSplitHeight=i,this.cache.estimatedUnifiedHeight=a}validateComputedHeight(e=this.getLayoutDiff()){if(this.fileContainer==null||e==null)return;let t=this.fileContainer.getBoundingClientRect();t.height===this.height?console.log(`VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFileDiff.computeApproximateSize: computed height doesnt match`,{name:e.name,elementHeight:t.height,computedHeight:this.height})}render({fileContainer:e,fileDiff:t,forceRender:n=!1,lineAnnotations:r,...i}={}){let a=Fo(i,`VirtualizedFileDiff.render`),o=a!=null,s=a?.oldFile,c=a?.newFile,l=o&&(!Hc(s,this.deletionFile)||!Hc(c,this.additionFile)),u=t??this.fileDiff;t==null&&o&&(l||this.fileDiff==null)&&(u=qo(a.oldFile,a.newFile,this.options.parseDiffOptions));let{forceRenderOverride:d,isSetup:f}=this;this.forceRenderOverride=void 0;let p=u!=null&&!en(this.fileDiff,u),m=p||l;if(e=this.getOrCreateFileContainer(e),u==null)return console.error(`VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data`),!1;p&&this.updateExternalDiff(u,r);let{pendingRenderDiff:h,layoutDiffChanged:g,renderedDiffChanged:_,annotationsChanged:v}=this.pendingRender!=null&&this.pendingRender.latestDiff===(this.getLatestDiff(u)??u)?{pendingRenderDiff:this.pendingRender.diff,layoutDiffChanged:!1,renderedDiffChanged:!1,annotationsChanged:!1}:this.updatePendingRender(u,r);if((v||g)&&this.resetLayoutCache({includeEstimatedHeights:g}),f)this.top??=this.getVirtualizedTop(),g&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.computeApproximateSize(!1,h));else{this.computeApproximateSize(!1,h);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()&&(!m||!f))return a!=null&&(this.deletionFile=s,this.additionFile=c),p&&this.clearReusableHeader(),this.pendingRender=void 0,this.renderPlaceholder(this.height);let y=this.virtualizer.getWindowSpecs(),b=this.top??0,x=this.computeRenderRangeFromWindow(h,b,y);return super.render({fileDiff:u,fileContainer:e,renderRange:x,lineAnnotations:r,forceRender:(d??n)||v||_||p,...a,...i})}finalizeRender(){if(this.getRenderedDiff()!==this.pendingRender?.diff)throw Error(`VirtualizedFileDiff.render: rendered a different diff than its prepared layout`);this.pendingRender=void 0,this.isSimpleMode()&&this.getSimpleVirtualizer()?.requestHeightReconcile(this)}updatePendingRender(e,t){let n=this.getLatestDiff(e)??e,r=this.getRenderedDiff(),{pendingRender:i}=this,a=i?.diff??r,o=this.hunksRenderer.getDiffForNextRender(n);return this.pendingRender={latestDiff:n,diff:o},{pendingRenderDiff:o,annotationsChanged:this.syncLineAnnotations(t),layoutDiffChanged:!en(a,o),renderedDiffChanged:!en(r,o)}}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type===`simple`}isAdvancedMode(){return this.virtualizer.type===`advanced`}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}getSimpleVirtualizer(){return this.virtualizer.type===`simple`?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type===`advanced`?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}getDiffStyle(){return this.options.diffStyle??`split`}getHunkSeparatorType(){return Vc(this.options.hunkSeparators)}approximateLayoutCheckpoints(e){if(!this.layoutDirty&&this.cache.checkpoints.length>0||e.hunks.length===0||this.options.collapsed===!0)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,i=e.hunks.length-1,a=Bc(e,this.options.loadDiffFiles!=null),o=this.getDiffStyle(),s=this.getHunkSeparatorType(),c=n?!0:this.hunksRenderer.getExpandedHunksMap(),l=Mc(this.cache.heightDeltas),u=wt(this.metrics,t)+this.cache.fileAnnotationHeight,d=0,f=({rowCount:e,startLineIndex:t,preSeparatorHeight:n=0,postSeparatorHeight:r=0,metadataOffsets:i=[]})=>{if(e<=0)return;let a=d,o=d+e,s=Fc(a);for(;s<o;){let e=s-a,r=u+(e>0?n:0)+e*this.metrics.lineHeight+Ic(i,e)*this.metrics.lineHeight+Nc(l,t,t+e);this.cache.checkpoints.push({renderedLineIndex:s,lineIndex:t+e,top:r}),s+=Dc}u+=n+e*this.metrics.lineHeight+i.length*this.metrics.lineHeight+Nc(l,t,t+e)+r,d=o};for(let t=0;t<e.hunks.length;t++){let n=e.hunks[t];if(n==null)throw Error(`VirtualizedFileDiff.approximateLayoutCheckpoints: invalid hunk index`);let l=mt({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:c,hunkIndex:t,collapsedContextThreshold:r}),u=l.collapsedLines>0?It({type:s,metrics:this.metrics,hunkIndex:t,hunkSpecs:n.hunkSpecs})?.totalHeight??0:0;f({rowCount:l.fromStart,startLineIndex:(o===`split`?n.splitLineStart:n.unifiedLineStart)-l.rangeSize});let d=u;f({rowCount:l.fromEnd,startLineIndex:(o===`split`?n.splitLineStart:n.unifiedLineStart)-l.fromEnd,preSeparatorHeight:d}),l.fromEnd>0&&(d=0);let p=t===i?Nn({fileDiff:e,hunkIndex:t,expandedHunks:c,collapsedContextThreshold:r,errorPrefix:`VirtualizedFileDiff`}):void 0,m=p!=null&&p.collapsedLines>0||t===i&&a?Mt({type:s,metrics:this.metrics})?.totalHeight??0:0,h=p==null?0:p.fromStart+p.fromEnd,g=o===`split`?n.splitLineCount:n.unifiedLineCount,_=o===`split`?n.splitLineStart:n.unifiedLineStart;f({rowCount:g,startLineIndex:_,preSeparatorHeight:d,postSeparatorHeight:h===0?m:0,metadataOffsets:Lc({diffStyle:o,hunk:n,rowCount:g})}),p!=null&&h>0&&f({rowCount:h,startLineIndex:_+g,postSeparatorHeight:m})}this.cache.totalLines=d}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);if(n.renderedLineIndex%t===0)return n}}getExpandedLineCount(e,t){let n=0;if(e.isPartial){for(let r of e.hunks)n+=t===`split`?r.splitLineCount:r.unifiedLineCount;return n}let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a=r?!0:this.hunksRenderer.getExpandedHunksMap();for(let[r,o]of e.hunks.entries()){let s=t===`split`?o.splitLineCount:o.unifiedLineCount;n+=s;let c=Math.max(o.collapsedBefore,0),{fromStart:l,fromEnd:u,renderAll:d}=mt({isPartial:e.isPartial,rangeSize:c,expandedHunks:a,hunkIndex:r,collapsedContextThreshold:i});c>0&&(n+=d?c:l+u)}let o=Nn({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:a,collapsedContextThreshold:i,errorPrefix:`VirtualizedFileDiff`});return o!=null&&(n+=o.fromStart+o.fromEnd),n}getLayoutLineCount(e,t){let n=this.getExpandedLineCount(e,t),r=t===`split`?e.splitLineCount:e.unifiedLineCount;return Math.max(n,r,e.additionLines.length,e.deletionLines.length,this.cache.totalLines)}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,expandUnchanged:a=!1,collapsedContextThreshold:o=1}=this.options,{hunkLineCount:s,lineHeight:c}=this.metrics,l=this.getDiffStyle(),u=this.getHunkSeparatorType(),d=Bc(e,this.options.loadDiffFiles!=null),f=this.height,p=this.getLayoutLineCount(e,l),m=wt(this.metrics,i),h=e.hunks.length>0?kt(this.metrics):0,{fileAnnotationHeight:g}=this.cache,_=m+g,v=Math.max(0,f-m-g-h),y=this.hasFileAnnotations(e),b=t+m,x=g>0&&y&&b<r&&b+g>n;if(t<n-f||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h};if(p<=s||e.hunks.length===0)return{startingLine:0,totalLines:s,bufferBefore:0,bufferAfter:0};this.approximateLayoutCheckpoints(e),p=this.getLayoutLineCount(e,l);let S=Math.ceil(Math.max(r-n,0)/c),C=Math.ceil(S/s)*s+s,w=C/s,T=w,E=[],D=(n+r)/2,O=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-C*c*2),s),k=t+(O?.top??_),A=O?.renderedLineIndex??0,j,M,N;if(Xt({diff:e,diffStyle:l,startingLine:O?.renderedLineIndex??0,expandedHunks:a?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:i,hunk:a,collapsedBefore:o,collapsedAfter:c,deletionLine:f,additionLine:p})=>{let m=p==null?f.splitLineIndex:p.splitLineIndex,h=p==null?f.unifiedLineIndex:p.unifiedLineIndex,g=(p?.noEOFCR??!1)||(f?.noEOFCR??!1),v=i===e.hunks.length-1&&a!=null&&(l===`split`?m===a.splitLineStart+a.splitLineCount-1:h===a.unifiedLineStart+a.unifiedLineCount-1),y=(o>0?It({type:u,metrics:this.metrics,hunkIndex:i,hunkSpecs:a?.hunkSpecs}):void 0)?.totalHeight??0;k+=y;let b=A%s===0,x=Math.floor(A/s);if(b&&(E[x]=k-(t+_+y),N!=null)){if(N<=0)return!0;N--}let S=this.getLineHeight(l===`split`?m:h,g);if(k>n-S&&k<r&&(j??=x),M==null&&k+S>D&&(M=x),N==null&&k>=r&&b&&(N=T),A++,k+=S,c>0||v&&d){let e=Mt({type:u,metrics:this.metrics});e!=null&&(k<r&&k+e.totalHeight>n&&(j??=x),M==null&&k+e.totalHeight>D&&(M=x),k+=e.totalHeight)}return!1}}),j==null){if(x)j=0,M=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h}}M??=j;let P=Math.round(M-w/2),F=Math.max(0,Math.ceil(p/s)-w),I=Math.max(0,Math.min(P,F)),L=I*s,R=P<0?C+P*s:C,z=E[I]??0,B=L===0?0:g+z,V=I+R/s,H=V<E.length?v-E[V]:v-(k-t-_);return{startingLine:L,totalLines:R,bufferBefore:B,bufferAfter:Math.max(0,H)}}};function jc(e){let t;for(let n of e){if(n==null)continue;let e=n.children[1];if(e instanceof HTMLElement)for(let n of e.children)n instanceof HTMLElement&&n.dataset.lineAnnotation===_n&&(t=Math.max(t??0,n.getBoundingClientRect().height))}return t}function Mc(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 Nc({lineIndexes:e,prefixTotals:t},n,r){if(n>=r||e.length===0)return 0;let i=Pc(e,n);return(t[Pc(e,r)]??0)-(t[i]??0)}function Pc(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 Fc(e){return Math.ceil(e/Dc)*Dc}function Ic(e,t){let n=0;for(let r of e)r<t&&n++;return n}function Lc({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 Rc(e,t){return(e.diffStyle??`split`)!==(t.diffStyle??`split`)||(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.diffIndicators??`bars`)!==(t.diffIndicators??`bars`)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)||e.unsafeCSS!==t.unsafeCSS}function zc(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function Bc(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function Vc(e){return typeof e==`function`?`custom`:e??`line-info`}function Hc(e,t){return e==null||t==null?e==null&&t==null:st(e,t)}function Uc(e,t){let[n,r]=e.split(`,`).map(Number);return t===`split`?r:n}var Wc=`theme.disableLineNumbers.overflow.themeType.disableFileHeader.disableVirtualizationBuffers.preferredHighlighter.useCSSClasses.useTokenTransformer.tokenizeMaxLineLength.tokenizeMaxLength.unsafeCSS.diffStyle.diffIndicators.disableBackground.expandUnchanged.loadDiffFiles.collapsedContextThreshold.lineDiffType.maxLineDiffLength.expansionLineCount.lineHoverHighlight.enableTokenInteractionsOnWhitespace.enableGutterUtility.__debugPointerEvents.enableLineSelection.controlledSelection.disableErrorHandling`.split(`.`),Gc=[`theme`,`disableLineNumbers`,`overflow`,`themeType`,`disableFileHeader`,`disableVirtualizationBuffers`,`preferredHighlighter`,`useCSSClasses`,`useTokenTransformer`,`tokenizeMaxLineLength`,`tokenizeMaxLength`,`unsafeCSS`,`lineHoverHighlight`,`enableTokenInteractionsOnWhitespace`,`enableGutterUtility`,`__debugPointerEvents`,`enableLineSelection`,`controlledSelection`,`disableErrorHandling`],Kc=[`renderCustomHeader`,`renderHeaderPrefix`,`renderHeaderFilenameSuffix`,`renderHeaderMetadata`,`renderAnnotation`,`renderGutterUtility`,`onPostRender`,`onGutterUtilityClick`,`onLineClick`,`onLineNumberClick`,`onLineEnter`,`onLineLeave`,`onTokenClick`,`onTokenEnter`,`onTokenLeave`],qc=[`onLineSelected`,`onLineSelectionStart`,`onLineSelectionChange`,`onLineSelectionEnd`],Jc=Symbol(`CodeView.itemOptionsState`);function Yc(e,t){Object.defineProperty(e,Jc,{configurable:!1,enumerable:!1,value:t})}function Xc(e){return e[Jc]}function Zc(e,t,n){Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get(){return n(this)}})}var Qc=120,$c=1,el=`--diffs-overflow-override`,tl=12e6,nl=1e6,rl=2e6,il=1e7,al=11e6;function ol(e){if(e==null)throw Error(`CodeView: createEditor is required for items with edit: true`)}var sl=(()=>{let{navigator:e}=globalThis,t=e.userAgent,n=/iP(?:hone|ad|od)/.test(t),r=e.platform===`MacIntel`&&e.maxTouchPoints>1;return(n||r)&&/AppleWebKit/.test(t)&&/Safari/.test(t)&&!/(CriOS|FxiOS|EdgiOS|OPiOS)/.test(t)})(),cl=class e{static __STOP=!1;static __lastScrollPosition=0;type=`advanced`;config={overscrollSize:200,intersectionObserverMargin:0,resizeDebugging:!1};items=[];idToItem=new Map;selectedLines=null;itemEditors=new Map;attachedEditors=new Set;instanceToItem=new Map;layoutDirtyIndex;pendingLayoutReset;renderOptionsRevision=0;slotCoordinator;slotSnapshot;scrollListeners=new Set;scrollHeight=0;containerHeight=-1;scrollTop=0;scrollPageOffset=0;scrollDirty=!0;scrollInteractionFixTimer;pointerEventsDisabled=!1;codeOverflowFix=!1;height=0;heightDirty=!0;windowSpecs={top:0,bottom:0};renderState={scrollTop:-1,firstIndex:-1,lastIndex:-1,stickyHeight:0,stickyTop:-1,stickyBottom:-1};itemMetricsCache=un;fileOptionsPrototype;diffOptionsPrototype;pendingScrollTarget;pendingLayoutAnchor;shouldFixContainerFocus=!1;scrollAnimation;root;resizeObserver;container=document.createElement(`div`);stickyContainer=document.createElement(`div`);stickyOffset=document.createElement(`div`);header={element:void 0,render:void 0,height:0};footer={element:void 0,render:void 0,height:0};elementPool=[];elementPoolVersion=0;elementPoolTracker=new WeakMap;pendingElementPool=[];options;workerManager;isReadySubscription;pendingHighlighterTheme;isContainerManaged;constructor(e={theme:qt},t,n=!1){this.options=e,this.computeMetricsCache(e.itemMetrics),this.fileOptionsPrototype=this.createFileOptionsPrototype(),this.diffOptionsPrototype=this.createDiffOptionsPrototype(),this.workerManager=t,this.isContainerManaged=n,this.stickyOffset.style.contain=`layout size`,this.stickyContainer.style.position=`sticky`,this.stickyContainer.style.width=`100%`,this.stickyContainer.style.contain=`layout style inline-size`,this.stickyContainer.style.isolation=`isolate`,this.stickyContainer.style.display=`flex`,this.stickyContainer.style.flexDirection=`column`}getLayout(){return this.options.layout??sr}getItemTopOffset(){return this.getLayout().paddingTop+this.header.height}computeMetricsCache(e){return this.itemMetricsCache={hunkLineCount:e?.hunkLineCount??un.hunkLineCount,lineHeight:e?.lineHeight??un.lineHeight,diffHeaderHeight:e?.diffHeaderHeight??un.diffHeaderHeight,hunkSeparatorHeight:e?.hunkSeparatorHeight,spacing:e?.spacing??un.spacing,paddingTop:e?.paddingTop,paddingBottom:e?.paddingBottom},this.itemMetricsCache}getSmoothScrollSettings(){return this.options.smoothScrollSettings??fr}shouldDisablePointerEvents(){return this.options.pointerEventsOnScroll!==!0}shouldValidateItemHeights(){return lr&&this.options.__devOnlyValidateItemHeights===!0}validateRenderedItemHeight(e){if(!this.shouldValidateItemHeights()||e.element==null)return;let t=e.instance.getAdvancedStickySpecs();if(t==null)return;let n=t.height,r=e.element.getBoundingClientRect().height;n!==r&&console.error(`CodeView: reconciled item height does not match DOM height`,{id:e.item.id,type:e.type,index:e.index,version:e.version,expectedHeight:n,actualHeight:r,delta:r-n,stickyTopOffset:t.topOffset,virtualizedHeight:e.instance.getVirtualizedHeight(),top:e.top,scrollTop:this.getScrollTop(),windowSpecs:{...this.windowSpecs},element:e.element,instance:e.instance})}validateStickyContainerHeight(){if(!this.shouldValidateItemHeights())return;let{firstIndex:e,lastIndex:t,stickyHeight:n,stickyTop:r,stickyBottom:i}=this.renderState;if(e===-1||t===-1)return;let a=this.stickyContainer.getBoundingClientRect().height;Math.abs(a-n)<$c||console.error(`CodeView: sticky container height does not match computed layout`,{computedStickyHeight:n,actualStickyHeight:a,delta:a-n,stickyTop:r,stickyBottom:i,firstIndex:e,lastIndex:t,firstStickySpecs:this.items[e]?.instance.getAdvancedStickySpecs(),lastStickySpecs:this.items[t]?.instance.getAdvancedStickySpecs(),scrollTop:this.getScrollTop(),scrollPageOffset:this.scrollPageOffset,windowSpecs:{...this.windowSpecs},stickyContainer:this.stickyContainer})}clearScrollInteractionTimer(){this.scrollInteractionFixTimer!=null&&(clearTimeout(this.scrollInteractionFixTimer),this.scrollInteractionFixTimer=void 0)}suspendScrollInteractions(){this.clearScrollInteractionTimer(),this.shouldDisablePointerEvents()&&!this.pointerEventsDisabled&&(this.stickyContainer.style.pointerEvents=`none`,this.pointerEventsDisabled=!0),sl&&!this.codeOverflowFix&&(this.stickyContainer.style.setProperty(el,`hidden`),this.codeOverflowFix=!0),this.scrollInteractionFixTimer=setTimeout(this.restoreScrollInteractions,Qc)}restoreScrollInteractions=()=>{this.clearScrollInteractionTimer(),this.pointerEventsDisabled&&=(this.stickyContainer.style.removeProperty(`pointer-events`),!1),this.codeOverflowFix&&=(this.stickyContainer.style.setProperty(el,`auto`),!1)};syncLayout(){let{gap:e,paddingBottom:t,paddingTop:n}=this.getLayout();this.stickyContainer.style.gap=`${e}px`,this.container?.style.setProperty(`margin-top`,`${n}px`),this.container?.style.setProperty(`margin-bottom`,`${t}px`)}reconcileHeaderFooterHosts(){let e=this.reconcileHost(`header`),t=this.reconcileHost(`footer`);return e||t}reconcileHost(e){let{root:t,container:n}=this;if(t==null||n==null)return!1;let r=e===`header`?this.header:this.footer,i=e===`header`?this.options.renderCodeViewHeader:this.options.renderCodeViewFooter;if(i==null)return r.element!=null&&(this.resizeObserver?.unobserve(r.element),r.element.remove(),r.element=void 0,r.render=void 0,this.setHostHeight(r,0),!1);if(r.element!=null&&i===r.render)return!1;let a=r.element??Oo(e,n,this.resizeObserver);r.element=a;let o=i();return o==null?!this.isContainerManaged&&a.children.length>0&&(a.textContent=``):a.replaceChildren(o),r.render=i,!0}setHostHeight(e,t){e.height!==t&&(e.height=t,this.scrollDirty=!0)}measureMountedHosts(){this.header.element!=null&&this.setHostHeight(this.header,this.header.element.getBoundingClientRect().height),this.footer.element!=null&&this.setHostHeight(this.footer,this.footer.element.getBoundingClientRect().height)}setup(t){if(this.root!=null)throw Error(`CodeView.setup: already setup`);this.workerManager?.subscribeToThemeChanges(this),this.root=t,this.root.style.overflowAnchor=`none`,this.root.hasAttribute(`tabindex`)||(this.root.tabIndex=-1),this.container??=document.createElement(`div`),this.container.style.contain=`layout style`,this.syncLayout(),this.container.appendChild(this.stickyOffset),this.container.appendChild(this.stickyContainer),this.root.appendChild(this.container),this.scrollDirty=!0,this.heightDirty=!0,this.resizeObserver=new ResizeObserver(this.handleResize),this.resizeObserver.observe(this.stickyContainer),this.root.addEventListener(`scroll`,this.handleScroll,{passive:!0}),this.root.addEventListener(`wheel`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`touchstart`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`pointerdown`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`keydown`,this.clearPendingScroll,{passive:!0}),this.resizeObserver.observe(this.root),this.render(!0),window.__INSTANCE=this,window.__TOGGLE=()=>{e.__STOP?(e.__STOP=!1,this.scrollTo({type:`position`,position:e.__lastScrollPosition,behavior:`instant`})):(e.__lastScrollPosition=this.getScrollTop(),e.__STOP=!0)}}reset(){kn(this.computeRenderRangeAndEmit),this.clearReadySubscription(),this.restoreScrollInteractions(),this.cleanAllRenderedItems();let e=[...this.itemEditors.values()].map(e=>{let t=this.idToItem.get(e.state.id);return t!=null&&(e.state.removedItem=t.item),{record:e,instance:t?.instance}});this.itemEditors.clear(),this.attachedEditors.clear(),this.selectedLines=null,this.items.length=0,this.idToItem.clear(),this.instanceToItem.clear();let t=!1,n;for(let{record:r,instance:i}of e)try{r.editor.cleanUp(`discard`),i?.cleanUp()}catch(e){t||(t=!0,n=e)}if(this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,this.stickyContainer.textContent=``,this.stickyOffset.style.height=``,this.container?.style.removeProperty(`height`),this.containerHeight=-1,this.windowSpecs={top:0,bottom:0},this.pendingLayoutAnchor=void 0,this.shouldFixContainerFocus=!1,this.height=0,this.scrollTop=0,this.scrollPageOffset=0,this.scrollHeight=0,this.scrollDirty=!0,this.heightDirty=!0,this.resetRenderState(),this.isContainerManaged||this.flushSlotCoordinator(),t)throw n}cleanUp(){let e=!1,t;try{this.reset()}catch(n){e=!0,t=n}if(this.clearElementPool(),this.restoreScrollInteractions(),this.workerManager?.unsubscribeToThemeChanges(this),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.root?.removeEventListener(`scroll`,this.handleScroll),this.root?.removeEventListener(`wheel`,this.clearPendingScroll),this.root?.removeEventListener(`touchstart`,this.clearPendingScroll),this.root?.removeEventListener(`pointerdown`,this.clearPendingScroll),this.root?.removeEventListener(`keydown`,this.clearPendingScroll),this.root?.style.removeProperty(`overflow-anchor`),this.container?.remove(),this.stickyOffset.remove(),this.stickyContainer.remove(),this.stickyContainer.textContent=``,this.header.element?.remove(),this.header.element=void 0,this.header.render=void 0,this.header.height=0,this.footer.element?.remove(),this.footer.element=void 0,this.footer.render=void 0,this.footer.height=0,this.root=void 0,this.container=void 0,e)throw t}cleanAllRenderedItems(){if(this.renderState.firstIndex!==-1)for(let e=this.renderState.firstIndex;e<=this.renderState.lastIndex;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.cleanAllRenderedItems: Item does not exist at index: ${e}`);this.releaseRenderedItem(t)}}primeScrollTarget(e){e.type!==`position`&&this.idToItem.get(e.id)?.instance.primeHighlightCache()}getElementPoolLimit(){let e=this.getHeight()+this.config.overscrollSize*2,{diffHeaderHeight:t}=this.itemMetricsCache;return Math.max(8,Math.ceil(e/Math.max(t,10))+1)*(this.isContainerManaged?2:1)}acquireElement(){this.promotePendingPooledElements();let e=this.elementPool.pop();for(;e!=null&&!this.isElementPoolGenerationCurrent(e);)e=this.elementPool.pop();return e??=document.createElement(Yt),this.markElementPoolGenerationCurrent(e),e}releaseRenderedItem(e){let{element:t}=e;t!=null&&this.renderedItemOwnsFocus(t)&&(this.shouldFixContainerFocus=!0),e.instance.cleanUp(!0),this.attachedEditors.delete(e.item.id),e.element=void 0,t!=null&&(t.remove(),this.cleanElement(t),this.queueElementForPool(t))}renderedItemOwnsFocus(e){let{activeElement:t}=document;return t===e||e.contains(t)||e.shadowRoot?.activeElement!=null}fixContainerFocus(){this.shouldFixContainerFocus&&(this.shouldFixContainerFocus=!1,this.root?.focus({preventScroll:!0}))}cleanElement(e){let{shadowRoot:t}=e;if(t!=null)for(let e of Array.from(t.children))pl(e)||e.remove();this.isContainerManaged||e.replaceChildren()}queueElementForPool(e){let t=this.getElementPoolLimit();!this.isElementPoolGenerationCurrent(e)||this.getElementPoolSize()>=t||(this.isElementClean(e)?this.elementPool.push(e):this.pendingElementPool.push(e))}promotePendingPooledElements(){if(this.pendingElementPool.length===0)return;let{pendingElementPool:e}=this;this.pendingElementPool=[];let t=this.getElementPoolLimit();for(let n of e)this.isElementPoolGenerationCurrent(n)&&this.isElementClean(n)&&this.elementPool.length<t?this.elementPool.push(n):this.isElementPoolGenerationCurrent(n)&&this.getElementPoolSize()<t&&this.pendingElementPool.push(n)}isElementClean(e){return e.childNodes.length===0}getElementPoolSize(){return this.elementPool.length+this.pendingElementPool.length}clearElementPool(){this.elementPool.length=0,this.pendingElementPool.length=0}invalidateElementPool(){this.elementPoolVersion++,this.clearElementPool()}markElementPoolGenerationCurrent(e){this.elementPoolTracker.set(e,this.elementPoolVersion)}isElementPoolGenerationCurrent(e){return this.elementPoolTracker.get(e)===this.elementPoolVersion}resolveEffectiveScrollBehavior(e,t){return ko()?`instant`:e.behavior===`smooth-auto`?Math.abs(t-this.getScrollTop())<=this.getHeight()*10?`smooth`:`instant`:e.behavior??`instant`}scrollTo(e){if(this.root==null)return;let t=this.normalizeScrollTarget(e);if(t==null)return;let n=this.resolveScrollTargetTop(t);n!=null&&(this.primeScrollTarget(t),this.resolveEffectiveScrollBehavior(t,n)===`smooth`?this.scrollAnimation??={position:this.getScrollTop(),velocity:0,lastTimestamp:performance.now()}:this.scrollAnimation=void 0,this.suspendScrollInteractions(),this.pendingLayoutAnchor=void 0,this.pendingScrollTarget=t,this.render())}setSelectedLines(e,t){this.applySelectedLines(e,t)}getSelectedLines(){return this.selectedLines}clearSelectedLines(e){this.applySelectedLines(null,e)}getItem(e){return this.idToItem.get(e)?.item}getEditor(e){return this.itemEditors.get(e)?.editor}updateItem(e){let t=this.idToItem.get(e.id);return t==null?(console.error(`CodeView.updateItem: unknown item id "${e.id}"`),!1):this.syncItemRecord(t,e)?(this.markItemLayoutDirty(t),this.scrollDirty=!0,this.render(),this.syncItemEditors(),this.syncSelection(),!0):!1}updateItemId(e,t){if(e===t)return!0;let n=this.idToItem.get(e);if(n==null)return console.error(`CodeView.updateItemId: unknown item id "${e}"`),!1;if(this.idToItem.has(t))return console.error(`CodeView.updateItemId: duplicate item id "${t}"`),!1;this.idToItem.delete(e),n.item.id=t,this.idToItem.set(t,n),this.updateItemOptionsId(n.instance.options,t),this.selectedLines?.id===e&&(this.selectedLines={...this.selectedLines,id:t},this.options.onSelectedLinesChange?.(this.selectedLines));let r=this.itemEditors.get(e);return r!=null&&(this.itemEditors.delete(e),this.itemEditors.set(t,r),this.attachedEditors.delete(e)&&this.attachedEditors.add(t)),this.renamePendingScrollTarget(e,t),this.renamePendingLayoutAnchor(e,t),this.render(),!0}addItem(e){this.addItems([e])}addItems(e){this.appendItemsInternal(e),this.syncItemEditors(),this.syncSelection()}removeItem(e){let t=this.idToItem.get(e);if(t==null)return console.error(`CodeView.removeItem: unknown item id "${e}"`),!1;let n=[];for(let e of this.items)e!==t&&n.push(e.item);return this.setItems(n),!0}setItems(e){let t;this.items.length===0?this.appendItemsInternal(e):this.tryAppendItems(e)||(t=this.reconcileItems(e)),this.syncItemEditors(t),this.syncSelection()}appendItemsInternal(e,t=!0){if(e.length===0)return;let n=this.getLayout(),r=this.items.length===0?0:this.scrollHeight+n.gap,i=r;for(let t=0;t<e.length;t++){let i=e[t];if(i==null)throw Error(`CodeView.appendItemsInternal: missing input item`);if(this.idToItem.has(i.id))throw Error(`CodeView.addItem: duplicate id "${i.id}"`);let a=this.createItem(i,this.items.length,r);this.items.push(a),this.idToItem.set(a.item.id,a),this.instanceToItem.set(a.instance,a),a.height=ll(a),r+=a.height+n.gap}this.scrollHeight=r-n.gap,this.scrollDirty=!0,t&&(this.canSkipRenderForAppend(i)?this.syncContainerHeight():this.render())}canSkipRenderForAppend(e){return this.container!=null&&this.renderState.firstIndex!==-1&&this.pendingScrollTarget==null&&this.scrollAnimation==null&&this.layoutDirtyIndex==null&&e>this.windowSpecs.bottom}onThemeChange(){this.invalidateElementPool()}setOptions(e){if(e==null)return;this.capturePendingLayoutAnchor();let{options:t}=this,n=this.getLayout(),{itemMetricsCache:r}=this;ul(t,e)&&this.invalidateElementPool(),this.options=e;let i=this.computeMetricsCache(e.itemMetrics),a=!cr(r,i),o=!cr(n,this.getLayout());o&&this.syncLayout();let s=a||dl(t,e);if(s){let n=this.pendingLayoutReset;this.pendingLayoutReset={metrics:a?i:n?.metrics,resetFileLayoutCache:!0,resetDiffLayoutCache:!0,includeEstimatedDiffHeights:n?.includeEstimatedDiffHeights===!0||a||fl(t,e)}}(o||s)&&(this.markLayoutDirtyFromIndex(0),this.scrollDirty=!0),dn(t,e)||this.renderOptionsRevision++,this.syncItemEditors();let c=t.renderCodeViewHeader!==e.renderCodeViewHeader||t.renderCodeViewFooter!==e.renderCodeViewFooter;!this.isContainerManaged&&(this.items.length>0||c)&&this.render()}capturePendingLayoutAnchor(e=this.idToItem){this.root!=null&&this.items.length!==0&&this.pendingScrollTarget==null&&(this.pendingLayoutAnchor=this.getScrollAnchor(this.getScrollTop(),e))}render(t=!1){e.__STOP||(t?(kn(this.computeRenderRangeAndEmit),this.computeRenderRangeAndEmit()):Dn(this.computeRenderRangeAndEmit))}isReady(){let{workerManager:e}=this;return e==null||e.getStats().workersFailed?this.isSharedHighlighterReady():e.isInitialized()?(this.clearReadySubscription(),!0):(this.isReadySubscription??=e.subscribeToStatChanges(e=>{(e.managerState===`initialized`||e.workersFailed)&&(this.clearReadySubscription(),this.render(!0))}),e.getStats().managerState===`waiting`&&e.initialize().catch(()=>{}),!1)}clearReadySubscription(){this.isReadySubscription!=null&&(this.isReadySubscription(),this.isReadySubscription=void 0,this.pendingHighlighterTheme=void 0)}isSharedHighlighterReady(){let e=this.workerManager?.getFileRenderOptions().theme??this.options.theme??qt;return xn()&&Un(e)?(this.clearReadySubscription(),!0):(cn(this.pendingHighlighterTheme,e)||this.clearReadySubscription(),this.isReadySubscription??=(()=>{this.pendingHighlighterTheme=e;let t=!1;return tr({themes:Gn(e),langs:[],preferredHighlighter:this.options.preferredHighlighter}).then(()=>{t||(this.clearReadySubscription(),this.render(!0))},e=>{t||(this.clearReadySubscription(),console.error(e))}),()=>{t=!0}})(),!1)}instanceChanged(e,t){let n=this.instanceToItem.get(e);if(n==null)throw Error(`CodeView.instanceChanged: An instance has changed that is not registered`);t&&this.markItemLayoutDirty(n),this.render()}getWindowSpecs(){return this.windowSpecs}getContainerElement(){return this.root}getHeaderElement(){return this.header.element}getFooterElement(){return this.footer.element}getRenderedItems(){let{firstIndex:e,lastIndex:t}=this.renderState;if(e===-1||t===-1||t<e)return[];let n=[];for(let r=e;r<=t;r++){let e=this.items[r];e?.element!=null&&(e.type===`diff`?n.push({id:e.item.id,type:`diff`,item:e.item,version:e.version,element:e.element,instance:e.instance}):n.push({id:e.item.id,type:`file`,item:e.item,version:e.version,element:e.element,instance:e.instance}))}return n}setSlotCoordinator(e){return e!==this.slotCoordinator&&(this.slotCoordinator=e,this.slotSnapshot=void 0,!0)}getSlotSnapshot(e){return this.buildSlotSnapshot(e)}buildSlotSnapshot(e){let t=yl(this.getRenderedItems(),e),{element:n}=this.header,{element:r}=this.footer;if(t!=null||n!=null||r!=null)return{items:t,header:n,footer:r}}subscribeToScroll(e){return this.scrollListeners.add(e),()=>{this.scrollListeners.delete(e)}}getLocalTopForInstance(e){let t=this.instanceToItem.get(e);if(t==null)throw Error(`CodeView.getLocalTopForInstance: unknown virtualized instance`);return t.top}getTopForItem(e){let t=this.idToItem.get(e);if(t!=null)return t.top+this.getItemTopOffset()}createItem(e,t,n){let{itemMetricsCache:r}=this;if(e.type===`diff`){let i=new Ac(this.createDiffOptions(e.id),this,r,this.workerManager,this.isContainerManaged);return{type:`diff`,item:e,version:e.version,index:t,top:n,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:i}}let i=new dt(this.createFileOptions(e.id),this,r,this.workerManager,this.isContainerManaged);return{type:`file`,item:e,version:e.version,index:t,top:n,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:i}}applySelectedLines(e,t){let{selectedLines:n}=this;e==null&&n==null||e!=null&&n?.id===e.id&&Vn(n.range,e.range)||(n!=null&&n.id!==e?.id&&this.idToItem.get(n.id)?.instance.setSelectedLines(null,{notify:!1}),this.selectedLines=e,this.idToItem.get(e?.id??``)?.instance.setSelectedLines(e?.range??null,t))}syncSelection(){if(this.selectedLines==null)return;let e=this.idToItem.get(this.selectedLines.id);if(e==null){this.selectedLines=null,this.options.onSelectedLinesChange?.(null);return}e.instance.setSelectedLines(this.selectedLines.range,{notify:!1})}isItemInEditMode(e){return e.item.edit===!0&&e.item.collapsed!==!0}attachItemEditor(e){let{id:t}=e.item,{createEditor:n}=this.options;if(e.element==null||this.attachedEditors.has(t)||!this.isItemInEditMode(e))return;let r=this.itemEditors.get(t),i;try{if(r==null){ol(n);let r=Xc(e.instance.options);if(r==null)throw Error(`CodeView.attachItemEditor: instance options are missing their state`);let a=e=>{let t=this.idToItem.get(r.id);t!=null&&this.options.onItemEditChange?.(e,t.item)},o=this.options.getEditStateKey?.(e.item);if(e.type===`diff`){let s=n(`file-diff`,{onChange:a},o);i=s,this.itemEditors.set(t,{editor:s,state:r,dispose:s.edit(e.instance)})}else{let s=n(`file`,{onChange:a},o);i=s,this.itemEditors.set(t,{editor:s,state:r,dispose:s.edit(e.instance)})}}else r.dispose=(e.type,r.editor.edit(e.instance));this.attachedEditors.add(t)}catch(t){throw i?.cleanUp(),this.releaseRenderedItem(e),t}}syncItemEditors(e){if(this.itemEditors.size===0)return;let t=[];for(let[n,r]of this.itemEditors){let i=this.idToItem.get(n),a=e?.get(n);if(a==null&&i!=null){let{edit:e=!1,collapsed:t=!1}=i.item;if(e){t&&this.attachedEditors.delete(n)&&r.editor.cleanUp(`recycle`);continue}}else a!=null&&(r.state.removedItem=a.item);this.itemEditors.delete(n),this.attachedEditors.delete(n),t.push(r)}if(t.length===0)return;let n=!1,r;for(let e of t){try{e.dispose()}catch(e){n||(n=!0,r=e)}let t=this.idToItem.get(e.state.id);t!=null&&this.markItemLayoutDirty(t)}if(this.render(),n)throw r}requireItemFromState(e){let t=this.idToItem.get(e.id)?.item??e.removedItem;if(t==null)throw Error(`CodeView.onItemEditComplete: unknown item "${e.id}"`);return t}completeFileItemEdit(e,t){let n=this.requireItemFromState(e);if(n.type!==`file`)throw Error(`CodeView.onItemEditComplete: item "${e.id}" is not a file item`);let r={...n,file:t.file,annotations:t.lineAnnotations,edit:!1,version:(n.version??0)+1};return(this.options.onItemEditComplete?.(t,n,r)??`reject`)===`reject`?`reject`:(this.idToItem.has(n.id)&&this.updateItem(r),`accept`)}completeDiffItemEdit(e,t){let n=this.requireItemFromState(e);if(n.type!==`diff`)throw Error(`CodeView.onItemEditComplete: item "${e.id}" is not a diff item`);let r={...n,fileDiff:t.fileDiff,annotations:t.lineAnnotations,edit:!1,version:(n.version??0)+1};return(this.options.onItemEditComplete?.(t,n,r)??`reject`)===`reject`?`reject`:(this.idToItem.has(n.id)&&this.updateItem(r),`accept`)}renamePendingScrollTarget(e,t){let{pendingScrollTarget:n}=this;n!=null&&n.type!==`position`&&n.id===e&&(this.pendingScrollTarget={...n,id:t})}renamePendingLayoutAnchor(e,t){this.pendingLayoutAnchor?.id===e&&(this.pendingLayoutAnchor.id=t)}createFileOptionsPrototype(){let e={};for(let t of Gc)Zc(e,t,()=>this.options[t]);Zc(e,`stickyHeader`,()=>this.options.stickyHeaders),Zc(e,`collapsed`,e=>{let t=Xc(e);if(t!=null)return this.getItemOptions(t,`file`)?.item.collapsed}),Zc(e,`onEditComplete`,e=>{if(this.options.onItemEditComplete==null)return;let t=Xc(e);if(t!=null)return e=>this.completeFileItemEdit(t,e)});for(let t of Kc)this.defineItemSharedCallback(e,`file`,t);for(let t of qc)this.defineItemSelectionCallback(e,`file`,t);return e}createDiffOptionsPrototype(){let e={};for(let t of Wc)Zc(e,t,()=>this.options[t]);Zc(e,`stickyHeader`,()=>this.options.stickyHeaders),Zc(e,`hunkSeparators`,()=>this.options.hunkSeparators),Zc(e,`collapsed`,e=>{let t=Xc(e);if(t!=null)return this.getItemOptions(t,`diff`)?.item.collapsed}),Zc(e,`onEditComplete`,e=>{if(this.options.onItemEditComplete==null)return;let t=Xc(e);if(t!=null)return e=>this.completeDiffItemEdit(t,e)});for(let t of Kc)this.defineItemSharedCallback(e,`diff`,t);for(let t of qc)this.defineItemSelectionCallback(e,`diff`,t);return e}createFileOptions(e){let t=Object.create(this.fileOptionsPrototype);return Yc(t,{id:e}),t}createDiffOptions(e){let t=Object.create(this.diffOptionsPrototype);return Yc(t,{id:e}),t}updateItemOptionsId(e,t){let n=Xc(e);if(n==null)throw Error(`CodeView.updateItemOptionsId: No valid state`);n.id=t}getItemOptions(e,t){let n=this.idToItem.get(e.id);if(n!=null&&n.type===t)return n}defineItemSharedCallback(e,t,n){Zc(e,n,e=>{if(this.options[n]==null)return;let r=Xc(e);if(r==null)return;let i=r.callbackCache??={},a=i[n];return a??(a=((...e)=>{let i=this.getItemOptions(r,t);if(i==null)return;let a=this.options[n];return a?.(...e,i)}),i[n]=a),a})}defineItemSelectionCallback(e,t,n){Zc(e,n,e=>{let r=Xc(e);if(r==null)return;let i=r.callbackCache??={},a=i[n];return a??(a=e=>{let i=this.getItemOptions(r,t);if(i==null)return;let a=e==null?null:{id:i.item.id,range:e};this.options.controlledSelection!==!0&&(e!=null||this.selectedLines?.id===i.item.id)&&this.applySelectedLines(a,{notify:!1}),this.options.onSelectedLinesChange?.(a);let o=this.options[n];return o?.(e,i)},i[n]=a),a})}markLayoutDirtyFromIndex(e){this.layoutDirtyIndex=Math.min(this.layoutDirtyIndex??e,e)}markItemLayoutDirty(e){if(this.items[e.index]!==e)throw Error(`CodeView.markItemLayoutDirty: unknown item id "${e.item.id}"`);this.markLayoutDirtyFromIndex(e.index)}tryAppendItems(e){if(e.length<=this.items.length)return!1;for(let t=0;t<this.items.length;t++){let n=this.items[t];if(n==null)throw Error(`CodeView.tryAppendItems: missing existing item`);let r=e[t];if(r==null||n.item.id!==r.id||n.type!==r.type)return!1}for(let t=0;t<this.items.length;t++){let n=this.items[t];if(n==null)throw Error(`CodeView.tryAppendItems: missing existing item`);let r=e[t];if(r==null)throw Error(`CodeView.tryAppendItems: append candidate missing prefix item`);this.syncItemRecord(n,r)&&this.markLayoutDirtyFromIndex(t)}return this.appendItemsInternal(e.slice(this.items.length),!1),this.scrollDirty=!0,this.render(),!0}reconcileItems(e){let{items:t,idToItem:n}=this,r=new Set(t),i=[],a=new Map,o=new Map,s=new Map,c;for(let s=0;s<e.length;s++){let l=e[s];if(l==null)throw Error(`CodeView.reconcileItems: missing input item`);if(a.has(l.id))throw Error(`CodeView.setItems: duplicate id "${l.id}"`);let u=n.get(l.id),d=u!=null&&u.type===l.type?u:this.createItem(l,s,0);d.index=s,u!=null&&u.type===l.type?(r.delete(u),this.syncItemRecord(d,l)&&(c=Math.min(c??s,s))):c=Math.min(c??s,s),t[s]!==d&&(c=Math.min(c??s,s)),i.push(d),a.set(l.id,d),o.set(d.instance,d)}if(c==null){if(r.size===0)return;c=Math.max(i.length-1,0)}this.capturePendingLayoutAnchor(a);for(let e=0;e<t.length;e++){let n=t[e];if(n==null||!r.has(n))continue;s.set(n.item.id,n),this.releaseRenderedItem(n);let a=Math.max(i.length-1,0);c=Math.min(c??a,a)}return this.items=i,this.idToItem=a,this.instanceToItem=o,this.renderState.firstIndex>=i.length?this.resetRenderState():this.renderState.lastIndex>=i.length&&(this.renderState.lastIndex=i.length-1),this.markLayoutDirtyFromIndex(c),this.scrollDirty=!0,this.render(),s.size>0?s:void 0}syncItemRecord(e,t){if(e.type!==t.type)throw Error(`CodeView.syncItemRecord: type mismatch for id "${t.id}"`);return e.version!==t.version&&(e.item=t,e.version=t.version,e.renderedOptionsRevision=-1,!0)}getMaxScrollTopForHeight(e){let{paddingBottom:t,paddingTop:n}=this.getLayout();return Math.max(n+this.header.height+e+this.footer.height+t-this.getHeight(),0)}getMaxScrollTop(){return this.getMaxScrollTopForHeight(this.getScrollHeight())}shouldRebaseScroll(){return this.getMaxScrollTop()>al}getPagedScrollHeight(){return this.shouldRebaseScroll()?Math.min(this.getScrollHeight(),tl):this.getScrollHeight()}getMaxPagedScrollTop(){return this.getMaxScrollTopForHeight(this.getPagedScrollHeight())}clampPagedScrollTop(e){let t=this.getMaxPagedScrollTop();return Math.max(0,Math.min(e,t))}clampScrollTop(e){let t=this.getMaxScrollTop();return Math.max(0,Math.min(e,t))}getMaxScrollPageOffset(){return Math.max(this.getMaxScrollTop()-this.getMaxPagedScrollTop(),0)}clampScrollPageOffset(e){let t=this.getMaxScrollPageOffset();return Math.max(0,Math.min(e,t))}resolveScrollPageWindow(e,t){let n=Ao(this.clampPagedScrollTop(t)),r=this.clampScrollPageOffset(e-n);return n=Ao(this.clampPagedScrollTop(e-r)),r=this.clampScrollPageOffset(e-n),{pagedScrollTop:n,scrollPageOffset:r}}resolvePagedScrollPosition(e){if(!this.shouldRebaseScroll())return{pagedScrollTop:this.clampPagedScrollTop(e),scrollPageOffset:0};let t=this.clampScrollPageOffset(this.scrollPageOffset),n=e-t,r=this.getMaxPagedScrollTop(),i=this.getMaxScrollPageOffset(),a=n>al&&t<i,o=n<nl&&t>0;return n<0||n>r||a||o?this.resolveScrollPageWindow(e,o?Math.min(il,r):rl):{pagedScrollTop:Ao(this.clampPagedScrollTop(n)),scrollPageOffset:t}}needsScrollPageUpdate(e){let t=Ao(this.clampScrollTop(e)),{scrollPageOffset:n}=this.resolvePagedScrollPosition(t);return n!==this.scrollPageOffset}getPagedLayoutTop(e){return this.shouldRebaseScroll()?Math.max(e-this.scrollPageOffset,0):e}getStickyHeaderOffset(){return this.options.stickyHeaders===!0&&this.options.disableFileHeader!==!0?this.itemMetricsCache.diffHeaderHeight:0}getScrollTargetRect(e){let t=this.idToItem.get(e.id);if(t==null){console.warn(`CodeView.scrollTo: unknown item id "${e.id}"`);return}if(e.type===`item`)return{top:t.top,height:t.height};if(e.type===`range`){let n=this.getRangeScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve range ${ml(e.range)} for item "${e.id}"`);return}return{top:t.top+n.top,height:n.height}}let n=this.getLineScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve line ${e.lineNumber} for item "${e.id}"`);return}return{top:t.top+n.top,height:n.height}}normalizeScrollTarget(e){if(e.type===`position`||e.align!==`nearest`)return e;let t=this.getScrollTargetRect(e);if(t==null)return;let n=e.offset??0,r=this.getItemTopOffset()+t.top,i=r+t.height,a=this.getScrollTop(),o=a+(e.type===`line`||e.type===`range`?this.getStickyHeaderOffset():0),s=a+this.getHeight();if(!(r-n<=o&&i+n>=s)){if(r-n<o)return{...e,align:`start`};if(i+n>s)return{...e,align:`end`}}}resolveScrollTargetTop(e){if(e.type===`position`){let t=this.clampScrollTop(e.position);return t===e.position?this.clampScrollTop(e.position-this.getStickyHeaderOffset()):t}let t=this.idToItem.get(e.id);if(t==null){console.warn(`CodeView.scrollTo: unknown item id "${e.id}"`);return}if(e.type===`item`)return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top,t.height,e.align,e.offset));if(e.type===`range`){let n=this.getRangeScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve range ${ml(e.range)} for item "${e.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top+n.top,n.height,e.align,e.offset,this.getStickyHeaderOffset()))}let n=this.getLineScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve line ${e.lineNumber} for item "${e.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top+n.top,n.height,e.align,e.offset,this.getStickyHeaderOffset()))}resolveAlignedScrollPosition(e,t,n,r=0,i=0){e+=this.getItemTopOffset();let a=this.getHeight();return n===`center`&&t+r<a?e-(a-t)/2+r:n===`end`?e-(a-t)+r:e-i-r}getLineScrollPosition(e,t){return e.type===`diff`?e.instance.getLinePosition(t.lineNumber,t.side):e.instance.getLinePosition(t.lineNumber)}getRangeScrollPosition(e,t){let{range:n}=t,r=this.getLineScrollPosition(e,{type:`line`,id:t.id,lineNumber:n.start,side:n.side}),i=this.getLineScrollPosition(e,{type:`line`,id:t.id,lineNumber:n.end,side:n.endSide??n.side});if(r==null||i==null)return;let a=r.top,o=a+r.height,s=i.top,c=s+i.height,l=Math.min(a,s);return{top:l,height:Math.max(o,c)-l}}computeTargetScrollTopForFrame(e,t){if(this.pendingScrollTarget==null)return e;let n=this.resolveScrollTargetTop(this.pendingScrollTarget);if(n==null)return e;let{scrollAnimation:r}=this;return r==null?n:this.computeSpringStep(r,n,t).position}computeSpringStep(e,t,n){let r=Math.max(0,n-e.lastTimestamp),{omega:i}=this.getSmoothScrollSettings(),a=Math.exp(-i*r),o=e.position-t,s=e.velocity+i*o;return{position:t+(o+s*r)*a,velocity:(s*(1-i*r)-i*o)*a}}advanceScrollAnimation(e,t){if(this.pendingScrollTarget==null)return;let n=this.resolveScrollTargetTop(this.pendingScrollTarget);if(n==null){this.pendingScrollTarget=void 0,this.scrollAnimation=void 0;return}let r=this.scrollAnimation;if(r==null)return n;r.position+=t;let{position:i,velocity:a}=this.computeSpringStep(r,n,e);r.lastTimestamp=e,r.position=i,r.velocity=a;let{positionEpsilon:o,velocityEpsilon:s}=this.getSmoothScrollSettings();return Math.abs(n-i)<=o&&Math.abs(a)<=s?(r.position=n,r.velocity=0,this.scrollAnimation=void 0,n):r.position}computeRenderRangeAndEmit=(t=performance.now())=>{if(e.__STOP||this.container==null||!this.isReady())return;let n=this.getHeight(),r=this.getScrollTop(),i=r,a=this.pendingLayoutAnchor!=null,o=this.getScrollAnchor(i);if(this.layoutDirtyIndex!=null&&(this.recomputeLayout(this.layoutDirtyIndex,this.pendingLayoutReset),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,a=!0),a&&o!=null){let e=this.resolveAnchoredScrollTop(o);if(e!=null){let t=e-i;i=e,this.scrollAnimation!=null&&(this.scrollAnimation.position+=t)}}a&&(i=this.clampScrollTop(i),this.syncContainerHeight());let s=this.computeTargetScrollTopForFrame(i,t),c=!a&&(this.renderState.scrollTop===-1||Math.abs(s-this.renderState.scrollTop)>n+this.config.overscrollSize*2);c&&(o=void 0),this.windowSpecs=Jn({scrollTop:s-this.header.height,height:n,scrollHeight:this.getScrollHeight(),fitPerfectly:c,fitPerfectlyOverscroll:this.getFitPerfectlyOverscroll(),overscrollSize:this.config.overscrollSize});let l=r;(this.pendingScrollTarget!=null&&s!==l||this.needsScrollPageUpdate(s))&&(this.applyScrollFix(s,l,this.windowSpecs),l=s);let{top:u,bottom:d}=this.windowSpecs,{firstIndex:f,lastIndex:p}=this.renderState;if(f>=0)for(let e=f;e<=p;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.computeRenderRangeAndEmit: No item at index: ${e}`);t.top>u-t.height&&t.top<=d||this.releaseRenderedItem(t)}let m=this.reconcileHeaderFooterHosts(),h,g=new Set,_=this.findFirstVisibleIndex(u),v=this.findLastVisibleIndex(d);for(let e=_;e<=v;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.computeRenderRangeAndEmit: missing item`);let{instance:n}=t;t.element==null?(t.element=this.acquireElement(),_l(this.stickyContainer,t.element,h),n.virtualizedSetup(),gl(t,t.element)&&(t.renderedOptionsRevision=this.renderOptionsRevision,g.add(t)),h=t.element):(_l(this.stickyContainer,t.element,h),gl(t,void 0,t.renderedOptionsRevision!==this.renderOptionsRevision)&&(t.renderedOptionsRevision=this.renderOptionsRevision,g.add(t)),h=t.element),t.item.edit===!0&&this.attachItemEditor(t)}this.renderState.firstIndex=_<=v?_:-1,this.renderState.lastIndex=v,this.flushSlotCoordinator(),this.flushManagers(g),m&&this.measureMountedHosts(),this.reconcileRenderedItems(g),this.syncContainerHeight(),this.updateStickyPositioning();let y=o==null?void 0:this.resolveAnchoredScrollTop(o);o===this.pendingLayoutAnchor&&(this.pendingLayoutAnchor=void 0);let b=y==null?0:y-i,x=s,S=!1;if(this.pendingScrollTarget!=null){let e=this.advanceScrollAnimation(t,b);e==null?x=i:(x=e,S=!0)}else x=y??s;x!==l&&(this.applyScrollFix(x,l,this.windowSpecs),l=x),S&&this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),this.renderState.scrollTop=Ao(l),this.updateStickyPositioning(),this.validateStickyContainerHeight(),this.fixContainerFocus(),(c||this.scrollAnimation!=null)&&this.render()};flushManagers(e){for(let t of e)t.instance.flushManagers()}syncContainerHeight(){let e=this.getPagedScrollHeight();this.container!=null&&this.containerHeight!==e&&(this.container.style.height=`${e}px`,this.containerHeight=e)}getStickyBounds(e){let{firstIndex:t,lastIndex:n}=e==null?this.renderState:{firstIndex:this.findFirstVisibleIndex(e.top),lastIndex:this.findLastVisibleIndex(e.bottom)};if(t===-1||n===-1||t>n)return;let r=this.items[t]?.instance.getAdvancedStickySpecs(e),i=this.items[n]?.instance.getAdvancedStickySpecs(e);if(r!=null&&i!=null)return{stickyTop:this.getPagedLayoutTop(Math.max(r.topOffset,0)),stickyBottom:this.getPagedLayoutTop(i.topOffset+i.height)}}applyStickyPositioning({stickyTop:e,stickyBottom:t}){let n=this.getHeight(),{itemMetricsCache:r}=this,i=t-e;this.renderState.stickyHeight=i,this.renderState.stickyTop=e,this.renderState.stickyBottom=t,this.stickyOffset.style.height=`${e}px`;let a=(Math.random()*r.lineHeight>>0)*-1,o=-Math.max(i+a,0)+n;this.stickyContainer.style.top=`${o}px`,this.stickyContainer.style.bottom=`${o+r.diffHeaderHeight}px`}syncPagedScrollScaffolding(e){this.syncContainerHeight();let t=this.getStickyBounds(e);if(t==null){this.stickyOffset.style.height=`${this.getPagedLayoutTop(e.top)}px`;return}this.applyStickyPositioning(t)}reconcileRenderedItems(e){let{firstIndex:t,lastIndex:n}=this.renderState;if(t===-1)return;let r=-1,i=!1;for(let a=t;a<this.items.length&&!(!i&&a>n);a++){let t=this.items[a];if(t==null)throw Error(`CodeView.reconcileRenderedItems: Invalid item`);r===-1?r=t.top:t.top!==r&&(t.top=r,t.instance.syncVirtualizedTop(),i=!0),(e==null?a<=n:e.has(t))&&(t.instance.reconcileHeights()&&(i=!0,t.height=t.instance.getVirtualizedHeight()),this.validateRenderedItemHeight(t)),r+=t.instance.getVirtualizedHeight(),a<this.items.length-1&&(r+=this.getLayout().gap)}i&&r!=null&&(this.scrollDirty=!0,this.scrollHeight=r)}updateStickyPositioning(){let e=this.getStickyBounds();if(e==null){this.renderState.firstIndex===-1&&(this.stickyOffset.style.height=``);return}let{stickyTop:t,stickyBottom:n}=e;(n-t!==this.renderState.stickyHeight||t!==this.renderState.stickyTop||n!==this.renderState.stickyBottom)&&this.applyStickyPositioning(e)}handleScroll=()=>{e.__STOP||(this.suspendScrollInteractions(),this.scrollDirty=!0,this.notifyScroll(),this.render())};clearPendingScroll=()=>{this.pendingScrollTarget=void 0,this.pendingLayoutAnchor=void 0,this.scrollAnimation=void 0};handleResize=e=>{let t=!1;for(let n of e)if(n.target===this.stickyContainer){let e=n.borderBoxSize[0].blockSize;if(Math.abs(e-this.renderState.stickyHeight)>=$c){let e=this.getScrollTop(),n=this.getScrollAnchor(e);this.reconcileRenderedItems(),this.updateStickyPositioning();let r=n==null?void 0:this.resolveAnchoredScrollTop(n);if(r!=null){let t=r-e;this.applyScrollFix(r,e,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=t)}this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),t=!0}}else if(n.target===this.header.element||n.target===this.footer.element){let e=n.target===this.header.element?this.header:this.footer,r=n.borderBoxSize[0].blockSize;if(r!==e.height){let n=this.getScrollTop(),i=this.getScrollAnchor(n);this.setHostHeight(e,r);let a=i==null?void 0:this.resolveAnchoredScrollTop(i);if(a!=null){let e=a-n;this.applyScrollFix(a,n,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=e)}this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),t=!0}}else this.scrollDirty=!0,this.heightDirty=!0,t=!0;t&&this.render(!0)};getScrollAnchorViewportTop(e,t){return e<t?t+this.getStickyHeaderOffset():t}getScrollAnchor(e,t=this.idToItem){let n,{pendingLayoutAnchor:r}=this;if(r!=null){let e=this.idToItem.get(r.id);if(e!=null&&t.get(r.id)===e)return r;e!=null&&(n=e)}if(e<=0)return;let{firstIndex:i,lastIndex:a,stickyTop:o,stickyBottom:s}=this.renderState;if(i===-1||a===-1)return;let c=this.getHeight();if(o!==-1&&s!==-1){for(let r=i;r<=a;r++){let i=this.items[r];if(i==null)continue;let a=this.getItemTopOffset()+i.top;if(a+i.height<=e)continue;if(a>=e+c)break;if(t.get(i.item.id)!==i){n??=i;continue}if(a>=e)return{type:`item`,id:i.item.id,viewportOffset:a-e};let o=this.getScrollAnchorViewportTop(a,e)-a,s=i.instance.getNumericScrollAnchor(o);if(s!=null){let t=a+s.top;return{type:`line`,id:i.item.id,lineNumber:s.lineNumber,side:s.side,viewportOffset:t-e}}}if(n!=null)for(let e=n.index+1;e<this.items.length;e++){let n=this.items[e];if(n!=null&&t.get(n.item.id)===n)return{type:`item`,id:n.item.id,viewportOffset:0}}}}resolveAnchoredScrollTop(e){let t=this.idToItem.get(e.id);if(t==null)return;let n=this.getItemTopOffset();if(e.type===`item`){let r=n+t.top;return this.clampScrollTop(r-e.viewportOffset)}let r=t.type===`diff`?t.instance.getLinePosition(e.lineNumber,e.side):t.instance.getLinePosition(e.lineNumber);if(r==null)return;let i=n+t.top+r.top;return this.clampScrollTop(i-e.viewportOffset)}applyScrollFix(e,t,n){if(this.root==null)return;let r=Ao(this.clampScrollTop(e)),i=Ao(t),{scrollPageOffset:a}=this,o=Ao(this.clampPagedScrollTop(i-a)),{pagedScrollTop:s,scrollPageOffset:c}=this.resolvePagedScrollPosition(r),l=s,u=a!==c;(r!==this.renderState.scrollTop||r!==i||l!==o||u)&&(this.suspendScrollInteractions(),(l!==o||u)&&(this.scrollPageOffset=c,this.syncPagedScrollScaffolding(n)),l!==o&&this.root.scrollTo({top:l,behavior:`instant`}),this.renderState.scrollTop=r,this.scrollTop=r,this.scrollDirty=!1)}isPendingTargetSettled(e){let t=this.resolveScrollTargetTop(e);return t==null||Ao(this.getScrollTop())===Ao(t)}getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root?.scrollTop??0;return this.scrollTop=this.clampScrollTop(e+this.scrollPageOffset),this.scrollTop}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root?.getBoundingClientRect().height??0,this.height):this.height}getScrollHeight(){return this.scrollHeight}flushSlotCoordinator(){if(this.slotCoordinator==null)return;let e=this.buildSlotSnapshot(this.slotCoordinator);Eo(this.slotSnapshot,e)||(this.slotSnapshot=e,this.slotCoordinator.onSnapshotChange(e))}notifyScroll(){if(this.scrollListeners.size===0)return;let e=this.getScrollTop();for(let t of this.scrollListeners)t(e,this)}findFirstVisibleIndex(e){let t=0,n=this.items.length-1,r=this.items.length;for(;t<=n;){let i=t+n>>1,a=this.items[i];if(a==null)throw Error(`CodeView.findFirstVisibleIndex: invalid item index`);a.top+a.height>e?(r=i,n=i-1):t=i+1}return r}findLastVisibleIndex(e){let t=0,n=this.items.length-1,r=-1;for(;t<=n;){let i=t+n>>1,a=this.items[i];if(a==null)throw Error(`CodeView.findLastVisibleIndex: invalid item index`);a.top<=e?(r=i,t=i+1):n=i-1}return r}recomputeLayout(e=0,t){if(this.items.length===0){this.scrollHeight=0;return}let n=this.getLayout(),r=0;if(e>0){let t=this.items[e-1];if(t==null)throw Error(`CodeView.recomputeLayout: invalid dirty index`);r=t.top+t.height+n.gap}for(let i=e;i<this.items.length;i++){let e=this.items[i];if(e==null)throw Error(`CodeView.recomputeLayout: invalid item index`);e.top=r,e.height=e.type===`diff`?e.instance.updateCodeViewLayout(e.item.fileDiff,r,t,e.item.annotations??[]):e.instance.updateCodeViewLayout(e.item.file,r,t,e.item.annotations??[]),r+=e.height,i<this.items.length-1&&(r+=n.gap)}r!==this.scrollHeight&&(this.scrollDirty=!0),this.scrollHeight=r}resetRenderState(){this.renderState.scrollTop=-1,this.renderState.firstIndex=-1,this.renderState.lastIndex=-1,this.renderState.stickyHeight=0,this.renderState.stickyTop=-1,this.renderState.stickyBottom=-1}getFitPerfectlyOverscroll(){return this.getLayout().gap+this.itemMetricsCache.diffHeaderHeight}};function ll(e){return e.instance.cleanUp(!0),e.type===`diff`?e.instance.updateCodeViewLayout(e.item.fileDiff,e.top,void 0,e.item.annotations??[]):e.instance.updateCodeViewLayout(e.item.file,e.top,void 0,e.item.annotations??[])}function ul(e,t){return!cn(e.theme??qt,t.theme??qt)||(e.themeType??`system`)!==(t.themeType??`system`)||e.unsafeCSS!==t.unsafeCSS}function dl(e,t){return(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS||(e.diffStyle??`split`)!==(t.diffStyle??`split`)||(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)}function fl(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 pl(e){return e instanceof SVGElement||wn(e)&&(e.hasAttribute(`data-core-css`)||e.hasAttribute(`data-theme-css`)||e.hasAttribute(`data-unsafe-css`))}function ml(e){let t=hl(e.start,e.side),n=hl(e.end,e.endSide??e.side);return t===n?t:`${t}-${n}`}function hl(e,t){return t==null?`${e}`:`${t===`deletions`?`D`:`A`}${e}`}function gl(e,t,n=!1){return e.type===`diff`?e.instance.render({deferManagers:!0,fileContainer:t,fileDiff:e.item.fileDiff,forceRender:n,lineAnnotations:e.item.annotations??[]}):e.instance.render({deferManagers:!0,fileContainer:t,file:e.item.file,forceRender:n,lineAnnotations:e.item.annotations??[]})}function _l(e,t,n){if(n==null){e.firstChild!==t&&e.prepend(t);return}n.nextSibling!==t&&n.after(t)}function vl(e){return(e.annotations?.length??0)>0}function yl(e,{hasHeaderRenderers:t,hasAnnotationRenderer:n,hasGutterRenderer:r}){if(e.length===0)return;if(t||r)return e;if(!n)return;let i=[];for(let t of e)vl(t.item)&&i.push(t);return i.length>0?i:void 0}function bl(e,t){typeof e==`function`?e(t):e!=null&&(e.current=t)}var Q=e(ae(),1),xl=e(_e(),1),Sl=typeof window>`u`?Q.useEffect:Q.useLayoutEffect;function Cl(e){return{instance:void 0,items:void 0,controlled:e,managedOptions:void 0,disableFlushSync:!1,slotCoordinator:void 0}}function wl(e,t){let{className:n,containerRef:r,disableWorkerPool:i=!1,editorOptions:a,getEditStateKey:o,initialItems:s,items:c,onItemEditChange:l,onItemEditComplete:u,onScroll:d,onSelectedLinesChange:f,options:p,renderAnnotation:m,renderCodeViewFooter:h,renderCodeViewHeader:g,renderCustomHeader:_,renderGutterUtility:v,renderHeaderFilenameSuffix:y,renderHeaderMetadata:b,renderHeaderPrefix:x,selectedLines:S,style:C}=e,w=c!==void 0,T=Wt(),E=(0,Q.useContext)(hr),D=(0,Q.useRef)(Cl(w)),O=_!=null,k=m!=null,A=v!=null,j=O||x!=null||y!=null||b!=null,M=j||k||A,N=g!=null,P=h!=null,F=gr(e=>{f?.(e)}),I=S!==void 0,L=gr((e,t,n)=>{if(T==null)throw Error(`CodeView: EditContext is not attached`);let r={...a,...t};return T(e,r,n)}),R=gr((e,t)=>{l?.(e,t)}),z=gr((e,t,n)=>u?.(e,t,n)??`reject`),B=(0,Q.useMemo)(()=>Al({options:p,hasCustomHeader:O,hasGutterRenderer:A,hasCodeViewHeader:N,hasCodeViewFooter:P,onSelectedLinesChange:f==null?void 0:F,controlledSelection:I,getEditStateKey:o,createEditor:T==null?void 0:L,onItemEditChange:l==null?void 0:R,onItemEditComplete:u==null?void 0:z}),[T,I,L,R,z,F,P,N,O,A,o,l,u,f,p]),[V]=(0,Q.useState)(()=>kl()),[,H]=(0,Q.useState)({}),U=gr(e=>{D.current.instance!=null&&(e==null||e!==D.current.instance.getContainerElement())&&(D.current.instance.cleanUp(),V.publish(void 0),D.current=Cl(w)),e!=null&&e!==D.current.instance?.getContainerElement()&&(D.current.instance=new cl(B,i?void 0:E,!0),D.current.instance.setup(e)),bl(r,e)}),W=gr(e=>{D.current.disableFlushSync?V.publish(e):(0,xl.flushSync)(()=>{V.publish(e)})}),G=(0,Q.useMemo)(()=>{if(j||k||A||N||P)return{hasHeaderRenderers:j,hasAnnotationRenderer:k,hasGutterRenderer:A,onSnapshotChange:W}},[W,k,A,j,N,P]);return Sl(()=>d==null?void 0:D.current.instance?.subscribeToScroll(d)),Sl(()=>{let{instance:e,controlled:t,items:n,managedOptions:r,slotCoordinator:i}=D.current;if(e!=null)try{D.current.disableFlushSync=!0;let a=!1;if(dn(B,r)||(D.current.managedOptions=B,e.setOptions(B),a=!0),t!==w){console.error(`CodeView: cannot switch between controlled and uncontrolled modes. Remount with a new key instead.`);return}if(w)c!==n&&(Dl(n,c)?D.current.items=c:El(n,c)?(D.current.items=c,e.addItems(c.slice(n.length))):(D.current.items=c,e.setItems(c),a=!0));else if(n==null){let t=s??[];D.current.items=t,t.length>0&&(e.setItems(t),a=!0)}S!==void 0&&e.setSelectedLines(S,{notify:!1});let o=e.setSlotCoordinator(G),l=!1;G!==i&&((G==null||i==null)&&(l=!0),D.current.slotCoordinator=G),(a||o)&&e.render(!0),o&&G==null&&V.publish(void 0),l&&H({})}finally{D.current.disableFlushSync=!1}}),(0,Q.useImperativeHandle)(t,()=>({addItems(e){let{controlled:t,instance:n}=D.current;Ol(t,`addItems`),n==null?console.error(`CodeView.addItems: no valid instance to append items with`,e):n.addItems(e)},getItem(e){let{instance:t}=D.current;if(t==null){console.error(`CodeView.getItem: no valid instance exists`,e);return}return t.getItem(e)},removeItem(e){let{controlled:t,instance:n}=D.current;return Ol(t,`removeItem`),n==null?(console.error(`CodeView.removeItem: no valid instance to remove item from`,e),!1):n.removeItem(e)},updateItem(e){let{controlled:t,instance:n}=D.current;return Ol(t,`updateItem`),n==null?(console.error(`CodeView.updateItem: no valid instance to update item with`,e),!1):n.updateItem(e)},updateItemId(e,t){let{controlled:n,instance:r}=D.current;return Ol(n,`updateItemId`),r==null?(console.error(`CodeView.updateItemId: no valid instance to update item id with`,e,t),!1):r.updateItemId(e,t)},scrollTo(e){let{instance:t}=D.current;t==null?console.error(`CodeView.scrollTo: no valid instance to scroll with`,e):t.scrollTo(e)},setSelectedLines(e){let{instance:t}=D.current;t==null?console.error(`CodeView.setSelectedLines: no valid instance to update selection with`,e):(t.setSelectedLines(e,{notify:!1}),F(e))},getSelectedLines(){let{instance:e}=D.current;return e==null?(console.error(`CodeView.getSelectedLines: no valid instance exists`),null):e.getSelectedLines()},clearSelectedLines(){let{instance:e}=D.current;e==null?console.error(`CodeView.clearSelectedLines: no valid instance to update selection with`):(e.clearSelectedLines({notify:!1}),F(null))},getEditor(e){let{instance:t}=D.current;if(t==null){console.error(`CodeView.getEditor: no valid instance exists`,e);return}return t.getEditor(e)},getInstance(){return D.current.instance}}),[F]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{ref:U,className:n,style:C}),(M||N||P)&&(0,Z.jsx)(jl,{managedContentStore:V,renderCustomHeader:_,renderHeaderPrefix:x,renderHeaderFilenameSuffix:y,renderHeaderMetadata:b,renderAnnotation:m,renderGutterUtility:v,renderCodeViewHeader:g,renderCodeViewFooter:h})]})}var Tl=(0,Q.forwardRef)(wl);function El(e,t){if(e==null||t.length<=e.length)return!1;if(e.length===0)return!0;for(let n=0;n<e.length;n++)if(t[n]!==e[n])return!1;return!0}function Dl(e,t){if(e==null||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Ol(e,t){if(e)throw Error(`CodeView.${t} cannot be used when CodeView is controlled. Use initialItems for imperative item updates.`)}function kl(){let e,t=new Set;return{getSnapshot(){return e},publish(n){if(!Eo(e,n)){e=n;for(let e of t)e()}},subscribe(e){return t.add(e),()=>{t.delete(e)}}}}function Al({options:e,hasCustomHeader:t,hasGutterRenderer:n,hasCodeViewHeader:r,hasCodeViewFooter:i,onSelectedLinesChange:a,controlledSelection:o,getEditStateKey:s,createEditor:c,onItemEditChange:l,onItemEditComplete:u}){let d={...e,controlledSelection:o,onSelectedLinesChange:a,createEditor:c};return s!=null&&(d.getEditStateKey=s),l!=null&&(d.onItemEditChange=l),u!=null&&(d.onItemEditComplete=u),t&&(d.renderCustomHeader=Nl),n&&(d.renderGutterUtility=Nl),r&&(d.renderCodeViewHeader=Nl),i&&(d.renderCodeViewFooter=Nl),d}var jl=(0,Q.memo)(function({managedContentStore:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,renderGutterUtility:o,renderCodeViewHeader:s,renderCodeViewFooter:c}){"use no memo";let l=gr(t=>e.subscribe(t)),u=gr(()=>e.getSnapshot()),d=(0,Q.useSyncExternalStore)(l,u,u),f=``;for(let e of d?.items??[])f+=`${e.id}:${e.version}:${e.type}`;let p=(0,Q.useMemo)(()=>d?.items?.map(e=>(0,xl.createPortal)(Ml({renderedItem:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,renderGutterUtility:o}),e.element,e.id)),[t,n,r,i,a,o,f]),m=(0,Q.useMemo)(()=>s!=null&&d?.header!=null?(0,xl.createPortal)(s(),d.header):null,[s,d?.header]),h=(0,Q.useMemo)(()=>c!=null&&d?.footer!=null?(0,xl.createPortal)(c(),d.footer):null,[c,d?.footer]);return(0,Z.jsxs)(Z.Fragment,{children:[p,m,h]})});function Ml({renderedItem:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,renderGutterUtility:o}){if(e.type===`diff`){let{item:s,instance:c}=e;return wo({fileDiff:s.fileDiff,renderCustomHeader:t==null?void 0:()=>t(s),renderHeaderPrefix:n==null?void 0:()=>n(s),renderHeaderFilenameSuffix:r==null?void 0:()=>r(s),renderHeaderMetadata:i==null?void 0:()=>i(s),renderAnnotation:a==null?void 0:e=>a(e,s),lineAnnotations:s.annotations,renderGutterUtility:o==null?void 0:e=>o(e,s),getHoveredLine:c.getHoveredLine,getAnnotationSlotName:c.getAnnotationSlotName})}{let{item:s,instance:c}=e;return gn({file:s.file,renderCustomHeader:t==null?void 0:()=>t(s),renderHeaderPrefix:n==null?void 0:()=>n(s),renderHeaderFilenameSuffix:r==null?void 0:()=>r(s),renderHeaderMetadata:i==null?void 0:()=>i(s),renderAnnotation:a==null?void 0:e=>a(e,s),lineAnnotations:s.annotations,renderGutterUtility:o==null?void 0:e=>o(e,s),getHoveredLine:c.getHoveredLine,getAnnotationSlotName:c.getAnnotationSlotName})}}function Nl(){}function Pl(e){return[...new Set([e.oldPath,e.newPath].filter(e=>e!=null))]}function Fl(e){return e.startsWith(`refs/heads/`)?e.slice(11):e.startsWith(`refs/remotes/`)?e.slice(13):e}function Il(e){return e.mergeBaseOid===null||e.mergeBaseOid===void 0?null:{baseOid:e.mergeBaseOid,headOid:e.head.oid}}function Ll(e){return e instanceof Error&&(e.name===`RequestError`||e.name===`ConnectionError`)?e.message:`The branch could not be compared. Try again.`}var Rl={kind:`handoff`},zl={kind:`all-changes`},Bl={kind:`specs`},Vl={kind:`branch`},Hl={kind:`proof`},Ul={kind:`graph`};function Wl(e){switch(e.kind){case`handoff`:return`handoff`;case`all-changes`:return`all-changes`;case`specs`:return`specs`;case`proof`:return`proof`;case`change`:return`change:${e.path}`;case`file`:return`file:${e.path}`;case`commit`:return`commit:${e.oid}`;case`branch`:return`branch`;case`branch-file`:return`branch:${e.path}`;case`graph`:return`graph`;case`timeline`:return`timeline:${e.path}`}}function Gl(e){if(e==null||e===``)return null;if(e===`handoff`)return Rl;if(e===`all-changes`)return zl;if(e===`specs`)return Bl;if(e===`proof`)return Hl;if(e===`branch`)return Vl;if(e===`graph`)return Ul;let t=e.indexOf(`:`);if(t<=0)return null;let n=e.slice(0,t),r=e.slice(t+1);if(r===``)return null;switch(n){case`change`:case`file`:case`timeline`:return{kind:n,path:r};case`branch`:return{kind:`branch-file`,path:r};case`commit`:return/^[0-9a-f]{4,64}$/.test(r)?{kind:n,oid:r}:null;default:return null}}function Kl(e,t,n){if(e.includes(t))return[...e];let r=n==null?-1:e.indexOf(n),i=[...e];return i.splice(r===-1?i.length:r+1,0,t),i}var ql={changes:`Changes`,files:`Files`,history:`History`};function Jl(e){switch(e.kind){case`handoff`:return`Changes`;case`all-changes`:return`All changes`;case`specs`:return`Specs`;case`proof`:return`Proof`;case`branch`:return`Branch changes`;case`graph`:return`Commit graph`;case`commit`:return e.oid.slice(0,7);case`change`:case`file`:case`branch-file`:return e.path.split(`/`).at(-1)??e.path;case`timeline`:return`Timeline of ${e.path.split(`/`).at(-1)??e.path}`}}function Yl(e){let t=Gl(e.entry),n=t?Jl(t):ql[e.surface??`files`],r=e.project?`${n} — ${e.project}`:n;return e.environment?`${r} · ${e.environment}`:r}var Xl=()=>({tabs:[],pinned:[]});function Zl(e){return[...e.pinned.filter(t=>e.tabs.includes(t)),...e.tabs.filter(t=>!e.pinned.includes(t))]}function Ql(e,t,n){return e.tabs.includes(t)?e:{...e,tabs:Kl(e.tabs,t,n)}}function $l(e,t){return{tabs:e.tabs.filter(e=>e!==t),pinned:e.pinned.filter(e=>e!==t)}}function eu(e,t){return{...e,tabs:e.tabs.filter(n=>n===t||e.pinned.includes(n))}}function tu(e){return{...e,tabs:e.tabs.filter(t=>e.pinned.includes(t))}}function nu(e,t){return e.pinned.includes(t)?{...e,pinned:e.pinned.filter(e=>e!==t)}:{...e,pinned:[...e.pinned,t]}}function ru(e,t,n){let r=Zl(e),i=new Set(Zl(n)),a=r.indexOf(t);return a===-1?null:[...r.slice(a+1),...r.slice(0,a).reverse()].find(e=>i.has(e))??null}function iu(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function au(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&(Gl(e)??null)!==null):[]}function ou(e){if(!iu(e)||!Array.isArray(e.panes))return null;let t=e.panes.map(e=>{let t=au(iu(e)?e.tabs:void 0);return{tabs:t,pinned:au(iu(e)?e.pinned:void 0).filter(e=>t.includes(e))}}).filter((e,t)=>t===0||e.tabs.length>0);return t.length>0?t:null}var $=J();function su(e){let t=(0,$.c)(4),{children:n}=e,r,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={poolSize:4,workerFactory:cu},i={theme:Kt},t[0]=r,t[1]=i):(r=t[0],i=t[1]);let a;return t[2]===n?a=t[3]:(a=(0,Z.jsx)(hn,{poolOptions:r,highlighterOptions:i,children:n}),t[2]=n,t[3]=a),a}function cu(){return new Worker(new URL(`/assets/worker-Bs0l0ezO.js`,``+import.meta.url),{type:`module`})}var lu=`(min-width: 1280px)`;function uu(){let e=(0,$.c)(2),[t,n]=(0,Q.useState)(du),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(lu),t=()=>n(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Q.useEffect)(r,i),t}function du(){return window.matchMedia(lu).matches}function fu(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function pu(e){return!e||typeof e!=`object`||!(`folded`in e)||!(`expanded`in e)?{folded:[],expanded:[]}:fu(e.folded)&&fu(e.expanded)?{folded:e.folded,expanded:e.expanded}:{folded:[],expanded:[]}}function mu(e,t,n=!1){return e.folded.includes(t)||n&&!e.expanded.includes(t)}function hu(e,t,n){let r=new Set(e.folded),i=new Set(e.expanded);for(let e of t)n?(r.add(e),i.delete(e)):(r.delete(e),i.add(e));return{folded:[...r],expanded:[...i]}}var gu=R(oe({saved:t})),_u=K.pipe(te(oe({panes:ve(j(oe({tabs:j(De),pinned:j(De)}))),saved:t}),{decode:F(e=>({panes:ou(e),saved:gu(e).pipe(ee(e=>e.saved),ce(()=>!0))})),encode:x()})),vu=K.pipe(te(oe({folded:j(De),expanded:j(De)}),{decode:F(pu),encode:x()})),yu=X(e=>T({runtime:or,key:`porcelain.tabs.${e}`,schema:_u,defaultValue:()=>({panes:null,saved:!1})})),bu=X(e=>T({runtime:or,key:e,schema:vu,defaultValue:()=>({folded:[],expanded:[]})}));function xu(e){let t=(0,$.c)(8),n;t[0]===e?n=t[1]:(n=yu(e),t[0]=e,t[1]=n);let r=n,{panes:i,saved:a}=xe(r),o=Te(r),s;t[2]===o?s=t[3]:(s=e=>o({panes:e,saved:!0}),t[2]=o,t[3]=s);let c;return t[4]!==i||t[5]!==a||t[6]!==s?(c={panes:i,saved:a,save:s},t[4]=i,t[5]=a,t[6]=s,t[7]=c):c=t[7],c}function Su(e,t){let n=(0,$.c)(7),r=`porcelain.folds.${e}.${t}`,i;n[0]===r?i=n[1]:(i=bu(r),n[0]=r,n[1]=i);let a=i,o=xe(a),s=Te(a),c;n[2]===s?c=n[3]:(c=(e,t)=>s(n=>hu(n,e,t)),n[2]=s,n[3]=c);let l;return n[4]!==c||n[5]!==o?(l={folds:o,setCollapsed:c},n[4]=c,n[5]=o,n[6]=l):l=n[6],l}var Cu=X(e=>T({runtime:or,key:`porcelain.walkthrough.${e}`,schema:De,defaultValue:()=>`briefing`})),wu=X(e=>O(`walkthrough`).pipe(w));function Tu(e){let t=(0,$.c)(12),n;t[0]===e?n=t[1]:(n=Cu(e),t[0]=e,t[1]=n);let r=n,i;t[2]===e?i=t[3]:(i=wu(e),t[2]=e,t[3]=i);let a=i,o=Te(r),s=Te(a),c=xe(r),l=xe(a),u;t[4]!==o||t[5]!==s?(u=e=>{o(e),s(`walkthrough`)},t[4]=o,t[5]=s,t[6]=u):u=t[6];let d;return t[7]!==s||t[8]!==c||t[9]!==l||t[10]!==u?(d={place:c,view:l,setView:s,setPlace:u},t[7]=s,t[8]=c,t[9]=l,t[10]=u,t[11]=d):d=t[11],d}function Eu(e){let t=(0,$.c)(19),{worktreeId:n,entry:r,side:i,onSearch:a,fallback:o,focused:s,setFocused:c}=e,{panes:l,saved:u,save:d}=xu(n),[f]=(0,Q.useState)(u),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=[void 0,void 0],t[0]=p):p=t[0];let[m,h]=(0,Q.useState)(p),g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=[null,null],t[1]=g):g=t[1];let[_,v]=(0,Q.useState)(g),y=(0,Q.useRef)(!1),b=[r!=null&&(Gl(r)??null)!==null?r:void 0,i!=null&&(Gl(i)??null)!==null?i:void 0],x,S;t[2]!==r||t[3]!==a||t[4]!==i?(x=()=>{r!=null&&(Gl(r)??null)===null&&a({entry:void 0},{replace:!0}),i!=null&&(Gl(i)??null)===null&&a({side:void 0},{replace:!0})},S=[r,i,a],t[2]=r,t[3]=a,t[4]=i,t[5]=x,t[6]=S):(x=t[5],S=t[6]),(0,Q.useEffect)(x,S);let C=e=>{let t=m[e];return t===void 0?b[e]:t??void 0},w=l??[o==null?Xl():{tabs:[o],pinned:[]}],T=[C(0)??(l==null?o:Zl(w[0]??Xl()).at(-1)??null),C(1)??(w[1]===null||w[1]===void 0?null:Zl(w[1]).at(-1)??null)],E=[Ql(w[0]??Xl(),T[0]??``,_[0])];(T[0]===null||T[0]===void 0)&&(E[0]=w[0]??Xl()),T[1]!==null&&T[1]!==void 0?E[1]=Ql(w[1]??Xl(),T[1],_[1]):w[1]?.tabs.length&&(E[1]=w[1]);let D=E.length>1;(0,Q.useEffect)(()=>{let e=m.map((e,t)=>e!==void 0&&(b[t]??null)===(e??null)?void 0:e);(e[0]!==m[0]||e[1]!==m[1])&&h([e[0],e[1]]),(_[0]!==T[0]||_[1]!==T[1])&&v(T),s===1&&!D&&c(0),(l==null||JSON.stringify(l)!==JSON.stringify(E))&&d(E)});let O;t[7]===a?O=t[8]:(O=e=>{h(t=>[`entry`in e?e.entry??null:t[0],`side`in e?e.side??null:t[1]]),a({...`entry`in e?{entry:e.entry??void 0}:{},...`side`in e?{side:e.side??void 0}:{}})},t[7]=a,t[8]=O);let k=O,A;t[9]===k?A=t[10]:(A=(e,t)=>k(e===0?{entry:t}:{side:t}),t[9]=k,t[10]=A);let j=A,M=(e,t)=>E.map((n,r)=>r===e?t:n),N=(e,t,n)=>{if(D&&t.tabs.length===0){let t=+(e===0);d([E[t]??Xl()]),c(0),k({entry:T[t],side:null});return}d(M(e,t)),n!==T[e]&&j(e,n)},P,F;return t[11]!==r||t[12]!==o||t[13]!==f||t[14]!==a||t[15]!==d||t[16]!==i?(P=()=>{o==null||y.current||f||r!=null||i!=null||(y.current=!0,d([{tabs:[o],pinned:[]}]),h(e=>[o,e[1]]),a({entry:o},{replace:!0}))},F=[r,o,f,a,i,d],t[11]=r,t[12]=o,t[13]=f,t[14]=a,t[15]=d,t[16]=i,t[17]=P,t[18]=F):(P=t[17],F=t[18]),(0,Q.useEffect)(P,F),{split:D,panes:E.map((e,t)=>({tabs:Zl(e),pinned:e.pinned,active:T[t]??null})),activate(e,t){c(e),j(e,t)},close(e,t){let n=E[e]??Xl(),r=$l(n,t);N(e,r,t===T[e]?ru(n,t,r):T[e])},closeOthers(e,t){N(e,eu(E[e]??Xl(),t),t)},closeUnpinned(e){let t=tu(E[e]??Xl()),n=T[e];N(e,t,n!=null&&t.tabs.includes(n)?n:Zl(t)[0]??null)},togglePin(e,t){d(M(e,nu(E[e]??Xl(),t)))},openToSide(e,t){let n=+(e===0),r=[...E];r[n]=Ql(E[n]??Xl(),t,T[n]),d(r),c(n),j(n,t)},step(e,t){let n=Zl(E[e]??Xl());if(n.length===0)return;let r=T[e]===null||T[e]===void 0?-1:n.indexOf(T[e]);j(e,n[(r+t+n.length)%n.length]??null)}}}function Du(e,t){let n=new Map(e.map(e=>[e.path,e])),r=[];for(let e of t){let t=n.get(e.path);t&&(r.push(t),n.delete(e.path))}return[...r,...n.values()]}function Ou(e,t){if(e.fingerprint===null||e.fingerprint===void 0)return`unreviewed`;let n=t.find(t=>t.path===e.path);return n?n.fingerprint===e.fingerprint?`reviewed`:`stale`:`unreviewed`}function ku(e,t){return t.find(t=>t.path===e.path)}function Au(e,t,n){let r=n==null?null:new Set(n);return e.changes.flatMap(n=>{if(r&&!r.has(n.path))return[];let i=ku(n,t.marks);return[{...n,environmentId:e.environmentId,worktreeId:e.worktreeId,statusToken:e.statusToken,reviewStatus:Ou(n,t.marks),...i?{mark:i}:{}}]})}function ju(e,t,n){let r=n==null?null:new Set(n);return e.flatMap(e=>{if(r&&!r.has(e.path))return[];let n=ku(e,t.marks);return[{...e,reviewStatus:Ou(e,t.marks),...n?{mark:n}:{}}]})}function Mu(e){return e instanceof Error&&(e.name===`ConnectionError`||e.name===`WriteNotSentError`)?e.message:`This review surface could not be loaded. Try again.`}function Nu(e){return e.fingerprint!==null&&e.fingerprint!==void 0}function Pu(e){return e.split(`/`).at(-1)??e}function Fu(e,t,n){let r=encodeURIComponent(e.token),i={expires:e.expires,signature:e.signature},a=new URL(t),o=n===void 0?void 0:new URL(n);return o!==void 0&&(a.protocol!==o.protocol||a.host!==o.host)?new URL(`/remote-review-summaries/${r}?${new URLSearchParams({computer:`${a.protocol}//${a.host}`,...i})}`,n).href:new URL(`/review-summaries/${r}?${new URLSearchParams(i)}`,t).href}function Iu(e){let t=(e,t)=>`${e} ${t}${e===1?``:`s`}`,n=e.filter(e=>e.binary!==!0),r=e.length-n.length,i=n.reduce((e,t)=>e+t.ranges.reduce((e,t)=>e+t.endLine-t.startLine+1,0),0),a=[...n.length>0?[`${t(i,`line`)} in ${t(n.length,`file`)}`]:[],...r>0?[t(r,`binary file`)]:[]];return a.length===0?null:a.join(` and `)}function Lu(e){return!e||typeof e!=`object`||!(`source`in e)||!(`openLayer`in e)?null:e.source===`porcelain-summary`&&typeof e.openLayer==`number`&&Number.isInteger(e.openLayer)?e.openLayer:null}var Ru={kind:`worktree`};function zu(e){return{kind:`branch`,base:e?.base?.ref??``,branch:e?.head.branch}}function Bu(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function Vu(e){return[...new Map(e.map(e=>[e.path,e])).values()]}function Hu(e){let t={marked:[],skipped:[],failed:[]},n=[];for(let r of Vu(e)){if(r.reviewStatus===`reviewed`){t.skipped.push({path:r.path,reason:`already-reviewed`});continue}if(!Nu(r)||r.fingerprint===null||r.fingerprint===void 0){t.skipped.push({path:r.path,reason:`not-fingerprintable`});continue}n.push({path:r.path,fingerprint:r.fingerprint})}return{report:t,files:n}}function Uu(e,t){return{...e,marked:[...e.marked,...t.marked],failed:[...e.failed,...t.conflicts.map(e=>({path:e.path,error:Error(e.reason===`missing`?`That file is no longer in the change list.`:`The file changed since it was shown.`)}))]}}function Wu(e){let t=e.failed.length,n=e.skipped.length;return[e.marked.length>0?`Marked ${e.marked.length} ${e.marked.length===1?`file`:`files`}.`:`No files marked.`,n>0?`Skipped ${n}.`:``,t>0?`${t} failed.`:``].filter(Boolean).join(` `)}function Gu(e){let t=Vu(e),n=t.filter(Nu),r=n.filter(e=>e.fingerprint!==null&&e.fingerprint!==void 0&&e.reviewStatus!==`reviewed`),i=n.filter(e=>e.reviewStatus===`reviewed`),a=t.length-n.length,o=r.length===0&&i.length>0,s=a>0?`${n.length} reviewed · ${a} unavailable`:`All reviewed`,c=n.length===0?null:o?`Unmark all`:r.length===0?s:null;return{entries:t,reviewedPaths:i.map(e=>e.path),unmarking:o,blocked:n.length===0||r.length===0&&i.length===0,label:n.length===0?`No files can be marked reviewed`:c??`Mark all ${r.length} files reviewed`,text:n.length===0?`No reviewable files`:c??`Mark all reviewed`}}function Ku(e,t){return t===`reviewed`?`Unmark ${e} as unreviewed`:t===`stale`?`Mark changed ${e} as reviewed`:`Mark ${e} as reviewed`}function qu(e,t){let n=e?.marks.find(e=>e.layerId===t.id);return n?.fingerprint===t.fingerprint&&!n.stale}function Ju(e,t){return!e?.fingerprint||t?null:e.reviewed?{kind:`unmark`,path:e.path}:{kind:`mark`,input:{path:e.path,fingerprint:e.fingerprint}}}function Yu(e){return e.kind===`branch`?{kind:`branch`,branch:e.branch}:{kind:`worktree`}}function Xu(e){return[`reviewed`,...e.kind===`branch`?[`branch`,e.branch??``]:[]]}function Zu(e,t){let n=new Map(e.marks.map(e=>[e.path,e]));for(let e of t)for(let t of e.changes)t.fingerprint?n.set(t.path,{path:t.path,fingerprint:t.fingerprint,reviewedAt:e.reviewedAt}):n.delete(t.path);return{...e,marks:[...n.values()]}}var Qu=class e extends p()(`@porcelain/client/ReviewedFilesState`){static layer(t,n,r){return fe(e,c(function*(){let e=yield*A(t),i=yield*v([]),a=Xu(r),o=yield*Qe(t,ye.reviewSurface(t.environmentId,n,a),c(function*(){let i=yield*e.request(e=>e.reviews.listReviewedFiles({params:{worktreeId:n.worktreeId},query:r.kind===`branch`?{scope:`branch`,branch:r.branch}:{}}));return yield*g(t,i.worktreeId===n.worktreeId),i}),we(),ye.worktreeReads(t,n,a));return{stream:me(o.stream,b(i),(e,t)=>_(e,e=>Zu(e,t))),confirm:(e,r)=>ue(a=>c(function*(){yield*a(g(t));let s={id:Symbol(),changes:e,reviewedAt:be(yield*U)};return yield*H(i,e=>[...e,s]),yield*a(o.confirm(r.pipe(Ce(e=>g(t,e.worktreeId===n.worktreeId))),(e,t)=>ie({worktreeId:t.worktreeId,marks:t.marks}))).pipe(q(H(i,e=>e.filter(e=>e.id!==s.id))))}))}}))}},$u=X(({connection:e,scope:t,range:n})=>e.atoms(r=>N(Qu.layer(e,t,n),r(W(e).layer))));function ed(e){return $u({...e,range:Yu(e.range)})}var td=X(e=>L(e.scope,`reviewed`,Qu,ed(e)));function nd({range:e=Ru,...t}){return td({...t,range:Yu(e)})}var rd=class e extends p()(`@porcelain/client/LayerMarksState`){static layer(t,n){return fe(e,c(function*(){let e=yield*A(t);return yield*Qe(t,ye.reviewSurface(t.environmentId,n,[`reviewed-layers`]),c(function*(){let r=yield*e.request(e=>e.reviews.listReviewedLayers({params:{worktreeId:n.worktreeId}}));return yield*g(t,r.worktreeId===n.worktreeId),r}),we(),ye.worktreeReads(t,n,[`reviewed-layers`]))}))}},id=X(({connection:e,scope:t})=>e.atoms(n=>N(rd.layer(e,t),n(W(e).layer)))),ad=X(({connection:e,scope:t})=>ke(e,t,[`review`],c(function*(){let{review:n}=yield*(yield*A(e)).request(e=>e.reviews.readPublishedReview({params:{worktreeId:t.worktreeId}})),r=n??null;return yield*g(e,r===null||r.environmentId===e.environmentId&&r.worktreeId===t.worktreeId),r}),W(e)).pipe(m(E(he)),i(0))),od=X(({connection:e,scope:t,proofId:n})=>ke(e,t,[`proof`,n],c(function*(){let r=yield*(yield*A(e)).request(e=>e.reviews.readProofFile({params:{worktreeId:t.worktreeId},query:{proofId:n}}));return yield*g(e,r.id===n),r}),W(e))),sd=X(e=>L(e.scope,`reviewed-layers`,rd,id(e))),cd=class e extends p()(`@porcelain/client/CommentThreadsState`){static layer(t,n){return fe(e,c(function*(){let e=yield*A(t);return yield*Qe(t,ye.reviewSurface(t.environmentId,n,[`comments`]),c(function*(){let r=yield*e.request(e=>e.reviews.listCommentThreads({params:{worktreeId:n.worktreeId}}));return yield*g(t,r.every(e=>e.worktreeId===n.worktreeId)),r}),we(),ye.worktreeReads(t,n,[`comments`]))}))}},ld=X(({connection:e,scope:t})=>e.atoms(n=>N(cd.layer(e,t),n(W(e).layer)))),ud=X(e=>L(e.scope,`comments`,cd,ld(e)));function dd(e,t){return t.endSide&&t.side&&t.endSide!==t.side?null:{...e,kind:`codeRange`,startLine:Math.min(t.start,t.end),endLine:Math.max(t.start,t.end),...e.comparison?.kind===`file`||e.comparison?.kind===`worktree`&&e.comparison.scope===`untracked`?{}:{side:t.side??`additions`}}}function fd(e,t){if(e.kind===`change`||e.filePath!==t.filePath)return!1;if(e.comparison?.kind===`branch`)return t.comparison?.kind===`branch`;if(e.revision!==t.revision)return!1;if(!e.comparison)return e.kind===`file`||t.comparison?.kind===`file`&&e.side===void 0;let n=t.comparison;return e.comparison.kind===n?.kind?e.comparison.kind===`worktree`&&n.kind===`worktree`?e.comparison.scope===n.scope:e.comparison.kind===`commit`&&n.kind===`commit`?e.comparison.parent===n.parent:!0:!1}function pd(e,t){return e.contentFingerprint!==null&&e.contentFingerprint!==void 0&&e.contentFingerprint!==t.contentFingerprint}function md(e){return e.comparison?.kind===`branch`?e.comparison.base:void 0}function hd(e){return e.kind===`change`?void 0:e.filePath}function gd(e){return e?{kind:`change`,comparison:{kind:`branch`,base:e.base},revision:e.tip}:{kind:`change`}}function _d(e){if(e.kind===`change`)return e.comparison?.kind===`branch`?`Whole branch`:`Whole change`;if(e.kind===`file`)return`Whole file`;let t=e.side===`deletions`?`−`:`+`;return e.startLine===e.endLine?`${t}${e.startLine}`:`${t}${e.startLine} to ${t}${e.endLine}`}function vd(e){return e.messages[0]?.author??`reviewer`}function yd(e){let t=e.filter(e=>e.resolved),n=t.filter(e=>vd(e)===`reviewer`).map(e=>({threadId:e.id,revision:e.revision}));return{confirmed:n,kept:t.length-n.length}}function bd(e){return e.resolved?`resolved`:e.messages.at(-1)?.author===`agent`?`agent-replied`:`awaiting-agent`}function xd(e){switch(bd(e)){case`resolved`:return`Resolved`;case`awaiting-agent`:return`Waiting for the agent`;case`agent-replied`:return vd(e)===`agent`&&e.messages.length===1?`From the agent`:`Agent replied`}}function Sd(e){return e.trim().length>0&&!e.includes(`\0`)&&e.length<=16e3}function Cd(e,t,n){return e?.body===t?e:n()}function wd(e,t){let n=[[`open`,e.open],[`resolved`,e.resolved]].filter(([,e])=>e>0);return e.highest===0||!n.every(([e])=>t.has(e))?null:e.highest}function Td(e,t,n=[]){let r=new Map(e.map(e=>[e.id,e]));for(let e of t)r.set(e.id,e);for(let e of n)r.delete(e);return[...r.values()]}var Ed=X(({connection:e,scope:t})=>{let r=ld({connection:e,scope:t}),i={worktreeId:t.worktreeId},a=n([ye.inventory(e.environmentId)]);function o(n,r=!1){return c(function*(){let i=yield*(yield*cd).confirm(n.pipe(Ce(n=>g(e,n.worktreeId===t.worktreeId))),(e,t)=>ie(Td(ce(e,()=>[]),[t])));return r&&(yield*a),i})}return{create:r.fn(Ae(`Reviews.createComment`)(function*(t){return yield*o((yield*A(e)).request(e=>e.reviews.createCommentThread({params:i,payload:t})))}),{concurrent:!0}),reply:r.fn(Ae(`Reviews.replyToComment`)(function*({threadId:t,body:n,messageId:r}){return yield*o((yield*A(e)).request(e=>e.reviews.replyToComment({params:{...i,threadId:t},payload:{body:n,messageId:r}})),!0)}),{concurrent:!0}),resolve:r.fn(Ae(`Reviews.resolveComment`)(function*({threadId:t,resolved:n}){return yield*o((yield*A(e)).request(e=>e.reviews.updateCommentThread({params:{...i,threadId:t},payload:{resolved:n}})))}),{concurrent:!0}),edit:r.fn(Ae(`Reviews.editComment`)(function*({threadId:t,messageId:n,body:r}){return yield*o((yield*A(e)).request(e=>e.reviews.editCommentMessage({params:{...i,threadId:t},payload:{messageId:n,body:r}})))}),{concurrent:!0}),remove:r.fn(Ae(`Reviews.deleteComment`)(function*({threadId:n,messageId:r}){let o=yield*A(e),s=yield*(yield*cd).confirm(c(function*(){let a=yield*o.request(e=>e.reviews.deleteCommentMessage({params:{...i,threadId:n},query:{messageId:r}}));return yield*g(e,a.threadId===n&&(!a.thread||a.thread.worktreeId===t.worktreeId)),a}),(e,t)=>ie(Td(ce(e,()=>[]),t.thread?[t.thread]:[],t.thread?[]:[t.threadId])));return yield*a,s}),{concurrent:!0}),removeResolved:r.fn(Ae(`Reviews.deleteResolvedComments`)(function*(t){let n=yield*A(e),r=yield*(yield*cd).confirm(n.request(e=>e.reviews.deleteResolvedComments({params:i,payload:{threads:t}})),(e,t)=>ie(Td(ce(e,()=>[]),[],t.deleted)));return yield*a,r}),{concurrent:!0}),seen:r.fn(Ae(`Reviews.markCommentsSeen`)(function*(n){let r=yield*A(e),o=yield*(yield*cd).confirm(c(function*(){let a=yield*r.request(e=>e.reviews.markCommentsSeen({params:i,payload:{throughRevision:n}}));return yield*g(e,a.worktreeId===t.worktreeId),a}),e=>e);return yield*a,o}),{concurrent:!0})}}),Dd=X(({connection:e,scope:t,range:n})=>{let r=ed({connection:e,scope:t,range:n}),i={worktreeId:t.worktreeId},a=n.kind===`branch`?{scope:`branch`,branch:n.branch}:{};function o(e,t){return ne(Qu,n=>n.confirm(e,t))}let s=Ae(`Reviews.markFile`)(function*(t){let r=yield*A(e);return yield*o([t],r.request(e=>n.kind===`branch`?e.reviews.setReviewedFile({params:i,payload:{...t,reviewed:!0,scope:`branch`,base:n.base}}):e.reviews.setReviewedFile({params:i,payload:{...t,reviewed:!0}})))}),c=Ae(`Reviews.unmarkFile`)(function*(t){let n=yield*A(e);return yield*o([{path:t}],n.request(e=>e.reviews.removeReviewedFile({params:i,query:{path:t,...a}})))}),u=Ae(`Reviews.markFiles`)(function*(t){return yield*o(t,(yield*A(e)).request(e=>n.kind===`branch`?e.reviews.setReviewedFiles({params:i,payload:{files:t,scope:`branch`,base:n.base}}):e.reviews.setReviewedFiles({params:i,payload:{files:t}})))}),d=Ae(`Reviews.unmarkFiles`)(function*(t){let n=yield*A(e);return yield*o(t.map(e=>({path:e})),n.request(e=>e.reviews.removeReviewedFiles({params:i,payload:{paths:[...t],...a}})))});return{set:r.fn(s,{concurrent:!0}),remove:r.fn(c,{concurrent:!0}),bulk:r.fn(Ae(`Reviews.reviewFiles`)(function*(e){if(e.kind===`unmark`){for(let t of Bu(e.paths,l))yield*d(t);return{kind:`unmark`}}let t=Hu(e.entries),n=t.report;for(let e of Bu(t.files,l))n=Uu(n,yield*u(e));return{kind:`mark`,report:n}}),{concurrent:!0})}}),Od=X(({connection:e,scope:t})=>id({connection:e,scope:t}).fn(Ae(`Reviews.toggleLayerMark`)(function*(r){let i=yield*A(e),a=yield*(yield*rd).confirm(c(function*(){let n=yield*i.request(e=>r.reviewed?e.reviews.removeReviewedLayer({params:{worktreeId:t.worktreeId},query:{layerId:r.layerId}}):e.reviews.setReviewedLayer({params:{worktreeId:t.worktreeId},payload:{layerId:r.layerId,fingerprint:r.fingerprint,reviewed:!0}}));return yield*g(e,n.worktreeId===t.worktreeId),n}),(e,t)=>ie(t));return yield*n([ye.inventory(e.environmentId)]),a}),{concurrent:!0})),kd=X(e=>ad(e).pipe(P,i(0)));function Ad(e,t){let n=(0,$.c)(9),r;n[0]!==t.connection||n[1]!==e?(r=kd({scope:e,connection:t.connection}),n[0]=t.connection,n[1]=e,n[2]=r):r=n[2];let i=r,a=xe(i),o;n[3]===a?o=n[4]:(o=ge(V(a)),n[3]=a,n[4]=o);let s=se(i),c;return n[5]!==a||n[6]!==o||n[7]!==s?(c={result:a,review:o,refresh:s},n[5]=a,n[6]=o,n[7]=s,n[8]=c):c=n[8],c}function jd(e,t){return Ad(e,t).review?.active??!1}var Md=[`fail`,`skipped`,`pass`];function Nd(e){let t=e?.checks??[],n=e=>t.filter(t=>t.result===e).length;return{failing:n(`fail`),skipped:n(`skipped`),passing:n(`pass`),current:e?.current??!0}}function Pd(e){return e.toSorted((e,t)=>Md.indexOf(e.result)-Md.indexOf(t.result))}function Fd(e,t){let n=e=>e.layerId===t;return{checks:(e?.checks??[]).filter(n),assets:(e?.assets??[]).filter(n),current:e?.current??!0}}function Id(e){let t=e.failing+e.skipped+e.passing;return t===0?`no checks`:e.failing>0?`${e.failing} failing`:e.current?e.skipped>0?`${e.skipped} skipped`:t===1?`passed`:`all ${t} passed`:`outdated`}function Ld(e){switch(e){case`fail`:return`Failed`;case`skipped`:return`Skipped`;case`pass`:return`Passed`}}function Rd(e){return Uint8Array.from(atob(e.base64),e=>e.charCodeAt(0))}function zd(e){return URL.parse(e)?.host??e}function Bd(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function Vd(e,t,n){return`${e} ${e===1?t:n}`}function Hd(e){let t=Nd(e),n=t.failing+t.skipped+t.passing;return t.failing>0?{key:`checks`,label:`${t.failing} of ${Vd(n,`check`,`checks`)} failing`,tone:`failing`}:n===0?{key:`checks`,label:`No checks attached`,tone:`attention`}:e?.current===!1?{key:`checks`,label:`Checks ran before the latest changes`,tone:`attention`}:t.skipped>0?{key:`checks`,label:`${Vd(t.skipped,`check`,`checks`)} skipped`,tone:`attention`}:{key:`checks`,label:`${Vd(n,`check`,`checks`)} passed`,tone:`ok`}}function Ud(e){if(e===null)return{key:`unexplained`,label:`No review published`,tone:`attention`};let t=Iu(e.notExplained);return t===null?{key:`unexplained`,label:`Every change explained`,tone:`ok`}:{key:`unexplained`,label:`${t} not explained`,tone:`attention`}}function Wd(e,t){if(e===0&&t===0)return[{key:`comments`,label:`No open comments`,tone:`ok`}];let n=[];return e>0&&n.push({key:`comments`,label:`${Vd(e,`comment`,`comments`)} waiting on the agent`,tone:`attention`}),t>0&&n.push({key:`replies`,label:`${Vd(t,`comment`,`comments`)} waiting on you`,tone:`attention`}),n}function Gd(e){let t=e.files.length,n=e.files.filter(e=>e.reviewStatus===`reviewed`).length,r=e.files.filter(e=>e.reviewStatus===`stale`).length,i=e.threads.filter(e=>bd(e)===`awaiting-agent`).length,a=e.threads.filter(e=>bd(e)===`agent-replied`).length,o=e.explains?Ud(e.review):null;return[t===0?{key:`files`,label:`No changed files`,tone:`ok`}:{key:`files`,label:`${n} of ${Vd(t,`file`,`files`)} reviewed`,tone:n===t?`ok`:`attention`},r===0?{key:`stale`,label:`No marks went stale`,tone:`ok`}:{key:`stale`,label:`${Vd(r,`mark`,`marks`)} changed since reviewed`,tone:`attention`},...o===null?[]:[o],...Wd(i,a),Hd(e.review?.proof)]}function Kd(e){let t=e.filter(e=>e.tone!==`ok`).length;return t===0?`Nothing left to check`:`${Vd(t,`thing`,`things`)} to check`}var qd=new Set([`spec`,`specs`,`__tests__`,`tests`]);function Jd(e){let t=e.slice(e.lastIndexOf(`/`)+1);return/\.(?:spec|test|browser)\.[^.]+$/.test(t)||/_(?:test|spec)\.[^.]+$/.test(t)||/^test_.+\.py$/.test(t)||/(?:Test|Tests|Spec)\.(?:java|kt|cs|swift|scala)$/.test(t)?!0:e.split(`/`).slice(0,-1).some(e=>qd.has(e))}function Yd(e,t){if(!t)return e;let n=[],r=[];for(let t of e)Jd(t.path)?r.push(t):n.push(t);return[...n,...r]}function Xd(e){return`decision:${e}`}function Zd(e,t,{specsApart:n}){let r=new Set(t),i=e=>n&&Jd(e),a=new Map,o=e.layers.map((e,t)=>{let n=Xd(e.id),o=[...new Set(e.steps.filter(e=>e.kind===`changed`).map(e=>e.pointer.path).filter(e=>r.has(e)))],s=[],c=[];for(let e of o){let t=i(e)?`specs`:a.get(e);if(t){c.push({path:e,stop:t});continue}a.set(e,n),s.push(e)}return{kind:`decision`,key:n,number:t+1,layer:e,paths:s,elsewhere:c}}),s=t.filter(i),c=t.filter(e=>!a.has(e)&&!i(e)),l=e.notExplained.flatMap(e=>{let t=i(e.path)&&r.has(e.path)?`specs`:a.get(e.path);return t?[{...e,stop:t}]:[]});return[{kind:`briefing`,key:`briefing`,paths:[]},...o,...c.length>0||l.length>0?[{kind:`unexplained`,key:`unexplained`,paths:c,partial:l}]:[],...s.length>0?[{kind:`specs`,key:`specs`,paths:s}]:[]]}function Qd(e,t){return e.find(e=>e.key===t)??e[0]??{kind:`briefing`,key:`briefing`,paths:[]}}function $d(e,t,n){let r=e.findIndex(e=>e.key===t);return r===-1?void 0:e[r+n]}function ef(e,t){let n=new Map(t.map(e=>[e.path,e.reviewStatus])),r=e.filter(e=>n.get(e)===`reviewed`).length;return{reviewed:r,total:e.length,done:r===e.length}}function tf(e){switch(e.kind){case`briefing`:return`Briefing`;case`decision`:return e.layer.title;case`unexplained`:return`Not explained`;case`specs`:return`Specs`}}function nf(e){return e.kind===`decision`?`${e.number}. ${tf(e)}`:tf(e)}function rf(e,t,n){if(e.kind===`briefing`)return!1;let r=ef(e.paths,t).done;return e.kind===`decision`?r&&n.get(e.layer.id)?.reviewed===!0:r}function af(e,t){return new Map(e.map(e=>{let n=e.steps.some(e=>e.location.state===`changed`);return[e.id,{stale:n,reviewed:qu(t,e)}]}))}function of(e){let t=[];for(let n of e.steps){if(n.kind!==`changed`)continue;let r=e.lanes[n.lane];r!==void 0&&t.at(-1)!==r&&t.push(r)}return t}function sf(e){let t=new Map(e.layers.map((e,t)=>[e.id,t+1]));return e=>({id:e.id,label:e.label,detail:e.detail,problem:e.problem,decision:e.layerId===void 0?void 0:t.get(e.layerId)})}function cf(e){let t=sf(e),n=e.diagram?.after.boxes??[],r=new Set(e.layers.map(e=>e.title)),i=n.filter(e=>!r.has(e.label));return{added:i.filter(e=>e.change===`new`).map(t),changed:i.filter(e=>e.change===`changed`).map(t),removed:i.filter(e=>e.change===`removed`).map(t),questions:n.filter(e=>e.problem!==void 0).map(t)}}function lf(e,t){let n=e.diagram?.after;if(!n)return[];let r=sf(e),i=new Map(n.boxes.map(e=>[e.id,e])),a=new Set(n.boxes.filter(e=>e.layerId===t).map(e=>e.id)),o=new Set;return n.arrows.flatMap(e=>{let t=a.has(e.from);if(t===a.has(e.to))return[];let n=i.get(t?e.to:e.from);return!n||o.has(n.id)?[]:(o.add(n.id),[{verb:e.label??`relates to`,outgoing:t,change:n.change,part:r(n)}])})}function uf(e){let t=[],n=[],r=()=>{let e=t.indexOf(null);return e===-1?(t.push(null),t.length-1):e};for(let i of e){let e=t.flatMap((e,t)=>e===i.oid?[t]:[]);for(let n of e)t[n]=null;let a=e.length>0?Math.min(...e):r(),o=i.parentOids.map((e,n)=>{let i=t.indexOf(e),o=n===0?a:i===-1?r():i;return t[o]=e,o});n.push({commit:i,lane:a,outgoing:o,lanesAfter:[...t]})}return n}function df(e){let t=e.flatMap(e=>[e.lane,...e.outgoing,...e.lanesAfter.flatMap((e,t)=>e==null?[]:[t])]);return 26+Math.max(0,...t)*16}function ff(e){return e.slice(0,7)}function pf(e){return e.replace(/^refs\/(?:heads|remotes|tags)\//u,``)}function mf(e){let t=e%100;return`${e}${t>=11&&t<=13?`th`:[`th`,`st`,`nd`,`rd`][e%10]??`th`}`}function hf(e,t){if(!e)return`This branch`;let n=e.head;switch(n.kind){case`attached`:return t(n.ref);case`detached`:return`Detached HEAD`;case`unborn`:return`No commits yet on ${t(n.ref)}`}}function gf(e){let t=e.findLastIndex(e=>e.restarted),n=t===-1?e:e.slice(t),r=n.at(-1);return{snapshot:n[0]?.snapshot??null,commits:n.flatMap(e=>e.commits),nextAfter:r?.nextAfter??null,boundary:r?.boundary??null,restarted:r?.restarted??!1}}var _f=X(({connection:e,scope:t})=>Y(e,t,[`history`],re(void 0,n=>c(function*(){let r=yield*(yield*A(e)).request(e=>e.changes.listCommits({params:{worktreeId:t.worktreeId},query:{after:n?.after,tip:n?.tip}}));return yield*g(e),[[r],r.nextAfter&&r.tip?ie({after:r.nextAfter,tip:r.tip}):we()]})),W(e))),vf=X(({connection:e,scope:t,oid:n,parent:r=1})=>ke(e,t,[`commit`,n,r],c(function*(){let i=yield*(yield*A(e)).request(e=>e.changes.readCommitFiles({params:{worktreeId:t.worktreeId,oid:n},query:r===1?{}:{parent:r}}));return yield*g(e,i.commit.oid===n&&(i.comparison.kind===`empty-tree`||i.comparison.parentNumber===r)),i}),W(e))),yf=X(({connection:e,scope:t,path:n})=>ke(e,t,[`history`,`file`,n],c(function*(){return yield*(yield*A(e)).request(e=>e.changes.listFileCommits({params:{worktreeId:t.worktreeId},query:{path:n,limit:100}}))}),W(e))),bf=X(e=>u(_f(e),e=>_(e,e=>gf(e.items))).pipe(i(0)));function xf(e,t,n,r){let i=(0,$.c)(5),a=r===void 0?1:r,o;return i[0]!==e||i[1]!==n||i[2]!==a||i[3]!==t?(o=vf({connection:e,scope:t,oid:n,parent:a}),i[0]=e,i[1]=n,i[2]=a,i[3]=t,i[4]=o):o=i[4],$n(o).value}function Sf(e,t){let n=(0,$.c)(12),r;n[0]!==e||n[1]!==t?(r=_f({connection:e,scope:t}),n[0]=e,n[1]=t,n[2]=r):r=n[2];let i=r,a;n[3]!==e||n[4]!==t?(a=bf({connection:e,scope:t}),n[3]=e,n[4]=t,n[5]=a):a=n[5];let{result:o,value:s}=$n(a),c=Te(i),l;n[6]===c?l=n[7]:(l=()=>c(void 0),n[6]=c,n[7]=l);let u;return n[8]!==o||n[9]!==l||n[10]!==s?(u={...s,result:o,readMore:l},n[8]=o,n[9]=l,n[10]=s,n[11]=u):u=n[11],u}var Cf={added:`Added`,modified:`Modified`,deleted:`Deleted`,renamed:`Renamed`,"type-changed":`Type changed`};function wf(e,t){if(e.status===`renamed`&&e.previousPath!==null&&e.previousPath!==void 0)return`Renamed from ${e.previousPath}`;let n=Cf[e.status];return e.path===t?n:`${n} as ${e.path}`}function Tf(e){return e.body===null||e.body===void 0?e.subject:`${e.subject}\n\n${e.body}`}function Ef(e){let t=(0,$.c)(58),{commit:n,selected:r,height:i,inset:a,onSelect:o,children:s}=e,c;t[0]!==i||t[1]!==a?(c={height:i,paddingLeft:a},t[0]=i,t[1]=a,t[2]=c):c=t[2];let l=n.subject,u=i===void 0&&`py-1.5`,d=r&&`bg-accent`,f;t[3]!==u||t[4]!==d?(f=I(`flex w-full flex-col justify-center gap-0.5 rounded-lg px-2 text-left transition-colors hover:bg-accent`,u,d),t[3]=u,t[4]=d,t[5]=f):f=t[5];let p;t[6]!==n.subject||t[7]!==o||t[8]!==r||t[9]!==c||t[10]!==f?(p=(0,Z.jsx)(`button`,{type:`button`,style:c,"aria-pressed":r,title:l,onClick:o,className:f}),t[6]=n.subject,t[7]=o,t[8]=r,t[9]=c,t[10]=f,t[11]=p):p=t[11];let m;t[12]===n.parentOids.length?m=t[13]:(m=n.parentOids.length>1&&(0,Z.jsx)($a,{"aria-label":`Merge commit`,className:`size-3.5 shrink-0 text-muted-foreground`}),t[12]=n.parentOids.length,t[13]=m);let h;t[14]===n.subject?h=t[15]:(h=(0,Z.jsx)(`span`,{className:`truncate`,children:n.subject}),t[14]=n.subject,t[15]=h);let g;t[16]!==m||t[17]!==h?(g=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 text-caption leading-tight`,children:[m,h]}),t[16]=m,t[17]=h,t[18]=g):g=t[18];let _;t[19]===n.oid?_=t[20]:(_=ff(n.oid),t[19]=n.oid,t[20]=_);let v;t[21]===_?v=t[22]:(v=(0,Z.jsx)(`code`,{className:`font-mono`,children:_}),t[21]=_,t[22]=v);let y;t[23]===n.author.name?y=t[24]:(y=(0,Z.jsx)(`span`,{className:`truncate`,children:n.author.name}),t[23]=n.author.name,t[24]=y);let b;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),t[25]=b):b=t[25];let x;t[26]===n.author.timestamp?x=t[27]:(x=Be(n.author.timestamp),t[26]=n.author.timestamp,t[27]=x);let S;t[28]===x?S=t[29]:(S=(0,Z.jsx)(`span`,{className:`shrink-0`,children:x}),t[28]=x,t[29]=S);let C;t[30]!==v||t[31]!==y||t[32]!==S?(C=(0,Z.jsxs)(`span`,{className:`flex gap-1.5 text-2xs text-muted-foreground`,children:[v,y,b,S]}),t[30]=v,t[31]=y,t[32]=S,t[33]=C):C=t[33];let w;t[34]===n.refs?w=t[35]:(w=n.refs.length>0&&(0,Z.jsx)(`span`,{className:`flex gap-1 overflow-hidden`,children:n.refs.map(Df)}),t[34]=n.refs,t[35]=w);let T;t[36]!==s||t[37]!==C||t[38]!==w||t[39]!==p||t[40]!==g?(T=(0,Z.jsxs)(ri,{render:p,children:[g,C,s,w]}),t[36]=s,t[37]=C,t[38]=w,t[39]=p,t[40]=g,t[41]=T):T=t[41];let E;t[42]===n.oid?E=t[43]:(E=()=>pe(n.oid,`commit id`),t[42]=n.oid,t[43]=E);let D;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(Pe,{}),t[44]=D):D=t[44];let O;t[45]===E?O=t[46]:(O=(0,Z.jsxs)(ti,{onClick:E,children:[D,`Copy commit id`]}),t[45]=E,t[46]=O);let k;t[47]===n?k=t[48]:(k=()=>pe(Tf(n),`commit message`),t[47]=n,t[48]=k);let A;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(Pe,{}),t[49]=A):A=t[49];let j;t[50]===k?j=t[51]:(j=(0,Z.jsxs)(ti,{onClick:k,children:[A,`Copy message`]}),t[50]=k,t[51]=j);let M;t[52]!==O||t[53]!==j?(M=(0,Z.jsxs)(Sr,{children:[O,j]}),t[52]=O,t[53]=j,t[54]=M):M=t[54];let N;return t[55]!==T||t[56]!==M?(N=(0,Z.jsxs)(ma,{children:[T,M]}),t[55]=T,t[56]=M,t[57]=N):N=t[57],N}function Df(e){return(0,Z.jsx)(Re,{title:e,variant:`secondary`,className:`h-4 shrink-0`,children:pf(e)},e)}var Of=[`text-graph-1`,`text-graph-2`,`text-graph-3`,`text-graph-4`,`text-graph-5`,`text-graph-6`],kf=e=>13+e*16,Af=e=>Of[e%Of.length]??Of[0];function jf(e){let t=(0,$.c)(6),{rows:n,width:r}=e,i=n.length*58,a;t[0]===n?a=t[1]:(a=n.map((e,t)=>{let r=t*58+29,i=n[t+1],a=e.lanesAfter.flatMap((t,n)=>t==null||i==null?[]:[{lane:n,startX:e.outgoing.includes(n)?kf(e.lane):kf(n),endX:t===i.commit.oid?kf(i.lane):kf(n)}]),o=e.commit.parentOids.length>1;return(0,Z.jsxs)(`g`,{children:[a.map(e=>{let{lane:t,startX:n,endX:i}=e;return(0,Z.jsx)(`path`,{d:n===i?`M ${n} ${r} L ${i} ${r+58}`:`M ${n} ${r} C ${n} ${r+29}, ${i} ${r+29}, ${i} ${r+58}`,fill:`none`,stroke:`currentColor`,strokeWidth:z,className:Af(t)},t)}),(0,Z.jsx)(`circle`,{cx:kf(e.lane),cy:r,r:o?5:4,fill:o?`var(--card)`:`currentColor`,stroke:`currentColor`,strokeWidth:2,className:Af(e.lane)})]},e.commit.oid)}),t[0]=n,t[1]=a);let o;return t[2]!==i||t[3]!==a||t[4]!==r?(o=(0,Z.jsx)(`svg`,{"aria-hidden":`true`,className:`pointer-events-none absolute top-2 left-1.5`,"data-testid":`history-graph`,width:r,height:i,children:a}),t[2]=i,t[3]=a,t[4]=r,t[5]=o):o=t[5],o}function Mf(e){let t=(0,$.c)(3),{enabled:n,onVisible:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:`h-px`,ref:e=>{if(!e||!n||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(e=>{let[t]=e;t?.isIntersecting&&r()},{rootMargin:`0px 0px 240px 0px`});return t.observe(e),()=>t.disconnect()}}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function Nf(e){let t=(0,$.c)(12),{commits:n,history:r,selected:i,onSelect:a}=e,o;if(t[0]!==n||t[1]!==a||t[2]!==i){let e;t[4]!==a||t[5]!==i?(e=e=>(0,Z.jsx)(Ef,{commit:e,selected:i===e.oid,onSelect:()=>a(e.oid)},e.oid),t[4]=a,t[5]=i,t[6]=e):e=t[6],o=n.map(e),t[0]=n,t[1]=a,t[2]=i,t[3]=o}else o=t[3];let s;t[7]===r?s=t[8]:(s=(0,Z.jsx)(Pf,{history:r}),t[7]=r,t[8]=s);let c;return t[9]!==o||t[10]!==s?(c=(0,Z.jsxs)(`div`,{className:`px-1.5 py-2`,children:[o,s]}),t[9]=o,t[10]=s,t[11]=c):c=t[11],c}function Pf(e){let t=(0,$.c)(14),{history:n}=e,r;t[0]!==n.boundary||t[1]!==n.nextAfter||t[2]!==n.readMore||t[3]!==n.result?(r=n.result.waiting?(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 px-2 py-3 text-2xs text-muted-foreground`,children:[(0,Z.jsx)(Ve,{className:`size-3.5`}),`Loading older commits…`]}):B(n.result)?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-2 text-2xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:`Couldn't load older commits`}),(0,Z.jsx)(h,{size:`xs`,variant:`outline`,onClick:n.readMore,children:`Retry`})]}):n.nextAfter===null||n.nextAfter===void 0?(0,Z.jsx)(`p`,{className:`px-2 py-3 text-2xs text-muted-foreground`,children:n.boundary===`shallow`?`Shallow clone: older history is not available.`:n.boundary===`wide`?`Too many branches meet here to continue past this point.`:`Start of history.`}):null,t[0]=n.boundary,t[1]=n.nextAfter,t[2]=n.readMore,t[3]=n.result,t[4]=r):r=t[4];let i;t[5]!==n.nextAfter||t[6]!==n.result?(i=n.nextAfter!==null&&n.nextAfter!==void 0&&!n.result.waiting&&!B(n.result),t[5]=n.nextAfter,t[6]=n.result,t[7]=i):i=t[7];let a;t[8]!==n.readMore||t[9]!==i?(a=(0,Z.jsx)(Mf,{enabled:i,onVisible:n.readMore}),t[8]=n.readMore,t[9]=i,t[10]=a):a=t[10];let o;return t[11]!==r||t[12]!==a?(o=(0,Z.jsxs)(Z.Fragment,{children:[r,a]}),t[11]=r,t[12]=a,t[13]=o):o=t[13],o}function Ff(e){let t=(0,$.c)(13),{scope:n,connection:r,selected:i,onSelect:a,onOpenGraph:o}=e,s=Sf(r,n),c;t[0]!==s.commits.length||t[1]!==o?(c=s.commits.length>0?(0,Z.jsxs)(h,{size:`xs`,variant:`ghost`,onClick:o,children:[(0,Z.jsx)(Za,{}),`Open graph`]}):void 0,t[0]=s.commits.length,t[1]=o,t[2]=c):c=t[2];let l;t[3]!==s||t[4]!==c?(l=(0,Z.jsx)(If,{history:s,action:c}),t[3]=s,t[4]=c,t[5]=l):l=t[5];let u;t[6]!==s||t[7]!==a||t[8]!==i?(u=s.commits.length===0?(0,Z.jsx)(Lf,{}):(0,Z.jsx)(Nf,{commits:s.commits,history:s,selected:i,onSelect:a}),t[6]=s,t[7]=a,t[8]=i,t[9]=u):u=t[9];let d;return t[10]!==l||t[11]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[l,u]}),t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function If(e){let t=(0,$.c)(8),{history:n,action:r}=e,i;t[0]!==r||t[1]!==n.snapshot?(i=(n.snapshot!==null&&n.snapshot!==void 0||r!==void 0)&&(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 border-b py-1.5 pr-1.5 pl-3.5 text-2xs text-muted-foreground`,children:[(0,Z.jsx)(oa,{className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:hf(n.snapshot??void 0,Wr)}),r]}),t[0]=r,t[1]=n.snapshot,t[2]=i):i=t[2];let a;t[3]===n.restarted?a=t[4]:(a=n.restarted&&(0,Z.jsx)(`p`,{role:`status`,className:`shrink-0 border-b bg-muted/40 px-3.5 py-2 text-2xs text-muted-foreground`,children:`History changed. Showing it from the top.`}),t[3]=n.restarted,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,Z.jsxs)(Z.Fragment,{children:[i,a]}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function Lf(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(Ye,{children:(0,Z.jsxs)(Le,{children:[(0,Z.jsx)(Ze,{children:`No commits yet`}),(0,Z.jsx)(Ue,{children:`Commits will appear here once this worktree has history.`})]})}),e[0]=t):t=e[0],t}function Rf(e){let t=(0,$.c)(13),{scope:n,connection:r,onSelect:i}=e,a=Sf(r,n),o,s;t[0]===a.commits?(o=t[1],s=t[2]):(o=uf(a.commits),s=df(o),t[0]=a.commits,t[1]=o,t[2]=s);let c=s,l;t[3]===a?l=t[4]:(l=(0,Z.jsx)(If,{history:a}),t[3]=a,t[4]=l);let u;t[5]!==a||t[6]!==i||t[7]!==o||t[8]!==c?(u=o.length===0?(0,Z.jsx)(Lf,{}):(0,Z.jsxs)(`div`,{className:`relative px-1.5 py-2`,children:[(0,Z.jsx)(jf,{rows:o,width:c}),(0,Z.jsx)(`ol`,{"aria-label":`Commit graph`,className:`flex flex-col`,children:o.map(e=>{let{commit:t}=e;return(0,Z.jsx)(`li`,{children:(0,Z.jsx)(Ef,{commit:t,selected:!1,height:58,inset:c+8,onSelect:()=>i(t.oid)})},t.oid)})}),(0,Z.jsx)(`div`,{style:{paddingLeft:c},children:(0,Z.jsx)(Pf,{history:a})})]}),t[5]=a,t[6]=i,t[7]=o,t[8]=c,t[9]=u):u=t[9];let d;return t[10]!==l||t[11]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[l,u]}),t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function zf(e,t,n){let r=(0,$.c)(4),i;return r[0]!==e||r[1]!==n||r[2]!==t?(i=yf({connection:e,scope:t,path:n}),r[0]=e,r[1]=n,r[2]=t,r[3]=i):i=r[3],$n(i).value}function Bf(e){let t=(0,$.c)(17),{scope:n,connection:r,path:i,onSelect:a}=e,o=zf(r,n,i);if(o.commits.length===0){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ye,{children:(0,Z.jsxs)(Le,{children:[(0,Z.jsx)(Ze,{children:`No commits touch this file`}),(0,Z.jsx)(Ue,{children:`Its timeline starts with the first commit that includes it.`})]})}),t[0]=e):e=t[0],e}let s=`Timeline of ${i}`,c;if(t[1]!==a||t[2]!==i||t[3]!==o.commits){let e;t[5]!==a||t[6]!==i?(e=e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(Ef,{commit:e.commit,selected:!1,onSelect:()=>a({oid:e.commit.oid,path:e.path}),children:(0,Z.jsx)(`span`,{className:`truncate text-2xs text-muted-foreground`,children:wf(e,i)})})},e.commit.oid),t[5]=a,t[6]=i,t[7]=e):e=t[7],c=o.commits.map(e),t[1]=a,t[2]=i,t[3]=o.commits,t[4]=c}else c=t[4];let l=o.more?`Showing the latest ${o.commits.length} commits.`:`Start of this file’s history.`,u;t[8]===l?u=t[9]:(u=(0,Z.jsx)(`span`,{children:l}),t[8]=l,t[9]=u);let d;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(`span`,{children:`A merge appears only when its own result changed the file.`}),t[10]=d):d=t[10];let f;t[11]===u?f=t[12]:(f=(0,Z.jsxs)(`li`,{className:`flex flex-col gap-1 px-2 py-3 text-2xs text-muted-foreground`,children:[u,d]}),t[11]=u,t[12]=f);let p;return t[13]!==s||t[14]!==c||t[15]!==f?(p=(0,Z.jsxs)(`ol`,{"aria-label":s,className:`flex flex-col p-2`,children:[c,f]}),t[13]=s,t[14]=c,t[15]=f,t[16]=p):p=t[16],p}var Vf=e=>function(t){return t.className===null||t.className===void 0?(0,Z.jsx)(hi,{path:e}):(0,Z.jsx)(hi,{path:e,className:t.className})};function Hf(e,t){let n=Gl(e);switch(n?.kind){case`handoff`:return t?{Icon:to,title:`Review`,hint:`Walkthrough of the decisions`}:{Icon:pa,title:`Changes`,hint:`All changes`};case`all-changes`:return{Icon:pa,title:`All changes`,hint:`Every changed file, including specs`};case`specs`:return{Icon:Ya,title:`Specs`,hint:`Changed spec and test files`};case`proof`:return{Icon:Ya,title:`Proof`,hint:`Checks and attachments the agent published`};case`change`:return{Icon:Vf(n.path),title:Pu(n.path),hint:`${n.path} · changes`};case`file`:return{Icon:Vf(n.path),title:Pu(n.path),hint:`${n.path} · file`};case`commit`:return{Icon:fi,title:ff(n.oid),hint:`Commit ${n.oid}`};case`branch`:return{Icon:oa,title:`Branch`,hint:`Every change on the branch`};case`branch-file`:return{Icon:Vf(n.path),title:Pu(n.path),hint:`${n.path} · branch`};case`graph`:return{Icon:Za,title:`Graph`,hint:`Commit graph of the checked-out branch`};case`timeline`:return{Icon:Si,title:Pu(n.path),hint:`${n.path} · timeline`};default:return{Icon:Ua,title:e,hint:e}}}function Uf(e){let t=(0,$.c)(37),n,r,i,a,o,s,c,l,u;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9]):({tabs:l,pinned:o,active:r,reviewing:s,side:c,focused:i,leading:a,trailing:u,...n}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u);let d=c!=null&&i&&`bg-muted/40`,f;t[10]===d?f=t[11]:(f=I(`flex h-10 shrink-0 items-center border-b`,d),t[10]=d,t[11]=f);let p;t[12]===a?p=t[13]:(p=a!=null&&(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center pl-1`,children:a}),t[12]=a,t[13]=p);let m=c==null?`Open documents`:`Open documents, ${c} pane`,h;t[14]===l.length?h=t[15]:(h=l.length===0&&(0,Z.jsx)(`span`,{className:`px-2 text-xs text-muted-foreground`,children:`No open tabs`}),t[14]=l.length,t[15]=h);let g;t[16]!==n||t[17]!==r||t[18]!==o||t[19]!==s||t[20]!==c||t[21]!==l?(g=l.map((e,t)=>{let i=o.includes(e),a=i&&!o.includes(l[t+1]??``)&&t<l.length-1;return(0,Z.jsxs)(`span`,{className:`contents`,children:[(0,Z.jsx)(Wf,{tabKey:e,active:e===r,pinned:i,hasUnpinned:l.some(e=>!o.includes(e)),reviewing:s,side:c,...n}),a&&(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-4 w-px shrink-0 bg-border`})]},e)}),t[16]=n,t[17]=r,t[18]=o,t[19]=s,t[20]=c,t[21]=l,t[22]=g):g=t[22];let _;t[23]!==m||t[24]!==h||t[25]!==g?(_=(0,Z.jsx)(Di,{className:`size-full overflow-y-hidden`,children:(0,Z.jsxs)(`div`,{role:`tablist`,"aria-label":m,className:`flex h-full w-max min-w-full items-center gap-1 px-1.5`,children:[h,g]})}),t[23]=m,t[24]=h,t[25]=g,t[26]=_):_=t[26];let v;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(Ai,{orientation:`horizontal`,className:`absolute inset-x-0 bottom-0 data-horizontal:h-1.5`}),t[27]=v):v=t[27];let y;t[28]===_?y=t[29]:(y=(0,Z.jsxs)(pi,{className:`relative h-full min-w-0 flex-1`,children:[_,v]}),t[28]=_,t[29]=y);let b;t[30]===u?b=t[31]:(b=u!=null&&(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5 px-1.5`,children:u}),t[30]=u,t[31]=b);let x;return t[32]!==b||t[33]!==f||t[34]!==p||t[35]!==y?(x=(0,Z.jsxs)(`div`,{className:f,children:[p,y,b]}),t[32]=b,t[33]=f,t[34]=p,t[35]=y,t[36]=x):x=t[36],x}function Wf(e){let t=(0,$.c)(89),{tabKey:n,active:r,pinned:i,hasUnpinned:a,reviewing:o,side:s,onActivate:c,onClose:l,onCloseOthers:u,onCloseUnpinned:d,onTogglePin:f,onOpenToSide:p}=e,m;t[0]!==o||t[1]!==n?(m=Hf(n,o),t[0]=o,t[1]=n,t[2]=m):m=t[2];let{Icon:h,title:g,hint:_}=m,v=(0,Q.useRef)(null),y=s==null?`Open to the side`:s===`left`?`Open in the right pane`:`Open in the left pane`,b,x;t[3]===r?(b=t[4],x=t[5]):(b=()=>{r&&v.current?.scrollIntoView?.({block:`nearest`,inline:`nearest`})},x=[r],t[3]=r,t[4]=b,t[5]=x),(0,Q.useEffect)(b,x);let S=i?`${_} · pinned`:_,C=r?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/50`,w;t[6]===C?w=t[7]:(w=I(`group flex h-7 shrink-0 cursor-default items-center gap-1.5 rounded-md pr-1 pl-2 text-xs transition-colors`,C),t[6]=C,t[7]=w);let T;t[8]!==c||t[9]!==n?(T=()=>c(n),t[8]=c,t[9]=n,t[10]=T):T=t[10];let E;t[11]!==l||t[12]!==i||t[13]!==n?(E=e=>{e.button===1&&!i&&(e.preventDefault(),l(n))},t[11]=l,t[12]=i,t[13]=n,t[14]=E):E=t[14];let D;t[15]!==c||t[16]!==n?(D=e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c(n))},t[15]=c,t[16]=n,t[17]=D):D=t[17];let O;t[18]!==r||t[19]!==S||t[20]!==w||t[21]!==T||t[22]!==E||t[23]!==D||t[24]!==n?(O=(0,Z.jsx)(`div`,{ref:v,role:`tab`,tabIndex:0,"aria-selected":r,title:S,"data-entry":n,className:w,onClick:T,onAuxClick:E,onKeyDown:D}),t[18]=r,t[19]=S,t[20]=w,t[21]=T,t[22]=E,t[23]=D,t[24]=n,t[25]=O):O=t[25];let k;t[26]===h?k=t[27]:(k=(0,Z.jsx)(h,{className:`size-3.5 shrink-0`}),t[26]=h,t[27]=k);let A;t[28]===n?A=t[29]:(A=I(`max-w-44 truncate pr-0.5`,n.startsWith(`file:`)&&`italic`),t[28]=n,t[29]=A);let j;t[30]!==A||t[31]!==g?(j=(0,Z.jsx)(`span`,{className:A,children:g}),t[30]=A,t[31]=g,t[32]=j):j=t[32];let M;t[33]!==r||t[34]!==l||t[35]!==f||t[36]!==i||t[37]!==n||t[38]!==g?(M=i?(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Unpin ${g}`,onClick:e=>{e.stopPropagation(),f(n)},className:`grid size-4 place-items-center rounded-sm text-muted-foreground hover:bg-foreground/10 hover:text-foreground`,children:(0,Z.jsx)(zi,{className:`size-3`})}):(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Close ${g}`,onClick:e=>{e.stopPropagation(),l(n)},className:I(`grid size-4 place-items-center rounded-sm text-muted-foreground hover:bg-foreground/10 hover:text-foreground`,r?`opacity-100`:`opacity-0 group-hover:opacity-100 focus-visible:opacity-100`),children:(0,Z.jsx)(rt,{className:`size-3`})}),t[33]=r,t[34]=l,t[35]=f,t[36]=i,t[37]=n,t[38]=g,t[39]=M):M=t[39];let N;t[40]!==O||t[41]!==k||t[42]!==j||t[43]!==M?(N=(0,Z.jsxs)(ri,{render:O,children:[k,j,M]}),t[40]=O,t[41]=k,t[42]=j,t[43]=M,t[44]=N):N=t[44];let P;t[45]!==f||t[46]!==n?(P=()=>f(n),t[45]=f,t[46]=n,t[47]=P):P=t[47];let F;t[48]===i?F=t[49]:(F=i?(0,Z.jsx)(qi,{}):(0,Z.jsx)(zi,{}),t[48]=i,t[49]=F);let L=i?`Unpin`:`Pin`,R;t[50]!==P||t[51]!==F||t[52]!==L?(R=(0,Z.jsxs)(ti,{onClick:P,children:[F,L]}),t[50]=P,t[51]=F,t[52]=L,t[53]=R):R=t[53];let z;t[54]!==p||t[55]!==n?(z=()=>p(n),t[54]=p,t[55]=n,t[56]=z):z=t[56];let B;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Z.jsx)(Na,{}),t[57]=B):B=t[57];let V;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsx)($r,{children:zn(In.openToSide)}),t[58]=V):V=t[58];let H;t[59]!==y||t[60]!==z?(H=(0,Z.jsxs)(ti,{onClick:z,children:[B,y,V]}),t[59]=y,t[60]=z,t[61]=H):H=t[61];let U;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Z.jsx)(Mr,{}),t[62]=U):U=t[62];let W;t[63]!==l||t[64]!==n?(W=()=>l(n),t[63]=l,t[64]=n,t[65]=W):W=t[65];let G;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,Z.jsx)(rt,{}),t[66]=G):G=t[66];let K;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,Z.jsx)($r,{children:zn(In.closeTab)}),t[67]=K):K=t[67];let q;t[68]===W?q=t[69]:(q=(0,Z.jsxs)(ti,{onClick:W,children:[G,`Close`,K]}),t[68]=W,t[69]=q);let J;t[70]!==u||t[71]!==n?(J=()=>u(n),t[70]=u,t[71]=n,t[72]=J):J=t[72];let ee;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Z.jsx)(vo,{}),t[73]=ee):ee=t[73];let Y;t[74]===J?Y=t[75]:(Y=(0,Z.jsxs)(ti,{onClick:J,children:[ee,`Close others`]}),t[74]=J,t[75]=Y);let te=!a,ne;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Z.jsx)(ao,{}),t[76]=ne):ne=t[76];let re;t[77]!==d||t[78]!==te?(re=(0,Z.jsxs)(ti,{disabled:te,onClick:d,children:[ne,`Close unpinned`]}),t[77]=d,t[78]=te,t[79]=re):re=t[79];let ie;t[80]!==R||t[81]!==H||t[82]!==q||t[83]!==Y||t[84]!==re?(ie=(0,Z.jsxs)(Sr,{className:`min-w-52`,children:[R,H,U,q,Y,re]}),t[80]=R,t[81]=H,t[82]=q,t[83]=Y,t[84]=re,t[85]=ie):ie=t[85];let ae;return t[86]!==N||t[87]!==ie?(ae=(0,Z.jsxs)(ma,{children:[N,ie]}),t[86]=N,t[87]=ie,t[88]=ae):ae=t[88],ae}function Gf(e,t,n){let r=(0,$.c)(4),i=n===void 0?Ru:n,a;return r[0]!==t.connection||r[1]!==i||r[2]!==e?(a=nd({scope:e,connection:t.connection,range:i}),r[0]=t.connection,r[1]=i,r[2]=e,r[3]=a):a=r[3],$n(a).value}function Kf(e,t,n){let r=(0,$.c)(4),i=n===void 0?Ru:n,a;r[0]!==t.connection||r[1]!==i||r[2]!==e?(a=nd({scope:e,connection:t.connection,range:i}),r[0]=t.connection,r[1]=i,r[2]=e,r[3]=a):a=r[3],M(a)}function qf(e,t,n,r){let i=(0,$.c)(4),a=Gf(e,t),o;return i[0]!==n||i[1]!==r||i[2]!==a?(o=Au(n,a,r),i[0]=n,i[1]=r,i[2]=a,i[3]=o):o=i[3],o}var Jf=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function Yf(e){let t=[],n=[];for(let r of e.split(`
|
|
4
|
+
`)){let e=Jf.exec(r);e==null?n.length===0?t.push(r):r!==``&&n.at(-1)?.lines.push(r):n.push({oldStart:Number(e[1]),newStart:Number(e[2]),lines:[]})}return{header:t,hunks:n}}var Xf=(e,t,n,r)=>`@@ -${t===0?e-1:e},${t} +${r===0?n-1:n},${r} @@`;function Zf(e){let t=e.oldStart===0?1:e.oldStart,n=e.newStart===0?1:e.newStart;return e.lines.map(e=>{let r={text:e,oldLine:t,newLine:n,position:n};return e.startsWith(`+`)?n+=1:e.startsWith(`-`)?t+=1:e.startsWith(`\\`)||(t+=1,n+=1),r})}function Qf(e){let t=e[0];if(t==null)return[];let n=e.filter(e=>e.text.startsWith(` `)||e.text.startsWith(`-`)).length,r=e.filter(e=>e.text.startsWith(` `)||e.text.startsWith(`+`)).length;return[Xf(t.oldLine,n,t.newLine,r),...e.map(e=>e.text)]}function $f(e){let t=e.map(e=>e.startLine===e.endLine?`${e.startLine}`:`${e.startLine}–${e.endLine}`);return`${e.length===1&&e[0]?.startLine===e[0]?.endLine?`Line`:`Lines`} ${t.join(`, `)}`}function ep(e,t,n=3){let{header:r,hunks:i}=Yf(e);if(i.length===0)return e;let a=e=>t.some(t=>e>=t.startLine-n&&e<=t.endLine+n),o=[...r];for(let e of i){let t=[];for(let n of Zf(e))(n.text.startsWith(`\\`)?t.length>0:a(n.position))?t.push(n):t.length>0&&(o.push(...Qf(t)),t=[]);t.length>0&&o.push(...Qf(t))}return o.length===r.length?null:`${o.join(`
|
|
5
|
+
`)}\n`}function tp(e,t,n){let r=n.map(e=>` ${e}`);return[`diff --git ${JSON.stringify(`a/${e}`)} ${JSON.stringify(`b/${e}`)}`,`--- ${JSON.stringify(`a/${e}`)}`,`+++ ${JSON.stringify(`b/${e}`)}`,`@@ -${t},${n.length} +${t},${n.length} @@`,...r,``].join(`
|
|
6
|
+
`)}function np(e,t,n){(e[t]??=[]).push(n)}function rp(e,t){let n={};return e.steps.forEach((r,i)=>{if(r.location.state===`committed`)return;let a=`${i+1}`;np(n,r.pointer.path,{title:t===void 0?r.title:`${t}. ${e.title} · ${r.title}`,text:r.text,line:r.location.state===`current`?r.location.endLine:r.pointer.endLine,stale:r.location.state===`changed`,marker:t===void 0?a:`${t}.${a}`,tone:`agent`})}),n}function ip(e){let t={};for(let n of e)for(let e of n.ranges)np(t,n.path,{title:`Not explained`,text:`${$f([e])} changed without an explanation from the agent.`,line:e.endLine,stale:!1,tone:`gap`});return t}function ap(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n))for(let n of r)np(t,e,n);return t}function op(e,t,n,r){return{id:e,kind:`file`,path:t,contents:n,version:ct(n),...r?{note:r}:{}}}var sp=new Map,cp=new Map;function lp(e){if(e.kind===`diff`){let t=sp.get(e.id);return t?.cacheKey!==void 0&&t.cacheKey===e.fileDiff.cacheKey?{type:`diff`,fileDiff:t}:(sp.set(e.id,e.fileDiff),{type:`diff`,fileDiff:e.fileDiff})}let t=cp.get(e.id);if(t?.name===e.path&&t.contents===e.contents)return{type:`file`,file:t};let n={name:e.path,contents:e.contents};return cp.set(e.id,n),{type:`file`,file:n}}function up(e,t,n){let r=(0,$.c)(9),i=n===void 0?Ru:n,a;r[0]!==t.connection||r[1]!==i||r[2]!==e?(a=Dd({scope:e,connection:t.connection,range:i}),r[0]=t.connection,r[1]=i,r[2]=e,r[3]=a):a=r[3];let o=a.set,s;r[4]===Symbol.for(`react.memo_cache_sentinel`)?(s={mode:`promiseExit`},r[4]=s):s=r[4];let[c,l]=G(o,s),u=Te(o),d;return r[5]!==c||r[6]!==l||r[7]!==u?(d={result:c,submit:l,start:u},r[5]=c,r[6]=l,r[7]=u,r[8]=d):d=r[8],d}function dp(e,t,n){let r=(0,$.c)(9),i=n===void 0?Ru:n,a;r[0]!==t.connection||r[1]!==i||r[2]!==e?(a=Dd({scope:e,connection:t.connection,range:i}),r[0]=t.connection,r[1]=i,r[2]=e,r[3]=a):a=r[3];let o=a.remove,s;r[4]===Symbol.for(`react.memo_cache_sentinel`)?(s={mode:`promiseExit`},r[4]=s):s=r[4];let[c,l]=G(o,s),u=Te(o),d;return r[5]!==c||r[6]!==l||r[7]!==u?(d={result:c,submit:l,start:u},r[5]=c,r[6]=l,r[7]=u,r[8]=d):d=r[8],d}function fp(e,t,n){let r=(0,$.c)(10),i=n===void 0?Ru:n,a;r[0]!==t.connection||r[1]!==i||r[2]!==e?(a=Dd({scope:e,connection:t.connection,range:i}),r[0]=t.connection,r[1]=i,r[2]=e,r[3]=a):a=r[3];let[o,s]=G(a.bulk),c;r[4]===o?c=r[5]:(c=ge(V(o)),r[4]=o,r[5]=c);let l=c,u=!o.waiting&&l?.kind===`mark`?l.report:null,d;return r[6]!==o||r[7]!==s||r[8]!==u?(d={result:o,report:u,start:s},r[6]=o,r[7]=s,r[8]=u,r[9]=d):d=r[9],d}function pp(e,t,n,r){let i=(0,$.c)(4),a=r===void 0?Ru:r,o=up(e,t,a),s=dp(e,t,a),c;return i[0]!==o||i[1]!==n||i[2]!==s?(c={toggle(e){let t=Ju(e,o.result.waiting||s.result.waiting);t&&(t.kind===`unmark`?s.submit(t.path):o.submit(t.input)).then(e=>{Se(e)&&n({title:`Could not update review`,description:Mu(le(e.cause)),type:`error`})})}},i[0]=o,i[1]=n,i[2]=s,i[3]=c):c=i[3],c}function mp(e,t){let n=(0,$.c)(6),r;n[0]!==t.connection||n[1]!==e?(r=ud({scope:e,connection:t.connection}),n[0]=t.connection,n[1]=e,n[2]=r):r=n[2];let{result:i,value:a}=$n(r),o;return n[3]!==i||n[4]!==a?(o={threads:a,result:i},n[3]=i,n[4]=a,n[5]=o):o=n[5],o}function hp(e,t){let n=(0,$.c)(3),r;n[0]!==t.connection||n[1]!==e?(r=ud({scope:e,connection:t.connection}),n[0]=t.connection,n[1]=e,n[2]=r):r=n[2],M(r)}function gp(e){let t=(0,$.c)(6),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={mode:`promiseExit`},t[0]=n):n=t[0];let[r,i]=G(e,n),a;t[1]===i?a=t[2]:(a=(e,t)=>{i(e).then(e=>{de(e)&&t?.()})},t[1]=i,t[2]=a);let o;return t[3]!==r||t[4]!==a?(o={result:r,send:a},t[3]=r,t[4]=a,t[5]=o):o=t[5],o}function _p(e,t){let n=(0,$.c)(3),r;return n[0]!==t.connection||n[1]!==e?(r=Ed({scope:e,connection:t.connection}),n[0]=t.connection,n[1]=e,n[2]=r):r=n[2],Te(r.seen)}function vp(e,t){let n=(0,$.c)(5),r;n[0]!==t.connection||n[1]!==e?(r=Ed({scope:e,connection:t.connection}),n[0]=t.connection,n[1]=e,n[2]=r):r=n[2];let i=gp(r.create),a;return n[3]===i?a=n[4]:(a={...i,bodyLimit:Oe},n[3]=i,n[4]=a),a}function yp(e,t){let n=(0,$.c)(5),r;n[0]!==t.connection||n[1]!==e?(r=Ed({scope:e,connection:t.connection}),n[0]=t.connection,n[1]=e,n[2]=r):r=n[2];let i=gp(r.reply),a;return n[3]===i?a=n[4]:(a={...i,bodyLimit:Oe},n[3]=i,n[4]=a),a}function bp(e,t){let n=(0,$.c)(3),r;return n[0]!==t.connection||n[1]!==e?(r=Ed({scope:e,connection:t.connection}),n[0]=t.connection,n[1]=e,n[2]=r):r=n[2],gp(r.resolve)}function xp(e,t){let n=(0,$.c)(5),r;n[0]!==t.connection||n[1]!==e?(r=Ed({scope:e,connection:t.connection}),n[0]=t.connection,n[1]=e,n[2]=r):r=n[2];let i=gp(r.edit),a;return n[3]===i?a=n[4]:(a={...i,bodyLimit:Oe},n[3]=i,n[4]=a),a}function Sp(e,t){let n=(0,$.c)(3),r;return n[0]!==t.connection||n[1]!==e?(r=Ed({scope:e,connection:t.connection}),n[0]=t.connection,n[1]=e,n[2]=r):r=n[2],gp(r.remove)}function Cp(e,t){let n=(0,$.c)(9),r;n[0]!==t.connection||n[1]!==e?(r=Ed({scope:e,connection:t.connection}),n[0]=t.connection,n[1]=e,n[2]=r):r=n[2];let[i,a]=G(r.removeResolved),o;n[3]===a?o=n[4]:(o=()=>a(s),n[3]=a,n[4]=o);let c;return n[5]!==i||n[6]!==a||n[7]!==o?(c={result:i,send:a,reset:o},n[5]=i,n[6]=a,n[7]=o,n[8]=c):c=n[8],c}function wp(e){let t=(0,$.c)(55),{scope:n,context:r,anchor:i,onClose:a}=e,o=(0,Q.useId)(),[s,c]=(0,Q.useState)(``),l=(0,Q.useRef)(void 0),u;t[0]===i?u=t[1]:(u=JSON.stringify(i),t[0]=i,t[1]=u);let d=u,f=vp(n,r),p;t[2]===s?p=t[3]:(p=Sd(s),t[2]=s,t[3]=p);let m=p,g;t[4]!==i||t[5]!==d||t[6]!==s||t[7]!==f||t[8]!==a||t[9]!==m?(g=()=>{if(!m||f.result.waiting)return;let e=Cd(l.current?.anchor===d?l.current:void 0,s,()=>({body:s,anchor:d,threadId:crypto.randomUUID(),messageId:crypto.randomUUID()}));l.current=e,f.send({anchor:i,body:s,threadId:e.threadId,messageId:e.messageId},()=>{l.current=void 0,a()})},t[4]=i,t[5]=d,t[6]=s,t[7]=f,t[8]=a,t[9]=m,t[10]=g):g=t[10];let _=g,v;t[11]===_?v=t[12]:(v=e=>{e.preventDefault(),_()},t[11]=_,t[12]=v);let y;t[13]===i?y=t[14]:(y=hd(i),t[13]=i,t[14]=y);let b;t[15]===i?b=t[16]:(b=_d(i),t[15]=i,t[16]=b);let x;t[17]!==i.kind||t[18]!==i.revision?(x=i.kind===`change`&&i.revision!==null&&i.revision!==void 0?`at ${i.revision.slice(0,7)}`:void 0,t[17]=i.kind,t[18]=i.revision,t[19]=x):x=t[19];let S;t[20]!==y||t[21]!==b||t[22]!==x?(S=[y,b,x].filter(Tp),t[20]=y,t[21]=b,t[22]=x,t[23]=S):S=t[23];let C=S.join(` · `),w;t[24]!==o||t[25]!==C?(w=(0,Z.jsx)(`label`,{htmlFor:o,className:`text-xs text-muted-foreground`,children:C}),t[24]=o,t[25]=C,t[26]=w):w=t[26];let T;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>{l.current=void 0,c(e.target.value)},t[27]=T):T=t[27];let E;t[28]!==f.result.waiting||t[29]!==a||t[30]!==_?(E=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),_()),e.key===`Escape`&&!f.result.waiting&&(e.stopPropagation(),a())},t[28]=f.result.waiting,t[29]=a,t[30]=_,t[31]=E):E=t[31];let D;t[32]!==s||t[33]!==o||t[34]!==f.bodyLimit||t[35]!==f.result.waiting||t[36]!==E?(D=(0,Z.jsx)(br,{id:o,autoFocus:!0,"aria-label":`Comment`,placeholder:`Share feedback…`,value:s,maxLength:f.bodyLimit,disabled:f.result.waiting,onChange:T,onKeyDown:E}),t[32]=s,t[33]=o,t[34]=f.bodyLimit,t[35]=f.result.waiting,t[36]=E,t[37]=D):D=t[37];let O;t[38]===f.result?O=t[39]:(O=B(f.result)&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:Mu(le(f.result.cause))}),t[38]=f.result,t[39]=O);let k;t[40]!==f.result.waiting||t[41]!==a?(k=(0,Z.jsx)(h,{type:`button`,size:`sm`,variant:`ghost`,disabled:f.result.waiting,onClick:a,children:`Cancel`}),t[40]=f.result.waiting,t[41]=a,t[42]=k):k=t[42];let A=!m||f.result.waiting,j=f.result.waiting?`Posting…`:`Comment`,M;t[43]!==A||t[44]!==j?(M=(0,Z.jsx)(h,{type:`submit`,size:`sm`,disabled:A,children:j}),t[43]=A,t[44]=j,t[45]=M):M=t[45];let N;t[46]!==k||t[47]!==M?(N=(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[k,M]}),t[46]=k,t[47]=M,t[48]=N):N=t[48];let P;return t[49]!==w||t[50]!==D||t[51]!==O||t[52]!==N||t[53]!==v?(P=(0,Z.jsxs)(`form`,{className:`m-3 flex flex-col gap-2 rounded-lg border bg-card p-3 font-sans`,onSubmit:v,children:[w,D,O,N]}),t[49]=w,t[50]=D,t[51]=O,t[52]=N,t[53]=v,t[54]=P):P=t[54],P}function Tp(e){return e!=null}function Ep(e){let t=(0,$.c)(28),{title:n,text:r,stale:i,marker:a,tone:o}=e,s=i!==void 0&&i,c=(o===void 0?`agent`:o)===`gap`,l;t[0]===r?l=t[1]:(l=(0,Z.jsx)(yr,{text:r,className:`text-sm`}),t[0]=r,t[1]=l);let u=l,d=`${c?`Not explained`:`Agent note`}${n?` · ${n}`:``}`,f=c&&`border-graph-4/40 bg-graph-4/5`,p;t[2]===f?p=t[3]:(p=I(`m-3 flex max-w-3xl gap-2.5 rounded-lg border bg-background px-3 py-2.5 font-sans shadow-xs`,f),t[2]=f,t[3]=p);let m=c&&`bg-graph-4/15 text-graph-4`,h;t[4]===m?h=t[5]:(h=I(`mt-px grid h-5 min-w-5 shrink-0 place-items-center rounded-full bg-graph-1/12 px-1 text-2xs font-semibold text-graph-1 tabular-nums`,m),t[4]=m,t[5]=h);let g;t[6]!==c||t[7]!==a?(g=c?(0,Z.jsx)(Sn,{className:`size-3`}):a??`•`,t[6]=c,t[7]=a,t[8]=g):g=t[8];let _;t[9]!==h||t[10]!==g?(_=(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:h,children:g}),t[9]=h,t[10]=g,t[11]=_):_=t[11];let v;t[12]===n?v=t[13]:(v=n&&(0,Z.jsx)(`p`,{className:`text-caption font-medium`,children:n}),t[12]=n,t[13]=v);let y;t[14]===s?y=t[15]:(y=s&&(0,Z.jsx)(`p`,{role:`status`,className:`text-caption text-graph-4`,children:`Code changed since the review was written.`}),t[14]=s,t[15]=y);let b;t[16]!==u||t[17]!==r.length?(b=r.length>360?(0,Z.jsxs)(`details`,{className:`text-muted-foreground`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer text-caption`,children:`Read the note`}),u]}):(0,Z.jsx)(`div`,{className:`text-muted-foreground`,children:u}),t[16]=u,t[17]=r.length,t[18]=b):b=t[18];let x;t[19]!==v||t[20]!==y||t[21]!==b?(x=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v,y,b]}),t[19]=v,t[20]=y,t[21]=b,t[22]=x):x=t[22];let S;return t[23]!==_||t[24]!==x||t[25]!==d||t[26]!==p?(S=(0,Z.jsxs)(`aside`,{"aria-label":d,className:p,children:[_,x]}),t[23]=_,t[24]=x,t[25]=d,t[26]=p,t[27]=S):S=t[27],S}var Dp=S(`group/bubble relative flex w-fit max-w-[80%] min-w-0 flex-col gap-1 group-data-[align=end]/message:self-end data-[align=end]:self-end data-[variant=ghost]:max-w-full`,{variants:{variant:{default:`*:data-[slot=bubble-content]:bg-primary *:data-[slot=bubble-content]:text-primary-foreground [&>[data-slot=bubble-content]:is(button,a):hover]:bg-primary/80`,secondary:`*:data-[slot=bubble-content]:bg-secondary *:data-[slot=bubble-content]:text-secondary-foreground [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)]`,muted:`*:data-[slot=bubble-content]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[color-mix(in_oklch,var(--muted),var(--foreground)_5%)]`,tinted:`*:data-[slot=bubble-content]:bg-[oklch(from_var(--primary)_0.93_calc(c*0.4)_h)] *:data-[slot=bubble-content]:text-foreground dark:*:data-[slot=bubble-content]:bg-[oklch(from_var(--primary)_0.3_calc(c*0.4)_h)] [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[oklch(from_var(--primary)_0.88_calc(c*0.5)_h)] dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-[oklch(from_var(--primary)_0.35_calc(c*0.5)_h)]`,outline:`*:data-[slot=bubble-content]:border-border *:data-[slot=bubble-content]:bg-background [&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:text-foreground dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-input/30`,ghost:`border-none *:data-[slot=bubble-content]:rounded-none *:data-[slot=bubble-content]:bg-transparent *:data-[slot=bubble-content]:p-0 [&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:text-foreground dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted/50`,destructive:`*:data-[slot=bubble-content]:bg-destructive/10 *:data-[slot=bubble-content]:text-destructive dark:*:data-[slot=bubble-content]:bg-destructive/20 [&>[data-slot=bubble-content]:is(button,a):hover]:bg-destructive/20 dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-destructive/30`}},defaultVariants:{variant:`default`}});function Op({variant:e=`default`,align:t=`start`,className:n,...r}){return(0,Z.jsx)(`div`,{"data-slot":`bubble`,"data-variant":e,"data-align":t,className:I(Dp({variant:e}),n),...r})}function kp({className:e,render:t,...n}){return Me({defaultTagName:`div`,props:a({className:I(`w-fit max-w-full min-w-0 overflow-hidden rounded-3xl border border-transparent px-3 py-2.5 text-sm leading-relaxed wrap-break-word group-data-[align=end]/bubble:self-end [button]:text-left [button,a]:transition-colors [button,a]:outline-none [button,a]:focus-visible:border-ring [button,a]:focus-visible:ring-3 [button,a]:focus-visible:ring-ring/30`,e)},n),render:t,state:{slot:`bubble-content`}})}S(`absolute z-10 flex w-fit shrink-0 items-center justify-center gap-1 rounded-full bg-muted px-1.5 py-0.5 text-sm ring-3 ring-card has-[button]:p-0`,{variants:{side:{top:`top-0 -translate-y-3/4`,bottom:`bottom-0 translate-y-3/4`},align:{start:`left-3`,end:`right-3`}},defaultVariants:{side:`bottom`,align:`end`}});function Ap({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`message-group`,className:I(`flex min-w-0 flex-col gap-2`,e),...t})}function jp({className:e,align:t=`start`,...n}){return(0,Z.jsx)(`div`,{"data-slot":`message`,"data-align":t,className:I(`group/message relative flex w-full min-w-0 gap-2 text-sm data-[align=end]:flex-row-reverse`,e),...n})}function Mp({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`message-avatar`,className:I(`flex w-fit min-w-8 shrink-0 items-center justify-center self-end overflow-hidden rounded-full bg-muted group-has-data-[slot=message-footer]/message:-translate-y-8`,e),...t})}function Np({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`message-content`,className:I(`flex w-full min-w-0 flex-col gap-2.5 wrap-break-word group-data-[align=end]/message:*:data-slot:self-end`,e),...t})}function Pp({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`message-header`,className:I(`flex max-w-full min-w-0 items-center px-3 text-xs font-medium text-muted-foreground group-has-data-[variant=ghost]/message:px-0`,e),...t})}var Fp=e=>e==null?null:Be(e);function Ip(e){let t=(0,$.c)(7),{author:n}=e,r=n===`agent`,i;t[0]===` `?i=t[1]:(i=I(`size-6 min-w-6`,` `),t[0]=` `,t[1]=i);let a;t[2]===r?a=t[3]:(a=r?(0,Z.jsx)(Li,{className:`size-3.5`}):(0,Z.jsx)(bo,{className:`size-3.5`}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Z.jsx)(Mp,{className:i,children:a}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Lp(e){let t=(0,$.c)(10),{thread:n}=e,r;t[0]===n?r=t[1]:(r=vd(n),t[0]=n,t[1]=r);let i=r===`agent`,a=i?`font-medium text-foreground`:`text-muted-foreground`,o;t[2]===a?o=t[3]:(o=I(`flex shrink-0 items-center gap-1`,a),t[2]=a,t[3]=o);let s;t[4]===i?s=t[5]:(s=i?(0,Z.jsx)(Li,{className:`size-3`}):(0,Z.jsx)(bo,{className:`size-3`}),t[4]=i,t[5]=s);let c=i?`Agent`:`You`,l;return t[6]!==o||t[7]!==s||t[8]!==c?(l=(0,Z.jsxs)(`span`,{className:o,children:[s,c]}),t[6]=o,t[7]=s,t[8]=c,t[9]=l):l=t[9],l}function Rp(e){let t=(0,$.c)(26),{owner:n,messageId:r,onEdit:i}=e,a=Sp(n.scope,n.context),o;t[0]===a.result.waiting?o=t[1]:(o=(0,Z.jsx)(h,{variant:`ghost`,size:`icon-xs`,"aria-label":`Comment actions`,disabled:a.result.waiting}),t[0]=a.result.waiting,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(La,{}),t[2]=s):s=t[2];let c;t[3]===o?c=t[4]:(c=(0,Z.jsx)(Fr,{render:o,children:s}),t[3]=o,t[4]=c);let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(ki,{}),t[5]=l):l=t[5];let u;t[6]===i?u=t[7]:(u=(0,Z.jsxs)(Ji,{onClick:i,children:[l,`Edit`]}),t[6]=i,t[7]=u);let d;t[8]!==r||t[9]!==n.threadId||t[10]!==a?(d=()=>a.send({threadId:n.threadId,messageId:r}),t[8]=r,t[9]=n.threadId,t[10]=a,t[11]=d):d=t[11];let f;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(Fe,{}),t[12]=f):f=t[12];let p;t[13]===d?p=t[14]:(p=(0,Z.jsxs)(Ji,{variant:`destructive`,onClick:d,children:[f,`Delete`]}),t[13]=d,t[14]=p);let m;t[15]!==u||t[16]!==p?(m=(0,Z.jsxs)(Lr,{align:`end`,children:[u,p]}),t[15]=u,t[16]=p,t[17]=m):m=t[17];let g;t[18]!==c||t[19]!==m?(g=(0,Z.jsxs)(Ar,{children:[c,m]}),t[18]=c,t[19]=m,t[20]=g):g=t[20];let _;t[21]===a.result?_=t[22]:(_=B(a.result)&&(0,Z.jsx)(`span`,{role:`alert`,className:`font-normal text-destructive`,children:Mu(le(a.result.cause))}),t[21]=a.result,t[22]=_);let v;return t[23]!==g||t[24]!==_?(v=(0,Z.jsxs)(Z.Fragment,{children:[g,_]}),t[23]=g,t[24]=_,t[25]=v):v=t[25],v}function zp(e){let t=(0,$.c)(33),{owner:n,message:r,onDone:i}=e,[a,o]=(0,Q.useState)(r.body),s=xp(n.scope,n.context),c;t[0]===a?c=t[1]:(c=Sd(a),t[0]=a,t[1]=c);let l=c,u;t[2]!==a||t[3]!==s||t[4]!==r.id||t[5]!==i||t[6]!==n.threadId||t[7]!==l?(u=e=>{e.preventDefault(),l&&!s.result.waiting&&s.send({threadId:n.threadId,messageId:r.id,body:a},i)},t[2]=a,t[3]=s,t[4]=r.id,t[5]=i,t[6]=n.threadId,t[7]=l,t[8]=u):u=t[8];let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=e=>o(e.target.value),t[9]=d):d=t[9];let f;t[10]===i?f=t[11]:(f=e=>{e.key===`Escape`&&i()},t[10]=i,t[11]=f);let p;t[12]!==a||t[13]!==s.bodyLimit||t[14]!==s.result.waiting||t[15]!==f?(p=(0,Z.jsx)(br,{autoFocus:!0,"aria-label":`Edit comment`,value:a,maxLength:s.bodyLimit,disabled:s.result.waiting,onChange:d,onKeyDown:f}),t[12]=a,t[13]=s.bodyLimit,t[14]=s.result.waiting,t[15]=f,t[16]=p):p=t[16];let m;t[17]===s.result?m=t[18]:(m=B(s.result)&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-2xs text-destructive`,children:Mu(le(s.result.cause))}),t[17]=s.result,t[18]=m);let g;t[19]!==s.result.waiting||t[20]!==i?(g=(0,Z.jsx)(h,{type:`button`,size:`sm`,variant:`ghost`,disabled:s.result.waiting,onClick:i,children:`Cancel`}),t[19]=s.result.waiting,t[20]=i,t[21]=g):g=t[21];let _=s.result.waiting||!l,v=s.result.waiting?`Saving…`:`Save`,y;t[22]!==_||t[23]!==v?(y=(0,Z.jsx)(h,{type:`submit`,size:`sm`,disabled:_,children:v}),t[22]=_,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==y||t[26]!==g?(b=(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[g,y]}),t[25]=y,t[26]=g,t[27]=b):b=t[27];let x;return t[28]!==b||t[29]!==u||t[30]!==p||t[31]!==m?(x=(0,Z.jsxs)(`form`,{className:`flex w-full flex-col gap-2`,onSubmit:u,children:[p,m,b]}),t[28]=b,t[29]=u,t[30]=p,t[31]=m,t[32]=x):x=t[32],x}function Bp(e){let t=(0,$.c)(32),{message:n,owner:r,wide:i}=e,a=i!==void 0&&i,[o,s]=(0,Q.useState)(!1),c=n.author!==`agent`,l;t[0]===n.createdAt?l=t[1]:(l=Fp(n.createdAt),t[0]=n.createdAt,t[1]=l);let u=l,d=c?`end`:`start`,f;t[2]!==n.author||t[3]!==a?(f=!a&&(0,Z.jsx)(Ip,{author:n.author}),t[2]=n.author,t[3]=a,t[4]=f):f=t[4];let p=c?`You`:`Agent`,m;t[5]===u?m=t[6]:(m=u!=null&&(0,Z.jsx)(`span`,{className:`font-normal`,children:u}),t[5]=u,t[6]=m);let h;t[7]===n.editedAt?h=t[8]:(h=n.editedAt!==null&&n.editedAt!==void 0&&(0,Z.jsx)(`span`,{className:`font-normal`,children:`edited`}),t[7]=n.editedAt,t[8]=h);let g;t[9]!==o||t[10]!==n.id||t[11]!==c||t[12]!==r?(g=c&&!o&&(0,Z.jsx)(Rp,{owner:r,messageId:n.id,onEdit:()=>s(!0)}),t[9]=o,t[10]=n.id,t[11]=c,t[12]=r,t[13]=g):g=t[13];let _;t[14]!==p||t[15]!==m||t[16]!==h||t[17]!==g?(_=(0,Z.jsxs)(Pp,{children:[p,m,h,g]}),t[14]=p,t[15]=m,t[16]=h,t[17]=g,t[18]=_):_=t[18];let v;t[19]!==o||t[20]!==n||t[21]!==c||t[22]!==r||t[23]!==a?(v=o?(0,Z.jsx)(zp,{owner:r,message:n,onDone:()=>s(!1)}):(0,Z.jsx)(Op,{variant:c?`tinted`:`muted`,align:c?`end`:`start`,className:a?`max-w-full`:`max-w-[85%]`,children:(0,Z.jsx)(kp,{className:`whitespace-pre-wrap`,children:n.body})}),t[19]=o,t[20]=n,t[21]=c,t[22]=r,t[23]=a,t[24]=v):v=t[24];let y;t[25]!==v||t[26]!==_?(y=(0,Z.jsxs)(Np,{children:[_,v]}),t[25]=v,t[26]=_,t[27]=y):y=t[27];let b;return t[28]!==y||t[29]!==d||t[30]!==f?(b=(0,Z.jsxs)(jp,{align:d,children:[f,y]}),t[28]=y,t[29]=d,t[30]=f,t[31]=b):b=t[31],b}function Vp(e){let t=(0,$.c)(105),{thread:n,scope:r,context:i,onReveal:a}=e,[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(``),f=(0,Q.useRef)(void 0),p=yp(r,i),m=bp(r,i),g;t[0]===n?g=t[1]:(g=bd(n),t[0]=n,t[1]=g);let _=g,v=a!=null,y;t[2]!==i||t[3]!==r||t[4]!==n.id?(y={scope:r,context:i,threadId:n.id},t[2]=i,t[3]=r,t[4]=n.id,t[5]=y):y=t[5];let b=y,x;t[6]!==v||t[7]!==a||t[8]!==n.anchor?(x=v?(0,Z.jsxs)(`button`,{type:`button`,onClick:a,title:n.anchor.kind===`change`?`Show the change`:`Show in the code`,className:`flex min-w-0 items-center gap-1 rounded px-0.5 font-mono text-foreground hover:underline`,children:[n.anchor.kind!==`change`&&(0,Z.jsx)(`span`,{className:`truncate`,children:Pu(n.anchor.filePath)}),(0,Z.jsx)(`span`,{className:`shrink-0 font-sans text-muted-foreground`,children:_d(n.anchor)}),n.anchor.revision!==null&&n.anchor.revision!==void 0&&(0,Z.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`in `,n.anchor.revision.slice(0,7)]})]}):(0,Z.jsx)(`span`,{children:_d(n.anchor)}),t[6]=v,t[7]=a,t[8]=n.anchor,t[9]=x):x=t[9];let S=x,C;t[10]!==m||t[11]!==n.id||t[12]!==n.resolved?(C=()=>m.send({threadId:n.id,resolved:!n.resolved}),t[10]=m,t[11]=n.id,t[12]=n.resolved,t[13]=C):C=t[13];let w;t[14]===n.resolved?w=t[15]:(w=n.resolved?(0,Z.jsx)(go,{"data-icon":`inline-start`}):(0,Z.jsx)(k,{"data-icon":`inline-start`}),t[14]=n.resolved,t[15]=w);let T=n.resolved?`Reopen`:`Resolve`,E;t[16]!==m.result.waiting||t[17]!==C||t[18]!==w||t[19]!==T?(E=(0,Z.jsxs)(h,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6`,disabled:m.result.waiting,onClick:C,children:[w,T]}),t[16]=m.result.waiting,t[17]=C,t[18]=w,t[19]=T,t[20]=E):E=t[20];let D=E,O;t[21]===m.result?O=t[22]:(O=B(m.result)&&(0,Z.jsx)(`span`,{role:`alert`,className:`max-w-64 text-2xs text-destructive`,children:Mu(le(m.result.cause))}),t[21]=m.result,t[22]=O);let A;t[23]!==D||t[24]!==O?(A=(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[D,O]}),t[23]=D,t[24]=O,t[25]=A):A=t[25];let j=A,M;t[26]!==u||t[27]!==p||t[28]!==o||t[29]!==n.id?(M=o&&(0,Z.jsx)(`form`,{className:`mt-3`,onSubmit:e=>{if(e.preventDefault(),!Sd(u)||p.result.waiting)return;let t=Cd(f.current,u,()=>({body:u,messageId:crypto.randomUUID()}));f.current=t,p.send({threadId:n.id,body:u,messageId:t.messageId},()=>{f.current=void 0,d(``),s(!1)})},children:(0,Z.jsxs)(Ke,{children:[(0,Z.jsxs)(ze,{children:[(0,Z.jsx)(Xe,{htmlFor:`reply-${n.id}`,children:`Reply`}),(0,Z.jsx)(br,{id:`reply-${n.id}`,value:u,maxLength:p.bodyLimit,required:!0,disabled:p.result.waiting,onChange:e=>{f.current=void 0,d(e.target.value)},placeholder:`Add a reply…`})]}),B(p.result)&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-2xs text-destructive`,children:Mu(le(p.result.cause))}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(h,{type:`submit`,size:`sm`,disabled:p.result.waiting||!Sd(u),children:p.result.waiting?`Replying…`:`Post reply`}),(0,Z.jsx)(h,{type:`button`,size:`sm`,variant:`ghost`,disabled:p.result.waiting,onClick:()=>s(!1),children:`Cancel`})]})]})}),t[26]=u,t[27]=p,t[28]=o,t[29]=n.id,t[30]=M):M=t[30];let N=M;if(v&&!n.resolved){let e;t[31]===n?e=t[32]:(e=(0,Z.jsx)(Lp,{thread:n}),t[31]=n,t[32]=e);let r;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t[33]=r):r=t[33];let i;t[34]!==e||t[35]!==S?(i=(0,Z.jsxs)(`div`,{className:`mb-3 flex min-w-0 items-center gap-1.5 text-2xs text-muted-foreground`,children:[e,r,S]}),t[34]=e,t[35]=S,t[36]=i):i=t[36];let a;t[37]!==c||t[38]!==n.messages?(a=!c&&n.messages.length>1&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>l(!0),className:`mb-2 text-2xs text-muted-foreground hover:text-foreground hover:underline`,children:[`Show `,n.messages.length-1,` earlier`]}),t[37]=c,t[38]=n.messages,t[39]=a):a=t[39];let u;t[40]!==c||t[41]!==n.messages?(u=c?n.messages:n.messages.slice(-1),t[40]=c,t[41]=n.messages,t[42]=u):u=t[42];let d;if(t[43]!==b||t[44]!==u){let e;t[46]===b?e=t[47]:(e=e=>(0,Z.jsx)(Bp,{message:e,owner:b,wide:!0},e.id),t[46]=b,t[47]=e),d=u.map(e),t[43]=b,t[44]=u,t[45]=d}else d=t[45];let f;t[48]===d?f=t[49]:(f=(0,Z.jsx)(Ap,{children:d}),t[48]=d,t[49]=f);let p;t[50]!==o||t[51]!==j||t[52]!==_||t[53]!==n?(p=!o&&(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center gap-1 border-t pt-2`,children:[(0,Z.jsx)(Re,{variant:_===`agent-replied`?`secondary`:`outline`,className:I(`h-4 `,_===`agent-replied`&&``),children:xd(n)}),(0,Z.jsx)(h,{type:`button`,size:`sm`,variant:`ghost`,className:`ml-auto h-6`,onClick:()=>s(!0),children:`Reply`}),j]}),t[50]=o,t[51]=j,t[52]=_,t[53]=n,t[54]=p):p=t[54];let m;return t[55]!==N||t[56]!==i||t[57]!==a||t[58]!==f||t[59]!==p?(m=(0,Z.jsxs)(`article`,{className:`rounded-xl border bg-card p-3`,"aria-label":`Comment thread`,children:[i,a,f,N,p]}),t[55]=N,t[56]=i,t[57]=a,t[58]=f,t[59]=p,t[60]=m):m=t[60],m}if(n.resolved){let e;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(k,{className:`size-3.5 shrink-0 text-graph-2`}),t[61]=e):e=t[61];let r;t[62]!==v||t[63]!==n||t[64]!==S?(r=v?S:(0,Z.jsx)(Lp,{thread:n}),t[62]=v,t[63]=n,t[64]=S,t[65]=r):r=t[65];let i=n.messages[0]?.body,a;t[66]===i?a=t[67]:(a=(0,Z.jsx)(`span`,{className:`truncate`,children:i}),t[66]=i,t[67]=a);let o;return t[68]!==j||t[69]!==r||t[70]!==a?(o=(0,Z.jsxs)(`article`,{className:`flex min-w-0 items-center gap-2 rounded-lg border border-dashed px-2.5 py-1.5 text-2xs text-muted-foreground`,"aria-label":`Resolved comment thread`,children:[e,r,a,j]}),t[68]=j,t[69]=r,t[70]=a,t[71]=o):o=t[71],o}let P;t[72]===n?P=t[73]:(P=(0,Z.jsx)(Lp,{thread:n}),t[72]=n,t[73]=P);let F;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t[74]=F):F=t[74];let L;t[75]===S?L=t[76]:(L=(0,Z.jsx)(`span`,{children:S}),t[75]=S,t[76]=L);let R=_===`agent-replied`?`secondary`:`outline`,z;t[77]===n?z=t[78]:(z=xd(n),t[77]=n,t[78]=z);let V;t[79]!==R||t[80]!==z?(V=(0,Z.jsx)(Re,{variant:R,className:`h-4`,children:z}),t[79]=R,t[80]=z,t[81]=V):V=t[81];let H;t[82]!==o||t[83]!==j?(H=!o&&(0,Z.jsxs)(`div`,{className:`ml-auto flex gap-0.5`,children:[(0,Z.jsx)(h,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6`,onClick:()=>s(!0),children:`Reply`}),j]}),t[82]=o,t[83]=j,t[84]=H):H=t[84];let U;t[85]!==P||t[86]!==L||t[87]!==V||t[88]!==H?(U=(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 text-2xs text-muted-foreground`,children:[P,F,L,V,H]}),t[85]=P,t[86]=L,t[87]=V,t[88]=H,t[89]=U):U=t[89];let W;if(t[90]!==b||t[91]!==n.messages){let e;t[93]===b?e=t[94]:(e=e=>(0,Z.jsx)(Bp,{message:e,owner:b},e.id),t[93]=b,t[94]=e),W=n.messages.map(e),t[90]=b,t[91]=n.messages,t[92]=W}else W=t[92];let G;t[95]===W?G=t[96]:(G=(0,Z.jsx)(Ap,{children:W}),t[95]=W,t[96]=G);let K;t[97]!==o||t[98]!==_?(K=_===`awaiting-agent`&&!o&&(0,Z.jsx)(`p`,{className:`mt-2 text-right text-2xs text-muted-foreground`,children:`The agent reads this when you ask it to check its comments.`}),t[97]=o,t[98]=_,t[99]=K):K=t[99];let q;return t[100]!==N||t[101]!==U||t[102]!==G||t[103]!==K?(q=(0,Z.jsxs)(`article`,{className:`rounded-xl border bg-card p-3 shadow-sm`,"aria-label":`Comment thread`,children:[U,G,N,K]}),t[100]=N,t[101]=U,t[102]=G,t[103]=K,t[104]=q):q=t[104],q}function Hp(e){let t=(0,$.c)(11),{threads:n,result:r}=mp(e.scope,e.context),i=pp(e.scope,e.context,Up,e.range),a;t[0]===r?a=t[1]:(a=B(r)&&(0,Z.jsx)(`p`,{role:`alert`,className:`px-3 text-xs text-destructive`,children:`Comments could not be refreshed.`}),t[0]=r,t[1]=a);let o;t[2]===i?o=t[3]:(o=e=>i.toggle(e.review),t[2]=i,t[3]=o);let s;t[4]!==e||t[5]!==o||t[6]!==n?(s=(0,Z.jsx)(Wp,{...e,threads:n,onToggleReviewed:o}),t[4]=e,t[5]=o,t[6]=n,t[7]=s):s=t[7];let c;return t[8]!==a||t[9]!==s?(c=(0,Z.jsxs)(Z.Fragment,{children:[a,s]}),t[8]=a,t[9]=s,t[10]=c):c=t[10],c}function Up(e){return Vt.add(e)}function Wp(e){let t=(0,$.c)(60),{entries:n,scope:r,context:i,interaction:a,header:o,footer:s,headerLeading:c,headerActions:l,toolbar:u,threads:d,commentRequest:f,foundLine:p,disableFileHeader:m,fullHeight:g,collapsible:_,onToggleReviewed:v}=e,y=m!==void 0&&m,b=g!==void 0&&g,x=_!==void 0&&_,{dark:S}=ln(),{preferences:C}=Tn(),w=Yd(n,C.collapseSpecs),T=Su(a.worktreeId,a.entry),E=(0,Q.useRef)(null),[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(0),[N,P]=(0,Q.useState)(null),F=new Set(w.filter(e=>D?.id!==e.id&&mu(T.folds,e.id,w.length>1&&e.review?.reviewed===!0||(x||w.length>1)&&C.collapseSpecs&&Jd(e.path))).map(Xp)),I;t[0]!==w||t[1]!==O||t[2]!==M||t[3]!==A?(I=e=>{e?.comment&&(M(w.findIndex(t=>t.id===e.id)),O({id:e.id,anchor:{...e.comment,kind:`file`}}),A(null))},t[0]=w,t[1]=O,t[2]=M,t[3]=A,t[4]=I):I=t[4];let L=I,R;t[5]!==O||t[6]!==A?(R=()=>{O(null),A(null)},t[5]=O,t[6]=A,t[7]=R):R=t[7];let z=R,B=(0,Q.useRef)(void 0),V;t[8]!==f||t[9]!==w[0]||t[10]!==L?(V=()=>{f!==void 0&&B.current!==f&&(B.current=f,L(w[0]))},t[8]=f,t[9]=w[0],t[10]=L,t[11]=V):V=t[11],(0,Q.useEffect)(V);let H=(0,Q.useRef)(void 0),U;t[12]!==w[0]||t[13]!==p||t[14]!==A?(U=()=>{let e=w[0];if(!p||!e||H.current===p.nonce)return;H.current=p.nonce;let t={start:p.line,end:p.line};A({id:e.id,range:t}),E.current?.scrollTo({type:`line`,id:e.id,lineNumber:p.line,align:`center`})},t[12]=w[0],t[13]=p,t[14]=A,t[15]=U):U=t[15],(0,Q.useEffect)(U);let W=(0,Q.useRef)(void 0),G=a.reveal,K;t[16]!==w||t[17]!==G?(K=G&&w.find(e=>e.comment&&fd(G.anchor,e.comment)),t[16]=w,t[17]=G,t[18]=K):K=t[18];let q=K;(0,Q.useEffect)(()=>{if(!G||!q||W.current===G.nonce)return;if(F.has(q.id)){T.setCollapsed([q.id],!1);return}let e=requestAnimationFrame(()=>{let e=G.anchor,t=q.comment&&pd(e,q.comment);E.current?.scrollTo(e.kind===`codeRange`&&!t?{type:`line`,id:q.id,lineNumber:e.startLine,...q.kind===`diff`?{side:e.side??`additions`}:{},align:`center`}:{type:`item`,id:q.id,align:`start`}),M(w.findIndex(e=>e.id===q.id)),W.current=G.nonce});return()=>cancelAnimationFrame(e)});let J;t[19]!==w||t[20]!==M?(J=e=>{let t=w[e];t&&(M(e),E.current?.scrollTo({type:`item`,id:t.id,align:`start`}))},t[19]=w,t[20]=M,t[21]=J):J=t[21];let ee=J,Y=new Map(w.map(Yp)),te=w.map(e=>{let t=e.comment,n=t?d.filter(n=>fd(n.anchor,t)&&(n.anchor.comparison||w.find(e=>e.comment&&fd(n.anchor,e.comment))?.id===e.id)).map(e=>({kind:`thread`,thread:e,stale:pd(e.anchor,t)})):[];for(let t of e.agentNotes??[])n.push({...t,kind:`agent`});D?.id===e.id&&n.push({kind:`composer`,anchor:D.anchor});let r=n.map(Jp);return{id:e.id,collapsed:F.has(e.id),version:ct(JSON.stringify([e.version,F.has(e.id),n])),annotations:r,...lp(e)}}),ne,re;t[22]===w?(ne=t[23],re=t[24]):(ne=w.filter(qp),re=new Set(ne.map(Kp)),t[22]=w,t[23]=ne,t[24]=re);let ie=re.size,ae=ne[0]?.id,oe;if(t[25]!==w){oe=new Map;for(let e of w)e.review&&!oe.has(e.review.path)&&oe.set(e.review.path,e.id);t[25]=w,t[26]=oe}else oe=t[26];let se,ce;t[27]!==w||t[28]!==M?(se=(e,t)=>M(w.findIndex(e=>e.id===t.item.id)),ce=(e,t)=>M(w.findIndex(e=>e.id===t.item.id)),t[27]=w,t[28]=M,t[29]=se,t[30]=ce):(se=t[29],ce=t[30]);let le={theme:Kt,themeType:S?`dark`:`light`,overflow:C.lineOverflow,diffStyle:C.diffStyle,diffIndicators:`classic`,hunkSeparators:`line-info`,stickyHeaders:!y&&!b,disableFileHeader:y,enableLineSelection:!0,enableGutterUtility:!0,onLineClick:se,onLineNumberClick:ce,onGutterUtilityClick:(e,t)=>{let n=Y.get(t.item.id);if(!n?.comment)return;let r=dd(n.comment,e);if(!r){P(`Select lines on one side of the comparison.`);return}M(w.findIndex(e=>e.id===n.id)),P(null),O({id:n.id,anchor:r}),A({id:n.id,range:e})},lineHoverHighlight:`number`,unsafeCSS:`${dr}${pr}${y?`[data-code] { padding-top: 0 !important; }`:pn}`,...y?{itemMetrics:{paddingTop:0}}:{},layout:{paddingTop:y?0:12,paddingBottom:b||s?12:160,gap:12}},ue=w.length>0&&w.every(e=>F.has(e.id)),de;t[31]!==w||t[32]!==T?(de=e=>T.setCollapsed(w.map(Gp),e),t[31]=w,t[32]=T,t[33]=de):de=t[33];let fe=de,pe=e=>{M(w.findIndex(t=>t.id===e)),T.setCollapsed([e],!F.has(e))},X;t[34]!==ue||t[35]!==w.length||t[36]!==fe?(X=w.length>1?(0,Z.jsxs)(h,{size:`sm`,variant:`ghost`,onClick:()=>fe(!ue),children:[ue?(0,Z.jsx)(Da,{"aria-hidden":`true`,"data-icon":`inline-start`}):(0,Z.jsx)(Ta,{"aria-hidden":`true`,"data-icon":`inline-start`}),ue?`Expand all`:`Collapse all`]}):null,t[34]=ue,t[35]=w.length,t[36]=fe,t[37]=X):X=t[37];let me=X,he=k!=null&&D==null?(()=>{let e=Y.get(k.id);return e?.comment?dd(e.comment,k.range):null})():null,ge=`@container/code relative flex min-h-0 flex-1 flex-col`,_e;t[38]!==w||t[39]!==ee||t[40]!==j||t[41]!==a.active||t[42]!==v||t[43]!==L?(_e=a.active&&(0,Z.jsx)(Zp,{next:()=>ee(Math.min(j+1,w.length-1)),previous:()=>ee(Math.max(j-1,0)),comment:()=>L(w[j]),review:()=>{let e=w[j];e&&v(e)}}),t[38]=w,t[39]=ee,t[40]=j,t[41]=a.active,t[42]=v,t[43]=L,t[44]=_e):_e=t[44];let ve=N?(0,Z.jsx)(`p`,{role:`status`,className:`absolute bottom-3 left-3 z-10 rounded-lg border bg-popover p-2 text-xs`,children:N}):he!=null&&(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`pointer-events-none absolute bottom-3 left-3 z-10 flex max-w-[calc(100%-1.5rem)] items-center gap-1.5 rounded-lg border bg-popover/95 px-2.5 py-1 text-xs text-popover-foreground shadow-md`,children:[(0,Z.jsx)(so,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`span`,{className:`truncate`,children:[Pu(he.filePath),` ·`,` `,_d(he)]}),he.kind===`codeRange`&&he.comparison?.kind===`worktree`&&he.side!==`deletions`&&(he.comparison.scope===`staged`||he.comparison.scope===`unstaged`)&&(0,Z.jsx)(`span`,{className:`pointer-events-auto`,children:(0,Z.jsx)(Wi,{scope:r,context:i,path:he.filePath,hunk:{scope:he.comparison.scope,startLine:he.startLine,endLine:he.endLine},variant:`compact`})})]}),ye;t[45]!==me||t[46]!==u?(ye=u?u(me):me&&(0,Z.jsx)(`div`,{className:`flex shrink-0 justify-end px-3`,children:me}),t[45]=me,t[46]=u,t[47]=ye):ye=t[47];let be;t[48]!==w.length||t[49]!==s||t[50]!==o||t[51]!==l?(be=w.length===0&&(o||l||s)&&(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,"data-testid":`empty-code-document`,children:[o?.(),s?.(),l&&(0,Z.jsx)(`div`,{className:`flex justify-end px-3.5 py-2`,children:(0,Z.jsx)(mi,{children:l})})]}),t[48]=w.length,t[49]=s,t[50]=o,t[51]=l,t[52]=be):be=t[52];let xe=w.length>0&&(0,Z.jsx)(Tl,{ref:E,items:te,selectedLines:k,onSelectedLinesChange:e=>{D||(A(e),e&&M(w.findIndex(t=>t.id===e.id)))},renderAnnotation:e=>{let t=e.metadata;return t.kind===`agent`?(0,Z.jsx)(Ep,{title:t.title,text:t.text,stale:t.stale,...t.marker?{marker:t.marker}:{},...t.tone?{tone:t.tone}:{}}):t.kind===`composer`?(0,Z.jsx)(wp,{scope:r,context:i,anchor:t.anchor,onClose:z},JSON.stringify(t.anchor)):(0,Z.jsxs)(`div`,{className:`m-3 font-sans`,children:[t.stale&&(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-graph-4`,children:`Code changed since this comment`}),(0,Z.jsx)(Vp,{scope:r,context:i,thread:t.thread})]})},renderHeaderMetadata:e=>{let t=Y.get(e.id);if(y||!t)return null;let n=e.id===w[0]?.id?l:null,r=e.id===w[0]?.id?c:null,i=t.review?.stale?(0,Z.jsx)(`span`,{className:`rounded-md bg-graph-4/15 px-1.5 py-0.5 font-sans text-2xs text-graph-4`,children:`Changed since reviewed`}):null,a=t.comment?(0,Z.jsxs)(h,{variant:`ghost`,size:`xs`,"aria-label":`Comment on ${t.path} (${t.kind===`diff`?t.note??`diff`:`file`})`,onClick:()=>L(t),children:[(0,Z.jsx)(so,{}),(0,Z.jsx)(`span`,{className:`max-narrow:sr-only`,children:`Comment`})]}):null;return!i&&!r&&!n&&!a?null:(0,Z.jsxs)(`div`,{className:`flex max-w-full flex-wrap items-center justify-end gap-1.5`,children:[i,r,(n||a)&&(0,Z.jsxs)(mi,{children:[n,a]})]})},options:le,className:b?`flex-none overflow-visible`:`min-h-0 flex-1 overflow-auto`,...o?{renderCodeViewHeader:o}:{},...s?{renderCodeViewFooter:s}:{},renderHeaderPrefix:e=>{let t=Y.get(e.id);if(!t)return null;let n=F.has(e.id),r=t.review,i=r&&oe.get(r.path)===t.id?r.control:null;return(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[C.collapseSpecs&&e.id===ae&&w.length>ne.length&&(0,Z.jsxs)(`span`,{className:`mr-2 border-r pr-2 font-sans text-xs font-medium`,children:[`Specs · `,ie,` files`]}),(x||w.length>1)&&(0,Z.jsx)(`button`,{type:`button`,"aria-expanded":!n,"aria-label":`${n?`Expand`:`Collapse`} ${t.path}`,onClick:()=>pe(e.id),className:`-ml-1 grid size-5 place-items-center rounded-md font-sans text-muted-foreground hover:bg-accent hover:text-foreground`,children:n?(0,Z.jsx)(Tr,{className:`size-3.5`}):(0,Z.jsx)(Ne,{className:`size-3.5`})}),i]})},renderHeaderFilenameSuffix:e=>{let t=Y.get(e.id);return t&&t.note?(0,Z.jsx)(`span`,{className:`ml-2 hidden max-w-48 truncate font-sans text-xs text-muted-foreground @code-wide/code:block`,title:t.note,children:t.note}):null}}),Se;return t[53]!==ge||t[54]!==_e||t[55]!==ve||t[56]!==ye||t[57]!==be||t[58]!==xe?(Se=(0,Z.jsxs)(`div`,{className:ge,children:[_e,ve,ye,be,xe]}),t[53]=ge,t[54]=_e,t[55]=ve,t[56]=ye,t[57]=be,t[58]=xe,t[59]=Se):Se=t[59],Se}function Gp(e){return e.id}function Kp(e){return e.path}function qp(e){return Jd(e.path)}function Jp(e){if(e.kind===`agent`)return{lineNumber:e.stale?0:e.line,side:`additions`,metadata:e};let t=e.kind===`thread`?e.thread.anchor:e.anchor,n=t.kind===`codeRange`&&!(e.kind===`thread`&&e.stale)?t.endLine:0,r=t.kind===`codeRange`?t.side??`additions`:`additions`;return e.kind,{lineNumber:n,side:r,metadata:e}}function Yp(e){return[e.id,e]}function Xp(e){return e.id}function Zp(e){let t=(0,$.c)(1),{next:n,previous:r,comment:i,review:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={ignoreInputs:!0},t[0]=o):o=t[0];let s=o;return vn(In.nextFile,n,s),vn(In.previousFile,r,s),vn(In.commentOnFile,i,s),vn(In.toggleReviewed,a,s),null}function Qp(e){let t=(0,$.c)(16),{title:n,titleLabel:r,subtitle:i,children:a,className:o}=e,s;t[0]===o?s=t[1]:(s=I(`flex min-h-11 shrink-0 flex-wrap items-center gap-x-2.5 gap-y-1 border-b px-3.5`,o),t[0]=o,t[1]=s);let c;t[2]!==n||t[3]!==r?(c=(0,Z.jsx)(`h1`,{"aria-label":r,className:`truncate text-ui leading-tight font-semibold`,children:n}),t[2]=n,t[3]=r,t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=i!=null&&(0,Z.jsx)(`p`,{className:`truncate text-2xs leading-tight text-muted-foreground`,children:i}),t[5]=i,t[6]=l);let u;t[7]!==c||t[8]!==l?(u=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-auto flex-col`,children:[c,l]}),t[7]=c,t[8]=l,t[9]=u):u=t[9];let d;t[10]===a?d=t[11]:(d=(0,Z.jsx)(`div`,{className:`ml-auto flex max-w-full shrink-0 flex-wrap items-center justify-end gap-1.5`,children:a}),t[10]=a,t[11]=d);let f;return t[12]!==s||t[13]!==u||t[14]!==d?(f=(0,Z.jsxs)(`header`,{"data-testid":`document-toolbar`,className:s,children:[u,d]}),t[12]=s,t[13]=u,t[14]=d,t[15]=f):f=t[15],f}function $p(e){let t=(0,$.c)(4),{more:n,pending:r,onReadMore:i}=e;if(n<=0)return null;let a=r?`Reading…`:`Read ${Math.min(n,25)} more of ${n}`,o;return t[0]!==i||t[1]!==r||t[2]!==a?(o=(0,Z.jsx)(`div`,{className:`border-t px-4 py-3 text-center`,children:(0,Z.jsx)(h,{variant:`outline`,size:`sm`,onClick:i,disabled:r,children:a})}),t[0]=i,t[1]=r,t[2]=a,t[3]=o):o=t[3],o}function em(e,t,n){return{path:n.path,fingerprint:n.fingerprint??null,reviewed:n.reviewStatus===`reviewed`,stale:n.reviewStatus===`stale`,control:(0,Z.jsx)(tm,{scope:e,context:t,path:n.path,fingerprint:n.fingerprint,status:n.reviewStatus,compact:!0},`review:${n.path}`)}}function tm(e){let t=(0,$.c)(44),{scope:n,context:r,path:i,fingerprint:a,status:o,compact:s,range:c}=e,l=s!==void 0&&s,u=c===void 0?Ru:c,d=up(n,r,u),f=dp(n,r,u),p=d.result.waiting||f.result.waiting,m,g;if(t[0]!==l||t[1]!==a||t[2]!==d||t[3]!==i||t[4]!==p||t[5]!==o||t[6]!==f){g=Symbol.for(`react.early_return_sentinel`);bb0:{let e=B(d.result)?le(d.result.cause):B(f.result)?le(f.result.cause):void 0;if(a==null){let e=`${i} cannot be marked as reviewed because its current state could not be established`,n;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(da,{className:`size-3`,"aria-hidden":`true`}),t[9]=n):n=t[9];let r=l&&`sr-only`,a;t[10]===r?a=t[11]:(a=I(r),t[10]=r,t[11]=a);let o;t[12]===a?o=t[13]:(o=(0,Z.jsx)(`span`,{className:a,children:`Not reviewable`}),t[12]=a,t[13]=o);let s;t[14]!==e||t[15]!==o?(s=(0,Z.jsxs)(`span`,{title:e,className:`inline-flex items-center gap-1 text-2xs text-muted-foreground`,children:[n,o]}),t[14]=e,t[15]=o,t[16]=s):s=t[16],g=s;break bb0}let n=o===`reviewed`,r;t[17]!==i||t[18]!==o?(r=Ku(i,o),t[17]=i,t[18]=o,t[19]=r):r=t[19];let s=r,c=l?`icon-xs`:`xs`,u=n?`ghost`:`outline`,_=l&&`size-5 `,v=l&&n&&` `,y;t[20]!==_||t[21]!==v?(y=I(_,v),t[20]=_,t[21]=v,t[22]=y):y=t[22];let b;t[23]!==a||t[24]!==d||t[25]!==i||t[26]!==n||t[27]!==f?(b=()=>{n?f.start(i):d.start({path:i,fingerprint:a})},t[23]=a,t[24]=d,t[25]=i,t[26]=n,t[27]=f,t[28]=b):b=t[28];let x;t[29]!==l||t[30]!==p||t[31]!==n||t[32]!==o?(x=p?(0,Z.jsx)(D,{className:`animate-spin`}):n?(0,Z.jsx)(k,{}):o===`stale`?(0,Z.jsx)(go,{}):(0,Z.jsx)(k,{className:I(l&&`invisible`)}),t[29]=l,t[30]=p,t[31]=n,t[32]=o,t[33]=x):x=t[33];let S=!l&&(n?`Reviewed`:o===`stale`?`Review again`:`Mark reviewed`),C;t[34]!==s||t[35]!==p||t[36]!==n||t[37]!==y||t[38]!==b||t[39]!==x||t[40]!==S||t[41]!==c||t[42]!==u?(C=(0,Z.jsxs)(h,{type:`button`,size:c,variant:u,className:y,"aria-pressed":n,disabled:p,"aria-label":s,title:s,onClick:b,children:[x,S]}),t[34]=s,t[35]=p,t[36]=n,t[37]=y,t[38]=b,t[39]=x,t[40]=S,t[41]=c,t[42]=u,t[43]=C):C=t[43],m=(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[C,e!==void 0&&(0,Z.jsx)(`span`,{role:`alert`,className:`max-w-52 truncate text-2xs text-destructive`,children:Mu(e)})]})}t[0]=l,t[1]=a,t[2]=d,t[3]=i,t[4]=p,t[5]=o,t[6]=f,t[7]=m,t[8]=g}else m=t[7],g=t[8];return g===Symbol.for(`react.early_return_sentinel`)?m:g}function nm(e){let t=(0,$.c)(26),{scope:n,context:r,entries:i,compact:a,range:o}=e,s=a!==void 0&&a,c=fp(n,r,o===void 0?Ru:o),l;t[0]===i?l=t[1]:(l=Gu(i),t[0]=i,t[1]=l);let u=l,d=c.result.waiting,f=u.blocked||d,p;t[2]!==c||t[3]!==f||t[4]!==u.entries||t[5]!==u.reviewedPaths||t[6]!==u.unmarking?(p=()=>{f||(u.unmarking?c.start({kind:`unmark`,paths:u.reviewedPaths}):c.start({kind:`mark`,entries:u.entries}))},t[2]=c,t[3]=f,t[4]=u.entries,t[5]=u.reviewedPaths,t[6]=u.unmarking,t[7]=p):p=t[7];let m=p,g=s?`icon-xs`:`xs`,_;t[8]!==d||t[9]!==u.unmarking?(_=d?(0,Z.jsx)(D,{className:`animate-spin`}):u.unmarking?(0,Z.jsx)(go,{}):(0,Z.jsx)(k,{}),t[8]=d,t[9]=u.unmarking,t[10]=_):_=t[10];let v=!s&&(d?u.unmarking?`Unmarking…`:`Marking…`:u.text),y;t[11]!==f||t[12]!==u.label||t[13]!==m||t[14]!==g||t[15]!==_||t[16]!==v?(y=(0,Z.jsxs)(h,{type:`button`,size:g,variant:`outline`,disabled:f,"aria-label":u.label,title:u.label,onClick:m,children:[_,v]}),t[11]=f,t[12]=u.label,t[13]=m,t[14]=g,t[15]=_,t[16]=v,t[17]=y):y=t[17];let b;t[18]===c.report?b=t[19]:(b=c.report&&(0,Z.jsx)(rm,{report:c.report}),t[18]=c.report,t[19]=b);let x;t[20]===c.result?x=t[21]:(x=B(c.result)&&(0,Z.jsx)(`span`,{role:`alert`,className:`max-w-64 text-right text-2xs text-destructive`,children:Mu(le(c.result.cause))}),t[20]=c.result,t[21]=x);let S;return t[22]!==x||t[23]!==y||t[24]!==b?(S=(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 flex-col items-end gap-1`,children:[y,b,x]}),t[22]=x,t[23]=y,t[24]=b,t[25]=S):S=t[25],S}function rm(e){let t=(0,$.c)(11),{report:n}=e,r=n.failed.length,i=r>0?`alert`:`status`,a=r>0?`text-destructive`:`text-muted-foreground`,o;t[0]===a?o=t[1]:(o=I(`max-w-64 text-right text-2xs leading-tight`,a),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=r>0&&(0,Z.jsx)(Xr,{className:`mr-1 inline size-3`}),t[2]=r,t[3]=s);let c;t[4]===n?c=t[5]:(c=Wu(n),t[4]=n,t[5]=c);let l;return t[6]!==i||t[7]!==o||t[8]!==s||t[9]!==c?(l=(0,Z.jsxs)(`span`,{role:i,className:o,children:[s,c]}),t[6]=i,t[7]=o,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function im(e){let t=(0,$.c)(7),{title:n,description:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(Ze,{children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Z.jsx)(Ue,{children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Z.jsx)(Ye,{children:(0,Z.jsxs)(Le,{children:[i,a]})}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function am(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(sm,{...e,path:void 0}),t[0]=e,t[1]=n),n}function om(e){let t=(0,$.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({path:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,Z.jsx)(sm,{...r,path:n}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}function sm(e){let t=(0,$.c)(18),{scope:n,context:r,interaction:i,base:a,path:o}=e,{connection:s}=r,c=Pi(n,s,a);if(B(c.result)){let e;t[0]===c.result?e=t[1]:(e=Ll(B(c.result)?le(c.result.cause):void 0),t[0]=c.result,t[1]=e);let n;t[2]===e?n=t[3]:(n=(0,Z.jsx)(im,{title:`Branch could not be compared`,description:e}),t[2]=e,t[3]=n);let r;t[4]===c.refresh?r=t[5]:(r=(0,Z.jsx)(h,{variant:`outline`,onClick:c.refresh,children:`Compare again`}),t[4]=c.refresh,t[5]=r);let i;return t[6]!==n||t[7]!==r?(i=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center p-4`,children:[n,r]}),t[6]=n,t[7]=r,t[8]=i):i=t[8],i}if(!y(c.result)){let e;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(cm,{}),t[9]=e):e=t[9],e}if(c.result.value.base===void 0){let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(im,{title:`No default branch`,description:`Choose the branch this one is compared against in the Branch list.`}),t[10]=e):e=t[10],e}let l;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(cm,{}),t[11]=l):l=t[11];let u;return t[12]!==c.result.value||t[13]!==r||t[14]!==i||t[15]!==o||t[16]!==n?(u=(0,Z.jsx)(Q.Suspense,{fallback:l,children:(0,Z.jsx)(lm,{scope:n,context:r,interaction:i,branch:c.result.value,path:o})}),t[12]=c.result.value,t[13]=r,t[14]=i,t[15]=o,t[16]=n,t[17]=u):u=t[17],u}function cm(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`p`,{role:`status`,className:`p-4 text-sm`,children:`Comparing the branch…`}),e[0]=t):t=e[0],t}function lm(e){let t=(0,$.c)(26),{scope:n,context:r,interaction:i,branch:a,path:o}=e,s;t[0]===a?s=t[1]:(s=zu(a),t[0]=a,t[1]=s);let c=s,l=Gf(n,r,c);if(a.base===null||a.base===void 0)return null;let u;t[2]!==a.files||t[3]!==l||t[4]!==o?(u=ju(a.files,l,o==null?void 0:[o]),t[2]=a.files,t[3]=l,t[4]=o,t[5]=u):u=t[5];let d=u;if(o!=null&&d.length===0){let e;t[6]===a.base.ref?e=t[7]:(e=Fl(a.base.ref),t[6]=a.base.ref,t[7]=e);let n=`${o} has no committed change since ${e}.`,r;return t[8]===n?r=t[9]:(r=(0,Z.jsx)(im,{title:`Not changed on this branch`,description:n}),t[8]=n,t[9]=r),r}let f=o!=null,p=a.base.ref,m=a.head,h=a.mergeBaseOid??``,g=a.commits,_;t[10]===a?_=t[11]:(_=Il(a),t[10]=a,t[11]=_);let v;t[12]!==a.base.ref||t[13]!==a.commits||t[14]!==a.head||t[15]!==h||t[16]!==_?(v={base:p,head:m,mergeBaseOid:h,commits:g,diffRange:_},t[12]=a.base.ref,t[13]=a.commits,t[14]=a.head,t[15]=h,t[16]=_,t[17]=v):v=t[17];let y;return t[18]!==r||t[19]!==i||t[20]!==d||t[21]!==c||t[22]!==n||t[23]!==f||t[24]!==v?(y=(0,Z.jsx)(um,{scope:n,context:r,interaction:i,range:c,items:d,single:f,branch:v}),t[18]=r,t[19]=i,t[20]=d,t[21]=c,t[22]=n,t[23]=f,t[24]=v,t[25]=y):y=t[25],y}function um(e){let t=(0,$.c)(51),{scope:n,context:r,interaction:i,range:a,items:o,single:s,branch:c}=e,{connection:l}=r,u=ge(V(Jr(n,l))),d;t[0]===c.head.oid?d=t[1]:(d={of:c.head.oid,shown:25},t[0]=c.head.oid,t[1]=d);let[f,p]=(0,Q.useState)(d),m=f.of===c.head.oid?f.shown:25,h=o.slice(0,m),g=Br(n,l,c.diffRange,h.map(Pl)),_;t[2]===g.patches?_=t[3]:(_=e=>g.patches.get(Pl(e).join(`\0`)),t[2]=g.patches,t[3]=_);let v=_,y;t[4]!==r||t[5]!==a||t[6]!==n?(y=(e,t)=>(0,Z.jsx)(tm,{scope:n,context:r,path:e.path,fingerprint:e.fingerprint,status:e.reviewStatus,range:a,compact:t},`review:${e.path}`),t[4]=r,t[5]=a,t[6]=n,t[7]=y):y=t[7];let b=y,x;t[8]!==c.base||t[9]!==c.head.oid||t[10]!==b||t[11]!==v?(x=e=>{let t=Hr(c.head.oid,e,v(e));return t==null?[]:[{...t,id:`branch:${e.path}`,comment:{filePath:e.path,comparison:{kind:`branch`,base:c.base},revision:c.head.oid,contentFingerprint:e.fingerprint},review:{path:e.path,fingerprint:e.fingerprint,reviewed:e.reviewStatus===`reviewed`,stale:e.reviewStatus===`stale`,control:b(e,!0)}}]},t[8]=c.base,t[9]=c.head.oid,t[10]=b,t[11]=v,t[12]=x):x=t[12];let S=h.flatMap(x),C=new Set(S.map(dm)),w=h.filter(e=>!C.has(e.path)),T=o.length-h.length,E=u?.changes.length??0,[D]=o,O;t[13]===i.reveal?O=t[14]:(O=i.reveal?.compose?{commentRequest:i.reveal.nonce}:{},t[13]=i.reveal,t[14]=O);let k;t[15]!==r||t[16]!==b||t[17]!==D||t[18]!==o||t[19]!==a||t[20]!==n||t[21]!==s?(k=e=>s&&D?(0,Z.jsx)(Qp,{title:Pu(D.path),subtitle:`${D.path} · on the branch`,children:b(D,!1)}):(0,Z.jsxs)(Qp,{title:`Branch`,subtitle:`${o.length} ${o.length===1?`file`:`files`} changed`,children:[e,(0,Z.jsx)(nm,{scope:n,context:r,entries:o,range:a})]}),t[15]=r,t[16]=b,t[17]=D,t[18]=o,t[19]=a,t[20]=n,t[21]=s,t[22]=k):k=t[22];let A;t[23]!==c||t[24]!==b||t[25]!==g.failed||t[26]!==g.retry||t[27]!==w||t[28]!==v||t[29]!==s||t[30]!==E?(A=()=>(0,Z.jsx)(fm,{branch:c,single:s,uncommitted:E,omitted:w,patchOf:v,failed:g.failed,onRetry:g.retry,control:e=>b(e,!0)}),t[23]=c,t[24]=b,t[25]=g.failed,t[26]=g.retry,t[27]=w,t[28]=v,t[29]=s,t[30]=E,t[31]=A):A=t[31];let j;t[32]!==r||t[33]!==S||t[34]!==i||t[35]!==a||t[36]!==n||t[37]!==O||t[38]!==k||t[39]!==A?(j=(0,Z.jsx)(Hp,{scope:n,context:r,interaction:i,range:a,...O,entries:S,toolbar:k,header:A}),t[32]=r,t[33]=S,t[34]=i,t[35]=a,t[36]=n,t[37]=O,t[38]=k,t[39]=A,t[40]=j):j=t[40];let M;t[41]!==c.head.oid||t[42]!==m?(M=()=>p({of:c.head.oid,shown:m+25}),t[41]=c.head.oid,t[42]=m,t[43]=M):M=t[43];let N;t[44]!==g.pending||t[45]!==T||t[46]!==M?(N=(0,Z.jsx)($p,{more:T,pending:g.pending,onReadMore:M}),t[44]=g.pending,t[45]=T,t[46]=M,t[47]=N):N=t[47];let P;return t[48]!==N||t[49]!==j?(P=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[j,N]}),t[48]=N,t[49]=j,t[50]=P):P=t[50],P}function dm(e){return e.path}function fm(e){let t=(0,$.c)(24),{branch:n,single:r,uncommitted:i,omitted:a,patchOf:o,failed:s,onRetry:c,control:l}=e,u;t[0]===n.head.branch?u=t[1]:(u=n.head.branch===null||n.head.branch===void 0?`This commit`:Fl(n.head.branch),t[0]=n.head.branch,t[1]=u);let d=u,f;t[2]!==n.base||t[3]!==n.commits||t[4]!==n.head.oid||t[5]!==n.mergeBaseOid||t[6]!==d||t[7]!==r?(f=!r&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`h2`,{className:`text-sm font-semibold`,children:[d,` since `,Fl(n.base)]}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-2xs text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{children:[n.commits,` `,n.commits===1?`commit`:`commits`]}),(0,Z.jsxs)(`span`,{children:[`from`,` `,(0,Z.jsx)(`span`,{className:`font-mono`,children:ff(n.mergeBaseOid)}),` `,`to `,(0,Z.jsx)(`span`,{className:`font-mono`,children:ff(n.head.oid)})]}),(0,Z.jsx)(Re,{variant:`secondary`,className:`h-4`,children:Fl(n.base)})]})]}),t[2]=n.base,t[3]=n.commits,t[4]=n.head.oid,t[5]=n.mergeBaseOid,t[6]=d,t[7]=r,t[8]=f):f=t[8];let p;t[9]===i?p=t[10]:(p=i>0&&(0,Z.jsx)(`p`,{className:`mt-1 text-2xs text-muted-foreground`,children:`Uncommitted changes are not part of the branch review. Review them under Uncommitted.`}),t[9]=i,t[10]=p);let m;t[11]!==s||t[12]!==c?(m=s&&(0,Z.jsxs)(`p`,{className:`mt-3 flex items-center gap-2 text-xs text-muted-foreground`,children:[`Some patches could not be read.`,(0,Z.jsx)(h,{size:`xs`,variant:`outline`,onClick:c,children:`Try again`})]}),t[11]=s,t[12]=c,t[13]=m):m=t[13];let g;t[14]!==l||t[15]!==s||t[16]!==a||t[17]!==o?(g=a.length>0&&(0,Z.jsx)(`ul`,{className:`mt-3 space-y-1.5`,"aria-label":`Changes without code preview`,children:a.map(e=>(0,Z.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 rounded-lg border bg-muted/25 px-3 py-2 text-xs`,children:[l(e),(0,Z.jsx)(`span`,{className:`truncate font-mono font-medium`,children:e.path}),(0,Z.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[e.status,` · `,pm(e,o(e),s)]})]},e.path))}),t[14]=l,t[15]=s,t[16]=a,t[17]=o,t[18]=g):g=t[18];let _;return t[19]!==f||t[20]!==p||t[21]!==m||t[22]!==g?(_=(0,Z.jsxs)(`section`,{className:`mx-4 mt-3 rounded-xl border px-4 py-3`,children:[f,p,m,g]}),t[19]=f,t[20]=p,t[21]=m,t[22]=g,t[23]=_):_=t[23],_}function pm(e,t,n){return e.oldMode===`160000`||e.newMode===`160000`?`Submodule change`:t===void 0?n?`The patch could not be read`:`Reading the patch`:t.kind===`binary`?`Binary change`:t.kind===`omitted`?t.reason===`size-limit`?`Too large to show`:`Cannot be shown`:`No code change`}var mm=e=>[...new Set([e.oldPath,e.newPath].filter(e=>e!=null))],hm=e=>mm(e).join(`\0`);function gm(e){let t=(0,$.c)(46),{scope:n,context:r,interaction:i,oid:a}=e,{connection:o}=r,{reveal:s}=i,c=s?.anchor.comparison?.kind===`commit`?s.anchor.comparison.parent:1,l=s?.nonce,u;t[0]!==c||t[1]!==l?(u={nonce:l,parent:c},t[0]=c,t[1]=l,t[2]=u):u=t[2];let[d,f]=(0,Q.useState)(u),p=d.nonce===s?.nonce?d.parent:c,[,m]=(0,Q.useTransition)(),g=xf(o,n,a,p),_=`${a}:${p}`,v;t[3]===_?v=t[4]:(v={of:_,shown:25},t[3]=_,t[4]=v);let[y,b]=(0,Q.useState)(v),x=y.of===`${a}:${p}`?y.shown:25,S;t[5]!==a||t[6]!==p||t[7]!==x?(S=()=>b({of:`${a}:${p}`,shown:x+25}),t[5]=a,t[6]=p,t[7]=x,t[8]=S):S=t[8];let C=S,w=g.files.slice(0,x),T=w.map(vm),E=Ii(o,n,a,p,T),D;t[9]===E.patches?D=t[10]:(D=e=>E.patches.get(hm(e)),t[9]=E.patches,t[10]=D);let O=D,k;t[11]!==a||t[12]!==p||t[13]!==O?(k=e=>{let t=Hr(a,e,O(e));return t==null?[]:[{...t,id:`${t.id}:${p}`,comment:{filePath:t.path,revision:a,comparison:{kind:`commit`,parent:p}}}]},t[11]=a,t[12]=p,t[13]=O,t[14]=k):k=t[14];let A=w.flatMap(k),j;t[15]!==a||t[16]!==O?(j=e=>(Hr(a,e,O(e))??null)===null,t[15]=a,t[16]=O,t[17]=j):j=t[17];let M=w.filter(j),N=g.files.length-w.length,P;t[18]!==g.commit||t[19]!==g.files.length||t[20]!==a||t[21]!==p||t[22]!==s?.nonce||t[23]!==m?(P=e=>(0,Z.jsxs)(Qp,{title:(0,Z.jsx)(`span`,{className:`font-mono`,children:ff(a)}),subtitle:`${g.files.length} file${g.files.length===1?``:`s`} changed`,children:[g.commit.parentOids.length>1&&(0,Z.jsx)(Ti,{value:String(p),onValueChange:e=>m(()=>f({nonce:s?.nonce,parent:Number(e)})),children:(0,Z.jsx)(Ri,{className:`h-7`,children:g.commit.parentOids.map(_m)})}),(0,Z.jsxs)(h,{size:`sm`,variant:`ghost`,onClick:()=>pe(a,`commit id`),children:[(0,Z.jsx)(Pe,{className:`size-3.5`}),`Copy id`]}),(0,Z.jsxs)(h,{size:`sm`,variant:`ghost`,onClick:()=>pe(Tf(g.commit),`commit message`),children:[(0,Z.jsx)(Pe,{className:`size-3.5`}),`Copy message`]}),e]}),t[18]=g.commit,t[19]=g.files.length,t[20]=a,t[21]=p,t[22]=s?.nonce,t[23]=m,t[24]=P):P=t[24];let F;t[25]!==g||t[26]!==E.failed||t[27]!==E.retry||t[28]!==a||t[29]!==M||t[30]!==O?(F=()=>(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(ym,{commit:g,oid:a,omitted:M,patchOf:O,failed:E.failed,onRetry:E.retry})}),t[25]=g,t[26]=E.failed,t[27]=E.retry,t[28]=a,t[29]=M,t[30]=O,t[31]=F):F=t[31];let I;t[32]!==r||t[33]!==A||t[34]!==i||t[35]!==n||t[36]!==F||t[37]!==P?(I=(0,Z.jsx)(Hp,{toolbar:P,scope:n,context:r,interaction:i,entries:A,header:F}),t[32]=r,t[33]=A,t[34]=i,t[35]=n,t[36]=F,t[37]=P,t[38]=I):I=t[38];let L;t[39]!==E.pending||t[40]!==N||t[41]!==C?(L=(0,Z.jsx)($p,{more:N,pending:E.pending,onReadMore:C}),t[39]=E.pending,t[40]=N,t[41]=C,t[42]=L):L=t[42];let R;return t[43]!==I||t[44]!==L?(R=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[I,L]}),t[43]=I,t[44]=L,t[45]=R):R=t[45],R}function _m(e,t){return(0,Z.jsxs)(Oi,{value:String(t+1),children:[mf(t+1),` parent ·`,` `,(0,Z.jsx)(`span`,{className:`font-mono`,children:ff(e)})]},e)}function vm(e){return mm(e)}function ym(e){let t=(0,$.c)(33),{commit:n,oid:r,omitted:i,patchOf:a,failed:o,onRetry:s}=e,c;t[0]===n.commit.subject?c=t[1]:(c=(0,Z.jsx)(`h2`,{className:`text-sm font-semibold`,children:n.commit.subject}),t[0]=n.commit.subject,t[1]=c);let l;t[2]===n.commit.body?l=t[3]:(l=n.commit.body!==null&&n.commit.body!==void 0&&(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-caption leading-relaxed text-muted-foreground`,children:n.commit.body}),t[2]=n.commit.body,t[3]=l);let u;t[4]===n.commit.bodyTruncated?u=t[5]:(u=n.commit.bodyTruncated&&(0,Z.jsx)(`p`,{className:`mt-1 text-2xs text-muted-foreground`,children:`Commit message truncated`}),t[4]=n.commit.bodyTruncated,t[5]=u);let d;t[6]===n.commit?d=t[7]:(d=n.commit!==null&&n.commit!==void 0&&(0,Z.jsxs)(`span`,{children:[n.commit.author.name,` ·`,` `,Be(n.commit.author.timestamp)]}),t[6]=n.commit,t[7]=d);let f;t[8]===r?f=t[9]:(f=(0,Z.jsx)(`span`,{className:`font-mono`,children:r}),t[8]=r,t[9]=f);let p;t[10]!==n.commit.parentOids||t[11]!==n.comparison.baseOid||t[12]!==n.comparison.kind||t[13]!==n.comparison.parentNumber?(p=n.comparison.kind===`parent`?(0,Z.jsxs)(`span`,{children:[`against`,` `,(0,Z.jsx)(`span`,{className:`font-mono`,children:ff(n.comparison.baseOid)}),n.commit.parentOids.length>1&&` (${mf(n.comparison.parentNumber)} parent of a merge)`]}):(0,Z.jsx)(`span`,{children:`root commit`}),t[10]=n.commit.parentOids,t[11]=n.comparison.baseOid,t[12]=n.comparison.kind,t[13]=n.comparison.parentNumber,t[14]=p):p=t[14];let m;t[15]===n.commit.refs?m=t[16]:(m=n.commit.refs.map(bm),t[15]=n.commit.refs,t[16]=m);let h;t[17]!==d||t[18]!==f||t[19]!==p||t[20]!==m?(h=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-2xs text-muted-foreground`,children:[d,f,p,m]}),t[17]=d,t[18]=f,t[19]=p,t[20]=m,t[21]=h):h=t[21];let g;t[22]!==o||t[23]!==i||t[24]!==s||t[25]!==a?(g=i.length>0&&(0,Z.jsx)(xm,{changes:i,patchOf:a,failed:o,onRetry:s}),t[22]=o,t[23]=i,t[24]=s,t[25]=a,t[26]=g):g=t[26];let _;return t[27]!==c||t[28]!==l||t[29]!==u||t[30]!==h||t[31]!==g?(_=(0,Z.jsxs)(`section`,{className:`mx-4 mt-3 rounded-xl border px-4 py-3`,children:[c,l,u,h,g]}),t[27]=c,t[28]=l,t[29]=u,t[30]=h,t[31]=g,t[32]=_):_=t[32],_}function bm(e){return(0,Z.jsx)(Re,{title:e,variant:`secondary`,className:`h-4`,children:pf(e)},e)}function xm(e){let t=(0,$.c)(15),{changes:n,patchOf:r,failed:i,onRetry:a}=e,o;t[0]!==i||t[1]!==a?(o=i&&(0,Z.jsxs)(`p`,{className:`mt-3 flex items-center gap-2 text-xs text-muted-foreground`,children:[`Some patches could not be read.`,(0,Z.jsx)(h,{size:`xs`,variant:`outline`,onClick:a,children:`Try again`})]}),t[0]=i,t[1]=a,t[2]=o):o=t[2];let s;if(t[3]!==n||t[4]!==i||t[5]!==r){let e;t[7]!==i||t[8]!==r?(e=e=>{let t=e.newPath??e.oldPath??`Unknown path`,n=r(e),a=e.oldMode===`160000`||e.newMode===`160000`,o=a?`Submodule change`:n===void 0?i?`The patch could not be read`:`Reading the patch`:n.kind===`binary`?`Binary change`:n.kind===`omitted`?n.reason===`size-limit`?`Too large to show`:`Cannot be shown`:`No code change`;return(0,Z.jsxs)(`li`,{className:`rounded-lg border bg-muted/25 px-3 py-2 text-xs`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate font-mono font-medium`,children:t}),(0,Z.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[e.status,` · `,o]})]}),a&&n?.kind===`text`&&(0,Z.jsx)(`pre`,{className:`mt-1 overflow-x-auto whitespace-pre-wrap font-mono text-2xs text-muted-foreground`,children:n.patch.split(`
|
|
7
|
+
`).filter(Cm).map(Sm).join(`
|
|
8
|
+
`)})]},`${e.oldPath}->${e.newPath}:${e.status}`)},t[7]=i,t[8]=r,t[9]=e):e=t[9],s=n.map(e),t[3]=n,t[4]=i,t[5]=r,t[6]=s}else s=t[6];let c;t[10]===s?c=t[11]:(c=(0,Z.jsx)(`ul`,{className:`mt-3 space-y-1.5`,"aria-label":`Changes without code preview`,children:s}),t[10]=s,t[11]=c);let l;return t[12]!==o||t[13]!==c?(l=(0,Z.jsxs)(Z.Fragment,{children:[o,c]}),t[12]=o,t[13]=c,t[14]=l):l=t[14],l}function Sm(e){return e.slice(1)}function Cm(e){return/^[+-]Subproject commit /.test(e)}function wm(e,t,n){if(t===``)return[];let r=t.toLocaleLowerCase(),i=[],a=e.split(`
|
|
9
|
+
`);for(let[e,t]of a.entries()){let a=t.toLocaleLowerCase(),o=a.indexOf(r);for(;o!==-1;){if(i.length===n)return i;i.push({line:e+1,column:o}),o=a.indexOf(r,o+r.length)}}return i}function Tm(e,t){return Math.max(0,Math.min(e,t-1))}function Em(e,t,n){return t===0?0:(Tm(e,t)+n+t)%t}function Dm(e,t,n){if(t===0)return`No results`;let r=t===n?`+`:``;return`${Tm(e,t)+1} of ${t}${r}`}function Om(e){let t=(0,$.c)(55),{text:n,focusRequest:r,onReveal:i,onClose:a}=e,o=(0,Q.useRef)(null),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(0),d;t[0]!==s||t[1]!==n?(d=wm(n,s,je),t[0]=s,t[1]=n,t[2]=d):d=t[2];let f=d,p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>{o.current?.focus(),o.current?.select()},t[3]=p):p=t[3];let m;t[4]===r?m=t[5]:(m=[r],t[4]=r,t[5]=m),(0,Q.useEffect)(p,m);let h;t[6]!==f||t[7]!==i?(h=(e,t)=>{let n=t===void 0?f:t;u(e);let r=n[e];r&&i(r.line)},t[6]=f,t[7]=i,t[8]=h):h=t[8];let g=h,_;t[9]!==l||t[10]!==f.length||t[11]!==g?(_=e=>g(Em(l,f.length,e)),t[9]=l,t[10]=f.length,t[11]=g,t[12]=_):_=t[12];let v=_,y;t[13]===a?y=t[14]:(y=e=>{e.key===`Escape`&&(e.preventDefault(),a())},t[13]=a,t[14]=y);let b;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(Dr,{children:(0,Z.jsx)(ia,{})}),t[15]=b):b=t[15];let x;t[16]!==g||t[17]!==n?(x=e=>{c(e.target.value),g(0,wm(n,e.target.value,je))},t[16]=g,t[17]=n,t[18]=x):x=t[18];let S;t[19]===v?S=t[20]:(S=e=>{e.key===`Enter`&&(e.preventDefault(),v(e.shiftKey?-1:1))},t[19]=v,t[20]=S);let C;t[21]!==s||t[22]!==x||t[23]!==S?(C=(0,Z.jsx)(Ur,{ref:o,"aria-label":`Find in file`,placeholder:`Find in file`,value:s,onChange:x,onKeyDown:S}),t[21]=s,t[22]=x,t[23]=S,t[24]=C):C=t[24];let w;t[25]!==l||t[26]!==f.length||t[27]!==s?(w=s!==``&&(0,Z.jsx)(Fi,{role:`status`,children:Dm(l,f.length,1e4)}),t[25]=l,t[26]=f.length,t[27]=s,t[28]=w):w=t[28];let T=f.length===0,E;t[29]===v?E=t[30]:(E=()=>v(-1),t[29]=v,t[30]=E);let D;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(We,{}),t[31]=D):D=t[31];let O;t[32]!==T||t[33]!==E?(O=(0,Z.jsx)(Er,{size:`icon-xs`,"aria-label":`Previous match`,disabled:T,onClick:E,children:D}),t[32]=T,t[33]=E,t[34]=O):O=t[34];let k=f.length===0,A;t[35]===v?A=t[36]:(A=()=>v(1),t[35]=v,t[36]=A);let j;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Z.jsx)(Ne,{}),t[37]=j):j=t[37];let M;t[38]!==k||t[39]!==A?(M=(0,Z.jsx)(Er,{size:`icon-xs`,"aria-label":`Next match`,disabled:k,onClick:A,children:j}),t[38]=k,t[39]=A,t[40]=M):M=t[40];let N;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(rt,{}),t[41]=N):N=t[41];let P;t[42]===a?P=t[43]:(P=(0,Z.jsx)(Er,{size:`icon-xs`,"aria-label":`Close find`,onClick:a,children:N}),t[42]=a,t[43]=P);let F;t[44]!==w||t[45]!==O||t[46]!==M||t[47]!==P?(F=(0,Z.jsxs)(Dr,{align:`inline-end`,children:[w,O,M,P]}),t[44]=w,t[45]=O,t[46]=M,t[47]=P,t[48]=F):F=t[48];let I;t[49]!==C||t[50]!==F?(I=(0,Z.jsxs)(Zr,{className:`w-full max-w-sm`,children:[b,C,F]}),t[49]=C,t[50]=F,t[51]=I):I=t[51];let L;return t[52]!==I||t[53]!==y?(L=(0,Z.jsx)(`div`,{role:`search`,className:`flex shrink-0 justify-end border-b px-3 py-1.5`,onKeyDown:y,children:I}),t[52]=I,t[53]=y,t[54]=L):L=t[54],L}function km(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=Mi(e.path)?(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-auto`,children:[(0,Z.jsx)(Pm,{path:e.path,copy:!1,children:(0,Z.jsxs)(mi,{className:`max-w-full flex-wrap justify-end`,children:[(0,Z.jsx)(Fm,{path:e.path,onOpen:e.onOpen}),(0,Z.jsx)(Im,{path:e.path})]})}),(0,Z.jsx)(Zi,{scope:e.scope,path:e.path,connection:e.context.connection})]}):(0,Z.jsx)(Am,{...e}),t[0]=e,t[1]=n),n}function Am(e){let t=(0,$.c)(16),n;t[0]===e.path?n=t[1]:(n=e.path.split(`/`).slice(0,-1).join(`/`),t[0]=e.path,t[1]=n);let r=n,{connection:i}=e.context,a=Ir(i,e.scope,r),o;t[2]===e.path?o=t[3]:(o=e.path.split(`/`).at(-1),t[2]=e.path,t[3]=o);let s=o,c;if(t[4]!==a.entries||t[5]!==s){let e;t[7]===s?e=t[8]:(e=e=>e.name===s,t[7]=s,t[8]=e),c=a.entries.find(e),t[4]=a.entries,t[5]=s,t[6]=c}else c=t[6];let l=c;if(l?.kind===`symlink`){let n=`Not followed: symlink to ${l.target??`an unknown target`}`,r;return t[9]!==e.path||t[10]!==n?(r=(0,Z.jsx)(jm,{path:e.path,message:n}),t[9]=e.path,t[10]=n,t[11]=r):r=t[11],r}if(l?.kind===`submodule`){let n;return t[12]===e.path?n=t[13]:(n=(0,Z.jsx)(jm,{path:e.path,message:`Not followed: submodule`}),t[12]=e.path,t[13]=n),n}let u;return t[14]===e?u=t[15]:(u=(0,Z.jsx)(Mm,{...e}),t[14]=e,t[15]=u),u}function jm(e){let t=(0,$.c)(7),{path:n,message:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(Pm,{path:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Z.jsx)(`div`,{className:`grid min-h-48 flex-1 place-items-center p-6`,children:(0,Z.jsx)(im,{title:`Not shown`,description:r})}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Mm(e){let t=(0,$.c)(19),{scope:n,context:r,interaction:i,path:a,onOpen:o}=e,{connection:s}=r,c=qr(s,n,a),l=`kind`in c,{draft:u,state:d,reset:f}=Hn(s,n,a,l?``:c.text,l?``:c.contentFingerprint??``);if(l&&d.owner===null&&d.text===d.savedText){let e;return t[0]!==c.reason||t[1]!==a?(e=(0,Z.jsx)(jm,{path:a,message:c.reason}),t[0]=c.reason,t[1]=a,t[2]=e):e=t[2],e}let p;t[3]===l?p=t[4]:(p=l&&(0,Z.jsx)(`p`,{role:`alert`,className:`border-b bg-graph-4/10 px-3.5 py-2 text-xs text-graph-4`,children:`The file is no longer readable. Your unsaved draft is still available below.`}),t[3]=l,t[4]=p);let m=l?d.savedText:c.text,h=l?d.fingerprint:c.contentFingerprint,g;t[5]!==r||t[6]!==u||t[7]!==i||t[8]!==o||t[9]!==a||t[10]!==f||t[11]!==n||t[12]!==d||t[13]!==m||t[14]!==h?(g=(0,Z.jsx)(Nm,{scope:n,context:r,interaction:i,path:a,text:m,contentFingerprint:h,draft:u,draftState:d,reset:f,onOpen:o}),t[5]=r,t[6]=u,t[7]=i,t[8]=o,t[9]=a,t[10]=f,t[11]=n,t[12]=d,t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;return t[16]!==p||t[17]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[p,g]}),t[16]=p,t[17]=g,t[18]=_):_=t[18],_}function Nm(e){let t=(0,$.c)(76),{scope:n,context:r,interaction:i,path:a,text:o,contentFingerprint:s,draft:c,draftState:l,reset:u,onOpen:d}=e,{preferences:f}=Tn(),{connection:p}=r,m=zr(n,p),g;t[0]===a?g=t[1]:(g=Lm(a),t[0]=a,t[1]=g);let _=g,v;if(t[2]!==m.changes||t[3]!==a){let e;t[5]===a?e=t[6]:(e=e=>e.path===a,t[5]=a,t[6]=e),v=m.changes.some(e),t[2]=m.changes,t[3]=a,t[4]=v}else v=t[4];let y=v,b;t[7]!==_||t[8]!==f?(b=()=>Rm(_,f),t[7]=_,t[8]=f,t[9]=b):b=t[9];let[x,S]=(0,Q.useState)(b),{reveal:C,active:w}=i,T,E;t[10]!==a||t[11]!==C?(T=()=>{C?.anchor.comparison?.kind===`file`&&C.anchor.filePath===a&&S(`source`)},E=[C,a],t[10]=a,t[11]=C,t[12]=T,t[13]=E):(T=t[12],E=t[13]),(0,Q.useEffect)(T,E);let[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(),[j,M]=(0,Q.useState)(),N=(0,Q.useId)();di(c,N,s);let P=_===`code`||x===`source`,F;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>A(Date.now()),t[14]=F):F=t[14];let I=w&&P&&!D,L;t[15]===I?L=t[16]:(L={enabled:I,ignoreInputs:!1,conflictBehavior:`allow`},t[15]=I,t[16]=L),vn(In.findInFile,F,L);let R=l.diskChanged.has(N)?`Changed on disk just now`:``,z;t[17]===R?z=t[18]:(z=(0,Z.jsx)(`span`,{"aria-live":`polite`,className:`hidden text-xs text-muted-foreground xl:inline`,children:R}),t[17]=R,t[18]=z);let B;t[19]!==_||t[20]!==x?(B=_!==`code`&&(0,Z.jsx)(Ti,{value:x,onValueChange:e=>{(e===`rendered`||e===`source`)&&S(e)},children:(0,Z.jsxs)(Ri,{className:`h-7`,children:[(0,Z.jsx)(Oi,{value:`rendered`,children:_===`markdown`?`Reader`:`Preview`}),(0,Z.jsx)(Oi,{value:`source`,children:`Source`})]})}),t[19]=_,t[20]=x,t[21]=B):B=t[21];let V;t[22]!==z||t[23]!==B?(V=(0,Z.jsxs)(Z.Fragment,{children:[z,B]}),t[22]=z,t[23]=B,t[24]=V):V=t[24];let H=V,U;t[25]!==s||t[26]!==c||t[27]!==l.owner||t[28]!==l.savedText||t[29]!==l.text||t[30]!==N?(U=s&&(0,Z.jsxs)(h,{variant:`ghost`,size:`xs`,disabled:l.owner!==null&&l.owner!==N,title:l.owner&&l.owner!==N?`Editing in another pane`:void 0,onClick:()=>{c.claim(N)&&O(!0)},children:[(0,Z.jsx)(ki,{}),(0,Z.jsx)(`span`,{className:`max-narrow:sr-only`,children:l.text===l.savedText?`Edit`:`Resume edit`})]}),t[25]=s,t[26]=c,t[27]=l.owner,t[28]=l.savedText,t[29]=l.text,t[30]=N,t[31]=U):U=t[31];let W;t[32]!==y||t[33]!==d||t[34]!==a?(W=y&&(0,Z.jsxs)(h,{variant:`ghost`,size:`xs`,onClick:()=>d({kind:`change`,path:a}),children:[(0,Z.jsx)(pa,{}),(0,Z.jsx)(`span`,{className:`max-narrow:sr-only`,children:`Open diff`})]}),t[32]=y,t[33]=d,t[34]=a,t[35]=W):W=t[35];let G;t[36]!==d||t[37]!==a?(G=(0,Z.jsx)(Fm,{path:a,onOpen:d}),t[36]=d,t[37]=a,t[38]=G):G=t[38];let K;t[39]===a?K=t[40]:(K=(0,Z.jsx)(Im,{path:a}),t[39]=a,t[40]=K);let q;t[41]!==U||t[42]!==W||t[43]!==G||t[44]!==K?(q=(0,Z.jsxs)(Z.Fragment,{children:[U,W,G,K]}),t[41]=U,t[42]=W,t[43]=G,t[44]=K,t[45]=q):q=t[45];let J=q;if(D){let e;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>O(!1),t[46]=e):e=t[46];let n;t[47]!==s||t[48]!==u||t[49]!==o?(n=()=>{u(o,s??``),O(!1)},t[47]=s,t[48]=u,t[49]=o,t[50]=n):n=t[50];let r;t[51]===a?r=t[52]:(r=e=>(0,Z.jsx)(Pm,{path:a,children:e}),t[51]=a,t[52]=r);let i;return t[53]!==w||t[54]!==y||t[55]!==c||t[56]!==l||t[57]!==N||t[58]!==a||t[59]!==n||t[60]!==r?(i=(0,Z.jsx)(oi,{owner:N,path:a,draft:c,state:l,active:w,changed:y,onDone:e,onDiscard:n,renderToolbar:r}),t[53]=w,t[54]=y,t[55]=c,t[56]=l,t[57]=N,t[58]=a,t[59]=n,t[60]=r,t[61]=i):i=t[61],i}let ee;return t[62]!==J||t[63]!==p||t[64]!==s||t[65]!==r||t[66]!==k||t[67]!==j||t[68]!==i||t[69]!==_||t[70]!==H||t[71]!==x||t[72]!==a||t[73]!==n||t[74]!==o?(ee=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-card`,children:x===`rendered`&&_===`markdown`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Pm,{path:a,copy:!1,children:[H,(0,Z.jsx)(mi,{className:`max-w-full flex-wrap justify-end`,children:J})]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,Z.jsx)(yr,{text:o,className:`mx-auto max-w-[78ch] px-6 py-6`})})]}):x===`rendered`&&_===`html`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Pm,{path:a,copy:!1,children:[H,(0,Z.jsx)(mi,{className:`max-w-full flex-wrap justify-end`,children:J})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,children:[(0,Z.jsx)(`p`,{className:`border-b bg-muted/40 px-3.5 py-1.5 text-2xs text-muted-foreground`,children:`Sandboxed preview: scripts run, and cannot read Porcelain, your cookies or the review API, load anything from the network, submit a form, or move the page around them. A script can still send what it sees out by sending this frame to another address.`}),(0,Z.jsx)(ci,{scope:n,path:a,html:o,connection:p})]})]}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[k!==void 0&&(0,Z.jsx)(Om,{text:o,focusRequest:k,onReveal:e=>M({line:e,nonce:Date.now()}),onClose:()=>A(void 0)}),(0,Z.jsx)(Hp,{scope:n,context:r,interaction:i,headerLeading:H,headerActions:J,...j===void 0?{}:{foundLine:j},entries:[{...op(`file:${a}`,a,o),...s?{comment:{filePath:a,comparison:{kind:`file`},contentFingerprint:s}}:{}}]})]})}),t[62]=J,t[63]=p,t[64]=s,t[65]=r,t[66]=k,t[67]=j,t[68]=i,t[69]=_,t[70]=H,t[71]=x,t[72]=a,t[73]=n,t[74]=o,t[75]=ee):ee=t[75],ee}function Pm(e){let t=(0,$.c)(24),{path:n,children:r,copy:i}=e,a=i===void 0||i,o=n.lastIndexOf(`/`)+1,s;t[0]!==n||t[1]!==o?(s=n.slice(0,o),t[0]=n,t[1]=o,t[2]=s):s=t[2];let c=s,l;t[3]!==n||t[4]!==o?(l=n.slice(o),t[3]=n,t[4]=o,t[5]=l):l=t[5];let u=l,d;t[6]===n?d=t[7]:(d=(0,Z.jsx)(hi,{path:n,className:`size-4 shrink-0`}),t[6]=n,t[7]=d);let f;t[8]===c?f=t[9]:(f=c&&(0,Z.jsx)(`span`,{className:`truncate font-normal text-muted-foreground`,children:c}),t[8]=c,t[9]=f);let p;t[10]===u?p=t[11]:(p=(0,Z.jsx)(`span`,{className:`shrink-0`,children:u}),t[10]=u,t[11]=p);let m;t[12]!==d||t[13]!==f||t[14]!==p?(m=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[d,f,p]}),t[12]=d,t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]!==a||t[17]!==n?(h=a&&(0,Z.jsx)(Im,{path:n}),t[16]=a,t[17]=n,t[18]=h):h=t[18];let g;return t[19]!==r||t[20]!==n||t[21]!==m||t[22]!==h?(g=(0,Z.jsxs)(Qp,{titleLabel:n,title:m,children:[r,h]}),t[19]=r,t[20]=n,t[21]=m,t[22]=h,t[23]=g):g=t[23],g}function Fm(e){let t=(0,$.c)(7),{path:n,onOpen:r}=e,i;t[0]!==r||t[1]!==n?(i=()=>r({kind:`timeline`,path:n}),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Si,{}),o=(0,Z.jsx)(`span`,{className:`max-narrow:sr-only`,children:`Timeline`}),t[3]=a,t[4]=o):(a=t[3],o=t[4]);let s;return t[5]===i?s=t[6]:(s=(0,Z.jsxs)(h,{variant:`ghost`,size:`xs`,"aria-label":`Timeline`,title:`Timeline`,onClick:i,children:[a,o]}),t[5]=i,t[6]=s),s}function Im(e){let t=(0,$.c)(6),{path:n}=e,r;t[0]===n?r=t[1]:(r=()=>pe(n,`path`),t[0]=n,t[1]=r);let i,a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(Pe,{}),a=(0,Z.jsx)(`span`,{className:`max-narrow:sr-only`,children:`Copy path`}),t[2]=i,t[3]=a):(i=t[2],a=t[3]);let o;return t[4]===r?o=t[5]:(o=(0,Z.jsxs)(h,{variant:`ghost`,size:`xs`,"aria-label":`Copy path`,title:`Copy path`,onClick:r,children:[i,a]}),t[4]=r,t[5]=o),o}function Lm(e){let t=e.toLowerCase();return t.endsWith(`.md`)||t.endsWith(`.mdx`)?`markdown`:t.endsWith(`.html`)||t.endsWith(`.htm`)?`html`:`code`}function Rm(e,t){return e===`markdown`?t.markdownDefault===`reader`?`rendered`:`source`:e===`html`&&t.htmlDefault===`preview`?`rendered`:`source`}function zm(e){let t=(0,$.c)(6),{scope:n,context:r,absent:i,children:a}=e,o=Ad(n,r),s=o.review?.active?o.review:null;if(f(o.result)){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`p`,{role:`status`,className:`p-4 text-sm`,children:`Loading review…`}),t[0]=e):e=t[0],e}if(!s){let e;return t[1]===i?e=t[2]:(e=(0,Z.jsx)(im,{title:`No review here`,description:i}),t[1]=i,t[2]=e),e}let c;return t[3]!==a||t[4]!==s?(c=a(s),t[3]=a,t[4]=s,t[5]=c):c=t[5],c}function Bm(e){let t=(0,$.c)(3),[n,r]=(0,Q.useState)(),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(!e)return;let t=URL.createObjectURL(new Blob([Rd(e)],{type:e.mediaType}));return r({file:e,url:t}),()=>URL.revokeObjectURL(t)},a=[e],t[0]=e,t[1]=i,t[2]=a),(0,Q.useEffect)(i,a),n!==void 0&&n.file===e?n.url:void 0}function Vm(e,t,n){let r=(0,$.c)(4),i;return r[0]!==t.connection||r[1]!==n||r[2]!==e?(i=od({scope:e,connection:t.connection,proofId:n}),r[0]=t.connection,r[1]=n,r[2]=e,r[3]=i):i=r[3],xe(i)}function Hm(e,t,n){let r=t.find(t=>t.id===e.layerId);if(!r)return;let i=r.steps.find(t=>t.id===e.stepId);return n?i?.title:i?`${r.title} · ${i.title}`:r.title}function Um(e){let t=(0,$.c)(13),{scope:n,context:r,proof:i,layers:a,inLayer:o}=e,s=o!==void 0&&o,c;t[0]!==s||t[1]!==a||t[2]!==i.checks?(c=i.checks.length>0&&(0,Z.jsxs)(`section`,{"aria-label":`Checks`,className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground`,children:`Checks`}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:Pd(i.checks).map((e,t)=>(0,Z.jsx)(Wm,{check:e,target:Hm(e,a,s)},`${e.result}:${e.name}:${t}`))})]}),t[0]=s,t[1]=a,t[2]=i.checks,t[3]=c):c=t[3];let l;t[4]!==r||t[5]!==s||t[6]!==a||t[7]!==i.assets||t[8]!==n?(l=i.assets.length>0&&(0,Z.jsxs)(`section`,{"aria-label":`Attachments`,className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground`,children:`Attachments`}),(0,Z.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,children:i.assets.map(e=>(0,Z.jsx)(`li`,{className:`min-w-0`,children:(0,Z.jsx)(Gm,{scope:n,context:r,asset:e,target:Hm(e,a,s)})},e.id))})]}),t[4]=r,t[5]=s,t[6]=a,t[7]=i.assets,t[8]=n,t[9]=l):l=t[9];let u;return t[10]!==c||t[11]!==l?(u=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12],u}function Wm(e){let t=(0,$.c)(35),{check:n,target:r}=e,i=n.result===`fail`,a=n.result===`pass`?nr:i?ja:ka,o=n.name,s;t[0]===n.result?s=t[1]:(s=Ld(n.result),t[0]=n.result,t[1]=s);let c=`${o}: ${s}`,l=n.result,u=i&&`border-destructive/50 bg-destructive/5`,d;t[2]===u?d=t[3]:(d=I(`rounded-lg border px-3 py-2`,u),t[2]=u,t[3]=d);let f=n.result===`pass`&&`text-graph-2`,p=i&&`text-destructive`,m=n.result===`skipped`&&`text-muted-foreground`,h;t[4]!==f||t[5]!==p||t[6]!==m?(h=I(`size-4 shrink-0`,f,p,m),t[4]=f,t[5]=p,t[6]=m,t[7]=h):h=t[7];let g;t[8]!==a||t[9]!==h?(g=(0,Z.jsx)(a,{"aria-hidden":!0,className:h}),t[8]=a,t[9]=h,t[10]=g):g=t[10];let _;t[11]===n.name?_=t[12]:(_=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:n.name}),t[11]=n.name,t[12]=_);let v=i?`font-medium text-destructive`:`text-muted-foreground`,y;t[13]===v?y=t[14]:(y=I(`shrink-0 text-xs`,v),t[13]=v,t[14]=y);let b;t[15]===n.result?b=t[16]:(b=Ld(n.result),t[15]=n.result,t[16]=b);let x;t[17]!==y||t[18]!==b?(x=(0,Z.jsx)(`span`,{className:y,children:b}),t[17]=y,t[18]=b,t[19]=x):x=t[19];let S;t[20]!==g||t[21]!==_||t[22]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[g,_,x]}),t[20]=g,t[21]=_,t[22]=x,t[23]=S):S=t[23];let C;t[24]===r?C=t[25]:(C=r&&(0,Z.jsx)(`p`,{className:`mt-0.5 truncate pl-6 text-xs text-muted-foreground`,children:r}),t[24]=r,t[25]=C);let w;t[26]===n.output?w=t[27]:(w=n.output&&(0,Z.jsx)(`pre`,{className:`mt-2 max-h-48 overflow-auto rounded-md bg-muted p-2 font-mono text-xs whitespace-pre-wrap`,children:n.output}),t[26]=n.output,t[27]=w);let T;return t[28]!==n.result||t[29]!==S||t[30]!==C||t[31]!==w||t[32]!==c||t[33]!==d?(T=(0,Z.jsxs)(`li`,{"aria-label":c,"data-result":l,className:d,children:[S,C,w]}),t[28]=n.result,t[29]=S,t[30]=C,t[31]=w,t[32]=c,t[33]=d,t[34]=T):T=t[34],T}function Gm(e){let t=(0,$.c)(34),{scope:n,context:r,asset:i,target:a}=e,o;t[0]===i.title?o=t[1]:(o=(0,Z.jsx)(`span`,{className:`truncate text-sm`,children:i.title}),t[0]=i.title,t[1]=o);let s;t[2]===a?s=t[3]:(s=a&&(0,Z.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:a}),t[2]=a,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,Z.jsxs)(`figcaption`,{className:`flex min-w-0 flex-col px-1 pt-1.5`,children:[o,s]}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l=c;if(i.kind===`link`){let e;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(za,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),t[7]=e):e=t[7];let n;t[8]===i.title?n=t[9]:(n=(0,Z.jsx)(`span`,{className:`truncate`,children:i.title}),t[8]=i.title,t[9]=n);let r;t[10]!==i.url||t[11]!==n?(r=(0,Z.jsxs)(`a`,{href:i.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-w-0 items-center gap-1.5 px-1 text-sm underline-offset-2 hover:underline`,children:[e,n]}),t[10]=i.url,t[11]=n,t[12]=r):r=t[12];let o;t[13]===i.url?o=t[14]:(o=zd(i.url),t[13]=i.url,t[14]=o);let s;t[15]===o?s=t[16]:(s=(0,Z.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:o}),t[15]=o,t[16]=s);let c;t[17]===a?c=t[18]:(c=a&&(0,Z.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:a}),t[17]=a,t[18]=c);let l;t[19]!==s||t[20]!==c?(l=(0,Z.jsxs)(`figcaption`,{className:`flex min-w-0 flex-col px-1 pt-0.5`,children:[s,c]}),t[19]=s,t[20]=c,t[21]=l):l=t[21];let u;return t[22]!==l||t[23]!==r?(u=(0,Z.jsxs)(`figure`,{className:`rounded-lg border p-2`,children:[r,l]}),t[22]=l,t[23]=r,t[24]=u):u=t[24],u}let u=i.kind===`video`,d;t[25]!==i.id||t[26]!==i.title||t[27]!==r||t[28]!==n||t[29]!==u?(d=(0,Z.jsx)(Km,{scope:n,context:r,id:i.id,title:i.title,video:u}),t[25]=i.id,t[26]=i.title,t[27]=r,t[28]=n,t[29]=u,t[30]=d):d=t[30];let f;return t[31]!==l||t[32]!==d?(f=(0,Z.jsxs)(`figure`,{className:`rounded-lg border p-2`,children:[d,l]}),t[31]=l,t[32]=d,t[33]=f):f=t[33],f}function Km(e){let t=(0,$.c)(9),{scope:n,context:r,id:i,title:a,video:o}=e,s=Vm(n,r,i),c;t[0]===s?c=t[1]:(c=ge(V(s)),t[0]=s,t[1]=c);let l=Bm(c);if(B(s)){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`p`,{role:`status`,className:`p-3 text-xs text-muted-foreground`,children:`This attachment could not be loaded.`}),t[2]=e):e=t[2],e}if(l===void 0){let e=o?`video`:`image`,n;return t[3]===e?n=t[4]:(n=(0,Z.jsxs)(`p`,{role:`status`,className:`p-3 text-xs text-muted-foreground`,children:[`Loading `,e,`…`]}),t[3]=e,t[4]=n),n}let u;return t[5]!==a||t[6]!==l||t[7]!==o?(u=o?(0,Z.jsx)(`video`,{controls:!0,"aria-label":a,src:l,className:`max-h-80 w-full rounded-md bg-muted`}):(0,Z.jsx)(`img`,{src:l,alt:a,className:`max-h-80 w-full rounded-md bg-muted object-contain`}),t[5]=a,t[6]=l,t[7]=o,t[8]=u):u=t[8],u}function qm(e){let t=(0,$.c)(7),{scope:n,context:r}=e,i;t[0]!==r||t[1]!==n?(i=e=>(0,Z.jsx)(Jm,{scope:n,context:r,review:e}),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a;return t[3]!==r||t[4]!==n||t[5]!==i?(a=(0,Z.jsx)(zm,{scope:n,context:r,absent:`Proof comes with a published review. This worktree has no review now.`,children:i}),t[3]=r,t[4]=n,t[5]=i,t[6]=a):a=t[6],a}function Jm(e){let t=(0,$.c)(36),{scope:n,context:r,review:i}=e,a,o,s,c,l,u,d,f;t[0]!==i.proof||t[1]!==i.publishedAt?(s=Nd(i.proof),o=i.proof.checks.length===0&&i.proof.assets.length===0,d=`flex min-h-0 flex-1 flex-col`,f=`Proof`,a=Qp,u=`Proof`,t[10]===i.publishedAt?c=t[11]:(c=Bd(i.publishedAt),t[10]=i.publishedAt,t[11]=c),l=Id(s),t[0]=i.proof,t[1]=i.publishedAt,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f):(a=t[2],o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9]);let p=`Published ${c} · checks ${l} · ${i.proof.assets.length} ${i.proof.assets.length===1?`attachment`:`attachments`}`,m;t[12]!==a||t[13]!==u||t[14]!==p?(m=(0,Z.jsx)(a,{title:u,subtitle:p}),t[12]=a,t[13]=u,t[14]=p,t[15]=m):m=t[15];let h;t[16]===s.failing?h=t[17]:(h=s.failing>0&&(0,Z.jsxs)(Je,{variant:`destructive`,children:[(0,Z.jsx)(ja,{}),(0,Z.jsx)(He,{children:s.failing===1?`1 check failed`:`${s.failing} checks failed`}),(0,Z.jsx)(Ge,{children:`The agent reported this work as not passing yet.`})]}),t[16]=s.failing,t[17]=h);let g;t[18]!==o||t[19]!==s.current?(g=!s.current&&!o&&(0,Z.jsxs)(Je,{children:[(0,Z.jsx)(Si,{}),(0,Z.jsx)(He,{children:`These checks ran before the latest changes`}),(0,Z.jsx)(Ge,{children:`The code changed after the agent published this proof. Ask it to run the checks again.`})]}),t[18]=o,t[19]=s.current,t[20]=g):g=t[20];let _;t[21]!==r||t[22]!==o||t[23]!==i.layers||t[24]!==i.proof||t[25]!==n?(_=o?(0,Z.jsx)(im,{title:`No proof attached`,description:`The agent published this review without checks or attachments.`}):(0,Z.jsx)(Um,{scope:n,context:r,proof:i.proof,layers:i.layers}),t[21]=r,t[22]=o,t[23]=i.layers,t[24]=i.proof,t[25]=n,t[26]=_):_=t[26];let v;t[27]!==_||t[28]!==h||t[29]!==g?(v=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:(0,Z.jsxs)(`div`,{className:`flex max-w-3xl flex-col gap-4`,children:[h,g,_]})}),t[27]=_,t[28]=h,t[29]=g,t[30]=v):v=t[30];let y;return t[31]!==v||t[32]!==d||t[33]!==f||t[34]!==m?(y=(0,Z.jsxs)(`section`,{className:d,"aria-label":f,children:[m,v]}),t[31]=v,t[32]=d,t[33]=f,t[34]=m,t[35]=y):y=t[35],y}function Ym(e){let t=(0,$.c)(25),{scope:n,context:r,interaction:i,paths:a,files:o,focus:s,header:c,headerActions:l,commentRequest:u,toolbar:d,agentNotes:f,footer:p}=e,m=o===void 0?[]:o,{connection:h}=r;Kf(n,r);let g=Du(qf(n,r,zr(n,h),a),m),_=g[0]?.statusToken??``,v=Pr(n,h,_,g.flatMap(nh),g.flatMap(th)),y=ui(h,n,g.flatMap($m)),b;t[0]===v.diffs?b=t[1]:(b=e=>{let[t]=oh(e);return t?v.diffs.get(Cr(t)):void 0},t[0]=v.diffs,t[1]=b);let x=b,S=v.pending||y.pending,C=v.failed||y.failed,w=new Map(m.map(Qm)),T;t[2]!==x||t[3]!==y?(T=e=>{let t=e.comparisons.flatMap(e=>{if(e.scope===`unmerged`)return[`Conflict`];if(e.scope===`untracked`)return y.contents.has(e.path)?[]:[`Not readable`];if(!e.supported)return[`Unsupported comparison`];let t=x(e);return t?t.kind===`binary`?[`Binary change`]:t.kind===`omitted`?[`Content omitted: ${ch(t.reason)}`]:Kr(e,t)?[]:[`No single-file textual patch`]:[]});return t.length>0?[{item:e,reasons:t}]:[]},t[2]=x,t[3]=y,t[4]=T):T=t[4];let E=g.flatMap(T),D=g.flatMap(e=>e.comparisons.flatMap(t=>{let i=em(n,r,e);if(t.scope===`untracked`){let n=y.contents.get(t.path);return n===void 0?[]:[{...op(ha(t),e.path,n,w.get(e.path)??`${t.scope} · untracked`),review:i,comment:{filePath:e.path,comparison:{kind:`worktree`,scope:`untracked`},...e.fingerprint?{contentFingerprint:e.fingerprint}:{}}}]}if(t.scope===`unmerged`||!t.supported)return[];let a=ah(x(t),s?.[e.path]),o=a?Kr(t,a):null,c=w.get(e.path);return o?[{...o,...c?{note:c}:{},review:i,comment:{filePath:e.path,comparison:{kind:`worktree`,scope:t.scope},...e.fingerprint?{contentFingerprint:e.fingerprint}:{}}}]:[]}));for(let[e,t]of Object.entries(f??{})){let n=D.filter(t=>t.path===e),r=n.find(Zm)??n[0];if(r)for(let e of t){let t=r.kind===`file`?e.line<=r.contents.split(`
|
|
10
|
+
`).length:r.fileDiff.hunks.some(t=>e.line>=t.additionStart&&e.line<t.additionStart+t.additionCount);r.agentNotes=[...r.agentNotes??[],{...e,line:t?e.line:0}]}}let O=new Set(D.map(Xm)),k=c||S||C||E.length>0?()=>(0,Z.jsxs)(Z.Fragment,{children:[c?.(),(S||C)&&(0,Z.jsx)(sh,{failed:C,retry:()=>{v.retry(),y.retry()}}),E.length>0&&(0,Z.jsx)(lh,{changes:E,renderedPaths:O,scope:n,context:r,...D.length===0&&u!==void 0?{commentRequest:u}:{}})]}):void 0,A;t[5]===u?A=t[6]:(A=u===void 0?{}:{commentRequest:u},t[5]=u,t[6]=A);let j;t[7]===p?j=t[8]:(j=p?{footer:p}:{},t[7]=p,t[8]=j);let M;t[9]===k?M=t[10]:(M=k?{header:k}:{},t[9]=k,t[10]=M);let N;t[11]===l?N=t[12]:(N=l?{headerActions:l}:{},t[11]=l,t[12]=N);let P;t[13]===d?P=t[14]:(P=d?{toolbar:d}:{},t[13]=d,t[14]=P);let F;return t[15]!==r||t[16]!==D||t[17]!==i||t[18]!==n||t[19]!==A||t[20]!==j||t[21]!==M||t[22]!==N||t[23]!==P?(F=(0,Z.jsx)(Hp,{scope:n,context:r,interaction:i,...A,entries:D,...j,...M,...N,...P}),t[15]=r,t[16]=D,t[17]=i,t[18]=n,t[19]=A,t[20]=j,t[21]=M,t[22]=N,t[23]=P,t[24]=F):F=t[24],F}function Xm(e){return e.path}function Zm(e){return e.comment?.comparison?.kind===`worktree`&&e.comment.comparison.scope===`unstaged`}function Qm(e){return[e.path,e.note]}function $m(e){return e.comparisons.flatMap(eh)}function eh(e){return e.scope===`untracked`?[e.path]:[]}function th(e){return e.comparisons.flatMap(oh)}function nh(e){return e.comparisons.some(rh)?[{path:e.path,fingerprint:e.fingerprint}]:[]}function rh(e){return e.scope===`staged`||e.scope===`unstaged`}var ih=new WeakMap;function ah(e,t){if(!e||!t?.length||e.kind!==`text`)return e;let n=t.map(e=>`${e.startLine}-${e.endLine}`).join(`,`),r=ih.get(e),i=r?.get(n);if(i)return i;let a=ep(e.patch,t),o=a?{...e,patch:a}:e;return r??=new Map,r.set(n,o),ih.set(e,r),o}function oh(e){return e.scope===`staged`||e.scope===`unstaged`?[{scope:e.scope,oldPath:e.oldPath,newPath:e.newPath}]:[]}function sh(e){let t=(0,$.c)(3),{failed:n,retry:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,Z.jsx)(`section`,{className:`mx-4 mt-3 flex items-center gap-3 rounded-lg border bg-muted/40 px-4 py-3 text-xs text-muted-foreground`,"aria-live":`polite`,children:n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{children:`The changes in this document could not be read.`}),(0,Z.jsx)(h,{size:`xs`,variant:`outline`,onClick:r,children:`Load the changes again`})]}):(0,Z.jsx)(`span`,{children:`Loading changes…`})}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function ch(e){return e.replaceAll(`-`,` `)}function lh(e){let t=(0,$.c)(14),{changes:n,renderedPaths:r,scope:i,context:a,commentRequest:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(`p`,{className:`text-xs font-medium`,children:`Non-text content`}),t[0]=s):s=t[0];let c;if(t[1]!==n||t[2]!==o||t[3]!==a||t[4]!==r||t[5]!==i){let e;t[7]!==o||t[8]!==a||t[9]!==r||t[10]!==i?(e=e=>{let{item:t,reasons:n}=e;return(0,Z.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.path}),Mi(t.path)&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{children:`Current worktree image`}),(0,Z.jsx)(Zi,{scope:i,path:t.path,connection:a.connection})]}),(0,Z.jsx)(Re,{variant:`outline`,className:`shrink-0`,children:n.join(`, `)}),!r.has(t.path)&&(0,Z.jsx)(tm,{scope:i,context:a,path:t.path,fingerprint:t.fingerprint,status:t.reviewStatus,compact:!0}),!r.has(t.path)&&(0,Z.jsx)(uh,{scope:i,context:a,path:t.path,...o===void 0?{}:{commentRequest:o}})]},t.path)},t[7]=o,t[8]=a,t[9]=r,t[10]=i,t[11]=e):e=t[11],c=n.map(e),t[1]=n,t[2]=o,t[3]=a,t[4]=r,t[5]=i,t[6]=c}else c=t[6];let l;return t[12]===c?l=t[13]:(l=(0,Z.jsxs)(`section`,{className:`mx-4 mt-3 rounded-lg border bg-muted/40 px-4 py-3`,children:[s,(0,Z.jsx)(`ul`,{className:`mt-2 flex flex-col gap-2 text-xs text-muted-foreground`,children:c})]}),t[12]=c,t[13]=l),l}function uh(e){let t=(0,$.c)(14),{scope:n,context:r,path:i,commentRequest:a}=e,{threads:o}=mp(n,r),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(void 0),u,d;t[0]===a?(u=t[1],d=t[2]):(u=()=>{a!==void 0&&l.current!==a&&(l.current=a,c(!0))},d=[a],t[0]=a,t[1]=u,t[2]=d),(0,Q.useEffect)(u,d);let f;if(t[3]!==s||t[4]!==r||t[5]!==i||t[6]!==n||t[7]!==o){let e;t[9]===i?e=t[10]:(e=e=>e.anchor.kind===`file`&&e.anchor.filePath===i&&!e.anchor.revision,t[9]=i,t[10]=e);let a=o.filter(e),l;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>c(!0),t[11]=l):l=t[11];let u;t[12]===i?u=t[13]:(u=(0,Z.jsxs)(h,{size:`xs`,variant:`ghost`,onClick:l,children:[`Comment on `,i]}),t[12]=i,t[13]=u),f=(0,Z.jsxs)(Z.Fragment,{children:[u,(a.length>0||s)&&(0,Z.jsxs)(`div`,{className:`w-full space-y-2`,children:[a.map(e=>(0,Z.jsx)(Vp,{scope:n,context:r,thread:e},e.id)),s&&(0,Z.jsx)(wp,{scope:n,context:r,anchor:{kind:`file`,filePath:i},onClose:()=>c(!1)})]})]}),t[3]=s,t[4]=r,t[5]=i,t[6]=n,t[7]=o,t[8]=f}else f=t[8];return f}function dh(e,t){let n=(0,$.c)(4),r,i;n[0]!==e||n[1]!==t?(r=()=>{let n=n=>{if(n.source!==e.current?.contentWindow)return;let r=Lu(n.data);r!==null&&t(r)};return window.addEventListener(`message`,n),()=>window.removeEventListener(`message`,n)},i=[e,t],n[0]=e,n[1]=t,n[2]=r,n[3]=i):(r=n[2],i=n[3]),(0,Q.useEffect)(r,i)}function fh(e,t,n){let r=(0,$.c)(16),i;r[0]!==t.connection||r[1]!==e?(i=sd({scope:e,connection:t.connection}),r[0]=t.connection,r[1]=e,r[2]=i):i=r[2];let a=i,o=xe(a),s=se(a),c=Ad(e,t),l;r[3]!==n||r[4]!==o?(l=af(n,ge(V(o))),r[3]=n,r[4]=o,r[5]=l):l=r[5];let u;r[6]!==o||r[7]!==c?(u=y(o)&&!o.waiting&&!c.result.waiting,r[6]=o,r[7]=c,r[8]=u):u=r[8];let d;r[9]===o?d=r[10]:(d=B(o),r[9]=o,r[10]=d);let f;return r[11]!==s||r[12]!==l||r[13]!==u||r[14]!==d?(f={states:l,settled:u,failed:d,retry:s},r[11]=s,r[12]=l,r[13]=u,r[14]=d,r[15]=f):f=r[15],f}function ph(e,t,n){let r=(0,$.c)(12);Kf(e,t);let{preferences:i}=Tn(),a=zr(e,t.connection),o=qf(e,t,a),s=Zd(n,a.changes.map(mh),{specsApart:i.collapseSpecs}),{place:c,setPlace:l,view:u,setView:d}=Tu(e.worktreeId),f=fh(e,t,n.layers),p=Qd(s,c),m;r[0]!==f||r[1]!==o?(m=e=>rf(e,o,f.states),r[0]=f,r[1]=o,r[2]=m):m=r[2];let h;return r[3]!==f||r[4]!==o||r[5]!==l||r[6]!==d||r[7]!==s||r[8]!==p||r[9]!==m||r[10]!==u?(h={stops:s,items:o,stop:p,go:l,view:u,setView:d,decisions:f,done:m},r[3]=f,r[4]=o,r[5]=l,r[6]=d,r[7]=s,r[8]=p,r[9]=m,r[10]=u,r[11]=h):h=r[11],h}function mh(e){return e.path}function hh(e){let t=(0,$.c)(11),{part:n,action:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(Sn,{className:`mt-0.5 size-4 shrink-0 text-graph-4`}),t[0]=i):i=t[0];let a;t[1]===n.label?a=t[2]:(a=(0,Z.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Needs your decision · `,n.label]}),t[1]=n.label,t[2]=a);let o;t[3]===n.problem?o=t[4]:(o=(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.problem}),t[3]=n.problem,t[4]=o);let s;t[5]!==a||t[6]!==o?(s=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7];let c;return t[8]!==r||t[9]!==s?(c=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-graph-4/40 bg-graph-4/5 p-3`,children:[i,s,r]}),t[8]=r,t[9]=s,t[10]=c):c=t[10],c}function gh(e){let t=(0,$.c)(107),{review:n,stops:r,items:i,decisions:a,done:o,onGo:s,onOpen:c}=e,l,u,d,f,p,m,g,_,v,y,b,x,S,C,w,T,E;if(t[0]!==a||t[1]!==o||t[2]!==i||t[3]!==s||t[4]!==n||t[5]!==r){let e=r.filter(bh),c=r.filter(yh),D;t[23]!==i||t[24]!==r?(D=ef(r.flatMap(vh),i),t[23]=i,t[24]=r,t[25]=D):D=t[25];let O=D,A=e.filter(o).length,j=[...e,...c].find(e=>!o(e)),M=cf(n),N;t[26]===a?N=t[27]:(N=e=>a.get(e.layer.id)?.stale,t[26]=a,t[27]=N);let P=e.filter(N).length,F;t[28]===r?F=t[29]:(F=r.find(_h),t[28]=r,t[29]=F);let L=F,R=Nd(n.proof),z=M.questions.length>0?[`${M.questions.length} to decide`]:[],B;t[30]===P?B=t[31]:(B=P>0?[`${P} moved`]:[],t[30]=P,t[31]=B);let V;t[32]===L?V=t[33]:(V=L?[`unexplained changes`]:[],t[32]=L,t[33]=V);let H;t[34]!==z||t[35]!==B||t[36]!==V?(H=[...z,...B,...V],t[34]=z,t[35]=B,t[36]=V,t[37]=H):H=t[37];let U=H,W=M.added.length+M.changed.length+M.removed.length>0;g=`min-h-0 flex-1 overflow-auto`,_=`Briefing`,v=`region`,d=`mx-auto flex max-w-3xl flex-col gap-9 px-6 pt-8 pb-16`;let G;t[38]===n.revision?G=t[39]:(G=(0,Z.jsxs)(`p`,{className:`text-2xs font-medium tracking-wide text-muted-foreground uppercase`,children:[`Briefing · revision `,n.revision]}),t[38]=n.revision,t[39]=G);let K;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,Z.jsx)(`p`,{className:`max-w-2xl text-sm text-muted-foreground text-pretty`,children:`Read each decision through its code and mark it reviewed. Every changed file belongs to exactly one stop, and changes no decision explains come last, so finishing the walkthrough means nothing was left out.`}),t[40]=K):K=t[40];let q=`${O.reviewed} / ${O.total}`,J=O.total===0?0:O.reviewed/O.total,ee;t[41]!==q||t[42]!==J?(ee=(0,Z.jsx)(Sh,{label:`Files reviewed`,value:q,fraction:J}),t[41]=q,t[42]=J,t[43]=ee):ee=t[43];let Y=`${A} / ${e.length}`,te=e.length===0?0:A/e.length,ne;t[44]!==Y||t[45]!==te?(ne=(0,Z.jsx)(Sh,{label:`Decisions reviewed`,value:Y,fraction:te}),t[44]=Y,t[45]=te,t[46]=ne):ne=t[46];let re=`${M.questions.length+P+ +!!L}`,ie=U.join(` · `)||`Nothing`,ae=M.questions.length+P>0||L?`warning`:`calm`,oe;t[47]!==re||t[48]!==ie||t[49]!==ae?(oe=(0,Z.jsx)(Sh,{label:`Needs attention`,value:re,caption:ie,tone:ae}),t[47]=re,t[48]=ie,t[49]=ae,t[50]=oe):oe=t[50];let se;t[51]!==ee||t[52]!==ne||t[53]!==oe?(se=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-3 gap-2`,children:[ee,ne,oe]}),t[51]=ee,t[52]=ne,t[53]=oe,t[54]=se):se=t[54];let ce=j?(0,Z.jsxs)(h,{onClick:()=>s(j.key),children:[A===0&&O.reviewed===0?`Start with`:`Continue with`,` `,nf(j),(0,Z.jsx)(xa,{"data-icon":`inline-end`})]}):(0,Z.jsxs)(`p`,{className:`flex items-center gap-1.5 text-sm font-medium text-graph-2`,children:[(0,Z.jsx)(k,{className:`size-4`}),` Everything in this change is reviewed`]}),le;t[55]===ce?le=t[56]:(le=(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:ce}),t[55]=ce,t[56]=le),f=(0,Z.jsxs)(`header`,{className:`flex flex-col gap-4`,children:[G,(0,Z.jsxs)(`h2`,{className:`text-2xl leading-tight font-semibold text-balance`,children:[e.length,` `,e.length===1?`decision`:`decisions`,` shape this change`]}),K,se,le]}),p=(W||M.questions.length>0)&&(0,Z.jsxs)(`section`,{"aria-labelledby":`briefing-system`,className:`flex flex-col gap-3`,children:[(0,Z.jsx)(xh,{id:`briefing-system`,children:`What this adds to the system`}),M.questions.map(e=>(0,Z.jsx)(hh,{part:e,action:(0,Z.jsx)(Th,{part:e,review:n,onGo:s})},`question:${e.id}`)),W&&(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 max-narrow:grid-cols-1`,children:[(0,Z.jsx)(wh,{title:`New`,icon:(0,Z.jsx)(Ei,{className:`size-3.5 text-graph-2`}),parts:M.added,review:n,onGo:s}),(0,Z.jsx)(wh,{title:`Changed`,icon:(0,Z.jsx)(ki,{className:`size-3.5 text-graph-1`}),parts:M.changed,review:n,onGo:s}),(0,Z.jsx)(wh,{title:`Removed`,icon:(0,Z.jsx)(fo,{className:`size-3.5 text-destructive`}),parts:M.removed,review:n,onGo:s,struck:!0})]})]});let ue;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,Z.jsx)(xh,{id:`briefing-decisions`,children:`The walkthrough`}),t[57]=ue):ue=t[57];let de;t[58]!==a||t[59]!==o||t[60]!==i||t[61]!==s?(de=e=>{let t=a.get(e.layer.id),n=ef(e.paths,i);return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>s(e.key),className:`flex w-full items-start gap-3 px-3.5 py-3 text-left hover:bg-accent/50`,children:[(0,Z.jsx)(Ch,{done:o(e),label:`${e.number}`}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e.layer.title}),(0,Z.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:of(e.layer).join(` → `)||`No changed code`})]}),(0,Z.jsxs)(`span`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[n.reviewed,`/`,n.total,` files`]}),t?.stale&&(0,Z.jsxs)(Re,{variant:`outline`,children:[(0,Z.jsx)(Sn,{className:`text-graph-4`}),` Code moved`]})]})]})},e.key)},t[58]=a,t[59]=o,t[60]=i,t[61]=s,t[62]=de):de=t[62];let fe=e.map(de),pe;t[63]!==i||t[64]!==s?(pe=e=>{let t=ef(e.paths,i);return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>s(e.key),className:`flex w-full items-start gap-3 px-3.5 py-3 text-left hover:bg-accent/50`,children:[(0,Z.jsx)(`span`,{className:I(`grid size-6 shrink-0 place-items-center rounded-full bg-muted text-muted-foreground`,e.kind===`unexplained`&&`bg-graph-4/15 text-graph-4`),children:e.kind===`unexplained`?(0,Z.jsx)(Va,{className:`size-3.5`}):(0,Z.jsx)(Ya,{className:`size-3.5`})}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:tf(e)}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.kind===`unexplained`?`Changes no decision explains`:`Set apart by your settings`})]}),(0,Z.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[t.reviewed,`/`,t.total,` files`]})]})},e.key)},t[63]=i,t[64]=s,t[65]=pe):pe=t[65];let X=c.map(pe);t[66]!==fe||t[67]!==X?(m=(0,Z.jsxs)(`section`,{"aria-labelledby":`briefing-decisions`,className:`flex flex-col gap-2`,children:[ue,(0,Z.jsxs)(`ol`,{className:`flex flex-col divide-y rounded-xl border`,children:[fe,X]})]}),t[66]=fe,t[67]=X,t[68]=m):m=t[68],T=`briefing-evidence`,E=`flex flex-col gap-2`,t[69]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(xh,{id:`briefing-evidence`,children:`Evidence`}),t[69]=u):u=t[69],C=`flex items-center gap-3 rounded-xl border px-3.5 py-3`;let me=R.failing>0&&`text-destructive`,he;t[70]===me?he=t[71]:(he=I(`size-4 shrink-0 text-muted-foreground`,me),t[70]=me,t[71]=he),t[72]===he?w=t[73]:(w=(0,Z.jsx)(Ya,{className:he}),t[72]=he,t[73]=w),b=`min-w-0 flex-1 text-sm`,x=`Checks the agent ran ·`,S=` `;let ge=R.failing>0&&`font-medium text-destructive`;t[74]===ge?l=t[75]:(l=I(`text-muted-foreground`,ge),t[74]=ge,t[75]=l),y=Id(R),t[0]=a,t[1]=o,t[2]=i,t[3]=s,t[4]=n,t[5]=r,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m,t[12]=g,t[13]=_,t[14]=v,t[15]=y,t[16]=b,t[17]=x,t[18]=S,t[19]=C,t[20]=w,t[21]=T,t[22]=E}else l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],g=t[12],_=t[13],v=t[14],y=t[15],b=t[16],x=t[17],S=t[18],C=t[19],w=t[20],T=t[21],E=t[22];let D;t[76]!==l||t[77]!==y?(D=(0,Z.jsx)(`span`,{className:l,children:y}),t[76]=l,t[77]=y,t[78]=D):D=t[78];let O;t[79]!==D||t[80]!==b||t[81]!==x||t[82]!==S?(O=(0,Z.jsxs)(`p`,{className:b,children:[x,S,D]}),t[79]=D,t[80]=b,t[81]=x,t[82]=S,t[83]=O):O=t[83];let A;t[84]===c?A=t[85]:(A=(0,Z.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>c(Hl),children:`Open proof`}),t[84]=c,t[85]=A);let j;t[86]!==O||t[87]!==A||t[88]!==C||t[89]!==w?(j=(0,Z.jsxs)(`div`,{className:C,children:[w,O,A]}),t[86]=O,t[87]=A,t[88]=C,t[89]=w,t[90]=j):j=t[90];let M;t[91]!==u||t[92]!==j||t[93]!==T||t[94]!==E?(M=(0,Z.jsxs)(`section`,{"aria-labelledby":T,className:E,children:[u,j]}),t[91]=u,t[92]=j,t[93]=T,t[94]=E,t[95]=M):M=t[95];let N;t[96]!==d||t[97]!==f||t[98]!==p||t[99]!==m||t[100]!==M?(N=(0,Z.jsxs)(`div`,{className:d,children:[f,p,m,M]}),t[96]=d,t[97]=f,t[98]=p,t[99]=m,t[100]=M,t[101]=N):N=t[101];let P;return t[102]!==g||t[103]!==_||t[104]!==v||t[105]!==N?(P=(0,Z.jsx)(`div`,{className:g,"aria-label":_,role:v,children:N}),t[102]=g,t[103]=_,t[104]=v,t[105]=N,t[106]=P):P=t[106],P}function _h(e){return e.kind===`unexplained`}function vh(e){return e.paths}function yh(e){return e.kind===`unexplained`||e.kind===`specs`}function bh(e){return e.kind===`decision`}function xh(e){let t=(0,$.c)(3),{id:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,Z.jsx)(`h3`,{id:n,className:`text-sm font-semibold`,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function Sh(e){let t=(0,$.c)(16),{label:n,value:r,fraction:i,caption:a,tone:o}=e,s=o===void 0?`calm`:o,c;t[0]===n?c=t[1]:(c=(0,Z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:n}),t[0]=n,t[1]=c);let l=s===`warning`&&`text-graph-4`,u;t[2]===l?u=t[3]:(u=I(`text-xl font-semibold tabular-nums`,l),t[2]=l,t[3]=u);let d;t[4]!==u||t[5]!==r?(d=(0,Z.jsx)(`dd`,{className:u,children:r}),t[4]=u,t[5]=r,t[6]=d):d=t[6];let f;t[7]===a?f=t[8]:(f=a&&(0,Z.jsx)(`span`,{className:`text-2xs text-muted-foreground`,children:a}),t[7]=a,t[8]=f);let p;t[9]===i?p=t[10]:(p=i!==void 0&&(0,Z.jsx)(`span`,{className:`block h-1 overflow-hidden rounded-full bg-muted`,children:(0,Z.jsx)(`span`,{className:`block h-full rounded-full bg-graph-2`,style:{width:`${Math.round(i*100)}%`}})}),t[9]=i,t[10]=p);let m;return t[11]!==c||t[12]!==d||t[13]!==f||t[14]!==p?(m=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-xl border px-3.5 py-3`,children:[c,d,f,p]}),t[11]=c,t[12]=d,t[13]=f,t[14]=p,t[15]=m):m=t[15],m}function Ch(e){let t=(0,$.c)(8),{done:n,label:r}=e,i=n&&`border-graph-2 bg-graph-2 text-background`,a;t[0]===i?a=t[1]:(a=I(`grid size-6 shrink-0 place-items-center rounded-full border text-2xs font-semibold tabular-nums`,i),t[0]=i,t[1]=a);let o;t[2]!==n||t[3]!==r?(o=n?(0,Z.jsx)(k,{className:`size-3.5`,"aria-label":`Reviewed`}):r,t[2]=n,t[3]=r,t[4]=o):o=t[4];let s;return t[5]!==a||t[6]!==o?(s=(0,Z.jsx)(`span`,{className:a,children:o}),t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function wh(e){let t=(0,$.c)(14),{title:n,icon:r,parts:i,review:a,onGo:o,struck:s}=e,c=s!==void 0&&s,l;t[0]===i.length?l=t[1]:(l=(0,Z.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:i.length}),t[0]=i.length,t[1]=l);let u;t[2]!==r||t[3]!==l||t[4]!==n?(u=(0,Z.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium`,children:[r,n,l]}),t[2]=r,t[3]=l,t[4]=n,t[5]=u):u=t[5];let d;t[6]!==o||t[7]!==i||t[8]!==a||t[9]!==c?(d=i.length===0?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Nothing`}):(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2`,children:i.map(e=>(0,Z.jsxs)(`li`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(`span`,{className:I(`text-sm font-medium`,c&&`text-muted-foreground line-through`),children:e.label}),e.detail&&(0,Z.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:e.detail}),(0,Z.jsx)(Th,{part:e,review:a,onGo:o,inline:!0})]},e.id))}),t[6]=o,t[7]=i,t[8]=a,t[9]=c,t[10]=d):d=t[10];let f;return t[11]!==u||t[12]!==d?(f=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl border p-3`,children:[u,d]}),t[11]=u,t[12]=d,t[13]=f):f=t[13],f}function Th(e){let t=(0,$.c)(10),{part:n,review:r,onGo:i,inline:a}=e,o=a!==void 0&&a,s=n.decision===void 0?void 0:r.layers[n.decision-1];if(!s||n.decision===void 0)return null;let c=o&&`self-start`,l;t[0]===c?l=t[1]:(l=I(`shrink-0`,c),t[0]=c,t[1]=l);let u;t[2]!==s.id||t[3]!==i?(u=()=>i(Xd(s.id)),t[2]=s.id,t[3]=i,t[4]=u):u=t[4];let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(xa,{"data-icon":`inline-end`}),t[5]=d):d=t[5];let f;return t[6]!==n.decision||t[7]!==l||t[8]!==u?(f=(0,Z.jsxs)(h,{variant:`link`,size:`xs`,className:l,onClick:u,children:[`Decision `,n.decision,d]}),t[6]=n.decision,t[7]=l,t[8]=u,t[9]=f):f=t[9],f}function Eh(e,t,n){let r=(0,$.c)(20),i;r[0]!==t.connection||r[1]!==e?(i=Dd({scope:e,connection:t.connection,range:Ru}),r[0]=t.connection,r[1]=e,r[2]=i):i=r[2];let a;r[3]===Symbol.for(`react.memo_cache_sentinel`)?(a={mode:`promiseExit`},r[3]=a):a=r[3];let[o,s]=G(i.bulk,a),c;r[4]!==t.connection||r[5]!==e?(c=Od({scope:e,connection:t.connection}),r[4]=t.connection,r[5]=e,r[6]=c):c=r[6];let l;r[7]===Symbol.for(`react.memo_cache_sentinel`)?(l={mode:`promiseExit`},r[7]=l):l=r[7];let[u,d]=G(c,l),f;r[8]===n?f=r[9]:(f=(e,t)=>(n({title:e,description:t,type:`error`}),!1),r[8]=n,r[9]=f);let p=f,m;r[10]!==p||r[11]!==s?(m=async e=>{let t=Gu(e);if(t.unmarking||t.blocked)return!0;let n=await s({kind:`mark`,entries:t.entries});if(Se(n))return p(`Could not mark the files reviewed`,Mu(le(n.cause)));let r=n.value.kind===`mark`?n.value.report:null;return r&&r.failed.length>0?p(`Some files changed before they were marked`,Wu(r)):!0},r[10]=p,r[11]=s,r[12]=m):m=r[12];let h=m,g;r[13]!==p||r[14]!==d?(g=async(e,t)=>{let n=await d({...e,reviewed:t});return!Se(n)||p(`Could not update the decision`,Mu(le(n.cause)))},r[13]=p,r[14]=d,r[15]=g):g=r[15];let _=g,v=o.waiting||u.waiting,y;return r[16]!==h||r[17]!==_||r[18]!==v?(y={pending:v,complete(e){(async()=>{await h(e.files)&&(!e.decision||e.decision.reviewed||await _(e.decision,!1))&&e.onDone?.()})()},reopen(e){_(e,!0)}},r[16]=h,r[17]=_,r[18]=v,r[19]=y):y=r[19],y}function Dh(e){let t=(0,$.c)(14),n,r,i;if(t[0]===e?(n=t[1],r=t[2],i=t[3]):({layer:n,steps:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i),i.length===0)return null;let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsxs)(`div`,{className:`px-4 pt-5 pb-2 font-sans`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Existing code it relies on`}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The decision builds on this code without changing it.`})]}),t[4]=a):a=t[4];let o;if(t[5]!==n||t[6]!==r||t[7]!==i){let e;t[9]!==n||t[10]!==r?(e=e=>(0,Z.jsx)(kh,{...r,step:e,number:n.steps.indexOf(e)+1,lane:n.lanes[e.lane]??``},e.id),t[9]=n,t[10]=r,t[11]=e):e=t[11],o=i.map(e),t[5]=n,t[6]=r,t[7]=i,t[8]=o}else o=t[8];let s;return t[12]===o?s=t[13]:(s=(0,Z.jsxs)(`section`,{"aria-label":`Existing code it relies on`,className:`mt-3 flex flex-col border-t`,children:[a,o]}),t[12]=o,t[13]=s),s}function Oh(e){return`step-excerpt-${e.id}`}function kh(e){let t=(0,$.c)(55),{step:n,number:r,lane:i,scope:a,context:o,interaction:s,onOpen:c}=e,[l,u]=(0,Q.useState)(!1),d=n.location.state===`committed`,f=n.location.state===`changed`,p=f?n.pointer:n.location,m=kr(a,o.connection,n.pointer.path,p.startLine,p.endLine,!f&&(!d||l)),g,_;if(t[0]!==m||t[1]!==p.endLine||t[2]!==f||t[3]!==r||t[4]!==n.id||t[5]!==n.pointer.path||t[6]!==n.text||t[7]!==n.title){let e=ge(V(m)),i=`${r}`,a;if(t[10]!==n.text||t[11]!==n.title||t[12]!==i?(a={title:n.title,text:n.text,marker:i},t[10]=n.text,t[11]=n.title,t[12]=i,t[13]=a):a=t[13],_=a,g=[],e&&!f){let r=tp(n.pointer.path,e.from,e.lines),i=Ci(r).flatMap(Ah)[0];if(i){let e;t[14]===n.pointer.path?e=t[15]:(e={filePath:n.pointer.path},t[14]=n.pointer.path,t[15]=e);let a;t[16]!==p.endLine||t[17]!==_?(a=[{..._,line:p.endLine,stale:!1}],t[16]=p.endLine,t[17]=_,t[18]=a):a=t[18],g.push({id:`excerpt:${n.id}`,kind:`diff`,path:n.pointer.path,fileDiff:i,version:ct(r),comment:e,agentNotes:a})}}t[0]=m,t[1]=p.endLine,t[2]=f,t[3]=r,t[4]=n.id,t[5]=n.pointer.path,t[6]=n.text,t[7]=n.title,t[8]=g,t[9]=_}else g=t[8],_=t[9];let v;t[19]===n?v=t[20]:(v=Oh(n),t[19]=n,t[20]=v);let y=`Step ${n.title}`,b;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(Ga,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[21]=b):b=t[21];let x=n.pointer.path,S;t[22]===p?S=t[23]:(S=$f([p]),t[22]=p,t[23]=S);let C=d?` · committed`:``,w;t[24]!==i||t[25]!==S||t[26]!==C?(w=(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[` `,`· `,i,` · `,S,C]}),t[24]=i,t[25]=S,t[26]=C,t[27]=w):w=t[27];let T;t[28]!==n.pointer.path||t[29]!==w?(T=(0,Z.jsxs)(`p`,{className:`min-w-0 flex-1 truncate text-sm`,children:[x,w]}),t[28]=n.pointer.path,t[29]=w,t[30]=T):T=t[30];let E;t[31]!==c||t[32]!==n.pointer.path?(E=()=>c({kind:`file`,path:n.pointer.path}),t[31]=c,t[32]=n.pointer.path,t[33]=E):E=t[33];let D;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(Ga,{"data-icon":`inline-start`}),t[34]=D):D=t[34];let O;t[35]===E?O=t[36]:(O=(0,Z.jsxs)(h,{variant:`ghost`,size:`xs`,onClick:E,children:[D,`Open file`]}),t[35]=E,t[36]=O);let k;t[37]!==O||t[38]!==T?(k=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pt-3 pb-1`,children:[b,T,O]}),t[37]=O,t[38]=T,t[39]=k):k=t[39];let A;t[40]!==d||t[41]!==o||t[42]!==g||t[43]!==l||t[44]!==s||t[45]!==m||t[46]!==f||t[47]!==_||t[48]!==a?(A=g.length>0?(0,Z.jsx)(Hp,{scope:a,context:o,interaction:{...s,active:!1},entries:g,disableFileHeader:!0,fullHeight:!0}):(0,Z.jsxs)(`div`,{className:`flex flex-col items-start gap-1 px-4 pt-1`,children:[f?(0,Z.jsx)(`p`,{role:`status`,className:`pl-5.5 text-sm text-graph-4`,children:`Code changed since the review was written.`}):d&&!l?(0,Z.jsx)(h,{variant:`outline`,size:`sm`,className:`ml-5.5`,onClick:()=>u(!0),children:`Committed · Show code`}):(0,Z.jsx)(`p`,{role:`status`,className:`pl-5.5 text-sm text-muted-foreground`,children:B(m)?`Code could not be loaded.`:`Loading code…`}),(0,Z.jsx)(Ep,{..._})]}),t[40]=d,t[41]=o,t[42]=g,t[43]=l,t[44]=s,t[45]=m,t[46]=f,t[47]=_,t[48]=a,t[49]=A):A=t[49];let j;return t[50]!==v||t[51]!==k||t[52]!==A||t[53]!==y?(j=(0,Z.jsxs)(`article`,{id:v,"aria-label":y,className:`flex scroll-mt-2 flex-col font-sans`,children:[k,A]}),t[50]=v,t[51]=k,t[52]=A,t[53]=y,t[54]=j):j=t[54],j}function Ah(e){return e.files}function jh(e){let t=(0,$.c)(95),{stop:n,stops:r,items:i,decision:a,decisionsSettled:o,finished:s,onGo:c,...l}=e,{review:u,scope:d,context:f,interaction:p}=l,[m,g]=(0,Q.useState)(),_=Eh(d,f,Ph),v;t[0]===n.paths?v=t[1]:(v=new Set(n.paths),t[0]=n.paths,t[1]=v);let y=v,b;if(t[2]!==i||t[3]!==y){let e;t[5]===y?e=t[6]:(e=e=>y.has(e.path),t[5]=y,t[6]=e),b=i.filter(e),t[2]=i,t[3]=y,t[4]=b}else b=t[4];let x=b,S;t[7]!==i||t[8]!==n.paths?(S=ef(n.paths,i),t[7]=i,t[8]=n.paths,t[9]=S):S=t[9];let C=S,w;t[10]!==n.key||t[11]!==r?(w=$d(r,n.key,-1),t[10]=n.key,t[11]=r,t[12]=w):w=t[12];let T=w,E;t[13]!==n.key||t[14]!==r?(E=$d(r,n.key,1),t[13]=n.key,t[14]=r,t[15]=E):E=t[15];let D=E,O=n.kind===`decision`?n.layer:void 0,A;t[16]!==_||t[17]!==a?.reviewed||t[18]!==x||t[19]!==O?(A=e=>_.complete({files:x,...e?{onDone:e}:{},...O?{decision:{layerId:O.id,fingerprint:O.fingerprint,reviewed:a?.reviewed===!0}}:{}}),t[16]=_,t[17]=a?.reviewed,t[18]=x,t[19]=O,t[20]=A):A=t[20];let j=A,M=C.total-C.reviewed,N=C.total===0?`No changed files of its own`:`${C.reviewed} of ${C.total} ${C.total===1?`file`:`files`} reviewed here`,P;t[21]!==D?.key||t[22]!==c?(P=()=>c(D?.key??`briefing`),t[21]=D?.key,t[22]=c,t[23]=P):P=t[23];let F=P,I;t[24]===O?.id?I=t[25]:(I=(e,t)=>e.id===O?.id?rp(e):rp(e,t+1),t[24]=O?.id,t[25]=I);let L=ap(...u.layers.map(I),n.kind===`unexplained`?{}:ip(u.notExplained.filter(e=>y.has(e.path)))),R;t[26]!==y||t[27]!==n.elsewhere||t[28]!==n.kind||t[29]!==n.layer?(R=n.kind===`decision`?n.layer.steps.filter(e=>e.location.state===`committed`||!y.has(e.pointer.path)&&!n.elsewhere.some(t=>t.path===e.pointer.path)):[],t[26]=y,t[27]=n.elsewhere,t[28]=n.kind,t[29]=n.layer,t[30]=R):R=t[30];let z=R,B;t[31]!==z||t[32]!==i||t[33]!==c||t[34]!==l||t[35]!==g||t[36]!==y||t[37]!==n.elsewhere||t[38]!==n.kind?(B=e=>{let t=i.find(t=>t.path===e.pointer.path),r=t&&y.has(t.path)?Fh(e,t):null;if(r){g({anchor:r,nonce:Date.now()});return}let a=n.kind===`decision`?n.elsewhere.find(t=>t.path===e.pointer.path):void 0;if(a){c(a.stop);return}if(z.includes(e)){document.getElementById(Oh(e))?.scrollIntoView({block:`start`});return}let o=e.location.state===`changed`?e.pointer:e.location;l.onOpen({kind:`file`,path:e.pointer.path},{kind:`codeRange`,filePath:e.pointer.path,startLine:o.startLine,endLine:o.endLine,comparison:{kind:`file`}})},t[31]=z,t[32]=i,t[33]=c,t[34]=l,t[35]=g,t[36]=y,t[37]=n.elsewhere,t[38]=n.kind,t[39]=B):B=t[39];let V=B,H;t[40]===n?H=t[41]:(H=nf(n),t[40]=n,t[41]=H);let U=m??p.reveal,W;t[42]!==p||t[43]!==U?(W={...p,reveal:U},t[42]=p,t[43]=U,t[44]=W):W=t[44];let G=n.paths,K;t[45]===n.paths?K=t[46]:(K=n.paths.map(Nh),t[45]=n.paths,t[46]=K);let q;t[47]!==F||t[48]!==_||t[49]!==a?.reviewed||t[50]!==o||t[51]!==O||t[52]!==j||t[53]!==D||t[54]!==c||t[55]!==T||t[56]!==N?(q=e=>(0,Z.jsxs)(`nav`,{"aria-label":`Walkthrough stop`,className:`flex shrink-0 items-center gap-1 border-b px-2 py-1`,children:[(0,Z.jsx)(h,{variant:`ghost`,size:`icon-sm`,disabled:!T,"aria-label":T?`Previous: ${nf(T)}`:`Previous`,title:T?`${nf(T)} (${zn(In.previousStop)})`:void 0,onClick:()=>T&&c(T.key),children:(0,Z.jsx)(Ca,{})}),(0,Z.jsx)(h,{variant:`ghost`,size:`icon-sm`,disabled:!D,"aria-label":D?`Next: ${nf(D)}`:`Next`,title:D?`${nf(D)} (${zn(In.nextStop)})`:void 0,onClick:F,children:(0,Z.jsx)(Tr,{})}),(0,Z.jsx)(`span`,{className:`ml-1 min-w-0 flex-1 truncate text-xs text-muted-foreground tabular-nums`,children:N}),e,O&&(0,Z.jsxs)(h,{variant:a?.reviewed?`ghost`:`outline`,size:`sm`,"aria-pressed":a?.reviewed===!0,disabled:!o||_.pending,onClick:()=>a?.reviewed?_.reopen({layerId:O.id,fingerprint:O.fingerprint}):j(),children:[(0,Z.jsx)(k,{"data-icon":`inline-start`}),a?.reviewed?`Decision reviewed`:`Mark decision reviewed`]})]}),t[47]=F,t[48]=_,t[49]=a?.reviewed,t[50]=o,t[51]=O,t[52]=j,t[53]=D,t[54]=c,t[55]=T,t[56]=N,t[57]=q):q=t[57];let J;t[58]!==a||t[59]!==c||t[60]!==V||t[61]!==u||t[62]!==n||t[63]!==r?(J=()=>n.kind===`decision`?(0,Z.jsx)(Lh,{stop:n,total:r.filter(Mh).length,review:u,decision:a,onStep:V,onGo:c}):n.kind===`unexplained`?(0,Z.jsx)(qh,{stop:n,stops:r,onGo:c}):(0,Z.jsx)(Ih,{eyebrow:(0,Z.jsx)(`span`,{className:`tracking-wide uppercase`,children:`Set apart by your settings`}),title:`Specs`,lead:`Specs are folded because agents follow the project's spec rules. Open the ones that matter to you; the countdown still includes them.`}),t[58]=a,t[59]=c,t[60]=V,t[61]=u,t[62]=n,t[63]=r,t[64]=J):J=t[64];let ee;t[65]!==F||t[66]!==_.pending||t[67]!==f||t[68]!==o||t[69]!==z||t[70]!==s||t[71]!==p||t[72]!==O||t[73]!==j||t[74]!==D||t[75]!==C.total||t[76]!==l||t[77]!==M||t[78]!==d||t[79]!==n.kind||t[80]!==n.layer?(ee=()=>(0,Z.jsxs)(Z.Fragment,{children:[n.kind===`decision`&&(0,Z.jsx)(Dh,{scope:d,context:f,interaction:p,onOpen:l.onOpen,layer:n.layer,steps:z}),(0,Z.jsx)(`div`,{className:`mt-3 border-t bg-muted/20`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4 px-4 pt-5 pb-16 font-sans`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:s?`All reviewed here`:O?`Done with this decision?`:`Done here?`}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s?D?`Next: ${nf(D)}`:`This was the last stop.`:M>0?`Marks the ${M} remaining ${M===1?`file`:`files`} here reviewed${O?` and records the decision`:``}.`:C.total===0?`Records the decision. Its code is shown in other stops.`:`Its files are reviewed; this records the decision.`})]}),(0,Z.jsxs)(h,{disabled:_.pending||O&&!o,onClick:()=>s?F():j(F),children:[s?D?`Continue`:`Back to the briefing`:D?`Mark reviewed and continue`:`Mark reviewed and finish`,(0,Z.jsx)(xa,{"data-icon":`inline-end`})]})]})})]}),t[65]=F,t[66]=_.pending,t[67]=f,t[68]=o,t[69]=z,t[70]=s,t[71]=p,t[72]=O,t[73]=j,t[74]=D,t[75]=C.total,t[76]=l,t[77]=M,t[78]=d,t[79]=n.kind,t[80]=n.layer,t[81]=ee):ee=t[81];let Y;t[82]!==f||t[83]!==L||t[84]!==d||t[85]!==n.paths||t[86]!==W||t[87]!==K||t[88]!==q||t[89]!==J||t[90]!==ee?(Y=(0,Z.jsx)(Ym,{scope:d,context:f,interaction:W,paths:G,files:K,agentNotes:L,toolbar:q,header:J,footer:ee}),t[82]=f,t[83]=L,t[84]=d,t[85]=n.paths,t[86]=W,t[87]=K,t[88]=q,t[89]=J,t[90]=ee,t[91]=Y):Y=t[91];let te;return t[92]!==H||t[93]!==Y?(te=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,role:`region`,"aria-label":H,children:Y}),t[92]=H,t[93]=Y,t[94]=te):te=t[94],te}function Mh(e){return e.kind===`decision`}function Nh(e){return{path:e}}function Ph(e){return Vt.add(e)}function Fh(e,t){let n=[`unstaged`,`staged`,`untracked`].find(e=>t.comparisons.some(t=>t.scope===e));if(!n)return null;let r={kind:`worktree`,scope:n};return e.location.state===`current`?{kind:`codeRange`,filePath:t.path,startLine:e.location.startLine,endLine:e.location.endLine,side:`additions`,comparison:r}:{kind:`file`,filePath:t.path,comparison:r}}function Ih(e){let t=(0,$.c)(13),{eyebrow:n,title:r,lead:i,children:a}=e,o;t[0]===n?o=t[1]:(o=(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 text-2xs font-medium text-muted-foreground`,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,Z.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-balance`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=i&&(0,Z.jsx)(`div`,{className:`max-w-3xl text-sm text-muted-foreground text-pretty`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==o||t[7]!==s||t[8]!==c?(l=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[o,s,c]}),t[6]=o,t[7]=s,t[8]=c,t[9]=l):l=t[9];let u;return t[10]!==a||t[11]!==l?(u=(0,Z.jsx)(`div`,{className:`border-b bg-muted/20`,children:(0,Z.jsxs)(`div`,{className:`mx-auto flex max-w-4xl flex-col gap-4 px-5 pt-6 pb-5 font-sans`,children:[l,a]})}),t[10]=a,t[11]=l,t[12]=u):u=t[12],u}function Lh(e){let t=(0,$.c)(32),{stop:n,total:r,review:i,decision:a,onStep:o,onGo:s}=e,{layer:c}=n,l;if(t[0]!==a?.reviewed||t[1]!==a?.stale||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==i||t[6]!==n.elsewhere||t[7]!==n.number||t[8]!==r){let e=of(c),u=lf(i,c.id),d=[...cf(i).questions.filter(e=>e.decision===n.number),...u.flatMap(Uh)].filter(Hh),f=Fd(i.proof,c.id),p;t[10]!==n.number||t[11]!==r?(p=(0,Z.jsxs)(`span`,{className:`tracking-wide uppercase`,children:[`Decision `,n.number,` of `,r]}),t[10]=n.number,t[11]=r,t[12]=p):p=t[12];let m;t[13]===a?.reviewed?m=t[14]:(m=a?.reviewed&&(0,Z.jsxs)(Re,{variant:`outline`,children:[(0,Z.jsx)(k,{className:`text-graph-2`}),` Reviewed`]}),t[13]=a?.reviewed,t[14]=m);let g;t[15]===a?.stale?g=t[16]:(g=a?.stale&&(0,Z.jsxs)(Re,{variant:`outline`,children:[(0,Z.jsx)(Sn,{className:`text-graph-4`}),` Code moved since it was explained`]}),t[15]=a?.stale,t[16]=g);let _;t[17]!==p||t[18]!==m||t[19]!==g?(_=(0,Z.jsxs)(Z.Fragment,{children:[p,m,g]}),t[17]=p,t[18]=m,t[19]=g,t[20]=_):_=t[20];let v=c.title,y;t[21]===c.summary?y=t[22]:(y=(0,Z.jsx)(Wh,{text:c.summary}),t[21]=c.summary,t[22]=y);let b;t[23]===d?b=t[24]:(b=d.map(zh),t[23]=d,t[24]=b);let x;t[25]!==c||t[26]!==o?(x=(0,Z.jsx)(Kh,{layer:c,onStep:o}),t[25]=c,t[26]=o,t[27]=x):x=t[27];let S;t[28]!==s||t[29]!==i.layers||t[30]!==n.elsewhere?(S=n.elsewhere.length>0&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:`Also changes`}),n.elsewhere.map(e=>(0,Z.jsxs)(h,{variant:`outline`,size:`xs`,title:e.path,onClick:()=>s(e.stop),children:[Pu(e.path),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:e.stop===`specs`?`· in Specs`:`· shown in decision ${i.layers.findIndex(t=>Xd(t.id)===e.stop)+1}`})]},e.path))]}),t[28]=s,t[29]=i.layers,t[30]=n.elsewhere,t[31]=S):S=t[31],l=(0,Z.jsxs)(Ih,{eyebrow:_,title:v,lead:y,children:[e.length>0&&(0,Z.jsx)(`ol`,{"aria-label":`Route through the system`,className:`flex flex-wrap items-center gap-1.5`,children:e.map(Vh)}),u.length>0&&(0,Z.jsx)(`ul`,{"aria-label":`Connections`,className:`flex flex-wrap gap-1.5`,children:u.map(Bh)}),b,x,S,f.checks.length>0&&(0,Z.jsx)(`ul`,{"aria-label":`Checks for this decision`,className:`flex flex-wrap gap-1.5`,children:Pd(f.checks).map(Rh)})]}),t[0]=a?.reviewed,t[1]=a?.stale,t[2]=c,t[3]=s,t[4]=o,t[5]=i,t[6]=n.elsewhere,t[7]=n.number,t[8]=r,t[9]=l}else l=t[9];return l}function Rh(e){return(0,Z.jsxs)(`li`,{className:I(`rounded-md border px-2 py-1 text-xs`,e.result===`fail`&&`border-destructive/40 text-destructive`),children:[e.name,` · `,Ld(e.result)]},e.name)}function zh(e){return(0,Z.jsx)(hh,{part:e},e.id)}function Bh(e){return(0,Z.jsxs)(`li`,{className:`flex items-center gap-1.5 rounded-md border bg-background px-2 py-1 text-xs`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:e.outgoing?e.verb:`${e.part.label} ${e.verb}`}),e.outgoing&&(0,Z.jsx)(`span`,{className:`font-medium`,children:e.part.label}),e.change&&(0,Z.jsx)(`span`,{className:I(`rounded px-1 text-2xs font-medium`,e.change===`new`&&`bg-graph-2/12 text-graph-2`,e.change===`changed`&&`bg-graph-1/12 text-graph-1`,e.change===`removed`&&`bg-destructive/10 text-destructive`),children:e.change===`new`?`New`:e.change===`changed`?`Changed`:`Removed`})]},e.part.id)}function Vh(e,t){return(0,Z.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[t>0&&(0,Z.jsx)(xa,{className:`size-3 text-muted-foreground`,"aria-hidden":`true`}),(0,Z.jsx)(Re,{variant:`secondary`,children:e})]},`${e}:${t}`)}function Hh(e,t,n){return n.findIndex(t=>t.id===e.id)===t}function Uh(e){return e.part.problem?[e.part]:[]}function Wh(e){let t=(0,$.c)(11),{text:n}=e,[r,i]=(0,Q.useState)(!1),a=n.length>320,o=a&&!r&&`line-clamp-3`,s;t[0]===o?s=t[1]:(s=I(`text-sm`,o),t[0]=o,t[1]=s);let c;t[2]!==s||t[3]!==n?(c=(0,Z.jsx)(yr,{text:n,className:s}),t[2]=s,t[3]=n,t[4]=c):c=t[4];let l;t[5]!==a||t[6]!==r?(l=a&&(0,Z.jsx)(h,{variant:`link`,size:`xs`,onClick:()=>i(Gh),children:r?`Show less`:`Read more`}),t[5]=a,t[6]=r,t[7]=l):l=t[7];let u;return t[8]!==c||t[9]!==l?(u=(0,Z.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u}function Gh(e){return!e}function Kh(e){let t=(0,$.c)(9),{layer:n,onStep:r}=e,i;if(t[0]!==n.lanes||t[1]!==n.steps||t[2]!==r){let e;t[4]!==n.lanes||t[5]!==r?(e=(e,t)=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,"aria-label":`Go to step ${t+1}: ${e.title}`,onClick:()=>r(e),className:`flex w-full items-start gap-2.5 rounded-lg border bg-background px-2.5 py-2 text-left hover:border-foreground/20 hover:bg-accent/40`,children:[(0,Z.jsx)(`span`,{className:I(`mt-px grid size-5 shrink-0 place-items-center rounded-full bg-graph-1/12 text-2xs font-semibold text-graph-1 tabular-nums`,e.kind===`context`&&`bg-muted text-muted-foreground`),children:t+1}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(`span`,{className:`text-caption font-medium`,children:e.title}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 text-2xs text-muted-foreground`,children:[(0,Z.jsx)(vi,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`truncate`,title:e.pointer.path,children:e.pointer.path})]}),(0,Z.jsxs)(`span`,{className:`text-2xs text-muted-foreground`,children:[n.lanes[e.lane],e.kind===`context`&&` · existing code`,e.location.state===`changed`&&(0,Z.jsx)(`span`,{className:`text-graph-4`,children:` · code moved`}),e.location.state===`committed`&&` · committed`]})]})]})},e.id),t[4]=n.lanes,t[5]=r,t[6]=e):e=t[6],i=n.steps.map(e),t[0]=n.lanes,t[1]=n.steps,t[2]=r,t[3]=i}else i=t[3];let a;return t[7]===i?a=t[8]:(a=(0,Z.jsx)(`ol`,{"aria-label":`Steps`,className:`grid grid-cols-2 gap-1.5 max-narrow:grid-cols-1`,children:i}),t[7]=i,t[8]=a),a}function qh(e){let t=(0,$.c)(10),{stop:n,stops:r,onGo:i}=e,a;t[0]===r?a=t[1]:(a=e=>{let t=r.find(t=>t.key===e);return t?nf(t):e},t[0]=r,t[1]=a);let o=a,s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(`span`,{className:`tracking-wide uppercase`,children:`After the decisions`}),t[2]=s):s=t[2];let c=n.paths.length>0?`${n.paths.length} changed ${n.paths.length===1?`file has`:`files have`} no decision pointing at ${n.paths.length===1?`it`:`them`}. Read ${n.paths.length===1?`it`:`them`} before calling the review done, or ask the agent to explain.`:`Every changed file belongs to a decision, but some lines inside them have no explanation.`,l;t[3]!==i||t[4]!==n.partial||t[5]!==o?(l=n.partial.length>0&&(0,Z.jsx)(`ul`,{"aria-label":`Unexplained lines in explained files`,className:`flex flex-col gap-1.5`,children:n.partial.map(e=>(0,Z.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2 rounded-lg border border-graph-4/40 bg-graph-4/5 px-3 py-2 text-sm`,children:[(0,Z.jsx)(Sn,{className:`size-4 shrink-0 text-graph-4`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 break-all`,title:e.path,children:[e.path,(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,e.ranges.length>0?$f(e.ranges):`whole file`]})]}),(0,Z.jsxs)(h,{variant:`outline`,size:`xs`,onClick:()=>i(e.stop),children:[`Read in `,o(e.stop)]})]},e.path))}),t[3]=i,t[4]=n.partial,t[5]=o,t[6]=l):l=t[6];let u;return t[7]!==c||t[8]!==l?(u=(0,Z.jsx)(Ih,{eyebrow:s,title:`Not explained`,lead:c,children:l}),t[7]=c,t[8]=l,t[9]=u):u=t[9],u}function Jh(e){let t=(0,$.c)(55),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({address:n,onRefresh:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let{review:a,scope:o,context:s,interaction:c}=i,l=ph(o,s,a),u=l.view,[d,f]=(0,Q.useState)(),p=l.go,m;t[4]!==p||t[5]!==l.stop.key||t[6]!==l.stops?(m=e=>{let t=$d(l.stops,l.stop.key,e);t&&p(t.key)},t[4]=p,t[5]=l.stop.key,t[6]=l.stops,t[7]=m):m=t[7];let g=m,_=c.active&&u===`walkthrough`,v;t[8]===_?v=t[9]:(v={ignoreInputs:!0,enabled:_},t[8]=_,t[9]=v);let y=v,b;t[10]===g?b=t[11]:(b=()=>g(1),t[10]=g,t[11]=b),vn(In.nextStop,b,y);let x;t[12]===g?x=t[13]:(x=()=>g(-1),t[12]=g,t[13]=x),vn(In.previousStop,x,y);let S;t[14]===l.stops?S=t[15]:(S=l.stops.flatMap(Yh),t[14]=l.stops,t[15]=S);let C=S,w=`${a.layers.length} ${a.layers.length===1?`decision`:`decisions`} · ${C.length} changed ${C.length===1?`file`:`files`}`,T;t[16]!==r||t[17]!==a.summary||t[18]!==l?(T=e=>{e===`summary`?(f(a.summary),r(),l.setView(`summary`)):l.setView(`walkthrough`)},t[16]=r,t[17]=a.summary,t[18]=l,t[19]=T):T=t[19];let E;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsxs)(Ri,{children:[(0,Z.jsx)(Oi,{value:`walkthrough`,children:`Walkthrough`}),(0,Z.jsx)(Oi,{value:`summary`,children:`Agent summary`})]}),t[20]=E):E=t[20];let D;t[21]!==T||t[22]!==u?(D=(0,Z.jsx)(Ti,{value:u,onValueChange:T,"aria-label":`Review presentation`,children:E}),t[21]=T,t[22]=u,t[23]=D):D=t[23];let O;t[24]!==D||t[25]!==w?(O=(0,Z.jsx)(Qp,{title:`Review`,subtitle:w,children:D}),t[24]=D,t[25]=w,t[26]=O):O=t[26];let k=u===`walkthrough`?l.stop.key:void 0,A;t[27]===l.decisions.states?A=t[28]:(A=e=>l.decisions.states.get(e)?.stale,t[27]=l.decisions.states,t[28]=A);let j;t[29]!==p||t[30]!==k||t[31]!==A||t[32]!==l.done||t[33]!==l.items||t[34]!==l.stops?(j=(0,Z.jsx)(Xh,{stops:l.stops,items:l.items,current:k,done:l.done,staleDecision:A,onGo:p}),t[29]=p,t[30]=k,t[31]=A,t[32]=l.done,t[33]=l.items,t[34]=l.stops,t[35]=j):j=t[35];let M;t[36]!==l.decisions.failed||t[37]!==l.decisions.retry?(M=l.decisions.failed&&(0,Z.jsxs)(`p`,{role:`alert`,className:`flex shrink-0 flex-wrap items-center gap-2 border-b px-3.5 py-2 text-xs text-destructive`,children:[`Which decisions you reviewed could not be read, so none are shown as reviewed.`,(0,Z.jsx)(h,{variant:`outline`,size:`xs`,onClick:l.decisions.retry,children:`Try again`})]}),t[36]=l.decisions.failed,t[37]=l.decisions.retry,t[38]=M):M=t[38];let N;t[39]===a.diagnostics?N=t[40]:(N=a.diagnostics===`unavailable`&&(0,Z.jsx)(`p`,{role:`status`,className:`border-b px-3.5 py-2 text-xs`,children:`The worktree is unavailable. This is the saved review; code locations and coverage could not be checked.`}),t[39]=a.diagnostics,t[40]=N);let P;t[41]!==n||t[42]!==p||t[43]!==d||t[44]!==i||t[45]!==a||t[46]!==u||t[47]!==l?(P=u===`summary`?a.summary===d?(0,Z.jsx)(`p`,{role:`status`,className:`p-4 text-sm text-muted-foreground`,children:`Refreshing summary…`}):(0,Z.jsx)($h,{review:a,address:n,onLayer:e=>p(Xd(e))}):l.stop.kind===`briefing`?(0,Z.jsx)(gh,{...i,stops:l.stops,items:l.items,decisions:l.decisions.states,done:l.done,onGo:p}):(0,Z.jsx)(jh,{...i,stop:l.stop,stops:l.stops,items:l.items,decision:l.stop.kind===`decision`?l.decisions.states.get(l.stop.layer.id):void 0,decisionsSettled:l.decisions.settled,finished:l.done(l.stop),onGo:p},l.stop.key),t[41]=n,t[42]=p,t[43]=d,t[44]=i,t[45]=a,t[46]=u,t[47]=l,t[48]=P):P=t[48];let F;return t[49]!==O||t[50]!==j||t[51]!==M||t[52]!==N||t[53]!==P?(F=(0,Z.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":`Review walkthrough`,children:[O,j,M,N,P]}),t[49]=O,t[50]=j,t[51]=M,t[52]=N,t[53]=P,t[54]=F):F=t[54],F}function Yh(e){return e.paths}function Xh(e){let t=(0,$.c)(38),{stops:n,items:r,current:i,done:a,staleDecision:o,onGo:s}=e,c;t[0]!==r||t[1]!==n?(c=ef(n.flatMap(Qh),r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c,u,d;t[3]!==a||t[4]!==n?(u=n.filter(Zh),d=u.filter(a),t[3]=a,t[4]=n,t[5]=u,t[6]=d):(u=t[5],d=t[6]);let f=d,p;if(t[7]!==i||t[8]!==a||t[9]!==r||t[10]!==s||t[11]!==o||t[12]!==n){let e;t[14]!==i||t[15]!==a||t[16]!==r||t[17]!==s||t[18]!==o?(e=e=>{let t=ef(e.paths,r),n=a(e),c=e.kind===`decision`&&o(e.layer.id)===!0,l=e.kind===`briefing`?`Open the briefing`:`${nf(e)} · ${t.reviewed} of ${t.total} files reviewed${c?` · code moved`:``}${n?` · done`:``}`,u=e.key===i;return e.kind===`briefing`?(0,Z.jsx)(`li`,{className:`shrink-0`,children:(0,Z.jsx)(`button`,{type:`button`,"aria-label":l,title:l,"aria-current":u?`step`:void 0,onClick:()=>s(e.key),className:I(`grid size-6 place-items-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground`,u&&`bg-accent text-foreground`),children:(0,Z.jsx)(Fa,{className:`size-3.5`})})},e.key):(0,Z.jsx)(`li`,{className:`min-w-3`,style:{flexGrow:Math.max(1,e.paths.length)},children:(0,Z.jsx)(`button`,{type:`button`,"aria-label":l,title:l,"aria-current":u?`step`:void 0,onClick:()=>s(e.key),className:`group flex h-6 w-full items-center`,children:(0,Z.jsx)(`span`,{className:I(`relative block h-1.5 w-full overflow-hidden rounded-full bg-muted transition-[height] group-hover:h-2.5`,c&&`bg-graph-4/25`,e.kind===`unexplained`&&`bg-graph-4/20`,u&&`h-2.5 bg-foreground/20`),children:(0,Z.jsx)(`span`,{className:I(`absolute inset-y-0 left-0 rounded-full bg-graph-2/70`,n&&`bg-graph-2`),style:{width:`${t.total===0?n?100:0:t.reviewed/t.total*100}%`}})})})},e.key)},t[14]=i,t[15]=a,t[16]=r,t[17]=s,t[18]=o,t[19]=e):e=t[19],p=n.map(e),t[7]=i,t[8]=a,t[9]=r,t[10]=s,t[11]=o,t[12]=n,t[13]=p}else p=t[13];let m;t[20]===p?m=t[21]:(m=(0,Z.jsx)(`ol`,{className:`flex min-w-0 flex-1 items-center gap-1`,children:p}),t[20]=p,t[21]=m);let h;t[22]!==l.done||t[23]!==l.total?(h=l.done&&l.total>0&&(0,Z.jsx)(k,{className:`size-3.5 text-graph-2`,"aria-hidden":`true`}),t[22]=l.done,t[23]=l.total,t[24]=h):h=t[24];let g;t[25]!==l.reviewed||t[26]!==l.total?(g=(0,Z.jsxs)(`span`,{children:[l.reviewed,` of `,l.total,` files reviewed`]}),t[25]=l.reviewed,t[26]=l.total,t[27]=g):g=t[27];let _;t[28]!==u.length||t[29]!==f.length?(_=(0,Z.jsxs)(`span`,{className:`text-muted-foreground max-narrow:hidden`,children:[`· `,f.length,` of `,u.length,` decisions`]}),t[28]=u.length,t[29]=f.length,t[30]=_):_=t[30];let v;t[31]!==h||t[32]!==g||t[33]!==_?(v=(0,Z.jsxs)(`p`,{role:`status`,className:`flex shrink-0 items-center gap-1.5 text-xs tabular-nums`,children:[h,g,_]}),t[31]=h,t[32]=g,t[33]=_,t[34]=v):v=t[34];let y;return t[35]!==m||t[36]!==v?(y=(0,Z.jsxs)(`nav`,{"aria-label":`Walkthrough progress`,className:`flex shrink-0 items-center gap-3 border-b px-3.5 py-1.5`,children:[m,v]}),t[35]=m,t[36]=v,t[37]=y):y=t[37],y}function Zh(e){return e.kind===`decision`}function Qh(e){return e.paths}function $h(e){let t=(0,$.c)(11),{review:n,address:r,onLayer:i}=e,a=(0,Q.useRef)(null),{dark:s}=ln(),c;t[0]!==i||t[1]!==n.layers?(c=e=>{let t=n.layers[e-1];t&&i(t.id)},t[0]=i,t[1]=n.layers,t[2]=c):c=t[2],dh(a,c);let l;t[3]!==r||t[4]!==n.summary?(l=Fu(n.summary,r,o()),t[3]=r,t[4]=n.summary,t[5]=l):l=t[5];let u=`${l}#theme=${s?`dark`:`light`}`,d=s?`dark`:`light`,f;t[6]===d?f=t[7]:(f={colorScheme:d},t[6]=d,t[7]=f);let p;return t[8]!==u||t[9]!==f?(p=(0,Z.jsx)(`iframe`,{ref:a,title:`Review summary`,src:u,sandbox:`allow-scripts allow-forms allow-popups allow-modals`,referrerPolicy:`no-referrer`,className:`block min-h-0 w-full flex-1 border-0`,style:f}),t[8]=u,t[9]=f,t[10]=p):p=t[10],p}function eg(e){let t=(0,$.c)(42),{scope:n,context:r,document:i,onOpen:a,active:o,reveal:s,base:c}=e,l=o!==void 0&&o,u=n.worktreeId,d;t[0]===i?d=t[1]:(d=Wl(i),t[0]=i,t[1]=d);let f;t[2]!==l||t[3]!==s||t[4]!==n.worktreeId||t[5]!==d?(f={active:l,worktreeId:u,entry:d,reveal:s},t[2]=l,t[3]=s,t[4]=n.worktreeId,t[5]=d,t[6]=f):f=t[6];let p;t[7]!==r||t[8]!==a||t[9]!==n||t[10]!==f?(p={scope:n,context:r,onOpen:a,interaction:f},t[7]=r,t[8]=a,t[9]=n,t[10]=f,t[11]=p):p=t[11];let m=p;switch(i.kind){case`handoff`:{let e;return t[12]===m?e=t[13]:(e=(0,Z.jsx)(rg,{...m}),t[12]=m,t[13]=e),e}case`all-changes`:{let e;return t[14]===m?e=t[15]:(e=(0,Z.jsx)(ig,{...m}),t[14]=m,t[15]=e),e}case`specs`:{let e;return t[16]===m?e=t[17]:(e=(0,Z.jsx)(ig,{...m,specsOnly:!0}),t[16]=m,t[17]=e),e}case`proof`:{let e;return t[18]!==r||t[19]!==n?(e=(0,Z.jsx)(qm,{scope:n,context:r}),t[18]=r,t[19]=n,t[20]=e):e=t[20],e}case`change`:{let e;return t[21]!==i.path||t[22]!==m?(e=(0,Z.jsx)(ug,{...m,path:i.path}),t[21]=i.path,t[22]=m,t[23]=e):e=t[23],e}case`file`:{let e;return t[24]!==i.path||t[25]!==m?(e=(0,Z.jsx)(km,{...m,path:i.path}),t[24]=i.path,t[25]=m,t[26]=e):e=t[26],e}case`commit`:{let e;return t[27]!==i.oid||t[28]!==m?(e=(0,Z.jsx)(gm,{...m,oid:i.oid}),t[27]=i.oid,t[28]=m,t[29]=e):e=t[29],e}case`branch`:{let e;return t[30]!==c||t[31]!==m?(e=(0,Z.jsx)(am,{...m,base:c}),t[30]=c,t[31]=m,t[32]=e):e=t[32],e}case`branch-file`:{let e;return t[33]!==c||t[34]!==i.path||t[35]!==m?(e=(0,Z.jsx)(om,{...m,base:c,path:i.path}),t[33]=c,t[34]=i.path,t[35]=m,t[36]=e):e=t[36],e}case`timeline`:{let e;return t[37]!==i.path||t[38]!==m?(e=(0,Z.jsx)(ng,{...m,path:i.path}),t[37]=i.path,t[38]=m,t[39]=e):e=t[39],e}case`graph`:{let e;return t[40]===m?e=t[41]:(e=(0,Z.jsx)(tg,{...m}),t[40]=m,t[41]=e),e}}}function tg(e){let t=(0,$.c)(7),{scope:n,context:r,onOpen:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Qp,{title:(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(Za,{className:`size-4 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:`Commit graph`})]}),subtitle:`Commits on this branch with their merges and refs`}),t[0]=a):a=t[0];let o;t[1]===i?o=t[2]:(o=e=>i({kind:`commit`,oid:e}),t[1]=i,t[2]=o);let s;return t[3]!==r.connection||t[4]!==n||t[5]!==o?(s=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[a,(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,Z.jsx)(Rf,{scope:n,connection:r.connection,onSelect:o})})]}),t[3]=r.connection,t[4]=n,t[5]=o,t[6]=s):s=t[6],s}function ng(e){let t=(0,$.c)(16),{scope:n,context:r,path:i,onOpen:a}=e,o=`Timeline of ${i}`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(Si,{className:`size-4 shrink-0`}),t[0]=s):s=t[0];let c;t[1]===i?c=t[2]:(c=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[s,(0,Z.jsx)(`span`,{className:`truncate`,children:i})]}),t[1]=i,t[2]=c);let l;t[3]!==o||t[4]!==c?(l=(0,Z.jsx)(Qp,{titleLabel:o,title:c,subtitle:`Commits that changed this file`}),t[3]=o,t[4]=c,t[5]=l):l=t[5];let u;t[6]===a?u=t[7]:(u=e=>a({kind:`commit`,oid:e.oid},{kind:`file`,filePath:e.path,revision:e.oid,comparison:{kind:`commit`,parent:1}}),t[6]=a,t[7]=u);let d;t[8]!==r.connection||t[9]!==i||t[10]!==n||t[11]!==u?(d=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,Z.jsx)(Bf,{scope:n,connection:r.connection,path:i,onSelect:u})}),t[8]=r.connection,t[9]=i,t[10]=n,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function rg(e){let t=(0,$.c)(9),n=Ad(e.scope,e.context),r=n.review;if(f(n.result)){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`p`,{role:`status`,className:`p-4 text-sm`,children:`Loading review…`}),t[0]=e):e=t[0],e}if(B(n.result)){let e;return t[1]===n.refresh?e=t[2]:(e=(0,Z.jsx)(dg,{retry:n.refresh}),t[1]=n.refresh,t[2]=e),e}if(r?.active){let i;return t[3]!==e||t[4]!==n.refresh||t[5]!==r?(i=(0,Z.jsx)(Jh,{...e,review:r,onRefresh:n.refresh,address:e.context.connection.address}),t[3]=e,t[4]=n.refresh,t[5]=r,t[6]=i):i=t[6],i}let i;return t[7]===e?i=t[8]:(i=(0,Z.jsx)(ig,{...e}),t[7]=e,t[8]=i),i}function ig(e){let t=(0,$.c)(26),{scope:n,context:r,interaction:i,specsOnly:a}=e,o=a!==void 0&&a,{connection:s}=r;Kf(n,r);let{preferences:c}=Tn(),l=zr(n,s),u=qf(n,r,l),d=Ad(n,r),f=!o&&d.review?.active?d.review:void 0,p;t[0]!==u||t[1]!==o?(p=o?u.filter(lg):u,t[0]=u,t[1]=o,t[2]=p):p=t[2];let m=p,h;t[3]!==l||t[4]!==c||t[5]!==f?(h=f?Zd(f,l.changes.map(cg),{specsApart:c.collapseSpecs}).flatMap(sg):[],t[3]=l,t[4]=c,t[5]=f,t[6]=h):h=t[6];let g=h,_;t[7]!==m||t[8]!==o?(_=o?{paths:m.map(og)}:{},t[7]=m,t[8]=o,t[9]=_):_=t[9];let v;t[10]!==f||t[11]!==g?(v=f?{files:g,agentNotes:ap(...f.layers.map(ag),ip(f.notExplained))}:{},t[10]=f,t[11]=g,t[12]=v):v=t[12];let y;t[13]!==m||t[14]!==r||t[15]!==i||t[16]!==n||t[17]!==o?(y=e=>(0,Z.jsxs)(Qp,{title:o?`Specs`:i.entry===`all-changes`?`All changes`:`Changes`,subtitle:`${m.length} files`,children:[e,(0,Z.jsx)(nm,{scope:n,context:r,entries:m})]}),t[13]=m,t[14]=r,t[15]=i,t[16]=n,t[17]=o,t[18]=y):y=t[18];let b;return t[19]!==r||t[20]!==i||t[21]!==n||t[22]!==_||t[23]!==v||t[24]!==y?(b=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,Z.jsx)(Ym,{scope:n,context:r,interaction:i,..._,...v,toolbar:y})}),t[19]=r,t[20]=i,t[21]=n,t[22]=_,t[23]=v,t[24]=y,t[25]=b):b=t[25],b}function ag(e,t){return rp(e,t+1)}function og(e){return e.path}function sg(e){return e.paths.map(t=>({path:t,note:nf(e)}))}function cg(e){return e.path}function lg(e){return Jd(e.path)}function ug(e){let t=(0,$.c)(14),{scope:n,context:r,interaction:i,onOpen:a,path:o}=e,{connection:s}=r;Kf(n,r);let c=zr(n,s),l;if(t[0]===o?l=t[1]:(l=[o],t[0]=o,t[1]=l),!qf(n,r,c,l).find(e=>e.path===o)){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(im,{title:`Change no longer present`,description:`Choose a change that is still present in the current review.`}),t[2]=e):e=t[2],e}let u;t[3]!==r||t[4]!==i||t[5]!==a||t[6]!==o||t[7]!==n?(u=e=>(0,Z.jsx)(Ym,{...i.reveal?.compose?{commentRequest:i.reveal.nonce}:{},headerActions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(h,{variant:`ghost`,size:`xs`,onClick:()=>a({kind:`file`,path:o}),children:[(0,Z.jsx)(Ga,{}),(0,Z.jsx)(`span`,{className:`max-narrow:sr-only`,children:`Open file`})]}),e]}),scope:n,context:r,interaction:i,paths:[o]}),t[3]=r,t[4]=i,t[5]=a,t[6]=o,t[7]=n,t[8]=u):u=t[8];let d;return t[9]!==r||t[10]!==o||t[11]!==n||t[12]!==u?(d=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,Z.jsx)(Wi,{scope:n,context:r,path:o,variant:`quiet`,children:u})}),t[9]=r,t[10]=o,t[11]=n,t[12]=u,t[13]=d):d=t[13],d}function dg(e){let t=(0,$.c)(3),{retry:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(im,{title:`Review could not be loaded`,description:`The saved publication could not be read.`}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center p-4`,children:[r,(0,Z.jsx)(h,{variant:`outline`,onClick:n,children:`Retry review`})]}),t[1]=n,t[2]=i),i}function fg(e,t){let n=(0,$.c)(6),r;n[0]===e?r=n[1]:(r=C(e),n[0]=e,n[1]=r);let i;n[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={mode:`promiseExit`},n[2]=i):i=n[2];let a=Te(r,i),o;return n[3]!==a||n[4]!==t?(o=e=>{a(t).then(t=>{de(t)&&e()})},n[3]=a,n[4]=t,n[5]=o):o=n[5],o}var pg=class extends Q.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}render(){return this.state.error?(0,Z.jsx)(`div`,{className:`px-1.5 py-3`,children:(0,Z.jsx)(Je,{children:(0,Z.jsxs)(Ge,{children:[Mu(this.state.error),(0,Z.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>{this.props.reset(()=>this.setState({error:null}))},children:`Try again`})]})})}):this.props.children}};function mg(e){let t=(0,$.c)(6),{children:n,connection:r,scope:i}=e,a=fg(r,i),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsxs)(`div`,{role:`status`,"aria-label":`Loading review`,className:`flex flex-col gap-3 p-4`,children:[(0,Z.jsx)(ra,{className:`h-5 w-2/3`}),(0,Z.jsx)(ra,{className:`h-9 w-full`}),(0,Z.jsx)(ra,{className:`h-9 w-full`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Loading review…`})]}),t[0]=o):o=t[0];let s;t[1]===n?s=t[2]:(s=(0,Z.jsx)(Q.Suspense,{fallback:o,children:n}),t[1]=n,t[2]=s);let c;return t[3]!==a||t[4]!==s?(c=(0,Z.jsx)(pg,{reset:a,children:s}),t[3]=a,t[4]=s,t[5]=c):c=t[5],c}function hg({defaultTagName:e,props:t,render:n,state:r={},stateAttributesMapping:i}){let a=gg(_g(r,i),t);if(!n)return Q.createElement(e,a);if(typeof n==`function`)return n(a,r);if(!Q.isValidElement(n))return null;let o=n.props,s={...gg(a,o),ref:bg(a.ref,o.ref)};return Q.cloneElement(n,s)}function gg(...e){let t={};for(let n of e){if(!n)continue;let e=n;for(let n of Object.keys(e)){let r=e[n];if(r===void 0)continue;let i=t[n];t[n]=n===`className`?[i,r].filter(Boolean).join(` `):n===`style`?{...i,...r}:n===`ref`?bg(i,r):yg(n)&&typeof i==`function`&&typeof r==`function`?vg(r,i):r}}return t}function _g(e,t){let n={};for(let r of Object.keys(e)){let i=e[r],a=t?.[r]?.(i);if(a){Object.assign(n,a);continue}if(r===`slot`){n[`data-slot`]=i;continue}let o=`data-${String(r).replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}`;typeof i==`boolean`?n[o]=i?``:void 0:i!=null&&(n[o]=String(i))}return n}function vg(e,t){return function(n){e(n),n.defaultPrevented||t(n)}}function yg(e){return/^on[A-Z]/.test(e)}function bg(...e){let t=e.filter(Boolean);if(t.length!==0)return e=>{for(let n of t)typeof n==`function`?n(e):n&&(n.current=e)}}var xg=8,Sg=64,Cg=0,wg=.5,Tg=180,Eg=new Set([`ArrowDown`,`ArrowUp`,`End`,`Home`,`PageDown`,`PageUp`,` `]),Dg={start:!1,end:!1},Og={currentAnchorId:null,visibleMessageIds:[]};function kg({content:e,scrollEdgeThreshold:t,spacer:n,viewport:r}){if(!r||!e)return Dg;let i=Vg({content:e,spacer:n,viewport:r});return{start:r.scrollTop>t,end:i-r.scrollTop-r.clientHeight>t}}function Ag({content:e,scrollMargin:t,scrollPreviousItemPeek:n,spacer:r,viewport:i,visibleMessageIds:a}){if(!e||!i)return Og;let o=i.getBoundingClientRect(),s=o.top+t+n,c=typeof IntersectionObserver>`u`,l=[],u=null;for(let t of jg(e,r)){let e=t.dataset.messageId;if(!e)continue;let n=t.dataset.scrollAnchor===`true`,r=n||c?t.getBoundingClientRect():null;(c&&r?r.bottom>s&&r.top<o.bottom:a.has(e))&&l.push(e),n&&r&&r.top<=s+wg&&(u=e)}return l.length===0&&u===null?Og:{currentAnchorId:u,visibleMessageIds:l}}function jg(e,t){return Array.from(e.children).filter(e=>e instanceof HTMLElement&&e!==t)}function Mg(e,t){for(let n=t;n<e.length;n++){let t=e[n];if(t?.dataset.scrollAnchor===`true`)return t}return null}function Ng(e,t){for(let n of e)if(n.dataset.scrollAnchor===`true`&&!t.has(n))return n;return null}function Pg(e,t){let n=0;for(let r=t;r<e.length;r++)if(e[r]?.dataset.scrollAnchor===`true`&&(n+=1,n>1))return!0;return!1}function Fg(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.dataset.scrollAnchor===`true`)return n}return null}function Ig({content:e,spacer:t,viewport:n}){let r=n.getBoundingClientRect();for(let n of jg(e,t)){if(!n.dataset.messageId)continue;let e=n.getBoundingClientRect();if(e.bottom>r.top&&e.top<r.bottom)return n}return null}function Lg({align:e,element:t,scrollMargin:n,spacer:r,viewport:i}){let a=Rg(t,i),o=t.getBoundingClientRect().height,s=Wg(r);if(e===`center`){let e=Math.max(0,i.clientHeight-s.start-s.end);return a-s.start-(e-o)/2-n}if(e===`end`)return a-i.clientHeight+o+s.end+n;if(e===`nearest`){let e=a+o,t=i.scrollTop+s.start,r=i.scrollTop+i.clientHeight-s.end;return a>=t&&e<=r?i.scrollTop:a<t?a-s.start-n:e-i.clientHeight+s.end+n}return a-s.start-n}function Rg(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function zg(e,t){return e.getBoundingClientRect().top-t.getBoundingClientRect().top}function Bg({content:e,scrollTop:t,spacer:n,viewport:r}){let i=Vg({content:e,spacer:n,viewport:r});return t+r.clientHeight-i}function Vg({content:e,spacer:t,viewport:n}){let r=jg(e,t),i=Ug(e),a=n.getBoundingClientRect(),o=n.scrollTop,s=i.start+i.end;for(let e of r){let t=e.getBoundingClientRect();s=Math.max(s,t.bottom-a.top+o+i.end)}return s}function Hg(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function Ug(e){let t=window.getComputedStyle(e);return{end:Kg(t.paddingBlockEnd||t.paddingBottom),start:Kg(t.paddingBlockStart||t.paddingTop)}}function Wg(e){let t=e?.parentElement;return t?Ug(t):{end:0,start:0}}function Gg(e){if(!e)return 0;let t=window.getComputedStyle(e);return Kg(t.rowGap===`normal`?t.gap:t.rowGap)}function Kg(e){if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function qg(e,t){let n=e,r=new Set;return{getSnapshot:()=>n,hasListeners:()=>r.size>0,setSnapshot:e=>{t(n,e)||(n=e,r.forEach(e=>e()))},subscribe:(e,t,n)=>{let i=r.size===0;return r.add(e),i&&t?.(),()=>{r.delete(e),r.size===0&&n?.()}}}}function Jg(e,t){return qg(e,t)}function Yg(){return qg(Og,Zg)}function Xg(e,t){return e.start===t.start&&e.end===t.end}function Zg(e,t){return e.currentAnchorId!==t.currentAnchorId||e.visibleMessageIds.length!==t.visibleMessageIds.length?!1:e.visibleMessageIds.every((e,n)=>e===t.visibleMessageIds[n])}function Qg({autoScroll:e,defaultScrollPosition:t,scrollEdgeThreshold:n,scrollMargin:r,scrollPreviousItemPeek:i}){let a=Q.useRef(e),o=Q.useRef(!1),s=Q.useRef(null),c=Q.useRef(!1),l=Q.useRef(n),u=Q.useRef(0),d=Q.useRef(null),f=Q.useRef(0),p=Q.useRef(e?`following-bottom`:`free-scrolling`),m=Q.useRef(new Map),h=Q.useRef(null),g=Q.useRef(null),_=Q.useRef(null),v=Q.useRef(i),y=Q.useRef(!0),b=Q.useRef(null),x=Q.useRef(r),S=Q.useRef(null),C=Q.useRef(0),w=Q.useRef(0),T=Q.useRef(null),E=Q.useRef(null),D=Q.useRef(null),O=Q.useRef(null),k=Q.useRef(null),A=Q.useRef(null),j=Q.useRef(null),M=Q.useRef(null),N=Q.useRef(null),P=Q.useRef(new Set),F=Q.useRef(new WeakSet);return D.current===null&&(D.current=Jg(t===`end`||t===`last-anchor`,(e,t)=>e===t)),O.current===null&&(O.current=Jg(Dg,Xg)),N.current===null&&(N.current=Yg()),a.current=e,l.current=n,x.current=r,v.current=i,{autoScrollRef:a,autoscrollingRef:o,autoscrollingTimeoutRef:k,streamingTurnRef:_,contentRef:s,defaultScrollPositionAppliedRef:c,firstItemRef:d,itemCountRef:u,lastScrollTopRef:f,messageElementsRef:m,modeRef:p,pendingScrollFrameRef:S,pendingScrollToMessageRef:h,prependRestoreRef:g,preserveScrollOnPrependRef:y,pendingDefaultScrollStore:D.current,rootRef:b,scrollEdgeThresholdRef:l,scrollMarginRef:x,scrollPreviousItemPeekRef:v,spacerGapRef:C,spacerHeightRef:w,spacerRef:T,stateFrameRef:E,stateStore:O.current,viewportRef:A,visibilityFrameRef:j,visibilityObserverRef:M,visibilityStore:N.current,visibleMessageIdsRef:P,handledScrollAnchorsRef:F}}function $g(e){e.pendingDefaultScrollStore.setSnapshot(!1)}function e_(e){e.defaultScrollPositionAppliedRef.current=!0,$g(e)}function t_({refs:e,commitScrollState:t,scheduleStateCommit:n,scheduleVisibilitySync:r}){let{streamingTurnRef:i,autoScrollRef:a,autoscrollingRef:o,autoscrollingTimeoutRef:s,contentRef:c,itemCountRef:l,messageElementsRef:u,modeRef:d,pendingScrollToMessageRef:f,prependRestoreRef:p,scrollMarginRef:m,scrollPreviousItemPeekRef:h,spacerGapRef:g,spacerHeightRef:_,spacerRef:v,viewportRef:y}=e,b=Q.useCallback(e=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null),o.current!==e&&(o.current=e,t()),e&&(s.current=window.setTimeout(()=>{s.current=null,o.current=!1,t()},Tg))},[t]),x=Q.useCallback(e=>{let t=v.current;if(!t)return;let n=Math.max(0,Math.ceil(e));_.current!==n&&(_.current=n,t.hidden=n===0,t.style.height=`${n}px`,t.style.marginTop=n>0?`${-g.current}px`:``)},[]),S=Q.useCallback((e,{behavior:r=`auto`,autoscrolling:i=!1}={})=>{let a=y.current;if(!a)return;let o=Math.max(0,e);if(Math.abs(a.scrollTop-o)<=wg){a.scrollTop=o,t();return}i&&b(!0),a.scrollTo({top:o,behavior:r}),n()},[t,n,b]),C=Q.useCallback(({behavior:e=`auto`}={})=>y.current?(x(0),i.current=null,d.current=`free-scrolling`,S(0,{behavior:e}),r(),!0):!1,[r,S,x]),w=Q.useCallback(({behavior:e=`auto`}={})=>{let t=y.current;return t?(x(0),i.current=null,d.current=a.current?`following-bottom`:`free-scrolling`,S(Hg(t),{autoscrolling:!0,behavior:e}),r(),!0):!1},[r,S,x]),T=Q.useCallback((e,{align:t=`start`,behavior:n=`auto`,scrollMargin:a=m.current}={},{keepPreviousPeek:o=!1}={})=>{let s=c.current,l=y.current;if(!s||!l||!s.contains(e))return!1;let u=Lg({align:t,element:e,scrollMargin:o?a+h.current:a,spacer:v.current,viewport:l}),f=Bg({content:s,scrollTop:u,spacer:v.current,viewport:l});return x(f),p.current={element:e,viewportTop:zg(e,l)},d.current=o?`anchored-to-message`:`settling-jump`,i.current=o?e:null,S(u,{behavior:n}),r(),!0},[r,S,x]),E=Q.useCallback(()=>{let e=i.current;return!e||!e.isConnected||d.current!==`anchored-to-message`?!1:T(e,{align:`start`},{keepPreviousPeek:!0})},[T]),D=Q.useCallback((t,n)=>{let r=u.current.get(t);return r?(e_(e),T(r,n)?(f.current=null,!0):(f.current={messageId:t,options:n},!0)):l.current===0&&(f.current={messageId:t,options:n},e_(e),!0)},[T]);return{flushPendingScrollToMessage:Q.useCallback(()=>{let t=f.current;if(!t)return!1;let n=u.current.get(t.messageId);return!n||!T(n,t.options)?!1:(f.current=null,e_(e),!0)},[T]),reanchorToAnchoredMessage:E,scrollToElement:T,scrollToEnd:w,scrollToMessage:D,scrollToStart:C}}function n_(e,t){return Q.useCallback(n=>{e.current=n,n&&t()},[e,t])}function r_({autoScroll:e=!1,defaultScrollPosition:t=`end`,scrollEdgeThreshold:n=xg,scrollPreviousItemPeek:r=Sg,scrollMargin:i=Cg}){let a=Qg({autoScroll:e,defaultScrollPosition:t,scrollEdgeThreshold:n,scrollMargin:i,scrollPreviousItemPeek:r}),{streamingTurnRef:o,autoScrollRef:s,autoscrollingRef:c,autoscrollingTimeoutRef:l,contentRef:u,defaultScrollPositionAppliedRef:d,firstItemRef:f,itemCountRef:p,lastScrollTopRef:m,messageElementsRef:h,modeRef:g,pendingScrollFrameRef:_,pendingScrollToMessageRef:v,prependRestoreRef:y,preserveScrollOnPrependRef:b,pendingDefaultScrollStore:x,rootRef:S,scrollEdgeThresholdRef:C,scrollMarginRef:w,scrollPreviousItemPeekRef:T,spacerGapRef:E,spacerHeightRef:D,spacerRef:O,stateFrameRef:k,stateStore:A,viewportRef:j,visibilityFrameRef:M,visibilityObserverRef:N,visibilityStore:P,visibleMessageIdsRef:F,handledScrollAnchorsRef:I}=a,L=Q.useRef(t);L.current!==t&&(L.current=t,d.current=!1);let R=Q.useCallback(e=>{let t=S.current,n=j.current,r=[e.start&&`start`,e.end&&`end`].filter(Boolean).join(` `),i=c.current;for(let e of[t,n])e&&(r?e.setAttribute(`data-scrollable`,r):e.removeAttribute(`data-scrollable`),e.toggleAttribute(`data-autoscrolling`,i))},[]),z=Q.useCallback(e=>{let t=j.current?.scrollTop??0,n=t<m.current-wg;m.current=t,s.current&&!e.end&&g.current!==`settling-jump`&&g.current!==`anchored-to-message`?g.current=`following-bottom`:g.current===`following-bottom`&&e.end&&n&&!c.current&&(g.current=`free-scrolling`)},[]),B=Q.useCallback(()=>{let e=kg({content:u.current,scrollEdgeThreshold:C.current,spacer:O.current,viewport:j.current});z(e);let t=g.current===`following-bottom`?{...e,end:!1}:e;R(t),A.setSnapshot(t)},[z,A,R]),V=Q.useCallback(()=>{k.current===null&&(k.current=window.requestAnimationFrame(()=>{k.current=null,B()}))},[B]),H=Q.useCallback(()=>{P.hasListeners()&&M.current===null&&(M.current=window.requestAnimationFrame(()=>{M.current=null,P.hasListeners()&&P.setSnapshot(Ag({content:u.current,scrollMargin:w.current,scrollPreviousItemPeek:T.current,spacer:O.current,viewport:j.current,visibleMessageIds:F.current}))}))},[P]),{flushPendingScrollToMessage:U,reanchorToAnchoredMessage:W,scrollToElement:G,scrollToEnd:K,scrollToMessage:q,scrollToStart:J}=t_({refs:a,commitScrollState:B,scheduleStateCommit:V,scheduleVisibilitySync:H}),ee=Q.useCallback(()=>{let e=y.current,t=j.current;if(!e||!t||!e.element.isConnected)return!1;let n=zg(e.element,t)-e.viewportTop;return Math.abs(n)<=wg?!1:(t.scrollTop+=n,e.viewportTop=zg(e.element,t),V(),H(),!0)},[V,H]),Y=Q.useCallback(()=>{let e=u.current,t=j.current;if(!e||!t){y.current=null;return}let n=Ig({content:e,spacer:O.current,viewport:t});y.current=n?{element:n,viewportTop:zg(n,t)}:null},[]),te=Q.useCallback(()=>{_.current===null&&(_.current=window.requestAnimationFrame(()=>{_.current=null,U()&&Y()}))},[Y,U]),ne=Q.useCallback(()=>{if(!t||d.current||p.current===0)return!1;let e=!1;if(t===`last-anchor`){let t=u.current,n=j.current,r=t&&n?Fg(jg(t,O.current)):null;if(!t||!n||!r)e=K({behavior:`auto`});else{let i=Rg(r,n);e=Vg({content:t,spacer:O.current,viewport:n})-i<=n.clientHeight?K({behavior:`auto`}):G(r,{align:`start`},{keepPreviousPeek:!0})}}else e=t===`end`?K({behavior:`auto`}):J({behavior:`auto`});return e?(e_(a),!0):!1},[t,G,K,J]),re=Q.useCallback(()=>{let e=u.current;if(!e)return;let t=jg(e,O.current),n=p.current,r=f.current;p.current=t.length,f.current=t[0]??null,(()=>{if(U())return;if(n===0){if(ne()||t.length>0&&s.current&&K({behavior:`auto`}))return;B(),H();return}let e=r?t.indexOf(r):-1;if(b.current&&e>0){ee();return}if(t.length>n){let e=Mg(t,n);if(e){if(s.current&&g.current===`following-bottom`&&Pg(t,n)){K({behavior:`auto`});return}G(e,{align:`start`},{keepPreviousPeek:!0}),I.current.add(e);return}}if(t.length===n){let e=Ng(t,I.current);if(e){G(e,{align:`start`},{keepPreviousPeek:!0}),I.current.add(e);return}}g.current===`following-bottom`&&s.current?K({behavior:`auto`}):(B(),H())})(),Y()},[ne,Y,B,U,ee,H,G,K]),ie=Q.useCallback(()=>{if(g.current===`following-bottom`&&s.current){K({behavior:`auto`});return}let e=D.current;if(W()){s.current&&e>0&&D.current===0&&K({behavior:`auto`});return}V(),H()},[W,V,H,K]),ae=Q.useCallback(()=>{let e=j.current;if(e&&P.hasListeners()){if(typeof IntersectionObserver>`u`){H();return}N.current||=new IntersectionObserver(e=>{for(let t of e){let e=t.target.dataset.messageId;e&&(t.isIntersecting?F.current.add(e):F.current.delete(e))}H()},{root:e,rootMargin:`${-(w.current+T.current)}px 0px 0px 0px`,threshold:[0,.01,.5,1]}),h.current.forEach(e=>{N.current?.observe(e)}),H()}},[H,P]),oe=Q.useCallback(()=>{M.current!==null&&(window.cancelAnimationFrame(M.current),M.current=null),N.current?.disconnect(),N.current=null,F.current.clear(),P.setSnapshot(Og)},[P]),se=Q.useCallback((e,t,n)=>{if(t){h.current.set(e,t),N.current?.observe(t),H(),v.current?.messageId===e&&te();return}n&&h.current.get(e)===n&&(h.current.delete(e),F.current.delete(e),N.current?.unobserve(n),H())},[te,H]),ce=Q.useCallback(()=>{(g.current===`following-bottom`||g.current===`anchored-to-message`||g.current===`settling-jump`)&&(o.current=null,g.current=`free-scrolling`)},[]),le=Q.useCallback(()=>R(A.getSnapshot()),[A,R]),ue=n_(S,le),de=n_(j,le),fe=Q.useCallback(e=>{u.current=e},[]),pe=Q.useCallback(e=>{O.current=e,E.current=Gg(e?.parentElement??null)},[]),X=Q.useCallback(()=>{B(),H(),Y()},[Y,B,H]),me=Q.useMemo(()=>({handleContentChange:re,handleResize:ie,observeVisibility:ae,pendingDefaultScrollStore:x,preserveScrollOnPrependRef:b,scrollToEnd:K,scrollToMessage:q,scrollToStart:J,setContentElement:fe,setRootElement:ue,setSpacerElement:pe,setViewportElement:de,stateStore:A,syncAfterScroll:X,unobserveVisibility:oe,userScrollIntent:ce,viewportRef:j,visibilityStore:P}),[re,ie,ae,x,K,q,J,fe,ue,pe,de,A,X,oe,ce,P]);return Q.useLayoutEffect(()=>{ne()||p.current===0&&$g(a)},[ne]),Q.useEffect(()=>()=>{k.current!==null&&(window.cancelAnimationFrame(k.current),k.current=null),M.current!==null&&(window.cancelAnimationFrame(M.current),M.current=null),l.current!==null&&(window.clearTimeout(l.current),l.current=null),_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null),N.current?.disconnect(),N.current=null},[]),Q.useLayoutEffect(()=>{if(e&&g.current===`following-bottom`&&p.current>0){K({behavior:`auto`});return}B()},[e,B,K]),{context:me,registerMessage:se}}function i_(e){let t=Q.useRef(e);return t.current=e,t}var a_=Q.createContext(null),o_=Q.createContext(null);function s_(){let e=Q.useContext(a_);if(!e)throw Error(`useMessageScroller must be used within a MessageScroller.`);return e}function c_(){let e=Q.useContext(o_);if(!e)throw Error(`MessageScrollerItem must be used within a MessageScroller.`);return e}function l_({autoScroll:e=!1,children:t,defaultScrollPosition:n=`end`,scrollEdgeThreshold:r,scrollPreviousItemPeek:i,scrollMargin:a}){let{context:o,registerMessage:s}=r_({autoScroll:e,defaultScrollPosition:n,scrollEdgeThreshold:r,scrollPreviousItemPeek:i,scrollMargin:a});return(0,Z.jsx)(a_.Provider,{value:o,children:(0,Z.jsx)(o_.Provider,{value:s,children:t})})}function u_(){let{pendingDefaultScrollStore:e}=s_();return Q.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function d_({children:e,...t}){let{setRootElement:n}=s_(),r=u_();return(0,Z.jsx)(`div`,{ref:n,...t,...r?{"data-pending-scroll":``}:null,children:e})}function f_({"aria-label":e,children:t,onKeyDown:n,onScroll:r,onTouchMove:i,onWheel:a,preserveScrollOnPrepend:o=!0,ref:s,role:c,tabIndex:l,...u}){let{handleResize:d,preserveScrollOnPrependRef:f,setViewportElement:p,syncAfterScroll:m,userScrollIntent:h,viewportRef:g}=s_(),_=u_();f.current=o;let v=Q.useCallback(e=>{p(e),bg(s)?.(e)},[s,p]);function y(e){m(),r?.(e)}function b(e){h(),a?.(e)}function x(e){h(),i?.(e)}function S(e){Eg.has(e.key)&&h(),n?.(e)}return Q.useEffect(()=>{let e=g.current;if(!e||typeof ResizeObserver>`u`)return;let t=0,n=new ResizeObserver(()=>{window.cancelAnimationFrame(t),t=window.requestAnimationFrame(d)});return n.observe(e),()=>{window.cancelAnimationFrame(t),n.disconnect()}},[d,g]),(0,Z.jsx)(`div`,{ref:v,role:c??`region`,"aria-label":e??`Messages`,tabIndex:l??0,onKeyDown:S,onScroll:y,onTouchMove:x,onWheel:b,...u,..._?{"data-pending-scroll":``}:null,children:t})}function p_({"aria-relevant":e,children:t,ref:n,role:r,spacerClassName:i,...a}){let{handleContentChange:o,handleResize:s,setContentElement:c,setSpacerElement:l}=s_(),u=Q.useRef(null),d=Q.useCallback(e=>{u.current=e,c(e),bg(n)?.(e)},[n,c]);return Q.useLayoutEffect(()=>{let e=u.current;if(!e||(o(),typeof MutationObserver>`u`))return;let t=new MutationObserver(()=>{o()});return t.observe(e,{childList:!0}),()=>t.disconnect()},[o]),Q.useEffect(()=>{let e=u.current;if(!e||typeof ResizeObserver>`u`)return;let t=0,n=new ResizeObserver(()=>{window.cancelAnimationFrame(t),t=window.requestAnimationFrame(s)});return n.observe(e),()=>{window.cancelAnimationFrame(t),n.disconnect()}},[s]),(0,Z.jsxs)(`div`,{ref:d,role:r??`log`,"aria-relevant":e??`additions`,...a,children:[t,(0,Z.jsx)(`div`,{ref:l,"aria-hidden":`true`,"data-message-scroller-spacer":``,hidden:!0,className:i})]})}function m_({messageId:e,ref:t,scrollAnchor:n=!1,...r}){let i=c_(),a=Q.useRef(null),o=Q.useCallback(n=>{let r=a.current;a.current=n,e&&i(e,n,r),bg(t)?.(n)},[e,t,i]);return(0,Z.jsx)(`div`,{ref:o,"data-message-id":e,"data-scroll-anchor":n?`true`:`false`,...r})}function h_({behavior:e=`smooth`,children:t,direction:n=`end`,onClick:r,render:i,tabIndex:a,type:o=`button`,...s}){let{scrollToEnd:c,scrollToStart:l,stateStore:u}=s_(),d=i_(r),f=Q.useCallback(e=>u.subscribe(e),[u]),p=Q.useCallback(()=>{let e=u.getSnapshot();return n===`start`?e.start:e.end},[n,u]),m=Q.useSyncExternalStore(f,p,p),h=Q.useCallback(t=>{m&&(d.current?.(t),t.defaultPrevented||(t.currentTarget.blur(),n===`start`?l({behavior:e}):c({behavior:e})))},[e,n,m,d,c,l]);return hg({defaultTagName:`button`,props:gg({type:o,inert:!m,tabIndex:m?a:-1,children:t??(0,Z.jsxs)(`span`,{children:[`Scroll to `,n]}),onClick:h},s),render:i,state:{active:m,direction:n},stateAttributesMapping:{active:e=>({"data-active":e?`true`:`false`})}})}var g_={Provider:l_,Root:d_,Viewport:f_,Content:p_,Item:m_,Button:h_};function __(e){return(0,Z.jsx)(g_.Provider,{...e})}function v_({className:e,...t}){return(0,Z.jsx)(g_.Root,{"data-slot":`message-scroller`,className:I(`group/message-scroller relative flex size-full min-h-0 flex-col overflow-hidden`,e),...t})}function y_({className:e,...t}){return(0,Z.jsx)(g_.Viewport,{"data-slot":`message-scroller-viewport`,className:I(`size-full min-h-0 min-w-0 scroll-fade-b scrollbar-thin scrollbar-gutter-stable overflow-y-auto overscroll-contain contain-content data-autoscrolling:scrollbar-thumb-transparent data-autoscrolling:scrollbar-track-transparent data-pending-scroll:invisible`,e),...t})}function b_({className:e,...t}){return(0,Z.jsx)(g_.Content,{"data-slot":`message-scroller-content`,className:I(`flex h-max min-h-full flex-col gap-8`,e),...t})}function x_({className:e,scrollAnchor:t=!1,...n}){return(0,Z.jsx)(g_.Item,{"data-slot":`message-scroller-item`,scrollAnchor:t,className:I(`min-w-0 shrink-0 [contain-intrinsic-size:auto_10rem] [content-visibility:auto]`,e),...n})}function S_({direction:e=`end`,className:t,children:n,render:r,variant:i=`secondary`,size:a=`icon-sm`,...o}){return(0,Z.jsx)(g_.Button,{"data-slot":`message-scroller-button`,"data-direction":e,"data-variant":i,"data-size":a,direction:e,className:I(`absolute inset-s-1/2 -translate-x-1/2 border-border bg-background text-foreground transition-[translate,scale,opacity] duration-200 hover:bg-muted hover:text-foreground data-[active=false]:pointer-events-none data-[active=false]:scale-95 data-[active=false]:opacity-0 data-[active=false]:duration-400 data-[active=false]:ease-[cubic-bezier(0.7,0,0.84,0)] data-[active=true]:translate-y-0 data-[active=true]:scale-100 data-[active=true]:opacity-100 data-[active=true]:ease-[cubic-bezier(0.23,1,0.32,1)] data-[direction=end]:bottom-4 data-[direction=end]:data-[active=false]:translate-y-full data-[direction=start]:top-4 data-[direction=start]:data-[active=false]:-translate-y-full rtl:translate-x-1/2 data-[direction=start]:[&_svg]:rotate-180`,t),render:r??(0,Z.jsx)(h,{variant:i,size:a}),...o,children:n??(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ca,{}),(0,Z.jsx)(`span`,{className:`sr-only`,children:e===`end`?`Scroll to end`:`Scroll to start`})]})})}function C_(e){let t=(0,$.c)(62),{scope:n,connection:r,base:i,onBase:a}=e,[o,s]=(0,Q.useState)(!1),c=xr(n,r,o),l,u,d,p,m,g,_,v,b,x,S,C,w,T,E;if(t[0]!==i||t[1]!==c.refresh||t[2]!==c.result||t[3]!==a||t[4]!==o){let e=ge(V(c.result)),n;t[20]===i?n=t[21]:(n=i==null?`the default branch`:Fl(i),t[20]=i,t[21]=n);let r=n,D=e?.defaultRef??null,O=i??D,k=[{heading:`Local`,entries:e?.bases.filter(E_)??[]},{heading:`Remote`,entries:e?.bases.filter(T_)??[]}].filter(w_),A=e=>{a(e===D?void 0:e),s(!1)};p=Vi,E=o,g=s;let j=`Compare against ${r}`,M;t[22]===j?M=t[23]:(M=(0,Z.jsx)(h,{variant:`outline`,size:`sm`,className:`w-full justify-between`,"aria-label":j,title:`Choose the branch this one is compared against`}),t[22]=j,t[23]=M);let N;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(oa,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[24]=N):N=t[24];let P;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`Against `}),t[25]=P):P=t[25];let F;t[26]===r?F=t[27]:(F=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[N,(0,Z.jsxs)(`span`,{className:`truncate`,children:[P,r]})]}),t[26]=r,t[27]=F);let I;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(Da,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[28]=I):I=t[28],t[29]!==M||t[30]!==F?(_=(0,Z.jsxs)(ji,{render:M,children:[F,I]}),t[29]=M,t[30]=F,t[31]=_):_=t[31],d=Xi,w=`start`,T=`w-72`,u=fa,t[32]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(Yr,{"aria-label":`Find a base branch`,placeholder:`Find a branch`}),t[32]=C):C=t[32],l=sa,m=`Base branches`,t[33]===c.result?v=t[34]:(v=f(c.result)&&(0,Z.jsx)(`p`,{role:`status`,className:`p-3 text-xs text-muted-foreground`,children:`Reading branches…`}),t[33]=c.result,t[34]=v),t[35]!==c.refresh||t[36]!==c.result?(b=B(c.result)&&(0,Z.jsxs)(`div`,{className:`p-3 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`block`,children:`The branches could not be read.`}),(0,Z.jsx)(h,{variant:`outline`,size:`xs`,className:`mt-2`,onClick:c.refresh,children:`Try again`})]}),t[35]=c.refresh,t[36]=c.result,t[37]=b):b=t[37],t[38]===c.result?x=t[39]:(x=y(c.result)&&(0,Z.jsx)(_i,{children:`No branch matches.`}),t[38]=c.result,t[39]=x),S=k.map(e=>(0,Z.jsx)(ua,{heading:e.heading,children:e.entries.map(e=>(0,Z.jsxs)(wr,{value:e.name,"data-checked":e.ref===O,onSelect:()=>A(e.ref),children:[(0,Z.jsx)(`span`,{className:`truncate`,children:e.name}),e.ref===D&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`default`})]},e.ref))},e.heading)),t[0]=i,t[1]=c.refresh,t[2]=c.result,t[3]=a,t[4]=o,t[5]=l,t[6]=u,t[7]=d,t[8]=p,t[9]=m,t[10]=g,t[11]=_,t[12]=v,t[13]=b,t[14]=x,t[15]=S,t[16]=C,t[17]=w,t[18]=T,t[19]=E}else l=t[5],u=t[6],d=t[7],p=t[8],m=t[9],g=t[10],_=t[11],v=t[12],b=t[13],x=t[14],S=t[15],C=t[16],w=t[17],T=t[18],E=t[19];let D;t[40]!==l||t[41]!==m||t[42]!==v||t[43]!==b||t[44]!==x||t[45]!==S?(D=(0,Z.jsxs)(l,{"aria-label":m,children:[v,b,x,S]}),t[40]=l,t[41]=m,t[42]=v,t[43]=b,t[44]=x,t[45]=S,t[46]=D):D=t[46];let O;t[47]!==u||t[48]!==D||t[49]!==C?(O=(0,Z.jsxs)(u,{children:[C,D]}),t[47]=u,t[48]=D,t[49]=C,t[50]=O):O=t[50];let k;t[51]!==d||t[52]!==O||t[53]!==w||t[54]!==T?(k=(0,Z.jsx)(d,{align:w,className:T,children:O}),t[51]=d,t[52]=O,t[53]=w,t[54]=T,t[55]=k):k=t[55];let A;return t[56]!==p||t[57]!==g||t[58]!==_||t[59]!==k||t[60]!==E?(A=(0,Z.jsxs)(p,{open:E,onOpenChange:g,children:[_,k]}),t[56]=p,t[57]=g,t[58]=_,t[59]=k,t[60]=E,t[61]=A):A=t[61],A}function w_(e){return e.entries.length>0}function T_(e){return e.remote}function E_(e){return!e.remote}var D_=`flex w-full min-w-0 items-center gap-1.5 rounded-lg px-2 py-1 text-left text-caption transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:font-medium`;function O_(e){let t=(0,$.c)(87),{path:n,document:r,note:i,scopes:a,reviewStatus:o,commentCount:s,active:c,onOpen:l,onReview:u,canReview:d,onDiscard:f,indented:p}=e,m=p!==void 0&&p,h;t[0]===n?h=t[1]:(h=Pu(n),t[0]=n,t[1]=h);let g;t[2]===a?g=t[3]:(g=a.length>0?` · ${a.join(` + `)}`:``,t[2]=a,t[3]=g);let _=`${h}${g}`,v=i==null?n:`${n}\n${i}`,y=m&&`pl-7`,b=c&&`bg-accent font-medium text-foreground`,x;t[4]!==y||t[5]!==b?(x=I(D_,`text-muted-foreground`,y,b),t[4]=y,t[5]=b,t[6]=x):x=t[6];let S;t[7]!==r||t[8]!==l?(S=()=>l(r),t[7]=r,t[8]=l,t[9]=S):S=t[9];let C;t[10]!==c||t[11]!==_||t[12]!==v||t[13]!==x||t[14]!==S?(C=(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":c,"aria-label":_,title:v,className:x,onClick:S}),t[10]=c,t[11]=_,t[12]=v,t[13]=x,t[14]=S,t[15]=C):C=t[15];let w;t[16]===o?w=t[17]:(w=(0,Z.jsx)(A_,{status:o}),t[16]=o,t[17]=w);let T;t[18]===n?T=t[19]:(T=(0,Z.jsx)(hi,{path:n,className:`size-3.5 shrink-0`}),t[18]=n,t[19]=T);let E=o===`reviewed`&&`line-through decoration-muted-foreground/40`,D;t[20]===E?D=t[21]:(D=I(`min-w-0 flex-1 truncate`,E),t[20]=E,t[21]=D);let O;t[22]===n?O=t[23]:(O=Pu(n),t[22]=n,t[23]=O);let A;t[24]!==D||t[25]!==O?(A=(0,Z.jsx)(`span`,{className:D,children:O}),t[24]=D,t[25]=O,t[26]=A):A=t[26];let j;t[27]===s?j=t[28]:(j=s>0&&(0,Z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-0.5 text-2xs`,children:[(0,Z.jsx)(lo,{className:`size-3`}),s]}),t[27]=s,t[28]=j);let M;t[29]!==w||t[30]!==T||t[31]!==A||t[32]!==j||t[33]!==C?(M=(0,Z.jsxs)(ri,{render:C,children:[w,T,A,j]}),t[29]=w,t[30]=T,t[31]=A,t[32]=j,t[33]=C,t[34]=M):M=t[34];let N=!d,P;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(k,{}),t[35]=P):P=t[35];let F;t[36]===o?F=t[37]:(F=k_(o),t[36]=o,t[37]=F);let L;t[38]!==u||t[39]!==N||t[40]!==F?(L=(0,Z.jsxs)(ti,{disabled:N,onClick:u,children:[P,F]}),t[38]=u,t[39]=N,t[40]=F,t[41]=L):L=t[41];let R;t[42]!==r||t[43]!==l||t[44]!==n?(R=()=>l(r,{kind:`file`,filePath:n},{compose:!0}),t[42]=r,t[43]=l,t[44]=n,t[45]=R):R=t[45];let z;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(so,{}),t[46]=z):z=t[46];let B;t[47]===R?B=t[48]:(B=(0,Z.jsxs)(ti,{onClick:R,children:[z,`Comment`]}),t[47]=R,t[48]=B);let V;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsx)(Mr,{}),t[49]=V):V=t[49];let H;t[50]!==r||t[51]!==l?(H=()=>l(r),t[50]=r,t[51]=l,t[52]=H):H=t[52];let U;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Z.jsx)(pa,{}),t[53]=U):U=t[53];let W;t[54]===H?W=t[55]:(W=(0,Z.jsxs)(ti,{onClick:H,children:[U,`Open diff`]}),t[54]=H,t[55]=W);let G;t[56]!==l||t[57]!==n?(G=()=>l({kind:`file`,path:n}),t[56]=l,t[57]=n,t[58]=G):G=t[58];let K;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,Z.jsx)(Ga,{}),t[59]=K):K=t[59];let q;t[60]===G?q=t[61]:(q=(0,Z.jsxs)(ti,{onClick:G,children:[K,`Open file`]}),t[60]=G,t[61]=q);let J;t[62]!==l||t[63]!==n?(J=()=>l({kind:`timeline`,path:n}),t[62]=l,t[63]=n,t[64]=J):J=t[64];let ee;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Z.jsx)(Si,{}),t[65]=ee):ee=t[65];let Y;t[66]===J?Y=t[67]:(Y=(0,Z.jsxs)(ti,{onClick:J,children:[ee,`Show timeline`]}),t[66]=J,t[67]=Y);let te;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Z.jsx)(Mr,{}),t[68]=te):te=t[68];let ne;t[69]===n?ne=t[70]:(ne=()=>pe(n,`relative path`),t[69]=n,t[70]=ne);let re;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Z.jsx)(Pe,{}),t[71]=re):re=t[71];let ie;t[72]===ne?ie=t[73]:(ie=(0,Z.jsxs)(ti,{onClick:ne,children:[re,`Copy relative path`]}),t[72]=ne,t[73]=ie);let ae;t[74]===f?ae=t[75]:(ae=f&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Mr,{}),(0,Z.jsxs)(ti,{variant:`destructive`,onClick:f,children:[(0,Z.jsx)(bi,{}),`Discard`]})]}),t[74]=f,t[75]=ae);let oe;t[76]!==L||t[77]!==B||t[78]!==W||t[79]!==q||t[80]!==Y||t[81]!==ie||t[82]!==ae?(oe=(0,Z.jsxs)(Sr,{className:`min-w-52`,children:[L,B,V,W,q,Y,te,ie,ae]}),t[76]=L,t[77]=B,t[78]=W,t[79]=q,t[80]=Y,t[81]=ie,t[82]=ae,t[83]=oe):oe=t[83];let se;return t[84]!==M||t[85]!==oe?(se=(0,Z.jsxs)(ma,{children:[M,oe]}),t[84]=M,t[85]=oe,t[86]=se):se=t[86],se}function k_(e){return e===`reviewed`?`Unmark as reviewed`:e===`stale`?`Mark as reviewed again`:`Mark as reviewed`}function A_(e){let t=(0,$.c)(8),{status:n}=e,r=n??`unreviewed`,i;t[0]===n?i=t[1]:(i=j_(n),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r===`reviewed`?(0,Z.jsx)(k,{className:`size-3.5 text-graph-2`}):r===`stale`?(0,Z.jsx)(go,{className:`size-3 text-graph-4`}):(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/60`}),t[2]=r,t[3]=a);let o;return t[4]!==r||t[5]!==i||t[6]!==a?(o=(0,Z.jsx)(`span`,{className:`grid w-3.5 shrink-0 place-items-center`,"data-review-state":r,title:i,children:a}),t[4]=r,t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function j_(e){return e===`reviewed`?`Reviewed`:e===`stale`?`Changed since review`:`Not reviewed`}function M_(e){let t=(0,$.c)(15),{scope:n,context:r,base:i,activeEntry:a,threads:o,onOpen:s,onBase:c}=e,l;t[0]!==i||t[1]!==r.connection||t[2]!==c||t[3]!==n?(l=(0,Z.jsx)(`div`,{className:`shrink-0 px-2 pt-2`,children:(0,Z.jsx)(C_,{scope:n,connection:r.connection,base:i,onBase:c})}),t[0]=i,t[1]=r.connection,t[2]=c,t[3]=n,t[4]=l):l=t[4];let u;t[5]!==a||t[6]!==i||t[7]!==r||t[8]!==s||t[9]!==n||t[10]!==o?(u=(0,Z.jsx)(N_,{scope:n,context:r,base:i,activeEntry:a,threads:o,onOpen:s}),t[5]=a,t[6]=i,t[7]=r,t[8]=s,t[9]=n,t[10]=o,t[11]=u):u=t[11];let d;return t[12]!==l||t[13]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[l,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14],d}function N_(e){let t=(0,$.c)(19),{scope:n,context:r,base:i,activeEntry:a,threads:o,onOpen:s}=e,{connection:c}=r,l=Pi(n,c,i);if(B(l.result)){let e;t[0]===l.result?e=t[1]:(e=Ll(B(l.result)?le(l.result.cause):void 0),t[0]=l.result,t[1]=e);let n;t[2]===e?n=t[3]:(n=(0,Z.jsx)(`span`,{className:`block`,children:e}),t[2]=e,t[3]=n);let r;t[4]===l.refresh?r=t[5]:(r=(0,Z.jsx)(h,{variant:`outline`,size:`xs`,className:`mt-2`,onClick:l.refresh,children:`Try again`}),t[4]=l.refresh,t[5]=r);let i;return t[6]!==n||t[7]!==r?(i=(0,Z.jsxs)(`div`,{role:`alert`,className:`p-3 text-xs text-muted-foreground`,children:[n,r]}),t[6]=n,t[7]=r,t[8]=i):i=t[8],i}if(!y(l.result)){let e;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(P_,{}),t[9]=e):e=t[9],e}if(l.result.value.base===void 0){let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`div`,{className:`p-3`,children:(0,Z.jsx)(im,{title:`No default branch`,description:`Choose the branch this one is compared against.`})}),t[10]=e):e=t[10],e}let u;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(P_,{}),t[11]=u):u=t[11];let d;return t[12]!==a||t[13]!==l.result.value||t[14]!==r||t[15]!==s||t[16]!==n||t[17]!==o?(d=(0,Z.jsx)(Q.Suspense,{fallback:u,children:(0,Z.jsx)(F_,{scope:n,context:r,branch:l.result.value,activeEntry:a,threads:o,onOpen:s})}),t[12]=a,t[13]=l.result.value,t[14]=r,t[15]=s,t[16]=n,t[17]=o,t[18]=d):d=t[18],d}function P_(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`p`,{role:`status`,className:`p-3 text-xs text-muted-foreground`,children:`Comparing the branch…`}),e[0]=t):t=e[0],t}function F_(e){let t=(0,$.c)(50),{scope:n,context:r,branch:i,activeEntry:a,threads:o,onOpen:s}=e,{preferences:c}=Tn(),l;t[0]===i?l=t[1]:(l=zu(i),t[0]=i,t[1]=l);let u=l,d=Gf(n,r,u),f=pp(n,r,I_,u);if(i.base===null||i.base===void 0)return null;let p,m,h,g,_,v,y;if(t[2]!==a||t[3]!==i.base.ref||t[4]!==i.commits||t[5]!==i.files||t[6]!==i.head.branch||t[7]!==d||t[8]!==s||t[9]!==c.collapseSpecs||t[10]!==f||t[11]!==o){let e=ju(i.files,d),n;t[19]===i.head.branch?n=t[20]:(n=i.head.branch===null||i.head.branch===void 0?`this commit`:Fl(i.head.branch),t[19]=i.head.branch,t[20]=n);let r=n,l=`${i.commits} ${i.commits===1?`commit`:`commits`}`;p=Bi,y=`h-0 min-h-0 flex-1`,m=`p-2`;let u;t[21]===i.base.ref?u=t[22]:(u=Fl(i.base.ref),t[21]=i.base.ref,t[22]=u),t[23]!==l||t[24]!==r||t[25]!==u?(h=(0,Z.jsxs)(`p`,{className:`px-2 pb-1.5 text-2xs text-muted-foreground`,children:[l,` on `,r,` since `,u]}),t[23]=l,t[24]=r,t[25]=u,t[26]=h):h=t[26];let b;t[27]===a?b=t[28]:(b=a===Wl(Vl)&&`bg-accent`,t[27]=a,t[28]=b);let x;t[29]===b?x=t[30]:(x=I(D_,b),t[29]=b,t[30]=x);let S;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(S=Wl(Vl),t[31]=S):S=t[31];let C;t[32]===s?C=t[33]:(C=()=>s(Vl),t[32]=s,t[33]=C);let w;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(oa,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[34]=w):w=t[34],g=(0,Z.jsxs)(`button`,{type:`button`,className:x,"aria-pressed":a===S,onClick:C,children:[w,`All branch changes`,(0,Z.jsx)(`span`,{className:`ml-auto text-2xs text-muted-foreground tabular-nums`,children:e.length})]}),_=e.length===0&&(0,Z.jsxs)(`p`,{className:`p-3 text-sm text-muted-foreground`,children:[`No changes since `,Fl(i.base.ref)]});let T;t[35]!==a||t[36]!==s||t[37]!==f||t[38]!==o?(T=e=>(0,Z.jsx)(O_,{path:e.path,document:{kind:`branch-file`,path:e.path},note:e.status,scopes:[e.status],reviewStatus:e.reviewStatus,commentCount:o.filter(t=>t.anchor.comparison?.kind===`branch`&&hd(t.anchor)===e.path&&!t.resolved).length,active:a===Wl({kind:`branch-file`,path:e.path}),onOpen:s,canReview:e.fingerprint!==null&&e.fingerprint!==void 0,onReview:()=>f.toggle({path:e.path,reviewed:e.reviewStatus===`reviewed`,fingerprint:e.fingerprint})},e.path),t[35]=a,t[36]=s,t[37]=f,t[38]=o,t[39]=T):T=t[39],v=Yd(e,c.collapseSpecs).map(T),t[2]=a,t[3]=i.base.ref,t[4]=i.commits,t[5]=i.files,t[6]=i.head.branch,t[7]=d,t[8]=s,t[9]=c.collapseSpecs,t[10]=f,t[11]=o,t[12]=p,t[13]=m,t[14]=h,t[15]=g,t[16]=_,t[17]=v,t[18]=y}else p=t[12],m=t[13],h=t[14],g=t[15],_=t[16],v=t[17],y=t[18];let b;t[40]!==m||t[41]!==h||t[42]!==g||t[43]!==_||t[44]!==v?(b=(0,Z.jsxs)(`div`,{className:m,children:[h,g,_,v]}),t[40]=m,t[41]=h,t[42]=g,t[43]=_,t[44]=v,t[45]=b):b=t[45];let x;return t[46]!==p||t[47]!==y||t[48]!==b?(x=(0,Z.jsx)(p,{className:y,children:b}),t[46]=p,t[47]=y,t[48]=b,t[49]=x):x=t[49],x}function I_(e){return Vt.add(e)}function L_(e){return e===1?`1 resolved thread`:`${e} resolved threads`}function R_(e){let t=(0,$.c)(48),{scope:n,context:r,threads:i}=e,[a,o]=(0,Q.useState)(null),s=Cp(n,r),c;t[0]===i?c=t[1]:(c=yd(i),t[0]=i,t[1]=c);let{confirmed:l,kept:u}=c,d;t[2]===s.result?d=t[3]:(d=ge(V(s.result))?.skipped.length??0,t[2]=s.result,t[3]=d);let f=d,p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>o(null),t[4]=p):p=t[4];let m=p,g=l.length===0,_;t[5]!==l||t[6]!==s?(_=()=>{s.reset(),o(l)},t[5]=l,t[6]=s,t[7]=_):_=t[7];let v;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(Fe,{"data-icon":`inline-start`}),t[8]=v):v=t[8];let b;t[9]!==g||t[10]!==_?(b=(0,Z.jsxs)(h,{type:`button`,variant:`ghost`,size:`xs`,className:`ml-auto`,disabled:g,onClick:_,children:[v,`Delete resolved`]}),t[9]=g,t[10]=_,t[11]=b):b=t[11];let x;t[12]!==a||t[13]!==s.result||t[14]!==f?(x=a!==null&&!(y(s.result)&&f===0),t[12]=a,t[13]=s.result,t[14]=f,t[15]=x):x=t[15];let S;t[16]===s.result?S=t[17]:(S=e=>{!e&&!s.result.waiting&&m()},t[16]=s.result,t[17]=S);let C;t[18]!==a?.length||t[19]!==s.result||t[20]!==f?(C=y(s.result)?`Kept ${f===1?`1 thread`:`${f} threads`} that changed`:`Delete ${L_(a?.length??0)}?`,t[18]=a?.length,t[19]=s.result,t[20]=f,t[21]=C):C=t[21];let w;t[22]===C?w=t[23]:(w=(0,Z.jsx)(Yi,{children:C}),t[22]=C,t[23]=w);let T;t[24]!==u||t[25]!==s.result?(T=y(s.result)?`The agent answered or someone reopened them after you confirmed, so they stay for you to read first.`:`This deletes the resolved threads you started, with the agent's replies in them, for you and for the agent.${u>0?` ${L_(u)} the agent started ${u===1?`stays`:`stay`}, since you cannot delete what the agent wrote on its own.`:``}`,t[24]=u,t[25]=s.result,t[26]=T):T=t[26];let E;t[27]===T?E=t[28]:(E=(0,Z.jsx)(ii,{children:T}),t[27]=T,t[28]=E);let D;t[29]!==w||t[30]!==E?(D=(0,Z.jsxs)(Rr,{children:[w,E]}),t[29]=w,t[30]=E,t[31]=D):D=t[31];let O;t[32]===s.result?O=t[33]:(O=B(s.result)&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:Mu(le(s.result.cause))}),t[32]=s.result,t[33]=O);let k;t[34]!==a||t[35]!==s?(k=(0,Z.jsx)(jr,{children:y(s.result)?(0,Z.jsx)(h,{onClick:m,children:`Close`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Nr,{disabled:s.result.waiting,children:`Cancel`}),(0,Z.jsx)(h,{variant:`destructive`,disabled:s.result.waiting,onClick:()=>s.send(a??[]),children:s.result.waiting?`Deleting…`:`Delete`})]})}),t[34]=a,t[35]=s,t[36]=k):k=t[36];let A;t[37]!==D||t[38]!==O||t[39]!==k?(A=(0,Z.jsxs)(ei,{children:[D,O,k]}),t[37]=D,t[38]=O,t[39]=k,t[40]=A):A=t[40];let j;t[41]!==A||t[42]!==x||t[43]!==S?(j=(0,Z.jsx)(ni,{open:x,onOpenChange:S,children:A}),t[41]=A,t[42]=x,t[43]=S,t[44]=j):j=t[44];let M;return t[45]!==j||t[46]!==b?(M=(0,Z.jsxs)(Z.Fragment,{children:[b,j]}),t[45]=j,t[46]=b,t[47]=M):M=t[47],M}function z_(e){let t=(0,$.c)(10),{files:n,review:r,threads:i,onSelect:a}=e,o;t[0]!==n||t[1]!==r||t[2]!==i?(o=Gd({files:n,review:r,explains:!0,threads:i}),t[0]=n,t[1]=r,t[2]=i,t[3]=o):o=t[3];let s;t[4]!==n||t[5]!==a?(s=e=>a(e,n.find(B_)?.path),t[4]=n,t[5]=a,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,Z.jsx)(W_,{items:o,onSelect:s}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function B_(e){return e.reviewStatus===`stale`}function V_(e){let t=(0,$.c)(9),{scope:n,context:r,base:i,review:a,threads:o,onSelect:s}=e,{connection:c}=r,l=Pi(n,c,i),u;t[0]===l.result?u=t[1]:(u=ge(V(l.result)),t[0]=l.result,t[1]=u);let d=u;if(d?.base===null||d?.base===void 0)return null;let f;return t[2]!==d||t[3]!==r||t[4]!==s||t[5]!==a||t[6]!==n||t[7]!==o?(f=(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(H_,{scope:n,context:r,branch:d,review:a,threads:o,onSelect:s})}),t[2]=d,t[3]=r,t[4]=s,t[5]=a,t[6]=n,t[7]=o,t[8]=f):f=t[8],f}function H_(e){let t=(0,$.c)(16),{scope:n,context:r,branch:i,review:a,threads:o,onSelect:s}=e,c;t[0]===i?c=t[1]:(c=zu(i),t[0]=i,t[1]=c);let l=Gf(n,r,c);if(i.base===null||i.base===void 0)return null;let u,d,f;t[2]!==i.files||t[3]!==l||t[4]!==a||t[5]!==o?(d=ju(i.files,l),u=W_,f=Gd({files:d,review:a,explains:!1,threads:o}),t[2]=i.files,t[3]=l,t[4]=a,t[5]=o,t[6]=u,t[7]=d,t[8]=f):(u=t[6],d=t[7],f=t[8]);let p;t[9]!==d||t[10]!==s?(p=e=>s(e,d.find(U_)?.path),t[9]=d,t[10]=s,t[11]=p):p=t[11];let m;return t[12]!==u||t[13]!==f||t[14]!==p?(m=(0,Z.jsx)(u,{items:f,onSelect:p}),t[12]=u,t[13]=f,t[14]=p,t[15]=m):m=t[15],m}function U_(e){return e.reviewStatus===`stale`}function W_(e){let t=(0,$.c)(25),{items:n,onSelect:r}=e,i=n.some(K_)?`failing`:n.some(G_)?`attention`:`ok`,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-lg px-2 py-1.5 text-left text-caption hover:bg-accent`}),t[0]=a):a=t[0];let o;t[1]===i?o=t[2]:(o=(0,Z.jsx)(q_,{tone:i}),t[1]=i,t[2]=o);let s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(`span`,{className:`font-medium`,children:`Readiness`}),t[3]=s):s=t[3];let c=i===`failing`&&`text-destructive`,l;t[4]===c?l=t[5]:(l=I(`ml-auto truncate text-2xs text-muted-foreground`,c),t[4]=c,t[5]=l);let u;t[6]===n?u=t[7]:(u=Kd(n),t[6]=n,t[7]=u);let d;t[8]!==l||t[9]!==u?(d=(0,Z.jsx)(`span`,{className:l,children:u}),t[8]=l,t[9]=u,t[10]=d):d=t[10];let f;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(Ne,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground transition-transform group-data-closed/readiness:-rotate-90`}),t[11]=f):f=t[11];let p;t[12]!==o||t[13]!==d?(p=(0,Z.jsxs)(li,{render:a,children:[o,s,d,f]}),t[12]=o,t[13]=d,t[14]=p):p=t[14];let m;if(t[15]!==n||t[16]!==r){let e;t[18]===r?e=t[19]:(e=e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,className:I(`flex w-full min-w-0 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-left text-caption text-muted-foreground hover:bg-accent hover:text-foreground`,e.tone===`failing`&&`font-medium text-destructive`),onClick:()=>r(e.key),children:[(0,Z.jsx)(q_,{tone:e.tone}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.label})]})},e.key),t[18]=r,t[19]=e),m=n.map(e),t[15]=n,t[16]=r,t[17]=m}else m=t[17];let h;t[20]===m?h=t[21]:(h=(0,Z.jsx)(ai,{children:(0,Z.jsx)(`ul`,{className:`px-1 pb-1`,children:m})}),t[20]=m,t[21]=h);let g;return t[22]!==h||t[23]!==p?(g=(0,Z.jsx)(`section`,{"aria-label":`Readiness`,className:`mx-2 mt-2 shrink-0 rounded-lg border bg-muted/20`,children:(0,Z.jsxs)(si,{defaultOpen:!0,className:`group/readiness`,children:[p,h]})}),t[22]=h,t[23]=p,t[24]=g):g=t[24],g}function G_(e){return e.tone===`attention`}function K_(e){return e.tone===`failing`}function q_(e){let t=(0,$.c)(3),{tone:n}=e;if(n===`ok`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(nr,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-graph-2`}),t[0]=e):e=t[0],e}if(n===`failing`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ja,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-destructive`}),t[1]=e):e=t[1],e}let r;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(Xr,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-graph-4`}),t[2]=r):r=t[2],r}function J_(e){let t=(0,$.c)(53),{scope:n,context:r,activeEntry:i,onOpen:a,changeScope:o,base:s,onChangeScope:c,onBase:l}=e,{connection:u}=r,[d,f]=(0,Q.useState)(`layers`),{setPlace:p}=Tu(n.worktreeId);Kf(n,r),hp(n,r);let m=zr(n,u),h=Ad(n,r),g=h.review?.active?h.review:null,{threads:_}=mp(n,r),v=qf(n,r,m),y;t[0]===_?y=t[1]:(y=_.filter(Y_),t[0]=_,t[1]=y);let b=y.length,x=o===`branch`,S;t[2]!==x||t[3]!==a||t[4]!==g||t[5]!==p?(S=(e,t)=>{if(e===`comments`||e===`replies`){f(`comments`);return}f(`layers`),e===`checks`&&a(Hl),e===`unexplained`&&(g&&p(`unexplained`),a({kind:`handoff`})),e===`files`&&a(x?Vl:{kind:`handoff`}),e===`stale`&&t!==void 0&&a(x?{kind:`branch-file`,path:t}:{kind:`change`,path:t})},t[2]=x,t[3]=a,t[4]=g,t[5]=p,t[6]=S):S=t[6];let C=S,w;t[7]===c?w=t[8]:(w=e=>{ya(e)&&c(e)},t[7]=c,t[8]=w);let T;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsxs)(Ri,{variant:`line`,className:`w-full`,"aria-label":`Changes to review`,children:[(0,Z.jsx)(Oi,{value:`uncommitted`,className:`flex-1`,children:`Uncommitted`}),(0,Z.jsx)(Oi,{value:`branch`,className:`flex-1`,children:`Branch`})]}),t[9]=T):T=t[9];let E;t[10]!==o||t[11]!==w?(E=(0,Z.jsx)(`div`,{className:`shrink-0 px-2`,children:(0,Z.jsx)(Ti,{value:o,onValueChange:w,children:T})}),t[10]=o,t[11]=w,t[12]=E):E=t[12];let D;t[13]!==s||t[14]!==x||t[15]!==v||t[16]!==r||t[17]!==g||t[18]!==n||t[19]!==C||t[20]!==_?(D=x?(0,Z.jsx)(V_,{scope:n,context:r,base:s,review:g,threads:_,onSelect:C}):(0,Z.jsx)(z_,{files:v,review:g,threads:_,onSelect:C}),t[13]=s,t[14]=x,t[15]=v,t[16]=r,t[17]=g,t[18]=n,t[19]=C,t[20]=_,t[21]=D):D=t[21];let O;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(O=e=>{(e===`layers`||e===`comments`)&&f(e)},t[22]=O):O=t[22];let k=g&&!x?`Explore`:`Changed files`,A;t[23]===k?A=t[24]:(A=(0,Z.jsx)(Oi,{value:`layers`,className:`flex-1`,children:k}),t[23]=k,t[24]=A);let j;t[25]===b?j=t[26]:(j=b>0&&(0,Z.jsx)(Re,{variant:`secondary`,className:`h-4 min-w-4`,children:b}),t[25]=b,t[26]=j);let M;t[27]===j?M=t[28]:(M=(0,Z.jsxs)(Oi,{value:`comments`,className:`flex-1`,children:[`Comments`,j]}),t[27]=j,t[28]=M);let N;t[29]!==M||t[30]!==A?(N=(0,Z.jsxs)(Ri,{className:`h-8 w-full`,children:[A,M]}),t[29]=M,t[30]=A,t[31]=N):N=t[31];let P;t[32]!==N||t[33]!==d?(P=(0,Z.jsx)(`div`,{className:`shrink-0 px-2 pt-2`,children:(0,Z.jsx)(Ti,{value:d,onValueChange:O,"aria-label":`Review views`,children:N})}),t[32]=N,t[33]=d,t[34]=P):P=t[34];let F;t[35]!==i||t[36]!==s||t[37]!==x||t[38]!==v||t[39]!==r||t[40]!==m||t[41]!==l||t[42]!==a||t[43]!==g||t[44]!==n||t[45]!==_||t[46]!==d?(F=d===`layers`&&x?(0,Z.jsx)(M_,{scope:n,context:r,base:s,activeEntry:i,threads:_,onOpen:a,onBase:l}):d===`layers`?(0,Z.jsx)(X_,{scope:n,context:r,activeEntry:i,onOpen:a,list:m,review:g,changes:v,threads:_}):(0,Z.jsx)(ov,{list:m,threads:_,branch:x,base:s,scope:n,context:r,onOpen:a}),t[35]=i,t[36]=s,t[37]=x,t[38]=v,t[39]=r,t[40]=m,t[41]=l,t[42]=a,t[43]=g,t[44]=n,t[45]=_,t[46]=d,t[47]=F):F=t[47];let I;return t[48]!==P||t[49]!==F||t[50]!==E||t[51]!==D?(I=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[E,D,P,F]}),t[48]=P,t[49]=F,t[50]=E,t[51]=D,t[52]=I):I=t[52],I}function Y_(e){return!e.resolved}function X_(e){let t=(0,$.c)(16),{scope:n,context:r,activeEntry:i,onOpen:a,list:o,review:s,changes:c,threads:l}=e,{preferences:u}=Tn(),d=o.changes.map(tv),f=u.collapseSpecs?d.filter(ev):d,p=u.collapseSpecs?d.filter(Jd):[],m=new Map(c.map($_)),h=pp(n,r,Q_),[g,_]=(0,Q.useState)(null),v=e=>(0,Z.jsx)(O_,{path:e,document:{kind:`change`,path:e},note:void 0,scopes:[...new Set(o.changes.find(t=>t.path===e)?.comparisons.map(Z_))],reviewStatus:m.get(e)?.reviewStatus,commentCount:l.filter(t=>hd(t.anchor)===e&&!t.resolved).length,active:i===Wl({kind:`change`,path:e}),onOpen:a,canReview:m.get(e)?.fingerprint!==null&&m.get(e)?.fingerprint!==void 0,onReview:()=>h.toggle({path:e,reviewed:m.get(e)?.reviewStatus===`reviewed`,fingerprint:m.get(e)?.fingerprint}),onDiscard:()=>_(t=>({path:e,nonce:(t?.nonce??0)+1}))},e),y=Bi,b=s?(0,Z.jsx)(nv,{scope:n,context:r,review:s,activeEntry:i,onOpen:a,files:d.length}):(0,Z.jsx)(`button`,{type:`button`,className:D_,"aria-pressed":i===`handoff`,onClick:()=>a({kind:`handoff`}),children:`All changes`}),x;t[0]===s?x=t[1]:(x=s&&(0,Z.jsx)(`p`,{className:`px-2 pt-4 pb-1 text-xs text-muted-foreground`,children:`Changed files`}),t[0]=s,t[1]=x);let S=d.length===0&&(0,Z.jsx)(`p`,{className:`p-3 text-sm text-muted-foreground`,children:`No changes`}),C=f.map(v),w=p.length>0&&(0,Z.jsxs)(`details`,{open:!u.collapseSpecs,className:`mt-3 border-t pt-2`,children:[(0,Z.jsxs)(`summary`,{className:`cursor-pointer px-2 py-2 text-xs font-medium`,children:[`Specs · `,p.length,` files`]}),(0,Z.jsx)(`button`,{type:`button`,className:`flex w-full min-w-0 items-center gap-1.5 rounded-lg px-2 py-1 text-left text-caption transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:font-medium`,"aria-pressed":i===`specs`,onClick:()=>a(Bl),children:`Open all specs`}),p.map(v)]},String(u.collapseSpecs)),T;t[2]!==r||t[3]!==g||t[4]!==n?(T=g&&(0,Z.jsx)(Wi,{scope:n,context:r,path:g.path,signal:g.nonce,hiddenTrigger:!0}),t[2]=r,t[3]=g,t[4]=n,t[5]=T):T=t[5];let E;t[6]!==b||t[7]!==x||t[8]!==S||t[9]!==C||t[10]!==w||t[11]!==T?(E=(0,Z.jsxs)(`div`,{className:`p-2`,children:[b,x,S,C,w,T]}),t[6]=b,t[7]=x,t[8]=S,t[9]=C,t[10]=w,t[11]=T,t[12]=E):E=t[12];let D;return t[13]!==y||t[14]!==E?(D=(0,Z.jsx)(y,{className:`h-0 min-h-0 flex-1`,children:E}),t[13]=y,t[14]=E,t[15]=D):D=t[15],D}function Z_(e){return e.scope}function Q_(e){return Vt.add(e)}function $_(e){return[e.path,e]}function ev(e){return!Jd(e)}function tv(e){return e.path}function nv(e){let t=(0,$.c)(29),{scope:n,context:r,review:i,activeEntry:a,onOpen:o,files:s}=e,c=ph(n,r,i),l;t[0]!==o||t[1]!==c?(l=e=>{c.go(e),o({kind:`handoff`})},t[0]=o,t[1]=c,t[2]=l):l=t[2];let u=l,d;t[3]!==a||t[4]!==c.stop?(d=e=>a===`handoff`&&c.stop.key===e,t[3]=a,t[4]=c.stop,t[5]=d):d=t[5];let f=d,p;t[6]!==f||t[7]!==u||t[8]!==i||t[9]!==c?(p=c.stops.map(e=>{let t=ef(e.paths,c.items),n=c.done(e),r=e.kind===`decision`?c.decisions.states.get(e.layer.id):void 0;return(0,Z.jsxs)(`button`,{type:`button`,className:D_,"aria-pressed":f(e.key),onClick:()=>u(e.key),children:[e.kind===`briefing`?(0,Z.jsx)(Fa,{className:`size-3.5 shrink-0 text-muted-foreground`}):e.kind===`decision`?(0,Z.jsx)(`span`,{className:I(`grid size-4 shrink-0 place-items-center rounded-full text-2xs text-muted-foreground tabular-nums`,n&&`bg-graph-2 text-background`),children:n?(0,Z.jsx)(k,{className:`size-3`,"aria-label":`Reviewed`}):e.number}):e.kind===`unexplained`?(0,Z.jsx)(Va,{className:`size-3.5 shrink-0 text-graph-4`}):(0,Z.jsx)(Ya,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[tf(e),e.kind===`unexplained`&&` · ${Iu(i.notExplained)??`${e.paths.length} files`}`]}),r?.stale&&(0,Z.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-graph-4`,"aria-label":`Code moved`}),e.kind!==`briefing`&&t.total>0&&(0,Z.jsxs)(`span`,{className:`shrink-0 text-2xs text-muted-foreground tabular-nums`,children:[t.reviewed,`/`,t.total]})]},e.key)}),t[6]=f,t[7]=u,t[8]=i,t[9]=c,t[10]=p):p=t[10];let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=Wl(Hl),t[11]=m):m=t[11];let h=a===m,g;t[12]!==o||t[13]!==i||t[14]!==h?(g=(0,Z.jsx)(rv,{review:i,active:h,onOpen:o}),t[12]=o,t[13]=i,t[14]=h,t[15]=g):g=t[15];let _=a===`all-changes`,v;t[16]===o?v=t[17]:(v=()=>o(zl),t[16]=o,t[17]=v);let y;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(pa,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[18]=y):y=t[18];let b;t[19]===s?b=t[20]:(b=(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[`All changes · `,s,` files`]}),t[19]=s,t[20]=b);let x;t[21]!==b||t[22]!==_||t[23]!==v?(x=(0,Z.jsxs)(`button`,{type:`button`,className:D_,"aria-pressed":_,onClick:v,children:[y,b]}),t[21]=b,t[22]=_,t[23]=v,t[24]=x):x=t[24];let S;return t[25]!==x||t[26]!==p||t[27]!==g?(S=(0,Z.jsxs)(`nav`,{"aria-label":`Walkthrough`,className:`flex flex-col`,children:[p,g,x]}),t[25]=x,t[26]=p,t[27]=g,t[28]=S):S=t[28],S}function rv(e){let t=(0,$.c)(36),{review:n,active:r,onOpen:i}=e,a,o,s,c,l,u,d,f,p,m;if(t[0]!==r||t[1]!==i||t[2]!==n.proof){let e=Nd(n.proof);d=`button`,f=D_,p=r,t[13]===i?m=t[14]:(m=()=>i(Hl),t[13]=i,t[14]=m);let h=e.failing>0&&`text-destructive`,g;t[15]===h?g=t[16]:(g=I(`size-3.5 shrink-0 text-muted-foreground`,h),t[15]=h,t[16]=g),t[17]===g?o=t[18]:(o=(0,Z.jsx)(Ya,{className:g}),t[17]=g,t[18]=o),l=`min-w-0 truncate`,u=`Proof`;let _=e.failing>0&&`font-medium text-destructive`;t[19]===_?a=t[20]:(a=I(`text-muted-foreground`,_),t[19]=_,t[20]=a),s=` · `,c=Id(e),t[0]=r,t[1]=i,t[2]=n.proof,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m}else a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12];let h;t[21]!==a||t[22]!==s||t[23]!==c?(h=(0,Z.jsxs)(`span`,{className:a,children:[s,c]}),t[21]=a,t[22]=s,t[23]=c,t[24]=h):h=t[24];let g;t[25]!==h||t[26]!==l||t[27]!==u?(g=(0,Z.jsxs)(`span`,{className:l,children:[u,h]}),t[25]=h,t[26]=l,t[27]=u,t[28]=g):g=t[28];let _;return t[29]!==o||t[30]!==g||t[31]!==d||t[32]!==f||t[33]!==p||t[34]!==m?(_=(0,Z.jsxs)(`button`,{type:d,className:f,"aria-pressed":p,onClick:m,children:[o,g]}),t[29]=o,t[30]=g,t[31]=d,t[32]=f,t[33]=p,t[34]=m,t[35]=_):_=t[35],_}function iv(e){let t=(0,$.c)(10),{scope:n,context:r,anchor:i}=e,[a,o]=(0,Q.useState)(!1),s=i?.comparison?.kind===`branch`;if(a&&i){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>o(!1),t[0]=e):e=t[0];let a;return t[1]!==i||t[2]!==r||t[3]!==n?(a=(0,Z.jsx)(wp,{scope:n,context:r,anchor:i,onClose:e}),t[1]=i,t[2]=r,t[3]=n,t[4]=a):a=t[4],a}let c=i==null,l,u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>o(!0),u=(0,Z.jsx)(so,{"data-icon":`inline-start`}),t[5]=l,t[6]=u):(l=t[5],u=t[6]);let d=s?`Comment on the whole branch`:`Comment on the whole change`,f;return t[7]!==c||t[8]!==d?(f=(0,Z.jsx)(`div`,{className:`shrink-0 px-2 pt-2`,children:(0,Z.jsxs)(h,{type:`button`,variant:`outline`,size:`sm`,className:`w-full`,disabled:c,onClick:l,children:[u,d]})}),t[7]=c,t[8]=d,t[9]=f):f=t[9],f}function av(e){let t=(0,$.c)(12),{scope:n,context:r,base:i}=e,{connection:a}=r,o=Pi(n,a,i),s,c,l,u;if(t[0]!==o.result||t[1]!==r||t[2]!==n){let e=ge(V(o.result)),i=e?.base?.ref,a=e?.head.oid;s=iv,c=n,l=r,u=i==null||a==null?void 0:gd({base:i,tip:a}),t[0]=o.result,t[1]=r,t[2]=n,t[3]=s,t[4]=c,t[5]=l,t[6]=u}else s=t[3],c=t[4],l=t[5],u=t[6];let d;return t[7]!==s||t[8]!==c||t[9]!==l||t[10]!==u?(d=(0,Z.jsx)(s,{scope:c,context:l,anchor:u}),t[7]=s,t[8]=c,t[9]=l,t[10]=u,t[11]=d):d=t[11],d}function ov(e){let t=(0,$.c)(45),{scope:n,context:r,list:i,threads:a,branch:o,base:s,onOpen:c}=e,[l,u]=(0,Q.useState)(`open`),d;t[0]===i.changes?d=t[1]:(d=new Set(i.changes.map(dv)),t[0]=i.changes,t[1]=d);let f=d,p=[...a].filter(e=>e.resolved===(l===`resolved`)).sort(uv),m;t[2]===a?m=t[3]:(m=a.filter(lv),t[2]=a,t[3]=m);let h=m.length,g=a.length-h,_;t[4]!==h||t[5]!==g?(_={open:h,resolved:g},t[4]=h,t[5]=g,t[6]=_):_=t[6];let v=_,y=l===`open`?`No open comments yet.`:`Nothing resolved yet.`,b;t[7]===a?b=t[8]:(b=a.map(cv).sort().join(`
|
|
11
|
+
`),t[7]=a,t[8]=b);let x=b,S;t[9]===a?S=t[10]:(S=a.reduce(sv,0),t[9]=a,t[10]=S);let C=S,w=_p(n,r),T;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(T={snapshot:``,filters:new Set},t[11]=T):T=t[11];let E=(0,Q.useRef)(T),D,O;t[12]!==l||t[13]!==C||t[14]!==w||t[15]!==h||t[16]!==g||t[17]!==x?(D=()=>{E.current.snapshot!==x&&(E.current={snapshot:x,filters:new Set}),E.current.filters.add(l);let e=wd({highest:C,open:h,resolved:g},E.current.filters);e!==null&&w(e)},O=[l,C,w,h,g,x],t[12]=l,t[13]=C,t[14]=w,t[15]=h,t[16]=g,t[17]=x,t[18]=D,t[19]=O):(D=t[18],O=t[19]),(0,Q.useEffect)(D,O);let k;t[20]!==f||t[21]!==c?(k=e=>{if(e.kind===`change`){c(e.comparison?.kind===`branch`?Vl:{kind:`handoff`},e);return}let t=e.comparison?.kind===`branch`?{kind:`branch-file`,path:e.filePath}:e.revision!==null&&e.revision!==void 0?{kind:`commit`,oid:e.revision}:e.comparison?.kind!==`file`&&f.has(e.filePath)?{kind:`change`,path:e.filePath}:{kind:`file`,path:e.filePath};c(t,e)},t[20]=f,t[21]=c,t[22]=k):k=t[22];let A=k,j;t[23]!==s||t[24]!==o||t[25]!==r||t[26]!==n?(j=o?(0,Z.jsx)(av,{scope:n,context:r,base:s}):(0,Z.jsx)(iv,{scope:n,context:r,anchor:gd(void 0)}),t[23]=s,t[24]=o,t[25]=r,t[26]=n,t[27]=j):j=t[27];let M;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(M=[`open`,`resolved`],t[28]=M):M=t[28];let N;t[29]!==v||t[30]!==l?(N=M.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":l===e,onClick:()=>u(e),className:I(`rounded-md px-2 py-1 text-2xs capitalize text-muted-foreground transition-colors hover:bg-accent`,l===e&&`bg-accent text-foreground`),children:[e,` `,(0,Z.jsx)(`span`,{className:`tabular-nums`,children:v[e]})]},e)),t[29]=v,t[30]=l,t[31]=N):N=t[31];let P;t[32]!==r||t[33]!==l||t[34]!==g||t[35]!==n||t[36]!==a?(P=l===`resolved`&&g>0&&(0,Z.jsx)(R_,{scope:n,context:r,threads:a}),t[32]=r,t[33]=l,t[34]=g,t[35]=n,t[36]=a,t[37]=P):P=t[37];let F;t[38]!==N||t[39]!==P?(F=(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-1 px-2 pt-2`,children:[N,P]}),t[38]=N,t[39]=P,t[40]=F):F=t[40];let L=p.length===0?(0,Z.jsx)(`p`,{className:`px-4 py-6 text-center text-caption text-muted-foreground`,children:y}):(0,Z.jsx)(__,{autoScroll:!0,defaultScrollPosition:`end`,children:(0,Z.jsxs)(v_,{className:`min-h-0 flex-1`,children:[(0,Z.jsx)(y_,{"aria-label":`Comments`,children:(0,Z.jsx)(b_,{className:I(``,``),children:p.map((e,t)=>(0,Z.jsx)(x_,{messageId:e.id,scrollAnchor:t===p.length-1,children:(0,Z.jsx)(Vp,{thread:e,scope:n,context:r,onReveal:()=>A(e.anchor)})},e.id))})}),(0,Z.jsx)(S_,{})]})},l),R;return t[41]!==j||t[42]!==F||t[43]!==L?(R=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[j,F,L]}),t[41]=j,t[42]=F,t[43]=L,t[44]=R):R=t[44],R}function sv(e,t){return Math.max(e,t.revision)}function cv(e){return`${e.id}:${e.revision}`}function lv(e){return!e.resolved}function uv(e,t){return fv(e).localeCompare(fv(t))}function dv(e){return e.path}function fv(e){return e.messages.at(-1)?.createdAt??``}function pv(e){let t=(0,$.c)(40),{scope:n,context:r,worktreePath:i,surface:a,activeEntry:o,available:s,onSurface:c,onOpen:l,changes:u}=e,d;t[0]===c?d=t[1]:(d=e=>{va(e)&&c(e)},t[0]=c,t[1]=d);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsxs)(Oi,{value:`files`,className:`min-w-0`,children:[(0,Z.jsx)(qa,{className:`size-3.5`}),(0,Z.jsx)(`span`,{className:`truncate`,children:`Files`})]}),t[2]=f):f=t[2];let p;t[3]!==r||t[4]!==n?(p=(0,Z.jsx)(Oi,{value:`changes`,className:`min-w-0`,children:(0,Z.jsx)(mv,{scope:n,context:r})}),t[3]=r,t[4]=n,t[5]=p):p=t[5];let m;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsxs)(Oi,{value:`history`,className:`min-w-0`,children:[(0,Z.jsx)(Si,{className:`size-3.5`}),(0,Z.jsx)(`span`,{className:`truncate`,children:`History`})]}),t[6]=m):m=t[6];let h;t[7]===p?h=t[8]:(h=(0,Z.jsx)(`div`,{className:`shrink-0 p-1.5`,children:(0,Z.jsxs)(Ri,{className:`h-8 w-full`,children:[f,p,m]})}),t[7]=p,t[8]=h);let g;t[9]!==o||t[10]!==s||t[11]!==u||t[12]!==r||t[13]!==l||t[14]!==n||t[15]!==i?(g=(0,Z.jsx)(Ki,{value:`changes`,className:`min-h-0 overflow-hidden`,children:(0,Z.jsx)(hv,{scope:n,context:r,worktreePath:i,surface:`changes`,activeEntry:o,available:s,onOpen:l,changes:u})}),t[9]=o,t[10]=s,t[11]=u,t[12]=r,t[13]=l,t[14]=n,t[15]=i,t[16]=g):g=t[16];let _;t[17]!==o||t[18]!==s||t[19]!==u||t[20]!==r||t[21]!==l||t[22]!==n||t[23]!==i?(_=(0,Z.jsx)(Ki,{value:`files`,className:`min-h-0 overflow-hidden`,children:(0,Z.jsx)(hv,{scope:n,context:r,worktreePath:i,surface:`files`,activeEntry:o,available:s,onOpen:l,changes:u})}),t[17]=o,t[18]=s,t[19]=u,t[20]=r,t[21]=l,t[22]=n,t[23]=i,t[24]=_):_=t[24];let v;t[25]!==o||t[26]!==s||t[27]!==u||t[28]!==r||t[29]!==l||t[30]!==n||t[31]!==i?(v=(0,Z.jsx)(Ki,{value:`history`,className:`min-h-0 overflow-hidden`,children:(0,Z.jsx)(hv,{scope:n,context:r,worktreePath:i,surface:`history`,activeEntry:o,available:s,onOpen:l,changes:u})}),t[25]=o,t[26]=s,t[27]=u,t[28]=r,t[29]=l,t[30]=n,t[31]=i,t[32]=v):v=t[32];let y;return t[33]!==a||t[34]!==d||t[35]!==h||t[36]!==g||t[37]!==_||t[38]!==v?(y=(0,Z.jsx)(`aside`,{"aria-label":`Review sidebar`,"data-testid":`review-sidebar`,className:`flex h-full min-h-0 flex-col overflow-hidden rounded-xl border bg-card`,children:(0,Z.jsxs)(Ti,{value:a,onValueChange:d,className:`min-h-0 flex-1`,children:[h,g,_,v]})}),t[33]=a,t[34]=d,t[35]=h,t[36]=g,t[37]=_,t[38]=v,t[39]=y):y=t[39],y}function mv(e){let t=(0,$.c)(7),{scope:n,context:r}=e,i=jd(n,r)===!0,a=i?ro:pa,o;t[0]===a?o=t[1]:(o=(0,Z.jsx)(a,{className:`size-3.5 shrink-0`}),t[0]=a,t[1]=o);let s=i?`Review`:`Changes`,c;t[2]===s?c=t[3]:(c=(0,Z.jsx)(`span`,{className:`truncate`,children:s}),t[2]=s,t[3]=c);let l;return t[4]!==o||t[5]!==c?(l=(0,Z.jsxs)(Z.Fragment,{children:[o,c]}),t[4]=o,t[5]=c,t[6]=l):l=t[6],l}function hv(e){let t=(0,$.c)(37),{scope:n,context:r,worktreePath:i,surface:a,activeEntry:o,available:s,onOpen:c,changes:l}=e,u=Ad(n,r);if(!s){let e;t[0]!==c||t[1]!==u.review||t[2]!==a?(e=u.review&&a===`changes`&&(0,Z.jsx)(h,{variant:`ghost`,onClick:()=>c({kind:`handoff`}),children:`Saved review`}),t[0]=c,t[1]=u.review,t[2]=a,t[3]=e):e=t[3];let n;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(im,{title:`Worktree unavailable`,description:`Restore the checkout and return to Porcelain to browse its files and Git state.`}),t[4]=n):n=t[4];let r;return t[5]===e?r=t[6]:(r=(0,Z.jsxs)(`div`,{className:`p-3`,children:[e,n]}),t[5]=e,t[6]=r),r}let d=`${n.worktreeId}:${a}`,f;t[7]!==o||t[8]!==l||t[9]!==r||t[10]!==c||t[11]!==n||t[12]!==a?(f=a===`changes`&&(0,Z.jsx)(J_,{scope:n,context:r,activeEntry:o,onOpen:c,changeScope:l.scope,base:l.base,onChangeScope:l.onScope,onBase:l.onBase}),t[7]=o,t[8]=l,t[9]=r,t[10]=c,t[11]=n,t[12]=a,t[13]=f):f=t[13];let p;t[14]!==o||t[15]!==r.connection||t[16]!==c||t[17]!==n||t[18]!==a||t[19]!==i?(p=a===`files`&&(0,Z.jsx)(aa,{scope:n,connection:r.connection,worktreePath:i,selected:o?.startsWith(`file:`)?o.slice(5):``,onOpen:c}),t[14]=o,t[15]=r.connection,t[16]=c,t[17]=n,t[18]=a,t[19]=i,t[20]=p):p=t[20];let m;t[21]!==o||t[22]!==r.connection||t[23]!==c||t[24]!==n||t[25]!==a?(m=a===`history`&&(0,Z.jsx)(Ff,{scope:n,connection:r.connection,selected:o?.startsWith(`commit:`)?o.slice(7):``,onSelect:e=>c({kind:`commit`,oid:e}),onOpenGraph:()=>c({kind:`graph`})}),t[21]=o,t[22]=r.connection,t[23]=c,t[24]=n,t[25]=a,t[26]=m):m=t[26];let g;t[27]!==r.connection||t[28]!==n||t[29]!==d||t[30]!==f||t[31]!==p||t[32]!==m?(g=(0,Z.jsxs)(mg,{connection:r.connection,scope:n,children:[f,p,m]},d),t[27]=r.connection,t[28]=n,t[29]=d,t[30]=f,t[31]=p,t[32]=m,t[33]=g):g=t[33];let _=g,v;return t[34]!==_||t[35]!==a?(v=a===`files`?(0,Z.jsx)(`div`,{className:`h-full`,children:_}):(0,Z.jsx)(Bi,{className:`h-full`,children:_}),t[34]=_,t[35]=a,t[36]=v):v=t[36],v}function gv(e){let t=(0,$.c)(101),{worktree:n,projectId:r,search:i,onSearch:a,context:o,navigationTrigger:s}=e,[c,l]=(0,Q.useState)(!0),[u,d]=(0,Q.useState)(!1),f=uu(),[p,m]=(0,Q.useState)(0),g=(0,Q.useRef)(null),_=(0,Q.useRef)(null),v=(0,Q.useRef)(null),{isMobile:y,open:b,openMobile:x}=wi(),S=i.surface??`files`,C;t[0]!==r||t[1]!==n.id?(C={projectId:r,worktreeId:n.id},t[0]=r,t[1]=n.id,t[2]=C):C=t[2];let w=C,T;t[3]===c?T=t[4]:(T=()=>{c&&g.current?.focus(),l(vv)},t[3]=c,t[4]=T);let E=T,D;t[5]!==f||t[6]!==E?(D=()=>{f?E():d(_v)},t[5]=f,t[6]=E,t[7]=D):D=t[7];let O;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(O={ignoreInputs:!0},t[8]=O):O=t[8],vn(In.toggleSidebar,D,O);let[k,A]=(0,Q.useState)(),j;t[9]!==p||t[10]!==a?(j=(e,t,n)=>{let r=Wl(e);A(t?{anchor:t,nonce:Date.now(),pane:p,key:r,...n?.compose?{compose:!0}:{}}:void 0);let i=t?md(t):void 0;a({...p===1?{side:r}:{entry:r},...i===void 0?{}:{base:i}}),d(!1)},t[9]=p,t[10]=a,t[11]=j):j=t[11];let M=j,N;t[12]===a?N=t[13]:(N=e=>{a({surface:e})},t[12]=a,t[13]=N);let P=N,F;t[14]===P?F=t[15]:(F=()=>P(`changes`),t[14]=P,t[15]=F);let I;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(I={ignoreInputs:!0},t[16]=I):I=t[16],vn(In.surfaceReview,F,I);let L;t[17]===P?L=t[18]:(L=()=>P(`files`),t[17]=P,t[18]=L);let R;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(R={ignoreInputs:!0},t[19]=R):R=t[19],vn(In.surfaceFiles,L,R);let z;t[20]===P?z=t[21]:(z=()=>P(`history`),t[20]=P,t[21]=z);let B;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(B={ignoreInputs:!0},t[22]=B):B=t[22],vn(In.surfaceHistory,z,B);let V=p===1?i.side:i.entry,H=i.scope??`uncommitted`,U,W;t[23]===a?(U=t[24],W=t[25]):(U=e=>a({scope:e===`branch`?e:void 0}),W=e=>a({base:e}),t[23]=a,t[24]=U,t[25]=W);let G;t[26]!==i.base||t[27]!==H||t[28]!==U||t[29]!==W?(G={scope:H,base:i.base,onScope:U,onBase:W},t[26]=i.base,t[27]=H,t[28]=U,t[29]=W,t[30]=G):G=t[30];let K;t[31]!==o||t[32]!==M||t[33]!==w||t[34]!==P||t[35]!==S||t[36]!==V||t[37]!==G||t[38]!==n.available||t[39]!==n.path?(K=(0,Z.jsx)(pv,{scope:w,context:o,worktreePath:n.path,surface:S,activeEntry:V,available:n.available,onSurface:P,onOpen:M,changes:G}),t[31]=o,t[32]=M,t[33]=w,t[34]=P,t[35]=S,t[36]=V,t[37]=G,t[38]=n.available,t[39]=n.path,t[40]=K):K=t[40];let q=K,J;t[41]!==o||t[42]!==w?(J=(0,Z.jsx)(ta,{scope:w,context:o}),t[41]=o,t[42]=w,t[43]=J):J=t[43];let ee=c?`Hide review sidebar`:`Show review sidebar`,Y;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(Y=zn(In.toggleSidebar),t[44]=Y):Y=t[44];let te;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Z.jsx)(mo,{}),t[45]=te):te=t[45];let ne;t[46]!==c||t[47]!==ee||t[48]!==E?(ne=(0,Z.jsx)(h,{ref:g,className:`hidden xl:inline-flex`,variant:`ghost`,size:`icon-sm`,"aria-label":ee,"aria-expanded":c,"aria-keyshortcuts":In.toggleSidebar,title:`Toggle review sidebar (${Y})`,onClick:E,children:te}),t[46]=c,t[47]=ee,t[48]=E,t[49]=ne):ne=t[49];let re;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Z.jsx)(ea,{render:(0,Z.jsx)(h,{variant:`ghost`,size:`icon-sm`,ref:_,className:`xl:hidden`,"aria-label":`Review`,"aria-keyshortcuts":In.toggleSidebar,title:`Toggle review sidebar (${zn(In.toggleSidebar)})`}),children:(0,Z.jsx)(mo,{})}),t[50]=re):re=t[50];let ie;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(ie=()=>{let e=document.activeElement;return e===document.body||v.current?.contains(e)?_.current:!1},t[51]=ie):ie=t[51];let ae;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Z.jsxs)(gi,{className:`sr-only`,children:[(0,Z.jsx)(Gi,{children:`Worktree review`}),(0,Z.jsx)(Ni,{children:`Choose a review surface and open a document.`})]}),t[52]=ae):ae=t[52];let oe;t[53]===q?oe=t[54]:(oe=(0,Z.jsxs)(Qi,{ref:v,finalFocus:ie,className:`w-[min(90vw,22rem)]!`,showCloseButton:!1,children:[ae,q]}),t[53]=q,t[54]=oe);let se;t[55]!==u||t[56]!==oe?(se=(0,Z.jsxs)(Ui,{open:u,onOpenChange:d,children:[re,oe]}),t[55]=u,t[56]=oe,t[57]=se):se=t[57];let ce;t[58]!==J||t[59]!==ne||t[60]!==se?(ce=(0,Z.jsxs)(Z.Fragment,{children:[J,ne,se]}),t[58]=J,t[59]=ne,t[60]=se,t[61]=ce):ce=t[61];let le=ce,ue=y?0:480,de;t[62]!==o||t[63]!==w?(de=(0,Z.jsx)(yi,{scope:w,context:o}),t[62]=o,t[63]=w,t[64]=de):de=t[64];let fe;t[65]!==o||t[66]!==M||t[67]!==w?(fe=(0,Z.jsx)($i,{scope:w,context:o,onOpen:M}),t[65]=o,t[66]=M,t[67]=w,t[68]=fe):fe=t[68];let pe;t[69]!==o||t[70]!==p||t[71]!==s||t[72]!==y||t[73]!==b||t[74]!==x||t[75]!==a||t[76]!==M||t[77]!==k||t[78]!==w||t[79]!==i.base||t[80]!==i.entry||t[81]!==i.side||t[82]!==le||t[83]!==n.id?(pe=(0,Z.jsx)(yv,{reveal:k,scope:w,context:o,worktreeId:n.id,entry:i.entry,side:i.side,base:i.base,onSearch:a,focused:p,setFocused:m,onOpen:M,navigationTrigger:s,navigatorIsMobile:y,navigatorOpen:b,navigatorOpenMobile:x,tabControls:le}),t[69]=o,t[70]=p,t[71]=s,t[72]=y,t[73]=b,t[74]=x,t[75]=a,t[76]=M,t[77]=k,t[78]=w,t[79]=i.base,t[80]=i.entry,t[81]=i.side,t[82]=le,t[83]=n.id,t[84]=pe):pe=t[84];let X;t[85]!==o.connection||t[86]!==w||t[87]!==de||t[88]!==fe||t[89]!==pe?(X=(0,Z.jsx)(`section`,{"aria-label":`Review content`,className:`flex h-full min-w-0 flex-col overflow-hidden rounded-xl border bg-card`,children:(0,Z.jsxs)(mg,{connection:o.connection,scope:w,children:[de,fe,pe]})}),t[85]=o.connection,t[86]=w,t[87]=de,t[88]=fe,t[89]=pe,t[90]=X):X=t[90];let me;t[91]!==ue||t[92]!==X?(me=(0,Z.jsx)(Gr,{id:`review-document`,minSize:ue,children:X}),t[91]=ue,t[92]=X,t[93]=me):me=t[93];let he;t[94]!==f||t[95]!==q||t[96]!==c?(he=c&&f&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Vr,{className:`w-2 bg-transparent after:w-2`}),(0,Z.jsx)(Gr,{id:`review-sidebar`,defaultSize:320,minSize:260,maxSize:520,children:q})]}),t[94]=f,t[95]=q,t[96]=c,t[97]=he):he=t[97];let ge;return t[98]!==me||t[99]!==he?(ge=(0,Z.jsxs)(Or,{orientation:`horizontal`,className:`min-h-0 flex-1`,children:[me,he]}),t[98]=me,t[99]=he,t[100]=ge):ge=t[100],ge}function _v(e){return!e}function vv(e){return!e}function yv(e){let t=(0,$.c)(55),{reveal:n,scope:r,context:i,worktreeId:a,entry:o,side:s,base:c,onSearch:l,focused:u,setFocused:d,onOpen:f,navigationTrigger:p,navigatorIsMobile:m,navigatorOpen:h,navigatorOpenMobile:g,tabControls:_}=e,{connection:v}=i,y=ge(V(Jr(r,v))),b=Ad(r,i),x=!!b.review?.active||y!=null&&y.changes.length>0,S;t[0]===x?S=t[1]:(S=x?Wl({kind:`handoff`}):null,t[0]=x,t[1]=S);let C;t[2]!==o||t[3]!==u||t[4]!==l||t[5]!==d||t[6]!==s||t[7]!==S||t[8]!==a?(C={worktreeId:a,entry:o,side:s,onSearch:l,fallback:S,focused:u,setFocused:d},t[2]=o,t[3]=u,t[4]=l,t[5]=d,t[6]=s,t[7]=S,t[8]=a,t[9]=C):C=t[9];let w=Eu(C),T;t[10]!==u||t[11]!==w.panes?(T=w.panes[u]??{tabs:[],pinned:[],active:null},t[10]=u,t[11]=w.panes,t[12]=T):T=t[12];let E=T,D=w.split||u===0,O;t[13]===D?O=t[14]:(O={ignoreInputs:!0,enabled:D},t[13]=D,t[14]=O);let k=O,A;t[15]!==u||t[16]!==w?(A=()=>w.step(u,1),t[15]=u,t[16]=w,t[17]=A):A=t[17],vn(In.nextTab,A,k);let j;t[18]!==u||t[19]!==w?(j=()=>w.step(u,-1),t[18]=u,t[19]=w,t[20]=j):j=t[20],vn(In.previousTab,j,k);let M;t[21]!==u||t[22]!==E.active||t[23]!==w?(M=()=>E.active!==null&&E.active!==void 0&&w.close(u,E.active),t[21]=u,t[22]=E.active,t[23]=w,t[24]=M):M=t[24],vn(In.closeTab,M,k);let N;t[25]!==u||t[26]!==E.active||t[27]!==w?(N=()=>E.active!==null&&E.active!==void 0&&w.openToSide(u,E.active),t[25]=u,t[26]=E.active,t[27]=w,t[28]=N):N=t[28],vn(In.openToSide,N,k);let P;t[29]!==c||t[30]!==i||t[31]!==u||t[32]!==x||t[33]!==w||t[34]!==p||t[35]!==m||t[36]!==h||t[37]!==g||t[38]!==f||t[39]!==b.review?.active||t[40]!==n||t[41]!==r||t[42]!==d||t[43]!==_?(P=e=>({reveal:n,index:e,layout:w,split:w.split,focused:u===e,setFocused:d,scope:r,context:i,reviewing:b.review?.active===!0,handoff:b.review?.active?`review`:x?`changes`:null,base:c,onOpen:f,navigationTrigger:p,navigatorIsMobile:m,navigatorOpen:h,navigatorOpenMobile:g,tabControls:_}),t[29]=c,t[30]=i,t[31]=u,t[32]=x,t[33]=w,t[34]=p,t[35]=m,t[36]=h,t[37]=g,t[38]=f,t[39]=b.review?.active,t[40]=n,t[41]=r,t[42]=d,t[43]=_,t[44]=P):P=t[44];let F=P;if(!w.split){let e;return t[45]===F?e=t[46]:(e=(0,Z.jsx)(bv,{...F(0)}),t[45]=F,t[46]=e),e}let I;t[47]===F?I=t[48]:(I=(0,Z.jsx)(Gr,{id:`pane-left`,minSize:320,children:(0,Z.jsx)(bv,{...F(0)})}),t[47]=F,t[48]=I);let L;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsx)(Vr,{withHandle:!0}),t[49]=L):L=t[49];let R;t[50]===F?R=t[51]:(R=(0,Z.jsx)(Gr,{id:`pane-right`,minSize:320,children:(0,Z.jsx)(bv,{...F(1)})}),t[50]=F,t[51]=R);let z;return t[52]!==I||t[53]!==R?(z=(0,Z.jsxs)(Or,{orientation:`horizontal`,className:`min-h-0 flex-1`,children:[I,L,R]}),t[52]=I,t[53]=R,t[54]=z):z=t[54],z}function bv(e){let t=(0,$.c)(59),{reveal:n,index:r,layout:i,split:a,focused:o,setFocused:s,scope:c,context:l,reviewing:u,handoff:d,base:f,onOpen:p,navigationTrigger:m,navigatorIsMobile:h,navigatorOpen:g,navigatorOpenMobile:_,tabControls:v}=e,y;t[0]!==r||t[1]!==i.panes?(y=i.panes[r]??{tabs:[],pinned:[],active:null},t[0]=r,t[1]=i.panes,t[2]=y):y=t[2];let b=y,x=b.active??void 0,S;t[3]===x?S=t[4]:(S=Gl(x),t[3]=x,t[4]=S);let C=S,w=a?`${r===0?`Left`:`Right`} pane`:void 0,T,E;t[5]!==r||t[6]!==s?(T=()=>s(r),E=()=>s(r),t[5]=r,t[6]=s,t[7]=T,t[8]=E):(T=t[7],E=t[8]);let D=a&&r===1&&`border-l`,O;t[9]===D?O=t[10]:(O=I(`flex h-full min-h-0 flex-col`,D),t[9]=D,t[10]=O);let k;t[11]!==r||t[12]!==m||t[13]!==h||t[14]!==g||t[15]!==_?(k=r===0?(0,Z.jsx)(vr,{ref:m,"aria-label":`Toggle Sidebar`,"aria-expanded":h?_:g,"aria-keyshortcuts":On()===`mac`?`Meta+B`:`Control+B`,title:`Toggle projects (${zn(In.toggleNavigator)})`,onClick:()=>{!h&&g&&requestAnimationFrame(()=>m.current?.focus())}}):void 0,t[11]=r,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=k):k=t[16];let A=a?r===0?`left`:`right`:null,j,M,N,P,F,L;t[17]!==r||t[18]!==i?(j=e=>i.activate(r,e),M=e=>i.close(r,e),N=e=>i.closeOthers(r,e),P=()=>i.closeUnpinned(r),F=e=>i.togglePin(r,e),L=e=>i.openToSide(r,e),t[17]=r,t[18]=i,t[19]=j,t[20]=M,t[21]=N,t[22]=P,t[23]=F,t[24]=L):(j=t[19],M=t[20],N=t[21],P=t[22],F=t[23],L=t[24]);let R=!a||r===1?v:void 0,z;t[25]!==o||t[26]!==b.active||t[27]!==b.pinned||t[28]!==b.tabs||t[29]!==u||t[30]!==A||t[31]!==j||t[32]!==M||t[33]!==N||t[34]!==P||t[35]!==F||t[36]!==L||t[37]!==R||t[38]!==k?(z=(0,Z.jsx)(Uf,{leading:k,tabs:b.tabs,pinned:b.pinned,active:b.active,reviewing:u,side:A,focused:o,onActivate:j,onClose:M,onCloseOthers:N,onCloseUnpinned:P,onTogglePin:F,onOpenToSide:L,trailing:R}),t[25]=o,t[26]=b.active,t[27]=b.pinned,t[28]=b.tabs,t[29]=u,t[30]=A,t[31]=j,t[32]=M,t[33]=N,t[34]=P,t[35]=F,t[36]=L,t[37]=R,t[38]=k,t[39]=z):z=t[39];let B;t[40]!==f||t[41]!==l||t[42]!==C||t[43]!==o||t[44]!==d||t[45]!==r||t[46]!==p||t[47]!==b.active||t[48]!==n||t[49]!==c?(B=C==null?(0,Z.jsx)(xv,{handoff:d,onOpen:p}):(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,Z.jsx)(mg,{connection:l.connection,scope:c,children:(0,Z.jsx)(eg,{scope:c,context:l,document:C,base:f,onOpen:p,active:o,reveal:n?.pane===r&&n.key===b.active?n:void 0})},b.active)}),t[40]=f,t[41]=l,t[42]=C,t[43]=o,t[44]=d,t[45]=r,t[46]=p,t[47]=b.active,t[48]=n,t[49]=c,t[50]=B):B=t[50];let V;return t[51]!==o||t[52]!==z||t[53]!==B||t[54]!==w||t[55]!==T||t[56]!==E||t[57]!==O?(V=(0,Z.jsxs)(`section`,{"aria-label":w,"data-focused":o,onPointerDownCapture:T,onFocusCapture:E,className:O,children:[z,B]}),t[51]=o,t[52]=z,t[53]=B,t[54]=w,t[55]=T,t[56]=E,t[57]=O,t[58]=V):V=t[58],V}function xv(e){let t=(0,$.c)(14),{handoff:n,onOpen:r}=e,i=n===`review`?`the review`:`all changes`,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(qe,{children:(0,Z.jsx)(to,{})}),t[0]=a):a=t[0];let o=n?`Nothing open`:`No changes to review`,s;t[1]===o?s=t[2]:(s=(0,Z.jsx)(Ze,{children:o}),t[1]=o,t[2]=s);let c=n?`Open ${i}, or choose a file or commit from the right.`:`Browse files or history from the right.`,l;t[3]===c?l=t[4]:(l=(0,Z.jsx)(Ue,{children:c}),t[3]=c,t[4]=l);let u;t[5]!==s||t[6]!==l?(u=(0,Z.jsxs)(Le,{children:[a,s,l]}),t[5]=s,t[6]=l,t[7]=u):u=t[7];let d;t[8]!==n||t[9]!==r?(d=n&&(0,Z.jsx)(h,{onClick:()=>r({kind:`handoff`}),children:n===`review`?`Open review`:`Open all changes`}),t[8]=n,t[9]=r,t[10]=d):d=t[10];let f;return t[11]!==u||t[12]!==d?(f=(0,Z.jsx)(`div`,{className:`grid min-h-0 flex-1 place-items-center p-8`,children:(0,Z.jsxs)(Ye,{children:[u,d]})}),t[11]=u,t[12]=d,t[13]=f):f=t[13],f}function Sv(e){let t={projectId:e.projectId,worktreeId:e.worktreeId};return e.remote===null?tt({to:`/$projectId/$worktreeId`,params:t}):tt({to:`/remotes/$environmentId/$projectId/$worktreeId`,params:{environmentId:e.remote,...t}})}function Cv(e,t){let n=(0,$.c)(2),r=Qr(e,t,wv),i;return n[0]===r?i=n[1]:(i=()=>r?r():la.openWithPayload({remote:null}),n[0]=r,n[1]=i),i}function wv(e){return Vt.add({title:`Could not open the project`,description:Ie(e),type:`error`})}function Tv(e){let t=(0,$.c)(11),{connection:n,empty:i}=e,a=et(),o=$e(),s;t[0]!==i||t[1]!==a?(s=e=>a({...Sv(e),replace:i}),t[0]=i,t[1]=a,t[2]=s):s=t[2];let c=s,l=Cv(n,c),u,d;t[3]!==a||t[4]!==l?(u=()=>r(e=>{e===`open-settings`?a({to:`/settings/$section`,params:{section:`appearance`}}):l()}),d=[a,l],t[3]=a,t[4]=l,t[5]=u,t[6]=d):(u=t[5],d=t[6]),(0,Q.useEffect)(u,d);let f;return t[7]!==n||t[8]!==c||t[9]!==o?(f=(0,Z.jsx)(xi,{connection:n,remotes:o,onOpened:c}),t[7]=n,t[8]=c,t[9]=o,t[10]=f):f=t[10],f}export{su as a,gv as i,Cv as n,Yl as o,Sv as r,Tv as t};
|