@fabiofiorita/porcelain 0.83.0 → 0.85.0
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 +1 -1
- package/package.json +1 -1
- package/server/src/cli/main.mjs +6203 -5256
- package/web/dist/assets/_paired-B6tiTIDs.js +40 -0
- package/web/dist/assets/_paired-BTiwzm1O.js +1 -0
- package/web/dist/assets/_section-C1ant2Gf.js +1 -0
- package/web/dist/assets/access-Dl1HKbYr.js +17 -0
- package/web/dist/assets/confirmed-read-DcLEUmry.js +133 -0
- package/web/dist/assets/{core-R2hgk4px.js → core-CzPj8AUX.js} +1 -1
- package/web/dist/assets/{file-editor-CnQvPWI-.js → file-editor-ZzNIR2Bb.js} +13 -13
- package/web/dist/assets/{highlights-DchcZkI3.js → highlights-CkhjI2ek.js} +2 -2
- package/web/dist/assets/index-B38tyj8W.js +1504 -0
- package/web/dist/assets/{index-HBCxqMtr.css → index-wLG_09Ob.css} +1 -1
- package/web/dist/assets/lazyRouteComponent-Blj06I1z.js +1 -0
- package/web/dist/assets/pair-BTiwzm1O.js +1 -0
- package/web/dist/assets/pair-Cc4RvFWD.js +1 -0
- package/web/dist/assets/resolveLanguages-ByH4UCRT.js +2 -0
- package/web/dist/assets/shiki-DylxQut3.js +1 -0
- package/web/dist/assets/{stream-tokenizer-BU46NudF.js → stream-tokenizer-DzPUGMwH.js} +3 -3
- package/web/dist/assets/themeResolver-fzWDoZkr.js +2 -0
- package/web/dist/assets/themes-K9KCd10n.js +2 -0
- package/web/dist/assets/useMatch-DOx1OLzI.js +1 -0
- package/web/dist/assets/workspace-error-WdCLSEta.js +1 -0
- package/web/dist/index.html +8 -13
- package/web/dist/assets/_-16pZD2GN.js +0 -1
- package/web/dist/assets/_paired-B0WyT4V9.js +0 -1
- package/web/dist/assets/_paired-Dr6SPIr0.js +0 -1
- package/web/dist/assets/_paired-DtlvYTx3.js +0 -1
- package/web/dist/assets/_paired-DwhFACbc.js +0 -1
- package/web/dist/assets/_section-BtREvi1c.js +0 -1
- package/web/dist/assets/_worktreeId-B0WyT4V9.js +0 -1
- package/web/dist/assets/_worktreeId-BqvleVW2.js +0 -1
- package/web/dist/assets/_worktreeId-DwhFACbc.js +0 -1
- package/web/dist/assets/_worktreeId-mENbJ8d6.js +0 -1
- package/web/dist/assets/access-FSq50_zr.js +0 -17
- package/web/dist/assets/connected-workspace-CoqMh8ZH.js +0 -1
- package/web/dist/assets/constants-CmGPilXJ.js +0 -1
- package/web/dist/assets/desktop-actions-Dp7uXLpd.js +0 -40
- package/web/dist/assets/edit-file-u4Jh7DaZ.js +0 -271
- package/web/dist/assets/hastToHtml-yWaxTNYJ.js +0 -3
- package/web/dist/assets/index-C-VbrrPp.js +0 -10
- package/web/dist/assets/lazyRouteComponent-1k1cz2Rs.js +0 -1
- package/web/dist/assets/lib-6HYXi0_j.js +0 -9
- package/web/dist/assets/pair-B0WyT4V9.js +0 -1
- package/web/dist/assets/pair-CDRRpeB2.js +0 -1
- package/web/dist/assets/resolveLanguages-BkDrap64.js +0 -2
- package/web/dist/assets/root-DLTE-HSj.js +0 -1
- package/web/dist/assets/settings-page-C4F13mjh.js +0 -1350
- package/web/dist/assets/shiki-DuHfSKnd.js +0 -1
- package/web/dist/assets/themes-BSeJ3lIS.js +0 -2
- package/web/dist/assets/useMatch-CfGvegwy.js +0 -1
- package/web/dist/assets/useRouterState-CWTR8rVi.js +0 -1
- package/web/dist/assets/workspace-error-Cufx_WLE.js +0 -1
- package/web/dist/assets/workspace-pending-jNTTS2oy.js +0 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$ as t,$n as n,$r as r,$s as i,Aa as a,Ac as o,Al as s,An as c,B as l,Ba as u,Bl as d,Bn as f,Co as p,Da as m,Dc as h,Di as g,Dl as _,Dn as v,Ea as y,Ei as b,El as x,En as S,F as C,Fa as w,Fi as T,Fl as E,Ga as D,Gc as O,Gt as k,Ha as A,Hc as j,Hl as M,Hn as N,Ho as P,Ia as F,Ic as I,Ii as L,J as R,Jn as z,Jo as B,Jt as V,Ka as H,Kc as U,Kn as W,Ko as G,Kt as K,L as ee,La as q,Li as te,Ll as ne,M as re,Mc as J,Ml as ie,Na as ae,Nc as oe,Oc as se,Ol as ce,Pc as Y,Po as le,Q as ue,Qn as de,Qr as fe,R as pe,Ra as me,Rc as he,Ri as ge,Rl as _e,Sc as ve,Ss as ye,U as be,Ua as xe,Uc as Se,Ut as Ce,V as we,Va as Te,Vc as Ee,Vl as De,Vn as Oe,W as ke,Wa as X,Wn as Ae,Wr as je,Wt as Me,X as Ne,Xn as Pe,Xo as Fe,Xt as Ie,Y as Le,Yn as Re,Yr as ze,Yt as Be,Z as Ve,Za as He,Zn as Ue,Zo as We,Zr as Ge,Zt as Ke,_ as qe,_l as Je,_o as Ye,_r as Xe,_s as Ze,a as Qe,aa as $e,ac as et,ai as tt,al as nt,ar as rt,as as it,b as at,bc as ot,bo as st,br as ct,c as lt,cc as ut,co as dt,cr as ft,ct as pt,da as mt,dr as ht,ds as gt,dt as _t,ec as vt,eo as yt,er as bt,et as xt,fc as St,fl as Ct,fr as wt,fs as Tt,ft as Et,g as Dt,gl as Ot,gr as kt,gs as At,h as jt,hi as Mt,hl as Nt,hn as Pt,hr as Ft,hs as It,ht as Lt,i as Rt,ic as zt,ir as Bt,is as Vt,ja as Ht,jc as Ut,jl as Wt,ka as Gt,kc as Kt,kl as qt,kn as Jt,la as Yt,li as Xt,lo as Zt,lr as Qt,ls as $t,lt as en,mi as tn,mn as nn,mr as rn,ms as an,mt as on,n as sn,nc as cn,ni as ln,nl as un,nr as dn,ns as fn,o as pn,oc as mn,oo as hn,or as gn,os as _n,ot as vn,pi as yn,pl as bn,pr as xn,ps as Sn,pt as Cn,q as wn,qa as Tn,qn as En,qt as Dn,r as On,ra as kn,rc as An,ri as jn,rn as Mn,rr as Nn,rs as Pn,s as Fn,sa as In,sc as Ln,sl as Rn,sr as zn,ss as Bn,tc as Vn,tl as Hn,tn as Un,tr as Wn,ts as Gn,ua as Kn,uc as qn,ul as Jn,ur as Yn,ut as Xn,v as Zn,vi as Qn,vn as $n,vr as er,wa as tr,wi as nr,wo as rr,x as ir,xi as ar,xl as or,xo as sr,xr as cr,y as lr,ya as ur,yi as dr,yl as fr,yo as pr,yr as mr,ys as hr,z as gr,za as _r,zn as vr}from"./access-Dl1HKbYr.js";import{$ as yr,$n as br,$t as xr,A as Sr,Ai as Cr,At as wr,B as Tr,Bi as Er,Bn as Dr,Br as Or,Bt as kr,C as Ar,Ci as jr,Cn as Mr,Cr as Nr,Ct as Pr,D as Fr,Di as Ir,Dr as Lr,Dt as Rr,E as zr,Ei as Br,En as Vr,Er as Hr,Et as Ur,F as Wr,Fi as Gr,Fn as Kr,Fr as qr,G as Jr,Gn as Yr,Gr as Xr,Gt as Zr,H as Qr,Hi as $r,Hn as ei,Hr as ti,Ht as ni,I as ri,Ii as ii,In as ai,It as oi,J as si,Jn as ci,Jr as li,Jt as ui,K as di,Kn as fi,Kr as pi,Kt as mi,L as hi,Li as gi,Lt as _i,M as vi,Mi as yi,Mn as bi,Mr as xi,N as Si,Ni as Ci,Nn as wi,Nt as Ti,O as Ei,Oi as Di,On as Oi,Or as ki,Ot as Ai,P as ji,Pi as Mi,Pn as Ni,Pr as Pi,Q as Fi,Qn as Ii,Qt as Li,R as Ri,Ri as zi,Rn as Bi,Rr as Vi,Rt as Hi,S as Ui,Si as Wi,Sn as Gi,Sr as Ki,St as qi,T as Ji,Ti as Yi,Tn as Xi,Tr as Zi,Tt as Qi,U as $i,Ui as ea,Un as ta,Ur as na,Ut as ra,V as ia,Vi as aa,Vn as oa,Vr as sa,Vt as ca,W as la,Wn as ua,Wr as da,Wt as fa,X as pa,Xn as ma,Xr as ha,Xt as ga,Y as _a,Yn as va,Yr as ya,Yt as ba,Z as xa,Zn as Sa,Zt as Ca,_ as wa,_i as Ta,_n as Ea,_t as Da,a as Oa,ar as ka,at as Aa,b as ja,bi as Ma,bn as Na,br as Pa,bt as Fa,c as Ia,ci as La,cn as Ra,cr as za,ct as Ba,d as Va,di as Ha,dn as Ua,dr as Wa,dt as Ga,en as Ka,er as qa,et as Ja,f as Ya,fi as Xa,fn as Za,fr as Qa,ft as $a,g as eo,gi as to,gn as no,gt as ro,h as io,hi as ao,hn as oo,hr as so,ht as co,i as lo,in as uo,ir as fo,it as po,j as mo,ji as ho,jn as go,jt as _o,k as vo,ki as yo,kr as bo,kt as xo,l as So,li as Co,ln as wo,lr as To,lt as Eo,m as Do,mi as Oo,mn as ko,mr as Ao,mt as jo,nn as Mo,nr as No,nt as Po,o as Fo,or as Io,ot as Lo,p as Ro,pi as zo,pn as Bo,pr as Vo,pt as Ho,q as Uo,qn as Wo,qr as Go,qt as Ko,r as qo,rn as Jo,rr as Yo,rt as Xo,si as Zo,sn as Qo,sr as $o,st as es,tn as ts,tr as ns,tt as rs,u as is,ui as as,un as os,ur as ss,ut as cs,v as ls,vi as us,vn as ds,vt as fs,w as ps,wi as ms,wn as hs,wr as gs,wt as _s,x as vs,xi as ys,xn as bs,xr as xs,xt as Ss,y as Cs,yi as ws,yn as Ts,yr as Es,yt as Ds,z as Os,zi as ks,zn as As,zr as js,zt as Ms}from"./index-B38tyj8W.js";import{n as Ns}from"./useMatch-DOx1OLzI.js";import{$ as Ps,$t as Fs,B as Is,C as Ls,Ct as Rs,G as zs,Gt as Bs,H as Vs,It as Hs,J as Us,Jt as Ws,K as Gs,Kt as Ks,L as qs,Lt as Js,N as Ys,P as Xs,Pt as Zs,Qt as Qs,R as $s,S as ec,U as tc,V as nc,W as rc,Wt as ic,X as ac,Xt as oc,Y as sc,Yt as cc,Z as lc,Zt as uc,_ as dc,at as fc,b as pc,bt as mc,c as hc,ct as gc,d as _c,dt as vc,en as yc,et as bc,f as xc,g as Sc,gt as Cc,h as wc,ht as Tc,it as Ec,l as Dc,lt as Oc,m as kc,mt as Ac,nt as jc,o as Mc,ot as Nc,p as Pc,q as Fc,qt as Ic,rt as Lc,s as Rc,st as zc,t as Bc,tn as Vc,u as Hc,ut as Uc,v as Wc,x as Gc,xt as Kc,y as qc,yt as Jc}from"./confirmed-read-DcLEUmry.js";import{i as Yc,n as Xc,r as Zc,t as Qc}from"./cloneFileDiffMetadata-Cmt5VYmb.js";import{t as $c}from"./resolveLanguages-ByH4UCRT.js";import{t as el}from"./themeResolver-fzWDoZkr.js";import{t as tl}from"./workspace-error-WdCLSEta.js";function nl(e){let t=hr({warn:e?.router===void 0}),n=e?.router||t;return Ze(n.stores.__store,Ns(e,n))}var rl={name:`archive-restore`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]};rl.node;var il=xe(rl),al={name:`archive`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]};al.node;var ol=xe(al),sl={name:`arrow-down-right`,size:24,node:[[`path`,{d:`m7 7 10 10`,key:`1fmybs`}],[`path`,{d:`M17 7v10H7`,key:`6fjiku`}]]};sl.node;var cl=xe(sl),ll={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};ll.node;var ul=xe(ll),dl={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};dl.node;var fl=xe(dl),pl={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};pl.node;var ml=xe(pl),hl={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`}]]};hl.node;var gl=xe(hl),_l={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`}]]};_l.node;var vl=xe(_l),yl={name:`circle-dashed`,size:24,node:[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]};yl.node;var bl=xe(yl),xl={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`]};xl.node;var Sl=xe(xl),Cl={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`}]]};Cl.node;var wl=xe(Cl),Tl={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`}]]};Tl.node;var El=xe(Tl),Dl={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`}]]};Dl.node;var Ol=xe(Dl),kl={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`}]]};kl.node;var Al=xe(kl),jl={name:`git-commit-horizontal`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]],aliases:[`git-commit`]};jl.node;var Ml=xe(jl),Nl={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`}]]};Nl.node;var Pl=xe(Nl),Fl={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`}]]};Fl.node;var Il=xe(Fl),Ll={name:`git-pull-request-closed`,size:24,node:[[`path`,{d:`m15.5 3.5 5 5`,key:`1kmx7t`}],[`path`,{d:`m15.5 8.5 5-5`,key:`saftza`}],[`path`,{d:`M18 11.62V15`,key:`1greaj`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}]]};Ll.node;var Rl=xe(Ll),zl={name:`git-pull-request`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]};zl.node;var Bl=xe(zl),Vl={name:`git-pull-request-draft`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M18 6V5`,key:`1oao2s`}],[`path`,{d:`M18 11v-1`,key:`11c8tz`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]};Vl.node;var Hl=xe(Vl),Ul={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`}]]};Ul.node;var Wl=xe(Ul),Gl={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`}]]};Gl.node;var Kl=xe(Gl),ql={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`}]]};ql.node;var Jl=xe(ql),Yl={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};Yl.node;var Xl=xe(Yl),Zl={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`]};Zl.node;var Ql=xe(Zl),$l={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};$l.node;var eu=xe($l),tu={name:`tag`,size:24,node:[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]};tu.node;var nu=xe(tu),ru={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};ru.node;var iu=xe(ru),au={name:`user-round`,size:24,node:[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]],aliases:[`user-2`]};au.node;var ou=xe(au);function su(e){switch(e){case`size-limit`:return`Too large to show`;case`unsupported-submodule`:return`Submodule change`;case`unsupported-encoding`:return`Unsupported text encoding`}}function cu(e){switch(e.kind){case`binary`:return`Binary change`;case`metadata-only`:return`No code change`;case`omitted`:return su(e.reason);case`text`:return}}function lu(e,t,n){return jr(e)?`Submodule change`:t===void 0?n?`The patch could not be read`:void 0:cu(t)}function uu(e){return e.scope===`staged`||e.scope===`unstaged`?{scope:e.scope,oldPath:e.oldPath,newPath:e.newPath}:void 0}var du=/(?=^From [a-f0-9]+ .+$)/m,fu=/(?=^diff --git)/gm,pu=/^(---|\+\+\+)\s+([^\t\r\n]+)/,mu=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i;Object.freeze({fromStart:0,fromEnd:0}),Object.freeze([]);function hu(e,t){return e-(t===0?0:1)}function gu(e,t){return hu(e,t)+t}var _u=1;function vu(e,...t){return`ck${_u}:${JSON.stringify([e,...t])}`}function yu(e){let t=e.length;return e.charCodeAt(t-1)===10&&(t--,e.charCodeAt(t-1)===13&&t--),e.slice(0,t)}var bu=new TextEncoder,xu=new TextDecoder(`utf-8`,{ignoreBOM:!0}),Su=/[\uD800-\uDFFF]/,Cu=1024,wu=new Uint8Array(Cu);function Tu(){wu.length!==Cu&&(wu=new Uint8Array(Cu))}function Eu(e){if(e.length===0)return e;if(Su.test(e))return JSON.parse(JSON.stringify(e));let t=e.length*3;wu.length<t&&(wu=new Uint8Array(t));let{written:n}=bu.encodeInto(e,wu);return xu.decode(wu.subarray(0,n))}var Du=new TextDecoder(`utf-8`,{ignoreBOM:!0}),Ou={'"':`"`,"\\":`\\`,a:`\x07`,b:`\b`,t:` `,n:`
|
|
2
|
+
`,v:`\v`,f:`\f`,r:`\r`};function ku(e){if(e[0]!==`"`)return;let t=``,n=1;for(;n<e.length;){let r=e[n];if(r===`"`)return{fileName:t,rawLength:n+1};if(r!==`\\`){t+=r,n++;continue}let i=Ou[e[n+1]];if(i!=null){t+=i,n+=2;continue}let a=[];do{let t=Au(e,n+1);if(t==null)return;a.push(t),n+=4}while(e[n]===`\\`&&e[n+1]>=`0`&&e[n+1]<=`7`);t+=Du.decode(new Uint8Array(a))}}function Au(e,t){let n=e.charCodeAt(t)-48,r=e.charCodeAt(t+1)-48,i=e.charCodeAt(t+2)-48;if(n>=0&&n<=3&&r>=0&&r<=7&&i>=0&&i<=7)return n*64+r*8+i}var ju=4096,Mu=.5;function Nu(e){for(let t of e.hunks)for(let n=0;n<t.hunkContent.length;n++){let r=t.hunkContent[n];if(r.type!==`change`)continue;let i=Pu(e,r);i!=null&&(t.hunkContent.splice(n,1,...i),n+=i.length-1)}}function Pu(e,t){let{deletions:n,additions:r,deletionLineIndex:i,additionLineIndex:a}=t,o=Math.min(n,r),s=Math.abs(r-n);if(o===0||s===0||o*(s+1)>ju)return null;let c=[];for(let t=0;t<n;t++)c.push(Iu(e.deletionLines[i+t]??``));let l=[];for(let t=0;t<r;t++)l.push(Iu(e.additionLines[a+t]??``));let u=r>n,d=0,f=-1;for(let e=0;e<=s;e++){let t=0;for(let n=0;n<o;n++)t+=Lu(c[n+(u?0:e)],l[n+(u?e:0)]);e===0?f=t+o*Mu:t>f&&(f=t,d=e)}if(d===0)return null;let p=[],m=(e,t,n,r)=>{(e>0||t>0)&&p.push({type:`change`,deletions:e,additions:t,deletionLineIndex:n,additionLineIndex:r})};return u?(m(0,d,i,a),m(o,o,i,a+d),m(0,r-o-d,i+o,a+d+o)):(m(d,0,i,a),m(o,o,i+d,a),m(n-o-d,0,i+d+o,a+o)),p}var Fu=/\s+/g;function Iu(e){return e.replace(Fu,``)}function Lu(e,t){if(e===t)return 1;let n=Math.max(e.length,t.length),r=Math.min(e.length,t.length);if(r===0)return 0;let i=0;for(;i<r&&e[i]===t[i];)i++;let a=0;for(;a<r-i&&e[e.length-1-a]===t[t.length-1-a];)a++;return(i+a)/n}var Ru=/^diff --git ("a\/(?:[^"\\]|\\.)*"|a\/.+?) ("b\/(?:[^"\\]|\\.)*"|b\/.+?)$/;function zu(e,{cacheKeyPrefix:t,disableLineMatching:n,throwOnError:r=!1}={},i){let a=rd(e),o=a?Ku(e):qu(e),s=n===!0?`patch-file-raw`:`patch-file`,c,l=[];for(let e of o){if(a&&!fu.test(e)||!a&&!Ju(e)){if(c==null)c=Eu(e);else if(r)throw Error(`parsePatchContent: unknown file blob`);else console.error(`parsePatchContent: unknown file blob:`,e);continue}let o=Bu(e,{cacheKey:t==null?void 0:i==null?vu(s,t,String(l.length)):vu(s,t,String(i),String(l.length)),isGitDiff:a,disableLineMatching:n,throwOnError:r});o!=null&&l.push(o)}return{patchMetadata:c,files:l}}function Bu(e,{cacheKey:t,disableLineMatching:n=!1,isGitDiff:r=fu.test(e),oldFile:i,newFile:a,throwOnError:o=!1}={}){let s=0,c=id(e,`@@ `),l,u=i==null||a==null,d=0,f=0;for(let e of c){let n=Gu(e),c=n[0];if(c==null){if(o)throw Error(`parsePatchContent: invalid hunk`);console.error(`parsePatchContent: invalid hunk`,e);continue}let p=ed(c),m=0,h=0;if(p==null||l==null){if(l!=null){if(o)throw Error(`parsePatchContent: Invalid hunk`);console.error(`parsePatchContent: Invalid hunk`,e);continue}l={name:``,type:`change`,hunks:[],splitLineCount:0,unifiedLineCount:0,isPartial:u,additionLines:!u&&i!=null&&a!=null?Wu(a.contents):[],deletionLines:!u&&i!=null&&a!=null?Wu(i.contents):[],additionCharacterCount:!u&&i!=null&&a!=null?a.contents.length:0,deletionCharacterCount:!u&&i!=null&&a!=null?i.contents.length:0,cacheKey:od(t)},l.additionLines.length===1&&a?.contents===``&&(l.additionLines.length=0),l.deletionLines.length===1&&i?.contents===``&&(l.deletionLines.length=0);for(let e of n){if(e.startsWith(`diff --git`)){let t=e.trim().match(Ru);if(t==null){if(o)throw Error(`parsePatchContent: invalid git diff header`);console.error(`parsePatchContent: invalid git diff header`,e);continue}let n=Hu(t[1],!0),r=Hu(t[2],!0);l.name=Eu(r),n!==r&&(l.prevName=Eu(n));continue}let t=e.startsWith(`---`)||e.startsWith(`+++`)?e.match(pu):null;if(t!=null){let[,e,n]=t,i=Hu(n,r);if(e===`---`&&i!==`/dev/null`){let e=Eu(i);l.prevName=e,l.name=e}else e===`+++`&&i!==`/dev/null`&&(l.name=Eu(i))}else if(r){if(e.startsWith(`new mode `)&&(l.mode=Eu(e.slice(8).trim())),e.startsWith(`old mode `)&&(l.prevMode=Eu(e.slice(8).trim())),e.startsWith(`new file mode`)&&(l.type=`new`,l.mode=Eu(e.slice(13).trim())),e.startsWith(`deleted file mode`)&&(l.type=`deleted`,l.mode=Eu(e.slice(17).trim())),e.startsWith(`similarity index`)&&(e.startsWith(`similarity index 100%`)?l.type=`rename-pure`:l.type=`rename-changed`),e.startsWith(`index `)){let[,t,n,r]=e.trim().match(mu)??[];t!=null&&(l.prevObjectId=Eu(t)),n!=null&&(l.newObjectId=Eu(n)),r!=null&&(l.mode=Eu(r))}(e.startsWith(`rename from `)||e.startsWith(`copy from `))&&(l.prevName=Eu(Hu(e.slice(e.startsWith(`rename`)?12:10)))),(e.startsWith(`rename to `)||e.startsWith(`copy to `))&&(l.name=Eu(Hu(e.slice(e.startsWith(`rename`)?10:8))))}}continue}let g,_;for(;n.length>0&&(n[n.length-1]===`
|
|
3
|
+
`||n[n.length-1]===`\r`||n[n.length-1]===`\r
|
|
4
|
+
`||n[n.length-1]===``);)n.pop();let{additionStart:v,deletionStart:y}=p;d=u?d:y-1,f=u?f:v-1;let b={collapsedBefore:0,splitLineCount:0,splitLineStart:0,unifiedLineCount:0,unifiedLineStart:0,additionCount:p.additionCount,additionStart:v,additionLines:m,deletionCount:p.deletionCount,deletionStart:y,deletionLines:h,deletionLineIndex:d,additionLineIndex:f,hunkContent:[],hunkContext:od(p.hunkContext),hunkSpecs:Eu(c),noEOFCRAdditions:!1,noEOFCRDeletions:!1},x=0,S=0;for(let e=1;e<n.length;e++){let t=n[e];if(x>=b.additionCount&&S>=b.deletionCount&&!t.startsWith(`\\`)){if(!Qu(t)||$u(t))break;if(o)throw Error(`parsePatchContent: hunk has more lines than expected`)}let r=t[0];if(r!==`+`&&r!==`-`&&r!==` `&&r!==`\\`){if(o)throw Error(`parsePatchContent: invalid hunk line`);console.error(`parseLineType: Invalid firstChar: "${r}", full line: "${t}"`),console.error(`processFile: invalid rawLine:`,t);continue}let i=sd(r);if(i===`addition`){if(o&&x>=b.additionCount)throw Error(`parsePatchContent: hunk has too many addition lines`);let e=cd(t);(g==null||g.type!==`change`)&&(g=ld(`change`,d,f),b.hunkContent.push(g)),f++,x++,u&&(l.additionLines.push(e),l.additionCharacterCount+=e.length),g.additions++,m++,_=`addition`}else if(i===`deletion`){if(o&&S>=b.deletionCount)throw Error(`parsePatchContent: hunk has too many deletion lines`);let e=cd(t);(g==null||g.type!==`change`)&&(g=ld(`change`,d,f),b.hunkContent.push(g)),d++,S++,u&&(l.deletionLines.push(e),l.deletionCharacterCount+=e.length),g.deletions++,h++,_=`deletion`}else if(i===`context`){if(o&&(S>=b.deletionCount||x>=b.additionCount))throw Error(`parsePatchContent: hunk has too many context lines`);let e=cd(t);(g==null||g.type!==`context`)&&(g=ld(`context`,d,f),b.hunkContent.push(g)),f++,d++,x++,S++,u&&(l.deletionLines.push(e),l.additionLines.push(e),l.deletionCharacterCount+=e.length,l.additionCharacterCount+=e.length),g.lines++,_=`context`}else if(i===`metadata`&&g!=null){if(g.type===`context`?(b.noEOFCRAdditions=!0,b.noEOFCRDeletions=!0):_===`deletion`?b.noEOFCRDeletions=!0:_===`addition`&&(b.noEOFCRAdditions=!0),u&&(_===`addition`||_===`context`)){let e=l.additionLines.length-1;if(e>=0){let t=l.additionLines[e],n=yu(t);l.additionLines[e]=n,l.additionCharacterCount+=n.length-t.length}}if(u&&(_===`deletion`||_===`context`)){let e=l.deletionLines.length-1;if(e>=0){let t=l.deletionLines[e],n=yu(t);l.deletionLines[e]=n,l.deletionCharacterCount+=n.length-t.length}}}}if(x!==b.additionCount||S!==b.deletionCount){if(o)throw Error(`parsePatchContent: hunk line count mismatch`);console.error(`parsePatchContent: hunk line count mismatch: "${c.trimEnd()}", declared old/new ${b.deletionCount}/${b.additionCount}, parsed old/new ${S}/${x}`);let e=hu(b.additionStart,b.additionCount)+(x===0?0:1),t=hu(b.deletionStart,b.deletionCount)+(S===0?0:1);if(!u){let n=e-b.additionStart,r=t-b.deletionStart;b.additionLineIndex+=n,b.deletionLineIndex+=r;for(let e of b.hunkContent)e.additionLineIndex+=n,e.deletionLineIndex+=r}b.additionStart=e,b.deletionStart=t,b.additionCount=x,b.deletionCount=S}b.additionLines=m,b.deletionLines=h,b.collapsedBefore=Math.max(hu(b.additionStart,b.additionCount)-s,0),l.hunks.push(b),s=gu(b.additionStart,b.additionCount);for(let e of b.hunkContent)e.type===`context`?(b.splitLineCount+=e.lines,b.unifiedLineCount+=e.lines):(b.splitLineCount+=Math.max(e.additions,e.deletions),b.unifiedLineCount+=e.deletions+e.additions);b.splitLineStart=l.splitLineCount+b.collapsedBefore,b.unifiedLineStart=l.unifiedLineCount+b.collapsedBefore,l.splitLineCount+=b.collapsedBefore+b.splitLineCount,l.unifiedLineCount+=b.collapsedBefore+b.unifiedLineCount}if(l!=null){if(o&&u&&!r&&l.hunks.length===0)throw Error(`parsePatchContent: unified file has no hunks`);if(l.hunks.length>0&&!u&&l.additionLines.length>0&&l.deletionLines.length>0){let e=l.hunks[l.hunks.length-1],t=gu(e.additionStart,e.additionCount),n=l.additionLines.length,r=Math.max(n-t,0);l.splitLineCount+=r,l.unifiedLineCount+=r}return r||(l.prevName!=null&&l.name!==l.prevName?l.hunks.length>0?l.type=`rename-changed`:l.type=`rename-pure`:(i==null||i.contents===``)&&a!=null&&a.contents!==``?l.type=`new`:i!=null&&i.contents!==``&&(a==null||a.contents===``)&&(l.type=`deleted`)),l.type!==`rename-pure`&&l.type!==`rename-changed`&&(l.prevName=void 0),n||Nu(l),l}}function Vu(e,t={}){let{cacheKeyPrefix:n,throwOnError:r=!1}=t,i=[],a=Uu(e)?e.split(du):[e];for(let e of a)try{i.push(zu(e,t,n==null?void 0:i.length))}catch(e){if(r)throw e;console.error(e)}finally{Tu()}return i}function Hu(e,t=!1){let n=e.trim(),r=n.startsWith(`"`)?ku(n)?.fileName??n:n;return t&&(r.startsWith(`a/`)||r.startsWith(`b/`))?r.slice(2):r}function Uu(e){return e.startsWith(`From `)||e.includes(`
|
|
5
|
+
From `)}function Wu(e){let t=Gu(e);for(let e=0;e<t.length;e++)t[e]=Eu(t[e]);return t}function Gu(e){if(e.length===0)return[``];let t=[],n=0;for(;;){let r=e.indexOf(`
|
|
6
|
+
`,n);if(r===-1)break;t.push(e.slice(n,r+1)),n=r+1}return n<e.length&&t.push(e.slice(n)),t}function Ku(e){return id(e,`diff --git`)}function qu(e){if(e.length===0)return[``];let t=[],n=0,r=0,i=0,a=0,o=!1;for(;r<e.length;){let s=Zu(e,r);if(i<=0&&a<=0){if(Yu(e,r)){r>n&&t.push(e.slice(n,r)),n=r,o=!0,r=Zu(e,s);continue}if(o&&e.startsWith(`@@ -`,r)){let t=ed(e.slice(r,s));t!=null&&(i=t.deletionCount,a=t.additionCount)}r=s;continue}let c=e[r];c===`\\`||(c===` `?(i=Math.max(i-1,0),a=Math.max(a-1,0)):c===`-`?i=Math.max(i-1,0):c===`+`&&(a=Math.max(a-1,0))),r=s}return t.push(e.slice(n)),t}function Ju(e){return Yu(e,0)}function Yu(e,t){let n=Zu(e,t);return Xu(e,t,`---`)&&Xu(e,n,`+++`)}function Xu(e,t,n){if(!e.startsWith(n,t))return!1;let r=e[t+n.length];if(r!==` `&&r!==` `)return!1;for(let r=t+n.length+1;r<e.length;r++){let t=e[r];if(t===`
|
|
7
|
+
`||t===`\r`)break;if(t!==` `&&t!==` `)return!0}return!1}function Zu(e,t){let n=e.indexOf(`
|
|
8
|
+
`,t);return n===-1?e.length:n+1}function Qu(e){let t=e[0];return t===`+`||t===`-`||t===` `}function $u(e){if(!e.startsWith(`--`))return!1;for(let t=2;t<e.length;t++){let n=e[t];if(n!==` `&&n!==` `&&n!==`
|
|
9
|
+
`&&n!==`\r`)return!1}return!0}function ed(e){if(!e.startsWith(`@@ -`))return;let t=4,n=td(e,t);if(n==null)return;let r=n.value;t=n.endIndex;let i=1;if(e[t]===`,`){let n=td(e,t+1);if(n==null)return;i=n.value,t=n.endIndex}if(e[t]!==` `||e[t+1]!==`+`)return;t+=2;let a=td(e,t);if(a==null)return;let o=a.value;t=a.endIndex;let s=1;if(e[t]===`,`){let n=td(e,t+1);if(n==null)return;s=n.value,t=n.endIndex}if(e[t]!==` `||e[t+1]!==`@`||e[t+2]!==`@`)return;let c,l=t+3;return e[l]===` `&&(c=nd(e.slice(l+1))),{additionCount:s,additionStart:o,deletionCount:i,deletionStart:r,hunkContext:c}}function td(e,t){let n=t,r=0;for(;n<e.length;n++){let t=e.charCodeAt(n)-48;if(t<0||t>9)break;r=r*10+t}if(n!==t)return{value:r,endIndex:n}}function nd(e){return e.endsWith(`\r
|
|
10
|
+
`)?e.slice(0,-2):e.endsWith(`
|
|
11
|
+
`)?e.slice(0,-1):e}function rd(e){return e.startsWith(`diff --git`)||e.includes(`
|
|
12
|
+
diff --git`)}function id(e,t){if(e.length===0)return[``];let n=`\n${t}`,r=e.startsWith(t)?0:ad(e,n,0);if(r===-1)return[e];let i=[];r>0&&i.push(e.slice(0,r));let a=r;for(;;){let t=ad(e,n,a+1);if(t===-1)break;i.push(e.slice(a,t)),a=t}return i.push(e.slice(a)),i}function ad(e,t,n){let r=e.indexOf(t,n);return r===-1?-1:r+1}function od(e){return e==null?e:Eu(e)}function sd(e){return e===` `?`context`:e===`\\`?`metadata`:e===`+`?`addition`:`deletion`}function cd(e){let t=e.slice(1);return Eu(t===``?`
|
|
13
|
+
`:t)}function ld(e,t,n){return e===`change`?{type:`change`,additions:0,deletions:0,additionLineIndex:n,deletionLineIndex:t}:{type:`context`,lines:0,additionLineIndex:n,deletionLineIndex:t}}function ud(e){let t=e[0];if(t!==`+`&&t!==`-`&&t!==` `&&t!==`\\`){console.error(`parseLineType: Invalid firstChar: "${t}", full line: "${e}"`);return}let n=e.substring(1);return{line:n===``?`
|
|
14
|
+
`:n,type:t===` `?`context`:t===`\\`?`metadata`:t===`+`?`addition`:`deletion`}}function dd(e){if(e.trim()===``)return{kind:`empty`};let t=e.split(`
|
|
15
|
+
`);t.at(-1)===``&&t.pop();let n=t.findIndex(e=>e.startsWith(`@@`));if(n<0)return{kind:`invalid`};try{let r=Vu(t[0]?.startsWith(`@@`)?`diff --git a/excerpt b/excerpt\n${e}`:e,{throwOnError:!0}).flatMap(e=>e.files),i=r[0];if(r.length!==1||!i?.hunks.length)return{kind:`invalid`};let a=n,o=0,s=[];for(let e of i.hunks){if(t[a]!==e.hunkSpecs?.replace(/\n$/,``))return{kind:`invalid`};let n={id:`patch:${a}`,text:t[a++]??``},r=[],i=e.deletionStart||1,c=e.additionStart||1,l=e=>{let n=t[a]??``,s=ud(n),l=e===`removed`?`deletion`:e===`added`?`addition`:`context`;if(s?.type!==l)return!1;let u={source:n,line:{id:`patch:${a++}`,text:n.slice(1),kind:e,...e===`added`?{}:{oldLine:i},...e===`removed`?{}:{newLine:c}},oldLine:i,newLine:c,position:c};return r.push(u),e!==`added`&&i++,e!==`removed`&&c++,e!==`context`&&o++,t[a]===`\`&&r.push({...u,source:`\`,line:{id:`patch:${a++}`,text:`\`}}),!0};for(let n of e.hunkContent)if(n.type===`context`){for(let e=0;e<n.lines;e++)if(!l(`context`))return{kind:`invalid`}}else for(let e=0;e<n.deletions+n.additions;e++){let e=ud(t[a]??``)?.type;if(!l(e===`deletion`?`removed`:`added`))return{kind:`invalid`}}s.push({header:n,lines:r})}return a===t.length?{kind:`valid`,header:t.slice(0,n),hunks:s,changes:o}:{kind:`invalid`}}catch{return{kind:`invalid`}}}var fd=(e,t,n,r)=>`@@ -${t===0?e-1:e},${t} +${r===0?n-1:n},${r} @@`;function pd(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[fd(t.oldLine,n,t.newLine,r),...e.map(e=>e.text)]}function md(e,t,n=3,r=`new`){let i=dd(e);if(i.kind!==`valid`)return i.kind===`empty`?e:null;let{header:a,hunks:o}=i,s=e=>t.some(t=>e>=t.startLine-n&&e<=t.endLine+n),c=[...a];for(let e of o){let t=[];for(let n of e.lines){let e={...n,text:n.source};(e.text.startsWith(`\\`)?t.length>0:s(r===`old`?e.oldLine:e.position))?t.push(e):t.length>0&&(c.push(...pd(t)),t=[])}t.length>0&&c.push(...pd(t))}return c.length===a.length?null:`${c.join(`
|
|
16
|
+
`)}\n`}function hd(e){return e.mergeBaseOid===null||e.mergeBaseOid===void 0?null:{baseOid:e.mergeBaseOid,headOid:e.head.oid}}function gd(e){return e instanceof Error&&(e.name===`RequestError`||e.name===`ConnectionError`)?e.message:`The branch could not be compared. Try again.`}function _d(e){let t=new Map;for(let n of e){let e=ys(n);t.has(e)||t.set(e,{path:e,paths:[e],kind:`kind`in n?n.kind:`changed`})}return[...t.values()]}var vd=new Set([`spec`,`specs`,`__tests__`,`tests`]);function yd(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=>vd.has(e))}function bd(e,t){if(!t)return e;let n=[],r=[];for(let t of e)yd(t.path)?r.push(t):n.push(t);return[...n,...r]}function xd(e,t){return e?`Unmark as reviewed`:t?`Mark as reviewed again`:`Mark as reviewed`}function Sd(e){switch(e.kind){case`file`:return[{id:`review`,label:xd(e.status===`reviewed`,e.status===`stale`),disabled:!e.canReview},{id:`open`,label:`Open diff`},{id:`open-to-side`,label:e.sideLabel},{id:`open-file`,label:`Open file`},{id:`timeline`,label:`Show timeline`},{id:`copy-relative`,label:`Copy relative path`},...e.canDiscard?[{id:`discard`,label:`Discard`,destructive:!0}]:[]];case`section`:return[{id:`open`,label:`Open`}];case`group`:return[{id:`expand-all`,label:`Expand all`},{id:`collapse-all`,label:`Collapse all`}];default:return e}}var Z=e(i(),1),Cd=Z.createContext({disabled:!1});function wd(){return Z.useContext(Cd)}var Td=e=>/\.(png|jpe?g|gif|webp|avif|svg|ico)$/i.test(e);function Ed({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function Dd(e,t){let n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:Od(n,e.startContentIndex)}}function Od(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 Q=ye();function kd({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=ti}){let p=n?.(e),m=r?.(e),h=i?.(e),g=a?.(e);return(0,Q.jsxs)(Q.Fragment,{children:[p==null?(0,Q.jsxs)(Q.Fragment,{children:[m!=null&&(0,Q.jsx)(`div`,{slot:`header-prefix`,children:m}),h!=null&&(0,Q.jsx)(`div`,{slot:`header-filename-suffix`,children:h}),g!=null&&(0,Q.jsx)(`div`,{slot:`header-metadata`,children:g})]}):(0,Q.jsx)(`div`,{slot:jc,children:p}),o!=null&&l?.map((t,n)=>(0,Q.jsx)(`div`,{slot:f(t),children:o(t,e)},n)),t!=null&&c!=null&&d!=null&&t.map(t=>{if(t==null)return;let n=Ad(t,e);return(0,Q.jsx)(`div`,{slot:n,style:da,children:c(t,d)},n)}),s!=null&&(0,Q.jsx)(`div`,{slot:`gutter-utility-slot`,style:na,children:s(u)})]})}function Ad(e,t){let n=Dd(e,t);return n==null?void 0:Ed({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex})}function jd(e,t){return e?.cacheKey!=null||t?.cacheKey!=null?e?.cacheKey===t?.cacheKey:e===t}function Md(e,t){return e?.cacheKey===t?.cacheKey&&e?.contents===t?.contents&&e?.name===t?.name&&e?.lang===t?.lang}function Nd(e,t){return Zi(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength&&e.lineDiffType===t.lineDiffType&&e.maxLineDiffLength===t.maxLineDiffLength}function Pd(e){let t=e.lang??Ki(e.name),n=e.lang??(e.prevName==null?`text`:Ki(e.prevName));return t===`text`&&n===`text`}function Fd(e){return[sa(e.additionStart,e.additionCount)+1,Or(e.additionStart,e.additionCount)+1]}function Id({isPartial:e,rangeSize:t,expandedHunks:n,hunkIndex:r,collapsedContextThreshold:i}){let a=Math.max(t,0);if(a===0||e)return{fromStart:0,fromEnd:0,rangeSize:a,collapsedLines:a,renderAll:!1};if(n===!0||a<=i)return{fromStart:a,fromEnd:0,rangeSize:a,collapsedLines:0,renderAll:!0};let o=n?.get(r),s=Math.min(Math.max(o?.fromStart??0,0),a),c=Math.min(Math.max(o?.fromEnd??0,0),a),l=s+c,u=l>=a;return{fromStart:u?a:s,fromEnd:u?0:c,rangeSize:a,collapsedLines:Math.max(a-l,0),renderAll:u}}function Ld(e){let t=e.hunks[e.hunks.length-1];if(t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return!1;let n=e.additionLines.length-Or(t.additionStart,t.additionCount),r=e.deletionLines.length-Or(t.deletionStart,t.deletionCount);return n<=0&&r<=0?!1:n!==r}function Rd({fileDiff:e,errorPrefix:t}){let n=e.hunks[e.hunks.length-1];if(n==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return 0;let r=e.additionLines.length-Or(n.additionStart,n.additionCount),i=e.deletionLines.length-Or(n.deletionStart,n.deletionCount);if(r<=0&&i<=0)return 0;if(r!==i)throw Error(`${t}: trailing context mismatch (additions=${r}, deletions=${i}) for ${e.name}`);return Math.min(r,i)}function zd({fileDiff:e,hunkIndex:t,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:i}){if(t!==e.hunks.length-1)return;let a=Rd({fileDiff:e,errorPrefix:i});if(a<=0)return;if(n===!0||a<=r)return{fromStart:a,fromEnd:0,rangeSize:a,collapsedLines:0,renderAll:!0};let o=n?.get(e.hunks.length),s=Math.min(Math.max(o?.fromStart??0,0),a);return{fromStart:s,fromEnd:0,rangeSize:a,collapsedLines:a-s,renderAll:s>=a}}function Bd({fileDiff:e,lineNumber:t,expandedHunks:n,collapsedContextThreshold:r}){if(n===!0||e.isPartial)return!0;for(let[i,a]of e.hunks.entries()){let[o,s]=Fd(a);if(t<o){let s=Id({isPartial:e.isPartial,rangeSize:a.collapsedBefore,expandedHunks:n,hunkIndex:i,collapsedContextThreshold:r}),c=o-s.rangeSize;return s.renderAll||t<c+s.fromStart||t>=o-s.fromEnd}if(t<s)return!0}let i=zd({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:`isAdditionLineRenderable`});if(i==null||i.renderAll)return!0;let a=e.hunks[e.hunks.length-1],[,o]=Fd(a);return t<o+i.fromStart||t>=o+i.rangeSize}function Vd({fileDiff:e,lineNumber:t,direction:n,expandedHunks:r,collapsedContextThreshold:i}){if(r===!0||e.isPartial)return t;let a=[],o=1;for(let[t,n]of e.hunks.entries()){let[s,c]=Fd(n),l=Id({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:r,hunkIndex:t,collapsedContextThreshold:i}),u=s-l.rangeSize;l.renderAll?a.push([u,s]):(l.fromStart>0&&a.push([u,u+l.fromStart]),l.fromEnd>0&&a.push([s-l.fromEnd,s])),a.push([s,c]),o=c}let s=zd({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:r,collapsedContextThreshold:i,errorPrefix:`getNearestRenderableAdditionLine`});if(s!=null){let e=o;o=e+s.rangeSize,s.renderAll?a.push([e,o]):s.fromStart>0&&a.push([e,e+s.fromStart])}if(t>=o)return t;if(n===`down`){for(let[e,n]of a)if(n>t)return Math.max(e,t)}else for(let e=a.length-1;e>=0;e--){let[n,r]=a[e];if(n<=t)return Math.min(r-1,t)}}function Hd({type:e,metrics:t}){return t.hunkSeparatorHeight??va(e)}function Ud({type:e,metrics:t}){return e===`simple`||e===`metadata`||e===`line-info-basic`?0:t.spacing}function Wd({type:e,hunkIndex:t,hunkSpecs:n}){switch(e){case`simple`:return t>0;case`metadata`:return n!=null;case`line-info`:case`line-info-basic`:case`custom`:return!0}}function Gd(e){return e!==`simple`&&e!==`metadata`}function Kd({type:e,metrics:t,hunkIndex:n,hunkSpecs:r}){if(!Wd({type:e,hunkIndex:n,hunkSpecs:r}))return;let i=Hd({type:e,metrics:t}),a=Ud({type:e,metrics:t}),o=n>0?a:0,s=a;return{height:i,gapBefore:o,gapAfter:s,totalHeight:o+i+s}}function qd({type:e,metrics:t}){if(!Gd(e))return;let n=Hd({type:e,metrics:t}),r=Ud({type:e,metrics:t});return{height:n,gapBefore:r,gapAfter:0,totalHeight:r+n}}function Jd({diff:e,diffStyle:t,startingLine:n=0,totalLines:r=1/0,expandedHunks:i,collapsedContextThreshold:a=1,callback:o}){let s=Yd({diff:e,diffStyle:t,startingLine:n,expandedHunks:i,collapsedContextThreshold:a}),c={viewportStart:n,viewportEnd:n+r,isWindowedHighlight:n>0||r<1/0,splitCount:s.splitCount,unifiedCount:s.unifiedCount,finalHunkIndex:e.hunks.length-1,shouldBreak(){if(!c.isWindowedHighlight)return!1;let e=c.unifiedCount>=n+r,i=c.splitCount>=n+r;return t===`unified`?e:(t===`split`||e)&&i},shouldSkip(e,r){if(!c.isWindowedHighlight)return!1;let i=e>0&&c.unifiedCount+e<=n,a=r>0&&c.splitCount+r<=n;return t===`unified`?i:(t===`split`||i)&&a},incrementCounts(e,n){(t===`unified`||t===`both`)&&(c.unifiedCount+=e),(t===`split`||t===`both`)&&(c.splitCount+=n)},isInWindow(e,n){if(!c.isWindowedHighlight)return!0;let r=c.isInUnifiedWindow(e),i=c.isInSplitWindow(n);return t===`unified`?r:t===`split`?i:r||i},isInUnifiedWindow(e){return!c.isWindowedHighlight||c.unifiedCount>=n-e&&c.unifiedCount<n+r},isInSplitWindow(e){return!c.isWindowedHighlight||c.splitCount>=n-e&&c.splitCount<n+r},emit(e,n=!1){return n||(t===`unified`?c.incrementCounts(1,0):t===`split`?c.incrementCounts(0,1):c.incrementCounts(1,1)),o(e)??!1}};hunkIterator:for(let n=s.hunkIndex;n<e.hunks.length;n++){let r=e.hunks[n];if(r==null)throw Error(`iterateOverDiff: invalid hunk index`);if(c.shouldBreak())break;let o=sa(r.deletionStart,r.deletionCount),s=sa(r.additionStart,r.additionCount),l=!e.isPartial&&r.deletionCount===0?o:r.deletionLineIndex,u=!e.isPartial&&r.additionCount===0?s:r.additionLineIndex,d=Id({isPartial:e.isPartial,rangeSize:r.collapsedBefore,expandedHunks:i,hunkIndex:n,collapsedContextThreshold:a}),f=n===c.finalHunkIndex?zd({fileDiff:e,hunkIndex:n,expandedHunks:i,collapsedContextThreshold:a,errorPrefix:`iterateOverDiff`}):void 0,p=d.fromStart+d.fromEnd;function m(e,n){return f==null||f.collapsedLines<=0||f.fromStart+f.fromEnd>0?0:t===`unified`?e===r.unifiedLineStart+r.unifiedLineCount-1?f.collapsedLines:0:n===r.splitLineStart+r.splitLineCount-1?f.collapsedLines:0}let h=d.collapsedLines===0;function g(){return h?0:(h=!0,d.collapsedLines)}if(c.shouldSkip(p,p))c.incrementCounts(p,p),g();else{let e=r.unifiedLineStart-d.rangeSize,i=r.splitLineStart-d.rangeSize,a=l-d.rangeSize,f=u-d.rangeSize,p=o+1-d.rangeSize,m=s+1-d.rangeSize;if(Qd(c,d.fromStart,t,t=>c.emit({hunkIndex:n,hunk:r,collapsedBefore:0,collapsedAfter:0,type:`context-expanded`,deletionLine:{lineNumber:p+t,lineIndex:a+t,noEOFCR:!1,unifiedLineIndex:e+t,splitLineIndex:i+t},additionLine:{unifiedLineIndex:e+t,splitLineIndex:i+t,lineIndex:f+t,lineNumber:m+t,noEOFCR:!1}}))||(e=r.unifiedLineStart-d.fromEnd,i=r.splitLineStart-d.fromEnd,a=l-d.fromEnd,f=u-d.fromEnd,p=o+1-d.fromEnd,m=s+1-d.fromEnd,Qd(c,d.fromEnd,t,t=>c.emit({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:0,type:`context-expanded`,deletionLine:{lineNumber:p+t,lineIndex:a+t,noEOFCR:!1,unifiedLineIndex:e+t,splitLineIndex:i+t},additionLine:{unifiedLineIndex:e+t,splitLineIndex:i+t,lineIndex:f+t,lineNumber:m+t,noEOFCR:!1}}),()=>{g()})))break hunkIterator}let _=r.unifiedLineStart,v=r.splitLineStart,y=l,b=u,x=o+1,S=s+1,C=r.hunkContent.at(-1);for(let e of r.hunkContent){if(c.shouldBreak())break hunkIterator;let i=e===C;if(e.type===`context`){if(c.shouldSkip(e.lines,e.lines))c.incrementCounts(e.lines,e.lines),g();else if(Qd(c,e.lines,t,t=>{let a=i&&t===e.lines-1,o=_+t,s=v+t;return c.emit({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:m(o,s),type:`context`,deletionLine:{lineNumber:x+t,lineIndex:y+t,noEOFCR:a&&r.noEOFCRDeletions,unifiedLineIndex:o,splitLineIndex:s},additionLine:{unifiedLineIndex:o,splitLineIndex:s,lineIndex:b+t,lineNumber:S+t,noEOFCR:a&&r.noEOFCRAdditions}})},()=>{g()}))break hunkIterator;_+=e.lines,v+=e.lines,y+=e.lines,b+=e.lines,x+=e.lines,S+=e.lines}else{let a=Math.max(e.deletions,e.additions),o=e.deletions+e.additions;if(!c.shouldSkip(o,a)){let s=$d(c,e,t);(s[0]?.[0]??0)>0&&g();for(let[l,u]of s)for(let s=l;s<u;s++){let l=m(_+s,t===`unified`?v+(s<e.deletions?s:s-e.deletions):v+s);if(c.emit(ef({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:l,diffStyle:t,index:s,unifiedLineIndex:_,splitLineIndex:v,additionLineIndex:b,deletionLineIndex:y,additionLineNumber:S,deletionLineNumber:x,content:e,isLastContent:i,unifiedCount:o,splitCount:a}),!0))break hunkIterator}}g(),c.incrementCounts(o,a),_+=o,v+=a,y+=e.deletions,b+=e.additions,x+=e.deletions,S+=e.additions}}if(f!=null){let{collapsedLines:n,fromStart:r,fromEnd:i}=f,a=r+i;if(Qd(c,a,t,t=>{let r=t===a-1;return c.emit({hunkIndex:e.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:r?n:0,type:`context-expanded`,deletionLine:{lineNumber:x+t,lineIndex:y+t,noEOFCR:!1,unifiedLineIndex:_+t,splitLineIndex:v+t},additionLine:{unifiedLineIndex:_+t,splitLineIndex:v+t,lineIndex:b+t,lineNumber:S+t,noEOFCR:!1}})},void 0,()=>c.shouldBreak()))break hunkIterator}}}function Yd({diff:e,diffStyle:t,startingLine:n,expandedHunks:r,collapsedContextThreshold:i}){if(n<=0||t===`both`)return{hunkIndex:0,splitCount:0,unifiedCount:0};let a=Xd({diff:e,expandedHunks:r,collapsedContextThreshold:i}),o=0,s=e.hunks.length-1,c=e.hunks.length;for(;o<=s;){let e=o+s>>1,r=a[e+1];if(r==null)throw Error(`iterateOverDiff: invalid hunk prefix index`);(t===`unified`?r.unifiedCount:r.splitCount)>n?(c=e,s=e-1):o=e+1}if(c>=e.hunks.length){let t=a[e.hunks.length];if(t==null)throw Error(`iterateOverDiff: invalid terminal hunk prefix index`);return{hunkIndex:e.hunks.length,splitCount:t.splitCount,unifiedCount:t.unifiedCount}}let l=a[c];if(l==null)throw Error(`iterateOverDiff: invalid selected hunk prefix index`);return{hunkIndex:c,splitCount:l.splitCount,unifiedCount:l.unifiedCount}}function Xd({diff:e,expandedHunks:t,collapsedContextThreshold:n}){let r=0,i=0,a=e.hunks.length-1,o=[{splitCount:0,unifiedCount:0}];for(let s=0;s<e.hunks.length;s++){let c=e.hunks[s];if(c==null)throw Error(`iterateOverDiff: invalid hunk summary index`);let l=Id({isPartial:e.isPartial,rangeSize:c.collapsedBefore,expandedHunks:t,hunkIndex:s,collapsedContextThreshold:n}),u=l.fromStart+l.fromEnd;r+=u+c.splitLineCount,i+=u+c.unifiedLineCount;let d=s===a?zd({fileDiff:e,hunkIndex:s,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:`iterateOverDiff`}):void 0;if(d!=null){let e=d.fromStart+d.fromEnd;r+=e,i+=e}o.push({splitCount:r,unifiedCount:i})}return o}function Zd(e,t,n){if(!e.isWindowedHighlight||t<=0)return[0,t];let r=[];function i(n){let i=Math.max(0,e.viewportStart-n),a=Math.min(t,e.viewportEnd-n);a>i&&r.push([i,a])}if(n!==`split`&&i(e.unifiedCount),n!==`unified`&&i(e.splitCount),r.length===0)return[0,0];let a=r[0][0],o=r[0][1];for(let e=1;e<r.length;e++){let t=r[e];a=Math.min(a,t[0]),o=Math.max(o,t[1])}return[a,o]}function Qd(e,t,n,r,i,a){let[o,s]=Zd(e,t,n);o>0&&(e.incrementCounts(o,o),i?.());let c=o;for(;c<t;){if(a?.()===!0)return!0;if(c>=s){e.incrementCounts(t-c,t-c);break}if(e.isInWindow(0,0)){if(r(c)===!0)return!0}else e.incrementCounts(1,1);c++}return!1}function $d(e,t,n){if(!e.isWindowedHighlight)return[[0,n===`unified`?t.deletions+t.additions:Math.max(t.deletions,t.additions)]];let r=n!==`split`,i=n!==`unified`,a=n===`unified`?`unified`:`split`,o=[];function s(t,n){if(t+n<=e.viewportStart||t>=e.viewportEnd)return;let r=Math.max(0,e.viewportStart-t),i=Math.min(n,e.viewportEnd-t);return i>r?[r,i]:void 0}function c(e,n){return a===`split`?e:n===`additions`?[e[0]+t.deletions,e[1]+t.deletions]:e}function l(e,t){if(e==null)return;let[n,r]=c(e,t);r>n&&o.push([n,r])}if(r&&(l(s(e.unifiedCount,t.deletions),`deletions`),l(s(e.unifiedCount+t.deletions,t.additions),`additions`)),i&&(l(s(e.splitCount,t.deletions),`deletions`),l(s(e.splitCount,t.additions),`additions`)),o.length===0)return o;o.sort((e,t)=>e[0]-t[0]);let u=[o[0]];for(let[e,t]of o.slice(1)){let n=u[u.length-1];e<=n[1]?n[1]=Math.max(n[1],t):u.push([e,t])}return u}function ef({hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,diffStyle:i,index:a,unifiedLineIndex:o,splitLineIndex:s,additionLineIndex:c,deletionLineIndex:l,additionLineNumber:u,deletionLineNumber:d,content:f,isLastContent:p,unifiedCount:m,splitCount:h}){let g=a<f.deletions?o+a:void 0,_=i===`unified`?a>=f.deletions?o+a:void 0:a<f.additions?o+f.deletions+a:void 0,v=i===`unified`?s+(a<f.deletions?a:a-f.deletions):s+a,y=a<f.deletions?l+a:void 0,b=a<f.deletions?d+a:void 0,x=i===`unified`?a>=f.deletions?c+(a-f.deletions):void 0:a<f.additions?c+a:void 0,S=i===`unified`?a>=f.deletions?u+(a-f.deletions):void 0:a<f.additions?u+a:void 0,C=i===`unified`?p&&a===f.deletions-1&&t.noEOFCRDeletions:p&&a===h-1&&t.noEOFCRDeletions,w=i===`unified`?p&&a===m-1&&t.noEOFCRAdditions:p&&a===h-1&&t.noEOFCRAdditions,T=y!=null&&b!=null&&g!=null?{lineNumber:b,lineIndex:y,noEOFCR:C,unifiedLineIndex:g,splitLineIndex:v}:void 0,E=x!=null&&S!=null&&_!=null?{unifiedLineIndex:_,splitLineIndex:v,lineIndex:x,lineNumber:S,noEOFCR:w}:void 0;if(T==null&&E!=null)return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:void 0,additionLine:E};if(T!=null&&E==null)return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:T,additionLine:void 0};if(T==null||E==null)throw Error(`iterateOverDiff: missing change line data`);return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:T,additionLine:E}}var tf=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r)setTimeout(function(){r(e)},0);else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h)d[r]=void 0;else{if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}},nf=new class extends tf{};function rf(e,t,n){return nf.diff(e,t,n)}function af(e,t){let n=0;for(;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function of(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function sf(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function cf(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function lf(e,t){return sf(e,t,``)}function uf(e,t){return cf(e,t,``)}function df(e,t){return t.slice(0,ff(e,t))}function ff(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function pf(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function mf(e,t){if(t)return gf(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function hf(e,t){if(t)return gf(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function gf(e,t){if(!t)return[hf(e),mf(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=pf(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var _f=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,vf=RegExp(`[${_f}]+|\\s+|[^${_f}]`,`ug`);new class extends tf{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=pf(e,r)}else n=e.match(vf)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&yf(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&yf(n,i,r,null,t.intlSegmenter),e}};function yf(e,t,n,r,i){if(t&&n){let[a,o]=gf(t.value,i),[s,c]=gf(n.value,i);if(e){let r=af(a,s);e.value=cf(e.value,s,r),t.value=lf(t.value,r),n.value=lf(n.value,r)}if(r){let e=of(o,c);r.value=sf(r.value,c,e),t.value=uf(t.value,e),n.value=uf(n.value,e)}}else if(n){if(e){let e=hf(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=hf(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=hf(r.value,i),[a,o]=gf(t.value,i),s=af(n,a);t.value=lf(t.value,s);let c=of(lf(n,s),o);t.value=uf(t.value,c),r.value=sf(r.value,n,c),e.value=cf(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=hf(r.value,i),n=df(mf(t.value,i),e);t.value=uf(t.value,n)}else if(e){let n=df(mf(e.value,i),hf(t.value,i));t.value=lf(t.value,n)}}var bf=new class extends tf{tokenize(e){let t=RegExp(`(\\r?\\n)|[${_f}]+|[^\\S\\n\\r]+|[^${_f}]`,`ug`);return e.match(t)||[]}};function xf(e,t,n){return bf.diff(e,t,n)}var Sf=new class extends tf{constructor(){super(...arguments),this.tokenize=wf}equals(e,t,n){return n.ignoreWhitespace?(n.newlineIsToken&&e.includes(`
|
|
17
|
+
`)||(e=e.trim()),n.newlineIsToken&&t.includes(`
|
|
18
|
+
`)||(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
19
|
+
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
20
|
+
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function Cf(e,t,n){return Sf.diff(e,t,n)}function wf(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
21
|
+
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function Tf(e){return e==`.`||e==`!`||e==`?`}new class extends tf{tokenize(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(r==e.length-1){t.push(e.slice(n));break}if(Tf(e[r])&&e[r+1].match(/\s/)){for(t.push(e.slice(n,r+1)),r=n=r+1;e[r+1]?.match(/\s/);)r++;t.push(e.slice(n,r+1)),n=r+1}}return t}},new class extends tf{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},new class extends tf{constructor(){super(...arguments),this.tokenize=wf}get useLongestToken(){return!0}castInput(e,t){let{undefinedReplacement:n,stringifyReplacer:r=(e,t)=>t===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify(Ef(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};function Ef(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a=0;for(;a<t.length;a+=1)if(t[a]===e)return n[a];let o;if(Object.prototype.toString.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=Ef(e[a],t,n,r,String(a));return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),typeof e==`object`&&e){t.push(e),o={},n.push(o);let i=[],s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(s);for(i.sort(),a=0;a<i.length;a+=1)s=i[a],o[s]=Ef(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}new class extends tf{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};function Df(e){for(let t=0;t<e.length;t++)if(e[t]<` `||e[t]>`~`||e[t]===`"`||e[t]===`\\`)return!0;return!1}function Of(e){if(!Df(e))return e;let t=`"`,n=new TextEncoder().encode(e),r=0;for(;r<n.length;){let e=n[r];t+=e===7?`\\a`:e===8?`\\b`:e===9?`\\t`:e===10?`\\n`:e===11?`\\v`:e===12?`\\f`:e===13?`\\r`:e===34?`\\"`:e===92?`\\\\`:e>=32&&e<=126?String.fromCharCode(e):`\\`+e.toString(8).padStart(3,`0`),r++}return t+=`"`,t}var kf={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0};function Af(e,t,n,r,i,a,o){let s;s=o?typeof o==`function`?{callback:o}:o:{},s.context===void 0&&(s.context=4);let c=s.context;if(s.newlineIsToken)throw Error(`newlineIsToken may not be used with patch-generation functions, only with diffing functions`);if(s.callback){let{callback:e}=s;Cf(n,r,Object.assign(Object.assign({},s),{callback:t=>{let n=l(t);e(n)}}))}else return l(Cf(n,r,s));function l(n){if(!n)return;n.push({value:``,lines:[]});function r(e){return e.map(function(e){return` `+e})}let o=[],s=0,l=0,u=[],d=1,f=1;for(let e=0;e<n.length;e++){let t=n[e],i=t.lines||Nf(t.value);if(t.lines=i,t.added||t.removed){if(!s){let t=n[e-1];s=d,l=f,t&&(u=c>0?r(t.lines.slice(-c)):[],s-=u.length,l-=u.length)}for(let e of i)u.push((t.added?`+`:`-`)+e);t.added?f+=i.length:d+=i.length}else{if(s){if(i.length<=c*2&&e<n.length-2)for(let e of r(i))u.push(e);else{let e=Math.min(i.length,c);for(let t of r(i.slice(0,e)))u.push(t);let t={oldStart:s,oldLines:d-s+e,newStart:l,newLines:f-l+e,lines:u};o.push(t),s=0,l=0,u=[]}}d+=i.length,f+=i.length}}for(let e of o)for(let t=0;t<e.lines.length;t++)e.lines[t].endsWith(`
|
|
22
|
+
`)?e.lines[t]=e.lines[t].slice(0,-1):(e.lines.splice(t+1,0,`\`),t++);return{oldFileName:e,newFileName:t,oldHeader:i,newHeader:a,hunks:o}}}function jf(e,t){if(t||=kf,Array.isArray(e)){if(e.length>1&&!t.includeFileHeaders&&!e.every(e=>e.isGit))throw Error(`Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)`);return e.map(e=>jf(e,t)).join(`
|
|
23
|
+
`)}let n=[];if(e.isGit){if(t=kf,!e.oldFileName)throw Error(`oldFileName must be specified for Git patches`);if(!e.newFileName)throw Error(`newFileName must be specified for Git patches`);let r=e.oldFileName,i=e.newFileName;e.isCreate&&r===`/dev/null`?r=i.replace(/^b\//,`a/`):e.isDelete&&i===`/dev/null`&&(i=r.replace(/^a\//,`b/`)),n.push(`diff --git `+Of(r)+` `+Of(i)),e.isDelete&&n.push(`deleted file mode `+(e.oldMode??`100644`)),e.isCreate&&n.push(`new file mode `+(e.newMode??`100644`)),e.oldMode&&e.newMode&&!e.isDelete&&!e.isCreate&&(n.push(`old mode `+e.oldMode),n.push(`new mode `+e.newMode)),e.isRename&&(n.push(`rename from `+Of((e.oldFileName??``).replace(/^a\//,``))),n.push(`rename to `+Of((e.newFileName??``).replace(/^b\//,``)))),e.isCopy&&(n.push(`copy from `+Of((e.oldFileName??``).replace(/^a\//,``))),n.push(`copy to `+Of((e.newFileName??``).replace(/^b\//,``))))}else t.includeIndex&&e.oldFileName==e.newFileName&&e.oldFileName!==void 0&&n.push(`Index: `+e.oldFileName),t.includeUnderline&&n.push(`===================================================================`);let r=e.hunks.length>0;t.includeFileHeaders&&e.oldFileName!==void 0&&e.newFileName!==void 0&&(!e.isGit||r)&&(n.push(`--- `+Of(e.oldFileName)+(e.oldHeader?` `+e.oldHeader:``)),n.push(`+++ `+Of(e.newFileName)+(e.newHeader?` `+e.newHeader:``)));for(let t=0;t<e.hunks.length;t++){let r=e.hunks[t],i=r.oldLines===0?r.oldStart-1:r.oldStart,a=r.newLines===0?r.newStart-1:r.newStart;n.push(`@@ -`+i+`,`+r.oldLines+` +`+a+`,`+r.newLines+` @@`);for(let e of r.lines)n.push(e)}return n.join(`
|
|
24
|
+
`)+`
|
|
25
|
+
`}function Mf(e,t,n,r,i,a,o){if(typeof o==`function`&&(o={callback:o}),o?.callback){let{callback:s}=o;Af(e,t,n,r,i,a,Object.assign(Object.assign({},o),{callback:e=>{s(e?jf(e,o.headerOptions):void 0)}}))}else{let s=Af(e,t,n,r,i,a,o);return s?jf(s,o?.headerOptions):void 0}}function Nf(e){let t=e.endsWith(`
|
|
26
|
+
`),n=e.split(`
|
|
27
|
+
`).map(e=>e+`
|
|
28
|
+
`);return t?n.pop():n.push(n.pop().slice(0,-1)),n}function Pf({line:e,spanStart:t,spanLength:n}){return{start:{line:e,character:t},end:{line:e,character:t+n},properties:{"data-diff-span":``},alwaysWrap:!0}}function Ff({item:e,arr:t,enableJoin:n,isNeutral:r=!1,isLastItem:i=!1}){let a=t[t.length-1];if(a==null||i||!n){t.push([+!r,e.value]);return}let o=a[0]===0;r===o||r&&e.value.length===1&&!o?a[1]+=e.value:t.push([+!r,e.value])}var If={forcePlainText:!1};function Lf(e,t,n,{forcePlainText:r,lazyLineAST:i=!1,startingLine:a,totalLines:o,expandedHunks:s,collapsedContextThreshold:c=1}=If){r?(a??=0,o??=1/0):(a=0,o=1/0);let l=a>0||o<1/0;i&&=!r&&!n.useTokenTransformer;let u=typeof n.theme==`string`?t.getTheme(n.theme).type:void 0,d=Ao({theme:n.theme,highlighter:t}),f=r&&!l&&(e.unifiedLineCount>1e3||e.splitLineCount>1e3)?`none`:n.lineDiffType,p={deletionLines:[],additionLines:[]},{maxLineDiffLength:m}=n,h=!r&&!e.isPartial,g=r?s:void 0,_=new Map;function v(e){let t=h?0:e,n=_.get(t)??Bf();return _.set(t,n),n}function y(e,t,n,r){if(l){let e=n.at(-1);(e==null||e.targetIndex+e.count!==t)&&(e={targetIndex:t,originalOffset:r.length,count:0},n.push(e)),e.count++}r.push(e)}Jd({diff:e,diffStyle:`both`,startingLine:a,totalLines:o,expandedHunks:!l||g,collapsedContextThreshold:c,callback:({hunkIndex:t,additionLine:n,deletionLine:r,type:i})=>{let a=v(t),o=n==null?r.splitLineIndex:n.splitLineIndex;i===`change`&&n!=null&&r!=null&&zf({additionLine:e.additionLines[n.lineIndex],deletionLine:e.deletionLines[r.lineIndex],deletionLineIndex:a.deletionContent.length,additionLineIndex:a.additionContent.length,deletionDecorations:a.deletionDecorations,additionDecorations:a.additionDecorations,lineDiffType:f,maxLineDiffLength:m}),r!=null&&(y(e.deletionLines[r.lineIndex],r.lineIndex,a.deletionSegments,a.deletionContent),a.deletionInfo.push({type:i===`change`?`change-deletion`:i,lineNumber:r.lineNumber,altLineNumber:i===`change`?void 0:n.lineNumber??void 0,lineIndex:`${r.unifiedLineIndex},${o}`})),n!=null&&(y(e.additionLines[n.lineIndex],n.lineIndex,a.additionSegments,a.additionContent),a.additionInfo.push({type:i===`change`?`change-addition`:i,lineNumber:n.lineNumber,altLineNumber:i===`change`?void 0:r.lineNumber??void 0,lineIndex:`${n.unifiedLineIndex},${o}`}))}});for(let a of _.values()){if(a.deletionContent.length===0&&a.additionContent.length===0)continue;let o={name:e.prevName??e.name,contents:a.deletionContent.value},s={name:e.name,contents:a.additionContent.value},{deletionLines:c,additionLines:l}=Vf({deletionFile:o,deletionInfo:a.deletionInfo,deletionDecorations:a.deletionDecorations,additionFile:s,additionInfo:a.additionInfo,additionDecorations:a.additionDecorations,highlighter:t,options:n,languageOverride:r?`text`:e.lang,lazyLineAST:i});if(h)p.deletionLines=c,p.additionLines=l;else for(let[e,t,n]of[[p.deletionLines,c,a.deletionSegments],[p.additionLines,l,a.additionSegments]])if(n.length>0)for(let r of n)for(let n=0;n<r.count;n++)e[r.targetIndex+n]=t[r.originalOffset+n];else if(i){let n=e.length;for(let r=0;r<t.length;r++)Io(e,n+r,()=>t[r])}else so(e,t)}return{code:p,themeStyles:d,baseThemeType:u}}function Rf(e,{deletionLineIndex:t,additionLineIndex:n,deletionDecorations:r,additionDecorations:i}){let a=0,o=0,s=-1,c=0,l=-1,u=0;for(let{value:t,added:n,removed:r}of e)r?(s===-1&&(s=a),a+=t.length,c=a):n?(l===-1&&(l=o),o+=t.length,u=o):(a+=t.length,o+=t.length);s!==-1&&r.push(Pf({line:t,spanStart:s,spanLength:c-s})),l!==-1&&i.push(Pf({line:n,spanStart:l,spanLength:u-l}))}function zf({deletionLine:e,additionLine:t,deletionLineIndex:n,additionLineIndex:r,deletionDecorations:i,additionDecorations:a,lineDiffType:o,maxLineDiffLength:s}){if(e==null||t==null||o===`none`||(e=Wo(e),t=Wo(t),e.length>s||t.length>s))return;let c=o===`char`?rf(e,t):xf(e,t);if(o===`word-line`){Rf(c,{deletionLineIndex:n,additionLineIndex:r,deletionDecorations:i,additionDecorations:a});return}let l=[],u=[],d=o===`word-alt`,f=c.at(-1);for(let e of c){let t=e===f;!e.added&&!e.removed?(Ff({item:e,arr:l,enableJoin:d,isNeutral:!0,isLastItem:t}),Ff({item:e,arr:u,enableJoin:d,isNeutral:!0,isLastItem:t})):e.removed?Ff({item:e,arr:l,enableJoin:d,isLastItem:t}):Ff({item:e,arr:u,enableJoin:d,isLastItem:t})}let p=0;for(let e of l)e[0]===1&&i.push(Pf({line:n,spanStart:p,spanLength:e[1].length})),p+=e[1].length;p=0;for(let e of u)e[0]===1&&a.push(Pf({line:r,spanStart:p,spanLength:e[1].length})),p+=e[1].length}function Bf(){return{deletionContent:{push(e){this.value+=e,this.length++},value:``,length:0},additionContent:{push(e){this.value+=e,this.length++},value:``,length:0},deletionInfo:[],additionInfo:[],deletionDecorations:[],additionDecorations:[],deletionSegments:[],additionSegments:[]}}function Vf({lazyLineAST:e,deletionFile:t,additionFile:n,deletionInfo:r,additionInfo:i,highlighter:a,deletionDecorations:o,additionDecorations:s,languageOverride:c,options:{theme:l,useTokenTransformer:u,tokenizeMaxLineLength:d}}){let f=(t,n,r)=>t.contents===``?[]:ka(a.codeToTokens(Wo(t.contents),Vo(c??Ki(t.name),l,d)).tokens,{state:{lineInfo:n},useTokenTransformer:u,decorations:r,lazyLineAST:e,cacheHtmlStyles:a.name===`highlights`});return{deletionLines:f(t,r,o),additionLines:f(n,i,s)}}function Hf(e){let t=[];for(let n of e){let e=xi.get(n);if(e==null)throw Error(`getResolvedLanguages: ${n} is not resolved. Please resolve languages before calling getResolvedLanguages`);t.push(e)}return t}function Uf(e){for(let t of Array.isArray(e)?e:[e])if(!xi.has(t))return!1;return!0}function Wf(e,t=Vi()){return el(t).getResolvedThemes(e)}function Gf(e,t=Vi()){return el(t).hasResolvedThemes(e)}function Kf(e,t=Vi()){return el(t).resolveThemes(e)}var qf=0,Jf=1,Yf=2,Xf=4,Zf=5,Qf=6,$f=[void 0,null,!0,!1];function ep(e){if(Array.isArray(e))return e;let{ops:t,offsets:n,strings:r,text:i,extras:a}=e,o=Array(n.length/2),s=0,c=0;function l(e){let n=Array(e);for(let o=0;o<e;o++){let e=t[s++];if(e!==qf){if(e===Jf){let e=c+t[s++];n[o]={type:`text`,value:i.slice(c,e)},c=e}else if(e===Yf){let e=r[t[s++]],i={};for(let e=t[s++];e>0;e--){let e=r[t[s++]],n=t[s++],o=n===Xf?r[t[s++]]:n===Zf?t[s++]:n===Qf?a[t[s++]]:$f[n];e===`__proto__`?Object.defineProperty(i,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):i[e]=o}n[o]={type:`element`,tagName:e,properties:i,children:l(t[s++])}}else n[o]=a[t[s++]]}}return n}for(let e=0;e<o.length;e++)t[n[e*2]]!==qf&&Io(o,e,()=>(s=n[e*2],c=n[e*2+1],l(1)[0]),{retain:!1});return o}var tp=e(Yc(),1),np=Symbol(`IGNORE_RESPONSE`),rp=1e4,ip=class{options;preferredHighlighter;renderOptions;renderOptionsRequestVersion=0;renderOptionsVersion=0;initialized=!1;workers=[];queuedTasks=[];queuedTaskByInstance=new Map;taskByHighlightKey=new Map;activeTaskById=new Map;activeRequestByInstance=new Map;nextRequestId=0;themeSubscribers=new Set;workersFailed=!1;terminated=!1;statSubscribers=new Set;fileCache;diffCache;_queuedBroadcast;lifecycleGeneration=0;constructor(e,{langs:t,theme:n=gc,useTokenTransformer:r=!1,lineDiffType:i=`word-alt`,maxLineDiffLength:a=1e3,tokenizeMaxLineLength:o=1e3,preferredHighlighter:s}){this.options=e,this.preferredHighlighter=Vi(s),this.renderOptions={theme:n,useTokenTransformer:r,lineDiffType:i,maxLineDiffLength:a,tokenizeMaxLineLength:o},this.fileCache=new tp.default.LRUMap(e.totalASTLRUCacheSize??100),this.diffCache=new tp.default.LRUMap(e.totalASTLRUCacheSize??100),this.queueInitialization(t)}isWorkingPool(){return!this.workersFailed&&!this.terminated}shouldHighlightOnMainThread(e){let{mainThreadMaxCharacters:t=-1}=this.options;return(`contents`in e?e.contents.length:e.deletionCharacterCount+e.additionCharacterCount)<=t}getFileResultCache(e){return e.cacheKey==null?void 0:this.fileCache.get(e.cacheKey)}getDiffResultCache(e){return e.cacheKey==null?void 0:this.diffCache.get(e.cacheKey)}setFileResultCache(e,{result:t,options:n}){return e==null||!Nr(n,this.getFileRenderOptions())?!1:(this.fileCache.set(e,{result:t,options:n}),this.queueBroadcastStateChanges(),!0)}setDiffResultCache(e,{result:t,options:n}){return e==null||!Nd(n,this.getDiffRenderOptions())?!1:(this.diffCache.set(e,{result:t,options:n}),this.queueBroadcastStateChanges(),!0)}inspectCaches(){let{fileCache:e,diffCache:t}=this;return{fileCache:e,diffCache:t}}evictFileFromCache(e){try{return this.fileCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}evictDiffFromCache(e){try{return this.diffCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}async setRenderOptions({theme:e=this.renderOptions.theme??gc,useTokenTransformer:t=this.renderOptions.useTokenTransformer??!1,lineDiffType:n=this.renderOptions.lineDiffType??`word-alt`,maxLineDiffLength:r=this.renderOptions.maxLineDiffLength??1e3,tokenizeMaxLineLength:i=this.renderOptions.tokenizeMaxLineLength??1e3}){let{lifecycleGeneration:a}=this,o=++this.renderOptionsRequestVersion,s=()=>this.isCurrentLifecycle(a)&&this.renderOptionsRequestVersion===o;try{let a={theme:e,useTokenTransformer:t,lineDiffType:n,maxLineDiffLength:r,tokenizeMaxLineLength:i};if(!this.isInitialized())try{await this.initialize()}catch(e){if(!this.workersFailed)throw e}if(!s()||Nd(a,this.renderOptions))return;let o=Pi(e),c=[];if(Zi(a.theme,this.renderOptions.theme)||(c=Gf(o,this.preferredHighlighter)?Wf(o,this.preferredHighlighter):await Kf(o,this.preferredHighlighter)),!s()||Hr({theme:e})==null&&(await this.loadSharedHighlighter(o,[`text`]),!s()))return;let l=this.setRenderOptionsOnWorkers(a,c);this.renderOptions=a,this.renderOptionsVersion++,this.diffCache.clear(),this.fileCache.clear(),this.invalidateRenderTasks();for(let e of this.themeSubscribers)e.onThemeChange();await l}catch(e){if(e instanceof qa||!s())return;throw e}}getPreferredHighlighter(){return this.preferredHighlighter}getFileRenderOptions(){let{tokenizeMaxLineLength:e,theme:t,useTokenTransformer:n}=this.renderOptions;return{theme:t,useTokenTransformer:n,tokenizeMaxLineLength:e}}getDiffRenderOptions(){return{...this.renderOptions}}async setRenderOptionsOnWorkers(e,t){if(this.workersFailed)return;this.isInitialized()||await this.initialize();let n=[];for(let r of this.workers){if(!r.initialized)throw console.log({managedWorker:r}),Error(`setRenderOptionsOnWorkers: Somehow we have an uninitialized worker`);n.push(new Promise((n,i)=>{let a=this.generateRequestId(),o={type:`set-render-options`,id:a,request:{type:`set-render-options`,id:a,renderOptions:e,resolvedThemes:t},resolve:n,reject:i,requestStart:Date.now()};this.activeTaskById.set(a,o),r.pendingSetupRequestId=a,r.worker.postMessage(o.request)}))}await Promise.all(n)}subscribeToThemeChanges(e){return this.themeSubscribers.add(e),this.queueBroadcastStateChanges(),()=>{this.unsubscribeToThemeChanges(e),this.queueBroadcastStateChanges()}}unsubscribeToThemeChanges(e){this.themeSubscribers.delete(e),this.queueBroadcastStateChanges()}subscribeToStatChanges(e){return this.statSubscribers.add(e),e(this.getStats()),()=>{this.statSubscribers.delete(e)}}queueBroadcastStateChanges(){this._queuedBroadcast??=requestAnimationFrame(this._broadcastStateChanges)}_broadcastStateChanges=()=>{this._queuedBroadcast!=null&&(cancelAnimationFrame(this._queuedBroadcast),this._queuedBroadcast=void 0);let e=this.getStats();for(let t of this.statSubscribers)t(e)};cleanUpTasks(e){this.detachInstanceFromQueuedTasks(e);let t=this.activeRequestByInstance.get(e);if(t!=null){let n=this.activeTaskById.get(t);sp(n)?(this.detachInstanceFromRenderTask(n,e),!n.primeCache&&n.instances.size===0&&this.removeActiveTask(n)):this.activeTaskById.delete(t)}this.activeRequestByInstance.delete(e),this.queueBroadcastStateChanges()}isInitialized(){return this.initialized===!0}async initialize(e=[]){if(this.initialized===!0)Hr({theme:this.renderOptions.theme})??await this.loadSharedHighlighter(Pi(this.renderOptions.theme),[`text`,...e]);else{if(this.initialized===!1){this.terminated=!1;let{lifecycleGeneration:t}=this,n=new Promise((n,r)=>{(async()=>{try{let r=Pi(this.renderOptions.theme),i=Gf(r,this.preferredHighlighter)?Wf(r,this.preferredHighlighter):await Kf(r,this.preferredHighlighter);if(!this.isCurrentLifecycle(t)){n();return}let a=[];if(this.preferredHighlighter!==`highlights`&&(a=Uf(e)?Hf(e):await $c(e)),!this.isCurrentLifecycle(t)){n();return}if(await Promise.all([this.loadSharedHighlighter(r,[`text`,...e]),this.initializeWorkers(i,a)]),!this.isCurrentLifecycle(t)){this.terminateWorkers(),n();return}this.initialized=!0,this.drainQueue(),this.queueBroadcastStateChanges(),n()}catch(e){if(e instanceof qa||!this.isCurrentLifecycle(t)){n();return}this.initialized=!1,this.workersFailed=!0,this.cancelActiveWorkerTasks(),this.terminateWorkers(),this.activeTaskById.clear();for(let t of this.queuedTasks)this.rejectRenderTaskCallbacks(t,lp(e));this.queueBroadcastStateChanges(),r(e)}})()});return this.initialized=n,this.queueBroadcastStateChanges(),n}return this.initialized}}async loadSharedHighlighter(e,t){try{await Lr({themes:e,langs:t,preferredHighlighter:this.preferredHighlighter})}catch(e){if(!(e instanceof qr))throw e}}async initializeWorkers(e,t){this.workersFailed=!1;let n=[],r=xs(),i=r>0?Pa():void 0;this.workers.length>0&&this.terminateWorkers();for(let a=0;a<(this.options.poolSize??8);a++){let a=this.options.workerFactory(),o={worker:a,requestId:void 0,pendingSetupRequestId:void 0,initialized:!1,langs:new Set([`text`,...t.map(({name:e})=>e)]),customExtensionsVersion:0};a.addEventListener(`message`,e=>{this.handleWorkerMessage(o,e.data)}),a.addEventListener(`error`,e=>this.handleWorkerError(o,e)),this.workers.push(o),n.push(new Promise((n,a)=>{let s=this.generateRequestId(),c={type:`initialize`,id:s,request:{type:`initialize`,resultFormat:`hast-ops-v1`,id:s,renderOptions:this.renderOptions,preferredHighlighter:this.preferredHighlighter,resolvedThemes:e,resolvedLanguages:t,customExtensionsVersion:i==null?void 0:r,customExtensionMap:i},resolve(){o.initialized=!0,n()},reject:a,requestStart:Date.now()};o.pendingSetupRequestId=s,this.activeTaskById.set(s,c),this.executeTask(o,c)}))}let a=this.options.workerInitializationTimeout??rp,o;try{await Promise.race([Promise.all(n),new Promise((e,t)=>{o=setTimeout(()=>{t(Error(`WorkerPoolManager: worker initialization timed out after ${a}ms`))},a)})])}finally{o!=null&&clearTimeout(o)}}handleWorkerError(e,t){let{onWorkerError:n}=this.options;if(n!=null)try{n(t,e.worker)}catch(e){console.error(`WorkerPoolManager: onWorkerError threw:`,e)}else console.error(`Worker error:`,t,e);let{pendingSetupRequestId:r}=e;if(r==null)return;let i=this.activeTaskById.get(r);if(i?.type!==`initialize`)return;let a=up(t);n!=null&&Yo(a),i.reject(a),this.cleanWorkerAndTask(e,i)}drainQueue=()=>{if(this._queuedDrain=void 0,this.initialized===!0&&this.queuedTasks.length!==0){for(let e=0;e<this.queuedTasks.length;){let t=this.queuedTasks[e];if(this.hasActiveRequest(t)){e++;continue}let n=op(t.request),r=this.getAvailableWorker(n);if(r==null)break;this.queuedTasks.splice(e,1),this.assignWorkerToTask(t,r),this.resolveLanguagesAndExecuteTask(r,t,n)}this.queueBroadcastStateChanges()}};highlightFileAST(e,t){let n=this.getFileResultCache(t);Es(t)||n!=null&&Nr(n.options,this.getFileRenderOptions())||this.hasMatchingFileInstanceTask(e,t)||this.submitTask(e,{type:`file`,file:t})}primeFileHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(Error(`WorkerPoolManager.primeFileHighlightCache: worker pool is not working`));if(!this.shouldPrimeFileHighlightCache(e))return Promise.resolve();if(this.shouldHighlightOnMainThread(e)){let t=this.getFileRenderOptions();return this.primeHighlightCacheOnMainThread(op({type:`file`,file:e}),t.theme,n=>this.setFileResultCache(e.cacheKey,{result:fo(e,n,t),options:t}))}let t=this.getOrCreateFileHighlightCacheTask(e);return t==null?Promise.resolve():this.createRenderTaskCallbacks(t)}shouldPrimeFileHighlightCache(e){if(e.cacheKey==null)return console.warn(`WorkerPoolManager.primeFileHighlightCache: priming highlight cache requires file.cacheKey; skipping "${e.name}".`),!1;let t=this.getFileResultCache(e);return!Es(e)&&(t==null||!Nr(t.options,this.getFileRenderOptions()))}getOrCreateFileHighlightCacheTask(e){let t=this.getFileHighlightKey(e);if(t==null)return;let n=this.getTaskByHighlightKey(t);if(n!=null){if(n.type!==`file`)throw Error(`WorkerPoolManager.getOrCreateFileHighlightCacheTask: Invalid task type`);return n.primeCache=!0,n}{let n=this.submitCacheTask({type:`file`,file:e},t);if(n.type!==`file`)throw Error(`WorkerPoolManager.getOrCreateFileHighlightCacheTask: Invalid task created`);return n}}getPlainFileAST(e,t,n,r){let i=Hr({theme:this.renderOptions.theme});if(i==null)this.queueInitialization();else return fo(e,i,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,lines:r})}highlightDiffAST(e,t){let n=this.getDiffResultCache(t);Pd(t)||n!=null&&Nd(n.options,this.getDiffRenderOptions())||this.hasMatchingDiffInstanceTask(e,t)||this.submitTask(e,{type:`diff`,diff:t})}primeDiffHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(Error(`WorkerPoolManager.primeDiffHighlightCache: worker pool is not working`));if(!this.shouldPrimeDiffHighlightCache(e))return Promise.resolve();if(this.shouldHighlightOnMainThread(e)){let t=this.getDiffRenderOptions();return this.primeHighlightCacheOnMainThread(op({type:`diff`,diff:e}),t.theme,n=>this.setDiffResultCache(e.cacheKey,{result:Lf(e,n,t),options:t}))}let t=this.getOrCreateDiffHighlightCacheTask(e);return t==null?Promise.resolve():this.createRenderTaskCallbacks(t)}shouldPrimeDiffHighlightCache(e){if(e.cacheKey==null)return console.warn(`WorkerPoolManager.primeDiffHighlightCache: priming highlight cache requires diff.cacheKey; skipping "${e.prevName??e.name}" -> "${e.name}".`),!1;let t=this.getDiffResultCache(e);return!Pd(e)&&(t==null||!Nd(t.options,this.getDiffRenderOptions()))}primeHighlightCacheOnMainThread(e,t,n){function r(){let r=Hr({theme:t,langs:e});return r!=null&&n(r)}if(r())return Promise.resolve();let{lifecycleGeneration:i}=this;return this.loadSharedHighlighter(Pi(t),[`text`,...e]).then(()=>{if(!this.isCurrentLifecycle(i))throw new qa;if(!r())throw new br})}getOrCreateDiffHighlightCacheTask(e){let t=this.getDiffHighlightKey(e);if(t==null)return;let n=this.getTaskByHighlightKey(t);if(n!=null){if(n.type!==`diff`)throw Error(`WorkerPoolManager.getOrCreateDiffHighlightCacheTask: Invalid task type`);return n.primeCache=!0,n}{let n=this.submitCacheTask({type:`diff`,diff:e},t);if(n.type!==`diff`)throw Error(`WorkerPoolManager.getOrCreateDiffHighlightCacheTask: Invalid task created`);return n}}getPlainDiffAST(e,t,n,r,i){let a=Hr({theme:this.renderOptions.theme});if(a==null)this.queueInitialization();else return Lf(e,a,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,expandedHunks:r,collapsedContextThreshold:i})}terminate(){this.lifecycleGeneration++,this.cancelActiveWorkerTasks(),this.terminateWorkers();let e=new qa;for(let t of this.queuedTasks)this.rejectRenderTaskCallbacks(t,e);this.fileCache.clear(),this.diffCache.clear(),this.activeRequestByInstance.clear(),this.queuedTasks.length=0,this.queuedTaskByInstance.clear(),this.taskByHighlightKey.clear(),this.activeTaskById.clear(),this.initialized=!1,this.workersFailed=!1,this.terminated=!0,this.queueBroadcastStateChanges()}isCurrentLifecycle(e){return this.lifecycleGeneration===e}queueInitialization(e){this.initialize(e).catch(e=>{No(e)||console.error(e)})}cancelActiveWorkerTasks(){let e=new qa;for(let t of this.activeTaskById.values())`reject`in t?t.reject(e):sp(t)&&this.rejectRenderTaskCallbacks(t,e)}terminateWorkers(){for(let e of this.workers)e.worker.terminate();this.workers.length=0}getStats(){return{managerState:this.initialized===!1?`waiting`:this.initialized===!0?`initialized`:`initializing`,totalWorkers:this.workers.length,workersFailed:this.workersFailed,busyWorkers:this.workers.filter(e=>e.requestId!=null||e.pendingSetupRequestId!=null).length,queuedTasks:this.queuedTasks.length,activeTasks:this.activeTaskById.size,themeSubscribers:this.themeSubscribers.size,fileCacheSize:this.fileCache.size,diffCacheSize:this.diffCache.size}}submitTask(e,t){this.initialized===!1&&this.queueInitialization();let n=this.getHighlightKeyForRequest(t),r=n==null?void 0:this.getTaskByHighlightKey(n);if(r!=null){this.detachInstanceFromQueuedTasks(e,r),this.addInstanceToTask(r,e),this.queueBroadcastStateChanges();return}this.detachInstanceFromQueuedTasks(e);let i=this.generateRequestId(),a=Date.now(),{renderOptionsVersion:o}=this,s=(()=>{switch(t.type){case`file`:return{type:`file`,id:i,request:{...t,id:i},instances:new Set([e]),primeCache:!1,highlightKey:n,callbacks:new Set,renderOptionsVersion:o,requestStart:a};case`diff`:return{type:`diff`,id:i,request:{...t,id:i},instances:new Set([e]),primeCache:!1,highlightKey:n,callbacks:new Set,renderOptionsVersion:o,requestStart:a}}})();this.enqueueRenderTask(s,e)}submitCacheTask(e,t){this.initialized===!1&&this.queueInitialization();let n=this.generateRequestId(),r=Date.now(),{renderOptionsVersion:i}=this,a=(()=>{switch(e.type){case`file`:return{type:`file`,id:n,request:{...e,id:n},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:i,requestStart:r};case`diff`:return{type:`diff`,id:n,request:{...e,id:n},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:i,requestStart:r}}})();return this.enqueueRenderTask(a),a}enqueueRenderTask(e,t){this.queuedTasks.push(e),t!=null&&this.queuedTaskByInstance.set(t,e),e.highlightKey!=null&&this.taskByHighlightKey.set(e.highlightKey,e),this.queueDrain()}async resolveLanguagesAndExecuteTask(e,t,n){try{let r=Hr(),i=n.filter(e=>r==null||!gs(e,r));i.length>0&&this.loadSharedHighlighter(Pi(this.renderOptions.theme),[`text`,...i]).catch(e=>{console.error(e)});let a=this.preferredHighlighter===`highlights`?[]:n.filter(t=>!e.langs.has(t));if(a.length>0&&(Uf(a)?t.request.resolvedLanguages=Hf(a):t.request.resolvedLanguages=await $c(a)),!this.activeTaskById.has(t.id)){e.requestId===t.id&&(this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain());return}this.executeTask(e,t)}catch(n){this.rejectRenderTaskCallbacks(t,lp(n)),this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain()}}handleWorkerMessage(e,t){let n=this.activeTaskById.get(t.id);try{if(n==null)throw np;if(t.type===`error`){let e=Error(t.error);if(t.stack&&(e.stack=t.stack),`reject`in n)n.reject(e);else if(sp(n))this.notifyHighlightError(n,e),this.rejectRenderTaskCallbacks(n,e);else throw Error(`handleWorkerMessage: unknown task type`);throw e}if(sp(n))for(let{name:t}of n.request.resolvedLanguages??[])e.langs.add(t);switch(t.requestType){case`initialize`:if(n.type!==`initialize`)throw Error(`handleWorkerMessage: task/response dont match`);this.syncCustomExtensionVersion(e,n.request),n.resolve();break;case`set-render-options`:if(n.type!==`set-render-options`)throw Error(`handleWorkerMessage: task/response dont match`);n.resolve();break;case`file`:{if(n.type!==`file`)throw Error(`handleWorkerMessage: task/response dont match`);let{options:r}=t;if(!this.isCurrentRenderTask(n)||!Nr(r,this.getFileRenderOptions()))throw np;let{request:i}=n,a={...t.result,code:ep(t.result.code)};this.syncCustomExtensionVersion(e,i),n.cacheKeyAtDispatch!=null&&this.fileCache.set(n.cacheKeyAtDispatch,{result:a,options:r}),this.resolveRenderTaskCallbacks(n),this.notifyFileInstances(n,a,r);break}case`diff`:{if(n.type!==`diff`)throw Error(`handleWorkerMessage: task/response dont match`);let{options:r}=t;if(!this.isCurrentRenderTask(n)||!Nd(r,this.getDiffRenderOptions()))throw np;let{request:i}=n,a={...t.result,code:{deletionLines:ep(t.result.code.deletionLines),additionLines:ep(t.result.code.additionLines)}};this.syncCustomExtensionVersion(e,i),n.cacheKeyAtDispatch!=null&&this.diffCache.set(n.cacheKeyAtDispatch,{result:a,options:r}),this.resolveRenderTaskCallbacks(n),this.notifyDiffInstances(n,a,r);break}}}catch(e){e!==np&&console.error(e,n,t)}this.cleanWorkerAndTask(e,n,t.id),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain()}_queuedDrain;queueDrain(){this._queuedDrain??(this._queuedDrain=Promise.resolve().then(this.drainQueue),this.queueBroadcastStateChanges())}assignWorkerToTask(e,t){t.requestId=e.id,sp(e)&&(this.clearQueuedInstanceRequests(e),this.trackInstanceRequests(e)),this.activeTaskById.set(e.id,e)}cleanWorkerAndTask(e,t,n=t?.id){e.requestId===n&&(e.requestId=void 0),e.pendingSetupRequestId===n&&(e.pendingSetupRequestId=void 0),t!=null&&(sp(t)&&(this.rejectRenderTaskCallbacks(t,new br),this.clearInstanceRequests(t),this.clearHighlightKey(t)),this.activeTaskById.delete(t.id))}executeTask(e,t){ap(t.request)&&this.maybeAttachCustomExtensions(e,t.request),this.activeTaskById.has(t.id)||this.assignWorkerToTask(t,e);try{t.type===`file`?t.cacheKeyAtDispatch=t.request.file.cacheKey:t.type===`diff`&&(t.cacheKeyAtDispatch=t.request.diff.cacheKey),e.worker.postMessage(t.request)}catch(n){console.error(`Failed to post message to worker:`,n),sp(t)?(this.notifyHighlightError(t,n),this.rejectRenderTaskCallbacks(t,lp(n))):`reject`in t&&t.reject(n),this.cleanWorkerAndTask(e,t),this.queuedTasks.length>0&&this.queueDrain()}this.queueBroadcastStateChanges()}maybeAttachCustomExtensions(e,t){if(t.customExtensionsVersion!=null)return;let n=xs();e.customExtensionsVersion>=n||(t.customExtensionsVersion=n,t.customExtensionMap=Pa())}syncCustomExtensionVersion(e,t){t.customExtensionsVersion!=null&&(e.customExtensionsVersion=t.customExtensionsVersion)}getAvailableWorker(e){let t;for(let n of this.workers){if(n.requestId!=null||n.pendingSetupRequestId!=null||!n.initialized)continue;if(t=n,e.length===0)break;let r=!0;for(let t of e)if(!n.langs.has(t)){r=!1;break}if(r)break}return t}getFileHighlightKey(e){if(e.cacheKey!=null)return`file:${e.cacheKey}:${this.renderOptionsVersion}`}getDiffHighlightKey(e){if(e.cacheKey!=null)return`diff:${e.cacheKey}:${this.renderOptionsVersion}`}getHighlightKeyForRequest(e){switch(e.type){case`file`:return this.getFileHighlightKey(e.file);case`diff`:return this.getDiffHighlightKey(e.diff)}}hasActiveRequest(e){for(let t of cp(e))if(this.activeRequestByInstance.has(t))return!0;return!1}addInstanceToTask(e,t){e.type,e.instances.add(t),this.activeTaskById.has(e.id)?this.activeRequestByInstance.set(t,e.id):this.queuedTaskByInstance.set(t,e)}detachInstanceFromQueuedTasks(e,t){let n=this.queuedTaskByInstance.get(e);n!=null&&n!==t&&(this.queuedTaskByInstance.delete(e),this.detachInstanceFromRenderTask(n,e),!n.primeCache&&n.instances.size===0&&this.removeQueuedTask(n))}detachInstanceFromRenderTask(e,t){e.type,e.instances.delete(t)}removeQueuedTask(e){let t=this.queuedTasks.indexOf(e);t!==-1&&this.queuedTasks.splice(t,1),this.rejectRenderTaskCallbacks(e,new br),this.clearQueuedInstanceRequests(e),this.clearHighlightKey(e)}removeActiveTask(e){this.rejectRenderTaskCallbacks(e,new br),this.clearInstanceRequests(e),this.clearHighlightKey(e),this.activeTaskById.delete(e.id)}createRenderTaskCallbacks(e){return new Promise((t,n)=>{e.callbacks.add({resolve:t,reject:n})})}resolveRenderTaskCallbacks(e){for(let t of e.callbacks)t.resolve();e.callbacks.clear()}rejectRenderTaskCallbacks(e,t){for(let n of e.callbacks)n.reject(t);e.callbacks.clear()}invalidateRenderTasks(){for(let e=this.queuedTasks.length-1;e>=0;e--){let t=this.queuedTasks[e];t.renderOptionsVersion!==this.renderOptionsVersion&&this.removeQueuedTask(t)}for(let e of Array.from(this.activeTaskById.values()))sp(e)&&e.renderOptionsVersion!==this.renderOptionsVersion&&this.removeActiveTask(e)}clearQueuedInstanceRequests(e){for(let t of cp(e))this.queuedTaskByInstance.get(t)===e&&this.queuedTaskByInstance.delete(t)}clearHighlightKey(e){e.highlightKey!=null&&this.taskByHighlightKey.get(e.highlightKey)===e&&this.taskByHighlightKey.delete(e.highlightKey)}trackInstanceRequests(e){for(let t of cp(e))this.activeRequestByInstance.set(t,e.id)}clearInstanceRequests(e){for(let t of cp(e))this.activeRequestByInstance.get(t)===e.id&&this.activeRequestByInstance.delete(t)}notifyFileInstances(e,t,n){for(let r of e.instances)this.activeRequestByInstance.get(r)===e.id&&r.onHighlightSuccess(e.request.file,t,n)}notifyDiffInstances(e,t,n){for(let r of e.instances)this.activeRequestByInstance.get(r)===e.id&&r.onHighlightSuccess(e.request.diff,t,n)}notifyHighlightError(e,t){for(let n of cp(e))this.activeRequestByInstance.get(n)===e.id&&n.onHighlightError(t)}hasMatchingFileInstanceTask(e,t){for(let n of this.iterateRenderTasks())if(n.type===`file`&&this.isCurrentRenderTask(n)&&n.instances.has(e)&&Md(t,n.request.file))return!0;return!1}hasMatchingDiffInstanceTask(e,t){for(let n of this.iterateRenderTasks())if(n.type===`diff`&&this.isCurrentRenderTask(n)&&n.instances.has(e)&&jd(n.request.diff,t))return!0;return!1}getTaskByHighlightKey(e){let t=this.taskByHighlightKey.get(e);return t!=null&&this.isCurrentRenderTask(t)?t:void 0}isCurrentRenderTask(e){return e.renderOptionsVersion===this.renderOptionsVersion}*iterateRenderTasks(){for(let e of this.queuedTasks)yield e;for(let e of this.activeTaskById.values())sp(e)&&(yield e)}generateRequestId(){return`req_${++this.nextRequestId}`}};function ap(e){return e.type===`initialize`||e.type===`file`||e.type===`diff`}function op(e){let t=new Set;switch(e.type){case`file`:t.add(e.file.lang??Ki(e.file.name));break;case`diff`:t.add(e.diff.lang??Ki(e.diff.name)),t.add(e.diff.lang??Ki(e.diff.prevName??`-`))}return t.delete(`text`),Array.from(t)}function sp(e){return e?.type===`file`||e?.type===`diff`}function cp(e){return e.instances}function lp(e){if(e instanceof Error)return e;if(typeof e==`object`&&e){if(`error`in e&&e.error instanceof Error)return e.error;if(`message`in e&&typeof e.message==`string`)return Error(e.message)}return Error(String(e))}function up(e){let t=`error`in e?e.error:void 0,n=`message`in e&&typeof e.message==`string`&&e.message!==``?e.message:t instanceof Error?t.message:`the worker script failed to load (the error event carries no message)`;return new ns(`WorkerPoolManager: worker failed: ${n}`,t instanceof Error?{cause:t}:void 0)}function dp(e){if(e.type===`diff`){let{instance:t,item:n}=e;return t.__getNextRenderData({fileDiff:t.fileDiff??n.fileDiff,lineAnnotations:void 0})}let{instance:t,item:n}=e;return t.__getNextRenderData({file:t.file??n.file,lineAnnotations:void 0})}function fp(e,t){return e==null||t==null?e===t:e.header!==t.header||e.footer!==t.footer?!1:pp(e.items,t.items)}function pp(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 mp(e,t,n){let r=document.createElement(`div`);return r.style.display=`flow-root`,e===`header`?(r.setAttribute(bc,``),t.before(r)):(r.setAttribute(Ps,``),t.after(r)),n?.observe(r),r}function hp(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function gp(e){let t=window.devicePixelRatio??1;return Math.round(e*t)/t}async function _p(e,t=300){let n;try{await Promise.race([e(),new Promise(e=>{n=setTimeout(e,t)})])}finally{n!=null&&clearTimeout(n)}}function vp({fileDiff:e,metrics:t,disableFileHeader:n,hunkSeparators:r,expandUnchanged:i,expandedHunks:a,collapsedContextThreshold:o,canHydratePartialDiff:s}){let c=Sa(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=Id({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=Kd({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=yp(i);c+=p.split*t.lineHeight,l+=p.unified*t.lineHeight;let m=n===d?zd({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=qd({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}else if(n===d&&e.isPartial&&s){let e=qd({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}if(e.hunks.length>0){let e=Ii(t);c+=e,l+=e}return{splitHeight:c,unifiedHeight:l}}function yp(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 bp(e,t)}function bp(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 xp({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 Sp(e){return e===``?[]:e.split(Rs)}function Cp(e,t,n,r={}){let i=e===`clone`?Qc(t):t;if(!i.isPartial)throw Error(`hydratePartialDiff: fileDiff must be partial`);switch(i.type){case`change`:case`rename-changed`:return wp(i,Ep(i,n),Dp(i,n),r);case`rename-pure`:{let e=Dp(i,n);Op(i,n);let t=Sp(e.contents);return i.isPartial=!1,i.deletionLines=t,i.additionLines=t,i.deletionCharacterCount=e.contents.length,i.additionCharacterCount=e.contents.length,Ap(i,null,e,r),i}}throw Error(`hydratePartialDiff: ${i.type} diffs cannot be hydrated from loaded files`)}function wp(e,t,n,r){let i=Sp(t.contents),a=Sp(n.contents),{hunks:o,splitLineCount:s,unifiedLineCount:c}=Tp(e.hunks,a.length);return e.hunks=o,e.splitLineCount=s,e.unifiedLineCount=c,e.isPartial=!1,e.deletionLines=i,e.additionLines=a,e.deletionCharacterCount=t.contents.length,e.additionCharacterCount=n.contents.length,Ap(e,t,n,r),e}function Tp(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)e.type===`context`?(p.push({...e,additionLineIndex:s,deletionLineIndex:c}),s+=e.lines,c+=e.lines,d+=e.lines,f+=e.lines):(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(sa(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=Or(t.additionStart,t.additionCount)}if(a.length>0){let e=a[a.length-1],i=Or(e.additionStart,e.additionCount),o=Math.max(t-i,0);n+=o,r+=o}return{hunks:a,splitLineCount:n,unifiedLineCount:r}}function Ep(e,t){if(t.oldFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile`);return t.oldFile}function Dp(e,t){if(t.newFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires newFile`);return t.newFile}function Op(e,t){if(t.oldFile!==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile to be null`)}function kp(e,t,n,r){return e.cacheKey==null?jp(t,n,r):`${e.cacheKey}:hydrated`}function Ap(e,t,n,r){let i=kp(e,t,n,r);i==null?delete e.cacheKey:e.cacheKey=i}function jp(e,t,n){return e!=null&&t!=null?e.cacheKey!=null&&t.cacheKey!=null?ui(n.disableLineMatching===!0?`hydrated-files-raw`:`hydrated-files`,e.cacheKey,t.cacheKey):void 0:e?.cacheKey??t?.cacheKey}var Mp=`/dev/null`;function Np(e,t,{disableLineMatching:n,...r}={},i=!1){if(e===null&&t===null)throw Error(`parseDiffFromFile: You must pass oldFile, newFile, or both`);let a=e??Pp(),o=t??Pp(),s=Mf(a.name,o.name,a.contents,o.contents,a.header,o.header,r),c=mi(s,{cacheKey:(()=>{let r=e?.cacheKey,i=t?.cacheKey;return r!=null&&i!=null?ui(n===!0?`diff-raw`:`diff`,r,i):void 0})(),oldFile:a,newFile:o,disableLineMatching:n,throwOnError:i});if(c==null)throw Error(`parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?`);e===null?(c.type=`new`,c.prevName=void 0):t===null&&(c.type=`deleted`,c.prevName=void 0);let l=t?.lang??(t===null?e?.lang:void 0);return l!=null&&(c.lang=l),c}function Pp(){return{name:Mp,contents:``}}var Fp=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));n==null||t==null?this.cleanUp():(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 Ip(e,t){let n=Np({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,additionCharacterCount:n.additionCharacterCount,deletionCharacterCount:n.deletionCharacterCount,type:n.type}}function Lp(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 Rp(e){for(let t of e)if(t.trim().length>0)return!1;return!0}function zp(e,t){return t.length>0&&t.length<e.deletionLines.length&&Rp(t)}function Bp(e,t,n,r){let i=e.deletionLines.join(``),a=Lp(t.length,i),o=Np({name:e.prevName??e.name,contents:i},{name:e.name,contents:a,lang:e.lang},r);return{hunks:o.hunks,splitLineCount:o.splitLineCount,unifiedLineCount:o.unifiedLineCount,additionLines:t,deletionLines:o.deletionLines,additionCharacterCount:n,deletionCharacterCount:o.deletionCharacterCount,type:o.type}}function Vp(e,t){return Bp(e,[``],0,t)}function Hp(e,t){if(e.additionLines.length===0)return Vp(e,t);if(zp(e,e.additionLines))return Bp(e,e.additionLines,e.additionCharacterCount,t);let n=e.additionLines,r=Ip(e,t);return Wp(r,n),r}function Up(e){return e.length>1&&e.at(-1)===``}function Wp(e,t){if(!Up(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&&Or(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,em(e);return}}}function Gp(e,t,n){if(e.isPartial||e.deletionLines.length!==e.additionLines.length)return Kp(e,Ip(e,n));let r=Array.from(t);if(r.length===0)return Kp(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||Wo(r)===Wo(i))return Kp(e,Ip(e,n))}let i=qp(e,r);if(i.size===0)return Kp(e,Ip(e,n));for(let t of i)if(!Yp(e,t,n))return Kp(e,Ip(e,n));return em(e),Ld(e)?Kp(e,Ip(e,n)):Kp(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type})}function Kp(e,t){return Object.assign(e,t),t}function qp(e,t){let n=new Set;for(let r of t){let t=Jp(e,r);if(t==null)return new Set;n.add(t)}return n}function Jp(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 Yp(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=Np({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:(Zp(r,s),Xp(e,t),!0)}function Xp(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(`
|
|
29
|
+
`),n.noEOFCRDeletions=i!=null&&i!==``&&!i.endsWith(`
|
|
30
|
+
`)}function Zp(e,t){let n=e.additionLineIndex,r=e.deletionLineIndex;e.hunkContent=t.hunkContent.map(e=>Qp(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,$p(e)}function Qp(e,t,n){return{...e,additionLineIndex:e.additionLineIndex+t,deletionLineIndex:e.deletionLineIndex+n}}function $p(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 em(e){let t=0,n=0,r=0;for(let i of e.hunks)i.collapsedBefore=Math.max(sa(i.additionStart,i.additionCount)-r,0),i.splitLineStart=t+i.collapsedBefore,i.unifiedLineStart=n+i.collapsedBefore,$p(i),t+=i.collapsedBefore+i.splitLineCount,n+=i.collapsedBefore+i.unifiedLineCount,r=Or(i.additionStart,i.additionCount);if(e.hunks.length>0){let r=e.hunks[e.hunks.length-1],i=Math.max(e.additionLines.length-Or(r.additionStart,r.additionCount),0);t+=i,n+=i}e.splitLineCount=t,e.unifiedLineCount=n}var tm=new WeakMap;function nm(e){return e.length>1&&e[e.length-1]===``?e.slice(0,-1):e}function rm(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 im(e,t,n){let r=e.hunks,i=e.additionLines,a=nm(i),o=a===i?e:{...e,additionLines:a},s=hm(r,pm(o,t,n),e.deletionLines.length),c=vm(o,s);if(e.additionLines=a,e.hunks=c,e.editSessionDirty=!0,Om(e),Wp(e,i),xm(r,e.hunks))return{regions:s.map(e=>e.previousSpan)}}function am(e,t,n,r){let i=new Set(t),a=Array.from(i).filter(t=>t>=0&&t<e.additionLines.length).sort((e,t)=>e-t);if(a.length===0)return;let o=t=>i.has(t)?r?.get(t):e.additionLines[t],{hunks:s}=e,c,l=0;for(let t of a){for(;l<s.length;){let e=s[l];if(t<wm(e)+e.additionCount)break;l++}let r=s[l],i=r==null?void 0:wm(r);if(i==null||t<i||c!=null&&c!==l)return im(e,n,o);c=l}if(c!=null){if(om(e,a,c,r,n))e.editSessionDirty=!0;else return im(e,n,o)}}function om(e,t,n,r,i){if(r==null||i?.ignoreWhitespace===!0||i?.stripTrailingCr===!0)return!1;let a=sm(e),o=e.hunks[n];if(o.hunkContent.some(cm))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 sm(e){let t=tm.get(e);if(t?.lines===e.deletionLines)return t.set;let n=new Set(e.deletionLines);return tm.set(e,{lines:e.deletionLines,set:n}),n}function cm(e){return e?.type===`change`&&(e.additions===0||e.deletions===0)}function lm(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 um(e,t,n){let r=[];if(e.isPartial)return r;for(let[i,a]of e.hunks.entries()){let o=Id({isPartial:e.isPartial,rangeSize:a.collapsedBefore,expandedHunks:t,hunkIndex:i,collapsedContextThreshold:n});if(o.rangeSize<=n)continue;let s=Tm(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=zd({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=Tm(t)+t.deletionCount;r.push([n,n+i.fromStart])}return r}function dm(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=Tm(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,Tm(i)+i.deletionCount,e.deletionLines.length),n}function fm(e,t){return e.editSessionDirty===!0&&(delete e.editSessionDirty,Object.assign(e,e.additionLines.length<=1&&e.additionLines.join(``)===``?Ip(e,t):Hp(e,t)),!0)}function pm(e,t,n){if(rm(e.deletionLines,e.additionLines)==null)return[];let r=Np({name:e.prevName??e.name,contents:e.deletionLines.join(``)},{name:e.name,contents:e.additionLines.join(``),lang:e.lang},t),i,a=(t,a)=>{i??=mm(e.hunks);for(let e=0;e<=a;e++){let o=i.get(t.deletionLineIndex-e);if(o!=null&&o.additions===t.additions&&o.deletions===t.deletions){if(t.additions>0&&n!=null){for(let e=0;e<t.additions;e++)if(n(o.additionLineIndex+e)!==r.additionLines[t.additionLineIndex+e])return a}return e}}return a},o=[],s=0,c=0;for(let e of r.hunks){Ko(e,r,a);let t=e.additionCount>0?e.additionLineIndex-s:e.deletionLineIndex-c;s+=t,c+=t;for(let t of e.hunkContent){if(t.type===`context`){s+=t.lines,c+=t.lines;continue}let e=Qp(t,0,0);e.additions===0&&(e.additionLineIndex=s),e.deletions===0&&(e.deletionLineIndex=c),o.push(e),s+=e.additions,c+=e.deletions}}return o}function mm(e){let t=new Map;for(let n of e)for(let e of n.hunkContent)e.type===`change`&&(e.additions===0||e.deletions===0)&&t.set(e.deletionLineIndex,e);return t}function hm(e,t,n){let r=e.map((e,t)=>{let n=Tm(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&&gm(t,o,i[i.length-1])?i.pop():void 0;for(;a<r.length&&r[a].deletionStart<=o;)s=_m(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 gm(e,t,n){return e<=n.deletionEnd&&t>=n.deletionStart}function _m(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 vm(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`);bm(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`);bm(s,c,i,r),r+=c,i+=c,n.push(ym(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 ym(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:Em(t.additionStart,r),additionCount:r,additionLines:a,additionLineIndex:Dm(t.additionStart,r),deletionStart:Em(t.deletionStart,i),deletionCount:i,deletionLines:o,deletionLineIndex:Dm(t.deletionStart,i),hunkContent:n,hunkSpecs:`@@ -${Em(t.deletionStart,i)},${i} +${Em(t.additionStart,r)},${r} @@`,splitLineStart:0,splitLineCount:0,unifiedLineStart:0,unifiedLineCount:0,noEOFCRAdditions:!1,noEOFCRDeletions:!1};return $p(s),s}function bm(e,t,n,r){t>0&&e.push({type:`context`,lines:t,additionLineIndex:n,deletionLineIndex:r})}function xm(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(Tm(r)!==Tm(i)||r.deletionCount!==i.deletionCount||wm(r)!==wm(i)||r.additionCount!==i.additionCount||r.splitLineCount!==i.splitLineCount||!Sm(r,i))return!0}return!1}function Sm(e,t){let n=Cm(e),r=Cm(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*Cm(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 wm(e){return sa(e.additionStart,e.additionCount)}function Tm(e){return sa(e.deletionStart,e.deletionCount)}function Em(e,t){return t===0?e:e+1}function Dm(e,t){return t===0?e-1:e}function Om(e){em(e);for(let t=0;t<e.hunks.length;t++)Xp(e,t)}function km(e){return ss({tagName:`div`,properties:{"data-content-buffer":``,"data-buffer-size":e,style:`grid-row: span ${e};min-height:calc(${e} * 1lh)`}})}function Am(e){return ss({tagName:`div`,children:[ss({tagName:`span`,children:[Qa(`No newline at end of file`)]})],properties:{"data-no-newline":``,"data-line-type":e,"data-column-content":``}})}function jm(e){return ss({tagName:`div`,children:[Wa({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 Mm({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(ss({tagName:`div`,children:[Qa(t)],properties:{"data-separator-wrapper":``}})),(e===`line-info`||e===`line-info-basic`)&&t!=null){let e=[];n!=null&&(r?(a||(e.push(jm(`up`)),s++),o||(e.push(jm(`down`)),s++)):(e.push(jm(!a&&!o?`both`:a?`down`:`up`)),s++)),e.push(ss({tagName:`div`,children:[ss({tagName:`span`,children:[Qa(t)],properties:{"data-unmodified-lines":``}})],properties:{"data-separator-content":``}})),r&&n!=null&&e.push(ss({tagName:`div`,children:[Qa(`Expand all`)],properties:{role:`button`,"data-expand-button":``,"data-expand-all-button":``}})),c.push(ss({tagName:`div`,children:e,properties:{"data-separator-wrapper":``,"data-separator-multi-button":s>1?``:void 0}}))}return e===`custom`&&i!=null&&c.push(ss({tagName:`slot`,properties:{name:i}})),ss({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 Nm(e,t){return`hunk-separator-${e}-${t}`}function Pm(e){let t=e.at(-1);return t==null?0:Math.max(Or(t.additionStart,t.additionCount),Or(t.deletionStart,t.deletionCount))}var Fm=-1,Im=class{options;annotationSlotName;onRenderUpdate;workerManager;__id=`diff-hunks-renderer:${++Fm}`;diff;expandedHunks=new Map;deletionAnnotations={};additionAnnotations={};computedLangs=[`text`];renderCache;pendingHighlightResult;pendingStructuralRows;editSessionActive=!1;constructor(e={theme:gc},t=ti,n,r){this.options=e,this.annotationSlotName=t,this.onRenderUpdate=n,this.workerManager=r}cleanUp(){this.endEditSession(),this.recycle(),this.expandedHunks.clear(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.diff=void 0,this.editSessionActive?(this.renderCache!=null&&(this.renderCache.renderRange=void 0),this.pendingHighlightResult=void 0,this.pendingStructuralRows=void 0):this.clearRenderCache(),this.additionAnnotations={},this.deletionAnnotations={},this.workerManager?.cleanUpTasks(this)}beginEditSession(e,t){let{editSessionActive:n}=this;this.editSessionActive=!0,n||(this.pendingHighlightResult=void 0),this.diff=e,n&&this.renderCache!=null&&this.renderCache.diff!==e&&this.clearRenderCache();let{renderCache:r}=this;if(!e.isPartial&&e.additionLines.length===0){Object.assign(e,Vp(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&&jd(r.diff,t),{result:s}=r;!r.highlighted||s==null||!Nd(r.options,i)||!a&&!o?this.clearRenderCache():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,this.diff??this.clearRenderCache()}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||!jd(t.diff,e)||Pd(e)||Xm(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=>{No(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||!jd(n,e)||!jd(r.diff,e)||this.editSessionActive)return;let{options:i}=this.getRenderOptions(n);Nd(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)??fc}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,r,i){this.pendingStructuralRows=void 0;let{renderCache:a}=this;if(a==null)return!1;let{result:o,diff:s}=a;if(o==null)return!1;if(s.isPartial)throw Error(`Could not update render cache for partial diff`);let c=o.code.additionLines,l=this.pendingStructuralRows=n?new Map:void 0,u=[],d=new Map;if(l==null&&r!=null){let t=s.additionLines.length,n=Km(s.additionLines,i);for(let[i,a]of r){if(i<0||i>t||i===t&&(a===``||!n))continue;let r=s.additionLines[i]??``;r!==a&&(s.additionLines[i]=a,s.additionCharacterCount+=a.length-r.length,u.push(i),d.set(i,r),e.has(i)||(c[i]=qm(i,Wo(a))))}}for(let[t,n]of e){let e=c[t]?.properties??{},i=n.map(e=>e[2]).join(``),a=t<s.additionLines.length,o=a?s.additionLines[t]??``:``,f=Wo(o);if(l==null&&a&&r?.has(t)!==!0){let e=Gi(o,i);s.additionLines[t]=e,s.additionCharacterCount+=e.length-o.length,f!==i&&(u.push(t),d.set(t,o))}let p={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}]})};l==null?c[t]=p:l.set(t,p)}let f=!1;if(u.length>0){if(this.editSessionActive){if(s.additionLines.length<=1&&s.additionLines.join(``)===``)this.applyRecomputePreservingSessionType(s,Vp(s,this.options.parseDiffOptions)),f=!0;else if(zp(s,s.additionLines))this.applyRecomputePreservingSessionType(s,Bp(s,s.additionLines,s.additionCharacterCount,this.options.parseDiffOptions)),f=!0;else{let e=am(s,u,this.options.parseDiffOptions,d);this.applyExpansionRemap(e),f=e!=null}}else Object.assign(s,Gp(s,u,this.options.parseDiffOptions))}return o.baseThemeType=t,a.isDirty=!0,f}applyExpansionRemap(e){e!=null&&(this.expandedHunks=lm(this.expandedHunks,e))}applyDocumentChange(e){let{pendingStructuralRows:t,renderCache:n}=this;this.pendingStructuralRows=void 0;let r=this.diff??n?.diff;if(r==null)return;let i=n?.result;if(r.isPartial)throw Error(`Could not apply document change for partial diff`);let{additionLines:a}=r,{lines:o,characterCount:s}=Jm(e);if(r.additionLines=o,r.additionCharacterCount=s,i!=null&&(i.code.additionLines=Gm(a,r.additionLines,i.code.additionLines,e)),r.additionLines.length<=1&&r.additionLines.join(``)===``?(this.applyRecomputePreservingSessionType(r,Vp(r,this.options.parseDiffOptions)),i!=null&&(i.code.additionLines[0]=qm(0,e.getLineText(0)))):this.editSessionActive?this.applySessionDocumentChange(r,a):Object.assign(r,Hp(r,this.options.parseDiffOptions)),t!=null&&i!=null)for(let[e,n]of t)e<i.code.additionLines.length&&(i.code.additionLines[e]=n);n!=null&&(n.isDirty=!0)}applySessionDocumentChange(e,t){let{parseDiffOptions:n}=this.options,r=e.additionLines;zp(e,r)?this.applyRecomputePreservingSessionType(e,Bp(e,r,e.additionCharacterCount,n)):this.applyExpansionRemap(im(e,n,e=>t[e]))}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=>bs(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=gc,headerRenderMode:g=`default`,tokenizeMaxLineLength:_=1e3,tokenizeMaxLength:v=Oc,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}}initializeHighlighter(){return Lr(Ea(this.computedLangs,{theme:this.getLocalHighlightTheme(),preferredHighlighter:Kr(this.workerManager,this.options)}))}hydrate(e){if(e==null)return;this.diff=e;let{options:t}=this.getRenderOptions(e),n=Xm(e,this.getTokenizeMaxLength()),r=this.workerManager?.getDiffResultCache(e);r!=null&&!Nd(t,r.options)&&(r=void 0),this.renderCache??={diff:e,hydrated:!0,highlighted:!n&&!Pd(e),options:t,result:n?void 0:r?.result,renderRange:void 0};let i=this.getHighlightWorkerManager(e);i==null?Hr({theme:this.getLocalHighlightTheme()})??(this.computedLangs=Ym(e),this.initializeHighlighter().catch(e=>{e instanceof qr||this.onHighlightError(e)})):this.renderCache.result==null&&!n&&i.highlightDiffAST(this,this.diff)}getHighlightWorkerManager(e){let{editSessionActive:t,workerManager:n}=this;return!t&&n?.isWorkingPool()===!0&&!n.shouldHighlightOnMainThread(e)?n:void 0}cacheHighlightResult(e,t){let{editSessionActive:n,workerManager:r}=this;!n&&r?.isWorkingPool()===!0&&r.setDiffResultCache(e.cacheKey,t)}getLocalHighlightTheme(){return this.workerManager?.getDiffRenderOptions().theme??this.options.theme??gc}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||!jd(e,n.diff)||!Nd(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(jd(this.renderCache.diff,e))return this.renderCache.diff;let n=!(e.additionLines.length>0||e.deletionLines.length>0)||Pd(e)||Xm(e,this.getTokenizeMaxLength());return this.canRenderDiff(e,t,n)?e:this.renderCache.diff}canRenderDiff(e,t,n){let{renderCache:r}=this;return r==null||jd(r.diff,e)?!0:n?r.result==null&&r.hydrated!==!0||this.workerManager?.isWorkingPool()===!0&&!this.workerManager.shouldHighlightOnMainThread(e)||Hr({theme:t.theme})!=null:r.result==null&&r.hydrated!==!0?!0:this.getHighlightWorkerManager(e)==null?Hr({theme:t.theme})!=null:!r.highlighted}renderDiff(e=this.diff,t=Nc){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||Pd(e)||Xm(e,this.getTokenizeMaxLength()),l=this.canRenderDiff(e,i,c),u=!jd(e,this.renderCache.diff),d=!Mr(this.renderCache.renderRange,t),f=this.getHighlightWorkerManager(e);if(f!=null){let o=this.renderCache.result==null&&this.renderCache.highlighted&&!c&&!u&&no(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=f.getPlainDiffAST(e,t.startingLine,t.totalLines,no(t)||n?!0:this.expandedHunks,r)),this.renderCache.renderRange=t),!c&&s&&(!this.renderCache.highlighted||a)&&f.highlightDiffAST(this,e)}else{this.computedLangs=Ym(e);let n=Hr(),r=n!=null&&bo(i.theme,n),o=n!=null&&gs(this.computedLangs,n),s=!c&&o,u=Number.isFinite(t.totalLines);if(l&&n!=null&&r&&(a||c||!this.renderCache.highlighted&&s||this.renderCache.result==null)){let{result:t,options:r}=this.renderDiffWithHighlighter(e,n,c||!o,u);this.renderCache={diff:e,options:r,highlighted:s,result:t,renderRange:void 0},s&&this.cacheHighlightResult(e,{result:t,options:r})}r&&(c||o)||this.asyncHighlight(e,u).then(({result:t,options:n})=>{c||this.cacheHighlightResult(e,{result:t,options:n}),this.applyHighlightResult(e,t,n,!c)}).catch(e=>{e instanceof qr||this.onHighlightError(e)})}return this.renderCache.result==null?void 0:this.processDiffResult(this.renderCache.diff,t,this.renderCache.result)}async asyncRender(e,t=Nc){this.diff=e;let{result:n}=await this.asyncHighlight(e,Number.isFinite(t.totalLines));return this.processDiffResult(e,t,n)}createPreElement(e,t,n){let{diffIndicators:r,disableBackground:i,disableLineNumbers:a,overflow:o}=this.getOptionsWithDefaults();return ds({type:`diff`,diffIndicators:r,disableBackground:i,disableLineNumbers:a,overflow:o,split:e,totalLines:t,customProperties:n})}async asyncHighlight(e,t=!1){let n=Xm(e,this.getTokenizeMaxLength());this.computedLangs=n?[`text`]:Ym(e);let r=Hr(),i=r!=null&&bo(this.getLocalHighlightTheme(),r),a=n||r!=null&&gs(this.computedLangs,r);return r!=null&&i&&a||(r=await this.initializeHighlighter()),this.renderDiffWithHighlighter(e,r,n,t)}renderDiffWithHighlighter(e,t,n=!1,r=!1){let{options:i}=this.getRenderOptions(e),{collapsedContextThreshold:a}=this.getOptionsWithDefaults(),o=Lf(e,t,i,{forcePlainText:n,lazyLineAST:r,expandedHunks:n?!0:void 0,collapsedContextThreshold:a});if(this.editSessionActive&&e.additionLines.length===1&&e.additionLines[0]===``&&o.code.additionLines[0]==null){let t;if(Jd({diff:e,diffStyle:`both`,expandedHunks:n?!0:void 0,collapsedContextThreshold:a,callback:({additionLine:e})=>{if(e?.lineIndex===0)return t=e,!0}}),t==null)throw Error(`DiffHunksRenderer: missing empty addition line`);o.code.additionLines[0]=qm(0,``,t.unifiedLineIndex,t.splitLineIndex)}return{result:o,options:i}}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&&jd(i,e)&&Nd(n,this.getRenderOptions(i).options)&&(a.result!=null&&a.highlighted&&Nd(a.options,n)&&jd(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&&Nd(t,n.options))return n}getReadyRenderResult(e,t){let{pendingHighlightResult:n}=this;if(n!=null&&jd(n.diff,e)&&Nd(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&&jd(e,n.diff)&&Nd(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=Zm(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:To(),deletionsGutterAST:To(),additionsGutterAST:To(),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=Rd({fileDiff:e,errorPrefix:`DiffHunksRenderer.processDiffResult`}),C={size:0,side:void 0,increment(){this.size+=1},flush(){a!==`unified`&&(this.size<=0||this.side==null?(this.side=void 0,this.size=0):(this.side===`additions`?(x.pushToGutter(`additions`,$o(void 0,`buffer`,this.size)),h?.push(km(this.size))):(x.pushToGutter(`deletions`,$o(void 0,`buffer`,this.size)),g?.push(km(this.size))),this.size=0,this.side=void 0))}},w=(e,t,n,r,i)=>{x.pushToGutter(e,za(t,n,r,i))};function T(e){C.flush(),a===`unified`?Hm(`unified`,e,x):(Hm(`deletions`,e,x),Hm(`additions`,e,x))}this.pushFileLevelAnnotations(e,a,t,x),Jd({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,h=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 g=a===`unified`?h:l,_={type:c,hunkIndex:t,lineIndex:g,unifiedLineIndex:h,splitLineIndex:l,deletionLine:s,additionLine:o};if(a===`unified`){let n=this.getUnifiedInjectedRowsForLine?.(_);n?.before!=null&&zm(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,`${h},${l}`,u.gutterProperties),i==null?r!=null&&(r=Um(r,u.contentProperties,d&&s!=null?{"data-line":s.lineNumber,"data-line-index":`${h},${l}`}:void 0)):i=Um(i,u.contentProperties,d&&o!=null?{"data-line":o.lineNumber,"data-line-index":`${h},${l}`}:void 0),Vm({diffStyle:`unified`,type:c,deletionLine:r,additionLine:i,unifiedSpan:this.getAnnotations(`unified`,s?.lineNumber,o?.lineNumber,t,g),createAnnotationElement:e=>this.createAnnotationElement(e),context:x}),n?.after!=null&&zm(n.after,x)}else{let n=this.getSplitInjectedRowsForLine?.(_);n?.before!=null&&Bm(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,g);if(p!=null&&C.size>0&&C.flush(),s!=null){let e=Um(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=Um(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)}Vm({diffStyle:`split`,type:c,additionLine:i,deletionLine:r,...p,createAnnotationElement:e=>this.createAnnotationElement(e),context:x}),n?.after!=null&&Bm(n.after,x,C)}let v=a===`split`&&n!=null&&l===n.splitLineStart+n.splitLineCount-1,E=t===e.hunks.length-1&&n!=null&&(a===`split`?l===n.splitLineStart+n.splitLineCount-1:h===n.unifiedLineStart+n.unifiedLineCount-1),D=v?n.noEOFCRDeletions:!1,O=v?n.noEOFCRAdditions:!1,k=(s?.noEOFCR??!1)||D,A=(o?.noEOFCR??!1)||O;if(A||k){if(a===`split`&&C.flush(),k){let e=c===`context`||c===`context-expanded`?c:`change-deletion`;a===`unified`?(x.unifiedContentAST.push(Am(e)),x.pushToGutter(`unified`,$o(e,`metadata`,1))):(x.deletionsContentAST.push(Am(e)),x.pushToGutter(`deletions`,$o(e,`metadata`,1)),A||(x.pushToGutter(`additions`,$o(void 0,`buffer`,1)),x.additionsContentAST.push(km(1))))}if(A&&!(f&&k&&c!==`change`)){let e=c===`context`||c===`context-expanded`?c:`change-addition`;a===`unified`?(x.unifiedContentAST.push(Am(e)),x.pushToGutter(`unified`,$o(e,`metadata`,1))):(x.additionsContentAST.push(Am(e)),x.pushToGutter(`additions`,$o(e,`metadata`,1)),k||(x.pushToGutter(`deletions`,$o(void 0,`buffer`,1)),x.deletionsContentAST.push(km(1))))}x.incrementRowCount(1)}u!==`simple`&&u!==`metadata`&&(i>0||E&&p)&&T({hunkIndex:c===`context-expanded`?t:t+1,collapsedLines:E&&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(Pm(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=To(n);return i.properties.style=`grid-row: span ${t.rowCount}`,[i,Na(r,t.rowCount)]}renderFullAST(e,t=[]){let n=this.getOptionsWithDefaults().hunkSeparators===`line-info`,r=this.renderCodeAST(`unified`,e);if(r!=null)return t.push(ss({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(ss({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(ss({tagName:`code`,children:a,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-additions":``}})),{...e.preNode,children:t}}renderFullHTML(e,t=[]){return Oi(this.renderFullAST(e,t))}renderPartialHTML(e,t){return Oi(t==null?e:ss({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(!wi(n))return;let i=e.type===`new`?[]:this.getAnnotationNames(go(this.deletionAnnotations)),a=e.type===`deleted`?[]:this.getAnnotationNames(go(this.additionAnnotations));if(i.length===0&&a.length===0)return;let{createAnnotationElement:o}=this;Vm(t===`unified`?{diffStyle:t,type:`context`,unifiedSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:i.concat(a)},createAnnotationElement:o,context:r}:{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 Ts({fileOrDiff:e,mode:t,stickyHeader:n})}},Lm=new Intl.PluralRules(`en-US`);function Rm(e){return`${e} unmodified line${Lm.select(e)===`one`?``:`s`}`}function zm(e,t){for(let n of e)t.unifiedContentAST.push(n.content),t.pushToGutter(`unified`,n.gutter),t.incrementRowCount(1)}function Bm(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 Vm({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`,$o(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`,$o(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`,$o(e,`annotation`,1)),l=!0}}l&&c.incrementRowCount(1)}function Hm(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,Mm({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),l.push(Mm({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1));return}if(c.hunkSeparators===`simple`){t>0&&(c.pushToGutter(e,Mm({type:`simple`,isFirstHunk:a,isLastHunk:!1})),l.push(Mm({type:`simple`,isFirstHunk:a,isLastHunk:!1})),e!==`additions`&&c.incrementRowCount(1));return}let u=Nm(e,t),d=r>c.expansionLineCount,f=s?t:void 0,p=typeof n==`number`?Rm(n):`More unchanged context may be available`;c.pushToGutter(e,Mm({type:c.hunkSeparators,content:p,expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),l.push(Mm({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 Um(e,t,n){return e==null||e.type!==`element`||t==null&&n==null?e:{...e,properties:{...e.properties,...t,...n}}}function Wm(e){return e.length>0&&e[e.length-1]===``?e.length-1:e.length}function Gm(e,t,n,r){let i=Wm(e),a=Wm(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]??=qm(e,r.getLineText(e));return l}function Km(e,t){return t===e.length+1&&e.at(-1)?.endsWith(`
|
|
31
|
+
`)===!0}function qm(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 Jm(e){let t=[],n=0;for(let r=0;r<e.lineCount;r++){let i=e.getLineText(r,!0);t.push(i),n+=i.length}return{lines:t,characterCount:n}}function Ym(e){if(e.lang!=null)return[e.lang];let t=Ki(e.prevName??e.name),n=Ki(e.name);return t===n?[n]:[t,n]}function Xm(e,t){return Math.max(e.additionLines.length,e.deletionLines.length)>t}function Zm(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function Qm(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function $m(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 eh(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:ts(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,parseDiffOptions:e?.parseDiffOptions,collapsedContextThreshold:e?.collapsedContextThreshold,lineDiffType:e?.lineDiffType,maxLineDiffLength:e?.maxLineDiffLength,expansionLineCount:e?.expansionLineCount,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}function th(e){return e.isPartial&&(e.type===`change`||e.type===`rename-changed`||e.type===`rename-pure`)}function nh(e){let t={...e};return delete t.cacheKey,t}function rh(e,t){if(e.isPartial||t.isPartial)throw Error(`FileDiff.shouldResetEditorForExternalDiff: diffs must be fully hydrated`);let n=e.lang??Ki(e.name),r=t.lang??Ki(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 ih(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function ah(e,t){let{oldFile:n}=e;return n==null?t.type===`new`:t.type!==`new`&&n.name===(t.prevName??t.name)&&ih(n.lines,t.deletionLines)}var oh=-1,sh=class{options;workerManager;requestOwnerRender;static LoadedCustomComponent=!0;__id=`file-diff:${++oh}`;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;get lineAnnotations(){return this.renderedData?.lineAnnotations??Tc}managersDirty=!1;deletionFile;additionFile;fileDiff;editSession;renderedData;pendingData;forceRenderOverride;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:gc},t,n){this.options=e,this.workerManager=t,this.requestOwnerRender=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new hs,this.scrollSyncManager=new Fp,this.interactionManager=new Xi(`diff`,Vr(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??gc}getHunksRendererOptions(e){return eh(e)}createHunksRenderer(e){return new Im(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=sa(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}}else{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(Vr(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&&!Zi(this.appliedThemeCSS.theme,this.getTheme())}getHoveredLine=()=>this.interactionManager.getHoveredLine();getAnnotationSlotName=e=>Jo(this.editSession?.annotations,e,ti);getLatestAnnotations(){return this.pendingData?.lineAnnotations??this.editSession?.annotations?.current??this.lineAnnotations}getAnnotationsForDiff(e){let{pendingData:t}=this;return t!=null&&jd(e,t.fileDiff)?t.lineAnnotations:this.lineAnnotations}isNewAnnotations(e){let t=this.editSession?.annotations;return e===this.getLatestAnnotations()?!1:t==null||e!==t.provided&&e!==t.current}setLineAnnotations(e){let t=this.editSession?.annotations;if(t!=null){if(!this.isNewAnnotations(e))return;uo(t,e,ti)}let n=this.getWorkingDiff();n!=null&&(this.pendingData={fileDiff:n,lineAnnotations:e})}syncEditSessionAnnotationsFromEditor(e){let t=this.editSession?.annotations;return t==null||e===t.current?!1:(t.current=e,this.renderedData!=null&&(this.renderedData.lineAnnotations=e),this.pendingData=void 0,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.lineAnnotations.length>0||this.pre?.hasAttribute(`data-has-merge-conflict`)===!0)}getCodeScrollLeft(){return Math.max(this.codeUnified?.scrollLeft??0,this.codeDeletions?.scrollLeft??0,this.codeAdditions?.scrollLeft??0)}setCodeScrollLeft(e){this.codeUnified!=null&&(this.codeUnified.scrollLeft=e),this.codeAdditions!=null&&(this.codeAdditions.scrollLeft=e),this.codeDeletions!=null&&(this.codeDeletions.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.hunksRenderer.getEffectiveCodeOptions()}}cleanUp(e=!1){let{editor:t}=this;oa(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.isComponentManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.renderedData=void 0,this.pendingData=void 0),this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre?.remove(),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?.remove(),this.headerElement=void 0,this.clearHeaderSlots(),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.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=xp(a,`FileDiff.hydrate`),s=o?.oldFile,c=o?.newFile;this.hydrateElements(e,t);let l=this.editor!=null;l||fh(this.pre,uh({fileDiff:i,oldFile:s,newFile:c}),this.options.collapsed)||ph(this.headerElement,dh({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),Ca(e,t);for(let t of e.shadowRoot?.children??[])if(t instanceof SVGElement)this.spriteSVG=t;else 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))}else`diffsHeader`in t.dataset?this.headerElement=t:t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)?this.themeCSSStyle=t:t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent)}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}){let i=r??this.getLatestAnnotations();this.pendingData=void 0,this.additionFile=n,this.deletionFile=t,this.fileDiff=e??(t!==void 0&&n!==void 0?Np(t,n,this.options.parseDiffOptions):void 0),this.renderedData=this.fileDiff==null?void 0:{fileDiff:this.fileDiff,lineAnnotations:i},this.fileDiff!=null&&this.adoptRenderData(this.fileDiff),this.pre!=null&&(this.syncInteractionOptions(),this.hunksRenderer.hydrate(this.fileDiff),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}rerender(){!this.enabled||this.getInputDiff()==null&&this.additionFile==null&&this.deletionFile==null||this.requestRender()||this.render({forceRender:!0,renderRange:this.renderRange})}requestRender(){let{requestOwnerRender:e}=this;return this.editSession!=null||e==null?!1:(this.forceRenderOverride=!0,e(),!0)}get isComponentManaged(){return this.requestOwnerRender!=null}onThemeChange(){this.hunksRenderer.clearRenderCache(),this.rerender()}handleExpandHunk=(e,t,n)=>{this.expandHunk(e,t,n)};expandHunk=(e,t,n)=>{this.loadFilesIfNecessary(),this.hunksRenderer.expandHunk(e,t,n),this.rerender()};loadFilesIfNecessary(){let e=this.getInputDiff(),{loadDiffFiles:t}=this.options;if(e==null||!th(e)||this.pendingFiles?.fileDiff===e)return;if(t==null)throw Error(`FileDiff: loadDiffFiles is required to load full files for a partial diff`);let n=this.loadFilesForDiff(e,t),r=this.pendingFiles={fileDiff:e,promise:n};r.promise=n.finally(()=>{this.pendingFiles===r&&(this.pendingFiles=void 0)})}__canAttachEditor(){let e=this.getInputDiff();return e!=null&&!e.isPartial}async prepareForEditing(){if(this.__canAttachEditor())return;let e=this.__prepareForEditing();if(e==null){let e=this.getInputDiff();throw e?.isPartial===!0&&!th(e)?Error(`FileDiff.prepareForEditing: this partial diff cannot be hydrated; provide a complete diff`):Error(`FileDiff.prepareForEditing: a partial diff requires loadDiffFiles`)}if(await e,!this.__canAttachEditor())throw Error(`FileDiff.prepareForEditing: the diff did not finish loading`)}__prepareForEditing(){if(this.__canAttachEditor())return;let e=this.getInputDiff();if(e?.isPartial===!0&&!th(e))throw Error(`FileDiff: this partial diff cannot be hydrated; provide a complete diff to edit`);return this.loadFilesIfNecessary(),this.pendingFiles?.promise}async loadFilesForDiff(e,t){try{let n=await t(e);if(this.getInputDiff()!==e)return;await this.handleFilesLoaded(e,n)}catch(e){if(this.options.disableErrorHandling===!0)throw e;console.error(e)}}async handleFilesLoaded(e,t){this.getInputDiff()===e&&e.isPartial&&(Cp(`merge`,e,t,this.options.parseDiffOptions),this.setHydratedState(t),this.installHydratedSessionDiff(e)?this.rerender():(await _p(()=>this.primeHighlightCache(e)),this.enabled&&this.getInputDiff()===e&&this.rerender()))}installHydratedSessionDiff(e){if(e.isPartial)throw Error(`FileDiff.installHydratedSessionDiff: diffs cannot be partial for editing`);return this.getInputDiff()===e&&this.editSession?.outgoingDiff!=null&&(this.installEditSession(e),!0)}updateInputDiff(e,t){if(jd(this.getInputDiff(),e))return!1;let n=this.getLatestAnnotations();this.fileDiff=e;let{editSession:r}=this,i=r?.outgoingDiff??r?.diff;return r!=null&&(e.isPartial?r.inputDiff=e:this.installEditSession(e),this.editSession!=null&&(this.editSession.outgoingDiff=i)),this.editSession?.annotations!=null&&t!=null&&(this.editSession.annotations=Mo(t,ti,this.editSession.annotations)),this.pendingData={fileDiff:this.editSession?.diff??e,lineAnnotations:this.editSession?.annotations?.current??t??n},i!=null&&e.isPartial&&this.loadFilesIfNecessary(),!0}installEditSession(e,t,n){let r=e.additionLines.join(``),i=t==null?void 0:Sp(t.contents),a=n!=null&&ah(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=nh(e);t!=null&&i!=null&&!o&&(s.name=t.name,s.lang=t.lang),a&&n!=null&&t!=null&&i!=null&&(s.additionLines=i,s.additionCharacterCount=t.contents.length,s.type=n.type,s.hunks=n.hunks,s.editSessionDirty=!0,em(s));let c=this.editSession?.annotations??Mo(this.getLatestAnnotations(),ti);this.editSession={diff:s,inputDiff:e,annotations:c,outgoingDiff:this.editSession?.outgoingDiff},this.pendingData={fileDiff:s,lineAnnotations:c.current},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`);n=this.forceRenderOverride??n,this.forceRenderOverride=void 0;let l=xp(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=_&&(!lh(u,this.deletionFile)||!lh(d,this.additionFile)),y=e!=null&&!jd(e,this.getInputDiff()),b=i!=null&&(i.length>0||this.getLatestAnnotations().length>0)&&this.isNewAnnotations(i);if(!f&&Mr(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.getInputDiff()==null)&&(x=Np(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.updateInputDiff(e,i):x!=null&&(y=!0,this.updateInputDiff(x,i)),y&&this.clearReusableHeader(),i!=null&&this.setLineAnnotations(i);let C=this.getWorkingDiff();if(C==null)return!1;C.editSessionDirty===!0&&this.shouldSelfHealEditSession()&&(fm(C,this.options.parseDiffOptions),this.hunksRenderer.refreshHighlightedResult()),m&&this.loadFilesIfNecessary(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.prepareRenderData(this.hunksRenderer.getDiffForNextRender(C));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,Cc);e!=null&&this.applyThemeState(a,e.themeStyles,p,e.baseThemeType),e?.headerElement!=null&&this.applyHeaderToDOM(e.headerElement,a,e.fileDiff),this.renderSeparators([]),this.adoptRenderData(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||!jd(this.getRenderedDiff(),C))&&this.applyPartialRender({fileDiff:C,previousRenderRange:S,renderRange:h})){let e=this.getRenderedDiff();e!=null&&this.adoptRenderData(e)}else{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.adoptRenderData(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)}getInputDiff(){return this.fileDiff}getWorkingDiff(e=this.fileDiff){return this.editSession?.diff??e}getRenderedDiff(){return this.renderedData?.fileDiff}__getNextRenderData({fileDiff:e,lineAnnotations:t}){let n=this.editSession?.annotations;if(n!=null)return{fileDiff:e,lineAnnotations:t!=null&&this.isNewAnnotations(t)?t:n.provided};let r=this.getWorkingDiff(e)??e,i=this.hunksRenderer.getDiffForNextRender(r);return{fileDiff:i,lineAnnotations:t!=null&&jd(i,r)?t:this.getAnnotationsForDiff(i)}}prepareRenderData(e){this.hunksRenderer.setLineAnnotations(this.getAnnotationsForDiff(e))}adoptRenderData(e){let{pendingData:t}=this,n=t!=null&&jd(e,t.fileDiff);this.renderedData={fileDiff:e,lineAnnotations:n?t.lineAnnotations:this.lineAnnotations},n&&(this.pendingData=void 0)}syncRenderViewToEditor(){let{editor:e,fileContainer:t}=this,n=this.getLatestAnnotations(),r=this.computeEditorRenderRange(this.renderRange),i=this.getWorkingDiff();if(e==null||t==null||i==null||i.isPartial)return;let a=a=>{if(!this.enabled||this.editor!==e||this.fileContainer!==t||this.getWorkingDiff()!==i)return;let o=this.editSession?.outgoingDiff,s=this.getInputDiff(),c=o!=null&&s!=null&&o!==i,l=c&&o!=null&&s!=null?rh(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??Ki(i.name),c=Hr({theme:o,lang:s});c==null?Lr({themes:Pi(o),langs:[`text`,s],preferredHighlighter:Kr(this.workerManager,this.options)}).then(a).catch(e=>{e instanceof qr||console.error(e)}):a(c)}computeEditorRenderRange(e){let t=this.getWorkingDiff();if(e==null||t==null||no(e))return e;let{diffStyle:n=`split`,expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a,o;return Jd({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 t=this.getInputDiff(),{diff:n,outgoingDiff:r}=this.editSession??{};if(r!=null&&t!=null){if(!t.isPartial&&rh(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?Xc(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`);if(!this.__canAttachEditor())throw Error(`FileDiff.__attachEditor: a complete diff is required before editing`);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 t=this.getInputDiff(),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(ch(r)),e.__getDocumentSessionState()),this.editor=e,this.getInputDiff()?.isPartial===!0&&this.loadFilesIfNecessary();let i=this.editSession?.diff;this.hunksRenderer.editorRenderReady()?(i!=null&&this.hunksRenderer.diffCache===i&&this.adoptRenderData(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}=this;if(n==null)return;let{diff:r,inputDiff:i,annotations:a}=n,o=a?.provided??this.lineAnnotations;if(this.editor!=null)throw Error(`FileDiff.__completeEditSession: detach the editor before completing the session`);this.hunksRenderer.endEditSession(),this.finalizeEditSessionHunks();let s=a?.current,c,l=null,u=null,d=!1,f;if(t==null)throw Error(`FileDiff.__completeEditSession: editor is required for completion`);let p=Qc(r),m={name:p.name,contents:p.additionLines.join(``)};p.lang!=null&&(m.lang=p.lang);let h={fileDiff:p,editor:t,originalFileDiff:i,oldFile:p.type===`new`?null:{name:p.prevName??p.name,contents:p.deletionLines.join(``)},newFile:m,lineAnnotations:s,originalLineAnnotations:o};Object.freeze(h);try{if(t.__emitEditComplete(h),this.options.onEditComplete?.(h)===`accept`){if(p.cacheKey!=null&&p.cacheKey===i.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.additionFile!=null&&(this.deletionFile=l,this.additionFile=u),this.editSession=void 0,this.fileDiff=e&&c!=null?c:i,this.pendingData={fileDiff:this.fileDiff,lineAnnotations:e&&c!=null?s??o:o},e&&this.fileContainer!=null&&this.rerender(),d)throw f}finalizeEditSessionHunks(){let e=this.getWorkingDiff();if(e==null||e.editSessionDirty!==!0)return!1;let{collapsedContextThreshold:t=1}=this.options,n=um(e,this.hunksRenderer.getExpandedHunksMap(),t);return fm(e,this.options.parseDiffOptions),this.hunksRenderer.setExpandedHunksMap(dm(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()}applySuspendedDocumentChange(e,t){this.applyDocumentChange(e,t),this.hunksRenderer.clearRenderCache()}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;this.hunksRenderer.updateRenderCache(e,t,a,n.changedDocumentLines,n.documentLineCount)?(this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!0,this.escalateEditSessionRender()):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{diff:e,inputDiff:t}=this.editSession??{};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 Bd({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 Vd({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]=Fd(o);if(e<s){let c=Id({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=zd({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]=Fd(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(){ei(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.setPlaceholderHeight(e)}setPlaceholderHeight(e){return this.placeHolder!=null&&(this.placeHolder.style.setProperty(`height`,`${e}px`),!0)}async primeHighlightCache(e=this.getInputDiff()){let{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||Pd(e))return;let n=this.options.tokenizeMaxLength??1e5;Math.max(e.additionLines.length,e.deletionLines.length)>n||await t.primeDiffHighlightCache(e).catch(e=>{No(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.isComponentManaged||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||!$m(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.isComponentManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderedData:t,options:{renderAnnotation:n}}=this;if(n!=null&&t!=null){let{fileDiff:r,lineAnnotations:i}=t;for(let[t,a]of i.entries()){let i=this.getAnnotationSlotName(a),o=`${t}-${i}`,s=this.annotationCache.get(o);if(s==null||s.fileDiff!==r||!Qm(a,s.annotation)){s?.element.remove();let e=n(a,r);if(e==null)continue;s={element:Bo(i),annotation:a,fileDiff:r},s.element.appendChild(e),this.fileContainer.appendChild(s.element),this.annotationCache.set(o,s)}e.delete(o)}}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=Za();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:As(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):As(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=oo;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&&jd(r,n)?i:void 0)??Oi(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.isComponentManaged)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,jc,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,Kc,d),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,Jc,f),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,mc,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;this.pre?.toggleAttribute(`data-custom-styles`,!!e);let t=this.fileContainer?.shadowRoot;t!=null&&(e==null||e===``?(this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0):(this.unsafeCSSStyle?.parentNode!==t||this.appliedUnsafeCSS!==e)&&(this.unsafeCSSStyle??=Ua(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=wo(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=os(i);this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c?this.appliedThemeCSS.theme=s:this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i?(this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c}):(this.themeCSSStyle=Li({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:Ra(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=Qo(this.themeCSSStyle.textContent??``,os(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&Bi()}applyHunksToDOM(e,t){this.shouldGuardRebuildScroll()?xr(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=mh(t[0]),a=mh(t[1]);return i==null||a==null?!1:(r.gutter.innerHTML=Oi(i),r.content.innerHTML=Oi(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=Ka({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=Ka({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=Ka({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.adoptRenderData(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.getWorkingDiff();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=mh(r?.[0]),a=mh(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.adoptRenderData(t.fileDiff)}refreshUnifiedDiffView(){let e=this.getWorkingDiff();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=mh(r?.[0]),a=mh(r?.[1]),o=()=>{for(let[e,t]of[[n.gutter,i],[n.content,a]])t!=null&&(e.innerHTML=Oi(t));t.rowCount!==this.lastRowCount&&(this.applyRowSpan(`unified`,n,t.rowCount),this.lastRowCount=t.rowCount),this.adoptRenderData(t.fileDiff)};this.shouldGuardRebuildScroll()?xr(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=mh(t[0]),i=mh(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++;else 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++;else if(`separator`in e.dataset&&`separator`in u.dataset)(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);else if(e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset)(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);else if(e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset)(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);else 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}else 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){t==null||this.shouldDisableVirtualizationBuffers()?(this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)):(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};ko(u,this.appliedPreAttributes)||(ga(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 ch(e){return{name:e.name,lang:e.lang,contents:e.additionLines.join(``)}}function lh(e,t){return e==null||t==null?e==null&&t==null:Md(e,t)}function uh({fileDiff:e,oldFile:t,newFile:n}){return e!=null&&e.hunks.length>0||t!=null||n!=null}function dh({fileDiff:e,oldFile:t,newFile:n}){return e!=null||t!=null||n!=null}function fh(e,t,n=!1){return!n&&e==null&&t}function ph(e,t,n=!1){return e==null&&t&&!n}function mh(e){if(e!=null&&e.type===`element`)return e.children??[]}var hh=3e3,gh=new Map,_h=-1,vh=class extends sh{__id=`little-virtualized-file-diff:${++_h}`;renderType=`virtualized`;top;height=0;metrics;cache={heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0,fileAnnotationHeight:0,ghostTextRows:gh,ghostTextRowsByIndex:new Map};isVisible=!1;isSetup=!1;virtualizer;layoutDirty=!0;currentCollapsed;pendingHydratedDiff;pendingExpansions;pendingRender;constructor(e,t,n,r,i){super(e,r,i),this.virtualizer=t,this.metrics=ci(n)}setMetrics(e,t=!1){let n=ci(e);(t||!ua(this.metrics,n))&&(this.metrics=n,this.resetLayoutCache({includeEstimatedHeights:!0}))}setLineAnnotations(e){this.syncLineAnnotations(e)&&(this.forceRenderOverride=!0)}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.forceRenderOverride=!0,!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.getLayoutAnnotations();return bi(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=!ta(t,e),r=n&&Eh(t,e);super.setOptions(e),r&&this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:Dh(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=gh,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`},metrics:{lineHeight:n}}=this,r=this.placeHolder==null?this.getRenderedDiff():this.getLayoutDiff();if(this.fileContainer==null||r==null)return this.height!==0&&(e=!0),this.height=0,e;this.top=this.getVirtualizedTop(),e=this.applyGhostTextRows(r,this.editor?.__getGhostTextRows()??gh);let{ghostTextRowsByIndex:i}=this.cache,a=t!==`scroll`||this.lineAnnotations.length>0||this.isResizeDebuggingEnabled();if(this.placeHolder!=null||!a&&this.cache.heightDeltas.size===0&&this.cache.fileAnnotationHeight===0)return e&&(this.computeApproximateSize(!0),this.setPlaceholderHeight(this.height)),e;let o=this.getDiffStyle(),s=o===`split`?[this.codeDeletions,this.codeAdditions]:[this.codeUnified];if(this.renderRange!=null&&wi(this.renderRange)){let t=yh(s)??0;this.setFileAnnotationHeight(t)&&(e=!0)}for(let t of s){if(t==null)continue;let r=t.children[1];if(!(r instanceof HTMLElement))continue;let s=o===`split`&&t===this.codeDeletions;for(let t of r.children){if(!(t instanceof HTMLElement))continue;let r=t.dataset.lineIndex;if(r==null)continue;let c=jh(r,o),l=i.get(c)??0;if(s&&l>0)continue;let u=this.cache.heightDeltas.get(c)??0;if(!a&&u===l*n)continue;let d=t.getBoundingClientRect().height+l*n,f=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(f=!0),d+=t.nextElementSibling.getBoundingClientRect().height);let p=this.getEstimatedLineHeight(f),m=d-p;m!==u&&(e=!0,this.cache.measuredHeightDeltaTotal+=m-u,m===0?this.cache.heightDeltas.delete(c):this.cache.heightDeltas.set(c,m))}}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.installHydratedSessionDiff(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.updateInputDiff(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)&&(i=!0),(d||n?.resetDiffLayoutCache===!0&&n.includeEstimatedDiffHeights)&&(a=!0),n?.metrics!=null&&(this.metrics=ci(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=Sa(this.metrics,i),f=this.getLayoutCheckpointBeforeLineIndex(u),p=f?.top??d+this.cache.fileAnnotationHeight;if(o)return{top:ma(this.metrics,i),height:0};let m;return Jd({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=Kd({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=qd({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??Sa(this.metrics,n)+this.cache.fileAnnotationHeight,u;return Jd({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=Kd({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=qd({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||!jd(this.getRenderedDiff(),this.getWorkingDiff()));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.getInputDiff()!=null&&(this.loadFilesIfNecessary(),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.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))};async handleFilesLoaded(e,t){if(this.getInputDiff()===e&&e.isPartial){if(this.isAdvancedMode()){let n=Cp(`clone`,e,t,this.options.parseDiffOptions);if(await _p(()=>this.primeHighlightCache(n)),this.getInputDiff()!==e)return;this.pendingHydratedDiff={expectedDiff:e,nextDiff:n,files:t}}else{if(Cp(`merge`,e,t,this.options.parseDiffOptions),this.setHydratedState(t),!this.installHydratedSessionDiff(e)&&(await _p(()=>this.primeHighlightCache(e)),this.getInputDiff()!==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.getInputDiff())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 Bd({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.getInputDiff()!=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.getInputDiff()==null&&this.additionFile==null&&this.deletionFile==null)return;let e=this.getWorkingDiff(),t=e==null?void 0:this.hunksRenderer.getDiffForNextRender(e);this.isSimpleMode()&&(this.pendingRender=void 0),this.forceRenderOverride=!0,this.isSimpleMode()&&this.requestRender()||this.virtualizer.instanceChanged(this,!jd(this.getRenderedDiff(),t))}get isComponentManaged(){return this.getAdvancedVirtualizer()?.isComponentManaged??super.isComponentManaged}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()??gh);let{disableFileHeader:i=!1,collapsed:a=!1}=this.options;a?(this.height+=ma(this.metrics,i),this.layoutDirty=!1):(this.height=this.getActiveEstimatedHeight(t)+this.cache.measuredHeightDeltaTotal,n&&!r&&this.validateComputedHeight(t),this.layoutDirty=!1)}getLayoutDiff(){return this.pendingRender?.diff??this.getRenderedDiff()}getLayoutAnnotations(){let{pendingRender:e}=this;return e==null?this.lineAnnotations:this.getAnnotationsForDiff(e.diff)}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}=vp({fileDiff:e,metrics:this.metrics,disableFileHeader:t,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:n,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r,canHydratePartialDiff:Oh(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=xp(i,`VirtualizedFileDiff.render`),o=a!=null,s=a?.oldFile,c=a?.newFile,l=o&&(!Ah(s,this.deletionFile)||!Ah(c,this.additionFile)),u=t??this.getInputDiff();t==null&&o&&(l||this.getInputDiff()==null)&&(u=Np(a.oldFile,a.newFile,this.options.parseDiffOptions));let{forceRenderOverride:d,isSetup:f}=this;this.forceRenderOverride=void 0;let p=u!=null&&!jd(this.getInputDiff(),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.updateInputDiff(u,r);let{pendingRenderDiff:h,layoutDiffChanged:g,renderedDiffChanged:_,annotationsChanged:v}=this.pendingRender!=null&&this.pendingRender.workingDiff===(this.getWorkingDiff(u)??u)?{pendingRenderDiff:this.pendingRender.diff,layoutDiffChanged:!1,renderedDiffChanged:!1,annotationsChanged:this.syncLineAnnotations(r)}:this.updatePendingRender(u,r);if(g&&this.resetLayoutCache({includeEstimatedHeights:!0}),f)this.top??=this.getVirtualizedTop(),this.layoutDirty&&this.isSimpleMode()&&(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.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(!jd(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.getWorkingDiff(e)??e,r=this.getRenderedDiff(),{pendingRender:i}=this,a=i?.diff??r,o=this.hunksRenderer.getDiffForNextRender(n);return this.pendingRender={workingDiff:n,diff:o},{pendingRenderDiff:o,annotationsChanged:this.syncLineAnnotations(t),layoutDiffChanged:!jd(a,o),renderedDiffChanged:!jd(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 kh(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=Oh(e,this.options.loadDiffFiles!=null),o=this.getDiffStyle(),s=this.getHunkSeparatorType(),c=n?!0:this.hunksRenderer.getExpandedHunksMap(),l=bh(this.cache.heightDeltas),u=Sa(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=Ch(a);for(;s<o;){let e=s-a,r=u+(e>0?n:0)+e*this.metrics.lineHeight+wh(i,e)*this.metrics.lineHeight+xh(l,t,t+e);this.cache.checkpoints.push({renderedLineIndex:s,lineIndex:t+e,top:r}),s+=hh}u+=n+e*this.metrics.lineHeight+i.length*this.metrics.lineHeight+xh(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=Id({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:c,hunkIndex:t,collapsedContextThreshold:r}),u=l.collapsedLines>0?Kd({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?zd({fileDiff:e,hunkIndex:t,expandedHunks:c,collapsedContextThreshold:r,errorPrefix:`VirtualizedFileDiff`}):void 0,m=p!=null&&p.collapsedLines>0||t===i&&a?qd({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:Th({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}=Id({isPartial:e.isPartial,rangeSize:c,expandedHunks:a,hunkIndex:r,collapsedContextThreshold:i});c>0&&(n+=d?c:l+u)}let o=zd({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=Oh(e,this.options.loadDiffFiles!=null),f=this.height,p=this.getLayoutLineCount(e,l),m=Sa(this.metrics,i),h=e.hunks.length>0?Ii(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(Jd({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?Kd({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=qd({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 yh(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===`-1,-1`&&(t=Math.max(t??0,n.getBoundingClientRect().height))}return t}function bh(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 xh({lineIndexes:e,prefixTotals:t},n,r){if(n>=r||e.length===0)return 0;let i=Sh(e,n);return(t[Sh(e,r)]??0)-(t[i]??0)}function Sh(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 Ch(e){return Math.ceil(e/hh)*hh}function wh(e,t){let n=0;for(let r of e)r<t&&n++;return n}function Th({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 Eh(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 Dh(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 Oh(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function kh(e){return typeof e==`function`?`custom`:e??`line-info`}function Ah(e,t){return e==null||t==null?e==null&&t==null:Md(e,t)}function jh(e,t){let[n,r]=e.split(`,`).map(Number);return t===`split`?r:n}var Mh=`theme.disableLineNumbers.overflow.themeType.disableFileHeader.disableVirtualizationBuffers.preferredHighlighter.useCSSClasses.useTokenTransformer.tokenizeMaxLineLength.tokenizeMaxLength.unsafeCSS.diffStyle.diffIndicators.disableBackground.expandUnchanged.loadDiffFiles.parseDiffOptions.collapsedContextThreshold.lineDiffType.maxLineDiffLength.expansionLineCount.lineHoverHighlight.enableTokenInteractionsOnWhitespace.enableGutterUtility.__debugPointerEvents.enableLineSelection.controlledSelection.disableErrorHandling`.split(`.`),Nh=[`theme`,`disableLineNumbers`,`overflow`,`themeType`,`disableFileHeader`,`disableVirtualizationBuffers`,`preferredHighlighter`,`useCSSClasses`,`useTokenTransformer`,`tokenizeMaxLineLength`,`tokenizeMaxLength`,`unsafeCSS`,`lineHoverHighlight`,`enableTokenInteractionsOnWhitespace`,`enableGutterUtility`,`__debugPointerEvents`,`enableLineSelection`,`controlledSelection`,`disableErrorHandling`],Ph=[`renderCustomHeader`,`renderHeaderPrefix`,`renderHeaderFilenameSuffix`,`renderHeaderMetadata`,`renderAnnotation`,`renderGutterUtility`,`onPostRender`,`onGutterUtilityClick`,`onLineClick`,`onLineNumberClick`,`onLineEnter`,`onLineLeave`,`onTokenClick`,`onTokenEnter`,`onTokenLeave`],Fh=[`onLineSelected`,`onLineSelectionStart`,`onLineSelectionChange`,`onLineSelectionEnd`],Ih=Symbol(`CodeView.itemOptionsState`);function Lh(e,t){Object.defineProperty(e,Ih,{configurable:!1,enumerable:!1,value:t})}function Rh(e){return e[Ih]}function zh(e,t,n){Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get(){return n(this)}})}var Bh=120,Vh=1,Hh=`--diffs-overflow-override`;function Uh(e,t,n){return{containerHeight:e,triggerTop:t,targetTop:n,targetBottom:e-n,threshold:e-t}}var Wh=Uh(12e6,1e6,2e6),Gh=Uh(2**22,5e5,1e6);function Kh(e){if(e==null)throw Error(`CodeView: createEditor is required for items with edit: true`)}var qh=(()=>{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)})(),Jh=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;scrollRebaseConfig=ai()?Gh:Wh;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=Lc;fileOptionsPrototype;diffOptionsPrototype;pendingScrollTarget;pendingLayoutAnchor;headerResizeAnchor;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;isComponentManaged;slotSnapshotStale=!1;constructor(e={theme:gc},t,n=!1){this.options=e,this.computeMetricsCache(e.itemMetrics),this.fileOptionsPrototype=this.createFileOptionsPrototype(),this.diffOptionsPrototype=this.createDiffOptionsPrototype(),this.workerManager=t,this.isComponentManaged=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??Ec}getItemTopOffset(){return this.getLayout().paddingTop+this.header.height}computeMetricsCache(e){return this.itemMetricsCache={hunkLineCount:e?.hunkLineCount??Lc.hunkLineCount,lineHeight:e?.lineHeight??Lc.lineHeight,diffHeaderHeight:e?.diffHeaderHeight??Lc.diffHeaderHeight,hunkSeparatorHeight:e?.hunkSeparatorHeight,spacing:e?.spacing??Lc.spacing,paddingTop:e?.paddingTop,paddingBottom:e?.paddingBottom},this.itemMetricsCache}getSmoothScrollSettings(){return this.options.smoothScrollSettings??zc}shouldDisablePointerEvents(){return this.options.pointerEventsOnScroll!==!0}shouldValidateItemHeights(){return vc&&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)<Vh||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),qh&&!this.codeOverflowFix&&(this.stickyContainer.style.setProperty(Hh,`hidden`),this.codeOverflowFix=!0),this.scrollInteractionFixTimer=setTimeout(this.restoreScrollInteractions,Bh)}restoreScrollInteractions=()=>{this.clearScrollInteractionTimer(),this.pointerEventsDisabled&&=(this.stickyContainer.style.removeProperty(`pointer-events`),!1),this.codeOverflowFix&&=(this.stickyContainer.style.setProperty(Hh,`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??mp(e,n,this.resizeObserver);r.element=a;let o=i();return o==null?!this.isComponentManaged&&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(){oa(this.computeRenderRangeAndEmit),this.clearReadySubscription(),this.restoreScrollInteractions(),this.cleanAllRenderedItems();let{items:e}=this,t=[...this.itemEditors.values()].map(e=>{let t=this.idToItem.get(e.state.id);return t!=null&&(e.state.removedItem=t.item),e});this.itemEditors.clear(),this.attachedEditors.clear(),this.selectedLines=null,this.items=[],this.idToItem.clear(),this.instanceToItem.clear();let n=!1,r;for(let e of t)try{e.editor.cleanUp(`discard`)}catch(e){n||(n=!0,r=e)}for(let t of e)try{t.instance.cleanUp()}catch(e){n||(n=!0,r=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.headerResizeAnchor=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.isComponentManaged||this.flushSlotCoordinator(),n)throw r}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.isComponentManaged?2:1)}acquireElement(){this.promotePendingPooledElements();let e=this.elementPool.pop();for(;e!=null&&!this.isElementPoolGenerationCurrent(e);)e=this.elementPool.pop();return e??=document.createElement(Ac),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))$h(e)||e.remove();this.isComponentManaged||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 hp()?`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));try{this.syncItemEditors(t)}finally{for(let e of t?.values()??[])e.instance.cleanUp()}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=Yh(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;Xh(t,e)&&this.invalidateElementPool(),this.options=e;let i=this.computeMetricsCache(e.itemMetrics),a=!ua(r,i),o=!ua(n,this.getLayout());o&&this.syncLayout();let s=a||Zh(t,e);if(s){let n=this.pendingLayoutReset;this.pendingLayoutReset={metrics:a?i:n?.metrics,resetFileLayoutCache:!0,resetDiffLayoutCache:!0,includeEstimatedDiffHeights:n?.includeEstimatedDiffHeights===!0||a||Qh(t,e)}}(o||s)&&(this.markLayoutDirtyFromIndex(0),this.scrollDirty=!0),ta(t,e)||this.renderOptionsRevision++,this.syncItemEditors();let c=t.renderCodeViewHeader!==e.renderCodeViewHeader||t.renderCodeViewFooter!==e.renderCodeViewFooter;!this.isComponentManaged&&(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?(oa(this.computeRenderRangeAndEmit),this.computeRenderRangeAndEmit()):ei(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??gc;return Hr({theme:e})==null?(Zi(this.pendingHighlighterTheme,e)||this.clearReadySubscription(),this.isReadySubscription??=(()=>{this.pendingHighlighterTheme=e;let t=!1;return ki({themes:Pi(e),langs:[],preferredHighlighter:Kr(this.workerManager,this.options)}).then(()=>{t||(this.clearReadySubscription(),this.render(!0))},e=>{t||(this.clearReadySubscription(),e instanceof qr||console.error(e))}),()=>{t=!0}})(),!1):(this.clearReadySubscription(),!0)}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.itemEditors.has(n.item.id)||(this.slotSnapshotStale=!0),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=ag(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 vh(this.createDiffOptions(e.id),this,r,this.workerManager);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 ba(this.createFileOptions(e.id),this,r,this.workerManager);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&&Dr(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);e==null?(this.selectedLines=null,this.options.onSelectedLinesChange?.(null)):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&&e.type===`diff`&&!e.instance.__canAttachEditor()){e.instance.__prepareForEditing();return}if(r==null){Kh(n);let r=Rh(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 Nh)zh(e,t,()=>this.options[t]);zh(e,`stickyHeader`,()=>this.options.stickyHeaders),zh(e,`collapsed`,e=>{let t=Rh(e);if(t!=null)return this.getItemOptions(t,`file`)?.item.collapsed}),zh(e,`onEditComplete`,e=>{if(this.options.onItemEditComplete==null)return;let t=Rh(e);if(t!=null)return e=>this.completeFileItemEdit(t,e)});for(let t of Ph)this.defineItemSharedCallback(e,`file`,t);for(let t of Fh)this.defineItemSelectionCallback(e,`file`,t);return e}createDiffOptionsPrototype(){let e={};for(let t of Mh)zh(e,t,()=>this.options[t]);zh(e,`stickyHeader`,()=>this.options.stickyHeaders),zh(e,`hunkSeparators`,()=>this.options.hunkSeparators),zh(e,`collapsed`,e=>{let t=Rh(e);if(t!=null)return this.getItemOptions(t,`diff`)?.item.collapsed}),zh(e,`onEditComplete`,e=>{if(this.options.onItemEditComplete==null)return;let t=Rh(e);if(t!=null)return e=>this.completeDiffItemEdit(t,e)});for(let t of Ph)this.defineItemSharedCallback(e,`diff`,t);for(let t of Fh)this.defineItemSelectionCallback(e,`diff`,t);return e}createFileOptions(e){let t=Object.create(this.fileOptionsPrototype);return Lh(t,{id:e}),t}createDiffOptions(e){let t=Object.create(this.diffOptionsPrototype);return Lh(t,{id:e}),t}updateItemOptionsId(e,t){let n=Rh(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){zh(e,n,e=>{if(this.options[n]==null)return;let r=Rh(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){zh(e,n,e=>{let r=Rh(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()>this.scrollRebaseConfig.threshold}getPagedScrollHeight(){return this.shouldRebaseScroll()?Math.min(this.getScrollHeight(),this.scrollRebaseConfig.containerHeight):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=gp(this.clampPagedScrollTop(t)),r=this.clampScrollPageOffset(e-n);return n=gp(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{scrollPageOffset:t,scrollRebaseConfig:n}=this,r=this.clampScrollPageOffset(t),i=e-r,a=this.getMaxPagedScrollTop(),o=this.getMaxScrollPageOffset(),s=i>n.threshold&&r<o,c=i<n.triggerTop&&r>0;return i<0||i>a||s||c?this.resolveScrollPageWindow(e,c?Math.min(n.targetBottom,a):n.targetTop):{pagedScrollTop:gp(this.clampPagedScrollTop(i)),scrollPageOffset:r}}needsScrollPageUpdate(e){let t=gp(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 ${eg(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}"`);else 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 ${eg(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}"`);else 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=this.pendingScrollTarget!=null,a=r,o=this.pendingLayoutAnchor!=null,s=this.getScrollAnchor(a);if(this.layoutDirtyIndex!=null&&(this.recomputeLayout(this.layoutDirtyIndex,this.pendingLayoutReset),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,o=!0),o&&s!=null){let e=this.resolveAnchoredScrollTop(s);if(e!=null){let t=e-a;a=e,this.scrollAnimation!=null&&(this.scrollAnimation.position+=t)}}o&&(a=this.clampScrollTop(a),this.syncContainerHeight());let c=this.computeTargetScrollTopForFrame(a,t),l=!o&&(this.renderState.scrollTop===-1||Math.abs(c-this.renderState.scrollTop)>n+this.config.overscrollSize*2);l&&(s=void 0),this.windowSpecs=Zc({scrollTop:c-this.header.height,height:n,scrollHeight:this.getScrollHeight(),fitPerfectly:l,fitPerfectlyOverscroll:this.getFitPerfectlyOverscroll(),overscrollSize:this.config.overscrollSize});let u=r;(this.pendingScrollTarget!=null&&c!==u||this.needsScrollPageUpdate(c))&&(this.applyScrollFix(c,u,this.windowSpecs),u=c);let{top:d,bottom:f}=this.windowSpecs,{firstIndex:p,lastIndex:m}=this.renderState;if(p>=0)for(let e=p;e<=m;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.computeRenderRangeAndEmit: No item at index: ${e}`);t.top>d-t.height&&t.top<=f||this.releaseRenderedItem(t)}let h=this.reconcileHeaderFooterHosts(),g,_=new Set,v=this.findFirstVisibleIndex(d),y=this.findLastVisibleIndex(f);for(let e=v;e<=y;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(),rg(this.stickyContainer,t.element,g),n.virtualizedSetup(),ng(t,t.element)&&(t.renderedOptionsRevision=this.renderOptionsRevision,_.add(t)),g=t.element):(rg(this.stickyContainer,t.element,g),ng(t,void 0,t.renderedOptionsRevision!==this.renderOptionsRevision)&&(t.renderedOptionsRevision=this.renderOptionsRevision,_.add(t)),g=t.element),t.item.edit===!0&&this.attachItemEditor(t)}this.renderState.firstIndex=v<=y?v:-1,this.renderState.lastIndex=y,this.flushSlotCoordinator(),this.flushManagers(_),h&&this.measureMountedHosts(),this.reconcileRenderedItems(_),this.syncContainerHeight(),this.updateStickyPositioning();let b=s==null?void 0:this.resolveAnchoredScrollTop(s);s===this.pendingLayoutAnchor&&(this.pendingLayoutAnchor=void 0);let x=b==null?0:b-a,S=c,C=!1;if(this.pendingScrollTarget!=null){let e=this.advanceScrollAnimation(t,x);e==null?S=a:(S=e,C=!0)}else S=b??c;S!==u&&(this.applyScrollFix(S,u,this.windowSpecs),u=S),C&&this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),this.renderState.scrollTop=gp(u),this.updateStickyPositioning(),i&&(this.headerResizeAnchor=void 0,this.getScrollAnchor(u)),this.validateStickyContainerHeight(),this.fixContainerFocus(),(l||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);t==null?this.stickyOffset.style.height=`${this.getPagedLayoutTop(e.top)}px`: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.headerResizeAnchor=void 0,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)>=Vh){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=this.header.element!=null&&this.header.element.getBoundingClientRect().height!==this.header.height,r=e=>(n||(this.headerResizeAnchor=e==null?void 0:{anchor:e,item:this.idToItem.get(e.id)}),e),i,{pendingLayoutAnchor:a}=this;if(a!=null){let e=this.idToItem.get(a.id);if(e!=null&&t.get(a.id)===e)return r(a);e!=null&&(i=e)}let o=this.headerResizeAnchor;if(n&&this.pendingScrollTarget==null&&o!=null&&this.idToItem.get(o.anchor.id)===o.item&&t.get(o.anchor.id)===o.item)return o.anchor;if(e<=0)return r(void 0);let{firstIndex:s,lastIndex:c,stickyTop:l,stickyBottom:u}=this.renderState;if(s===-1||c===-1)return;let d=this.getHeight();if(l!==-1&&u!==-1){for(let n=s;n<=c;n++){let a=this.items[n];if(a==null)continue;let o=this.getItemTopOffset()+a.top;if(o+a.height<=e)continue;if(o>=e+d)break;if(t.get(a.item.id)!==a){i??=a;continue}if(o>=e)return r({type:`item`,id:a.item.id,viewportOffset:o-e});let s=this.getScrollAnchorViewportTop(o,e)-o,c=a.instance.getNumericScrollAnchor(s);if(c!=null){let t=o+c.top;return r({type:`line`,id:a.item.id,lineNumber:c.lineNumber,side:c.side,viewportOffset:t-e})}}if(i!=null)for(let e=i.index+1;e<this.items.length;e++){let n=this.items[e];if(n!=null&&t.get(n.item.id)===n)return r({type:`item`,id:n.item.id,viewportOffset:0})}return r(void 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=gp(this.clampScrollTop(e)),i=gp(t),{scrollPageOffset:a}=this,o=gp(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||gp(this.getScrollTop())===gp(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}getScrollHeight(){return this.scrollHeight}flushSlotCoordinator(){if(this.slotCoordinator==null)return;let e=this.buildSlotSnapshot(this.slotCoordinator);(this.slotSnapshotStale||!fp(this.slotSnapshot,e))&&(this.slotSnapshotStale=!1,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 Yh(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 Xh(e,t){return!Zi(e.theme??gc,t.theme??gc)||(e.themeType??`system`)!==(t.themeType??`system`)||e.unsafeCSS!==t.unsafeCSS}function Zh(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 Qh(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 $h(e){return e instanceof SVGElement||As(e)&&(e.hasAttribute(`data-core-css`)||e.hasAttribute(`data-theme-css`)||e.hasAttribute(`data-unsafe-css`))}function eg(e){let t=tg(e.start,e.side),n=tg(e.end,e.endSide??e.side);return t===n?t:`${t}-${n}`}function tg(e,t){return t==null?`${e}`:`${t===`deletions`?`D`:`A`}${e}`}function ng(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 rg(e,t,n){n==null?e.firstChild!==t&&e.prepend(t):n.nextSibling!==t&&n.after(t)}function ig(e){return(e.item.annotations?.length??0)>0||dp(e).lineAnnotations.length>0}function ag(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)ig(t)&&i.push(t);return i.length>0?i:void 0}function og(e,t){typeof e==`function`?e(t):e!=null&&(e.current=t)}var sg=e(Tt(),1),cg=typeof window>`u`?Z.useEffect:Z.useLayoutEffect;function lg(e){return{instance:void 0,items:void 0,controlled:e,managedOptions:void 0,disableFlushSync:!1,slotCoordinator:void 0}}function ug(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=pi(),E=(0,Z.useContext)(Yr),D=(0,Z.useRef)(lg(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=Go(e=>{f?.(e)}),I=S!==void 0,L=Go((e,t,n)=>{if(T==null)throw Error(`CodeView: EditContext is not attached`);let r={...a,...t};return T(e,r,n)}),R=Go((e,t)=>{l?.(e,t)}),z=Go((e,t,n)=>u?.(e,t,n)??`reject`),B=(0,Z.useMemo)(()=>gg({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,Z.useState)(()=>hg()),[,H]=(0,Z.useState)({}),U=Go(e=>{D.current.instance!=null&&(e==null||e!==D.current.instance.getContainerElement())&&(D.current.instance.cleanUp(),V.publish(void 0),D.current=lg(w)),e!=null&&e!==D.current.instance?.getContainerElement()&&(D.current.instance=new Jh(B,i?void 0:E,!0),D.current.instance.setup(e)),og(r,e)}),W=Go(e=>{D.current.disableFlushSync?V.publish(e):(0,sg.flushSync)(()=>{V.publish(e)})}),G=(0,Z.useMemo)(()=>{if(j||k||A||N||P)return{hasHeaderRenderers:j,hasAnnotationRenderer:k,hasGutterRenderer:A,onSnapshotChange:W}},[W,k,A,j,N,P]);return cg(()=>d==null?void 0:D.current.instance?.subscribeToScroll(d)),cg(()=>{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(ta(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&&(pg(n,c)?D.current.items=c:fg(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,Z.useImperativeHandle)(t,()=>({addItems(e){let{controlled:t,instance:n}=D.current;mg(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);else return t.getItem(e)},removeItem(e){let{controlled:t,instance:n}=D.current;return mg(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 mg(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 mg(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);else return t.getEditor(e)},getInstance(){return D.current.instance}}),[F]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{ref:U,className:n,style:C}),(M||N||P)&&(0,Q.jsx)(_g,{managedContentStore:V,renderCustomHeader:_,renderHeaderPrefix:x,renderHeaderFilenameSuffix:y,renderHeaderMetadata:b,renderAnnotation:m,renderGutterUtility:v,renderCodeViewHeader:g,renderCodeViewFooter:h})]})}var dg=(0,Z.forwardRef)(ug);function fg(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 pg(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 mg(e,t){if(e)throw Error(`CodeView.${t} cannot be used when CodeView is controlled. Use initialItems for imperative item updates.`)}function hg(){let e,t=new Set;return{getSnapshot(){return e},publish(n){if(e!==n){e=n;for(let e of t)e()}},subscribe(e){return t.add(e),()=>{t.delete(e)}}}}function gg({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=bg),n&&(d.renderGutterUtility=bg),r&&(d.renderCodeViewHeader=bg),i&&(d.renderCodeViewFooter=bg),d}var _g=(0,Z.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=Go(t=>e.subscribe(t)),u=Go(()=>e.getSnapshot()),d=(0,Z.useSyncExternalStore)(l,u,u),f=(0,Z.useMemo)(()=>{let e={renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,renderGutterUtility:o};return d?.items?.map(t=>(0,sg.createPortal)(t.type===`diff`?(0,Q.jsx)(vg,{version:t.version??0,item:t.item,getHoveredLine:t.instance.getHoveredLine,getAnnotationSlotName:t.instance.getAnnotationSlotName,...dp(t),...e}):(0,Q.jsx)(yg,{version:t.version??0,item:t.item,getHoveredLine:t.instance.getHoveredLine,getAnnotationSlotName:t.instance.getAnnotationSlotName,...dp(t),...e}),t.element,t.id))},[t,n,r,i,a,o,d?.items]),p=(0,Z.useMemo)(()=>s!=null&&d?.header!=null?(0,sg.createPortal)(s(),d.header):null,[s,d?.header]),m=(0,Z.useMemo)(()=>c!=null&&d?.footer!=null?(0,sg.createPortal)(c(),d.footer):null,[c,d?.footer]);return(0,Q.jsxs)(Q.Fragment,{children:[f,p,m]})}),vg=(0,Z.memo)(function({item:e,fileDiff:t,lineAnnotations:n,getHoveredLine:r,getAnnotationSlotName:i,renderCustomHeader:a,renderHeaderPrefix:o,renderHeaderFilenameSuffix:s,renderHeaderMetadata:c,renderAnnotation:l,renderGutterUtility:u}){return kd({fileDiff:t,renderCustomHeader:a==null?void 0:()=>a(e),renderHeaderPrefix:o==null?void 0:()=>o(e),renderHeaderFilenameSuffix:s==null?void 0:()=>s(e),renderHeaderMetadata:c==null?void 0:()=>c(e),renderAnnotation:l==null?void 0:(t,n)=>l(t,n,e),lineAnnotations:n,renderGutterUtility:u==null?void 0:t=>u(t,e),getHoveredLine:r,getAnnotationSlotName:i})}),yg=(0,Z.memo)(function({item:e,file:t,lineAnnotations:n,getHoveredLine:r,getAnnotationSlotName:i,renderCustomHeader:a,renderHeaderPrefix:o,renderHeaderFilenameSuffix:s,renderHeaderMetadata:c,renderAnnotation:l,renderGutterUtility:u}){return js({file:t,renderCustomHeader:a==null?void 0:()=>a(e),renderHeaderPrefix:o==null?void 0:()=>o(e),renderHeaderFilenameSuffix:s==null?void 0:()=>s(e),renderHeaderMetadata:c==null?void 0:()=>c(e),renderAnnotation:l==null?void 0:(t,n)=>l(t,n,e),lineAnnotations:n,renderGutterUtility:u==null?void 0:t=>u(t,e),getHoveredLine:r,getAnnotationSlotName:i})});function bg(){}var xg=typeof window>`u`?Z.useEffect:Z.useLayoutEffect;function Sg({fileDiff:e,oldFile:t,newFile:n,options:r,editorOptions:i,editStateKey:a,lineAnnotations:o,selectedLines:s,prerenderedHTML:c,metrics:l,hasGutterRenderUtility:u,hasCustomHeader:d,disableWorkerPool:f,edit:p,onEditChange:m,onEditComplete:h}){let g=fa(),_=s!==void 0,v=(0,Z.useContext)(Yr),y=pi(),[b,x]=(0,Z.useState)(),S=Go(e=>m?.(e)),C=m==null?void 0:S,w=(0,Z.useRef)(null),T=Go(r=>{let i=h?.(r)??`reject`;return i===`accept`&&(w.current={fileDiff:{installed:r.fileDiff,stale:r.originalFileDiff},filePair:e==null?{fileDiff:r.fileDiff,installed:{oldFile:r.oldFile,newFile:r.newFile},stale:{oldFile:t??null,newFile:n??null}}:null,annotations:{installed:r.lineAnnotations,stale:r.originalLineAnnotations}}),i}),E=h==null?void 0:T,D=Cg({acceptedCache:w,fileDiff:e,newFile:n,oldFile:t,parseDiffOptions:r?.parseDiffOptions}),O=(0,Z.useRef)(null),k=ra(),A=Tg(w,D,o),j=ni(O,A)??{fileDiff:D,lineAnnotations:o??Tc},M=(0,Z.useRef)(null),N=(0,Z.useRef)(null),P=Go(()=>{if(y==null)throw Error(`FileDiff: EditContext is not attached`);return y(`file-diff`,i??{},a)}),F=Go(e=>{if(e!=null){if(O.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);g==null?O.current=new sh(Og({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:C,onEditComplete:E,options:r}),f?void 0:v,k):O.current=new vh(Og({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:C,onEditComplete:E,options:r}),g,l,f?void 0:v,k),O.current.hydrate({fileDiff:D,fileContainer:e,lineAnnotations:o,prerenderedHTML:c})}else{if(O.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);N.current=null,O.current.cleanUp(),O.current=null,M.current=null}});xg(()=>{let{current:e}=O;if(e==null)return;let t=Og({controlledSelection:_,hasCustomHeader:d,hasGutterRenderUtility:u,onEditChange:C,onEditComplete:E,options:r}),n=!ta(e.options,t);if(e.setOptions(t),!p&&(N.current=null,M.current!=null)){let{current:e}=M;M.current=null,e()}let i=Dg(D,o,w);if(e.render({forceRender:n,fileDiff:i.fileDiff,lineAnnotations:i.lineAnnotations}),s!==void 0&&e.setSelectedLines(s),!p||M.current!=null)return;if(y==null)throw Error(`FileDiff: EditContext is not attached`);let a=()=>{O.current===e&&M.current==null&&e.__canAttachEditor()&&(M.current=kg(e,P),k())};if(e.__canAttachEditor()){N.current=null,a();return}let c=e.__prepareForEditing();if(c==null){N.current=null;return}if(N.current?.promise===c)return;let l={promise:c};N.current=l,c.then(()=>{N.current===l&&(a(),N.current=null)}).catch(e=>{N.current===l&&(N.current=null,x(e))})});let I=(0,Z.useCallback)(()=>O.current?.getHoveredLine(),[]),L=(0,Z.useCallback)(e=>O.current?.getAnnotationSlotName(e)??ti(e),[]);if(b!=null)throw b;return{...j,ref:F,getHoveredLine:I,getAnnotationSlotName:L}}function Cg({acceptedCache:e,fileDiff:t,newFile:n,oldFile:r,parseDiffOptions:i}){return(0,Z.useMemo)(()=>{if(t!=null)return t;let{current:a}=e,o=a?.filePair;if(a!=null&&o!=null){if(wg(r,n,o.stale)||wg(r,n,o.installed))return o.fileDiff;a.filePair=null}return Np(r??null,n??null,i)},[e,t,r,n,i])}function wg(e,t,n){return Ni(e??void 0,n.oldFile??void 0)&&Ni(t??void 0,n.newFile??void 0)}function Tg(e,t,n){"use no memo";return Eg(t,n,e.current)}function Eg(e,t,n){return{fileDiff:n?.fileDiff!=null&&jd(e,n.fileDiff.stale)?n.fileDiff.installed:e,lineAnnotations:n?.annotations!=null&&t===n.annotations.stale?n.annotations.installed:t}}function Dg(e,t,n){let{current:r}=n,i=Eg(e,t,r);return r==null||(r.fileDiff!=null&&!jd(e,r.fileDiff.stale)&&(r.fileDiff=null),t!==r.annotations?.stale&&(r.annotations=null),r.fileDiff==null&&r.annotations==null&&r.filePair==null&&(n.current=null)),i}function Og({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r,onEditChange:i,onEditComplete:a}){return{...e,controlledSelection:t,renderCustomHeader:n?Xr:e?.renderCustomHeader,renderGutterUtility:r?Xr:e?.renderGutterUtility,onEditChange:i,onEditComplete:a}}function kg(e,t){let n=t();try{return n.edit(e)}catch(e){throw n.cleanUp(),e}}function Ag({fileDiff:e,options:t,editorOptions:n,editStateKey:r,metrics:i,lineAnnotations:a,selectedLines:o,className:s,style:c,prerenderedHTML:l,renderAnnotation:u,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderGutterUtility:h,disableWorkerPool:g=!1,edit:_=!1,onEditChange:v,onEditComplete:y}){let{ref:b,getHoveredLine:x,getAnnotationSlotName:S,fileDiff:C,lineAnnotations:w}=Sg({fileDiff:e,options:t,editorOptions:n,editStateKey:r,metrics:i,lineAnnotations:a,selectedLines:o,prerenderedHTML:l,hasGutterRenderUtility:h!=null,hasCustomHeader:d!=null,disableWorkerPool:g,edit:_,onEditChange:v,onEditComplete:y}),T=kd({fileDiff:C,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderAnnotation:u,renderGutterUtility:h,lineAnnotations:w,getHoveredLine:x,getAnnotationSlotName:S});return(0,Q.jsx)(Ac,{ref:b,className:s,style:c,children:Zr(T,l)})}var $=gt(),jg=new WeakMap;function Mg(e){return new ip({poolSize:2,workerFactory:()=>new Worker(new URL(`/assets/pierre-worker-CcC2iNVI.js`,``+import.meta.url),{type:`module`})},{theme:e,preferredHighlighter:Us})}function Ng(e){let t=(0,$.c)(6),{children:n}=e,[r,i]=(0,Z.useState)(),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>e=>{if(!e)return;let t={standard:Mg(ac),review:Mg(zs)};return jg.set(t.standard,t.review),i(t),()=>{jg.delete(t.standard),t.standard.terminate(),t.review.terminate()}},t[0]=a):a=t[0];let[o]=(0,Z.useState)(a),s;t[1]!==n||t[2]!==r?(s=r&&(0,Q.jsx)(Yr,{value:r.standard,children:n}),t[1]=n,t[2]=r,t[3]=s):s=t[3];let c;return t[4]===s?c=t[5]:(c=(0,Q.jsx)(`div`,{ref:o,className:`contents`,children:s}),t[4]=s,t[5]=c),c}function Pg(e){let t=(0,$.c)(10),n,r;t[0]===e?(n=t[1],r=t[2]):({review:r,...n}=e,t[0]=e,t[1]=n,t[2]=r);let i=fi(),a;t[3]===i?a=t[4]:(a=i?jg.get(i):void 0,t[3]=i,t[4]=a);let o=r?a:i,s;t[5]===n?s=t[6]:(s=(0,Q.jsx)(dg,{...n}),t[5]=n,t[6]=s);let c;return t[7]!==o||t[8]!==s?(c=(0,Q.jsx)(Yr,{value:o,children:s}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function Fg(e,t){let n=(0,$.c)(9),r;n[0]!==t.connection||n[1]!==e?(r=er({connection:t.connection,scope:e}),n[0]=t.connection,n[1]=e,n[2]=r):r=n[2];let i;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(i={mode:`promiseExit`},n[3]=i):i=n[3];let[a,o]=Pn(r,i),s;n[4]===o?s=n[5]:(s=e=>{o(e)},n[4]=o,n[5]=s);let c;return n[6]!==a||n[7]!==s?(c={result:a,dismiss:s},n[6]=a,n[7]=s,n[8]=c):c=n[8],c}function Ig(e){let t=new Map;for(let n of e){let e=n.id.split(`:`)[0]||n.id,r=t.get(e)??[];r.push(n),t.set(e,r)}return[...t.entries()]}function Lg(e,t){let n=e?.filter(e=>!e.id.endsWith(`:default`));return n?.find(e=>e.id===t)?.id??n?.find(e=>/^codex:(?:.*-)?luna(?:-|$)/.test(e.id))?.id??n?.find(e=>e.id===`claude:haiku`)?.id??n?.find(e=>e.id===`claude:sonnet`)?.id}function Rg(e){return e.split(`/`).at(-1)??e}function zg(e,t){let{message:n,stashOid:r,option:i}=t;return e===`stash-create`?{action:e,message:n,includeUntracked:i}:{action:e,stashOid:r,restoreIndex:i}}function Bg(e,t,n){return{mode:e===`amend`?`amend`:`single`,message:e===`commit`?t:``,amendMessage:e===`amend`?t:n,excluded:new Set,added:new Set,groups:null}}function Vg(e,t,n=new Set){return t.some(t=>!n.has(t.path)&&e.files?.find(e=>e.path===t.path)?.fingerprint!==t.fingerprint)}var Hg=[{id:`commit`,label:`Commit…`,description:`Commit selected files`},{id:`amend`,label:`Amend last commit…`,description:`Replace the latest commit`},{id:`push`,label:`Push`,description:`Send committed changes`},{id:`pull`,label:`Pull`,description:`Bring in upstream changes`},{id:`fetch`,label:`Fetch`,description:`Update a remote-tracking branch`},{id:`stash-create`,label:`Stash changes`,description:`Set aside local changes`},{id:`stash-apply`,label:`Apply stash`,description:`Restore a stash and keep it`},{id:`stash-pop`,label:`Pop stash`,description:`Restore, then remove a stash`}],Ug=[{id:`commit`,actions:[Hg[0],Hg[1]]},{id:`sync`,actions:[Hg[2],Hg[3],Hg[4]]},{id:`stash`,actions:[Hg[5],Hg[7]]}];function Wg(e){return Hg.find(t=>t.id===e)?.label}function Gg(e,t,n){return e===`pull`&&n?n:dn(e,t)}function Kg(e){let t=(0,$.c)(18),{scope:n,context:r}=e,{connection:i}=r,a=ne(J(Fa(n,i))),o=Ae(r),s=Fg(n,r),c=a?.interrupted;if(!c)return null;let l=c.action.replaceAll(`-`,` `),u;t[0]===l?u=t[1]:(u=(0,Q.jsxs)(`p`,{className:`font-medium`,children:[`A Git action was interrupted:`,` `,l]}),t[0]=l,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:`Check the current changes before trying again.`}),t[2]=d):d=t[2];let f;t[3]===s.result?f=t[4]:(f=h(s.result)&&(0,Q.jsx)(`p`,{role:`alert`,className:`mt-1 text-destructive`,children:kt(ie(s.result.cause))}),t[3]=s.result,t[4]=f);let p;t[5]!==f||t[6]!==u?(p=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[u,d,f]}),t[5]=f,t[6]=u,t[7]=p):p=t[7];let m=s.result.waiting||!!o,g;t[8]!==s||t[9]!==c.requestId?(g=()=>s.dismiss(c.requestId),t[8]=s,t[9]=c.requestId,t[10]=g):g=t[10];let _;t[11]!==m||t[12]!==g||t[13]!==o?(_=(0,Q.jsx)(X,{size:`xs`,variant:`ghost`,disabled:m,"aria-description":o,onClick:g,children:`Got it`}),t[11]=m,t[12]=g,t[13]=o,t[14]=_):_=t[14];let v;return t[15]!==p||t[16]!==_?(v=(0,Q.jsxs)(`div`,{role:`status`,className:`flex shrink-0 items-start gap-3 border-b border-graph-4/20 bg-graph-4/10 px-3 py-2 text-xs`,children:[p,_]}),t[15]=p,t[16]=_,t[17]=v):v=t[17],v}function qg(e){let t=(0,$.c)(23),{scope:n,context:r,onOpen:i}=e,{connection:a}=r,o=ne(J(Fa(n,a))),s=o?.inProgress;if(!s)return null;let c=o.changes.filter(Jg),l=`${s===`merge`?`Merge`:`Rebase`} recovery`,u=s===`merge`?`Merge`:`Rebase`,d=c.length?`is waiting for conflict resolution`:`is ready to finish`,f;t[0]!==u||t[1]!==d?(f=(0,Q.jsxs)(`p`,{className:`font-medium`,children:[u,` `,d]}),t[0]=u,t[1]=d,t[2]=f):f=t[2];let p=c.length>0&&(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:c.map(e=>(0,Q.jsx)(X,{size:`xs`,variant:`outline`,onClick:()=>i({kind:`file`,path:e.path}),children:e.path},e.path))}),m=s===`merge`&&o.mergeHeadOid?`Use Commit from the Git menu to finish. The merge commit includes every staged resolution.`:`Stage the resolved files, then continue in a terminal in this worktree.`,h;t[3]===m?h=t[4]:(h=(0,Q.jsxs)(`p`,{children:[`Resolve the files in your editor or with your agent.`,` `,m]}),t[3]=m,t[4]=h);let g;t[5]===s?g=t[6]:(g=s===`rebase`&&(0,Q.jsx)(Xg,{command:`git rebase --continue`}),t[5]=s,t[6]=g);let _;t[7]!==o||t[8]!==s?(_=s===`merge`&&!o.mergeHeadOid&&(0,Q.jsx)(Xg,{command:`git commit`}),t[7]=o,t[8]=s,t[9]=_):_=t[9];let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(`span`,{children:`To back out:`}),t[10]=v):v=t[10];let y=`git ${s} --abort`,b;t[11]===y?b=t[12]:(b=(0,Q.jsx)(Xg,{command:y}),t[11]=y,t[12]=b);let x;t[13]!==_||t[14]!==b||t[15]!==g?(x=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[g,_,v,b]}),t[13]=_,t[14]=b,t[15]=g,t[16]=x):x=t[16];let S;return t[17]!==l||t[18]!==x||t[19]!==f||t[20]!==p||t[21]!==h?(S=(0,Q.jsxs)(`section`,{"aria-label":l,className:`shrink-0 space-y-2 border-b border-graph-4/20 bg-graph-4/10 px-3 py-2 text-xs`,children:[f,p,h,x]}),t[17]=l,t[18]=x,t[19]=f,t[20]=p,t[21]=h,t[22]=S):S=t[22],S}function Jg(e){return e.comparisons.some(Yg)}function Yg(e){return e.scope===`unmerged`}function Xg(e){let t=(0,$.c)(8),{command:n}=e,r=`Copy ${n}`,i,a;t[0]===n?(i=t[1],a=t[2]):(i=()=>tr(n,`command`),a=(0,Q.jsx)(`code`,{children:n}),t[0]=n,t[1]=i,t[2]=a);let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(q,{}),t[3]=o):o=t[3];let s;return t[4]!==r||t[5]!==i||t[6]!==a?(s=(0,Q.jsxs)(X,{size:`xs`,variant:`outline`,"aria-label":r,onClick:i,children:[a,o]}),t[4]=r,t[5]=i,t[6]=a,t[7]=s):s=t[7],s}function Zg(e,t){let n=(0,$.c)(5),r;if(n[0]!==t||n[1]!==e.state){let i;n[3]===t?i=n[4]:(i=e=>e.operations.get(t)??null,n[3]=t,n[4]=i),r=e.state.map(i),n[0]=t,n[1]=e.state,n[2]=r}else r=n[2];return it(r)}var Qg=cn(e=>vt({done:new Set,activeGroup:null,ownHead:null,busy:!1,error:null,drafted:{message:null,groups:null},draftedBy:{message:null,groups:null},editingFiles:!1})),$g=cn(e=>new Set);function e_(e,t,n){let r=(0,$.c)(14),{connection:i}=n,{operations:a}=i,o;r[0]!==t||r[1]!==e?(o=dr(e,t),r[0]=t,r[1]=e,r[2]=o):o=r[2];let s=o,c;r[3]!==s||r[4]!==a.state.value.operations?(c=()=>{let e=a.state.value.operations.get(s);return e?.receipt&&Qn(e.receipt)?e.requestId:null},r[3]=s,r[4]=a.state.value.operations,r[5]=c):c=r[5];let[l]=(0,Z.useState)(c),u=Zg(a,s),d=u?.requestId===l?null:u,f={connection:i,scope:e,action:t},{value:p}=Bc(yn(f)),m=Mt(f),h=tn(f),g=$t(m),_=$t(h),v;r[6]===d?v=r[7]:(v=d?.receipt&&Qn(d.receipt),r[6]=d,r[7]=v);let y=!!v,b;return r[8]!==p||r[9]!==g||r[10]!==d||r[11]!==_||r[12]!==y?(b={...p,execution:g,recovered:_,operation:d,canStartNew:y},r[8]=p,r[9]=g,r[10]=d,r[11]=_,r[12]=y,r[13]=b):b=r[13],b}var t_=cn(({signal:e,submit:t,recover:n})=>Ln(r=>{e!==void 0&&(r.set(t,Vn),r.set(n,Vn))}));function n_(e,t,n){let r=(0,$.c)(45),{path:i,hunk:a,signal:o,what:s,look:c,readChanges:l,notify:u,dismissNotice:d,close:f}=n,p=e_(e,`discard`,t),m=e_(e,`stash-apply`,t),h=!(!p.operation||p.canStartNew),g;r[0]===l?g=r[1]:(g=()=>or({try:l,catch:c_}),r[0]=l,r[1]=g);let _;r[2]!==f||r[3]!==d||r[4]!==u||r[5]!==m||r[6]!==g||r[7]!==s?(_={what:s,readChanges:g,notify:u,dismissNotice:d,close:f,restore:m,restoreTimeoutMs:ln,run:Nt},r[2]=f,r[3]=d,r[4]=u,r[5]=m,r[6]=g,r[7]=s,r[8]=_):_=r[8];let v=_,[y]=(0,Z.useState)(o_),[b]=(0,Z.useState)(i_),x;r[9]===Symbol.for(`react.memo_cache_sentinel`)?(x={mode:`promiseExit`},r[9]=x):x=r[9];let[S,C]=Pn(y,x),w;r[10]===Symbol.for(`react.memo_cache_sentinel`)?(w={mode:`promiseExit`},r[10]=w):w=r[10];let[T,E]=Pn(b,w),D=Bn(y),O=Bn(b),k;r[11]!==b||r[12]!==o||r[13]!==y?(k=t_({signal:o,submit:y,recover:b}),r[11]=b,r[12]=o,r[13]=y,r[14]=k):k=r[14],Vt(k);let A=S.waiting||T.waiting,j=r_,M;r[15]!==T||r[16]!==S?(M=j(S)??j(T),r[15]=T,r[16]=S,r[17]=M):M=r[17];let N;r[18]!==O||r[19]!==D?(N=()=>{D(Vn),O(Vn)},r[18]=O,r[19]=D,r[20]=N):N=r[20];let P;r[21]!==A||r[22]!==p||r[23]!==v||r[24]!==a||r[25]!==c||r[26]!==i||r[27]!==O||r[28]!==C||r[29]!==h?(P=()=>{A||h||!c||(O(Vn),C({run:()=>p.run({action:`discard`,path:i,...a?{hunk:a}:{}},Ft(c,[i])),discarding:v}))},r[21]=A,r[22]=p,r[23]=v,r[24]=a,r[25]=c,r[26]=i,r[27]=O,r[28]=C,r[29]=h,r[30]=P):P=r[30];let F;r[31]!==A||r[32]!==p.recover||r[33]!==v||r[34]!==E||r[35]!==D?(F=()=>{A||(D(Vn),E({recover:p.recover,discarding:v}))},r[31]=A,r[32]=p.recover,r[33]=v,r[34]=E,r[35]=D,r[36]=F):F=r[36];let I;return r[37]!==A||r[38]!==p.operation||r[39]!==M||r[40]!==N||r[41]!==P||r[42]!==F||r[43]!==h?(I={operation:p.operation,uncertain:h,busy:A,error:M,reset:N,run:P,checkOutcome:F},r[37]=A,r[38]=p.operation,r[39]=M,r[40]=N,r[41]=P,r[42]=F,r[43]=h,r[44]=I):I=r[44],I}function r_(e){return ne(J(e))??(h(e)?{text:kt(ie(e.cause)),moved:!1}:null)}function i_(){return An(a_)}function a_(e){return bt(e.recover(),e.discarding)}function o_(){return An(s_)}function s_(e){return bt(e.run(),e.discarding)}function c_(e){return new Wt(e,kt(e))}function l_({text:e}){return e.split(/`([^`\n]+)`/).map((e,t)=>t%2?(0,Q.jsx)(`code`,{className:`box-decoration-clone rounded bg-muted px-1 py-0.5 font-mono text-[0.9em]`,children:e},t):e)}function u_(e){let t=(0,$.c)(6),{text:n,children:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(Ks,{className:`mt-0.5 size-4 shrink-0`}),t[0]=i):i=t[0];let a;t[1]===n?a=t[2]:(a=(0,Q.jsx)(l_,{text:n}),t[1]=n,t[2]=a);let o;return t[3]!==r||t[4]!==a?(o=(0,Q.jsxs)(`p`,{role:`alert`,className:`flex gap-2 text-sm text-destructive`,children:[i,(0,Q.jsxs)(`span`,{children:[a,r]})]}),t[3]=r,t[4]=a,t[5]=o):o=t[5],o}function d_(e){let t=(0,$.c)(50),{scope:n,context:r,path:i,hunk:a,variant:o,signal:s,hiddenTrigger:c,children:l}=e,u=o===void 0?`button`:o,d=c!==void 0&&c,{connection:f}=r,p=ne(J(Fa(n,f))),m=Ho(n,f),[h,g]=(0,Z.useState)(!1),[_,y]=(0,Z.useState)(null),b=p,x=b?gn(b):null,C=b?.changes.find(e=>e.path===i),w=_??x,T;t[0]===a?T=t[1]:(T=a?h_(a):null,t[0]=a,t[1]=T);let E=T,D;t[2]!==E||t[3]!==i?(D=E?`${E} of ${Rg(i)}`:Rg(i),t[2]=E,t[3]=i,t[4]=D):D=t[4];let O=D,k;t[5]===g?k=t[6]:(k=()=>g(!1),t[5]=g,t[6]=k);let A;t[7]!==w||t[8]!==a||t[9]!==i||t[10]!==m||t[11]!==s||t[12]!==k||t[13]!==O?(A={path:i,hunk:a,signal:s,what:O,look:w,readChanges:m,notify:m_,dismissNotice:p_,close:k},t[7]=w,t[8]=a,t[9]=i,t[10]=m,t[11]=s,t[12]=k,t[13]=O,t[14]=A):A=t[14];let j=n_(n,r,A),{busy:M,error:N,uncertain:P}=j,F=Ae(r),I=!!(w&&(C||h)),[L,R]=(0,Z.useState)();s!==void 0&&s!==L&&x&&(R(s),y(x),g(!0));let z;t[15]!==j||t[16]!==d||t[17]!==a||t[18]!==E||t[19]!==i||t[20]!==g||t[21]!==y||t[22]!==I||t[23]!==x||t[24]!==u||t[25]!==F?(z=I&&!d?(0,Q.jsxs)(X,{size:u===`button`?`sm`:`xs`,disabled:!!F,"aria-description":F,variant:u===`button`?`destructive`:`ghost`,"aria-label":a?`Discard ${E} of ${Rg(i)}`:`Discard changes to ${Rg(i)}`,onClick:()=>{j.reset(),y(x),g(!0)},children:[(0,Q.jsx)(iu,{}),g_(u)]}):null,t[15]=j,t[16]=d,t[17]=a,t[18]=E,t[19]=i,t[20]=g,t[21]=y,t[22]=I,t[23]=x,t[24]=u,t[25]=F,t[26]=z):z=t[26];let B=z,V;t[27]!==M||t[28]!==j.checkOutcome||t[29]!==j.operation?.receipt||t[30]!==j.run||t[31]!==N||t[32]!==a||t[33]!==h||t[34]!==i||t[35]!==g||t[36]!==I||t[37]!==P||t[38]!==O||t[39]!==F?(V=I?(0,Q.jsx)(_s,{open:h,onOpenChange:e=>!M&&g(e),children:(0,Q.jsxs)(Ur,{children:[(0,Q.jsxs)(xo,{children:[(0,Q.jsxs)(wr,{children:[`Discard `,O,`?`]}),(0,Q.jsx)(Rr,{children:a?`Select one complete changed hunk. Only that hunk is reverted; partial selections are refused. A recovery copy is saved first.`:`The file goes back to the last commit. You can restore the changes.`})]}),(0,Q.jsx)(v,{className:`rounded-lg bg-muted/50 px-3 py-2 font-mono text-xs`,render:(0,Q.jsx)(`p`,{}),text:i}),N&&(0,Q.jsx)(u_,{text:N.text,children:N.moved?` Look at the diff again before discarding.`:``}),j.operation?.receipt?.progress.map(f_),P&&!j.operation?.receipt&&(0,Q.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`The response was lost. Check the existing discard request before trying again.`}),(0,Q.jsxs)(Ai,{children:[(0,Q.jsx)(Qi,{disabled:M,children:N?.moved?`Look again`:`Cancel`}),!N?.moved&&(P?(0,Q.jsxs)(X,{disabled:M,onClick:j.checkOutcome,children:[M&&(0,Q.jsx)(S,{"aria-hidden":`true`}),`Check outcome`]}):(0,Q.jsx)(X,{variant:`destructive`,disabled:M||!!F,"aria-description":F,onClick:j.run,children:M?`Discarding…`:`Discard`}))]})]})}):null,t[27]=M,t[28]=j.checkOutcome,t[29]=j.operation?.receipt,t[30]=j.run,t[31]=N,t[32]=a,t[33]=h,t[34]=i,t[35]=g,t[36]=I,t[37]=P,t[38]=O,t[39]=F,t[40]=V):V=t[40];let H=V;if(l){let e;t[41]!==l||t[42]!==B?(e=l(B),t[41]=l,t[42]=B,t[43]=e):e=t[43];let n;return t[44]!==H||t[45]!==e?(n=(0,Q.jsxs)(Q.Fragment,{children:[e,H]}),t[44]=H,t[45]=e,t[46]=n):n=t[46],n}let U;return t[47]!==H||t[48]!==B?(U=(0,Q.jsxs)(Q.Fragment,{children:[B,H]}),t[47]=H,t[48]=B,t[49]=U):U=t[49],U}function f_(e){return(0,Q.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:e},e)}function p_(e){return ms.close(e)}function m_(e){return ms.add(e)}function h_({startLine:e,endLine:t}){return e===t?`line ${e}`:`lines ${e}–${t}`}function g_(e){return e===`quiet`?(0,Q.jsx)(`span`,{className:`max-narrow:sr-only`,children:`Discard`}):e===`compact`?`Discard selection`:`Discard`}var __=H(`flex w-fit items-stretch *:focus-visible:relative *:focus-visible:z-10 has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1`,{variants:{orientation:{horizontal:`*:data-slot:rounded-r-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-r-md! [&>[data-slot]~[data-slot]]:rounded-l-none [&>[data-slot]~[data-slot]]:border-l-0`,vertical:`flex-col *:data-slot:rounded-b-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-md! [&>[data-slot]~[data-slot]]:rounded-t-none [&>[data-slot]~[data-slot]]:border-t-0`}},defaultVariants:{orientation:`horizontal`}});function v_({className:e,orientation:t,...n}){return(0,Q.jsx)(`div`,{role:`group`,"data-slot":`button-group`,"data-orientation":t,className:Tn(__({orientation:t}),e),...n})}function y_(e,t,n){let r=(0,$.c)(32),i=e_(e,`fetch`,t),a=e_(e,`pull`,t),o=e_(e,`push`,t),s=e_(e,`stash-apply`,t),c;r[0]===n.details?c=r[1]:(c=()=>or({try:n.details.read,catch:S_}),r[0]=n.details,r[1]=c);let l;r[2]!==n.details||r[3]!==c?(l={...n.details,read:c},r[2]=n.details,r[3]=c,r[4]=l):l=r[4];let u;r[5]!==n||r[6]!==l?(u={...n,details:l},r[5]=n,r[6]=l,r[7]=u):u=r[7];let d=u,f,p;r[8]!==i||r[9]!==a||r[10]!==o?(f={fetch:i,pull:a,push:o},p=[`fetch`,`pull`,`push`].map(e=>({name:e,operation:f[e].operation,canStartNew:f[e].canStartNew,checking:f[e].recovered.waiting})).find(x_),r[8]=i,r[9]=a,r[10]=o,r[11]=f,r[12]=p):(f=r[11],p=r[12]);let m=p,h;r[13]!==d||r[14]!==f||r[15]!==m?(h=()=>{m&&Nt(z(d,f[m.name],m.name))},r[13]=d,r[14]=f,r[15]=m,r[16]=h):h=r[16];let g;r[17]!==d||r[18]!==f?(g=(e,t)=>Nt(Pe(d,f[e],e,t)),r[17]=d,r[18]=f,r[19]=g):g=r[19];let _;r[20]!==d||r[21]!==s?(_=e=>Nt(Re(d,s,e)),r[20]=d,r[21]=s,r[22]=_):_=r[22];let v;r[23]!==n.onLooked||r[24]!==n.refreshLook?(v=()=>Ot(En(or({try:n.refreshLook,catch:b_}),n.onLooked)),r[23]=n.onLooked,r[24]=n.refreshLook,r[25]=v):v=r[25];let y;return r[26]!==m||r[27]!==h||r[28]!==g||r[29]!==_||r[30]!==v?(y={running:m,checkOutcome:h,runNetwork:g,restoreDiscarded:_,lookAgain:v},r[26]=m,r[27]=h,r[28]=g,r[29]=_,r[30]=v,r[31]=y):y=r[31],y}function b_(e){return new Wt(e,kt(e))}function x_(e){let{operation:t,canStartNew:n}=e;return t!=null&&!n}function S_(e){return new Wt(e,kt(e))}function C_(e){let t=(0,$.c)(12),{action:n,className:r}=e;switch(n){case`amend`:{let e;return t[0]===r?e=t[1]:(e=(0,Q.jsx)(Ir,{className:r}),t[0]=r,t[1]=e),e}case`push`:{let e;return t[2]===r?e=t[3]:(e=(0,Q.jsx)(Er,{className:r}),t[2]=r,t[3]=e),e}case`pull`:case`fetch`:{let e;return t[4]===r?e=t[5]:(e=(0,Q.jsx)(ul,{className:r}),t[4]=r,t[5]=e),e}case`stash-create`:{let e;return t[6]===r?e=t[7]:(e=(0,Q.jsx)(ol,{className:r}),t[6]=r,t[7]=e),e}case`stash-apply`:case`stash-pop`:{let e;return t[8]===r?e=t[9]:(e=(0,Q.jsx)(il,{className:r}),t[8]=r,t[9]=e),e}default:{let e;return t[10]===r?e=t[11]:(e=(0,Q.jsx)(Ml,{className:r}),t[10]=r,t[11]=e),e}}}function w_(e){if(!e)return null;for(let t of e.elements){let e=t.tagName;if(e===`BUTTON`||e===`INPUT`){let e=t;if(e.type===`submit`)return e}}return null}var T_=`data-checked`,E_=`data-unchecked`;function D_(e){return{checked(t){return e.indeterminate?{}:t?{[T_]:``}:{[E_]:``}},...Ke}}var O_=Z.createContext(void 0);function k_(){return Z.useContext(O_)}var A_=Z.createContext(void 0);function j_(){let e=Z.useContext(A_);if(e===void 0)throw Error(Fe(14));return e}var M_=`data-parent`,N_=Z.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i=!1,"aria-labelledby":o,disabled:s=!1,form:c,id:l,indeterminate:u=!1,inputRef:d,name:f,onCheckedChange:m,parent:h=!1,readOnly:g=!1,render:_,required:v=!1,uncheckedValue:y,value:b,nativeButton:x=!1,style:S,...C}=e,{clearErrors:w}=Be(),{disabled:T,name:E,setDirty:D,setFilled:O,setFocused:A,setTouched:j,state:M,validationMode:N,validityData:P,validation:F}=Ie(),I=wd(),{labelId:L,registerControlId:R,getDescriptionProps:z}=V(),B=k_(),H=B?.allValues===void 0?void 0:B.parent,U=H!==void 0,W=T||I.disabled||B?.disabled||s,ee=E??f,q=b??ee,te=a(),ne=B?.registerControlId!==R,re=K({id:l||void 0,enabled:ne}),J=x?re:te,ie={};U&&(h?ie=H.getParentProps():q!==void 0&&(ie=H.getChildProps(q)));let{checked:ae=n,indeterminate:oe=u,onCheckedChange:se,...ce}=ie,Y=B?.value,le=Z.useRef(null),{getButtonProps:ue,buttonRef:de}=dt({disabled:W,native:x}),fe=B?.validation??F,[pe,me]=Un({controlled:q!==void 0&&Y!==void 0&&!h?Y.includes(q):ae,default:i,name:`Checkbox`,state:`checked`}),he=U?!!ae:pe,ge=U&&oe||u;k(le,te,pe,void 0,!B&&!W,f);let _e=H?.registerChildId,ve=Z.useRef(null),ye=fe.registerInput,be=B?q:void 0,xe=Z.useCallback(e=>ye(e,{controlRef:le,value:be}),[ye,be]),Se=sr(d,ve,h?void 0:xe),Ce=Dn(o,L,ve,!x,re);We(()=>{ve.current&&(ve.current.indeterminate=ge),B||O(pe)},[pe,ge,B,O]),Me(pe,()=>{B||(w(ee),D(pe!==P.initialValue),fe.change(pe))});let we=st({checked:pe,disabled:W,form:c,name:h?void 0:ee,id:x?void 0:re,required:v,ref:Se,style:ee?rr:p,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(g){e.preventDefault();return}let t=e.currentTarget.checked,n=yt(hn,e.nativeEvent);if(m?.(t,n),!n.isCanceled&&(se?.(t,n),!n.isCanceled&&(me(t),q!==void 0&&B!==void 0&&!h&&!U))){let e=t?[...B.value,q]:B.value.filter(e=>e!==q);B.setValue(e,n)}},onClick(e){e.stopPropagation()},onFocus(){le.current?.focus()}},b===void 0?Gn:{value:(B?pe&&b:b)||``},z,e=>fe.getValidationProps(W,e));Z.useEffect(()=>{if(!H||q===void 0)return;let e=H.disabledStatesRef.current;return e.set(q,W),()=>{e.delete(q)}},[H,W,q]);let Te=Z.useMemo(()=>({...M,checked:he,disabled:W,readOnly:g,required:v,indeterminate:ge}),[M,he,W,g,v,ge]),Ee=D_(Te),De=pr(`span`,e,{state:Te,ref:[de,le,t],props:[{id:J,role:`checkbox`,"aria-checked":ge?`mixed`:he,"aria-readonly":g||void 0,"aria-required":v||void 0,"aria-labelledby":Ce,[M_]:h?``:void 0,onFocus(){W||A(!0)},onBlur(){let e=ve.current;e&&(j(!0),A(!1),N===`onBlur`&&fe.commit(B?Y:e.checked))},onKeyDown(e){if(e.key!==`Enter`||(e.preventBaseUIHandler(),e.defaultPrevented))return;let t=ve.current?.form??null,n=e.currentTarget,r=e.nativeEvent,i=e.preventDefault,a=r.preventDefault,o=!1;e.preventDefault=()=>{o=!0,i.call(e)},r.preventDefault=()=>{o=!0,a.call(r)},a.call(r),G(n).queueMicrotask(()=>{e.preventDefault=i,r.preventDefault=a,o||w_(t)?.click()})},onClick(e){if(g||W)return;e.preventDefault();let t=ve.current;t&&Zt(t,e)}},C,ce,ue,z,e=>fe.getValidationProps(W,e)],stateAttributesMapping:Ee}),Oe=De.props.id;return We(()=>{if(_e&&!h&&q!==void 0&&Oe!==void 0)return _e(q,Oe)},[_e,h,q,Oe]),(0,Q.jsxs)(A_.Provider,{value:Te,children:[De,!pe&&!B&&ee&&!h&&y!==void 0&&(0,Q.jsx)(`input`,{type:`hidden`,form:c,name:ee,value:y,disabled:W}),(0,Q.jsx)(`input`,{...we,suppressHydrationWarning:!0})]})}),P_=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=j_(),c=s.checked||s.indeterminate,{mounted:l,transitionStatus:u,setMounted:d}=He(c),f=Z.useRef(null),p={...s,transitionStatus:u};Ye({batch:!0,enabled:!c,open:c,ref:f,onComplete(){c||d(!1)}});let m={...D_(s),...le},h=a||l,g=pr(`span`,e,{ref:[t,f],state:p,stateAttributesMapping:m,props:o});return h?g:null});function F_({className:e,...t}){return(0,Q.jsx)(N_,{"data-slot":`checkbox`,className:Tn(`peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-shadow outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary`,e),...t,children:(0,Q.jsx)(P_,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,Q.jsx)(Te,{})})})}var I_={added:`Added`,modified:`Modified`,deleted:`Deleted`,renamed:`Renamed`,"type-changed":`Type changed`};function L_(e,t){if(e.status===`renamed`&&e.previousPath!==null&&e.previousPath!==void 0)return`Renamed from ${e.previousPath}`;let n=I_[e.status];return e.path===t?n:`${n} as ${e.path}`}function R_(e){return e.body===null||e.body===void 0?e.subject:`${e.subject}\n\n${e.body}`}function z_(e){return[...new Set([e.oldPath,e.newPath].filter(e=>e!=null))]}function B_(e){return e.newPath??e.oldPath??`Unknown path`}var V_=7;function H_(e){return e.slice(0,V_)}function U_(e){return e.replace(/^refs\/(?:heads|remotes|tags)\//u,``)}function W_(e){return e.filter(e=>e.kind!==`head`)}function G_(e,t){return e.kind===`local-branch`&&`refs/heads/${e.name}`===t}function K_(e){switch(e?.head.kind){case`attached`:return U_(e.head.ref);case`unborn`:return`No commits yet on ${U_(e.head.ref)}`;case`detached`:return`Detached HEAD`;default:return`This branch`}}function q_(e){return e===`shallow`?`Shallow clone: older history is not available.`:e===`wide`?`Too many branches meet here to continue past this point.`:`Start of history.`}function J_(e,t){return e==null?{name:K_(t),counts:null,upstream:`Branch status unavailable`}:e.name?e.upstream?{name:e.name,counts:`${e.ahead} ahead · ${e.behind} behind`,upstream:`against ${e.upstream}`}:{name:e.name,counts:null,upstream:`No upstream`}:{name:`Detached HEAD`,counts:null,upstream:`No branch checked out`}}function Y_(e,t,n,r){let i=(0,$.c)(29),{expectedStatus:a,onBusy:o,onLookAgain:s}=r,c=e_(e,t,n),[l]=(0,Z.useState)($_),u;i[0]===Symbol.for(`react.memo_cache_sentinel`)?(u={mode:`promiseExit`},i[0]=u):u=i[0];let[d,f]=Pn(l,u),p=Bn(l),m=c.execution.waiting||c.recovered.waiting||d.waiting,h=!(!c.operation||c.canStartNew),g=Q_,_=c.operation?.receipt,v;i[1]!==c.execution||i[2]!==c.recovered||i[3]!==d?(v=g(c.execution)??g(d)??g(c.recovered),i[1]=c.execution,i[2]=c.recovered,i[3]=d,i[4]=v):v=i[4];let y;i[5]!==m||i[6]!==a||i[7]!==c||i[8]!==o||i[9]!==p||i[10]!==h?(y=e=>{m||h||(o(!0),p(Vn),c.reset(),Nt(c.run(e,Ft(a,a.files?.map(Z_)??[],void 0,!0)).pipe(Rn(fr(()=>o(!1))),bn)))},i[5]=m,i[6]=a,i[7]=c,i[8]=o,i[9]=p,i[10]=h,i[11]=y):y=i[11];let b;i[12]!==m||i[13]!==c||i[14]!==s||i[15]!==f?(b=()=>{s&&!m&&(c.reset(),f({read:or({try:s,catch:X_}),startNew:c.startNew()}))},i[12]=m,i[13]=c,i[14]=s,i[15]=f,i[16]=b):b=i[16];let x;i[17]!==c||i[18]!==p?(x=()=>{c.reset(),p(Vn),Nt(c.recover().pipe(bn))},i[17]=c,i[18]=p,i[19]=x):x=i[19];let S;return i[20]!==m||i[21]!==c.operation||i[22]!==_||i[23]!==v||i[24]!==y||i[25]!==b||i[26]!==x||i[27]!==h?(S={operation:c.operation,messageLimit:ur,outcome:_,busy:m,uncertain:h,error:v,onSubmit:y,lookAgain:b,checkOutcome:x},i[20]=m,i[21]=c.operation,i[22]=_,i[23]=v,i[24]=y,i[25]=b,i[26]=x,i[27]=h,i[28]=S):S=i[28],S}function X_(e){return new Wt(e,kt(e))}function Z_(e){return e.path}function Q_(e){return h(e)?ie(e.cause):null}function $_(){return An(ev)}function ev(e){return W(e.read,e.startNew)}function tv(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 nv(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 rv(e){let t=e%100;return`${e}${t>=11&&t<=13?`th`:[`th`,`st`,`nd`,`rd`][e%10]??`th`}`}function iv(e){let t=ov(e),n=t.at(-1);return{snapshot:t[0]?.snapshot??null,commits:t.flatMap(e=>e.commits),nextAfter:n?.nextAfter??null,boundary:n?.boundary??null,restarted:n?.restarted??!1}}function av(e){let t=ov(e),n=t.at(-1);return{commits:t.flatMap(e=>e.commits),tip:t[0]?.tip??null,nextAfter:n?.nextAfter??null,boundary:n?.boundary??null,restarted:t[0]?.restarted??!1}}function ov(e){let t=e.findLastIndex(e=>e.restarted);return t===-1?e:e.slice(t)}var sv=cn(e=>Ln({loaded:0,selected:void 0,scrollOffset:0,graphScrollOffset:0,resetId:0}).pipe(et)),cv=cn(({connection:e,scope:t})=>te(e,t,[`history`],n=>dv(n,sv({connection:e,scope:t,kind:`commits`}),n=>Ct(function*(){let r=yield*(yield*Kn(e)).request(e=>e.changes.listCommits({params:{worktreeId:t.worktreeId},query:{after:n?.after,tip:n?.tip}}));return yield*In(e),r}),e=>e.nextAfter&&e.tip?{after:e.nextAfter,tip:e.tip}:void 0),Yt(e))),lv=cn(({connection:e,scope:t,oid:n,parent:r=1})=>ge(e,t,[`commit`,n,r],Ct(function*(){let i=yield*(yield*Kn(e)).request(e=>e.changes.readCommitFiles({params:{worktreeId:t.worktreeId,oid:n},query:r===1?{}:{parent:r}}));return yield*In(e,i.commit.oid===n&&(i.comparison.kind===`empty-tree`||i.comparison.parentNumber===r)),i}),Yt(e)).pipe(L)),uv=cn(({connection:e,scope:t,path:n})=>te(e,t,[`history`,`file`,n],r=>dv(r,sv({connection:e,scope:t,kind:`file`,path:n}),r=>Ct(function*(){let i=yield*(yield*Kn(e)).request(e=>e.changes.listFileCommits({params:{worktreeId:t.worktreeId},query:{path:n,limit:100,after:r}}));return yield*In(e),i}),e=>e.nextAfter),Yt(e)));function dv(e,t,n,r){let i=e.once(t).loaded,a=0;return ve(void 0,o=>Ct(function*(){let s=[],c=a,l=o,u=!1;do{let e=yield*n(l);e.restarted&&(c=0,u=!0),c+=e.commits.length,s.push(e),l=r(e)}while(o===void 0&&c<i&&l!==void 0&&!u);a=c;let d=e.once(t);return e.set(t,{...d,loaded:a,...u?{selected:void 0,scrollOffset:0,graphScrollOffset:0,resetId:d.resetId+1}:{}}),[s,l===void 0?De():M(l)]}))}var fv=cn(e=>ut(uv(e),e=>Ut(e,e=>av(e.items))).pipe(L)),pv=cn(e=>ut(cv(e),e=>Ut(e,e=>iv(e.items))).pipe(L));cn(e=>zt((t,n)=>{let r=sv({...e,kind:`commit`,oid:t.oid,parent:t.parent}),i=n(r);n.set(r,{...i,selected:t.path,scrollOffset:0,resetId:i.resetId+1})}));function mv(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=lv({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],Bc(o).value}function hv(e){let t=(0,$.c)(13),{tracking:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsx)(yi,{className:`mt-0.5 size-3.5 shrink-0 text-muted-foreground`}),t[0]=r):r=t[0];let i;t[1]===n.name?i=t[2]:(i=(0,Q.jsx)(v,{className:`min-w-0 flex-1 font-mono text-caption font-medium text-foreground`,text:n.name}),t[1]=n.name,t[2]=i);let a;t[3]===n.counts?a=t[4]:(a=n.counts!==null&&(0,Q.jsx)(`span`,{className:`shrink-0 text-2xs text-muted-foreground tabular-nums`,children:n.counts}),t[3]=n.counts,t[4]=a);let o;t[5]!==i||t[6]!==a?(o=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[i,a]}),t[5]=i,t[6]=a,t[7]=o):o=t[7];let s;t[8]===n.upstream?s=t[9]:(s=(0,Q.jsx)(v,{className:`text-2xs text-muted-foreground`,text:n.upstream}),t[8]=n.upstream,t[9]=s);let c;return t[10]!==o||t[11]!==s?(c=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[r,(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[o,s]})]}),t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function gv(e,t){let n=(0,$.c)(19),r;n[0]!==e||n[1]!==t?(r=cv({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=pv({connection:e,scope:t}),n[3]=e,n[4]=t,n[5]=a):a=n[5];let{result:o,value:s}=Bc(a),c=Bn(i),l;n[6]!==e||n[7]!==t?(l=sv({connection:e,scope:t,kind:`commits`}),n[6]=e,n[7]=t,n[8]=l):l=n[8];let u=l,d=$t(u,_v),f=Bn(u),p;n[9]===f?p=n[10]:(p=e=>f(t=>({...t,selected:e})),n[9]=f,n[10]=p);let m;n[11]===c?m=n[12]:(m=()=>c(void 0),n[11]=c,n[12]=m);let h;return n[13]!==o||n[14]!==d||n[15]!==p||n[16]!==m||n[17]!==s?(h={...s,result:o,selected:d,select:p,readMore:m},n[13]=o,n[14]=d,n[15]=p,n[16]=m,n[17]=s,n[18]=h):h=n[18],h}function _v(e){return e.selected}function vv(e){let t=(0,$.c)(3),{enabled:n,onVisible:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,Q.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 yv(e){let t=(0,$.c)(5),[n,r]=(0,Z.useState)(1),i;t[0]===e?i=t[1]:(i=function(t){if(!t)return;let n=t.querySelector(`[data-ref-measurement]`);if(!n)return;let i=()=>{let i=Array.from(n.children,xv),a=i.pop()??0,o=Number.parseFloat(getComputedStyle(t).columnGap),s=t.getBoundingClientRect().width;if(i.reduce(bv,0)+Math.max(0,i.length-1)*o<=s){r(e);return}let c=0,l=0;for(let t of i){c+=t+(l===0?0:o);let n=l+1===e?0:o+a;if(c+n>s)break;l+=1}r(Math.max(1,l))},a=new ResizeObserver(i);return a.observe(t),a.observe(n),i(),()=>a.disconnect()},t[0]=e,t[1]=i);let a=i,o;return t[2]!==a||t[3]!==n?(o={row:a,visibleCount:n},t[2]=a,t[3]=n,t[4]=o):o=t[4],o}function bv(e,t){return e+t}function xv(e){return e.getBoundingClientRect().width}var Sv=`min-w-0 max-w-40`;function Cv(e){let t=(0,$.c)(21),{refs:n,current:i,onOpenCommit:a}=e,o=i===void 0?Ev:i,{row:s,visibleCount:c}=yv(n.length),l;if(t[0]!==o||t[1]!==a||t[2]!==n||t[3]!==s||t[4]!==c){let e=n.slice(c),i;t[6]===n?i=t[7]:(i=n.map(Tv),t[6]=n,t[7]=i);let u;t[8]===n.length?u=t[9]:(u=(0,Q.jsxs)(Mn,{variant:`secondary`,className:Sv,children:[`+`,n.length]}),t[8]=n.length,t[9]=u);let d;t[10]!==i||t[11]!==u?(d=(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none invisible absolute inset-0 overflow-hidden`,children:(0,Q.jsxs)(`div`,{"data-ref-measurement":!0,className:`flex w-max gap-1`,children:[i,u]})}),t[10]=i,t[11]=u,t[12]=d):d=t[12];let f;if(t[13]!==o||t[14]!==a||t[15]!==n||t[16]!==c){let e;t[18]!==o||t[19]!==a?(e=e=>(0,Q.jsx)(v,{text:e.name,renderTrigger:t=>(0,Q.jsxs)(Mn,{render:(0,Q.jsx)(`button`,{type:`button`,onClick:a}),variant:o(e)?`brand-soft`:`outline`,className:`${Sv} pointer-events-auto shrink`,children:[e.kind===`tag`&&(0,Q.jsx)(nu,{"aria-hidden":`true`}),t]}),children:e.name},`${e.kind}:${e.name}`),t[18]=o,t[19]=a,t[20]=e):e=t[20],f=n.slice(0,c).map(e),t[13]=o,t[14]=a,t[15]=n,t[16]=c,t[17]=f}else f=t[17];l=(0,Q.jsxs)(`div`,{ref:s,className:`pointer-events-none relative flex min-w-0 items-center gap-1`,children:[d,f,e.length>0&&(0,Q.jsxs)(sn,{children:[(0,Q.jsxs)(Fn,{render:(0,Q.jsx)(Mn,{render:(0,Q.jsx)(`button`,{type:`button`}),variant:`secondary`,className:`${Sv} pointer-events-auto`,"aria-label":`Show ${e.length} more ${r(e.length,`ref`)}`}),children:[`+`,e.length]}),(0,Q.jsxs)(On,{align:`start`,className:`max-w-[calc(100vw-2rem)]`,children:[(0,Q.jsx)(pn,{children:`More refs`}),(0,Q.jsx)(`ul`,{className:`max-h-64 overflow-y-auto text-xs`,children:e.map(wv)})]})]})]}),t[0]=o,t[1]=a,t[2]=n,t[3]=s,t[4]=c,t[5]=l}else l=t[5];return l}function wv(e){return(0,Q.jsxs)(`li`,{className:`flex items-center gap-1 py-1 break-all`,children:[e.kind===`tag`&&(0,Q.jsx)(nu,{"aria-hidden":`true`,className:`size-3 shrink-0`}),e.name]},`${e.kind}:${e.name}`)}function Tv(e){return(0,Q.jsxs)(Mn,{variant:`secondary`,className:Sv,children:[e.kind===`tag`&&(0,Q.jsx)(nu,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{"data-label":e.name,className:`before:content-[attr(data-label)]`})]},`${e.kind}:${e.name}`)}function Ev(){return!1}function Dv(e){let t=(0,$.c)(74),{commit:n,selected:r,height:i,inset:a,layout:o,head:s,headRef:c,onSelect:l,openToSide:u,children:d}=e,f=o===void 0?`stacked`:o,p=s!==void 0&&s,[m,h]=(0,Z.useState)(!1),g;t[0]!==l||t[1]!==u?(g=e=>l(u!==void 0&&e.altKey),t[0]=l,t[1]=u,t[2]=g):g=t[2];let _=g,y;t[3]===c?y=t[4]:(y=e=>G_(e,c),t[3]=c,t[4]=y);let b=y,x;if(t[5]!==n.refs||t[6]!==b){let e;t[8]===b?e=t[9]:(e=(e,t)=>Number(b(t))-Number(b(e)),t[8]=b,t[9]=e),x=W_(n.refs).toSorted(e),t[5]=n.refs,t[6]=b,t[7]=x}else x=t[7];let S=x,C;t[10]===p?C=t[11]:(C=p?(0,Q.jsx)(Mn,{variant:`brand`,className:`relative shrink-0`,children:`HEAD`}):null,t[10]=p,t[11]=C);let w=C,T=f===`stacked`&&`font-medium`,E=(p||r)&&`font-semibold`,D;t[12]!==T||t[13]!==E?(D=Tn(`flex min-w-0 items-center gap-1 text-ui leading-4.5 font-normal`,T,E),t[12]=T,t[13]=E,t[14]=D):D=t[14];let O;t[15]===n.parentOids.length?O=t[16]:(O=n.parentOids.length>1&&(0,Q.jsx)(Il,{"aria-label":`Merge commit`,className:`size-3.5 shrink-0 text-muted-foreground`}),t[15]=n.parentOids.length,t[16]=O);let k;t[17]===n.subject?k=t[18]:(k=(0,Q.jsx)(v,{text:n.subject}),t[17]=n.subject,t[18]=k);let A=f===`stacked`&&w,j;t[19]!==O||t[20]!==k||t[21]!==A||t[22]!==D?(j=(0,Q.jsxs)(`span`,{className:D,children:[O,k,A]}),t[19]=O,t[20]=k,t[21]=A,t[22]=D,t[23]=j):j=t[23];let M=j,N;t[24]===n.author.timestamp?N=t[25]:(N=wn(n.author.timestamp),t[24]=n.author.timestamp,t[25]=N);let P=N,F;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>{e&&h(!1)},t[26]=F):F=t[26];let I;t[27]!==i||t[28]!==a?(I={height:i,paddingLeft:a},t[27]=i,t[28]=a,t[29]=I):I=t[29];let L=f===`stacked`?`flex-col justify-center gap-0.5`:`items-center gap-3`,R=i===void 0&&`py-1.5`,z=r&&`bg-muted ring-1 ring-border ring-inset`,B=p&&`bg-muted ring-1 ring-border ring-inset`,V;t[30]!==L||t[31]!==R||t[32]!==z||t[33]!==B?(V=Tn(`relative flex w-full rounded-lg px-2 text-left transition-colors hover:bg-accent`,L,R,z,B),t[30]=L,t[31]=R,t[32]=z,t[33]=B,t[34]=V):V=t[34];let H;t[35]!==I||t[36]!==V?(H=(0,Q.jsx)(`div`,{style:I,className:V}),t[35]=I,t[36]=V,t[37]=H):H=t[37];let U;t[38]!==P||t[39]!==d||t[40]!==n.author.name||t[41]!==n.oid||t[42]!==b||t[43]!==w||t[44]!==a||t[45]!==f||t[46]!==S||t[47]!==_||t[48]!==r||t[49]!==M?(U=f===`stacked`?(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1.5`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:_,className:Tn(`block min-w-0 text-left before:absolute before:inset-0 before:rounded-lg`,S.length>0?`max-w-3/5`:`flex-1`),children:[M,(0,Q.jsxs)(`span`,{style:{left:a},className:`absolute inset-x-2 mt-0.5 flex min-w-0 gap-1.5 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`code`,{className:`font-mono`,children:H_(n.oid)}),(0,Q.jsx)(v,{text:n.author.name}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,Q.jsx)(`span`,{className:`shrink-0`,children:P})]}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5 block h-4`}),d!==void 0&&(0,Q.jsx)(`span`,{className:`flex min-w-0`,children:d})]}),S.length>0&&(0,Q.jsx)(`div`,{className:`flex h-4.5 min-w-0 flex-1 flex-col justify-center`,children:(0,Q.jsx)(Cv,{refs:S,current:b,onOpenCommit:_})})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`code`,{className:`hidden w-16 shrink-0 font-mono text-xs text-muted-foreground @md/graph:block`,children:H_(n.oid)}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:_,className:`flex max-w-3/5 min-w-0 shrink-0 items-center text-left before:absolute before:inset-0 before:rounded-lg`,children:[M,(0,Q.jsx)(`span`,{className:`sr-only`,children:` ${H_(n.oid)} ${n.author.name} ${P}`})]}),w,(0,Q.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:S.length>0&&(0,Q.jsx)(Cv,{refs:S,current:b,onOpenCommit:_})})]}),(0,Q.jsx)(v,{className:`hidden w-28 shrink-0 text-xs text-muted-foreground @2xl/graph:block`,text:n.author.name}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-right text-xs whitespace-nowrap text-muted-foreground tabular-nums`,children:P})]}),t[38]=P,t[39]=d,t[40]=n.author.name,t[41]=n.oid,t[42]=b,t[43]=w,t[44]=a,t[45]=f,t[46]=S,t[47]=_,t[48]=r,t[49]=M,t[50]=U):U=t[50];let W;t[51]!==H||t[52]!==U?(W=(0,Q.jsx)(di,{render:H,children:U}),t[51]=H,t[52]=U,t[53]=W):W=t[53];let G=!m,K;t[54]===u?K=t[55]:(K=u&&(0,Q.jsxs)($i,{onClick:()=>{(0,sg.flushSync)(()=>h(!0)),u.open()},children:[(0,Q.jsx)(gi,{}),u.label]}),t[54]=u,t[55]=K);let ee;t[56]===n.oid?ee=t[57]:(ee=()=>tr(n.oid,`commit id`),t[56]=n.oid,t[57]=ee);let te;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Q.jsx)(q,{}),t[58]=te):te=t[58];let ne;t[59]===ee?ne=t[60]:(ne=(0,Q.jsxs)($i,{onClick:ee,children:[te,`Copy commit id`]}),t[59]=ee,t[60]=ne);let re;t[61]===n?re=t[62]:(re=()=>tr(R_(n),`commit message`),t[61]=n,t[62]=re);let J;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,Q.jsx)(q,{}),t[63]=J):J=t[63];let ie;t[64]===re?ie=t[65]:(ie=(0,Q.jsxs)($i,{onClick:re,children:[J,`Copy message`]}),t[64]=re,t[65]=ie);let ae;t[66]!==G||t[67]!==K||t[68]!==ne||t[69]!==ie?(ae=(0,Q.jsxs)(Qr,{finalFocus:G,children:[K,ne,ie]}),t[66]=G,t[67]=K,t[68]=ne,t[69]=ie,t[70]=ae):ae=t[70];let oe;return t[71]!==W||t[72]!==ae?(oe=(0,Q.jsxs)(ia,{onOpenChange:F,children:[W,ae]}),t[71]=W,t[72]=ae,t[73]=oe):oe=t[73],oe}var Ov=[`text-graph-1`,`text-graph-2`,`text-graph-3`,`text-graph-4`,`text-graph-5`,`text-graph-6`],kv=e=>13+e*16,Av=e=>Ov[e%Ov.length]??Ov[0];function jv(e){let t=(0,$.c)(7),{rows:n,width:r,rowHeight:i}=e,a=n.length*i,o;t[0]!==i||t[1]!==n?(o=n.map((e,t)=>{let r=t*i+i*.5,a=n[t+1],o=e.lanesAfter.flatMap((r,i)=>{if(r==null||a==null)return[];let o=e.outgoing.includes(i)?kv(e.lane):kv(i),s=r===a.commit.oid?kv(a.lane):kv(i),c=[o];return o!==kv(i)&&n[t-1]?.lanesAfter[i]===r&&c.push(kv(i)),c.map(e=>({lane:i,startX:e,endX:s}))}),s=e.commit.parentOids.length>1;return(0,Q.jsxs)(`g`,{children:[o.map(e=>{let{lane:t,startX:n,endX:a}=e;return(0,Q.jsx)(`path`,{d:n===a?`M ${n} ${r} L ${a} ${r+i}`:`M ${n} ${r} C ${n} ${r+i*.5}, ${a} ${r+i*.5}, ${a} ${r+i}`,fill:`none`,stroke:`currentColor`,strokeWidth:tt,className:Av(t)},`${t}-${n}`)}),(0,Q.jsx)(`circle`,{cx:kv(e.lane),cy:r,r:s?5:4,fill:s?`var(--card)`:`currentColor`,stroke:`currentColor`,strokeWidth:2,className:Av(e.lane)})]},e.commit.oid)}),t[0]=i,t[1]=n,t[2]=o):o=t[2];let s;return t[3]!==a||t[4]!==o||t[5]!==r?(s=(0,Q.jsx)(`svg`,{"aria-hidden":`true`,className:`pointer-events-none absolute top-2 left-1.5`,"data-testid":`history-graph`,width:r,height:a,children:o}),t[3]=a,t[4]=o,t[5]=r,t[6]=s):s=t[6],s}function Mv(e){let t=(0,$.c)(47),{label:n,layout:r,history:i,selected:a,onSelect:o,sideLabel:s,highlightHead:c}=e,l=c!==void 0&&c,u,d,f,p,m,h,g,_;if(t[0]!==l||t[1]!==i.commits||t[2]!==i.snapshot||t[3]!==n||t[4]!==r||t[5]!==o||t[6]!==a||t[7]!==s){d=tv(i.commits),_=nv(d),u=r===`columns`?30:44;let e=i.snapshot?.tipOid,c=i.snapshot?.head.kind===`attached`?i.snapshot.head.ref:void 0;g=`relative py-2 pr-3 pl-1.5`,f=n,p=`flex flex-col`,m=Nv;let v;t[16]!==c||t[17]!==l||t[18]!==r||t[19]!==o||t[20]!==u||t[21]!==a||t[22]!==s||t[23]!==e||t[24]!==_?(v=t=>{let{commit:n}=t;return(0,Q.jsx)(`li`,{children:(0,Q.jsx)(Dv,{commit:n,selected:a===n.oid,height:u,inset:_+8,layout:r,head:l&&n.oid===e,headRef:c,onSelect:e=>o(n.oid,e),openToSide:{label:s,open:()=>o(n.oid,!0)}})},n.oid)},t[16]=c,t[17]=l,t[18]=r,t[19]=o,t[20]=u,t[21]=a,t[22]=s,t[23]=e,t[24]=_,t[25]=v):v=t[25],h=d.map(v),t[0]=l,t[1]=i.commits,t[2]=i.snapshot,t[3]=n,t[4]=r,t[5]=o,t[6]=a,t[7]=s,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g,t[15]=_}else u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14],_=t[15];let v;t[26]!==f||t[27]!==p||t[28]!==m||t[29]!==h?(v=(0,Q.jsx)(`ol`,{"aria-label":f,className:p,onKeyDown:m,children:h}),t[26]=f,t[27]=p,t[28]=m,t[29]=h,t[30]=v):v=t[30];let y;t[31]!==u||t[32]!==d||t[33]!==_?(y=(0,Q.jsx)(jv,{rows:d,width:_,rowHeight:u}),t[31]=u,t[32]=d,t[33]=_,t[34]=y):y=t[34];let b;t[35]===_?b=t[36]:(b={paddingLeft:_},t[35]=_,t[36]=b);let x;t[37]===i?x=t[38]:(x=(0,Q.jsx)(Pv,{history:i}),t[37]=i,t[38]=x);let S;t[39]!==x||t[40]!==b?(S=(0,Q.jsx)(`div`,{style:b,children:x}),t[39]=x,t[40]=b,t[41]=S):S=t[41];let C;return t[42]!==S||t[43]!==g||t[44]!==v||t[45]!==y?(C=(0,Q.jsxs)(`div`,{className:g,children:[v,y,S]}),t[42]=S,t[43]=g,t[44]=v,t[45]=y,t[46]=C):C=t[46],C}function Nv(e){if(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=Array.from(e.currentTarget.querySelectorAll(`button[aria-pressed]`)),n=e.target instanceof Element?e.target.closest(`li`):null,r=t.findIndex(e=>e.closest(`li`)===n);if(r<0)return;e.preventDefault(),e.stopPropagation();let i=t[r+(e.key===`ArrowDown`?1:-1)];i&&(i.focus(),i.click())}function Pv(e){let t=(0,$.c)(11),{history:n}=e,r;t[0]===n?r=t[1]:(r=(0,Q.jsx)(Fv,{history:n}),t[0]=n,t[1]=r);let i;t[2]!==n.nextAfter||t[3]!==n.result?(i=n.nextAfter!==null&&n.nextAfter!==void 0&&!n.result.waiting&&!h(n.result),t[2]=n.nextAfter,t[3]=n.result,t[4]=i):i=t[4];let a;t[5]!==n.readMore||t[6]!==i?(a=(0,Q.jsx)(vv,{enabled:i,onVisible:n.readMore}),t[5]=n.readMore,t[6]=i,t[7]=a):a=t[7];let o;return t[8]!==r||t[9]!==a?(o=(0,Q.jsxs)(Q.Fragment,{children:[r,a]}),t[8]=r,t[9]=a,t[10]=o):o=t[10],o}function Fv(e){let t=(0,$.c)(8),{history:n}=e;if(n.result.waiting){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(`p`,{className:`px-2 py-3`,children:(0,Q.jsx)(ee,{label:`Reading older commits`})}),t[0]=e):e=t[0],e}if(h(n.result)){let e;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(`span`,{children:`Couldn't load older commits`}),t[1]=e):e=t[1];let r;return t[2]===n.readMore?r=t[3]:(r=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-2 text-2xs text-muted-foreground`,children:[e,(0,Q.jsx)(X,{size:`xs`,variant:`outline`,onClick:n.readMore,children:`Retry`})]}),t[2]=n.readMore,t[3]=r),r}if(n.nextAfter===null||n.nextAfter===void 0){let e;t[4]===n.boundary?e=t[5]:(e=q_(n.boundary),t[4]=n.boundary,t[5]=e);let r;return t[6]===e?r=t[7]:(r=(0,Q.jsx)(`p`,{className:`px-2 py-3 text-2xs text-muted-foreground`,children:e}),t[6]=e,t[7]=r),r}return null}function Iv(e,t){let n=(0,$.c)(4),r=t===void 0?`scrollOffset`:t,i=$t(we),a;return n[0]!==e||n[1]!==r||n[2]!==i?(a={ref:t=>{if(!t)return;let n=t.querySelector(`[data-slot="scroll-area-viewport"]`)??t;n.scrollTop=i.get(e)[r]},onScrollCapture:t=>{t.target instanceof HTMLElement&&i.set(e,{...i.get(e),[r]:t.target.scrollTop})}},n[0]=e,n[1]=r,n[2]=i,n[3]=a):a=n[3],a}function Lv(e){let t=(0,$.c)(18),{scope:n,connection:r,selected:i,onSelect:a,sideLabel:o,onOpenGraph:s,onOpenChanges:c}=e,l=gv(r,n),u=ne(J(Fa(n,r))),d=J_(u?.branch,l.snapshot),f=u?.changes.length??0,p;t[0]!==r||t[1]!==n?(p=sv({connection:r,scope:n,kind:`commits`}),t[0]=r,t[1]=n,t[2]=p):p=t[2];let m=Iv(p),h;t[3]===l?h=t[4]:(h=(0,Q.jsx)(zv,{history:l}),t[3]=l,t[4]=h);let g=si,_=f>0&&(0,Q.jsx)(`div`,{className:`pt-2 pr-3 pl-1.5`,children:(0,Q.jsxs)(`button`,{type:`button`,onClick:c,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2 text-left text-caption transition-colors hover:bg-accent`,children:[(0,Q.jsx)(bl,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Q.jsx)(v,{className:`flex-1`,text:`Uncommitted changes`}),(0,Q.jsx)(`span`,{className:`text-2xs text-muted-foreground tabular-nums`,children:fe(f,`file`)})]})}),y;t[5]!==l||t[6]!==a||t[7]!==i||t[8]!==o?(y=l.commits.length===0?(0,Q.jsx)(Bv,{}):(0,Q.jsx)(Mv,{label:`Commits`,layout:`stacked`,history:l,selected:i||l.selected||``,onSelect:(e,t)=>{l.select(e),a(e,t)},sideLabel:o}),t[5]=l,t[6]=a,t[7]=i,t[8]=o,t[9]=y):y=t[9];let b;t[10]!==g||t[11]!==m||t[12]!==_||t[13]!==y?(b=(0,Q.jsxs)(g,{className:`min-h-0 flex-initial`,role:`region`,"aria-label":`History reading area`,...m,children:[_,y]}),t[10]=g,t[11]=m,t[12]=_,t[13]=y,t[14]=b):b=t[14];let x;return t[15]!==l.commits.length||t[16]!==s?(x=l.commits.length>0&&(0,Q.jsx)(`div`,{className:`shrink-0 border-t p-1.5`,children:(0,Q.jsxs)(X,{variant:`ghost`,className:`w-full justify-start`,onClick:s,children:[(0,Q.jsx)(Pl,{}),`Open graph`,(0,Q.jsx)(me,{className:`ml-auto text-muted-foreground`})]})}),t[15]=l.commits.length,t[16]=s,t[17]=x):x=t[17],(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,Q.jsx)(`section`,{"aria-label":`Branch`,className:`flex shrink-0 border-b px-3.5 py-2.5`,children:(0,Q.jsx)(hv,{tracking:d})}),h,b,x]})}function Rv(e){let t=(0,$.c)(7),{history:n}=e,r;t[0]===n.snapshot?r=t[1]:(r=n.snapshot!==null&&n.snapshot!==void 0&&(0,Q.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 border-b px-3.5 font-mono text-caption leading-4 text-muted-foreground`,children:[(0,Q.jsx)(yi,{className:`size-3.5 shrink-0`}),(0,Q.jsx)(v,{className:`min-w-0 flex-1 font-medium text-foreground`,text:K_(n.snapshot)})]}),t[0]=n.snapshot,t[1]=r);let i;t[2]===n?i=t[3]:(i=(0,Q.jsx)(zv,{history:n}),t[2]=n,t[3]=i);let a;return t[4]!==r||t[5]!==i?(a=(0,Q.jsxs)(Q.Fragment,{children:[r,i]}),t[4]=r,t[5]=i,t[6]=a):a=t[6],a}function zv(e){let t=(0,$.c)(1),{history:n}=e;if(!n.restarted)return null;let r;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.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[0]=r):r=t[0],r}function Bv(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(Ei,{children:(0,Q.jsx)(vo,{children:(0,Q.jsx)(Sr,{children:`No commits yet`})})}),e[0]=t):t=e[0],t}function Vv(e){let t=(0,$.c)(14),{scope:n,connection:r,onSelect:i,sideLabel:a}=e,o=gv(r,n),s=re(),c;t[0]!==r||t[1]!==n?(c=sv({connection:r,scope:n,kind:`commits`}),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=Iv(c,`graphScrollOffset`),u;t[3]===o?u=t[4]:(u=(0,Q.jsx)(Rv,{history:o}),t[3]=o,t[4]=u);let d;t[5]!==o||t[6]!==i||t[7]!==s||t[8]!==a?(d=o.commits.length===0?(0,Q.jsx)(Bv,{}):(0,Q.jsx)(Mv,{label:`Commit graph`,highlightHead:!0,layout:s?`stacked`:`columns`,history:o,selected:o.selected??``,onSelect:(e,t)=>{o.select(e),i(e,t)},sideLabel:a}),t[5]=o,t[6]=i,t[7]=s,t[8]=a,t[9]=d):d=t[9];let f;return t[10]!==l||t[11]!==u||t[12]!==d?(f=(0,Q.jsxs)(`div`,{className:`@container/graph flex min-h-0 flex-1 flex-col overflow-auto`,role:`region`,"aria-label":`Graph reading area`,...l,children:[u,d]}),t[10]=l,t[11]=u,t[12]=d,t[13]=f):f=t[13],f}function Hv(e,t,n){let r=(0,$.c)(6),i={connection:e,scope:t,path:n},{value:a,result:o}=Bc(fv(i)),s=Bn(uv(i)),c;r[0]===s?c=r[1]:(c=()=>s(void 0),r[0]=s,r[1]=c);let l;return r[2]!==o||r[3]!==c||r[4]!==a?(l={...a,result:o,readMore:c},r[2]=o,r[3]=c,r[4]=a,r[5]=l):l=r[5],l}function Uv(e){let t=(0,$.c)(34),{scope:n,connection:r,path:i,onSelect:a,sideLabel:o}=e,s=Hv(r,n,i),c;t[0]!==r||t[1]!==i||t[2]!==n?(c=sv({connection:r,scope:n,kind:`file`,path:i}),t[0]=r,t[1]=i,t[2]=n,t[3]=c):c=t[3];let l=c,u=$t(l,Wv),d=Bn(l),f=Iv(l),p;t[4]!==a||t[5]!==d?(p=(e,t)=>{d(t=>({...t,selected:e.commit.oid})),a({oid:e.commit.oid,path:e.path},t)},t[4]=a,t[5]=d,t[6]=p):p=t[6];let m=p;if(s.commits.length===0&&s.nextAfter===null){let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Ei,{children:(0,Q.jsx)(vo,{children:(0,Q.jsx)(Sr,{children:`No commits touch this file`})})}),t[7]=e):e=t[7],e}let h=`Timeline of ${i}`,g;if(t[8]!==m||t[9]!==i||t[10]!==u||t[11]!==o||t[12]!==s.commits){let e;t[14]!==m||t[15]!==i||t[16]!==u||t[17]!==o?(e=e=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(Dv,{commit:e.commit,selected:u===e.commit.oid,onSelect:t=>m(e,t),openToSide:{label:o,open:()=>m(e,!0)},children:(0,Q.jsx)(v,{className:`text-2xs text-muted-foreground`,text:L_(e,i)})})},e.commit.oid),t[14]=m,t[15]=i,t[16]=u,t[17]=o,t[18]=e):e=t[18],g=s.commits.map(e),t[8]=m,t[9]=i,t[10]=u,t[11]=o,t[12]=s.commits,t[13]=g}else g=t[13];let _;t[19]===s.restarted?_=t[20]:(_=s.restarted&&(0,Q.jsx)(`span`,{role:`status`,children:`History changed. Showing it from the top.`}),t[19]=s.restarted,t[20]=_);let y;t[21]===s?y=t[22]:(y=(0,Q.jsx)(Gv,{timeline:s}),t[21]=s,t[22]=y);let b;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(`span`,{children:`A merge appears only when its own result changed the file.`}),t[23]=b):b=t[23];let x;t[24]!==_||t[25]!==y?(x=(0,Q.jsxs)(`li`,{className:`flex flex-col gap-1 px-2 py-3 text-2xs text-muted-foreground`,children:[_,y,b]}),t[24]=_,t[25]=y,t[26]=x):x=t[26];let S;t[27]!==h||t[28]!==g||t[29]!==x?(S=(0,Q.jsxs)(`ol`,{"aria-label":h,className:`flex flex-col p-2`,children:[g,x]}),t[27]=h,t[28]=g,t[29]=x,t[30]=S):S=t[30];let C;return t[31]!==f||t[32]!==S?(C=(0,Q.jsx)(`div`,{role:`region`,"aria-label":`Timeline reading area`,className:`min-h-0 flex-1 overflow-auto`,...f,children:S}),t[31]=f,t[32]=S,t[33]=C):C=t[33],C}function Wv(e){return e.selected}function Gv(e){let t=(0,$.c)(10),{timeline:n}=e;if(h(n.result)){let e;return t[0]===n.readMore?e=t[1]:(e=(0,Q.jsxs)(`div`,{role:`status`,children:[`Couldn't load older commits`,(0,Q.jsx)(X,{size:`xs`,variant:`outline`,onClick:n.readMore,children:`Retry`})]}),t[0]=n.readMore,t[1]=e),e}if(n.nextAfter){let e;t[2]===n.result.waiting?e=t[3]:(e=n.result.waiting&&(0,Q.jsx)(S,{"aria-hidden":`true`}),t[2]=n.result.waiting,t[3]=e);let r;return t[4]!==e||t[5]!==n.readMore||t[6]!==n.result.waiting?(r=(0,Q.jsxs)(X,{size:`sm`,variant:`outline`,disabled:n.result.waiting,onClick:n.readMore,children:[e,`Load older commits`]}),t[4]=e,t[5]=n.readMore,t[6]=n.result.waiting,t[7]=r):r=t[7],r}let r=n.boundary===`shallow`?`Shallow clone: older history is not available.`:`Start of this file’s history.`,i;return t[8]===r?i=t[9]:(i=(0,Q.jsx)(`span`,{children:r}),t[8]=r,t[9]=i),i}function Kv(e){let t=(0,$.c)(2),n;return t[0]===e.connection?n=t[1]:(n=cr(e.connection),t[0]=e.connection,t[1]=n),$t(n)}var qv=Jn(`BrowserCommitDraft.submit`)(function*(e,t,n){return yield*Je(Ct(function*(){let r=yield*nt(_(),e=>x(e,s)),i=new AbortController,a=()=>{Nt(x(r,s))};return yield*nt(fr(()=>{t.add(i),i.signal.addEventListener(`abort`,a,{once:!0})}),()=>fr(()=>{i.signal.removeEventListener(`abort`,a),t.delete(i)})),yield*e(n,r)}))});function Jv(e,t,n){let r=(0,$.c)(12),i;r[0]!==t.connection||r[1]!==e?(i=ct({connection:t.connection,scope:e}),r[0]=t.connection,r[1]=e,r[2]=i):i=r[2];let{value:a}=Bc(i),o;r[3]!==t.connection||r[4]!==e?(o=mr({connection:t.connection,scope:e}),r[3]=t.connection,r[4]=e,r[5]=o):o=r[5];let s=$t(o),c;r[6]!==n||r[7]!==a?(c=e=>qv(a,n,e),r[6]=n,r[7]=a,r[8]=c):c=r[8];let l;return r[9]!==s||r[10]!==c?(l={result:s,submit:c},r[9]=s,r[10]=c,r[11]=l):l=r[11],l}function Yv(e,t,n,r){let i=(0,$.c)(121),{scope:a,status:o,action:s,onBusy:c,onLookAgain:l,initialMessage:u,lastCommitMessage:d}=e,f=s===void 0?`commit`:s,p=u===void 0?``:u,m=d===void 0?``:d,h;i[0]!==f||i[1]!==p||i[2]!==m?(h=Bg(f,p,m),i[0]=f,i[1]=p,i[2]=m,i[3]=h):h=i[3];let g;i[4]===h?g=i[5]:(g={defaultValues:h},i[4]=h,i[5]=g);let _=Mc(g),v;i[6]===_?v=i[7]:(v=Qg(_),i[6]=_,i[7]=v);let y=v,b;i[8]===_?b=i[9]:(b=$g(_),i[8]=_,i[9]=b);let x=b,{mode:S,message:C,amendMessage:w,excluded:T,added:E,groups:D}=Ws(_.store,ty),{done:O,activeGroup:k,ownHead:A,busy:j,error:M,drafted:N,draftedBy:P,editingFiles:F}=it(y),I;i[10]===_?I=i[11]:(I=e=>_.setFieldValue(`mode`,e),i[10]=_,i[11]=I);let L=I,R;i[12]===_?R=i[13]:(R=e=>_.setFieldValue(`message`,e),i[12]=_,i[13]=R);let z=R,B;i[14]===_?B=i[15]:(B=e=>_.setFieldValue(`amendMessage`,e),i[14]=_,i[15]=B);let V=B,H;i[16]===_?H=i[17]:(H=e=>_.setFieldValue(`excluded`,e),i[16]=_,i[17]=H);let U=H,W;i[18]===_?W=i[19]:(W=e=>_.setFieldValue(`added`,e),i[18]=_,i[19]=W);let G=W,K;i[20]===_?K=i[21]:(K=e=>_.setFieldValue(`groups`,e),i[20]=_,i[21]=K);let ee=K,q;i[22]===y?q=i[23]:(q=e=>y.update(t=>({...t,done:typeof e==`function`?e(t.done):e})),i[22]=y,i[23]=q);let te=q,re;i[24]===y?re=i[25]:(re=e=>y.update(t=>({...t,activeGroup:e})),i[24]=y,i[25]=re);let ie=re,ae;i[26]===y?ae=i[27]:(ae=e=>y.update(t=>({...t,ownHead:e})),i[26]=y,i[27]=ae);let oe=ae,se;i[28]===y?se=i[29]:(se=e=>y.update(t=>({...t,busy:e})),i[28]=y,i[29]=se);let ce=se,Y;i[30]===y?Y=i[31]:(Y=e=>y.update(t=>({...t,error:e})),i[30]=y,i[31]=Y);let le=Y,ue=(e,t)=>{let n=t?.length===1?`1 selected file`:`${t?.length} selected files`;y.update(r=>({...r,drafted:{...r.drafted,[e]:t},draftedBy:{...r.draftedBy,[e]:t?`Generated by ${ne(J(me))?.find(e=>e.id===he)?.label??he} from ${n}`:null}}))},de=S===`amend`?`amend`:`commit`,fe=e_(a,de,t),pe=Jv(a,t,x),me=Kv(t),he=Lg(ne(J(me)),r.value),ge;if(i[32]!==T||i[33]!==n){let e;i[35]===T?e=i[36]:(e=e=>!T.has(e.path),i[35]=T,i[36]=e),ge=new Set(n.filter(e).flatMap(ey)),i[32]=T,i[33]=n,i[34]=ge}else ge=i[34];let _e;i[37]===ge?_e=i[38]:(_e=[...ge],i[37]=ge,i[38]=_e);let ve=_e,ye;if(i[39]!==E||i[40]!==n){let e;i[42]===E?e=i[43]:(e=e=>E.has(e.path),i[42]=E,i[43]=e),ye=new Set(n.filter(e).flatMap($v)),i[39]=E,i[40]=n,i[41]=ye}else ye=i[41];let be;i[44]===ye?be=i[45]:(be=[...ye],i[44]=ye,i[45]=be);let xe=de===`amend`?be:ve,Se=de===`amend`?w:C,Ce=!(!fe.operation||fe.canStartNew),we=fe.operation?.receipt,Te=j||pe.result.waiting||fe.recovered.waiting,Ee=D?N.groups:N.message,De;i[46]!==Ee||i[47]!==de||i[48]!==O||i[49]!==D||i[50]!==o?(De=de===`commit`&&Ee!=null&&Vg(o,Ee,new Set((D??[]).filter(e=>O.has(e.id)).flatMap(Qv))),i[46]=Ee,i[47]=de,i[48]=O,i[49]=D,i[50]=o,i[51]=De):De=i[51];let Oe=De,ke;i[52]!==n||i[53]!==D?(ke=D?n.filter(e=>!D.some(t=>t.paths.includes(e.path))):[],i[52]=n,i[53]=D,i[54]=ke):ke=i[54];let X=ke,Ae;i[55]!==de||i[56]!==Se||i[57]!==O||i[58]!==D||i[59]!==S||i[60]!==xe||i[61]!==Oe||i[62]!==o?(Ae=Oe||(S===`groups`?!D?.length||D.filter(e=>!O.has(e.id)).some(Zv):!Se.trim()||de!==`amend`&&o.inProgress!==`merge`&&!xe.length),i[55]=de,i[56]=Se,i[57]=O,i[58]=D,i[59]=S,i[60]=xe,i[61]=Oe,i[62]=o,i[63]=Ae):Ae=i[63];let Me=Ae,Ne;i[64]===o?Ne=i[65]:(Ne=dn(`commit`,o),i[64]=o,i[65]=Ne);let Pe=Ne,Fe;i[66]===o?Fe=i[67]:(Fe=dn(`amend`,o),i[66]=o,i[67]=Fe);let Ie=Fe,Le;i[68]===l?Le=i[69]:(Le=l?or({try:l,catch:Xv}):void 0,i[68]=l,i[69]=Le);let Re;return i[70]!==k||i[71]!==E||i[72]!==w||i[73]!==Ie||i[74]!==Me||i[75]!==j||i[76]!==de||i[77]!==Pe||i[78]!==ve||i[79]!==x||i[80]!==Se||i[81]!==O||i[82]!==N||i[83]!==P||i[84]!==F||i[85]!==M||i[86]!==T||i[87]!==n||i[88]!==_||i[89]!==pe||i[90]!==fe||i[91]!==D||i[92]!==X||i[93]!==C||i[94]!==S||i[95]!==he||i[96]!==me||i[97]!==c||i[98]!==A||i[99]!==xe||i[100]!==we||i[101]!==a||i[102]!==ie||i[103]!==G||i[104]!==V||i[105]!==ce||i[106]!==te||i[107]!==ue||i[108]!==le||i[109]!==U||i[110]!==ee||i[111]!==z||i[112]!==L||i[113]!==oe||i[114]!==Oe||i[115]!==y||i[116]!==o||i[117]!==Le||i[118]!==Ce||i[119]!==Te?(Re={scope:a,status:o,onBusy:c,onLookAgain:Le,createId:je,mode:S,commitAction:de,git:fe,generator:pe,models:me,model:he,message:C,amendMessage:w,editingFiles:F,excluded:T,added:E,groups:D,done:O,activeGroup:k,ownHead:A,busy:j,error:M,drafted:N,draftedBy:P,files:n,commitPaths:ve,paths:xe,currentMessage:Se,uncertain:Ce,receipt:we,working:Te,staleDraft:Oe,leftUncommitted:X,blocker:Me,commitModeBlocker:Pe,amendModeBlocker:Ie,controllers:x,form:_,setMode:L,setMessage:z,setAmendMessage:V,setExcluded:U,setAdded:G,setGroups:ee,setDone:te,setActiveGroup:ie,setOwnHead:oe,setBusy:ce,setError:le,setDrafted:ue,state:y},i[70]=k,i[71]=E,i[72]=w,i[73]=Ie,i[74]=Me,i[75]=j,i[76]=de,i[77]=Pe,i[78]=ve,i[79]=x,i[80]=Se,i[81]=O,i[82]=N,i[83]=P,i[84]=F,i[85]=M,i[86]=T,i[87]=n,i[88]=_,i[89]=pe,i[90]=fe,i[91]=D,i[92]=X,i[93]=C,i[94]=S,i[95]=he,i[96]=me,i[97]=c,i[98]=A,i[99]=xe,i[100]=we,i[101]=a,i[102]=ie,i[103]=G,i[104]=V,i[105]=ce,i[106]=te,i[107]=ue,i[108]=le,i[109]=U,i[110]=ee,i[111]=z,i[112]=L,i[113]=oe,i[114]=Oe,i[115]=y,i[116]=o,i[117]=Le,i[118]=Ce,i[119]=Te,i[120]=Re):Re=i[120],Re}function Xv(e){return new Wt(e,kt(e))}function Zv(e){return!e.message.trim()||!e.paths.length}function Qv(e){return e.paths}function $v(e){return e.paths}function ey(e){return e.paths}function ty(e){return e.values}function ny(e,t,n,r){let i=(0,$.c)(46),a=Yv(e,t,n,r),{state:o,form:s,commitAction:c,setMode:l,setGroups:u,setDrafted:d,setAmendMessage:f,setMessage:p,setAdded:m,setExcluded:h}=a,g,_,v,y;i[0]===a?(g=i[1],_=i[2],v=i[3],y=i[4]):(g=()=>Nt(ft(a)),_=()=>Nt(Qt(a,a.mode===`groups`?`groups`:`message`)),v=()=>Nt(Yn(a)),y=()=>Nt(ht(a)),i[0]=a,i[1]=g,i[2]=_,i[3]=v,i[4]=y);let b;i[5]===o?b=i[6]:(b=()=>o.update(ry),i[5]=o,i[6]=b);let x;i[7]!==c||i[8]!==f||i[9]!==p?(x=e=>{c===`amend`?f(e):p(e)},i[7]=c,i[8]=f,i[9]=p,i[10]=x):x=i[10];let S;i[11]!==d||i[12]!==u||i[13]!==l?(S=e=>{(e===`single`||e===`amend`||e===`groups`)&&(l(e),e===`single`&&(u(null),d(`groups`,null)))},i[11]=d,i[12]=u,i[13]=l,i[14]=S):S=i[14];let C;i[15]!==c||i[16]!==s||i[17]!==m||i[18]!==h?(C=(e,t)=>{if(c===`amend`){let n=new Set(s.state.values.added);t?n.add(e):n.delete(e),m(n)}else{let n=new Set(s.state.values.excluded);t?n.delete(e):n.add(e),h(n)}},i[15]=c,i[16]=s,i[17]=m,i[18]=h,i[19]=C):C=i[19];let w,T,E,D;i[20]!==s||i[21]!==u?(E=e=>u(s.state.values.groups?.filter(t=>t.id!==e)??null),D=(e,t)=>u(s.state.values.groups?.map(n=>n.id===e?{...n,message:t}:n)??null),w=(e,t)=>u(s.state.values.groups?.map(n=>({...n,paths:[...n.paths.filter(t=>!e.includes(t)),...n.id===t?e:[]]}))??null),T=()=>u([...s.state.values.groups??[],{id:je(),message:``,paths:[]}]),i[20]=s,i[21]=u,i[22]=w,i[23]=T,i[24]=E,i[25]=D):(w=i[22],T=i[23],E=i[24],D=i[25]);let O;i[26]!==d||i[27]!==u||i[28]!==l?(O=()=>{l(`single`),u(null),d(`groups`,null)},i[26]=d,i[27]=u,i[28]=l,i[29]=O):O=i[29];let k;return i[30]!==r.set||i[31]!==a||i[32]!==g||i[33]!==_||i[34]!==w||i[35]!==T||i[36]!==O||i[37]!==v||i[38]!==y||i[39]!==b||i[40]!==x||i[41]!==S||i[42]!==C||i[43]!==E||i[44]!==D?(k={...a,messageLimit:ur,groupLimit:20,commit:g,generate:_,lookAgain:v,checkOutcome:y,setModel:r.set,toggleEditingFiles:b,setCurrentMessage:x,setMode:S,setIncluded:C,removeGroup:E,setGroupMessage:D,moveFile:w,addGroup:T,clearGroups:O},i[30]=r.set,i[31]=a,i[32]=g,i[33]=_,i[34]=w,i[35]=T,i[36]=O,i[37]=v,i[38]=y,i[39]=b,i[40]=x,i[41]=S,i[42]=C,i[43]=E,i[44]=D,i[45]=k):k=i[45],k}function ry(e){return{...e,editingFiles:!e.editingFiles}}var iy=cn(e=>Ln(t=>{t.addFinalizer(()=>{for(let t of e)t.abort();e.clear()})}));function ay(e){let t=(0,$.c)(2),n;t[0]===e?n=t[1]:(n=iy(e),t[0]=e,t[1]=n),Vt(n)}function oy(e){let t=(0,$.c)(107),{status:n,liveBranch:r,onLookAgain:i}=e,{preferences:a,setPreference:o}=qs(),s=e.context,c;t[0]===e.status.changes?c=t[1]:(c=_d(e.status.changes),t[0]=e.status.changes,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(`commitModel`,e),t[2]=o,t[3]=l);let u;t[4]!==a.commitModel||t[5]!==l?(u={value:a.commitModel,set:l},t[4]=a.commitModel,t[5]=l,t[6]=u):u=t[6];let d=ny(e,s,c,u);ay(d.controllers);let[f,p]=(0,Z.useState)(d.mode===`groups`),m=Ae(e.context),{mode:h,commitAction:g,git:_,model:v,groups:y,done:b,commitPaths:x,uncertain:S,receipt:C,working:w,error:T,staleDraft:E,blocker:D,commitModeBlocker:O,amendModeBlocker:k}=d,A,j;t[7]!==D||t[8]!==d||t[9]!==S||t[10]!==w||t[11]!==m?(A=e=>{e.preventDefault(),m||D||w||S||d.commit()},j=e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),m||D||w||S||d.commit())},t[7]=D,t[8]=d,t[9]=S,t[10]=w,t[11]=m,t[12]=A,t[13]=j):(A=t[12],j=t[13]);let M=g===`amend`?`Amend last commit`:`Commit changes`,N;t[14]===M?N=t[15]:(N=(0,Q.jsx)(Xo,{children:M}),t[14]=M,t[15]=N);let P=g===`amend`?`The last commit is replaced by one with this message and the files you add.`:`Committed steps fold away in the review and show up in History.`,F;t[16]===P?F=t[17]:(F=(0,Q.jsx)(rs,{children:P}),t[16]=P,t[17]=F);let I;t[18]!==N||t[19]!==F?(I=(0,Q.jsxs)(Po,{children:[N,F]}),t[18]=N,t[19]=F,t[20]=I):I=t[20];let L=r??void 0,R;t[21]===L?R=t[22]:(R=J_(L,null),t[21]=L,t[22]=R);let z;t[23]===R?z=t[24]:(z=(0,Q.jsx)(`div`,{className:`flex items-center gap-2 rounded-xl bg-muted/50 px-3 py-2 text-caption`,children:(0,Q.jsx)(hv,{tracking:R})}),t[23]=R,t[24]=z);let B;t[25]!==k||t[26]!==O||t[27]!==x||t[28]!==d.setMode||t[29]!==h||t[30]!==v||t[31]!==n.inProgress||t[32]!==w?(B=n.inProgress!==`merge`&&(0,Q.jsx)(Rc,{value:h,onValueChange:d.setMode,children:(0,Q.jsxs)(Dc,{className:`w-full`,children:[(0,Q.jsx)(Hc,{value:`single`,className:`flex-1`,disabled:w||O!=null,children:`Single commit`}),(0,Q.jsx)(Hc,{value:`amend`,className:`flex-1`,disabled:w||k!=null,children:`Amend last`}),(0,Q.jsx)(Hc,{value:`groups`,className:`flex-1`,disabled:w||O!=null||!v||!x.length,children:`Use groups`})]})}),t[25]=k,t[26]=O,t[27]=x,t[28]=d.setMode,t[29]=h,t[30]=v,t[31]=n.inProgress,t[32]=w,t[33]=B):B=t[33];let V=w||S,H;t[34]!==d||t[35]!==f||t[36]!==h?(H=h===`groups`?(0,Q.jsx)(_y,{form:d}):(0,Q.jsx)(ly,{form:d,onMessage:f?void 0:e=>{e.focus(),p(!0)}}),t[34]=d,t[35]=f,t[36]=h,t[37]=H):H=t[37];let U;t[38]!==V||t[39]!==H?(U=(0,Q.jsx)(`fieldset`,{disabled:V,className:`flex min-w-0 flex-col gap-3`,children:H}),t[38]=V,t[39]=H,t[40]=U):U=t[40];let W;t[41]!==g||t[42]!==d||t[43]!==m?(W=g===`commit`&&(0,Q.jsx)(uy,{form:d,writeBlock:m}),t[41]=g,t[42]=d,t[43]=m,t[44]=W):W=t[44];let G;t[45]!==d.currentMessage||t[46]!==h?(G=h!==`groups`&&!d.currentMessage.trim()&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,role:`status`,children:`Write or generate a message before committing.`}),t[45]=d.currentMessage,t[46]=h,t[47]=G):G=t[47];let K;t[48]===E?K=t[49]:(K=E&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-graph-4`,children:`The worktree changed since this draft was proposed. Generate it again before committing.`}),t[48]=E,t[49]=K);let ee;t[50]!==g||t[51]!==e?(ee=Cy(e,g),t[50]=g,t[51]=e,t[52]=ee):ee=t[52];let q;t[53]===ee?q=t[54]:(q=(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:ee}),t[53]=ee,t[54]=q);let te;t[55]!==T||t[56]!==C?(te=C&&!(T&&Xe(C))&&(0,Q.jsxs)(`div`,{role:`status`,className:`text-sm`,children:[(0,Q.jsx)(`p`,{children:C.state}),C.progress.map(cy)]}),t[55]=T,t[56]=C,t[57]=te):te=t[57];let ne;t[58]!==C||t[59]!==S?(ne=S&&!C&&(0,Q.jsx)(`p`,{role:`status`,children:`Outcome not yet confirmed`}),t[58]=C,t[59]=S,t[60]=ne):ne=t[60];let re;t[61]===T?re=t[62]:(re=T?(0,Q.jsx)(u_,{text:kt(T)}):null,t[61]=T,t[62]=re);let J;t[63]!==d.lookAgain||t[64]!==i||t[65]!==C||t[66]!==E||t[67]!==w?(J=(E||C&&wt(C))&&i&&(0,Q.jsx)(X,{type:`button`,variant:`outline`,disabled:w,onClick:d.lookAgain,children:`Look again`}),t[63]=d.lookAgain,t[64]=i,t[65]=C,t[66]=E,t[67]=w,t[68]=J):J=t[68];let ie;t[69]!==d.checkOutcome||t[70]!==_.operation||t[71]!==w?(ie=_.operation&&!w&&(0,Q.jsx)(X,{type:`button`,variant:`outline`,onClick:d.checkOutcome,children:`Check outcome`}),t[69]=d.checkOutcome,t[70]=_.operation,t[71]=w,t[72]=ie):ie=t[72];let ae;t[73]!==D||t[74]!==b||t[75]!==y||t[76]!==h||t[77]!==C||t[78]!==n.changes||t[79]!==n.inProgress||t[80]!==S||t[81]!==w||t[82]!==m?(ae=!!m||w||S||!!(C&&wt(C))||D||n.inProgress!==`merge`&&n.changes.some(sy)||!!(h===`groups`&&y?.every(e=>b.has(e.id))),t[73]=D,t[74]=b,t[75]=y,t[76]=h,t[77]=C,t[78]=n.changes,t[79]=n.inProgress,t[80]=S,t[81]=w,t[82]=m,t[83]=ae):ae=t[83];let oe;t[84]===d?oe=t[85]:(oe=wy(d),t[84]=d,t[85]=oe);let se;t[86]!==ae||t[87]!==oe||t[88]!==m?(se=(0,Q.jsx)(X,{type:`submit`,"aria-description":m,disabled:ae,children:oe}),t[86]=ae,t[87]=oe,t[88]=m,t[89]=se):se=t[89];let ce;return t[90]!==I||t[91]!==z||t[92]!==B||t[93]!==U||t[94]!==W||t[95]!==G||t[96]!==K||t[97]!==q||t[98]!==te||t[99]!==ne||t[100]!==re||t[101]!==J||t[102]!==ie||t[103]!==se||t[104]!==A||t[105]!==j?(ce=(0,Q.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:A,onKeyDown:j,children:[I,z,B,U,W,G,K,q,te,ne,re,J,ie,se]}),t[90]=I,t[91]=z,t[92]=B,t[93]=U,t[94]=W,t[95]=G,t[96]=K,t[97]=q,t[98]=te,t[99]=ne,t[100]=re,t[101]=J,t[102]=ie,t[103]=se,t[104]=A,t[105]=j,t[106]=ce):ce=t[106],ce}function sy(e){return e.scope===`unmerged`}function cy(e){return(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e},e)}function ly(e){let t=(0,$.c)(50),{form:n,onMessage:r}=e,{commitAction:i,editingFiles:a,excluded:o,added:s,files:c,paths:l,currentMessage:u,working:d}=n,f=i===`amend`?`Files to add`:`Files`,p;t[0]===f?p=t[1]:(p=(0,Q.jsx)(`span`,{className:`font-medium`,children:f}),t[0]=f,t[1]=p);let m;t[2]!==c.length||t[3]!==l.length?(m=(0,Q.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[`(`,l.length,` of `,c.length,`)`]}),t[2]=c.length,t[3]=l.length,t[4]=m):m=t[4];let h;t[5]!==i||t[6]!==a||t[7]!==c.length||t[8]!==n||t[9]!==d?(h=i===`commit`&&c.length>0&&(0,Q.jsx)(X,{type:`button`,size:`xs`,variant:`ghost`,className:`ml-auto`,disabled:d,onClick:()=>n.toggleEditingFiles(),children:a?`Done`:`Edit`}),t[5]=i,t[6]=a,t[7]=c.length,t[8]=n,t[9]=d,t[10]=h):h=t[10];let g;t[11]!==p||t[12]!==m||t[13]!==h?(g=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-caption`,children:[p,m,h]}),t[11]=p,t[12]=m,t[13]=h,t[14]=g):g=t[14];let _;if(t[15]!==s||t[16]!==i||t[17]!==a||t[18]!==o||t[19]!==c||t[20]!==n){let e;t[22]!==s||t[23]!==i||t[24]!==a||t[25]!==o||t[26]!==n?(e=e=>{let t=i===`amend`?s.has(e.path):!o.has(e.path),r=i===`amend`||a,c=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ya,{path:e.path,className:`size-3.5 shrink-0`}),(0,Q.jsx)(v,{className:`min-w-0 flex-1`,text:e.path}),(0,Q.jsx)(`span`,{"aria-hidden":r,className:`shrink-0 text-muted-foreground`,children:xy(e.kind,t,i)})]});return r?(0,Q.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 rounded-lg px-2 py-1 text-xs hover:bg-muted`,children:[(0,Q.jsx)(F_,{checked:t,onCheckedChange:t=>n.setIncluded(e.path,t)}),c]},e.path):(0,Q.jsx)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-lg px-2 py-1 text-xs`,children:c},e.path)},t[22]=s,t[23]=i,t[24]=a,t[25]=o,t[26]=n,t[27]=e):e=t[27],_=c.map(e),t[15]=s,t[16]=i,t[17]=a,t[18]=o,t[19]=c,t[20]=n,t[21]=_}else _=t[21];let y;t[28]===_?y=t[29]:(y=(0,Q.jsx)(`div`,{className:`max-h-40 overflow-auto rounded-xl border p-1`,children:_}),t[28]=_,t[29]=y);let b;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)($n,{htmlFor:`commit-message`,children:`Message`}),t[30]=b):b=t[30];let x;t[31]!==i||t[32]!==n.draftedBy?(x=i===`commit`&&n.draftedBy.message&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.draftedBy.message}),t[31]=i,t[32]=n.draftedBy,t[33]=x):x=t[33];let S;t[34]===r?S=t[35]:(S=e=>{e&&r?.(e)},t[34]=r,t[35]=S);let C;t[36]===n?C=t[37]:(C=e=>n.setCurrentMessage(e.target.value),t[36]=n,t[37]=C);let w;t[38]!==u||t[39]!==n.messageLimit||t[40]!==S||t[41]!==C?(w=(0,Q.jsx)(hi,{ref:S,id:`commit-message`,value:u,onChange:C,rows:4,maxLength:n.messageLimit,placeholder:`Describe what changed and why`}),t[38]=u,t[39]=n.messageLimit,t[40]=S,t[41]=C,t[42]=w):w=t[42];let T;t[43]!==w||t[44]!==x?(T=(0,Q.jsxs)(Pt,{children:[b,x,w]}),t[43]=w,t[44]=x,t[45]=T):T=t[45];let E;return t[46]!==T||t[47]!==g||t[48]!==y?(E=(0,Q.jsxs)(Q.Fragment,{children:[g,y,T]}),t[46]=T,t[47]=g,t[48]=y,t[49]=E):E=t[49],E}function uy(e){let n=(0,$.c)(63),{form:r,writeBlock:i}=e,{models:a,model:o}=r,s,c,l,u,d,f,p,m,g,_,v,y,b;if(n[0]!==r||n[1]!==o||n[2]!==a||n[3]!==i){let e=ne(J(a));l=e?.find(e=>e.id===o),u=!e&&!h(a);let x;n[17]!==r||n[18]!==i?(x=i??hy(r),n[17]=r,n[18]=i,n[19]=x):x=n[19],d=x,y=`flex flex-wrap items-center gap-2`;let S=u||!!d||r.working||r.uncertain,C;n[20]===r?C=n[21]:(C=()=>r.generate(),n[20]=r,n[21]=C);let w;n[22]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Q.jsx)(Xl,{}),n[22]=w):w=n[22];let T=r.generator.result.waiting?`Generating…`:`Generate with AI`;n[23]!==S||n[24]!==C||n[25]!==T||n[26]!==i?(b=(0,Q.jsxs)(X,{type:`button`,variant:`outline`,size:`sm`,disabled:S,"aria-description":i,onClick:C,children:[w,T]}),n[23]=S,n[24]=C,n[25]=T,n[26]=i,n[27]=b):b=n[27],c=R,p=e?.map(my)??[],m=o??null,g=!e?.length||r.working||r.uncertain,n[28]===r?_=n[29]:(_=e=>{e&&r.setModel(e)},n[28]=r,n[29]=_);let E=u||e?.length?`Choose a model`:`No coding CLI available`;n[30]===E?v=n[31]:(v=(0,Q.jsx)(t,{"aria-label":`Commit model`,className:`w-auto max-w-48`,size:`sm`,children:(0,Q.jsx)(xt,{placeholder:E})}),n[30]=E,n[31]=v),s=Le,f=Ig(e?.filter(py)??[]).map(dy),n[0]=r,n[1]=o,n[2]=a,n[3]=i,n[4]=s,n[5]=c,n[6]=l,n[7]=u,n[8]=d,n[9]=f,n[10]=p,n[11]=m,n[12]=g,n[13]=_,n[14]=v,n[15]=y,n[16]=b}else s=n[4],c=n[5],l=n[6],u=n[7],d=n[8],f=n[9],p=n[10],m=n[11],g=n[12],_=n[13],v=n[14],y=n[15],b=n[16];let x;n[32]!==s||n[33]!==f?(x=(0,Q.jsx)(s,{children:f}),n[32]=s,n[33]=f,n[34]=x):x=n[34];let S;n[35]!==c||n[36]!==p||n[37]!==m||n[38]!==g||n[39]!==_||n[40]!==v||n[41]!==x?(S=(0,Q.jsxs)(c,{items:p,value:m,disabled:g,onValueChange:_,children:[v,x]}),n[35]=c,n[36]=p,n[37]=m,n[38]=g,n[39]=_,n[40]=v,n[41]=x,n[42]=S):S=n[42];let C;n[43]!==l?.label||n[44]!==o||n[45]!==u||n[46]!==d?(C=!u&&(d??`Sends the selected changes to ${l?.label} through ${o?.split(`:`)[0]===`claude`?`Claude Code`:`Codex`}.`),n[43]=l?.label,n[44]=o,n[45]=u,n[46]=d,n[47]=C):C=n[47];let w;n[48]===C?w=n[49]:(w=(0,Q.jsx)(`p`,{className:`w-full text-xs text-muted-foreground`,role:`status`,children:C}),n[48]=C,n[49]=w);let T;n[50]!==r.generate||n[51]!==r.generator.result||n[52]!==r.uncertain||n[53]!==r.working||n[54]!==d||n[55]!==i?(T=h(r.generator.result)&&!r.working&&(0,Q.jsx)(X,{type:`button`,variant:`outline`,size:`sm`,disabled:!!d||r.uncertain,"aria-description":i,onClick:r.generate,children:`Try again`}),n[50]=r.generate,n[51]=r.generator.result,n[52]=r.uncertain,n[53]=r.working,n[54]=d,n[55]=i,n[56]=T):T=n[56];let E;return n[57]!==S||n[58]!==w||n[59]!==T||n[60]!==y||n[61]!==b?(E=(0,Q.jsxs)(`div`,{className:y,children:[b,S,w,T]}),n[57]=S,n[58]=w,n[59]=T,n[60]=y,n[61]=b,n[62]=E):E=n[62],E}function dy(e){let[t,n]=e;return(0,Q.jsxs)(Ne,{children:[(0,Q.jsx)(ue,{children:t}),n.map(fy)]},t)}function fy(e){return(0,Q.jsx)(Ve,{value:e.id,children:e.label},e.id)}function py(e){return!e.id.endsWith(`:default`)}function my(e){return{value:e.id,label:e.label}}function hy({models:e,model:t,paths:n}){if(h(e))return`Could not load coding CLI models. You can still commit manually.`;let r=ne(J(e));return r?!t&&r.some(e=>!e.id.endsWith(`:default`))?`Choose a model to generate a message.`:t?n.length?null:`Select files to generate a message.`:`No coding CLI available. Write a message to commit manually.`:null}function gy(e,t){return e?`Groups were not proposed.`:t?`Proposing commits…`:`Generate groups with AI, then review each message and file before committing.`}function _y(e){let n=(0,$.c)(34),{form:r}=e,{groups:i,done:a,activeGroup:o,files:s,leftUncommitted:c,error:l}=r;if(i===null){let e;n[0]!==l||n[1]!==r.working?(e=gy(l,r.working),n[0]=l,n[1]=r.working,n[2]=e):e=n[2];let t;return n[3]===e?t=n[4]:(t=(0,Q.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:e}),n[3]=e,n[4]=t),t}let u;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(u={value:`uncommitted`,label:`Leave uncommitted`},n[5]=u):u=n[5];let d;n[6]===i?d=n[7]:(d=[u,...i.map(by)],n[6]=i,n[7]=d);let f=d,p;n[8]===r.draftedBy.groups?p=n[9]:(p=r.draftedBy.groups&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r.draftedBy.groups}),n[8]=r.draftedBy.groups,n[9]=p);let m;n[10]!==o||n[11]!==f||n[12]!==a||n[13]!==s||n[14]!==r||n[15]!==i?(m=i.map((e,n)=>(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2 rounded-lg border p-3`,"aria-label":`Commit ${n+1}`,children:[(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Commit `,n+1,Sy(e.id,a,o)]}),e.paths.length===0&&a.size===0&&(0,Q.jsx)(X,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>r.removeGroup(e.id),children:`Remove empty group`}),(0,Q.jsx)(hi,{"aria-label":`Message for commit ${n+1}`,value:e.message,disabled:a.has(e.id),required:!0,maxLength:r.messageLimit,onChange:t=>r.setGroupMessage(e.id,t.target.value)}),s.filter(t=>e.paths.includes(t.path)).map(n=>(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs`,children:[(0,Q.jsx)(v,{className:`min-w-0 flex-1`,text:n.path}),(0,Q.jsxs)(R,{items:f,value:e.id,disabled:a.size>0,onValueChange:e=>{e&&r.moveFile(n.paths,e)},children:[(0,Q.jsx)(t,{size:`sm`,"aria-label":`Commit for ${n.path}`,children:(0,Q.jsx)(xt,{})}),(0,Q.jsxs)(Le,{children:[(0,Q.jsx)(Ve,{value:`uncommitted`,children:`Leave uncommitted`}),i.map(yy)]})]})]},n.path))]},e.id)),n[10]=o,n[11]=f,n[12]=a,n[13]=s,n[14]=r,n[15]=i,n[16]=m):m=n[16];let h;n[17]!==f||n[18]!==a.size||n[19]!==r||n[20]!==i||n[21]!==c?(h=c.length>0&&(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2 rounded-lg border border-dashed p-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Left uncommitted`}),c.map(e=>(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs`,children:[(0,Q.jsx)(v,{className:`min-w-0 flex-1`,text:e.path}),(0,Q.jsxs)(R,{items:f,value:`uncommitted`,disabled:a.size>0,onValueChange:t=>{t&&r.moveFile(e.paths,t)},children:[(0,Q.jsx)(t,{size:`sm`,"aria-label":`Commit for ${e.path}`,children:(0,Q.jsx)(xt,{})}),(0,Q.jsxs)(Le,{children:[(0,Q.jsx)(Ve,{value:`uncommitted`,children:`Leave uncommitted`}),i.map(vy)]})]})]},e.path))]}),n[17]=f,n[18]=a.size,n[19]=r,n[20]=i,n[21]=c,n[22]=h):h=n[22];let g;n[23]!==a.size||n[24]!==r.addGroup||n[25]!==r.clearGroups||n[26]!==r.groupLimit||n[27]!==i.length?(g=a.size===0&&(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(X,{type:`button`,variant:`outline`,size:`sm`,disabled:i.length>=r.groupLimit,onClick:r.addGroup,children:[(0,Q.jsx)(Di,{}),`Add group`]}),(0,Q.jsx)(X,{type:`button`,variant:`ghost`,size:`sm`,onClick:r.clearGroups,children:`Single commit`})]}),n[23]=a.size,n[24]=r.addGroup,n[25]=r.clearGroups,n[26]=r.groupLimit,n[27]=i.length,n[28]=g):g=n[28];let _;return n[29]!==p||n[30]!==m||n[31]!==h||n[32]!==g?(_=(0,Q.jsxs)(Q.Fragment,{children:[p,m,h,g]}),n[29]=p,n[30]=m,n[31]=h,n[32]=g,n[33]=_):_=n[33],_}function vy(e,t){return(0,Q.jsxs)(Ve,{value:e.id,children:[`Commit `,t+1]},e.id)}function yy(e,t){return(0,Q.jsxs)(Ve,{value:e.id,children:[`Commit `,t+1]},e.id)}function by(e,t){return{value:e.id,label:`Commit ${t+1}`}}function xy(e,t,n){return t?e.replaceAll(`-`,` `):n===`amend`?`Not added`:`Excluded`}function Sy(e,t,n){return t.has(e)?` · committed`:n===e?` · in progress`:``}function Cy({status:e,liveBranch:t,replacedSubject:n},r){return r===`amend`?`Amending replaces the last commit${n?`: ${n}`:``}. ${t?.upstream&&t.ahead===0?`This commit is already on the known upstream; amending rewrites shared history.`:`Unselected staged changes stay staged.`}`:e.inProgress===`merge`?`This finishes the merge and commits every staged resolution, including staged files outside your selection.`:`Selected files use their current contents. Other staged files stay staged.`}function wy({working:e,generator:t,groups:n,commitAction:r}){return e?t.result.waiting?`Generating…`:r===`amend`?`Amending…`:`Committing…`:n&&r===`commit`?`Commit groups in order`:r===`amend`?`Amend last commit`:`Commit selected files`}function Ty(e){let t=(0,$.c)(15),{scope:n,context:r,entry:i,status:a,current:o,onBusy:s,onLookAgain:c}=e;if(i===`switch`||i===`discard`||i===`fetch`||i===`pull`||i===`push`)return null;if(i===`commit`||i===`amend`){let e;return t[0]!==r||t[1]!==i||t[2]!==s||t[3]!==c||t[4]!==n||t[5]!==a?(e=(0,Q.jsx)(Ey,{scope:n,context:r,action:i,status:a,onBusy:s,onLookAgain:c}),t[0]=r,t[1]=i,t[2]=s,t[3]=c,t[4]=n,t[5]=a,t[6]=e):e=t[6],e}let l;return t[7]!==r||t[8]!==o||t[9]!==i||t[10]!==s||t[11]!==c||t[12]!==n||t[13]!==a?(l=(0,Q.jsx)(Oy,{scope:n,context:r,action:i,status:a,current:o,onBusy:s,onLookAgain:c},i),t[7]=r,t[8]=o,t[9]=i,t[10]=s,t[11]=c,t[12]=n,t[13]=a,t[14]=l):l=t[14],l}function Ey(e){let t=(0,$.c)(17),{scope:n,context:r,action:i,status:a,onBusy:o,onLookAgain:s}=e,c;t[0]===i?c=t[1]:(c=(0,Q.jsx)(Dy,{action:i}),t[0]=i,t[1]=c);let l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(ee,{label:`Reading commit details`}),t[2]=l):l=t[2];let u;t[3]===c?u=t[4]:(u=(0,Q.jsxs)(Q.Fragment,{children:[c,l]}),t[3]=c,t[4]=u);let d;t[5]!==i||t[6]!==r||t[7]!==o||t[8]!==s||t[9]!==n||t[10]!==a?(d=e=>{let t=e.headCommit;return i===`amend`&&!t?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Dy,{action:i}),(0,Q.jsx)(`p`,{role:`alert`,children:`The last commit could not be read. Close and try again.`})]}):(0,Q.jsx)(oy,{scope:n,context:r,action:i,status:a,liveBranch:e.branch??a.branch,initialMessage:i===`amend`&&t?[t.subject,t.body].filter(Boolean).join(`
|
|
32
|
+
|
|
33
|
+
`):``,lastCommitMessage:t?[t.subject,t.body].filter(Boolean).join(`
|
|
34
|
+
|
|
35
|
+
`):``,...t?{replacedSubject:t.subject}:{},onBusy:o,onLookAgain:s})},t[5]=i,t[6]=r,t[7]=o,t[8]=s,t[9]=n,t[10]=a,t[11]=d):d=t[11];let f;return t[12]!==r||t[13]!==n||t[14]!==u||t[15]!==d?(f=(0,Q.jsx)(ky,{scope:n,context:r,pending:u,children:d}),t[12]=r,t[13]=n,t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function Dy(e){let t=(0,$.c)(7),{action:n}=e,r=n===`amend`?`Amend last commit`:`Commit changes`,i;t[0]===r?i=t[1]:(i=(0,Q.jsx)(Xo,{children:r}),t[0]=r,t[1]=i);let a=n===`amend`?`The last commit is replaced by one with this message and the files you add.`:`Committed steps fold away in the review and show up in History.`,o;t[2]===a?o=t[3]:(o=(0,Q.jsx)(rs,{children:a}),t[2]=a,t[3]=o);let s;return t[4]!==i||t[5]!==o?(s=(0,Q.jsxs)(Po,{children:[i,o]}),t[4]=i,t[5]=o,t[6]=s):s=t[6],s}function Oy(e){let t=(0,$.c)(13),{scope:n,context:r,action:i,status:a,current:o,onBusy:s,onLookAgain:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(ee,{label:`Reading the branch`}),t[0]=l):l=t[0];let u;t[1]!==i||t[2]!==r||t[3]!==o||t[4]!==s||t[5]!==c||t[6]!==n||t[7]!==a?(u=e=>(0,Q.jsx)(Ay,{scope:n,context:r,action:i,status:{...a,branch:e.branch??a.branch},expectedStatus:a,current:o,onBusy:s,onLookAgain:c}),t[1]=i,t[2]=r,t[3]=o,t[4]=s,t[5]=c,t[6]=n,t[7]=a,t[8]=u):u=t[8];let d;return t[9]!==r||t[10]!==n||t[11]!==u?(d=(0,Q.jsx)(ky,{scope:n,context:r,pending:l,children:u}),t[9]=r,t[10]=n,t[11]=u,t[12]=d):d=t[12],d}function ky(e){let t=(0,$.c)(12),{scope:n,context:r,pending:i,children:a}=e,o=Da(n,r.connection);if(h(o.result)){let e;t[0]===o.result.cause?e=t[1]:(e=kt(ie(o.result.cause)),t[0]=o.result.cause,t[1]=e);let n;t[2]===e?n=t[3]:(n=(0,Q.jsx)(u_,{text:e}),t[2]=e,t[3]=n);let r;t[4]===o.refresh?r=t[5]:(r=(0,Q.jsx)(X,{variant:`outline`,onClick:o.refresh,children:`Read status again`}),t[4]=o.refresh,t[5]=r);let i;return t[6]!==n||t[7]!==r?(i=(0,Q.jsxs)(Q.Fragment,{children:[n,r]}),t[6]=n,t[7]=r,t[8]=i):i=t[8],i}if(!Kt(o.result))return i;let s;return t[9]!==a||t[10]!==o.result.value?(s=a(o.result.value),t[9]=a,t[10]=o.result.value,t[11]=s):s=t[11],s}function Ay(e){let n=(0,$.c)(71),{scope:r,context:i,action:a,status:o,expectedStatus:s,current:c,onBusy:l,onLookAgain:u}=e,d=s===void 0?o:s,f=c===void 0?o:c,p=o.branch,[m,h]=(0,Z.useState)(`Porcelain review`),[g,_]=(0,Z.useState)(p?.stashes?.[0]?.oid??``),[v,y]=(0,Z.useState)(a===`stash-create`),b=Ae(i),x;n[0]!==d||n[1]!==l||n[2]!==u?(x={expectedStatus:d,onBusy:l,onLookAgain:u},n[0]=d,n[1]=l,n[2]=u,n[3]=x):x=n[3];let S=Y_(r,a,i,x),{busy:C,uncertain:w,outcome:T,error:E}=S,D;n[4]===T?D=n[5]:(D=T&&wt(T),n[4]=T,n[5]=D);let O=!!D,k;n[6]!==a||n[7]!==S||n[8]!==m||n[9]!==v||n[10]!==g||n[11]!==b?(k=e=>{e.preventDefault(),b||S.onSubmit(zg(a,{message:m,stashOid:g,option:v}))},n[6]=a,n[7]=S,n[8]=m,n[9]=v,n[10]=g,n[11]=b,n[12]=k):k=n[12];let A=C||w,j;n[13]!==a||n[14]!==v?(j=a===`stash-create`&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:v?`Tracked changes and new files are set aside. The handoff stays empty until you restore the stash.`:`Tracked changes are set aside. New files stay in the worktree.`}),n[13]=a,n[14]=v,n[15]=j):j=n[15];let M;n[16]!==a||n[17]!==S.messageLimit||n[18]!==m?(M=a===`stash-create`&&(0,Q.jsxs)(Pt,{children:[(0,Q.jsx)($n,{htmlFor:`git-message`,children:`Message`}),(0,Q.jsx)(hi,{id:`git-message`,value:m,onChange:e=>h(e.target.value),required:!0,maxLength:S.messageLimit})]}),n[16]=a,n[17]=S.messageLimit,n[18]=m,n[19]=M):M=n[19];let N;n[20]!==a||n[21]!==p||n[22]!==g?(N=(a===`stash-apply`||a===`stash-pop`)&&(0,Q.jsxs)(Pt,{children:[(0,Q.jsx)($n,{htmlFor:`git-stash`,children:`Stash`}),p?.stashes?.length?(0,Q.jsxs)(R,{items:p.stashes.map(My),value:g,onValueChange:e=>{e&&_(e)},children:[(0,Q.jsx)(t,{id:`git-stash`,children:(0,Q.jsx)(xt,{})}),(0,Q.jsx)(Le,{children:p.stashes.map(jy)})]}):(0,Q.jsx)(Ce,{id:`git-stash`,value:g,onChange:e=>_(e.target.value),required:!0,pattern:`([a-f0-9]{40}|[a-f0-9]{64})`})]}),n[20]=a,n[21]=p,n[22]=g,n[23]=N):N=n[23];let P;n[24]===v?P=n[25]:(P=(0,Q.jsx)(F_,{checked:v,onCheckedChange:y}),n[24]=v,n[25]=P);let F=a===`stash-create`?`Include untracked files`:`Restore staged changes`,I;n[26]!==P||n[27]!==F?(I=(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[P,F]}),n[26]=P,n[27]=F,n[28]=I):I=n[28];let L;n[29]!==I||n[30]!==A||n[31]!==j||n[32]!==M||n[33]!==N?(L=(0,Q.jsxs)(`fieldset`,{disabled:A,className:`flex min-w-0 flex-col gap-4`,children:[j,M,N,I]}),n[29]=I,n[30]=A,n[31]=j,n[32]=M,n[33]=N,n[34]=L):L=n[34];let z;n[35]!==f||n[36]!==d||n[37]!==T||n[38]!==O?(z=O?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm`,children:rn(xn(d,f))}):(0,Q.jsx)(Ny,{outcome:T}),n[35]=f,n[36]=d,n[37]=T,n[38]=O,n[39]=z):z=n[39];let B;n[40]!==T||n[41]!==w?(B=w&&!T&&(0,Q.jsx)(`p`,{role:`status`,children:`Outcome not yet confirmed`}),n[40]=T,n[41]=w,n[42]=B):B=n[42];let V;n[43]===E?V=n[44]:(V=E?(0,Q.jsx)(u_,{text:kt(E)}):null,n[43]=E,n[44]=V);let H;n[45]!==C||n[46]!==S.lookAgain||n[47]!==u||n[48]!==O?(H=O&&u&&(0,Q.jsx)(X,{type:`button`,variant:`outline`,disabled:C,onClick:S.lookAgain,children:`Look again`}),n[45]=C,n[46]=S.lookAgain,n[47]=u,n[48]=O,n[49]=H):H=n[49];let U;n[50]!==C||n[51]!==S.checkOutcome||n[52]!==S.operation||n[53]!==O?(U=S.operation&&!C&&!O&&(0,Q.jsx)(X,{type:`button`,variant:`outline`,onClick:S.checkOutcome,children:`Check outcome`}),n[50]=C,n[51]=S.checkOutcome,n[52]=S.operation,n[53]=O,n[54]=U):U=n[54];let W=!!b||C||w||O,G;n[55]!==a||n[56]!==C?(G=C?`Working…`:Wg(a),n[55]=a,n[56]=C,n[57]=G):G=n[57];let K;n[58]!==W||n[59]!==G||n[60]!==b?(K=(0,Q.jsx)(X,{type:`submit`,"aria-description":b,disabled:W,children:G}),n[58]=W,n[59]=G,n[60]=b,n[61]=K):K=n[61];let ee;return n[62]!==L||n[63]!==z||n[64]!==B||n[65]!==V||n[66]!==H||n[67]!==U||n[68]!==K||n[69]!==k?(ee=(0,Q.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:k,children:[L,z,B,V,H,U,K]}),n[62]=L,n[63]=z,n[64]=B,n[65]=V,n[66]=H,n[67]=U,n[68]=K,n[69]=k,n[70]=ee):ee=n[70],ee}function jy(e){return(0,Q.jsxs)(Ve,{value:e.oid,children:[e.message,` · `,H_(e.oid)]},e.oid)}function My(e){return{value:e.oid,label:`${e.message} · ${H_(e.oid)}`}}function Ny(e){let t=(0,$.c)(7),{outcome:n}=e;if(!n)return null;if(n.message&&Xe(n)&&n.state!==`conflicted`){let e;return t[0]===n.message?e=t[1]:(e=(0,Q.jsx)(u_,{text:n.message}),t[0]=n.message,t[1]=e),e}let r=n.state,i;t[2]===n?i=t[3]:(i=Py(n),t[2]=n,t[3]=i);let a;return t[4]!==n.state||t[5]!==i?(a=(0,Q.jsxs)(`p`,{role:`status`,className:`text-sm`,children:[r,i]}),t[4]=n.state,t[5]=i,t[6]=a):a=t[6],a}function Py({message:e,reason:t}){return e?` · ${e}`:t?` · ${t.replaceAll(`_`,` `).toLowerCase()}`:``}function Fy(e){let t=(0,$.c)(56),{scope:r,context:i}=e,{connection:a}=i,o=ne(J(Fa(r,a))),[s,c]=(0,Z.useState)(!1),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>e=>{if(!e)return;let t=()=>c(e.getClientRects().length===0);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},t[0]=l):l=t[0];let[d]=(0,Z.useState)(l),[f,p]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),_=o!=null&&Bt(gn(o)).kind===`hint`,b=f||_,x=Da(r,a,b),C=ne(J(x.result)),w=jo(r,a),T=_c(a),E;t[1]===T?E=t[2]:(E=Is(T),t[1]=T,t[2]=E);let D=E,O;t[3]!==D||t[4]!==T?(O=D?void 0:nc(T),t[3]=D,t[4]=T,t[5]=O):O=t[5];let k=O,[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)(null),[I,L]=(0,Z.useState)(null),[R,z]=(0,Z.useState)(null),B=Ae(i),V;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>p(!0),t[6]=V):V=t[6];let H;t[7]!==k||t[8]!==D?(H=D?{kind:`ready`,strategy:D}:{kind:`blocked`,reason:k??`Changes & Git settings for this computer are unavailable.`},t[7]=k,t[8]=D,t[9]=H):H=t[9];let U;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>{e&&F(null),N(e)},t[10]=U):U=t[10];let W;t[11]!==x||t[12]!==w||t[13]!==H?(W={details:x,enableDetails:V,pull:H,notify:zy,onProgress:U,onResult:F,refreshLook:w,onLooked:z},t[11]=x,t[12]=w,t[13]=H,t[14]=W):W=t[14];let G=y_(r,i,W);if(o==null)return null;let K={...gn(o),branch:rt(o.branch,b?C?.branch:void 0)},q;t[15]===I?q=t[16]:(q=e=>e.id===I,t[15]=I,t[16]=q);let te=Hg.find(q),re=Bt(K),ie=re.kind===`run`&&re.action===`pull`&&!D,ae=B??(ie&&k?k:n(re,K)),oe=zn(re,K),ce=Wn(K),Y=G.running,le;t[17]!==x.result||t[18]!==b?(le=b&&se(x.result),t[17]=x.result,t[18]=b,t[19]=le):le=t[19];let ue=le,fe=ue?Ug.slice(0,1):Ug,pe=e=>{B||(Ue(e)?G.runNetwork(e,K.branch):(z(K),L(e)))},me;t[20]===Y?me=t[21]:(me=e=>{e||F(null),Y&&N(e)},t[20]=Y,t[21]=me);let he=Y?`${de(Y.name)}…`:re.label,ge=!Y&&oe!=null&&` ${oe}`,_e;t[22]!==he||t[23]!==ge?(_e=(0,Q.jsxs)(`span`,{ref:d,"aria-hidden":`true`,className:`hidden @min-lg/pane:inline`,children:[he,ge]}),t[22]=he,t[23]=ge,t[24]=_e):_e=t[24];let ve;t[25]!==G.checkOutcome||t[26]!==P||t[27]!==Y?(ve=(0,Q.jsx)(On,{align:`end`,className:`w-80`,children:P&&!Y?(0,Q.jsxs)(Qe,{children:[(0,Q.jsx)(pn,{children:P.title}),P.description!==void 0&&(P.type===`error`?(0,Q.jsx)(u_,{text:P.description}):(0,Q.jsx)(Rt,{children:(0,Q.jsx)(l_,{text:P.description})}))]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(pn,{children:Y?`${de(Y.name)}…`:`Git action…`}),(0,Q.jsx)(`ol`,{className:`flex flex-col gap-0.5 font-mono text-2xs leading-4`,children:Y?.operation?.receipt?.progress.length?Y.operation.receipt.progress.slice(-4).map(Ry):(0,Q.jsx)(`li`,{className:`text-muted-foreground`,children:`Waiting for Git…`})}),Y&&P?.description&&(0,Q.jsx)(u_,{text:P.description}),Y&&(0,Q.jsxs)(X,{variant:`outline`,disabled:Y.checking,onClick:G.checkOutcome,children:[Y.checking&&(0,Q.jsx)(S,{"aria-hidden":`true`}),`Check outcome`]})]})}),t[25]=G.checkOutcome,t[26]=P,t[27]=Y,t[28]=ve):ve=t[28];let ye;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(ye=e=>{g(e),e&&p(!0)},t[29]=ye):ye=t[29];let be=!!B||Y!=null,xe;t[30]!==be||t[31]!==B?(xe=(0,Q.jsx)(Lt,{render:(0,Q.jsx)(X,{variant:`outline`,size:`icon`,"aria-label":`Git actions`,disabled:be,"aria-description":B})}),t[30]=be,t[31]=B,t[32]=xe):xe=t[32];let Se;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,Q.jsx)(u,{className:`size-3.5`}),t[33]=Se):Se=t[33];let Ce;t[34]===xe?Ce=t[35]:(Ce=(0,Q.jsx)(Gt,{render:xe,children:Se}),t[34]=xe,t[35]=Ce);let we=B??`Git actions`,Te;t[36]===we?Te=t[37]:(Te=(0,Q.jsx)(m,{role:`tooltip`,className:`break-all`,children:we}),t[36]=we,t[37]=Te);let Ee;t[38]!==Ce||t[39]!==Te?(Ee=(0,Q.jsxs)(y,{children:[Ce,Te]}),t[38]=Ce,t[39]=Te,t[40]=Ee):Ee=t[40];let De=ce?(0,Q.jsx)(hv,{tracking:J_(ce,null)}):(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(yi,{className:`size-3.5 shrink-0`}),`Git actions`]}),Oe;t[41]===De?Oe=t[42]:(Oe=(0,Q.jsx)(en,{children:(0,Q.jsx)(_t,{children:De})}),t[41]=De,t[42]=Oe);let ke;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,Q.jsx)(on,{}),t[43]=ke):ke=t[43];let je=fe.map((e,t)=>(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(en,{children:e.actions.map(e=>{let t=Gg(e.id,K,k),n=t??Nn(e.id,K);return(0,Q.jsxs)(y,{onOpenChange:Ly,children:[(0,Q.jsx)(Gt,{render:(0,Q.jsx)(`span`,{className:`block`}),children:(0,Q.jsxs)(Xn,{disabled:!!B||t!=null,"aria-description":B,onClick:()=>pe(e.id),children:[(0,Q.jsx)(C_,{action:e.id}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsx)(v,{text:e.label}),t&&(0,Q.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:t})]})]})}),(0,Q.jsxs)(m,{children:[e.description,n&&` ${n}`]})]},e.id)})}),(ue||t<fe.length-1)&&(0,Q.jsx)(on,{})]},e.id)),Me;t[44]===ue?Me=t[45]:(Me=ue&&(0,Q.jsx)(ee,{label:`Reading Git status`,className:`mx-2 my-1`}),t[44]=ue,t[45]=Me);let Ne=!ue&&(ce?.discarded?.length??0)>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(on,{}),(0,Q.jsxs)(en,{children:[(0,Q.jsx)(_t,{children:`Discarded`}),ce?.discarded?.map(e=>{let t=e.kind===`rename`?`Restore discarded rename of ${e.path}`:`Restore discarded hunk of ${e.path}`;return(0,Q.jsxs)(y,{onOpenChange:Iy,children:[(0,Q.jsx)(Gt,{render:(0,Q.jsx)(`span`,{className:`block`}),children:(0,Q.jsxs)(Xn,{onClick:()=>{g(!1),G.restoreDiscarded(e)},children:[(0,Q.jsx)(iu,{}),(0,Q.jsx)(v,{className:`min-w-0`,text:t,propagateEscape:!0})]})}),(0,Q.jsxs)(m,{children:[t,` · Kept until you restore it`]})]},e.oid)})]})]}),Pe;t[46]!==ue||t[47]!==Oe||t[48]!==je||t[49]!==Me||t[50]!==Ne?(Pe=(0,Q.jsxs)(pt,{align:`end`,className:`w-76`,"aria-busy":ue,children:[Oe,ke,je,Me,Ne]}),t[46]=ue,t[47]=Oe,t[48]=je,t[49]=Me,t[50]=Ne,t[51]=Pe):Pe=t[51];let Fe;return t[52]!==h||t[53]!==Ee||t[54]!==Pe?(Fe=(0,Q.jsxs)(vn,{open:h,onOpenChange:ye,children:[Ee,Pe]}),t[52]=h,t[53]=Ee,t[54]=Pe,t[55]=Fe):Fe=t[55],(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(v_,{"aria-label":`Git controls`,className:`shrink-0`,children:[(0,Q.jsxs)(y,{children:[(0,Q.jsxs)(sn,{open:Y!=null&&M||P!=null,onOpenChange:me,children:[(0,Q.jsxs)(Gt,{render:(0,Q.jsx)(Fn,{render:(0,Q.jsx)(X,{variant:`outline`,size:s?`icon`:`default`,"aria-label":Y?`${de(Y.name)} in progress: show progress`:re.label,disabled:Y==null&&(re.kind===`hint`||ie||!!B),"aria-description":B,focusableWhenDisabled:!0,className:`aria-disabled:cursor-default`,onClick:()=>{Y||P||B||(re.kind===`commit`?pe(`commit`):re.kind===`stash`?pe(`stash-apply`):re.kind===`run`&&G.runNetwork(re.action,K.branch))}})}),children:[Y?(0,Q.jsx)(S,{className:`size-3.5`}):(0,Q.jsx)(C_,{action:By(re),className:`size-3.5`}),_e]}),ve]}),(0,Q.jsx)(m,{role:`tooltip`,className:`break-all`,children:Y?`${de(Y.name)} in progress: show progress`:ae})]}),Fe]}),I==null?null:(0,Q.jsx)(Fi,{open:!0,disablePointerDismissal:!0,onOpenChange:e=>{!e&&!A&&L(null)},children:(0,Q.jsxs)(Ja,{"aria-busy":A,className:`max-h-[min(90svh,48rem)] overflow-y-auto sm:max-w-2xl`,children:[te?.id!==`commit`&&te?.id!==`amend`&&(0,Q.jsxs)(Po,{children:[(0,Q.jsx)(Xo,{children:te?.label??`Git action`}),(0,Q.jsx)(rs,{children:Vy(te?.id)})]}),(0,Q.jsx)(Ty,{scope:r,context:i,entry:I,status:R??K,current:K,onBusy:j,onLookAgain:G.lookAgain})]})})]})}function Iy(e,t){t.reason===`escape-key`&&t.allowPropagation()}function Ly(e,t){t.reason===`escape-key`&&t.allowPropagation()}function Ry(e){return(0,Q.jsx)(v,{render:(0,Q.jsx)(`li`,{}),text:e},e)}function zy(e){let{title:t,description:n,type:r}=e;return ms.add({title:t,description:n===void 0?void 0:(0,Q.jsx)(l_,{text:n}),type:r})}function By(e){return e.kind===`run`?e.action:e.kind===`stash`?`stash-apply`:`commit`}function Vy(e){return e===`stash-pop`?`Its changes come back into the working tree and the stash is dropped.`:e===`stash-apply`?`Its changes come back into the working tree and the stash is kept.`:`Every change, new files included, is set aside until you pop the stash.`}function Hy(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=be(`(min-width: 1280px)`),e[0]=t):t=e[0],$t(t)}var Uy={kind:`review`},Wy=[`review`,`handoff`,`walkthrough`,`walkthrough-changes`],Gy={kind:`all-changes`},Ky={kind:`specs`},qy={kind:`branch`},Jy={kind:`graph`};function Yy(e){switch(e.kind){case`review`:return`review`;case`all-changes`:return`all-changes`;case`specs`:return`specs`;case`change`:return`change:${e.path}`;case`file`:return`file:${e.path}`;case`commit`:return`commit:${e.oid}`;case`pull-request`:return`pull-request:${e.projectId}:${e.number}${e.environmentId?`:environment=${encodeURIComponent(e.environmentId)}`:``}`;case`branch`:return`branch`;case`branch-file`:return`branch:${e.path}`;case`graph`:return`graph`;case`timeline`:return`timeline:${e.path}`;case`walkthrough-step`:return`walkthrough-step:${e.step}`}}function Xy(e){if(e==null||e===``)return null;if(Wy.includes(e))return Uy;if(e===`all-changes`)return Gy;if(e===`specs`)return Ky;if(e===`branch`)return qy;if(e===`graph`)return Jy;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`walkthrough-step`:return/^[1-9][0-9]*$/.test(r)&&Number.isSafeInteger(Number(r))?{kind:n,step:Number(r)}:null;case`commit`:return/^[0-9a-f]{4,64}$/.test(r)?{kind:n,oid:r}:null;case`pull-request`:{let[e,t,i,a]=r.split(`:`);return e!==void 0&&e.length>0&&t!==void 0&&a===void 0&&(i===void 0||/^environment=[a-zA-Z0-9_-]+$/.test(i))&&/^[1-9][0-9]*$/.test(t)&&Number.isSafeInteger(Number(t))?{kind:n,projectId:e,number:Number(t),...i?{environmentId:i.slice(12)}:{}}:null}default:return null}}function Zy(e){let t=Xy(e);return t?Yy(t):void 0}function Qy(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 $y={changes:`Changes`,files:`Files`,history:`History`};function eb(e){switch(e.kind){case`review`:return`Review`;case`all-changes`:return`All changes`;case`specs`:return`Specs`;case`branch`:return`Branch changes`;case`graph`:return`Commit graph`;case`commit`:return H_(e.oid);case`pull-request`:return`PR #${e.number}`;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}`;case`walkthrough-step`:return`Step ${e.step}`}}function tb(e){let t=Xy(e.entry),n=(e.firstDocument!==void 0&&(!t||t.kind===`review`)?e.firstDocument:void 0)??(t?eb(t):$y[e.surface??`files`]),r=e.project?`${n} — ${e.project}`:n;return e.environment?`${r} · ${e.environment}`:r}var nb=()=>({tabs:[],pinned:[]}),rb=`review`;function ib(e){return e===rb}function ab(e,t){let n=`${e}-${encodeURIComponent(t)}`;return{tab:`${n}-tab`,panel:`${n}-panel`}}function ob(e,t){let n=Zy(e);return n===void 0||!ib(n)?n:t?ub(sb(t)).at(-1):void 0}function sb(e){return{tabs:e.tabs.filter(e=>!ib(e)),pinned:e.pinned.filter(e=>!ib(e))}}function cb(e){return{tabs:[rb,...e.tabs.filter(e=>!ib(e))],pinned:e.pinned.filter(e=>!ib(e))}}function lb(e,t,n){if(e[t]?.tabs.includes(n))return t;let r=+(t===0);return e[r]?.tabs.includes(n)?r:t}function ub(e){return[...e.tabs.filter(ib),...e.pinned.filter(t=>!ib(t)&&e.tabs.includes(t)),...e.tabs.filter(t=>!ib(t)&&!e.pinned.includes(t))]}function db(e,t,n){return e.tabs.includes(t)?e:{...e,tabs:Qy(e.tabs,t,n)}}function fb(e,t){return ib(t)?e:{tabs:e.tabs.filter(e=>e!==t),pinned:e.pinned.filter(e=>e!==t)}}function pb(e,t){return{...e,tabs:e.tabs.filter(n=>ib(n)||n===t||e.pinned.includes(n))}}function mb(e){return{...e,tabs:e.tabs.filter(t=>ib(t)||e.pinned.includes(t))}}function hb(e,t){return ib(t)?e:e.pinned.includes(t)?{...e,pinned:e.pinned.filter(e=>e!==t)}:{...e,pinned:[...e.pinned,t]}}function gb(e,t,n){let r=Xy(e);return r?.kind===`file`&&Bs(r.path,t)?Yy({kind:`file`,path:ic(r.path,t,n)}):e}function _b(e,t,n){let r=e=>[...new Set(e.map(e=>gb(e,t,n)))];return{tabs:r(e.tabs),pinned:r(e.pinned)}}function vb(e,t){let n=Xy(e);return n?.kind===`file`&&Bs(n.path,t)}function yb(e,t){return{tabs:e.tabs.filter(e=>!vb(e,t)),pinned:e.pinned.filter(e=>!vb(e,t))}}function bb(e,t,n){if(n.tabs.includes(t))return t;let r=ub(e),i=new Set(ub(n)),a=r.indexOf(t);return a===-1?null:[...r.slice(a+1),...r.slice(0,a).reverse()].find(e=>i.has(e)&&!ib(e))??e.tabs.find(e=>i.has(e))??null}function xb(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Sb(e){return Array.isArray(e)?[...new Set(e.flatMap(e=>{let t=typeof e==`string`?Zy(e):void 0;return t===void 0?[]:[t]}))]:[]}function Cb(e){if(!xb(e)||!Array.isArray(e.panes))return null;let t=e.panes.map(e=>{let t=Sb(xb(e)?e.tabs:void 0);return{tabs:t,pinned:Sb(xb(e)?e.pinned:void 0).filter(e=>t.includes(e))}}).map((e,t)=>t===0?e:sb(e)).filter((e,t)=>t===0||e.tabs.length>0);return t.length>0?t:null}function wb(e){return e===null?`Open to the side`:e===`left`?`Open in the right pane`:`Open in the left pane`}function Tb(e,t,n){let r=t.flatMap(e=>ub(e)),i=n===null?e:[n,...e],a=new Set(r);return[...new Set([...i,...r])].filter(e=>a.has(e))}function Eb(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function Db(e){return!e||typeof e!=`object`||!(`folded`in e)||!(`expanded`in e)?{folded:[],expanded:[]}:Eb(e.folded)&&Eb(e.expanded)?{folded:e.folded,expanded:e.expanded}:{folded:[],expanded:[]}}function Ob(e,t,n=!1){return e.folded.includes(t)||n&&!e.expanded.includes(t)}function kb(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]}}function Ab(e,t){return e?.owner===t?void 0:e}var jb=U(j({saved:Y})),Mb=U(j({focused:I([0,1])})),Nb=Se.pipe(O(j({panes:he(oe(j({tabs:oe(Ee),pinned:oe(Ee)}))),saved:Y,focused:I([0,1])}),{decode:un(e=>({panes:Cb(e),saved:jb(e).pipe(d(e=>e.saved),E(()=>!0)),focused:Mb(e).pipe(d(e=>e.focused),E(()=>0))})),encode:Hn()})),Pb=Se.pipe(O(j({folded:oe(Ee),expanded:oe(Ee)}),{decode:un(Db),encode:Hn()})),Fb=cn(e=>mn({runtime:Vs,key:`porcelain.tabs.${e}`,schema:Nb,defaultValue:()=>({panes:null,saved:!1,focused:0})})),Ib=cn(e=>Ln({recent:[],actives:null}).pipe(et)),Lb=cn(e=>mn({runtime:Vs,key:e,schema:Pb,defaultValue:()=>({folded:[],expanded:[]})}));function Rb(e){let t=(0,$.c)(24),n;t[0]===e?n=t[1]:(n=Fb(e),t[0]=e,t[1]=n);let r=n,{panes:i,saved:a,focused:o}=$t(r),s=Bn(r),c=$t(we),l;t[2]===e?l=t[3]:(l=Ib(e),t[2]=e,t[3]=l);let u=l,d;t[4]!==r||t[5]!==c?(d=e=>{let t=c.get(r);t.focused!==e&&c.set(r,{...t,focused:e})},t[4]=r,t[5]=c,t[6]=d):d=t[6];let f;t[7]===s?f=t[8]:(f=e=>s(t=>({...t,panes:e,saved:!0})),t[7]=s,t[8]=f);let p;t[9]!==u||t[10]!==r||t[11]!==c?(p=()=>({panes:c.get(r).panes,actives:c.get(u).actives}),t[9]=u,t[10]=r,t[11]=c,t[12]=p):p=t[12];let m;t[13]!==u||t[14]!==c?(m=e=>{c.set(u,{...c.get(u),actives:e})},t[13]=u,t[14]=c,t[15]=m):m=t[15];let h;return t[16]!==o||t[17]!==i||t[18]!==a||t[19]!==d||t[20]!==f||t[21]!==p||t[22]!==m?(h={panes:i,saved:a,focused:o,setFocused:d,save:f,latest:p,saveActives:m},t[16]=o,t[17]=i,t[18]=a,t[19]=d,t[20]=f,t[21]=p,t[22]=m,t[23]=h):h=t[23],h}function zb(e,t){let n=(0,$.c)(7),r=`porcelain.folds.${e}.${t}`,i;n[0]===r?i=n[1]:(i=Lb(r),n[0]=r,n[1]=i);let a=i,o=$t(a),s=Bn(a),c;n[2]===s?c=n[3]:(c=(e,t)=>s(n=>kb(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 Bb=cn(e=>Ln(25).pipe(et)),Vb=cn(e=>Ln({viewer:null,restored:null})),Hb=cn(e=>Ln({scrollTop:0,selection:null,focused:void 0}).pipe(et));function Ub(e){let t=(0,$.c)(33),n=(0,Z.useId)(),r;t[0]===n?r=t[1]:(r=Vb(n),t[0]=n,t[1]=r);let i=r;Vt(i);let a=$t(we),o;t[2]===e?o=t[3]:(o=Hb(e),t[2]=e,t[3]=o);let s=o,c,l,u,d,f,p;t[4]!==s||t[5]!==a?(c=()=>a.get(s).scrollTop,l=()=>a.get(s).selection,u=()=>a.get(s).focused,d=e=>a.set(s,{...a.get(s),focused:e}),f=e=>{a.set(s,{...a.get(s),scrollTop:e})},p=e=>{a.set(s,{...a.get(s),selection:e})},t[4]=s,t[5]=a,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p):(c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11]);let m;t[12]!==i||t[13]!==a?(m=e=>a.get(i).viewer?.scrollTo(e),t[12]=i,t[13]=a,t[14]=m):m=t[14];let h;t[15]!==i||t[16]!==e||t[17]!==s||t[18]!==a?(h=(t,n)=>{let r=a.get(i);(r.restored?.viewer!==t||r.restored.owner!==e)&&(t.scrollTo({type:`position`,position:a.get(s).scrollTop+n,behavior:`instant`}),a.set(i,{...r,restored:{viewer:t,owner:e}}))},t[15]=i,t[16]=e,t[17]=s,t[18]=a,t[19]=h):h=t[19];let g;t[20]!==i||t[21]!==a?(g=e=>{if(e)return a.set(i,{...a.get(i),viewer:e}),()=>{let t=a.get(i);t.viewer===e&&a.set(i,{...t,viewer:null})}},t[20]=i,t[21]=a,t[22]=g):g=t[22];let _;return t[23]!==h||t[24]!==g||t[25]!==c||t[26]!==l||t[27]!==u||t[28]!==d||t[29]!==f||t[30]!==p||t[31]!==m?(_={position:c,selection:l,focused:u,rememberFocus:d,rememberPosition:f,rememberSelection:p,scrollTo:m,restorePosition:h,attach:g},t[23]=h,t[24]=g,t[25]=c,t[26]=l,t[27]=u,t[28]=d,t[29]=f,t[30]=p,t[31]=m,t[32]=_):_=t[32],_}var Wb=mn({runtime:Vs,key:`porcelain.review-panel.open`,schema:Y,defaultValue:()=>!0}).pipe(et);function Gb(){let e=(0,$.c)(3),t=$t(Wb),n=Bn(Wb),r;return e[0]!==t||e[1]!==n?(r={open:t,setOpen:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],r}var Kb=cn(e=>Ln(void 0).pipe(et)),qb=new Map,Jb=cn(e=>Ln(t=>{let n=Symbol();qb.set(e.worktreeId,{owner:n,title:e.title}),t.set(Kb(e.worktreeId),e.title),t.addFinalizer(()=>{Ab(qb.get(e.worktreeId),n)||(qb.delete(e.worktreeId),t.set(Kb(e.worktreeId),void 0))})}));function Yb(e){let t=(0,$.c)(8),{worktreeId:n,entry:r,side:i,onSearch:a,fallback:o,focused:s,setFocused:c,ready:l,focusBoundary:u,focusBoundaryOpen:d}=e,{panes:f,saved:p,save:m,latest:h,saveActives:g}=Rb(n),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=[void 0,void 0],t[0]=_):_=t[0];let[v,y]=(0,Z.useState)(_),b;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(b=[null,null],t[1]=b):b=t[1];let[x,S]=(0,Z.useState)(b),C=(0,Z.useId)(),w;t[2]===C?w=t[3]:(w=Zb(C),t[2]=C,t[3]=w);let T=$t(w),E=T.cancel,D=[cb(f?.[0]??nb()),...f?.slice(1)??[]],O=ob(i,D[1]),k=[Zy(r),O];Vt(Qb({ready:l,entry:r,side:i,keptSide:O,onSearch:a,fallback:o,saved:p}));let A=e=>{let t=v[e];return t===void 0?k[e]:t??void 0},j=ub(f?.[0]??nb()).at(-1),M=j&&!ib(j)?j:rb,N=[A(0)??(f==null?o??`review`:M),A(1)??(A(0)!==void 0||D[1]===null||D[1]===void 0?null:ub(D[1]).at(-1)??null)],P=[db(D[0]??nb(),N[0]??``,x[0])];(N[0]===null||N[0]===void 0)&&(P[0]=D[0]??nb()),N[1]!==null&&N[1]!==void 0&&(P[1]=db(D[1]??nb(),N[1],x[1]));let F=P.length>1;if(l){let e=v.map((e,t)=>e!==void 0&&(k[t]??null)===(e??null)?void 0:e);(e[0]!==v[0]||e[1]!==v[1])&&y([e[0],e[1]]),(x[0]!==N[0]||x[1]!==N[1])&&S(N)}Vt($b({worktreeId:n,panes:P,ready:l}));let I;t[4]===n?I=t[5]:(I=Ib(n),t[4]=n,t[5]=I);let{recent:L}=$t(I),R=N[s]??null;Vt(ex({worktreeId:n,panes:P,actives:N,active:R,ready:l}));let z=Tb(L,P,R).flatMap(Xb),B=e=>{E();let t=h().actives??N;g([`entry`in e?e.entry??null:t[0],`side`in e?e.side??null:t[1]]),y(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}:{}})},V;t[6]===B?V=t[7]:(V=(e,t)=>B(e===0?{entry:t}:{side:t}),t[6]=B,t[7]=V);let H=V,U=(e,t)=>P.map((n,r)=>r===e?t:n),W=e=>{let t=h(),n=t.panes?[cb(t.panes[0]??nb()),...t.panes.slice(1)]:P,r=t.actives??N,{next:i,after:a}=e(n,r);if(i.length>1&&(i[1]?.tabs.length??0)===0){m([i[0]??nb()]),c(0),B({entry:a[0]??null,side:null});return}m(i);let o={};(a[0]??null)!==(r[0]??null)&&(o.entry=a[0]??null),i.length>1&&(a[1]??null)!==(r[1]??null)&&(o.side=a[1]??null),Object.keys(o).length>0&&B(o)},G=(e,t,n)=>{if(E(),F&&t.tabs.length===0){let t=+(e===0);m([P[t]??nb()]),c(0),B({entry:N[t],side:null})}else m(U(e,t)),n!==N[e]&&H(e,n)};return{recentFiles:z,bindQuickOpen:T.bindQuickOpen,focusDestination:T.schedule,hasDestinationFocus(){return T.current()!==null},selectPane(e){E(),c(e)},focusPane(e,t){if(d||T.restoringQuickOpen&&t.getAttribute(`role`)===`tab`)return;let n=T.destination;n!==null&&(n.pane!==e||t.getAttribute(`role`)!==`tab`||t.getAttribute(`data-entry`)!==n.key)&&E(),c(e)},bindPane(e,t){return T.bind(e,t,{focused:s,actives:N,panes:P,focusBoundary:u})},split:F,panes:P.map((e,t)=>({tabs:ub(e),pinned:e.pinned,active:N[t]??null})),activate(e,t){c(e),H(e,t)},open(e,t,n){let r=n!==void 0&&n,i=lb(P,e,t);return H(i,t),r?T.cancel():T.request({pane:i,key:t}),c(i),i},closePane(e){F&&G(e,nb(),null)},close(e,t){let n=P[e]??nb(),r=fb(n,t);G(e,r,t===N[e]?bb(n,t,r):N[e])},closeOthers(e,t){G(e,pb(P[e]??nb(),t),t)},closeUnpinned(e){let t=mb(P[e]??nb()),n=N[e];G(e,t,n!=null&&t.tabs.includes(n)?n:ub(t)[0]??null)},moveFiles(e,t){W((n,r)=>({next:n.map(n=>_b(n,e,t)),after:r.map(n=>n===null?null:gb(n,e,t))}))},closeRemovedFiles(e){W((t,n)=>{let r=t.map(t=>yb(t,e));return{next:r,after:n.map((n,i)=>n!==null&&vb(n,e)?bb(t[i]??nb(),n,r[i]??nb()):n)}})},togglePin(e,t){m(U(e,hb(P[e]??nb(),t)))},openToSide(e,t){if(ib(t))return;let n=+(e===0),r=[...P];r[n]=db(P[n]??nb(),t,N[n]),m(r),H(n,t),T.request({pane:n,key:t}),c(n)},step(e,t){E();let n=ub(P[e]??nb());if(n.length===0)return;let r=N[e]===null||N[e]===void 0?-1:n.indexOf(N[e]);H(e,n[(r+t+n.length)%n.length]??null)}}}function Xb(e){let t=Xy(e);return t?.kind===`file`?[t.path]:[]}var Zb=cn(e=>Ln(e=>{let t=[null,null],n=null,r=!1,i=null,a,o=null,s=()=>{o!==null&&cancelAnimationFrame(o),o=null},c=()=>{i=null,r=!1,s()},l=()=>i&&a&&(a.focused!==i.pane||a.actives[i.pane]!==i.key||!a.panes[i.pane]?.tabs.includes(i.key))?null:i,u=()=>{i&&o===null&&(o=requestAnimationFrame(()=>{o=null;let e=l();if(!e||a?.focusBoundary?.isConnected||n?.isConnected)return;let s=[...t[e.pane]?.querySelectorAll(`[role="tab"]`)??[]].find(t=>t.dataset.entry===e.key);s?.isConnected&&(s.focus(),s.ownerDocument.activeElement===s&&i===e&&(i=null,r=!1))}))};return e.addFinalizer(c),{get destination(){return i},get restoringQuickOpen(){return r},current:l,cancel:c,schedule:u,bindQuickOpen:e=>{n=e,e===null&&u()},request(e){i=e,r=n?.isConnected===!0},bind(e,n,r){if(s(),a=r,t[e]=n,l(),n)return u(),()=>{t[e]===n&&(t[e]=null),s()}}}})),Qb=cn(({ready:e,entry:t,side:n,keptSide:r,onSearch:i,fallback:a,saved:o})=>Ln(()=>{e&&(t!==void 0&&Zy(t)!==t&&i({entry:Zy(t)},{replace:!0}),n!==void 0&&r!==n&&i({side:r},{replace:!0}),!o&&t===void 0&&n===void 0&&a!==null&&i({entry:a},{replace:!0}))})),$b=cn(({worktreeId:e,panes:t,ready:n})=>Ln(r=>{if(!n)return;let i=Fb(e),a=r.once(i);a.saved&&JSON.stringify(a.panes)===JSON.stringify(t)&&(t.length>1||a.focused===0)||r.set(i,{...a,panes:t,saved:!0,focused:t.length>1?a.focused:0})})),ex=cn(({worktreeId:e,panes:t,actives:n,active:r,ready:i})=>Ln(a=>{if(!i)return;let o=Ib(e),s=a.once(o),c=Tb(s.recent,t,r);s.actives?.[0]===n[0]&&s.actives[1]===n[1]&&s.recent.length===c.length&&s.recent.every((e,t)=>e===c[t])||a.set(o,{recent:c,actives:n})}));function tx(e,t){return{onActivate:n=>e.activate(t,n),onClose:n=>e.close(t,n),onCloseOthers:n=>e.closeOthers(t,n),onCloseUnpinned:()=>e.closeUnpinned(t),onTogglePin:n=>e.togglePin(t,n),onOpenToSide:n=>e.openToSide(t,n),onClosePane:e.split?()=>e.closePane(t):void 0}}function nx(e){let t=e?.closest(`[data-tab-viewport]`);if(!e||!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.left<r.left?n.left-r.left:Math.max(0,n.right-r.right);t.scrollBy({left:i})}function rx(e){let t=Xy(e);switch(t?.kind){case`review`:return{Icon:Wl,title:`Review`,hint:`The branch's review`};case`walkthrough-step`:return{Icon:Ci,title:`Step ${t.step}`,hint:`Changes in step ${t.step}`};case`all-changes`:return{Icon:Ci,title:`All changes`,hint:`Every changed file, including specs`};case`specs`:return{Icon:Al,title:`Specs`,hint:`Changed spec and test files`};case`change`:return{Icon:Mi,title:ao(t.path),accessibleName:t.path,hint:`${t.path} · changes`};case`file`:return{Icon:Mi,title:ao(t.path),accessibleName:t.path,hint:t.path};case`commit`:return{Icon:Ml,title:H_(t.oid),hint:`Commit ${t.oid}`};case`branch`:return{Icon:yi,title:`Branch`,hint:`Every change on the branch`};case`branch-file`:return{Icon:Mi,title:ao(t.path),accessibleName:t.path,hint:`${t.path} · branch`};case`pull-request`:return{Icon:Bl,title:`PR #${t.number}`,hint:`Pull request #${t.number}`};case`graph`:return{Icon:yi,title:`Graph`,hint:`Commit graph of the checked-out branch`};case`timeline`:return{Icon:Ir,title:`Timeline of ${ao(t.path)}`,accessibleName:`Timeline of ${t.path}`,hint:`${t.path} · timeline`};default:return{Icon:wl,title:e,hint:e}}}function ix(e){let t=(0,$.c)(51),n,r,i,a,o,s,c,l,d;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],d=t[9]):({tabs:l,pinned:s,active:r,side:c,leading:o,trailing:d,commitContext:i,ids:a,...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]=d);let f=c!=null&&`gap-2`,p;t[10]===f?p=t[11]:(p=Tn(`flex h-12 shrink-0 items-center gap-1.5 border-b px-2.5 text-[length:var(--text-ui)] leading-[1.4]`,f),t[10]=f,t[11]=p);let h;t[12]===o?h=t[13]:(h=o!=null&&(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center`,children:o}),t[12]=o,t[13]=h);let g=c==null?`Open documents`:`Open documents, ${c} pane`,_;t[14]!==n||t[15]!==r||t[16]!==a||t[17]!==s||t[18]!==c||t[19]!==l?(_=l.includes(`review`)&&(0,Q.jsx)(`span`,{className:`flex shrink-0`,children:(0,Q.jsx)(sx,{tabKey:`review`,ids:a(`review`),active:r===`review`,pinned:!1,hasUnpinned:l.some(e=>!ib(e)&&!s.includes(e)),side:c,...n})}),t[14]=n,t[15]=r,t[16]=a,t[17]=s,t[18]=c,t[19]=l,t[20]=_):_=t[20];let v;t[21]!==n||t[22]!==r||t[23]!==i||t[24]!==a||t[25]!==s||t[26]!==c||t[27]!==l?(v=l.filter(ax).map((e,t)=>{let o=s.includes(e),u=o&&!s.includes(l[t+1]??``)&&t<l.length-1,d=Xy(e),f={tabKey:e,ids:a(e),active:e===r,pinned:o,hasUnpinned:l.some(e=>!ib(e)&&!s.includes(e)),side:c,...n};return(0,Q.jsxs)(`span`,{className:`flex min-w-0 shrink-0 items-center`,children:[i&&d?.kind===`commit`?(0,Q.jsx)(cx,{...f,commitContext:i,oid:d.oid}):(0,Q.jsx)(sx,{...f}),u&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-4 w-px shrink-0 bg-border`})]},e)}),t[21]=n,t[22]=r,t[23]=i,t[24]=a,t[25]=s,t[26]=c,t[27]=l,t[28]=v):v=t[28];let b;t[29]===v?b=t[30]:(b=(0,Q.jsx)(pa,{"data-tab-viewport":``,className:`size-full overflow-y-hidden`,ref:ox,children:(0,Q.jsx)(`div`,{className:`flex h-full w-max min-w-full items-center gap-1 px-1.5`,children:v})}),t[29]=v,t[30]=b);let x;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(_a,{orientation:`horizontal`,className:`absolute inset-x-0 bottom-0 data-horizontal:h-1.5`}),t[31]=x):x=t[31];let S;t[32]===b?S=t[33]:(S=(0,Q.jsxs)(xa,{className:`@container/tabs relative h-full min-w-0 flex-1`,children:[b,x]}),t[32]=b,t[33]=S);let C;t[34]!==g||t[35]!==_||t[36]!==S?(C=(0,Q.jsxs)(`div`,{role:`tablist`,"aria-label":g,className:`flex h-full min-w-0 flex-1 items-center gap-1 overflow-hidden`,children:[_,S]}),t[34]=g,t[35]=_,t[36]=S,t[37]=C):C=t[37];let w;t[38]!==n||t[39]!==r||t[40]!==s||t[41]!==l?(w=l.length>1&&(0,Q.jsxs)(vn,{children:[(0,Q.jsxs)(y,{disableHoverablePopup:!0,children:[(0,Q.jsx)(Gt,{render:(0,Q.jsx)(Lt,{render:(0,Q.jsx)(X,{variant:`ghost`,size:`icon-sm`,className:`shrink-0`,"aria-label":`Open document list`})}),children:(0,Q.jsx)(u,{})}),(0,Q.jsx)(m,{children:`Open document list`})]}),(0,Q.jsx)(pt,{align:`end`,className:`w-auto max-w-[min(28rem,90vw)] min-w-56`,children:(0,Q.jsx)(Et,{value:r??``,onValueChange:e=>{typeof e==`string`&&l.includes(e)&&n.onActivate(e)},children:l.map(e=>{let{Icon:t,title:n,hint:r,accessibleName:i}=rx(e);return(0,Q.jsxs)(Cn,{value:e,closeOnClick:!0,"aria-label":i===void 0?n:i,className:`items-start`,children:[(0,Q.jsx)(t,{className:`mt-0.5`}),(0,Q.jsx)(`span`,{className:`min-w-0 whitespace-normal break-all`,children:r}),s.includes(e)&&(0,Q.jsx)(Cr,{"aria-label":`Pinned`,className:`mt-0.5`})]},e)})})})]}),t[38]=n,t[39]=r,t[40]=s,t[41]=l,t[42]=w):w=t[42];let T;t[43]===d?T=t[44]:(T=d!=null&&(0,Q.jsx)(`div`,{className:`ml-1 flex shrink-0 items-center gap-0.5 border-l pl-2`,children:d}),t[43]=d,t[44]=T);let E;return t[45]!==C||t[46]!==w||t[47]!==T||t[48]!==p||t[49]!==h?(E=(0,Q.jsxs)(`div`,{"data-pane-bar":``,className:p,children:[h,C,w,T]}),t[45]=C,t[46]=w,t[47]=T,t[48]=p,t[49]=h,t[50]=E):E=t[50],E}function ax(e){return!ib(e)}function ox(e){if(!e)return;let t=()=>nx(e.querySelector(`[role="tab"][aria-selected="true"]`)),n=0,r=new ResizeObserver(()=>{cancelAnimationFrame(n),n=requestAnimationFrame(t)});return r.observe(e),()=>{cancelAnimationFrame(n),r.disconnect()}}function sx(e){let t=(0,$.c)(88),{tabKey:n,commitSubject:r,ids:i,active:a,pinned:o,hasUnpinned:s,side:c,onActivate:l,onClose:u,onCloseOthers:d,onCloseUnpinned:f,onTogglePin:p,onOpenToSide:h,onClosePane:g}=e,_;t[0]===n?_=t[1]:(_=rx(n),t[0]=n,t[1]=_);let{Icon:b,title:x,hint:S,accessibleName:C}=_,w=C===void 0?x:C,T=r?`${x} ${r}`:x,E=r?`${S} · ${r}`:S,[D,O]=(0,Z.useState)(!1),k;t[2]===c?k=t[3]:(k=wb(c),t[2]=c,t[3]=k);let A=k,j;t[4]!==l||t[5]!==n?(j=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l(n))},t[4]=l,t[5]=n,t[6]=j):j=t[6];let M=j,N;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{e&&O(!1)},t[7]=N):N=t[7];let P;t[8]===n?P=t[9]:(P=Tn(`min-w-0 flex-1`,n.startsWith(`file:`)&&`italic`),t[8]=n,t[9]=P);let F=o?`${E} · pinned`:E,I;t[10]!==b||t[11]!==w||t[12]!==M||t[13]!==a||t[14]!==r||t[15]!==i.panel||t[16]!==i.tab||t[17]!==l||t[18]!==u||t[19]!==p||t[20]!==o||t[21]!==n||t[22]!==T||t[23]!==x?(I=e=>(0,Q.jsxs)(di,{render:(0,Q.jsx)(`div`,{ref:e=>{a&&nx(e)},role:`tab`,id:i.tab,"aria-controls":a?i.panel:void 0,tabIndex:0,"aria-selected":a,"aria-label":r?T:w,"data-entry":n,className:Tn(`group flex h-7 min-w-0 max-w-[min(100cqw,calc(var(--spacing)*45))] cursor-default items-center gap-1.5 rounded-md px-2 text-xs font-medium transition-colors`,a?`bg-muted text-foreground ring-1 ring-border ring-inset`:`text-muted-foreground hover:bg-accent/50`,a&&!ib(n)&&!o&&`pr-0.5`),onClick:()=>l(n),onAuxClick:e=>{e.button===1&&!o&&!ib(n)&&(e.preventDefault(),u(n))},onKeyDown:e=>{e.target===e.currentTarget&&M(e)}}),children:[(0,Q.jsx)(b,{className:`size-3.5 shrink-0`,strokeWidth:ib(n)?1.75:void 0}),e,!ib(n)&&o&&(0,Q.jsxs)(y,{disableHoverablePopup:!0,children:[(0,Q.jsx)(Gt,{render:(0,Q.jsx)(X,{type:`button`,"aria-label":`Unpin ${x}`,onClick:e=>{e.stopPropagation(),p(n)},variant:`ghost`,size:`icon-xs`}),children:(0,Q.jsx)(Cr,{className:`size-3`})}),(0,Q.jsx)(m,{children:`Unpin ${x}`})]}),!ib(n)&&a&&(0,Q.jsxs)(y,{disableHoverablePopup:!0,children:[(0,Q.jsx)(Gt,{render:(0,Q.jsx)(X,{type:`button`,"aria-label":`Close ${x}`,onClick:e=>{e.stopPropagation(),u(n)},variant:`ghost`,size:`icon-xs`,className:`mr-0.5`}),children:(0,Q.jsx)(Ht,{className:`size-3`})}),(0,Q.jsxs)(m,{children:[`Close ${x}`,(0,Q.jsx)(Os,{children:oc(Ys.closeTab)})]})]})]}),t[10]=b,t[11]=w,t[12]=M,t[13]=a,t[14]=r,t[15]=i.panel,t[16]=i.tab,t[17]=l,t[18]=u,t[19]=p,t[20]=o,t[21]=n,t[22]=T,t[23]=x,t[24]=I):I=t[24];let L;t[25]!==P||t[26]!==F||t[27]!==I||t[28]!==T?(L=(0,Q.jsx)(v,{className:P,text:F,disclose:`always`,renderTrigger:I,children:T}),t[25]=P,t[26]=F,t[27]=I,t[28]=T,t[29]=L):L=t[29];let R=!D,z;t[30]===n?z=t[31]:(z=ib(n),t[30]=n,t[31]=z);let B;t[32]!==p||t[33]!==n?(B=()=>p(n),t[32]=p,t[33]=n,t[34]=B):B=t[34];let V;t[35]===o?V=t[36]:(V=o?(0,Q.jsx)(yo,{}):(0,Q.jsx)(Cr,{}),t[35]=o,t[36]=V);let H=o?`Unpin`:`Pin`,U;t[37]!==z||t[38]!==B||t[39]!==V||t[40]!==H?(U=(0,Q.jsxs)($i,{disabled:z,onClick:B,children:[V,H]}),t[37]=z,t[38]=B,t[39]=V,t[40]=H,t[41]=U):U=t[41];let W;t[42]!==h||t[43]!==n?(W=h===void 0||ib(n),t[42]=h,t[43]=n,t[44]=W):W=t[44];let G;t[45]!==h||t[46]!==n?(G=()=>{(0,sg.flushSync)(()=>O(!0)),h?.(n)},t[45]=h,t[46]=n,t[47]=G):G=t[47];let K;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,Q.jsx)(gi,{}),t[48]=K):K=t[48];let ee;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Q.jsx)(Jr,{children:oc(Ys.openToSide)}),t[49]=ee):ee=t[49];let q;t[50]!==A||t[51]!==W||t[52]!==G?(q=(0,Q.jsxs)($i,{disabled:W,onClick:G,children:[K,A,ee]}),t[50]=A,t[51]=W,t[52]=G,t[53]=q):q=t[53];let te;t[54]===g?te=t[55]:(te=g&&(0,Q.jsxs)($i,{onClick:g,children:[(0,Q.jsx)(gi,{}),`Close pane`]}),t[54]=g,t[55]=te);let ne;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Q.jsx)(la,{}),t[56]=ne):ne=t[56];let re;t[57]===n?re=t[58]:(re=ib(n),t[57]=n,t[58]=re);let J;t[59]!==u||t[60]!==n?(J=()=>u(n),t[59]=u,t[60]=n,t[61]=J):J=t[61];let ie;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Q.jsx)(Ht,{}),t[62]=ie):ie=t[62];let ae;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Q.jsx)(Jr,{children:oc(Ys.closeTab)}),t[63]=ae):ae=t[63];let oe;t[64]!==re||t[65]!==J?(oe=(0,Q.jsxs)($i,{disabled:re,onClick:J,children:[ie,`Close`,ae]}),t[64]=re,t[65]=J,t[66]=oe):oe=t[66];let se;t[67]!==d||t[68]!==n?(se=()=>d(n),t[67]=d,t[68]=n,t[69]=se):se=t[69];let ce;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Q.jsx)(Ql,{}),t[70]=ce):ce=t[70];let Y;t[71]===se?Y=t[72]:(Y=(0,Q.jsxs)($i,{onClick:se,children:[ce,`Close others`]}),t[71]=se,t[72]=Y);let le=!s,ue;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,Q.jsx)(Kl,{}),t[73]=ue):ue=t[73];let de;t[74]!==f||t[75]!==le?(de=(0,Q.jsxs)($i,{disabled:le,onClick:f,children:[ue,`Close unpinned`]}),t[74]=f,t[75]=le,t[76]=de):de=t[76];let fe;t[77]!==R||t[78]!==U||t[79]!==q||t[80]!==te||t[81]!==oe||t[82]!==Y||t[83]!==de?(fe=(0,Q.jsxs)(Qr,{className:`min-w-52`,finalFocus:R,children:[U,q,te,ne,oe,Y,de]}),t[77]=R,t[78]=U,t[79]=q,t[80]=te,t[81]=oe,t[82]=Y,t[83]=de,t[84]=fe):fe=t[84];let pe;return t[85]!==fe||t[86]!==L?(pe=(0,Q.jsx)(`span`,{className:`inline-flex min-w-0 flex-1`,children:(0,Q.jsxs)(ia,{onOpenChange:N,children:[L,fe]})}),t[85]=fe,t[86]=L,t[87]=pe):pe=t[87],pe}function cx(e){let t=(0,$.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({commitContext:n,oid:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]!==n||t[5]!==r?(a=lv({...n,oid:r,parent:1}),t[4]=n,t[5]=r,t[6]=a):a=t[6];let o=$t(a),s;t[7]===o?s=t[8]:(s=ne(J(o)),t[7]=o,t[8]=s);let c=s?.commit.subject,l;return t[9]!==c||t[10]!==i?(l=(0,Q.jsx)(sx,{...i,commitSubject:c}),t[9]=c,t[10]=i,t[11]=l):l=t[11],l}function lx(e,t,n){let r=(0,$.c)(13),i;r[0]!==e||r[1]!==n||r[2]!==t?(i=b({connection:e,projectId:t,number:n}),r[0]=e,r[1]=n,r[2]=t,r[3]=i):i=r[3];let{value:a}=Bc(i),o=Aa(e);if(a.kind!==`available`)return;let s;if(r[4]!==o.projects||r[5]!==t||r[6]!==a.pullRequest){let e;r[8]===t?e=r[9]:(e=e=>e.id===t&&e.available,r[8]=t,r[9]=e),s=o.projects.find(e)?.worktrees.find(e=>e.available&&e.branch===a.pullRequest.headBranch),r[4]=o.projects,r[5]=t,r[6]=a.pullRequest,r[7]=s}else s=r[7];let c=s,l;return r[10]!==t||r[11]!==c?(l=c?{projectId:t,worktreeId:c.id}:void 0,r[10]=t,r[11]=c,r[12]=l):l=r[12],l}function ux(e){let t=(0,$.c)(13),{label:n,description:r,icon:i,shortcut:a,onClick:o,disabled:s,pressed:c,variant:l,iconOnly:u}=e,d=s!==void 0&&s,f=l===void 0?`ghost`:l,p=u!==void 0&&u,h;t[0]===p?h=t[1]:(h=p?[`compact`]:[`compact`,`key`,`full`],t[0]=p,t[1]=h);let g;return t[2]!==i||t[3]!==r||t[4]!==d||t[5]!==p||t[6]!==n||t[7]!==o||t[8]!==c||t[9]!==a||t[10]!==h||t[11]!==f?(g=(0,Q.jsx)(Q.Fragment,{children:h.map(e=>(0,Q.jsxs)(y,{children:[(0,Q.jsxs)(Gt,{render:(0,Q.jsx)(X,{variant:f,size:e===`compact`?`icon`:`default`,className:Tn(!p&&e===`compact`&&`@min-lg/pane:hidden`,e===`key`&&`hidden @min-lg/pane:inline-flex @min-3xl/pane:hidden`,e===`full`&&`hidden @min-3xl/pane:inline-flex`),"aria-label":n,"aria-keyshortcuts":a,"aria-pressed":c,disabled:d,focusableWhenDisabled:!0,onClick:o}),children:[c===!1?(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`size-3.5 shrink-0 rounded-sm border-[--spacing(0.375)] border-border-strong bg-background`}):(0,Q.jsx)(i,{className:`size-3.5`}),e===`full`&&(0,Q.jsx)(`span`,{children:n}),a&&e!==`compact`&&(0,Q.jsx)(Os,{children:oc(a)})]}),(0,Q.jsxs)(m,{role:`tooltip`,children:[r??n,a&&(0,Q.jsx)(Os,{children:oc(a)})]})]},e))}),t[2]=i,t[3]=r,t[4]=d,t[5]=p,t[6]=n,t[7]=o,t[8]=c,t[9]=a,t[10]=h,t[11]=f,t[12]=g):g=t[12],g}function dx(e,t,n){let r=(0,$.c)(4),i=n===void 0?Zo:n,a;return r[0]!==t.connection||r[1]!==i||r[2]!==e?(a=Pr({scope:e,connection:t.connection,range:i}),r[0]=t.connection,r[1]=i,r[2]=e,r[3]=a):a=r[3],Bc(a).value}function fx(e,t,n){let r=(0,$.c)(4),i=n===void 0?Zo:n,a;r[0]!==t.connection||r[1]!==i||r[2]!==e?(a=Pr({scope:e,connection:t.connection,range:i}),r[0]=t.connection,r[1]=i,r[2]=e,r[3]=a):a=r[3],Vt(a)}function px(e,t,n,r){let i=(0,$.c)(4),a=dx(e,t),o;return i[0]!==n||i[1]!==r||i[2]!==a?(o=Ta(n,a,r),i[0]=n,i[1]=r,i[2]=a,i[3]=o):o=i[3],o}function mx(e){let t=(0,$.c)(14),{scope:n,context:r,base:i,quiet:a,children:o}=e,s=a!==void 0&&a,c;t[0]===s?c=t[1]:(c=s?null:(0,Q.jsx)(l,{label:`Comparing the branch`}),t[0]=s,t[1]=c);let u=c,d=Ga(n,r.connection,i);if(h(d.result)){let e;t[2]===d.result.cause?e=t[3]:(e=gd(ie(d.result.cause)),t[2]=d.result.cause,t[3]=e);let n;return t[4]!==d.refresh||t[5]!==e?(n=(0,Q.jsx)(pe,{description:e,onRetry:d.refresh}),t[4]=d.refresh,t[5]=e,t[6]=n):n=t[6],n}if(!Kt(d.result))return u;if(d.result.value.base===void 0){let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(gr,{message:`Choose the branch this one is compared against in the Branch list.`}),t[7]=e):e=t[7],e}let f;t[8]!==d.result.value||t[9]!==o?(f=o(d.result.value),t[8]=d.result.value,t[9]=o,t[10]=f):f=t[10];let p;return t[11]!==u||t[12]!==f?(p=(0,Q.jsx)(Z.Suspense,{fallback:u,children:f}),t[11]=u,t[12]=f,t[13]=p):p=t[13],p}function hx(e){return e?e.hunks.flatMap(e=>{let t=e.additionStart;return e.hunkContent.flatMap(e=>{if(e.type===`context`)return t+=e.lines,[];let n=t;return t+=e.additions,Array.from({length:e.additions},(e,t)=>`[data-code] [data-line="${n+t}"] { box-shadow: inset calc(var(--spacing) * 0.75) 0 var(--add-fg); }`)})}).join(`
|
|
36
|
+
`):``}function gx(e,t,n,r){return{id:e,kind:`file`,path:t,contents:n,version:lc(n),...r?{note:r}:{}}}var _x=new Map,vx=new Map;function yx(e){if(e.kind===`diff`){let t=_x.get(e.id);return t?.cacheKey!==void 0&&t.cacheKey===e.fileDiff.cacheKey?{type:`diff`,fileDiff:t}:(_x.set(e.id,e.fileDiff),{type:`diff`,fileDiff:e.fileDiff})}let t=vx.get(e.id);if(t?.file.name===e.path&&t.file.contents===e.contents)return{type:`file`,file:t.file};let n=(t?.revision??0)+1;if(!Number.isSafeInteger(n))throw Error(`File highlighting exhausted its revision identifiers.`);let r={name:e.path,contents:e.contents,cacheKey:JSON.stringify([e.id,e.path,n])};return vx.set(e.id,{file:r,revision:n}),{type:`file`,file:r}}function bx(e){let t=new Map;for(let n of e){let e=t.get(n.path)??{additions:0,deletions:0},r=xx(n);e.additions+=r.additions,e.deletions+=r.deletions,t.set(n.path,e)}return t}function xx(e){return e.kind===`file`?{additions:e.contents.split(`
|
|
37
|
+
`).filter((e,t,n)=>t<n.length-1||e).length,deletions:0}:e.fileDiff.hunks.reduce((e,t)=>({additions:e.additions+t.additionLines,deletions:e.deletions+t.deletionLines}),{additions:0,deletions:0})}function Sx(e,t,n){let r=(0,$.c)(9),i=n===void 0?Zo:n,a;r[0]!==t.connection||r[1]!==i||r[2]!==e?(a=qi({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]=Pn(o,s),u=Bn(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 Cx(e,t,n){let r=(0,$.c)(9),i=n===void 0?Zo:n,a;r[0]!==t.connection||r[1]!==i||r[2]!==e?(a=qi({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]=Pn(o,s),u=Bn(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 wx(e,t,n){let r=(0,$.c)(12),i=n===void 0?Zo:n,a;r[0]!==t.connection||r[1]!==i||r[2]!==e?(a=qi({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.bulk,[s,c]=Pn(o),l;r[4]===Symbol.for(`react.memo_cache_sentinel`)?(l={mode:`promiseExit`},r[4]=l):l=r[4];let u=Bn(o,l),d;r[5]===s?d=r[6]:(d=ne(J(s)),r[5]=s,r[6]=d);let f=d,p=!s.waiting&&f?.kind===`mark`?f.report:null,m;return r[7]!==s||r[8]!==c||r[9]!==u||r[10]!==p?(m={result:s,submit:u,report:p,start:c},r[7]=s,r[8]=c,r[9]=u,r[10]=p,r[11]=m):m=r[11],m}function Tx(e,t,n,r){let i=(0,$.c)(5),a=r===void 0?Zo:r,o=Ae(t),s=Sx(e,t,a),c=Cx(e,t,a),l;return i[0]!==s||i[1]!==n||i[2]!==c||i[3]!==o?(l={writeBlock:o,toggle(e){if(o)return;let t=Xa(e,s.result.waiting||c.result.waiting);t&&(t.kind===`unmark`?c.submit(t.path):s.submit(t.input)).then(e=>{ce(e)&&n({title:`Could not update review`,description:ws(ie(e.cause)),type:`error`})})}},i[0]=s,i[1]=n,i[2]=c,i[3]=o,i[4]=l):l=i[4],l}function Ex(e,t,n,r,i,a){let o=(0,$.c)(22),s=Ae(t),c;o[0]===r?c=o[1]:(c=Ha(r),o[0]=r,o[1]=c);let l=c,u;o[2]===i?u=o[3]:(u=Ha(i),o[2]=i,o[3]=u);let d=u,f=wx(e,t,n),p=wx(e,t),m;if(o[4]!==r||o[5]!==i){let e=[...r,...i];m=e.length>0&&e.every(Ox),o[4]=r,o[5]=i,o[6]=m}else m=o[6];let h=m,g=f.result.waiting||p.result.waiting,_=!!s||g||l.blocked&&d.blocked,v;o[7]!==r||o[8]!==f||o[9]!==l||o[10]!==_||o[11]!==a||o[12]!==h||o[13]!==i||o[14]!==p||o[15]!==d?(v=()=>{if(_)return;let e=[{entries:r,plan:l,command:f},{entries:i,plan:d,command:p}].filter(Dx).map(e=>e.command.submit(h?{kind:`unmark`,paths:e.plan.reviewedPaths}:{kind:`mark`,entries:e.entries}));Promise.all(e).then(e=>{let t=e.find(ce);if(t){a({title:`Could not update review`,description:ws(ie(t.cause)),type:`error`});return}let n={marked:[],skipped:[],failed:[]};for(let t of e)qt(t)&&t.value.kind===`mark`&&(n.marked.push(...t.value.report.marked),n.skipped.push(...t.value.report.skipped),n.failed.push(...t.value.report.failed));a(as(n)??{title:h?`Step marked unreviewed`:`Step marked reviewed`,type:`success`})})},o[7]=r,o[8]=f,o[9]=l,o[10]=_,o[11]=a,o[12]=h,o[13]=i,o[14]=p,o[15]=d,o[16]=v):v=o[16];let y=v,b;return o[17]!==_||o[18]!==h||o[19]!==y||o[20]!==s?(b={reviewed:h,disabled:_,toggle:y,writeBlock:s},o[17]=_,o[18]=h,o[19]=y,o[20]=s,o[21]=b):b=o[21],b}function Dx(e){return e.entries.length>0}function Ox(e){return e.reviewStatus===`reviewed`}function kx(e){let t=(0,$.c)(7),{counts:n}=e,r;t[0]===n.additions?r=t[1]:(r=(0,Q.jsxs)(`span`,{className:`text-add-fg`,children:[`+`,n.additions]}),t[0]=n.additions,t[1]=r);let i;t[2]===n.deletions?i=t[3]:(i=(0,Q.jsxs)(`span`,{className:`text-del-fg`,children:[`−`,n.deletions]}),t[2]=n.deletions,t[3]=i);let a;return t[4]!==r||t[5]!==i?(a=(0,Q.jsxs)(`span`,{className:`shrink-0 font-mono text-xs leading-4 font-medium tabular-nums`,children:[r,` `,i]}),t[4]=r,t[5]=i,t[6]=a):a=t[6],a}function Ax(e){if(!(!e||e.side===`deletions`||e.endSide!==void 0&&e.endSide!==e.side))return{startLine:Math.min(e.start,e.end),endLine:Math.max(e.start,e.end)}}function jx(e){let t=(0,$.c)(11),n=Tx(e.scope,e.context,Mx,e.range),r;t[0]!==e.interaction.entry||t[1]!==e.range?(r=JSON.stringify([e.interaction.entry,e.range]),t[0]=e.interaction.entry,t[1]=e.range,t[2]=r):r=t[2];let i;t[3]!==e||t[4]!==n?(i=t=>{n.writeBlock||(e.onReview?e.onReview(t):n.toggle(t.review))},t[3]=e,t[4]=n,t[5]=i):i=t[5];let a;return t[6]!==e||t[7]!==n.writeBlock||t[8]!==r||t[9]!==i?(a=(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsx)(Nx,{...e,writeBlock:n.writeBlock,onToggleReviewed:i},r)}),t[6]=e,t[7]=n.writeBlock,t[8]=r,t[9]=i,t[10]=a):a=t[10],a}function Mx(e){return ms.add(e)}function Nx(e){let t=(0,$.c)(118),{entries:n,scope:r,context:i,interaction:a,header:o,footer:s,headerLeading:c,headerActions:l,emptyActions:d,toolbar:f,foundLine:p,disableFileHeader:m,fileDiff:h,compactThreads:g,fullHeight:_,compactHeight:y,collapsible:b,decision:x,column:S,readingColumn:C,framed:w,range:T,onToggleReviewed:E,writeBlock:D}=e,O=m!==void 0&&m,k=g!==void 0&&g,A=_!==void 0&&_,j=y!==void 0&&y,M=b!==void 0&&b,N=x!==void 0&&x,P=S!==void 0&&S,F=C===void 0?P:C,I=w!==void 0&&w,{dark:L}=$s(),{preferences:R}=qs(),z=xc(i.connection),B=N?n:bd(n,z),V=zb(a.worktreeId,a.entry),H;t[0]!==i.connection.environmentId||t[1]!==a.entry||t[2]!==a.worktreeId||t[3]!==T?(H=JSON.stringify([i.connection.environmentId,a.worktreeId,a.entry,T]),t[0]=i.connection.environmentId,t[1]=a.entry,t[2]=a.worktreeId,t[3]=T,t[4]=H):H=t[4];let U=Ub(H),W;t[5]===U?W=t[6]:(W=()=>U.selection(),t[5]=U,t[6]=W);let[G,K]=(0,Z.useState)(W),ee=G?B.find(e=>e.id===G.lines.id):void 0,q=G!==null&&ee?.version!==G.version,te=q?null:G?.lines??null,ne=e=>{let t=e?B.find(t=>t.id===e.id):void 0,n=e&&t?{lines:e,version:t.version}:null;K(n),U.rememberSelection(n)},re=te?.range,J;t[7]===re?J=t[8]:(J=Ax(re),t[7]=re,t[8]=J);let ie=J,ae;t[9]===U?ae=t[10]:(ae=()=>U.focused(),t[9]=U,t[10]=ae);let[oe,se]=(0,Z.useState)(ae),ce;t[11]===U?ce=t[12]:(ce=e=>{se(e),U.rememberFocus(e)},t[11]=U,t[12]=ce);let Y=ce,le;t[13]===oe?le=t[14]:(le=e=>e.id===oe,t[13]=oe,t[14]=le);let ue=Math.max(B.findIndex(le),0),de=new Set(B.filter(e=>Ob(V.folds,e.id,B.length>1&&e.review?.reviewed===!0||(M||B.length>1)&&z&&yd(e.path))).map(Rx)),[pe,he]=(0,Z.useState)(),[ge,_e]=(0,Z.useState)(),ve=e=>{let t=B[e];t&&(Y(t.id),U.scrollTo({type:`item`,id:t.id,align:`start`}))},ye=new Map(B.map(Lx)),be=B.map(e=>({id:e.id,collapsed:de.has(e.id),version:lc(JSON.stringify([e.version,de.has(e.id)])),...yx(e)})),xe=B.filter(Ix),Se=new Set(xe.map(Fx)).size,Ce=xe[0]?.id,we=new Map;for(let e of B)e.review&&!we.has(e.review.path)&&we.set(e.review.path,e.id);let Ee=A||s?12:160,De=N||P||k||I?zs:ac,Oe=L?`dark`:`light`,ke=R.lineOverflow,Ae=R.diffStyle,je=!O&&!A,Me=O||j,Ne,Pe;t[15]===Y?(Ne=t[16],Pe=t[17]):(Ne=(e,t)=>Y(t.item.id),Pe=(e,t)=>Y(t.item.id),t[15]=Y,t[16]=Ne,t[17]=Pe);let Fe;t[18]===h?Fe=t[19]:(Fe=hx(h),t[18]=h,t[19]=Fe);let Ie=`${k?`[data-line-annotation]:has([data-file-thread-marker]) { margin-left: 0; }`:``}${Fe}${N||P||I?rc:``}${P?tc:``}${sc}${O||j?`[data-code] { padding-top: 0 !important; }`:Fc}${k?Gs:``}${j?`[data-diffs-header], pre { border: 0; border-radius: 0; }`:``}`,Le;t[20]===P?Le=t[21]:(Le=P?{itemMetrics:{lineHeight:22,diffHeaderHeight:41}}:{},t[20]=P,t[21]=Le);let Re;t[22]!==j||t[23]!==O?(Re=O||j?{itemMetrics:{paddingTop:0}}:{},t[22]=j,t[23]=O,t[24]=Re):Re=t[24];let ze=O||j?0:12,Be=j?0:Ee,Ve;t[25]!==ze||t[26]!==Be?(Ve={paddingTop:ze,paddingBottom:Be,gap:12},t[25]=ze,t[26]=Be,t[27]=Ve):Ve=t[27];let He;t[28]!==R.diffStyle||t[29]!==R.lineOverflow||t[30]!==De||t[31]!==Oe||t[32]!==je||t[33]!==Me||t[34]!==Ne||t[35]!==Pe||t[36]!==Ie||t[37]!==Le||t[38]!==Re||t[39]!==Ve?(He={preferredHighlighter:Us,theme:De,themeType:Oe,overflow:ke,diffStyle:Ae,diffIndicators:`classic`,hunkSeparators:`line-info`,stickyHeaders:je,disableFileHeader:Me,enableLineSelection:!0,enableGutterUtility:!1,onLineClick:Ne,onLineNumberClick:Pe,lineHoverHighlight:`number`,unsafeCSS:Ie,...Le,...Re,layout:Ve},t[28]=R.diffStyle,t[29]=R.lineOverflow,t[30]=De,t[31]=Oe,t[32]=je,t[33]=Me,t[34]=Ne,t[35]=Pe,t[36]=Ie,t[37]=Le,t[38]=Re,t[39]=Ve,t[40]=He):He=t[40];let Ue=He,We=B.length>0&&B.every(e=>de.has(e.id)),Ge;t[41]!==B||t[42]!==V?(Ge=e=>V.setCollapsed(B.map(Px),e),t[41]=B,t[42]=V,t[43]=Ge):Ge=t[43];let Ke=Ge,qe=e=>{Y(e),V.setCollapsed([e],!de.has(e))},Je;t[44]===We?Je=t[45]:(Je=We?(0,Q.jsx)(vl,{"aria-hidden":`true`,"data-icon":`inline-start`}):(0,Q.jsx)(gl,{"aria-hidden":`true`,"data-icon":`inline-start`}),t[44]=We,t[45]=Je);let Ye=Je,Xe=We?`Expand all files`:`Collapse all files`,Ze;t[46]!==We||t[47]!==Ke?(Ze=()=>Ke(!We),t[46]=We,t[47]=Ke,t[48]=Ze):Ze=t[48];let Qe;t[49]!==Ye||t[50]!==Xe||t[51]!==Ze?(Qe=(0,Q.jsxs)(X,{size:`sm`,variant:`ghost`,onClick:Ze,children:[Ye,Xe]}),t[49]=Ye,t[50]=Xe,t[51]=Ze,t[52]=Qe):Qe=t[52];let $e=Qe,et=B.length>1?$e:null,tt;t[53]!==a.entry||t[54]!==a.toolbarTarget?(tt=a.toolbarTarget!==void 0&&/^(file|review-file|review-change|change|branch):/.test(a.entry),t[53]=a.entry,t[54]=a.toolbarTarget,t[55]=tt):tt=t[55];let nt=tt,rt=B[ue]??B[0],it;t[56]!==d||t[57]!==rt||t[58]!==l||t[59]!==E||t[60]!==nt||t[61]!==D?(it=nt&&(rt?(0,Q.jsxs)(Q.Fragment,{children:[rt.review&&(0,Q.jsx)(ux,{label:`Reviewed`,variant:`outline`,icon:rt?.review?.reviewed?Te:eu,shortcut:Ys.toggleReviewed,description:D,disabled:!!D||!rt?.review?.fingerprint,pressed:rt?.review?.reviewed,onClick:()=>{rt&&E(rt)}}),l]}):d??l),t[56]=d,t[57]=rt,t[58]=l,t[59]=E,t[60]=nt,t[61]=D,t[62]=it):it=t[62];let at=it,ot;t[63]!==et||t[64]!==B||t[65]!==ve||t[66]!==ue||t[67]!==V||t[68]!==o?(ot=o&&(()=>o({collapse:et,current:B[ue]?.path,counts:bx(B),open:e=>{let t=B.findIndex(t=>t.path===e),n=B[t];n&&V.setCollapsed([n.id],!1),ve(t)}})),t[63]=et,t[64]=B,t[65]=ve,t[66]=ue,t[67]=V,t[68]=o,t[69]=ot):ot=t[69];let st=ot,ct=(N||P||k||I)&&`decision-code`,lt=k&&`file-code`,ut=I&&`commit-code`,dt=j&&`overflow-hidden rounded-lg border`,ft;t[70]!==ct||t[71]!==lt||t[72]!==ut||t[73]!==dt?(ft=Tn(`@container/code relative flex min-h-0 flex-1 flex-col`,ct,lt,ut,dt),t[70]=ct,t[71]=lt,t[72]=ut,t[73]=dt,t[74]=ft):ft=t[74];let pt;t[75]!==a.toolbarTarget||t[76]!==at?(pt=a.toolbarTarget&&at&&(0,sg.createPortal)(at,a.toolbarTarget),t[75]=a.toolbarTarget,t[76]=at,t[77]=pt):pt=t[77];let mt;t[78]!==B||t[79]!==ve||t[80]!==ue||t[81]!==a.active||t[82]!==a.entry||t[83]!==E?(mt=a.active&&B.length>0&&(0,Q.jsx)(Bx,{reviewEnabled:!a.entry.startsWith(`walkthrough-step:`),next:()=>ve(Math.min(ue+1,B.length-1)),previous:()=>ve(Math.max(ue-1,0)),review:()=>{let e=B[ue];e?.review&&E(e)}}),t[78]=B,t[79]=ve,t[80]=ue,t[81]=a.active,t[82]=a.entry,t[83]=E,t[84]=mt):mt=t[84];let ht;t[85]===q?ht=t[86]:(ht=q&&(0,Q.jsx)(`p`,{role:`status`,className:`absolute bottom-3 left-3 z-10 rounded-lg border bg-popover p-2 text-xs`,children:`Code changed since these lines were selected. Select lines again.`}),t[85]=q,t[86]=ht);let gt;t[87]!==ie||t[88]!==i||t[89]!==r||t[90]!==ee?(gt=ie&&ee?.discardScope&&(0,Q.jsx)(`div`,{className:`absolute bottom-3 left-3 z-10 rounded-lg border bg-popover p-2`,children:(0,Q.jsx)(d_,{scope:r,context:i,path:ee.path,hunk:{scope:ee.discardScope,...ie},variant:`compact`})}),t[87]=ie,t[88]=i,t[89]=r,t[90]=ee,t[91]=gt):gt=t[91];let _t;t[92]!==et||t[93]!==P||t[94]!==f?(_t=f?f(et):!P&&et&&(0,Q.jsx)(`div`,{className:`flex shrink-0 justify-end px-3`,children:et}),t[92]=et,t[93]=P,t[94]=f,t[95]=_t):_t=t[95];let vt;t[96]!==B.length||t[97]!==s||t[98]!==o||t[99]!==l||t[100]!==c||t[101]!==nt||t[102]!==F||t[103]!==st?(vt=B.length===0&&(o||l||s)&&(0,Q.jsxs)(`div`,{className:Tn(`min-h-0 flex-1 overflow-auto`,F&&zx),"data-testid":`empty-code-document`,children:[c&&(0,Q.jsx)(`div`,{className:`flex items-center gap-1 px-3.5 py-2`,children:c}),st?.(),s?.(),!nt&&l&&(0,Q.jsx)(`div`,{className:`flex justify-end px-3.5 py-2`,children:(0,Q.jsx)(v_,{children:l})})]}),t[96]=B.length,t[97]=s,t[98]=o,t[99]=l,t[100]=c,t[101]=nt,t[102]=F,t[103]=st,t[104]=vt):vt=t[104];let yt;t[105]!==j||t[106]!==B[0]?(yt=j&&B[0]&&(0,Q.jsx)(`div`,{className:`flex min-h-10 shrink-0 items-center gap-2 border-b bg-muted px-2 py-1`,children:(0,Q.jsx)(v,{className:`min-w-0 flex-1 font-mono text-caption font-medium`,text:B[0].path})}),t[105]=j,t[106]=B[0],t[107]=yt):yt=t[107];let bt=B.length>0&&(0,Q.jsx)(Pg,{ref:e=>{if(!e)return;let t=e.getInstance();if(!t)return;let n=U.attach(t),r=requestAnimationFrame(()=>{U.restorePosition(t,Ue.stickyHeaders&&!Ue.disableFileHeader?Ue.itemMetrics?.diffHeaderHeight??Uc.diffHeaderHeight:0);let n=a.fileTarget,r=n?B.find(e=>e.path===n.path):void 0;n&&r&&n.nonce!==ge&&(V.setCollapsed([r.id],!1),e.scrollTo({type:`item`,id:r.id,align:`start`}),Y(r.id),_e(n.nonce));let i=B[0];p&&i&&pe!==p.nonce&&(ne({id:i.id,range:{start:p.line,end:p.line}}),e.scrollTo({type:`line`,id:i.id,lineNumber:p.line,align:`center`}),he(p.nonce))});return()=>{cancelAnimationFrame(r),n?.()}},items:be,onScroll:U.rememberPosition,selectedLines:te,onSelectedLinesChange:e=>{ne(e),e&&Y(e.id)},renderHeaderMetadata:e=>{let t=ye.get(e.id);if(O||!t)return null;let n=e.id===B[0]?.id,r=!nt&&n?l:null,i=e.id===B[0]?.id?c:null,a=t.review?.stale?(0,Q.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;return P?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[a,(0,Q.jsx)(kx,{counts:xx(t)})]}):!a&&!i&&!r?null:(0,Q.jsxs)(`div`,{className:Tn(`flex max-w-full items-center justify-end gap-1.5`,!N&&`flex-wrap`),children:[a,i,r&&(0,Q.jsx)(v_,{children:r})]})},review:N||P||k||I,options:Ue,className:Tn(j&&`max-h-48 flex-none overflow-auto`,!j&&A&&`flex-none overflow-visible`,!j&&!A&&`min-h-0 flex-1 overflow-auto`,F&&zx),...st?{renderCodeViewHeader:st}:{},...s?{renderCodeViewFooter:s}:{},renderHeaderPrefix:e=>{let t=ye.get(e.id);if(!t)return null;let n=de.has(e.id),r=t.review,i=r&&!nt&&we.get(r.path)===t.id?r.control:null;return(0,Q.jsxs)(`span`,{className:Tn(`flex items-center`,P?`gap-2`:`gap-1`),children:[!N&&z&&e.id===Ce&&B.length>xe.length&&(0,Q.jsxs)(`span`,{className:`mr-2 border-r pr-2 font-sans text-xs font-medium`,children:[`Specs · `,fe(Se,`file`)]}),(P||M||B.length>1)&&(0,Q.jsx)(Hx,{label:`${n?`Expand`:`Collapse`} ${t.path}`,icon:n?me:u,expanded:!n,onClick:()=>qe(e.id)}),i]})},renderHeaderFilenameSuffix:e=>{let t=ye.get(e.id);return t&&t.note?(0,Q.jsx)(v,{className:`ml-2 hidden max-w-48 font-sans text-xs text-muted-foreground @code-wide/code:block`,text:t.note}):null}}),xt;return t[108]!==ft||t[109]!==pt||t[110]!==mt||t[111]!==ht||t[112]!==gt||t[113]!==_t||t[114]!==vt||t[115]!==yt||t[116]!==bt?(xt=(0,Q.jsxs)(`div`,{role:`region`,"aria-label":`Code content`,className:ft,children:[pt,mt,ht,gt,_t,vt,yt,bt]}),t[108]=ft,t[109]=pt,t[110]=mt,t[111]=ht,t[112]=gt,t[113]=_t,t[114]=vt,t[115]=yt,t[116]=bt,t[117]=xt):xt=t[117],xt}function Px(e){return e.id}function Fx(e){return e.path}function Ix(e){return yd(e.path)}function Lx(e){return[e.id,e]}function Rx(e){return e.id}var zx=`px-[max(--spacing(4),calc((100%-var(--container-reading))/2))] @2xl/pane:px-[max(--spacing(7),calc((100%-var(--container-reading))/2))]`;function Bx(e){let t=(0,$.c)(4),{reviewEnabled:n,next:r,previous: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;cc(Ys.nextFile,r,s),cc(Ys.previousFile,i,s);let c;return t[1]!==a||t[2]!==n?(c=n?(0,Q.jsx)(Vx,{review:a}):null,t[1]=a,t[2]=n,t[3]=c):c=t[3],c}function Vx(e){let t=(0,$.c)(1),{review:n}=e,r;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={ignoreInputs:!0},t[0]=r):r=t[0],cc(Ys.toggleReviewed,n,r),null}function Hx(e){let t=(0,$.c)(14),{label:n,icon:r,expanded:i,onClick:a}=e,o;t[0]!==i||t[1]!==n||t[2]!==a?(o=(0,Q.jsx)(X,{size:`icon-xs`,variant:`ghost`,"aria-label":n,"aria-expanded":i,onClick:a}),t[0]=i,t[1]=n,t[2]=a,t[3]=o):o=t[3];let s;t[4]===r?s=t[5]:(s=(0,Q.jsx)(r,{}),t[4]=r,t[5]=s);let c;t[6]!==o||t[7]!==s?(c=(0,Q.jsx)(Gt,{render:o,children:s}),t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;t[9]===n?l=t[10]:(l=(0,Q.jsx)(m,{children:n}),t[9]=n,t[10]=l);let u;return t[11]!==c||t[12]!==l?(u=(0,Q.jsxs)(y,{children:[c,l]}),t[11]=c,t[12]=l,t[13]=u):u=t[13],u}function Ux(e){let t=(0,$.c)(51),{target:n,barActions:r,title:i,titleLabel:a,subtitle:o,children:s,className:c,inline:l}=e;if(l!==void 0&&l){let e=a??(typeof i==`string`?i:``),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(`h1`,{}),t[0]=n):n=t[0];let r;t[1]!==e||t[2]!==i?(r=(0,Q.jsx)(v,{text:e,render:n,className:`min-w-0 text-ui font-semibold`,children:i}),t[1]=e,t[2]=i,t[3]=r):r=t[3];let c;t[4]===o?c=t[5]:(c=o&&(0,Q.jsx)(`span`,{className:`shrink-0 text-caption text-muted-foreground`,children:o}),t[4]=o,t[5]=c);let l;t[6]!==r||t[7]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-64 items-baseline gap-2`,children:[r,c]}),t[6]=r,t[7]=c,t[8]=l):l=t[8];let u;t[9]===s?u=t[10]:(u=(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:s}),t[9]=s,t[10]=u);let d;return t[11]!==l||t[12]!==u?(d=(0,Q.jsxs)(`header`,{"data-testid":`document-toolbar`,className:`flex min-h-11 shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b px-4 py-1.5`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}if(n!==void 0){let e;t[14]!==r||t[15]!==s||t[16]!==n?(e=n&&(0,sg.createPortal)(r===void 0?s:r,n),t[14]=r,t[15]=s,t[16]=n,t[17]=e):e=t[17];let c=a??(typeof i==`string`?i:``),l;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(`h1`,{}),t[18]=l):l=t[18];let u;t[19]!==c||t[20]!==i?(u=(0,Q.jsx)(v,{text:c,render:l,className:`text-ui font-semibold`,children:i}),t[19]=c,t[20]=i,t[21]=u):u=t[21];let d;t[22]===o?d=t[23]:(d=o&&(0,Q.jsx)(`p`,{className:`text-2xs text-muted-foreground`,children:o}),t[22]=o,t[23]=d);let f;t[24]!==r||t[25]!==s?(f=r!==void 0&&(0,Q.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:s}),t[24]=r,t[25]=s,t[26]=f):f=t[26];let p;t[27]!==u||t[28]!==d||t[29]!==f?(p=(0,Q.jsxs)(`div`,{className:`shrink-0 px-3.5 py-2`,children:[u,d,f]}),t[27]=u,t[28]=d,t[29]=f,t[30]=p):p=t[30];let m;return t[31]!==e||t[32]!==p?(m=(0,Q.jsxs)(Q.Fragment,{children:[e,p]}),t[31]=e,t[32]=p,t[33]=m):m=t[33],m}let u;t[34]===c?u=t[35]:(u=Tn(`flex min-h-11 shrink-0 flex-wrap items-center gap-x-2.5 gap-y-1 border-b px-3.5`,c),t[34]=c,t[35]=u);let d=a??(typeof i==`string`?i:``),f;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(`h1`,{}),t[36]=f):f=t[36];let p;t[37]!==d||t[38]!==i?(p=(0,Q.jsx)(v,{text:d,render:f,className:`text-ui leading-tight font-semibold`,children:i}),t[37]=d,t[38]=i,t[39]=p):p=t[39];let m;t[40]===o?m=t[41]:(m=o!=null&&(0,Q.jsx)(v,{text:o,render:(0,Q.jsx)(`p`,{}),className:`text-2xs leading-tight text-muted-foreground`}),t[40]=o,t[41]=m);let h;t[42]!==p||t[43]!==m?(h=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-auto flex-col`,children:[p,m]}),t[42]=p,t[43]=m,t[44]=h):h=t[44];let g;t[45]===s?g=t[46]:(g=(0,Q.jsx)(`div`,{className:`ml-auto flex max-w-full shrink-0 flex-wrap items-center justify-end gap-1.5`,children:s}),t[45]=s,t[46]=g);let _;return t[47]!==u||t[48]!==h||t[49]!==g?(_=(0,Q.jsxs)(`header`,{"data-testid":`document-toolbar`,className:u,children:[h,g]}),t[47]=u,t[48]=h,t[49]=g,t[50]=_):_=t[50],_}function Wx(e){let t=(0,$.c)(7),{more:n,total:r,pending:i,onReadMore:a}=e;if(n<=0)return null;let o;t[0]===i?o=t[1]:(o=i&&(0,Q.jsx)(S,{"aria-hidden":`true`}),t[0]=i,t[1]=o);let s=`Read ${Math.min(n,25)} more of ${r}`,c;return t[2]!==a||t[3]!==i||t[4]!==o||t[5]!==s?(c=(0,Q.jsx)(`div`,{className:`border-t px-4 py-3 text-center`,children:(0,Q.jsxs)(X,{variant:`outline`,size:`sm`,onClick:a,disabled:i,children:[o,s]})}),t[2]=a,t[3]=i,t[4]=o,t[5]=s,t[6]=c):c=t[6],c}function Gx(e){let t=(0,$.c)(2),{count:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:`flex flex-col`,children:Array.from({length:n},Kx)}),t[0]=n,t[1]=r),r}function Kx(e,t){return(0,Q.jsx)(`div`,{className:`min-h-40`},t)}function qx(e,t,n){return{path:n.path,fingerprint:n.fingerprint??null,reviewed:n.reviewStatus===`reviewed`,stale:n.reviewStatus===`stale`,control:(0,Q.jsx)(Jx,{scope:e,context:t,path:n.path,fingerprint:n.fingerprint,status:n.reviewStatus,compact:!0},`review:${n.path}`)}}function Jx(e){let t=(0,$.c)(47),{scope:n,context:r,path:i,fingerprint:a,status:o,compact:s,range:c}=e,l=s!==void 0&&s,u=c===void 0?Zo:c,d=Ae(r),f=Sx(n,r,u),p=Cx(n,r,u),h=f.result.waiting||p.result.waiting,g,_;if(t[0]!==l||t[1]!==a||t[2]!==f||t[3]!==i||t[4]!==h||t[5]!==o||t[6]!==p||t[7]!==d){_=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Ss(f.result,p.result);if(a==null){let e;t[10]===i?e=t[11]:(e=Oo([i]),t[10]=i,t[11]=e);let n;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(Gr,{className:`size-3`,"aria-hidden":`true`}),t[12]=n):n=t[12];let r=l?`Not reviewable`:`Not reviewable: too large or unreadable`,a;t[13]!==e||t[14]!==r?(a=(0,Q.jsxs)(`span`,{title:e,className:`inline-flex items-center gap-1 text-2xs text-muted-foreground`,children:[n,r]}),t[13]=e,t[14]=r,t[15]=a):a=t[15],_=a;break bb0}let n=o===`reviewed`,r;t[16]!==i||t[17]!==o?(r=zo(i,o),t[16]=i,t[17]=o,t[18]=r):r=t[18];let s=r,c=l?`icon-xs`:`xs`,u=n?`ghost`:`outline`,b=h||!!d,x;t[19]!==a||t[20]!==f||t[21]!==i||t[22]!==n||t[23]!==p?(x=()=>{n?p.start(i):f.start({path:i,fingerprint:a})},t[19]=a,t[20]=f,t[21]=i,t[22]=n,t[23]=p,t[24]=x):x=t[24];let S;t[25]!==l||t[26]!==h||t[27]!==o?(S=(0,Q.jsx)(eS,{pending:h,status:o,compact:l}),t[25]=l,t[26]=h,t[27]=o,t[28]=S):S=t[28];let C;t[29]!==l||t[30]!==o?(C=!l&&tS(o),t[29]=l,t[30]=o,t[31]=C):C=t[31];let w;t[32]!==s||t[33]!==n||t[34]!==S||t[35]!==C||t[36]!==c||t[37]!==u||t[38]!==b||t[39]!==x||t[40]!==d?(w=(0,Q.jsx)(Gt,{render:(0,Q.jsxs)(X,{type:`button`,size:c,variant:u,"aria-pressed":n,disabled:b,"aria-description":d,"aria-label":s,onClick:x,children:[S,C]})}),t[32]=s,t[33]=n,t[34]=S,t[35]=C,t[36]=c,t[37]=u,t[38]=b,t[39]=x,t[40]=d,t[41]=w):w=t[41];let T=d??s,E;t[42]===T?E=t[43]:(E=(0,Q.jsx)(m,{role:`tooltip`,className:`break-all`,children:T}),t[42]=T,t[43]=E);let D;t[44]!==w||t[45]!==E?(D=(0,Q.jsxs)(y,{children:[w,E]}),t[44]=w,t[45]=E,t[46]=D):D=t[46],g=(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[D,e!==void 0&&(0,Q.jsx)(v,{className:`max-w-52 text-2xs text-destructive`,render:(0,Q.jsx)(`span`,{role:`alert`}),text:ws(e)})]})}t[0]=l,t[1]=a,t[2]=f,t[3]=i,t[4]=h,t[5]=o,t[6]=p,t[7]=d,t[8]=g,t[9]=_}else g=t[8],_=t[9];return _===Symbol.for(`react.early_return_sentinel`)?g:_}function Yx(e){let t=(0,$.c)(25),{scope:n,context:r,path:i,fingerprint:a,status:o,latest:s,onStart:c}=e,l=Ae(r),u=Sx(n,r,Zo),d=Cx(n,r,Zo),f=u.result.waiting||d.result.waiting,p=Ss(u.result,d.result),h=s?p:void 0,g=(0,Z.useId)(),_=o===`reviewed`,v=a!=null,b=o===`stale`?`Changed since reviewed`:`Toggle reviewed`,x;t[0]!==i||t[1]!==v||t[2]!==b||t[3]!==l?(x=l??(v?b:Oo([i])),t[0]=i,t[1]=v,t[2]=b,t[3]=l,t[4]=x):x=t[4];let S=x,C=`${i} reviewed`,w=h!==void 0,T=f||!v||!!l,E;t[5]!==f||t[6]!==a||t[7]!==u||t[8]!==c||t[9]!==i||t[10]!==_||t[11]!==d||t[12]!==l?(E=()=>{l||f||a==null||(c(),_?d.start(i):u.start({path:i,fingerprint:a}))},t[5]=f,t[6]=a,t[7]=u,t[8]=c,t[9]=i,t[10]=_,t[11]=d,t[12]=l,t[13]=E):E=t[13];let D;t[14]!==f||t[15]!==g||t[16]!==_||t[17]!==C||t[18]!==w||t[19]!==T||t[20]!==E?(D=(0,Q.jsx)(Gt,{render:(0,Q.jsx)(F_,{checked:_,"aria-label":C,"aria-describedby":g,"aria-invalid":w,disabled:T,"aria-busy":f,onCheckedChange:E})}),t[14]=f,t[15]=g,t[16]=_,t[17]=C,t[18]=w,t[19]=T,t[20]=E,t[21]=D):D=t[21];let O;return t[22]!==S||t[23]!==g?(O=(0,Q.jsx)(`span`,{id:g,hidden:!0,children:S}),t[22]=S,t[23]=g,t[24]=O):O=t[24],(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(y,{children:[D,(0,Q.jsx)(m,{role:`tooltip`,className:`break-all`,children:h===void 0?S:ws(h)})]}),O,h!==void 0&&(0,Q.jsx)(`span`,{role:`alert`,className:`sr-only`,children:ws(h)})]})}function Xx(e){let t=(0,$.c)(22),{scope:n,context:r,interaction:i,branchFiles:a,changes:o,committed:s,dirty:c,range:l}=e,u=dx(n,r,l),d;t[0]!==a||t[1]!==s||t[2]!==u?(d=to(a,u,s),t[0]=a,t[1]=s,t[2]=u,t[3]=d):d=t[3];let f=d,p=dx(n,r),m;t[4]!==o||t[5]!==c||t[6]!==p?(m=Ta(o,p,c),t[4]=o,t[5]=c,t[6]=p,t[7]=m):m=t[7];let{reviewed:h,disabled:g,toggle:_,writeBlock:v}=Ex(n,r,l,f,m,Zx);if(!i.toolbarTarget)return null;let y;t[8]!==i.active||t[9]!==_?(y=i.active&&(0,Q.jsx)(Qx,{toggle:_}),t[8]=i.active,t[9]=_,t[10]=y):y=t[10];let b=v??(h?`Mark this step unreviewed`:`Mark this step reviewed`),x;t[11]!==g||t[12]!==h||t[13]!==b||t[14]!==_?(x=(0,Q.jsx)(ux,{label:`Reviewed`,description:b,variant:`outline`,icon:Te,shortcut:Ys.toggleReviewed,pressed:h,disabled:g,onClick:_}),t[11]=g,t[12]=h,t[13]=b,t[14]=_,t[15]=x):x=t[15];let S;t[16]!==y||t[17]!==x?(S=(0,Q.jsxs)(Q.Fragment,{children:[y,x]}),t[16]=y,t[17]=x,t[18]=S):S=t[18];let C;return t[19]!==i.toolbarTarget||t[20]!==S?(C=(0,sg.createPortal)(S,i.toolbarTarget),t[19]=i.toolbarTarget,t[20]=S,t[21]=C):C=t[21],C}function Zx(e){return ms.add(e)}function Qx(e){let t=(0,$.c)(1),{toggle:n}=e,r;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={ignoreInputs:!0},t[0]=r):r=t[0],cc(Ys.toggleReviewed,n,r),null}function $x(e){let t=(0,$.c)(6),{scope:n,context:r,entries:i,compact:a,range:o}=e,s=a!==void 0&&a,c=wx(n,r,o===void 0?Zo:o),l=Ha(i),u=c.result.waiting,d=Ae(r),f=l.blocked||u||!!d,p=()=>{f||(l.unmarking?c.start({kind:`unmark`,paths:l.reviewedPaths}):c.start({kind:`mark`,entries:l.entries}))},g=d??l.label,_;t[0]===g?_=t[1]:(_=(0,Q.jsx)(m,{role:`tooltip`,className:`break-all`,children:g}),t[0]=g,t[1]=_);let v;t[2]===c.report?v=t[3]:(v=c.report&&(0,Q.jsx)(iS,{report:c.report}),t[2]=c.report,t[3]=v);let b;return t[4]===c.result?b=t[5]:(b=h(c.result)&&(0,Q.jsx)(`span`,{role:`alert`,className:`max-w-64 text-right text-2xs text-destructive`,children:ws(ie(c.result.cause))}),t[4]=c.result,t[5]=b),(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 flex-col items-end gap-1`,children:[(0,Q.jsxs)(y,{children:[(0,Q.jsx)(Gt,{render:(0,Q.jsxs)(X,{type:`button`,size:s?`icon-xs`:`xs`,variant:`outline`,disabled:f,"aria-label":l.label,"aria-description":d,onClick:p,children:[(0,Q.jsx)(nS,{pending:u,unmarking:l.unmarking}),!s&&rS(u,l.unmarking,l.text)]})}),_]}),v,b]})}function eS(e){let t=(0,$.c)(7),{pending:n,status:r,compact:i}=e;if(n){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(F,{className:`animate-spin`}),t[0]=e):e=t[0],e}if(r===`reviewed`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Te,{}),t[1]=e):e=t[1],e}if(r===`stale`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Ic,{}),t[2]=e):e=t[2],e}let a=i&&`invisible`,o;t[3]===a?o=t[4]:(o=Tn(a),t[3]=a,t[4]=o);let s;return t[5]===o?s=t[6]:(s=(0,Q.jsx)(Te,{className:o}),t[5]=o,t[6]=s),s}function tS(e){return e===`reviewed`?`Reviewed`:e===`stale`?`Review again`:`Mark reviewed`}function nS(e){let t=(0,$.c)(3),{pending:n,unmarking:r}=e;if(n){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(F,{className:`animate-spin`}),t[0]=e):e=t[0],e}if(r){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Ic,{}),t[1]=e):e=t[1],e}let i;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(Te,{}),t[2]=i):i=t[2],i}function rS(e,t,n){return e?t?`Unmarking…`:`Marking…`:n}function iS(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=Tn(`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,Q.jsx)(ks,{className:`mr-1 inline size-3`}),t[2]=r,t[3]=s);let c;t[4]===n?c=t[5]:(c=Co(n),t[4]=n,t[5]=c);let l;return t[6]!==i||t[7]!==o||t[8]!==s||t[9]!==c?(l=(0,Q.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 aS(e){let t=(0,$.c)(9),n,r;if(t[0]===e?(n=t[1],r=t[2]):({compared:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),n){let e=r.fullHeight??!1,i;return t[3]!==n||t[4]!==r||t[5]!==e?(i=(0,Q.jsx)(cS,{...r,branch:n,path:void 0,fullHeight:e}),t[3]=n,t[4]=r,t[5]=e,t[6]=i):i=t[6],i}let i;return t[7]===r?i=t[8]:(i=(0,Q.jsx)(sS,{...r,path:void 0}),t[7]=r,t[8]=i),i}function oS(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,Q.jsx)(sS,{...r,path:n}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}function sS(e){let t=(0,$.c)(14),{scope:n,context:r,interaction:i,base:a,path:o,only:s,heading:c,fullHeight:l,onOpen:u}=e,d=l!==void 0&&l,f;t[0]!==r||t[1]!==d||t[2]!==c||t[3]!==i||t[4]!==u||t[5]!==s||t[6]!==o||t[7]!==n?(f=e=>(0,Q.jsx)(cS,{scope:n,context:r,interaction:i,onOpen:u,branch:e,path:o,only:s,heading:c,fullHeight:d}),t[0]=r,t[1]=d,t[2]=c,t[3]=i,t[4]=u,t[5]=s,t[6]=o,t[7]=n,t[8]=f):f=t[8];let p;return t[9]!==a||t[10]!==r||t[11]!==n||t[12]!==f?(p=(0,Q.jsx)(mx,{scope:n,context:r,base:a,children:f}),t[9]=a,t[10]=r,t[11]=n,t[12]=f,t[13]=p):p=t[13],p}function cS(e){let t=(0,$.c)(33),{scope:n,context:r,interaction:i,branch:a,path:o,only:s,heading:c,fullHeight:l,onOpen:u}=e,d=l!==void 0&&l,f;t[0]===a?f=t[1]:(f=La(a),t[0]=a,t[1]=f);let p=f,m=dx(n,r,p);if(a.base===null||a.base===void 0)return null;let h;t[2]!==a.files||t[3]!==s||t[4]!==o?(h=()=>s?a.files.filter(e=>s.includes(e.path)||e.oldPath!==void 0&&s.includes(e.oldPath)).map(lS):o==null?void 0:[o],t[2]=a.files,t[3]=s,t[4]=o,t[5]=h):h=t[5];let g=h,_;t[6]!==a.files||t[7]!==m||t[8]!==g?(_=to(a.files,m,g()),t[6]=a.files,t[7]=m,t[8]=g,t[9]=_):_=t[9];let v=_;if(o!=null&&v.length===0){let e;t[10]===a.base.ref?e=t[11]:(e=U_(a.base.ref),t[10]=a.base.ref,t[11]=e);let n=`${o} has no committed change since ${e}.`,r;return t[12]===n?r=t[13]:(r=(0,Q.jsx)(gr,{message:n}),t[12]=n,t[13]=r),r}let y=o!=null,b=a.base.ref,x=a.head,S=a.mergeBaseOid??``,C=a.commits,w;t[14]===a?w=t[15]:(w=hd(a),t[14]=a,t[15]=w);let T;t[16]!==a.base.ref||t[17]!==a.commits||t[18]!==a.head||t[19]!==w||t[20]!==S?(T={base:b,head:x,mergeBaseOid:S,commits:C,diffRange:w},t[16]=a.base.ref,t[17]=a.commits,t[18]=a.head,t[19]=w,t[20]=S,t[21]=T):T=t[21];let E;return t[22]!==r||t[23]!==d||t[24]!==c||t[25]!==i||t[26]!==v||t[27]!==u||t[28]!==p||t[29]!==n||t[30]!==T||t[31]!==y?(E=(0,Q.jsx)(uS,{scope:n,context:r,interaction:i,onOpen:u,range:p,items:v,single:y,heading:c,fullHeight:d,branch:T}),t[22]=r,t[23]=d,t[24]=c,t[25]=i,t[26]=v,t[27]=u,t[28]=p,t[29]=n,t[30]=T,t[31]=y,t[32]=E):E=t[32],E}function lS(e){return e.path}function uS(e){let t=(0,$.c)(59),{scope:n,context:r,interaction:i,range:a,items:o,single:s,heading:c,fullHeight:l,branch:u,onOpen:d}=e,f=l!==void 0&&l,{connection:p}=r,m=ne(J(Fa(n,p))),h=JSON.stringify([u.base,u.head.branch]),[g,_]=Pn(Bb(JSON.stringify([p.environmentId,n.projectId,n.worktreeId,h]))),v=o.slice(0,g),y=$a(n,p,u.diffRange,v.map(z_)),b=JSON.stringify([u.diffRange,v.map(fS)]),[x,S]=(0,Z.useState)({version:``,comparison:h,patches:new Map});if(!y.pending&&!y.failed&&x.version!==b){let e;t[0]===y.patches?e=t[1]:(e=e=>{let t=y.patches.get(z_(e).join(`\0`));return t?[[e.fingerprint,t]]:[]},t[0]=y.patches,t[1]=e),S({version:b,comparison:h,patches:new Map(v.flatMap(e))})}let C=e=>y.patches.get(z_(e).join(`\0`))??(x.comparison===h?x.patches.get(e.fingerprint):void 0),w;t[2]!==r||t[3]!==a||t[4]!==n?(w=(e,t)=>(0,Q.jsx)(Jx,{scope:n,context:r,path:e.path,fingerprint:e.fingerprint,status:e.reviewStatus,range:a,compact:t},`review:${e.path}`),t[2]=r,t[3]=a,t[4]=n,t[5]=w):w=t[5];let T=w,E;t[6]!==u.head.oid||t[7]!==T||t[8]!==C?(E=e=>{let t=co(u.head.oid,e,C(e));return t==null?[]:[{...t,id:`branch:${e.path}`,review:{path:e.path,fingerprint:e.fingerprint,reviewed:e.reviewStatus===`reviewed`,stale:e.reviewStatus===`stale`,control:T(e,!0)}}]},t[6]=u.head.oid,t[7]=T,t[8]=C,t[9]=E):E=t[9];let D=v.flatMap(E),O=new Set(D.map(dS)),k=v.filter(e=>!O.has(e.path)&&(i.quiet!==!0||y.failed||C(e)!==void 0)),A=o.length-v.length,j=m?.changes.length??0,[M]=o,N=c!==void 0;if(i.quiet===!0&&D.length===0&&y.pending){let e;return t[10]===v.length?e=t[11]:(e=(0,Q.jsx)(Gx,{count:v.length}),t[10]=v.length,t[11]=e),e}let P=!s&&!N,F;t[12]!==M||t[13]!==d||t[14]!==s?(F=s&&M?(0,Q.jsx)(ux,{label:`Timeline`,iconOnly:!0,icon:Ir,onClick:()=>d({kind:`timeline`,path:M.path})}):void 0,t[12]=M,t[13]=d,t[14]=s,t[15]=F):F=t[15];let I;t[16]!==r||t[17]!==T||t[18]!==M||t[19]!==c||t[20]!==i.toolbarTarget||t[21]!==o||t[22]!==a||t[23]!==n||t[24]!==s||t[25]!==N?(I=e=>s&&M&&N?null:s&&M?(0,Q.jsx)(Ux,{target:i.toolbarTarget,barActions:null,title:ao(M.path),subtitle:`${M.path} · on the branch`,children:T(M,!1)}):N?(0,Q.jsxs)(Ux,{inline:!0,...c?{title:c.title,titleLabel:c.titleLabel}:{title:`All changes`},subtitle:fe(o.length,`file`),children:[e,c?.after]}):(0,Q.jsxs)(Ux,{target:i.toolbarTarget,barActions:null,title:`Branch`,subtitle:`${fe(o.length,`file`)} changed`,children:[e,(0,Q.jsx)($x,{scope:n,context:r,entries:o,range:a})]}),t[16]=r,t[17]=T,t[18]=M,t[19]=c,t[20]=i.toolbarTarget,t[21]=o,t[22]=a,t[23]=n,t[24]=s,t[25]=N,t[26]=I):I=t[26];let L;t[27]!==u||t[28]!==T||t[29]!==y.failed||t[30]!==y.retry||t[31]!==k||t[32]!==C||t[33]!==s||t[34]!==N||t[35]!==j?(L=()=>(0,Q.jsx)(pS,{branch:u,single:s,singleHeader:N,uncommitted:j,omitted:k,patchOf:C,failed:y.failed,onRetry:y.retry,control:e=>T(e,!0)}),t[27]=u,t[28]=T,t[29]=y.failed,t[30]=y.retry,t[31]=k,t[32]=C,t[33]=s,t[34]=N,t[35]=j,t[36]=L):L=t[36];let R;t[37]!==r||t[38]!==D||t[39]!==f||t[40]!==i||t[41]!==a||t[42]!==n||t[43]!==P||t[44]!==F||t[45]!==I||t[46]!==L?(R=(0,Q.jsx)(jx,{fullHeight:f,readingColumn:P,scope:n,context:r,interaction:i,range:a,headerActions:F,entries:D,toolbar:I,header:L}),t[37]=r,t[38]=D,t[39]=f,t[40]=i,t[41]=a,t[42]=n,t[43]=P,t[44]=F,t[45]=I,t[46]=L,t[47]=R):R=t[47];let z;t[48]!==_||t[49]!==g?(z=()=>_(g+25),t[48]=_,t[49]=g,t[50]=z):z=t[50];let B;t[51]!==y.pending||t[52]!==o.length||t[53]!==A||t[54]!==z?(B=(0,Q.jsx)(Wx,{more:A,total:o.length,pending:y.pending,onReadMore:z}),t[51]=y.pending,t[52]=o.length,t[53]=A,t[54]=z,t[55]=B):B=t[55];let V;return t[56]!==B||t[57]!==R?(V=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[R,B]}),t[56]=B,t[57]=R,t[58]=V):V=t[58],V}function dS(e){return e.path}function fS(e){return e.fingerprint}function pS(e){let t=(0,$.c)(26),{branch:n,single:r,singleHeader:i,uncommitted:a,omitted:o,patchOf:s,failed:c,onRetry:l,control:u}=e,d;t[0]===n.head.branch?d=t[1]:(d=n.head.branch===null||n.head.branch===void 0?`This commit`:U_(n.head.branch),t[0]=n.head.branch,t[1]=d);let f=d;if(i&&!c&&o.length===0)return null;let p;t[2]!==n.base||t[3]!==n.commits||t[4]!==n.head.oid||t[5]!==n.mergeBaseOid||t[6]!==f||t[7]!==r||t[8]!==i?(p=!r&&!i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`h2`,{className:`text-sm font-semibold`,children:[f,` since `,U_(n.base)]}),(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-2xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:fe(n.commits,`commit`)}),(0,Q.jsxs)(`span`,{children:[`from`,` `,(0,Q.jsx)(`span`,{className:`font-mono`,children:H_(n.mergeBaseOid)}),` `,`to `,(0,Q.jsx)(`span`,{className:`font-mono`,children:H_(n.head.oid)})]}),(0,Q.jsx)(Mn,{variant:`secondary`,children:U_(n.base)})]})]}),t[2]=n.base,t[3]=n.commits,t[4]=n.head.oid,t[5]=n.mergeBaseOid,t[6]=f,t[7]=r,t[8]=i,t[9]=p):p=t[9];let m;t[10]!==i||t[11]!==a?(m=a>0&&!i&&(0,Q.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[10]=i,t[11]=a,t[12]=m):m=t[12];let h;t[13]!==c||t[14]!==l?(h=c&&(0,Q.jsxs)(`p`,{className:`mt-3 flex items-center gap-2 text-xs text-muted-foreground`,children:[`Some patches could not be read.`,(0,Q.jsx)(X,{size:`xs`,variant:`outline`,onClick:l,children:`Try again`})]}),t[13]=c,t[14]=l,t[15]=h):h=t[15];let g;t[16]!==u||t[17]!==c||t[18]!==o||t[19]!==s?(g=o.length>0&&(0,Q.jsx)(`ul`,{className:`mt-3 space-y-1.5`,"aria-label":`Changes without code preview`,children:o.map(e=>(0,Q.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 rounded-lg border bg-muted/25 px-3 py-2 text-xs`,children:[u(e),(0,Q.jsx)(v,{className:`font-mono font-medium`,text:e.path}),(0,Q.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[e.status,s(e)!==void 0||c?` · ${lu(e,s(e),c)??`No code change`}`:``]})]},e.path))}),t[16]=u,t[17]=c,t[18]=o,t[19]=s,t[20]=g):g=t[20];let _;return t[21]!==p||t[22]!==m||t[23]!==h||t[24]!==g?(_=(0,Q.jsxs)(`section`,{className:`mx-4 mt-3 rounded-xl border px-4 py-3`,children:[p,m,h,g]}),t[21]=p,t[22]=m,t[23]=h,t[24]=g,t[25]=_):_=t[25],_}var mS=e=>z_(e).join(`\0`);function hS(e){let t=(0,$.c)(52),{scope:n,context:r,interaction:i,oid:a,onOpen:o}=e,{connection:s}=r,[c,l]=(0,Z.useState)(1),[,u]=(0,Z.useTransition)(),d=mv(s,n,a,c),f;t[0]!==s||t[1]!==n?(f=pv({connection:s,scope:n}),t[0]=s,t[1]=n,t[2]=f):f=t[2];let p=ne(J($t(f))),m=p?.snapshot?.head.kind===`attached`&&p.commits.some(e=>e.oid===a)?U_(p.snapshot.head.ref):void 0,h=`${a}:${c}`,g;t[3]===h?g=t[4]:(g={of:h,shown:25},t[3]=h,t[4]=g);let[_,y]=(0,Z.useState)(g),b=_.of===`${a}:${c}`?_.shown:25,x;t[5]!==a||t[6]!==c||t[7]!==b?(x=()=>y({of:`${a}:${c}`,shown:b+25}),t[5]=a,t[6]=c,t[7]=b,t[8]=x):x=t[8];let S=x,C=d.files.slice(0,b),w=C.map(yS),T=Eo(s,n,a,c,w),E;t[9]===T.patches?E=t[10]:(E=e=>T.patches.get(mS(e)),t[9]=T.patches,t[10]=E);let D=E,O;t[11]!==a||t[12]!==c||t[13]!==D?(O=e=>{let t=co(a,e,D(e));return t==null?[]:[{...t,id:`${t.id}:${c}`}]},t[11]=a,t[12]=c,t[13]=D,t[14]=O):O=t[14];let k=C.flatMap(O),A;t[15]!==a||t[16]!==D?(A=e=>(co(a,e,D(e))??null)===null,t[15]=a,t[16]=D,t[17]=A):A=t[17];let j=C.filter(A),M=d.files.length-C.length,N;t[18]!==d.commit.subject||t[19]!==a?(N=d.commit.subject||`Commit ${H_(a)}`,t[18]=d.commit.subject,t[19]=a,t[20]=N):N=t[20];let P=N,F=new Map(k.map(vS));for(let e of C)D(e)?.kind===`metadata-only`&&F.set(B_(e),{added:0,removed:0});let I=M===0&&d.files.every(e=>{let t=D(e);return F.has(B_(e))||t?.kind===`binary`})?[...F.values()].reduce(_S,{added:0,removed:0}):void 0,L;t[21]===a?L=t[22]:(L=(0,Q.jsx)(ux,{label:`Copy hash`,icon:q,onClick:()=>tr(a,`commit id`)}),t[21]=a,t[22]=L);let R;t[23]===o?R=t[24]:(R=(0,Q.jsx)(ux,{label:`Open in graph`,icon:yi,onClick:()=>o({kind:`graph`})}),t[23]=o,t[24]=R);let z;t[25]!==R||t[26]!==L?(z=(0,Q.jsxs)(Q.Fragment,{children:[L,R]}),t[25]=R,t[26]=L,t[27]=z):z=t[27];let B=z,V;t[28]!==B||t[29]!==m||t[30]!==d.commit||t[31]!==i.toolbarTarget||t[32]!==a||t[33]!==c||t[34]!==u||t[35]!==P?(V=e=>(0,Q.jsxs)(`header`,{className:`mx-auto w-full max-w-commit px-7 pt-10`,children:[i.toolbarTarget?(0,sg.createPortal)(B,i.toolbarTarget):(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:B}),(0,Q.jsxs)(`div`,{className:`flex min-h-5.5 min-w-0 flex-wrap items-center gap-x-2 text-ui leading-5.5 font-medium text-muted-foreground`,children:[(0,Q.jsx)(Ml,{className:`size-3.5 shrink-0`}),(0,Q.jsxs)(`span`,{children:[`Commit`,` `,(0,Q.jsx)(v,{text:a,disclose:`always`,className:`font-mono text-caption text-foreground`,children:H_(a)})]}),m&&(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[`on`,` `,(0,Q.jsx)(v,{text:m,className:`font-mono text-caption font-normal`})]})]}),(0,Q.jsx)(v,{text:P,render:(0,Q.jsx)(`h1`,{}),className:`mt-3 text-2xl leading-tight font-semibold tracking-tight`}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[d.commit.parentOids.length>1&&(0,Q.jsx)(Rc,{value:String(c),onValueChange:e=>u(()=>l(Number(e))),children:(0,Q.jsx)(Dc,{children:d.commit.parentOids.map(gS)})}),(0,Q.jsx)(ux,{label:`Copy message`,icon:q,onClick:()=>tr(R_(d.commit),`commit message`)}),e]})]}),t[28]=B,t[29]=m,t[30]=d.commit,t[31]=i.toolbarTarget,t[32]=a,t[33]=c,t[34]=u,t[35]=P,t[36]=V):V=t[36];let H=()=>(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsx)(bS,{commit:d,branch:m,counts:F,total:I,omitted:j,patchOf:D,failed:T.failed,onRetry:T.retry})}),U;t[37]!==r||t[38]!==k||t[39]!==i||t[40]!==n||t[41]!==V||t[42]!==H?(U=(0,Q.jsx)(jx,{toolbar:V,framed:!0,scope:n,context:r,interaction:i,entries:k,header:H}),t[37]=r,t[38]=k,t[39]=i,t[40]=n,t[41]=V,t[42]=H,t[43]=U):U=t[43];let W;t[44]!==d.files.length||t[45]!==T.pending||t[46]!==M||t[47]!==S?(W=(0,Q.jsx)(Wx,{more:M,total:d.files.length,pending:T.pending,onReadMore:S}),t[44]=d.files.length,t[45]=T.pending,t[46]=M,t[47]=S,t[48]=W):W=t[48];let G;return t[49]!==U||t[50]!==W?(G=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[U,W]}),t[49]=U,t[50]=W,t[51]=G):G=t[51],G}function gS(e,t){return(0,Q.jsxs)(Hc,{value:String(t+1),children:[rv(t+1),` parent ·`,` `,(0,Q.jsx)(`span`,{className:`font-mono`,children:H_(e)})]},e)}function _S(e,t){return{added:e.added+t.added,removed:e.removed+t.removed}}function vS(e){return[e.path,e.lineCounts]}function yS(e){return z_(e)}function bS(e){let t=(0,$.c)(67),{commit:n,omitted:r,patchOf:i,failed:a,onRetry:o,branch:s,counts:c,total:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-5 shrink-0 place-items-center rounded-sm border border-border-strong text-foreground`,children:(0,Q.jsx)(ou,{className:`size-3`})}),t[0]=u):u=t[0];let d;t[1]===n.commit.author.name?d=t[2]:(d=(0,Q.jsx)(v,{text:n.commit.author.name,className:`font-medium text-foreground`}),t[1]=n.commit.author.name,t[2]=d);let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),t[3]=f):f=t[3];let p;t[4]===n.commit.author.timestamp?p=t[5]:(p=wn(n.commit.author.timestamp),t[4]=n.commit.author.timestamp,t[5]=p);let m;t[6]===p?m=t[7]:(m=(0,Q.jsx)(`span`,{children:p}),t[6]=p,t[7]=m);let h;t[8]!==n.commit.parentOids||t[9]!==n.comparison.baseOid||t[10]!==n.comparison.kind||t[11]!==n.comparison.parentNumber?(h=n.comparison.kind===`parent`?(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`· `}),`parent`,` `,(0,Q.jsx)(`span`,{className:`font-mono text-caption leading-5 text-foreground`,children:H_(n.comparison.baseOid)}),n.commit.parentOids.length>1&&` (${rv(n.comparison.parentNumber)} parent of a merge)`]}):(0,Q.jsx)(`span`,{children:`root commit`}),t[8]=n.commit.parentOids,t[9]=n.comparison.baseOid,t[10]=n.comparison.kind,t[11]=n.comparison.parentNumber,t[12]=h):h=t[12];let g;t[13]!==d||t[14]!==m||t[15]!==h?(g=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-ui leading-5 text-muted-foreground`,children:[u,d,f,m,h]}),t[13]=d,t[14]=m,t[15]=h,t[16]=g):g=t[16];let _;if(t[17]!==s||t[18]!==n.commit.refs){let e;t[20]===s?e=t[21]:(e=e=>e.kind!==`local-branch`||e.name!==s,t[20]=s,t[21]=e),_=W_(n.commit.refs).filter(e).map(xS),t[17]=s,t[18]=n.commit.refs,t[19]=_}else _=t[19];let y;t[22]===_?y=t[23]:(y=(0,Q.jsx)(`div`,{className:`mt-2 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-caption text-muted-foreground`,children:_}),t[22]=_,t[23]=y);let b;t[24]===n.commit.body?b=t[25]:(b=n.commit.body!==null&&n.commit.body!==void 0&&(0,Q.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap text-ui leading-relaxed wrap-anywhere text-muted-foreground`,children:n.commit.body}),t[24]=n.commit.body,t[25]=b);let x;t[26]!==n.commit.bodyTruncated||t[27]!==n.commit.subjectTruncated?(x=(n.commit.subjectTruncated||n.commit.bodyTruncated)&&(0,Q.jsx)(`p`,{className:`mt-1 text-caption text-muted-foreground`,children:`Commit message truncated`}),t[26]=n.commit.bodyTruncated,t[27]=n.commit.subjectTruncated,t[28]=x):x=t[28];let S;t[29]===n.files.length?S=t[30]:(S=fe(n.files.length,`file`),t[29]=n.files.length,t[30]=S);let C;t[31]===S?C=t[32]:(C=(0,Q.jsxs)(`span`,{children:[S,` changed`]}),t[31]=S,t[32]=C);let w;t[33]===l?w=t[34]:(w=l&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`mx-2 font-normal text-muted-foreground`,children:`·`}),(0,Q.jsx)(TS,{count:l})]}),t[33]=l,t[34]=w);let T;t[35]!==n.files.length||t[36]!==a||t[37]!==l?(T=!l&&n.files.length>0&&(0,Q.jsx)(`span`,{className:`ml-2 font-normal text-muted-foreground`,children:a?`Line counts unavailable`:`Line counts incomplete`}),t[35]=n.files.length,t[36]=a,t[37]=l,t[38]=T):T=t[38];let E;t[39]!==C||t[40]!==w||t[41]!==T?(E=(0,Q.jsxs)(`p`,{className:`border-b pb-1.5 text-xs font-medium tabular-nums`,children:[C,w,T]}),t[39]=C,t[40]=w,t[41]=T,t[42]=E):E=t[42];let D;if(t[43]!==n.files||t[44]!==c||t[45]!==i){let e;t[47]!==c||t[48]!==i?(e=e=>(0,Q.jsxs)(`li`,{className:`flex h-8 min-w-0 items-center gap-2.5 rounded-sm pr-1.5 pl-1 text-caption leading-4`,children:[(0,Q.jsx)(`span`,{"aria-label":e.status,className:`w-4 shrink-0 text-center font-mono text-xs font-semibold text-brand`,children:e.status.slice(0,1).toUpperCase()}),(0,Q.jsx)(v,{text:z_(e).join(` → `),className:`flex-1 font-mono font-medium`}),(0,Q.jsx)(TS,{count:c.get(B_(e))}),i(e)?.kind===`binary`&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Binary`})]},mS(e)),t[47]=c,t[48]=i,t[49]=e):e=t[49],D=n.files.map(e),t[43]=n.files,t[44]=c,t[45]=i,t[46]=D}else D=t[46];let O;t[50]===D?O=t[51]:(O=(0,Q.jsx)(`ul`,{className:`max-h-64 divide-y overflow-y-auto border-b`,"aria-label":`Changed files`,children:D}),t[50]=D,t[51]=O);let k;t[52]!==E||t[53]!==O?(k=(0,Q.jsxs)(`section`,{"aria-label":`Files changed`,className:`mt-7`,children:[E,O]}),t[52]=E,t[53]=O,t[54]=k):k=t[54];let A;t[55]!==a||t[56]!==r||t[57]!==o||t[58]!==i?(A=r.length>0&&(0,Q.jsx)(SS,{changes:r,patchOf:i,failed:a,onRetry:o}),t[55]=a,t[56]=r,t[57]=o,t[58]=i,t[59]=A):A=t[59];let j;return t[60]!==b||t[61]!==x||t[62]!==k||t[63]!==A||t[64]!==g||t[65]!==y?(j=(0,Q.jsxs)(`section`,{className:`mx-auto mt-1 mb-6 w-full max-w-commit min-w-0 px-7`,children:[g,y,b,x,k,A]}),t[60]=b,t[61]=x,t[62]=k,t[63]=A,t[64]=g,t[65]=y,t[66]=j):j=t[66],j}function xS(e){return(0,Q.jsx)(v,{text:e.name,className:`font-mono`},`${e.kind}:${e.name}`)}function SS(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,Q.jsxs)(`p`,{className:`mt-3 flex items-center gap-2 text-xs text-muted-foreground`,children:[`Some patches could not be read.`,(0,Q.jsx)(X,{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=B_(e),n=r(e),a=jr(e),o=n===void 0&&!i?void 0:lu(e,n,i)??`No code change`;return(0,Q.jsxs)(`li`,{className:`rounded-lg border bg-muted/25 px-3 py-2 text-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(v,{className:`font-mono font-medium`,text:t}),(0,Q.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[e.status,o&&` · ${o}`]})]}),a&&n?.kind===`text`&&(0,Q.jsx)(`pre`,{className:`mt-1 overflow-x-auto whitespace-pre-wrap font-mono text-2xs text-muted-foreground`,children:n.patch.split(`
|
|
38
|
+
`).filter(wS).map(CS).join(`
|
|
39
|
+
`)})]},`${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,Q.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,Q.jsxs)(Q.Fragment,{children:[o,c]}),t[12]=o,t[13]=c,t[14]=l):l=t[14],l}function CS(e){return e.slice(1)}function wS(e){return/^[+-]Subproject commit /.test(e)}function TS(e){let t=(0,$.c)(7),{count:n}=e;if(!n)return null;let r;t[0]===n.added?r=t[1]:(r=(0,Q.jsxs)(`span`,{className:`text-add-fg`,children:[`+`,n.added]}),t[0]=n.added,t[1]=r);let i;t[2]===n.removed?i=t[3]:(i=(0,Q.jsxs)(`span`,{className:`text-del-fg`,children:[`−`,n.removed]}),t[2]=n.removed,t[3]=i);let a;return t[4]!==r||t[5]!==i?(a=(0,Q.jsxs)(`span`,{className:`shrink-0 space-x-1 font-mono text-xs font-medium tabular-nums`,children:[r,i]}),t[4]=r,t[5]=i,t[6]=a):a=t[6],a}function ES(e){let t=(0,$.c)(40),{scope:n,context:r,label:i,items:a,rows:o,controls:s,actions:c,actionsOpen:l,onActionsOpenChange:u}=e,[d,f]=(0,Z.useState)(),p;t[0]===a?p=t[1]:(p=a.filter(DS),t[0]=a,t[1]=p);let m=p.length,h;t[2]===a.length?h=t[3]:(h=fe(a.length,`file`),t[2]=a.length,t[3]=h);let g=`${m} of ${h} reviewed`,_;t[4]===i?_=t[5]:(_=(0,Q.jsx)(`h2`,{className:`text-ui leading-4 font-medium text-foreground`,children:i}),t[4]=i,t[5]=_);let y=`File review actions: ${g}`,b;t[6]===y?b=t[7]:(b=(0,Q.jsx)(X,{type:`button`,size:`xs`,variant:`ghost`,className:`ml-auto`,"aria-label":y}),t[6]=y,t[7]=b);let x;t[8]!==g||t[9]!==b?(x=(0,Q.jsx)(Fn,{render:b,children:g}),t[8]=g,t[9]=b,t[10]=x):x=t[10];let S;t[11]!==c||t[12]!==s.collapse?(S=(0,Q.jsxs)(On,{"aria-label":`File review actions`,align:`end`,children:[s.collapse,c]}),t[11]=c,t[12]=s.collapse,t[13]=S):S=t[13];let C;t[14]!==l||t[15]!==u||t[16]!==x||t[17]!==S?(C=(0,Q.jsxs)(sn,{open:l,onOpenChange:u,children:[x,S]}),t[14]=l,t[15]=u,t[16]=x,t[17]=S,t[18]=C):C=t[18];let w;t[19]!==_||t[20]!==C?(w=(0,Q.jsxs)(`div`,{className:`flex min-h-6 flex-wrap items-center gap-x-3.5 gap-y-1 border-b pb-1.5 text-xs text-muted-foreground tabular-nums`,children:[_,C]}),t[19]=_,t[20]=C,t[21]=w):w=t[21];let T;if(t[22]!==r||t[23]!==s||t[24]!==a||t[25]!==d||t[26]!==o||t[27]!==n){let e;t[29]!==r||t[30]!==s||t[31]!==d||t[32]!==n?(e=e=>{let t=e.path.lastIndexOf(`/`)+1,i=s.counts.get(e.path);return(0,Q.jsxs)(`li`,{className:`box-content flex h-8 items-center gap-3 border-t pl-1 first:border-t-0 last:border-b`,children:[(0,Q.jsx)(Yx,{scope:n,context:r,path:e.path,fingerprint:e.fingerprint,status:e.reviewStatus,latest:d===e.path,onStart:()=>f(e.path)}),(0,Q.jsx)(v,{text:e.path,renderTrigger:(n,r)=>(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`${e.path}${i?` +${i.additions} −${i.deletions}`:``}`,"aria-current":s.current===e.path?`true`:void 0,onClick:()=>s.open(e.path),className:`flex h-8 min-w-0 flex-1 items-center gap-3 rounded-sm px-1.5 text-left whitespace-nowrap text-foreground outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 font-mono text-caption leading-4`,children:[t>0&&r(e.path.slice(0,t),`shrink-[100] text-muted-foreground`,`start`),r(e.path.slice(t),`shrink-0 max-w-full`)]}),i&&(0,Q.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,Q.jsx)(kx,{counts:i})})]})})]},e.path)},t[29]=r,t[30]=s,t[31]=d,t[32]=n,t[33]=e):e=t[33],T=a.slice(0,o??a.length).map(e),t[22]=r,t[23]=s,t[24]=a,t[25]=d,t[26]=o,t[27]=n,t[28]=T}else T=t[28];let E;t[34]===T?E=t[35]:(E=(0,Q.jsx)(`ol`,{children:T}),t[34]=T,t[35]=E);let D;return t[36]!==i||t[37]!==E||t[38]!==w?(D=(0,Q.jsxs)(`section`,{"aria-label":i,className:`pb-3.25`,children:[w,E]}),t[36]=i,t[37]=E,t[38]=w,t[39]=D):D=t[39],D}function DS(e){return e.reviewStatus===`reviewed`}function OS(e){let t=(0,$.c)(41),{path:n,note:r,diff:i,children:a}=e,o,s,c,l,u,d,f,p,m,h;if(t[0]!==i?.hunks||t[1]!==n){let e=n.split(`/`);l=e.pop()??n;let r;t[12]===i?.hunks?r=t[13]:(r=i?.hunks.reduce(AS,0),t[12]=i?.hunks,t[13]=r),s=r;let a;t[14]===i?.hunks?a=t[15]:(a=i?.hunks.reduce(kS,0),t[14]=i?.hunks,t[15]=a),c=a,m=``,h=`@container/file-heading flex min-h-11 shrink-0 items-center gap-2.5 px-4 text-ui leading-[1.4] whitespace-nowrap text-foreground`,o=v,u=n,d=`min-w-0 font-mono text-[length:var(--text-caption)] leading-4 text-muted-foreground`,t[16]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(`h1`,{}),t[16]=f):f=t[16],p=e.length>0&&(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.join(` / `),` / `]}),t[0]=i?.hunks,t[1]=n,t[2]=o,t[3]=s,t[4]=c,t[5]=l,t[6]=u,t[7]=d,t[8]=f,t[9]=p,t[10]=m,t[11]=h}else o=t[2],s=t[3],c=t[4],l=t[5],u=t[6],d=t[7],f=t[8],p=t[9],m=t[10],h=t[11];let g;t[17]===l?g=t[18]:(g=(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:l}),t[17]=l,t[18]=g);let _;t[19]!==o||t[20]!==u||t[21]!==d||t[22]!==f||t[23]!==p||t[24]!==g?(_=(0,Q.jsxs)(o,{text:u,className:d,render:f,children:[p,g]}),t[19]=o,t[20]=u,t[21]=d,t[22]=f,t[23]=p,t[24]=g,t[25]=_):_=t[25];let y;t[26]===r?y=t[27]:(y=r&&(0,Q.jsx)(`span`,{className:`hidden shrink-0 text-xs text-muted-foreground @md/file-heading:inline`,children:r}),t[26]=r,t[27]=y);let b;t[28]!==s||t[29]!==c||t[30]!==i?(b=i&&(0,Q.jsxs)(`span`,{"aria-label":`${s} additions, ${c} deletions`,className:`font-mono text-xs font-medium tabular-nums`,children:[(0,Q.jsxs)(`span`,{className:`text-add-fg`,children:[`+`,s]}),` `,(0,Q.jsxs)(`span`,{className:`text-del-fg`,children:[`−`,c]})]}),t[28]=s,t[29]=c,t[30]=i,t[31]=b):b=t[31];let x;t[32]!==a||t[33]!==b?(x=(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[b,a]}),t[32]=a,t[33]=b,t[34]=x):x=t[34];let S;return t[35]!==x||t[36]!==m||t[37]!==h||t[38]!==_||t[39]!==y?(S=(0,Q.jsxs)(`header`,{"data-file-heading":m,className:h,children:[_,y,x]}),t[35]=x,t[36]=m,t[37]=h,t[38]=_,t[39]=y,t[40]=S):S=t[40],S}function kS(e,t){return e+t.deletionLines}function AS(e,t){return e+t.additionLines}function jS(e,t,n){if(t===``)return[];let r=t.toLocaleLowerCase(),i=[],a=e.split(`
|
|
40
|
+
`);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 MS(e,t){return Math.max(0,Math.min(e,t-1))}function NS(e,t,n){return t===0?0:(MS(e,t)+n+t)%t}function PS(e,t,n){if(t===0)return`No results`;let r=t===n?`+`:``;return`${MS(e,t)+1} of ${t}${r}`}function FS(e){let t=(0,$.c)(65),{text:n,focusRequest:r,onReveal:i,onClose:a}=e,[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(0),d;t[0]!==o||t[1]!==n?(d=jS(n,o,jn),t[0]=o,t[1]=n,t[2]=d):d=t[2];let f=d,[p,h]=(0,Z.useState)(),g;t[3]!==f||t[4]!==i?(g=(e,t)=>{let n=t===void 0?f:t;l(e);let r=n[e];r&&i(r.line)},t[3]=f,t[4]=i,t[5]=g):g=t[5];let _=g,v;t[6]!==c||t[7]!==f.length||t[8]!==_?(v=e=>_(NS(c,f.length,e)),t[6]=c,t[7]=f.length,t[8]=_,t[9]=v):v=t[9];let b=v,x;t[10]===a?x=t[11]:(x=e=>{e.key===`Escape`&&(e.preventDefault(),a())},t[10]=a,t[11]=x);let S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Q.jsx)(vi,{children:(0,Q.jsx)(Br,{})}),t[12]=S):S=t[12];let C;t[13]!==r||t[14]!==p?(C=e=>{e&&p!==r&&(e.focus(),e.select(),h(r))},t[13]=r,t[14]=p,t[15]=C):C=t[15];let w;t[16]!==_||t[17]!==n?(w=e=>{s(e.target.value),_(0,jS(n,e.target.value,jn))},t[16]=_,t[17]=n,t[18]=w):w=t[18];let T;t[19]===b?T=t[20]:(T=e=>{e.key===`Enter`&&(e.preventDefault(),b(e.shiftKey?-1:1))},t[19]=b,t[20]=T);let E;t[21]!==o||t[22]!==C||t[23]!==w||t[24]!==T?(E=(0,Q.jsx)(ji,{ref:C,"aria-label":`Find in file`,placeholder:`Find in file`,value:o,onChange:w,onKeyDown:T}),t[21]=o,t[22]=C,t[23]=w,t[24]=T,t[25]=E):E=t[25];let D;t[26]!==c||t[27]!==f.length||t[28]!==o?(D=o!==``&&(0,Q.jsx)(Wr,{role:`status`,children:PS(c,f.length,1e4)}),t[26]=c,t[27]=f.length,t[28]=o,t[29]=D):D=t[29];let O=f.length===0,k;t[30]===b?k=t[31]:(k=()=>b(-1),t[30]=b,t[31]=k);let A;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Q.jsx)(_r,{}),t[32]=A):A=t[32];let j;t[33]!==O||t[34]!==k?(j=(0,Q.jsx)(Gt,{render:(0,Q.jsx)(Si,{size:`icon-xs`,"aria-label":`Previous match`,disabled:O,onClick:k,children:A})}),t[33]=O,t[34]=k,t[35]=j):j=t[35];let M;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Q.jsx)(m,{role:`tooltip`,className:`break-all`,children:`Previous match`}),t[36]=M):M=t[36];let N;t[37]===j?N=t[38]:(N=(0,Q.jsxs)(y,{children:[j,M]}),t[37]=j,t[38]=N);let P=f.length===0,F;t[39]===b?F=t[40]:(F=()=>b(1),t[39]=b,t[40]=F);let I;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Q.jsx)(u,{}),t[41]=I):I=t[41];let L;t[42]!==P||t[43]!==F?(L=(0,Q.jsx)(Gt,{render:(0,Q.jsx)(Si,{size:`icon-xs`,"aria-label":`Next match`,disabled:P,onClick:F,children:I})}),t[42]=P,t[43]=F,t[44]=L):L=t[44];let R;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Q.jsx)(m,{role:`tooltip`,className:`break-all`,children:`Next match`}),t[45]=R):R=t[45];let z;t[46]===L?z=t[47]:(z=(0,Q.jsxs)(y,{children:[L,R]}),t[46]=L,t[47]=z);let B;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Q.jsx)(Ht,{}),t[48]=B):B=t[48];let V;t[49]===a?V=t[50]:(V=(0,Q.jsx)(Gt,{render:(0,Q.jsx)(Si,{size:`icon-xs`,"aria-label":`Close find`,onClick:a,children:B})}),t[49]=a,t[50]=V);let H;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,Q.jsx)(m,{role:`tooltip`,className:`break-all`,children:`Close find`}),t[51]=H):H=t[51];let U;t[52]===V?U=t[53]:(U=(0,Q.jsxs)(y,{children:[V,H]}),t[52]=V,t[53]=U);let W;t[54]!==D||t[55]!==N||t[56]!==z||t[57]!==U?(W=(0,Q.jsxs)(vi,{align:`inline-end`,children:[D,N,z,U]}),t[54]=D,t[55]=N,t[56]=z,t[57]=U,t[58]=W):W=t[58];let G;t[59]!==W||t[60]!==E?(G=(0,Q.jsxs)(mo,{className:`w-full max-w-sm`,children:[S,E,W]}),t[59]=W,t[60]=E,t[61]=G):G=t[61];let K;return t[62]!==G||t[63]!==x?(K=(0,Q.jsx)(`div`,{role:`search`,className:`flex shrink-0 justify-end border-b px-3 py-1.5`,onKeyDown:x,children:G}),t[62]=G,t[63]=x,t[64]=K):K=t[64],K}function IS(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=Td(e.path)?(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-auto`,children:[(0,Q.jsx)(JS,{...e}),(0,Q.jsx)(US,{path:e.path,copy:!1,children:(0,Q.jsxs)(v_,{className:`max-w-full flex-wrap justify-end`,children:[(0,Q.jsx)(WS,{path:e.path,onOpen:e.onOpen}),(0,Q.jsx)(GS,{path:e.path})]})}),(0,Q.jsx)(li,{scope:e.scope,path:e.path,connection:e.context.connection})]}):(0,Q.jsx)(LS,{...e}),t[0]=e,t[1]=n),n}function LS(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=oi(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||t[10]!==n?(r=(0,Q.jsx)(RS,{...e,message:n}),t[9]=e,t[10]=n,t[11]=r):r=t[11],r}if(l?.kind===`submodule`){let n;return t[12]===e?n=t[13]:(n=(0,Q.jsx)(RS,{...e,message:`Not followed: submodule`}),t[12]=e,t[13]=n),n}let u;return t[14]===e?u=t[15]:(u=(0,Q.jsx)(zS,{...e}),t[14]=e,t[15]=u),u}function RS(e){let t=(0,$.c)(13),n,r;t[0]===e?(n=t[1],r=t[2]):({message:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===r?i=t[4]:(i=(0,Q.jsx)(JS,{...r}),t[3]=r,t[4]=i);let a;t[5]===r.path?a=t[6]:(a=(0,Q.jsx)(US,{path:r.path}),t[5]=r.path,t[6]=a);let o;t[7]===n?o=t[8]:(o=(0,Q.jsx)(`div`,{className:`grid min-h-48 flex-1 place-items-center p-6`,children:(0,Q.jsx)(gr,{message:n})}),t[7]=n,t[8]=o);let s;return t[9]!==i||t[10]!==a||t[11]!==o?(s=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[i,a,o]}),t[9]=i,t[10]=a,t[11]=o,t[12]=s):s=t[12],s}function zS(e){let t=(0,$.c)(24),{scope:n,context:r,interaction:i,path:a,onOpen:o}=e,{file:s,draft:c,state:l,reset:u,edit:d}=Ti(r,n,a),f=`kind`in s;if(f&&l.owner===null&&l.text===l.savedText){let e;return t[0]!==r||t[1]!==s.reason||t[2]!==i||t[3]!==o||t[4]!==a||t[5]!==n?(e=(0,Q.jsx)(RS,{scope:n,context:r,interaction:i,onOpen:o,path:a,message:s.reason}),t[0]=r,t[1]=s.reason,t[2]=i,t[3]=o,t[4]=a,t[5]=n,t[6]=e):e=t[6],e}let p;t[7]===f?p=t[8]:(p=f&&(0,Q.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[7]=f,t[8]=p);let m=f?l.savedText:s.text,h=f?l.fingerprint:s.contentFingerprint,g;t[9]!==r||t[10]!==c||t[11]!==d||t[12]!==i||t[13]!==o||t[14]!==a||t[15]!==u||t[16]!==n||t[17]!==l||t[18]!==m||t[19]!==h?(g=(0,Q.jsx)(BS,{scope:n,context:r,interaction:i,path:a,text:m,contentFingerprint:h,draft:c,draftState:l,reset:u,edit:d,onOpen:o}),t[9]=r,t[10]=c,t[11]=d,t[12]=i,t[13]=o,t[14]=a,t[15]=u,t[16]=n,t[17]=l,t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;return t[21]!==p||t[22]!==g?(_=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[p,g]}),t[21]=p,t[22]=g,t[23]=_):_=t[23],_}function BS(e){let t=(0,$.c)(91),{scope:n,context:r,interaction:i,path:a,text:o,contentFingerprint:s,draft:c,draftState:l,reset:u,edit:d,onOpen:f}=e,{preferences:p}=qs(),h=Ae(r),{connection:g}=r,_=Ds(n,g),v;t[0]===a?v=t[1]:(v=KS(a),t[0]=a,t[1]=v);let b=v,x;t[2]===a?x=t[3]:(x=[a],t[2]=a,t[3]=x);let S=px(n,r,_,x)[0],C=S?.comparisons??[],w=C.find(VS)??C[0],T=w?uu(w):void 0,E;t[4]!==a||t[5]!==S?(E=S?[{path:a,fingerprint:S.fingerprint}]:[],t[4]=a,t[5]=S,t[6]=E):E=t[6];let D=fs(n,g,S?.statusToken??``,E,T?[T]:[]),O=T?D.diffs.get(Wi(T)):void 0,k=w&&w.scope!==`untracked`&&w.scope!==`unmerged`&&O?ro(w,O)?.fileDiff:void 0,A=w&&`kind`in w?`${w.scope} · ${w.kind}`:w?.scope,j;if(t[7]!==_.changes||t[8]!==a){let e;t[10]===a?e=t[11]:(e=e=>e.path===a,t[10]=a,t[11]=e),j=_.changes.some(e),t[7]=_.changes,t[8]=a,t[9]=j}else j=t[9];let M=j,N;t[12]!==b||t[13]!==p?(N=()=>qS(b,p),t[12]=b,t[13]=p,t[14]=N):N=t[14];let[P,F]=(0,Z.useState)(N),{active:I}=i,[L,R]=(0,Z.useState)(!1),[z,B]=(0,Z.useState)(),[V,H]=(0,Z.useState)(),{element:U,attach:W}=Ri(),G=(0,Z.useId)();So(c,G,s);let K=b===`code`||P===`source`,ee=_o(),q;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(q=()=>B(Date.now()),t[15]=q):q=t[15];let te=ee&&I&&K&&!L,ne;t[16]===te?ne=t[17]:(ne={enabled:te,ignoreInputs:!1,conflictBehavior:`allow`},t[16]=te,t[17]=ne),cc(Ys.findInFile,q,ne);let re=l.diskChanged.has(G)?`Changed on disk just now`:``,J;t[18]===re?J=t[19]:(J=(0,Q.jsx)(`span`,{"aria-live":`polite`,className:`hidden text-xs text-muted-foreground xl:inline`,children:re}),t[18]=re,t[19]=J);let ie;t[20]!==b||t[21]!==P?(ie=b!==`code`&&(0,Q.jsx)(Rc,{value:P,onValueChange:e=>{(e===`rendered`||e===`source`)&&F(e)},children:(0,Q.jsxs)(Dc,{children:[(0,Q.jsx)(Hc,{value:`rendered`,children:b===`markdown`?`Reader`:`Preview`}),(0,Q.jsx)(Hc,{value:`source`,children:`Source`})]})}),t[20]=b,t[21]=P,t[22]=ie):ie=t[22];let oe;t[23]!==J||t[24]!==ie?(oe=(0,Q.jsxs)(Q.Fragment,{children:[J,ie]}),t[23]=J,t[24]=ie,t[25]=oe):oe=t[25];let se=oe,ce;t[26]!==s||t[27]!==l.owner||t[28]!==l.savedText||t[29]!==l.text||t[30]!==d||t[31]!==G||t[32]!==h?(ce=s&&(0,Q.jsxs)(y,{children:[(0,Q.jsx)(Gt,{render:(0,Q.jsx)(X,{variant:`ghost`,size:`icon-sm`,disabled:!!h||l.owner!==null&&l.owner!==G,"aria-description":h,"aria-label":l.text===l.savedText?`Edit`:`Resume edit`,onClick:()=>{d(G)&&R(!0)}}),children:(0,Q.jsx)(ae,{})}),(0,Q.jsx)(m,{role:`tooltip`,children:h??(l.owner!==null&&l.owner!==G?`Editing in another pane`:`Edit`)})]}),t[26]=s,t[27]=l.owner,t[28]=l.savedText,t[29]=l.text,t[30]=d,t[31]=G,t[32]=h,t[33]=ce):ce=t[33];let Y;t[34]!==M||t[35]!==f||t[36]!==a?(Y=M&&(0,Q.jsxs)(y,{children:[(0,Q.jsx)(Gt,{render:(0,Q.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":`Open diff`,onClick:()=>f({kind:`change`,path:a})}),children:(0,Q.jsx)(Ci,{})}),(0,Q.jsx)(m,{role:`tooltip`,children:`Open diff`})]}),t[34]=M,t[35]=f,t[36]=a,t[37]=Y):Y=t[37];let le;t[38]!==i.toolbarTarget||t[39]!==f||t[40]!==a?(le=i.toolbarTarget===void 0&&(0,Q.jsx)(WS,{path:a,onOpen:f}),t[38]=i.toolbarTarget,t[39]=f,t[40]=a,t[41]=le):le=t[41];let ue;t[42]===a?ue=t[43]:(ue=(0,Q.jsx)(GS,{path:a}),t[42]=a,t[43]=ue);let de;t[44]!==ce||t[45]!==Y||t[46]!==le||t[47]!==ue?(de=(0,Q.jsxs)(Q.Fragment,{children:[ce,Y,le,ue]}),t[44]=ce,t[45]=Y,t[46]=le,t[47]=ue,t[48]=de):de=t[48];let fe=de;if(L){let e;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>R(!1),t[49]=e):e=t[49];let n;t[50]!==s||t[51]!==u||t[52]!==o?(n=()=>{u(o,s??``),R(!1)},t[50]=s,t[51]=u,t[52]=o,t[53]=n):n=t[53];let r;t[54]===a?r=t[55]:(r=e=>(0,Q.jsx)(US,{path:a,children:e}),t[54]=a,t[55]=r);let i;return t[56]!==I||t[57]!==M||t[58]!==c||t[59]!==l||t[60]!==G||t[61]!==a||t[62]!==n||t[63]!==r||t[64]!==h?(i=(0,Q.jsx)(Hi,{owner:G,path:a,draft:c,state:l,active:I,writeBlock:h,changed:M,onDone:e,onDiscard:n,renderToolbar:r}),t[56]=I,t[57]=M,t[58]=c,t[59]=l,t[60]=G,t[61]=a,t[62]=n,t[63]=r,t[64]=h,t[65]=i):i=t[65],i}let pe;t[66]!==i.toolbarTarget||t[67]!==f||t[68]!==a||t[69]!==K?(pe=i.toolbarTarget&&!K&&(0,sg.createPortal)((0,Q.jsx)(Q.Fragment,{children:(0,Q.jsx)(WS,{path:a,onOpen:f})}),i.toolbarTarget),t[66]=i.toolbarTarget,t[67]=f,t[68]=a,t[69]=K,t[70]=pe):pe=t[70];let me;t[71]!==W||t[72]!==U||t[73]!==fe||t[74]!==r||t[75]!==k||t[76]!==z||t[77]!==V||t[78]!==i||t[79]!==b||t[80]!==se||t[81]!==P||t[82]!==A||t[83]!==f||t[84]!==a||t[85]!==n||t[86]!==o?(me=P===`rendered`&&b!==`code`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(US,{path:a,copy:!1,children:[se,(0,Q.jsx)(v_,{className:`max-w-full flex-wrap justify-end`,children:fe})]}),(0,Q.jsx)(HS,{scope:n,context:r,path:a,kind:b,text:o})]}):(0,Q.jsxs)(`div`,{ref:W,className:`flex min-h-0 flex-1 flex-col`,children:[z!==void 0&&(0,Q.jsx)(FS,{text:o,focusRequest:z,onReveal:e=>H({line:e,nonce:Date.now()}),onClose:()=>{B(void 0),U?.querySelector(`[aria-label="Code content"] [tabindex="-1"]`)?.focus({preventScroll:!0})}}),(0,Q.jsxs)(OS,{path:a,note:A,diff:k,children:[se,fe]}),(0,Q.jsx)(jx,{disableFileHeader:!0,compactThreads:!0,fileDiff:k,scope:n,context:r,interaction:i,headerActions:i.toolbarTarget===void 0?void 0:(0,Q.jsx)(WS,{path:a,onOpen:f}),...V===void 0?{}:{foundLine:V},entries:[{...gx(`file:${a}`,a,o)}]})]}),t[71]=W,t[72]=U,t[73]=fe,t[74]=r,t[75]=k,t[76]=z,t[77]=V,t[78]=i,t[79]=b,t[80]=se,t[81]=P,t[82]=A,t[83]=f,t[84]=a,t[85]=n,t[86]=o,t[87]=me):me=t[87];let he;return t[88]!==pe||t[89]!==me?(he=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-card`,children:[pe,me]}),t[88]=pe,t[89]=me,t[90]=he):he=t[90],he}function VS(e){return e.scope===`unstaged`}function HS(e){let t=(0,$.c)(8),{scope:n,context:r,path:i,kind:a,text:o}=e;if(a===`markdown`){let e;return t[0]===o?e=t[1]:(e=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,Q.jsx)(kr,{text:o,className:`mx-auto max-w-[78ch] px-6 py-6`})}),t[0]=o,t[1]=e),e}let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.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.`}),t[2]=s):s=t[2];let c;return t[3]!==r.connection||t[4]!==i||t[5]!==n||t[6]!==o?(c=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,children:[s,(0,Q.jsx)(_i,{scope:n,path:i,html:o,connection:r.connection})]}),t[3]=r.connection,t[4]=i,t[5]=n,t[6]=o,t[7]=c):c=t[7],c}function US(e){let t=(0,$.c)(7),{path:n,children:r,copy:i}=e,a=i===void 0||i,o;t[0]!==a||t[1]!==n?(o=a&&(0,Q.jsx)(GS,{path:n}),t[0]=a,t[1]=n,t[2]=o):o=t[2];let s;return t[3]!==r||t[4]!==n||t[5]!==o?(s=(0,Q.jsxs)(OS,{path:n,children:[r,o]}),t[3]=r,t[4]=n,t[5]=o,t[6]=s):s=t[6],s}function WS(e){let t=(0,$.c)(3),{path:n,onOpen:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,Q.jsx)(ux,{label:`Timeline`,iconOnly:!0,icon:Ir,onClick:()=>r({kind:`timeline`,path:n})}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function GS(e){let t=(0,$.c)(8),{path:n}=e,r;t[0]===n?r=t[1]:(r=(0,Q.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":`Copy path`,onClick:()=>tr(n,`path`)}),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(q,{}),t[2]=i):i=t[2];let a;t[3]===r?a=t[4]:(a=(0,Q.jsx)(Gt,{render:r,children:i}),t[3]=r,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(m,{role:`tooltip`,children:`Copy path`}),t[5]=o):o=t[5];let s;return t[6]===a?s=t[7]:(s=(0,Q.jsxs)(y,{children:[a,o]}),t[6]=a,t[7]=s),s}function KS(e){let t=e.toLowerCase();return t.endsWith(`.md`)||t.endsWith(`.mdx`)?`markdown`:t.endsWith(`.html`)||t.endsWith(`.htm`)?`html`:`code`}function qS(e,t){return e===`markdown`||e===`html`?t.documentsDefault:`source`}function JS(e){let t=(0,$.c)(6),{interaction:n,path:r,onOpen:i}=e;if(!n.toolbarTarget)return null;let a;t[0]!==i||t[1]!==r?(a=(0,Q.jsx)(WS,{path:r,onOpen:i}),t[0]=i,t[1]=r,t[2]=a):a=t[2];let o;return t[3]!==n.toolbarTarget||t[4]!==a?(o=(0,sg.createPortal)(a,n.toolbarTarget),t[3]=n.toolbarTarget,t[4]=a,t[5]=o):o=t[5],o}function YS(e,t){let[n,r]=(0,Z.useState)(e);return!t&&n!==e&&r(e),t?n:e}function XS(e){return[...new Set(e)].join(`, `)}function ZS(e){let t=(0,$.c)(52),{scope:n,context:r,interaction:i,paths:a,files:o,focus:s,header:c,headerActions:l,headerLeading:u,toolbar:d,footer:f,column:p,fullHeight:m,windowLimit:h}=e,g=o===void 0?[]:o,_=p!==void 0&&p,v=m!==void 0&&m,{connection:y}=r,[b,x]=(0,Z.useState)(),S;t[0]!==b||t[1]!==x?(S=(e,t)=>{b===e&&(x(void 0),t.focus({preventScroll:!0}),t.scrollIntoView({block:`start`}))},t[0]=b,t[1]=x,t[2]=S):S=t[2];let C=S;fx(n,r);let w=i.quiet===!0,T=YS(Ds(n,y),i.hidden===!0),E=us(px(n,r,T,a),g),D=E[0]?.statusToken??``,O=fs(n,y,D,E.flatMap(iC),E.flatMap(nC)),k=Ms(y,n,i.hidden===!0?[]:E.flatMap(eC)),[A,j]=(0,Z.useState)(h),M=h!==void 0&&A!==void 0&&h>A;!M||O.pending||O.failed||k.pending||k.failed||j(h);let N=w||M,[P,F]=(0,Z.useState)(k.contents);i.hidden===!0||k.pending||k.failed||oC(P,k.contents)||F(k.contents);let I;t[3]!==N||t[4]!==P||t[5]!==k.contents||t[6]!==k.failed?(I=e=>k.contents.get(e)??(N||k.failed?P.get(e):void 0),t[3]=N,t[4]=P,t[5]=k.contents,t[6]=k.failed,t[7]=I):I=t[7];let L=I,[R,z]=(0,Z.useState)(O.diffs);!O.pending&&!O.failed&&R!==O.diffs&&z(O.diffs);let B;t[8]===O.diffs?B=t[9]:(B=e=>{let t=uu(e);return t?O.diffs.get(Wi(t)):void 0},t[8]=O.diffs,t[9]=B);let V=B,H;t[10]!==O.failed||t[11]!==N||t[12]!==R||t[13]!==V?(H=e=>{let t=uu(e);if(t)return V(e)??(N||O.failed?R.get(Wi(t)):void 0)},t[10]=O.failed,t[11]=N,t[12]=R,t[13]=V,t[14]=H):H=t[14];let U=H,W=!w&&(O.pending||k.pending),G=!O.pending&&!k.pending&&(O.failed&&(M||R.size===0)||k.failed&&(M||P.size===0)),K=new Map(g.map($S)),ee;t[15]!==V||t[16]!==U||t[17]!==L||t[18]!==k.contents||t[19]!==k.pending?(ee=e=>{let t=e.comparisons.flatMap(e=>{if(e.scope===`unmerged`)return[`Conflict`];if(e.scope===`untracked`)return L(e.path)!==void 0||k.pending?[]:[`Not readable`];if(!e.supported)return[`Unsupported comparison`];let t=U(e);return t?t.kind===`binary`?[`Binary change`]:t.kind===`omitted`?[`Content omitted: ${su(t.reason)}`]:ro(e,t)?[]:[`No single-file textual patch`]:[]}),n=e.comparisons.every(e=>e.scope===`untracked`?L(e.path)===void 0||k.contents.has(e.path):U(e)===void 0||V(e)!==void 0);return t.length>0?[{item:e,reasons:t,current:n}]:[]},t[15]=V,t[16]=U,t[17]=L,t[18]=k.contents,t[19]=k.pending,t[20]=ee):ee=t[20];let q=E.flatMap(ee),te=E.flatMap(e=>e.comparisons.flatMap(t=>{let i=qx(n,r,e);if(t.scope===`untracked`){let n=L(t.path);if(n===void 0)return[];let r=k.contents.has(t.path);return[{...gx(Ma(t),e.path,n,K.get(e.path)??`untracked`),...r?{review:i}:{}}]}if(t.scope===`unmerged`||!t.supported)return[];let a=cC(U(t),s?.[e.path]),o=a?ro(t,a):null,c=K.get(e.path),l=V(t)!==void 0;return o?[{...o,...c?{note:c}:{},...l?{review:i,discardScope:t.scope}:{}}]:[]})),ne=new Set(te.map(QS)),re=i.toolbarTarget!==void 0&&/^(file|change|branch):/.test(i.entry)&&te.length===0&&E.length===1?q[0]?.item:void 0,J=c||W||G||q.length>0?e=>(0,Q.jsxs)(Q.Fragment,{children:[c?.({...e,open:t=>{x(void 0),ne.has(t)?e.open(t):x(t)}}),G&&(0,Q.jsx)(lC,{column:_,retry:()=>{O.retry(),k.retry()}}),q.length>0&&(0,Q.jsx)(uC,{changes:q,column:_,onTarget:(e,t)=>{t&&C(e,t)},renderedPaths:ne,scope:n,context:r,paneFile:!!re})]}):void 0;if(w&&te.length===0&&(O.pending||k.pending)){let e;return t[21]===E.length?e=t[22]:(e=(0,Q.jsx)(Gx,{count:E.length}),t[21]=E.length,t[22]=e),e}let ie;t[23]!==r||t[24]!==l||t[25]!==i.active||t[26]!==re||t[27]!==n?(ie=re?(0,Q.jsx)(dC,{scope:n,context:r,item:re,active:i.active,children:l}):void 0,t[23]=r,t[24]=l,t[25]=i.active,t[26]=re,t[27]=n,t[28]=ie):ie=t[28];let ae;t[29]===f?ae=t[30]:(ae=f?{footer:f}:{},t[29]=f,t[30]=ae);let oe;t[31]===J?oe=t[32]:(oe=J?{header:J}:{},t[31]=J,t[32]=oe);let se;t[33]===l?se=t[34]:(se=l?{headerActions:l}:{},t[33]=l,t[34]=se);let ce;t[35]===u?ce=t[36]:(ce=u?{headerLeading:u}:{},t[35]=u,t[36]=ce);let Y;t[37]===d?Y=t[38]:(Y=d?{toolbar:d}:{},t[37]=d,t[38]=Y);let le;return t[39]!==_||t[40]!==r||t[41]!==te||t[42]!==v||t[43]!==i||t[44]!==n||t[45]!==ae||t[46]!==oe||t[47]!==se||t[48]!==ce||t[49]!==Y||t[50]!==ie?(le=(0,Q.jsx)(jx,{fullHeight:v,emptyActions:ie,scope:n,context:r,interaction:i,entries:te,column:_,...ae,...oe,...se,...ce,...Y}),t[39]=_,t[40]=r,t[41]=te,t[42]=v,t[43]=i,t[44]=n,t[45]=ae,t[46]=oe,t[47]=se,t[48]=ce,t[49]=Y,t[50]=ie,t[51]=le):le=t[51],le}function QS(e){return e.path}function $S(e){return[e.path,e.note]}function eC(e){return e.comparisons.flatMap(tC)}function tC(e){return e.scope===`untracked`?[e.path]:[]}function nC(e){return e.comparisons.flatMap(rC)}function rC(e){let t=uu(e);return t?[t]:[]}function iC(e){return e.comparisons.some(aC)?[{path:e.path,fingerprint:e.fingerprint}]:[]}function aC(e){return e.scope===`staged`||e.scope===`unstaged`}function oC(e,t){return e.size===t.size&&[...t].every(([t,n])=>e.get(t)===n)}var sC=new WeakMap;function cC(e,t){if(!e||!t?.length||e.kind!==`text`)return e;let n=t.map(e=>`${e.startLine}-${e.endLine}`).join(`,`),r=sC.get(e),i=r?.get(n);if(i)return i;let a=md(e.patch,t),o=a?{...e,patch:a}:e;return r??=new Map,r.set(n,o),sC.set(e,r),o}function lC(e){let t=(0,$.c)(8),{column:n,retry:r}=e,i=!n&&`mx-4`,a;t[0]===i?a=t[1]:(a=Tn(`mt-3 flex items-center gap-3 rounded-lg border bg-muted/40 px-4 py-3 text-xs text-muted-foreground`,i),t[0]=i,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(`span`,{children:`The changes in this document could not be read.`}),t[2]=o):o=t[2];let s;t[3]===r?s=t[4]:(s=(0,Q.jsx)(X,{size:`xs`,variant:`outline`,onClick:r,children:`Try again`}),t[3]=r,t[4]=s);let c;return t[5]!==a||t[6]!==s?(c=(0,Q.jsxs)(`section`,{role:`alert`,className:a,children:[o,s]}),t[5]=a,t[6]=s,t[7]=c):c=t[7],c}function uC(e){let t=(0,$.c)(21),{changes:n,column:r,onTarget:i,renderedPaths:a,scope:o,context:s,paneFile:c}=e,l=!r&&`mx-4`,u;t[0]===l?u=t[1]:(u=Tn(`mt-3 rounded-lg border bg-muted/40 px-4 py-3`,l),t[0]=l,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(`p`,{className:`text-xs font-medium`,children:`Non-text content`}),t[2]=d):d=t[2];let f;if(t[3]!==n||t[4]!==s||t[5]!==i||t[6]!==c||t[7]!==a||t[8]!==o){let e;t[10]!==s||t[11]!==i||t[12]!==c||t[13]!==a||t[14]!==o?(e=e=>{let{item:t,reasons:n,current:r}=e;return(0,Q.jsxs)(`li`,{"aria-label":`${t.path}: ${XS(n)}`,tabIndex:-1,ref:e=>i(t.path,e),className:`flex min-w-0 scroll-mt-3 flex-wrap items-center gap-2 outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,Q.jsx)(v,{className:`min-w-0 basis-full`,text:t.path}),Td(t.path)&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{children:`Current worktree image`}),(0,Q.jsx)(li,{scope:o,path:t.path,connection:s.connection})]}),(0,Q.jsx)(Mn,{variant:`outline`,className:`h-auto max-w-full text-left whitespace-normal`,children:XS(n)}),!c&&r&&!a.has(t.path)&&(0,Q.jsx)(Jx,{scope:o,context:s,path:t.path,fingerprint:t.fingerprint,status:t.reviewStatus,compact:!!t.fingerprint})]},t.path)},t[10]=s,t[11]=i,t[12]=c,t[13]=a,t[14]=o,t[15]=e):e=t[15],f=n.map(e),t[3]=n,t[4]=s,t[5]=i,t[6]=c,t[7]=a,t[8]=o,t[9]=f}else f=t[9];let p;t[16]===f?p=t[17]:(p=(0,Q.jsx)(`ul`,{className:`mt-2 flex flex-col gap-2 text-xs text-muted-foreground`,children:f}),t[16]=f,t[17]=p);let m;return t[18]!==u||t[19]!==p?(m=(0,Q.jsxs)(`section`,{className:u,children:[d,p]}),t[18]=u,t[19]=p,t[20]=m):m=t[20],m}function dC(e){let t=(0,$.c)(18),{scope:n,context:r,item:i,active:a,children:o}=e,s=Tx(n,r,fC),c;t[0]!==r||t[1]!==i||t[2]!==n?(c=qx(n,r,i),t[0]=r,t[1]=i,t[2]=n,t[3]=c):c=t[3];let l=c,u=_o(),d;t[4]!==s||t[5]!==l?(d=()=>s.toggle(l),t[4]=s,t[5]=l,t[6]=d):d=t[6];let f=d,p=u&&a,m;t[7]===p?m=t[8]:(m={enabled:p,ignoreInputs:!0},t[7]=p,t[8]=m),cc(Ys.toggleReviewed,f,m);let h=l.reviewed?Te:eu,g=!!s.writeBlock||!l.fingerprint,_;t[9]!==s.writeBlock||t[10]!==h||t[11]!==g||t[12]!==l.reviewed||t[13]!==f?(_=(0,Q.jsx)(ux,{label:`Reviewed`,variant:`outline`,icon:h,shortcut:Ys.toggleReviewed,description:s.writeBlock,disabled:g,pressed:l.reviewed,onClick:f}),t[9]=s.writeBlock,t[10]=h,t[11]=g,t[12]=l.reviewed,t[13]=f,t[14]=_):_=t[14];let v;return t[15]!==o||t[16]!==_?(v=(0,Q.jsxs)(Q.Fragment,{children:[_,o]}),t[15]=o,t[16]=_,t[17]=v):v=t[17],v}function fC(e){return ms.add(e)}var pC=Z.createContext(void 0);function mC(){let e=Z.useContext(pC);if(e===void 0)throw Error(Fe(13));return e}var hC={imageLoadingStatus:()=>null},gC=Z.forwardRef(function(e,t){let{className:n,render:r,style:i,...a}=e,[o,s]=Z.useState(`idle`),c={imageLoadingStatus:o},l=Z.useMemo(()=>({imageLoadingStatus:o,setImageLoadingStatus:s}),[o,s]),u=pr(`span`,e,{state:c,ref:t,props:a,stateAttributesMapping:hC});return(0,Q.jsx)(pC.Provider,{value:l,children:u})});function _C(e,{referrerPolicy:t,crossOrigin:n,sizes:r,srcSet:i},a){let o=Z.useState(`idle`),s=o[1];return We(()=>{if(!a)return fn;if(!e&&!i)return s(`error`),fn;let o=!0,c=new window.Image,l=e=>()=>{o&&s(e)};return s(`loading`),c.onload=l(`loaded`),c.onerror=l(`error`),t&&(c.referrerPolicy=t),c.crossOrigin=n??null,r&&(c.sizes=r),i&&(c.srcset=i),e&&(c.src=e),c.complete&&s(c.naturalWidth>0?`loaded`:`error`),()=>{o=!1}},[a,e,i,r,n,t,s]),o}var vC={...hC,...le},yC=Z.forwardRef(function(e,t){let{className:n,render:r,onLoadingStatusChange:i,keepMounted:a=!1,style:o,sizes:s,srcSet:c,src:l,...u}=e,{setImageLoadingStatus:d}=mC(),[f,p]=_C(l,e,!a),m=f===`loaded`,{mounted:h,transitionStatus:g,setMounted:_}=He(m),v=Z.useRef(null),y=Z.useRef(!0);We(()=>{if(!a)return;let e=y.current;y.current=!1;let t=v.current;if(!t)return;if(!t.complete){p(`loading`);return}let n=t.naturalWidth>0?`loaded`:`error`;p(n),n===`loaded`&&e&&_(!0)},[a,l,c,s,u.crossOrigin,u.referrerPolicy,r,p,_]);let b=a?{"data-loading":f===`loading`?``:void 0,"data-error":f===`error`?``:void 0,"aria-hidden":f!==`loaded`||void 0,onLoad(){p(`loaded`)},onError(){p(`error`)}}:void 0,x=B(e=>{i?.(e),d(e)});We(()=>{f!==`idle`&&x(f)},[f,x]),We(()=>()=>d(`idle`),[d]),Ye({enabled:!m,open:m,ref:v,onComplete(){m||_(!1)}});let S={imageLoadingStatus:f,transitionStatus:a&&g===`ending`?void 0:g},C=a||h,w={};s!==void 0&&(w.sizes=s),c!==void 0&&(w.srcSet=c),l!==void 0&&(w.src=l);let T=pr(`img`,e,{state:S,ref:[t,v],props:[b,u,w],stateAttributesMapping:vC,enabled:C});return C?T:null}),bC=Z.forwardRef(function(e,t){let{className:n,render:r,delay:i=0,style:a,...o}=e,{imageLoadingStatus:s}=mC(),[c,l]=Z.useState(i===0),u=P();return Z.useEffect(()=>(i>0?u.start(i,()=>l(!0)):l(!0),u.clear),[u,i]),pr(`span`,e,{state:{imageLoadingStatus:s},ref:t,props:o,stateAttributesMapping:hC,enabled:s!==`loaded`&&(i===0||c)})});function xC({className:e,size:t=`default`,...n}){return(0,Q.jsx)(gC,{"data-slot":`avatar`,"data-size":t,className:Tn(`group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten`,e),...n})}function SC({className:e,...t}){return(0,Q.jsx)(yC,{"data-slot":`avatar-image`,className:Tn(`aspect-square size-full rounded-full object-cover`,e),...t})}function CC({className:e,...t}){return(0,Q.jsx)(bC,{"data-slot":`avatar-fallback`,className:Tn(`flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs`,e),...t})}var wC={open:Bl,draft:Hl,merged:Il,closed:Rl};function TC(e){let t=(0,$.c)(10),{pull:n}=e,r;t[0]===n?r=t[1]:(r=pc(n),t[0]=n,t[1]=r);let i=r,a=wC[i],o;t[2]===a?o=t[3]:(o=(0,Q.jsx)(a,{"aria-hidden":`true`}),t[2]=a,t[3]=o);let s;t[4]===n?s=t[5]:(s=Gc(n),t[4]=n,t[5]=s);let c;return t[6]!==i||t[7]!==o||t[8]!==s?(c=(0,Q.jsxs)(Mn,{variant:i,children:[o,s]}),t[6]=i,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}var EC={passed:(0,Q.jsx)(Te,{"aria-hidden":`true`,strokeWidth:2.5,className:`size-3 shrink-0 text-add-fg`}),running:(0,Q.jsx)(F,{"aria-hidden":`true`,className:`size-3 shrink-0`}),failed:(0,Q.jsx)(Ht,{"aria-hidden":`true`,strokeWidth:2.5,className:`size-3 shrink-0 text-del-fg`})};function DC(e){let t=(0,$.c)(6),{tone:n,label:r,className:i}=e,a;t[0]===i?a=t[1]:(a=Tn(`inline-flex items-center gap-1`,i),t[0]=i,t[1]=a);let o=n!==`none`&&EC[n],s;return t[2]!==r||t[3]!==a||t[4]!==o?(s=(0,Q.jsxs)(`span`,{className:a,children:[o,r]}),t[2]=r,t[3]=a,t[4]=o,t[5]=s):s=t[5],s}function OC(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground`,children:`·`}),e[0]=t):t=e[0],t}var kC={passed:`open`,failed:`closed`,none:`outline`};function AC(e){let t=(0,$.c)(61),{projectId:n,number:r,context:i,toolbarTarget:a,onBack:o,onFile:s}=e,c;t[0]!==i.connection||t[1]!==r||t[2]!==n?(c=b({connection:i.connection,projectId:n,number:r}),t[0]=i.connection,t[1]=r,t[2]=n,t[3]=c):c=t[3];let u=c,d=$t(u),f=_n(u),p;t[4]===d?p=t[5]:(p=ne(J(d)),t[4]=d,t[5]=p);let m=p;if(h(d)){let e;return t[6]===f?e=t[7]:(e=(0,Q.jsx)(pe,{description:`The pull request could not be read.`,onRetry:f}),t[6]=f,t[7]=e),e}if(!m){let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(l,{label:`Reading the pull request`}),t[8]=e):e=t[8],e}if(m.kind===`unavailable`){let e;return t[9]!==d.waiting||t[10]!==f||t[11]!==m.reason?(e=(0,Q.jsx)(VC,{reason:m.reason,retrying:d.waiting,onRetry:f}),t[9]=d.waiting,t[10]=f,t[11]=m.reason,t[12]=e):e=t[12],e}let g=m.pullRequest,_;t[13]!==i||t[14]!==r||t[15]!==n||t[16]!==g.state?(_=g.state===`merged`||g.state===`closed`?(0,Q.jsx)(Ro,{context:i,projectId:n,number:r}):void 0,t[13]=i,t[14]=r,t[15]=n,t[16]=g.state,t[17]=_):_=t[17];let y;t[18]!==g.url||t[19]!==_||t[20]!==a?(y=(0,Q.jsx)(MC,{url:g.url,target:a,archive:_}),t[18]=g.url,t[19]=_,t[20]=a,t[21]=y):y=t[21];let x=`Pull request #${r}`,S;t[22]===g?S=t[23]:(S=(0,Q.jsx)(NC,{pull:g}),t[22]=g,t[23]=S);let C;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(`h2`,{children:`Description`}),t[24]=C):C=t[24];let w;t[25]===g.author?w=t[26]:(w=g.author&&(0,Q.jsx)(v,{text:`by ${g.author}`}),t[25]=g.author,t[26]=w);let T;t[27]!==g.author||t[28]!==g.createdAt?(T=g.author&&g.createdAt&&(0,Q.jsx)(OC,{}),t[27]=g.author,t[28]=g.createdAt,t[29]=T):T=t[29];let E;t[30]===g.createdAt?E=t[31]:(E=g.createdAt&&(0,Q.jsx)(`time`,{dateTime:g.createdAt,children:HC(g.createdAt)}),t[30]=g.createdAt,t[31]=E);let D;t[32]!==E||t[33]!==w||t[34]!==T?(D=(0,Q.jsxs)(`div`,{className:jC,children:[C,(0,Q.jsxs)(`div`,{className:`ml-auto flex min-w-0 items-center gap-1.5 font-normal`,children:[w,T,E]})]}),t[32]=E,t[33]=w,t[34]=T,t[35]=D):D=t[35];let O;t[36]===g.description?O=t[37]:(O=g.description.trim()?(0,Q.jsx)(kr,{text:g.description,className:`pt-3.5 text-(length:--text-prose) leading-6 wrap-anywhere text-foreground-2 [&_h1]:text-foreground [&_h2]:text-foreground [&_h3]:text-base [&_h3]:leading-6 [&_h3]:text-foreground [&_code]:text-ui [&_code]:leading-5 [&_p]:leading-6 [&_p]:mt-1 [&_p]:mb-0 [&_ul]:mt-2 [&_ul]:mb-0 [&_ol]:mt-2 [&_ol]:mb-0 [&_li]:my-0 [&_h1]:mb-0 [&_h2]:mb-0 [&_h3]:mb-0 [&_h1]:tracking-pr-subheading [&_h2]:tracking-pr-subheading [&_h3]:tracking-pr-subheading [&_code]:rounded-sm [&_code]:px-1.25 [&_code]:py-px [&_code]:ring-1 [&_code]:ring-border [&_code]:ring-inset`}):(0,Q.jsx)(`p`,{className:`pt-3.5 text-ui text-muted-foreground`,children:`No description provided.`}),t[36]=g.description,t[37]=O);let k;t[38]!==D||t[39]!==O?(k=(0,Q.jsxs)(`section`,{"aria-label":`Description`,children:[D,O]}),t[38]=D,t[39]=O,t[40]=k):k=t[40];let A;t[41]!==o||t[42]!==s||t[43]!==g?(A=(0,Q.jsx)(FC,{pull:g,onBack:o,onFile:s}),t[41]=o,t[42]=s,t[43]=g,t[44]=A):A=t[44];let j;t[45]!==k||t[46]!==A?(j=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[k,A]}),t[45]=k,t[46]=A,t[47]=j):j=t[47];let M;t[48]===g?M=t[49]:(M=(0,Q.jsx)(`aside`,{"aria-label":`Checks and details`,className:`min-w-0 shrink-0 @min-4xl/pr:w-68`,children:(0,Q.jsx)(zC,{pull:g})}),t[48]=g,t[49]=M);let N;t[50]!==j||t[51]!==M?(N=(0,Q.jsxs)(`div`,{className:`mt-7 flex min-w-0 flex-col gap-x-11 gap-y-7 @min-4xl/pr:flex-row`,children:[j,M]}),t[50]=j,t[51]=M,t[52]=N):N=t[52];let P;t[53]!==d.waiting||t[54]!==N||t[55]!==x||t[56]!==S?(P=(0,Q.jsxs)(`article`,{"aria-busy":d.waiting,"aria-label":x,className:`mx-auto w-full max-w-280 min-w-0 px-4 pt-9 pb-12 text-ui @min-3xl/pr:px-7`,children:[S,N]}),t[53]=d.waiting,t[54]=N,t[55]=x,t[56]=S,t[57]=P):P=t[57];let F;return t[58]!==P||t[59]!==y?(F=(0,Q.jsxs)(`div`,{className:`@container/pr flex min-h-0 min-w-0 flex-1 flex-col overflow-auto`,children:[y,P]}),t[58]=P,t[59]=y,t[60]=F):F=t[60],F}var jC=`flex min-h-6 min-w-0 flex-wrap items-center gap-x-2 gap-y-1 border-b pb-1.5 text-xs leading-4 font-medium text-muted-foreground`;function MC(e){let t=(0,$.c)(21),{url:n,target:r,archive:i}=e,a;t[0]===n?a=t[1]:(a=(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,nativeButton:!1,render:(0,Q.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`}),"aria-label":`Open on GitHub`,className:``}),t[0]=n,t[1]=a);let o=r!==void 0&&`hidden @min-3xl/pane:inline`,s;t[2]===o?s=t[3]:(s=Tn(o),t[2]=o,t[3]=s);let c;t[4]===s?c=t[5]:(c=(0,Q.jsx)(`span`,{className:s,children:`Open on GitHub`}),t[4]=s,t[5]=c);let l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(A,{"aria-hidden":`true`,className:`size-3.5`}),t[6]=l):l=t[6];let u;t[7]!==a||t[8]!==c?(u=(0,Q.jsxs)(Gt,{render:a,children:[c,l]}),t[7]=a,t[8]=c,t[9]=u):u=t[9];let d;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(m,{children:`Open on GitHub`}),t[10]=d):d=t[10];let f;t[11]===u?f=t[12]:(f=(0,Q.jsxs)(y,{children:[u,d]}),t[11]=u,t[12]=f);let p;t[13]!==i||t[14]!==f?(p=(0,Q.jsxs)(Q.Fragment,{children:[i,f]}),t[13]=i,t[14]=f,t[15]=p):p=t[15];let h=p;if(r!==void 0){let e;return t[16]!==h||t[17]!==r?(e=r?(0,sg.createPortal)(h,r):null,t[16]=h,t[17]=r,t[18]=e):e=t[18],e}let g;return t[19]===h?g=t[20]:(g=(0,Q.jsx)(`div`,{className:`flex h-12 shrink-0 items-center justify-end border-b px-3`,children:h}),t[19]=h,t[20]=g),g}function NC(e){let t=(0,$.c)(50),{pull:n}=e,r;t[0]===n.url?r=t[1]:(r=qc(n.url)?.split(`/`).at(-1),t[0]=n.url,t[1]=r);let i=r,a,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(Bl,{"aria-hidden":`true`,strokeWidth:1.75,className:`size-3.5 shrink-0`}),o=(0,Q.jsx)(`span`,{className:`shrink-0`,children:`Pull request`}),t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s;t[4]===i?s=t[5]:(s=i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(OC,{}),(0,Q.jsx)(v,{text:i})]}),t[4]=i,t[5]=s);let c;t[6]===s?c=t[7]:(c=(0,Q.jsxs)(`div`,{className:`flex h-5.5 min-w-0 items-center gap-2 text-ui leading-5.5 font-medium text-muted-foreground`,children:[a,o,s]}),t[6]=s,t[7]=c);let l;t[8]===n.number?l=t[9]:(l=(0,Q.jsxs)(`span`,{className:`text-title-dim tabular-nums`,children:[`#`,n.number]}),t[8]=n.number,t[9]=l);let u;t[10]!==n.title||t[11]!==l?(u=(0,Q.jsxs)(`h1`,{className:`mt-3 text-4xl leading-10 font-semibold tracking-pr-title wrap-anywhere`,children:[l,` `,n.title]}),t[10]=n.title,t[11]=l,t[12]=u):u=t[12];let d;t[13]===n?d=t[14]:(d=(0,Q.jsx)(TC,{pull:n}),t[13]=n,t[14]=d);let f;t[15]!==n.author||t[16]!==n.authorAvatarUrl?(f=n.author&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(IC,{author:n.author,url:n.authorAvatarUrl}),(0,Q.jsx)(v,{text:n.author,className:`font-medium text-foreground`}),(0,Q.jsx)(OC,{})]}),t[15]=n.author,t[16]=n.authorAvatarUrl,t[17]=f):f=t[17];let p;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(`span`,{tabIndex:0,className:`inline-flex max-w-full min-w-0 items-center gap-1.5 font-mono text-caption text-foreground outline-none`}),t[18]=p):p=t[18];let h;t[19]===n.baseBranch?h=t[20]:(h=(0,Q.jsx)(v,{text:n.baseBranch}),t[19]=n.baseBranch,t[20]=h);let g;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(fl,{"aria-hidden":`true`,strokeWidth:1.75,className:`size-3 shrink-0 text-muted-foreground`}),t[21]=g):g=t[21];let _;t[22]===n.headBranch?_=t[23]:(_=(0,Q.jsx)(v,{text:n.headBranch}),t[22]=n.headBranch,t[23]=_);let b;t[24]!==h||t[25]!==_?(b=(0,Q.jsxs)(Gt,{render:p,children:[h,g,_]}),t[24]=h,t[25]=_,t[26]=b):b=t[26];let x;t[27]!==n.baseBranch||t[28]!==n.headBranch?(x=(0,Q.jsxs)(m,{children:[`Merges `,n.headBranch,` into `,n.baseBranch]}),t[27]=n.baseBranch,t[28]=n.headBranch,t[29]=x):x=t[29];let S;t[30]!==b||t[31]!==x?(S=(0,Q.jsxs)(y,{children:[b,x]}),t[30]=b,t[31]=x,t[32]=S):S=t[32];let C;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(OC,{}),t[33]=C):C=t[33];let w;t[34]===n.updatedAt?w=t[35]:(w=HC(n.updatedAt),t[34]=n.updatedAt,t[35]=w);let T;t[36]===w?T=t[37]:(T=(0,Q.jsxs)(`span`,{children:[`updated `,w]}),t[36]=w,t[37]=T);let E;t[38]!==S||t[39]!==T||t[40]!==d||t[41]!==f?(E=(0,Q.jsxs)(`div`,{className:`mt-3.5 flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-2 text-ui leading-5 text-muted-foreground`,children:[d,f,S,C,T]}),t[38]=S,t[39]=T,t[40]=d,t[41]=f,t[42]=E):E=t[42];let D;t[43]===n.labels?D=t[44]:(D=n.labels.length>0&&(0,Q.jsx)(`ul`,{"aria-label":`Labels`,className:`mt-3 flex min-w-0 flex-wrap gap-1.5`,children:n.labels.map(PC)}),t[43]=n.labels,t[44]=D);let O;return t[45]!==E||t[46]!==D||t[47]!==c||t[48]!==u?(O=(0,Q.jsxs)(`header`,{className:`min-w-0`,children:[c,u,E,D]}),t[45]=E,t[46]=D,t[47]=c,t[48]=u,t[49]=O):O=t[49],O}function PC(e,t){return(0,Q.jsx)(`li`,{className:`min-w-0 max-w-full`,children:(0,Q.jsx)(Mn,{variant:`outline`,className:`max-w-full`,children:(0,Q.jsx)(v,{text:e.name})})},`${e.name}:${t}`)}function FC(e){let t=(0,$.c)(23),{pull:n,onBack:r,onFile:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(`h2`,{children:`Conversation`}),t[0]=a):a=t[0];let o;t[1]===n.timeline.length?o=t[2]:(o=(0,Q.jsx)(`span`,{className:`font-normal tabular-nums`,children:n.timeline.length}),t[1]=n.timeline.length,t[2]=o);let s=`${n.url}#issue-comment-box`,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(w,{"aria-hidden":`true`,className:`size-3 shrink-0`}),t[3]=c):c=t[3];let l,u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsxs)(`span`,{children:[`Comments on GitHub ·`,` `,(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:`reply there`})]}),u=(0,Q.jsx)(A,{"aria-hidden":`true`,className:`size-3 shrink-0`}),t[4]=l,t[5]=u):(l=t[4],u=t[5]);let d;t[6]===s?d=t[7]:(d=(0,Q.jsxs)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,className:`ml-auto inline-flex max-w-full min-w-0 flex-wrap items-center gap-1 font-normal outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:[c,l,u]}),t[6]=s,t[7]=d);let f;t[8]!==o||t[9]!==d?(f=(0,Q.jsxs)(`div`,{className:jC,children:[a,o,d]}),t[8]=o,t[9]=d,t[10]=f):f=t[10];let p;t[11]!==i||t[12]!==n.timeline?(p=n.timeline.length>0?(0,Q.jsx)(`ol`,{"aria-label":`Timeline`,className:`relative mt-3.5 flex min-w-0 flex-col gap-4 before:absolute before:top-4 before:bottom-2.5 before:left-2.5 before:w-px before:bg-border`,children:dc(n.timeline).map(e=>{let{item:t,comments:n}=e;return(0,Q.jsx)(LC,{item:t,onFile:i,children:n.length>0&&(0,Q.jsx)(`ol`,{"aria-label":`Comments on review by ${t.author??`Unknown author`}`,className:`mt-3 flex min-w-0 flex-col gap-3 border-l pl-3`,children:n.map(e=>(0,Q.jsx)(LC,{item:e,onFile:i},e.id))})},t.id)})}):(0,Q.jsx)(`p`,{className:`pt-3.5 text-ui text-muted-foreground`,children:`No comments or reviews on GitHub yet.`}),t[11]=i,t[12]=n.timeline,t[13]=p):p=t[13];let m;t[14]===n.truncated?m=t[15]:(m=n.truncated&&(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Some labels or conversation items are not shown. Open on GitHub to see everything.`}),t[14]=n.truncated,t[15]=m);let h;t[16]===r?h=t[17]:(h=(0,Q.jsxs)(`p`,{className:`mt-4 flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1 text-xs leading-4 text-muted-foreground @min-3xl/pr:ml-7.5`,children:[`Questions about the change belong in its Walkthrough.`,(0,Q.jsx)(X,{variant:`link`,size:`sm`,onClick:r,children:`Back to the worktree`})]}),t[16]=r,t[17]=h);let g;return t[18]!==m||t[19]!==h||t[20]!==f||t[21]!==p?(g=(0,Q.jsxs)(`section`,{"aria-label":`Conversation on GitHub`,className:`mt-7 min-w-0`,children:[f,p,m,h]}),t[18]=m,t[19]=h,t[20]=f,t[21]=p,t[22]=g):g=t[22],g}function IC(e){let t=(0,$.c)(9),{author:n,url:r}=e,i;t[0]===r?i=t[1]:(i=r&&(0,Q.jsx)(SC,{src:r,alt:``}),t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=n.slice(0,1).toUpperCase(),t[2]=n,t[3]=a);let o;t[4]===a?o=t[5]:(o=(0,Q.jsx)(CC,{children:a}),t[4]=a,t[5]=o);let s;return t[6]!==i||t[7]!==o?(s=(0,Q.jsxs)(xC,{size:`sm`,"aria-hidden":`true`,children:[i,o]}),t[6]=i,t[7]=o,t[8]=s):s=t[8],s}function LC(e){let t=(0,$.c)(51),{item:n,onFile:r,children:i}=e,{dark:a}=$s(),o;t[0]===n.reviewState?o=t[1]:(o=ec(n.reviewState),t[0]=n.reviewState,t[1]=o);let s=o,c=n.author??`Unknown author`,l=n.line??n.originalLine,u=n.path,d=n.path===void 0?void 0:`${n.path}${l===void 0?``:`:${l}`}`,f;t[2]!==c||t[3]!==n.authorAvatarUrl?(f=(0,Q.jsx)(`div`,{className:`z-1 shrink-0 bg-background`,children:(0,Q.jsx)(IC,{author:c,url:n.authorAvatarUrl})}),t[2]=c,t[3]=n.authorAvatarUrl,t[4]=f):f=t[4];let p;t[5]===c?p=t[6]:(p=(0,Q.jsx)(v,{text:c,className:`text-ui leading-4.5 font-semibold text-foreground`}),t[5]=c,t[6]=p);let h;t[7]===s?h=t[8]:(h=s&&(0,Q.jsx)(Mn,{variant:kC[s.tone],children:s.label}),t[7]=s,t[8]=h);let g=!s&&n.kind===`comment`?`commented · `:``,_;t[9]===n.time?_=t[10]:(_=HC(n.time),t[9]=n.time,t[10]=_);let b;t[11]!==g||t[12]!==_?(b=(0,Q.jsxs)(`span`,{children:[g,_]}),t[11]=g,t[12]=_,t[13]=b):b=t[13];let x;t[14]===n.url?x=t[15]:(x=(0,Q.jsx)(`a`,{href:n.url,target:`_blank`,rel:`noreferrer`}),t[14]=n.url,t[15]=x);let S=`Open this ${n.kind===`review`?`review`:`comment`} on GitHub`,C;t[16]!==x||t[17]!==S?(C=(0,Q.jsx)(X,{variant:`ghost`,size:`icon-sm`,nativeButton:!1,render:x,"aria-label":S,className:`ml-auto`}),t[16]=x,t[17]=S,t[18]=C):C=t[18];let w;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Q.jsx)(A,{"aria-hidden":`true`,className:`size-3`}),t[19]=w):w=t[19];let T;t[20]===C?T=t[21]:(T=(0,Q.jsx)(Gt,{render:C,children:w}),t[20]=C,t[21]=T);let E;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Q.jsx)(m,{children:`Open on GitHub`}),t[22]=E):E=t[22];let D;t[23]===T?D=t[24]:(D=(0,Q.jsxs)(y,{children:[T,E]}),t[23]=T,t[24]=D);let O;t[25]!==D||t[26]!==p||t[27]!==h||t[28]!==b?(O=(0,Q.jsxs)(`div`,{className:`flex min-h-5 min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs leading-4 text-muted-foreground`,children:[p,h,b,D]}),t[25]=D,t[26]=p,t[27]=h,t[28]=b,t[29]=O):O=t[29];let k;t[30]!==d||t[31]!==n.path||t[32]!==r||t[33]!==u?(k=d&&(0,Q.jsxs)(`div`,{className:`mt-2.5 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 rounded-t-lg border bg-muted px-2 py-1.5`,children:[r&&n.path!==void 0?(0,Q.jsxs)(X,{variant:`ghost`,size:`sm`,"aria-label":`Open ${d}`,className:`max-w-full min-w-0 justify-start`,onClick:()=>{u!==void 0&&r(u)},children:[(0,Q.jsx)(Mi,{"aria-hidden":`true`}),(0,Q.jsx)(v,{text:d})]}):(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 font-mono text-xs`,children:[(0,Q.jsx)(Mi,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Q.jsx)(v,{text:d})]}),(0,Q.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`review comment`})]}),t[30]=d,t[31]=n.path,t[32]=r,t[33]=u,t[34]=k):k=t[34];let j;t[35]!==a||t[36]!==n.diffHunk||t[37]!==u?(j=n.diffHunk&&(0,Q.jsx)(`div`,{role:`region`,"aria-label":`Code excerpt for ${u??`review comment`}`,className:`max-h-64 min-w-0 overflow-auto border-x`,children:(0,Q.jsx)(ca,{file:{name:u??`review.diff`,contents:n.diffHunk,lang:`diff`},options:{theme:ac,preferredHighlighter:Us,themeType:a?`dark`:`light`,disableFileHeader:!0,disableLineNumbers:!0,overflow:`wrap`}})}),t[35]=a,t[36]=n.diffHunk,t[37]=u,t[38]=j):j=t[38];let M;t[39]!==d||t[40]!==n.body?(M=n.body.trim()&&(0,Q.jsx)(kr,{text:n.body,className:Tn(`mt-1 text-sm leading-5.5 wrap-anywhere [&_p]:my-0 [&_p]:leading-5.5`,d&&`mt-0 rounded-b-lg border border-t-0 px-3 py-2.5 text-ui [&_p]:leading-4.75`)}),t[39]=d,t[40]=n.body,t[41]=M):M=t[41];let N;t[42]!==i||t[43]!==O||t[44]!==k||t[45]!==j||t[46]!==M?(N=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[O,k,j,M,i]}),t[42]=i,t[43]=O,t[44]=k,t[45]=j,t[46]=M,t[47]=N):N=t[47];let P;return t[48]!==N||t[49]!==f?(P=(0,Q.jsxs)(`li`,{className:`relative flex min-w-0 items-start gap-2.5`,children:[f,N]}),t[48]=N,t[49]=f,t[50]=P):P=t[50],P}var RC={passed:{Icon:zi,label:`Passed`,color:`text-add-fg`},failed:{Icon:Sl,label:`Failed`,color:`text-del-fg`},running:{Icon:F,label:`Running`,color:`text-muted-foreground`}};function zC(e){let t=(0,$.c)(34),{pull:n}=e,r;t[0]!==n.checks||t[1]!==n.checksSummary||t[2]!==n.checksTruncated?(r=Sc(n.checks,n.checksTruncated,n.checksSummary),t[0]=n.checks,t[1]=n.checksSummary,t[2]=n.checksTruncated,t[3]=r):r=t[3];let i=r,a;t[4]===n.mergeable?a=t[5]:(a=Wc(n.mergeable),t[4]=n.mergeable,t[5]=a);let o=a,s;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(`h2`,{children:`Checks`}),t[6]=s):s=t[6];let c=i.tone===`passed`?`${n.checks.length}${n.checksTruncated?`+`:``} passed`:i.label,l;t[7]!==i.tone||t[8]!==c?(l=(0,Q.jsxs)(`div`,{className:jC,children:[s,(0,Q.jsx)(DC,{tone:i.tone,label:c,className:`ml-auto text-foreground tabular-nums`})]}),t[7]=i.tone,t[8]=c,t[9]=l):l=t[9];let u;t[10]===n.checks?u=t[11]:(u=n.checks.length===0?(0,Q.jsx)(`p`,{className:`pt-3 text-ui text-muted-foreground`,children:`No checks reported by GitHub.`}):(0,Q.jsx)(`ul`,{className:`mt-1`,"aria-label":`Pull request checks`,children:n.checks.map(BC)}),t[10]=n.checks,t[11]=u);let d;t[12]===n.checksTruncated?d=t[13]:(d=n.checksTruncated&&(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`More checks are available on GitHub.`}),t[12]=n.checksTruncated,t[13]=d);let f;t[14]!==l||t[15]!==u||t[16]!==d?(f=(0,Q.jsxs)(`section`,{"aria-label":`GitHub checks`,children:[l,u,d]}),t[14]=l,t[15]=u,t[16]=d,t[17]=f):f=t[17];let p;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Head`}),t[18]=p):p=t[18];let m=n.headSha,h;t[19]===n.headSha?h=t[20]:(h=H_(n.headSha),t[19]=n.headSha,t[20]=h);let g;t[21]!==n.headSha||t[22]!==h?(g=(0,Q.jsxs)(`div`,{className:`flex h-7 min-w-0 items-center gap-2`,children:[p,(0,Q.jsx)(`dd`,{className:`ml-auto min-w-0 font-mono text-caption font-medium`,children:(0,Q.jsx)(v,{text:m,disclose:`always`,children:h})})]}),t[21]=n.headSha,t[22]=h,t[23]=g):g=t[23];let _;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Mergeable`}),t[24]=_):_=t[24];let y;t[25]!==o.label||t[26]!==o.tone?(y=(0,Q.jsxs)(`div`,{className:`flex h-7 items-center gap-2 border-t`,children:[_,(0,Q.jsx)(`dd`,{className:`ml-auto font-medium`,children:(0,Q.jsx)(DC,{tone:o.tone,label:o.label,className:`gap-1.5`})})]}),t[25]=o.label,t[26]=o.tone,t[27]=y):y=t[27];let b;t[28]!==g||t[29]!==y?(b=(0,Q.jsxs)(`dl`,{"aria-label":`Merge`,className:`mt-5 border-y text-ui leading-4.5`,children:[g,y]}),t[28]=g,t[29]=y,t[30]=b):b=t[30];let x;return t[31]!==b||t[32]!==f?(x=(0,Q.jsxs)(Q.Fragment,{children:[f,b]}),t[31]=b,t[32]=f,t[33]=x):x=t[33],x}function BC(e,t){let n=wc(e),r=kc(e.durationMs),i=RC[n],a=i.Icon;return(0,Q.jsxs)(`li`,{className:`flex h-7 min-w-0 items-center gap-2 text-ui leading-4.5`,children:[(0,Q.jsx)(a,{role:`img`,"aria-label":i.label,className:Tn(`size-3.5 shrink-0`,i.color)}),(0,Q.jsx)(v,{text:e.name,className:`min-w-0 flex-1`}),r&&(0,Q.jsx)(`span`,{className:`shrink-0 text-xs leading-4 text-muted-foreground tabular-nums`,children:r}),e.detailsUrl&&(0,Q.jsxs)(y,{children:[(0,Q.jsxs)(Gt,{render:(0,Q.jsx)(`a`,{href:e.detailsUrl,target:`_blank`,rel:`noreferrer`,"aria-label":`Details for ${e.name} on GitHub`,className:D({variant:`ghost`,size:`sm`})}),children:[`Details`,(0,Q.jsx)(A,{"aria-hidden":`true`,className:`size-2.75`})]}),(0,Q.jsxs)(m,{children:[`Details for `,e.name,` on GitHub`]})]})]},`${e.name}:${t}`)}function VC(e){let t=(0,$.c)(20),{reason:n,retrying:r,onRetry:i}=e,a=At(),o;t[0]===n?o=t[1]:(o=Pc(n),t[0]=n,t[1]=o);let{description:s,action:c}=o,l;t[2]!==i||t[3]!==r?(l=(0,Q.jsx)(X,{variant:`outline`,disabled:r,onClick:i,children:`Try again`}),t[2]=i,t[3]=r,t[4]=l):l=t[4];let u=l;if(c.kind===`settings`){let e;t[5]===a?e=t[6]:(e=()=>void a({to:`/settings/$section`,params:{section:`git`}}),t[5]=a,t[6]=e);let n;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(Yi,{}),t[7]=n):n=t[7];let r;t[8]!==c.label||t[9]!==e?(r=(0,Q.jsxs)(X,{variant:`outline`,onClick:e,children:[n,c.label]}),t[8]=c.label,t[9]=e,t[10]=r):r=t[10],u=r}if(c.kind===`install`){let e;t[11]===c.url?e=t[12]:(e=(0,Q.jsx)(`a`,{href:c.url,target:`_blank`,rel:`noreferrer`}),t[11]=c.url,t[12]=e);let n;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(A,{}),t[13]=n):n=t[13];let r;t[14]!==c.label||t[15]!==e?(r=(0,Q.jsxs)(X,{variant:`outline`,nativeButton:!1,render:e,children:[n,c.label]}),t[14]=c.label,t[15]=e,t[16]=r):r=t[16],u=r}let d;return t[17]!==u||t[18]!==s?(d=(0,Q.jsx)(gr,{role:`alert`,message:s,action:u}),t[17]=u,t[18]=s,t[19]=d):d=t[19],d}function HC(e){return Number.isFinite(Date.parse(e))?wn(e):`unknown time`}function UC(e){let t=(0,$.c)(51),{scope:n,context:r,document:i,onOpen:a,onBrowse:o,sideLabel:s,active:c,hidden:l,base:u,toolbarTarget:d,review:f,walkthroughCode:p,fileTarget:m}=e,h=c!==void 0&&c,g=l!==void 0&&l,_=n.worktreeId,v;t[0]===i?v=t[1]:(v=Yy(i),t[0]=i,t[1]=v);let y;t[2]!==h||t[3]!==m||t[4]!==g||t[5]!==n.worktreeId||t[6]!==v||t[7]!==d?(y={toolbarTarget:d,active:h,worktreeId:_,entry:v,fileTarget:m,hidden:g},t[2]=h,t[3]=m,t[4]=g,t[5]=n.worktreeId,t[6]=v,t[7]=d,t[8]=y):y=t[8];let b;t[9]!==u||t[10]!==r||t[11]!==o||t[12]!==a||t[13]!==n||t[14]!==s||t[15]!==y?(b={base:u,scope:n,context:r,onOpen:a,onBrowse:o,sideLabel:s,interaction:y},t[9]=u,t[10]=r,t[11]=o,t[12]=a,t[13]=n,t[14]=s,t[15]=y,t[16]=b):b=t[16];let x=b;switch(i.kind){case`review`:{let e;return t[17]!==f||t[18]!==x?(e=f?(0,Q.jsx)(f,{...x}):null,t[17]=f,t[18]=x,t[19]=e):e=t[19],e}case`all-changes`:{let e;return t[20]===x?e=t[21]:(e=(0,Q.jsx)(YC,{...x}),t[20]=x,t[21]=e),e}case`specs`:{let e;return t[22]===x?e=t[23]:(e=(0,Q.jsx)(XC,{...x,specsOnly:!0}),t[22]=x,t[23]=e),e}case`change`:{let e;return t[24]!==i.path||t[25]!==x?(e=(0,Q.jsx)($C,{...x,path:i.path}),t[24]=i.path,t[25]=x,t[26]=e):e=t[26],e}case`file`:{let e;return t[27]!==i.path||t[28]!==x?(e=(0,Q.jsx)(IS,{...x,path:i.path}),t[27]=i.path,t[28]=x,t[29]=e):e=t[29],e}case`commit`:{let e;return t[30]!==i.oid||t[31]!==x?(e=(0,Q.jsx)(hS,{...x,oid:i.oid}),t[30]=i.oid,t[31]=x,t[32]=e):e=t[32],e}case`branch`:{let e;return t[33]===x?e=t[34]:(e=(0,Q.jsx)(aS,{...x}),t[33]=x,t[34]=e),e}case`branch-file`:{let e;return t[35]!==i.path||t[36]!==x?(e=(0,Q.jsx)(oS,{...x,path:i.path}),t[35]=i.path,t[36]=x,t[37]=e):e=t[37],e}case`walkthrough-step`:{let e;return t[38]!==p||t[39]!==i||t[40]!==x?(e=p?(0,Q.jsx)(p,{...x,document:i}):null,t[38]=p,t[39]=i,t[40]=x,t[41]=e):e=t[41],e}case`timeline`:{let e;return t[42]!==i.path||t[43]!==x?(e=(0,Q.jsx)(qC,{...x,path:i.path}),t[42]=i.path,t[43]=x,t[44]=e):e=t[44],e}case`graph`:{let e;return t[45]===x?e=t[46]:(e=(0,Q.jsx)(KC,{...x}),t[45]=x,t[46]=e),e}case`pull-request`:{let e;return t[47]!==r||t[48]!==i||t[49]!==d?(e=(0,Q.jsx)(WC,{document:i,context:r,toolbarTarget:d}),t[47]=r,t[48]=i,t[49]=d,t[50]=e):e=t[50],e}}}function WC(e){let t=(0,$.c)(15),{document:n,context:r,toolbarTarget:i}=e,a=vr(),o=N(),s=n.environmentId??r.connection.environmentId,l;if(t[0]!==s||t[1]!==o){let e;t[3]===s?e=t[4]:(e=e=>e.connection.environmentId===s,t[3]=s,t[4]=e),l=o.find(e),t[0]=s,t[1]=o,t[2]=l}else l=t[2];let u=l,d;t[5]!==s||t[6]!==a||t[7]!==u?(d=s===a.connection.environmentId?a:u&&{connection:u.connection,remoteStatus:c(s)},t[5]=s,t[6]=a,t[7]=u,t[8]=d):d=t[8];let f=d;if(!f){let e;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(gr,{message:`Pair this pull request's computer in Settings to read it.`}),t[9]=e):e=t[9],e}let p;return t[10]!==n||t[11]!==a.connection.environmentId||t[12]!==f||t[13]!==i?(p=(0,Q.jsx)(GC,{document:n,context:f,localEnvironmentId:a.connection.environmentId,toolbarTarget:i}),t[10]=n,t[11]=a.connection.environmentId,t[12]=f,t[13]=i,t[14]=p):p=t[14],p}function GC(e){let t=(0,$.c)(17),{document:n,context:r,localEnvironmentId:i,toolbarTarget:a}=e,o=At(),s=lx(r.connection,n.projectId,n.number),c;t[0]!==s||t[1]!==r.connection||t[2]!==i||t[3]!==o?(c=e=>{if(!s){o({to:`/`});return}let t=s,n={entry:Yy(e)};o(r.connection.environmentId===i?{to:`/$projectId/$worktreeId`,params:t,search:n}:{to:`/remotes/$environmentId/$projectId/$worktreeId`,params:{...t,environmentId:r.connection.environmentId},search:n})},t[0]=s,t[1]=r.connection,t[2]=i,t[3]=o,t[4]=c):c=t[4];let l=c,u;t[5]===l?u=t[6]:(u=()=>l({kind:`review`}),t[5]=l,t[6]=u);let d;t[7]!==s||t[8]!==l?(d=s?e=>l({kind:`file`,path:e}):void 0,t[7]=s,t[8]=l,t[9]=d):d=t[9];let f;return t[10]!==r||t[11]!==n.number||t[12]!==n.projectId||t[13]!==u||t[14]!==d||t[15]!==a?(f=(0,Q.jsx)(AC,{projectId:n.projectId,number:n.number,context:r,toolbarTarget:a,onBack:u,onFile:d}),t[10]=r,t[11]=n.number,t[12]=n.projectId,t[13]=u,t[14]=d,t[15]=a,t[16]=f):f=t[16],f}function KC(e){let t=(0,$.c)(7),{scope:n,context:r,onOpen:i,sideLabel:a}=e,o;t[0]===i?o=t[1]:(o=(e,t)=>i({kind:`commit`,oid:e},{toSide:t===!0}),t[0]=i,t[1]=o);let s;return t[2]!==r.connection||t[3]!==n||t[4]!==a||t[5]!==o?(s=(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,Q.jsx)(Vv,{scope:n,connection:r.connection,sideLabel:a,onSelect:o})}),t[2]=r.connection,t[3]=n,t[4]=a,t[5]=o,t[6]=s):s=t[6],s}function qC(e){let t=(0,$.c)(17),{scope:n,context:r,path:i,onOpen:a,sideLabel:o}=e,s=`Timeline of ${i}`,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(Ir,{className:`size-4 shrink-0`}),t[0]=c):c=t[0];let l;t[1]===i?l=t[2]:(l=(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[c,(0,Q.jsx)(v,{text:i})]}),t[1]=i,t[2]=l);let u;t[3]!==s||t[4]!==l?(u=(0,Q.jsx)(Ux,{titleLabel:s,title:l,subtitle:`Commits that changed this file`}),t[3]=s,t[4]=l,t[5]=u):u=t[5];let d;t[6]===a?d=t[7]:(d=(e,t)=>a({kind:`commit`,oid:e.oid},{path:e.path,toSide:t===!0}),t[6]=a,t[7]=d);let f;t[8]!==r.connection||t[9]!==i||t[10]!==n||t[11]!==o||t[12]!==d?(f=(0,Q.jsx)(Uv,{scope:n,connection:r.connection,path:i,sideLabel:o,onSelect:d}),t[8]=r.connection,t[9]=i,t[10]=n,t[11]=o,t[12]=d,t[13]=f):f=t[13];let p;return t[14]!==u||t[15]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[u,f]}),t[14]=u,t[15]=f,t[16]=p):p=t[16],p}function JC(e,t){return fe(t,e?`uncommitted spec change`:`uncommitted change`)}function YC(e){let t=(0,$.c)(11),{connection:n}=e.context,r;t[0]!==n.environmentId||t[1]!==e.scope.projectId||t[2]!==e.scope.worktreeId?(r=Bb(JSON.stringify([n.environmentId,e.scope.projectId,e.scope.worktreeId,`all-changes`])),t[0]=n.environmentId,t[1]=e.scope.projectId,t[2]=e.scope.worktreeId,t[3]=r):r=t[3];let[i,a]=Pn(r),o;t[4]!==a||t[5]!==i?(o=()=>a(i+25),t[4]=a,t[5]=i,t[6]=o):o=t[6];let s;return t[7]!==e||t[8]!==i||t[9]!==o?(s=(0,Q.jsx)(XC,{...e,limit:i,onReadMore:o}),t[7]=e,t[8]=i,t[9]=o,t[10]=s):s=t[10],s}function XC(e){let t=(0,$.c)(63),{scope:n,context:r,interaction:i,onBrowse:a,specsOnly:o,only:s,heading:c,fullHeight:l,limit:u,onReadMore:d}=e,f=o!==void 0&&o,[p,m]=(0,Z.useState)(!1),{connection:h}=r;fx(n,r);let g=px(n,r,YS(Ds(n,h),i.hidden===!0)),_;t[0]!==s||t[1]!==f?(_=e=>s?s.includes(e):!f||yd(e),t[0]=s,t[1]=f,t[2]=_):_=t[2];let v=_,y,b,x,S,C,w,T,E,D,O,k,A;if(t[3]!==p||t[4]!==g||t[5]!==r||t[6]!==l||t[7]!==c||t[8]!==v||t[9]!==i||t[10]!==u||t[11]!==a||t[12]!==s||t[13]!==n||t[14]!==f){C=Symbol.for(`react.early_return_sentinel`);bb0:{let e;if(t[27]===v?e=t[28]:(e=e=>v(e.path),t[27]=v,t[28]=e),b=g.filter(e),x=u===void 0?b:b.slice(0,u),S=c!==void 0,!f&&b.length===0&&p&&m(!1),s&&b.length===0){let e;t[29]===c?e=t[30]:(e=c&&(0,Q.jsx)(Ux,{inline:!0,title:c.title,titleLabel:c.titleLabel,children:c.after}),t[29]=c,t[30]=e);let n;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(`p`,{className:`p-5 text-prose text-foreground-2`,children:`Nothing uncommitted in this step.`}),t[31]=n):n=t[31];let r;t[32]===e?r=t[33]:(r=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[e,n]}),t[32]=e,t[33]=r),C=r;break bb0}if(!f&&b.length===0){let e;t[34]===a?e=t[35]:(e=(0,Q.jsx)(QC,{onBrowse:a}),t[34]=a,t[35]=e),C=e;break bb0}A=`flex min-h-0 flex-1 flex-col`,y=ZS,w=l,T=n,E=r,D=i,O=u,k=f||s||u!==void 0?{paths:x.map(ZC)}:{}}t[3]=p,t[4]=g,t[5]=r,t[6]=l,t[7]=c,t[8]=v,t[9]=i,t[10]=u,t[11]=a,t[12]=s,t[13]=n,t[14]=f,t[15]=y,t[16]=b,t[17]=x,t[18]=S,t[19]=C,t[20]=w,t[21]=T,t[22]=E,t[23]=D,t[24]=O,t[25]=k,t[26]=A}else y=t[15],b=t[16],x=t[17],S=t[18],C=t[19],w=t[20],T=t[21],E=t[22],D=t[23],O=t[24],k=t[25],A=t[26];if(C!==Symbol.for(`react.early_return_sentinel`))return C;let j=!S,M;t[36]!==p||t[37]!==b||t[38]!==r||t[39]!==c||t[40]!==n||t[41]!==x||t[42]!==S||t[43]!==f?(M=S?{toolbar:e=>(0,Q.jsxs)(Ux,{inline:!0,...c?{title:c.title,titleLabel:c.titleLabel}:{title:`All changes`},subtitle:JC(f,b.length),children:[e,c?.after]})}:{header:e=>(0,Q.jsx)(`div`,{className:`pt-6`,children:(0,Q.jsx)(ES,{scope:n,context:r,label:JC(f,b.length),items:b,rows:x.length,controls:e,actionsOpen:p,onActionsOpenChange:m,actions:(0,Q.jsx)($x,{scope:n,context:r,entries:b})})})},t[36]=p,t[37]=b,t[38]=r,t[39]=c,t[40]=n,t[41]=x,t[42]=S,t[43]=f,t[44]=M):M=t[44];let N;t[45]!==y||t[46]!==j||t[47]!==M||t[48]!==w||t[49]!==T||t[50]!==E||t[51]!==D||t[52]!==O||t[53]!==k?(N=(0,Q.jsx)(y,{fullHeight:w,scope:T,context:E,interaction:D,windowLimit:O,...k,column:j,...M}),t[45]=y,t[46]=j,t[47]=M,t[48]=w,t[49]=T,t[50]=E,t[51]=D,t[52]=O,t[53]=k,t[54]=N):N=t[54];let P;t[55]!==b||t[56]!==d||t[57]!==x?(P=d&&(0,Q.jsx)(Wx,{more:b.length-x.length,total:b.length,pending:!1,onReadMore:d}),t[55]=b,t[56]=d,t[57]=x,t[58]=P):P=t[58];let F;return t[59]!==N||t[60]!==P||t[61]!==A?(F=(0,Q.jsxs)(`div`,{className:A,children:[N,P]}),t[59]=N,t[60]=P,t[61]=A,t[62]=F):F=t[62],F}function ZC(e){return e.path}function QC(e){let t=(0,$.c)(5),{onBrowse:n}=e,r;t[0]===n?r=t[1]:(r=e=>n(`files`,e.currentTarget),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(Os,{children:oc(Ys.surfaceFiles)}),t[2]=i):i=t[2];let a;return t[3]===r?a=t[4]:(a=(0,Q.jsx)(`div`,{className:`mx-auto w-full max-w-xl`,children:(0,Q.jsx)(gr,{message:`No changes to review.`,action:(0,Q.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:r,children:[`Files `,i]})})}),t[3]=r,t[4]=a),a}function $C(e){let t=(0,$.c)(14),{scope:n,context:r,interaction:i,onOpen:a,path:o}=e,{connection:s}=r;fx(n,r);let c=Ds(n,s),l;if(t[0]===o?l=t[1]:(l=[o],t[0]=o,t[1]=l),!px(n,r,c,l).find(e=>e.path===o)){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(gr,{message:`This change is no longer present.`}),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,Q.jsx)(ZS,{headerActions:(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsx)(ux,{label:`Timeline`,iconOnly:!0,icon:Ir,onClick:()=>a({kind:`timeline`,path:o})})}),headerLeading:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(X,{variant:`ghost`,size:`xs`,"aria-label":`Open file`,onClick:()=>a({kind:`file`,path:o}),children:[(0,Q.jsx)(El,{}),(0,Q.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,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,Q.jsx)(d_,{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 ew(e){let t=(0,$.c)(80),{scope:n,connection:r,base:i,onBase:a,compact:o}=e,s=o!==void 0&&o,[c,l]=(0,Z.useState)(!1),u=cs(n,r,c),d=Ga(n,r,i),f,p,m,g,_,y,b,x,S,C,w,T,E,D,O;if(t[0]!==i||t[1]!==u.refresh||t[2]!==u.result||t[3]!==s||t[4]!==d.result||t[5]!==a||t[6]!==c){let e=ne(J(u.result)),n;t[22]===d.result?n=t[23]:(n=ne(J(d.result)),t[22]=d.result,t[23]=n);let r=i??n?.base?.ref,o;t[24]===r?o=t[25]:(o=r===void 0?`the default branch`:U_(r),t[24]=r,t[25]=o);let k=o,A=e?.defaultRef??null,j=i??A,M=[{heading:`Local`,entries:e?.bases.filter(rw)??[]},{heading:`Remote`,entries:e?.bases.filter(nw)??[]}].filter(tw),N=e=>{a(e===A?void 0:e),l(!1)};g=sn,_=c,y=l;let P=s?`max-w-24 @min-3xl/pane:max-w-40`:`w-full`,F;t[26]===P?F=t[27]:(F=Tn(`justify-between`,P),t[26]=P,t[27]=F);let I=`Compare against ${k}`,L;t[28]!==F||t[29]!==I?(L=(0,Q.jsx)(X,{variant:`outline`,size:`sm`,className:F,"aria-label":I,title:`Choose the branch this one is compared against`}),t[28]=F,t[29]=I,t[30]=L):L=t[30];let R=s&&`hidden @min-3xl/pane:block`,z;t[31]===R?z=t[32]:(z=Tn(`size-3.5 shrink-0 text-muted-foreground`,R),t[31]=R,t[32]=z);let B;t[33]===z?B=t[34]:(B=(0,Q.jsx)(yi,{className:z}),t[33]=z,t[34]=B);let V=`Against ${k}`,H=s&&`hidden @min-3xl/pane:inline`,U;t[35]===H?U=t[36]:(U=Tn(`text-muted-foreground`,H),t[35]=H,t[36]=U);let W;t[37]===U?W=t[38]:(W=(0,Q.jsxs)(`span`,{className:U,children:[`Against`,` `]}),t[37]=U,t[38]=W);let G;t[39]!==k||t[40]!==V||t[41]!==W?(G=(0,Q.jsxs)(v,{text:V,children:[W,k]}),t[39]=k,t[40]=V,t[41]=W,t[42]=G):G=t[42];let K;t[43]!==B||t[44]!==G?(K=(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[B,G]}),t[43]=B,t[44]=G,t[45]=K):K=t[45];let q;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,Q.jsx)(vl,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[46]=q):q=t[46],t[47]!==L||t[48]!==K?(b=(0,Q.jsxs)(Fn,{render:L,children:[K,q]}),t[47]=L,t[48]=K,t[49]=b):b=t[49],m=On,D=`start`,O=`w-72`,p=Ui,t[50]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Q.jsx)(Ji,{"aria-label":`Find a base branch`,placeholder:`Find a branch`}),t[50]=E):E=t[50],f=Fr,x=`Base branches`,t[51]===u.result?S=t[52]:(S=se(u.result)&&(0,Q.jsx)(`p`,{className:`p-3`,children:(0,Q.jsx)(ee,{label:`Reading branches`})}),t[51]=u.result,t[52]=S),t[53]!==u.refresh||t[54]!==u.result?(C=h(u.result)&&(0,Q.jsxs)(`div`,{className:`p-3 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`block`,children:`The branches could not be read.`}),(0,Q.jsx)(X,{variant:`outline`,size:`xs`,className:`mt-2`,onClick:u.refresh,children:`Try again`})]}),t[53]=u.refresh,t[54]=u.result,t[55]=C):C=t[55],t[56]===u.result?w=t[57]:(w=Kt(u.result)&&(0,Q.jsx)(Ar,{children:`No branch matches.`}),t[56]=u.result,t[57]=w),T=M.map(e=>(0,Q.jsx)(ps,{heading:e.heading,children:e.entries.map(e=>(0,Q.jsxs)(zr,{value:e.name,"data-checked":e.ref===j,onSelect:()=>N(e.ref),children:[(0,Q.jsx)(v,{text:e.name}),e.ref===A&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`default`})]},e.ref))},e.heading)),t[0]=i,t[1]=u.refresh,t[2]=u.result,t[3]=s,t[4]=d.result,t[5]=a,t[6]=c,t[7]=f,t[8]=p,t[9]=m,t[10]=g,t[11]=_,t[12]=y,t[13]=b,t[14]=x,t[15]=S,t[16]=C,t[17]=w,t[18]=T,t[19]=E,t[20]=D,t[21]=O}else f=t[7],p=t[8],m=t[9],g=t[10],_=t[11],y=t[12],b=t[13],x=t[14],S=t[15],C=t[16],w=t[17],T=t[18],E=t[19],D=t[20],O=t[21];let k;t[58]!==f||t[59]!==x||t[60]!==S||t[61]!==C||t[62]!==w||t[63]!==T?(k=(0,Q.jsxs)(f,{"aria-label":x,children:[S,C,w,T]}),t[58]=f,t[59]=x,t[60]=S,t[61]=C,t[62]=w,t[63]=T,t[64]=k):k=t[64];let A;t[65]!==p||t[66]!==k||t[67]!==E?(A=(0,Q.jsxs)(p,{children:[E,k]}),t[65]=p,t[66]=k,t[67]=E,t[68]=A):A=t[68];let j;t[69]!==m||t[70]!==A||t[71]!==D||t[72]!==O?(j=(0,Q.jsx)(m,{align:D,className:O,children:A}),t[69]=m,t[70]=A,t[71]=D,t[72]=O,t[73]=j):j=t[73];let M;return t[74]!==g||t[75]!==_||t[76]!==y||t[77]!==b||t[78]!==j?(M=(0,Q.jsxs)(g,{open:_,onOpenChange:y,children:[b,j]}),t[74]=g,t[75]=_,t[76]=y,t[77]=b,t[78]=j,t[79]=M):M=t[79],M}function tw(e){return e.entries.length>0}function nw(e){return e.remote}function rw(e){return!e.remote}function iw(e,t){let n=(0,$.c)(6),r;n[0]===e?r=n[1]:(r=Ge(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=Bn(r,i),o;return n[3]!==a||n[4]!==t?(o=e=>{a(t).then(t=>{qt(t)&&e()})},n[3]=a,n[4]=t,n[5]=o):o=n[5],o}var aw=class extends Z.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}render(){return this.state.error?(0,Q.jsx)(pe,{description:ws(this.state.error),onRetry:()=>this.props.reset(()=>this.setState({error:null}))}):this.props.children}};function ow(e){let t=(0,$.c)(9),{children:n,connection:r,scope:i,quiet:a,documentKey:o}=e,s=a!==void 0&&a,c=iw(r,i),u;t[0]===s?u=t[1]:(u=s?null:(0,Q.jsx)(l,{label:`Loading review`}),t[0]=s,t[1]=u);let d;t[2]!==n||t[3]!==o||t[4]!==c?(d=(0,Q.jsx)(aw,{reset:c,children:n},o),t[2]=n,t[3]=o,t[4]=c,t[5]=d):d=t[5];let f;return t[6]!==u||t[7]!==d?(f=(0,Q.jsx)(Z.Suspense,{fallback:u,children:d}),t[6]=u,t[7]=d,t[8]=f):f=t[8],f}function sw(e){let t=(0,$.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({layout:n,onSurface:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=uw(),t[4]=a):a=t[4];let o;t[5]===i?o=t[6]:(o=e=>(0,Q.jsx)(fw,{...i,actionsTarget:e}),t[5]=i,t[6]=o);let s;return t[7]!==n||t[8]!==r||t[9]!==i.surface||t[10]!==o?(s=(0,Q.jsx)(cw,{layout:n,surfaces:lw,names:a,published:!1,surface:i.surface,onSurface:r,children:o}),t[7]=n,t[8]=r,t[9]=i.surface,t[10]=o,t[11]=s):s=t[11],s}function cw(e){let t=(0,$.c)(19),{layout:n,surfaces:r,names:i,published:a,surface:o,onSurface:s,children:c}=e,{element:l,attach:u}=Ri(),d;t[0]===u?d=t[1]:(d=(0,Q.jsx)(`div`,{ref:u,className:`ml-auto flex shrink-0 items-center gap-0.5`}),t[0]=u,t[1]=d);let f=d,p;t[2]!==l||t[3]!==c?(p=c(l),t[2]=l,t[3]=c,t[4]=p):p=t[4];let m=p,h=n===`docked`&&`motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-right-1 duration-150`,g;t[5]===h?g=t[6]:(g=Tn(`flex h-full min-h-0 flex-col overflow-hidden rounded-paper bg-card shadow-paper`,h),t[5]=h,t[6]=g);let _;t[7]!==m||t[8]!==n||t[9]!==i||t[10]!==s||t[11]!==a||t[12]!==o||t[13]!==r||t[14]!==f?(_=n===`docked`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-1 border-b pr-2.5 pl-4`,children:[(0,Q.jsx)(v,{className:`text-ui leading-5 font-semibold`,render:(0,Q.jsx)(`h2`,{}),text:i[o]}),f]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 text-sm`,children:m})]}):(0,Q.jsxs)(Rc,{value:o,onValueChange:e=>{Fo(e)&&s(e)},className:`min-h-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center gap-1 border-b px-1.5`,children:[(0,Q.jsx)(Dc,{className:`h-8 min-w-0 flex-1`,children:r.map(e=>(0,Q.jsx)(v,{propagateEscape:!0,text:i[e],renderTrigger:t=>(0,Q.jsxs)(Hc,{value:e,className:`min-w-0`,children:[(0,Q.jsx)(dw,{published:a,surface:e,className:`size-3.5 shrink-0`}),t]})},e))}),f]}),(0,Q.jsx)(hc,{value:o,className:`min-h-0 overflow-hidden`,children:m})]}),t[7]=m,t[8]=n,t[9]=i,t[10]=s,t[11]=a,t[12]=o,t[13]=r,t[14]=f,t[15]=_):_=t[15];let y;return t[16]!==g||t[17]!==_?(y=(0,Q.jsx)(`aside`,{"aria-label":`Review sidebar`,"data-testid":`review-sidebar`,className:g,children:_}),t[16]=g,t[17]=_,t[18]=y):y=t[18],y}var lw=[`files`,`changes`,`history`];function uw(){return $y}function dw(e){let t=(0,$.c)(7),{published:n,surface:r,className:i}=e;if(r===`files`){let e;return t[0]===i?e=t[1]:(e=(0,Q.jsx)(Ol,{className:i}),t[0]=i,t[1]=e),e}if(r===`history`){let e;return t[2]===i?e=t[3]:(e=(0,Q.jsx)(Ir,{className:i}),t[2]=i,t[3]=e),e}let a;return t[4]!==i||t[5]!==n?(a=n?(0,Q.jsx)(Wl,{className:i}):(0,Q.jsx)(Ci,{className:i}),t[4]=i,t[5]=n,t[6]=a):a=t[6],a}function fw(e){let t=(0,$.c)(38),{changesNavigation:n,scope:r,context:i,worktreePath:a,surface:o,activeEntry:s,available:c,onOpen:l,onFilesMoved:u,onFilesRemoved:d,sideLabel:f,changes:p,actionsTarget:m}=e;if(!c){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(`div`,{className:`p-3`,children:(0,Q.jsx)(gr,{message:`This worktree is unavailable.`})}),t[0]=e):e=t[0],e}let h=`${r.worktreeId}:${o}`,g;t[1]!==n||t[2]!==s||t[3]!==p||t[4]!==i||t[5]!==l||t[6]!==r||t[7]!==f||t[8]!==o?(g=o===`changes`&&(0,Q.jsx)(n,{scope:r,context:i,activeEntry:s,onOpen:l,sideLabel:f,changeScope:p.scope,base:p.base,onChangeScope:p.onScope,onBase:p.onBase}),t[1]=n,t[2]=s,t[3]=p,t[4]=i,t[5]=l,t[6]=r,t[7]=f,t[8]=o,t[9]=g):g=t[9];let _;t[10]!==m||t[11]!==s||t[12]!==i||t[13]!==u||t[14]!==d||t[15]!==l||t[16]!==r||t[17]!==f||t[18]!==o||t[19]!==a?(_=o===`files`&&(0,Q.jsx)(Va,{scope:r,context:i,worktreePath:a,selected:s?.startsWith(`file:`)?s.slice(5):``,onOpen:l,onMoved:u,onTrashed:d,sideLabel:f,actionsTarget:m}),t[10]=m,t[11]=s,t[12]=i,t[13]=u,t[14]=d,t[15]=l,t[16]=r,t[17]=f,t[18]=o,t[19]=a,t[20]=_):_=t[20];let v;t[21]!==s||t[22]!==i.connection||t[23]!==l||t[24]!==r||t[25]!==f||t[26]!==o?(v=o===`history`&&(0,Q.jsx)(Lv,{scope:r,connection:i.connection,selected:s?.startsWith(`commit:`)?s.slice(7):``,onSelect:(e,t)=>l({kind:`commit`,oid:e},{toSide:t===!0,preserveFocus:!0}),sideLabel:f,onOpenGraph:()=>l({kind:`graph`}),onOpenChanges:()=>l(Gy)}),t[21]=s,t[22]=i.connection,t[23]=l,t[24]=r,t[25]=f,t[26]=o,t[27]=v):v=t[27];let y;t[28]!==i.connection||t[29]!==r||t[30]!==h||t[31]!==g||t[32]!==_||t[33]!==v?(y=(0,Q.jsxs)(ow,{connection:i.connection,scope:r,quiet:!0,children:[g,_,v]},h),t[28]=i.connection,t[29]=r,t[30]=h,t[31]=g,t[32]=_,t[33]=v,t[34]=y):y=t[34];let b=y,x;return t[35]!==b||t[36]!==o?(x=o===`changes`?(0,Q.jsx)(si,{className:`h-full`,children:b}):(0,Q.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:b}),t[35]=b,t[36]=o,t[37]=x):x=t[37],x}var pw={files:Ys.surfaceFiles,changes:Ys.surfaceChanges,history:Ys.surfaceHistory};function mw(e){let t=(0,$.c)(32),{surfaces:n,names:r,published:i,surface:a,open:o,onSelect:s,onHide:c,onToggle:l,toggleRef:u}=e,d=o?`Hide side panel`:`Show side panel`,f;if(t[0]!==r||t[1]!==c||t[2]!==s||t[3]!==o||t[4]!==i||t[5]!==a||t[6]!==n){let e;t[8]!==r||t[9]!==c||t[10]!==s||t[11]!==o||t[12]!==i||t[13]!==a?(e=e=>{let t=o&&a===e;return(0,Q.jsx)(`span`,{"data-selected":t||void 0,className:`workspace-choice inline-flex rounded-lg data-selected:text-foreground`,children:(0,Q.jsxs)(y,{children:[(0,Q.jsx)(Gt,{render:(0,Q.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":r[e],"aria-pressed":t,"aria-keyshortcuts":pw[e],onClick:()=>t?c():s(e)}),children:(0,Q.jsx)(dw,{published:i,surface:e})}),(0,Q.jsxs)(m,{side:`left`,children:[r[e],` `,(0,Q.jsx)(Os,{children:oc(pw[e])})]})]})},e)},t[8]=r,t[9]=c,t[10]=s,t[11]=o,t[12]=i,t[13]=a,t[14]=e):e=t[14],f=n.map(e),t[0]=r,t[1]=c,t[2]=s,t[3]=o,t[4]=i,t[5]=a,t[6]=n,t[7]=f}else f=t[7];let p;t[15]!==l||t[16]!==o||t[17]!==d||t[18]!==u?(p=(0,Q.jsx)(X,{ref:u,variant:`ghost`,size:`icon`,className:`mt-auto`,"aria-label":d,"aria-expanded":o,"aria-keyshortcuts":Ys.toggleSidebar,onClick:l}),t[15]=l,t[16]=o,t[17]=d,t[18]=u,t[19]=p):p=t[19];let h;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Q.jsx)(Jl,{}),t[20]=h):h=t[20];let g;t[21]===p?g=t[22]:(g=(0,Q.jsx)(Gt,{render:p,children:h}),t[21]=p,t[22]=g);let _;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(Os,{children:oc(Ys.toggleSidebar)}),t[23]=_):_=t[23];let v;t[24]===d?v=t[25]:(v=(0,Q.jsxs)(m,{side:`left`,children:[d,` `,_]}),t[24]=d,t[25]=v);let b;t[26]!==g||t[27]!==v?(b=(0,Q.jsxs)(y,{children:[g,v]}),t[26]=g,t[27]=v,t[28]=b):b=t[28];let x;return t[29]!==f||t[30]!==b?(x=(0,Q.jsxs)(`nav`,{"aria-label":`Side panel`,className:`flex w-11 shrink-0 flex-col items-center gap-1 pt-2.5 pb-2 pl-1 text-muted-foreground`,children:[f,b]}),t[29]=f,t[30]=b,t[31]=x):x=t[31],x}function hw(e){let t=(0,$.c)(175),{worktree:n,projectId:r,search:i,onSearch:a,context:o,navigationTrigger:s,review:c,changesNavigation:l,walkthroughCode:u,firstDocument:d}=e,{open:f,setOpen:p}=Gb(),[h,g]=(0,Z.useState)(!1),_=Hy(),[v,b]=(0,Z.useState)(_);v!==_&&(b(_),_&&h&&(p(!0),g(!1)));let x=Ri(),S=Ri(),C=Ri(),{isMobile:w,open:T,openMobile:E}=Dt(),D=i.surface??(d.guided?`changes`:`files`),O;t[0]!==r||t[1]!==n.id?(O={projectId:r,worktreeId:n.id},t[0]=r,t[1]=n.id,t[2]=O):O=t[2];let k=O,{saved:A,focused:j,setFocused:M}=Rb(n.id),N=Fa(k,o.connection),P=Ga(d.guided&&i.scope===void 0?k:void 0,o.connection,i.base).result,F=ne(J(P))?.files.length===0&&(ne(J(N))?.changes.length??0)>0,I;t[3]===N?I=t[4]:(I=_e(J(N)),t[3]=N,t[4]=I);let L=I,R;t[5]!==A||t[6]!==i.entry||t[7]!==i.side?(R=!A&&!Xy(i.entry)&&!Xy(i.side),t[5]=A,t[6]=i.entry,t[7]=i.side,t[8]=R):R=t[8];let z=R,B=!z||!L&&!d.pending,V=d.guided||(ne(J(N))?.changes.length??0)>0?rb:null,H=h&&!_,U;t[9]!==V||t[10]!==j||t[11]!==C.element||t[12]!==a||t[13]!==B||t[14]!==i.entry||t[15]!==i.side||t[16]!==M||t[17]!==H||t[18]!==n.id?(U={worktreeId:n.id,entry:i.entry,side:i.side,onSearch:a,fallback:V,focused:j,setFocused:M,ready:B,focusBoundary:C.element,focusBoundaryOpen:H},t[9]=V,t[10]=j,t[11]=C.element,t[12]=a,t[13]=B,t[14]=i.entry,t[15]=i.side,t[16]=M,t[17]=H,t[18]=n.id,t[19]=U):U=t[19];let W=Yb(U),G;t[20]!==j||t[21]!==W.split?(G=wb(bw(W.split,j)),t[20]=j,t[21]=W.split,t[22]=G):G=t[22];let K=G,ee;t[23]!==f||t[24]!==x||t[25]!==p?(ee=()=>{f&&x.element?.focus(),p(_w)},t[23]=f,t[24]=x,t[25]=p,t[26]=ee):ee=t[26];let q=ee,te;t[27]!==_||t[28]!==q?(te=()=>{_?q():g(gw)},t[27]=_,t[28]=q,t[29]=te):te=t[29];let re;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(re={ignoreInputs:!0},t[30]=re):re=t[30],cc(Ys.toggleSidebar,te,re);let[ie,ae]=(0,Z.useState)(),oe;t[31]!==_||t[32]!==j||t[33]!==W?(oe=(e,t)=>{let n=Yy(e),r=+(j===0),i=t?.toSide?r:W.open(j,n,t?.preserveFocus===!0&&_);ae(t?.path?{path:t.path,nonce:Date.now(),pane:i,key:n}:void 0),t?.toSide&&W.openToSide(j,n),g(!1)},t[31]=_,t[32]=j,t[33]=W,t[34]=oe):oe=t[34];let se=oe,ce;t[35]===a?ce=t[36]:(ce=e=>{a({surface:e})},t[35]=a,t[36]=ce);let Y=ce,le;t[37]!==_||t[38]!==p||t[39]!==Y?(le=e=>{Y(e),_?p(!0):g(!0)},t[37]=_,t[38]=p,t[39]=Y,t[40]=le):le=t[40];let ue=le,de;t[41]===ue?de=t[42]:(de=()=>ue(`changes`),t[41]=ue,t[42]=de);let fe;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(fe={ignoreInputs:!0},t[43]=fe):fe=t[43],cc(Ys.surfaceChanges,de,fe);let pe;t[44]===ue?pe=t[45]:(pe=()=>ue(`files`),t[44]=ue,t[45]=pe);let me;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(me={ignoreInputs:!0},t[46]=me):me=t[46],cc(Ys.surfaceFiles,pe,me);let he;t[47]===ue?he=t[48]:(he=()=>ue(`history`),t[47]=ue,t[48]=he);let ge;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ge={ignoreInputs:!0},t[49]=ge):ge=t[49],cc(Ys.surfaceHistory,he,ge);let ve=Ri(),ye;t[50]!==ve||t[51]!==ue?(ye=(e,t)=>{ve.attach(t),ue(e)},t[50]=ve,t[51]=ue,t[52]=ye):ye=t[52];let be=ye,xe=i.scope??(d.guided&&!F?`branch`:`uncommitted`),Se,Ce;t[53]===a?(Se=t[54],Ce=t[55]):(Se=e=>a({scope:e}),Ce=e=>a({base:e}),t[53]=a,t[54]=Se,t[55]=Ce);let we,Te,Ee,De,Oe,ke,Ae,je,Me,Ne,Pe,Fe,Ie;if(t[56]!==be||t[57]!==ve||t[58]!==l||t[59]!==o||t[60]!==_||t[61]!==ie||t[62]!==d||t[63]!==j||t[64]!==W||t[65]!==h||t[66]!==C||t[67]!==S||t[68]!==s||t[69]!==w||t[70]!==T||t[71]!==E||t[72]!==z||t[73]!==a||t[74]!==se||t[75]!==N||t[76]!==f||t[77]!==x||t[78]!==c||t[79]!==k||t[80]!==i.base||t[81]!==p||t[82]!==Y||t[83]!==ue||t[84]!==K||t[85]!==D||t[86]!==xe||t[87]!==Se||t[88]!==Ce||t[89]!==q||t[90]!==u||t[91]!==n.available||t[92]!==n.path){let e={scope:xe,onScope:Se,onBase:Ce},r=W.panes[j]?.active??void 0,v=t=>(0,Q.jsx)(sw,{changesNavigation:l,layout:t,scope:k,context:o,worktreePath:n.path,surface:D,activeEntry:r,available:n.available,onSurface:Y,onOpen:se,onFilesMoved:(e,t)=>W.moveFiles(e,t),onFilesRemoved:e=>W.closeRemovedFiles(e),sideLabel:K,changes:{...e,base:i.base,onBase:e=>a({base:e})}}),b;t[106]!==ve||t[107]!==o||t[108]!==_||t[109]!==W||t[110]!==h||t[111]!==S||t[112]!==k?(b=e=>(0,Q.jsxs)(`div`,{"data-review-controls":``,className:`contents`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1 h-5 w-px bg-border`}),(0,Q.jsx)(Fy,{scope:k,context:o}),(0,Q.jsxs)(y,{children:[(0,Q.jsx)(Gt,{render:(0,Q.jsx)(X,{variant:`ghost`,size:`icon-sm`,ref:e=>S.attach(e),className:`xl:hidden`,"aria-label":`Review`,"aria-haspopup":`dialog`,"aria-expanded":h&&!_,"aria-keyshortcuts":Ys.toggleSidebar,onClick:()=>{ve.attach(null),W.selectPane(e),g(!0)},children:(0,Q.jsx)(Jl,{})})}),(0,Q.jsxs)(m,{role:`tooltip`,className:`break-all`,children:[`Review `,(0,Q.jsx)(Os,{children:oc(Ys.toggleSidebar)})]})]})]}),t[106]=ve,t[107]=o,t[108]=_,t[109]=W,t[110]=h,t[111]=S,t[112]=k,t[113]=b):b=t[113];let O=b,A;t[114]===se?A=t[115]:(A=e=>se({kind:`file`,path:e}),t[114]=se,t[115]=A),t[116]!==o.connection||t[117]!==W.bindQuickOpen||t[118]!==W.recentFiles||t[119]!==k||t[120]!==A?(Fe=(0,Q.jsx)(is,{bindPopup:W.bindQuickOpen,openFiles:W.recentFiles,scope:k,connection:o.connection,onOpen:A}),t[116]=o.connection,t[117]=W.bindQuickOpen,t[118]=W.recentFiles,t[119]=k,t[120]=A,t[121]=Fe):Fe=t[121];let M=w?0:480,P;t[122]!==o||t[123]!==k?(P=(0,Q.jsx)(Kg,{scope:k,context:o}),t[122]=o,t[123]=k,t[124]=P):P=t[124];let F;t[125]!==o||t[126]!==se||t[127]!==k?(F=(0,Q.jsx)(qg,{scope:k,context:o,onOpen:se}),t[125]=o,t[126]=se,t[127]=k,t[128]=F):F=t[128];let I=(0,Q.jsxs)(`section`,{"aria-label":`Review content`,className:`flex h-full min-w-0 flex-col overflow-hidden rounded-paper border bg-card`,children:[P,F,(0,Q.jsx)(vw,{review:c,walkthroughCode:u,firstDocument:d,changesNavigation:l,fileTarget:ie,scope:k,context:o,overview:N,needsDefault:z,layout:W,base:i.base,changes:e,focused:j,onOpen:se,onBrowse:be,navigationTrigger:s,navigatorIsMobile:w,navigatorOpen:T,navigatorOpenMobile:E,tabControls:O})]}),L;t[129]!==M||t[130]!==I?(L=(0,Q.jsx)(wa,{id:`review-document`,minSize:M,children:I}),t[129]=M,t[130]=I,t[131]=L):L=t[131];let R=f&&_&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(eo,{"aria-label":`Document panes and side panel`,className:`w-2 bg-transparent after:w-2`}),(0,Q.jsx)(wa,{id:`review-sidebar`,defaultSize:320,minSize:260,maxSize:520,children:v(`docked`)})]}),B;t[132]!==L||t[133]!==R?(B=(0,Q.jsxs)(ls,{orientation:`horizontal`,className:`min-h-0 flex-1`,children:[L,R]}),t[132]=L,t[133]=R,t[134]=B):B=t[134];let V;t[135]!==_||t[136]!==f||t[137]!==x||t[138]!==p||t[139]!==ue||t[140]!==D||t[141]!==q?(V=_&&(0,Q.jsx)(mw,{surfaces:lw,names:uw(),published:!1,surface:D,open:f,onSelect:ue,onHide:()=>p(!1),onToggle:q,toggleRef:e=>x.attach(e)}),t[135]=_,t[136]=f,t[137]=x,t[138]=p,t[139]=ue,t[140]=D,t[141]=q,t[142]=V):V=t[142],t[143]!==B||t[144]!==V?(Ie=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[B,V]}),t[143]=B,t[144]=V,t[145]=Ie):Ie=t[145],Te=qe,Me=h&&!_,Ne=g,t[146]===W?Pe=t[147]:(Pe=e=>{e||W.focusDestination()},t[146]=W,t[147]=Pe),we=Zn,t[148]!==W||t[149]!==C?(Ee=e=>{C.attach(e),e===null&&W.focusDestination()},t[148]=W,t[149]=C,t[150]=Ee):Ee=t[150],t[151]!==ve.element||t[152]!==W||t[153]!==C.element||t[154]!==S.element?(De=()=>{if(W.hasDestinationFocus())return!1;let e=document.activeElement;return e===document.body||C.element?.contains(e)?ve.element?.isConnected?ve.element:S.element:!1},t[151]=ve.element,t[152]=W,t[153]=C.element,t[154]=S.element,t[155]=De):De=t[155],Oe=`w-[min(90vw,22rem)]!`,ke=!1,t[156]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=(0,Q.jsxs)(at,{className:`sr-only`,children:[(0,Q.jsx)(ir,{children:`Worktree review`}),(0,Q.jsx)(lr,{children:`Choose a review surface and open a document.`})]}),t[156]=Ae):Ae=t[156],je=!_&&v(`sheet`),t[56]=be,t[57]=ve,t[58]=l,t[59]=o,t[60]=_,t[61]=ie,t[62]=d,t[63]=j,t[64]=W,t[65]=h,t[66]=C,t[67]=S,t[68]=s,t[69]=w,t[70]=T,t[71]=E,t[72]=z,t[73]=a,t[74]=se,t[75]=N,t[76]=f,t[77]=x,t[78]=c,t[79]=k,t[80]=i.base,t[81]=p,t[82]=Y,t[83]=ue,t[84]=K,t[85]=D,t[86]=xe,t[87]=Se,t[88]=Ce,t[89]=q,t[90]=u,t[91]=n.available,t[92]=n.path,t[93]=we,t[94]=Te,t[95]=Ee,t[96]=De,t[97]=Oe,t[98]=ke,t[99]=Ae,t[100]=je,t[101]=Me,t[102]=Ne,t[103]=Pe,t[104]=Fe,t[105]=Ie}else we=t[93],Te=t[94],Ee=t[95],De=t[96],Oe=t[97],ke=t[98],Ae=t[99],je=t[100],Me=t[101],Ne=t[102],Pe=t[103],Fe=t[104],Ie=t[105];let Le;t[157]!==we||t[158]!==Ee||t[159]!==De||t[160]!==Oe||t[161]!==ke||t[162]!==Ae||t[163]!==je?(Le=(0,Q.jsxs)(we,{ref:Ee,finalFocus:De,className:Oe,showCloseButton:ke,children:[Ae,je]}),t[157]=we,t[158]=Ee,t[159]=De,t[160]=Oe,t[161]=ke,t[162]=Ae,t[163]=je,t[164]=Le):Le=t[164];let Re;t[165]!==Te||t[166]!==Me||t[167]!==Ne||t[168]!==Pe||t[169]!==Le?(Re=(0,Q.jsx)(Te,{open:Me,onOpenChange:Ne,onOpenChangeComplete:Pe,children:Le}),t[165]=Te,t[166]=Me,t[167]=Ne,t[168]=Pe,t[169]=Le,t[170]=Re):Re=t[170];let ze;return t[171]!==Fe||t[172]!==Ie||t[173]!==Re?(ze=(0,Q.jsxs)(Q.Fragment,{children:[Fe,Ie,Re]}),t[171]=Fe,t[172]=Ie,t[173]=Re,t[174]=ze):ze=t[174],ze}function gw(e){return!e}function _w(e){return!e}function vw(e){let t=(0,$.c)(3),n=_e(J(e.overview));if(e.needsDefault&&n&&h(e.overview))throw ie(e.overview.cause);if(e.needsDefault&&(n||e.firstDocument.pending)){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(l,{label:`Loading review`}),t[0]=e):e=t[0],e}let r;return t[1]===e?r=t[2]:(r=(0,Q.jsx)(yw,{...e}),t[1]=e,t[2]=r),r}function yw(e){let t=(0,$.c)(51),{review:n,changesNavigation:r,walkthroughCode:i,firstDocument:a,layout:o,fileTarget:s,scope:c,context:l,base:u,changes:d,focused:f,onOpen:p,onBrowse:m,navigationTrigger:h,navigatorIsMobile:g,navigatorOpen:_,navigatorOpenMobile:v,tabControls:y}=e,b;t[0]!==f||t[1]!==o.panes?(b=o.panes[f]??{tabs:[],pinned:[],active:null},t[0]=f,t[1]=o.panes,t[2]=b):b=t[2];let x=b,S=_o()&&(o.split||f===0),C;t[3]===S?C=t[4]:(C={ignoreInputs:!0,enabled:S},t[3]=S,t[4]=C);let w=C,T;t[5]!==f||t[6]!==o?(T=()=>o.step(f,1),t[5]=f,t[6]=o,t[7]=T):T=t[7],cc(Ys.nextTab,T,w);let E;t[8]!==f||t[9]!==o?(E=()=>o.step(f,-1),t[8]=f,t[9]=o,t[10]=E):E=t[10],cc(Ys.previousTab,E,w);let D;t[11]!==f||t[12]!==x.active||t[13]!==o?(D=()=>x.active!==null&&x.active!==void 0&&o.close(f,x.active),t[11]=f,t[12]=x.active,t[13]=o,t[14]=D):D=t[14],cc(Ys.closeTab,D,w);let O;t[15]!==f||t[16]!==x.active||t[17]!==o?(O=()=>x.active!==null&&x.active!==void 0&&o.openToSide(f,x.active),t[15]=f,t[16]=x.active,t[17]=o,t[18]=O):O=t[18],cc(Ys.openToSide,O,w);let k;t[19]!==u||t[20]!==d||t[21]!==r||t[22]!==l||t[23]!==s||t[24]!==a||t[25]!==f||t[26]!==o||t[27]!==h||t[28]!==g||t[29]!==_||t[30]!==v||t[31]!==m||t[32]!==p||t[33]!==n||t[34]!==c||t[35]!==y||t[36]!==i?(k=e=>({review:n,changesNavigation:r,walkthroughCode:i,firstDocument:a,fileTarget:s,index:e,layout:o,split:o.split,focused:f===e,scope:c,context:l,base:u,changes:d,onOpen:p,onBrowse:m,navigationTrigger:h,navigatorIsMobile:g,navigatorOpen:_,navigatorOpenMobile:v,tabControls:y}),t[19]=u,t[20]=d,t[21]=r,t[22]=l,t[23]=s,t[24]=a,t[25]=f,t[26]=o,t[27]=h,t[28]=g,t[29]=_,t[30]=v,t[31]=m,t[32]=p,t[33]=n,t[34]=c,t[35]=y,t[36]=i,t[37]=k):k=t[37];let A=k,j=g?`vertical`:`horizontal`,M=g?200:320,N;t[38]===A?N=t[39]:(N=(0,Q.jsx)(xw,{...A(0)}),t[38]=A,t[39]=N);let P;t[40]!==M||t[41]!==N?(P=(0,Q.jsx)(wa,{id:`pane-left`,minSize:M,children:N}),t[40]=M,t[41]=N,t[42]=P):P=t[42];let F;t[43]!==o.split||t[44]!==g||t[45]!==A?(F=o.split&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(eo,{"aria-label":g?`Top and bottom document panes`:`Left and right document panes`,withHandle:!0}),(0,Q.jsx)(wa,{id:`pane-right`,minSize:g?200:320,children:(0,Q.jsx)(xw,{...A(1)})})]}),t[43]=o.split,t[44]=g,t[45]=A,t[46]=F):F=t[46];let I;return t[47]!==P||t[48]!==F||t[49]!==j?(I=(0,Q.jsxs)(ls,{orientation:j,className:`min-h-0 flex-1`,children:[P,F]}),t[47]=P,t[48]=F,t[49]=j,t[50]=I):I=t[50],I}function bw(e,t){return e?t===0?`left`:`right`:null}function xw(e){let t=(0,$.c)(99),{review:n,walkthroughCode:r,firstDocument:i,fileTarget:a,index:o,layout:s,split:c,focused:l,scope:u,context:d,base:f,changes:p,onOpen:h,onBrowse:g,navigationTrigger:_,navigatorIsMobile:v,navigatorOpen:b,navigatorOpenMobile:x,tabControls:S}=e,{element:C,attach:w}=Ri(),T;t[0]!==o||t[1]!==s.panes?(T=s.panes[o]??{tabs:[],pinned:[],active:null},t[0]=o,t[1]=s.panes,t[2]=T):T=t[2];let E=T,D=(0,Z.useDeferredValue)(E.active),O;t[3]!==D||t[4]!==E.active||t[5]!==E.tabs?(O=E.tabs.includes(D??``)?D:E.active,t[3]=D,t[4]=E.active,t[5]=E.tabs,t[6]=O):O=t[6];let k=O,A=k!==E.active,j=(0,Z.useId)(),[M,N]=(0,Z.useState)(!1);!M&&k===`review`&&N(!0);let P=k??void 0,F;t[7]===P?F=t[8]:(F=Xy(P),t[7]=P,t[8]=F);let I=F,L;t[9]!==o||t[10]!==s?(L=e=>{let t=e.target;t instanceof Element&&e.currentTarget.contains(t)&&t.closest(`[data-review-controls]`)===null&&(e.type===`pointerdown`?s.selectPane(o):s.focusPane(o,t))},t[9]=o,t[10]=s,t[11]=L):L=t[11];let R=L,z;t[12]!==o||t[13]!==s?(z=e=>s.bindPane(o,e),t[12]=o,t[13]=s,t[14]=z):z=t[14];let B=c?`${o===0?`Left`:`Right`} pane`:void 0,V=c&&o===1&&`border-l`,H=o===1&&`motion-safe:animate-in motion-safe:fade-in-0 duration-150`,U;t[15]!==V||t[16]!==H?(U=Tn(`@container/pane relative flex h-full min-h-0 min-w-0 flex-col`,V,H),t[15]=V,t[16]=H,t[17]=U):U=t[17];let W;t[18]===j?W=t[19]:(W=e=>ab(j,e),t[18]=j,t[19]=W);let G;t[20]!==d.connection||t[21]!==u?(G={connection:d.connection,scope:u},t[20]=d.connection,t[21]=u,t[22]=G):G=t[22];let K;t[23]!==o||t[24]!==_||t[25]!==v||t[26]!==b||t[27]!==x?(K=o===0?(0,Q.jsxs)(y,{children:[(0,Q.jsx)(Gt,{render:(0,Q.jsx)(`span`,{className:`inline-flex`}),children:(0,Q.jsx)(jt,{ref:e=>_.attach(e),"aria-label":`Toggle Sidebar`,"aria-expanded":v?x:b,"aria-keyshortcuts":Fs()===`mac`?`Meta+B`:`Control+B`,onClick:()=>{!v&&b&&requestAnimationFrame(()=>_.element?.focus())}})}),(0,Q.jsxs)(m,{role:`tooltip`,className:`break-all`,children:[`Toggle Sidebar`,` `,(0,Q.jsx)(Os,{children:oc(Ys.toggleNavigator)})]})]}):void 0,t[23]=o,t[24]=_,t[25]=v,t[26]=b,t[27]=x,t[28]=K):K=t[28];let ee=E.tabs,q=E.pinned,te;t[29]!==o||t[30]!==c?(te=bw(c,o),t[29]=o,t[30]=c,t[31]=te):te=t[31];let ne;t[32]!==o||t[33]!==s?(ne=tx(s,o),t[32]=o,t[33]=s,t[34]=ne):ne=t[34];let re;t[35]!==I?.kind||t[36]!==f||t[37]!==p||t[38]!==d.connection||t[39]!==i||t[40]!==u?(re=I?.kind===`branch`&&!i.guided&&(0,Q.jsx)(ew,{scope:u,connection:d.connection,base:f,onBase:p.onBase,compact:!0}),t[35]=I?.kind,t[36]=f,t[37]=p,t[38]=d.connection,t[39]=i,t[40]=u,t[41]=re):re=t[41];let J;t[42]!==w||t[43]!==re?(J=(0,Q.jsx)(`div`,{ref:w,"data-pane-controls":``,role:`toolbar`,"aria-label":`Document controls`,className:`flex items-center gap-1`,children:re}),t[42]=w,t[43]=re,t[44]=J):J=t[44];let ie;t[45]!==o||t[46]!==c||t[47]!==S?(ie=(!c||o===1)&&S(o),t[45]=o,t[46]=c,t[47]=S,t[48]=ie):ie=t[48];let ae;t[49]!==J||t[50]!==ie?(ae=(0,Q.jsxs)(Q.Fragment,{children:[J,ie]}),t[49]=J,t[50]=ie,t[51]=ae):ae=t[51];let oe;t[52]!==E.pinned||t[53]!==E.tabs||t[54]!==k||t[55]!==W||t[56]!==G||t[57]!==K||t[58]!==te||t[59]!==ne||t[60]!==ae?(oe=(0,Q.jsx)(ix,{ids:W,commitContext:G,leading:K,tabs:ee,pinned:q,active:k,side:te,...ne,trailing:ae}),t[52]=E.pinned,t[53]=E.tabs,t[54]=k,t[55]=W,t[56]=G,t[57]=K,t[58]=te,t[59]=ne,t[60]=ae,t[61]=oe):oe=t[61];let se;t[62]!==I?.kind||t[63]!==f||t[64]!==p||t[65]!==d.connection||t[66]!==i||t[67]!==u?(se=I?.kind===`branch-file`&&!i.guided&&(0,Q.jsxs)(`div`,{role:`group`,"aria-label":`Branch comparison`,className:`flex items-center gap-2 border-b px-3.5 py-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:`Branch comparison`}),(0,Q.jsx)(ew,{scope:u,connection:d.connection,base:f,onBase:p.onBase,compact:!0})]}),t[62]=I?.kind,t[63]=f,t[64]=p,t[65]=d.connection,t[66]=i,t[67]=u,t[68]=se):se=t[68];let ce;t[69]!==E.tabs||t[70]!==M?(ce=M&&E.tabs.includes(`review`)?rb:null,t[69]=E.tabs,t[70]=M,t[71]=ce):ce=t[71];let Y;t[72]!==f||t[73]!==d||t[74]!==a||t[75]!==l||t[76]!==o||t[77]!==g||t[78]!==h||t[79]!==j||t[80]!==A||t[81]!==n||t[82]!==u||t[83]!==k||t[84]!==c||t[85]!==ce||t[86]!==C||t[87]!==r?(Y=[{slot:rb,entry:ce},{slot:`document`,entry:k===`review`?null:k}].map(e=>{let{slot:t,entry:i}=e,s=Xy(i??void 0),p=s!==null&&i===k,m=i?ab(j,i):void 0;return(0,Q.jsx)(`div`,{role:s?`tabpanel`:void 0,id:m?.panel,"aria-labelledby":m?.tab,"aria-hidden":!p,inert:!p||A,className:Tn(`flex min-h-0 flex-1 flex-col overflow-hidden`,!p&&`pointer-events-none invisible absolute opacity-0 inset-x-0 top-12 bottom-0`),children:(0,Q.jsx)(ow,{documentKey:i??void 0,connection:d.connection,scope:u,children:s&&(0,Q.jsx)(UC,{review:n,walkthroughCode:r,scope:u,context:d,document:s,sideLabel:wb(bw(c,o)),base:f,onOpen:h,onBrowse:g,active:p&&l&&!A,hidden:!p,toolbarTarget:p&&!A?C:null,fileTarget:p&&a?.pane===o&&a.key===k?a:void 0})})},t)}),t[72]=f,t[73]=d,t[74]=a,t[75]=l,t[76]=o,t[77]=g,t[78]=h,t[79]=j,t[80]=A,t[81]=n,t[82]=u,t[83]=k,t[84]=c,t[85]=ce,t[86]=C,t[87]=r,t[88]=Y):Y=t[88];let le;return t[89]!==R||t[90]!==l||t[91]!==A||t[92]!==U||t[93]!==oe||t[94]!==se||t[95]!==Y||t[96]!==z||t[97]!==B?(le=(0,Q.jsxs)(`section`,{ref:z,"aria-label":B,"data-focused":l,"aria-busy":A,onPointerDownCapture:R,onFocusCapture:R,className:U,children:[oe,se,Y]}),t[89]=R,t[90]=l,t[91]=A,t[92]=U,t[93]=oe,t[94]=se,t[95]=Y,t[96]=z,t[97]=B,t[98]=le):le=t[98],le}var Sw={open:Ci,review:Te,"open-to-side":gi,"open-file":El,timeline:Ir,"copy-relative":q,discard:iu,"expand-all":vl,"collapse-all":gl};function Cw(e){let t=(0,$.c)(2),{action:n}=e,r=Sw[n.id],i;return t[0]===r?i=t[1]:(i=(0,Q.jsx)(r,{}),t[0]=r,t[1]=i),i}function ww(e){let t=(0,$.c)(52),{actions:n,label:r,description:i,writeBlock:a,onAction:o,children:s}=e,c=(0,Z.useId)(),[l,u]=(0,Z.useState)(!1),d;t[0]===a?d=t[1]:(d=e=>e===`review`||e===`discard`?a:void 0,t[0]=a,t[1]=d);let f=d,p;t[2]!==f||t[3]!==o?(p=e=>{f(e)||(e===`open-to-side`&&(0,sg.flushSync)(()=>u(!0)),o(e))},t[2]=f,t[3]=o,t[4]=p):p=t[4];let h=p,g;t[5]!==h||t[6]!==f?(g=e=>{let t=f(e.id);return{disabled:e.disabled||!!t,"aria-description":t,variant:e.destructive?`destructive`:`default`,onClick:()=>h(e.id)}},t[5]=h,t[6]=f,t[7]=g):g=t[7];let _=g,v;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>{e&&u(!1)},t[8]=v):v=t[8];let b=v,x;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(`div`,{className:`min-w-0`}),t[9]=x):x=t[9];let S;t[10]!==i||t[11]!==c?(S=i&&(0,Q.jsx)(`span`,{id:c,className:`sr-only`,children:i}),t[10]=i,t[11]=c,t[12]=S):S=t[12];let C=i?c:void 0,w;t[13]!==r||t[14]!==C?(w=(0,Q.jsx)(X,{variant:`ghost`,size:`icon-xs`,className:`shrink-0`,"aria-label":r,"aria-describedby":C}),t[13]=r,t[14]=C,t[15]=w):w=t[15];let T;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Q.jsx)(ii,{}),t[16]=T):T=t[16];let E;t[17]===w?E=t[18]:(E=(0,Q.jsx)(Gt,{render:(0,Q.jsx)(Lt,{render:w,children:T})}),t[17]=w,t[18]=E);let D;t[19]===r?D=t[20]:(D=(0,Q.jsx)(m,{role:`tooltip`,className:`break-all`,children:r}),t[19]=r,t[20]=D);let O;t[21]!==E||t[22]!==D?(O=(0,Q.jsxs)(y,{children:[E,D]}),t[21]=E,t[22]=D,t[23]=O):O=t[23];let k=!l,A;if(t[24]!==n||t[25]!==_){let e;t[27]===_?e=t[28]:(e=e=>(0,Q.jsxs)(Xn,{..._(e),children:[(0,Q.jsx)(Cw,{action:e}),e.label]},e.id),t[27]=_,t[28]=e),A=n.map(e),t[24]=n,t[25]=_,t[26]=A}else A=t[26];let j;t[29]!==k||t[30]!==A?(j=(0,Q.jsx)(pt,{align:`end`,finalFocus:k,children:A}),t[29]=k,t[30]=A,t[31]=j):j=t[31];let M;t[32]!==O||t[33]!==j||t[34]!==S?(M=(0,Q.jsxs)(vn,{onOpenChange:b,children:[S,O,j]}),t[32]=O,t[33]=j,t[34]=S,t[35]=M):M=t[35];let N;t[36]!==s||t[37]!==M?(N=s(M),t[36]=s,t[37]=M,t[38]=N):N=t[38];let P;t[39]===N?P=t[40]:(P=(0,Q.jsx)(di,{render:x,children:N}),t[39]=N,t[40]=P);let F=!l,I;if(t[41]!==n||t[42]!==_){let e;t[44]===_?e=t[45]:(e=e=>(0,Q.jsxs)($i,{..._(e),children:[(0,Q.jsx)(Cw,{action:e}),e.label]},e.id),t[44]=_,t[45]=e),I=n.map(e),t[41]=n,t[42]=_,t[43]=I}else I=t[43];let L;t[46]!==F||t[47]!==I?(L=(0,Q.jsx)(Qr,{finalFocus:F,children:I}),t[46]=F,t[47]=I,t[48]=L):L=t[48];let R;return t[49]!==P||t[50]!==L?(R=(0,Q.jsxs)(ia,{onOpenChange:b,children:[P,L]}),t[49]=P,t[50]=L,t[51]=R):R=t[51],R}var Tw=`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 Ew(e){let t=(0,$.c)(31),{path:n,document:r,note:i,scopes:a,changeStatus:o,reviewStatus:s,active:c,onOpen:l,sideLabel:u,onReview:d,canReview:f,writeBlock:p,onDiscard:m,indented:h}=e,g=h!==void 0&&h,_;t[0]===n?_=t[1]:(_=ao(n),t[0]=n,t[1]=_);let y;t[2]===a?y=t[3]:(y=a.length>0?` · ${a.join(` + `)}`:``,t[2]=a,t[3]=y);let b=`${_}${y}`,x;t[4]!==r||t[5]!==m||t[6]!==l||t[7]!==d||t[8]!==n?(x=e=>{bb10:switch(e){case`review`:d();break bb10;case`open`:l(r);break bb10;case`open-to-side`:l(r,{toSide:!0});break bb10;case`open-file`:l({kind:`file`,path:n});break bb10;case`timeline`:l({kind:`timeline`,path:n});break bb10;case`copy-relative`:tr(n,`relative path`);break bb10;case`discard`:m?.()}},t[4]=r,t[5]=m,t[6]=l,t[7]=d,t[8]=n,t[9]=x):x=t[9];let S=x,C=`Actions for ${n}`,w=m!==void 0,T;t[10]!==f||t[11]!==s||t[12]!==u||t[13]!==w?(T=Sd({kind:`file`,status:s,canReview:f,sideLabel:u,canDiscard:w}),t[10]=f,t[11]=s,t[12]=u,t[13]=w,t[14]=T):T=t[14];let E;t[15]!==c||t[16]!==o||t[17]!==r||t[18]!==g||t[19]!==b||t[20]!==i||t[21]!==l||t[22]!==n||t[23]!==s?(E=e=>(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":c,"aria-label":b,"aria-description":Ow(o,s),title:i==null?n:`${n}\n${i}`,className:Tn(Tw,`flex-1 text-muted-foreground`,g&&`pl-7`,c&&`bg-accent font-medium text-foreground`),onClick:e=>l(r,{toSide:e.altKey}),children:[(0,Q.jsx)(Dw,{status:o,reviewStatus:s}),(0,Q.jsx)(ya,{path:n,className:`size-3.5 shrink-0`}),(0,Q.jsx)(v,{className:Tn(`min-w-0 flex-1 `,s===`reviewed`&&`line-through decoration-muted-foreground/40`),text:ao(n)})]}),e]}),t[15]=c,t[16]=o,t[17]=r,t[18]=g,t[19]=b,t[20]=i,t[21]=l,t[22]=n,t[23]=s,t[24]=E):E=t[24];let D;return t[25]!==S||t[26]!==C||t[27]!==T||t[28]!==E||t[29]!==p?(D=(0,Q.jsx)(ww,{label:C,actions:T,writeBlock:p,onAction:S,children:E}),t[25]=S,t[26]=C,t[27]=T,t[28]=E,t[29]=p,t[30]=D):D=t[30],D}function Dw(e){let t=(0,$.c)(16),{status:n,reviewStatus:r}=e,i=r??`unreviewed`,a;t[0]!==r||t[1]!==n?(a=Ow(n,r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s=n===void 0&&`bg-muted-foreground/60`,c=(n===`added`||n===`untracked`)&&`bg-graph-2`,l=n===`modified`&&`bg-graph-4`,u=n===`deleted`&&`bg-destructive`,d=n===`renamed`&&`bg-graph-1`,f;t[3]!==s||t[4]!==c||t[5]!==l||t[6]!==u||t[7]!==d?(f=Tn(`size-1.5 rounded-full`,s,c,l,u,d),t[3]=s,t[4]=c,t[5]=l,t[6]=u,t[7]=d,t[8]=f):f=t[8];let p;t[9]===f?p=t[10]:(p=(0,Q.jsx)(`span`,{className:f}),t[9]=f,t[10]=p);let m;return t[11]!==o||t[12]!==i||t[13]!==n||t[14]!==p?(m=(0,Q.jsx)(`span`,{role:`img`,"aria-label":o,className:`grid w-3.5 shrink-0 place-items-center`,"data-review-state":i,"data-change-status":n,title:o,children:p}),t[11]=o,t[12]=i,t[13]=n,t[14]=p,t[15]=m):m=t[15],m}function Ow(e,t){return`${e===void 0?`Change type unavailable`:Hs[e].label} · ${kw(t)}`}function kw(e){return e===`reviewed`?`Reviewed`:e===`stale`?`Changed since review`:`Not reviewed`}function Aw(e){let t=(0,$.c)(17),{label:n,active:r,onOpen:i,className:a,plain:o,children:s}=e,c=a===void 0?Tw:a;if(o!==void 0&&o){let e;return t[0]!==r||t[1]!==s||t[2]!==c||t[3]!==n||t[4]!==i?(e=(0,Q.jsx)(`div`,{className:`flex min-w-0 items-center`,children:(0,Q.jsx)(`button`,{type:`button`,className:c,"aria-pressed":r,"aria-label":n,onClick:i,children:s})}),t[0]=r,t[1]=s,t[2]=c,t[3]=n,t[4]=i,t[5]=e):e=t[5],e}let l=`Actions for ${n}`,u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u=Sd({kind:`section`}),t[6]=u):u=t[6];let d;t[7]!==r||t[8]!==s||t[9]!==c||t[10]!==i?(d=e=>(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,Q.jsx)(`button`,{type:`button`,className:c,"aria-pressed":r,onClick:i,children:s}),e]}),t[7]=r,t[8]=s,t[9]=c,t[10]=i,t[11]=d):d=t[11];let f;return t[12]!==i||t[13]!==l||t[14]!==u||t[15]!==d?(f=(0,Q.jsx)(ww,{label:l,actions:u,onAction:i,children:d}),t[12]=i,t[13]=l,t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function jw(e){let t=(0,$.c)(15),{name:n,count:r,expanded:i,onExpanded:a,onAll:o,action:s,children:c}=e,l=i?u:me,d;t[0]!==l||t[1]!==r||t[2]!==i||t[3]!==n||t[4]!==a?(d=e=>(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:Tw,"aria-label":n,"aria-expanded":i,onClick:()=>a(!i),children:[(0,Q.jsx)(v,{className:`min-w-0 flex-1`,text:`${n} · ${fe(r,`file`)}`}),(0,Q.jsx)(l,{className:`size-3.5 shrink-0`})]}),e]}),t[0]=l,t[1]=r,t[2]=i,t[3]=n,t[4]=a,t[5]=d):d=t[5];let f=d,p;t[6]!==s||t[7]!==n||t[8]!==o||t[9]!==f?(p=s?f(s):(0,Q.jsx)(ww,{label:`Actions for ${n}`,actions:Sd({kind:`group`}),onAction:e=>o(e===`expand-all`),children:f}),t[6]=s,t[7]=n,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=i&&c,h;return t[11]!==n||t[12]!==p||t[13]!==m?(h=(0,Q.jsxs)(`section`,{"aria-label":n,className:`mt-3 border-t pt-2`,children:[p,m]}),t[11]=n,t[12]=p,t[13]=m,t[14]=h):h=t[14],h}function Mw(e){let t=(0,$.c)(17),{label:n,value:r,options:i,onValue:a,className:o}=e,s;t[0]===o?s=t[1]:(s=Tn(`shrink-0`,o),t[0]=o,t[1]=s);let c;t[2]!==a||t[3]!==i?(c=e=>{let t=i.find(t=>t.value===e);t&&a(t.value)},t[2]=a,t[3]=i,t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=i.map(Nw),t[5]=i,t[6]=l);let u;t[7]!==n||t[8]!==l?(u=(0,Q.jsx)(Dc,{"aria-label":n,className:`w-full`,children:l}),t[7]=n,t[8]=l,t[9]=u):u=t[9];let d;t[10]!==c||t[11]!==u||t[12]!==r?(d=(0,Q.jsx)(Rc,{value:r,onValueChange:c,children:u}),t[10]=c,t[11]=u,t[12]=r,t[13]=d):d=t[13];let f;return t[14]!==s||t[15]!==d?(f=(0,Q.jsx)(`div`,{className:s,children:d}),t[14]=s,t[15]=d,t[16]=f):f=t[16],f}function Nw(e){return(0,Q.jsx)(Hc,{value:e.value,className:`min-w-0`,children:e.label},e.value)}function Pw(e){let t=(0,$.c)(16),{scope:n,context:r,base:i,activeEntry:a,onOpen:o,sideLabel:s,onBase:c,grouping:l}=e,u;t[0]!==i||t[1]!==r.connection||t[2]!==c||t[3]!==n?(u=(0,Q.jsx)(`div`,{className:`shrink-0 px-2 pt-2`,children:(0,Q.jsx)(ew,{scope:n,connection:r.connection,base:i,onBase:c})}),t[0]=i,t[1]=r.connection,t[2]=c,t[3]=n,t[4]=u):u=t[4];let d;t[5]!==a||t[6]!==i||t[7]!==r||t[8]!==l||t[9]!==o||t[10]!==n||t[11]!==s?(d=(0,Q.jsx)(Fw,{scope:n,context:r,base:i,activeEntry:a,onOpen:o,sideLabel:s,grouping:l}),t[5]=a,t[6]=i,t[7]=r,t[8]=l,t[9]=o,t[10]=n,t[11]=s,t[12]=d):d=t[12];let f;return t[13]!==u||t[14]!==d?(f=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[u,d]}),t[13]=u,t[14]=d,t[15]=f):f=t[15],f}function Fw(e){let t=(0,$.c)(12),{scope:n,context:r,base:i,activeEntry:a,onOpen:o,sideLabel:s,grouping:c}=e,l;t[0]!==a||t[1]!==r||t[2]!==c||t[3]!==o||t[4]!==n||t[5]!==s?(l=e=>(0,Q.jsx)(Iw,{scope:n,context:r,branch:e,activeEntry:a,onOpen:o,sideLabel:s,grouping:c}),t[0]=a,t[1]=r,t[2]=c,t[3]=o,t[4]=n,t[5]=s,t[6]=l):l=t[6];let u;return t[7]!==i||t[8]!==r||t[9]!==n||t[10]!==l?(u=(0,Q.jsx)(mx,{scope:n,context:r,base:i,quiet:!0,children:l}),t[7]=i,t[8]=r,t[9]=n,t[10]=l,t[11]=u):u=t[11],u}function Iw(e){let t=(0,$.c)(53),{scope:n,context:r,branch:i,activeEntry:a,onOpen:o,sideLabel:s,grouping:c}=e,l=xc(r.connection),u;t[0]===i?u=t[1]:(u=La(i),t[0]=i,t[1]=u);let d=u,f=dx(n,r,d),p=Tx(n,r,Lw,d);if(i.base===null||i.base===void 0)return null;let m,h,g,_,y,b,x;if(t[2]!==c||t[3]!==a||t[4]!==i.base.ref||t[5]!==i.commits||t[6]!==i.files||t[7]!==i.head.branch||t[8]!==r||t[9]!==f||t[10]!==o||t[11]!==p||t[12]!==n||t[13]!==s||t[14]!==l){let e=to(i.files,f),u;t[22]===i.head.branch?u=t[23]:(u=i.head.branch===null||i.head.branch===void 0?`this commit`:U_(i.head.branch),t[22]=i.head.branch,t[23]=u);let d=u,S;t[24]===i.commits?S=t[25]:(S=fe(i.commits,`commit`),t[24]=i.commits,t[25]=S);let C=S,w=c?`All changes`:`All branch changes`,T;t[26]!==a||t[27]!==o||t[28]!==p||t[29]!==s?(T=e=>(0,Q.jsx)(Ew,{path:e.path,document:{kind:`branch-file`,path:e.path},note:e.status,changeStatus:Zs(e),scopes:[e.status],reviewStatus:e.reviewStatus,active:a===Yy({kind:`branch-file`,path:e.path}),onOpen:o,sideLabel:s,writeBlock:p.writeBlock,canReview:e.fingerprint!==null&&e.fingerprint!==void 0,onReview:()=>p.toggle({path:e.path,reviewed:e.reviewStatus===`reviewed`,fingerprint:e.fingerprint})},e.path),t[26]=a,t[27]=o,t[28]=p,t[29]=s,t[30]=T):T=t[30];let E=T;m=si,x=`h-0 min-h-0 flex-1`,h=`p-2 pr-3`;let D;t[31]===i.base.ref?D=t[32]:(D=U_(i.base.ref),t[31]=i.base.ref,t[32]=D),t[33]!==C||t[34]!==d||t[35]!==D?(g=(0,Q.jsxs)(`p`,{className:`px-2 pb-1.5 text-2xs text-muted-foreground`,children:[C,` on `,d,` since `,D]}),t[33]=C,t[34]=d,t[35]=D,t[36]=g):g=t[36];let O;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(O=Yy(qy),t[37]=O):O=t[37];let k;t[38]===o?k=t[39]:(k=()=>o(qy),t[38]=o,t[39]=k);let A;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Q.jsx)(yi,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[40]=A):A=t[40];let j;t[41]===w?j=t[42]:(j=(0,Q.jsx)(v,{className:`min-w-0 flex-1`,text:w}),t[41]=w,t[42]=j),_=(0,Q.jsxs)(Aw,{label:w,active:a===O,onOpen:k,plain:c!==void 0,children:[A,j,(0,Q.jsx)(`span`,{className:`ml-auto text-2xs text-muted-foreground tabular-nums`,children:e.length})]}),y=e.length===0&&(0,Q.jsxs)(`p`,{className:`p-3 text-sm text-muted-foreground`,children:[`No changes since `,U_(i.base.ref)]}),b=c?(0,Q.jsx)(c,{scope:n,context:r,items:e,row:E,activeEntry:a,onOpen:o}):bd(e,l).map(E),t[2]=c,t[3]=a,t[4]=i.base.ref,t[5]=i.commits,t[6]=i.files,t[7]=i.head.branch,t[8]=r,t[9]=f,t[10]=o,t[11]=p,t[12]=n,t[13]=s,t[14]=l,t[15]=m,t[16]=h,t[17]=g,t[18]=_,t[19]=y,t[20]=b,t[21]=x}else m=t[15],h=t[16],g=t[17],_=t[18],y=t[19],b=t[20],x=t[21];let S;t[43]!==h||t[44]!==g||t[45]!==_||t[46]!==y||t[47]!==b?(S=(0,Q.jsxs)(`div`,{className:h,children:[g,_,y,b]}),t[43]=h,t[44]=g,t[45]=_,t[46]=y,t[47]=b,t[48]=S):S=t[48];let C;return t[49]!==m||t[50]!==x||t[51]!==S?(C=(0,Q.jsx)(m,{className:x,children:S}),t[49]=m,t[50]=x,t[51]=S,t[52]=C):C=t[52],C}function Lw(e){return ms.add(e)}var Rw=[{value:`uncommitted`,label:`Uncommitted`},{value:`branch`,label:`Branch`}];function zw(e){let t=(0,$.c)(28),{grouping:n,scope:r,context:i,activeEntry:a,onOpen:o,sideLabel:s,changeScope:c,base:l,onChangeScope:u,onBase:d}=e,{connection:f}=i;fx(r,i);let p=Ds(r,f),m=px(r,i,p),h=c===`branch`,g;t[0]!==c||t[1]!==u?(g=(0,Q.jsx)(Mw,{label:`Changes to review`,className:`px-2.5 pt-3`,value:c,onValue:u,options:Rw}),t[0]=c,t[1]=u,t[2]=g):g=t[2];let _;t[3]!==a||t[4]!==l||t[5]!==h||t[6]!==i||t[7]!==n?.branch||t[8]!==d||t[9]!==o||t[10]!==r||t[11]!==s?(_=h&&(0,Q.jsx)(Pw,{scope:r,context:i,base:l,activeEntry:a,onOpen:o,sideLabel:s,onBase:d,grouping:n?.branch}),t[3]=a,t[4]=l,t[5]=h,t[6]=i,t[7]=n?.branch,t[8]=d,t[9]=o,t[10]=r,t[11]=s,t[12]=_):_=t[12];let v;t[13]!==a||t[14]!==l||t[15]!==h||t[16]!==m||t[17]!==i||t[18]!==n?.uncommitted||t[19]!==p||t[20]!==o||t[21]!==r||t[22]!==s?(v=!h&&(0,Q.jsx)(Bw,{scope:r,context:i,activeEntry:a,onOpen:o,sideLabel:s,list:p,changes:m,grouping:n?.uncommitted,base:l}),t[13]=a,t[14]=l,t[15]=h,t[16]=m,t[17]=i,t[18]=n?.uncommitted,t[19]=p,t[20]=o,t[21]=r,t[22]=s,t[23]=v):v=t[23];let y;return t[24]!==g||t[25]!==_||t[26]!==v?(y=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[g,_,v]}),t[24]=g,t[25]=_,t[26]=v,t[27]=y):y=t[27],y}function Bw(e){let t=(0,$.c)(16),{scope:n,context:r,activeEntry:i,onOpen:a,sideLabel:o,list:s,changes:c,grouping:l,base:u}=e,d=xc(r.connection),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f={changes:!0,specs:!1},t[0]=f):f=t[0];let[p,m]=(0,Z.useState)(f),h=s.changes.map(Gw),g=d?h.filter(Ww):h,_=d?h.filter(yd):[],v=new Map(c.map(Uw)),y=Js(s.changes),b=Tx(n,r,Hw),[x,S]=(0,Z.useState)(null),C=()=>l?(0,Q.jsx)(l,{base:u,scope:n,context:r,paths:h,row:w,activeEntry:i,onOpen:a}):(0,Q.jsx)(Aw,{label:`All changes`,active:i===Yy(Gy),onOpen:()=>a(Gy),children:`All changes`}),w=e=>(0,Q.jsx)(Ew,{path:e,document:{kind:`change`,path:e},note:void 0,changeStatus:y.files.get(e),scopes:[...new Set(s.changes.find(t=>t.path===e)?.comparisons.map(Vw))],reviewStatus:v.get(e)?.reviewStatus,active:i===Yy({kind:`change`,path:e}),onOpen:a,sideLabel:o,writeBlock:b.writeBlock,canReview:v.get(e)?.fingerprint!==null&&v.get(e)?.fingerprint!==void 0,onReview:()=>b.toggle({path:e,reviewed:v.get(e)?.reviewStatus===`reviewed`,fingerprint:v.get(e)?.fingerprint}),onDiscard:()=>S(t=>({path:e,nonce:(t?.nonce??0)+1}))},e),T=si,E;t[1]===C?E=t[2]:(E=C(),t[1]=C,t[2]=E);let D=!l&&h.length===0&&(0,Q.jsx)(`p`,{className:`p-3 text-sm text-muted-foreground`,children:`No changes`}),O=!l&&g.length>0&&(0,Q.jsx)(jw,{name:`Changed files`,count:g.length,expanded:p.changes,onExpanded:e=>m(t=>({...t,changes:e})),onAll:e=>m({changes:e,specs:e}),children:g.map(w)}),k=!l&&_.length>0&&(0,Q.jsxs)(jw,{name:`Specs`,count:_.length,expanded:p.specs,onExpanded:e=>m(t=>({...t,specs:e})),onAll:e=>m({changes:e,specs:e}),children:[(0,Q.jsx)(Aw,{label:`Open all specs`,active:i===`specs`,onOpen:()=>a(Ky),children:`Open all specs`}),_.map(w)]}),A;t[3]!==r||t[4]!==x||t[5]!==n?(A=x&&(0,Q.jsx)(d_,{scope:n,context:r,path:x.path,signal:x.nonce,hiddenTrigger:!0}),t[3]=r,t[4]=x,t[5]=n,t[6]=A):A=t[6];let j;t[7]!==E||t[8]!==D||t[9]!==O||t[10]!==k||t[11]!==A?(j=(0,Q.jsxs)(`div`,{className:`px-2.5 pt-2 pb-3`,children:[E,D,O,k,A]}),t[7]=E,t[8]=D,t[9]=O,t[10]=k,t[11]=A,t[12]=j):j=t[12];let M;return t[13]!==T||t[14]!==j?(M=(0,Q.jsx)(T,{className:`h-0 min-h-0 flex-1`,children:j}),t[13]=T,t[14]=j,t[15]=M):M=t[15],M}function Vw(e){return e.scope}function Hw(e){return ms.add(e)}function Uw(e){return[e.path,e]}function Ww(e){return!yd(e)}function Gw(e){return e.path}function Kw(e){let t=(0,$.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsx)(ha,{}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,Q.jsxs)(Q.Fragment,{children:[r,(0,Q.jsx)(Ng,{children:n})]}),t[1]=n,t[2]=i),i}function qw(e){let t=(0,$.c)(6),{children:n}=e,[r,i]=(0,Z.useState)(!0),a=f(),o;t[0]===a?o=t[1]:(o=a&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Cs,{connection:a}),(0,Q.jsx)(Ya,{connection:a}),(0,Q.jsx)(ja,{connection:a})]}),t[0]=a,t[1]=o);let s;return t[2]!==n||t[3]!==r||t[4]!==o?(s=(0,Q.jsx)(Kw,{children:(0,Q.jsxs)(io,{open:r,onOpenChange:i,children:[n,o]})}),t[2]=n,t[3]=r,t[4]=o,t[5]=s):s=t[5],s}function Jw(e){let t=e.walkthrough;if(t===void 0)return{kind:`unwritten`};switch(t.state.status){case`queued`:case`running`:return{kind:`writing`,run:t};case`failed`:return{kind:`failed`,run:t,failure:t.state.failure};case`ready`:return{kind:`ready`,run:t,content:t.state.content,freshness:e.freshness,attempt:e.attempt}}}function Yw(e){return e.walkthrough===void 0?`changes`:`walkthrough`}var Xw=[`One`,`Two`,`Three`,`Four`,`Five`];function Zw(e){return e.stops.flatMap((e,t)=>e.attention===void 0?[]:[{stop:e,step:t+1,attention:e.attention}])}function Qw(e){let t=Zw(e).length;return e.outcome===`nothing`?`Nothing needs you.`:e.outcome===`worth_knowing`||t===0?`Worth knowing.`:t===1?`One call is yours.`:`${Xw[t-1]??t} calls are yours.`}function $w(e,t=[]){let n=[...e.excerpts.map(e=>e.path),...e.files.map(e=>e.path)],r=t.flatMap(e=>e.oldPath!==void 0&&n.includes(e.oldPath)?[e.path]:[]);return[...new Set([...n,...r])]}function eT(e){return new Set(e.stops.flatMap(e=>$w(e))).size}function tT(e,t){return e.has(t.path)||t.oldPath!==void 0&&e.has(t.oldPath)}function nT(e,t,n=[]){let r=new Set;return{steps:e.stops.map((e,i)=>{let a=new Set($w(e,n)),o=t.filter(e=>tT(a,e));for(let e of o)r.add(e);return{stop:e,step:i+1,files:o}}),outside:t.filter(e=>!r.has(e))}}var rT={claude:`Claude`,codex:`Codex`},iT={claude:`claude auth login`,codex:`codex login`};function aT(e,t){let n=rT[t.provider];switch(e.kind){case`signed_out`:return{title:`Sign in to ${n} again with ${iT[t.provider]}, then try again.`,message:``,command:iT[t.provider]};case`agent_not_installed`:return{title:`${n} isn't installed here.`,message:e.message};case`timed_out`:return{title:`The walkthrough took too long.`,message:e.message};case`unusable_output`:return{title:`${n} wrote something unreadable.`,message:e.message};case`other`:return{title:`The walkthrough didn't finish.`,message:e.message}}}var oT=new Set([`signed_out`,`agent_not_installed`,`timed_out`,`unusable_output`,`other`]);function sT(e){return typeof e==`string`&&oT.has(e)}function cT(e){return typeof e==`object`&&e&&`kind`in e&&`message`in e&&sT(e.kind)&&typeof e.message==`string`?{kind:e.kind,message:e.message}:{kind:`other`,message:e instanceof Error&&e.message!==``?e.message:`Porcelain could not start the walkthrough.`}}function lT(e){let t=(e.branch===void 0?void 0:e.pullRequests?.find(t=>t.headBranch===e.branch&&t.state===`open`)?.number)??e.displayedRun?.pullRequestNumber;return{...e.base===void 0?{}:{base:e.base},...t===void 0?{}:{pullRequestNumber:t}}}function uT(e){let t=Jw(e);return t.kind===`ready`?dT(t.content.title).replace(/\.$/,``):`Review`}function dT(e){return e.replaceAll("`",``)}function fT(e){return e.split(/(`[^`]+`)/).filter(e=>e!==``).map(e=>e.length>2&&e.startsWith("`")&&e.endsWith("`")?{kind:`code`,text:e.slice(1,-1)}:{kind:`text`,text:e})}function pT({branch:e,worktree:t,only:n}){let r=e=>[...new Set(e.filter(e=>n===void 0||n.includes(e.path)||e.oldPath!==void 0&&n.includes(e.oldPath)).map(e=>e.path))],i=t.flatMap(e=>[e,...(e.comparisons??[]).flatMap(t=>`oldPath`in t?[{path:e.path,oldPath:t.oldPath}]:[])]);return{branch:r(e),worktree:r(i)}}function mT(e,t,n){let r=0,i=e=>{let i=r<n;return r+=(t?e.branch.length:0)+e.worktree.length,i};return{steps:e.steps.map(i),outside:i(e.outside)}}function hT(e,t){return[...e.flatMap(({oldPath:e,path:t})=>e===void 0?[]:[[e,t]]),...t.flatMap(e=>(e.comparisons??[]).flatMap(t=>{let n=`oldPath`in t?t.oldPath:void 0;return n===void 0?[]:[[n,e.path]]}))]}function gT(e,t){let n=new Set(e),r=!0;for(;r;){r=!1;for(let[e,i]of t)n.has(e)!==n.has(i)&&(n.add(e),n.add(i),r=!0)}return[...n]}function _T({content:e,branch:t,worktree:n}){let r=hT(t,n),i=(e?.stops??[]).map(e=>pT({branch:t,worktree:n,only:gT($w(e),r)})),a=pT({branch:t,worktree:n}),o=e=>new Set(i.flatMap(e)),s=o(e=>e.branch),c=o(e=>e.worktree);return{steps:i,outside:{branch:a.branch.filter(e=>!s.has(e)),worktree:a.worktree.filter(e=>!c.has(e))}}}var vT=cn(e=>Yt(e.connection).fn(Jn(`Walkthroughs.start`)(function*(t){let n=yield*mt(e.connection,n=>n.walkthroughs.startWalkthrough({params:{worktreeId:e.scope.worktreeId},payload:t}));return yield*ot([$e.reviewSurface(e.connection.environmentId,e.scope,[`walkthrough`])]),n})));function yT([e,t],n){let r=ne(J(n.pulls)),i=lT({...n,pullRequests:r?.kind===`available`?r.pullRequests:void 0}),a=ne(J(e));return{accepted:a?.branch===n.branch?a:void 0,waiting:o(e),failure:h(e)?cT(ie(e.cause)):void 0,start:()=>void t(i)}}var bT=cn(({connection:e,scope:t,runId:n})=>{let r=Yt(e),i={worktreeId:t.worktreeId,runId:n},a=ot([$e.reviewSurface(e.environmentId,t,[`walkthrough-conversations`])]),o=e=>({...i,messageId:e});return{addMessage:r.fn(Jn(`Walkthroughs.addMessage`)(function*(t){let n=yield*mt(e,e=>e.walkthroughs.addWalkthroughMessage({params:i,payload:t}));return yield*a,n})),retryAnswer:r.fn(Jn(`Walkthroughs.retryAnswer`)(function*(t){let n=yield*mt(e,e=>e.walkthroughs.retryWalkthroughAnswer({params:o(t)}));return yield*a,n})),saveMessage:r.fn(Jn(`Walkthroughs.saveMessage`)(function*(t){let n=yield*mt(e,e=>e.walkthroughs.saveWalkthroughMessage({params:o(t.messageId),payload:{saved:t.saved}}));return yield*a,n})),postMessage:r.fn(Jn(`Walkthroughs.postMessage`)(function*(t){let n=yield*mt(e,e=>e.walkthroughs.postWalkthroughMessage({params:o(t)}));return yield*a,n})),readBrief:r.fn(Jn(`Walkthroughs.readBrief`)(function*(t){return(yield*mt(e,e=>e.walkthroughs.readWalkthroughBrief({params:i,query:t===void 0?{}:{messageId:t}}))).text})),postSavedMessages:r.fn(Jn(`Walkthroughs.postSavedMessages`)(function*(){let t=yield*mt(e,e=>e.walkthroughs.postSavedWalkthroughMessages({params:i}));return yield*a,t}))}});function xT([e,t]){return{waiting:o(e),run:async e=>{let n=await t(e);if(ce(n))throw ie(n.cause);return n.value}}}var ST=Jn(`Walkthroughs.readConversations`)(function*({connection:e,scope:t,runId:n}){return yield*mt(e,e=>e.walkthroughs.listWalkthroughConversations({params:{worktreeId:t.worktreeId,runId:n}}))}),CT=cn(e=>ge(e.connection,e.scope,[`walkthrough-conversations`,e.runId],ST(e),Yt(e.connection)).pipe(L)),wT=cn(e=>T(e,e.excerpt===void 0?[`walkthrough`]:[`walkthrough-excerpt`,e.excerpt.runId,e.excerpt.step],t=>t.walkthroughs.readWalkthrough({params:{worktreeId:e.scope.worktreeId},query:e.excerpt===void 0?{}:{excerptRunId:e.excerpt.runId,excerptStep:e.excerpt.step}}),t=>t.walkthrough===void 0||t.walkthrough.worktreeId===e.scope.worktreeId)),TT=cn(e=>T(e,[`walkthrough-asset`,e.runId,e.assetId],t=>t.walkthroughs.readWalkthroughAsset({params:{worktreeId:e.scope.worktreeId,runId:e.runId,assetId:e.assetId}})));function ET(e,t){let n=ne(J(e));return n===void 0?h(e)?{status:`failed`}:{status:`reading`}:{status:`read`,value:t(n)}}function DT(e,t){return e.conversations.filter(e=>e.anchor.kind===t.kind&&(e.anchor.kind===`walkthrough`||t.kind===`stop`&&e.anchor.title===t.title))}function OT(e){return e.messages.filter(e=>e.author===`developer`)}function kT(e,t){return e.messages.find(e=>e.author===`agent`&&e.replyTo===t)}function AT(e){return e.conversations.flatMap(OT).filter(e=>e.post.status===`saved`).length}function jT(e){return e===void 0||e.post.status===`none`?`available`:e.post.status}function MT(e,t){return(e?.conversations??[]).filter(({anchor:e})=>e.kind===`walkthrough`||!t.includes(e.title))}function NT(e){return typeof e==`object`&&e&&(`status`in e&&e.status===409||`name`in e&&e.name===`WalkthroughRepositoryChangedError`)?{text:`Nothing was posted. Copy the brief instead.`,copy:!0}:{text:e instanceof Error?e.message:`The request failed. Try again.`,copy:!1}}var PT=/^[a-z][a-z\d+.-]*:\/\/[^/?#\s]+(\/[^?#\s]*)?(?:[?#]\S*)?$/i,FT=/\/(?:pull|issues)\/([1-9]\d*)\/?$/;function IT(e){let t=PT.exec(e)?.[1]??``,n=FT.exec(t)?.[1];return n===void 0?`Posted comment`:`Posted on #${n}`}function LT(e){return e===void 0?{single:`Copy as prompt`,together:`Copy together`}:{single:`Post on #${e}`,together:`Post together on #${e}`}}function RT(e){return OT(e).map(t=>({message:t,reply:kT(e,t.id)}))}function zT(e,t){return e?DT(e,{kind:`stop`,title:t}):[]}function BT(e){let t=e?AT(e):0;if(t!==0)return t===1?`1 comment saved`:`${t} comments saved`}function VT(e){let{outcome:t}=e;return t.status===`brief`?{kind:`brief`,text:t.text}:t.status!==`posted`||t.notPosted.length===0?{kind:`done`}:{kind:`still-saved`,messages:e.view.conversations.flatMap(OT).filter(e=>t.notPosted.includes(e.id))}}function HT(e){let t=e.walkthrough.status===`read`?e.walkthrough.value:void 0;return{name:Yw(t??{walkthrough:void 0,freshness:`unknown`}),pending:e.walkthrough.status===`reading`,guided:t?.walkthrough!==void 0}}var UT={product:`Product call`,contract:`Contract call`,tradeoff:`Tradeoff`,risk:`Risk to accept`,accessibility:`Accessibility call`};function WT(e){return UT[e.kind]}var GT={added:`+`,changed:`~`,removed:`−`};function KT(e){return GT[e.change]}var qT=4,JT=7,YT=3;function XT(e,t){let n=e.growth;return{shown:t?n:n.slice(0,qT),hidden:t?0:Math.max(0,n.length-qT)}}function ZT(e,t){let n=e.onlyInTranscript.length+e.stillUnclear.length,r=t?e.onlyInTranscript:e.onlyInTranscript.slice(0,YT),i=t?e.stillUnclear:e.stillUnclear.slice(0,Math.max(0,YT-r.length));return{explained:r,unclear:i,total:n,hidden:n-r.length-i.length}}function QT(e,t){let n=t?eT(t):0;return[...e.pullRequestNumber===void 0?[]:[`#${e.pullRequestNumber}`],...n>0?[n===1?`1 file`:`${n} files`]:[],`written for ${e.headOid.slice(0,JT)}${e.includesUncommitted?` and uncommitted work`:``}`].join(` · `)}function $T(e,t){return aT(e,t?.writer??{provider:`claude`,model:``,effort:`high`})}function eE(e,t){if(!(!t||e.kind!==`unwritten`&&e.kind!==`failed`))return{failure:t,run:e.kind===`failed`?e.run:void 0}}function tE(e,t){let n=e.attempt,r=n?.state.status,i=n?.state.status===`failed`?{failure:n.state.failure,writer:n.writer}:void 0;return{updating:t.waiting||r===`queued`||r===`running`,failure:t.failure?{failure:t.failure,writer:n?.writer??e.run.writer}:i}}function nE(e){switch(e.evidenceUnavailable){case`head_mismatch`:return`Screenshots and checks are not shown: the pull request is at another commit. Push, then update.`;case`github_account`:return`Screenshots and checks are not shown: choose a GitHub account for this project, then update.`;case`github_unavailable`:return`Screenshots and checks are not shown: GitHub could not be reached. Try updating later.`;case void 0:return}}var rE=[`queued`,`evidence`,`transcript`,`writing`,`validating`,`ready`],iE={queued:`Queued`,evidence:`Reading pull request evidence`,transcript:`Reading the coding conversation`,writing:`Writing the walkthrough`,validating:`Checking the walkthrough`,ready:`Walkthrough saved`,failed:`Update failed`};function aE(e,t){if(!t)return e;let n=e.attempt??e.walkthrough;return n&&(n.id===t.id||n.createdAt>t.createdAt||n.branch!==t.branch)?e:e.walkthrough?.state.status===`ready`&&t.state.status!==`ready`?{...e,attempt:t}:{walkthrough:t,freshness:`unknown`}}function oE(e,t){let n=e.progress??[],r=n.at(-1),i=e.state.status===`failed`?`failed`:e.state.status===`ready`?`ready`:r?.stage??(e.state.status===`queued`?`queued`:`writing`),a=n.filter(e=>e.stage!==`failed`).at(-1)?.stage,o=i===`failed`?Math.max(0,rE.findIndex(e=>e===a)):Math.max(0,rE.findIndex(e=>e===i));return{label:t?`Requesting update`:iE[i],completed:t?0:o,total:rE.length-1,entries:n,steps:rE.map(e=>iE[e]),active:t||e.state.status===`queued`||e.state.status===`running`}}function sE(e){switch(e){case`current`:return`Up to date with the current work.`;case`unknown`:return;case`changed`:return`The work changed after this walkthrough’s snapshot. Update to include the latest changes.`}}function cE(e,t){return{connection:t.connection,scope:{projectId:e.projectId,worktreeId:e.worktreeId}}}var lE=cn(e=>wT(e).pipe(qn,St(0)));function uE(e,t){let n=(0,$.c)(12),r;n[0]!==t||n[1]!==e?(r=lE(cE(e,t)),n[0]=t,n[1]=e,n[2]=r):r=n[2];let i=r,a=$t(i),o,s,c;if(n[3]!==a){let e=ne(J(a));o=a,s=e,c=e?Jw(e):void 0,n[3]=a,n[4]=o,n[5]=s,n[6]=c}else o=n[4],s=n[5],c=n[6];let l=_n(i),u;return n[7]!==o||n[8]!==s||n[9]!==c||n[10]!==l?(u={result:o,read:s,phase:c,refresh:l},n[7]=o,n[8]=s,n[9]=c,n[10]=l,n[11]=u):u=n[11],u}function dE(e,t){let{phase:n}=uE(e,t);return n?.kind===`ready`?n:void 0}function fE(e,t,n){let r=(0,$.c)(2),i=Ga(e,t.connection,n).result,a;return r[0]===i?a=r[1]:(a=ne(J(i))?.files??[],r[0]=i,r[1]=a),a}function pE(e,t){let n=(0,$.c)(2),{read:r}=uE(e,t),i;return n[0]===r?i=n[1]:(i=r?uT(r):`Review`,n[0]=r,n[1]=i),i}function mE(e,t){let n=(0,$.c)(2),{result:r}=uE(e,t),i;return n[0]===r?i=n[1]:(i=HT({walkthrough:ET(r,hE)}),n[0]=r,n[1]=i),i}function hE(e){return e}var gE=cn(e=>Ln(t=>{let n=t(TT(e));return Ut(n,e=>{let n=URL.createObjectURL(new Blob([Uint8Array.from(e)]));return t.addFinalizer(()=>URL.revokeObjectURL(n)),n})}));function _E(e){let t=(0,$.c)(3),n={...cE(e.scope,e.context),runId:e.runId,assetId:e.assetId},r=$t(gE(n)),i=_n(TT(n)),a;return t[0]!==r||t[1]!==i?(a={url:r,retry:i},t[0]=r,t[1]=i,t[2]=a):a=t[2],a}function vE(e,t,n,r){let i=(0,$.c)(8),a;i[0]!==t||i[1]!==n||i[2]!==e||i[3]!==r?(a=wT({...cE(e,t),excerpt:{runId:n,step:r}}),i[0]=t,i[1]=n,i[2]=e,i[3]=r,i[4]=a):a=i[4];let o=a,s=$t(o),c=_n(o),l;return i[5]!==s||i[6]!==c?(l={result:s,retry:c},i[5]=s,i[6]=c,i[7]=l):l=i[7],l}function yE(e,t,n,r){let i=(0,$.c)(8),a;i[0]!==t.connection||i[1]!==e.projectId||i[2]!==e.worktreeId?(a=vT({connection:t.connection,scope:{projectId:e.projectId,worktreeId:e.worktreeId}}),i[0]=t.connection,i[1]=e.projectId,i[2]=e.worktreeId,i[3]=a):a=i[3];let o;i[4]===Symbol.for(`react.memo_cache_sentinel`)?(o={mode:`promiseExit`},i[4]=o):o=i[4];let[s,c]=Pn(a,o),l=ne(J(Fa(e,t.connection))),u;i[5]!==t.connection||i[6]!==e.projectId?(u=g({connection:t.connection,projectId:e.projectId}),i[5]=t.connection,i[6]=e.projectId,i[7]=u):u=i[7];let d=$t(u);return yT([s,c],{pulls:d,branch:l?.branch?.name??r?.branch,displayedRun:r,base:n})}function bE(e){let t=(0,$.c)(4),{text:n}=e,r;t[0]===n?r=t[1]:(r=fT(n).map(xE),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,Q.jsx)(Q.Fragment,{children:r}),t[2]=r,t[3]=i),i}function xE(e,t){return e.kind===`code`?(0,Q.jsx)(`code`,{className:`rounded bg-muted px-1 py-px font-mono text-[0.86em]`,children:e.text},t):e.text}var SE=H(`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 CE({variant:e=`default`,align:t=`start`,className:n,...r}){return(0,Q.jsx)(`div`,{"data-slot":`bubble`,"data-variant":e,"data-align":t,className:Tn(SE({variant:e}),n),...r})}function wE({className:e,render:t,...n}){return nn({defaultTagName:`div`,props:st({className:Tn(`w-fit max-w-full min-w-0 overflow-hidden rounded-lg border border-transparent px-2.5 py-1.5 text-xs/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-2 [button,a]:focus-visible:ring-ring/30`,e)},n),render:t,state:{slot:`bubble-content`}})}H(`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-xs ring-2 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 TE({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`message-group`,className:Tn(`flex min-w-0 flex-col gap-1.5`,e),...t})}function EE({className:e,align:t=`start`,...n}){return(0,Q.jsx)(`div`,{"data-slot":`message`,"data-align":t,className:Tn(`group/message relative flex w-full min-w-0 gap-1.5 text-xs/relaxed data-[align=end]:flex-row-reverse`,e),...n})}function DE({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`message-content`,className:Tn(`flex w-full min-w-0 flex-col gap-2 wrap-break-word group-data-[align=end]/message:*:data-slot:self-end`,e),...t})}function OE({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`message-header`,className:Tn(`flex max-w-full min-w-0 items-center px-2.5 text-[0.625rem] font-medium text-muted-foreground group-has-data-[variant=ghost]/message:px-0`,e),...t})}function kE({scope:e,context:t,runId:n}){return{connection:t.connection,runId:n,scope:{projectId:e.projectId,worktreeId:e.worktreeId}}}function AE(e){let t=(0,$.c)(10),n;t[0]===e?n=t[1]:(n=CT(kE(e)),t[0]=e,t[1]=n);let r=n,i=$t(r),a;t[2]===i?a=t[3]:(a=ne(J(i)),t[2]=i,t[3]=a);let o;t[4]===i?o=t[5]:(o=h(i),t[4]=i,t[5]=o);let s=_n(r),c;return t[6]!==a||t[7]!==o||t[8]!==s?(c={view:a,failed:o,refresh:s},t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function jE(e){let t=(0,$.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={mode:`promiseExit`},t[0]=n):n=t[0];let r=Pn(e,n),i;return t[1]===r?i=t[2]:(i=xT(r),t[1]=r,t[2]=i),i}function ME(e){let t=(0,$.c)(9),n;t[0]===e?n=t[1]:(n=bT(kE(e)),t[0]=e,t[1]=n);let r=n,i=jE(r.addMessage),a=jE(r.retryAnswer),o=jE(r.saveMessage),s=jE(r.postMessage),c=jE(r.postSavedMessages),l=jE(r.readBrief),u;return t[2]!==i||t[3]!==a||t[4]!==o||t[5]!==s||t[6]!==c||t[7]!==l?(u={add:i,retry:a,save:o,post:s,postSaved:c,brief:l},t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8],u}function NE(e,t){let n=(0,$.c)(17),r=ME(e),[i,a]=(0,Z.useState)(),o=r.post.waiting||r.postSaved.waiting||r.save.waiting||r.brief.waiting,s;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=e=>a(NT(e)),n[0]=s):s=n[0];let c=s,l;n[1]!==r.brief||n[2]!==t?.id?(l=()=>void r.brief.run(t?.id).then(FE,c),n[1]=r.brief,n[2]=t?.id,n[3]=l):l=n[3];let u=l,d;n[4]!==r.save||n[5]!==t?(d=e=>{t&&r.save.run({messageId:t.id,saved:e}).catch(c)},n[4]=r.save,n[5]=t,n[6]=d):d=n[6];let f=d,p;n[7]!==r.post||n[8]!==r.postSaved||n[9]!==t?(p=()=>{a(void 0),(t?r.post.run(t.id):r.postSaved.run(void 0)).then(e=>{let t=VT(e);t.kind===`brief`&&tr(t.text,`brief`,!1),t.kind===`still-saved`&&a({text:`Still saved: ${t.messages.map(PE).join(`; `)}. These comments belong to a different repository.`,copy:!1})},c)},n[7]=r.post,n[8]=r.postSaved,n[9]=t,n[10]=p):p=n[10];let m=p,h;return n[11]!==u||n[12]!==i||n[13]!==m||n[14]!==f||n[15]!==o?(h={notice:i,waiting:o,copy:u,save:f,post:m},n[11]=u,n[12]=i,n[13]=m,n[14]=f,n[15]=o,n[16]=h):h=n[16],h}function PE(e){return e.text}function FE(e){e&&tr(e,`brief`,!1)}function IE(e,t){let n=(0,$.c)(7),[r,i]=(0,Z.useState)(),a=ME(e),o;n[0]!==a.retry||n[1]!==t?(o=()=>{i(void 0),a.retry.run(t).catch(e=>i(NT(e).text))},n[0]=a.retry,n[1]=t,n[2]=o):o=n[2];let s=o,c;return n[3]!==a.retry.waiting||n[4]!==r||n[5]!==s?(c={failure:r,waiting:a.retry.waiting,retry:s},n[3]=a.retry.waiting,n[4]=r,n[5]=s,n[6]=c):c=n[6],c}function LE(e){let t=(0,$.c)(6),[n,r]=(0,Z.useState)(),i=ME(e),a;t[0]===i.add?a=t[1]:(a=(e,t)=>{r(void 0),i.add.run(e).then(t,e=>r(NT(e).text))},t[0]=i.add,t[1]=a);let o;return t[2]!==i.add.waiting||t[3]!==n||t[4]!==a?(o={failure:n,waiting:i.add.waiting,send:a},t[2]=i.add.waiting,t[3]=n,t[4]=a,t[5]=o):o=t[5],o}function RE(e){let t=(0,$.c)(30),{owner:n,message:r,number:i}=e,{notice:a,waiting:o,copy:s,save:c,post:l}=NE(n,r),u;t[0]===r?u=t[1]:(u=jT(r),t[0]=r,t[1]=u);let d=u,f=i===void 0?s:l,p=Ae(n.context),m=i===void 0?void 0:p,h;t[2]===i?h=t[3]:(h=LT(i),t[2]=i,t[3]=h);let g=h,_;t[4]!==r||t[5]!==d?(_=d===`posted`&&r?.post.status===`posted`?(0,Q.jsx)(`a`,{className:`text-caption text-muted-foreground hover:underline`,href:r.post.url,target:`_blank`,rel:`noreferrer`,children:IT(r.post.url)}):null,t[4]=r,t[5]=d,t[6]=_):_=t[6];let v;t[7]!==c||t[8]!==d||t[9]!==o||t[10]!==p?(v=d===`saved`&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 text-caption text-muted-foreground`,children:[`Saved for later`,(0,Q.jsx)(X,{variant:`link`,size:`sm`,disabled:o||!!p,"aria-description":p,onClick:()=>c(!1),children:`Undo`})]}),t[7]=c,t[8]=d,t[9]=o,t[10]=p,t[11]=v):v=t[11];let y;t[12]!==f||t[13]!==g||t[14]!==r||t[15]!==m||t[16]!==c||t[17]!==d||t[18]!==o||t[19]!==p?(y=d===`available`&&(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Q.jsx)(X,{size:`sm`,variant:r?`outline`:`default`,disabled:o||!!m,"aria-description":m,onClick:f,children:r?g.single:g.together}),r&&(0,Q.jsx)(X,{variant:`link`,size:`sm`,disabled:o||!!p,"aria-description":p,onClick:()=>c(!0),children:`Save for later`})]}),t[12]=f,t[13]=g,t[14]=r,t[15]=m,t[16]=c,t[17]=d,t[18]=o,t[19]=p,t[20]=y):y=t[20];let b;t[21]!==s||t[22]!==a||t[23]!==o?(b=a&&(0,Q.jsxs)(`div`,{role:`status`,className:`text-caption text-muted-foreground`,children:[a.text,a.copy&&(0,Q.jsx)(X,{variant:`link`,size:`sm`,disabled:o,onClick:()=>s(),children:`Copy`})]}),t[21]=s,t[22]=a,t[23]=o,t[24]=b):b=t[24];let x;return t[25]!==_||t[26]!==v||t[27]!==y||t[28]!==b?(x=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[_,v,y,b]}),t[25]=_,t[26]=v,t[27]=y,t[28]=b,t[29]=x):x=t[29],x}function zE(e){let t=(0,$.c)(34),{message:n,children:r,owner:i}=e,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>e=>{if(!e)return;let t=()=>c(e.scrollHeight>e.clientHeight);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},t[0]=l):l=t[0];let[u]=(0,Z.useState)(l),{failure:d,waiting:f,retry:p}=IE(i,n.replyTo),m=n.state,h=Ae(i.context),g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(OE,{children:`Walkthrough agent`}),t[1]=g):g=t[1];let _;t[2]!==a||t[3]!==m.status||t[4]!==m.text?(_=m.status===`answered`?(0,Q.jsx)(`span`,{ref:u,className:a?void 0:`line-clamp-3`,children:(0,Q.jsx)(bE,{text:m.text})}):null,t[2]=a,t[3]=m.status,t[4]=m.text,t[5]=_):_=t[5];let v;t[6]===m.status?v=t[7]:(v=m.status===`answering`&&(0,Q.jsx)(`span`,{role:`status`,className:`text-muted-foreground`,children:`Working…`}),t[6]=m.status,t[7]=v);let y;t[8]!==m.failure||t[9]!==m.status?(y=m.status===`failed`&&(0,Q.jsx)(`span`,{children:m.failure.message}),t[8]=m.failure,t[9]=m.status,t[10]=y):y=t[10];let b;t[11]!==_||t[12]!==v||t[13]!==y?(b=(0,Q.jsx)(CE,{variant:`ghost`,className:`max-w-full`,children:(0,Q.jsxs)(wE,{className:`whitespace-pre-wrap`,children:[_,v,y]})}),t[11]=_,t[12]=v,t[13]=y,t[14]=b):b=t[14];let x;t[15]!==s||t[16]!==a||t[17]!==m.status?(x=m.status===`answered`&&!a&&s&&(0,Q.jsx)(X,{variant:`link`,size:`sm`,onClick:()=>o(!0),children:`Read all`}),t[15]=s,t[16]=a,t[17]=m.status,t[18]=x):x=t[18];let S;t[19]!==p||t[20]!==m.status||t[21]!==f||t[22]!==h?(S=m.status===`failed`&&(0,Q.jsx)(X,{variant:`link`,size:`sm`,disabled:f||!!h,"aria-description":h,onClick:()=>p(),children:`Try again`}),t[19]=p,t[20]=m.status,t[21]=f,t[22]=h,t[23]=S):S=t[23];let C;t[24]!==r||t[25]!==x||t[26]!==S?(C=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[x,S,r]}),t[24]=r,t[25]=x,t[26]=S,t[27]=C):C=t[27];let w;t[28]===d?w=t[29]:(w=d&&(0,Q.jsx)(`p`,{role:`alert`,children:d}),t[28]=d,t[29]=w);let T;return t[30]!==w||t[31]!==b||t[32]!==C?(T=(0,Q.jsx)(EE,{children:(0,Q.jsxs)(DE,{children:[g,b,C,w]})}),t[30]=w,t[31]=b,t[32]=C,t[33]=T):T=t[33],T}function BE({conversation:e,owner:t,number:n}){return RT(e).map(({message:e,reply:r})=>{let i=(0,Q.jsx)(RE,{owner:t,message:e,number:n});return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(EE,{align:`end`,children:(0,Q.jsx)(DE,{children:(0,Q.jsx)(CE,{align:`end`,variant:`secondary`,children:(0,Q.jsx)(wE,{className:`whitespace-pre-wrap`,children:(0,Q.jsx)(bE,{text:e.text})})})})}),r?(0,Q.jsx)(zE,{owner:t,message:r,children:i}):(0,Q.jsx)(`div`,{className:`flex justify-end`,children:i})]},e.id)})}function VE(e){let t=(0,$.c)(35),{owner:n,anchor:r,placeholder:i}=e,[a,o]=(0,Z.useState)(``),s=Ae(n.context),{failure:c,waiting:l,send:u}=LE(n),d;t[0]!==r||t[1]!==a||t[2]!==u||t[3]!==l||t[4]!==s?(d=()=>{let e=a.trim();!e||l||s||u({anchor:r,text:e},()=>o(e=>e===a?``:e))},t[0]=r,t[1]=a,t[2]=u,t[3]=l,t[4]=s,t[5]=d):d=t[5];let f=d,p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>o(e.target.value),t[6]=p):p=t[6];let h;t[7]===f?h=t[8]:(h=e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),f())},t[7]=f,t[8]=h);let g;t[9]!==a||t[10]!==i||t[11]!==h?(g=(0,Q.jsx)(ri,{value:a,rows:1,maxLength:8e3,"aria-label":i,placeholder:i,className:`min-h-9`,onChange:p,onKeyDown:h}),t[9]=a,t[10]=i,t[11]=h,t[12]=g):g=t[12];let _;t[13]!==a||t[14]!==l||t[15]!==s?(_=!a.trim()||l||!!s,t[13]=a,t[14]=l,t[15]=s,t[16]=_):_=t[16];let v;t[17]===f?v=t[18]:(v=()=>f(),t[17]=f,t[18]=v);let b;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(Er,{}),t[19]=b):b=t[19];let x;t[20]!==_||t[21]!==v||t[22]!==s?(x=(0,Q.jsx)(Gt,{render:(0,Q.jsx)(Si,{size:`icon-xs`,variant:`default`,"aria-label":`Send`,disabled:_,"aria-description":s,onClick:v,children:b})}),t[20]=_,t[21]=v,t[22]=s,t[23]=x):x=t[23];let S;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Q.jsx)(m,{children:`Send`}),t[24]=S):S=t[24];let C;t[25]===x?C=t[26]:(C=(0,Q.jsx)(vi,{align:`inline-end`,children:(0,Q.jsxs)(y,{children:[x,S]})}),t[25]=x,t[26]=C);let w;t[27]!==C||t[28]!==g?(w=(0,Q.jsxs)(mo,{children:[g,C]}),t[27]=C,t[28]=g,t[29]=w):w=t[29];let T;t[30]===c?T=t[31]:(T=c&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-caption text-destructive`,children:c}),t[30]=c,t[31]=T);let E;return t[32]!==w||t[33]!==T?(E=(0,Q.jsxs)(Q.Fragment,{children:[w,T]}),t[32]=w,t[33]=T,t[34]=E):E=t[34],E}function HE(e){let t=(0,$.c)(22),{owner:n,title:r,call:i}=e,{view:a,failed:o,refresh:s}=AE(n),c,l,u;if(t[0]!==o||t[1]!==n||t[2]!==s||t[3]!==r||t[4]!==a){let e=zT(a,r);c=`flex flex-col gap-3`,t[8]!==o||t[9]!==s?(l=o&&(0,Q.jsxs)(`p`,{role:`alert`,className:`text-caption`,children:[`Comments could not be read.`,` `,(0,Q.jsx)(X,{variant:`link`,size:`sm`,onClick:s,children:`Try again`})]}),t[8]=o,t[9]=s,t[10]=l):l=t[10],u=e.length>0&&(0,Q.jsx)(`div`,{className:`border-t pt-3`,children:(0,Q.jsx)(TE,{children:e.map(e=>(0,Q.jsx)(BE,{owner:n,conversation:e,number:a?.pullRequestNumber},e.runId))})}),t[0]=o,t[1]=n,t[2]=s,t[3]=r,t[4]=a,t[5]=c,t[6]=l,t[7]=u}else c=t[5],l=t[6],u=t[7];let d;t[11]===r?d=t[12]:(d={kind:`stop`,title:r},t[11]=r,t[12]=d);let f=i?`Decide, or ask about this`:`Ask about this step`,p;t[13]!==n||t[14]!==d||t[15]!==f?(p=(0,Q.jsx)(VE,{owner:n,anchor:d,placeholder:f}),t[13]=n,t[14]=d,t[15]=f,t[16]=p):p=t[16];let m;return t[17]!==c||t[18]!==l||t[19]!==u||t[20]!==p?(m=(0,Q.jsxs)(`div`,{className:c,children:[l,u,p]}),t[17]=c,t[18]=l,t[19]=u,t[20]=p,t[21]=m):m=t[21],m}function UE(e){let t=(0,$.c)(19),{owner:n,titles:r}=e,{view:i}=AE(n),a,o,s,c,l;if(t[0]!==n||t[1]!==r||t[2]!==i){l=Symbol.for(`react.early_return_sentinel`);bb0:{let e=MT(i,r);if(e.length===0){l=null;break bb0}s=`flex flex-col gap-3 border-t pt-5`,t[8]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(`h2`,{className:`text-ui font-semibold`,children:`Earlier comments`}),t[8]=c):c=t[8],a=TE;let u;t[9]!==n||t[10]!==i?.pullRequestNumber?(u=(e,t)=>(0,Q.jsx)(BE,{owner:n,conversation:e,number:i?.pullRequestNumber},`${e.runId}:${t}`),t[9]=n,t[10]=i?.pullRequestNumber,t[11]=u):u=t[11],o=e.map(u)}t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else a=t[3],o=t[4],s=t[5],c=t[6],l=t[7];if(l!==Symbol.for(`react.early_return_sentinel`))return l;let u;t[12]!==a||t[13]!==o?(u=(0,Q.jsx)(a,{children:o}),t[12]=a,t[13]=o,t[14]=u):u=t[14];let d;return t[15]!==s||t[16]!==c||t[17]!==u?(d=(0,Q.jsxs)(`section`,{className:s,children:[c,u]}),t[15]=s,t[16]=c,t[17]=u,t[18]=d):d=t[18],d}function WE(e){let t=(0,$.c)(10),{owner:n}=e,{view:r}=AE(n),i;t[0]===r?i=t[1]:(i=BT(r),t[0]=r,t[1]=i);let a=i;if(!a)return null;let o;t[2]===a?o=t[3]:(o=(0,Q.jsx)(`span`,{children:a}),t[2]=a,t[3]=o);let s=r?.pullRequestNumber,c;t[4]!==n||t[5]!==s?(c=(0,Q.jsx)(RE,{owner:n,number:s}),t[4]=n,t[5]=s,t[6]=c):c=t[6];let l;return t[7]!==o||t[8]!==c?(l=(0,Q.jsx)(`div`,{className:`sticky bottom-4 z-30 flex justify-center`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-3 rounded-full border bg-popover py-1.5 pr-1.5 pl-4 text-ui shadow-sm`,children:[o,c]})}),t[7]=o,t[8]=c,t[9]=l):l=t[9],l}function GE(e){let t=(0,$.c)(69),{run:n,requesting:r,reused:i,freshness:a,failure:o,onUpdate:s,writeBlock:c}=e,l=r!==void 0&&r,u=i!==void 0&&i,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T;if(t[0]!==o||t[1]!==a||t[2]!==s||t[3]!==l||t[4]!==u||t[5]!==n||t[6]!==c){v=Symbol.for(`react.early_return_sentinel`);bb0:{if(d=oE(n,l),n.state.status===`ready`&&!d.active&&!l&&!o){let e=a===`changed`,r;t[22]!==e||t[23]!==u||t[24]!==n.state.writtenAt?(r=u&&!e?`Already up to date: the saved walkthrough was reused.`:(0,Q.jsxs)(Q.Fragment,{children:[`Saved`,` `,(0,Q.jsx)(`time`,{dateTime:n.state.writtenAt,children:new Date(n.state.writtenAt).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}),e&&` · Behind the current work`]}),t[22]=e,t[23]=u,t[24]=n.state.writtenAt,t[25]=r):r=t[25];let i;t[26]===r?i=t[27]:(i=(0,Q.jsx)(`p`,{role:`status`,children:r}),t[26]=r,t[27]=i);let o;t[28]!==e||t[29]!==s||t[30]!==c?(o=s&&(0,Q.jsx)(X,{size:`sm`,variant:e?`outline`:`ghost`,disabled:!!c,"aria-description":c,onClick:s,children:`Update walkthrough`}),t[28]=e,t[29]=s,t[30]=c,t[31]=o):o=t[31];let l;t[32]!==i||t[33]!==o?(l=(0,Q.jsxs)(`section`,{"aria-label":`Walkthrough status`,className:`flex flex-wrap items-center justify-between gap-2 text-caption text-muted-foreground`,children:[i,o]}),t[32]=i,t[33]=o,t[34]=l):l=t[34],v=l;break bb0}S=`Walkthrough status`,C=`flex flex-col gap-3 rounded-lg border p-4 text-ui`,w=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{role:`status`,className:`font-medium`,children:d.label}),!d.active&&s&&(0,Q.jsx)(X,{size:`sm`,variant:`outline`,disabled:!!c,"aria-description":c,onClick:s,children:o?`Try again`:`Update walkthrough`})]}),t[35]!==n.state.status||t[36]!==n.state.writtenAt?(T=n.state.status===`ready`&&(0,Q.jsxs)(`p`,{className:`text-caption text-muted-foreground`,children:[`Last written`,` `,(0,Q.jsx)(`time`,{dateTime:n.state.writtenAt,children:new Date(n.state.writtenAt).toLocaleString()})]}),t[35]=n.state.status,t[36]=n.state.writtenAt,t[37]=T):T=t[37],t[38]!==l||t[39]!==u?(f=u&&!l&&(0,Q.jsx)(`p`,{className:`text-caption text-muted-foreground`,children:`This snapshot already has a walkthrough. The saved version was reused.`}),t[38]=l,t[39]=u,t[40]=f):f=t[40];let e=`${d.completed/d.total*100}%`,r;t[41]===e?r=t[42]:(r=(0,Q.jsx)(`div`,{className:`h-full bg-primary`,style:{width:e}}),t[41]=e,t[42]=r),p=(0,Q.jsx)(`div`,{role:`progressbar`,"aria-label":`Walkthrough stages`,"aria-valuemin":0,"aria-valuemax":d.total,"aria-valuenow":d.completed,"aria-valuetext":d.label,className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:r}),m=(0,Q.jsx)(`ol`,{"aria-label":`Update stages`,className:`flex flex-wrap gap-x-3 gap-y-1 text-caption text-muted-foreground`,children:d.steps.map((e,t)=>(0,Q.jsxs)(`li`,{"aria-current":!l&&t===d.completed?`step`:void 0,children:[t+1,`. `,e]},e))}),t[43]===l?h=t[44]:(h=l&&(0,Q.jsx)(`p`,{children:`Sending the request and capturing the current work.`}),t[43]=l,t[44]=h),g=a&&(d.active||sE(a))&&(0,Q.jsx)(`p`,{className:`text-foreground-2`,children:d.active?`Showing the saved walkthrough while the update runs.`:sE(a)}),t[45]===o?_=t[46]:(_=o&&(0,Q.jsxs)(`p`,{role:`alert`,children:[aT(o.failure,o.writer).title,o.failure.kind!==`signed_out`&&` ${o.failure.message}`]}),t[45]=o,t[46]=_),t[47]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(`summary`,{className:`cursor-pointer text-muted-foreground`,children:`Update log`}),t[47]=x):x=t[47],y=`mt-2 flex flex-col gap-2 text-caption text-foreground-2`,b=d.entries.map(KE)}t[0]=o,t[1]=a,t[2]=s,t[3]=l,t[4]=u,t[5]=n,t[6]=c,t[7]=d,t[8]=f,t[9]=p,t[10]=m,t[11]=h,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}else d=t[7],f=t[8],p=t[9],m=t[10],h=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];if(v!==Symbol.for(`react.early_return_sentinel`))return v;let E;t[48]===d.entries.length?E=t[49]:(E=d.entries.length===0&&(0,Q.jsx)(`li`,{children:`This walkthrough predates the update log. Its recorded status is shown above.`}),t[48]=d.entries.length,t[49]=E);let D;t[50]!==E||t[51]!==y||t[52]!==b?(D=(0,Q.jsxs)(`ol`,{className:y,children:[b,E]}),t[50]=E,t[51]=y,t[52]=b,t[53]=D):D=t[53];let O;t[54]!==D||t[55]!==x?(O=(0,Q.jsxs)(`details`,{children:[x,D]}),t[54]=D,t[55]=x,t[56]=O):O=t[56];let k;return t[57]!==f||t[58]!==p||t[59]!==m||t[60]!==h||t[61]!==g||t[62]!==_||t[63]!==O||t[64]!==S||t[65]!==C||t[66]!==w||t[67]!==T?(k=(0,Q.jsxs)(`section`,{"aria-label":S,className:C,children:[w,T,f,p,m,h,g,_,O]}),t[57]=f,t[58]=p,t[59]=m,t[60]=h,t[61]=g,t[62]=_,t[63]=O,t[64]=S,t[65]=C,t[66]=w,t[67]=T,t[68]=k):k=t[68],k}function KE(e,t){return(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`time`,{dateTime:e.at,className:`mr-2 font-mono`,children:new Date(e.at).toLocaleString()}),e.message]},`${e.at}:${t}`)}function qE(e){let t=(0,$.c)(12),{label:n,icon:r,disabled:i,onClick:a}=e,o;t[0]!==i||t[1]!==n||t[2]!==a?(o=(0,Q.jsx)(X,{size:`icon-sm`,variant:`ghost`,"aria-label":n,disabled:i,onClick:a}),t[0]=i,t[1]=n,t[2]=a,t[3]=o):o=t[3];let s;t[4]!==r||t[5]!==o?(s=(0,Q.jsx)(Gt,{render:o,children:r}),t[4]=r,t[5]=o,t[6]=s):s=t[6];let c;t[7]===n?c=t[8]:(c=(0,Q.jsx)(m,{children:n}),t[7]=n,t[8]=c);let l;return t[9]!==s||t[10]!==c?(l=(0,Q.jsxs)(y,{children:[s,c]}),t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function JE(e){let t=(0,$.c)(11),{scope:n,context:r,run:i,item:a,className:o,opened:s}=e,c=s!==void 0&&s,l;t[0]!==r||t[1]!==a.assetId||t[2]!==i.id||t[3]!==n?(l={scope:n,context:r,runId:i.id,assetId:a.assetId},t[0]=r,t[1]=a.assetId,t[2]=i.id,t[3]=n,t[4]=l):l=t[4];let{url:u,retry:d}=_E(l);if(Kt(u)){let e;return t[5]!==o||t[6]!==u.value?(e=(0,Q.jsx)(`img`,{src:u.value,alt:``,loading:`lazy`,decoding:`async`,className:o}),t[5]=o,t[6]=u.value,t[7]=e):e=t[7],e}if(!c)return null;if(h(u)&&!u.waiting){let e;return t[8]===d?e=t[9]:(e=(0,Q.jsx)(gr,{role:`alert`,message:`This screenshot could not be loaded.`,action:(0,Q.jsx)(X,{variant:`outline`,size:`sm`,onClick:d,children:`Try again`})}),t[8]=d,t[9]=e),e}let f;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(`div`,{className:`grid min-h-48 place-items-center`,children:(0,Q.jsx)(ee,{label:`Reading the screenshot`})}),t[10]=f):f=t[10],f}function YE(e){let t=(0,$.c)(34),{scope:n,context:r,run:i,items:a}=e,[o,s]=(0,Z.useState)(null),c=o===null?void 0:a[o],l;if(t[0]!==r||t[1]!==a||t[2]!==i||t[3]!==n){let e;t[5]!==r||t[6]!==i||t[7]!==n?(e=(e,t)=>(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Enlarge screenshot ${t+1}`,onClick:()=>s(t),className:`group flex w-34 shrink-0 flex-col gap-1.5 text-left`,children:[(0,Q.jsx)(JE,{scope:n,context:r,run:i,item:e,className:`h-56 w-full rounded-lg border object-cover object-top transition-opacity group-hover:opacity-85`}),(0,Q.jsx)(`span`,{className:`line-clamp-3 text-caption leading-4 text-muted-foreground`,children:(0,Q.jsx)(bE,{text:e.shows})})]},e.assetId),t[5]=r,t[6]=i,t[7]=n,t[8]=e):e=t[8],l=a.map(e),t[0]=r,t[1]=a,t[2]=i,t[3]=n,t[4]=l}else l=t[4];let u;t[9]===l?u=t[10]:(u=(0,Q.jsx)(`div`,{className:`-mx-5 flex gap-3 overflow-x-auto px-5 pb-1 @3xl:-mx-0 @3xl:px-0`,children:l}),t[9]=l,t[10]=u);let d=c!==void 0,f;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(f=e=>{e||s(null)},t[11]=f):f=t[11];let p;t[12]===c?p=t[13]:(p=c&&(0,Q.jsx)(bE,{text:c.shows}),t[12]=c,t[13]=p);let m;t[14]===p?m=t[15]:(m=(0,Q.jsx)(Xo,{children:p}),t[14]=p,t[15]=m);let h;t[16]!==r||t[17]!==i||t[18]!==n||t[19]!==c?(h=c&&(0,Q.jsx)(JE,{scope:n,context:r,run:i,item:c,className:`mx-auto max-h-[72vh] rounded-lg border`,opened:!0}),t[16]=r,t[17]=i,t[18]=n,t[19]=c,t[20]=h):h=t[20];let g;t[21]!==a.length||t[22]!==o?(g=a.length>1&&o!==null&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-center gap-3 text-caption text-muted-foreground`,children:[(0,Q.jsx)(qE,{label:`Previous screenshot`,icon:(0,Q.jsx)(ml,{}),disabled:o===0,onClick:()=>s(o-1)}),o+1,` of `,a.length,(0,Q.jsx)(qE,{label:`Next screenshot`,icon:(0,Q.jsx)(me,{}),disabled:o===a.length-1,onClick:()=>s(o+1)})]}),t[21]=a.length,t[22]=o,t[23]=g):g=t[23];let _;t[24]!==m||t[25]!==h||t[26]!==g?(_=(0,Q.jsxs)(Ja,{className:`max-h-[92vh] overflow-auto sm:max-w-[min(92vw,52rem)]`,children:[m,h,g]}),t[24]=m,t[25]=h,t[26]=g,t[27]=_):_=t[27];let v;t[28]!==d||t[29]!==_?(v=(0,Q.jsx)(Fi,{open:d,onOpenChange:f,children:_}),t[28]=d,t[29]=_,t[30]=v):v=t[30];let y;return t[31]!==v||t[32]!==u?(y=(0,Q.jsxs)(Q.Fragment,{children:[u,v]}),t[31]=v,t[32]=u,t[33]=y):y=t[33],y}function XE(e,t){let n=md(e,[{startLine:t.start,endLine:t.end}],3,t.side);if(n)try{return mi(n,{throwOnError:!0})}catch{return}}function ZE(e){let t=(0,$.c)(24),{document:n,runId:r,step:i,excerpt:a}=e,{result:o,retry:s}=vE(n.scope,n.context,r,i),{dark:c}=$s();if(se(o)){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(ee,{label:`Loading captured lines`}),t[0]=e):e=t[0],e}if(h(o)){let e;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(`p`,{children:`The captured diff could not be read.`}),t[1]=e):e=t[1];let n;return t[2]===s?n=t[3]:(n=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-prose`,role:`alert`,children:[e,(0,Q.jsx)(X,{size:`sm`,variant:`outline`,onClick:s,children:`Try again`})]}),t[2]=s,t[3]=n),n}let l=o.value,u;t[4]!==l.capturedPatch||t[5]!==l.walkthrough?.id||t[6]!==a||t[7]!==r?(u=l.walkthrough?.id===r&&l.capturedPatch?XE(l.capturedPatch,a):void 0,t[4]=l.capturedPatch,t[5]=l.walkthrough?.id,t[6]=a,t[7]=r,t[8]=u):u=t[8];let d=u;if(!d){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(`p`,{children:`These lines are unavailable in the saved walkthrough.`}),t[9]=e):e=t[9];let r;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsx)(X,{variant:`outline`,size:`sm`}),t[10]=r):r=t[10];let a;return t[11]!==n||t[12]!==i?(a=(0,Q.jsxs)(`div`,{className:`flex flex-col items-start gap-3 text-prose`,children:[e,(0,Q.jsx)(yr,{render:r,onClick:()=>n.onOpen({kind:`walkthrough-step`,step:i}),children:`Open step code`})]}),t[11]=n,t[12]=i,t[13]=a):a=t[13],a}let f=a.side===`old`?`deletions`:`additions`,p=c?`dark`:`light`,m;t[14]===p?m=t[15]:(m={preferredHighlighter:Us,theme:ac,themeType:p,overflow:`wrap`,disableFileHeader:!0,unsafeCSS:sc,diffStyle:`unified`},t[14]=p,t[15]=m);let g;t[16]!==a.end||t[17]!==a.start||t[18]!==f?(g={start:a.start,end:a.end,side:f,endSide:f},t[16]=a.end,t[17]=a.start,t[18]=f,t[19]=g):g=t[19];let _;return t[20]!==d||t[21]!==m||t[22]!==g?(_=(0,Q.jsx)(`div`,{className:`min-w-0 overflow-auto rounded-lg border`,children:(0,Q.jsx)(Ag,{fileDiff:d,options:m,selectedLines:g})}),t[20]=d,t[21]=m,t[22]=g,t[23]=_):_=t[23],_}function QE(e){let t=(0,$.c)(21),[n,r]=(0,Z.useState)(!1),{excerpt:i}=e,a=i.start===i.end?`line ${i.start}`:`lines ${i.start}–${i.end}`,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsxs)(po,{render:(0,Q.jsx)(X,{className:`self-start`,size:`sm`,variant:`outline`}),children:[(0,Q.jsx)(cl,{}),`See the lines`]}),t[0]=o):o=t[0];let s,c;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsxs)(yr,{render:(0,Q.jsx)(X,{size:`sm`,variant:`ghost`,className:`-ml-2 self-start`}),children:[(0,Q.jsx)(fl,{}),`Back to step`]}),c=(0,Q.jsx)(Xo,{children:`Captured diff`}),t[1]=s,t[2]=c):(s=t[1],c=t[2]);let l=i.side===`old`?`Old`:`New`,u;t[3]!==i.path||t[4]!==a||t[5]!==l?(u=(0,Q.jsx)(rs,{children:(0,Q.jsxs)(`span`,{className:`font-mono break-all`,children:[i.path,` · `,l,` `,a]})}),t[3]=i.path,t[4]=a,t[5]=l,t[6]=u):u=t[6];let d;t[7]===i.caption?d=t[8]:(d=i.caption&&(0,Q.jsx)(`p`,{className:`text-prose`,children:(0,Q.jsx)(bE,{text:i.caption})}),t[7]=i.caption,t[8]=d);let f;t[9]!==u||t[10]!==d?(f=(0,Q.jsxs)(Po,{className:`min-w-0`,children:[s,c,u,d]}),t[9]=u,t[10]=d,t[11]=f):f=t[11];let p;t[12]!==n||t[13]!==e?(p=n&&(0,Q.jsx)(ZE,{...e}),t[12]=n,t[13]=e,t[14]=p):p=t[14];let m;t[15]!==f||t[16]!==p?(m=(0,Q.jsxs)(Ja,{className:`max-h-[calc(100dvh-2rem)] overflow-auto sm:max-w-2xl`,showCloseButton:!1,children:[f,p]}),t[15]=f,t[16]=p,t[17]=m):m=t[17];let h;return t[18]!==n||t[19]!==m?(h=(0,Q.jsxs)(Fi,{open:n,onOpenChange:r,children:[o,m]}),t[18]=n,t[19]=m,t[20]=h):h=t[20],h}function $E(e){let t=(0,$.c)(33),{document:n,waiting:r,onWrite:i}=e,{connection:a}=n.context,o=Ae(n.context),s=f(),c;t[0]===a?c=t[1]:(c=Xt(a),t[0]=a,t[1]=c);let l=c,u=$t(l),d=_n(l),p=ne(J(u)),m;t[2]===n.scope?m=t[3]:(m=e=>e.id===n.scope.projectId,t[2]=n.scope,t[3]=m);let g=Aa(a).projects.find(m),_=p?Ls(p,g?.walkthroughSettings?.writer):void 0,v=cs(n.scope,a,n.base===void 0),y;t[4]===v.result?y=t[5]:(y=ne(J(v.result)),t[4]=v.result,t[5]=y);let b=y,x=n.base??b?.defaultRef,C;t[6]===u?C=t[7]:(C=h(u),t[6]=u,t[7]=C);let w=C,T=p?.models.length===0,E;t[8]===u.waiting?E=t[9]:(E=u.waiting&&(0,Q.jsx)(S,{"aria-hidden":`true`}),t[8]=u.waiting,t[9]=E);let O;t[10]!==d||t[11]!==u.waiting||t[12]!==E?(O=(0,Q.jsxs)(X,{variant:`outline`,size:`sm`,disabled:u.waiting,onClick:d,children:[E,`Check writers again`]}),t[10]=d,t[11]=u.waiting,t[12]=E,t[13]=O):O=t[13];let k=O,A;t[14]!==x||t[15]!==_?(A=_?`Since ${x?U_(x):`the default branch`} · ${_.label}`:void 0,t[14]=x,t[15]=_,t[16]=A):A=t[16];let j=A,M=!!o||r||!_?.available,N;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Q.jsx)(Xl,{"data-icon":`inline-start`}),t[17]=N):N=t[17];let P;t[18]!==i||t[19]!==M||t[20]!==o?(P=(0,Q.jsxs)(X,{size:`sm`,disabled:M,"aria-description":o,onClick:i,children:[N,`Write walkthrough`]}),t[18]=i,t[19]=M,t[20]=o,t[21]=P):P=t[21];let F=P;if(w)j=`Could not check writers on the connected computer.`,F=k;else if(T)j=`Sign in to Claude Code or Codex on the connected computer.`,F=k;else if(_&&!_.available){j=`${_.label} is unavailable.`;let e;t[22]!==a||t[23]!==s?.environmentId||t[24]!==g?(e=g?.walkthroughSettings?.writer?(0,Q.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>Ba.openWithPayload({project:g,remote:a.environmentId===s?.environmentId?null:a.environmentId}),children:`Project walkthrough settings`}):(0,Q.jsx)(Sn,{to:`/settings/$section`,params:{section:`git`},className:D({variant:`outline`,size:`sm`}),children:`Settings → Changes & Git`}),t[22]=a,t[23]=s?.environmentId,t[24]=g,t[25]=e):e=t[25],F=e}let I;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Q.jsx)(`h1`,{className:`text-section font-semibold`,children:`No walkthrough yet.`}),t[26]=I):I=t[26];let L;t[27]!==w||t[28]!==j?(L=j&&(0,Q.jsx)(`p`,{role:w?`alert`:void 0,className:`min-w-0 text-ui text-muted-foreground`,children:j}),t[27]=w,t[28]=j,t[29]=L):L=t[29];let R;return t[30]!==F||t[31]!==L?(R=(0,Q.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[I,L,F]}),t[30]=F,t[31]=L,t[32]=R):R=t[32],R}function eD(e){let t=(0,$.c)(42),n,r;t[0]===e?(n=t[1],r=t[2]):({document:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=dE(r.scope,r.context),a=fE(r.scope,r.context,r.base),o=n.step,s=i?.content.stops[o-1];if(!i||!s){let e;return t[3]===r?e=t[4]:(e=(0,Q.jsx)(gr,{message:`The walkthrough changed since this tab was opened.`,action:(0,Q.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>r.onOpen({kind:`review`}),children:`Open review`})}),t[3]=r,t[4]=e),e}let c=i.content.stops.length,l=`Step ${o} of ${c}`,u;t[5]===l?u=t[6]:(u=(0,Q.jsx)(`span`,{className:`mr-2 font-normal text-muted-foreground`,children:l}),t[5]=l,t[6]=u);let d;t[7]===s.title?d=t[8]:(d=(0,Q.jsx)(bE,{text:s.title}),t[7]=s.title,t[8]=d);let f;t[9]!==u||t[10]!==d?(f=(0,Q.jsxs)(Q.Fragment,{children:[u,d]}),t[9]=u,t[10]=d,t[11]=f):f=t[11];let p;t[12]===s.title?p=t[13]:(p=dT(s.title),t[12]=s.title,t[13]=p);let m=`${l}: ${p}`,h;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Q.jsx)(ml,{}),t[14]=h):h=t[14];let g=o===1,_;t[15]!==r||t[16]!==o?(_=()=>r.onOpen({kind:`walkthrough-step`,step:o-1}),t[15]=r,t[16]=o,t[17]=_):_=t[17];let v;t[18]!==g||t[19]!==_?(v=(0,Q.jsx)(qE,{label:`Previous step`,icon:h,disabled:g,onClick:_}),t[18]=g,t[19]=_,t[20]=v):v=t[20];let y;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(me,{}),t[21]=y):y=t[21];let b=o===c,x;t[22]!==r||t[23]!==o?(x=()=>r.onOpen({kind:`walkthrough-step`,step:o+1}),t[22]=r,t[23]=o,t[24]=x):x=t[24];let S;t[25]!==b||t[26]!==x?(S=(0,Q.jsx)(qE,{label:`Next step`,icon:y,disabled:b,onClick:x}),t[25]=b,t[26]=x,t[27]=S):S=t[27];let C;t[28]!==S||t[29]!==v?(C=(0,Q.jsxs)(`span`,{className:`flex items-center`,children:[v,S]}),t[28]=S,t[29]=v,t[30]=C):C=t[30];let w;t[31]!==C||t[32]!==f||t[33]!==m?(w={title:f,titleLabel:m,after:C},t[31]=C,t[32]=f,t[33]=m,t[34]=w):w=t[34];let T=w,E;t[35]!==a||t[36]!==s?(E=$w(s,a),t[35]=a,t[36]=s,t[37]=E):E=t[37];let D=E,O;return t[38]!==T||t[39]!==D||t[40]!==r?(O=(0,Q.jsx)(aD,{...r,only:D,heading:T}),t[38]=T,t[39]=D,t[40]=r,t[41]=O):O=t[41],O}function tD(e){let t=(0,$.c)(34),{document:n,entry:r,code:i,label:a,branch:o,eager:s}=e,[c,l]=(0,Z.useState)(25),[u,d]=(0,Z.useState)(s);s&&!u&&d(!0);let f;t[0]!==o||t[1]!==i?(f=o?i.branch:[],t[0]=o,t[1]=i,t[2]=f):f=t[2];let p=f;if(p.length===0&&i.worktree.length===0)return null;if(!u){let e=`Code: ${a}`,n;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(n=nD(()=>d(!0)),t[3]=n):n=t[3];let r;t[4]===p?r=t[5]:(r=(0,Q.jsx)(rD,{title:`Branch`,paths:p}),t[4]=p,t[5]=r);let o;t[6]!==i.worktree||t[7]!==c?(o=i.worktree.slice(0,c),t[6]=i.worktree,t[7]=c,t[8]=o):o=t[8];let s;t[9]===o?s=t[10]:(s=(0,Q.jsx)(rD,{title:`Uncommitted`,paths:o}),t[9]=o,t[10]=s);let l;return t[11]!==e||t[12]!==r||t[13]!==s?(l=(0,Q.jsxs)(`div`,{role:`group`,"aria-label":e,ref:n,className:`-mx-5 flex flex-col gap-2 @3xl:-mx-8`,children:[r,s]}),t[11]=e,t[12]=r,t[13]=s,t[14]=l):l=t[14],l}let m;t[15]!==n.interaction||t[16]!==r?(m=e=>({...n.interaction,active:!1,quiet:!0,toolbarTarget:null,fileTarget:void 0,entry:`${r}:${e}`}),t[15]=n.interaction,t[16]=r,t[17]=m):m=t[17];let h=m,g=`Code: ${a}`,_;t[18]!==o||t[19]!==p||t[20]!==n||t[21]!==h||t[22]!==a?(_=p.length>0&&(0,Q.jsx)(`section`,{"aria-label":`${a}: branch`,className:`flex flex-col`,children:(0,Q.jsx)(aS,{...n,compared:o,only:p,fullHeight:!0,interaction:h(`branch`),heading:{title:`Branch`,titleLabel:`${a}: branch`}})}),t[18]=o,t[19]=p,t[20]=n,t[21]=h,t[22]=a,t[23]=_):_=t[23];let v;t[24]!==i.worktree||t[25]!==n||t[26]!==h||t[27]!==a||t[28]!==c?(v=i.worktree.length>0&&(0,Q.jsx)(`section`,{"aria-label":`${a}: uncommitted`,className:`flex flex-col`,children:(0,Q.jsx)(XC,{...n,only:i.worktree,limit:c,onReadMore:()=>l(c+25),fullHeight:!0,interaction:h(`uncommitted`),heading:{title:`Uncommitted`,titleLabel:`${a}: uncommitted`}})}),t[24]=i.worktree,t[25]=n,t[26]=h,t[27]=a,t[28]=c,t[29]=v):v=t[29];let y;return t[30]!==g||t[31]!==_||t[32]!==v?(y=(0,Q.jsxs)(`div`,{role:`group`,"aria-label":g,className:`-mx-5 flex flex-col gap-2 @3xl:-mx-8`,children:[_,v]}),t[30]=g,t[31]=_,t[32]=v,t[33]=y):y=t[33],y}function nD(e){return t=>{if(!t)return;let n=new IntersectionObserver(t=>{t.some(e=>e.isIntersecting)&&e()},{root:t.closest(`[data-review-scroll]`),rootMargin:`600px 0px`});return n.observe(t),()=>n.disconnect()}}function rD(e){let t=(0,$.c)(9),{title:n,paths:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`h3`,{className:`border-b px-4 py-2.5 text-ui font-semibold`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,25).map(iD),t[2]=r,t[3]=a);let o;t[4]===a?o=t[5]:(o=(0,Q.jsx)(`ul`,{children:a}),t[4]=a,t[5]=o);let s;return t[6]!==i||t[7]!==o?(s=(0,Q.jsxs)(`section`,{className:`flex flex-col`,children:[i,o]}),t[6]=i,t[7]=o,t[8]=s):s=t[8],s}function iD(e){return(0,Q.jsx)(`li`,{className:`min-h-40 px-4 py-3 font-mono text-caption text-muted-foreground`,children:e},e)}function aD(e){let t=(0,$.c)(9),n=Ds(e.scope,e.context.connection),[r,i]=(0,Z.useState)(`branch`),a;t[0]!==n||t[1]!==r||t[2]!==e?(a=t=>{let{branch:a,worktree:o}=pT({branch:t.files,worktree:n.changes,only:e.only}),s=a.length>0&&o.length>0,c=t=>({...e.interaction,active:e.interaction.active&&(!s||r===t),toolbarTarget:s&&r!==t?null:e.interaction.toolbarTarget,entry:s?`${e.interaction.entry}:${t}`:e.interaction.entry});return(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,Q.jsx)(Xx,{scope:e.scope,context:e.context,interaction:e.interaction,branchFiles:t.files,changes:n,committed:a,dirty:o,range:La(t)}),s&&(0,Q.jsx)(Ux,{inline:!0,title:e.heading.title,titleLabel:e.heading.titleLabel,children:e.heading.after}),(0,Q.jsxs)(`div`,{className:s?`min-h-0 flex-1 overflow-auto`:`flex min-h-0 flex-1 flex-col`,children:[a.length>0&&(0,Q.jsx)(`section`,{"aria-label":`Branch code`,className:`flex min-h-0 flex-1 flex-col`,onFocusCapture:()=>i(`branch`),onPointerDownCapture:()=>i(`branch`),children:(0,Q.jsx)(aS,{...e,only:a,fullHeight:s,interaction:c(`branch`),heading:s?{title:`Branch`,titleLabel:`Branch`}:e.heading})}),o.length>0&&(0,Q.jsx)(`section`,{"aria-label":`Uncommitted code`,className:`flex min-h-0 flex-1 flex-col`,onFocusCapture:()=>i(`uncommitted`),onPointerDownCapture:()=>i(`uncommitted`),children:(0,Q.jsx)(XC,{...e,only:o,fullHeight:s,interaction:c(`uncommitted`),heading:s?{title:`Uncommitted`,titleLabel:`Uncommitted`}:e.heading})}),a.length===0&&o.length===0&&(0,Q.jsx)(gr,{message:`These files no longer have changes.`})]})]})},t[0]=n,t[1]=r,t[2]=e,t[3]=a):a=t[3];let o;return t[4]!==e.base||t[5]!==e.context||t[6]!==e.scope||t[7]!==a?(o=(0,Q.jsx)(mx,{scope:e.scope,context:e.context,base:e.base,children:a}),t[4]=e.base,t[5]=e.context,t[6]=e.scope,t[7]=a,t[8]=o):o=t[8],o}var oD=e=>document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`}),sD=e=>`walkthrough-step-${e}`;function cD(e){let t=(0,$.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Q.jsx)(`div`,{className:`mx-auto flex w-full max-w-180 flex-col gap-10 px-5 py-8 @3xl:px-8 @3xl:py-12`,children:n}),t[0]=n,t[1]=r),r}function lD(e){let t=(0,$.c)(8),{run:n,content:r}=e,i;t[0]!==r||t[1]!==n?(i=QT(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a;t[3]===n?a=t[4]:(a=nE(n)?`\n${nE(n)}`:``,t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,Q.jsxs)(`p`,{className:`whitespace-pre-line font-mono text-caption text-muted-foreground`,children:[i,a]}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function uD(e){let t=(0,$.c)(10),{content:n}=e,r;if(t[0]!==n.title){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\.$/,t[2]=e):e=t[2],r=n.title.replace(e,``),t[0]=n.title,t[1]=r}else r=t[1];let i;t[3]===r?i=t[4]:(i=(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[r,`.`]}),t[3]=r,t[4]=i);let a;t[5]===n?a=t[6]:(a=Qw(n),t[5]=n,t[6]=a);let o;return t[7]!==i||t[8]!==a?(o=(0,Q.jsxs)(`h1`,{className:`text-subpage-title font-semibold tracking-tight text-balance @3xl:text-page-title`,children:[i,` `,a]}),t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function dD(e){let t=(0,$.c)(8),[n,r]=(0,Z.useState)(!1),i;t[0]!==e||t[1]!==n?(i=e(n),t[0]=e,t[1]=n,t[2]=i):i=t[2];let a=i,o;t[3]===a.hidden?o=t[4]:(o=a.hidden>0?(0,Q.jsx)(fD,{hidden:a.hidden,onClick:()=>r(!0)}):null,t[3]=a.hidden,t[4]=o);let s;return t[5]!==a||t[6]!==o?(s={...a,more:o},t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function fD(e){let t=(0,$.c)(3),{hidden:n,onClick:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,Q.jsx)(`div`,{className:`-ml-2`,children:(0,Q.jsxs)(X,{variant:`link`,size:`sm`,onClick:r,children:[n,` more`]})}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function pD(e){let t=(0,$.c)(10),{content:n}=e,r;t[0]===n?r=t[1]:(r=e=>XT(n,e),t[0]=n,t[1]=r);let{shown:i,more:a}=dD(r),o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(`h2`,{className:`text-ui font-semibold`,children:`How the system grew`}),t[2]=o):o=t[2];let s;t[3]===i?s=t[4]:(s=i.map(mD),t[3]=i,t[4]=s);let c;t[5]===s?c=t[6]:(c=(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:s}),t[5]=s,t[6]=c);let l;return t[7]!==a||t[8]!==c?(l=(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[o,c,a]}),t[7]=a,t[8]=c,t[9]=l):l=t[9],l}function mD(e,t){return(0,Q.jsxs)(`li`,{className:`grid grid-cols-[1rem_minmax(0,1fr)] text-prose`,children:[(0,Q.jsx)(`span`,{"aria-label":e.change,className:Tn(`font-mono`,e.change===`added`&&`text-add-fg`,e.change===`removed`&&`text-del-fg`,e.change===`changed`&&`text-muted-foreground`),children:KT(e)}),(0,Q.jsxs)(`span`,{className:`wrap-anywhere`,children:[(0,Q.jsxs)(`span`,{className:`font-medium`,children:[(0,Q.jsx)(bE,{text:e.what}),`.`]}),` `,(0,Q.jsx)(`span`,{className:`text-foreground-2`,children:(0,Q.jsx)(bE,{text:e.note})})]})]},`${t}:${e.what}`)}function hD(e){let t=(0,$.c)(13),{content:n}=e,r;t[0]===n?r=t[1]:(r=e=>ZT(n,e),t[0]=n,t[1]=r);let{explained:i,unclear:a,total:o,more:s}=dD(r);if(o===0)return null;let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(`h2`,{className:`text-ui font-semibold`,children:`What the code doesn't say`}),t[2]=c):c=t[2];let l;t[3]===i?l=t[4]:(l=i.map(_D),t[3]=i,t[4]=l);let u;t[5]===a?u=t[6]:(u=a.map(gD),t[5]=a,t[6]=u);let d;t[7]!==l||t[8]!==u?(d=(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-2 text-prose`,children:[l,u]}),t[7]=l,t[8]=u,t[9]=d):d=t[9];let f;return t[10]!==s||t[11]!==d?(f=(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2 border-t pt-5`,children:[c,d,s]}),t[10]=s,t[11]=d,t[12]=f):f=t[12],f}function gD(e,t){return(0,Q.jsx)(`li`,{className:`text-foreground-2`,children:(0,Q.jsx)(bE,{text:e})},`${t}:${e}`)}function _D(e,t){return(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`span`,{children:(0,Q.jsx)(bE,{text:e.point})}),` `,(0,Q.jsx)(`span`,{className:`text-foreground-2`,children:(0,Q.jsx)(bE,{text:e.answer})})]},`${t}:${e.point}`)}function vD(e){let t=(0,$.c)(12),{content:n,conversation:r}=e,i,a,o,s;if(t[0]!==n||t[1]!==r){s=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Zw(n);if(e.length===0){s=null;break bb0}i=`your-calls`,a=`flex scroll-mt-6 flex-col gap-3`;let c;t[6]===r?c=t[7]:(c=e=>{let{attention:t,step:n}=e;return(0,Q.jsxs)(`article`,{className:`flex flex-col gap-3 rounded-xl border bg-card p-4 @3xl:p-5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-caption text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:WT(t)}),(0,Q.jsxs)(`button`,{type:`button`,className:`hover:text-foreground`,onClick:()=>oD(sD(n)),children:[`Step `,n]})]}),(0,Q.jsx)(`h2`,{className:`text-section font-semibold text-pretty`,children:(0,Q.jsx)(bE,{text:t.question})}),(0,Q.jsx)(`p`,{className:`text-prose text-foreground-2`,children:(0,Q.jsx)(bE,{text:t.note})}),r?.({kind:`call`,step:n})]},n)},t[6]=r,t[7]=c),o=e.map(c)}t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s}else i=t[2],a=t[3],o=t[4],s=t[5];if(s!==Symbol.for(`react.early_return_sentinel`))return s;let c;return t[8]!==i||t[9]!==a||t[10]!==o?(c=(0,Q.jsx)(`section`,{id:i,className:a,children:o}),t[8]=i,t[9]=a,t[10]=o,t[11]=c):c=t[11],c}function yD(e){let t=(0,$.c)(38),{stop:n,step:r,run:i,props:a,code:o,branch:s,eager:c,conversation:l,excerpt:u}=e,d;t[0]===r?d=t[1]:(d=sD(r),t[0]=r,t[1]=d);let f;t[2]===n.attention?f=t[3]:(f=n.attention&&(0,Q.jsx)(`button`,{type:`button`,className:`ml-2 text-foreground hover:underline`,onClick:bD,children:`Your call`}),t[2]=n.attention,t[3]=f);let p;t[4]!==r||t[5]!==f?(p=(0,Q.jsxs)(`p`,{className:`whitespace-pre-line font-mono text-caption text-muted-foreground`,children:[`Step `,r,f]}),t[4]=r,t[5]=f,t[6]=p):p=t[6];let m;t[7]===n.title?m=t[8]:(m=(0,Q.jsx)(`h2`,{className:`text-lg leading-6 font-semibold text-pretty`,children:(0,Q.jsx)(bE,{text:n.title})}),t[7]=n.title,t[8]=m);let h;t[9]===n.explanation?h=t[10]:(h=(0,Q.jsx)(`p`,{className:`text-prose text-foreground-2`,children:(0,Q.jsx)(bE,{text:n.explanation})}),t[9]=n.explanation,t[10]=h);let g;t[11]!==u||t[12]!==a||t[13]!==i||t[14]!==r?(g=u&&(0,Q.jsx)(QE,{document:a,runId:i.id,step:r,excerpt:u}),t[11]=u,t[12]=a,t[13]=i,t[14]=r,t[15]=g):g=t[15];let _;t[16]!==a||t[17]!==i||t[18]!==n.evidence?(_=n.evidence.length>0&&(0,Q.jsx)(YE,{scope:a.scope,context:a.context,run:i,items:n.evidence}),t[16]=a,t[17]=i,t[18]=n.evidence,t[19]=_):_=t[19];let v;t[20]!==s||t[21]!==o||t[22]!==c||t[23]!==a||t[24]!==r?(v=o&&(0,Q.jsx)(tD,{document:a,entry:`review:step-${r}`,code:o,branch:s,eager:c,label:`Step ${r}`}),t[20]=s,t[21]=o,t[22]=c,t[23]=a,t[24]=r,t[25]=v):v=t[25];let y;t[26]!==l||t[27]!==r?(y=l?.({kind:`step`,step:r}),t[26]=l,t[27]=r,t[28]=y):y=t[28];let b;return t[29]!==d||t[30]!==p||t[31]!==m||t[32]!==h||t[33]!==g||t[34]!==_||t[35]!==v||t[36]!==y?(b=(0,Q.jsxs)(`li`,{id:d,className:`flex scroll-mt-6 flex-col gap-2.5 border-t pt-5`,children:[p,m,h,g,_,v,y]}),t[29]=d,t[30]=p,t[31]=m,t[32]=h,t[33]=g,t[34]=_,t[35]=v,t[36]=y,t[37]=b):b=t[37],b}function bD(){return oD(`your-calls`)}function xD(e){let t=(0,$.c)(100),{run:n,content:r,freshness:i,props:a,onUpdate:o,updateFailure:s,progressRun:c,requesting:l,reused:u,code:d}=e,f;t[0]!==a||t[1]!==n.id?(f={...a,runId:n.id},t[0]=a,t[1]=n.id,t[2]=f):f=t[2];let p=f,m;t[3]===r.stops?m=t[4]:(m=r.stops.find(wD)??r.stops.find(CD),t[3]=r.stops,t[4]=m);let h=m,g=Ae(a.context),_;t[5]!==r.stops||t[6]!==p?(_=e=>{let{kind:t,step:n}=e,i=r.stops[n-1].title;return(0,Q.jsx)(HE,{owner:p,title:i,call:t===`call`},i)},t[5]=r.stops,t[6]=p,t[7]=_):_=t[7];let v=_,y;t[8]!==i||t[9]!==o||t[10]!==c||t[11]!==l||t[12]!==u||t[13]!==s||t[14]!==g?(y=(0,Q.jsx)(GE,{run:c,requesting:l,reused:u,freshness:i,failure:s,onUpdate:o,writeBlock:g}),t[8]=i,t[9]=o,t[10]=c,t[11]=l,t[12]=u,t[13]=s,t[14]=g,t[15]=y):y=t[15];let b=y;if(r.outcome===`nothing`){let e;t[16]!==r||t[17]!==n?(e=(0,Q.jsx)(lD,{run:n,content:r}),t[16]=r,t[17]=n,t[18]=e):e=t[18];let i;t[19]===r?i=t[20]:(i=(0,Q.jsx)(uD,{content:r}),t[19]=r,t[20]=i);let o;t[21]===r.summary?o=t[22]:(o=(0,Q.jsx)(`p`,{className:`text-prose text-foreground-2`,children:(0,Q.jsx)(bE,{text:r.summary})}),t[21]=r.summary,t[22]=o);let s;t[23]!==b||t[24]!==e||t[25]!==i||t[26]!==o?(s=(0,Q.jsxs)(`header`,{className:`flex flex-col gap-3`,children:[e,i,o,b]}),t[23]=b,t[24]=e,t[25]=i,t[26]=o,t[27]=s):s=t[27];let c;t[28]!==d.branch||t[29]!==d.sections.outside||t[30]!==a?(c=(0,Q.jsx)(tD,{document:a,entry:`review:all`,code:d.sections.outside,branch:d.branch,eager:!0,label:`Every changed file`}),t[28]=d.branch,t[29]=d.sections.outside,t[30]=a,t[31]=c):c=t[31];let l;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(l=[],t[32]=l):l=t[32];let u,f;t[33]===p?(u=t[34],f=t[35]):(u=(0,Q.jsx)(UE,{owner:p,titles:l}),f=(0,Q.jsx)(WE,{owner:p}),t[33]=p,t[34]=u,t[35]=f);let m;return t[36]!==u||t[37]!==f||t[38]!==s||t[39]!==c?(m=(0,Q.jsxs)(cD,{children:[s,c,u,f]}),t[36]=u,t[37]=f,t[38]=s,t[39]=c,t[40]=m):m=t[40],m}let x;t[41]!==r||t[42]!==n?(x=(0,Q.jsx)(lD,{run:n,content:r}),t[41]=r,t[42]=n,t[43]=x):x=t[43];let S;t[44]===r?S=t[45]:(S=(0,Q.jsx)(uD,{content:r}),t[44]=r,t[45]=S);let C;t[46]===r.summary?C=t[47]:(C=(0,Q.jsx)(`p`,{className:`text-prose text-foreground-2`,children:(0,Q.jsx)(bE,{text:r.summary})}),t[46]=r.summary,t[47]=C);let w;t[48]!==b||t[49]!==x||t[50]!==S||t[51]!==C?(w=(0,Q.jsxs)(`header`,{className:`flex flex-col gap-3`,children:[x,S,C,b]}),t[48]=b,t[49]=x,t[50]=S,t[51]=C,t[52]=w):w=t[52];let T;t[53]!==r||t[54]!==v?(T=(0,Q.jsx)(vD,{content:r,conversation:v}),t[53]=r,t[54]=v,t[55]=T):T=t[55];let E;t[56]===r?E=t[57]:(E=r.growth.length>0&&(0,Q.jsx)(pD,{content:r}),t[56]=r,t[57]=E);let D;if(t[58]!==d.branch||t[59]!==d.eager||t[60]!==d.sections.steps||t[61]!==r.stops||t[62]!==v||t[63]!==h||t[64]!==a||t[65]!==n){let e;t[67]!==d.branch||t[68]!==d.eager||t[69]!==d.sections.steps||t[70]!==v||t[71]!==h||t[72]!==a||t[73]!==n?(e=(e,t)=>(0,Q.jsx)(yD,{stop:e,step:t+1,run:n,props:a,code:d.sections.steps[t],branch:d.branch,eager:d.eager.steps[t]??!0,conversation:v,excerpt:e===h?e.excerpts[0]:void 0},t),t[67]=d.branch,t[68]=d.eager,t[69]=d.sections.steps,t[70]=v,t[71]=h,t[72]=a,t[73]=n,t[74]=e):e=t[74],D=r.stops.map(e),t[58]=d.branch,t[59]=d.eager,t[60]=d.sections.steps,t[61]=r.stops,t[62]=v,t[63]=h,t[64]=a,t[65]=n,t[66]=D}else D=t[66];let O;t[75]===D?O=t[76]:(O=(0,Q.jsx)(`ol`,{className:`flex flex-col gap-10`,children:D}),t[75]=D,t[76]=O);let k;t[77]===r?k=t[78]:(k=(0,Q.jsx)(hD,{content:r}),t[77]=r,t[78]=k);let A;t[79]===r.stops?A=t[80]:(A=r.stops.map(SD),t[79]=r.stops,t[80]=A);let j;t[81]!==p||t[82]!==A?(j=(0,Q.jsx)(UE,{owner:p,titles:A}),t[81]=p,t[82]=A,t[83]=j):j=t[83];let M;t[84]!==d.branch||t[85]!==d.eager||t[86]!==d.sections.outside||t[87]!==a?(M=DD(d.sections.outside,d.branch)&&(0,Q.jsxs)(`section`,{"aria-labelledby":`review-not-covered`,className:`flex flex-col gap-2.5 border-t pt-5`,children:[(0,Q.jsx)(`h2`,{id:`review-not-covered`,className:`text-lg leading-6 font-semibold text-pretty`,children:`Not covered by the steps`}),(0,Q.jsx)(tD,{document:a,entry:`review:not-covered`,code:d.sections.outside,branch:d.branch,eager:d.eager.outside,label:`Not covered by the steps`})]}),t[84]=d.branch,t[85]=d.eager,t[86]=d.sections.outside,t[87]=a,t[88]=M):M=t[88];let N;t[89]===p?N=t[90]:(N=(0,Q.jsx)(WE,{owner:p}),t[89]=p,t[90]=N);let P;return t[91]!==E||t[92]!==O||t[93]!==k||t[94]!==j||t[95]!==M||t[96]!==N||t[97]!==w||t[98]!==T?(P=(0,Q.jsxs)(cD,{children:[w,T,E,O,k,j,M,N]}),t[91]=E,t[92]=O,t[93]=k,t[94]=j,t[95]=M,t[96]=N,t[97]=w,t[98]=T,t[99]=P):P=t[99],P}function SD(e){return e.title}function CD(e){return e.excerpts.length>0}function wD(e){return e.attention&&e.excerpts.length>0}function TD(e){let t=(0,$.c)(5),{run:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,Q.jsxs)(`header`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(lD,{run:n}),(0,Q.jsx)(GE,{run:n})]}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,Q.jsxs)(cD,{children:[i,r]}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function ED(e){let t=(0,$.c)(22),{run:n,failure:r,waiting:i,onRetry:a,writeBlock:o,children:s}=e,c;t[0]!==r||t[1]!==n?(c=$T(r,n),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c,u;t[3]===l.title?u=t[4]:(u=(0,Q.jsx)(`h1`,{className:`text-subpage-title font-semibold tracking-tight`,children:l.title}),t[3]=l.title,t[4]=u);let d;t[5]!==n||t[6]!==i?(d=n&&(0,Q.jsx)(GE,{run:n,requesting:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7];let f;t[8]===l.message?f=t[9]:(f=l.message&&(0,Q.jsx)(`p`,{className:`text-prose text-foreground-2`,children:l.message}),t[8]=l.message,t[9]=f);let p=i||!!o,m;t[10]!==a||t[11]!==p||t[12]!==o?(m=(0,Q.jsx)(X,{disabled:p,"aria-description":o,onClick:a,children:`Try again`}),t[10]=a,t[11]=p,t[12]=o,t[13]=m):m=t[13];let h;t[14]!==u||t[15]!==d||t[16]!==f||t[17]!==m?(h=(0,Q.jsxs)(`header`,{className:`flex flex-col items-start gap-3`,children:[u,d,f,m]}),t[14]=u,t[15]=d,t[16]=f,t[17]=m,t[18]=h):h=t[18];let g;return t[19]!==s||t[20]!==h?(g=(0,Q.jsxs)(cD,{children:[h,s]}),t[19]=s,t[20]=h,t[21]=g):g=t[21],g}var DD=(e,t)=>t!==void 0&&e.branch.length>0||e.worktree.length>0;function OD(e,t){let n=(0,$.c)(11),r=e.interaction.hidden===!0,i=YS(Ds(e.scope,e.context.connection),r),a=YS(Ga(e.scope,e.context.connection,e.base).result,r),o,s,c;if(n[0]!==i.changes||n[1]!==t||n[2]!==a){o=ne(J(a));let e=_T({content:t?.outcome===`nothing`?void 0:t,branch:o?.files??[],worktree:i.changes});s=e,c=mT(e,o!==void 0,25),n[0]=i.changes,n[1]=t,n[2]=a,n[3]=o,n[4]=s,n[5]=c}else o=n[3],s=n[4],c=n[5];let l=o!==void 0,u;return n[6]!==o||n[7]!==s||n[8]!==c||n[9]!==l?(u={sections:s,eager:c,branch:o,settled:l},n[6]=o,n[7]=s,n[8]=c,n[9]=l,n[10]=u):u=n[10],u}function kD(e){let t=(0,$.c)(23),n=Ae(e.context),{result:r,phase:i,read:a,refresh:o}=uE(e.scope,e.context),s=yE(e.scope,e.context,e.base,i&&i.kind!==`unwritten`?i.run:void 0),c;t[0]!==i||t[1]!==a||t[2]!==s?(c=a?Jw(aE(a,s.accepted)):i,t[0]=i,t[1]=a,t[2]=s,t[3]=c):c=t[3];let u=c,d=OD(e,u?.kind===`ready`?u.content:void 0),f;t[4]!==d.branch||t[5]!==d.sections.outside||t[6]!==e?(f=(0,Q.jsx)(tD,{document:e,entry:`review:all`,code:d.sections.outside,branch:d.branch,eager:!0,label:`Every changed file`}),t[4]=d.branch,t[5]=d.sections.outside,t[6]=e,t[7]=f):f=t[7];let p=f;if(u===void 0){let e;return t[8]!==p||t[9]!==o||t[10]!==r?(e=h(r)?(0,Q.jsx)(`div`,{"data-review-scroll":``,className:`@container h-full overflow-auto`,children:(0,Q.jsxs)(cD,{children:[(0,Q.jsx)(pe,{description:`The walkthrough could not be read.`,onRetry:o}),p]})}):(0,Q.jsx)(l,{label:`Loading walkthrough`}),t[8]=p,t[9]=o,t[10]=r,t[11]=e):e=t[11],e}let m;t[12]!==d||t[13]!==p||t[14]!==u||t[15]!==e||t[16]!==s||t[17]!==n?(m=()=>{let t=eE(u,s.failure);if(t)return(0,Q.jsx)(ED,{run:t.run,failure:t.failure,waiting:s.waiting,onRetry:s.start,writeBlock:n,children:p});switch(u.kind){case`unwritten`:return d.settled&&!DD(d.sections.outside,d.branch)?(0,Q.jsx)(QC,{...e}):(0,Q.jsxs)(cD,{children:[(0,Q.jsx)($E,{document:e,waiting:s.waiting,onWrite:s.start}),p]});case`writing`:return(0,Q.jsx)(TD,{run:u.run,children:p});case`failed`:return(0,Q.jsx)(ED,{run:u.run,failure:u.failure,waiting:s.waiting,onRetry:s.start,writeBlock:n,children:p});case`ready`:{let t=tE(u,s);return(0,Q.jsx)(xD,{run:u.run,content:u.content,freshness:u.freshness,props:e,onUpdate:s.start,progressRun:u.attempt??u.run,requesting:s.waiting,reused:s.accepted?.state.status===`ready`&&s.accepted.id===u.run.id,updateFailure:t.failure,code:d},u.run.id)}}},t[12]=d,t[13]=p,t[14]=u,t[15]=e,t[16]=s,t[17]=n,t[18]=m):m=t[18];let g=m,_;t[19]===g?_=t[20]:(_=g(),t[19]=g,t[20]=_);let v;return t[21]===_?v=t[22]:(v=(0,Q.jsx)(`div`,{"data-review-scroll":``,className:`@container h-full overflow-auto`,children:_}),t[21]=_,t[22]=v),v}function AD(e){let t=(0,$.c)(14),{steps:n,activeEntry:r,onOpen:i,row:a}=e,[o,s]=(0,Z.useState)(null);if(n.length===0)return null;let c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(`p`,{className:`px-2 pt-2 pb-1 text-2xs text-muted-foreground`,children:`By step`}),t[0]=c):c=t[0];let l;if(t[1]!==r||t[2]!==i||t[3]!==o||t[4]!==a||t[5]!==n){let e;t[7]!==r||t[8]!==i||t[9]!==o||t[10]!==a?(e=e=>{let{stop:t,step:n,files:c}=e,l={kind:`walkthrough-step`,step:n},u=r===Yy(l);return(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsxs)(Aw,{plain:!0,label:`Step ${n}`,active:u,onOpen:()=>{s(n),i(l)},children:[(0,Q.jsx)(`span`,{className:`w-3.5 shrink-0 text-center font-mono text-2xs text-muted-foreground`,children:n}),(0,Q.jsx)(v,{className:`min-w-0 flex-1`,text:dT(t.title)}),t.attention&&(0,Q.jsx)(`span`,{role:`img`,"aria-label":`Your call`,className:`size-1.5 shrink-0 rounded-full bg-foreground`}),(0,Q.jsx)(`span`,{className:`ml-auto text-2xs text-muted-foreground tabular-nums`,children:c.length})]}),(o===n||u)&&(0,Q.jsx)(`div`,{className:`pl-3`,children:c.map(a)})]},n)},t[7]=r,t[8]=i,t[9]=o,t[10]=a,t[11]=e):e=t[11],l=n.map(e),t[1]=r,t[2]=i,t[3]=o,t[4]=a,t[5]=n,t[6]=l}else l=t[6];let u;return t[12]===l?u=t[13]:(u=(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-col`,children:[c,l]}),t[12]=l,t[13]=u),u}function jD(e){let t=(0,$.c)(14),{files:n,row:r,context:i}=e,a=xc(i.connection),o,s;if(t[0]!==n||t[1]!==r||t[2]!==a){let e=a?n.filter(ND):[],i;t[5]!==n||t[6]!==a?(i=a?n.filter(MD):n,t[5]=n,t[6]=a,t[7]=i):i=t[7];let c=i;t[8]!==c||t[9]!==r?(o=c.length>0&&(0,Q.jsxs)(`div`,{role:`group`,"aria-label":`Not in the walkthrough yet`,className:`mt-1 flex flex-col`,children:[(0,Q.jsx)(`p`,{className:`px-2 pt-2 pb-1 text-2xs text-muted-foreground`,children:`Not in the walkthrough yet`}),c.map(r)]}),t[8]=c,t[9]=r,t[10]=o):o=t[10],s=e.length>0&&(0,Q.jsxs)(`div`,{role:`group`,"aria-label":`Specs`,className:`mt-1 flex flex-col`,children:[(0,Q.jsx)(`p`,{className:`px-2 pt-2 pb-1 text-2xs text-muted-foreground`,children:`Specs`}),e.map(r)]}),t[0]=n,t[1]=r,t[2]=a,t[3]=o,t[4]=s}else o=t[3],s=t[4];let c;return t[11]!==o||t[12]!==s?(c=(0,Q.jsxs)(Q.Fragment,{children:[o,s]}),t[11]=o,t[12]=s,t[13]=c):c=t[13],c}function MD(e){return!yd(e.path)}function ND(e){return yd(e.path)}function PD(e){let t=(0,$.c)(23),{scope:n,context:r,items:i,row:a,activeEntry:o,onOpen:s}=e,c=dE(n,r);if(!c||c.content.stops.length===0){let e;t[0]!==i||t[1]!==a?(e=i.map(a),t[0]=i,t[1]=a,t[2]=e):e=t[2];let n;return t[3]===e?n=t[4]:(n=(0,Q.jsx)(Q.Fragment,{children:e}),t[3]=e,t[4]=n),n}let l,u,d;t[5]!==i||t[6]!==c.content?(u=nT(c.content,i),l=AD,d=u.steps.filter(FD),t[5]=i,t[6]=c.content,t[7]=l,t[8]=u,t[9]=d):(l=t[7],u=t[8],d=t[9]);let f;t[10]!==l||t[11]!==o||t[12]!==s||t[13]!==a||t[14]!==d?(f=(0,Q.jsx)(l,{steps:d,activeEntry:o,onOpen:s,row:a}),t[10]=l,t[11]=o,t[12]=s,t[13]=a,t[14]=d,t[15]=f):f=t[15];let p;t[16]!==r||t[17]!==u.outside||t[18]!==a?(p=(0,Q.jsx)(jD,{files:u.outside,row:a,context:r}),t[16]=r,t[17]=u.outside,t[18]=a,t[19]=p):p=t[19];let m;return t[20]!==f||t[21]!==p?(m=(0,Q.jsxs)(Q.Fragment,{children:[f,p]}),t[20]=f,t[21]=p,t[22]=m):m=t[22],m}function FD(e){return e.files.length>0}function ID(e){let t=(0,$.c)(39),{scope:n,context:r,base:i,paths:a,row:o,activeEntry:s,onOpen:c}=e,l=dE(n,r),u=fE(n,r,i);if(a.length===0){let e=l?`Nothing uncommitted.`:`No changes`,n;return t[0]===e?n=t[1]:(n=(0,Q.jsx)(`p`,{className:`p-3 text-sm text-muted-foreground`,children:e}),t[0]=e,t[1]=n),n}let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=Yy(Gy),t[2]=d):d=t[2];let f=s===d,p;t[3]===c?p=t[4]:(p=()=>c(Gy),t[3]=c,t[4]=p);let m,h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(yi,{className:`size-3.5 shrink-0 text-muted-foreground`}),h=(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:`All changes`}),t[5]=m,t[6]=h):(m=t[5],h=t[6]);let g;t[7]===a.length?g=t[8]:(g=(0,Q.jsx)(`span`,{className:`ml-auto text-2xs text-muted-foreground tabular-nums`,children:a.length}),t[7]=a.length,t[8]=g);let _;t[9]!==f||t[10]!==p||t[11]!==g?(_=(0,Q.jsxs)(Aw,{plain:!0,label:`All changes`,active:f,onOpen:p,children:[m,h,g]}),t[9]=f,t[10]=p,t[11]=g,t[12]=_):_=t[12];let v=_;if(!l||l.content.stops.length===0){let e;t[13]!==a||t[14]!==o?(e=a.map(o),t[13]=a,t[14]=o,t[15]=e):e=t[15];let n;return t[16]!==v||t[17]!==e?(n=(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[v,e]}),t[16]=v,t[17]=e,t[18]=n):n=t[18],n}let y,b;if(t[19]!==a||t[20]!==l.content||t[21]!==u){let e=a.map(RD);y=nT(l.content,e,u),b=y.steps.filter(LD),t[19]=a,t[20]=l.content,t[21]=u,t[22]=y,t[23]=b}else y=t[22],b=t[23];let x=b,S;t[24]!==s||t[25]!==c||t[26]!==o||t[27]!==x?(S=x.length>0&&(0,Q.jsx)(AD,{steps:x,activeEntry:s,onOpen:c,row:e=>o(e.path)}),t[24]=s,t[25]=c,t[26]=o,t[27]=x,t[28]=S):S=t[28];let C;t[29]===o?C=t[30]:(C=e=>o(e.path),t[29]=o,t[30]=C);let w;t[31]!==r||t[32]!==y.outside||t[33]!==C?(w=(0,Q.jsx)(jD,{files:y.outside,row:C,context:r}),t[31]=r,t[32]=y.outside,t[33]=C,t[34]=w):w=t[34];let T;return t[35]!==v||t[36]!==w||t[37]!==S?(T=(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[v,S,w]}),t[35]=v,t[36]=w,t[37]=S,t[38]=T):T=t[38],T}function LD(e){return e.files.length>0}function RD(e){return{path:e}}var zD={branch:PD,uncommitted:ID};function BD(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Q.jsx)(zw,{...e,grouping:zD}),t[0]=e,t[1]=n),n}function VD(e){let t=(0,$.c)(9),n;t[0]!==e.projectId||t[1]!==e.worktree.id?(n={projectId:e.projectId,worktreeId:e.worktree.id},t[0]=e.projectId,t[1]=e.worktree.id,t[2]=n):n=t[2];let r;t[3]===e?r=t[4]:(r=(0,Q.jsx)(HD,{...e}),t[3]=e,t[4]=r);let i;return t[5]!==e.context.connection||t[6]!==n||t[7]!==r?(i=(0,Q.jsx)(ow,{connection:e.context.connection,scope:n,children:r}),t[5]=e.context.connection,t[6]=n,t[7]=r,t[8]=i):i=t[8],i}function HD(e){let t=(0,$.c)(13),n;t[0]!==e.projectId||t[1]!==e.worktree.id?(n={projectId:e.projectId,worktreeId:e.worktree.id},t[0]=e.projectId,t[1]=e.worktree.id,t[2]=n):n=t[2];let r=n,i=mE(r,e.context),a=pE(r,e.context),o;t[3]!==e.worktree.id||t[4]!==a?(o=Jb({worktreeId:e.worktree.id,title:a}),t[3]=e.worktree.id,t[4]=a,t[5]=o):o=t[5],Vt(o);let s;t[6]!==i.guided||t[7]!==i.pending?(s={pending:i.pending,guided:i.guided},t[6]=i.guided,t[7]=i.pending,t[8]=s):s=t[8];let c=s,l=i.guided?BD:zw,u;return t[9]!==c||t[10]!==e||t[11]!==l?(u=(0,Q.jsx)(hw,{...e,review:kD,changesNavigation:l,walkthroughCode:eD,firstDocument:c}),t[9]=c,t[10]=e,t[11]=l,t[12]=u):u=t[12],u}function UD(e){let t={projectId:e.projectId,worktreeId:e.worktreeId};return e.remote===null?an({to:`/$projectId/$worktreeId`,params:t}):an({to:`/remotes/$environmentId/$projectId/$worktreeId`,params:{environmentId:e.remote,...t}})}function WD(e,t){let n=(0,$.c)(2),r=Lo(e,t,GD),i;return n[0]===r?i=n[1]:(i=()=>r?r():es.openWithPayload({remote:null}),n[0]=r,n[1]=i),i}function GD(e){return ms.add({title:`Could not open the project`,description:kn(e),type:`error`})}function KD(e){let t=(0,$.c)(12),{connection:n,empty:r,settingsOpen:i}=e,a=At(),o=N(),{setOpenMobile:s}=Dt(),c;t[0]!==r||t[1]!==a||t[2]!==s?(c=e=>(s(!1),a({...UD(e),replace:r})),t[0]=r,t[1]=a,t[2]=s,t[3]=c):c=t[3];let l=c,u=WD(n,l),d;t[4]!==a||t[5]!==u||t[6]!==i?(d=ze(e=>{typeof e==`object`||i||(e===`open-settings`?a({to:`/settings/$section`,params:{section:qo}}):u())}),t[4]=a,t[5]=u,t[6]=i,t[7]=d):d=t[7],Vt(d);let f;return t[8]!==n||t[9]!==l||t[10]!==o?(f=(0,Q.jsx)(Uo,{connection:n,remotes:o,onOpened:l}),t[8]=n,t[9]=l,t[10]=o,t[11]=f):f=t[11],f}function qD(e){let t=(0,$.c)(7),{icon:n,tone:r}=e,i=(r===void 0?`default`:r)===`destructive`?`bg-destructive/10 text-destructive`:`bg-muted text-foreground`,a;t[0]===i?a=t[1]:(a=Tn(`grid size-10 shrink-0 place-items-center rounded-xl`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,Q.jsx)(n,{className:`size-5`}),t[2]=n,t[3]=o);let s;return t[4]!==a||t[5]!==o?(s=(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:a,children:o}),t[4]=a,t[5]=o,t[6]=s):s=t[6],s}function JD(e){let t=(0,$.c)(4),{keys:n}=e,r;t[0]===n?r=t[1]:(r=n.split(`+`).map(YD),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,Q.jsx)(Tr,{children:r}),t[2]=r,t[3]=i),i}function YD(e){return(0,Q.jsx)(Os,{className:`min-w-6 justify-center`,children:oc(e)},e)}function XD(e){let t=(0,$.c)(6),{open:n,onOpenChange:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(qD,{icon:ho}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsxs)(Po,{className:`flex-row items-center text-left`,children:[i,(0,Q.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Q.jsx)(Xo,{children:`Keyboard shortcuts`}),(0,Q.jsx)(rs,{children:`None of them fire while you are typing.`})]})]}),t[1]=a):a=t[1];let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsxs)(Ja,{className:`max-h-[85svh] grid-rows-[auto_minmax(0,1fr)] overflow-hidden sm:max-w-xl`,children:[a,(0,Q.jsx)(si,{className:`-mr-3 min-h-0`,children:(0,Q.jsx)(`div`,{className:`flex flex-col gap-5 pr-3`,children:Xs.map(ZD)})})]}),t[2]=o):o=t[2];let s;return t[3]!==r||t[4]!==n?(s=(0,Q.jsx)(Fi,{open:n,onOpenChange:r,children:o}),t[3]=r,t[4]=n,t[5]=s):s=t[5],s}function ZD(e){return(0,Q.jsxs)(`section`,{"aria-labelledby":`shortcuts-${e.title}`,children:[(0,Q.jsx)(`h3`,{id:`shortcuts-${e.title}`,className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:e.title}),(0,Q.jsx)(`dl`,{className:`divide-y rounded-xl border`,children:e.items.map(QD)})]},e.title)}function QD(e){return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-3 py-2`,children:[(0,Q.jsx)(`dt`,{className:`text-sm`,children:e.label}),(0,Q.jsx)(`dd`,{className:`shrink-0`,children:(0,Q.jsx)(JD,{keys:e.keys})})]},e.keys)}var $D={"not-found":`Page not found`,"missing-worktree":`Worktree not found`,empty:`Select a worktree on the left`};function eO(e){let t=(0,$.c)(112),{review:n,remote:r,unavailable:i,remoteStatus:a,showRemoteNotice:o,notice:s,background:c}=e,l=c!==void 0&&c,u=Ri(),d=$t(ke),f=Bn(ke),p;t[0]!==l||t[1]!==d||t[2]!==f?(p=e=>{e&&d&&!l&&(e.focus(),document.activeElement===e&&f(!1))},t[0]=l,t[1]=d,t[2]=f,t[3]=p):p=t[3];let m=p,h;t[4]!==m||t[5]!==u?(h=e=>{u.attach(e),m(e)},t[4]=m,t[5]=u,t[6]=h):h=t[6];let g;t[7]!==h||t[8]!==u.element?(g={element:u.element,attach:h},t[7]=h,t[8]=u.element,t[9]=g):g=t[9];let _=g,[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),{setOpenMobile:S,isMobile:w,open:T,openMobile:E}=Dt(),D;t[10]===S?D=t[11]:(D=(e,t)=>{y(!e&&t.reason===`escape-key`),S(e)},t[10]=S,t[11]=D);let O;t[12]!==_||t[13]!==v||t[14]!==m?(O=e=>{!e&&v&&(y(!1),_.element?.focus()),e||m(_.element)},t[12]=_,t[13]=v,t[14]=m,t[15]=O):O=t[15];let k;t[16]!==D||t[17]!==O?(k={onOpenChange:D,onOpenChangeComplete:O},t[16]=D,t[17]=O,t[18]=k):k=t[18];let A=k,j=At(),M=hr(),P=vr(),F=Aa(P.connection),I;t[19]===F?I=t[20]:(I=nr(F,ar(F)?.id),t[19]=F,t[20]=I);let L=I,R=!s&&F.projects.length===0,z=R?`Open your first project`:$D[s??`empty`];N();let B=vr(r?.connection),V;t[21]!==a||t[22]!==B?(V={...B,remoteStatus:a},t[21]=a,t[22]=B,t[23]=V):V=t[23];let H=V,U=r?.remote.environmentId??null,W;t[24]!==n||t[25]!==U?(W=n&&{remote:U,projectId:n.selection.projectId,worktreeId:n.selection.worktree.id},t[24]=n,t[25]=U,t[26]=W):W=t[26];let G=W,K=n?.selection.worktree.id??``,ee;t[27]===K?ee=t[28]:(ee=Kb(K),t[27]=K,t[28]=ee);let q=$t(ee),te;t[29]!==q||t[30]!==r||t[31]!==n?(te=n?tb({firstDocument:q,entry:n.search.entry,surface:n.search.surface,project:n.inventory.projects.find(e=>e.id===n.selection.projectId)?.name,environment:r||n.inventory.environment.custom?n.inventory.environment.name:void 0}):`Porcelain`,t[29]=q,t[30]=r,t[31]=n,t[32]=te):te=t[32],Oa(l?void 0:te);let ne;t[33]!==j||t[34]!==n||t[35]!==S?(ne=e=>(S(!1),j({...UD(e),replace:n===void 0})),t[33]=j,t[34]=n,t[35]=S,t[36]=ne):ne=t[36];let re=ne,J=WD(P.connection,re),ie;t[37]===S?ie=t[38]:(ie=()=>S(!1),t[37]=S,t[38]=ie);let ae=ie,oe;t[39]!==ae||t[40]!==j?(oe=e=>{let t=e===void 0?qo:e;ae(),j({to:`/settings/$section`,params:{section:t}})},t[39]=ae,t[40]=j,t[41]=oe):oe=t[41];let se=oe,ce;t[42]!==P.connection||t[43]!==j||t[44]!==n?.search||t[45]!==S||t[46]!==G?(ce=e=>{if(e.pullRequest.state!==`available`||!e.pullRequest.number)return;let t=Yy({kind:`pull-request`,projectId:e.projectId,number:e.pullRequest.number,environmentId:e.environmentId});S(!1);let r=G??(e.worktreeId?{remote:e.environmentId===P.connection.environmentId?null:e.environmentId,projectId:e.projectId,worktreeId:e.worktreeId}:void 0);r&&j({...UD(r),search:{...n?.search??{},entry:t}})},t[42]=P.connection,t[43]=j,t[44]=n?.search,t[45]=S,t[46]=G,t[47]=ce):ce=t[47];let Y;t[48]===J?Y=t[49]:(Y=e=>e?es.openWithPayload({remote:e.remote.environmentId}):J(),t[48]=J,t[49]=Y);let le;t[50]===se?le=t[51]:(le=()=>se(),t[50]=se,t[51]=le);let ue;t[52]!==ae||t[53]!==j?(ue=e=>{ae(),j({to:`/settings/$section/$environmentId`,params:{section:`computers`,environmentId:e}})},t[52]=ae,t[53]=j,t[54]=ue):ue=t[54];let de;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(de=()=>x(!0),t[55]=de):de=t[55];let fe;t[56]!==o||t[57]!==G||t[58]!==void 0||t[59]!==ce||t[60]!==Y||t[61]!==le||t[62]!==ue?(fe={remotes:void 0,selected:G,showRemoteNotice:o,onOpenPullRequest:ce,onOpenProject:Y,onOpenSettings:le,onOpenRemotes:ue,onOpenShortcuts:de},t[56]=o,t[57]=G,t[58]=void 0,t[59]=ce,t[60]=Y,t[61]=le,t[62]=ue,t[63]=fe):fe=t[63];let pe=fe,me;t[64]!==j||t[65]!==M||t[66]!==G?(me=(e,t)=>{if(!G)return;let n=UD(G);M.buildLocation({}).pathname===M.buildLocation(n).pathname&&j({...n,search:t=>({...t,...e}),...t})},t[64]=j,t[65]=M,t[66]=G,t[67]=me):me=t[67];let he=me,ge;t[68]===se?ge=t[69]:(ge=()=>se(),t[68]=se,t[69]=ge);let _e;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(_e={ignoreInputs:!0},t[70]=_e):_e=t[70],cc(Ys.openSettings,ge,_e);let ve,ye;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ve=()=>x(!0),ye={ignoreInputs:!0},t[71]=ve,t[72]=ye):(ve=t[71],ye=t[72]),cc(Ys.openShortcuts,ve,ye);let be;t[73]!==w||t[74]!==A||t[75]!==pe||t[76]!==re?(be=w&&(0,Q.jsx)(lt,{variant:`floating`,...A,children:(0,Q.jsx)(vs,{...pe,onSelect:e=>void re(e)})}),t[73]=w,t[74]=A,t[75]=pe,t[76]=re,t[77]=be):be=t[77];let xe;t[78]===re?xe=t[79]:(xe=e=>void re(e),t[78]=re,t[79]=xe);let Se;t[80]!==pe||t[81]!==xe?(Se={...pe,onSelect:xe},t[80]=pe,t[81]=xe,t[82]=Se):Se=t[82];let Ce;t[83]!==H||t[84]!==R||t[85]!==w||t[86]!==z||t[87]!==_||t[88]!==pe||t[89]!==s||t[90]!==he||t[91]!==T||t[92]!==J||t[93]!==E||t[94]!==L||t[95]!==r||t[96]!==n||t[97]!==S||t[98]!==U||t[99]!==i?(Ce=n?(0,Q.jsx)(VD,{navigationTrigger:_,worktree:n.selection.worktree,projectId:n.selection.projectId,search:n.search,onSearch:he,context:H},`${U??``}:${n.selection.worktree.id}`):(0,Q.jsx)(tO,{navigationTrigger:_,isMobile:w,open:T,openMobile:E,children:r&&i?(0,Q.jsx)(C,{name:r.remote.name,status:i,onOpenRemotes:()=>pe.onOpenRemotes(r.remote.environmentId)}):(0,Q.jsx)(gr,{message:z,action:(0,Q.jsx)(nO,{firstRun:R,notice:s,recovery:L,onOpenProject:()=>{S(!1),J()}})})}),t[83]=H,t[84]=R,t[85]=w,t[86]=z,t[87]=_,t[88]=pe,t[89]=s,t[90]=he,t[91]=T,t[92]=J,t[93]=E,t[94]=L,t[95]=r,t[96]=n,t[97]=S,t[98]=U,t[99]=i,t[100]=Ce):Ce=t[100];let we;t[101]!==w||t[102]!==T||t[103]!==Se||t[104]!==Ce?(we=(0,Q.jsx)(Do,{navigator:Se,isMobile:w,open:T,children:Ce}),t[101]=w,t[102]=T,t[103]=Se,t[104]=Ce,t[105]=we):we=t[105];let Te;t[106]===b?Te=t[107]:(Te=(0,Q.jsx)(XD,{open:b,onOpenChange:x}),t[106]=b,t[107]=Te);let Ee;return t[108]!==be||t[109]!==we||t[110]!==Te?(Ee=(0,Q.jsxs)(Q.Fragment,{children:[be,we,Te]}),t[108]=be,t[109]=we,t[110]=Te,t[111]=Ee):Ee=t[111],Ee}function tO(e){let t=(0,$.c)(12),{navigationTrigger:n,isMobile:r,open:i,openMobile:a,children:o}=e,s;t[0]===n?s=t[1]:(s=e=>n.attach(e),t[0]=n,t[1]=s);let c=r?a:i,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=uc(Qs(Ys.toggleNavigator,Fs())),t[2]=l):l=t[2];let u;t[3]!==s||t[4]!==c?(u=(0,Q.jsx)(Gt,{render:(0,Q.jsx)(jt,{ref:s,className:`absolute top-3 left-3`,"aria-label":`Toggle Sidebar`,"aria-expanded":c,"aria-keyshortcuts":l})}),t[3]=s,t[4]=c,t[5]=u):u=t[5];let d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsxs)(m,{side:`right`,children:[`Toggle sidebar`,(0,Q.jsx)(Os,{children:oc(Ys.toggleNavigator)})]}),t[6]=d):d=t[6];let f;t[7]===u?f=t[8]:(f=(0,Q.jsxs)(y,{children:[u,d]}),t[7]=u,t[8]=f);let p;return t[9]!==o||t[10]!==f?(p=(0,Q.jsxs)(`div`,{className:`relative grid h-full min-h-0 place-items-center rounded-paper border bg-card p-8`,children:[f,o]}),t[9]=o,t[10]=f,t[11]=p):p=t[11],p}function nO(e){let t=(0,$.c)(13),{firstRun:n,notice:r,recovery:i,onOpenProject:a}=e;if(n){let e;return t[0]===a?e=t[1]:(e=(0,Q.jsx)(X,{variant:`outline`,size:`sm`,onClick:a,children:`Open project`}),t[0]=a,t[1]=e),e}if(r===`missing-worktree`&&i){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=Tn(D({size:`sm`})),t[2]=e):e=t[2];let n;t[3]!==i.projectId||t[4]!==i.worktree.id?(n={projectId:i.projectId,worktreeId:i.worktree.id},t[3]=i.projectId,t[4]=i.worktree.id,t[5]=n):n=t[5];let r;return t[6]!==e||t[7]!==n?(r=(0,Q.jsx)(Sn,{className:e,to:`/$projectId/$worktreeId`,params:n,children:`Open available worktree`}),t[6]=e,t[7]=n,t[8]=r):r=t[8],r}if(r){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=Tn(D({variant:`outline`,size:`sm`})),t[9]=e):e=t[9];let n;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(n={},t[10]=n):n=t[10];let r;return t[11]===e?r=t[12]:(r=(0,Q.jsx)(Sn,{className:e,to:`/`,search:n,children:`Back to workspace`}),t[11]=e,t[12]=r),r}return null}function rO(e){let t=(0,$.c)(19),{projectId:n,worktreeId:r,search:i,remote:a,settled:o,remoteStatus:s,showRemoteNotice:c,background:l}=e,{connection:u}=vr(a?.connection),d=Aa(u),f;t[0]!==d||t[1]!==r?(f=nr(d,r),t[0]=d,t[1]=r,t[2]=f):f=t[2];let p=f;if(p?.projectId!==n){if(!o){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Ia,{}),t[3]=e):e=t[3],e}let e;return t[4]!==i||t[5]!==r?(e=(0,Q.jsx)(It,{to:`/`,search:{...i,worktree:r},replace:!0}),t[4]=i,t[5]=r,t[6]=e):e=t[6],e}let m;t[7]!==d||t[8]!==i||t[9]!==p?(m={selection:p,search:i,inventory:d},t[7]=d,t[8]=i,t[9]=p,t[10]=m):m=t[10];let h;t[11]===a?h=t[12]:(h=a?{remote:a}:{},t[11]=a,t[12]=h);let g;return t[13]!==l||t[14]!==s||t[15]!==c||t[16]!==m||t[17]!==h?(g=(0,Q.jsx)(aO,{review:m,...h,remoteStatus:s,showRemoteNotice:c,background:l}),t[13]=l,t[14]=s,t[15]=c,t[16]=m,t[17]=h,t[18]=g):g=t[18],g}var iO=Ln(void 0);function aO(e){let t=(0,$.c)(4),n;t[0]===e.remote?n=t[1]:(n=e.remote?Jt(e.remote.remote.environmentId):iO,t[0]=e.remote,t[1]=n),Vt(n);let r;return t[2]===e?r=t[3]:(r=(0,Q.jsx)(eO,{...e}),t[2]=e,t[3]=r),r}var oO={kind:`home`,pathname:`/`,search:{}};function sO(e){if(!e)return oO;let{pathname:t}=e;switch(e.routeId){case`/_paired/`:return{kind:`home`,pathname:t,search:e.search};case`/_paired/$projectId/$worktreeId`:return{kind:`worktree`,pathname:t,projectId:e.params.projectId,worktreeId:e.params.worktreeId,search:e.search};case`/_paired/remotes/$environmentId/$projectId/$worktreeId`:return{kind:`remote`,pathname:t,environmentId:e.params.environmentId,projectId:e.params.projectId,worktreeId:e.params.worktreeId,search:e.search};case`/_paired/settings/$section/`:case`/_paired/settings/$section/$environmentId`:return lo(e.params.section,`environmentId`in e.params?e.params.environmentId:void 0)?{kind:`settings`}:{kind:`not-found`,pathname:t};default:return{kind:`not-found`,pathname:t}}}function cO(e){let t=(0,$.c)(9),n;t[0]===e?n=t[1]:(n=JSON.stringify(e),t[0]=e,t[1]=n);let r=n,i;t[2]!==e||t[3]!==r?(i=()=>({key:r,view:e.kind===`settings`?oO:e}),t[2]=e,t[3]=r,t[4]=i):i=t[4];let[a,o]=(0,Z.useState)(i);e.kind!==`settings`&&a.key!==r&&o({key:r,view:e});let s;return t[5]!==a||t[6]!==e||t[7]!==r?(s=e.kind===`settings`?{workspace:a.view,workspaceKey:a.key,settingsOpen:!0}:{workspace:e,workspaceKey:r,settingsOpen:!1},t[5]=a,t[6]=e,t[7]=r,t[8]=s):s=t[8],s}function lO(e){let t=(0,$.c)(18),{view:n,settled:r,background:i,resetKey:a}=e,o=Vc(),s=!i,c;t[0]!==o.hotkey||t[1]!==s?(c={...o.hotkey,enabled:s},t[0]=o.hotkey,t[1]=s,t[2]=c):c=t[2];let l;t[3]!==o||t[4]!==c?(l={...o,hotkey:c},t[3]=o,t[4]=c,t[5]=l):l=t[5];let u;t[6]===a?u=t[7]:(u=()=>a,t[6]=a,t[7]=u);let d;t[8]!==i||t[9]!==r||t[10]!==n?(d=(0,Q.jsx)(uO,{view:n,settled:r,background:i}),t[8]=i,t[9]=r,t[10]=n,t[11]=d):d=t[11];let f;t[12]!==u||t[13]!==d?(f=(0,Q.jsx)(ea,{getResetKey:u,errorComponent:tl,children:d}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;return t[15]!==l||t[16]!==f?(p=(0,Q.jsx)(yc,{defaultOptions:l,children:f}),t[15]=l,t[16]=f,t[17]=p):p=t[17],p}function uO(e){let t=(0,$.c)(19),{view:n,settled:r,background:i}=e;switch(n.kind){case`home`:{let e;return t[0]!==i||t[1]!==r||t[2]!==n.search?(e=(0,Q.jsx)(dO,{search:n.search,settled:r,background:i}),t[0]=i,t[1]=r,t[2]=n.search,t[3]=e):e=t[3],e}case`worktree`:{let e;return t[4]!==i||t[5]!==r||t[6]!==n.projectId||t[7]!==n.search||t[8]!==n.worktreeId?(e=(0,Q.jsx)(rO,{projectId:n.projectId,worktreeId:n.worktreeId,search:n.search,settled:r,background:i}),t[4]=i,t[5]=r,t[6]=n.projectId,t[7]=n.search,t[8]=n.worktreeId,t[9]=e):e=t[9],e}case`remote`:{let e;return t[10]!==i||t[11]!==r||t[12]!==n.environmentId||t[13]!==n.projectId||t[14]!==n.search||t[15]!==n.worktreeId?(e=(0,Q.jsx)(fO,{environmentId:n.environmentId,projectId:n.projectId,worktreeId:n.worktreeId,search:n.search,settled:r,background:i},n.environmentId),t[10]=i,t[11]=r,t[12]=n.environmentId,t[13]=n.projectId,t[14]=n.search,t[15]=n.worktreeId,t[16]=e):e=t[16],e}case`not-found`:{let e;return t[17]===i?e=t[18]:(e=(0,Q.jsx)(eO,{notice:`not-found`,background:i}),t[17]=i,t[18]=e),e}}}function dO(e){let t=(0,$.c)(18),{search:n,settled:r,background:i}=e,a,o;t[0]===n?(a=t[1],o=t[2]):({worktree:o,...a}=n,t[0]=n,t[1]=a,t[2]=o);let{connection:s}=vr(),c=Aa(s),l;t[3]!==c||t[4]!==o?(l=o===void 0?nr(c,ar(c)?.id):nr(c,o),t[3]=c,t[4]=o,t[5]=l):l=t[5];let u=l;if(u&&r){let e;t[6]!==u.projectId||t[7]!==u.worktree.id?(e={projectId:u.projectId,worktreeId:u.worktree.id},t[6]=u.projectId,t[7]=u.worktree.id,t[8]=e):e=t[8];let n;t[9]!==a||t[10]!==o?(n=o===void 0?{}:a,t[9]=a,t[10]=o,t[11]=n):n=t[11];let r;return t[12]!==e||t[13]!==n?(r=(0,Q.jsx)(It,{to:`/$projectId/$worktreeId`,params:e,search:n,replace:!0}),t[12]=e,t[13]=n,t[14]=r):r=t[14],r}let d=o!==void 0&&r?`missing-worktree`:void 0,f;return t[15]!==i||t[16]!==d?(f=(0,Q.jsx)(eO,{notice:d,background:i}),t[15]=i,t[16]=d,t[17]=f):f=t[17],f}function fO(e){let t=(0,$.c)(7);Oe(e.environmentId);{if(!e.settled){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Ia,{}),t[0]=e):e=t[0],e}let n;return t[1]!==e.search||t[2]!==e.worktreeId?(n=(0,Q.jsx)(It,{to:`/`,search:{...e.search,worktree:e.worktreeId},replace:!0}),t[1]=e.search,t[2]=e.worktreeId,t[3]=n):n=t[3],n}}function pO(){let e=(0,$.c)(11),t=f(),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={select:hO},e[0]=n):n=e[0];let{workspace:r,workspaceKey:i,settingsOpen:a}=cO(aa(n)),o;e[1]===r?o=e[2]:(o={select:e=>e.status===`idle`&&e.location.pathname===r.pathname},e[1]=r,e[2]=o);let s=nl(o),c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c={select:mO},e[3]=c):c=e[3];let l=nl(c),u;return e[4]!==t||e[5]!==l||e[6]!==a||e[7]!==s||e[8]!==r||e[9]!==i?(u=t?(0,Q.jsxs)(qw,{children:[(0,Q.jsx)(lO,{view:r,settled:s,background:a,resetKey:i}),(0,Q.jsx)($r,{}),(0,Q.jsx)(KD,{connection:t,empty:l,settingsOpen:a})]}):(0,Q.jsx)(It,{to:`/pair`,replace:!0}),e[4]=t,e[5]=l,e[6]=a,e[7]=s,e[8]=r,e[9]=i,e[10]=u):u=e[10],u}function mO(e){return e.location.pathname===`/`}function hO(e){return sO(e.at(-1))}export{pO as component};
|