@p4code/cli 0.6.7 → 0.6.8

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,98 +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{Ba as i,Dt as a,Ia as o,Ja as s,Ka as c,Ll as ee,Na as te,Sn as l,Va as u,Wr as d,Wu as f,Xa as p,Xr as ne,Ya as re,_t as m,_u as ie,b as h,ct as g,du as _,eu as v,fl as y,gt as b,h as x,hl as S,ml as C,ou as ae,pl as w,qa as T,vn as E,yt as D,zr as oe}from"./previewAssetResource-x8WpJWsS.js";import{a as O,c as se,i as k,n as A,o as j,r as M,s as ce,t as N}from"./toggle-group-DJvoLvYJ.js";import{A as le,Fr as ue,J as de,Lr as fe,M as P,Mr as pe,Nr as me,Rr as he,Y as ge,_ as _e,_r as ve,cr as ye,ct as be,dr as xe,dt as Se,fr as Ce,ft as we,h as Te,hr as Ee,j as De,jr as Oe,k as ke,lr as Ae,lt as je,oi as Me,or as Ne,ot as Pe,pr as Fe,si as Ie,sr as Le,st as Re,ur as ze,ut as Be,yr as Ve}from"./index-eQUin3Y8.js";import{a as He,n as Ue}from"./fileCommentAnnotations-BpEl_BHN.js";var We=S(`pilcrow`,[[`path`,{d:`M13 4v16`,key:`8vvj80`}],[`path`,{d:`M17 4v16`,key:`7dpous`}],[`path`,{d:`M19 4H9.5a4.5 4.5 0 0 0 0 9H13`,key:`sh4n9v`}]]),F=e(n(),1);function Ge({threadRef:e,filePath:t,activeCwd:n,openInEditor:r,openFileSurface:i}){if(e){if(i){i(t);return}g.getState().openFile(e,t);return}r(n?x(t,n):t)}var I=r();function Ke(e,t){let n=(0,I.c)(4),r=Ee(e,t),i;return n[0]!==r.data||n[1]!==r.error||n[2]!==r.isPending?(i={data:r.data,error:r.error,isPending:r.isPending},n[0]=r.data,n[1]=r.error,n[2]=r.isPending,n[3]=i):i=n[3],i}var L=t(),qe=[];function Je(e){return(e.endSide??e.side)===`deletions`?`deletions`:`additions`}function R(e,t,n){let r=Je(t),i=e.findIndex(e=>e.side===r&&e.lineNumber===t.end);return i<0?[...e,{side:r,lineNumber:t.end,metadata:{entries:[n]}}]:e.map((e,t)=>t===i?{...e,metadata:{entries:[...e.metadata.entries,n]}}:e)}function Ye(e){let t=(0,I.c)(50),{files:n,sectionId:r,sectionTitle:i,composerDraftTarget:a,options:o,viewerRef:s,className:c,renderHeaderPrefix:ee}=e,te=oe(Qe),l=oe(B),u;t[0]===a?u=t[1]:(u=e=>e.getComposerDraft(a)?.reviewComments??qe,t[0]=a,t[1]=u);let f=oe(u),[p,re]=(0,F.useState)(null),[m,ie]=(0,F.useState)(null),h;t[2]===n?h=t[3]:(h=new Map(n.map(Ze)),t[2]=n,t[3]=h);let g=h,_;if(t[4]!==m||t[5]!==n||t[6]!==f||t[7]!==r){let e;t[9]!==m||t[10]!==f||t[11]!==r?(e=e=>{let{fileDiff:t,filePath:n,fileKey:i,collapsed:a}=e,o=f.filter(e=>e.sectionId===r&&e.filePath===n&&(e.fenceLanguage??`diff`)===`diff`).reduce((e,n)=>{let r=ne(t,n);return r?R(e,r,{id:n.id,kind:`comment`,range:r,rangeLabel:n.rangeLabel,text:n.text}):e},[]),s=m?.fileKey===i?[...o,m.annotation]:o;return{id:i,type:`diff`,fileDiff:t,annotations:s,collapsed:a,version:Re(`${a?`1`:`0`}:${s.flatMap(z).join(`:`)}`)}},t[9]=m,t[10]=f,t[11]=r,t[12]=e):e=t[12],_=n.map(e),t[4]=m,t[5]=n,t[6]=f,t[7]=r,t[8]=_}else _=t[8];let v=_,y;t[13]!==a||t[14]!==m?.annotation||t[15]!==l?(y=e=>{re(null),m?.annotation.metadata.entries.some(t=>t.id===e)?ie(null):l(a,e)},t[13]=a,t[14]=m?.annotation,t[15]=l,t[16]=y):y=t[16];let b=y,x;t[17]!==te||t[18]!==a||t[19]!==m||t[20]!==g||t[21]!==r||t[22]!==i?(x=(e,t)=>{let n=m?.annotation.metadata.entries.find(t=>t.id===e),o=m?g.get(m.fileKey):void 0;if(!n||!o)return;let s=d({id:n.id,sectionId:r,sectionTitle:i,filePath:o.filePath,fileDiff:o.fileDiff,range:n.range,text:t});s&&te(a,s),re(null),ie(null)},t[17]=te,t[18]=a,t[19]=m,t[20]=g,t[21]=r,t[22]=i,t[23]=x):x=t[23];let S=x,C;t[24]!==g||t[25]!==r||t[26]!==i?(C=(e,t)=>{if(!e)return;let n=t.item;if(n.type!==`diff`)return;let a=g.get(n.id);if(!a)return;let o=Ue(),s=d({id:o,sectionId:r,sectionTitle:i,filePath:a.filePath,fileDiff:a.fileDiff,range:e,text:``});s&&ie({fileKey:n.id,annotation:{side:Je(e),lineNumber:e.end,metadata:{entries:[{id:o,kind:`draft`,range:e,rangeLabel:s.rangeLabel,text:``}]}}})},t[24]=g,t[25]=r,t[26]=i,t[27]=C):C=t[27];let ae=C,w=m!==null,T;t[28]===s?T=t[29]:(T=s?{ref:s}:{},t[28]=s,t[29]=T);let E;t[30]===c?E=t[31]:(E=c?{className:c}:{},t[30]=c,t[31]=E);let D=!w,se=!w,k;t[32]!==ae||t[33]!==o||t[34]!==se||t[35]!==D?(k={...o,enableGutterUtility:D,enableLineSelection:se,onLineSelectionEnd:ae},t[32]=ae,t[33]=o,t[34]=se,t[35]=D,t[36]=k):k=t[36];let A;t[37]===ee?A=t[38]:(A=e=>e.type===`diff`?ee(e.fileDiff,e.id,e.collapsed===!0):null,t[37]=ee,t[38]=A);let j;t[39]!==b||t[40]!==S?(j=e=>(0,L.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,L.jsx)(He,{kind:e.kind,rangeLabel:e.rangeLabel,text:e.text,onCancel:()=>b(e.id),onComment:t=>S(e.id,t),onDelete:()=>b(e.id)},e.id))}),t[39]=b,t[40]=S,t[41]=j):j=t[41];let M;return t[42]!==v||t[43]!==p||t[44]!==k||t[45]!==A||t[46]!==j||t[47]!==T||t[48]!==E?(M=(0,L.jsx)(O,{...T,...E,items:v,selectedLines:p,onSelectedLinesChange:re,options:k,renderHeaderPrefix:A,renderAnnotation:j}),t[42]=v,t[43]=p,t[44]=k,t[45]=A,t[46]=j,t[47]=T,t[48]=E,t[49]=M):M=t[49],M}function z(e){return e.metadata.entries.map(Xe)}function Xe(e){return`${e.id}:${e.rangeLabel}:${e.text}`}function Ze(e){return[e.fileKey,e]}function B(e){return e.removeReviewComment}function Qe(e){return e.addReviewComment}function $e(e){return{diffPreview:v(e,{label:`environment-data:review:diff-preview`,tag:f.reviewGetDiffPreview,staleTimeMs:5e3})}}var et=$e(l);function V(e){return e.remoteName&&e.name.startsWith(`${e.remoteName}/`)?e.name.slice(e.remoteName.length+1):e.name}function tt(e,t){let n=new Set(t),r=e.map(e=>{let r=t.filter(t=>n.has(t)&&V(t)===e.name),i=r.find(e=>e.remoteName===`origin`)??r[0]??null;return i&&n.delete(i),{id:`local:${e.name}`,label:e.name,local:e,remote:i}}),i=t.filter(e=>n.has(e)).map(e=>({id:`remote:${e.name}`,label:e.name,local:null,remote:e}));return[...r,...i]}function nt(e,t){let n=t.trim().toLocaleLowerCase();return n.length===0?e:e.filter(e=>e.label.toLocaleLowerCase().includes(n)||e.local?.name.toLocaleLowerCase().includes(n)===!0||e.remote?.name.toLocaleLowerCase().includes(n)===!0)}var H=`__automatic_base_ref__`,rt=new Set,it=`
2
- [data-diffs-header],
3
- [data-diff],
4
- [data-file],
5
- [data-error-wrapper],
6
- [data-virtualizer-buffer] {
7
- --diffs-header-font-family: var(--font-sans) !important;
8
- --diffs-font-family: var(--font-mono) !important;
9
- --diffs-bg: color-mix(in srgb, var(--card) 90%, var(--background)) !important;
10
- --diffs-light-bg: color-mix(in srgb, var(--card) 90%, var(--background)) !important;
11
- --diffs-dark-bg: color-mix(in srgb, var(--card) 90%, var(--background)) !important;
12
- --diffs-token-light-bg: transparent;
13
- --diffs-token-dark-bg: transparent;
14
-
15
- --diffs-bg-context-override: color-mix(in srgb, var(--background) 97%, var(--foreground));
16
- --diffs-bg-hover-override: color-mix(in srgb, var(--background) 94%, var(--foreground));
17
- --diffs-bg-separator-override: color-mix(in srgb, var(--background) 95%, var(--foreground));
18
- --diffs-bg-buffer-override: color-mix(in srgb, var(--background) 90%, var(--foreground));
19
-
20
- --diffs-bg-addition-override: color-mix(in srgb, var(--background) 92%, var(--success));
21
- --diffs-bg-addition-number-override: color-mix(in srgb, var(--background) 88%, var(--success));
22
- --diffs-bg-addition-hover-override: color-mix(in srgb, var(--background) 85%, var(--success));
23
- --diffs-bg-addition-emphasis-override: color-mix(in srgb, var(--background) 80%, var(--success));
24
-
25
- --diffs-bg-deletion-override: color-mix(in srgb, var(--background) 92%, var(--destructive));
26
- --diffs-bg-deletion-number-override: color-mix(in srgb, var(--background) 88%, var(--destructive));
27
- --diffs-bg-deletion-hover-override: color-mix(in srgb, var(--background) 85%, var(--destructive));
28
- --diffs-bg-deletion-emphasis-override: color-mix(
29
- in srgb,
30
- var(--background) 80%,
31
- var(--destructive)
32
- );
33
-
34
- background-color: var(--diffs-bg) !important;
35
- }
36
-
37
- [data-file-info] {
38
- background-color: color-mix(in srgb, var(--card) 94%, var(--foreground)) !important;
39
- border-block-color: var(--border) !important;
40
- color: var(--foreground) !important;
41
- }
42
-
43
- [data-diffs-header] {
44
- position: sticky !important;
45
- top: 0;
46
- z-index: 4;
47
- background-color: color-mix(in srgb, var(--card) 94%, var(--foreground)) !important;
48
- border-bottom: 1px solid var(--border) !important;
49
- align-items: center !important;
50
- font-family: var(--font-sans) !important;
51
- font-size: 12px !important;
52
- line-height: 1 !important;
53
- min-height: 32px !important;
54
- padding-block: 6px !important;
55
- }
56
-
57
- [data-diffs-header] [data-header-content] {
58
- align-items: center !important;
59
- line-height: 1 !important;
60
- }
61
-
62
- [data-diffs-header] [data-metadata] {
63
- align-items: center !important;
64
- line-height: 1 !important;
65
- font-variant-numeric: tabular-nums;
66
- }
67
-
68
- [data-diffs-header] [data-additions-count],
69
- [data-diffs-header] [data-deletions-count] {
70
- font-family: var(--font-mono) !important;
71
- font-size: 11px !important;
72
- font-variant-numeric: tabular-nums;
73
- line-height: 1 !important;
74
- }
75
-
76
- [data-diffs-header] [data-change-icon],
77
- [data-diffs-header] [data-rename-icon] {
78
- display: block;
79
- flex-shrink: 0;
80
- }
81
-
82
- [data-title] {
83
- cursor: pointer;
84
- transition:
85
- color 120ms ease,
86
- text-decoration-color 120ms ease;
87
- text-decoration: underline;
88
- text-decoration-color: transparent;
89
- text-underline-offset: 2px;
90
- font-family: var(--font-sans) !important;
91
- }
92
-
93
- [data-title]:hover {
94
- color: color-mix(in srgb, var(--foreground) 84%, var(--primary)) !important;
95
- text-decoration-color: currentColor;
96
- }
97
- `;function U({mode:e=`inline`,composerDraftTarget:t,initialGitScope:n,threadRef:r}){let{resolvedTheme:l}=h(),d=ue(),[f]=(0,F.useState)(n),[ne,g]=(0,F.useState)(`stacked`),[v,x]=(0,F.useState)(d.wordWrap),[S,oe]=(0,F.useState)(d.diffIgnoreWhitespace),[O,_e]=(0,F.useState)(``),[Ee,Re]=(0,F.useState)(()=>({scopeKey:null,fileKeys:rt})),He=(0,F.useRef)(null),Ue=r.threadId,I=me(r),qe=I?.projectId??null,Je=pe(I&&qe?{environmentId:I.environmentId,projectId:qe}:null),R=I?.worktreePath??Je?.workspaceRoot,z=ee(E.configValueAtom(I?.environmentId??null)),Xe=ve(I?.environmentId??null,z?.availableEditors??[]),Ze=a(I!=null&&R!=null?Oe.status({environmentId:I.environmentId,input:{cwd:R}}):null),B=P(e=>De(e.byThreadKey,r,f===`unstaged`)),Qe=Ze.data?.isRepo??!0,{turnDiffSummaries:$e,inferredCheckpointTurnCountByTurnId:V}=le(I),U=(0,F.useMemo)(()=>[...$e].toSorted((e,t)=>{let n=e.checkpointTurnCount??V[e.turnId]??0,r=t.checkpointTurnCount??V[t.turnId]??0;return n===r?t.completedAt.localeCompare(e.completedAt):r-n}),[V,$e]);(0,F.useEffect)(()=>{B.kind===`turn`&&P.getState().reconcileTurnSelection(r,U.map(e=>e.turnId))},[B,U,r]);let W=B.kind===`turn`?B.turnId:null,G=B.kind===`unstaged`?`unstaged`:`branch`,K=B.kind===`branch`?B.baseRef:null,at=B.kind===`turn`?B.filePath:null,ot=B.kind===`turn`?B.revealRequestId:0,q=W===null?void 0:U.find(e=>e.turnId===W)??U[0],J=q&&(q.checkpointTurnCount??V[q.turnId]),st=U[0],ct=W===null?G===`unstaged`?`Working tree`:`Branch changes`:q?.turnId===st?.turnId?`Latest turn`:`Turn ${J??`?`}`,lt=q?`turn:${q.turnId}`:G,Y=`${r.environmentId}:${r.threadId}:${lt}`,ut=Ee.scopeKey===Y?Ee.fileKeys:rt,dt=q?`Turn ${J??`?`}`:G===`unstaged`?`Working tree`:`Branch changes`,ft=(0,F.useMemo)(()=>typeof J==`number`?{fromTurnCount:Math.max(0,J-1),toTurnCount:J}:null,[J]),pt=Ke({environmentId:I?.environmentId??null,threadId:Ue,fromTurnCount:ft?.fromTurnCount??null,toTurnCount:ft?.toTurnCount??null,ignoreWhitespace:S,cacheScope:q?`turn:${q.turnId}`:null},{enabled:Qe&&q!==void 0}),mt=a(W===null&&I&&R?et.diffPreview({environmentId:I.environmentId,input:{cwd:R,...K?{baseRef:K}:{},ignoreWhitespace:S}}):null),ht=W===null&&mt.error?.includes(`configured workspace root`)===!0&&z?.cwd!==void 0&&z.cwd!==R,gt=a(ht&&I&&z?et.diffPreview({environmentId:I.environmentId,input:{cwd:z.cwd,...K?{baseRef:K}:{},ignoreWhitespace:S}}):null),X=ht?gt:mt,Z=X.data?.sources.find(e=>e.kind===(G===`unstaged`?`working-tree`:`branch-range`)),_t=a(W===null&&G===`branch`&&I&&X.data?.cwd?Oe.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`local`,...O.trim().length>0?{query:O.trim()}:{},limit:100}}):null),vt=a(W===null&&G===`branch`&&I&&X.data?.cwd?Oe.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`remote`,...O.trim().length>0?{query:O.trim()}:{},limit:100}}):null),yt=tt(_t.data?.refs.filter(e=>e.name!==Z?.headRef)??[],vt.data?.refs??[]),bt=nt(yt,O),xt=e=>K&&K===e.remote?.name?K:e.local?.name??e.remote?.name??e.id,St=[H,...yt.map(xt)],Ct=[...O.trim().length===0?[H]:[],...bt.map(xt)],wt=Z?.diff,Tt=q?pt.data?.diff:wt,Et=!q&&Z?.truncated===!0,Dt=q?pt.isPending:X.isPending,Ot=q?pt.error:X.error,kt=typeof Tt==`string`&&Tt.trim().length===0,Q=(0,F.useMemo)(()=>Be(Tt,`diff-panel:${l}`,{compactPartialHunkOffsets:W===null}),[l,Tt,W]),At=(0,F.useMemo)(()=>!Q||Q.kind!==`files`?[]:Q.files.toSorted((e,t)=>we(e).localeCompare(we(t),void 0,{numeric:!0,sensitivity:`base`})),[Q]),$=(0,F.useMemo)(()=>At.map(e=>{let t=Pe(e);return{fileDiff:e,filePath:we(e),fileKey:t,collapsed:ut.has(t)}}),[ut,At]),jt=(0,F.useMemo)(()=>$.map(e=>e.fileKey),[$]),Mt=M(jt,ut),Nt=(0,F.useMemo)(()=>je(At),[At]);(0,F.useEffect)(()=>{if(!at)return;let e=$.find(e=>e.filePath===at);e&&He.current?.scrollTo({type:`item`,id:e.fileKey,align:`start`})},[$,at,ot]);let Pt=ke({threadRef:r,workspaceRoot:R??null}),Ft=(0,F.useCallback)(e=>{Ge({threadRef:r,filePath:e,activeCwd:R,openFileSurface:Pt,openInEditor:e=>{(async()=>{let t=await Xe(e);t._tag===`Failure`&&!ae(t)&&console.warn(`Failed to open diff file in editor.`,{operation:`open-diff-file`,environmentId:r.environmentId,threadId:r.threadId,...ie(_(t))})})()}})},[R,Pt,Xe,r]),It=(0,F.useCallback)(e=>{Re(t=>{let n=new Set(t.scopeKey===Y?t.fileKeys:[]);return n.has(e)?n.delete(e):n.add(e),{scopeKey:Y,fileKeys:n}})},[Y]),Lt=(0,F.useCallback)(()=>{Re(e=>{let t=e.scopeKey===Y?e.fileKeys:rt;return{scopeKey:Y,fileKeys:k(jt,t)}})},[Y,jt]),Rt=e=>{P.getState().selectTurn(r,e)},zt=e=>{P.getState().selectGitScope(r,e)},Bt=e=>{P.getState().selectBranchBaseRef(r,e)};return(0,L.jsx)(ge,{mode:e,header:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3 [-webkit-app-region:no-drag]`,children:[(0,L.jsxs)(o,{children:[(0,L.jsxs)(re,{className:`inline-flex h-6 max-w-full items-center gap-1 rounded-md bg-muted/70 px-2 text-xs font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Diff scope: ${ct}`,children:[(0,L.jsx)(`span`,{className:`truncate`,children:ct}),(0,L.jsx)(w,{className:`size-3.5 shrink-0 text-muted-foreground`})]}),(0,L.jsxs)(u,{align:`start`,className:`w-60`,children:[(0,L.jsx)(i,{className:W===null&&G===`unstaged`?`bg-foreground/[0.08]`:void 0,onClick:()=>zt(`unstaged`),children:(0,L.jsx)(`span`,{children:`Working tree`})}),(0,L.jsx)(i,{className:W===null&&G===`branch`?`bg-foreground/[0.08]`:void 0,onClick:()=>zt(`branch`),children:(0,L.jsx)(`span`,{children:`Branch changes`})}),(0,L.jsx)(i,{className:W!==null&&q?.turnId===st?.turnId?`bg-foreground/[0.08]`:void 0,onClick:()=>{st&&Rt(st.turnId)},children:(0,L.jsx)(`span`,{children:`Latest turn`})}),(0,L.jsxs)(c,{children:[(0,L.jsx)(s,{children:`Turn`}),(0,L.jsx)(T,{className:`w-64`,children:U.map(e=>{let t=e.checkpointTurnCount??V[e.turnId]??`?`;return(0,L.jsxs)(i,{className:e.turnId===q?.turnId?`bg-foreground/[0.08]`:void 0,onClick:()=>Rt(e.turnId),children:[(0,L.jsxs)(`span`,{children:[`Turn `,t]}),(0,L.jsx)(`span`,{className:`ml-auto text-xs tabular-nums text-muted-foreground`,children:Ve(e.completedAt,d.timestampFormat)})]},e.turnId)})})]})]})]}),W===null&&G===`branch`&&Z?.baseRef&&(0,L.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-center gap-2 overflow-hidden text-xs text-muted-foreground`,title:`${Z.headRef??`HEAD`} → ${Z.baseRef}`,"aria-label":`Comparing ${Z.headRef??`HEAD`} against ${Z.baseRef}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 max-w-48 truncate`,children:Z.headRef??`HEAD`}),(0,L.jsx)(Ie,{className:`size-3.5 shrink-0 opacity-70`}),(0,L.jsxs)(Ne,{items:St,filteredItems:Ct,value:K??H,onOpenChange:e=>{e||_e(``)},onValueChange:e=>{e&&Bt(e===H?null:e)},children:[(0,L.jsxs)(Ce,{className:`inline-flex min-w-0 max-w-48 items-center gap-1 overflow-hidden rounded-md px-1.5 py-1 outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Change comparison target. Currently ${Z.baseRef}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:Z.baseRef}),(0,L.jsx)(w,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,L.jsxs)(xe,{align:`start`,className:`w-72 min-w-0 max-w-[calc(100vw-1rem)] overflow-hidden [&>[data-slot=combobox-popup]]:min-w-0 [&>[data-slot=combobox-popup]]:overflow-hidden`,children:[(0,L.jsx)(`div`,{className:`min-w-0 shrink-0 px-3 pt-2.5`,children:(0,L.jsxs)(`div`,{className:`relative -translate-y-px border-b border-border/70 pb-1.5 transition-colors focus-within:border-ring`,children:[(0,L.jsx)(he,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1.5 left-0 size-4 shrink-0 text-muted-foreground/55`}),(0,L.jsx)(ye,{className:`[&_input]:h-6.5 [&_input]:ps-5 [&_input]:font-sans [&_input]:leading-6.5`,inputClassName:`rounded-none bg-transparent text-sm`,placeholder:`Search refs...`,showTrigger:!1,size:`sm`,unstyled:!0,value:O,onChange:e=>_e(e.target.value)})]})}),(0,L.jsxs)(`div`,{className:`grid shrink-0 grid-cols-[1rem_minmax(0,1fr)] items-center gap-2 border-b border-border/70 ps-3 pe-6.5 pt-2 pb-1.5 font-medium text-[10px] text-muted-foreground uppercase tracking-wide`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`}),(0,L.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_2rem] items-center`,children:[(0,L.jsx)(`span`,{children:`Branch`}),(0,L.jsx)(`span`,{className:`text-right`,children:`Remote`})]})]}),(0,L.jsx)(Le,{children:`No matching refs.`}),(0,L.jsxs)(ze,{className:`max-h-64 min-w-0 overflow-x-hidden`,children:[(0,L.jsx)(Ae,{className:`h-8 w-full min-w-0 grid-cols-[1rem_minmax(0,1fr)] py-0`,contentClassName:`w-full min-w-0 overflow-hidden`,value:H,children:(0,L.jsx)(`span`,{className:`block min-w-0 truncate`,children:`Automatic`})}),yt.map(e=>{let t=xt(e),n=e.local!==null&&e.remote!==null,r=e.remote?.name===t;return(0,L.jsx)(Ae,{className:`h-8 w-full min-w-0 grid-cols-[1rem_minmax(0,1fr)] py-0`,contentClassName:`w-full min-w-0 overflow-hidden`,value:t,children:(0,L.jsxs)(`div`,{className:`grid w-full min-w-0 grid-cols-[minmax(0,1fr)_2rem] items-center overflow-hidden`,children:[(0,L.jsx)(`span`,{className:`block min-w-0 truncate pe-2`,children:e.label}),n?(0,L.jsx)(`div`,{className:`flex justify-end`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,L.jsx)(Fe,{"aria-label":`Use remote version of ${e.label}`,checked:r,className:`[--thumb-size:--spacing(3)]`,onCheckedChange:t=>{let n=t?e.remote?.name:e.local?.name;n&&Bt(n)}})}):e.remote?(0,L.jsx)(`span`,{className:`flex justify-end text-muted-foreground`,title:`Remote only`,children:(0,L.jsx)(C,{"aria-hidden":`true`,className:`size-3`})}):null]})},e.id)})]})]})]})]})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 [-webkit-app-region:no-drag]`,children:[$.length>0&&(0,L.jsx)(Te,{additions:Nt.additions,deletions:Nt.deletions,className:`mr-1 text-[11px]`,layout:`inline`}),$.length>0&&(0,L.jsxs)(b,{children:[(0,L.jsx)(D,{render:(0,L.jsx)(te,{type:`button`,size:`icon-xs`,variant:`outline`,"aria-label":Mt?`Expand all files`:`Collapse all files`,onClick:Lt}),children:Mt?(0,L.jsx)(Me,{className:`size-3`}):(0,L.jsx)(se,{className:`size-3`})}),(0,L.jsx)(m,{side:`top`,children:Mt?`Expand all files`:`Collapse all files`})]}),(0,L.jsxs)(A,{className:`shrink-0`,variant:`outline`,size:`xs`,value:[ne],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&g(t)},children:[(0,L.jsx)(N,{"aria-label":`Stacked diff view`,value:`stacked`,children:(0,L.jsx)(j,{className:`size-3`})}),(0,L.jsx)(N,{"aria-label":`Split diff view`,value:`split`,children:(0,L.jsx)(ce,{className:`size-3`})})]}),(0,L.jsxs)(b,{children:[(0,L.jsx)(D,{render:(0,L.jsx)(N,{"aria-label":v?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`outline`,size:`xs`,pressed:v,onPressedChange:e=>{x(!!e)}}),children:(0,L.jsx)(fe,{className:`size-3`})}),(0,L.jsx)(m,{side:`top`,children:v?`Disable line wrapping`:`Enable line wrapping`})]}),(0,L.jsxs)(b,{children:[(0,L.jsx)(D,{render:(0,L.jsx)(N,{"aria-label":S?`Show whitespace changes`:`Hide whitespace changes`,variant:`outline`,size:`xs`,pressed:S,onPressedChange:e=>{oe(!!e)}}),children:(0,L.jsx)(We,{className:`size-3`})}),(0,L.jsx)(m,{side:`top`,children:S?`Show whitespace changes`:`Hide whitespace changes`})]})]})]}),children:I?Qe?W!==null&&U.length===0?(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`No completed turns yet.`}):(0,L.jsx)(L.Fragment,{children:(0,L.jsxs)(`div`,{className:`diff-panel-viewport flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[Et&&(0,L.jsx)(`p`,{className:`shrink-0 border-b border-border/70 bg-muted/40 px-3 py-1.5 text-[11px] text-muted-foreground`,children:`This diff was truncated because it exceeded the preview limit. The changes shown are incomplete.`}),Ot&&!Q&&(0,L.jsx)(`div`,{className:`px-3`,children:(0,L.jsx)(`p`,{className:`mb-2 text-[11px] text-red-500/80`,children:Ot})}),Q?Q.kind===`files`?(0,L.jsx)(`div`,{className:`min-h-0 flex-1`,onClickCapture:e=>{let t=(e.nativeEvent.composedPath?.()??[]).find(e=>e instanceof HTMLElement&&e.hasAttribute(`data-title`))?.textContent?.trim();t&&Ft(t)},children:(0,L.jsx)(Ye,{viewerRef:He,className:`diff-render-surface h-full min-h-0 overflow-auto`,files:$,sectionId:lt,sectionTitle:dt,composerDraftTarget:t,renderHeaderPrefix:(e,t,n)=>{let r=we(e);return(0,L.jsxs)(b,{children:[(0,L.jsx)(D,{render:(0,L.jsx)(`button`,{type:`button`,className:p(`inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm border-0 bg-transparent p-0 transition-colors hover:bg-foreground/10 focus-visible:outline-hidden`,be(e)),"aria-label":n?`Expand ${r}`:`Collapse ${r}`,"aria-expanded":!n,onClick:e=>{e.stopPropagation(),It(t)}}),children:n?(0,L.jsx)(y,{className:`size-4`}):(0,L.jsx)(w,{className:`size-4`})}),(0,L.jsx)(m,{side:`top`,children:n?`Expand diff`:`Collapse diff`})]})},options:{diffStyle:ne===`split`?`split`:`unified`,lineDiffType:`none`,overflow:v?`wrap`:`scroll`,theme:Se(l),themeType:l,unsafeCSS:it,stickyHeaders:!0,itemMetrics:{diffHeaderHeight:33},layout:{paddingTop:0,paddingBottom:8,gap:8}}},Y??lt)}):(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`p`,{className:`text-[11px] text-muted-foreground/75`,children:Q.reason}),(0,L.jsx)(`pre`,{className:p(`max-h-[72vh] rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90`,v?`overflow-auto whitespace-pre-wrap wrap-break-word`:`overflow-auto`),children:Q.text})]})}):Dt?(0,L.jsx)(de,{label:q?`Loading checkpoint diff...`:G===`unstaged`?`Loading working tree diff...`:`Loading branch diff...`}):(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center px-3 py-2 text-xs text-muted-foreground/70`,children:(0,L.jsx)(`p`,{children:kt?`No net changes in this selection.`:`No patch available for this selection.`})})]})}):(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`Turn diffs are unavailable because this project is not a git repository.`}):(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`Select a thread to inspect turn diffs.`})})}export{_e as DiffWorkerPoolProvider,U as default};
98
- //# sourceMappingURL=DiffPanel-BE233m2I.js.map
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{At as i,Au as a,Ba as o,Du as s,G as c,Ha as l,Ia as u,Iu as d,J as f,Ja as p,K as m,Ka as h,Ll as g,Na as _,Ou as v,Q as y,St as b,Tu as x,U as S,Ua as C,Uu as w,Va as T,W as E,Wa as D,X as ee,Xa as O,Ya as k,Yp as A,Z as j,_t as M,b as te,bt as N,ct as ne,du as P,ft as F,gt as re,hl as ie,md as ae,pt as I,qa as oe,qp as L,r as R,xt as z,yt as B,z as V,zr as se,zu as H}from"./previewAssetResource-x8WpJWsS.js";import{$ as ce,$r as U,Br as le,Cr as W,F as G,Gr as K,Hr as ue,I as de,Jn as q,Kn as J,Kr as Y,L as fe,N as X,O as pe,P as me,Q as he,R as ge,Sr as _e,Ur as ve,Xn as ye,Yn as be,Z as xe,a as Se,br as Ce,c as we,ci as Te,g as Ee,i as De,n as Oe,ni as ke,o as Ae,qn as je,qr as Me,r as Ne,s as Pe,si as Fe,t as Ie,wr as Le,xr as Re,z as ze,zr as Be}from"./index-eQUin3Y8.js";var Ve=ie(`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`}]]),He=ie(`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`}]]),Ue=ie(`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:v,recording:y,onPictureInPicture:b,pictureInPicture:x,pictureInPictureDisabled:S,onPickElement:C,pickActive:w,pickDisabled:T,pickDisabledReason:E,trailingActions:D}=e,ee=(0,Q.useRef)(null),[k,A]=(0,Q.useState)(n),[j,te]=(0,Q.useState)(!1),N,ne;t[0]===u?(N=t[1],ne=t[2]):(N=()=>{if(u==null)return;let e=ee.current;e&&e.focus()},ne=[u],t[0]=u,t[1]=N,t[2]=ne),(0,Q.useEffect)(N,ne);let P;t[3]!==k||t[4]!==m?(P=e=>{e?.preventDefault();let t=k.trim();t.length!==0&&(m(t),ee.current?.blur())},t[3]=k,t[4]=m,t[5]=P):P=t[5];let F=P,ie=o?d:We,ae=!o,I;t[6]!==ie||t[7]!==ae?(I=(0,$.jsx)(_,{variant:`ghost`,size:`icon-xs`,onClick:ie,disabled:ae,"aria-label":`Back`,type:`button`}),t[6]=ie,t[7]=ae,t[8]=I):I=t[8];let oe;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,$.jsx)(Te,{}),t[9]=oe):oe=t[9];let L;t[10]===I?L=t[11]:(L=(0,$.jsx)(B,{render:I,children:oe}),t[10]=I,t[11]=L);let R;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(M,{children:`Back`}),t[12]=R):R=t[12];let z;t[13]===L?z=t[14]:(z=(0,$.jsxs)(re,{children:[L,R]}),t[13]=L,t[14]=z);let V=s?f:We,se=!s,H;t[15]!==V||t[16]!==se?(H=(0,$.jsx)(_,{variant:`ghost`,size:`icon-xs`,onClick:V,disabled:se,"aria-label":`Forward`,type:`button`}),t[15]=V,t[16]=se,t[17]=H):H=t[17];let U;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(Fe,{}),t[18]=U):U=t[18];let le;t[19]===H?le=t[20]:(le=(0,$.jsx)(B,{render:H,children:U}),t[19]=H,t[20]=le);let W;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(M,{children:`Forward`}),t[21]=W):W=t[21];let G;t[22]===le?G=t[23]:(G=(0,$.jsxs)(re,{children:[le,W]}),t[22]=le,t[23]=G);let ue=c?We:p,de=i?`Stop`:`Refresh`,q;t[24]!==c||t[25]!==ue||t[26]!==de?(q=(0,$.jsx)(_,{variant:`ghost`,size:`icon-xs`,onClick:ue,disabled:c,"aria-label":de,type:`button`}),t[24]=c,t[25]=ue,t[26]=de,t[27]=q):q=t[27];let J=i&&`animate-spin`,Y;t[28]===J?Y=t[29]:(Y=O(J),t[28]=J,t[29]=Y);let fe;t[30]===Y?fe=t[31]:(fe=(0,$.jsx)(Be,{className:Y}),t[30]=Y,t[31]=fe);let X;t[32]!==q||t[33]!==fe?(X=(0,$.jsx)(B,{render:q,children:fe}),t[32]=q,t[33]=fe,t[34]=X):X=t[34];let pe=i?`Loading…`:`Refresh`,me;t[35]===pe?me=t[36]:(me=(0,$.jsx)(M,{children:pe}),t[35]=pe,t[36]=me);let ge;t[37]!==X||t[38]!==me?(ge=(0,$.jsxs)(re,{children:[X,me]}),t[37]=X,t[38]=me,t[39]=ge):ge=t[39];let _e;t[40]!==z||t[41]!==G||t[42]!==ge?(_e=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`Navigation`,children:[z,G,ge]}),t[40]=z,t[41]=G,t[42]=ge,t[43]=_e):_e=t[43];let ye=j?k:r??n,be=h&&!j&&`group-hover/address:pe-7 transition-[padding]`,Se;t[44]===be?Se=t[45]:(Se=O(be),t[44]=be,t[45]=Se);let Ce;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=e=>A(e.target.value),t[46]=Ce):Ce=t[46];let we;t[47]===n?we=t[48]:(we=()=>{A(n),te(!0),queueMicrotask(()=>ee.current?.select())},t[47]=n,t[48]=we);let Ee;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=()=>{te(!1)},t[49]=Ee):Ee=t[49];let De;t[50]!==F||t[51]!==n?(De=e=>{e.key===`Enter`&&F(e),e.key===`Escape`&&(e.preventDefault(),A(n),ee.current?.blur())},t[50]=F,t[51]=n,t[52]=De):De=t[52];let Oe;t[53]!==l||t[54]!==ye||t[55]!==Se||t[56]!==we||t[57]!==De?(Oe=(0,$.jsx)(B,{render:(0,$.jsx)(ce,{ref:ee,value:ye,className:Se,onChange:Ce,onFocus:we,onBlur:Ee,onKeyDown:De,placeholder:`Search or enter URL`,spellCheck:!1,disabled:l,"data-preview-url-input":!0,size:`sm`})}),t[53]=l,t[54]=ye,t[55]=Se,t[56]=we,t[57]=De,t[58]=Oe):Oe=t[58];let Ae;t[59]!==r||t[60]!==j||t[61]!==n?(Ae=!j&&r?(0,$.jsx)(M,{children:n}):null,t[59]=r,t[60]=j,t[61]=n,t[62]=Ae):Ae=t[62];let je;t[63]!==Oe||t[64]!==Ae?(je=(0,$.jsxs)(re,{children:[Oe,Ae]}),t[63]=Oe,t[64]=Ae,t[65]=je):je=t[65];let Me;t[66]!==j||t[67]!==h?(Me=h&&!j?(0,$.jsx)(he,{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)(re,{children:[(0,$.jsx)(B,{render:(0,$.jsx)(_,{variant:`ghost`,size:`icon-xs`,onClick:h,"aria-label":`Open in system browser`,type:`button`}),children:(0,$.jsx)(ke,{})}),(0,$.jsx)(M,{children:`Open in system browser`})]})}):null,t[66]=j,t[67]=h,t[68]=Me):Me=t[68];let Ne;t[69]!==je||t[70]!==Me?(Ne=(0,$.jsxs)(xe,{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:[je,Me]}),t[69]=je,t[70]=Me,t[71]=Ne):Ne=t[71];let Pe;t[72]!==C||t[73]!==w||t[74]!==T||t[75]!==E?(Pe=C?(0,$.jsxs)(re,{children:[(0,$.jsx)(B,{render:(0,$.jsx)(_,{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)(K,{className:O(w&&`text-primary`)})}),(0,$.jsx)(M,{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]=Pe):Pe=t[76];let Ie;t[77]!==v||t[78]!==g||t[79]!==y?(Ie=g?(0,$.jsxs)(re,{children:[(0,$.jsxs)(B,{render:(0,$.jsx)(_,{variant:y?`secondary`:`ghost`,size:`icon-xs`,onClick:e=>g(e.shiftKey),"aria-label":y?`Stop recording`:`Capture screenshot`,type:`button`,className:`relative`,disabled:v}),children:[(0,$.jsx)(Ve,{className:O(y&&`text-destructive`)}),y?(0,$.jsx)(`span`,{className:`absolute right-0.5 top-0.5 size-1.5 animate-status-pulse rounded-full bg-destructive`}):null]}),(0,$.jsx)(M,{children:y?`Stop recording`:`Screenshot · Shift-click to record`})]}):null,t[77]=v,t[78]=g,t[79]=y,t[80]=Ie):Ie=t[80];let Le;t[81]!==b||t[82]!==x||t[83]!==S?(Le=b?(0,$.jsxs)(re,{children:[(0,$.jsx)(B,{render:(0,$.jsx)(_,{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)(ve,{className:O(x&&`text-primary`)})}),(0,$.jsx)(M,{children:x?`Close floating preview`:`Float preview over chat`})]}):null,t[81]=b,t[82]=x,t[83]=S,t[84]=Le):Le=t[84];let Re;t[85]!==F||t[86]!==_e||t[87]!==Ne||t[88]!==Pe||t[89]!==Ie||t[90]!==Le||t[91]!==D?(Re=(0,$.jsxs)(`form`,{onSubmit:F,className:`surface-subheader gap-1 px-2`,"data-surface-subheader":!0,children:[_e,Ne,Pe,Ie,Le,D]}),t[85]=F,t[86]=_e,t[87]=Ne,t[88]=Pe,t[89]=Ie,t[90]=Le,t[91]=D,t[92]=Re):Re=t[92];let ze;t[93]===a?ze=t[94]:(ze=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]=ze);let He;return t[95]!==Re||t[96]!==ze?(He=(0,$.jsxs)(`div`,{className:`relative`,children:[Re,ze]}),t[95]=Re,t[96]=ze,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=O(`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=Le(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:Re(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:`||!_e(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)(J,{children:[(0,$.jsx)(q,{variant:`icon`,children:(0,$.jsx)(U,{className:`size-4.5 text-muted-foreground`})}),(0,$.jsx)(be,{children:`No preview yet`}),(0,$.jsx)(je,{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:a,deviceToolbarVisible:s,onToggleDeviceToolbar:c,nativePictureInPicture:d,onNativePictureInPicture:f}=e;if(!X)return null;let m=!n||!r,g;t[0]===n?g=t[1]:(g=e=>()=>{n&&e(n).catch(ft)},t[0]=n,t[1]=g);let v=g,y;t[2]===i?y=t[3]:(y=Math.round(i*100),t[2]=i,t[3]=y);let b=`${y}%`,x;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsxs)(re,{children:[(0,$.jsx)(B,{render:(0,$.jsx)(k,{render:(0,$.jsx)(_,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":`Preview menu`})}),children:(0,$.jsx)(He,{})}),(0,$.jsx)(M,{children:`More`})]}),t[4]=x):x=t[4];let S;t[5]===v?S=t[6]:(S=v(X.hardReload),t[5]=v,t[6]=S);let C;t[7]!==S||t[8]!==m?(C=(0,$.jsx)(o,{onClick:S,disabled:m,children:`Hard reload`}),t[7]=S,t[8]=m,t[9]=C):C=t[9];let w;t[10]===v?w=t[11]:(w=v(X.openDevTools),t[10]=v,t[11]=w);let E;t[12]!==w||t[13]!==m?(E=(0,$.jsx)(o,{onClick:w,disabled:m,children:`Open DevTools`}),t[12]=w,t[13]=m,t[14]=E):E=t[14];let ee=d?`Close separate preview window`:`Open separate preview window`,O;t[15]!==f||t[16]!==ee||t[17]!==m?(O=(0,$.jsx)(o,{onClick:f,disabled:m,children:ee}),t[15]=f,t[16]=ee,t[17]=m,t[18]=O):O=t[18];let A=s?`Hide device toolbar`:`Show device toolbar`,j;t[19]!==c||t[20]!==A||t[21]!==m?(j=(0,$.jsx)(o,{onClick:c,disabled:m,children:A}),t[19]=c,t[20]=A,t[21]=m,t[22]=j):j=t[22];let te;t[23]===m?te=t[24]:(te=(0,$.jsx)(p,{disabled:m,children:`Appearance`}),t[23]=m,t[24]=te);let N;t[25]===n?N=t[26]:(N=e=>{n&&X.setColorScheme(n,e).catch(dt)},t[25]=n,t[26]=N);let ne;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(ne=rt.map(ut),t[27]=ne):ne=t[27];let P;t[28]!==a||t[29]!==N?(P=(0,$.jsx)(oe,{className:`min-w-32`,children:(0,$.jsx)(l,{value:a,onValueChange:N,children:ne})}),t[28]=a,t[29]=N,t[30]=P):P=t[30];let F;t[31]!==te||t[32]!==P?(F=(0,$.jsxs)(h,{children:[te,P]}),t[31]=te,t[32]=P,t[33]=F):F=t[33];let ie;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(D,{}),t[34]=ie):ie=t[34];let ae;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(`span`,{children:`Zoom`}),t[35]=ae):ae=t[35];let I;t[36]===v?I=t[37]:(I=v(X.zoomOut),t[36]=v,t[37]=I);let L;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(Me,{}),t[38]=L):L=t[38];let R;t[39]!==I||t[40]!==m?(R=(0,$.jsx)(_,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:I,"aria-label":`Zoom out`,disabled:m,children:L}),t[39]=I,t[40]=m,t[41]=R):R=t[41];let z;t[42]===b?z=t[43]:(z=(0,$.jsx)(`span`,{className:`min-w-12 text-center text-xs tabular-nums text-muted-foreground`,children:b}),t[42]=b,t[43]=z);let V;t[44]===v?V=t[45]:(V=v(X.zoomIn),t[44]=v,t[45]=V);let se;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(ue,{}),t[46]=se):se=t[46];let H;t[47]!==V||t[48]!==m?(H=(0,$.jsx)(_,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:V,"aria-label":`Zoom in`,disabled:m,children:se}),t[47]=V,t[48]=m,t[49]=H):H=t[49];let ce;t[50]===v?ce=t[51]:(ce=v(X.resetZoom),t[50]=v,t[51]=ce);let U;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(le,{}),t[52]=U):U=t[52];let W;t[53]!==ce||t[54]!==m?(W=(0,$.jsx)(_,{variant:`ghost`,size:`icon-xs`,type:`button`,onClick:ce,"aria-label":`Reset zoom`,disabled:m,children:U}),t[53]=ce,t[54]=m,t[55]=W):W=t[55];let G;t[56]!==R||t[57]!==z||t[58]!==H||t[59]!==W?(G=(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[R,z,H,W]}),t[56]=R,t[57]=z,t[58]=H,t[59]=W,t[60]=G):G=t[60];let K;t[61]!==G||t[62]!==m?(K=(0,$.jsxs)(o,{closeOnClick:!1,onClick:lt,className:`justify-between`,disabled:m,children:[ae,G]}),t[61]=G,t[62]=m,t[63]=K):K=t[63];let de,q,J;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(D,{}),q=(0,$.jsx)(o,{onClick:st,children:`Clear cookies`}),J=(0,$.jsx)(o,{onClick:at,children:`Clear cache`}),t[64]=de,t[65]=q,t[66]=J):(de=t[64],q=t[65],J=t[66]);let Y;return t[67]!==j||t[68]!==F||t[69]!==K||t[70]!==C||t[71]!==E||t[72]!==O?(Y=(0,$.jsxs)(u,{children:[x,(0,$.jsxs)(T,{align:`end`,sideOffset:6,className:`min-w-56`,children:[C,E,O,j,F,ie,K,de,q,J]})]}),t[67]=j,t[68]=F,t[69]=K,t[70]=C,t[71]=E,t[72]=O,t[73]=Y):Y=t[73],Y}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)(C,{value:e.value,children:e.label},e.value)}function dt(){}function ft(){}function pt(e){return j[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 v;t[11]!==d||t[12]!==g?(v=(0,$.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:[g,`: `,d,`.`]}),t[11]=d,t[12]=g,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]===p?b=t[17]:(b=(0,$.jsx)(`div`,{className:`mt-8 text-xs uppercase tracking-wide text-muted-foreground/70`,children:p}),t[16]=p,t[17]=b);let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>s(ht),t[18]=x):x=t[18];let S=o?`Hide details`:`Details`,C;t[19]===S?C=t[20]:(C=(0,$.jsx)(_,{type:`button`,variant:`outline`,size:`sm`,onClick:x,children:S}),t[19]=S,t[20]=C);let w;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(`div`,{className:`flex-1`}),t[21]=w):w=t[21];let T;t[22]===a?T=t[23]:(T=(0,$.jsx)(_,{type:`button`,size:`sm`,onClick:a,children:`Reload`}),t[22]=a,t[23]=T);let E;t[24]!==C||t[25]!==T?(E=(0,$.jsxs)(`div`,{className:`mt-auto flex items-center gap-2 pt-8`,children:[C,w,T]}),t[24]=C,t[25]=T,t[26]=E):E=t[26];let D;return t[27]!==E||t[28]!==v||t[29]!==y||t[30]!==b?(D=(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,b,E]})}),t[27]=E,t[28]=v,t[29]=y,t[30]=b,t[31]=D):D=t[31],D}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 A()(`PreviewSessionThreadKeyParseError`,{threadKey:L}){get message(){return`Invalid scoped preview thread key: ${this.threadKey}`}},Dt=x(e=>{let t=H(e);if(t===null)throw new Et({threadKey:e});let n=y.list({environmentId:t.environmentId,input:{threadId:t.threadId}}),r=y.events({environmentId:t.environmentId,input:{}});return s(e=>{let i=!1,a=0,o=e=>{d(e)&&c(t,e.value)},s=r=>{if(!d(r)||r.value.threadId!==t.threadId)return;let i=E(t).serverEpoch;if(i!==null&&i!==r.value.serverEpoch){e.refresh(n);return}V(t,r.value)};e.addFinalizer(()=>{i=!0});let l=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(l))})}).pipe(v(1e3),a(`preview:session-sync:${e}`))});function Ot(e){let t=(0,Z.c)(2),n;t[0]===e?n=t[1]:(n=Dt(w(e)),t[0]=e,t[1]=n),g(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=O(`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=ge(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)(Y,{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:i();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=Ae(),l=(0,Q.useRef)(!1),u=(0,Q.useRef)(!0),d=ee(e),p=G(t=>me(t.byThreadKey,e)),h=se(e=>e.addPreviewAnnotation),g=se(e=>e.addImage),_=z(e.environmentId),v=b(e.environmentId),x=N(y.open),S=N(y.resize,`preview viewport resize`),{resolvedTheme:C}=te();Ot(e),(0,Q.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]);let T=t??d.activeTabId,E=T?de(e,d.serverEpoch,T):null,D=T&&E?c.has(E)?E:Ne(e,T):null,O=T?d.sessions[T]??null:null,k=T?d.desktopByTabId[T]??null:null;(0,Q.useEffect)(()=>{let e=X;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`},j=A._tag===`Idle`?``:A.url,M=k?.loading??A._tag===`Loading`,re=k?.canGoBack??O?.canGoBack??!1,ie=k?.canGoForward??O?.canGoForward??!1,oe=A._tag===`Idle`,L=A._tag===`LoadFailed`,B=pe(O),V=k?.controller??`none`,H=Tt(M),ce=j&&_&&v?Ke({url:j,environmentLabel:_.label,environmentHttpBaseUrl:v})??void 0:void 0,U=O?.viewport??ae,le=ge(e=>E?e.byTabId[E]?.rect??null:null),K=(0,Q.useCallback)(async t=>{E&&X?(await X.navigate(E,t),m(e,t)):await Ce({openPreview:x,threadRef:e,url:t})},[x,E,e]),ue=(0,Q.useCallback)(async e=>{try{await K(W(e))}catch{}},[K]),q=(0,Q.useCallback)(async t=>{try{await K(Re(e.environmentId,t))}catch{}},[K,e.environmentId]),J=(0,Q.useCallback)(()=>{X&&E&&X.refresh(E)},[E]),Y=(0,Q.useCallback)(()=>{X&&E&&X.zoomIn(E)},[E]),he=(0,Q.useCallback)(()=>{X&&E&&X.zoomOut(E)},[E]),_e=(0,Q.useCallback)(()=>{X&&E&&X.resetZoom(E)},[E]),ve=(0,Q.useCallback)(async t=>{if(!T)return;let n=await S({environmentId:e.environmentId,input:{threadId:e.threadId,tabId:T,viewport:t}});if(n._tag===`Failure`){let e=P(n);throw F.add({type:`error`,title:`Unable to resize browser viewport`,description:e instanceof Error?e.message:`An error occurred.`}),e}f(e,n.value)},[S,T,e]),be=()=>{if(!E)return;if(U._tag!==`fill`){Ie(E,ae).catch(()=>void 0);return}let e=le?Pe(le,k?.zoomFactor):{width:1024,height:768};Ie(E,{_tag:`freeform`,...e}).catch(()=>void 0)};(0,Q.useEffect)(()=>{if(E)return Oe(E,ve)},[ve,E]);let xe=(0,Q.useCallback)(()=>{X&&E&&X.goBack(E)},[E]),we=(0,Q.useCallback)(()=>{X&&E&&X.goForward(E)},[E]),Te=(0,Q.useCallback)(()=>{!It||!j||It.shell.openExternal(j).catch(()=>void 0)},[j]),ke=(0,Q.useCallback)(()=>{if(T){if(p?.tabId===T){G.getState().close(e);return}G.getState().open(e,T),ne.getState().close(e)}},[p?.tabId,T,e]),je=(0,Q.useCallback)(()=>{!X||!E||(k?.pictureInPicture?X.pictureInPicture.close:X.pictureInPicture.open)(E).catch(e=>{F.add({type:`error`,title:`Unable to update popped-out preview`,description:e instanceof Error?e.message:`An error occurred.`})})},[k?.pictureInPicture,E]),Me=(0,Q.useCallback)(t=>{if(!X||!E||!T)return;let n=X;if(D){Se(D).then(e=>{if(!e)return;let t=!1,r,i=()=>{if(!navigator.clipboard?.writeText){F.update(r,I({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=>{F.update(r,I({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=()=>{F.update(r,I({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:t?`Copied!`:`Copy path`,disabled:t,onClick:i},secondaryActionVariant:`outline`}}))};r=F.add(I({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:`Copy path`,onClick:i},secondaryActionVariant:`outline`}}))},e=>{F.add({type:`error`,title:`Unable to stop recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}if(t){De(E,e,T).catch(e=>{F.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:vt(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},r=!1,i=!1,a,o=(e=`success`,n=`Screenshot saved`,o)=>{F.update(a,I({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=F.add(I({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=>{F.add({type:`error`,title:`Unable to capture screenshot`,description:e instanceof Error?e.message:`An error occurred.`})})},[D,E,T,e]),Fe=(0,Q.useCallback)(()=>{if(!X||!E)return;if(l.current){X.cancelPickElement(E).catch(()=>void 0);return}let t=typeof document<`u`?document.activeElement:null;l.current=!0,s(!0),(async()=>{try{let t=await X.pickElement(E);if(!t)return;h(e,t);let n=await Ee(t);n&&t.screenshot&&g(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{}}})()},[g,h,E,e]);return(0,Q.useEffect)(()=>{let e=R(j,C);e&&K(e).catch(()=>void 0)},[K,C,j]),(0,Q.useEffect)(()=>()=>{l.current&&(l.current=!1,X&&E&&X.cancelPickElement(E).catch(()=>void 0),u.current&&s(!1))},[E]),(0,Q.useEffect)(()=>{if(r)return ye(e=>{switch(e){case`refresh`:J();return;case`focus-url`:a(e=>(e??0)+1);return;case`zoom-in`:Y();return;case`zoom-out`:he();return;case`reset-zoom`:_e();return;case`toggle-panel`:return}})},[J,_e,Y,he,r]),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,"data-thread-key":w(e),children:[(0,$.jsx)(Ge,{url:j,displayUrl:ce,loading:M,loadProgress:H,canGoBack:re,canGoForward:ie,refreshDisabled:oe,focusUrlNonce:i,onBack:xe,onForward:we,onRefresh:J,onSubmit:e=>void ue(e),onOpenInBrowser:T?Te:void 0,onCapture:X&&T?Me:void 0,captureDisabled:!k||L,recording:D!==null,onPictureInPicture:X&&T?ke:void 0,pictureInPicture:p?.tabId===T,pictureInPictureDisabled:!k?.hasWebContents||L,onPickElement:X&&T?Fe:void 0,pickActive:o,pickDisabled:!T||L,pickDisabledReason:L?`Page didn't load — pick unavailable until the page renders`:void 0,trailingActions:X?(0,$.jsx)(it,{tabId:E,hasWebContents:k?.hasWebContents??!1,zoomFactor:k?.zoomFactor??1,colorScheme:k?.colorScheme??`system`,deviceToolbarVisible:U._tag!==`fill`,onToggleDeviceToolbar:be,nativePictureInPicture:k?.pictureInPicture??!1,onNativePictureInPicture:je}):null}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[E&&O&&!B?(0,$.jsx)(fe,{tabId:E,visible:r&&!L,className:`absolute inset-0 h-full w-full`},E):null,B?(0,$.jsx)(nt,{environmentId:e.environmentId,configuredUrls:n,recentlySeenUrls:d.recentlySeenUrls,onOpenUrl:e=>void q(e)}):null,O&&k?(0,$.jsx)(jt,{zoomFactor:k.zoomFactor}):null,E&&k&&!B&&!L?(0,$.jsx)(Pt,{tabId:E,zoomFactor:k.zoomFactor,controller:V}):null,V===`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:V===`agent`?`Agent controlling browser`:`Human control`}),A._tag===`LoadFailed`?(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(mt,{url:A.url,code:A.code,description:A.description,onReload:J})}):null]})]})}function Rt(e){let t=(0,Z.c)(13),{mode:n,threadRef:r,tabId:i,configuredUrls:a,visible:o}=e;if(!S()){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)(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-DiRzX4UV.js.map