@p4code/cli 0.7.10 → 0.7.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/bin.mjs +688 -282
  2. package/dist/client/assets/DiffPanel-CjaHqa_8.js +98 -0
  3. package/dist/client/assets/FilePreviewPanel-C2PYAtLd.js +2230 -0
  4. package/dist/client/assets/P4DesignScreen-BsHZJ1Ch.css +1 -0
  5. package/dist/client/assets/P4DesignScreen-DC7SIQVB.js +19 -0
  6. package/dist/client/assets/PreviewPanel-BZDO7-Mk.js +2 -0
  7. package/dist/client/assets/PullRequestCodeTab-C_tIdavh.js +251 -0
  8. package/dist/client/assets/collapsible-SgMHVGmw.js +2 -0
  9. package/dist/client/assets/{entities-CB30asjw.js → entities-B4SwAa71.js} +2 -2
  10. package/dist/client/assets/{fileCommentAnnotations-B4KDyWYP.js → fileCommentAnnotations-5NB78l1R.js} +2 -2
  11. package/dist/client/assets/{index-CLwUrcHN.js → index-C5KWoWnj.js} +259 -249
  12. package/dist/client/assets/input-DXewBWN5.js +2 -0
  13. package/dist/client/assets/renderFileChildren-DyCrUihH.js +2 -0
  14. package/dist/client/assets/textarea-nbGt7Tak.js +48 -0
  15. package/dist/client/assets/timestampFormat-C0cLmm_Q.js +2 -0
  16. package/dist/client/assets/toggle-group-wBnK735z.js +2 -0
  17. package/dist/client/index.html +6 -4
  18. package/dist/{renderer-CcbFiDA_.mjs → renderer-BM58dAjb.mjs} +2 -2
  19. package/dist/{runtime-4S909Au8.mjs → runtime-1CxXZlXT.mjs} +2 -2
  20. package/dist/{src-KPj1bz7P.mjs → src-BkeUiTFp.mjs} +131 -3
  21. package/package.json +1 -1
  22. package/dist/client/assets/DiffPanel-CGdUVPnJ.js +0 -98
  23. package/dist/client/assets/FilePreviewPanel-BgE5h4tr.js +0 -2230
  24. package/dist/client/assets/P4DesignScreen-D6gkHJN-.css +0 -1
  25. package/dist/client/assets/P4DesignScreen-i-7mNhPB.js +0 -19
  26. package/dist/client/assets/PreviewPanel-D42c3ZHu.js +0 -2
  27. package/dist/client/assets/PullRequestCodeTab-D5W0ZyCG.js +0 -251
  28. package/dist/client/assets/collapsible-CjR2aTi6.js +0 -2
  29. package/dist/client/assets/renderFileChildren-DgVcYeGG.js +0 -2
  30. package/dist/client/assets/textarea-DXj6RvAd.js +0 -48
  31. package/dist/client/assets/toggle-group-Bla5cmgT.js +0 -2
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{Bi as i,Bl as a,Cl as o,Ei as s,Fi as c,Fu as l,G as u,H as d,Hi as f,Ii as p,Li as m,Mn as h,Ni as g,Pi as _,Qs as v,Rl as y,U as b,Ui as x,Ul as S,Vc as C,Vi as ee,Vl as w,W as T,Zl as E,al as D,bp as O,eu as k,f as A,i as j,iu as te,ki as M,n as ne,q as N,r as P,vp as re,zi as ie}from"./textarea-DXj6RvAd.js";import{$ as ae,$n as F,B as I,Br as L,Di as oe,E as R,Ei as se,F as z,Gr as B,Hr as V,I as ce,Ji as le,Jr as H,Kr as U,L as W,Li as ue,Ni as G,Qn as K,Qr as q,R as de,Si as fe,Ti as pe,Ur as me,V as J,Vr as he,Wr as Y,Xr as ge,Yr as X,Zr as _e,a as ve,ai as ye,c as be,d as xe,ei as Se,er as Ce,et as we,i as Te,ii as Ee,l as De,m as Oe,n as ke,ni as Ae,nr as je,o as Me,oi as Ne,qi as Pe,qr as Fe,r as Ie,ri as Le,s as Re,t as ze,ti as Be,tr as Ve,tt as He,u as Ue,vi as We,wr as Ge,xi as Ke,xr as qe,yi as Je,z as Ye,zr as Xe}from"./index-CLwUrcHN.js";var Ze=v(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),Qe=v(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),$e=v(`radio-tower`,[[`path`,{d:`M4.9 16.1C1 12.2 1 5.8 4.9 1.9`,key:`s0qx1y`}],[`path`,{d:`M7.8 4.7a6.14 6.14 0 0 0-.8 7.5`,key:`1idnkw`}],[`circle`,{cx:`12`,cy:`9`,r:`2`,key:`1092wv`}],[`path`,{d:`M16.2 4.8c2 2 2.26 5.11.8 7.47`,key:`ojru2q`}],[`path`,{d:`M19.1 1.9a9.96 9.96 0 0 1 0 14.1`,key:`rhi7fg`}],[`path`,{d:`M9.5 18h5`,key:`mfy3pd`}],[`path`,{d:`m8 22 4-11 4 11`,key:`25yftu`}]]),Z=r(),Q=e(n(),1),$=t(),et=()=>{};function tt(e){let t=(0,Z.c)(116),{url:n,displayUrl:r,loading:i,loadProgress:a,canGoBack:o,canGoForward:c,refreshDisabled:l,inputDisabled:d,focusUrlNonce:f,onBack:p,onForward:m,onRefresh:h,onSubmit:g,onOpenInBrowser:_,onCapture:v,captureDisabled:y,recording:b,onPictureInPicture:S,pictureInPicture:C,pictureInPictureDisabled:ee,onPickElement:w,pickActive:E,pickDisabled:D,pickDisabledReason:O,trailingActions:k}=e,A=(0,Q.useRef)(null),[j,te]=(0,Q.useState)(n),[M,ne]=(0,Q.useState)(!1),P;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(P=[],t[0]=P):P=t[0];let[re,ie]=(0,Q.useState)(P),[F,I]=(0,Q.useState)(-1),L=(0,Q.useId)(),oe;t[1]!==j||t[2]!==re||t[3]!==M||t[4]!==n?(oe=M&&j!==n?Ue(re,j):[],t[1]=j,t[2]=re,t[3]=M,t[4]=n,t[5]=oe):oe=t[5];let R=oe,se,z;t[6]===f?(se=t[7],z=t[8]):(se=()=>{if(f==null)return;let e=A.current;e&&e.focus()},z=[f],t[6]=f,t[7]=se,t[8]=z),(0,Q.useEffect)(se,z);let B;t[9]!==F||t[10]!==j||t[11]!==g||t[12]!==R?(B=e=>{e?.preventDefault();let t=R[F]?.url??j.trim();t.length!==0&&(g(t),A.current?.blur())},t[9]=F,t[10]=j,t[11]=g,t[12]=R,t[13]=B):B=t[13];let V=B,ce=o?p:et,H=!o,U;t[14]!==ce||t[15]!==H?(U=(0,$.jsx)(s,{variant:`ghost`,size:`icon-xs`,onClick:ce,disabled:H,"aria-label":`Back`,type:`button`}),t[14]=ce,t[15]=H,t[16]=U):U=t[16];let W;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(le,{}),t[17]=W):W=t[17];let G;t[18]===U?G=t[19]:(G=(0,$.jsx)(N,{render:U,children:W}),t[18]=U,t[19]=G);let K;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(u,{children:`Back`}),t[20]=K):K=t[20];let q;t[21]===G?q=t[22]:(q=(0,$.jsxs)(T,{children:[G,K]}),t[21]=G,t[22]=q);let de=c?m:et,me=!c,J;t[23]!==de||t[24]!==me?(J=(0,$.jsx)(s,{variant:`ghost`,size:`icon-xs`,onClick:de,disabled:me,"aria-label":`Forward`,type:`button`}),t[23]=de,t[24]=me,t[25]=J):J=t[25];let he;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,$.jsx)(Pe,{}),t[26]=he):he=t[26];let Y;t[27]===J?Y=t[28]:(Y=(0,$.jsx)(N,{render:J,children:he}),t[27]=J,t[28]=Y);let ge;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,$.jsx)(u,{children:`Forward`}),t[29]=ge):ge=t[29];let X;t[30]===Y?X=t[31]:(X=(0,$.jsxs)(T,{children:[Y,ge]}),t[30]=Y,t[31]=X);let _e=l?et:h,ve=i?`Stop`:`Refresh`,ye;t[32]!==l||t[33]!==_e||t[34]!==ve?(ye=(0,$.jsx)(s,{variant:`ghost`,size:`icon-xs`,onClick:_e,disabled:l,"aria-label":ve,type:`button`}),t[32]=l,t[33]=_e,t[34]=ve,t[35]=ye):ye=t[35];let be=i&&`animate-spin`,xe;t[36]===be?xe=t[37]:(xe=x(be),t[36]=be,t[37]=xe);let Se;t[38]===xe?Se=t[39]:(Se=(0,$.jsx)(We,{className:xe}),t[38]=xe,t[39]=Se);let Ce;t[40]!==ye||t[41]!==Se?(Ce=(0,$.jsx)(N,{render:ye,children:Se}),t[40]=ye,t[41]=Se,t[42]=Ce):Ce=t[42];let Te=i?`Loading…`:`Refresh`,Ee;t[43]===Te?Ee=t[44]:(Ee=(0,$.jsx)(u,{children:Te}),t[43]=Te,t[44]=Ee);let Oe;t[45]!==Ce||t[46]!==Ee?(Oe=(0,$.jsxs)(T,{children:[Ce,Ee]}),t[45]=Ce,t[46]=Ee,t[47]=Oe):Oe=t[47];let ke;t[48]!==q||t[49]!==X||t[50]!==Oe?(ke=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`Navigation`,children:[q,X,Oe]}),t[48]=q,t[49]=X,t[50]=Oe,t[51]=ke):ke=t[51];let Ae=M?j:r??n,je=_&&!M&&`group-hover/address:pe-7 transition-[padding]`,Me;t[52]===je?Me=t[53]:(Me=x(je),t[52]=je,t[53]=Me);let Ne;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=e=>{te(e.target.value),I(-1)},t[54]=Ne):Ne=t[54];let Fe;t[55]===n?Fe=t[56]:(Fe=()=>{te(n),ie(De()),I(-1),ne(!0),queueMicrotask(()=>A.current?.select())},t[55]=n,t[56]=Fe);let Ie;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=()=>{ne(!1)},t[57]=Ie):Ie=t[57];let Le;t[58]!==V||t[59]!==R.length||t[60]!==n?(Le=e=>{if(e.key===`Enter`&&V(e),(e.key===`ArrowDown`||e.key===`ArrowUp`)&&R.length>0){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;I(e=>{let n=e+t;return n>=R.length?-1:n<-1?R.length-1:n})}e.key===`Escape`&&(e.preventDefault(),te(n),A.current?.blur())},t[58]=V,t[59]=R.length,t[60]=n,t[61]=Le):Le=t[61];let Re=R.length>0,ze=F>=0?`${L}-${F}`:void 0,Be;t[62]!==d||t[63]!==L||t[64]!==Ae||t[65]!==Me||t[66]!==Fe||t[67]!==Le||t[68]!==Re||t[69]!==ze?(Be=(0,$.jsx)(N,{render:(0,$.jsx)(He,{ref:A,value:Ae,className:Me,onChange:Ne,onFocus:Fe,onBlur:Ie,onKeyDown:Le,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":Re,"aria-controls":L,"aria-activedescendant":ze,placeholder:`Search or enter URL`,spellCheck:!1,disabled:d,"data-preview-url-input":!0,size:`sm`})}),t[62]=d,t[63]=L,t[64]=Ae,t[65]=Me,t[66]=Fe,t[67]=Le,t[68]=Re,t[69]=ze,t[70]=Be):Be=t[70];let Ve;t[71]!==r||t[72]!==M||t[73]!==n?(Ve=!M&&r?(0,$.jsx)(u,{children:n}):null,t[71]=r,t[72]=M,t[73]=n,t[74]=Ve):Ve=t[74];let Ge;t[75]!==Be||t[76]!==Ve?(Ge=(0,$.jsxs)(T,{children:[Be,Ve]}),t[75]=Be,t[76]=Ve,t[77]=Ge):Ge=t[77];let Ke;t[78]!==M||t[79]!==_?(Ke=_&&!M?(0,$.jsx)(we,{align:`inline-end`,className:`pointer-events-none absolute inset-y-0 right-0 opacity-0 transition-opacity group-hover/address:pointer-events-auto group-hover/address:opacity-100`,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(N,{render:(0,$.jsx)(s,{variant:`ghost`,size:`icon-xs`,onClick:_,"aria-label":`Open in system browser`,type:`button`}),children:(0,$.jsx)(ue,{})}),(0,$.jsx)(u,{children:`Open in system browser`})]})}):null,t[78]=M,t[79]=_,t[80]=Ke):Ke=t[80];let qe;t[81]!==Ge||t[82]!==Ke?(qe=(0,$.jsxs)(ae,{className:`group/address h-7 flex-1 rounded-md border-transparent bg-transparent shadow-none before:shadow-none hover:bg-muted/40 focus-within:bg-background`,children:[Ge,Ke]}),t[81]=Ge,t[82]=Ke,t[83]=qe):qe=t[83];let Je;t[84]!==w||t[85]!==E||t[86]!==D||t[87]!==O?(Je=w?(0,$.jsxs)(T,{children:[(0,$.jsx)(N,{render:(0,$.jsx)(s,{variant:E?`secondary`:`ghost`,size:`icon-xs`,onClick:w,disabled:D,"aria-label":E?`Cancel annotation`:`Annotate preview`,"aria-pressed":E?`true`:`false`,type:`button`}),children:(0,$.jsx)(pe,{className:x(E&&`text-primary`)})}),(0,$.jsx)(u,{children:D&&O?O:E?`Cancel annotation (Esc)`:`Annotate elements, regions, and drawings`})]}):null,t[84]=w,t[85]=E,t[86]=D,t[87]=O,t[88]=Je):Je=t[88];let Ye;t[89]!==y||t[90]!==v||t[91]!==b?(Ye=v?(0,$.jsxs)(T,{children:[(0,$.jsxs)(N,{render:(0,$.jsx)(s,{variant:b?`secondary`:`ghost`,size:`icon-xs`,onClick:e=>v(e.shiftKey),"aria-label":b?`Stop recording`:`Capture screenshot`,type:`button`,className:`relative`,disabled:y}),children:[(0,$.jsx)(Ze,{className:x(b&&`text-destructive`)}),b?(0,$.jsx)(`span`,{className:`absolute right-0.5 top-0.5 size-1.5 animate-status-pulse rounded-full bg-destructive`}):null]}),(0,$.jsx)(u,{children:b?`Stop recording`:`Screenshot · Shift-click to record`})]}):null,t[89]=y,t[90]=v,t[91]=b,t[92]=Ye):Ye=t[92];let Xe;t[93]!==S||t[94]!==C||t[95]!==ee?(Xe=S?(0,$.jsxs)(T,{children:[(0,$.jsx)(N,{render:(0,$.jsx)(s,{variant:C?`secondary`:`ghost`,size:`icon-xs`,onClick:S,"aria-label":C?`Close floating preview`:`Float preview over chat`,"aria-pressed":C?`true`:`false`,type:`button`,disabled:ee}),children:(0,$.jsx)(fe,{className:x(C&&`text-primary`)})}),(0,$.jsx)(u,{children:C?`Close floating preview`:`Float preview over chat`})]}):null,t[93]=S,t[94]=C,t[95]=ee,t[96]=Xe):Xe=t[96];let Qe;t[97]!==V||t[98]!==ke||t[99]!==qe||t[100]!==Je||t[101]!==Ye||t[102]!==Xe||t[103]!==k?(Qe=(0,$.jsxs)(`form`,{onSubmit:V,className:`surface-subheader gap-1 px-2`,"data-surface-subheader":!0,children:[ke,qe,Je,Ye,Xe,k]}),t[97]=V,t[98]=ke,t[99]=qe,t[100]=Je,t[101]=Ye,t[102]=Xe,t[103]=k,t[104]=Qe):Qe=t[104];let $e;t[105]!==F||t[106]!==g||t[107]!==R||t[108]!==L?($e=R.length>0?(0,$.jsx)(`ul`,{id:L,role:`listbox`,"aria-label":`History suggestions`,className:`absolute inset-x-2 top-full z-50 mt-1 overflow-hidden rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-lg`,children:R.map((e,t)=>(0,$.jsxs)(`li`,{id:`${L}-${t}`,role:`option`,"aria-selected":t===F,onMouseDown:nt,onClick:()=>{g(e.url),A.current?.blur()},onMouseEnter:()=>I(t),className:`flex cursor-default flex-col rounded-md px-2 py-1 text-sm aria-selected:bg-accent aria-selected:text-accent-foreground`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.title||e.url}),e.title?(0,$.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.url}):null]},e.url))}):null,t[105]=F,t[106]=g,t[107]=R,t[108]=L,t[109]=$e):$e=t[109];let tt;t[110]===a?tt=t[111]:(tt=a>0?(0,$.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute bottom-0 left-0 z-10 h-0.5 rounded-r-full bg-primary transition-all duration-150 ease-out`,style:{width:`${a}%`,boxShadow:`0 0 6px 1px var(--color-ring)`}}):null,t[110]=a,t[111]=tt);let rt;return t[112]!==Qe||t[113]!==$e||t[114]!==tt?(rt=(0,$.jsxs)(`div`,{className:`relative`,children:[Qe,$e,tt]}),t[112]=Qe,t[113]=$e,t[114]=tt,t[115]=rt):rt=t[115],rt}function nt(e){return e.preventDefault()}function rt(e){try{let t=new URL(e.url),n=new URL(e.environmentHttpBaseUrl);if(t.origin===n.origin&&t.pathname.startsWith(`/api/assets/`)){let n=t.pathname.split(`/`).at(-1);if(!n)return null;let r=decodeURIComponent(n);return!r||r===`.`||r===`..`?null:`${e.environmentLabel} · ${r}`}return t.protocol===`http:`||t.protocol===`https:`?t.host:null}catch{return null}}function it(e){let t=(0,Z.c)(6),{className:n}=e,r;t[0]===n?r=t[1]:(r=x(`relative flex flex-col gap-0.5 overflow-hidden rounded-[5px] border border-border/60 bg-card p-1 shadow-xs/5`,n),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`flex gap-[2px]`,children:[(0,$.jsx)(`span`,{className:`size-[3px] rounded-full bg-destructive/80`}),(0,$.jsx)(`span`,{className:`size-[3px] rounded-full bg-warning/80`}),(0,$.jsx)(`span`,{className:`size-[3px] rounded-full bg-success/80`})]}),t[2]=i):i=t[2];let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsxs)(`div`,{className:`mt-[1px] flex flex-1 flex-col gap-[2px]`,children:[(0,$.jsx)(`span`,{className:`h-[2px] w-full rounded-full bg-muted-foreground/30`}),(0,$.jsx)(`span`,{className:`h-[2px] w-3/5 rounded-full bg-muted-foreground/20`})]}),t[3]=a):a=t[3];let o;return t[4]===r?o=t[5]:(o=(0,$.jsxs)(`div`,{"aria-hidden":!0,className:r,children:[i,a]}),t[4]=r,t[5]=o),o}function at(e){let t=(0,Z.c)(17),{server:n,onOpen:r}=e,i;t[0]===n?i=t[1]:(i=ot(n),t[0]=n,t[1]=i);let a=i,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(it,{className:`size-7 shrink-0`}),t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:a}),t[3]=a,t[4]=s);let c;t[5]!==n.host||t[6]!==n.port?(c=(0,$.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[n.host,`:`,n.port]}),t[5]=n.host,t[6]=n.port,t[7]=c):c=t[7];let l;t[8]!==s||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[s,c]}),t[8]=s,t[9]=c,t[10]=l):l=t[10];let u;t[11]===n.listening?u=t[12]:(u=n.listening?(0,$.jsx)(st,{}):(0,$.jsx)(ct,{}),t[11]=n.listening,t[12]=u);let d;return t[13]!==r||t[14]!==l||t[15]!==u?(d=(0,$.jsxs)(`button`,{type:`button`,onClick:r,className:`group flex w-full items-center gap-3 px-3 py-3 text-left hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[o,l,u]}),t[13]=r,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}function ot(e){return e.processName?e.processName:e.listening?`Listening`:e.source===`configured`?`Configured`:`Recently seen`}function st(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`span`,{"aria-label":`Listening`,className:`relative inline-flex size-2 shrink-0`,children:[(0,$.jsx)(`span`,{className:`absolute inset-0 animate-status-ping rounded-full bg-success opacity-60`}),(0,$.jsx)(`span`,{className:`relative inline-flex size-2 rounded-full bg-success`})]}),e[0]=t):t=e[0],t}function ct(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`span`,{"aria-label":`Not currently listening`,className:`size-2 shrink-0 rounded-full bg-muted-foreground/40`}),e[0]=t):t=e[0],t}function lt(e){let t=(0,Z.c)(7),n=_e(e.environmentId),r;if(t[0]!==e.configuredUrls||t[1]!==e.environmentId||t[2]!==e.recentlySeenUrls||t[3]!==n){let i;t[5]===e.environmentId?i=t[6]:(i=t=>({...t,url:H(e.environmentId,t.url)}),t[5]=e.environmentId,t[6]=i),r=ut({scanner:n.map(i),configuredUrls:e.configuredUrls??[],recentlySeenUrls:e.recentlySeenUrls??[]}),t[0]=e.configuredUrls,t[1]=e.environmentId,t[2]=e.recentlySeenUrls,t[3]=n,t[4]=r}else r=t[4];return r}function ut(e){let t=new Map;for(let n of e.configuredUrls){let e=ft(n);if(!e)continue;let r=dt(e.host,e.port);t.has(r)||t.set(r,{host:e.host,port:e.port,url:e.url,processName:null,pid:null,terminal:null,source:`configured`,listening:!1})}for(let n of e.scanner){let e=dt(n.host,n.port),r=t.get(e);if(r){t.set(e,{...r,processName:n.processName??r.processName,pid:n.pid??r.pid,terminal:n.terminal??r.terminal,listening:!0});continue}t.set(e,{...n,source:`scanner`,listening:!0})}for(let n of e.recentlySeenUrls){let e=ft(n);if(!e)continue;let r=dt(e.host,e.port);t.has(r)||t.set(r,{host:e.host,port:e.port,url:e.url,processName:null,pid:null,terminal:null,source:`recent`,listening:!1})}return Array.from(t.values()).toSorted((e,t)=>{let n={configured:0,scanner:1,recent:2};return n[e.source]===n[t.source]?e.port-t.port:n[e.source]-n[t.source]})}function dt(e,t){return`${e.toLowerCase()}:${t}`}function ft(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`||!X(t.hostname))return null;let n=t.port?Number.parseInt(t.port,10):t.protocol===`http:`?80:443;return!Number.isFinite(n)||n<=0?null:{host:t.hostname,port:n,url:t.href}}catch{return null}}function pt(e){let t=(0,Z.c)(16),{environmentId:n,configuredUrls:r,recentlySeenUrls:i,onOpenUrl:a}=e,o;t[0]!==r||t[1]!==n||t[2]!==i?(o={environmentId:n,configuredUrls:r,recentlySeenUrls:i},t[0]=r,t[1]=n,t[2]=i,t[3]=o):o=t[3];let s=lt(o);if(s.length===0){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(K,{children:[(0,$.jsx)(Ce,{variant:`icon`,children:(0,$.jsx)(G,{className:`size-4.5 text-muted-foreground`})}),(0,$.jsx)(Ve,{children:`No preview yet`}),(0,$.jsx)(F,{children:`Type a URL above, or run a dev script. Listening localhost ports will show up here automatically.`})]}),t[4]=e):e=t[4],e}let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)($e,{className:`size-4 shrink-0`}),(0,$.jsx)(`h2`,{className:`font-medium`,children:`Local servers`})]}),t[5]=c):c=t[5];let l;if(t[6]!==a||t[7]!==s){let e;t[9]===a?e=t[10]:(e=e=>(0,$.jsx)(at,{server:e,onOpen:()=>a(e.url)},`${e.host}:${e.port}`),t[9]=a,t[10]=e),l=s.map(e),t[6]=a,t[7]=s,t[8]=l}else l=t[8];let u;t[11]===l?u=t[12]:(u=(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border/60 overflow-hidden rounded-xl border border-border/70 bg-background`,children:l}),t[11]=l,t[12]=u);let d;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:`Select a listening port to open it in this browser tab.`}),t[13]=d):d=t[13];let f;return t[14]===u?f=t[15]:(f=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 overflow-y-auto px-5 py-8`,children:(0,$.jsxs)(`div`,{className:`m-auto flex w-full max-w-xl flex-col gap-3`,children:[c,u,d]})}),t[14]=u,t[15]=f),f}var mt=e=>(e instanceof Error?e.message:``).replace(/^Error invoking remote method '[^']+':\s*/u,``).replace(/^[A-Za-z]+Error:\s*/u,``).trim()||`Chrome import failed.`;function ht(e){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(!e.open||!z)return;let t=!1;return n(null),l(null),z.listChromeProfiles().then(e=>{t||(n(e),i(e[0]?.id??null))},e=>{t||(n([]),i(null),l(mt(e)))}),()=>{t=!0}},[e.open]);let u=async()=>{if(!(!z||!r)){o(!0);try{let t=await z.importFromChrome({profileId:r});be(t.history),d.add({type:`success`,title:`Imported from Chrome`,description:`${t.importedCookies} cookies and ${t.history.length} history entries.${t.failedCookies>0?` ${t.failedCookies} cookies could not be imported.`:``}`}),e.onOpenChange(!1)}catch(e){d.add({type:`error`,title:`Could not import from Chrome`,description:mt(e)})}finally{o(!1)}}};return(0,$.jsx)(Se,{open:e.open,onOpenChange:e.onOpenChange,children:(0,$.jsxs)(ye,{className:`max-w-md`,children:[(0,$.jsxs)(Le,{children:[(0,$.jsx)(Ne,{children:`Import from Chrome`}),(0,$.jsx)(Be,{children:`Copies all cookies and recent history from a Chrome profile into the built-in browser. Agents that use this browser can act with these signed-in sessions. macOS asks for Keychain access to decrypt the cookies.`})]}),(0,$.jsx)(Ee,{children:c?(0,$.jsx)(`p`,{className:`text-sm text-destructive-foreground`,children:c}):t===null?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Looking for Chrome profiles…`}):t.length===0?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No Chrome profiles found. Importing is available on macOS with Google Chrome installed.`}):(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":`Chrome profile`,className:`space-y-1`,children:t.map(e=>(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 rounded-md px-2 py-1.5 text-sm hover:bg-accent`,children:[(0,$.jsx)(`input`,{type:`radio`,name:`chrome-profile`,value:e.id,checked:r===e.id,onChange:()=>i(e.id)}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.name===e.id?null:(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.id})]},e.id))})}),(0,$.jsxs)(Ae,{children:[(0,$.jsx)(s,{variant:`outline`,onClick:()=>e.onOpenChange(!1),children:`Cancel`}),(0,$.jsx)(s,{disabled:!r||a,onClick:()=>void u(),children:a?`Importing…`:`Import`})]})]})})}var gt=[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}];function _t(e){let t=(0,Z.c)(81),{tabId:n,hasWebContents:r,zoomFactor:a,colorScheme:o,deviceToolbarVisible:l,onToggleDeviceToolbar:d,nativePictureInPicture:p,onNativePictureInPicture:h}=e,[v,y]=(0,Q.useState)(!1);if(!z)return null;let b=!n||!r,x;t[0]===n?x=t[1]:(x=e=>()=>{n&&e(n).catch(Tt)},t[0]=n,t[1]=x);let S=x,C;t[2]===a?C=t[3]:(C=Math.round(a*100),t[2]=a,t[3]=C);let w=`${C}%`,E;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsxs)(T,{children:[(0,$.jsx)(N,{render:(0,$.jsx)(f,{render:(0,$.jsx)(s,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":`Preview menu`})}),children:(0,$.jsx)(Qe,{})}),(0,$.jsx)(u,{children:`More`})]}),t[4]=E):E=t[4];let D;t[5]===S?D=t[6]:(D=S(z.hardReload),t[5]=S,t[6]=D);let O;t[7]!==D||t[8]!==b?(O=(0,$.jsx)(g,{onClick:D,disabled:b,children:`Hard reload`}),t[7]=D,t[8]=b,t[9]=O):O=t[9];let k;t[10]===S?k=t[11]:(k=S(z.openDevTools),t[10]=S,t[11]=k);let A;t[12]!==k||t[13]!==b?(A=(0,$.jsx)(g,{onClick:k,disabled:b,children:`Open DevTools`}),t[12]=k,t[13]=b,t[14]=A):A=t[14];let j=p?`Close separate preview window`:`Open separate preview window`,te;t[15]!==h||t[16]!==j||t[17]!==b?(te=(0,$.jsx)(g,{onClick:h,disabled:b,children:j}),t[15]=h,t[16]=j,t[17]=b,t[18]=te):te=t[18];let ne=l?`Hide device toolbar`:`Show device toolbar`,P;t[19]!==d||t[20]!==ne||t[21]!==b?(P=(0,$.jsx)(g,{onClick:d,disabled:b,children:ne}),t[19]=d,t[20]=ne,t[21]=b,t[22]=P):P=t[22];let re;t[23]===b?re=t[24]:(re=(0,$.jsx)(ee,{disabled:b,children:`Appearance`}),t[23]=b,t[24]=re);let ae;t[25]===n?ae=t[26]:(ae=e=>{n&&z.setColorScheme(n,e).catch(wt)},t[25]=n,t[26]=ae);let F;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(F=gt.map(Ct),t[27]=F):F=t[27];let I;t[28]!==o||t[29]!==ae?(I=(0,$.jsx)(i,{className:`min-w-32`,children:(0,$.jsx)(c,{value:o,onValueChange:ae,children:F})}),t[28]=o,t[29]=ae,t[30]=I):I=t[30];let L;t[31]!==re||t[32]!==I?(L=(0,$.jsxs)(ie,{children:[re,I]}),t[31]=re,t[32]=I,t[33]=L):L=t[33];let R;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(m,{}),t[34]=R):R=t[34];let se;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(`span`,{children:`Zoom`}),t[35]=se):se=t[35];let B;t[36]===S?B=t[37]:(B=S(z.zoomOut),t[36]=S,t[37]=B);let V;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(oe,{}),t[38]=V):V=t[38];let ce;t[39]!==B||t[40]!==b?(ce=(0,$.jsx)(s,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:B,"aria-label":`Zoom out`,disabled:b,children:V}),t[39]=B,t[40]=b,t[41]=ce):ce=t[41];let le;t[42]===w?le=t[43]:(le=(0,$.jsx)(`span`,{className:`min-w-12 text-center text-xs tabular-nums text-muted-foreground`,children:w}),t[42]=w,t[43]=le);let H;t[44]===S?H=t[45]:(H=S(z.zoomIn),t[44]=S,t[45]=H);let U;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(Ke,{}),t[46]=U):U=t[46];let W;t[47]!==H||t[48]!==b?(W=(0,$.jsx)(s,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:H,"aria-label":`Zoom in`,disabled:b,children:U}),t[47]=H,t[48]=b,t[49]=W):W=t[49];let ue;t[50]===S?ue=t[51]:(ue=S(z.resetZoom),t[50]=S,t[51]=ue);let G;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(Je,{}),t[52]=G):G=t[52];let K;t[53]!==ue||t[54]!==b?(K=(0,$.jsx)(s,{variant:`ghost`,size:`icon-xs`,type:`button`,onClick:ue,"aria-label":`Reset zoom`,disabled:b,children:G}),t[53]=ue,t[54]=b,t[55]=K):K=t[55];let q;t[56]!==ce||t[57]!==le||t[58]!==W||t[59]!==K?(q=(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[ce,le,W,K]}),t[56]=ce,t[57]=le,t[58]=W,t[59]=K,t[60]=q):q=t[60];let de;t[61]!==q||t[62]!==b?(de=(0,$.jsxs)(g,{closeOnClick:!1,onClick:St,className:`justify-between`,disabled:b,children:[se,q]}),t[61]=q,t[62]=b,t[63]=de):de=t[63];let fe,pe,me,J;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,$.jsx)(m,{}),pe=(0,$.jsx)(g,{onClick:bt,children:`Clear cookies`}),me=(0,$.jsx)(g,{onClick:vt,children:`Clear cache`}),J=(0,$.jsx)(m,{}),t[64]=fe,t[65]=pe,t[66]=me,t[67]=J):(fe=t[64],pe=t[65],me=t[66],J=t[67]);let he;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,$.jsx)(g,{onClick:()=>y(!0),children:`Import from Chrome…`}),t[68]=he):he=t[68];let Y;t[69]!==P||t[70]!==L||t[71]!==de||t[72]!==O||t[73]!==A||t[74]!==te?(Y=(0,$.jsxs)(M,{children:[E,(0,$.jsxs)(_,{align:`end`,sideOffset:6,className:`min-w-56`,children:[O,A,te,P,L,R,de,fe,pe,me,J,he]})]}),t[69]=P,t[70]=L,t[71]=de,t[72]=O,t[73]=A,t[74]=te,t[75]=Y):Y=t[75];let ge;t[76]===v?ge=t[77]:(ge=(0,$.jsx)(ht,{open:v,onOpenChange:y}),t[76]=v,t[77]=ge);let X;return t[78]!==Y||t[79]!==ge?(X=(0,$.jsxs)($.Fragment,{children:[Y,ge]}),t[78]=Y,t[79]=ge,t[80]=X):X=t[80],X}function vt(){z.clearCache().catch(yt)}function yt(){}function bt(){z.clearCookies().catch(xt)}function xt(){}function St(e){return e.preventDefault()}function Ct(e){return(0,$.jsx)(p,{value:e.value,children:e.label},e.value)}function wt(){}function Tt(){}function Et(e){return Fe[e]||(e.length>0?e:`Network error`)}function Dt(e){let t=(0,Z.c)(32),{url:n,code:r,description:i,onReload:a}=e,[o,c]=(0,Q.useState)(!1),l;t[0]===n?l=t[1]:(l=At(n)??n,t[0]=n,t[1]=l);let u=l,d;t[2]===i?d=t[3]:(d=Et(i),t[2]=i,t[3]=d);let f=d,p;t[4]!==r||t[5]!==i?(p=i.length>0?i:`ERR_${Math.abs(r)||`FAILED`}`,t[4]=r,t[5]=i,t[6]=p):p=t[6];let m=p,h,g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(kt,{className:`mb-6 size-12 text-muted-foreground/70`}),g=(0,$.jsx)(`h1`,{className:`mb-3 text-2xl font-semibold leading-tight text-foreground`,children:`This site can’t be reached`}),t[7]=h,t[8]=g):(h=t[7],g=t[8]);let _;t[9]===u?_=t[10]:(_=(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:u}),t[9]=u,t[10]=_);let v;t[11]!==f||t[12]!==_?(v=(0,$.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:[_,`: `,f,`.`]}),t[11]=f,t[12]=_,t[13]=v):v=t[13];let y;t[14]===o?y=t[15]:(y=o?(0,$.jsxs)(`div`,{className:`mt-6 rounded-lg border border-border bg-muted/40 p-4 text-sm`,children:[(0,$.jsx)(`p`,{className:`mb-2 font-medium text-foreground`,children:`Try:`}),(0,$.jsxs)(`ul`,{className:`list-disc space-y-1 pl-5 text-muted-foreground`,children:[(0,$.jsx)(`li`,{children:`Checking your connection`}),(0,$.jsx)(`li`,{children:`Confirming the dev server is running`}),(0,$.jsx)(`li`,{children:`Checking the proxy and the firewall`})]})]}):null,t[14]=o,t[15]=y);let b;t[16]===m?b=t[17]:(b=(0,$.jsx)(`div`,{className:`mt-8 text-xs uppercase tracking-wide text-muted-foreground/70`,children:m}),t[16]=m,t[17]=b);let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>c(Ot),t[18]=x):x=t[18];let S=o?`Hide details`:`Details`,C;t[19]===S?C=t[20]:(C=(0,$.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:x,children:S}),t[19]=S,t[20]=C);let ee;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(`div`,{className:`flex-1`}),t[21]=ee):ee=t[21];let w;t[22]===a?w=t[23]:(w=(0,$.jsx)(s,{type:`button`,size:`sm`,onClick:a,children:`Reload`}),t[22]=a,t[23]=w);let T;t[24]!==C||t[25]!==w?(T=(0,$.jsxs)(`div`,{className:`mt-auto flex items-center gap-2 pt-8`,children:[C,ee,w]}),t[24]=C,t[25]=w,t[26]=T):T=t[26];let E;return t[27]!==T||t[28]!==v||t[29]!==y||t[30]!==b?(E=(0,$.jsx)(`div`,{className:`relative flex h-full min-h-0 w-full overflow-y-auto bg-background`,children:(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-1 flex-col px-8 py-12 sm:py-16`,children:[h,g,v,y,b,T]})}),t[27]=T,t[28]=v,t[29]=y,t[30]=b,t[31]=E):E=t[31],E}function Ot(e){return!e}function kt(e){let t=(0,Z.c)(5),{className:n}=e,r,i,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`path`,{d:`M16 12 L48 12 L48 52 L16 52 Z`}),i=(0,$.jsx)(`path`,{d:`M22 22 L42 22 M22 30 L36 30 M22 38 L40 38`,strokeLinecap:`round`}),a=(0,$.jsx)(`path`,{d:`M52 8 L12 56`,strokeLinecap:`round`}),t[0]=r,t[1]=i,t[2]=a):(r=t[0],i=t[1],a=t[2]);let o;return t[3]===n?o=t[4]:(o=(0,$.jsxs)(`svg`,{viewBox:`0 0 64 64`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,className:n,children:[r,i,a]}),t[3]=n,t[4]=o),o}function At(e){try{return new URL(e).host}catch{return null}}function jt(e){let t=e.toLowerCase();return t.includes(`mac`)?`Reveal in Finder`:t.includes(`win`)?`Reveal in File Explorer`:`Reveal in Files`}var Mt=120,Nt=220,Pt=4,Ft=90,It=.08,Lt=.5;function Rt(e){let[t,n]=(0,Q.useState)(0),r=(0,Q.useRef)(0);return r.current=t,(0,Q.useEffect)(()=>{if(!e){if(r.current===0)return;n(100);let e=window.setTimeout(()=>n(0),Nt);return()=>window.clearTimeout(e)}n(e=>e>0&&e<95?e:Pt);let t=window.setInterval(()=>{let e=r.current;if(e>=Ft)return;let t=Ft-e,i=Math.max(Lt,t*It);n(Math.min(Ft,e+i))},Mt);return()=>window.clearInterval(t)},[e]),t}var zt=class extends O()(`PreviewSessionThreadKeyParseError`,{threadKey:re}){get message(){return`Invalid scoped preview thread key: ${this.threadKey}`}},Bt=y(e=>{let t=k(e);if(t===null)throw new zt({threadKey:e});let n=q.list({environmentId:t.environmentId,input:{threadId:t.threadId}}),r=q.events({environmentId:t.environmentId,input:{}});return a(e=>{let i=!1,a=0,o=e=>{E(e)&&me(t,e.value)},s=r=>{if(!E(r)||r.value.threadId!==t.threadId)return;let i=V(t).serverEpoch;if(i!==null&&i!==r.value.serverEpoch){e.refresh(n);return}L(t,r.value)};e.addFinalizer(()=>{i=!0});let c=e.once(r);e.subscribe(n,e=>{o(e)}),e.subscribe(r,e=>{a+=1,s(e)}),queueMicrotask(()=>{i||(e.refresh(n),a===0&&s(c))})}).pipe(w(1e3),S(`preview:session-sync:${e}`))});function Vt(e){let t=(0,Z.c)(2),n;t[0]===e?n=t[1]:(n=Bt(te(e)),t[0]=e,t[1]=n),D(n)}var Ht=1500,Ut=.001;function Wt(e){let t=(0,Z.c)(11),{zoomFactor:n}=e,[r,i]=(0,Q.useState)(!1),a=(0,Q.useRef)(n),o=(0,Q.useRef)(null),s,c;t[0]===n?(s=t[1],c=t[2]):(s=()=>{if(!(Math.abs(a.current-n)<Ut))return a.current=n,i(!0),o.current!==null&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{i(!1),o.current=null},Ht),()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)}},c=[n],t[0]=n,t[1]=s,t[2]=c),(0,Q.useEffect)(s,c);let l;t[3]===n?l=t[4]:(l=Math.round(n*100),t[3]=n,t[4]=l);let u=`${l}%`,d=!r,f=r?`opacity-100 translate-y-0`:`opacity-0 -translate-y-1`,p;t[5]===f?p=t[6]:(p=x(`pointer-events-none absolute top-3 right-3 z-20 select-none rounded-full border border-border/70 bg-popover/95 px-2.5 py-1 text-xs font-medium text-foreground shadow-md/10 backdrop-blur transition-all duration-200 ease-out`,f),t[5]=f,t[6]=p);let m;return t[7]!==u||t[8]!==d||t[9]!==p?(m=(0,$.jsx)(`div`,{"aria-hidden":d,className:p,children:u}),t[7]=u,t[8]=d,t[9]=p,t[10]=m):m=t[10],m}function Gt(e,t){return e?1:t===`human`?.18:.35}var Kt=700;function qt(e){let t=(0,Z.c)(9),{tabId:n,zoomFactor:r,controller:i}=e,a;t[0]===n?a=t[1]:(a=e=>e.byTabId[n]??null,t[0]=n,t[1]=a);let o=xe(a),s;t[2]===n?s=t[3]:(s=e=>e.byTabId[n]?.content??null,t[2]=n,t[3]=s);let c=I(s);if(!o)return null;let l;return t[4]!==c||t[5]!==i||t[6]!==o||t[7]!==r?(l=(0,$.jsx)(Jt,{event:o,content:c,zoomFactor:r,controller:i},o.sequence),t[4]=c,t[5]=i,t[6]=o,t[7]=r,t[8]=l):l=t[8],l}function Jt(e){let t=(0,Z.c)(15),{event:n,content:r,zoomFactor:i,controller:a}=e,[o,s]=(0,Q.useState)(!0),c,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=window.setTimeout(()=>s(!1),Kt);return()=>window.clearTimeout(e)},l=[],t[0]=c,t[1]=l):(c=t[0],l=t[1]),(0,Q.useEffect)(c,l);let u;t[2]!==o||t[3]!==a?(u=Gt(o,a),t[2]=o,t[3]=a,t[4]=u):u=t[4];let d=`translate3d(${n.x*i*(r?.scale??1)+(r?.x??0)-(r?.scrollLeft??0)}px, ${n.y*i*(r?.scale??1)+(r?.y??0)-(r?.scrollTop??0)}px, 0)`,f;t[5]!==u||t[6]!==d?(f={opacity:u,transform:d},t[5]=u,t[6]=d,t[7]=f):f=t[7];let p;t[8]!==n.phase||t[9]!==n.sequence?(p=n.phase===`click`?(0,$.jsx)(`span`,{className:`absolute left-0.5 top-0.5 size-4 animate-status-ping rounded-full bg-primary/25 motion-reduce:animate-none`},n.sequence):null,t[8]=n.phase,t[9]=n.sequence,t[10]=p):p=t[10];let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(se,{className:`relative size-5 -translate-x-0.5 -translate-y-0.5 fill-background text-primary drop-shadow-sm`,strokeWidth:2}),t[11]=m):m=t[11];let h;return t[12]!==f||t[13]!==p?(h=(0,$.jsxs)(`div`,{className:`pointer-events-none absolute left-0 top-0 z-40 transition-[transform,opacity] duration-150 ease-out motion-reduce:transition-none`,style:f,"aria-hidden":`true`,"data-agent-browser-cursor":!0,children:[p,m]}),t[12]=f,t[13]=p,t[14]=h):h=t[14],h}var Yt=typeof window>`u`?null:A();function Xt({threadRef:e,tabId:t,configuredUrls:n,visible:r}){let[i,a]=(0,Q.useState)(void 0),[s,c]=(0,Q.useState)(!1),u=Me(),f=(0,Q.useRef)(!1),p=(0,Q.useRef)(!0),m=U(e),g=W(t=>ce(t.byThreadKey,e)),_=h(e=>e.addPreviewAnnotation),v=h(e=>e.addImage),y=P(e.environmentId),x=j(e.environmentId),S=ne(q.open),ee=ne(q.resize,`preview viewport resize`),{resolvedTheme:w}=Ge();Vt(e),(0,Q.useEffect)(()=>(p.current=!0,()=>{p.current=!1}),[]);let T=t??m.activeTabId,E=T?de(e,m.serverEpoch,T):null,D=T&&E?u.has(E)?E:Ie(e,T):null,O=T?m.sessions[T]??null:null,k=T?m.desktopByTabId[T]??null:null;(0,Q.useEffect)(()=>{let e=z;if(!(!e||!E||!k?.pictureInPicture))return e.pictureInPicture.setVisible(E,r),()=>{e.pictureInPicture.setVisible(E,!1)}},[k?.pictureInPicture,E,r]);let A=O?.navStatus??{_tag:`Idle`},M=A._tag===`Idle`?``:A.url,N=k?.loading??A._tag===`Loading`,re=k?.canGoBack??O?.canGoBack??!1,ie=k?.canGoForward??O?.canGoForward??!1,ae=A._tag===`Idle`,F=A._tag===`LoadFailed`,L=R(O),oe=k?.controller??`none`,se=Rt(N),V=M&&y&&x?rt({url:M,environmentLabel:y.label,environmentHttpBaseUrl:x})??void 0:void 0,le=O?.viewport??l,ue=I(e=>E?e.byTabId[E]?.rect??null:null),G=(0,Q.useCallback)(async t=>{E&&z?(await z.navigate(E,t),Y(e,t)):await Xe({openPreview:S,threadRef:e,url:t})},[S,E,e]),K=(0,Q.useCallback)(async e=>{try{await G(ge(e))}catch{}},[G]),fe=(0,Q.useCallback)(async t=>{try{await G(H(e.environmentId,t))}catch{}},[G,e.environmentId]),pe=(0,Q.useCallback)(()=>{z&&E&&z.refresh(E)},[E]),me=(0,Q.useCallback)(()=>{z&&E&&z.zoomIn(E)},[E]),J=(0,Q.useCallback)(()=>{z&&E&&z.zoomOut(E)},[E]),he=(0,Q.useCallback)(()=>{z&&E&&z.resetZoom(E)},[E]),X=(0,Q.useCallback)(async t=>{if(!T)return;let n=await ee({environmentId:e.environmentId,input:{threadId:e.threadId,tabId:T,viewport:t}});if(n._tag===`Failure`){let e=o(n);throw d.add({type:`error`,title:`Unable to resize browser viewport`,description:e instanceof Error?e.message:`An error occurred.`}),e}B(e,n.value)},[ee,T,e]),_e=()=>{if(!E)return;if(le._tag!==`fill`){ze(E,l).catch(()=>void 0);return}let e=ue?Re(ue,k?.zoomFactor):{width:1024,height:768};ze(E,{_tag:`freeform`,...e}).catch(()=>void 0)};(0,Q.useEffect)(()=>{if(E)return ke(E,X)},[X,E]);let ye=(0,Q.useCallback)(()=>{z&&E&&z.goBack(E)},[E]),be=(0,Q.useCallback)(()=>{z&&E&&z.goForward(E)},[E]),xe=(0,Q.useCallback)(()=>{!Yt||!M||Yt.shell.openExternal(M).catch(()=>void 0)},[M]),Se=(0,Q.useCallback)(()=>{if(T){if(g?.tabId===T){W.getState().close(e);return}W.getState().open(e,T),C.getState().close(e)}},[g?.tabId,T,e]),Ce=(0,Q.useCallback)(()=>{!z||!E||(k?.pictureInPicture?z.pictureInPicture.close:z.pictureInPicture.open)(E).catch(e=>{d.add({type:`error`,title:`Unable to update popped-out preview`,description:e instanceof Error?e.message:`An error occurred.`})})},[k?.pictureInPicture,E]),we=(0,Q.useCallback)(t=>{if(!z||!E||!T)return;let n=z;if(D){ve(D).then(e=>{if(!e)return;let t=!1,r,i=()=>{if(!navigator.clipboard?.writeText){d.update(r,b({type:`error`,title:`Unable to copy recording path`,description:`Clipboard API unavailable.`,actionProps:a}));return}navigator.clipboard.writeText(e.path).then(()=>{t=!0,o(),window.setTimeout(()=>{t=!1,o()},2e3)},e=>{d.update(r,b({type:`error`,title:`Unable to copy recording path`,description:e instanceof Error?e.message:`An error occurred.`,actionProps:a}))})},a={children:jt(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},o=()=>{d.update(r,b({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:t?`Copied!`:`Copy path`,disabled:t,onClick:i},secondaryActionVariant:`outline`}}))};r=d.add(b({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:`Copy path`,onClick:i},secondaryActionVariant:`outline`}}))},e=>{d.add({type:`error`,title:`Unable to stop recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}if(t){Te(E,e,T).catch(e=>{d.add({type:`error`,title:`Unable to start recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}n.captureScreenshot(E).then(e=>{let t={children:jt(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},r=!1,i=!1,a,o=(e=`success`,n=`Screenshot saved`,o)=>{d.update(a,b({type:e,title:n,description:o,actionProps:{children:i?`Copied!`:`Copy image`,disabled:i,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:r?`Copied!`:`Copy path`,disabled:r,onClick:s}}],secondaryActionProps:{...t},secondaryActionVariant:`outline`}}))},s=()=>{if(!navigator.clipboard?.writeText){o(`error`,`Unable to copy screenshot path`,`Clipboard API unavailable.`);return}navigator.clipboard.writeText(e.path).then(()=>{r=!0,o(),window.setTimeout(()=>{r=!1,o()},2e3)},e=>{o(`error`,`Unable to copy screenshot path`,e instanceof Error?e.message:`An error occurred.`)})},c=()=>{n.copyArtifactToClipboard(e.path).then(()=>{i=!0,o(),window.setTimeout(()=>{i=!1,o()},2e3)},e=>{o(`error`,`Unable to copy screenshot`,e instanceof Error?e.message:`An error occurred.`)})};a=d.add(b({type:`success`,title:`Screenshot saved`,actionProps:{children:`Copy image`,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:`Copy path`,onClick:s}}],secondaryActionProps:{...t},secondaryActionVariant:`outline`}}))},e=>{d.add({type:`error`,title:`Unable to capture screenshot`,description:e instanceof Error?e.message:`An error occurred.`})})},[D,E,T,e]),Ee=(0,Q.useCallback)(()=>{if(!z||!E)return;if(f.current){z.cancelPickElement(E).catch(()=>void 0);return}let t=typeof document<`u`?document.activeElement:null;f.current=!0,c(!0),(async()=>{try{let t=await z.pickElement(E);if(!t)return;_(e,t);let n=await Oe(t);n&&t.screenshot&&v(e,{type:`image`,id:t.id,name:n.name,mimeType:n.type,sizeBytes:n.size,previewUrl:t.screenshot.dataUrl,file:n})}catch{}finally{if(f.current=!1,p.current&&c(!1),t&&t.isConnected&&typeof t.focus==`function`)try{t.focus({preventScroll:!0})}catch{}}})()},[v,_,E,e]);return(0,Q.useEffect)(()=>{let e=qe(M,w);e&&G(e).catch(()=>void 0)},[G,w,M]),(0,Q.useEffect)(()=>()=>{f.current&&(f.current=!1,z&&E&&z.cancelPickElement(E).catch(()=>void 0),p.current&&c(!1))},[E]),(0,Q.useEffect)(()=>{if(r)return je(e=>{switch(e){case`refresh`:pe();return;case`focus-url`:a(e=>(e??0)+1);return;case`zoom-in`:me();return;case`zoom-out`:J();return;case`reset-zoom`:he();return;case`toggle-panel`:return}})},[pe,he,me,J,r]),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,"data-thread-key":te(e),children:[(0,$.jsx)(tt,{url:M,displayUrl:V,loading:N,loadProgress:se,canGoBack:re,canGoForward:ie,refreshDisabled:ae,focusUrlNonce:i,onBack:ye,onForward:be,onRefresh:pe,onSubmit:e=>void K(e),onOpenInBrowser:T?xe:void 0,onCapture:z&&T?we:void 0,captureDisabled:!k||F,recording:D!==null,onPictureInPicture:z&&T?Se:void 0,pictureInPicture:g?.tabId===T,pictureInPictureDisabled:!k?.hasWebContents||F,onPickElement:z&&T?Ee:void 0,pickActive:s,pickDisabled:!T||F,pickDisabledReason:F?`Page didn't load — pick unavailable until the page renders`:void 0,trailingActions:z?(0,$.jsx)(_t,{tabId:E,hasWebContents:k?.hasWebContents??!1,zoomFactor:k?.zoomFactor??1,colorScheme:k?.colorScheme??`system`,deviceToolbarVisible:le._tag!==`fill`,onToggleDeviceToolbar:_e,nativePictureInPicture:k?.pictureInPicture??!1,onNativePictureInPicture:Ce}):null}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[E&&O&&!L?(0,$.jsx)(Ye,{tabId:E,visible:r&&!F,className:`absolute inset-0 h-full w-full`},E):null,L?(0,$.jsx)(pt,{environmentId:e.environmentId,configuredUrls:n,recentlySeenUrls:m.recentlySeenUrls,onOpenUrl:e=>void fe(e)}):null,O&&k?(0,$.jsx)(Wt,{zoomFactor:k.zoomFactor}):null,E&&k&&!L&&!F?(0,$.jsx)(qt,{tabId:E,zoomFactor:k.zoomFactor,controller:oe}):null,oe===`none`?null:(0,$.jsx)(`div`,{className:`pointer-events-none absolute left-3 top-3 z-40 rounded-full border border-border/70 bg-background/90 px-2.5 py-1 text-[11px] font-medium shadow-sm backdrop-blur`,children:oe===`agent`?`Agent controlling browser`:`Human control`}),A._tag===`LoadFailed`?(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(Dt,{url:A.url,code:A.code,description:A.description,onReload:pe})}):null]})]})}function Zt(e){let t=(0,Z.c)(13),{mode:n,threadRef:r,tabId:i,configuredUrls:a,visible:o}=e;if(!he()){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:(0,$.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:`Preview is only available in the P4 Code desktop app.`})}),t[0]=e):e=t[0];let r;return t[1]===n?r=t[2]:(r=(0,$.jsx)(J,{mode:n,children:e}),t[1]=n,t[2]=r),r}let s;t[3]===i?s=t[4]:(s=i===void 0?{}:{tabId:i},t[3]=i,t[4]=s);let c;t[5]!==a||t[6]!==s||t[7]!==r||t[8]!==o?(c=(0,$.jsx)(Xt,{threadRef:r,...s,configuredUrls:a,visible:o}),t[5]=a,t[6]=s,t[7]=r,t[8]=o,t[9]=c):c=t[9];let l;return t[10]!==n||t[11]!==c?(l=(0,$.jsx)(J,{mode:n,children:c}),t[10]=n,t[11]=c,t[12]=l):l=t[12],l}export{Zt as PreviewPanel};
2
- //# sourceMappingURL=PreviewPanel-D42c3ZHu.js.map
@@ -1,251 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{n as i,r as a,t as o}from"./collapsible-CjR2aTi6.js";import{Cl as s,Ei as c,G as l,H as u,Hi as d,Hs as f,Ks as p,Ln as m,Ni as h,Pi as g,Qs as _,Ui as v,Vs as y,W as b,Xs as x,Ys as S,Zs as C,ki as w,l as T,n as E,q as D,qc as O,rl as k,t as A}from"./textarea-DXj6RvAd.js";import{G as j,I as M,K as ee}from"./entities-CB30asjw.js";import{a as N,c as P,n as te,o as ne,r as re,s as ie,t as ae}from"./toggle-group-Bla5cmgT.js";import{Ci as oe,G as se,H as ce,Hi as le,Ir as ue,J as de,K as fe,Mi as pe,Q as F,U as me,Ui as he,W as ge,Wi as _e,X as ve,Y as ye,at as I,dt as be,ft as L,h as xe,ki as Se,lt as Ce,ot as we,pi as Te,pt as Ee,q as De,st as Oe,ut as ke,wr as Ae}from"./index-CLwUrcHN.js";var je=_(`message-square-off`,[[`path`,{d:`M19 19H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.7.7 0 0 1 2 21.286V5a2 2 0 0 1 1.184-1.826`,key:`1wyg69`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.656 3H20a2 2 0 0 1 2 2v11.344`,key:`mhl4k6`}]]),R=e(n(),1),Me=new Set([`pnpm-lock.yaml`,`yarn.lock`,`package-lock.json`,`bun.lockb`,`Cargo.lock`,`go.sum`,`composer.lock`,`Gemfile.lock`]),z=new Set([`__snapshots__`,`__generated__`,`dist`,`build`,`vendor`]),B=new Set([`__tests__`,`tests`,`test`]),Ne=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`];function Pe(e){let t=e.split(`/`),n=t.at(-1)??``;return Me.has(n)||n.endsWith(`.snap`)||n.endsWith(`.min.js`)||n.endsWith(`.min.css`)||/\.generated\./.test(n)||t.slice(0,-1).some(e=>z.has(e))?`generated`:/\.(?:test|spec)\./.test(n)||t.slice(0,-1).some(e=>B.has(e))?`test`:`source`}function Fe(e){let t=e.lastIndexOf(`.`);return t>e.lastIndexOf(`/`)?e.slice(0,t):e}function Ie(e){return Fe(e.split(`/`).at(-1)??``)}function Le(e,t){let n=e.split(`/`).slice(0,-1);for(let e of t.split(`/`))e===`.`||e===``||(e===`..`?n.pop():n.push(e));return n.join(`/`)}var Re=/(?:\bfrom|\bimport|\brequire\s*\()\s*\(?\s*["']([^"']+)["']/g;function ze(e,t,n,r){let i=new Set;for(let a of t){Re.lastIndex=0;let t=Re.exec(a);for(;t!==null;){let o=t[1]??``,s=o.startsWith(`.`)?Le(e,o):o,c=Ne.find(e=>s.endsWith(e)),l=c===void 0?s:s.slice(0,-c.length),u=n.get(l)??n.get(`${l}/index`)??r.get(Ie(l));u!==void 0&&u!==e&&i.add(u),t=Re.exec(a)}}return i}function Be(e,t){let n=new Set(e),r=[],i=[...e].sort((e,t)=>e.localeCompare(t));for(;n.size>0;){let e=i.filter(e=>n.has(e)),a=e.find(e=>[...t.get(e)??[]].every(e=>!n.has(e)))??e[0];n.delete(a),r.push(a)}return r}function V(e){return(e.split(`/`).at(-1)??``).replace(/\.(?:test|spec)\..*$/,``).replace(/\.[^.]+$/,``)}function Ve(e){let t=new Map;for(let n of e)t.set(L(n),n);let n=new Map;for(let e of t.keys())n.set(e,Pe(e));let r=[...t.keys()].filter(e=>n.get(e)===`source`),i=new Map,a=new Set,o=new Map;for(let e of r){i.set(Fe(e),e);let t=Ie(e);o.has(t)&&a.add(t),o.set(t,e)}for(let e of a)o.delete(e);let s=new Map;for(let e of r){let n=t.get(e);s.set(e,ze(e,[...n.additionLines,...n.deletionLines],i,o))}let c=Be(r,s),l=new Map;c.forEach((e,t)=>{let n=Ie(e);l.has(n)||l.set(n,t)});let u=[...t.keys()].filter(e=>n.get(e)===`test`).sort((e,t)=>(l.get(V(e))??2**53-1)-(l.get(V(t))??2**53-1)||e.localeCompare(t)),d=[...t.keys()].filter(e=>n.get(e)===`generated`).sort((e,t)=>e.localeCompare(t));return[...c,...u,...d].map(e=>t.get(e))}function He(e,t){return async n=>{let r=L(n),i=n.prevName?L({...n,name:n.prevName}):r,a=await e({changeType:n.type,oldPath:i,newPath:r}),o={name:r,contents:a.newContents,cacheKey:`${t}:new:${r}`};return n.type===`rename-pure`?{oldFile:null,newFile:o}:{oldFile:{name:i,contents:a.oldContents,cacheKey:`${t}:old:${i}`},newFile:o}}}function Ue(e,t){return He(async({changeType:n,oldPath:r,newPath:i})=>{let a=await e({environmentId:t.environmentId,input:{...t.reference,...t.commit===null?{}:{commit:t.commit},changeType:n,oldPath:r,newPath:i}});if(a._tag!==`Success`)throw s(a);return a.value},t.cacheKey)}var H=r();function U(e,t,n){return!n&&(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&t.trim().length>0}var W=t();function We(e){let t=(0,H.c)(43),{kind:n,rangeLabel:r,text:i,onTextChange:a,onCancel:o,onComment:s,onDelete:l,placeholder:u,submitLabel:d,pending:f,secondaryAction:p}=e,m=u===void 0?`Add a comment…`:u,h=d===void 0?`Comment`:d,g=f===void 0?!1:f,[_,v]=(0,R.useState)(``),y=n===`draft`&&!a?_:i,b;t[0]===y?b=t[1]:(b=y.trim(),t[0]=y,t[1]=b);let x=b;if(n===`comment`){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,W.jsx)(ee,{className:`mt-0.5 size-3.5 shrink-0 text-primary/70`,"aria-hidden":`true`}),t[2]=e):e=t[2];let n;t[3]===y?n=t[4]:(n=(0,W.jsx)(`p`,{className:`min-w-0 flex-1 whitespace-pre-wrap text-[13px] leading-5`,children:y}),t[3]=y,t[4]=n);let r;t[5]===l?r=t[6]:(r=l?(0,W.jsx)(c,{className:`-my-1 -mr-1 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/comment:opacity-100 focus-visible:opacity-100 max-sm:opacity-100`,variant:`ghost`,size:`icon-xs`,"aria-label":`Delete comment`,onClick:l,children:(0,W.jsx)(j,{className:`size-3`})}):null,t[5]=l,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,W.jsxs)(`div`,{"data-diff-comment-annotation":!0,className:`group/comment flex min-w-0 items-start gap-2.5 border-s-2 border-primary/55 bg-primary/[0.045] px-3 py-2.5 font-sans text-foreground`,contentEditable:!1,onPointerDown:q,children:[e,n,r]}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}let S=`Comment on lines ${r}`,C;t[10]===a?C=t[11]:(C=e=>(a??v)(e.target.value),t[10]=a,t[11]=C);let w;t[12]!==o||t[13]!==s||t[14]!==g||t[15]!==x?(w=e=>{e.key===`Escape`&&(e.preventDefault(),o()),U(e,x,g)&&(e.preventDefault(),s(x))},t[12]=o,t[13]=s,t[14]=g,t[15]=x,t[16]=w):w=t[16];let T;t[17]!==y||t[18]!==m||t[19]!==S||t[20]!==C||t[21]!==w?(T=(0,W.jsx)(A,{autoFocus:!0,unstyled:!0,className:`relative inline-flex w-full rounded-md border border-border/50 bg-background/20 font-sans text-foreground transition-colors focus-within:border-border/70 [&_[data-slot=textarea]]:min-h-12 [&_[data-slot=textarea]]:cursor-text [&_[data-slot=textarea]]:px-2.5 [&_[data-slot=textarea]]:py-1.5 [&_[data-slot=textarea]]:font-sans [&_[data-slot=textarea]]:text-xs [&_[data-slot=textarea]]:leading-5 max-sm:[&_[data-slot=textarea]]:min-h-12`,size:`sm`,value:y,placeholder:m,"aria-label":S,onChange:C,onFocus:G,onKeyDown:w}),t[17]=y,t[18]=m,t[19]=S,t[20]=C,t[21]=w,t[22]=T):T=t[22];let E;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,W.jsx)(`span`,{className:`mr-auto text-[10px] text-muted-foreground/70`,children:`⌘/Ctrl Enter to send`}),t[23]=E):E=t[23];let D;t[24]===o?D=t[25]:(D=(0,W.jsx)(c,{className:`text-muted-foreground hover:text-foreground`,variant:`ghost`,size:`xs`,onClick:o,children:`Cancel`}),t[24]=o,t[25]=D);let O;t[26]!==p||t[27]!==x?(O=p?(0,W.jsxs)(c,{size:`xs`,variant:`outline`,disabled:!p.allowEmpty&&!x,onClick:()=>p.onAction(x),children:[p.icon,p.label]}):null,t[26]=p,t[27]=x,t[28]=O):O=t[28];let k=g||!x,M;t[29]!==s||t[30]!==x?(M=()=>s(x),t[29]=s,t[30]=x,t[31]=M):M=t[31];let N;t[32]!==h||t[33]!==k||t[34]!==M?(N=(0,W.jsx)(c,{size:`xs`,disabled:k,onClick:M,children:h}),t[32]=h,t[33]=k,t[34]=M,t[35]=N):N=t[35];let P;t[36]!==D||t[37]!==O||t[38]!==N?(P=(0,W.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1`,children:[E,D,O,N]}),t[36]=D,t[37]=O,t[38]=N,t[39]=P):P=t[39];let te;return t[40]!==P||t[41]!==T?(te=(0,W.jsxs)(`div`,{"data-diff-comment-annotation":!0,className:`px-3 py-2 font-sans text-foreground`,contentEditable:!1,onPointerDown:K,children:[T,P]}),t[40]=P,t[41]=T,t[42]=te):te=t[42],te}function G(e){let t=e.currentTarget.value.length;e.currentTarget.setSelectionRange(t,t)}function K(e){return e.stopPropagation()}function q(e){return e.stopPropagation()}var J=`${I}
2
- :is(
3
- [data-line],
4
- [data-line-annotation],
5
- [data-merge-conflict],
6
- [data-merge-conflict-actions],
7
- [data-no-newline]
8
- )[data-selected-line] {
9
- --diffs-line-bg: light-dark(
10
- color-mix(
11
- in lab,
12
- var(--code-background) 88%,
13
- color-mix(in srgb, var(--code-background) 50%, var(--diffs-modified-base))
14
- ),
15
- color-mix(
16
- in lab,
17
- var(--code-background) 80%,
18
- color-mix(in srgb, var(--code-background) 70%, var(--diffs-modified-base))
19
- )
20
- ) !important;
21
- }
22
-
23
- :is([data-gutter-buffer], [data-column-number])[data-selected-line] {
24
- --diffs-line-bg: light-dark(
25
- color-mix(
26
- in lab,
27
- var(--code-background) 91%,
28
- color-mix(in srgb, var(--code-background) 35%, var(--diffs-modified-base))
29
- ),
30
- color-mix(
31
- in lab,
32
- var(--code-background) 85%,
33
- color-mix(in srgb, var(--code-background) 60%, var(--diffs-modified-base))
34
- )
35
- ) !important;
36
- }
37
-
38
- [data-indicators="bars"]
39
- :is([data-column-number], [data-gutter-buffer="annotation"])[data-selected-line] {
40
- position: relative;
41
- }
42
-
43
- [data-indicators="bars"]
44
- :is([data-column-number], [data-gutter-buffer="annotation"])[data-selected-line]::before {
45
- position: absolute !important;
46
- inset-block: 0 !important;
47
- inset-inline-start: 0 !important;
48
- display: block !important;
49
- width: 4px !important;
50
- min-width: 4px !important;
51
- max-width: 4px !important;
52
- height: auto !important;
53
- padding: 0 !important;
54
- content: "" !important;
55
- background-color: var(--diffs-modified-base) !important;
56
- background-image: none !important;
57
- }
58
-
59
- [data-file-info] {
60
- background-color: var(--code-background) !important;
61
- border-block-color: transparent !important;
62
- color: var(--code-foreground) !important;
63
- }
64
-
65
- [data-diffs-header] {
66
- position: sticky !important;
67
- top: 0;
68
- z-index: 4;
69
- background-color: var(--code-background) !important;
70
- border-bottom-color: transparent !important;
71
- align-items: center !important;
72
- font-family: var(--font-sans) !important;
73
- font-size: 12px !important;
74
- line-height: 1 !important;
75
- min-height: 32px !important;
76
- padding-block: 6px !important;
77
- padding-inline: 8px 12px !important;
78
- }
79
-
80
- [data-diffs-header]:hover {
81
- /* A native scrollbar gutter cannot be painted by descendants. Use an inset edge cue instead
82
- of a full-width band that would look accidentally clipped at the gutter. */
83
- background-color: var(--code-background) !important;
84
- box-shadow: inset 3px 0 color-mix(in srgb, var(--code-foreground) 24%, transparent);
85
- }
86
-
87
- :is([data-separator="line-info"], [data-separator="line-info-basic"]) {
88
- height: 24px !important;
89
- margin-block: 0 !important;
90
- background-color: var(--code-background) !important;
91
- }
92
-
93
- :is([data-separator="line-info"], [data-separator="line-info-basic"])
94
- [data-separator-wrapper] {
95
- padding-inline: 8px 12px !important;
96
- background-color: transparent !important;
97
- }
98
-
99
- :is([data-separator="line-info"], [data-separator="line-info-basic"])
100
- [data-separator-content] {
101
- gap: 8px;
102
- padding-inline: 0 !important;
103
- background-color: transparent !important;
104
- color: color-mix(in srgb, var(--code-foreground) 52%, var(--code-background)) !important;
105
- font-family: var(--font-sans) !important;
106
- font-size: 11px !important;
107
- text-decoration: none !important;
108
- }
109
-
110
- :is([data-separator="line-info"], [data-separator="line-info-basic"])
111
- [data-unmodified-lines] {
112
- display: flex !important;
113
- min-width: 0;
114
- flex: 1 1 auto;
115
- align-items: center;
116
- gap: 8px;
117
- }
118
-
119
- :is([data-separator="line-info"], [data-separator="line-info-basic"])[data-expand-index]
120
- [data-unmodified-lines] {
121
- cursor: pointer;
122
- }
123
-
124
- :is([data-separator="line-info"], [data-separator="line-info-basic"])
125
- [data-unmodified-lines]::before,
126
- :is([data-separator="line-info"], [data-separator="line-info-basic"])
127
- [data-unmodified-lines]::after {
128
- width: auto;
129
- height: 1px;
130
- flex: 1 1 auto;
131
- content: "";
132
- background-color: color-mix(in srgb, var(--code-background) 92%, var(--code-foreground));
133
- }
134
-
135
- :is([data-separator="line-info"], [data-separator="line-info-basic"])[data-expand-index]
136
- [data-separator-wrapper] {
137
- grid-template-columns: 0 minmax(0, 1fr) !important;
138
- }
139
-
140
- :is([data-separator="line-info"], [data-separator="line-info-basic"])[data-expand-index]
141
- [data-separator-content] {
142
- grid-column: 2 !important;
143
- }
144
-
145
- /* Visually hidden rather than display: none so the expand action stays keyboard-reachable. */
146
- :is([data-separator="line-info"], [data-separator="line-info-basic"])
147
- [data-expand-button] {
148
- position: absolute !important;
149
- width: 1px !important;
150
- height: 1px !important;
151
- margin: -1px !important;
152
- padding: 0 !important;
153
- overflow: hidden !important;
154
- clip-path: inset(50%) !important;
155
- border: 0 !important;
156
- white-space: nowrap !important;
157
- }
158
-
159
- :is([data-separator="line-info"], [data-separator="line-info-basic"]):has(
160
- [data-expand-button]
161
- )
162
- [data-separator-content] {
163
- cursor: pointer;
164
- }
165
-
166
- :is([data-separator="line-info"], [data-separator="line-info-basic"]):has(
167
- [data-expand-button]
168
- ):is(:hover, :focus-within)
169
- [data-separator-content] {
170
- color: color-mix(in srgb, var(--code-foreground) 76%, var(--code-background)) !important;
171
- }
172
-
173
- :is([data-separator="line-info"], [data-separator="line-info-basic"]):has(
174
- [data-expand-button]
175
- ):is(:hover, :focus-within)
176
- [data-unmodified-lines]::before,
177
- :is([data-separator="line-info"], [data-separator="line-info-basic"]):has(
178
- [data-expand-button]
179
- ):is(:hover, :focus-within)
180
- [data-unmodified-lines]::after {
181
- background-color: color-mix(in srgb, var(--code-background) 84%, var(--code-foreground));
182
- }
183
-
184
- [data-diffs-header] [data-header-content] {
185
- align-items: center !important;
186
- line-height: 1 !important;
187
- }
188
-
189
- [data-diffs-header] [data-metadata] {
190
- align-items: center !important;
191
- line-height: 1 !important;
192
- font-variant-numeric: tabular-nums;
193
- }
194
-
195
- [data-diffs-header] [data-additions-count],
196
- [data-diffs-header] [data-deletions-count] {
197
- font-family: var(--font-mono) !important;
198
- font-size: 11px !important;
199
- font-variant-numeric: tabular-nums;
200
- line-height: 1 !important;
201
- }
202
-
203
- [data-diffs-header] [data-change-icon],
204
- [data-diffs-header] [data-rename-icon] {
205
- display: block;
206
- flex-shrink: 0;
207
- }
208
-
209
- [data-title] {
210
- cursor: pointer;
211
- transition:
212
- color 120ms ease,
213
- text-decoration-color 120ms ease;
214
- text-decoration: underline;
215
- text-decoration-color: transparent;
216
- text-underline-offset: 2px;
217
- font-family: var(--font-sans) !important;
218
- }
219
-
220
- [data-title]:hover {
221
- color: color-mix(in srgb, var(--code-foreground) 84%, var(--primary)) !important;
222
- text-decoration-color: currentColor;
223
- }
224
-
225
- /* Expanding a file mounts its body all at once; easing it in matches the 200ms the app's
226
- collapsibles take. Appearance only — the viewer owns geometry, so height cannot animate.
227
- Departing content cuts, the same one-way rule the pull request chrome fold follows. */
228
- [data-diff],
229
- [data-file] {
230
- transition: opacity 200ms ease-out;
231
- }
232
-
233
- @starting-style {
234
- [data-diff],
235
- [data-file] {
236
- opacity: 0;
237
- }
238
- }
239
-
240
- @media (prefers-reduced-motion: reduce) {
241
- [data-diff],
242
- [data-file] {
243
- transition: none;
244
- }
245
- }
246
- `;function Ge(e){let t=(0,H.c)(18),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({options:r,viewerRef:o,className:n,unsafeCSSExtra:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===o?s=t[7]:(s=o?{ref:o}:{},t[6]=o,t[7]=s);let c=n?`diff-render-surface outline-none ${n}`:`diff-render-surface outline-none`,l=a?`${J}\n${a}`:J,u,d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u={diffHeaderHeight:32,hunkSeparatorHeight:24,spacing:0,paddingTop:0,paddingBottom:0},d={paddingTop:0,paddingBottom:0,gap:0},t[8]=u,t[9]=d):(u=t[8],d=t[9]);let f;t[10]!==r||t[11]!==l?(f={...r,unsafeCSS:l,itemMetrics:u,layout:d},t[10]=r,t[11]=l,t[12]=f):f=t[12];let p;return t[13]!==i||t[14]!==s||t[15]!==c||t[16]!==f?(p=(0,W.jsx)(N,{...i,...s,className:c,options:f}),t[13]=i,t[14]=s,t[15]=c,t[16]=f,t[17]=p):p=t[17],p}var Ke=`mx-3 my-2 rounded-xl border border-border/70 bg-background p-3 text-sm shadow-sm`;function qe(e){return t=>{t.key===`Escape`&&e.onCancel&&(t.preventDefault(),e.onCancel()),U(t,e.value,e.pending)&&(t.preventDefault(),e.onSubmit())}}function Je(e){let t=(0,H.c)(11),{comment:n,onRemove:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=v(Ke,`border-dashed`),t[0]=i):i=t[0];let a,o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,W.jsx)(Se,{className:`size-3.5`}),o=(0,W.jsx)(`span`,{children:`Pending — sent when you submit the review`}),t[1]=a,t[2]=o):(a=t[1],o=t[2]);let s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,W.jsx)(j,{className:`size-3.5`}),t[3]=s):s=t[3];let l;t[4]===r?l=t[5]:(l=(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[a,o,(0,W.jsx)(c,{size:`icon-xs`,variant:`ghost`,className:`ml-auto`,"aria-label":`Discard this comment`,onClick:r,children:s})]}),t[4]=r,t[5]=l);let u;t[6]===n.body?u=t[7]:(u=(0,W.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap leading-relaxed`,children:n.body}),t[6]=n.body,t[7]=u);let d;return t[8]!==l||t[9]!==u?(d=(0,W.jsxs)(`div`,{className:i,contentEditable:!1,onPointerDown:Ye,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10],d}function Ye(e){return e.stopPropagation()}function Xe({thread:e,workspaceRoot:t,canReply:n,canResolve:r,canReact:i,environmentId:a,reference:o,pending:s,fixPending:l,fixLabel:u=`Fix in a thread`,onFix:d,onReply:f,canEditComment:m,onEditComment:h,onToggleResolved:g,onReacted:_}){let[v,y]=(0,R.useState)(!e.isResolved),[b,x]=(0,R.useState)(!1),[S,C]=(0,R.useState)(``),[w,T]=(0,R.useState)(null),[E,D]=(0,R.useState)(!1),O=(0,R.useRef)(!1),k=async(e,t)=>{if(E)return;D(!0);let n=await h(e,t);D(!1),n&&T(null)},j=async()=>{let e=S.trim();if(!(e.length===0||s||O.current)){O.current=!0;try{await f(e)&&(C(``),x(!1))}finally{O.current=!1}}};return(0,W.jsxs)(`div`,{className:Ke,contentEditable:!1,onPointerDown:e=>e.stopPropagation(),children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[e.isResolved?(0,W.jsx)(p,{className:`size-3.5 text-emerald-600 dark:text-emerald-500`}):(0,W.jsx)(le,{className:`size-3.5`}),(0,W.jsxs)(`button`,{type:`button`,className:`hover:text-foreground`,"aria-expanded":v,onClick:()=>y(e=>!e),children:[e.isResolved?`Resolved`:`Open`,` · `,e.comments.length,` `,e.comments.length===1?`comment`:`comments`]}),e.isOutdated?(0,W.jsx)(`span`,{children:`outdated`}):null,d?(0,W.jsxs)(c,{size:`xs`,variant:`ghost`,className:`ml-auto`,disabled:s||l,onClick:d,children:[(0,W.jsx)(pe,{className:`size-3`}),l?`Preparing...`:u]}):null,r?(0,W.jsx)(c,{size:`xs`,variant:`ghost`,className:d?void 0:`ml-auto`,disabled:s,onClick:g,children:e.isResolved?`Unresolve`:`Resolve`}):null]}),v?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`mt-2 space-y-3`,children:e.comments.map(e=>(0,W.jsxs)(`article`,{className:`group min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,W.jsx)(De,{actor:e.author,className:`text-foreground`}),(0,W.jsx)(`span`,{children:ue(e.createdAt)})]}),w===e.id?(0,W.jsx)(me,{className:`mt-1`,value:e.body,cwd:t,label:`Edit comment`,saving:E,onSave:t=>void k(e.id,t),onCancel:()=>T(null)}):(0,W.jsxs)(`div`,{className:`mt-1 flex items-start gap-1`,children:[(0,W.jsx)(ge,{className:`min-w-0 flex-1 text-sm`,text:e.body,cwd:t}),m(e)?(0,W.jsx)(c,{size:`icon-xs`,variant:`ghost`,className:`shrink-0 text-muted-foreground opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100 focus-visible:opacity-100`,"aria-label":`Edit comment`,onClick:()=>T(e.id),children:(0,W.jsx)(oe,{className:`size-3`})}):null]}),(0,W.jsx)(ce,{className:`mt-1.5`,reactions:e.reactions??[],canReact:i,subjectId:e.id,environmentId:a,reference:o,onRefresh:_})]},e.id))}),n?b?(0,W.jsxs)(`div`,{className:`mt-2`,children:[(0,W.jsx)(A,{autoFocus:!0,size:`sm`,value:S,placeholder:`Reply`,"aria-label":`Reply to this conversation`,onChange:e=>C(e.target.value),onKeyDown:qe({value:S,pending:s,onSubmit:()=>void j(),onCancel:()=>x(!1)})}),(0,W.jsxs)(`div`,{className:`mt-2 flex justify-end gap-2`,children:[(0,W.jsx)(c,{size:`xs`,variant:`ghost`,onClick:()=>x(!1),children:`Cancel`}),(0,W.jsx)(c,{size:`xs`,disabled:s||S.trim().length===0,onClick:()=>void j(),children:`Reply`})]})]}):(0,W.jsx)(c,{size:`xs`,variant:`ghost`,className:`mt-2 px-1`,onClick:()=>x(!0),children:`Reply`}):null]}):null]})}var Ze=0;function Qe(){return Ze+=1,`pending-review-comment-${Ze}`}function $e(e){return`${e.projectId}/${e.repository}#${e.number}`}var et=[],Y=O()(e=>({drafts:{},summaries:{},addComment:(t,n)=>e(e=>({drafts:{...e.drafts,[t]:[...e.drafts[t]??et,n]}})),removeComment:(t,n)=>e(e=>{let r=(e.drafts[t]??et).filter(e=>e.id!==n);if(r.length>0)return{drafts:{...e.drafts,[t]:r}};let{[t]:i,...a}=e.drafts;return{drafts:a}}),removeComments:(t,n)=>e(e=>{let r=new Set(n),i=(e.drafts[t]??et).filter(e=>!r.has(e.id));if(i.length>0)return{drafts:{...e.drafts,[t]:i}};let{[t]:a,...o}=e.drafts;return{drafts:o}}),clear:t=>e(e=>{let{[t]:n,...r}=e.drafts;return{drafts:r}}),setSummary:(t,n)=>e(e=>({summaries:{...e.summaries,[t]:n}})),clearSummary:(t,n)=>e(e=>{if(e.summaries[t]!==n)return e;let{[t]:r,...i}=e.summaries;return{summaries:i}})}));function tt(e){let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>t.drafts[$e(e)]??et,t[0]=e,t[1]=n),Y(n)}var nt=[{value:`comment`,label:`Comment`,sent:`Review submitted`,icon:(0,W.jsx)(Se,{className:`size-3`})},{value:`approve`,label:`Approve`,sent:`Pull request approved`,icon:(0,W.jsx)(C,{className:`size-3`})},{value:`request-changes`,label:`Request changes`,sent:`Changes requested`,icon:(0,W.jsx)(he,{className:`size-3`})}];function rt(e){let t=(0,H.c)(13),{environmentId:n,reference:r,verdicts:i,onSubmitted:a}=e,[o,s]=(0,R.useState)(!1),l=tt(r),d=$e(r),f=Y(e=>e.summaries[d]??``),p=Y(ct),m=Y(st),h=Y(ot),g=Y(at),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_={reportFailure:!1},t[0]=_):_=t[0];let v=E(F.submitReview,_),y;t[1]===i?y=t[2]:(y=e=>i.includes(e.value),t[1]=i,t[2]=y);let b=nt.filter(y);if(b.length===0)return null;let x=async e=>{if(o)return;let t=f,i=l;s(!0);let c=await v({environmentId:n,input:{...r,verdict:e.value,body:t,comments:i}});if(s(!1),c._tag===`Failure`){u.add({type:`error`,title:`The review could not be submitted`});return}m(d,i.map(it)),g(d,t),u.add({type:`success`,title:e.sent}),a()},S;t[3]!==f||t[4]!==l.length?(S=e=>e===`approve`||f.trim().length>0||l.length>0,t[3]=f,t[4]=l.length,t[5]=S):S=t[5];let C=S,w=l.length===0?`No line comments yet`:`${l.length} ${l.length===1?`comment`:`comments`} pending`,T;t[6]===w?T=t[7]:(T=(0,W.jsx)(`span`,{children:w}),t[6]=w,t[7]=T);let D=l.length>0?(0,W.jsx)(c,{size:`xs`,variant:`ghost`,disabled:o,onClick:()=>p(d),children:`Discard`}):null,O;t[8]!==T||t[9]!==D?(O=(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[T,D]}),t[8]=T,t[9]=D,t[10]=O):O=t[10];let k=b.map(e=>(0,W.jsx)(c,{size:`xs`,variant:e.value===`comment`?`outline`:`default`,disabled:o||!C(e.value),onClick:()=>void x(e),children:(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[e.icon,e.label]})},e.value)),j;return t[11]===k?j=t[12]:(j=(0,W.jsx)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-2`,children:k}),t[11]=k,t[12]=j),(0,W.jsxs)(`div`,{className:`px-4 py-3`,children:[O,(0,W.jsx)(A,{size:`sm`,className:`mt-2`,value:f,placeholder:`Summarize your review (optional)`,"aria-label":`Review summary`,onChange:e=>h(d,e.target.value)}),j]})}function it(e){return e.id}function at(e){return e.clearSummary}function ot(e){return e.setSummary}function st(e){return e.removeComments}function ct(e){return e.clear}function lt(e,t,n){return e.hunks.some(e=>t===`left`?n>=e.deletionStart&&n<e.deletionStart+e.deletionCount:n>=e.additionStart&&n<e.additionStart+e.additionCount)}function ut(e,t,n){let r=t!==`expanded`;return n.has(e)?!r:r}var dt=10,ft=`
247
- [data-diffs-header] [data-additions-count],
248
- [data-diffs-header] [data-deletions-count] {
249
- display: none !important;
250
- }`,pt=[];function mt(e){return e===`left`?`deletions`:`additions`}function ht(e){return e===`deletions`?`left`:`right`}function X({environmentId:e,reference:t,detail:n,selectedCommitOid:r,onSelectedCommitChange:s,pendingFinding:p,fixFindingLabel:_=`Fix in a thread`,onFixFinding:C,onAddToAgentSelection:O,onRefresh:A,refreshToken:j=0}){let{resolvedTheme:ee}=Ae(),N=M(),[oe,ce]=(0,R.useState)(()=>new Set),[le,ue]=(0,R.useState)(dt),[pe,me]=(0,R.useState)(null),[he,ge]=(0,R.useState)(`stacked`),[I,De]=(0,R.useState)(N.wordWrap),[Me,z]=(0,R.useState)(null),[B,Ne]=(0,R.useState)(null),[Pe,Fe]=(0,R.useState)(!1),[Ie,Le]=(0,R.useState)(!1),[Re,ze]=(0,R.useState)(!1),[Be,V]=(0,R.useState)({key:``,cursor:null,slices:pt}),He=(0,R.useRef)(new Map),H=$e(t),U=r,G=U===null?H:`${H}@${U}`;(0,R.useEffect)(()=>{Ne(null),z(null),ce(new Set),me(null),ue(dt),Le(!1),V({key:G,cursor:null,slices:pt}),He.current.clear()},[G]);let K=Be.key===G?Be.slices:pt,q=Be.key===G?Be.cursor:null,J=T(F.diff({environmentId:e,input:{...t,...q===null?{}:{cursor:q},...U===null?{}:{commit:U}}}));(0,R.useEffect)(()=>{let e=J.data;e!==null&&V(t=>{let n=t.key===G?t.slices:pt,r={cursor:q,patch:e.patch,truncated:e.truncated,nextCursor:e.nextCursor,omittedFileStats:e.omittedFileStats??[]},i=n.findIndex(e=>e.cursor===q);if(i===-1)return{key:G,cursor:q,slices:[...n,r]};let a=n[i];return a!==void 0&&a.patch===r.patch&&a.truncated===r.truncated&&a.nextCursor===r.nextCursor&&a.omittedFileStats.length===r.omittedFileStats.length&&a.omittedFileStats.every((e,t)=>{let n=r.omittedFileStats[t];return n!==void 0&&n.path===e.path&&n.additions===e.additions&&n.deletions===e.deletions})?t:{key:G,cursor:q,slices:[...n.slice(0,i),r]}})},[q,J.data,G]);let Ke=k(F.diff({environmentId:e,input:{...t,...U===null?{}:{commit:U}}})),qe=(0,R.useRef)(j);(0,R.useEffect)(()=>{qe.current!==j&&(qe.current=j,V({key:G,cursor:null,slices:pt}),Ke())},[j,G,Ke]);let Ye=H,Ze=tt(t),et=Y(e=>e.addComment),nt=Y(e=>e.removeComment),it=E(F.replyToThread,{reportFailure:!1}),at=E(F.setThreadResolution,{reportFailure:!1}),ot=E(F.updateComment,{reportFailure:!1}),st=E(F.diffFileContents),ct=(0,R.useMemo)(()=>Ue(st,{environmentId:e,reference:t,commit:U,cacheKey:`pull-request:${H}:${n.updatedAt}:${U??`all`}`}),[U,n.updatedAt,e,st,t,H]),X=(0,R.useMemo)(()=>{let e=n.capabilities.review,t=n.viewerPermissions;return{inlineComment:e.inlineComment&&t.comment,reply:e.reply&&t.comment,resolve:e.resolve&&t.resolve,verdicts:e.verdicts.filter(e=>t.verdicts.includes(e))}},[n.capabilities.review,n.viewerPermissions]),gt=X.inlineComment&&U===null,_t=(0,R.useMemo)(()=>K.map(e=>{let t=`pull-request:${G}:${ee}:${e.cursor??`first`}:${Oe(e.patch)}`,n=He.current.get(t);if(n)return n;let r=ke(e.patch,t,{compactPartialHunkOffsets:!0});return r&&He.current.set(t,r),r}),[K,ee,G]),Z=(0,R.useMemo)(()=>_t.flatMap(e=>e?.kind===`files`?Ve(e.files):[]),[_t]),Q=K.at(-1)?.nextCursor??null,vt=K.some(e=>e.truncated)||_t.some(e=>e?.kind===`raw`),yt=(0,R.useMemo)(()=>{let e=new Set;if(U!==null)return e;for(let t of Z){let r=L(t);for(let i of n.reviewThreads)i.path===r&&i.line!==null&&lt(t,i.side,i.line)&&e.add(i.id)}return e},[U,n.reviewThreads,Z]),$=(0,R.useMemo)(()=>Z.map(e=>{let t=we(e),r=L(e),i=new Map,a=(e,t)=>{let n=`${e}:${t}`,r=i.get(n);if(r)return r;let a={side:e,line:t,threads:[],pending:[],draft:!1};return i.set(n,a),a};for(let e of n.reviewThreads)e.path!==r||e.line===null||yt.has(e.id)&&a(e.side,e.line).threads.push(e);if(U===null)for(let e of Ze)e.path===r&&a(e.side,e.line).pending.push(e);B?.fileKey===t&&(a(B.side,B.line).draft=!0);let o=ut(t,pe,oe),s=[...i.values()].map(e=>({side:mt(e.side),lineNumber:e.line,metadata:{threads:e.threads,pending:e.pending,draft:e.draft}}));return{id:t,type:`diff`,fileDiff:e,annotations:s,collapsed:o,version:Oe(`${o?`1`:`0`}:${s.map(({side:e,lineNumber:t,metadata:n})=>`${e}:${t}:${n.draft?`d`:``}:${n.pending.map(e=>`${e.id}:${e.body}`).join(`,`)}:${n.threads.map(e=>`${e.id}:${e.isResolved?`r`:``}:${e.isOutdated?`o`:``}:${e.comments.map(e=>`${e.id}:${e.author?.login??``}:${e.createdAt}:${e.body}:${(e.reactions??[]).map(e=>`${e.content}:${e.count}:${e.viewerHasReacted?`v`:``}`).join(`,`)}`).join(`;`)}`).join(`,`)}`).join(`|`)}`)}}),[U,n.reviewThreads,B,Z,pe,Ze,yt,oe]),bt=(0,R.useMemo)(()=>Ce(Z),[Z]),xt=(0,R.useMemo)(()=>new Map(K.flatMap(e=>e.omittedFileStats.map(e=>[e.path,e]))),[K]),St=(0,R.useMemo)(()=>$.map(e=>e.id),[$]),Ct=(0,R.useMemo)(()=>new Set($.filter(e=>e.collapsed===!0).map(e=>e.id)),[$]),wt=re(St,Ct),[Tt,Et]=(0,R.useState)(null);(0,R.useEffect)(()=>{if(Tt===null||Q===null||Q===q||J.isPending||J.error!==null)return;let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&V(e=>({...e,cursor:Q}))},{rootMargin:`240px`});return e.observe(Tt),()=>e.disconnect()},[q,J.error,J.isPending,Q,Tt]);let Dt=(0,R.useCallback)(e=>ce(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[]),Ot=()=>{me(re(St,Ct)?`expanded`:`folded`),ce(new Set)},kt=(0,R.useMemo)(()=>n.commits.toSorted((e,t)=>Date.parse(t.committedDate)-Date.parse(e.committedDate)),[n.commits]),At=(0,R.useCallback)((e,t)=>{if(!e||!gt)return;let n=t.item;if(n.type!==`diff`)return;let r=Z.find(e=>we(e)===n.id);if(!r)return;let i=L(r),a=Ee(r);Ne({fileKey:n.id,path:i,oldPath:a===i?null:a,line:e.end,side:ht(e.endSide??e.side),range:e})},[gt,Z]),jt=(0,R.useCallback)((e,t,r)=>{let i=Z.find(t=>we(t)===e.fileKey),a=i===void 0?null:m({id:`pull-request-selection:${e.fileKey}:${e.range.start}:${e.range.end}`,sectionId:`pull-request:${n.number}`,sectionTitle:`PR #${n.number} review`,filePath:e.path,fileDiff:i,range:e.range,text:t});Ne(null),z(null),a!==null&&r(a)},[n.number,Z]),Mt=(0,R.useCallback)(()=>Q===null?null:(0,W.jsx)(`div`,{ref:Et,className:`flex items-center justify-center gap-2 py-2 text-xs text-muted-foreground`,children:J.error===null?J.isPending?`Loading more files...`:null:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{children:`The rest of this diff could not be loaded.`}),(0,W.jsx)(c,{size:`xs`,variant:`outline`,onClick:()=>J.refresh(),children:`Retry`})]})}),[Q,J.error,J.isPending,J.refresh]),Nt=(0,R.useCallback)(e=>{let t=e.collapsed===!0;return(0,W.jsx)(`button`,{type:`button`,"aria-expanded":!t,"aria-label":t?`Expand diff`:`Collapse diff`,className:v(`mr-1 inline-flex size-5 items-center justify-center rounded text-muted-foreground transition-colors hover:text-foreground`),onClick:t=>{t.stopPropagation(),Dt(e.id)},children:t?(0,W.jsx)(S,{className:`size-4`}):(0,W.jsx)(x,{className:`size-4`})})},[Dt]),Pt=(0,R.useCallback)(e=>{if(e.type!==`diff`)return null;let t=0,n=0;for(let r of e.fileDiff.hunks)t+=r.additionLines,n+=r.deletionLines;if(t===0&&n===0){let r=xt.get(L(e.fileDiff));r&&({additions:t,deletions:n}=r)}return(0,W.jsx)(de,{additions:t,deletions:n,className:`font-mono text-[11px]`})},[xt]),Ft=(0,R.useMemo)(()=>({diffStyle:he===`split`?`split`:`unified`,lineDiffType:`none`,overflow:I?`wrap`:`scroll`,theme:be(ee),themeType:ee,stickyHeaders:!0,loadDiffFiles:ct,enableGutterUtility:gt&&B===null,enableLineSelection:gt&&B===null,onGutterUtilityClick:At,onLineSelectionEnd:At}),[he,I,ee,ct,gt,B,At]),It=(0,R.useCallback)(async(e,t)=>{if(Pe)return!1;Fe(!0);let n=await t();return Fe(!1),n._tag===`Failure`?(u.add({type:`error`,title:e}),!1):(A(),!0)},[A,Pe]),Lt=(0,R.useCallback)(r=>(0,W.jsx)(Xe,{thread:r,workspaceRoot:n.workspaceRoot,canReply:X.reply,canResolve:X.resolve,canReact:n.capabilities.reactions===!0,environmentId:e,reference:t,pending:Pe,fixPending:p===fe({kind:`thread`,thread:r}),fixLabel:_,...C?{onFix:()=>C({kind:`thread`,thread:r})}:{},onReply:n=>It(`Reply could not be posted`,()=>it({environmentId:e,input:{...t,threadId:r.id,body:n}})),canEditComment:e=>se(n,{author:e.author,kind:`review-comment`}),onEditComment:(n,r)=>It(`The comment could not be saved`,()=>ot({environmentId:e,input:{...t,commentId:n,kind:`review-comment`,body:r}})),onToggleResolved:()=>void It(`The conversation could not be updated`,()=>at({environmentId:e,input:{...t,threadId:r.id,resolved:!r.isResolved}})),onReacted:A},`${t.projectId}#${t.number}:${r.id}`),[n,e,_,A,C,p,t,it,X.reply,X.resolve,It,at,Pe,ot]),Rt=(0,R.useCallback)(e=>(0,W.jsxs)(`div`,{className:`py-1 font-sans text-foreground`,children:[e.metadata.threads.map(Lt),e.metadata.pending.map(e=>(0,W.jsx)(Je,{comment:e,onRemove:()=>nt(Ye,e.id)},e.id)),e.metadata.draft&&B?(0,W.jsx)(We,{kind:`draft`,rangeLabel:`${B.path}:${B.line}`,text:``,submitLabel:`Add to review`,...O?{secondaryAction:{label:`Add to agent`,onAction:e=>jt(B,e,t=>O({comment:t,request:e}))}}:{},onCancel:()=>{Ne(null),z(null)},onComment:e=>{et(Ye,{id:Qe(),path:B.path,...B.oldPath===null?{}:{oldPath:B.oldPath},line:B.line,side:B.side,body:e}),Ne(null),z(null)}}):null]}),[et,jt,B,O,nt,Lt,Ye]),zt=X.verdicts.length===0?null:(0,W.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 z-10`,children:Re?(0,W.jsxs)(`div`,{className:`chat-composer-glass pointer-events-auto absolute inset-x-3 bottom-3 rounded-xl border border-border/60 shadow-lg`,children:[(0,W.jsx)(c,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Close review`,className:`absolute right-2 top-2`,onClick:()=>ze(!1),children:(0,W.jsx)(y,{className:`size-3.5`})}),(0,W.jsx)(rt,{environmentId:e,reference:t,verdicts:X.verdicts,onSubmitted:()=>{A(),ze(!1)}})]}):(0,W.jsxs)(`button`,{type:`button`,className:`chat-composer-glass pointer-events-auto absolute bottom-3 right-4 flex items-center gap-1.5 rounded-full border border-border/60 px-3 py-1.5 text-xs font-medium shadow-lg`,onClick:()=>ze(!0),children:[(0,W.jsx)(Se,{className:`size-3.5`}),`Review`,Ze.length>0?(0,W.jsx)(`span`,{className:`flex size-4 items-center justify-center rounded-full bg-accent text-[10px] tabular-nums text-accent-foreground`,children:Ze.length}):null]})}),Bt=kt.find(e=>e.oid===U);(0,R.useEffect)(()=>{U!==null&&Bt===void 0&&s(null)},[U,s,Bt]);let Vt=Bt?Bt.messageHeadline:`All commits`,Ht=(0,W.jsxs)(`div`,{className:`surface-subheader justify-between gap-2 px-4 text-xs text-muted-foreground`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[kt.length>0?(0,W.jsxs)(w,{children:[(0,W.jsxs)(d,{className:`inline-flex h-6 max-w-64 items-center gap-1 rounded-md bg-accent px-2 text-xs font-medium text-accent-foreground outline-none transition-colors hover:bg-accent/80 focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Diff scope: ${Vt}`,children:[(0,W.jsx)(`span`,{className:`truncate`,children:Vt}),(0,W.jsx)(x,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,W.jsxs)(g,{align:`start`,className:`w-80`,children:[(0,W.jsx)(h,{className:U===null?`bg-foreground/[0.08]`:void 0,onClick:()=>s(null),children:(0,W.jsx)(`span`,{children:`All commits`})}),kt.slice(0,le).map(e=>(0,W.jsxs)(h,{className:e.oid===U?`bg-foreground/[0.08]`:void 0,onClick:()=>s(e.oid),children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate`,title:e.messageHeadline,children:e.messageHeadline}),(0,W.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-xs text-muted-foreground`,children:e.oid.slice(0,7)})]},e.oid)),kt.length>le?(0,W.jsx)(h,{closeOnClick:!1,onClick:()=>ue(e=>e+dt),children:(0,W.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Show more (`,kt.length-le,` left)`]})}):null]})]}):null,(0,W.jsxs)(ye,{children:[(0,W.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[Z.length,` `,Z.length===1?`file`:`files`,Q===null?``:`+`]}),vt?(0,W.jsxs)(b,{children:[(0,W.jsx)(D,{render:(0,W.jsx)(`span`,{className:`flex shrink-0 items-center`}),children:(0,W.jsx)(f,{"aria-label":`Some of this diff was not shown`,className:`size-3.5 text-amber-600 dark:text-amber-500`})}),(0,W.jsx)(l,{side:`bottom`,children:`The host withheld part of this diff — a binary file, or a change too large to inline.`})]}):null,U!==null&&X.inlineComment?(0,W.jsxs)(b,{children:[(0,W.jsx)(D,{render:(0,W.jsx)(`span`,{className:`flex shrink-0 items-center`}),children:(0,W.jsx)(je,{"aria-label":`Line comments are written from the whole change`,className:`size-3.5`})}),(0,W.jsx)(l,{side:`bottom`,children:`A comment is anchored to the whole change, so switch to All commits to write one.`})]}):null]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,W.jsx)(de,{additions:bt.additions,deletions:bt.deletions,className:`mr-1`}),St.length>0?(0,W.jsxs)(b,{children:[(0,W.jsx)(D,{render:(0,W.jsx)(c,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":wt?`Expand all files`:`Collapse all files`,onClick:Ot}),children:wt?(0,W.jsx)(_e,{className:`size-3.5`}):(0,W.jsx)(P,{className:`size-3.5`})}),(0,W.jsx)(l,{side:`top`,children:wt?`Expand all files`:`Collapse all files`})]}):null,(0,W.jsxs)(te,{className:`shrink-0 gap-1`,size:`sm`,value:[he],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&ge(t)},children:[(0,W.jsx)(ae,{"aria-label":`Stacked diff view`,value:`stacked`,variant:`ghost`,children:(0,W.jsx)(ne,{className:`size-3.5`})}),(0,W.jsx)(ae,{"aria-label":`Split diff view`,value:`split`,variant:`ghost`,children:(0,W.jsx)(ie,{className:`size-3.5`})})]}),(0,W.jsxs)(b,{children:[(0,W.jsx)(D,{render:(0,W.jsx)(ae,{"aria-label":I?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`ghost`,size:`sm`,pressed:I,onPressedChange:e=>{De(!!e)}}),children:(0,W.jsx)(Te,{className:`size-3.5`})}),(0,W.jsx)(l,{side:`top`,children:I?`Disable line wrapping`:`Enable line wrapping`})]})]})]}),Ut=e=>(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[Ht,(0,W.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`h-full overflow-auto`,children:e}),zt]})]});if(J.isPending&&K.length===0)return Ut((0,W.jsx)(ve,{label:`Loading pull request diff...`}));if(J.error&&K.length===0)return Ut((0,W.jsx)(`p`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:J.error}));let Wt=Q===null?_t.flatMap(e=>e?.kind===`raw`?[e]:[]):[];if(Z.length===0&&Wt.length>0)return Ut((0,W.jsx)(`div`,{className:`space-y-4 px-4 py-5`,children:Wt.map(e=>(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.reason}),(0,W.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs`,children:e.text})]},`${e.reason}:${e.text.slice(0,64)}`))}));if($.length===0&&Q===null)return Ut((0,W.jsx)(`p`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:U===null?`This pull request has no file changes.`:`This commit has no file changes.`}));let Gt=n.reviewThreads.filter(e=>!yt.has(e.id)),Kt=new Map;for(let e of Gt){let t=Kt.get(e.path);t?t.push(e):Kt.set(e.path,[e])}let qt=Wt.length===0?null:(0,W.jsx)(`div`,{className:`space-y-4 border-t border-border/60 px-4 py-5`,children:Wt.map(e=>(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.reason}),(0,W.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs`,children:e.text})]},`${e.reason}:${e.text.slice(0,64)}`))});return(0,W.jsx)(xe,{children:(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[Ht,Kt.size>0?(0,W.jsxs)(o,{className:`shrink-0 border-b border-border/60`,open:Ie,onOpenChange:Le,children:[(0,W.jsx)(`h2`,{children:(0,W.jsxs)(a,{className:`flex w-full items-center gap-1.5 px-4 py-2 text-left text-xs text-muted-foreground`,children:[(0,W.jsx)(`span`,{children:Q===null?`Conversations not on the current diff`:`Conversations not on the diff loaded so far`}),(0,W.jsx)(S,{"aria-hidden":!0,className:v(`size-3.5 transition-transform`,Ie&&`rotate-90`)}),(0,W.jsx)(`span`,{"aria-hidden":!0,className:`tabular-nums`,children:Gt.length}),(0,W.jsx)(`span`,{className:`sr-only`,children:Gt.length===1?`1 conversation`:`${Gt.length} conversations`})]})}),(0,W.jsx)(i,{children:(0,W.jsx)(`div`,{className:`max-h-64 space-y-3 overflow-auto px-4 pb-3`,children:[...Kt].map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`truncate px-3 text-xs text-muted-foreground`,title:e,children:e}),(0,W.jsx)(`div`,{className:`mt-1 space-y-2`,children:t.map(e=>(0,W.jsxs)(`div`,{children:[e.line===null?null:(0,W.jsxs)(`p`,{className:`px-3 text-xs text-muted-foreground`,children:[`Line `,e.line]}),Lt(e)]},e.id))})]},e))})})]}):null,(0,W.jsxs)(`div`,{className:`relative min-h-0 flex-1`,onClickCapture:e=>{let t=e.nativeEvent.composedPath?.()??[];for(let e of t)if(e instanceof HTMLElement){if(e instanceof HTMLButtonElement||e instanceof HTMLAnchorElement)return;if(e.hasAttribute(`data-diffs-header`)){let t=e.querySelector(`[data-title]`)?.textContent?.trim();if(t===void 0||t===``)return;let n=$.find(e=>L(e.fileDiff)===t);n!==void 0&&Dt(n.id);return}}},children:[(0,W.jsx)(Ge,{className:`h-full overflow-auto [scrollbar-gutter:stable]`,items:$,selectedLines:Me,onSelectedLinesChange:z,options:Ft,renderCodeViewFooter:Mt,renderHeaderPrefix:Nt,renderHeaderMetadata:Pt,renderAnnotation:Rt,unsafeCSSExtra:ft}),zt]}),qt]})})}export{X as PullRequestCodeTab,X as default};
251
- //# sourceMappingURL=PullRequestCodeTab-D5W0ZyCG.js.map
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{Ds as i,Eo as a,Fo as o,Fs as s,Io as c,Jo as l,Lo as u,Os as d,Po as f,Qo as p,Qs as m,To as h,Ui as g,Vo as _,Xo as v,Zo as y,_s as b,dg as x,es as S,js as C,ks as w,xs as T,zo as E,zs as D}from"./textarea-DXj6RvAd.js";var O=e(n(),1),k=typeof window<`u`?O.useLayoutEffect:O.useEffect;function A(e){let t=O.useRef({value:e,prev:null}),n=t.current.value;return e!==n&&(t.current={value:e,prev:n}),t.current.prev}function j(e,t,n={},r={}){O.useEffect(()=>{if(!e.current||r.disabled||typeof IntersectionObserver!=`function`)return;let i=new IntersectionObserver(([e])=>{t(e)},n);return i.observe(e.current),()=>{i.disconnect()}},[t,n,r.disabled,e])}function M(e){let t=O.useRef(null);return O.useImperativeHandle(e,()=>t.current,[]),t}function N(e){let t=x();return O.useCallback(n=>t.navigate({...n,from:n.from??e?.from}),[e?.from,t])}var P=m(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),F=m(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]);function I(e){let{open:t,defaultOpen:n,onOpenChange:r,disabled:i}=e,[a,o]=S({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:l,transitionStatus:u}=c(a,!0,!0),d=_(),[f,p]=O.useState(),m=f??d,h=y(e=>{let t=!a,n=E(T,e.nativeEvent);r(t,n),!n.isCanceled&&o(t)});return O.useMemo(()=>({disabled:i,handleTrigger:h,mounted:s,open:a,panelId:m,setMounted:l,setOpen:o,setPanelIdState:p,transitionStatus:u}),[i,h,s,a,m,l,o,p,u])}var L=O.createContext(void 0);function R(){let e=O.useContext(L);if(e===void 0)throw Error(D(15));return e}var z=function(e){return e.open=`data-open`,e.closed=`data-closed`,e[e.startingStyle=i.startingStyle]=`startingStyle`,e[e.endingStyle=i.endingStyle]=`endingStyle`,e}({}),B=function(e){return e.panelOpen=`data-panel-open`,e}({}),V={[z.open]:``},H={[z.closed]:``},U={open(e){return e?{[B.panelOpen]:``}:null}},W={open(e){return e?V:H},...d},G=t(),K=O.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...l}=e,u=y(o),d=I({open:s,defaultOpen:i,onOpenChange:u,disabled:a}),f=O.useMemo(()=>({open:d.open,disabled:d.disabled,transitionStatus:d.transitionStatus}),[d.open,d.disabled,d.transitionStatus]),p=O.useMemo(()=>({...d,onOpenChange:u,state:f}),[d,u,f]),m=w(`div`,e,{state:f,ref:t,props:l,stateAttributesMapping:W});return(0,G.jsx)(L.Provider,{value:p,children:m})}),q={...U,...d},ee=O.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=R(),{className:s,disabled:c=o,id:u,render:d,nativeButton:f=!0,style:p,...m}=e,{getButtonProps:h,buttonRef:g}=l({disabled:c,focusableWhenDisabled:!0,native:f});return w(`button`,e,{state:a,ref:[t,g],props:[{"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i},m,h],stateAttributesMapping:q})}),J={height:void 0,width:void 0};function te(e){let{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:c,onOpenChange:l,open:d,setMounted:p,setOpen:m,transitionStatus:g}=e,_=O.useRef(null),x=O.useRef(null),[S,C]=O.useState(J),w=O.useRef(J),T=O.useRef(!1),D=O.useRef(d),k=O.useRef(!1),[A,j]=O.useState(!1),M=O.useRef(null),N=s(t,_),P=h({mounted:c,open:d}),F=o(_,!1,!1),I=!d&&!c,L=A?`idle`:g,R=d&&(D.current||k.current),B=!d&&c&&x.current===`css-animation`&&S.height===void 0&&S.width===void 0?w.current:S,V=n&&I&&x.current!==`css-animation`,H=y((e,t=!0)=>{t&&(w.current=e),C(e)}),U=y(()=>{M.current?.(),M.current=null}),W=y(e=>{U(),M.current=()=>{M.current=null,e()}}),G=y(()=>{d&&c&&x.current===`css-animation`&&(k.current=!0)});v(()=>{!A||g===`starting`||j(!1)},[A,g]),O.useEffect(()=>()=>{G(),U()},[G,U]),v(()=>{let e=_.current;if(!e)return;!d&&M.current&&U();let t=ne(e,R);if(x.current=t,d&&g===`idle`&&D.current&&t===`css-animation`){w.current=Y(e);return}if(d&&g===`starting`){let n=T.current;if(T.current=!1,t===`none`){H(Y(e)),j(!0);return}if(t===`css-transition`){let t=re(e);if(H(Y(e)),!n)return t;let r=Z(e,`transition-duration`,`0s`);return W(r),j(!0),t}if(t===`css-animation`){if(H(Y(e)),!n){Z(e,`animation-name`,`none`)();return}let t=Z(e,`animation-name`,`none`),r=Z(e,`animation-duration`,`0s`);t(),W(r),j(!0);return}}if(!d&&c&&(g===`idle`||g===`starting`)){if(t===`none`){H(J,!1),p(!1);return}t===`css-animation`&&(D.current=!1,k.current=!1),H(Y(e));return}if(g!==`ending`)return;if(t===`none`){p(!1);return}let n=Y(e);if(!((n.height??0)>0||(n.width??0)>0)){p(!1);return}H(n),t===`css-animation`&&Z(e,`animation-name`,`none`)()},[c,d,U,H,p,W,R,g]),f({enabled:d&&c&&L===`idle`,open:!0,ref:_,onComplete(){d&&H(J,!1)}}),O.useEffect(()=>{if(d||!c||L!==`ending`||!_.current)return;let e=new AbortController,t=-1;function n(){P.current.open||(p(!1),H(J,!1))}return t=u.request(()=>{e.signal.aborted||F(n,e.signal)}),()=>{u.cancel(t),e.abort()}},[P,c,d,L,F,H,p]),v(()=>{let e=_.current;!e||!n||!I||e.setAttribute(`hidden`,`until-found`)},[I,n]),O.useEffect(function(){let e=_.current;if(!e)return;function t(e){T.current=!0,m(!0),l(!0,E(b,e))}return a(e,`beforematch`,t)},[l,m]);let K=i||n||c||d;return{height:B.height,props:{...V?{[z.startingStyle]:``}:void 0,hidden:I,id:r},ref:N,shouldPreventOpenAnimation:R,shouldRender:K,transitionStatus:L,width:B.width}}function Y(e){return{height:e.scrollHeight,width:e.scrollWidth}}function ne(e,t=!1){let n=p(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&X(n.animationDuration),i=X(n.transitionDuration);return r&&i||i?`css-transition`:r?`css-animation`:`none`}function X(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function Z(e,t,n){let r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===``){e.style.removeProperty(t);return}e.style.setProperty(t,r,i)}}function re(e){let t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(t=>{e.style.setProperty(t,`initial`,`important`)});function n(){Object.entries(t).forEach(([t,n])=>{if(n===``){e.style.removeProperty(t);return}e.style.setProperty(t,n)})}let r=u.request(n);return()=>{u.cancel(r),n()}}var Q=function(e){return e.collapsiblePanelHeight=`--collapsible-panel-height`,e.collapsiblePanelWidth=`--collapsible-panel-width`,e}({}),ie=O.forwardRef(function(e,t){let{className:n,hiddenUntilFound:r,keepMounted:i,render:a,id:o,style:s,...c}=e,{mounted:l,onOpenChange:u,open:d,panelId:f,setMounted:p,setPanelIdState:m,setOpen:h,state:g,transitionStatus:_}=R(),y=r??!1,b=i??!1;v(()=>{if(o)return m(o),()=>{m(void 0)}},[o,m]);let{height:x,props:S,ref:T,shouldPreventOpenAnimation:E,shouldRender:D,transitionStatus:O,width:k}=te({externalRef:t,hiddenUntilFound:y,id:f,keepMounted:b,mounted:l,onOpenChange:u,open:d,setMounted:p,setOpen:h,transitionStatus:_}),A={...g,transitionStatus:O},j=C(s,A),M=w(`div`,{...e,style:void 0},{state:A,ref:T,props:[S,{style:{[Q.collapsiblePanelHeight]:x===void 0?`auto`:`${x}px`,[Q.collapsiblePanelWidth]:k===void 0?`auto`:`${k}px`}},c,j?{style:j}:void 0,E?{style:{animationName:`none`}}:void 0],stateAttributesMapping:W});return D?M:null}),$=r();function ae(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,G.jsx)(K,{"data-slot":`collapsible`,...n}),t[2]=n,t[3]=r),r}function oe(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=g(`cursor-pointer`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(ee,{className:i,"data-slot":`collapsible-trigger`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function se(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=g(`panel-motion h-(--collapsible-panel-height) overflow-hidden transition-[height] duration-(--panel-duration) data-ending-style:h-0 data-starting-style:h-0 data-open:data-ending-style:[height:var(--collapsible-panel-height)]`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(ie,{className:i,"data-slot":`collapsible-panel`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}export{P as a,j as c,F as i,k as l,se as n,N as o,oe as r,M as s,ae as t,A as u};
2
- //# sourceMappingURL=collapsible-CjR2aTi6.js.map
@@ -1,2 +0,0 @@
1
- import{n as e}from"./compiler-runtime-CLAvuQ-D.js";import{$t as t,An as n,At as r,Bn as i,Bt as a,Cn as o,Ct as s,Dt as c,Et as l,Fn as u,Ft as d,Hn as f,Ht as p,In as m,It as h,Lt as g,Mt as _,Nn as v,Nt as y,Ot as b,Pt as x,Qt as S,Rt as C,St as w,Tn as T,Tt as E,Ut as D,Vn as O,Vt as k,Wt as A,Xt as j,Yt as M,Zt as N,_n as P,_t as F,an as I,bn as L,bt as R,dn as z,en as B,fn as V,gn as ee,gt as te,in as H,jt as ne,kt as re,mn as U,nn as W,on as ie,pn as G,qt as K,rn as ae,sn as oe,tn as q,un as J,vn as Y,vt as X,wn as se,wt as ce,x as le,xt as ue,yn as de,zn as fe,zt as pe}from"./index-CLwUrcHN.js";function Z(e,t){return t.cacheKey==null?e.file===t&&e.sourceContents===t.contents:e.cacheKey===t.cacheKey}var me=-1,he=class{options;onRenderUpdate;workerManager;__id=`file-renderer:${++me}`;highlighter;renderCache;computedLang=`text`;lineAnnotations={};lineCache;pendingStructuralRows;textDocumentCache=new WeakMap;editSessionActive=!1;constructor(e={theme:u},t,n){this.options=e,this.onRenderUpdate=t,this.workerManager=n,n?.isWorkingPool()!==!0&&(this.highlighter=H(e.theme??u)?ie():void 0)}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}setLineAnnotations(e){this.lineAnnotations={};for(let t of e){let e=this.lineAnnotations[t.lineNumber]??[];this.lineAnnotations[t.lineNumber]=e,e.push(t)}}cleanUp(){this.recycle(),this.workerManager=void 0,this.onRenderUpdate=void 0}beginEditSession(){this.editSessionActive=!0}endEditSession(){this.editSessionActive=!1}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}recycle(){this.clearRenderCache(),this.highlighter=void 0,this.workerManager?.cleanUpTasks(this),this.lineCache=void 0,this.endEditSession(),this.textDocumentCache=new WeakMap}syncEditedContentsToFile(){let{renderCache:e,lineCache:t}=this;e?.isDirty!==!0||t==null||!Z(t,e.file)||(e.file.contents=t.lines.join(``))}hasUnkeyedFileContentsChanged(e){let{lineCache:t}=this;return e.cacheKey==null&&t!=null&&t.file===e&&t.sourceContents!==e.contents}invalidateChangedUnkeyedFile(e){this.hasUnkeyedFileContentsChanged(e)&&(this.workerManager?.cleanUpTasks(this),this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap)}clearRenderCache(){this.syncEditedContentsToFile(),this.pendingStructuralRows=void 0;let e=this.renderCache;this.renderCache=void 0,e!=null&&e.isDirty===!0&&e.file.cacheKey!=null&&this.workerManager?.evictFileFromCache(e.file.cacheKey)}hydrate(e){let{options:t}=this.getRenderOptions(e),n=Q(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength()),r=this.workerManager?.getFileResultCache(e);r!=null&&!W(t,r.options)&&(r=void 0),this.renderCache??={file:e,options:t,highlighted:!n&&!g(e),result:n?void 0:r?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!n&&this.workerManager.highlightFileAST(this,e):this.highlighter??(this.computedLang=e.lang??N(e.name),this.initializeHighlighter())}getLocalHighlightTheme(){return this.workerManager?.getFileRenderOptions().theme??this.options.theme??u}getEffectiveCodeOptions(){let e=this.workerManager?.isWorkingPool()===!0?this.workerManager.getFileRenderOptions():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.getFileRenderOptions();return this.editSessionActive&&e.useTokenTransformer!==!0?{...e,useTokenTransformer:!0}:e}let{tokenizeMaxLineLength:e=1e3}=this.options;return{theme:this.getLocalHighlightTheme(),useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:e}})(),{renderCache:n}=this;return n?.result==null||!L(e,n.file)||!W(t,n.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}getOrCreateLineCache(e){this.invalidateChangedUnkeyedFile(e);let{lineCache:t}=this;return(t==null||!Z(t,e))&&(t={cacheKey:e.cacheKey,file:e,sourceContents:e.contents,lines:K(e.contents)}),this.lineCache=t,t.lines}getLineCount(e){let t=this.getOrCreateLineCache(e);return this.textDocumentCache.get(e)?.lineCount??t.length}updateRenderCache(e,t,n=!1){if(this.pendingStructuralRows=void 0,this.renderCache==null)return;let{file:r,result:i}=this.renderCache;if(i==null)return;let a=n?new Map:void 0;this.pendingStructuralRows=a;let o=this.lineCache!=null&&Z(this.lineCache,r)?this.lineCache:void 0;for(let[t,n]of e){if(a===void 0&&o!=null&&t<o.lines.length){let e=n.map(e=>e[2]).join(``);o.lines[t]=pe(o.lines[t]??``,e)}let e={type:`element`,tagName:`div`,properties:{"data-line":t+1,"data-line-type":`context`,"data-line-index":t},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}]})};a===void 0?i.code[t]=e:a.set(t,e)}i.baseThemeType=t,this.renderCache.isDirty=!0}applyDocumentChange(e){let t=this.pendingStructuralRows;if(this.pendingStructuralRows=void 0,this.renderCache==null)return;let{file:n,result:r}=this.renderCache;if(r==null)return;let i=this.lineCache!=null&&Z(this.lineCache,n)?this.lineCache.lines:K(n.contents),a=K(e.getText());if(i.length!==a.length){let n=Math.min(i.length,a.length),o=0;for(;o<n&&i[o]===a[o];)o++;let s=0;for(;s<n-o&&i[i.length-1-s]===a[a.length-1-s];)s++;let c=r.code;r.code=Array(a.length);for(let e=0;e<o;e++)r.code[e]=c[e];for(let e=0;e<s;e++)r.code[a.length-1-e]=c[i.length-1-e];if(t!==void 0)for(let[e,n]of t)e<a.length&&(r.code[e]=n);for(let t=o;t<a.length-s;t++)r.code[t]??={type:`element`,tagName:`div`,properties:{"data-line":t+1,"data-line-type":`context`,"data-line-index":t},children:[{type:`element`,tagName:`span`,properties:{"data-char":0},children:[{type:`text`,value:e.getLineText(t)}]}]};for(let e=0;e<r.code.length;e++){let t=r.code[e];t?.type===`element`&&(t.properties[`data-line`]=e+1,t.properties[`data-line-index`]=e)}this.renderCache.isDirty=!0}this.lineCache={cacheKey:n.cacheKey,file:n,sourceContents:n.contents,lines:a},this.textDocumentCache.set(n,e)}renderFile(e=this.renderCache?.file,t=v){if(e==null)return;this.invalidateChangedUnkeyedFile(e),this.renderCache?.isDirty===!0&&!L(e,this.renderCache.file)&&(this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap);let{options:n,forceHighlight:r}=this.getRenderOptions(e);this.renderCache?.isDirty===!0&&!W(n,this.renderCache.options)&&this.clearRenderCache();let i=this.getMatchingWorkerResultCache(e,n);i!=null&&!this.hasHighlightedRenderCache(e,n)&&(this.renderCache={file:e,highlighted:!0,renderRange:void 0,...i},r=!1),this.renderCache??={file:e,highlighted:!1,options:n,result:void 0,renderRange:void 0};let a=this.getOrCreateLineCache(e),o=e.contents.length>0,s=!o||g(e)||Q(a.length,this.getTokenizeMaxLength()),c=!L(e,this.renderCache.file),l=!q(this.renderCache.renderRange,t);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0)(s||this.renderCache.result==null||!this.renderCache.highlighted&&(c||l))&&(this.renderCache.file=e,this.renderCache.options=n,this.renderCache.highlighted=!1,(this.renderCache.result==null||c||l||r)&&(this.renderCache.result=this.workerManager.getPlainFileAST(e,t.startingLine,t.totalLines,a)),this.renderCache.renderRange=t),!s&&o&&(!this.renderCache.highlighted||r)&&this.workerManager.highlightFileAST(this,e);else{this.computedLang=e.lang??N(e.name);let t=this.highlighter!=null&&H(n.theme),i=this.highlighter!=null&&J(this.computedLang),a=!s&&i;if(this.highlighter!=null&&t&&(r||s||!this.renderCache.highlighted&&a||this.renderCache.result==null)){let{result:t,options:n}=this.renderFileWithHighlighter(e,this.highlighter,s||!i);this.renderCache={file:e,options:n,highlighted:a,result:t,renderRange:void 0}}(!t||!s&&!i)&&this.asyncHighlight(e).then(({result:t,options:n})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.applyHighlightResult(e,t,n,!s)})}return this.renderCache.result==null?void 0:this.processFileResult(this.renderCache.file,t,this.renderCache.result)}async asyncRender(e,t=v){let{result:n}=await this.asyncHighlight(e);return this.processFileResult(e,t,n)}async asyncHighlight(e){let t=Q(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength());this.computedLang=t?`text`:e.lang??N(e.name);let n=this.highlighter!=null&&ae(I(this.getLocalHighlightTheme())),r=t||this.highlighter!=null&&J(this.computedLang);return(this.highlighter==null||!n||!r)&&(this.highlighter=await this.initializeHighlighter()),this.renderFileWithHighlighter(e,this.highlighter,t)}renderFileWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e);return{result:A(e,t,r,{forcePlainText:n}),options:r}}processFileResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let a=this.getLineCount(e),{disableFileHeader:o=!1}=this.options,s=[],c=Y(),l=Math.min(t.startingLine+t.totalLines,a),u=0,d=D(t)?k(this.lineAnnotations):void 0;d!=null&&(c.children.push(ee(`context`,`annotation`,1)),s.push(B({type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:d.map(e=>M(e))})),u++);for(let r=t.startingLine;r<l;r++){let t=r+1,i=n[r];if(i==null){let n=`FileRenderer.processFileResult: Line doesnt exist`;throw console.error(n,{name:e.name,lineIndex:r,lineNumber:t}),Error(n)}c.children.push(P(`context`,t,`${r}`)),s.push(i),u++;let a=this.lineAnnotations[t];a!=null&&(c.children.push(ee(`context`,`annotation`,1)),s.push(B({type:`annotation`,hunkIndex:0,lineIndex:t,annotations:a.map(e=>M(e))})),u++)}return c.properties.style=`grid-row: span ${u}`,{gutterAST:c.children??[],contentAST:s,preAST:this.createPreElement(a),headerAST:o?void 0:this.renderHeader(e),totalLines:a,rowCount:u,themeStyles:r,baseThemeType:i,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:``}}renderHeader(e){let{headerRenderMode:n=`default`,stickyHeader:r=!1}=this.options;return t({fileOrDiff:e,mode:n,stickyHeader:r})}renderFullHTML(e){return U(this.renderFullAST(e))}renderFullAST(e,t=[]){return t.push(de({tagName:`code`,children:this.renderCodeAST(e),properties:{"data-code":``}})),{...e.preAST,children:t}}renderCodeAST(e){let t=Y();return t.children=e.gutterAST,t.properties.style=`grid-row: span ${e.rowCount}`,[t,C(e.contentAST,e.rowCount)]}renderPartialHTML(e,t=!1){return U(t?de({tagName:`code`,children:e,properties:{"data-code":``}}):e)}async initializeHighlighter(){return this.highlighter=await oe(j(this.computedLang,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}onHighlightSuccess(e,t,n,r=!0){this.editSessionActive||this.applyHighlightResult(e,t,n,r)}applyHighlightResult(e,t,n,r=!0){if(this.renderCache==null)return;let i=!L(e,this.renderCache.file)||!this.renderCache.highlighted||!W(n,this.renderCache.options);this.renderCache={file:e,options:n,highlighted:r,result:t,renderRange:void 0},i&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(e,t){if(this.editSessionActive)return;let n=this.workerManager?.getFileResultCache(e);if(!(n==null||!W(t,n.options)))return n}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&L(e,n.file)&&W(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}createPreElement(e){let{disableLineNumbers:t=!1,overflow:n=`scroll`}=this.options;return S({type:`file`,diffIndicators:`none`,disableBackground:!0,disableLineNumbers:t,overflow:n,split:!1,totalLines:e})}};function Q(e,t){return e>t}function ge(e,t){return e.lineNumber===t.lineNumber&&e.metadata===t.metadata}function _e(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,themeType:e?.themeType,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:s(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,unsafeCSS:e?.unsafeCSS,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}var ve=[``],ye=-1,be=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file:${++ye}`;type=`file`;fileContainer;spriteSVG;pre;code;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;errorWrapper;placeHolder;lastRenderedHeaderHTML;cachedHeaderHTML;appliedPreAttributes;lastRowCount;mounted=!1;headerElement;headerCustom;headerPrefix;headerFilenameSuffix;headerMetadata;fileRenderer;resizeManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;file;renderRange;enabled=!0;editor;constructor(e={theme:u},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new he(e,this.handleHighlightRender,this.workerManager),this.resizeManager=new z,this.interactionManager=new V(`file`,G(e)),this.workerManager?.subscribeToThemeChanges(this)}handleHighlightRender=()=>{this.rerender()};rerender(){!this.enabled||this.file==null||this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}__getCurrentFile(){return this.file}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(G(this.options))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??`system`)!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme==`string`||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType===t?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!se(this.appliedThemeCSS.theme,this.options.theme??u)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??`additions`})}getCodeScrollLeft(){return this.code?.scrollLeft??0}setCodeScrollLeft(e){this.code!=null&&(this.code.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.fileRenderer.getEffectiveCodeOptions()}}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{overflow:e=`scroll`}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:e===`wrap`,columnVariables:this.shouldApplyColumnVariables(e)?`apply`:`measure`}),this.managersDirty=!1}shouldApplyColumnVariables(e){return e===`scroll`&&this.lineAnnotations.length>0}cleanUp(e=!1){this.emitPostRender(!0),this.editor?.cleanUp(e),this.editor=void 0,this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.pre=void 0,this.code=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper?.remove(),this.errorWrapper=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.placeHolder?.remove(),this.placeHolder=void 0,e?this.fileRenderer.recycle():(this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0),this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){let{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,file:i,lineAnnotations:a}=e;if(!this.enabled)throw Error(`File.hydrate: attempting to call hydrate after cleaned up`);if(this.fileContainer!=null)throw Error(`File.hydrate: hydrate can only be called before the instance has rendered or hydrated`);this.hydrateElements(t,n),xe(this.pre,i,this.options.collapsed)||Se(this.headerElement,i,this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({file:i,lineAnnotations:a}),r||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),l(e,t);for(let t of Array.from(e.shadowRoot?.children??[])){if(t instanceof SVGElement){this.spriteSVG=t;continue}if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t,this.appliedPreAttributes=void 0;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)){this.themeCSSStyle=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)){this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent;continue}if(`diffsHeader`in t.dataset){this.headerElement=t,this.lastRenderedHeaderHTML=void 0;continue}}}this.pre!=null&&(this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute(`data-dehydrated`)),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({file:e,lineAnnotations:t}){this.lineAnnotations=t??this.lineAnnotations,this.file=e,this.fileRenderer.setOptions(_e(this.options)),this.syncInteractionOptions(),this.pre!=null&&(this.fileRenderer.hydrate(e),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}getOrCreateLineCache(e=this.file){return e==null?ve:this.fileRenderer.getOrCreateLineCache(e)}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}syncRenderViewToEditor(){let e=this.editor,t=this.fileContainer,n=this.file,r=this.lineAnnotations,i=this.renderRange;e!=null&&t!=null&&n!=null&&this.fileRenderer.initializeHighlighter().then(a=>{!this.enabled||this.editor!==e||this.fileContainer!==t||this.file!==n||e.__syncRenderView(a,t,n,r,i)})}attachEditor(e){this.editor?.cleanUp(),this.editor=e,this.fileRenderer.beginEditSession();let t=this.file==null?void 0:e.__prepareFile?.(this.file);return t!==void 0&&t!==this.file?this.renderPreparedFile({file:t,forceRender:!0,preventEmit:!0,renderRange:this.renderRange}):this.fileRenderer.editorRenderReady()?this.syncRenderViewToEditor():this.rerender(),()=>{this.editor=void 0,this.fileRenderer.endEditSession()}}applyDocumentChange(e,t){this.fileRenderer.applyDocumentChange(e),t!=null&&t!==this.lineAnnotations&&this.file!=null&&(this.setLineAnnotations(t),this.fileRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations())}updateRenderCache(e,t,n){this.fileRenderer.updateRenderCache(e,t,n?.lineCountChangeInFlight)}render(e){if(!this.enabled)throw Error(`File.render: attempting to call render after cleaned up`);let t=this.editor?.__prepareFile?.(e.file)??e.file;return this.renderPreparedFile(t===e.file?e:{...e,file:t})}renderPreparedFile({file:e,fileContainer:t,forceRender:n=!1,preventEmit:r=!1,containerWrapper:i,deferManagers:a=!1,lineAnnotations:o,renderRange:s}){this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:c=!1,themeType:l=`system`}=this.options,u=c?void 0:s,d=this.renderRange,f=this.hasThemeChanged(),p=o!=null&&(o.length>0||this.lineAnnotations.length>0)?o!==this.lineAnnotations:!1,m=!L(this.file,e)||this.fileRenderer.hasUnkeyedFileContentsChanged(e);if(!c&&!n&&q(u,this.renderRange)&&!m&&!p&&!f)return this.applyCachedThemeState(l);this.renderRange=u,m&&(this.cachedHeaderHTML=void 0),this.file=e,this.fileRenderer.setOptions(_e(this.options)),this.syncInteractionOptions(),o!=null&&this.setLineAnnotations(o),this.fileRenderer.setLineAnnotations(this.lineAnnotations);let{disableErrorHandling:h=!1,disableFileHeader:g=!1}=this.options;if(g&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),t=this.getOrCreateFileContainerNode(t,i),this.applyCachedThemeState(l),c){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let n=this.fileRenderer.renderFile(e,fe);n!=null&&this.applyThemeState(t,n.themeStyles,l,n.baseThemeType),n?.headerAST!=null&&this.applyHeaderToDOM(n.headerAST,t),this.injectUnsafeCSS()}catch(e){if(h)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,t)}return r||this.emitPostRender(),!0}try{let r=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,p,m||f)||!this.applyPartialRender(d,u)){let n=this.fileRenderer.renderFile(e,u);if(n==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(t,n.themeStyles,l,n.baseThemeType),n.headerAST!=null&&this.applyHeaderToDOM(n.headerAST,t),this.applyFullRender(n,r)}this.applyBuffers(r,u),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,a||this.flushManagers(),this.editor!=null&&this.syncRenderViewToEditor()}catch(e){if(h)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,t)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;n?.(t,this,`unmount`);return}if(t==null)return;let r=this.mounted?`update`:`mount`;this.mounted=!0,n?.(t,this,r)}removeRenderedCode(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.code?.remove(),this.code=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(e,t,n){return!(e||t||n)}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:`open`});this.placeHolder=document.createElement(`div`),this.placeHolder.dataset.placeholder=``,e.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty(`height`,`${e}px`),!0}async primeHighlightCache(e=this.file){let{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||g(e))return;let n=this.options.tokenizeMaxLength??1e5;this.fileRenderer.getOrCreateLineCache(e).length>n||await t.primeFileHighlightCache(e).catch(e=>{console.error(e)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.code?.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.code=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(let[n,r]of this.lineAnnotations.entries()){let i=`${n}-${M(r)}`,a=this.annotationCache.get(i);if(a==null||!ge(r,a.annotation)){a?.element.remove();let e=t(r);if(e==null)continue;a={element:x(M(r)),annotation:r},a.element.appendChild(e),this.fileContainer.appendChild(a.element),this.annotationCache.set(i,a)}e.delete(i)}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=y();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){let{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===``){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??=_(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=r(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.options.theme??u,s=typeof o==`string`?o:{...o},c=ne(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c){this.appliedThemeCSS.theme=s;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c};return}this.themeCSSStyle=ue({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:re(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=b(this.themeCSSStyle.textContent??``,ne(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&R()}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e);let n=this.code=c({code:this.code}),r=this.fileRenderer.renderCodeAST(e);this.editor?.__captureFocusForDOMReplacement();let i=()=>{if(n.childElementCount>=2)for(let e=0;e<2;e++){let t=n.children[e],i=r[e];t.innerHTML=U(i.children),t.style.cssText=i.properties.style}else n.innerHTML=U(r);t.contains(n)||t.replaceChildren(n)};this.shouldGuardRebuildScroll()?w(t,i):i(),this.lastRowCount=e.rowCount}applyPartialRender(e,t){if(e==null||t==null)return!1;let{file:n,code:r}=this,i=r==null?void 0:this.getColumns(r);if(n==null||r==null||i==null)return!1;let a=e.startingLine,o=t.startingLine,s=e.totalLines===1/0?1/0:a+e.totalLines,c=t.totalLines===1/0?1/0:o+t.totalLines,l=Math.max(a,o),u=Math.min(s,c);if(u<=l)return!1;if(!this.trimDOMToOverlap(i.gutter,l,u)||!this.trimDOMToOverlap(i.content,l,u))throw Error(`File.applyPartialRender: failed to trim to overlap`);let{length:d}=i.content.children,f=(e,t)=>{if(!(t<=0))return this.fileRenderer.renderFile(n,{startingLine:e,totalLines:t,bufferBefore:0,bufferAfter:0})},p=o<l?f(o,l-o):void 0;if(p===void 0&&o<l)return!1;let m=c===1/0?1/0:Math.max(0,c-u),h=c>u?f(u,m):void 0;return h===void 0&&c>u?!1:(this.cleanupErrorWrapper(),p!=null&&(i.gutter.insertAdjacentHTML(`afterbegin`,this.fileRenderer.renderPartialHTML(p.gutterAST)),i.content.insertAdjacentHTML(`afterbegin`,this.fileRenderer.renderPartialHTML(p.contentAST)),d+=p.rowCount),h!=null&&(i.gutter.insertAdjacentHTML(`beforeend`,this.fileRenderer.renderPartialHTML(h.gutterAST)),i.content.insertAdjacentHTML(`beforeend`,this.fileRenderer.renderPartialHTML(h.contentAST)),d+=h.rowCount),this.lastRowCount!==d&&(i.gutter.style.setProperty(`grid-row`,`span ${d}`),i.content.style.setProperty(`grid-row`,`span ${d}`),this.lastRowCount=d),!0)}getColumns(e){let t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}trimDOMToOverlap(e,t,n){let r=this.getDOMBoundaryIndices(e,[t,n]),i=r.get(t)??e.children.length,a=r.get(n)??e.children.length;if(i>a)return!1;for(let t=e.children.length-1;t>=a;--t)e.children[t]?.remove();for(let t=i-1;t>=0;--t)e.children[t]?.remove();return!0}getDOMBoundaryIndices(e,t){let n=[...new Set(t)].sort((e,t)=>e-t),r=new Map;if(n.length===0)return r;let i=0,a=n[i],{children:o}=e;a===0&&(r.set(0,0),i+=1,a=n[i]);for(let e=0;e<o.length;e+=1){let t=o[e];if(!(t instanceof HTMLElement))continue;let s=this.getLineIndexFromDOMNode(t);if(s!=null){for(;a!=null&&s>=a;)r.set(a,e),i+=1,a=n[i];if(i>=n.length)break}}for(let e of n)r.has(e)||r.set(e,o.length);return r}getLineIndexFromDOMNode(e){let t=e.dataset.lineIndex;if(t==null)return;let n=Number(t);return Number.isNaN(n)?void 0:n}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore??(this.bufferBefore=document.createElement(`div`),this.bufferBefore.dataset.virtualizerBuffer=`before`,e.before(this.bufferBefore)),this.bufferBefore.style.setProperty(`height`,`${t.bufferBefore}px`),this.bufferBefore.style.setProperty(`contain`,`strict`)):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter??(this.bufferAfter=document.createElement(`div`),this.bufferAfter.dataset.virtualizerBuffer=`after`,e.after(this.bufferAfter)),this.bufferAfter.style.setProperty(`height`,`${t.bufferAfter}px`),this.bufferAfter.style.setProperty(`contain`,`strict`)):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyHeaderToDOM(e,t){let{file:r}=this;if(r==null)return;this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let a=this.cachedHeaderHTML??U(e);if(this.cachedHeaderHTML=a,a!==this.lastRenderedHeaderHTML){let e=document.createElement(`div`);e.innerHTML=a;let n=e.firstElementChild;if(!(n instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(n):t.shadowRoot?.replaceChild(n,this.headerElement),this.headerElement=n,this.lastRenderedHeaderHTML=a}if(this.isContainerManaged)return;let{renderHeaderPrefix:o,renderHeaderFilenameSuffix:s,renderCustomHeader:c,renderHeaderMetadata:l}=this.options;if(c!=null){let e=c(r)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,n,e),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0}else{let e=o?.(r)??void 0,n=s?.(r)??void 0,a=l?.(r)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,f,e),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,i,n),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,O,a),this.headerCustom?.remove(),this.headerCustom=void 0}}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}getOrCreateFileContainerNode(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return n!=null&&i&&this.editor?.__captureFocusForDOMReplacement(),i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),i&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t!=null)for(let e of t.children)e instanceof SVGElement?this.spriteSVG??=e:ce(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):ce(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=h;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});return this.pre==null?(this.pre=document.createElement(`pre`),this.appliedPreAttributes=void 0,this.code=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(this.editor?.__captureFocusForDOMReplacement(),e.shadowRoot?.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(e){this.code=void 0;for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.hasAttribute(`data-code`)){this.code=t;return}}applyPreNodeAttributes(e,{totalLines:t}){let{overflow:n=`scroll`,disableLineNumbers:r=!1}=this.options,i={type:`file`,split:!1,overflow:n,disableLineNumbers:r,diffIndicators:`none`,disableBackground:!0,totalLines:t};d(i,this.appliedPreAttributes)||(E(e,i),this.appliedPreAttributes=i)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.textContent=``,n.appendChild(this.errorWrapper);let r=document.createElement(`div`);r.dataset.errorMessage=``,r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement(`pre`);i.dataset.errorStack=``,i.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function xe(e,t,n=!1){return!n&&e==null&&t!=null}function Se(e,t,n=!1){return e==null&&t!=null&&!n}var Ce=5e3,we=-1;function Te(e,t){return(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS}var Ee=class extends be{virtualizer;metrics;__id=`virtualized-file:${++we}`;top;height=0;cache={heights:new Map,checkpoints:[],fileAnnotationHeight:0};isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(e,t,n=m,r,i=!1){super(e,r,i),this.virtualizer=t,this.metrics=n}setMetrics(e,t=!1){let n=te(e);!t&&T(this.metrics,n)||(this.metrics=n,this.resetLayoutCache())}setLineAnnotations(e){this.syncLineAnnotations(e)&&this.resetLayoutCache()}syncLineAnnotations(e){return e==null||e===this.lineAnnotations||e.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(e),!0)}hasLineAnnotations(){return this.lineAnnotations.some(e=>e.lineNumber>0)}getLineHeight(e,t=!1){let n=this.cache.heights.get(e);if(n!=null)return n;let r=t?2:1;return this.metrics.lineHeight*r}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!o(t,e),r=Te(t,e);super.setOptions(e),r&&this.resetLayoutCache(!0),n&&(this.forceRenderOverride=!0),n&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache(e=!1,t=!0){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heights.size>0&&this.cache.heights.clear(),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.renderRange!=null&&t&&(this.renderRange=void 0),e&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let e=!1;if(this.fileContainer==null||this.file==null)return this.height!==0&&(e=!0),this.height=0,e;let{overflow:t=`scroll`}=this.options;if(this.top=this.getVirtualizedTop(),t===`scroll`&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled()||this.code==null)return e;let n=this.code.children[1];if(!(n instanceof HTMLElement))return e;let r=p(this.lineAnnotations);if(this.renderRange!=null&&r&&D(this.renderRange)){let t=De(n)??0;t!==this.cache.fileAnnotationHeight&&(this.cache.fileAnnotationHeight=t,e=!0)}else!r&&this.cache.fileAnnotationHeight!==0&&(this.cache.fileAnnotationHeight=0,e=!0);for(let t of n.children){if(!(t instanceof HTMLElement))continue;let n=t.dataset.lineIndex;if(n==null)continue;let r=Number(n),i=t.getBoundingClientRect().height,a=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(a=!0),i+=t.nextElementSibling.getBoundingClientRect().height);let o=this.getLineHeight(r,a);i!==o&&(e=!0,i===this.metrics.lineHeight*(a?2:1)?this.cache.heights.delete(r):this.cache.heights.set(r,i))}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer==null||this.file==null?!1:(e&&(this.top=this.getVirtualizedTop()),this.render({file:this.file}));prepareCodeViewItem(e,t,n,r){let i=this.syncLineAnnotations(r),a=!L(this.file,e)||this.fileRenderer.hasUnkeyedFileContentsChanged(e),o=n?.resetFileLayoutCache===!0||a||i;n?.metrics!=null&&(this.metrics=n.metrics,o=!0);let{collapsed:s=!1}=this.options;return this.currentCollapsed!==s&&(this.currentCollapsed=s,o=!0),o&&this.resetLayoutCache(),this.file!==e&&(this.layoutDirty=!0),this.file=e,this.top=t,this.computeApproximateSize(),this.height}getLinePosition(e){if(this.file==null||e<1)return;let{disableFileHeader:t=!1,collapsed:n=!1}=this.options,r=this.fileRenderer.getLineCount(this.file)-1,i=F(this.metrics,t);if(n||r<0)return{top:i,height:0};let a=Math.min(Math.max(e-1,0),r),{overflow:o=`scroll`}=this.options,{lineHeight:s}=this.metrics;if(i+=this.cache.fileAnnotationHeight,o===`scroll`&&!this.hasLineAnnotations())return{top:i+a*s,height:s};let c=this.getLayoutCheckpointBeforeLineIndex(a);i=c?.top??i;for(let e=c?.lineIndex??0;e<a;e++)i+=this.getLineHeight(e,!1);return{top:i,height:this.getLineHeight(a,!1)}}getEditorViewport(){return this.virtualizer.type===`simple`?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){if(this.file==null||this.renderRange==null)return;let{disableFileHeader:t=!1,collapsed:n=!1,overflow:r=`scroll`}=this.options;if(n||this.renderRange.totalLines<=0)return;let i=this.fileRenderer.getLineCount(this.file)-1;if(i<0)return;let a=F(this.metrics,t),o=Math.min(this.renderRange.startingLine,i),s=Math.min(o+this.renderRange.totalLines-1,i);if(s<o)return;let{fileAnnotationHeight:c}=this.cache;if(r===`scroll`&&!this.hasLineAnnotations()){let{lineHeight:t}=this.metrics,n=a+(o===0?c:this.renderRange.bufferBefore),r=o+Math.max(Math.ceil((e-n)/t),0);return r>s?void 0:{lineNumber:r+1,top:a+c+r*t}}let l=a+(o===0?c:this.renderRange.bufferBefore);for(let t=o;t<=s;t++){if(l>=e)return{lineNumber:t+1,top:l};l+=this.getLineHeight(t)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){if(this.top==null||this.file==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let t=e==null?this.renderRange:this.computeRenderRangeFromWindow(this.file,this.top,e);if(t==null)return;let{bufferBefore:n,bufferAfter:r,totalLines:i}=t,a=0;if(i===0){let t=e??this.virtualizer.getWindowSpecs();this.top<t.top&&(a=r)}return{topOffset:this.top+n+a,height:this.height-(n+r)}}cleanUp(e=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||this.resetLayoutCache(),this.isSetup=!1,super.cleanUp(e)}computeApproximateSize(e=!1,t=this.file){let n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;let r=this.height===0;if(this.height=0,this.cache.checkpoints=[],t==null){this.layoutDirty=!1;return}let{disableFileHeader:i=!1,collapsed:a=!1,overflow:o=`scroll`}=this.options,{lineHeight:s}=this.metrics,c=this.fileRenderer.getLineCount(t),l=F(this.metrics,i),u=X(this.metrics);if(this.height+=l,a){this.layoutDirty=!1;return}if(this.height+=this.cache.fileAnnotationHeight,o===`scroll`&&!this.hasLineAnnotations())this.height+=c*s;else for(let e=0;e<c;e++)this.addLayoutCheckpoint(e,this.height),this.height+=this.getLineHeight(e,!1);if(c>0&&(this.height+=u),this.fileContainer!=null&&n&&!r){let e=this.fileContainer.getBoundingClientRect();e.height===this.height?console.log(`VirtualizedFile.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFile.computeApproximateSize: computed height doesnt match`,{name:t.name,elementHeight:e.height,computedHeight:this.height})}this.layoutDirty=!1}setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.file==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(e,t,n=!1){let{renderRange:r}=this;if(this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(this.isSimpleMode(),!1),!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&r!==void 0&&this.file!==void 0){let e=this.virtualizer.getWindowSpecs(),t=this.computeRenderRangeFromWindow(this.file,this.top??0,e);t.bufferAfter!==r.bufferAfter&&this.updateBuffers(t)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}renderPreparedFile({fileContainer:e,file:t,forceRender:n=!1,lineAnnotations:r,...i}){let a=this.file==null||!L(this.file,t)||this.fileRenderer.hasUnkeyedFileContentsChanged(t),{forceRenderOverride:o,isSetup:s}=this;this.forceRenderOverride=void 0;let c=this.syncLineAnnotations(r);if(c&&this.resetLayoutCache(),e=this.getOrCreateFileContainerNode(e),t==null)return console.error(`VirtualizedFile.render: attempting to virtually render when we dont have file`),!1;if(s)this.top??=this.getVirtualizedTop(),a&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(!1),this.computeApproximateSize(!1,t));else{this.computeApproximateSize(!1,t);let n=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(n==null)throw Error(`VirtualizedFile.render: simple virtualizer is not available`);n.connect(e,this),this.isVisible=n.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!a||!s))return this.file=t,a&&(this.cachedHeaderHTML=void 0),this.renderPlaceholder(this.height);let l=this.virtualizer.getWindowSpecs(),u=this.top??0,d=this.computeRenderRangeFromWindow(t,u,l),f=super.renderPreparedFile({file:t,fileContainer:e,renderRange:d,lineAnnotations:r,forceRender:(o??n)||c||a,...i});return this.isSimpleMode()&&f&&this.getSimpleVirtualizer()?.requestHeightReconcile(this),f}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`}addLayoutCheckpoint(e,t){e%Ce===0&&this.cache.checkpoints.push({lineIndex:e,top:t})}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFile: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFile: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFile: invalid checkpoint index`);if(n.lineIndex%t===0)return n}}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}getSimpleVirtualizer(){return this.virtualizer.type===`simple`?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type===`advanced`?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,overflow:a=`scroll`}=this.options,{hunkLineCount:o,lineHeight:s}=this.metrics,c=this.fileRenderer.getLineCount(e),l=this.height,u=F(this.metrics,i),d=c>0?X(this.metrics):0,{fileAnnotationHeight:f}=this.cache,m=u+f,h=Math.max(0,l-u-f-d),g=p(this.lineAnnotations),_=t+u,v=f>0&&g&&_<r&&_+f>n;if(t<n-l||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-u-d};if(c<=o)return{startingLine:0,totalLines:o,bufferBefore:0,bufferAfter:0};let y=Math.ceil(Math.max(r-n,0)/s),b=Math.ceil(y/o)*o+o,x=b/o,S=(n+r)/2;if(a===`scroll`&&!this.hasLineAnnotations()){let e=t+m,i=e+h;if(!v&&!(e<r&&i>n))return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-u-d};let a=Math.floor(v&&S<t+m?0:(S-(t+m))/s),p=Math.floor(a/o)-Math.floor(x/2),g=Math.ceil(c/o),_=Math.max(0,Math.min(p,g))*o,y=p<0?b+p*o:b,C=_===0?0:f+_*s,w=Math.min(y,c-_);return{startingLine:_,totalLines:y,bufferBefore:C,bufferAfter:Math.max(0,(c-_-w)*s)}}let C=x,w=[],T=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-b*s*2),o),E=t+(T?.top??m),D=T?.lineIndex??0,O,k,A,j=T?.lineIndex??0;for(let e=j;e<c;e++){let i=D%o===0,a=Math.floor(D/o);if(i&&(w[a]=E-(t+m),A!=null)){if(A<=0)break;A--}let s=this.getLineHeight(e,!1);E>n-s&&E<r&&(O??=a),E+s>S&&(k??=a),A==null&&E>=r&&i&&(A=C),D++,E+=s}if(O==null)if(v)O=0,k=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-u-d};k??=O;let M=Math.round(k-x/2),N=Math.max(0,Math.ceil(c/o)-x),P=Math.max(0,Math.min(M,N)),I=P*o,L=M<0?b+M*o:b,R=w[P]??0,z=I===0?0:f+R,B=P+L/o,V=B<w.length?h-w[B]:h-(E-t-m);return{startingLine:I,totalLines:L,bufferBefore:z,bufferAfter:Math.max(0,V)}}};function De(e){let t;for(let n of e.children)n instanceof HTMLElement&&n.dataset.lineAnnotation===a&&(t=Math.max(t??0,n.getBoundingClientRect().height));return t}var $=e();function Oe({file:e,renderCustomHeader:t,renderHeaderPrefix:r,renderHeaderFilenameSuffix:i,renderHeaderMetadata:a,renderAnnotation:o,lineAnnotations:s,renderGutterUtility:c,getHoveredLine:l}){let u=t?.(e),d=r?.(e),f=i?.(e),p=a?.(e);return(0,$.jsxs)($.Fragment,{children:[u==null?(0,$.jsxs)($.Fragment,{children:[d!=null&&(0,$.jsx)(`div`,{slot:`header-prefix`,children:d}),f!=null&&(0,$.jsx)(`div`,{slot:`header-filename-suffix`,children:f}),p!=null&&(0,$.jsx)(`div`,{slot:`header-metadata`,children:p})]}):(0,$.jsx)(`div`,{slot:n,children:u}),o!=null&&s?.map((e,t)=>(0,$.jsx)(`div`,{slot:M(e),children:o(e)},t)),c!=null&&(0,$.jsx)(`div`,{slot:`gutter-utility-slot`,style:le,children:c(l)})]})}export{Ee as n,be as r,Oe as t};
2
- //# sourceMappingURL=renderFileChildren-DgVcYeGG.js.map