@p4code/cli 0.7.6 → 0.7.7

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.
@@ -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 M,ki as N,n as te,q as ne,r as re,vp as ie,zi as ae}from"./textarea-BCO9fIHa.js";import{$ as oe,$n as P,$r as F,B as I,Br as L,Cr as R,E as se,Ei as ce,F as z,Fi as le,Gi as ue,Gr as B,Hr as V,I as de,Jr as H,Ki as fe,Kr as pe,L as U,Qn as W,R as G,Rr as me,Ti as he,Ur as K,V as q,Vr as J,Wr as Y,Xr as X,Yr as ge,Zn as _e,Zr as ve,_i as ye,a as be,ai as xe,bi as Se,br as Ce,c as we,d as Te,ei as Ee,er as De,et as Oe,i as ke,ii as Ae,ji as je,l as Me,m as Ne,n as Pe,ni as Fe,o as Ie,qr as Le,r as Re,ri as ze,s as Be,t as Ve,ti as He,tr as Ue,tt as We,u as Ge,vi as Ke,wi as qe,xi as Je,z as Ye,zr as Xe}from"./index-BhrwhrFa.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,M]=(0,Q.useState)(n),[N,te]=(0,Q.useState)(!1),re;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(re=[],t[0]=re):re=t[0];let[ie,ae]=(0,Q.useState)(re),[P,F]=(0,Q.useState)(-1),I=(0,Q.useId)(),L;t[1]!==j||t[2]!==ie||t[3]!==N||t[4]!==n?(L=N&&j!==n?Ge(ie,j):[],t[1]=j,t[2]=ie,t[3]=N,t[4]=n,t[5]=L):L=t[5];let R=L,se,ce;t[6]===f?(se=t[7],ce=t[8]):(se=()=>{if(f==null)return;let e=A.current;e&&e.focus()},ce=[f],t[6]=f,t[7]=se,t[8]=ce),(0,Q.useEffect)(se,ce);let z;t[9]!==P||t[10]!==j||t[11]!==g||t[12]!==R?(z=e=>{e?.preventDefault();let t=R[P]?.url??j.trim();t.length!==0&&(g(t),A.current?.blur())},t[9]=P,t[10]=j,t[11]=g,t[12]=R,t[13]=z):z=t[13];let B=z,V=o?p:et,de=!o,H;t[14]!==V||t[15]!==de?(H=(0,$.jsx)(s,{variant:`ghost`,size:`icon-xs`,onClick:V,disabled:de,"aria-label":`Back`,type:`button`}),t[14]=V,t[15]=de,t[16]=H):H=t[16];let pe;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,$.jsx)(fe,{}),t[17]=pe):pe=t[17];let U;t[18]===H?U=t[19]:(U=(0,$.jsx)(ne,{render:H,children:pe}),t[18]=H,t[19]=U);let W;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(u,{children:`Back`}),t[20]=W):W=t[20];let G;t[21]===U?G=t[22]:(G=(0,$.jsxs)(T,{children:[U,W]}),t[21]=U,t[22]=G);let me=c?m:et,he=!c,K;t[23]!==me||t[24]!==he?(K=(0,$.jsx)(s,{variant:`ghost`,size:`icon-xs`,onClick:me,disabled:he,"aria-label":`Forward`,type:`button`}),t[23]=me,t[24]=he,t[25]=K):K=t[25];let q;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,$.jsx)(ue,{}),t[26]=q):q=t[26];let J;t[27]===K?J=t[28]:(J=(0,$.jsx)(ne,{render:K,children:q}),t[27]=K,t[28]=J);let Y;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,$.jsx)(u,{children:`Forward`}),t[29]=Y):Y=t[29];let X;t[30]===J?X=t[31]:(X=(0,$.jsxs)(T,{children:[J,Y]}),t[30]=J,t[31]=X);let ge=l?et:h,_e=i?`Stop`:`Refresh`,ve;t[32]!==l||t[33]!==ge||t[34]!==_e?(ve=(0,$.jsx)(s,{variant:`ghost`,size:`icon-xs`,onClick:ge,disabled:l,"aria-label":_e,type:`button`}),t[32]=l,t[33]=ge,t[34]=_e,t[35]=ve):ve=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)(ye,{className:xe}),t[38]=xe,t[39]=Se);let Ce;t[40]!==ve||t[41]!==Se?(Ce=(0,$.jsx)(ne,{render:ve,children:Se}),t[40]=ve,t[41]=Se,t[42]=Ce):Ce=t[42];let we=i?`Loading…`:`Refresh`,Te;t[43]===we?Te=t[44]:(Te=(0,$.jsx)(u,{children:we}),t[43]=we,t[44]=Te);let Ee;t[45]!==Ce||t[46]!==Te?(Ee=(0,$.jsxs)(T,{children:[Ce,Te]}),t[45]=Ce,t[46]=Te,t[47]=Ee):Ee=t[47];let De;t[48]!==G||t[49]!==X||t[50]!==Ee?(De=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`Navigation`,children:[G,X,Ee]}),t[48]=G,t[49]=X,t[50]=Ee,t[51]=De):De=t[51];let ke=N?j:r??n,Ae=_&&!N&&`group-hover/address:pe-7 transition-[padding]`,je;t[52]===Ae?je=t[53]:(je=x(Ae),t[52]=Ae,t[53]=je);let Ne;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=e=>{M(e.target.value),F(-1)},t[54]=Ne):Ne=t[54];let Pe;t[55]===n?Pe=t[56]:(Pe=()=>{M(n),ae(Me()),F(-1),te(!0),queueMicrotask(()=>A.current?.select())},t[55]=n,t[56]=Pe);let Fe;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=()=>{te(!1)},t[57]=Fe):Fe=t[57];let Ie;t[58]!==B||t[59]!==R.length||t[60]!==n?(Ie=e=>{if(e.key===`Enter`&&B(e),(e.key===`ArrowDown`||e.key===`ArrowUp`)&&R.length>0){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;F(e=>{let n=e+t;return n>=R.length?-1:n<-1?R.length-1:n})}e.key===`Escape`&&(e.preventDefault(),M(n),A.current?.blur())},t[58]=B,t[59]=R.length,t[60]=n,t[61]=Ie):Ie=t[61];let Le=R.length>0,Re=P>=0?`${I}-${P}`:void 0,ze;t[62]!==d||t[63]!==I||t[64]!==ke||t[65]!==je||t[66]!==Pe||t[67]!==Ie||t[68]!==Le||t[69]!==Re?(ze=(0,$.jsx)(ne,{render:(0,$.jsx)(We,{ref:A,value:ke,className:je,onChange:Ne,onFocus:Pe,onBlur:Fe,onKeyDown:Ie,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":Le,"aria-controls":I,"aria-activedescendant":Re,placeholder:`Search or enter URL`,spellCheck:!1,disabled:d,"data-preview-url-input":!0,size:`sm`})}),t[62]=d,t[63]=I,t[64]=ke,t[65]=je,t[66]=Pe,t[67]=Ie,t[68]=Le,t[69]=Re,t[70]=ze):ze=t[70];let Be;t[71]!==r||t[72]!==N||t[73]!==n?(Be=!N&&r?(0,$.jsx)(u,{children:n}):null,t[71]=r,t[72]=N,t[73]=n,t[74]=Be):Be=t[74];let Ve;t[75]!==ze||t[76]!==Be?(Ve=(0,$.jsxs)(T,{children:[ze,Be]}),t[75]=ze,t[76]=Be,t[77]=Ve):Ve=t[77];let He;t[78]!==N||t[79]!==_?(He=_&&!N?(0,$.jsx)(Oe,{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)(ne,{render:(0,$.jsx)(s,{variant:`ghost`,size:`icon-xs`,onClick:_,"aria-label":`Open in system browser`,type:`button`}),children:(0,$.jsx)(le,{})}),(0,$.jsx)(u,{children:`Open in system browser`})]})}):null,t[78]=N,t[79]=_,t[80]=He):He=t[80];let Ue;t[81]!==Ve||t[82]!==He?(Ue=(0,$.jsxs)(oe,{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:[Ve,He]}),t[81]=Ve,t[82]=He,t[83]=Ue):Ue=t[83];let Ke;t[84]!==w||t[85]!==E||t[86]!==D||t[87]!==O?(Ke=w?(0,$.jsxs)(T,{children:[(0,$.jsx)(ne,{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)(qe,{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]=Ke):Ke=t[88];let Ye;t[89]!==y||t[90]!==v||t[91]!==b?(Ye=v?(0,$.jsxs)(T,{children:[(0,$.jsxs)(ne,{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)(ne,{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)(Je,{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]!==B||t[98]!==De||t[99]!==Ue||t[100]!==Ke||t[101]!==Ye||t[102]!==Xe||t[103]!==k?(Qe=(0,$.jsxs)(`form`,{onSubmit:B,className:`surface-subheader gap-1 px-2`,"data-surface-subheader":!0,children:[De,Ue,Ke,Ye,Xe,k]}),t[97]=B,t[98]=De,t[99]=Ue,t[100]=Ke,t[101]=Ye,t[102]=Xe,t[103]=k,t[104]=Qe):Qe=t[104];let $e;t[105]!==P||t[106]!==g||t[107]!==R||t[108]!==I?($e=R.length>0?(0,$.jsx)(`ul`,{id:I,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:`${I}-${t}`,role:`option`,"aria-selected":t===P,onMouseDown:nt,onClick:()=>{g(e.url),A.current?.blur()},onMouseEnter:()=>F(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]=P,t[106]=g,t[107]=R,t[108]=I,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=X(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:Le(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:`||!H(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)(_e,{children:[(0,$.jsx)(P,{variant:`icon`,children:(0,$.jsx)(je,{className:`size-4.5 text-muted-foreground`})}),(0,$.jsx)(De,{children:`No preview yet`}),(0,$.jsx)(W,{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});we(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)(F,{open:e.open,onOpenChange:e.onOpenChange,children:(0,$.jsxs)(Ae,{className:`max-w-md`,children:[(0,$.jsxs)(Fe,{children:[(0,$.jsx)(xe,{children:`Import from Chrome`}),(0,$.jsx)(Ee,{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)(ze,{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)(He,{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)(ne,{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`,M;t[15]!==h||t[16]!==j||t[17]!==b?(M=(0,$.jsx)(g,{onClick:h,disabled:b,children:j}),t[15]=h,t[16]=j,t[17]=b,t[18]=M):M=t[18];let te=l?`Hide device toolbar`:`Show device toolbar`,re;t[19]!==d||t[20]!==te||t[21]!==b?(re=(0,$.jsx)(g,{onClick:d,disabled:b,children:te}),t[19]=d,t[20]=te,t[21]=b,t[22]=re):re=t[22];let ie;t[23]===b?ie=t[24]:(ie=(0,$.jsx)(ee,{disabled:b,children:`Appearance`}),t[23]=b,t[24]=ie);let oe;t[25]===n?oe=t[26]:(oe=e=>{n&&z.setColorScheme(n,e).catch(wt)},t[25]=n,t[26]=oe);let P;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(P=gt.map(Ct),t[27]=P):P=t[27];let F;t[28]!==o||t[29]!==oe?(F=(0,$.jsx)(i,{className:`min-w-32`,children:(0,$.jsx)(c,{value:o,onValueChange:oe,children:P})}),t[28]=o,t[29]=oe,t[30]=F):F=t[30];let I;t[31]!==ie||t[32]!==F?(I=(0,$.jsxs)(ae,{children:[ie,F]}),t[31]=ie,t[32]=F,t[33]=I):I=t[33];let L;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(m,{}),t[34]=L):L=t[34];let R;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(`span`,{children:`Zoom`}),t[35]=R):R=t[35];let se;t[36]===S?se=t[37]:(se=S(z.zoomOut),t[36]=S,t[37]=se);let le;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(ce,{}),t[38]=le):le=t[38];let ue;t[39]!==se||t[40]!==b?(ue=(0,$.jsx)(s,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:se,"aria-label":`Zoom out`,disabled:b,children:le}),t[39]=se,t[40]=b,t[41]=ue):ue=t[41];let B;t[42]===w?B=t[43]:(B=(0,$.jsx)(`span`,{className:`min-w-12 text-center text-xs tabular-nums text-muted-foreground`,children:w}),t[42]=w,t[43]=B);let V;t[44]===S?V=t[45]:(V=S(z.zoomIn),t[44]=S,t[45]=V);let de;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(Se,{}),t[46]=de):de=t[46];let H;t[47]!==V||t[48]!==b?(H=(0,$.jsx)(s,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:V,"aria-label":`Zoom in`,disabled:b,children:de}),t[47]=V,t[48]=b,t[49]=H):H=t[49];let fe;t[50]===S?fe=t[51]:(fe=S(z.resetZoom),t[50]=S,t[51]=fe);let pe;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,$.jsx)(Ke,{}),t[52]=pe):pe=t[52];let U;t[53]!==fe||t[54]!==b?(U=(0,$.jsx)(s,{variant:`ghost`,size:`icon-xs`,type:`button`,onClick:fe,"aria-label":`Reset zoom`,disabled:b,children:pe}),t[53]=fe,t[54]=b,t[55]=U):U=t[55];let W;t[56]!==ue||t[57]!==B||t[58]!==H||t[59]!==U?(W=(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[ue,B,H,U]}),t[56]=ue,t[57]=B,t[58]=H,t[59]=U,t[60]=W):W=t[60];let G;t[61]!==W||t[62]!==b?(G=(0,$.jsxs)(g,{closeOnClick:!1,onClick:St,className:`justify-between`,disabled:b,children:[R,W]}),t[61]=W,t[62]=b,t[63]=G):G=t[63];let me,he,K,q;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,$.jsx)(m,{}),he=(0,$.jsx)(g,{onClick:bt,children:`Clear cookies`}),K=(0,$.jsx)(g,{onClick:vt,children:`Clear cache`}),q=(0,$.jsx)(m,{}),t[64]=me,t[65]=he,t[66]=K,t[67]=q):(me=t[64],he=t[65],K=t[66],q=t[67]);let J;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,$.jsx)(g,{onClick:()=>y(!0),children:`Import from Chrome…`}),t[68]=J):J=t[68];let Y;t[69]!==re||t[70]!==I||t[71]!==G||t[72]!==O||t[73]!==A||t[74]!==M?(Y=(0,$.jsxs)(N,{children:[E,(0,$.jsxs)(_,{align:`end`,sideOffset:6,className:`min-w-56`,children:[O,A,M,re,I,L,G,me,he,K,q,J]})]}),t[69]=re,t[70]=I,t[71]=G,t[72]=O,t[73]=A,t[74]=M,t[75]=Y):Y=t[75];let X;t[76]===v?X=t[77]:(X=(0,$.jsx)(ht,{open:v,onOpenChange:y}),t[76]=v,t[77]=X);let ge;return t[78]!==Y||t[79]!==X?(ge=(0,$.jsxs)($.Fragment,{children:[Y,X]}),t[78]=Y,t[79]=X,t[80]=ge):ge=t[80],ge}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 pe[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:ie}){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=ve.list({environmentId:t.environmentId,input:{threadId:t.threadId}}),r=ve.events({environmentId:t.environmentId,input:{}});return a(e=>{let i=!1,a=0,o=e=>{E(e)&&V(t,e.value)},s=r=>{if(!E(r)||r.value.threadId!==t.threadId)return;let i=J(t).serverEpoch;if(i!==null&&i!==r.value.serverEpoch){e.refresh(n);return}Xe(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(M(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=Te(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)(he,{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=Ie(),f=(0,Q.useRef)(!1),p=(0,Q.useRef)(!0),m=B(e),g=U(t=>de(t.byThreadKey,e)),_=h(e=>e.addPreviewAnnotation),v=h(e=>e.addImage),y=re(e.environmentId),x=j(e.environmentId),S=te(ve.open),ee=te(ve.resize,`preview viewport resize`),{resolvedTheme:w}=R();Vt(e),(0,Q.useEffect)(()=>(p.current=!0,()=>{p.current=!1}),[]);let T=t??m.activeTabId,E=T?G(e,m.serverEpoch,T):null,D=T&&E?u.has(E)?E:Re(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`},N=A._tag===`Idle`?``:A.url,ne=k?.loading??A._tag===`Loading`,ie=k?.canGoBack??O?.canGoBack??!1,ae=k?.canGoForward??O?.canGoForward??!1,oe=A._tag===`Idle`,P=A._tag===`LoadFailed`,F=se(O),L=k?.controller??`none`,ce=Rt(ne),le=N&&y&&x?rt({url:N,environmentLabel:y.label,environmentHttpBaseUrl:x})??void 0:void 0,ue=O?.viewport??l,V=I(e=>E?e.byTabId[E]?.rect??null:null),H=(0,Q.useCallback)(async t=>{E&&z?(await z.navigate(E,t),K(e,t)):await me({openPreview:S,threadRef:e,url:t})},[S,E,e]),fe=(0,Q.useCallback)(async e=>{try{await H(ge(e))}catch{}},[H]),pe=(0,Q.useCallback)(async t=>{try{await H(Le(e.environmentId,t))}catch{}},[H,e.environmentId]),W=(0,Q.useCallback)(()=>{z&&E&&z.refresh(E)},[E]),he=(0,Q.useCallback)(()=>{z&&E&&z.zoomIn(E)},[E]),q=(0,Q.useCallback)(()=>{z&&E&&z.zoomOut(E)},[E]),J=(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}Y(e,n.value)},[ee,T,e]),_e=()=>{if(!E)return;if(ue._tag!==`fill`){Ve(E,l).catch(()=>void 0);return}let e=V?Be(V,k?.zoomFactor):{width:1024,height:768};Ve(E,{_tag:`freeform`,...e}).catch(()=>void 0)};(0,Q.useEffect)(()=>{if(E)return Pe(E,X)},[X,E]);let ye=(0,Q.useCallback)(()=>{z&&E&&z.goBack(E)},[E]),xe=(0,Q.useCallback)(()=>{z&&E&&z.goForward(E)},[E]),Se=(0,Q.useCallback)(()=>{!Yt||!N||Yt.shell.openExternal(N).catch(()=>void 0)},[N]),we=(0,Q.useCallback)(()=>{if(T){if(g?.tabId===T){U.getState().close(e);return}U.getState().open(e,T),C.getState().close(e)}},[g?.tabId,T,e]),Te=(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]),Ee=(0,Q.useCallback)(t=>{if(!z||!E||!T)return;let n=z;if(D){be(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){ke(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]),De=(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 Ne(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=Ce(N,w);e&&H(e).catch(()=>void 0)},[H,w,N]),(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 Ue(e=>{switch(e){case`refresh`:W();return;case`focus-url`:a(e=>(e??0)+1);return;case`zoom-in`:he();return;case`zoom-out`:q();return;case`reset-zoom`:J();return;case`toggle-panel`:return}})},[W,J,he,q,r]),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,"data-thread-key":M(e),children:[(0,$.jsx)(tt,{url:N,displayUrl:le,loading:ne,loadProgress:ce,canGoBack:ie,canGoForward:ae,refreshDisabled:oe,focusUrlNonce:i,onBack:ye,onForward:xe,onRefresh:W,onSubmit:e=>void fe(e),onOpenInBrowser:T?Se:void 0,onCapture:z&&T?Ee:void 0,captureDisabled:!k||P,recording:D!==null,onPictureInPicture:z&&T?we:void 0,pictureInPicture:g?.tabId===T,pictureInPictureDisabled:!k?.hasWebContents||P,onPickElement:z&&T?De:void 0,pickActive:s,pickDisabled:!T||P,pickDisabledReason:P?`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:ue._tag!==`fill`,onToggleDeviceToolbar:_e,nativePictureInPicture:k?.pictureInPicture??!1,onNativePictureInPicture:Te}):null}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[E&&O&&!F?(0,$.jsx)(Ye,{tabId:E,visible:r&&!P,className:`absolute inset-0 h-full w-full`},E):null,F?(0,$.jsx)(pt,{environmentId:e.environmentId,configuredUrls:n,recentlySeenUrls:m.recentlySeenUrls,onOpenUrl:e=>void pe(e)}):null,O&&k?(0,$.jsx)(Wt,{zoomFactor:k.zoomFactor}):null,E&&k&&!F&&!P?(0,$.jsx)(qt,{tabId:E,zoomFactor:k.zoomFactor,controller:L}):null,L===`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:L===`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:W})}):null]})]})}function Zt(e){let t=(0,Z.c)(13),{mode:n,threadRef:r,tabId:i,configuredUrls:a,visible:o}=e;if(!L()){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)(q,{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)(q,{mode:n,children:c}),t[10]=n,t[11]=c,t[12]=l):l=t[12],l}export{Zt as PreviewPanel};
2
- //# sourceMappingURL=PreviewPanel-idbNK1V5.js.map
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{r as t}from"./preload-helper-CEhsl8MR.js";import{n,r,t as i}from"./compiler-runtime-CLAvuQ-D.js";import{Ma as a,Ms as o,Qs as s,Ui as c,Zo as l,es as u,ks as d}from"./textarea-BCO9fIHa.js";import"./entities-E6o8Fydw.js";import{n as f,t as p}from"./renderFileChildren-D88f7MwM.js";import{Cn as m,Dn as h,En as g,Fn as _,Ln as v,Mn as y,On as b,Pn as x,Rn as S,Sn as C,T as w,Tn as T,b as E,ht as D,jn as O,kn as k,mt as A,nt as j,rt as M,sr as ee,w as te,wn as N,wt as P,xn as F,y as ne}from"./index-BhrwhrFa.js";var I=s(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),L=s(`columns-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]]),R=s(`rows-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M21 9H3`,key:`1338ky`}],[`path`,{d:`M21 15H3`,key:`9uk58r`}]]);function z(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function B(e,t){return e==null||t==null?e===t:e.header!==t.header||e.footer!==t.footer?!1:V(e.items,t.items)}function V(e,t){if(e==null||t==null)return e===t;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r==null||i==null||r.id!==i.id||r.type!==i.type||r.element!==i.element||r.instance!==i.instance||r.version!==i.version)return!1}return!0}function re(e,t,n){let r=document.createElement(`div`);return r.style.display=`flow-root`,e===`header`?(r.setAttribute(k,``),t.before(r)):(r.setAttribute(b,``),t.after(r)),n?.observe(r),r}function H(e){let t=window.devicePixelRatio??1;return Math.round(e*t)/t}var U=`theme.disableLineNumbers.overflow.themeType.disableFileHeader.disableVirtualizationBuffers.preferredHighlighter.useCSSClasses.useTokenTransformer.tokenizeMaxLineLength.tokenizeMaxLength.unsafeCSS.diffStyle.diffIndicators.disableBackground.expandUnchanged.loadDiffFiles.collapsedContextThreshold.lineDiffType.maxLineDiffLength.expansionLineCount.lineHoverHighlight.enableTokenInteractionsOnWhitespace.enableGutterUtility.__debugPointerEvents.enableLineSelection.controlledSelection.disableErrorHandling`.split(`.`),W=[`theme`,`disableLineNumbers`,`overflow`,`themeType`,`disableFileHeader`,`disableVirtualizationBuffers`,`preferredHighlighter`,`useCSSClasses`,`useTokenTransformer`,`tokenizeMaxLineLength`,`tokenizeMaxLength`,`unsafeCSS`,`lineHoverHighlight`,`enableTokenInteractionsOnWhitespace`,`enableGutterUtility`,`__debugPointerEvents`,`enableLineSelection`,`controlledSelection`,`disableErrorHandling`],ie=[`renderCustomHeader`,`renderHeaderPrefix`,`renderHeaderFilenameSuffix`,`renderHeaderMetadata`,`renderAnnotation`,`renderGutterUtility`,`onPostRender`,`onGutterUtilityClick`,`onLineClick`,`onLineNumberClick`,`onLineEnter`,`onLineLeave`,`onTokenClick`,`onTokenEnter`,`onTokenLeave`],ae=[`onLineSelected`,`onLineSelectionStart`,`onLineSelectionChange`,`onLineSelectionEnd`],oe=Symbol(`CodeView.itemOptionsState`);function G(e,t){Object.defineProperty(e,oe,{configurable:!1,enumerable:!1,value:t})}function K(e){return e[oe]}function q(e,t,n){Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get(){return n(this)}})}var se=120,ce=1,le=`--diffs-overflow-override`,J=12e6,ue=1e6,de=2e6,fe=J-de,pe=J-ue;function me(e){if(e==null)throw Error(`CodeView: createEditor is required for items with edit: true`)}var he=(()=>{let{navigator:e}=globalThis,t=e.userAgent,n=/iP(?:hone|ad|od)/.test(t),r=e.platform===`MacIntel`&&e.maxTouchPoints>1;return(n||r)&&/AppleWebKit/.test(t)&&/Safari/.test(t)&&!/(CriOS|FxiOS|EdgiOS|OPiOS)/.test(t)})(),ge=class e{static __STOP=!1;static __lastScrollPosition=0;type=`advanced`;config={overscrollSize:200,intersectionObserverMargin:0,resizeDebugging:!1};items=[];idToItem=new Map;selectedLines=null;itemEditors=new Map;attachedEditors=new Set;instanceToItem=new Map;layoutDirtyIndex;pendingLayoutReset;renderOptionsRevision=0;slotCoordinator;slotSnapshot;scrollListeners=new Set;scrollHeight=0;containerHeight=-1;scrollTop=0;scrollPageOffset=0;scrollDirty=!0;scrollInteractionFixTimer;pointerEventsDisabled=!1;codeOverflowFix=!1;height=0;heightDirty=!0;windowSpecs={top:0,bottom:0};renderState={scrollTop:-1,firstIndex:-1,lastIndex:-1,stickyHeight:0,stickyTop:-1,stickyBottom:-1};itemMetricsCache=O;fileOptionsPrototype;diffOptionsPrototype;pendingScrollTarget;pendingLayoutAnchor;shouldFixContainerFocus=!1;scrollAnimation;root;resizeObserver;container=document.createElement(`div`);stickyContainer=document.createElement(`div`);stickyOffset=document.createElement(`div`);header={element:void 0,render:void 0,height:0};footer={element:void 0,render:void 0,height:0};elementPool=[];elementPoolVersion=0;elementPoolTracker=new WeakMap;pendingElementPool=[];options;workerManager;isReadySubscription;isContainerManaged;constructor(e={theme:_},t,n=!1){this.options=e,this.computeMetricsCache(e.itemMetrics),this.fileOptionsPrototype=this.createFileOptionsPrototype(),this.diffOptionsPrototype=this.createDiffOptionsPrototype(),this.workerManager=t,this.isContainerManaged=n,this.stickyOffset.style.contain=`layout size`,this.stickyContainer.style.position=`sticky`,this.stickyContainer.style.width=`100%`,this.stickyContainer.style.contain=`layout style inline-size`,this.stickyContainer.style.isolation=`isolate`,this.stickyContainer.style.display=`flex`,this.stickyContainer.style.flexDirection=`column`}getLayout(){return this.options.layout??y}getItemTopOffset(){return this.getLayout().paddingTop+this.header.height}computeMetricsCache(e){return this.itemMetricsCache={hunkLineCount:e?.hunkLineCount??O.hunkLineCount,lineHeight:e?.lineHeight??O.lineHeight,diffHeaderHeight:e?.diffHeaderHeight??O.diffHeaderHeight,hunkSeparatorHeight:e?.hunkSeparatorHeight,spacing:e?.spacing??O.spacing,paddingTop:e?.paddingTop,paddingBottom:e?.paddingBottom},this.itemMetricsCache}getSmoothScrollSettings(){return this.options.smoothScrollSettings??x}shouldDisablePointerEvents(){return this.options.pointerEventsOnScroll!==!0}shouldValidateItemHeights(){return v&&this.options.__devOnlyValidateItemHeights===!0}validateRenderedItemHeight(e){if(!this.shouldValidateItemHeights()||e.element==null)return;let t=e.instance.getAdvancedStickySpecs();if(t==null)return;let n=t.height,r=e.element.getBoundingClientRect().height;n!==r&&console.error(`CodeView: reconciled item height does not match DOM height`,{id:e.item.id,type:e.type,index:e.index,version:e.version,expectedHeight:n,actualHeight:r,delta:r-n,stickyTopOffset:t.topOffset,virtualizedHeight:e.instance.getVirtualizedHeight(),top:e.top,scrollTop:this.getScrollTop(),windowSpecs:{...this.windowSpecs},element:e.element,instance:e.instance})}validateStickyContainerHeight(){if(!this.shouldValidateItemHeights())return;let{firstIndex:e,lastIndex:t,stickyHeight:n,stickyTop:r,stickyBottom:i}=this.renderState;if(e===-1||t===-1)return;let a=this.stickyContainer.getBoundingClientRect().height;Math.abs(a-n)<ce||console.error(`CodeView: sticky container height does not match computed layout`,{computedStickyHeight:n,actualStickyHeight:a,delta:a-n,stickyTop:r,stickyBottom:i,firstIndex:e,lastIndex:t,firstStickySpecs:this.items[e]?.instance.getAdvancedStickySpecs(),lastStickySpecs:this.items[t]?.instance.getAdvancedStickySpecs(),scrollTop:this.getScrollTop(),scrollPageOffset:this.scrollPageOffset,windowSpecs:{...this.windowSpecs},stickyContainer:this.stickyContainer})}clearScrollInteractionTimer(){this.scrollInteractionFixTimer!=null&&(clearTimeout(this.scrollInteractionFixTimer),this.scrollInteractionFixTimer=void 0)}suspendScrollInteractions(){this.clearScrollInteractionTimer(),this.shouldDisablePointerEvents()&&!this.pointerEventsDisabled&&(this.stickyContainer.style.pointerEvents=`none`,this.pointerEventsDisabled=!0),he&&!this.codeOverflowFix&&(this.stickyContainer.style.setProperty(le,`hidden`),this.codeOverflowFix=!0),this.scrollInteractionFixTimer=setTimeout(this.restoreScrollInteractions,se)}restoreScrollInteractions=()=>{this.clearScrollInteractionTimer(),this.pointerEventsDisabled&&=(this.stickyContainer.style.removeProperty(`pointer-events`),!1),this.codeOverflowFix&&=(this.stickyContainer.style.setProperty(le,`auto`),!1)};syncLayout(){let{gap:e,paddingBottom:t,paddingTop:n}=this.getLayout();this.stickyContainer.style.gap=`${e}px`,this.container?.style.setProperty(`margin-top`,`${n}px`),this.container?.style.setProperty(`margin-bottom`,`${t}px`)}reconcileHeaderFooterHosts(){let e=this.reconcileHost(`header`),t=this.reconcileHost(`footer`);return e||t}reconcileHost(e){let{root:t,container:n}=this;if(t==null||n==null)return!1;let r=e===`header`?this.header:this.footer,i=e===`header`?this.options.renderCodeViewHeader:this.options.renderCodeViewFooter;if(i==null)return r.element==null?!1:(this.resizeObserver?.unobserve(r.element),r.element.remove(),r.element=void 0,r.render=void 0,this.setHostHeight(r,0),!1);if(r.element!=null&&i===r.render)return!1;let a=r.element??re(e,n,this.resizeObserver);r.element=a;let o=i();return o==null?!this.isContainerManaged&&a.children.length>0&&(a.textContent=``):a.replaceChildren(o),r.render=i,!0}setHostHeight(e,t){e.height!==t&&(e.height=t,this.scrollDirty=!0)}measureMountedHosts(){this.header.element!=null&&this.setHostHeight(this.header,this.header.element.getBoundingClientRect().height),this.footer.element!=null&&this.setHostHeight(this.footer,this.footer.element.getBoundingClientRect().height)}setup(t){if(this.root!=null)throw Error(`CodeView.setup: already setup`);this.workerManager?.subscribeToThemeChanges(this),this.root=t,this.root.style.overflowAnchor=`none`,this.root.hasAttribute(`tabindex`)||(this.root.tabIndex=-1),this.container??=document.createElement(`div`),this.container.style.contain=`layout style`,this.syncLayout(),this.container.appendChild(this.stickyOffset),this.container.appendChild(this.stickyContainer),this.root.appendChild(this.container),this.scrollDirty=!0,this.heightDirty=!0,this.resizeObserver=new ResizeObserver(this.handleResize),this.resizeObserver.observe(this.stickyContainer),this.root.addEventListener(`scroll`,this.handleScroll,{passive:!0}),this.root.addEventListener(`wheel`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`touchstart`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`pointerdown`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`keydown`,this.clearPendingScroll,{passive:!0}),this.resizeObserver.observe(this.root),this.render(!0),window.__INSTANCE=this,window.__TOGGLE=()=>{e.__STOP?(e.__STOP=!1,this.scrollTo({type:`position`,position:e.__lastScrollPosition,behavior:`instant`})):(e.__lastScrollPosition=this.getScrollTop(),e.__STOP=!0)}}reset(){g(this.computeRenderRangeAndEmit),this.clearReadySubscription(),this.restoreScrollInteractions(),this.cleanAllRenderedItems();for(let e of this.itemEditors.values())e.editor.cleanUp();this.itemEditors.clear(),this.attachedEditors.clear(),this.selectedLines=null,this.items.length=0,this.idToItem.clear(),this.instanceToItem.clear(),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,this.stickyContainer.textContent=``,this.stickyOffset.style.height=``,this.container?.style.removeProperty(`height`),this.containerHeight=-1,this.windowSpecs={top:0,bottom:0},this.pendingLayoutAnchor=void 0,this.shouldFixContainerFocus=!1,this.height=0,this.scrollTop=0,this.scrollPageOffset=0,this.scrollHeight=0,this.scrollDirty=!0,this.heightDirty=!0,this.resetRenderState(),this.isContainerManaged||this.flushSlotCoordinator()}cleanUp(){this.reset(),this.clearElementPool(),this.restoreScrollInteractions(),this.workerManager?.unsubscribeToThemeChanges(this),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.root?.removeEventListener(`scroll`,this.handleScroll),this.root?.removeEventListener(`wheel`,this.clearPendingScroll),this.root?.removeEventListener(`touchstart`,this.clearPendingScroll),this.root?.removeEventListener(`pointerdown`,this.clearPendingScroll),this.root?.removeEventListener(`keydown`,this.clearPendingScroll),this.root?.style.removeProperty(`overflow-anchor`),this.container?.remove(),this.stickyOffset.remove(),this.stickyContainer.remove(),this.stickyContainer.textContent=``,this.header.element?.remove(),this.header.element=void 0,this.header.render=void 0,this.header.height=0,this.footer.element?.remove(),this.footer.element=void 0,this.footer.render=void 0,this.footer.height=0,this.root=void 0,this.container=void 0}cleanAllRenderedItems(){if(this.renderState.firstIndex!==-1)for(let e=this.renderState.firstIndex;e<=this.renderState.lastIndex;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.cleanAllRenderedItems: Item does not exist at index: ${e}`);this.releaseRenderedItem(t)}}primeScrollTarget(e){e.type!==`position`&&this.idToItem.get(e.id)?.instance.primeHighlightCache()}getElementPoolLimit(){let e=this.getHeight()+this.config.overscrollSize*2,{diffHeaderHeight:t}=this.itemMetricsCache;return Math.max(8,Math.ceil(e/Math.max(t,10))+1)*(this.isContainerManaged?2:1)}acquireElement(){this.promotePendingPooledElements();let e=this.elementPool.pop();for(;e!=null&&!this.isElementPoolGenerationCurrent(e);)e=this.elementPool.pop();return e??=document.createElement(S),this.markElementPoolGenerationCurrent(e),e}releaseRenderedItem(e){let{element:t}=e;t!=null&&this.renderedItemOwnsFocus(t)&&(this.shouldFixContainerFocus=!0),e.instance.cleanUp(!0),this.attachedEditors.delete(e.item.id),e.element=void 0,t!=null&&(t.remove(),this.cleanElement(t),this.queueElementForPool(t))}renderedItemOwnsFocus(e){let{activeElement:t}=document;return t===e||e.contains(t)||e.shadowRoot?.activeElement!=null}fixContainerFocus(){this.shouldFixContainerFocus&&(this.shouldFixContainerFocus=!1,this.root?.focus({preventScroll:!0}))}cleanElement(e){let{shadowRoot:t}=e;if(t!=null)for(let e of Array.from(t.children))xe(e)||e.remove();this.isContainerManaged||e.replaceChildren()}queueElementForPool(e){let t=this.getElementPoolLimit();!this.isElementPoolGenerationCurrent(e)||this.getElementPoolSize()>=t||(this.isElementClean(e)?this.elementPool.push(e):this.pendingElementPool.push(e))}promotePendingPooledElements(){if(this.pendingElementPool.length===0)return;let{pendingElementPool:e}=this;this.pendingElementPool=[];let t=this.getElementPoolLimit();for(let n of e)this.isElementPoolGenerationCurrent(n)&&this.isElementClean(n)&&this.elementPool.length<t?this.elementPool.push(n):this.isElementPoolGenerationCurrent(n)&&this.getElementPoolSize()<t&&this.pendingElementPool.push(n)}isElementClean(e){return e.childNodes.length===0}getElementPoolSize(){return this.elementPool.length+this.pendingElementPool.length}clearElementPool(){this.elementPool.length=0,this.pendingElementPool.length=0}invalidateElementPool(){this.elementPoolVersion++,this.clearElementPool()}markElementPoolGenerationCurrent(e){this.elementPoolTracker.set(e,this.elementPoolVersion)}isElementPoolGenerationCurrent(e){return this.elementPoolTracker.get(e)===this.elementPoolVersion}resolveEffectiveScrollBehavior(e,t){return z()?`instant`:e.behavior===`smooth-auto`?Math.abs(t-this.getScrollTop())<=this.getHeight()*10?`smooth`:`instant`:e.behavior??`instant`}scrollTo(e){if(this.root==null)return;let t=this.normalizeScrollTarget(e);if(t==null)return;let n=this.resolveScrollTargetTop(t);n!=null&&(this.primeScrollTarget(t),this.resolveEffectiveScrollBehavior(t,n)===`smooth`?this.scrollAnimation??={position:this.getScrollTop(),velocity:0,lastTimestamp:performance.now()}:this.scrollAnimation=void 0,this.suspendScrollInteractions(),this.pendingLayoutAnchor=void 0,this.pendingScrollTarget=t,this.render())}setSelectedLines(e,t){this.applySelectedLines(e,t)}getSelectedLines(){return this.selectedLines}clearSelectedLines(e){this.applySelectedLines(null,e)}getItem(e){return this.idToItem.get(e)?.item}getEditor(e){return this.itemEditors.get(e)?.editor}updateItem(e){let t=this.idToItem.get(e.id);return t==null?(console.error(`CodeView.updateItem: unknown item id "${e.id}"`),!1):this.syncItemRecord(t,e)?(this.markItemLayoutDirty(t),this.scrollDirty=!0,this.render(),this.syncItemEditors(),this.syncSelection(),!0):!1}updateItemId(e,t){if(e===t)return!0;let n=this.idToItem.get(e);if(n==null)return console.error(`CodeView.updateItemId: unknown item id "${e}"`),!1;if(this.idToItem.has(t))return console.error(`CodeView.updateItemId: duplicate item id "${t}"`),!1;this.idToItem.delete(e),n.item.id=t,this.idToItem.set(t,n),this.updateItemOptionsId(n.instance.options,t),this.selectedLines?.id===e&&(this.selectedLines={...this.selectedLines,id:t},this.options.onSelectedLinesChange?.(this.selectedLines));let r=this.itemEditors.get(e);return r!=null&&(r.state.id=t,this.itemEditors.delete(e),this.itemEditors.set(t,r),this.attachedEditors.delete(e)&&this.attachedEditors.add(t)),this.renamePendingScrollTarget(e,t),this.renamePendingLayoutAnchor(e,t),this.render(),!0}addItem(e){this.addItems([e])}addItems(e){this.appendItemsInternal(e),this.syncItemEditors(),this.syncSelection()}removeItem(e){let t=this.idToItem.get(e);if(t==null)return console.error(`CodeView.removeItem: unknown item id "${e}"`),!1;let n=[];for(let e of this.items)e!==t&&n.push(e.item);return this.setItems(n),!0}setItems(e){let t;this.items.length===0?this.appendItemsInternal(e):this.tryAppendItems(e)||(t=this.reconcileItems(e)),this.syncItemEditors(t),this.syncSelection()}appendItemsInternal(e,t=!0){if(e.length===0)return;let n=this.getLayout(),r=this.items.length===0?0:this.scrollHeight+n.gap,i=r;for(let t=0;t<e.length;t++){let i=e[t];if(i==null)throw Error(`CodeView.appendItemsInternal: missing input item`);if(this.idToItem.has(i.id))throw Error(`CodeView.addItem: duplicate id "${i.id}"`);let a=this.createItem(i,this.items.length,r);this.items.push(a),this.idToItem.set(a.item.id,a),this.instanceToItem.set(a.instance,a),a.height=_e(a),r+=a.height+n.gap}this.scrollHeight=r-n.gap,this.scrollDirty=!0,t&&(this.canSkipRenderForAppend(i)?this.syncContainerHeight():this.render())}canSkipRenderForAppend(e){return this.container!=null&&this.renderState.firstIndex!==-1&&this.pendingScrollTarget==null&&this.scrollAnimation==null&&this.layoutDirtyIndex==null&&e>this.windowSpecs.bottom}onThemeChange(){this.invalidateElementPool()}setOptions(e){if(e==null)return;this.capturePendingLayoutAnchor();let{options:t}=this,n=this.getLayout(),{itemMetricsCache:r}=this;ve(t,e)&&this.invalidateElementPool(),this.options=e;let i=this.computeMetricsCache(e.itemMetrics),a=!T(r,i),o=!T(n,this.getLayout());o&&this.syncLayout();let s=a||ye(t,e);if(s){let n=this.pendingLayoutReset;this.pendingLayoutReset={metrics:a?i:n?.metrics,resetFileLayoutCache:!0,resetDiffLayoutCache:!0,includeEstimatedDiffHeights:n?.includeEstimatedDiffHeights===!0||a||be(t,e)}}(o||s)&&(this.markLayoutDirtyFromIndex(0),this.scrollDirty=!0),m(t,e)||this.renderOptionsRevision++,this.syncItemEditors();let c=t.renderCodeViewHeader!==e.renderCodeViewHeader||t.renderCodeViewFooter!==e.renderCodeViewFooter;!this.isContainerManaged&&(this.items.length>0||c)&&this.render()}capturePendingLayoutAnchor(e=this.idToItem){this.root==null||this.items.length===0||this.pendingScrollTarget!=null||(this.pendingLayoutAnchor=this.getScrollAnchor(this.getScrollTop(),e))}render(t=!1){e.__STOP||(t?(g(this.computeRenderRangeAndEmit),this.computeRenderRangeAndEmit()):h(this.computeRenderRangeAndEmit))}isReady(){let{workerManager:e}=this;return e==null||e.isInitialized()||e.getStats().workersFailed?(this.clearReadySubscription(),!0):(this.isReadySubscription??=e.subscribeToStatChanges(e=>{e.managerState!==`initialized`&&!e.workersFailed||(this.clearReadySubscription(),this.render(!0))}),e.getStats().managerState===`waiting`&&e.initialize().catch(()=>{}),!1)}clearReadySubscription(){this.isReadySubscription!=null&&(this.isReadySubscription(),this.isReadySubscription=void 0)}instanceChanged(e,t){let n=this.instanceToItem.get(e);if(n==null)throw Error(`CodeView.instanceChanged: An instance has changed that is not registered`);t&&this.markItemLayoutDirty(n),this.render()}getWindowSpecs(){return this.windowSpecs}getContainerElement(){return this.root}getHeaderElement(){return this.header.element}getFooterElement(){return this.footer.element}getRenderedItems(){let{firstIndex:e,lastIndex:t}=this.renderState;if(e===-1||t===-1||t<e)return[];let n=[];for(let r=e;r<=t;r++){let e=this.items[r];e?.element!=null&&(e.type===`diff`?n.push({id:e.item.id,type:`diff`,item:e.item,version:e.version,element:e.element,instance:e.instance}):n.push({id:e.item.id,type:`file`,item:e.item,version:e.version,element:e.element,instance:e.instance}))}return n}setSlotCoordinator(e){return e===this.slotCoordinator?!1:(this.slotCoordinator=e,this.slotSnapshot=void 0,!0)}getSlotSnapshot(e){return this.buildSlotSnapshot(e)}buildSlotSnapshot(e){let t=De(this.getRenderedItems(),e),{element:n}=this.header,{element:r}=this.footer;if(!(t==null&&n==null&&r==null))return{items:t,header:n,footer:r}}subscribeToScroll(e){return this.scrollListeners.add(e),()=>{this.scrollListeners.delete(e)}}getLocalTopForInstance(e){let t=this.instanceToItem.get(e);if(t==null)throw Error(`CodeView.getLocalTopForInstance: unknown virtualized instance`);return t.top}getTopForItem(e){let t=this.idToItem.get(e);if(t!=null)return t.top+this.getItemTopOffset()}createItem(e,t,n){let{itemMetricsCache:r}=this;if(e.type===`diff`){let i=new A(this.createDiffOptions(e.id),this,r,this.workerManager,this.isContainerManaged);return{type:`diff`,item:e,version:e.version,index:t,top:n,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:i}}let i=new f(this.createFileOptions(e.id),this,r,this.workerManager,this.isContainerManaged);return{type:`file`,item:e,version:e.version,index:t,top:n,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:i}}applySelectedLines(e,t){let{selectedLines:n}=this;e==null&&n==null||e!=null&&n?.id===e.id&&C(n.range,e.range)||(n!=null&&n.id!==e?.id&&this.idToItem.get(n.id)?.instance.setSelectedLines(null,{notify:!1}),this.selectedLines=e,this.idToItem.get(e?.id??``)?.instance.setSelectedLines(e?.range??null,t))}syncSelection(){if(this.selectedLines==null)return;let e=this.idToItem.get(this.selectedLines.id);if(e==null){this.selectedLines=null,this.options.onSelectedLinesChange?.(null);return}e.instance.setSelectedLines(this.selectedLines.range,{notify:!1})}isItemInEditMode(e){return e.item.edit===!0&&e.item.collapsed!==!0}attachItemEditor(e){let{id:t}=e.item,{createEditor:n}=this.options;if(e.element==null||this.attachedEditors.has(t)||!this.isItemInEditMode(e))return;let r=this.itemEditors.get(t),i=!1;try{if(r==null){me(n);let e={id:t},a=n({onChange:(t,n)=>{let r=this.idToItem.get(e.id);r!=null&&(e.lastChange={item:r.item,file:t,lineAnnotations:n},this.options.onItemEditChange?.(r.item,t,n))}});if(a==null)return;r={editor:a,state:e},this.itemEditors.set(t,r),i=!0}r.editor.edit(e.instance),this.attachedEditors.add(t)}catch(n){throw i&&r!=null&&(this.itemEditors.delete(t),r.editor.cleanUp()),this.releaseRenderedItem(e),n}}syncItemEditors(e){if(this.itemEditors.size===0)return;let t=[];for(let[n,r]of this.itemEditors){let i=this.idToItem.get(n),a=e?.get(n);if(a==null&&i!=null&&this.isItemInEditMode(i))continue;r.editor.cleanUp(),this.itemEditors.delete(n),this.attachedEditors.delete(n);let{lastChange:o}=r.state,s=a==null?i?.item??o?.item:o?.item??a.item;s?.type===`diff`&&(a==null&&i!=null&&i.type===`diff`&&i.instance.completeEditSession()&&(this.markItemLayoutDirty(i),this.render()),D(s.fileDiff)),o!=null&&t.push(a!=null||i==null?o:{...o,item:i.item})}for(let{item:e,file:n,lineAnnotations:r}of t)this.options.onItemEditComplete?.(e,n,r)}renamePendingScrollTarget(e,t){let{pendingScrollTarget:n}=this;n==null||n.type===`position`||n.id!==e||(this.pendingScrollTarget={...n,id:t})}renamePendingLayoutAnchor(e,t){this.pendingLayoutAnchor?.id===e&&(this.pendingLayoutAnchor.id=t)}createFileOptionsPrototype(){let e={};for(let t of W)q(e,t,()=>this.options[t]);q(e,`stickyHeader`,()=>this.options.stickyHeaders),q(e,`collapsed`,e=>{let t=K(e);if(t!=null)return this.getItemOptions(t,`file`)?.item.collapsed});for(let t of ie)this.defineItemSharedCallback(e,`file`,t);for(let t of ae)this.defineItemSelectionCallback(e,`file`,t);return e}createDiffOptionsPrototype(){let e={};for(let t of U)q(e,t,()=>this.options[t]);q(e,`stickyHeader`,()=>this.options.stickyHeaders),q(e,`hunkSeparators`,()=>this.options.hunkSeparators),q(e,`collapsed`,e=>{let t=K(e);if(t!=null)return this.getItemOptions(t,`diff`)?.item.collapsed});for(let t of ie)this.defineItemSharedCallback(e,`diff`,t);for(let t of ae)this.defineItemSelectionCallback(e,`diff`,t);return e}createFileOptions(e){let t=Object.create(this.fileOptionsPrototype);return G(t,{id:e}),t}createDiffOptions(e){let t=Object.create(this.diffOptionsPrototype);return G(t,{id:e}),t}updateItemOptionsId(e,t){let n=K(e);if(n==null)throw Error(`CodeView.updateItemOptionsId: No valid state`);n.id=t}getItemOptions(e,t){let n=this.idToItem.get(e.id);if(!(n==null||n.type!==t))return n}defineItemSharedCallback(e,t,n){q(e,n,e=>{if(this.options[n]==null)return;let r=K(e);if(r==null)return;let i=r.callbackCache??={},a=i[n];return a??(a=((...e)=>{let i=this.getItemOptions(r,t);if(i==null)return;let a=this.options[n];return a?.(...e,i)}),i[n]=a),a})}defineItemSelectionCallback(e,t,n){q(e,n,e=>{let r=K(e);if(r==null)return;let i=r.callbackCache??={},a=i[n];return a??(a=(e=>{let i=this.getItemOptions(r,t);if(i==null)return;let a=e==null?null:{id:i.item.id,range:e};this.options.controlledSelection!==!0&&(e!=null||this.selectedLines?.id===i.item.id)&&this.applySelectedLines(a,{notify:!1}),this.options.onSelectedLinesChange?.(a);let o=this.options[n];return o?.(e,i)}),i[n]=a),a})}markLayoutDirtyFromIndex(e){this.layoutDirtyIndex=Math.min(this.layoutDirtyIndex??e,e)}markItemLayoutDirty(e){if(this.items[e.index]!==e)throw Error(`CodeView.markItemLayoutDirty: unknown item id "${e.item.id}"`);this.markLayoutDirtyFromIndex(e.index)}tryAppendItems(e){if(e.length<=this.items.length)return!1;for(let t=0;t<this.items.length;t++){let n=this.items[t];if(n==null)throw Error(`CodeView.tryAppendItems: missing existing item`);let r=e[t];if(r==null||n.item.id!==r.id||n.type!==r.type)return!1}for(let t=0;t<this.items.length;t++){let n=this.items[t];if(n==null)throw Error(`CodeView.tryAppendItems: missing existing item`);let r=e[t];if(r==null)throw Error(`CodeView.tryAppendItems: append candidate missing prefix item`);this.syncItemRecord(n,r)&&this.markLayoutDirtyFromIndex(t)}return this.appendItemsInternal(e.slice(this.items.length),!1),this.scrollDirty=!0,this.render(),!0}reconcileItems(e){let{items:t,idToItem:n}=this,r=new Set(t),i=[],a=new Map,o=new Map,s=new Map,c;for(let s=0;s<e.length;s++){let l=e[s];if(l==null)throw Error(`CodeView.reconcileItems: missing input item`);if(a.has(l.id))throw Error(`CodeView.setItems: duplicate id "${l.id}"`);let u=n.get(l.id),d=u!=null&&u.type===l.type?u:this.createItem(l,s,0);d.index=s,u!=null&&u.type===l.type?(r.delete(u),this.syncItemRecord(d,l)&&(c=Math.min(c??s,s))):c=Math.min(c??s,s),t[s]!==d&&(c=Math.min(c??s,s)),i.push(d),a.set(l.id,d),o.set(d.instance,d)}if(c==null){if(r.size===0)return;c=Math.max(i.length-1,0)}this.capturePendingLayoutAnchor(a);for(let e=0;e<t.length;e++){let n=t[e];if(n==null||!r.has(n))continue;s.set(n.item.id,n),this.releaseRenderedItem(n);let a=Math.max(i.length-1,0);c=Math.min(c??a,a)}return this.items=i,this.idToItem=a,this.instanceToItem=o,this.renderState.firstIndex>=i.length?this.resetRenderState():this.renderState.lastIndex>=i.length&&(this.renderState.lastIndex=i.length-1),this.markLayoutDirtyFromIndex(c),this.scrollDirty=!0,this.render(),s.size>0?s:void 0}syncItemRecord(e,t){if(e.type!==t.type)throw Error(`CodeView.syncItemRecord: type mismatch for id "${t.id}"`);return e.version===t.version?!1:(e.item=t,e.version=t.version,e.renderedOptionsRevision=-1,!0)}getMaxScrollTopForHeight(e){let{paddingBottom:t,paddingTop:n}=this.getLayout();return Math.max(n+this.header.height+e+this.footer.height+t-this.getHeight(),0)}getMaxScrollTop(){return this.getMaxScrollTopForHeight(this.getScrollHeight())}shouldRebaseScroll(){return this.getMaxScrollTop()>pe}getPagedScrollHeight(){return this.shouldRebaseScroll()?Math.min(this.getScrollHeight(),J):this.getScrollHeight()}getMaxPagedScrollTop(){return this.getMaxScrollTopForHeight(this.getPagedScrollHeight())}clampPagedScrollTop(e){let t=this.getMaxPagedScrollTop();return Math.max(0,Math.min(e,t))}clampScrollTop(e){let t=this.getMaxScrollTop();return Math.max(0,Math.min(e,t))}getMaxScrollPageOffset(){return Math.max(this.getMaxScrollTop()-this.getMaxPagedScrollTop(),0)}clampScrollPageOffset(e){let t=this.getMaxScrollPageOffset();return Math.max(0,Math.min(e,t))}resolveScrollPageWindow(e,t){let n=H(this.clampPagedScrollTop(t)),r=this.clampScrollPageOffset(e-n);return n=H(this.clampPagedScrollTop(e-r)),r=this.clampScrollPageOffset(e-n),{pagedScrollTop:n,scrollPageOffset:r}}resolvePagedScrollPosition(e){if(!this.shouldRebaseScroll())return{pagedScrollTop:this.clampPagedScrollTop(e),scrollPageOffset:0};let t=this.clampScrollPageOffset(this.scrollPageOffset),n=e-t,r=this.getMaxPagedScrollTop(),i=this.getMaxScrollPageOffset(),a=n>pe&&t<i,o=n<ue&&t>0;return n<0||n>r||a||o?this.resolveScrollPageWindow(e,o?Math.min(fe,r):de):{pagedScrollTop:H(this.clampPagedScrollTop(n)),scrollPageOffset:t}}needsScrollPageUpdate(e){let t=H(this.clampScrollTop(e)),{scrollPageOffset:n}=this.resolvePagedScrollPosition(t);return n!==this.scrollPageOffset}getPagedLayoutTop(e){return this.shouldRebaseScroll()?Math.max(e-this.scrollPageOffset,0):e}getStickyHeaderOffset(){return this.options.stickyHeaders===!0&&this.options.disableFileHeader!==!0?this.itemMetricsCache.diffHeaderHeight:0}getScrollTargetRect(e){let t=this.idToItem.get(e.id);if(t==null){console.warn(`CodeView.scrollTo: unknown item id "${e.id}"`);return}if(e.type===`item`)return{top:t.top,height:t.height};if(e.type===`range`){let n=this.getRangeScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve range ${Se(e.range)} for item "${e.id}"`);return}return{top:t.top+n.top,height:n.height}}let n=this.getLineScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve line ${e.lineNumber} for item "${e.id}"`);return}return{top:t.top+n.top,height:n.height}}normalizeScrollTarget(e){if(e.type===`position`||e.align!==`nearest`)return e;let t=this.getScrollTargetRect(e);if(t==null)return;let n=e.offset??0,r=this.getItemTopOffset()+t.top,i=r+t.height,a=this.getScrollTop(),o=a+(e.type===`line`||e.type===`range`?this.getStickyHeaderOffset():0),s=a+this.getHeight();if(!(r-n<=o&&i+n>=s)){if(r-n<o)return{...e,align:`start`};if(i+n>s)return{...e,align:`end`}}}resolveScrollTargetTop(e){if(e.type===`position`){let t=this.clampScrollTop(e.position);return t===e.position?this.clampScrollTop(e.position-this.getStickyHeaderOffset()):t}let t=this.idToItem.get(e.id);if(t==null){console.warn(`CodeView.scrollTo: unknown item id "${e.id}"`);return}if(e.type===`item`)return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top,t.height,e.align,e.offset));if(e.type===`range`){let n=this.getRangeScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve range ${Se(e.range)} for item "${e.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top+n.top,n.height,e.align,e.offset,this.getStickyHeaderOffset()))}let n=this.getLineScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve line ${e.lineNumber} for item "${e.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top+n.top,n.height,e.align,e.offset,this.getStickyHeaderOffset()))}resolveAlignedScrollPosition(e,t,n,r=0,i=0){e+=this.getItemTopOffset();let a=this.getHeight();return n===`center`&&t+r<a?e-(a-t)/2+r:n===`end`?e-(a-t)+r:e-i-r}getLineScrollPosition(e,t){return e.type===`diff`?e.instance.getLinePosition(t.lineNumber,t.side):e.instance.getLinePosition(t.lineNumber)}getRangeScrollPosition(e,t){let{range:n}=t,r=this.getLineScrollPosition(e,{type:`line`,id:t.id,lineNumber:n.start,side:n.side}),i=this.getLineScrollPosition(e,{type:`line`,id:t.id,lineNumber:n.end,side:n.endSide??n.side});if(r==null||i==null)return;let a=r.top,o=a+r.height,s=i.top,c=s+i.height,l=Math.min(a,s);return{top:l,height:Math.max(o,c)-l}}computeTargetScrollTopForFrame(e,t){if(this.pendingScrollTarget==null)return e;let n=this.resolveScrollTargetTop(this.pendingScrollTarget);if(n==null)return e;let{scrollAnimation:r}=this;return r==null?n:this.computeSpringStep(r,n,t).position}computeSpringStep(e,t,n){let r=Math.max(0,n-e.lastTimestamp),{omega:i}=this.getSmoothScrollSettings(),a=Math.exp(-i*r),o=e.position-t,s=e.velocity+i*o;return{position:t+(o+s*r)*a,velocity:(s*(1-i*r)-i*o)*a}}advanceScrollAnimation(e,t){if(this.pendingScrollTarget==null)return;let n=this.resolveScrollTargetTop(this.pendingScrollTarget);if(n==null){this.pendingScrollTarget=void 0,this.scrollAnimation=void 0;return}let r=this.scrollAnimation;if(r==null)return n;r.position+=t;let{position:i,velocity:a}=this.computeSpringStep(r,n,e);r.lastTimestamp=e,r.position=i,r.velocity=a;let{positionEpsilon:o,velocityEpsilon:s}=this.getSmoothScrollSettings();return Math.abs(n-i)<=o&&Math.abs(a)<=s?(r.position=n,r.velocity=0,this.scrollAnimation=void 0,n):r.position}computeRenderRangeAndEmit=(t=performance.now())=>{if(e.__STOP||this.container==null||!this.isReady())return;let n=this.getHeight(),r=this.getScrollTop(),i=r,a=this.pendingLayoutAnchor!=null,o=this.getScrollAnchor(i);if(this.layoutDirtyIndex!=null&&(this.recomputeLayout(this.layoutDirtyIndex,this.pendingLayoutReset),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,a=!0),a&&o!=null){let e=this.resolveAnchoredScrollTop(o);if(e!=null){let t=e-i;i=e,this.scrollAnimation!=null&&(this.scrollAnimation.position+=t)}}a&&(i=this.clampScrollTop(i),this.syncContainerHeight());let s=this.computeTargetScrollTopForFrame(i,t),c=!a&&(this.renderState.scrollTop===-1||Math.abs(s-this.renderState.scrollTop)>n+this.config.overscrollSize*2);c&&(o=void 0),this.windowSpecs=F({scrollTop:s-this.header.height,height:n,scrollHeight:this.getScrollHeight(),fitPerfectly:c,fitPerfectlyOverscroll:this.getFitPerfectlyOverscroll(),overscrollSize:this.config.overscrollSize});let l=r;(this.pendingScrollTarget!=null&&s!==l||this.needsScrollPageUpdate(s))&&(this.applyScrollFix(s,l,this.windowSpecs),l=s);let{top:u,bottom:d}=this.windowSpecs,{firstIndex:f,lastIndex:p}=this.renderState;if(f>=0)for(let e=f;e<=p;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.computeRenderRangeAndEmit: No item at index: ${e}`);t.top>u-t.height&&t.top<=d||this.releaseRenderedItem(t)}let m=this.reconcileHeaderFooterHosts(),h,g=new Set,_=this.findFirstVisibleIndex(u),v=this.findLastVisibleIndex(d);for(let e=_;e<=v;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.computeRenderRangeAndEmit: missing item`);let{instance:n}=t;t.element==null?(t.element=this.acquireElement(),Te(this.stickyContainer,t.element,h),n.virtualizedSetup(),we(t,t.element)&&(t.renderedOptionsRevision=this.renderOptionsRevision,g.add(t)),h=t.element):(Te(this.stickyContainer,t.element,h),we(t,void 0,t.renderedOptionsRevision!==this.renderOptionsRevision)&&(t.renderedOptionsRevision=this.renderOptionsRevision,g.add(t)),h=t.element),t.item.edit===!0&&this.attachItemEditor(t)}this.renderState.firstIndex=_<=v?_:-1,this.renderState.lastIndex=v,this.flushSlotCoordinator(),this.flushManagers(g),m&&this.measureMountedHosts(),this.reconcileRenderedItems(g),this.syncContainerHeight(),this.updateStickyPositioning();let y=o==null?void 0:this.resolveAnchoredScrollTop(o);o===this.pendingLayoutAnchor&&(this.pendingLayoutAnchor=void 0);let b=y==null?0:y-i,x=s,S=!1;if(this.pendingScrollTarget!=null){let e=this.advanceScrollAnimation(t,b);e==null?x=i:(x=e,S=!0)}else x=y??s;x!==l&&(this.applyScrollFix(x,l,this.windowSpecs),l=x),S&&this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),this.renderState.scrollTop=H(l),this.updateStickyPositioning(),this.validateStickyContainerHeight(),this.fixContainerFocus(),(c||this.scrollAnimation!=null)&&this.render()};flushManagers(e){for(let t of e)t.instance.flushManagers()}syncContainerHeight(){let e=this.getPagedScrollHeight();this.container==null||this.containerHeight===e||(this.container.style.height=`${e}px`,this.containerHeight=e)}getStickyBounds(e){let{firstIndex:t,lastIndex:n}=e==null?this.renderState:{firstIndex:this.findFirstVisibleIndex(e.top),lastIndex:this.findLastVisibleIndex(e.bottom)};if(t===-1||n===-1||t>n)return;let r=this.items[t]?.instance.getAdvancedStickySpecs(e),i=this.items[n]?.instance.getAdvancedStickySpecs(e);if(!(r==null||i==null))return{stickyTop:this.getPagedLayoutTop(Math.max(r.topOffset,0)),stickyBottom:this.getPagedLayoutTop(i.topOffset+i.height)}}applyStickyPositioning({stickyTop:e,stickyBottom:t}){let n=this.getHeight(),{itemMetricsCache:r}=this,i=t-e;this.renderState.stickyHeight=i,this.renderState.stickyTop=e,this.renderState.stickyBottom=t,this.stickyOffset.style.height=`${e}px`;let a=(Math.random()*r.lineHeight>>0)*-1,o=-Math.max(i+a,0)+n;this.stickyContainer.style.top=`${o}px`,this.stickyContainer.style.bottom=`${o+r.diffHeaderHeight}px`}syncPagedScrollScaffolding(e){this.syncContainerHeight();let t=this.getStickyBounds(e);t!=null&&this.applyStickyPositioning(t)}reconcileRenderedItems(e){let{firstIndex:t,lastIndex:n}=this.renderState;if(t===-1)return;let r=-1,i=!1;for(let a=t;a<this.items.length&&!(!i&&a>n);a++){let t=this.items[a];if(t==null)throw Error(`CodeView.reconcileRenderedItems: Invalid item`);r===-1?r=t.top:t.top!==r&&(t.top=r,t.instance.syncVirtualizedTop(),i=!0),(e==null?a<=n:e.has(t))&&(t.instance.reconcileHeights()&&(i=!0,t.height=t.instance.getVirtualizedHeight()),this.validateRenderedItemHeight(t)),r+=t.instance.getVirtualizedHeight(),a<this.items.length-1&&(r+=this.getLayout().gap)}i&&r!=null&&(this.scrollDirty=!0,this.scrollHeight=r)}updateStickyPositioning(){let e=this.getStickyBounds();if(e==null){this.renderState.firstIndex===-1&&(this.stickyOffset.style.height=``);return}let{stickyTop:t,stickyBottom:n}=e;n-t===this.renderState.stickyHeight&&t===this.renderState.stickyTop&&n===this.renderState.stickyBottom||this.applyStickyPositioning(e)}handleScroll=()=>{e.__STOP||(this.suspendScrollInteractions(),this.scrollDirty=!0,this.notifyScroll(),this.render())};clearPendingScroll=()=>{this.pendingScrollTarget=void 0,this.pendingLayoutAnchor=void 0,this.scrollAnimation=void 0};handleResize=e=>{let t=!1;for(let n of e)if(n.target===this.stickyContainer){let e=n.borderBoxSize[0].blockSize;if(Math.abs(e-this.renderState.stickyHeight)>=ce){let e=this.getScrollTop(),n=this.getScrollAnchor(e);this.reconcileRenderedItems(),this.updateStickyPositioning();let r=n==null?void 0:this.resolveAnchoredScrollTop(n);if(r!=null){let t=r-e;this.applyScrollFix(r,e,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=t)}this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),t=!0}}else if(n.target===this.header.element||n.target===this.footer.element){let e=n.target===this.header.element?this.header:this.footer,r=n.borderBoxSize[0].blockSize;if(r!==e.height){let n=this.getScrollTop(),i=this.getScrollAnchor(n);this.setHostHeight(e,r);let a=i==null?void 0:this.resolveAnchoredScrollTop(i);if(a!=null){let e=a-n;this.applyScrollFix(a,n,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=e)}this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),t=!0}}else this.scrollDirty=!0,this.heightDirty=!0,t=!0;t&&this.render(!0)};getScrollAnchorViewportTop(e,t){return e<t?t+this.getStickyHeaderOffset():t}getScrollAnchor(e,t=this.idToItem){let n,{pendingLayoutAnchor:r}=this;if(r!=null){let e=this.idToItem.get(r.id);if(e!=null&&t.get(r.id)===e)return r;e!=null&&(n=e)}if(e<=0)return;let{firstIndex:i,lastIndex:a,stickyTop:o,stickyBottom:s}=this.renderState;if(i===-1||a===-1)return;let c=this.getHeight();if(!(o===-1||s===-1)){for(let r=i;r<=a;r++){let i=this.items[r];if(i==null)continue;let a=this.getItemTopOffset()+i.top;if(a+i.height<=e)continue;if(a>=e+c)break;if(t.get(i.item.id)!==i){n??=i;continue}if(a>=e)return{type:`item`,id:i.item.id,viewportOffset:a-e};let o=this.getScrollAnchorViewportTop(a,e)-a,s=i.instance.getNumericScrollAnchor(o);if(s!=null){let t=a+s.top;return{type:`line`,id:i.item.id,lineNumber:s.lineNumber,side:s.side,viewportOffset:t-e}}}if(n!=null)for(let e=n.index+1;e<this.items.length;e++){let n=this.items[e];if(n!=null&&t.get(n.item.id)===n)return{type:`item`,id:n.item.id,viewportOffset:0}}}}resolveAnchoredScrollTop(e){let t=this.idToItem.get(e.id);if(t==null)return;let n=this.getItemTopOffset();if(e.type===`item`){let r=n+t.top;return this.clampScrollTop(r-e.viewportOffset)}let r=t.type===`diff`?t.instance.getLinePosition(e.lineNumber,e.side):t.instance.getLinePosition(e.lineNumber);if(r==null)return;let i=n+t.top+r.top;return this.clampScrollTop(i-e.viewportOffset)}applyScrollFix(e,t,n){if(this.root==null)return;let r=H(this.clampScrollTop(e)),i=H(t),{scrollPageOffset:a}=this,o=H(this.clampPagedScrollTop(i-a)),{pagedScrollTop:s,scrollPageOffset:c}=this.resolvePagedScrollPosition(r),l=s,u=a!==c;r===this.renderState.scrollTop&&r===i&&l===o&&!u||(this.suspendScrollInteractions(),(l!==o||u)&&(this.scrollPageOffset=c,this.syncPagedScrollScaffolding(n)),l!==o&&this.root.scrollTo({top:l,behavior:`instant`}),this.renderState.scrollTop=r,this.scrollTop=r,this.scrollDirty=!1)}isPendingTargetSettled(e){let t=this.resolveScrollTargetTop(e);return t==null?!0:H(this.getScrollTop())===H(t)}getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root?.scrollTop??0;return this.scrollTop=this.clampScrollTop(e+this.scrollPageOffset),this.scrollTop}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root?.getBoundingClientRect().height??0,this.height):this.height}getScrollHeight(){return this.scrollHeight}flushSlotCoordinator(){if(this.slotCoordinator==null)return;let e=this.buildSlotSnapshot(this.slotCoordinator);B(this.slotSnapshot,e)||(this.slotSnapshot=e,this.slotCoordinator.onSnapshotChange(e))}notifyScroll(){if(this.scrollListeners.size===0)return;let e=this.getScrollTop();for(let t of this.scrollListeners)t(e,this)}findFirstVisibleIndex(e){let t=0,n=this.items.length-1,r=this.items.length;for(;t<=n;){let i=t+n>>1,a=this.items[i];if(a==null)throw Error(`CodeView.findFirstVisibleIndex: invalid item index`);a.top+a.height>e?(r=i,n=i-1):t=i+1}return r}findLastVisibleIndex(e){let t=0,n=this.items.length-1,r=-1;for(;t<=n;){let i=t+n>>1,a=this.items[i];if(a==null)throw Error(`CodeView.findLastVisibleIndex: invalid item index`);a.top<=e?(r=i,t=i+1):n=i-1}return r}recomputeLayout(e=0,t){if(this.items.length===0){this.scrollHeight=0;return}let n=this.getLayout(),r=0;if(e>0){let t=this.items[e-1];if(t==null)throw Error(`CodeView.recomputeLayout: invalid dirty index`);r=t.top+t.height+n.gap}for(let i=e;i<this.items.length;i++){let e=this.items[i];if(e==null)throw Error(`CodeView.recomputeLayout: invalid item index`);if(e.top=r,e.type===`diff`){let n=e.instance.consumeCodeViewLayoutChanges(e.item.fileDiff);n!=null&&Object.assign(e.item.fileDiff,n),e.height=e.instance.prepareCodeViewItem(e.item.fileDiff,r,t,e.item.annotations??[])}else e.height=e.instance.prepareCodeViewItem(e.item.file,r,t,e.item.annotations??[]);r+=e.height,i<this.items.length-1&&(r+=n.gap)}r!==this.scrollHeight&&(this.scrollDirty=!0),this.scrollHeight=r}resetRenderState(){this.renderState.scrollTop=-1,this.renderState.firstIndex=-1,this.renderState.lastIndex=-1,this.renderState.stickyHeight=0,this.renderState.stickyTop=-1,this.renderState.stickyBottom=-1}getFitPerfectlyOverscroll(){return this.getLayout().gap+this.itemMetricsCache.diffHeaderHeight}};function _e(e){return e.instance.cleanUp(!0),e.type===`diff`?e.instance.prepareCodeViewItem(e.item.fileDiff,e.top,void 0,e.item.annotations??[]):e.instance.prepareCodeViewItem(e.item.file,e.top,void 0,e.item.annotations??[])}function ve(e,t){return!N(e.theme??_,t.theme??_)||(e.themeType??`system`)!==(t.themeType??`system`)||e.unsafeCSS!==t.unsafeCSS}function ye(e,t){return(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS||(e.diffStyle??`split`)!==(t.diffStyle??`split`)||(e.diffIndicators??`bars`)!==(t.diffIndicators??`bars`)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function be(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function xe(e){return e instanceof SVGElement?!0:P(e)&&(e.hasAttribute(`data-core-css`)||e.hasAttribute(`data-theme-css`)||e.hasAttribute(`data-unsafe-css`))}function Se(e){let t=Ce(e.start,e.side),n=Ce(e.end,e.endSide??e.side);return t===n?t:`${t}-${n}`}function Ce(e,t){return t==null?`${e}`:`${t===`deletions`?`D`:`A`}${e}`}function we(e,t,n=!1){return e.type===`diff`?e.instance.render({deferManagers:!0,fileContainer:t,fileDiff:e.item.fileDiff,forceRender:n,lineAnnotations:e.item.annotations??[]}):e.instance.render({deferManagers:!0,fileContainer:t,file:e.item.file,forceRender:n,lineAnnotations:e.item.annotations??[]})}function Te(e,t,n){if(n==null){e.firstChild!==t&&e.prepend(t);return}n.nextSibling!==t&&n.after(t)}function Ee(e){return(e.annotations?.length??0)>0}function De(e,{hasHeaderRenderers:t,hasAnnotationRenderer:n,hasGutterRenderer:r}){if(e.length===0)return;if(t||r)return e;if(!n)return;let i=[];for(let t of e)Ee(t.item)&&i.push(t);return i.length>0?i:void 0}var Y=e(r(),1),X=e(t(),1),Z=n(),Oe=typeof window>`u`?Y.useEffect:Y.useLayoutEffect;function ke(e){return{instance:void 0,items:void 0,controlled:e,managedOptions:void 0,disableFlushSync:!1,slotCoordinator:void 0}}function Ae(e,t){let{className:n,containerRef:r,disableWorkerPool:i=!1,editorOptions:a,initialItems:o,items:s,onItemEditChange:c,onItemEditComplete:l,onScroll:u,onSelectedLinesChange:d,options:f,renderAnnotation:p,renderCodeViewFooter:h,renderCodeViewHeader:g,renderCustomHeader:_,renderGutterUtility:v,renderHeaderFilenameSuffix:y,renderHeaderMetadata:b,renderHeaderPrefix:x,selectedLines:S,style:C}=e,T=s!==void 0,E=te(),D=(0,Y.useContext)(ne),O=(0,Y.useRef)(ke(T)),k=_!=null,A=p!=null,j=v!=null,M=k||x!=null||y!=null||b!=null,ee=M||A||j,N=g!=null,P=h!=null,F=w(e=>{d?.(e)}),I=S!==void 0,L=w(e=>{if(E==null)throw Error(`CodeView: EditContext is not attached`);let t=E({...a,...e});if(t==null)throw Error(`CodeView: EditProvider.createEditor must return an editor instance`);return t}),R=w((e,t,n)=>{c?.(e,t,n)}),z=w((e,t,n)=>{l?.(e,t,n)}),B=(0,Y.useMemo)(()=>Fe({options:f,hasCustomHeader:k,hasGutterRenderer:j,hasCodeViewHeader:N,hasCodeViewFooter:P,onSelectedLinesChange:d==null?void 0:F,controlledSelection:I,createEditor:E==null?void 0:L,onItemEditChange:c==null?void 0:R,onItemEditComplete:l==null?void 0:z}),[E,I,L,R,z,F,P,N,k,j,c,l,d,f]),[V]=(0,Y.useState)(()=>Pe()),[,re]=(0,Y.useState)({}),H=w(e=>{O.current.instance!=null&&(e==null||e!==O.current.instance.getContainerElement())&&(O.current.instance.cleanUp(),V.publish(void 0),O.current=ke(T)),e!=null&&e!==O.current.instance?.getContainerElement()&&(O.current.instance=new ge(B,i?void 0:D,!0),O.current.instance.setup(e)),typeof r==`function`?r(e):r!=null&&(r.current=e)}),U=w(e=>{O.current.disableFlushSync?V.publish(e):(0,X.flushSync)(()=>{V.publish(e)})}),W=(0,Y.useMemo)(()=>{if(!(!M&&!A&&!j&&!N&&!P))return{hasHeaderRenderers:M,hasAnnotationRenderer:A,hasGutterRenderer:j,onSnapshotChange:U}},[U,A,j,M,N,P]);return Oe(()=>u==null?void 0:O.current.instance?.subscribeToScroll(u)),Oe(()=>{let{instance:e,controlled:t,items:n,managedOptions:r,slotCoordinator:i}=O.current;if(e!=null)try{O.current.disableFlushSync=!0;let a=!1;if(m(B,r)||(O.current.managedOptions=B,e.setOptions(B),a=!0),t!==T){console.error(`CodeView: cannot switch between controlled and uncontrolled modes. Remount with a new key instead.`);return}if(T)s!==n&&(Ne(n,s)?O.current.items=s:Me(n,s)?(O.current.items=s,e.addItems(s.slice(n.length))):(O.current.items=s,e.setItems(s),a=!0));else if(n==null){let t=o??[];O.current.items=t,t.length>0&&(e.setItems(t),a=!0)}S!==void 0&&e.setSelectedLines(S,{notify:!1});let c=e.setSlotCoordinator(W),l=!1;W!==i&&((W==null||i==null)&&(l=!0),O.current.slotCoordinator=W),(a||c)&&e.render(!0),c&&W==null&&V.publish(void 0),l&&re({})}finally{O.current.disableFlushSync=!1}}),(0,Y.useImperativeHandle)(t,()=>({addItems(e){let{controlled:t,instance:n}=O.current;Q(t,`addItems`),n==null?console.error(`CodeView.addItems: no valid instance to append items with`,e):n.addItems(e)},getItem(e){let{instance:t}=O.current;if(t==null){console.error(`CodeView.getItem: no valid instance exists`,e);return}else return t.getItem(e)},removeItem(e){let{controlled:t,instance:n}=O.current;return Q(t,`removeItem`),n==null?(console.error(`CodeView.removeItem: no valid instance to remove item from`,e),!1):n.removeItem(e)},updateItem(e){let{controlled:t,instance:n}=O.current;return Q(t,`updateItem`),n==null?(console.error(`CodeView.updateItem: no valid instance to update item with`,e),!1):n.updateItem(e)},updateItemId(e,t){let{controlled:n,instance:r}=O.current;return Q(n,`updateItemId`),r==null?(console.error(`CodeView.updateItemId: no valid instance to update item id with`,e,t),!1):r.updateItemId(e,t)},scrollTo(e){let{instance:t}=O.current;t==null?console.error(`CodeView.scrollTo: no valid instance to scroll with`,e):t.scrollTo(e)},setSelectedLines(e){let{instance:t}=O.current;t==null?console.error(`CodeView.setSelectedLines: no valid instance to update selection with`,e):(t.setSelectedLines(e,{notify:!1}),F(e))},getSelectedLines(){let{instance:e}=O.current;return e==null?(console.error(`CodeView.getSelectedLines: no valid instance exists`),null):e.getSelectedLines()},clearSelectedLines(){let{instance:e}=O.current;e==null?console.error(`CodeView.clearSelectedLines: no valid instance to update selection with`):(e.clearSelectedLines({notify:!1}),F(null))},getEditor(e){let{instance:t}=O.current;if(t==null){console.error(`CodeView.getEditor: no valid instance exists`,e);return}return t.getEditor(e)},getInstance(){return O.current.instance}}),[F]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{ref:H,className:n,style:C}),(ee||N||P)&&(0,Z.jsx)(Ie,{managedContentStore:V,renderCustomHeader:_,renderHeaderPrefix:x,renderHeaderFilenameSuffix:y,renderHeaderMetadata:b,renderAnnotation:p,renderGutterUtility:v,renderCodeViewHeader:g,renderCodeViewFooter:h})]})}var je=(0,Y.forwardRef)(Ae);function Me(e,t){if(e==null||t.length<=e.length)return!1;if(e.length===0)return!0;for(let n=0;n<e.length;n++)if(t[n]!==e[n])return!1;return!0}function Ne(e,t){if(e==null||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Q(e,t){if(e)throw Error(`CodeView.${t} cannot be used when CodeView is controlled. Use initialItems for imperative item updates.`)}function Pe(){let e,t=new Set;return{getSnapshot(){return e},publish(n){if(!B(e,n)){e=n;for(let e of t)e()}},subscribe(e){return t.add(e),()=>{t.delete(e)}}}}function Fe({options:e,hasCustomHeader:t,hasGutterRenderer:n,hasCodeViewHeader:r,hasCodeViewFooter:i,onSelectedLinesChange:a,controlledSelection:o,createEditor:s,onItemEditChange:c,onItemEditComplete:l}){let u={...e,controlledSelection:o,onSelectedLinesChange:a,createEditor:s};return c!=null&&(u.onItemEditChange=c),l!=null&&(u.onItemEditComplete=l),t&&(u.renderCustomHeader=$),n&&(u.renderGutterUtility=$),r&&(u.renderCodeViewHeader=$),i&&(u.renderCodeViewFooter=$),u}var Ie=(0,Y.memo)(function({managedContentStore:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,renderGutterUtility:o,renderCodeViewHeader:s,renderCodeViewFooter:c}){"use no memo";let l=w(t=>e.subscribe(t)),u=w(()=>e.getSnapshot()),d=(0,Y.useSyncExternalStore)(l,u,u),f=``;for(let e of d?.items??[])f+=`${e.id}:${e.version}:${e.type}`;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Y.useMemo)(()=>d?.items?.map(e=>(0,X.createPortal)(Le({renderedItem:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,renderGutterUtility:o}),e.element,e.id)),[t,n,r,i,a,o,f]),(0,Y.useMemo)(()=>s!=null&&d?.header!=null?(0,X.createPortal)(s(),d.header):null,[s,d?.header]),(0,Y.useMemo)(()=>c!=null&&d?.footer!=null?(0,X.createPortal)(c(),d.footer):null,[c,d?.footer])]})});function Le({renderedItem:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,renderGutterUtility:o}){if(e.type===`diff`){let{item:s,instance:c}=e;return E({fileDiff:s.fileDiff,renderCustomHeader:t==null?void 0:()=>t(s),renderHeaderPrefix:n==null?void 0:()=>n(s),renderHeaderFilenameSuffix:r==null?void 0:()=>r(s),renderHeaderMetadata:i==null?void 0:()=>i(s),renderAnnotation:a==null?void 0:e=>a(e,s),lineAnnotations:s.annotations,renderGutterUtility:o==null?void 0:e=>o(e,s),getHoveredLine:c.getHoveredLine})}else{let{item:s,instance:c}=e;return p({file:s.file,renderCustomHeader:t==null?void 0:()=>t(s),renderHeaderPrefix:n==null?void 0:()=>n(s),renderHeaderFilenameSuffix:r==null?void 0:()=>r(s),renderHeaderMetadata:i==null?void 0:()=>i(s),renderAnnotation:a==null?void 0:e=>a(e,s),lineAnnotations:s.annotations,renderGutterUtility:o==null?void 0:e=>o(e,s),getHoveredLine:c.getHoveredLine})}}function $(){}function Re(e,t){return e.length>0&&e.every(e=>t.has(e))}function ze(e,t){return Re(e,t)?new Set:new Set(e)}var Be=function(e){return e.disabled=`data-disabled`,e.orientation=`data-orientation`,e.multiple=`data-multiple`,e}({}),Ve={multiple(e){return e?{[Be.multiple]:``}:null}},He=Y.forwardRef(function(e,t){let{defaultValue:n,disabled:r=!1,loopFocus:i=!0,onValueChange:s,orientation:c=`horizontal`,multiple:f=!1,value:p,className:m,render:h,style:g,..._}=e,v=a(!0),y=Y.useMemo(()=>p!==void 0||n!==void 0,[p,n]),b=(v?.disabled??!1)||r,[x,S]=u({controlled:p,default:p===void 0?n??o:void 0,name:`ToggleGroup`,state:`value`}),C=l((e,t,n)=>{let r;f?(r=x.slice(),t?r.push(e):r.splice(x.indexOf(e),1)):r=t?[e]:[],s?.(r,n),!n.isCanceled&&S(r)}),w={disabled:b,multiple:f,orientation:c},T=Y.useMemo(()=>({disabled:b,orientation:c,setGroupValue:C,value:x,isValueInitialized:y}),[b,c,C,x,y]),E={role:`group`},D=d(`div`,e,{enabled:!!v,state:w,ref:t,props:[E,_],stateAttributesMapping:Ve});return(0,Z.jsx)(M.Provider,{value:T,children:v?D:(0,Z.jsx)(ee,{render:h,className:m,style:g,state:w,refs:[t],props:[E,_],stateAttributesMapping:Ve,loopFocus:i,enableHomeAndEndKeys:!0,orientation:c})})}),Ue=i(),We=Y.createContext({size:`default`,variant:`default`});function Ge(e){let t=(0,Ue.c)(24),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({className:r,variant:a,size:o,orientation:s,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let l=a===void 0?`default`:a,u=o===void 0?`default`:o,d=s===void 0?`horizontal`:s,f;t[7]!==u||t[8]!==l?(f={size:u,variant:l},t[7]=u,t[8]=l,t[9]=f):f=t[9];let p=f,m=d===`horizontal`?`*:pointer-coarse:after:min-w-auto`:`*:pointer-coarse:after:min-h-auto`,h=l==="default"?`gap-0.5`:d===`horizontal`?`*:not-first:not-data-[slot=separator]:before:-start-[0.5px] *:not-last:not-data-[slot=separator]:before:-end-[0.5px] *:not-first:rounded-s-none *:not-last:rounded-e-none *:not-first:border-s-0 *:not-last:border-e-0 *:not-first:before:rounded-s-none *:not-last:before:rounded-e-none`:`*:not-first:not-data-[slot=separator]:before:-top-[0.5px] *:not-last:not-data-[slot=separator]:before:-bottom-[0.5px] flex-col *:not-first:rounded-t-none *:not-last:rounded-b-none *:not-first:border-t-0 *:not-last:border-b-0 *:not-first:before:rounded-t-none *:not-last:before:rounded-b-none *:data-[slot=toggle]:not-last:before:hidden dark:*:last:before:hidden dark:*:first:before:block`,g;t[10]!==r||t[11]!==m||t[12]!==h?(g=c(`flex w-fit *:focus-visible:z-10 dark:*:[[data-slot=separator]:has(+[data-slot=toggle]:hover)]:before:bg-input/64 dark:*:[[data-slot=separator]:has(+[data-slot=toggle][data-pressed])]:before:bg-input dark:*:[[data-slot=toggle]:hover+[data-slot=separator]]:before:bg-input/64 dark:*:[[data-slot=toggle][data-pressed]+[data-slot=separator]]:before:bg-input`,m,h,r),t[10]=r,t[11]=m,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==n||t[15]!==p?(_=(0,Z.jsx)(We,{value:p,children:n}),t[14]=n,t[15]=p,t[16]=_):_=t[16];let v;return t[17]!==d||t[18]!==i||t[19]!==u||t[20]!==g||t[21]!==_||t[22]!==l?(v=(0,Z.jsx)(He,{className:g,"data-size":u,"data-slot":`toggle-group`,"data-variant":l,orientation:d,...i,children:_}),t[17]=d,t[18]=i,t[19]=u,t[20]=g,t[21]=_,t[22]=l,t[23]=v):v=t[23],v}function Ke(e){let t=(0,Ue.c)(12),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,variant:o,size:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=Y.use(We),c=o??s.variant,l=a??s.size,u;return t[6]!==n||t[7]!==r||t[8]!==i||t[9]!==l||t[10]!==c?(u=(0,Z.jsx)(j,{className:r,"data-size":l,"data-variant":c,size:l,variant:c,...i,children:n}),t[6]=n,t[7]=r,t[8]=i,t[9]=l,t[10]=c,t[11]=u):u=t[11],u}export{je as a,I as c,ze as i,Ge as n,R as o,Re as r,L as s,Ke as t};
2
- //# sourceMappingURL=toggle-group-uKQBjVsg.js.map