@p4code/cli 0.2.31 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.mjs +321 -37
- package/dist/client/assets/{DiffPanel-B-2-QUPV.js → DiffPanel-xKJcGo_H.js} +3 -3
- package/dist/client/assets/{FilePreviewPanel-C4YhaSrH.js → FilePreviewPanel-B-eIWgzu.js} +14 -14
- package/dist/client/assets/PreviewPanel-Bd3EmzjZ.js +2 -0
- package/dist/client/assets/{PullRequestCodeTab-7Mw21G70.js → PullRequestCodeTab-GH9TVdPS.js} +2 -2
- package/dist/client/assets/arrow-right-D9TMoIs8.js +2 -0
- package/dist/client/assets/{fileCommentAnnotations-B9hOUK3h.js → fileCommentAnnotations-DQvXruQa.js} +2 -2
- package/dist/client/assets/index-CbSZYklw.js +2536 -0
- package/dist/client/assets/index-DuYVlfPp.css +1 -0
- package/dist/client/assets/previewAssetResource-BU7ePoYc.js +48 -0
- package/dist/client/assets/{renderFileChildren-DvgAC6eg.js → renderFileChildren-Dub6Umny.js} +2 -2
- package/dist/client/assets/{toggle-group-BKq4vMCI.js → toggle-group-Db7Sgk7U.js} +2 -2
- package/dist/client/index.html +3 -3
- package/package.json +1 -1
- package/dist/client/assets/PreviewPanel-ZUpYbtlk.js +0 -2
- package/dist/client/assets/arrow-right-BPchBceB.js +0 -2
- package/dist/client/assets/index-BOEKM5ad.js +0 -2527
- package/dist/client/assets/index-CfY-70_w.css +0 -1
- package/dist/client/assets/previewAssetResource-B_r-a_Fy.js +0 -48
|
@@ -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{$ as i,Aa as a,Bl as o,Da as s,Ea as c,Ef as l,G as u,Gl as d,Hl as f,J as p,K as m,Ma as h,Na as g,Oa as _,Of as v,Pa as y,Q as b,Qc as x,Ta as S,Ul as C,V as w,Vu as T,X as E,Zl as D,_a as O,ba as k,bt as ee,dt as A,eu as j,ft as M,gt as N,hl as P,ht as te,iu as F,ja as ne,jl as I,kt as L,ot as re,q as R,r as ie,st as z,vt as B,wa as V,x as H,xr as U,xt as ae,yt as W}from"./previewAssetResource-B_r-a_Fy.js";import{t as oe}from"./arrow-right-BPchBceB.js";import{$n as G,$r as K,A as q,Br as J,Dr as Y,Er as se,Jn as ce,Kr as le,M as ue,N as de,O as fe,Or as pe,P as me,Qn as he,Tr as ge,Ur as _e,Vr as ve,Wr as ye,Xn as be,Yn as xe,Zn as Se,a as Ce,c as we,ci as Te,er as Ee,g as De,i as Oe,j as ke,k as X,n as Ae,ni as je,o as Me,qr as Ne,r as Pe,s as Fe,t as Ie,tr as Le,wr as Re,z as ze}from"./index-BOEKM5ad.js";var Be=x(`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`}]]),Ve=x(`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`}]]),He=x(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),Ue=x(`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(),We=()=>{};function Ge(e){let t=(0,Z.c)(98),{url:n,displayUrl:r,loading:i,loadProgress:a,canGoBack:o,canGoForward:s,refreshDisabled:c,inputDisabled:l,focusUrlNonce:u,onBack:d,onForward:f,onRefresh:p,onSubmit:m,onOpenInBrowser:h,onCapture:g,captureDisabled:_,recording:v,onPictureInPicture:b,pictureInPicture:x,pictureInPictureDisabled:S,onPickElement:C,pickActive:w,pickDisabled:T,pickDisabledReason:E,trailingActions:D}=e,k=(0,Q.useRef)(null),[ee,A]=(0,Q.useState)(n),[j,M]=(0,Q.useState)(!1),P,F;t[0]===u?(P=t[1],F=t[2]):(P=()=>{if(u==null)return;let e=k.current;e&&e.focus()},F=[u],t[0]=u,t[1]=P,t[2]=F),(0,Q.useEffect)(P,F);let ne;t[3]!==ee||t[4]!==m?(ne=e=>{e?.preventDefault();let t=ee.trim();t.length!==0&&(m(t),k.current?.blur())},t[3]=ee,t[4]=m,t[5]=ne):ne=t[5];let I=ne,L=o?d:We,re=!o,R;t[6]!==L||t[7]!==re?(R=(0,$.jsx)(O,{variant:`ghost`,size:`icon-xs`,onClick:L,disabled:re,"aria-label":`Back`,type:`button`}),t[6]=L,t[7]=re,t[8]=R):R=t[8];let ie;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(Te,{}),t[9]=ie):ie=t[9];let z;t[10]===R?z=t[11]:(z=(0,$.jsx)(B,{render:R,children:ie}),t[10]=R,t[11]=z);let V;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(N,{children:`Back`}),t[12]=V):V=t[12];let H;t[13]===z?H=t[14]:(H=(0,$.jsxs)(te,{children:[z,V]}),t[13]=z,t[14]=H);let U=s?f:We,ae=!s,W;t[15]!==U||t[16]!==ae?(W=(0,$.jsx)(O,{variant:`ghost`,size:`icon-xs`,onClick:U,disabled:ae,"aria-label":`Forward`,type:`button`}),t[15]=U,t[16]=ae,t[17]=W):W=t[17];let G;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(oe,{}),t[18]=G):G=t[18];let K;t[19]===W?K=t[20]:(K=(0,$.jsx)(B,{render:W,children:G}),t[19]=W,t[20]=K);let q;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,$.jsx)(N,{children:`Forward`}),t[21]=q):q=t[21];let Y;t[22]===K?Y=t[23]:(Y=(0,$.jsxs)(te,{children:[K,q]}),t[22]=K,t[23]=Y);let se=c?We:p,ue=i?`Stop`:`Refresh`,de;t[24]!==c||t[25]!==se||t[26]!==ue?(de=(0,$.jsx)(O,{variant:`ghost`,size:`icon-xs`,onClick:se,disabled:c,"aria-label":ue,type:`button`}),t[24]=c,t[25]=se,t[26]=ue,t[27]=de):de=t[27];let fe=i&&`animate-spin`,pe;t[28]===fe?pe=t[29]:(pe=y(fe),t[28]=fe,t[29]=pe);let me;t[30]===pe?me=t[31]:(me=(0,$.jsx)(J,{className:pe}),t[30]=pe,t[31]=me);let he;t[32]!==de||t[33]!==me?(he=(0,$.jsx)(B,{render:de,children:me}),t[32]=de,t[33]=me,t[34]=he):he=t[34];let ge=i?`Loading…`:`Refresh`,_e;t[35]===ge?_e=t[36]:(_e=(0,$.jsx)(N,{children:ge}),t[35]=ge,t[36]=_e);let ve;t[37]!==he||t[38]!==_e?(ve=(0,$.jsxs)(te,{children:[he,_e]}),t[37]=he,t[38]=_e,t[39]=ve):ve=t[39];let Se;t[40]!==H||t[41]!==Y||t[42]!==ve?(Se=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`Navigation`,children:[H,Y,ve]}),t[40]=H,t[41]=Y,t[42]=ve,t[43]=Se):Se=t[43];let Ce=j?ee:r??n,we=h&&!j&&`group-hover/address:pe-7 transition-[padding]`,Ee;t[44]===we?Ee=t[45]:(Ee=y(we),t[44]=we,t[45]=Ee);let De;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(De=e=>A(e.target.value),t[46]=De):De=t[46];let Oe;t[47]===n?Oe=t[48]:(Oe=()=>{A(n),M(!0),queueMicrotask(()=>k.current?.select())},t[47]=n,t[48]=Oe);let ke;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ke=()=>{M(!1)},t[49]=ke):ke=t[49];let X;t[50]!==I||t[51]!==n?(X=e=>{e.key===`Enter`&&I(e),e.key===`Escape`&&(e.preventDefault(),A(n),k.current?.blur())},t[50]=I,t[51]=n,t[52]=X):X=t[52];let Ae;t[53]!==l||t[54]!==Ce||t[55]!==Ee||t[56]!==Oe||t[57]!==X?(Ae=(0,$.jsx)(B,{render:(0,$.jsx)(be,{ref:k,value:Ce,className:Ee,onChange:De,onFocus:Oe,onBlur:ke,onKeyDown:X,placeholder:`Search or enter URL`,spellCheck:!1,disabled:l,"data-preview-url-input":!0,size:`sm`})}),t[53]=l,t[54]=Ce,t[55]=Ee,t[56]=Oe,t[57]=X,t[58]=Ae):Ae=t[58];let Me;t[59]!==r||t[60]!==j||t[61]!==n?(Me=!j&&r?(0,$.jsx)(N,{children:n}):null,t[59]=r,t[60]=j,t[61]=n,t[62]=Me):Me=t[62];let Ne;t[63]!==Ae||t[64]!==Me?(Ne=(0,$.jsxs)(te,{children:[Ae,Me]}),t[63]=Ae,t[64]=Me,t[65]=Ne):Ne=t[65];let Pe;t[66]!==j||t[67]!==h?(Pe=h&&!j?(0,$.jsx)(xe,{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)(te,{children:[(0,$.jsx)(B,{render:(0,$.jsx)(O,{variant:`ghost`,size:`icon-xs`,onClick:h,"aria-label":`Open in system browser`,type:`button`}),children:(0,$.jsx)(je,{})}),(0,$.jsx)(N,{children:`Open in system browser`})]})}):null,t[66]=j,t[67]=h,t[68]=Pe):Pe=t[68];let Fe;t[69]!==Ne||t[70]!==Pe?(Fe=(0,$.jsxs)(ce,{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:[Ne,Pe]}),t[69]=Ne,t[70]=Pe,t[71]=Fe):Fe=t[71];let Ie;t[72]!==C||t[73]!==w||t[74]!==T||t[75]!==E?(Ie=C?(0,$.jsxs)(te,{children:[(0,$.jsx)(B,{render:(0,$.jsx)(O,{variant:w?`secondary`:`ghost`,size:`icon-xs`,onClick:C,disabled:T,"aria-label":w?`Cancel annotation`:`Annotate preview`,"aria-pressed":w?`true`:`false`,type:`button`}),children:(0,$.jsx)(le,{className:y(w&&`text-primary`)})}),(0,$.jsx)(N,{children:T&&E?E:w?`Cancel annotation (Esc)`:`Annotate elements, regions, and drawings`})]}):null,t[72]=C,t[73]=w,t[74]=T,t[75]=E,t[76]=Ie):Ie=t[76];let Le;t[77]!==_||t[78]!==g||t[79]!==v?(Le=g?(0,$.jsxs)(te,{children:[(0,$.jsxs)(B,{render:(0,$.jsx)(O,{variant:v?`secondary`:`ghost`,size:`icon-xs`,onClick:e=>g(e.shiftKey),"aria-label":v?`Stop recording`:`Capture screenshot`,type:`button`,className:`relative`,disabled:_}),children:[(0,$.jsx)(Be,{className:y(v&&`text-destructive`)}),v?(0,$.jsx)(`span`,{className:`absolute right-0.5 top-0.5 size-1.5 animate-status-pulse rounded-full bg-destructive`}):null]}),(0,$.jsx)(N,{children:v?`Stop recording`:`Screenshot · Shift-click to record`})]}):null,t[77]=_,t[78]=g,t[79]=v,t[80]=Le):Le=t[80];let Re;t[81]!==b||t[82]!==x||t[83]!==S?(Re=b?(0,$.jsxs)(te,{children:[(0,$.jsx)(B,{render:(0,$.jsx)(O,{variant:x?`secondary`:`ghost`,size:`icon-xs`,onClick:b,"aria-label":x?`Close floating preview`:`Float preview over chat`,"aria-pressed":x?`true`:`false`,type:`button`,disabled:S}),children:(0,$.jsx)(ye,{className:y(x&&`text-primary`)})}),(0,$.jsx)(N,{children:x?`Close floating preview`:`Float preview over chat`})]}):null,t[81]=b,t[82]=x,t[83]=S,t[84]=Re):Re=t[84];let ze;t[85]!==I||t[86]!==Se||t[87]!==Fe||t[88]!==Ie||t[89]!==Le||t[90]!==Re||t[91]!==D?(ze=(0,$.jsxs)(`form`,{onSubmit:I,className:`surface-subheader gap-1 px-2`,"data-surface-subheader":!0,children:[Se,Fe,Ie,Le,Re,D]}),t[85]=I,t[86]=Se,t[87]=Fe,t[88]=Ie,t[89]=Le,t[90]=Re,t[91]=D,t[92]=ze):ze=t[92];let Ve;t[93]===a?Ve=t[94]:(Ve=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[93]=a,t[94]=Ve);let He;return t[95]!==ze||t[96]!==Ve?(He=(0,$.jsxs)(`div`,{className:`relative`,children:[ze,Ve]}),t[95]=ze,t[96]=Ve,t[97]=He):He=t[97],He}function Ke(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 qe(e){let t=(0,Z.c)(6),{className:n}=e,r;t[0]===n?r=t[1]:(r=y(`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 Je(e){let t=(0,Z.c)(17),{server:n,onOpen:r}=e,i;t[0]===n?i=t[1]:(i=Ye(n),t[0]=n,t[1]=i);let a=i,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(qe,{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)(Xe,{}):(0,$.jsx)(Ze,{}),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 Ye(e){return e.processName?e.processName:e.listening?`Listening`:e.source===`configured`?`Configured`:`Recently seen`}function Xe(){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 Ze(){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 Qe(e){let t=(0,Z.c)(7),n=pe(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:ge(e.environmentId,t.url)}),t[5]=e.environmentId,t[6]=i),r=$e({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 $e(e){let t=new Map;for(let n of e.configuredUrls){let e=tt(n);if(!e)continue;let r=et(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=et(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=tt(n);if(!e)continue;let r=et(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 et(e,t){return`${e.toLowerCase()}:${t}`}function tt(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`||!se(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 nt(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=Qe(o);if(s.length===0){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(Se,{children:[(0,$.jsx)(G,{variant:`icon`,children:(0,$.jsx)(K,{className:`size-4.5 text-muted-foreground`})}),(0,$.jsx)(Ee,{children:`No preview yet`}),(0,$.jsx)(he,{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)(Ue,{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)(Je,{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 rt=[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}];function it(e){let t=(0,Z.c)(74),{tabId:n,hasWebContents:r,zoomFactor:i,colorScheme:o,deviceToolbarVisible:s,onToggleDeviceToolbar:l,nativePictureInPicture:u,onNativePictureInPicture:d}=e;if(!X)return null;let f=!n||!r,p;t[0]===n?p=t[1]:(p=e=>()=>{n&&e(n).catch(ft)},t[0]=n,t[1]=p);let m=p,v;t[2]===i?v=t[3]:(v=Math.round(i*100),t[2]=i,t[3]=v);let y=`${v}%`,b;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsxs)(te,{children:[(0,$.jsx)(B,{render:(0,$.jsx)(g,{render:(0,$.jsx)(O,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":`Preview menu`})}),children:(0,$.jsx)(Ve,{})}),(0,$.jsx)(N,{children:`More`})]}),t[4]=b):b=t[4];let x;t[5]===m?x=t[6]:(x=m(X.hardReload),t[5]=m,t[6]=x);let C;t[7]!==x||t[8]!==f?(C=(0,$.jsx)(V,{onClick:x,disabled:f,children:`Hard reload`}),t[7]=x,t[8]=f,t[9]=C):C=t[9];let w;t[10]===m?w=t[11]:(w=m(X.openDevTools),t[10]=m,t[11]=w);let T;t[12]!==w||t[13]!==f?(T=(0,$.jsx)(V,{onClick:w,disabled:f,children:`Open DevTools`}),t[12]=w,t[13]=f,t[14]=T):T=t[14];let E=u?`Close separate preview window`:`Open separate preview window`,D;t[15]!==d||t[16]!==E||t[17]!==f?(D=(0,$.jsx)(V,{onClick:d,disabled:f,children:E}),t[15]=d,t[16]=E,t[17]=f,t[18]=D):D=t[18];let ee=s?`Hide device toolbar`:`Show device toolbar`,A;t[19]!==l||t[20]!==ee||t[21]!==f?(A=(0,$.jsx)(V,{onClick:l,disabled:f,children:ee}),t[19]=l,t[20]=ee,t[21]=f,t[22]=A):A=t[22];let j;t[23]===f?j=t[24]:(j=(0,$.jsx)(h,{disabled:f,children:`Appearance`}),t[23]=f,t[24]=j);let M;t[25]===n?M=t[26]:(M=e=>{n&&X.setColorScheme(n,e).catch(dt)},t[25]=n,t[26]=M);let P;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(P=rt.map(ut),t[27]=P):P=t[27];let F;t[28]!==o||t[29]!==M?(F=(0,$.jsx)(ne,{className:`min-w-32`,children:(0,$.jsx)(c,{value:o,onValueChange:M,children:P})}),t[28]=o,t[29]=M,t[30]=F):F=t[30];let I;t[31]!==j||t[32]!==F?(I=(0,$.jsxs)(a,{children:[j,F]}),t[31]=j,t[32]=F,t[33]=I):I=t[33];let L;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(_,{}),t[34]=L):L=t[34];let re;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(`span`,{children:`Zoom`}),t[35]=re):re=t[35];let R;t[36]===m?R=t[37]:(R=m(X.zoomOut),t[36]=m,t[37]=R);let ie;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(Ne,{}),t[38]=ie):ie=t[38];let z;t[39]!==R||t[40]!==f?(z=(0,$.jsx)(O,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:R,"aria-label":`Zoom out`,disabled:f,children:ie}),t[39]=R,t[40]=f,t[41]=z):z=t[41];let H;t[42]===y?H=t[43]:(H=(0,$.jsx)(`span`,{className:`min-w-12 text-center text-xs tabular-nums text-muted-foreground`,children:y}),t[42]=y,t[43]=H);let U;t[44]===m?U=t[45]:(U=m(X.zoomIn),t[44]=m,t[45]=U);let ae;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(_e,{}),t[46]=ae):ae=t[46];let W;t[47]!==U||t[48]!==f?(W=(0,$.jsx)(O,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:U,"aria-label":`Zoom in`,disabled:f,children:ae}),t[47]=U,t[48]=f,t[49]=W):W=t[49];let oe;t[50]===m?oe=t[51]:(oe=m(X.resetZoom),t[50]=m,t[51]=oe);let G;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(ve,{}),t[52]=G):G=t[52];let K;t[53]!==oe||t[54]!==f?(K=(0,$.jsx)(O,{variant:`ghost`,size:`icon-xs`,type:`button`,onClick:oe,"aria-label":`Reset zoom`,disabled:f,children:G}),t[53]=oe,t[54]=f,t[55]=K):K=t[55];let q;t[56]!==z||t[57]!==H||t[58]!==W||t[59]!==K?(q=(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[z,H,W,K]}),t[56]=z,t[57]=H,t[58]=W,t[59]=K,t[60]=q):q=t[60];let J;t[61]!==q||t[62]!==f?(J=(0,$.jsxs)(V,{closeOnClick:!1,onClick:lt,className:`justify-between`,disabled:f,children:[re,q]}),t[61]=q,t[62]=f,t[63]=J):J=t[63];let Y,se,ce;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,$.jsx)(_,{}),se=(0,$.jsx)(V,{onClick:st,children:`Clear cookies`}),ce=(0,$.jsx)(V,{onClick:at,children:`Clear cache`}),t[64]=Y,t[65]=se,t[66]=ce):(Y=t[64],se=t[65],ce=t[66]);let le;return t[67]!==A||t[68]!==I||t[69]!==J||t[70]!==C||t[71]!==T||t[72]!==D?(le=(0,$.jsxs)(k,{children:[b,(0,$.jsxs)(S,{align:`end`,sideOffset:6,className:`min-w-56`,children:[C,T,D,A,I,L,J,Y,se,ce]})]}),t[67]=A,t[68]=I,t[69]=J,t[70]=C,t[71]=T,t[72]=D,t[73]=le):le=t[73],le}function at(){X.clearCache().catch(ot)}function ot(){}function st(){X.clearCookies().catch(ct)}function ct(){}function lt(e){return e.preventDefault()}function ut(e){return(0,$.jsx)(s,{value:e.value,children:e.label},e.value)}function dt(){}function ft(){}function pt(e){return i[e]||(e.length>0?e:`Network error`)}function mt(e){let t=(0,Z.c)(32),{url:n,code:r,description:i,onReload:a}=e,[o,s]=(0,Q.useState)(!1),c;t[0]===n?c=t[1]:(c=_t(n)??n,t[0]=n,t[1]=c);let l=c,u;t[2]===i?u=t[3]:(u=pt(i),t[2]=i,t[3]=u);let d=u,f;t[4]!==r||t[5]!==i?(f=i.length>0?i:`ERR_${Math.abs(r)||`FAILED`}`,t[4]=r,t[5]=i,t[6]=f):f=t[6];let p=f,m,h;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(gt,{className:`mb-6 size-12 text-muted-foreground/70`}),h=(0,$.jsx)(`h1`,{className:`mb-3 text-2xl font-semibold leading-tight text-foreground`,children:`This site can’t be reached`}),t[7]=m,t[8]=h):(m=t[7],h=t[8]);let g;t[9]===l?g=t[10]:(g=(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:l}),t[9]=l,t[10]=g);let _;t[11]!==d||t[12]!==g?(_=(0,$.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:[g,`: `,d,`.`]}),t[11]=d,t[12]=g,t[13]=_):_=t[13];let v;t[14]===o?v=t[15]:(v=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]=v);let y;t[16]===p?y=t[17]:(y=(0,$.jsx)(`div`,{className:`mt-8 text-xs uppercase tracking-wide text-muted-foreground/70`,children:p}),t[16]=p,t[17]=y);let b;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>s(ht),t[18]=b):b=t[18];let x=o?`Hide details`:`Details`,S;t[19]===x?S=t[20]:(S=(0,$.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,onClick:b,children:x}),t[19]=x,t[20]=S);let C;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(`div`,{className:`flex-1`}),t[21]=C):C=t[21];let w;t[22]===a?w=t[23]:(w=(0,$.jsx)(O,{type:`button`,size:`sm`,onClick:a,children:`Reload`}),t[22]=a,t[23]=w);let T;t[24]!==S||t[25]!==w?(T=(0,$.jsxs)(`div`,{className:`mt-auto flex items-center gap-2 pt-8`,children:[S,C,w]}),t[24]=S,t[25]=w,t[26]=T):T=t[26];let E;return t[27]!==T||t[28]!==_||t[29]!==v||t[30]!==y?(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:[m,h,_,v,y,T]})}),t[27]=T,t[28]=_,t[29]=v,t[30]=y,t[31]=E):E=t[31],E}function ht(e){return!e}function gt(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 _t(e){try{return new URL(e).host}catch{return null}}function vt(e){let t=e.toLowerCase();return t.includes(`mac`)?`Reveal in Finder`:t.includes(`win`)?`Reveal in File Explorer`:`Reveal in Files`}var yt=120,bt=220,xt=4,St=90,Ct=.08,wt=.5;function Tt(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),bt);return()=>window.clearTimeout(e)}n(e=>e>0&&e<95?e:xt);let t=window.setInterval(()=>{let e=r.current;if(e>=St)return;let t=St-e,i=Math.max(wt,t*Ct);n(Math.min(St,e+i))},yt);return()=>window.clearInterval(t)},[e]),t}var Et=class extends v()(`PreviewSessionThreadKeyParseError`,{threadKey:l}){get message(){return`Invalid scoped preview thread key: ${this.threadKey}`}},Dt=o(e=>{let t=j(e);if(t===null)throw new Et({threadKey:e});let n=z.list({environmentId:t.environmentId,input:{threadId:t.threadId}}),r=z.events({environmentId:t.environmentId,input:{}});return f(e=>{let i=!1,a=0,o=e=>{D(e)&&R(t,e.value)},s=r=>{if(!D(r)||r.value.threadId!==t.threadId)return;let i=m(t).serverEpoch;if(i!==null&&i!==r.value.serverEpoch){e.refresh(n);return}w(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(C(1e3),d(`preview:session-sync:${e}`))});function Ot(e){let t=(0,Z.c)(2),n;t[0]===e?n=t[1]:(n=Dt(F(e)),t[0]=e,t[1]=n),P(n)}var kt=1500,At=.001;function jt(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)<At))return a.current=n,i(!0),o.current!==null&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{i(!1),o.current=null},kt),()=>{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=y(`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 Mt(e,t){return e?1:t===`human`?.18:.35}var Nt=700;function Pt(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=we(a),s;t[2]===n?s=t[3]:(s=e=>e.byTabId[n]?.content??null,t[2]=n,t[3]=s);let c=me(s);if(!o)return null;let l;return t[4]!==c||t[5]!==i||t[6]!==o||t[7]!==r?(l=(0,$.jsx)(Ft,{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 Ft(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),Nt);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=Mt(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 It=typeof window>`u`?null:L();function Lt({threadRef:e,tabId:t,configuredUrls:n,visible:r}){let[i,a]=(0,Q.useState)(void 0),[o,s]=(0,Q.useState)(!1),c=Me(),l=(0,Q.useRef)(!1),u=(0,Q.useRef)(!0),d=b(e),f=ke(t=>q(t.byThreadKey,e)),m=U(e=>e.addPreviewAnnotation),h=U(e=>e.addImage),g=ee(e.environmentId),_=ae(e.environmentId),v=W(z.open),y=W(z.resize,`preview viewport resize`),{resolvedTheme:x}=H();Ot(e),(0,Q.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]);let S=t??d.activeTabId,C=S?ue(e,d.serverEpoch,S):null,w=S&&C?c.has(C)?C:Pe(e,S):null,D=S?d.sessions[S]??null:null,O=S?d.desktopByTabId[S]??null:null;(0,Q.useEffect)(()=>{let e=X;if(!(!e||!C||!O?.pictureInPicture))return e.pictureInPicture.setVisible(C,r),()=>{e.pictureInPicture.setVisible(C,!1)}},[O?.pictureInPicture,C,r]);let k=D?.navStatus??{_tag:`Idle`},j=k._tag===`Idle`?``:k.url,N=O?.loading??k._tag===`Loading`,P=O?.canGoBack??D?.canGoBack??!1,te=O?.canGoForward??D?.canGoForward??!1,ne=k._tag===`Idle`,L=k._tag===`LoadFailed`,R=fe(D),B=O?.controller??`none`,V=Tt(N),oe=j&&g&&_?Ke({url:j,environmentLabel:g.label,environmentHttpBaseUrl:_})??void 0:void 0,G=D?.viewport??T,K=me(e=>C?e.byTabId[C]?.rect??null:null),J=(0,Q.useCallback)(async t=>{C&&X?(await X.navigate(C,t),p(e,t)):await Re({openPreview:v,threadRef:e,url:t})},[v,C,e]),se=(0,Q.useCallback)(async e=>{try{await J(Y(e))}catch{}},[J]),ce=(0,Q.useCallback)(async t=>{try{await J(ge(e.environmentId,t))}catch{}},[J,e.environmentId]),le=(0,Q.useCallback)(()=>{X&&C&&X.refresh(C)},[C]),pe=(0,Q.useCallback)(()=>{X&&C&&X.zoomIn(C)},[C]),he=(0,Q.useCallback)(()=>{X&&C&&X.zoomOut(C)},[C]),_e=(0,Q.useCallback)(()=>{X&&C&&X.resetZoom(C)},[C]),ve=(0,Q.useCallback)(async t=>{if(!S)return;let n=await y({environmentId:e.environmentId,input:{threadId:e.threadId,tabId:S,viewport:t}});if(n._tag===`Failure`){let e=I(n);throw A.add({type:`error`,title:`Unable to resize browser viewport`,description:e instanceof Error?e.message:`An error occurred.`}),e}E(e,n.value)},[y,S,e]),ye=()=>{if(!C)return;if(G._tag!==`fill`){Ie(C,T).catch(()=>void 0);return}let e=K?Fe(K,O?.zoomFactor):{width:1024,height:768};Ie(C,{_tag:`freeform`,...e}).catch(()=>void 0)};(0,Q.useEffect)(()=>{if(C)return Ae(C,ve)},[ve,C]);let be=(0,Q.useCallback)(()=>{X&&C&&X.goBack(C)},[C]),xe=(0,Q.useCallback)(()=>{X&&C&&X.goForward(C)},[C]),Se=(0,Q.useCallback)(()=>{!It||!j||It.shell.openExternal(j).catch(()=>void 0)},[j]),we=(0,Q.useCallback)(()=>{if(S){if(f?.tabId===S){ke.getState().close(e);return}ke.getState().open(e,S),re.getState().close(e)}},[f?.tabId,S,e]),Te=(0,Q.useCallback)(()=>{!X||!C||(O?.pictureInPicture?X.pictureInPicture.close:X.pictureInPicture.open)(C).catch(e=>{A.add({type:`error`,title:`Unable to update popped-out preview`,description:e instanceof Error?e.message:`An error occurred.`})})},[O?.pictureInPicture,C]),Ee=(0,Q.useCallback)(t=>{if(!X||!C||!S)return;let n=X;if(w){Ce(w).then(e=>{if(!e)return;let t=!1,r,i=()=>{if(!navigator.clipboard?.writeText){A.update(r,M({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=>{A.update(r,M({type:`error`,title:`Unable to copy recording path`,description:e instanceof Error?e.message:`An error occurred.`,actionProps:a}))})},a={children:vt(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},o=()=>{A.update(r,M({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:t?`Copied!`:`Copy path`,disabled:t,onClick:i},secondaryActionVariant:`outline`}}))};r=A.add(M({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:`Copy path`,onClick:i},secondaryActionVariant:`outline`}}))},e=>{A.add({type:`error`,title:`Unable to stop recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}if(t){Oe(C,e,S).catch(e=>{A.add({type:`error`,title:`Unable to start recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}n.captureScreenshot(C).then(e=>{let t={children:vt(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},r=!1,i=!1,a,o=(e=`success`,n=`Screenshot saved`,o)=>{A.update(a,M({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=A.add(M({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=>{A.add({type:`error`,title:`Unable to capture screenshot`,description:e instanceof Error?e.message:`An error occurred.`})})},[w,C,S,e]),je=(0,Q.useCallback)(()=>{if(!X||!C)return;if(l.current){X.cancelPickElement(C).catch(()=>void 0);return}let t=typeof document<`u`?document.activeElement:null;l.current=!0,s(!0),(async()=>{try{let t=await X.pickElement(C);if(!t)return;m(e,t);let n=await De(t);n&&t.screenshot&&h(e,{type:`image`,id:t.id,name:n.name,mimeType:n.type,sizeBytes:n.size,previewUrl:t.screenshot.dataUrl,file:n})}catch{}finally{if(l.current=!1,u.current&&s(!1),t&&t.isConnected&&typeof t.focus==`function`)try{t.focus({preventScroll:!0})}catch{}}})()},[h,m,C,e]);return(0,Q.useEffect)(()=>{let e=ie(j,x);e&&J(e).catch(()=>void 0)},[J,x,j]),(0,Q.useEffect)(()=>()=>{l.current&&(l.current=!1,X&&C&&X.cancelPickElement(C).catch(()=>void 0),u.current&&s(!1))},[C]),(0,Q.useEffect)(()=>{if(r)return Le(e=>{switch(e){case`refresh`:le();return;case`focus-url`:a(e=>(e??0)+1);return;case`zoom-in`:pe();return;case`zoom-out`:he();return;case`reset-zoom`:_e();return;case`toggle-panel`:return}})},[le,_e,pe,he,r]),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,"data-thread-key":F(e),children:[(0,$.jsx)(Ge,{url:j,displayUrl:oe,loading:N,loadProgress:V,canGoBack:P,canGoForward:te,refreshDisabled:ne,focusUrlNonce:i,onBack:be,onForward:xe,onRefresh:le,onSubmit:e=>void se(e),onOpenInBrowser:S?Se:void 0,onCapture:X&&S?Ee:void 0,captureDisabled:!O||L,recording:w!==null,onPictureInPicture:X&&S?we:void 0,pictureInPicture:f?.tabId===S,pictureInPictureDisabled:!O?.hasWebContents||L,onPickElement:X&&S?je:void 0,pickActive:o,pickDisabled:!S||L,pickDisabledReason:L?`Page didn't load — pick unavailable until the page renders`:void 0,trailingActions:X?(0,$.jsx)(it,{tabId:C,hasWebContents:O?.hasWebContents??!1,zoomFactor:O?.zoomFactor??1,colorScheme:O?.colorScheme??`system`,deviceToolbarVisible:G._tag!==`fill`,onToggleDeviceToolbar:ye,nativePictureInPicture:O?.pictureInPicture??!1,onNativePictureInPicture:Te}):null}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[C&&D&&!R?(0,$.jsx)(de,{tabId:C,visible:r&&!L,className:`absolute inset-0 h-full w-full`},C):null,R?(0,$.jsx)(nt,{environmentId:e.environmentId,configuredUrls:n,recentlySeenUrls:d.recentlySeenUrls,onOpenUrl:e=>void ce(e)}):null,D&&O?(0,$.jsx)(jt,{zoomFactor:O.zoomFactor}):null,C&&O&&!R&&!L?(0,$.jsx)(Pt,{tabId:C,zoomFactor:O.zoomFactor,controller:B}):null,B===`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:B===`agent`?`Agent controlling browser`:`Human control`}),k._tag===`LoadFailed`?(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(mt,{url:k.url,code:k.code,description:k.description,onReload:le})}):null]})]})}function Rt(e){let t=(0,Z.c)(13),{mode:n,threadRef:r,tabId:i,configuredUrls:a,visible:o}=e;if(!u()){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 P4Code desktop app.`})}),t[0]=e):e=t[0];let r;return t[1]===n?r=t[2]:(r=(0,$.jsx)(ze,{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)(Lt,{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)(ze,{mode:n,children:c}),t[10]=n,t[11]=c,t[12]=l):l=t[12],l}export{Rt as PreviewPanel};
|
|
2
|
-
//# sourceMappingURL=PreviewPanel-ZUpYbtlk.js.map
|