@p4code/cli 0.2.26 → 0.2.27

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,4 +1,4 @@
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{Aa as i,El as a,Er as o,Et as s,Il as c,Ma as l,Mr as ee,Na as te,Pa as u,Qc as d,Ta as f,Xc as p,Yc as m,Zc as ne,_a as h,ah as re,au as g,ba as _,bl as v,bn as y,gn as b,gt as x,h as S,hl as ie,ht as C,ja as ae,jl as oe,ot as w,rn as T,vt as E,wa as D,x as O,xr as k}from"./previewAssetResource-JdwqlhCI.js";import{t as A}from"./arrow-right-Bu5WkIYh.js";import{a as se,i as j,n as M,o as ce,r as le,s as ue,t as de}from"./toggle-group-kcgtjPPC.js";import{F as fe,Fr as pe,I as me,J as he,L as ge,Lr as _e,Mr as ve,Nr as ye,R as N,Sr as be,Y as xe,_ as Se,at as Ce,cr as we,ct as Te,dr as Ee,fr as De,gr as Oe,h as ke,it as Ae,jr as je,lr as Me,lt as Ne,mr as Pe,oi as Fe,or as Ie,ot as Le,pr as Re,rt as ze,si as Be,sr as Ve,st as He,ur as Ue,zr as We}from"./index-BL9HZoA_.js";import{a as P,n as Ge}from"./fileCommentAnnotations-1_E_uBQa.js";var Ke=d(`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 qe({threadRef:e,filePath:t,activeCwd:n,openInEditor:r,openFileSurface:i}){if(e){if(i){i(t);return}w.getState().openFile(e,t);return}r(n?S(t,n):t)}var I=r();function Je(e,t){let n=(0,I.c)(4),r=Oe(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(),Ye=[];function Xe(e){return(e.endSide??e.side)===`deletions`?`deletions`:`additions`}function R(e,t,n){let r=Xe(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 Ze(e){let t=(0,I.c)(50),{files:n,sectionId:r,sectionTitle:i,composerDraftTarget:a,options:s,viewerRef:c,className:l,renderHeaderPrefix:te}=e,u=k(et),d=k(B),f;t[0]===a?f=t[1]:(f=e=>e.getComposerDraft(a)?.reviewComments??Ye,t[0]=a,t[1]=f);let p=k(f),[m,ne]=(0,F.useState)(null),[h,re]=(0,F.useState)(null),g;t[2]===n?g=t[3]:(g=new Map(n.map($e)),t[2]=n,t[3]=g);let _=g,v;if(t[4]!==h||t[5]!==n||t[6]!==p||t[7]!==r){let e;t[9]!==h||t[10]!==p||t[11]!==r?(e=e=>{let{fileDiff:t,filePath:n,fileKey:i,collapsed:a}=e,o=p.filter(e=>e.sectionId===r&&e.filePath===n&&(e.fenceLanguage??`diff`)===`diff`).reduce((e,n)=>{let r=ee(t,n);return r?R(e,r,{id:n.id,kind:`comment`,range:r,rangeLabel:n.rangeLabel,text:n.text}):e},[]),s=h?.fileKey===i?[...o,h.annotation]:o;return{id:i,type:`diff`,fileDiff:t,annotations:s,collapsed:a,version:Ae(`${a?`1`:`0`}:${s.flatMap(z).join(`:`)}`)}},t[9]=h,t[10]=p,t[11]=r,t[12]=e):e=t[12],v=n.map(e),t[4]=h,t[5]=n,t[6]=p,t[7]=r,t[8]=v}else v=t[8];let y=v,b;t[13]!==a||t[14]!==h?.annotation||t[15]!==d?(b=e=>{ne(null),h?.annotation.metadata.entries.some(t=>t.id===e)?re(null):d(a,e)},t[13]=a,t[14]=h?.annotation,t[15]=d,t[16]=b):b=t[16];let x=b,S;t[17]!==u||t[18]!==a||t[19]!==h||t[20]!==_||t[21]!==r||t[22]!==i?(S=(e,t)=>{let n=h?.annotation.metadata.entries.find(t=>t.id===e),s=h?_.get(h.fileKey):void 0;if(!n||!s)return;let c=o({id:n.id,sectionId:r,sectionTitle:i,filePath:s.filePath,fileDiff:s.fileDiff,range:n.range,text:t});c&&u(a,c),ne(null),re(null)},t[17]=u,t[18]=a,t[19]=h,t[20]=_,t[21]=r,t[22]=i,t[23]=S):S=t[23];let ie=S,C;t[24]!==_||t[25]!==r||t[26]!==i?(C=(e,t)=>{if(!e)return;let n=t.item;if(n.type!==`diff`)return;let a=_.get(n.id);if(!a)return;let s=Ge(),c=o({id:s,sectionId:r,sectionTitle:i,filePath:a.filePath,fileDiff:a.fileDiff,range:e,text:``});c&&re({fileKey:n.id,annotation:{side:Xe(e),lineNumber:e.end,metadata:{entries:[{id:s,kind:`draft`,range:e,rangeLabel:c.rangeLabel,text:``}]}}})},t[24]=_,t[25]=r,t[26]=i,t[27]=C):C=t[27];let ae=C,oe=h!==null,w;t[28]===c?w=t[29]:(w=c?{ref:c}:{},t[28]=c,t[29]=w);let T;t[30]===l?T=t[31]:(T=l?{className:l}:{},t[30]=l,t[31]=T);let E=!oe,D=!oe,O;t[32]!==ae||t[33]!==s||t[34]!==D||t[35]!==E?(O={...s,enableGutterUtility:E,enableLineSelection:D,onLineSelectionEnd:ae},t[32]=ae,t[33]=s,t[34]=D,t[35]=E,t[36]=O):O=t[36];let A;t[37]===te?A=t[38]:(A=e=>e.type===`diff`?te(e.fileDiff,e.id,e.collapsed===!0):null,t[37]=te,t[38]=A);let j;t[39]!==x||t[40]!==ie?(j=e=>(0,L.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,L.jsx)(P,{kind:e.kind,rangeLabel:e.rangeLabel,text:e.text,onCancel:()=>x(e.id),onComment:t=>ie(e.id,t),onDelete:()=>x(e.id)},e.id))}),t[39]=x,t[40]=ie,t[41]=j):j=t[41];let M;return t[42]!==y||t[43]!==m||t[44]!==O||t[45]!==A||t[46]!==j||t[47]!==w||t[48]!==T?(M=(0,L.jsx)(se,{...w,...T,items:y,selectedLines:m,onSelectedLinesChange:ne,options:O,renderHeaderPrefix:A,renderAnnotation:j}),t[42]=y,t[43]=m,t[44]=O,t[45]=A,t[46]=j,t[47]=w,t[48]=T,t[49]=M):M=t[49],M}function z(e){return e.metadata.entries.map(Qe)}function Qe(e){return`${e.id}:${e.rangeLabel}:${e.text}`}function $e(e){return[e.fileKey,e]}function B(e){return e.removeReviewComment}function et(e){return e.addReviewComment}function tt(e){return{diffPreview:v(e,{label:`environment-data:review:diff-preview`,tag:g.reviewGetDiffPreview,staleTimeMs:5e3})}}var nt=tt(y);function V(e){return e.remoteName&&e.name.startsWith(`${e.remoteName}/`)?e.name.slice(e.remoteName.length+1):e.name}function rt(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 it(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__`,at=new Set,ot=`
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{Aa as i,El as a,Er as o,Et as s,Il as c,Ma as l,Mr as ee,Na as te,Pa as u,Qc as d,Ta as f,Xc as p,Yc as m,Zc as ne,_a as h,ah as re,au as g,ba as _,bl as v,bn as y,gn as b,gt as x,h as S,hl as ie,ht as C,ja as ae,jl as oe,ot as w,rn as T,vt as E,wa as D,x as O,xr as k}from"./previewAssetResource-JdwqlhCI.js";import{t as A}from"./arrow-right-Bu5WkIYh.js";import{a as se,i as j,n as M,o as ce,r as le,s as ue,t as de}from"./toggle-group-4XK-wLB0.js";import{F as fe,Fr as pe,I as me,J as he,L as ge,Lr as _e,Mr as ve,Nr as ye,R as N,Sr as be,Y as xe,_ as Se,at as Ce,cr as we,ct as Te,dr as Ee,fr as De,gr as Oe,h as ke,it as Ae,jr as je,lr as Me,lt as Ne,mr as Pe,oi as Fe,or as Ie,ot as Le,pr as Re,rt as ze,si as Be,sr as Ve,st as He,ur as Ue,zr as We}from"./index-IA1MLjyL.js";import{a as P,n as Ge}from"./fileCommentAnnotations-BAZwrcFy.js";var Ke=d(`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 qe({threadRef:e,filePath:t,activeCwd:n,openInEditor:r,openFileSurface:i}){if(e){if(i){i(t);return}w.getState().openFile(e,t);return}r(n?S(t,n):t)}var I=r();function Je(e,t){let n=(0,I.c)(4),r=Oe(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(),Ye=[];function Xe(e){return(e.endSide??e.side)===`deletions`?`deletions`:`additions`}function R(e,t,n){let r=Xe(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 Ze(e){let t=(0,I.c)(50),{files:n,sectionId:r,sectionTitle:i,composerDraftTarget:a,options:s,viewerRef:c,className:l,renderHeaderPrefix:te}=e,u=k(et),d=k(B),f;t[0]===a?f=t[1]:(f=e=>e.getComposerDraft(a)?.reviewComments??Ye,t[0]=a,t[1]=f);let p=k(f),[m,ne]=(0,F.useState)(null),[h,re]=(0,F.useState)(null),g;t[2]===n?g=t[3]:(g=new Map(n.map($e)),t[2]=n,t[3]=g);let _=g,v;if(t[4]!==h||t[5]!==n||t[6]!==p||t[7]!==r){let e;t[9]!==h||t[10]!==p||t[11]!==r?(e=e=>{let{fileDiff:t,filePath:n,fileKey:i,collapsed:a}=e,o=p.filter(e=>e.sectionId===r&&e.filePath===n&&(e.fenceLanguage??`diff`)===`diff`).reduce((e,n)=>{let r=ee(t,n);return r?R(e,r,{id:n.id,kind:`comment`,range:r,rangeLabel:n.rangeLabel,text:n.text}):e},[]),s=h?.fileKey===i?[...o,h.annotation]:o;return{id:i,type:`diff`,fileDiff:t,annotations:s,collapsed:a,version:Ae(`${a?`1`:`0`}:${s.flatMap(z).join(`:`)}`)}},t[9]=h,t[10]=p,t[11]=r,t[12]=e):e=t[12],v=n.map(e),t[4]=h,t[5]=n,t[6]=p,t[7]=r,t[8]=v}else v=t[8];let y=v,b;t[13]!==a||t[14]!==h?.annotation||t[15]!==d?(b=e=>{ne(null),h?.annotation.metadata.entries.some(t=>t.id===e)?re(null):d(a,e)},t[13]=a,t[14]=h?.annotation,t[15]=d,t[16]=b):b=t[16];let x=b,S;t[17]!==u||t[18]!==a||t[19]!==h||t[20]!==_||t[21]!==r||t[22]!==i?(S=(e,t)=>{let n=h?.annotation.metadata.entries.find(t=>t.id===e),s=h?_.get(h.fileKey):void 0;if(!n||!s)return;let c=o({id:n.id,sectionId:r,sectionTitle:i,filePath:s.filePath,fileDiff:s.fileDiff,range:n.range,text:t});c&&u(a,c),ne(null),re(null)},t[17]=u,t[18]=a,t[19]=h,t[20]=_,t[21]=r,t[22]=i,t[23]=S):S=t[23];let ie=S,C;t[24]!==_||t[25]!==r||t[26]!==i?(C=(e,t)=>{if(!e)return;let n=t.item;if(n.type!==`diff`)return;let a=_.get(n.id);if(!a)return;let s=Ge(),c=o({id:s,sectionId:r,sectionTitle:i,filePath:a.filePath,fileDiff:a.fileDiff,range:e,text:``});c&&re({fileKey:n.id,annotation:{side:Xe(e),lineNumber:e.end,metadata:{entries:[{id:s,kind:`draft`,range:e,rangeLabel:c.rangeLabel,text:``}]}}})},t[24]=_,t[25]=r,t[26]=i,t[27]=C):C=t[27];let ae=C,oe=h!==null,w;t[28]===c?w=t[29]:(w=c?{ref:c}:{},t[28]=c,t[29]=w);let T;t[30]===l?T=t[31]:(T=l?{className:l}:{},t[30]=l,t[31]=T);let E=!oe,D=!oe,O;t[32]!==ae||t[33]!==s||t[34]!==D||t[35]!==E?(O={...s,enableGutterUtility:E,enableLineSelection:D,onLineSelectionEnd:ae},t[32]=ae,t[33]=s,t[34]=D,t[35]=E,t[36]=O):O=t[36];let A;t[37]===te?A=t[38]:(A=e=>e.type===`diff`?te(e.fileDiff,e.id,e.collapsed===!0):null,t[37]=te,t[38]=A);let j;t[39]!==x||t[40]!==ie?(j=e=>(0,L.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,L.jsx)(P,{kind:e.kind,rangeLabel:e.rangeLabel,text:e.text,onCancel:()=>x(e.id),onComment:t=>ie(e.id,t),onDelete:()=>x(e.id)},e.id))}),t[39]=x,t[40]=ie,t[41]=j):j=t[41];let M;return t[42]!==y||t[43]!==m||t[44]!==O||t[45]!==A||t[46]!==j||t[47]!==w||t[48]!==T?(M=(0,L.jsx)(se,{...w,...T,items:y,selectedLines:m,onSelectedLinesChange:ne,options:O,renderHeaderPrefix:A,renderAnnotation:j}),t[42]=y,t[43]=m,t[44]=O,t[45]=A,t[46]=j,t[47]=w,t[48]=T,t[49]=M):M=t[49],M}function z(e){return e.metadata.entries.map(Qe)}function Qe(e){return`${e.id}:${e.rangeLabel}:${e.text}`}function $e(e){return[e.fileKey,e]}function B(e){return e.removeReviewComment}function et(e){return e.addReviewComment}function tt(e){return{diffPreview:v(e,{label:`environment-data:review:diff-preview`,tag:g.reviewGetDiffPreview,staleTimeMs:5e3})}}var nt=tt(y);function V(e){return e.remoteName&&e.name.startsWith(`${e.remoteName}/`)?e.name.slice(e.remoteName.length+1):e.name}function rt(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 it(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__`,at=new Set,ot=`
2
2
  [data-diffs-header],
3
3
  [data-diff],
4
4
  [data-file],
@@ -95,4 +95,4 @@ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}f
95
95
  text-decoration-color: currentColor;
96
96
  }
97
97
  `;function U({mode:e=`inline`,composerDraftTarget:t,initialGitScope:n}){let{resolvedTheme:r}=O(),o=pe(),[ee]=(0,F.useState)(n),[d,g]=(0,F.useState)(`stacked`),[v,y]=(0,F.useState)(o.wordWrap),[S,w]=(0,F.useState)(o.diffIgnoreWhitespace),[k,se]=(0,F.useState)(``),[Se,Oe]=(0,F.useState)(()=>({scopeKey:null,fileKeys:at})),Ae=(0,F.useRef)(null),P=re({strict:!1,select:e=>T(e)}),Ge=P?.threadId??null,I=ye(P),Ye=I?.projectId??null,Xe=ve(I&&Ye?{environmentId:I.environmentId,projectId:Ye}:null),R=I?.worktreePath??Xe?.workspaceRoot,z=ie(b.configValueAtom(I?.environmentId??null)),Qe=Pe(I?.environmentId??null,z?.availableEditors??[]),$e=s(I!=null&&R!=null?je.status({environmentId:I.environmentId,input:{cwd:R}}):null),B=N(e=>ge(e.byThreadKey,P,ee===`unstaged`)),et=$e.data?.isRepo??!0,{turnDiffSummaries:tt,inferredCheckpointTurnCountByTurnId:V}=me(I),U=(0,F.useMemo)(()=>[...tt].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,tt]);(0,F.useEffect)(()=>{!P||B.kind!==`turn`||N.getState().reconcileTurnSelection(P,U.map(e=>e.turnId))},[B,U,P]);let W=B.kind===`turn`?B.turnId:null,G=B.kind===`unstaged`?`unstaged`:`branch`,K=B.kind===`branch`?B.baseRef:null,st=B.kind===`turn`?B.filePath:null,ct=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]),lt=U[0],ut=W===null?G===`unstaged`?`Working tree`:`Branch changes`:q?.turnId===lt?.turnId?`Latest turn`:`Turn ${J??`?`}`,dt=q?`turn:${q.turnId}`:G,Y=P?`${P.environmentId}:${P.threadId}:${dt}`:null,ft=Se.scopeKey===Y?Se.fileKeys:at,pt=q?`Turn ${J??`?`}`:G===`unstaged`?`Working tree`:`Branch changes`,mt=(0,F.useMemo)(()=>typeof J==`number`?{fromTurnCount:Math.max(0,J-1),toTurnCount:J}:null,[J]),ht=Je({environmentId:I?.environmentId??null,threadId:Ge,fromTurnCount:mt?.fromTurnCount??null,toTurnCount:mt?.toTurnCount??null,ignoreWhitespace:S,cacheScope:q?`turn:${q.turnId}`:null},{enabled:et&&q!==void 0}),gt=s(W===null&&I&&R?nt.diffPreview({environmentId:I.environmentId,input:{cwd:R,...K?{baseRef:K}:{},ignoreWhitespace:S}}):null),_t=W===null&&gt.error?.includes(`configured workspace root`)===!0&&z?.cwd!==void 0&&z.cwd!==R,vt=s(_t&&I&&z?nt.diffPreview({environmentId:I.environmentId,input:{cwd:z.cwd,...K?{baseRef:K}:{},ignoreWhitespace:S}}):null),X=_t?vt:gt,Z=X.data?.sources.find(e=>e.kind===(G===`unstaged`?`working-tree`:`branch-range`)),yt=s(W===null&&G===`branch`&&I&&X.data?.cwd?je.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`local`,...k.trim().length>0?{query:k.trim()}:{},limit:100}}):null),bt=s(W===null&&G===`branch`&&I&&X.data?.cwd?je.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`remote`,...k.trim().length>0?{query:k.trim()}:{},limit:100}}):null),xt=rt(yt.data?.refs.filter(e=>e.name!==Z?.headRef)??[],bt.data?.refs??[]),St=it(xt,k),Ct=e=>K&&K===e.remote?.name?K:e.local?.name??e.remote?.name??e.id,wt=[H,...xt.map(Ct)],Tt=[...k.trim().length===0?[H]:[],...St.map(Ct)],Et=Z?.diff,Dt=q?ht.data?.diff:Et,Ot=!q&&Z?.truncated===!0,kt=q?ht.isPending:X.isPending,At=q?ht.error:X.error,jt=typeof Dt==`string`&&Dt.trim().length===0,Q=(0,F.useMemo)(()=>He(Dt,`diff-panel:${r}`,{compactPartialHunkOffsets:W===null}),[r,Dt,W]),Mt=(0,F.useMemo)(()=>!Q||Q.kind!==`files`?[]:Q.files.toSorted((e,t)=>Ne(e).localeCompare(Ne(t),void 0,{numeric:!0,sensitivity:`base`})),[Q]),$=(0,F.useMemo)(()=>Mt.map(e=>{let t=ze(e);return{fileDiff:e,filePath:Ne(e),fileKey:t,collapsed:ft.has(t)}}),[ft,Mt]),Nt=(0,F.useMemo)(()=>$.map(e=>e.fileKey),[$]),Pt=le(Nt,ft),Ft=(0,F.useMemo)(()=>Le(Mt),[Mt]);(0,F.useEffect)(()=>{if(!st)return;let e=$.find(e=>e.filePath===st);e&&Ae.current?.scrollTo({type:`item`,id:e.fileKey,align:`start`})},[$,st,ct]);let It=fe({threadRef:P,workspaceRoot:R??null}),Lt=(0,F.useCallback)(e=>{qe({threadRef:P,filePath:e,activeCwd:R,openFileSurface:It,openInEditor:e=>{(async()=>{let t=await Qe(e);t._tag===`Failure`&&!a(t)&&console.warn(`Failed to open diff file in editor.`,{operation:`open-diff-file`,...P?{environmentId:P.environmentId,threadId:P.threadId}:{},...c(oe(t))})})()}})},[R,It,Qe,P]),Rt=(0,F.useCallback)(e=>{Oe(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]),zt=(0,F.useCallback)(()=>{Oe(e=>{let t=e.scopeKey===Y?e.fileKeys:at;return{scopeKey:Y,fileKeys:j(Nt,t)}})},[Y,Nt]),Bt=e=>{P&&N.getState().selectTurn(P,e)},Vt=e=>{P&&N.getState().selectGitScope(P,e)},Ht=e=>{P&&N.getState().selectBranchBaseRef(P,e)};return(0,L.jsx)(xe,{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)(_,{children:[(0,L.jsxs)(te,{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: ${ut}`,children:[(0,L.jsx)(`span`,{className:`truncate`,children:ut}),(0,L.jsx)(p,{className:`size-3.5 shrink-0 text-muted-foreground`})]}),(0,L.jsxs)(f,{align:`start`,className:`w-60`,children:[(0,L.jsx)(D,{className:W===null&&G===`unstaged`?`bg-foreground/[0.08]`:void 0,onClick:()=>Vt(`unstaged`),children:(0,L.jsx)(`span`,{children:`Working tree`})}),(0,L.jsx)(D,{className:W===null&&G===`branch`?`bg-foreground/[0.08]`:void 0,onClick:()=>Vt(`branch`),children:(0,L.jsx)(`span`,{children:`Branch changes`})}),(0,L.jsx)(D,{className:W!==null&&q?.turnId===lt?.turnId?`bg-foreground/[0.08]`:void 0,onClick:()=>{lt&&Bt(lt.turnId)},children:(0,L.jsx)(`span`,{children:`Latest turn`})}),(0,L.jsxs)(i,{children:[(0,L.jsx)(l,{children:`Turn`}),(0,L.jsx)(ae,{className:`w-64`,children:U.map(e=>{let t=e.checkpointTurnCount??V[e.turnId]??`?`;return(0,L.jsxs)(D,{className:e.turnId===q?.turnId?`bg-foreground/[0.08]`:void 0,onClick:()=>Bt(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:be(e.completedAt,o.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)(A,{className:`size-3.5 shrink-0 opacity-70`}),(0,L.jsxs)(Ve,{items:wt,filteredItems:Tt,value:K??H,onOpenChange:e=>{e||se(``)},onValueChange:e=>{e&&Ht(e===H?null:e)},children:[(0,L.jsxs)(Re,{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)(p,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,L.jsxs)(De,{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)(We,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1.5 left-0 size-4 shrink-0 text-muted-foreground/55`}),(0,L.jsx)(Me,{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:k,onChange:e=>se(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)(we,{children:`No matching refs.`}),(0,L.jsxs)(Ee,{className:`max-h-64 min-w-0 overflow-x-hidden`,children:[(0,L.jsx)(Ue,{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`})}),xt.map(e=>{let t=Ct(e),n=e.local!==null&&e.remote!==null,r=e.remote?.name===t;return(0,L.jsx)(Ue,{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)(Ie,{"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&&Ht(n)}})}):e.remote?(0,L.jsx)(`span`,{className:`flex justify-end text-muted-foreground`,title:`Remote only`,children:(0,L.jsx)(ne,{"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)(ke,{additions:Ft.additions,deletions:Ft.deletions,className:`mr-1 text-[11px]`,layout:`inline`}),$.length>0&&(0,L.jsxs)(C,{children:[(0,L.jsx)(E,{render:(0,L.jsx)(h,{type:`button`,size:`icon-xs`,variant:`outline`,"aria-label":Pt?`Expand all files`:`Collapse all files`,onClick:zt}),children:Pt?(0,L.jsx)(Fe,{className:`size-3`}):(0,L.jsx)(Be,{className:`size-3`})}),(0,L.jsx)(x,{side:`top`,children:Pt?`Expand all files`:`Collapse all files`})]}),(0,L.jsxs)(M,{className:`shrink-0`,variant:`outline`,size:`xs`,value:[d],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&g(t)},children:[(0,L.jsx)(de,{"aria-label":`Stacked diff view`,value:`stacked`,children:(0,L.jsx)(ce,{className:`size-3`})}),(0,L.jsx)(de,{"aria-label":`Split diff view`,value:`split`,children:(0,L.jsx)(ue,{className:`size-3`})})]}),(0,L.jsxs)(C,{children:[(0,L.jsx)(E,{render:(0,L.jsx)(de,{"aria-label":v?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`outline`,size:`xs`,pressed:v,onPressedChange:e=>{y(!!e)}}),children:(0,L.jsx)(_e,{className:`size-3`})}),(0,L.jsx)(x,{side:`top`,children:v?`Disable line wrapping`:`Enable line wrapping`})]}),(0,L.jsxs)(C,{children:[(0,L.jsx)(E,{render:(0,L.jsx)(de,{"aria-label":S?`Show whitespace changes`:`Hide whitespace changes`,variant:`outline`,size:`xs`,pressed:S,onPressedChange:e=>{w(!!e)}}),children:(0,L.jsx)(Ke,{className:`size-3`})}),(0,L.jsx)(x,{side:`top`,children:S?`Show whitespace changes`:`Hide whitespace changes`})]})]})]}),children:I?et?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:[Ot&&(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.`}),At&&!Q&&(0,L.jsx)(`div`,{className:`px-3`,children:(0,L.jsx)(`p`,{className:`mb-2 text-[11px] text-red-500/80`,children:At})}),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&&Lt(t)},children:(0,L.jsx)(Ze,{viewerRef:Ae,className:`diff-render-surface h-full min-h-0 overflow-auto`,files:$,sectionId:dt,sectionTitle:pt,composerDraftTarget:t,renderHeaderPrefix:(e,t,n)=>{let r=Ne(e);return(0,L.jsxs)(C,{children:[(0,L.jsx)(E,{render:(0,L.jsx)(`button`,{type:`button`,className:u(`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`,Ce(e)),"aria-label":n?`Expand ${r}`:`Collapse ${r}`,"aria-expanded":!n,onClick:e=>{e.stopPropagation(),Rt(t)}}),children:n?(0,L.jsx)(m,{className:`size-4`}):(0,L.jsx)(p,{className:`size-4`})}),(0,L.jsx)(x,{side:`top`,children:n?`Expand diff`:`Collapse diff`})]})},options:{diffStyle:d===`split`?`split`:`unified`,lineDiffType:`none`,overflow:v?`wrap`:`scroll`,theme:Te(r),themeType:r,unsafeCSS:ot,stickyHeaders:!0,itemMetrics:{diffHeaderHeight:33},layout:{paddingTop:0,paddingBottom:8,gap:8}}},Y??dt)}):(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:u(`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})]})}):kt?(0,L.jsx)(he,{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:jt?`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{Se as DiffWorkerPoolProvider,U as default};
98
- //# sourceMappingURL=DiffPanel-DMG1sFit.js.map
98
+ //# sourceMappingURL=DiffPanel-Jfn-nZ2P.js.map
@@ -1,4 +1,4 @@
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,Dr as a,El as o,G as s,Ot as c,Pa as l,Qc as u,Wc as d,Yc as f,_a as p,_f as m,al as h,dt as g,ft as _,gt as v,h as y,ht as b,il as x,jl as S,mt as C,n as w,o as T,st as E,vt as D,wt as O,x as ee,xr as k,xt as te,yt as A}from"./previewAssetResource-JdwqlhCI.js";import{n as j,r as M,t as N}from"./renderFileChildren-WGgqPbPK.js";import{$ as ne,Ar as re,Bn as ie,Cn as ae,Cr as oe,D as se,E as ce,Fn as le,Fr as ue,Gn as de,Gt as fe,Hn as pe,Hr as P,Ht as me,Jr as he,Jt as ge,Kn as F,Kt as _e,Mn as ve,Pr as ye,T as be,Un as xe,Ut as Se,Vn as Ce,Wn as we,Z as Te,Zr as I,_r as Ee,_t as De,an as Oe,b as ke,bn as Ae,br as je,ct as Me,d as Ne,ei as Pe,et as Fe,f as Ie,fn as Le,gt as Re,hr as ze,ii as Be,kr as Ve,l as He,m as Ue,on as We,p as Ge,qn as Ke,ri as qe,ti as Je,tt as Ye,u as Xe,v as Ze,vr as Qe,w as $e,wn as et,x as tt,y as nt,yr as rt,zr as it}from"./index-BL9HZoA_.js";import{a as at,i as ot,n as st,r as L,t as R}from"./fileCommentAnnotations-1_E_uBQa.js";var ct=u(`file-question-mark`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}]]),lt=u(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),ut=`file-tree-container`,dt=`data-file-tree-style`,ft=`data-file-tree-unsafe-css`,pt=`data-file-tree-scrollbar-measure`,mt=`data-file-tree-scrollbar-gutter-measured`,ht=`--trees-scrollbar-gutter-measured`,gt=`header`,_t=`context-menu`,vt=`context-menu-trigger`,yt=5,bt=1<<yt,xt=bt*4;function z(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function St(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function Ct(e,t){if(t.childIdByNameId!=null)return t.childIdByNameId;let n=new Map;for(let r of t.childIds){let t=e[r];t!=null&&n.set(t.nameId,r)}return t.childIdByNameId=n,n}function wt(e){if(e.childPositionById!=null)return e.childPositionById;let t=new Map;for(let n=0;n<e.childIds.length;n++){let r=e.childIds[n];r!=null&&t.set(r,n)}return e.childPositionById=t,t}function Tt(e,t){e.childPositionById!=null&&e.childPositionById.set(t,e.childIds.length),e.childIds.push(t)}function Et(e,t){if(e.childPositionById!=null)for(let n=t;n<e.childIds.length;n++){let t=e.childIds[n];t!=null&&e.childPositionById.set(t,n)}}function Dt(e,t){let n=0,r=0;for(let i of t.childIds){let t=e[i];t!=null&&(n+=t.subtreeNodeCount,r+=t.visibleSubtreeCount)}t.totalChildSubtreeNodeCount=n,t.totalChildVisibleSubtreeCount=r,jt(e,t)}function Ot(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=wt(e).get(t);if(i===void 0)return;let a=i>>yt;e.childVisibleChunkSums[a]+=r}function kt(e,t,n){let r=t.childVisibleChunkSums;if(r!=null){let i=n,a=0;for(let o of r){if(i<o){let r=Mt(e,t,a,i);return{...r,childVisibleIndex:n-r.localVisibleIndex}}i-=o,a+=bt}throw Error(`Visible child index ${String(n)} is out of range`)}let i=n;for(let r=0;r<t.childIds.length;r++){let a=t.childIds[r];if(a==null)continue;let o=e[a];if(o!=null){if(i<o.visibleSubtreeCount)return{childIndex:r,childVisibleIndex:n-i,localVisibleIndex:i};i-=o.visibleSubtreeCount}}throw Error(`Visible child index ${String(n)} is out of range`)}function At(e,t,n){let r=0,i=t.childVisibleChunkSums,a=0;if(i!=null){let e=n>>yt;for(let t=0;t<e;t+=1)r+=i[t]??0;a=e<<yt}for(let i=a;i<n;i+=1){let n=t.childIds[i];if(n==null)continue;let a=e[n];a!=null&&(r+=a.visibleSubtreeCount)}return r}function jt(e,t){if(t.childIds.length<xt){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/bt),r=new Int32Array(n);for(let n=0;n<t.childIds.length;n++){let i=t.childIds[n];if(i==null)continue;let a=e[i];a!=null&&(r[n>>yt]+=a.visibleSubtreeCount)}t.childVisibleChunkSums=r}function Mt(e,t,n,r){let i=Math.min(t.childIds.length,n+bt),a=r;for(let r=n;r<i;r++){let n=t.childIds[r];if(n==null)continue;let i=e[n];if(i!=null){if(a<i.visibleSubtreeCount)return{childIndex:r,localVisibleIndex:a};a-=i.visibleSubtreeCount}}throw Error(`Visible child index ${String(r)} is out of range`)}var Nt=7,Pt=3,Ft=1<<Pt,It=4;function Lt(e,t,n=0){return e<<It|n<<Pt|t}function Rt(e){return e.depthAndFlags>>>It}function zt(e){return(e.depthAndFlags&Ft)>>Pt}function B(e){return(e.depthAndFlags&Ft)!==0}function Bt(e){return e.depthAndFlags&Nt}function Vt(e,t){return(Bt(e)&t)!==0}function Ht(e,t){e.depthAndFlags|=t}function Ut(e,t){e.depthAndFlags=Lt(t,Bt(e),zt(e))}var Wt=Symbol(`benchmarkInstrumentation`);function Gt(e,t){return t==null||Object.defineProperty(e,Wt,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function Kt(e){return e==null?null:e[Wt]??null}function V(e,t,n){return e==null?n():e.measurePhase(t,n)}function qt(e,t,n){!Number.isFinite(n)||e==null||e.setCounter(t,n)}function Jt(e){return e>=48&&e<=57}function Yt(e){let t=[],n=0,r=0;for(;r<e.length;){for(;r<e.length&&!Jt(e.charCodeAt(r));)r+=1;if(r>=e.length)break;r>n&&t.push(e.slice(n,r));let i=0;for(;r<e.length&&Jt(e.charCodeAt(r));)i=i*10+(e.charCodeAt(r)-48),r+=1;t.push(i),n=r}return(n<e.length||t.length===0)&&t.push(e.slice(n)),t}function Xt(e){let t=e.toLowerCase();return{lowerValue:t,tokens:Yt(t)}}function Zt(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let n=e[r],i=t[r];if(n===i)continue;if(typeof n==`number`&&typeof i==`number`)return n<i?-1:1;let a=String(n),o=String(i);if(a!==o)return a<o?-1:1}return e.length===t.length?0:e.length<t.length?-1:1}function Qt(e,t){if(e.tokens.length===1&&t.tokens.length===1&&typeof e.tokens[0]==`string`&&typeof t.tokens[0]==`string`)return e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1;let n=Zt(e.tokens,t.tokens);return n===0?e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1:n}function $t(e,t,n){let r=Qt(n(e),n(t));return r===0?e===t?0:e<t?-1:1:r}function en(e,t){return $t(e,t,Xt)}function tn(e,t){return t===e.segments.length-1?+!!e.isDirectory:1}function nn(e,t){let n=Math.min(e.segments.length,t.segments.length);for(let r=0;r<n;r++){let n=e.segments[r],i=t.segments[r];if(n===i)continue;let a=tn(e,r);return a===tn(t,r)?en(n,i):a===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function rn(e,t){return nn(e,t)}function an(e,t,n){let r=e=>{let t=n.get(e);if(t!=null)return t;let r=Xt(e);return n.set(e,r),r},i=Math.min(e.segments.length,t.segments.length);for(let n=0;n<i;n++){let i=e.segments[n],a=t.segments[n];if(i===a)continue;let o=tn(e,n);return o===tn(t,n)?$t(i,a,r):o===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function on(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=Xt(r);return e.sortKeyById[t]=i,i}function sn(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??`default`}}function cn(e){let t=e.length>0&&e.charCodeAt(e.length-1)===47,n=t?e.length-1:e.length,r=[],i=0;for(let t=0;t<n;t++)e.charCodeAt(t)===47&&(r.push(e.slice(i,t)),i=t+1);return r.push(e.slice(i,n)),{hasTrailingSlash:t,segments:r}}function ln(e){let{hasTrailingSlash:t,segments:n}=cn(e);return{basename:n[n.length-1]??``,isDirectory:t,path:e,segments:n}}function un(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=cn(e);return{requiresDirectory:t,segments:n}}var dn=``;function fn(){let e=new Map;return e.set(dn,0),{idByValue:e,valueById:[dn],sortKeyById:[Xt(dn)]}}function pn(e,t){let n=e.idByValue.get(t);if(n!==void 0)return n;let r=e.valueById.length;return e.idByValue.set(t,r),e.valueById.push(t),r}function mn(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var hn=Symbol(`pathStorePreparedInputKind`);function gn(e,t){return e[hn]=t,e}function _n(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function vn(e,t,n){return n==="default"?rn(e,t):n(_n(e),_n(t))}function yn(){return{depthAndFlags:Lt(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function bn(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return r;return n}function xn(e){return e.isDirectory?e.segments.length:e.segments.length-1}function Sn(e){return Array.isArray(e)&&e.every(e=>typeof e==`object`&&!!e&&typeof e.path==`string`&&Array.isArray(e.segments)&&typeof e.basename==`string`&&typeof e.isDirectory==`boolean`)}function Cn(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function wn(e,t={}){return An(e,t).map(e=>e.path)}function Tn(e,t={}){let n=An(e,t);return gn({paths:n.map(e=>e.path),preparedPaths:n},`prepared`)}function En(e){let t=e.length,n=!1;for(let r=0;r<t;r+=1){let t=e[r];if(t.length>0&&t.charCodeAt(t.length-1)===47){n=!0;break}}return gn({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},`presorted`)}function Dn(e){let t=e,n=t.preparedPaths;if(t[hn]===`prepared`&&n!=null)return n;if(!Sn(n))throw Error(`preparedInput must come from PathStore.prepareInput()`);return n}function On(e){let t=e;return t[hn]===`presorted`&&t.presortedPaths!=null||Cn(t.presortedPaths)?t.presortedPaths:null}function kn(e){let t=e;return typeof t.presortedPathsContainDirectories==`boolean`?t.presortedPathsContainDirectories:null}function An(e,t={}){let n=sn(t),r=Kt(t);qt(r,`workload.inputFiles`,e.length);let i=V(r,`store.preparePathEntries.parse`,()=>e.map(e=>ln(e)));return V(r,`store.preparePathEntries.sort`,()=>i.sort((e,t)=>vn(e,t,n.sort))),i}var jn=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[yn()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=fn();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=Kt(e),this.options=sn(e);let t=e.initialExpandedPaths??null;if(t==null||t.length===0)this.initialExpandedPathSet=null;else{let e=new Set,n=t.length;for(let r=0;r<n;r+=1){let n=t[r],i=n.length;e.add(i>0&&n.charCodeAt(i-1)===47?n.slice(0,i-1):n)}this.initialExpandedPathSet=e,this.createdDirectoriesAllExpanded=!0}this.directories.set(0,z())}appendPaths(e){return V(this.instrumentation,`store.builder.appendPaths.parse`,()=>this.appendPreparedPaths(e.map(e=>ln(e))))}appendPreparedPaths(e,t=!0){return this.createdDirectoriesAllExpanded=!1,V(this.instrumentation,`store.builder.appendPreparedPaths`,()=>{for(let n of e)this.appendPreparedPath(n,t)}),this}appendPresortedPaths(e,t=null){return V(this.instrumentation,`store.builder.appendPresortedPaths`,()=>{if(t===!1){this.appendPresortedFilePaths(e);return}this.createdDirectoriesAllExpanded=!1;let n=null,r=0,i=this.nodes,a=this.segmentTable,o=a.idByValue,s=a.valueById,c=this.directoryStack,l=0,u=``,d=0;for(let t of e){if(n===t)throw Error(`Duplicate path: "${t}"`);let e=t.length>0&&t.charCodeAt(t.length-1)===47,a=e?t.length-1:t.length,f=0,p=0;if(n!=null)if(u.length>0&&t.length>u.length&&t.startsWith(u))f=d,p=u.length;else{let r=Math.min(a,n.length),i=!0;for(let e=0;e<r;e++){let r=t.charCodeAt(e);if(r!==n.charCodeAt(e)){i=!1;break}r===47&&(f++,p=e+1)}i&&e&&r===a&&n.length>a&&n.charCodeAt(a)===47&&(f++,p=a+1)}l=f,r=f;let m=p,h=t.indexOf(`/`,m);for(;h>=0&&h<a;){let e=c[l];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);r++;let n=t.slice(m,h),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n));let u=i.length;i.push({depthAndFlags:Lt(r,0,1),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(t.slice(0,h)),l++,c[l]=u,m=h+1,h=t.indexOf(`/`,m)}if(e){if(m<a){let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory parent for "${t}"`);r++;let n=t.slice(m,a),u=o.get(n);u===void 0&&(u=s.length,o.set(n,u),s.push(n));let d=i.length;i.push({depthAndFlags:Lt(r,0,1),nameId:u,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),l++,c[l]=d}let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory node for "${t}"`);this.promoteDirectoryToExplicit(e,t)}else{let e=c[l];if(e===void 0)throw Error(`Unable to resolve file parent for "${t}"`);let n=t.slice(m),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n)),i.push({depthAndFlags:Lt(r+1,0),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1})}m!==u.length&&(u=t.substring(0,m),d=r),n=t}c.length=l+1,n!=null&&(this.lastPreparedPath=ln(n)),this.hasDeferredDirectoryIndexes=!0}),this}appendPresortedFilePaths(e){let t=null,n=0,r=this.nodes,i=this.segmentTable,a=i.idByValue,o=i.valueById,s=this.directoryStack,c=0,l=``,u=0;for(let i of e){if(t===i)throw Error(`Duplicate path: "${i}"`);let e=i.length,d=0,f=0;if(t!=null)if(l.length>0&&i.length>l.length&&i.startsWith(l))d=u,f=l.length;else{let n=Math.min(e,t.length);for(let e=0;e<n;e++){let n=i.charCodeAt(e);if(n!==t.charCodeAt(e))break;n===47&&(d++,f=e+1)}}c=d,n=d;let p=f,m=i.indexOf(`/`,p);for(;m>=0;){let e=s[c];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);n++;let t=i.slice(p,m),l=a.get(t);l===void 0&&(l=o.length,a.set(t,l),o.push(t));let u=r.length;r.push({depthAndFlags:Lt(n,0,1),nameId:l,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(i.slice(0,m)),this.presortedDirectoryNodeIds.push(u),c++,s[c]=u,p=m+1,m=i.indexOf(`/`,p)}let h=s[c];if(h===void 0)throw Error(`Unable to resolve file parent for "${i}"`);let g=i.slice(p),_=a.get(g);_===void 0&&(_=o.length,a.set(g,_),o.push(g)),r.push({depthAndFlags:Lt(n+1,0),nameId:_,parentId:h,subtreeNodeCount:1,visibleSubtreeCount:1}),p!==l.length&&(l=i.substring(0,p),u=n),t=i}s.length=c+1,t!=null&&(this.lastPreparedPath=ln(t)),this.hasDeferredDirectoryIndexes=!0}finish(e={}){let t=e.skipSubtreeCountPass===!0;return this.hasDeferredDirectoryIndexes?(V(this.instrumentation,`store.builder.buildDirectoryIndexes`,()=>this.buildPresortedFinish(t)),this.hasDeferredDirectoryIndexes=!1):t||V(this.instrumentation,`store.builder.computeSubtreeCounts`,()=>this.computeSubtreeCounts(0)),{directories:this.directories,nodes:this.nodes,options:this.options,rootId:0,segmentTable:this.segmentTable,presortedDirectoryNodeIds:this.presortedDirectoryNodeIds.length>0?this.presortedDirectoryNodeIds:null}}didMatchAllInitialExpandedPaths(){return this.createdDirectoriesAllExpanded&&this.initialExpandedPathSet!=null&&this.createdDirectoryCount===this.initialExpandedPathSet.size}appendPreparedPath(e,t){if(this.hasDeferredDirectoryIndexes&&=(this.buildDirectoryIndexes(),!1),this.lastPreparedPath!=null){if(e.path===this.lastPreparedPath.path)throw Error(`Duplicate path: "${e.path}"`);if(t&&(this.options.sort==="default"?an(this.lastPreparedPath,e,this.segmentSortKeyCache):vn(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}let n=this.lastPreparedPath,r=xn(e),i=n==null?0:xn(n),a=n==null?0:bn(n.segments,e.segments),o=Math.min(a,r,i);this.directoryStack.length=o+1;for(let n=o;n<r;n++){let r=this.directoryStack[this.directoryStack.length-1];if(r===void 0)throw Error(`Directory stack underflow while building the path store`);let i=t?this.getOrCreateDirectoryChild(r,e.segments[n]):this.createDirectoryChild(r,e.segments[n]);this.directoryStack.push(i)}if(e.isDirectory){let t=this.directoryStack[this.directoryStack.length-1];if(t===void 0)throw Error(`Unable to resolve directory node for "${e.path}"`);this.promoteDirectoryToExplicit(t,e.path),this.lastPreparedPath=e;return}let s=this.directoryStack[this.directoryStack.length-1];if(s===void 0)throw Error(`Unable to resolve file parent for "${e.path}"`);t?this.createFileChild(s,e.basename,e.path):this.createFileChildUnchecked(s,e.basename),this.lastPreparedPath=e}recordCreatedDirectoryPath(e){!this.createdDirectoriesAllExpanded||this.initialExpandedPathSet==null||(this.createdDirectoryCount+=1,this.initialExpandedPathSet.has(e)||(this.createdDirectoriesAllExpanded=!1))}createFileChild(e,t,n){let r=pn(this.segmentTable,t),i=this.getDirectoryIndex(e),a=i.childIdByNameId;if(a!=null&&a.get(r)!==void 0)throw Error(`Path collides with an existing entry: "${n}"`);let o=this.nodes[e];if(o===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let s=this.nodes.length;return this.nodes.push({depthAndFlags:Lt(Rt(o)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),a?.set(r,s),Tt(i,s),s}createFileChildUnchecked(e,t){let n=pn(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:Lt(Rt(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Tt(r,a),a}getOrCreateDirectoryChild(e,t){let n=pn(this.segmentTable,t),r=this.getDirectoryIndex(e);if(r.childIdByNameId!=null){let e=r.childIdByNameId.get(n);if(e!==void 0){let n=this.nodes[e];if(n!=null&&!B(n))throw Error(`Path collides with an existing file while creating directory "${t}"`);return e}}let i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:Lt(Rt(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Tt(r,a),this.directories.set(a,z()),a}createDirectoryChild(e,t){let n=pn(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:Lt(Rt(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Tt(r,a),this.directories.set(a,z()),a}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!B(n))throw Error(`Path is not a directory: "${t}"`);if(Vt(n,1))throw Error(`Duplicate path: "${t}"`);Ht(n,1)}getDirectoryIndex(e){let t=this.directories.get(e);if(t!==void 0)return t;throw Error(`Unknown directory child index for node ${String(e)}`)}buildPresortedFinish(e){let t=this.nodes,n=this.directories;n.set(0,St());let r=-1,i=null;for(let e=1;e<t.length;e++){let a=t[e];if(a==null)continue;if(B(a)){let t=St();n.set(e,t),r=e,i=t}let o;a.parentId===r?o=i:(o=n.get(a.parentId),r=a.parentId,i=o??null),o?.childIds.push(e)}if(!e)for(let e=t.length-1;e>=1;e--){let n=t[e];if(n==null)continue;let r=t[n.parentId];r!=null&&(r.subtreeNodeCount+=n.subtreeNodeCount,r.visibleSubtreeCount+=n.visibleSubtreeCount)}}buildDirectoryIndexes(){let e=this.nodes;for(let t=1;t<e.length;t++){let n=e[t];if(n==null)continue;B(n)&&this.directories.set(t,z());let r=this.directories.get(n.parentId);r!=null&&(r.childIdByNameId!=null&&r.childIdByNameId.set(n.nameId,t),Tt(r,t))}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!B(t))return t.subtreeNodeCount=1,t.visibleSubtreeCount=1,1;let n=this.getDirectoryIndex(e),r=1;for(let e of n.childIds)r+=this.computeSubtreeCounts(e);return Dt(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function Mn(e,t=`closed`,n=null){let r=Pn(t);return{activeNodeCount:e.nodes.length-1,collapsedDirectoryIds:new Set,collapseNewDirectoriesByDefault:!1,defaultExpansion:r,directoriesOpenByDefault:r===`open`,hasCollapsedDirectoryOverrides:!1,directoryLoadInfoById:new Map,expandedDirectoryIds:new Set,instrumentation:n,listeners:new Map,pathCacheByNodeId:new Map([[e.rootId,{path:``,version:0}]]),pathCacheVersion:0,snapshot:e,transactionStack:[]}}function Nn(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function Pn(e){if(typeof e!=`number`)return e;if(!Number.isInteger(e)||e<0)throw Error(`initialExpansion must be "open", "closed", or a non-negative integer depth. Received: ${String(e)}`);return e}function Fn(e,t){return Vt(t,2)||e.defaultExpansion===`open`?!0:e.defaultExpansion===`closed`?!1:Rt(t)<=e.defaultExpansion}function In(e,t,n=e.snapshot.nodes[t]){return n==null||!B(n)?!1:e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides?!0:e.collapsedDirectoryIds.has(t)?!1:e.expandedDirectoryIds.has(t)?!0:Fn(e,n)}function Ln(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!B(r))return;let i=Fn(e,r);if(n){if(i){e.collapsedDirectoryIds.delete(t),e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0;return}e.expandedDirectoryIds.add(t);return}if(i){e.collapsedDirectoryIds.add(t),e.hasCollapsedDirectoryOverrides=!0;return}e.expandedDirectoryIds.delete(t)}function Rn(e,t){let n=e.directoryLoadInfoById.get(t);if(n!=null)return n;let r={activeAttemptId:null,errorMessage:null,nextAttemptId:1,state:`loaded`};return e.directoryLoadInfoById.set(t,r),r}function zn(e,t){return e.directoryLoadInfoById.get(t)?.state??`loaded`}function Bn(e,t){let n=Rn(e,t);if(n.state===`loading`&&n.activeAttemptId!=null)return{attemptId:n.activeAttemptId,nodeId:t,reused:!0};let r=n.nextAttemptId;return n.activeAttemptId=r,n.errorMessage=null,n.nextAttemptId+=1,n.state=`loading`,{attemptId:r,nodeId:t,reused:!1}}function Vn(e,t){let n=Rn(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state=`unloaded`}function Hn(e,t,n){let r=e.directoryLoadInfoById.get(t);return r==null||r.activeAttemptId!==n?!1:(r.activeAttemptId=null,r.errorMessage=null,r.state=`loaded`,!0)}function Un(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function Wn(e,t,n,r){let i=e.directoryLoadInfoById.get(t);return i==null||i.activeAttemptId!==n?!1:(i.activeAttemptId=null,i.errorMessage=r??null,i.state=`error`,!0)}function Gn(e,t){e.directoryLoadInfoById.delete(t)}function Kn(e,t,n){let r=n,i=e.listeners.get(t);return i==null?e.listeners.set(t,new Set([r])):i.add(r),()=>{let n=e.listeners.get(t);n!=null&&(n.delete(r),n.size===0&&e.listeners.delete(t))}}function qn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`add`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Jn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`remove`,path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function Yn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:`move`,projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function Xn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`expand`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Zn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`collapse`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Qn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`mark-directory-unloaded`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function $n(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`begin-child-load`,path:e.path,projectionChanged:e.projectionChanged,reused:e.reused,visibleCountDelta:null}}function er(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:e.childEvents.some(e=>e.canonicalChanged),childEvents:e.childEvents,operation:`apply-child-patch`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function tr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`complete-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function nr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,errorMessage:e.errorMessage,operation:`fail-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function rr(e){return{activeNodeCountAfter:e.activeNodeCountAfter,activeNodeCountBefore:e.activeNodeCountBefore,affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],cachedPathEntryCountAfter:e.cachedPathEntryCountAfter,cachedPathEntryCountBefore:e.cachedPathEntryCountBefore,canonicalChanged:!1,idsPreserved:e.idsPreserved,loadInfoEntryCountAfter:e.loadInfoEntryCountAfter,loadInfoEntryCountBefore:e.loadInfoEntryCountBefore,mode:e.mode,operation:`cleanup`,projectionChanged:e.projectionChanged,reclaimedCachedPathEntryCount:e.reclaimedCachedPathEntryCount,reclaimedLoadInfoEntryCount:e.reclaimedLoadInfoEntryCount,reclaimedNodeSlotCount:e.reclaimedNodeSlotCount,reclaimedSegmentCount:e.reclaimedSegmentCount,segmentCountAfter:e.segmentCountAfter,segmentCountBefore:e.segmentCountBefore,totalNodeSlotCountAfter:e.totalNodeSlotCountAfter,totalNodeSlotCountBefore:e.totalNodeSlotCountBefore,visibleCountDelta:null}}function ir(e,t,n){return{...n,visibleCountDelta:hr(e)-t}}function ar(e,t){let n=hr(e),r=Nn();e.transactionStack.push(r);try{t()}catch(t){throw cr(e,r,!1),t}cr(e,r,!0,hr(e)-n)}function or(e,t){let n=e.instrumentation;if(n==null){sr(e,t);return}V(n,`store.events.record`,()=>sr(e,t))}function sr(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){pr(e,t);return}n.events.push(t),fr(n,t)}function cr(e,t,n,r=null){if(e.transactionStack.pop()!==t)throw Error(`Transaction stack underflow`);if(!n)return;let i=e.transactionStack[e.transactionStack.length-1]??null;if(i!=null){let n=e.instrumentation;n==null?dr(i,t):V(n,`store.events.batch.merge`,()=>dr(i,t));return}let a=lr(t,r),o=e.instrumentation;if(o==null){pr(e,a);return}V(o,`store.events.batch.commit`,()=>pr(e,a))}function lr(e,t){return{affectedAncestorIds:[...e.affectedAncestorIds],affectedNodeIds:[...e.affectedNodeIds],canonicalChanged:e.events.some(e=>e.canonicalChanged),events:[...e.events],operation:`batch`,projectionChanged:e.events.some(e=>e.projectionChanged),visibleCountDelta:t}}function ur(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function dr(e,t){for(let n of t.events)e.events.push(n);ur(e,t)}function fr(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function pr(e,t){let n=e.instrumentation;if(n==null){mr(e,t);return}V(n,`store.events.emit`,()=>mr(e,t))}function mr(e,t){e.listeners.get(t.operation)?.forEach(e=>e(t)),e.listeners.get(`*`)?.forEach(e=>e(t))}function hr(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function gr(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!B(n)||Vt(n,2))return null;let r=e.snapshot.directories.get(t);if(r==null||r.childIds.length!==1)return null;let i=r.childIds[0];if(i==null)return null;let a=e.snapshot.nodes[i];return a==null||!B(a)?null:i}function _r(e,t){let n=t;for(;;){let t=gr(e,n);if(t==null)return n;n=t}}function vr(e,t){let n=[t],r=t;for(;;){let t=gr(e,r);if(t==null)return n;n.push(t),r=t}}function yr(e,t){let n=t==null?e.snapshot.rootId:Or(e,t);return n==null?[]:Ar(e,n)}function br(e,t){let n=ln(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=Gr(e,Wr(e,r)),{createdNodeIds:a,directoryId:o}=jr(e,r),s=new Set(a),c=o;if(n.isDirectory){let n=W(e,o);if(Vt(n,1))throw Error(`Path already exists: "${t}"`);Ht(n,1),e.pathCacheByNodeId.set(o,{path:t,version:e.pathCacheVersion}),s.add(o)}else c=Nr(e,o,n.basename),s.add(c);Tr(e,o);let l=Gr(e,o);return qn({affectedAncestorIds:Dr(e,c),affectedNodeIds:[...s],path:t,projectionChanged:Kr(i,l)})}function xr(e,t,n){let r=Or(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=W(e,r);if(Vt(i,2))throw Error(`The root node cannot be removed`);if(B(i)&&U(e,r).childIds.length>0&&n.recursive!==!0)throw Error(`Cannot remove a non-empty directory without recursive: "${t}"`);let a=i.parentId,o=Gr(e,a),s=Hr(e,r);Ir(e,a,r,i.nameId),Ur(e,a),Tr(e,a);let c=Gr(e,a);return Jn({affectedAncestorIds:Dr(e,a),affectedNodeIds:s,path:t,projectionChanged:Kr(o,c),recursive:n.recursive===!0})}function Sr(e,t,n,r){let i=Or(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let a=W(e,i);if(Vt(a,2))throw Error(`The root node cannot be moved`);let o=r.collision??`error`,s=Br(e,i,n),c=Gr(e,a.parentId),l=Gr(e,s.parentId),u=mn(e.snapshot.segmentTable,a.nameId),d=pn(e.snapshot.segmentTable,s.basename);if(s.parentId===a.parentId&&u===s.basename)return null;if(B(a)&&Xr(e,i,s.parentId))throw Error(`Cannot move a directory into one of its descendants`);let f=Ct(e.snapshot.nodes,U(e,s.parentId)).get(d),p=s.existingNodeId??f??null;if(p!=null&&p!==i&&Vr(e,p,o,zt(a))===`skip`)return null;let m=a.parentId;Ir(e,m,i,a.nameId),a.parentId=s.parentId,a.nameId=d,e.pathCacheByNodeId.delete(i),Yr(e,i),Fr(e,s.parentId,i),Ur(e,m),e.pathCacheVersion++,Tr(e,m),s.parentId!==m&&Tr(e,s.parentId);let h=Gr(e,m),g=Gr(e,s.parentId);return Yn({affectedAncestorIds:[...new Set([...Dr(e,m),...Dr(e,s.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:qr([c,l],[h,g]),to:H(e,i)})}function Cr(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function wr(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function H(e,t){let n=W(e,t),r=Cr(e,t);if(r!=null)return r;if(Vt(n,2))return wr(e,t,``);let i=H(e,n.parentId),a=mn(e.snapshot.segmentTable,n.nameId),o=i.length===0?a:`${i}${a}`;return wr(e,t,B(n)?`${o}/`:o)}function Tr(e,t){let n=e.instrumentation;if(n==null){Qr(e,t);return}V(n,`store.recomputeCountsUpwardFrom`,()=>Qr(e,t))}function Er(e,t){let n=[[t,0]],{nodes:r,directories:i}=e.snapshot;for(;n.length>0;){let t=n[n.length-1],a=t[0],o=r[a];if(o==null||!B(o)){Zr(e,a,o,!0),n.pop();continue}let s=i.get(a);if(s==null||t[1]>=s.childIds.length){Zr(e,a,o,!0),n.pop();continue}let c=s.childIds[t[1]++];n.push([c,0])}}function Dr(e,t){let n=[],r=t;for(;r!=null;){let t=W(e,r);if(n.push(r),r===e.snapshot.rootId)break;r=t.parentId}return n}function Or(e,t){if(t.length===0)return e.snapshot.rootId;let n=un(t);return kr(e,n.segments,n.requiresDirectory)}function kr(e,t,n){let r=e.snapshot.rootId;for(let n of t){let t=e.snapshot.segmentTable.idByValue.get(n);if(t===void 0)return null;let i=U(e,r),a=Ct(e.snapshot.nodes,i).get(t);if(a===void 0)return null;r=a}let i=W(e,r);return n&&!B(i)?null:r}function U(e,t){let n=e.snapshot.directories.get(t);if(n===void 0)throw Error(`Unknown directory child index for node ${String(t)}`);return n}function W(e,t){let n=e.snapshot.nodes[t];if(n===void 0||Vt(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function Ar(e,t){let n=e.snapshot.nodes[t];if(n===void 0||Vt(n,4))return[];if(!B(n))return[H(e,t)];if(U(e,t).childIds.length===0)return Vt(n,1)&&!Vt(n,2)?[H(e,t)]:[];let r=[],i=[{childIndex:0,nodeId:t}];for(;i.length>0;){let t=i[i.length-1];if(t==null)break;let n=e.snapshot.nodes[t.nodeId];if(n===void 0||Vt(n,4)){i.pop();continue}if(!B(n)){r.push(H(e,t.nodeId)),i.pop();continue}let a=U(e,t.nodeId);if(a.childIds.length===0){Vt(n,1)&&!Vt(n,2)&&r.push(H(e,t.nodeId)),i.pop();continue}let o=a.childIds[t.childIndex];if(o==null){i.pop();continue}t.childIndex++,i.push({childIndex:0,nodeId:o})}return r}function jr(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let t=pn(e.snapshot.segmentTable,i),a=U(e,r),o=Ct(e.snapshot.nodes,a).get(t);if(o!==void 0){if(!B(W(e,o)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=o;continue}r=Mr(e,r,t),n.push(r)}return{createdNodeIds:n,directoryId:r}}function Mr(e,t,n){let r=W(e,t),i=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:Lt(Rt(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,z()),Fr(e,t,i),e.collapseNewDirectoriesByDefault&&(e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0),e.activeNodeCount++,i}function Nr(e,t,n){let r=pn(e.snapshot.segmentTable,n),i=U(e,t);if(Ct(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${ei(e,t,n)}"`);let a=W(e,t),o=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:Lt(Rt(a)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),Fr(e,t,o),e.activeNodeCount++,o}function Pr(e,t,n){let r=0,i=t.childIds.length;for(;r<i;){let a=r+i>>>1,o=t.childIds[a];if(o==null){i=a;continue}Lr(e,n,o)<0?i=a:r=a+1}return r}function Fr(e,t,n){let r=U(e,t),i=W(e,n);Ct(e.snapshot.nodes,r).set(i.nameId,n),Ot(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let a=Pr(e,r,n);r.childIds.splice(a,0,n),Et(r,a),jt(e.snapshot.nodes,r)}function Ir(e,t,n,r){let i=U(e,t),a=wt(i),o=a.get(n)??-1;Ct(e.snapshot.nodes,i).delete(r),a.delete(n);let s=e.snapshot.nodes[n];s!=null&&Ot(i,n,-s.subtreeNodeCount,-s.visibleSubtreeCount),o>=0&&(i.childIds.splice(o,1),Et(i,o),jt(e.snapshot.nodes,i))}function Lr(e,t,n){let r=e.snapshot.options.sort;return r==="default"?Rr(e,t,n):r(zr(e,t),zr(e,n))}function Rr(e,t,n){let r=W(e,t),i=W(e,n),a=B(r);if(a!==B(i))return a?-1:1;let o=Qt(on(e.snapshot.segmentTable,r.nameId),on(e.snapshot.segmentTable,i.nameId));if(o!==0)return o;let s=mn(e.snapshot.segmentTable,r.nameId),c=mn(e.snapshot.segmentTable,i.nameId);return s===c?t<n?-1:1:s<c?-1:1}function zr(e,t){let n=W(e,t),r=H(e,t),i=B(n),a=i?r.slice(0,-1):r;return{basename:mn(e.snapshot.segmentTable,n.nameId),depth:Rt(n),isDirectory:i,path:r,segments:a.length===0?[]:a.split(`/`)}}function Br(e,t,n){let r=W(e,t),i=Or(e,n);if(i!=null){let t=W(e,i);if(B(t))return{basename:mn(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let a=un(n).segments;return{basename:a[a.length-1]??``,existingNodeId:i,parentId:t.parentId}}let a=un(n),o=a.segments[a.segments.length-1]??``,s=a.segments.slice(0,-1),c=s.length===0?e.snapshot.rootId:kr(e,s,!0);if(c==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:o,existingNodeId:null,parentId:c}}function Vr(e,t,n,r){if(n===`skip`)return`skip`;if(n===`error`)throw Error(`Destination already exists: "${H(e,t)}"`);let i=W(e,t);if(zt(i)!==r)throw Error(`replace collision requires the same source and destination kinds`);if(B(i)&&U(e,t).childIds.length>0)throw Error(`replace collision does not support non-empty directories`);let a=i.parentId,o=i.nameId;return Hr(e,t),Ir(e,a,t,o),Ur(e,a),Tr(e,a),`handled`}function Hr(e,t){let n=[],r=[{nodeId:t,visitedChildren:!1}];for(;r.length>0;){let t=r.pop();if(t==null)break;let i=W(e,t.nodeId);if(t.visitedChildren||!B(i)){B(i)&&e.snapshot.directories.delete(t.nodeId),Ht(i,4),e.pathCacheByNodeId.delete(t.nodeId),e.collapsedDirectoryIds.delete(t.nodeId)&&(e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0),e.expandedDirectoryIds.delete(t.nodeId),Gn(e,t.nodeId),e.activeNodeCount--,n.push(t.nodeId);continue}r.push({nodeId:t.nodeId,visitedChildren:!0});let a=U(e,t.nodeId);for(let e=a.childIds.length-1;e>=0;e--){let t=a.childIds[e];t!=null&&r.push({nodeId:t,visitedChildren:!1})}}return n}function Ur(e,t){let n=t;for(;n!=null;){let t=W(e,n);if(!B(t)||Vt(t,2)||U(e,n).childIds.length>0)return;Ht(t,1),n=t.parentId===n?null:t.parentId}}function Wr(e,t){let n=e.snapshot.rootId;for(let r of t){let t=e.snapshot.segmentTable.idByValue.get(r);if(t==null)break;let i=Ct(e.snapshot.nodes,U(e,n)).get(t);if(i==null||!B(W(e,i)))break;n=i}return n}function Gr(e,t){let n=Jr(e,t);if(n==null)return null;let r=_r(e,n),i=W(e,r),a=n===r?null:vr(e,n).map(t=>H(e,t));return JSON.stringify({flattenedSegmentPaths:a,hasChildren:U(e,r).childIds.length>0,path:H(e,r),terminalKind:zt(i)})}function Kr(e,t){return qr([e],[t])}function qr(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(r==null||i==null||r!==i)return!0}return!1}function Jr(e,t){let n=t;for(;n!=null;){let t=W(e,n);if(!B(t)||Vt(t,2))return null;if(!In(e,n,t))return n;n=t.parentId}return null}function Yr(e,t){let n=W(e,t);if(Ut(n,(t===e.snapshot.rootId?-1:Rt(W(e,n.parentId)))+1),!B(n))return;let r=U(e,t);for(let t of r.childIds)Yr(e,t)}function Xr(e,t,n){let r=n;for(;r!=null;){if(r===t)return!0;let n=W(e,r);if(r===e.snapshot.rootId)return!1;r=n.parentId}return!1}function Zr(e,t,n=W(e,t),r=!1){let i=e.instrumentation;if(i==null){$r(e,t,n,r);return}V(i,`store.recomputeNodeCounts`,()=>$r(e,t,n,r))}function Qr(e,t){let n=t;for(;n!=null;){let t=W(e,n),r=t.subtreeNodeCount,i=t.visibleSubtreeCount;if(Zr(e,n,t),n===e.snapshot.rootId)return;let a=t.subtreeNodeCount-r,o=t.visibleSubtreeCount-i,s=t.parentId;(a!==0||o!==0)&&Ot(U(e,s),n,a,o),n=s}}function $r(e,t,n,r){if(!B(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=U(e,t);if(r){let t=e.instrumentation;t==null?Dt(e.snapshot.nodes,i):V(t,`store.recomputeNodeCounts.rebuildChildAggregates`,()=>Dt(e.snapshot.nodes,i))}let a=1+i.totalChildSubtreeNodeCount,o=i.totalChildVisibleSubtreeCount;if(n.subtreeNodeCount=a,Vt(n,2)){n.visibleSubtreeCount=o;return}n.visibleSubtreeCount=gr(e,t)==null?In(e,t,n)?1+o:1:o}function ei(e,t,n){let r=H(e,t);return r.length===0?n:`${r}${n}`}function ti(e){return e!=null&&!Vt(e,4)}function ni(e,t){let n=e.snapshot.nodes[t];return!ti(n)||!B(n)||Vt(n,2)?null:n}function ri(e){let t=0;for(let[n,r]of e.pathCacheByNodeId)r.version===e.pathCacheVersion&&ti(e.snapshot.nodes[n])&&(t+=1);return t}function ii(e){return Math.max(0,e.valueById.length-1)}function ai(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:ri(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:ii(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function oi(e,t,n,r){return{activeNodeCountAfter:r.activeNodeCount,activeNodeCountBefore:n.activeNodeCount,cachedPathEntryCountAfter:r.cachedPathEntryCount,cachedPathEntryCountBefore:n.cachedPathEntryCount,idsPreserved:t,loadInfoEntryCountAfter:r.loadInfoEntryCount,loadInfoEntryCountBefore:n.loadInfoEntryCount,mode:e,reclaimedCachedPathEntryCount:n.cachedPathEntryCount-r.cachedPathEntryCount,reclaimedLoadInfoEntryCount:n.loadInfoEntryCount-r.loadInfoEntryCount,reclaimedNodeSlotCount:n.totalNodeSlotCount-r.totalNodeSlotCount,reclaimedSegmentCount:n.segmentCount-r.segmentCount,segmentCountAfter:r.segmentCount,segmentCountBefore:n.segmentCount,totalNodeSlotCountAfter:r.totalNodeSlotCount,totalNodeSlotCountBefore:n.totalNodeSlotCount}}function si(e){let t=[],n=[];for(let n of e.collapsedDirectoryIds)ni(e,n)!=null&&t.push(H(e,n));for(let t of e.expandedDirectoryIds)ni(e,t)!=null&&n.push(H(e,t));return{collapsedPaths:t,expandedPaths:n}}function ci(e){let t=[];for(let[n,r]of e.directoryLoadInfoById)ni(e,n)==null||zn(e,n)===`loaded`||t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:H(e,n)});return t}function li(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let t=Or(e,n);t!=null&&Ln(e,t,!0,W(e,t))}for(let n of t.collapsedPaths){let t=Or(e,n);t!=null&&Ln(e,t,!1,W(e,t))}}function ui(e,t){e.directoryLoadInfoById.clear();for(let n of t){let t=Or(e,n.path);t!=null&&ni(e,t)!=null&&e.directoryLoadInfoById.set(t,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function di(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:``,version:e.pathCacheVersion})}function fi(e){let t=e.snapshot.segmentTable,n=fn();for(let r of e.snapshot.nodes)if(ti(r)){if(Vt(r,2)){r.nameId=0;continue}r.nameId=pn(n,mn(t,r.nameId))}e.snapshot.segmentTable=n}function pi(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!ti(r)||!B(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter(n=>{let r=e.snapshot.nodes[n];return ti(r)&&r.parentId===t});n.childIds=i,n.childIdByNameId=new Map(i.map(t=>[W(e,t).nameId,t])),n.childPositionById=new Map(i.map((e,t)=>[e,t])),Dt(e.snapshot.nodes,n)}}function mi(e){let t=e.snapshot.nodes.length-1;for(;t>e.snapshot.rootId;){let n=e.snapshot.nodes[t];if(ti(n))break;--t}e.snapshot.nodes.length=t+1}function hi(e){let t=si(e),n=ci(e);V(e.instrumentation,`store.cleanup.stable.clearPathCaches`,()=>di(e)),V(e.instrumentation,`store.cleanup.stable.rebuildSegmentTable`,()=>fi(e)),V(e.instrumentation,`store.cleanup.stable.rebuildDirectoryIndexes`,()=>pi(e)),V(e.instrumentation,`store.cleanup.stable.trimTrailingRemovedNodeSlots`,()=>mi(e)),V(e.instrumentation,`store.cleanup.stable.restoreExpansionOverrides`,()=>li(e,t)),V(e.instrumentation,`store.cleanup.stable.restoreDirectoryLoadInfos`,()=>ui(e,n)),V(e.instrumentation,`store.cleanup.stable.recomputeCounts`,()=>Er(e,e.snapshot.rootId))}function gi(e){let t=si(e),n=ci(e),r=V(e.instrumentation,`store.cleanup.aggressive.listPaths`,()=>yr(e)),i=Gt({...e.snapshot.options},e.instrumentation),a=V(e.instrumentation,`store.cleanup.aggressive.rebuildSnapshot`,()=>{let e=new jn(i);return e.appendPaths(r),e.finish()});e.snapshot=a,e.activeNodeCount=a.nodes.length-1,e.pathCacheByNodeId=new Map([[a.rootId,{path:``,version:0}]]),e.pathCacheVersion=0,V(e.instrumentation,`store.cleanup.aggressive.restoreExpansionOverrides`,()=>li(e,t)),V(e.instrumentation,`store.cleanup.aggressive.restoreDirectoryLoadInfos`,()=>ui(e,n)),V(e.instrumentation,`store.cleanup.aggressive.recomputeCounts`,()=>Er(e,e.snapshot.rootId))}function _i(e){for(let t of e.directoryLoadInfoById.values())if(t.state===`loading`&&t.activeAttemptId!=null)return!0;return!1}function vi(e,t){let n=ai(e);t===`stable`?V(e.instrumentation,`store.cleanup.stable`,()=>hi(e)):V(e.instrumentation,`store.cleanup.aggressive`,()=>gi(e));let r=ai(e);return oi(t,t===`stable`,n,r)}var yi=64;function bi(e,t){let n=t+2;if(n<=e.length)return e;let r=e.length;for(;r<n;)r*=2;let i=new Int32Array(r);return i.fill(-1),i.set(e),i}function xi(e){return W(e,e.snapshot.rootId).visibleSubtreeCount}function Si(e,t,n,r){let i=W(e,t.terminalNodeId),a=Math.max(1,i.visibleSubtreeCount);return Math.min(r-1,n+a-1)}function Ci(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:Hi(e,t.cursor),setSize:t.setSize,subtreeEndIndex:Si(e,t.cursor,t.index,n)}}function wi(e,t,n,r,i,a){let o=U(e,t),{childIndex:s,childVisibleIndex:c,localVisibleIndex:l}=kt(e.snapshot.nodes,o,n),u=o.childIds[s];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return Ti(e,u,l,r+c,i+1,s,o.childIds.length,a)}function Ti(e,t,n,r,i,a,o,s){if(!B(W(e,t))){if(n===0)return{ancestors:s,cursor:{headNodeId:t,terminalNodeId:t,visibleDepth:i},index:r,posInSet:a,setSize:o};throw Error(`Visible index ${String(n)} is out of range for file`)}let c=Ii(e,t,i);if(n===0)return{ancestors:s,cursor:c,index:r,posInSet:a,setSize:o};let l=W(e,c.terminalNodeId);if(!B(l)||!In(e,c.terminalNodeId,l))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return wi(e,c.terminalNodeId,n-1,r+1,c.visibleDepth,[...s,{cursor:c,index:r,posInSet:a,setSize:o}])}function Ei(e,t){let n=xi(e);if(t<0||t>=n)return null;let r=wi(e,e.snapshot.rootId,t,0,-1,[]),i=r.ancestors.map(t=>H(e,t.cursor.terminalNodeId)),a=null;return{ancestorPaths:i,get ancestorRows(){if(a!=null)return a;let t=[],i=[];for(let a of r.ancestors){let r=Ci(e,a,n,[...i]);t.push(r),i.push(r.row.path)}return a=t,a},index:r.index,posInSet:r.posInSet,row:Hi(e,r.cursor),setSize:r.setSize,subtreeEndIndex:Si(e,r.cursor,r.index,n)}}function Di(e,t,n){let r=e.instrumentation,i=xi(e);if(i<=0||n<t)return[];let a=Math.max(0,Math.min(t,i-1)),o=Math.max(a,Math.min(n,i-1));if(r==null){if(a===0)return Vi(e,o+1);let t=[],n=Ni(e,a);for(let r=a;r<=o&&n!=null;r++){let r=Hi(e,n);t.push(r),n=Ri(e,n)}return t}let s=[],c=0,l=0,u=V(r,`store.getVisibleSlice.selectFirstRow`,()=>Ni(e,a));for(let t=a;t<=o&&u!=null;t++){let t=V(r,`store.getVisibleSlice.materializeRow`,()=>Hi(e,u));s.push(t),t.isFlattened&&(c++,l+=t.flattenedSegments?.length??0),u=V(r,`store.getVisibleSlice.advanceCursor`,()=>Ri(e,u))}return qt(r,`workload.visibleRowsRead`,s.length),qt(r,`workload.flattenedRowsRead`,c),qt(r,`workload.flattenedSegmentsRead`,l),s}function Oi(e,t=xi(e)){let n=e.instrumentation;return n==null?Bi(e,t):V(n,`store.getVisibleTreeProjection`,()=>Bi(e,t))}function ki(e){return zi(Oi(e))}function Ai(e,t){let n=Or(e,t);if(n==null||n===e.snapshot.rootId||B(W(e,n))&&_r(e,n)!==n)return null;let r=0,i=n,{nodes:a,rootId:o}=e.snapshot;for(;i!==o;){let t=W(e,i).parentId,n=U(e,t),s=wt(n).get(i);if(s==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=At(a,n,s),t!==o){let n=W(e,t),a=gr(e,t);if(!In(e,t,n)&&a!==i)return null;_r(e,t)===t&&(r+=1)}i=t}return r}function ji(e,t){let n=Or(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=W(e,n);if(!B(r))throw Error(`Path is not a directory: "${t}"`);return In(e,n,r)?null:(Ln(e,n,!0,r),Tr(e,n),Xn({affectedAncestorIds:Dr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0}))}function Mi(e,t){let n=Or(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=W(e,n);if(!B(r))throw Error(`Path is not a directory: "${t}"`);return In(e,n,r)?(Ln(e,n,!1,r),Tr(e,n),Zn({affectedAncestorIds:Dr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})):null}function Ni(e,t){return t<0||t>=xi(e)?null:Pi(e,e.snapshot.rootId,t,-1)}function Pi(e,t,n,r){let i=U(e,t),a=e.instrumentation,{childIndex:o,localVisibleIndex:s}=a==null?kt(e.snapshot.nodes,i,n):V(a,`store.getVisibleSlice.selectChildIndex`,()=>kt(e.snapshot.nodes,i,n)),c=i.childIds[o];if(c!=null)return Fi(e,c,s,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function Fi(e,t,n,r){if(!B(W(e,t))){if(n===0)return{headNodeId:t,terminalNodeId:t,visibleDepth:r};throw Error(`Visible index ${String(n)} is out of range for file`)}let i=Ii(e,t,r);if(n===0)return i;let a=W(e,i.terminalNodeId);if(!B(a)||!In(e,i.terminalNodeId,a))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Pi(e,i.terminalNodeId,n-1,i.visibleDepth)}function Ii(e,t,n){return B(W(e,t))?e.instrumentation==null?{headNodeId:t,terminalNodeId:_r(e,t),visibleDepth:n}:{headNodeId:t,terminalNodeId:V(e.instrumentation,`store.getVisibleSlice.flatten.resolveTerminalDirectory`,()=>_r(e,t)),visibleDepth:n}:{headNodeId:t,terminalNodeId:t,visibleDepth:n}}function Li(e,t){let n=W(e,t);if(!B(n))return!0;let r=n.parentId;return r===e.snapshot.rootId?!0:gr(e,r)!==t}function Ri(e,t){let n=W(e,t.terminalNodeId);if(B(n)){let r=U(e,t.terminalNodeId);if(In(e,t.terminalNodeId,n)&&r.childIds.length>0){let n=r.childIds[0];return n==null?null:Fi(e,n,0,t.visibleDepth+1)}}let r=t.terminalNodeId,i=t.visibleDepth;for(;;){let t=W(e,r);if(r===e.snapshot.rootId)return null;let n=t.parentId,a=U(e,n),o=wt(a).get(r)??-1;if(o<0)throw Error(`Child ${String(r)} was not found in its parent index`);let s=a.childIds[o+1]??null;if(s!=null)return Fi(e,s,0,i);Li(e,r)&&i--,r=n}}function zi(e){let t=e.paths.length,n=Array(t);for(let r=0;r<t;r+=1){let t=e.getParentIndex(r);n[r]={index:r,parentPath:t>=0?e.paths[t]??null:null,path:e.paths[r]??``,posInSet:e.posInSetByIndex[r]??0,setSize:e.setSizeByIndex[r]??0}}return{getParentIndex:e.getParentIndex,rows:n,get visibleIndexByPath(){return e.visibleIndexByPath}}}function Bi(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),a=new Int32Array(t),o=new Int32Array(yi);o.fill(-1);let s=0,{nodes:c,directories:l,segmentTable:u}=e.snapshot,d=[[l.get(e.snapshot.rootId),0,-1,``]],f=e.snapshot.options.flattenEmptyDirectories,p=e.pathCacheByNodeId,m=e.pathCacheVersion,h=u.valueById;for(;d.length>0&&s<t;){let t=d[d.length-1],u=t[0];if(t[1]>=u.childIds.length){d.pop();continue}let g=t[1],_=u.childIds[t[1]++],v=c[_],y=t[2]+1,b=t[3];o=bi(o,y);let x,S=_;if(B(v))S=f?_r(e,_):_,x=S===_?`${b}${h[v.nameId]}/`:H(e,S);else{let e=p.get(_);x=e!=null&&e.version===m?e.path:`${b}${h[v.nameId]}`}r[s]=o[y],n[s]=x,i[s]=g,a[s]=u.childIds.length,o[y+1]=s,s+=1;let C=c[S];C!=null&&B(C)&&In(e,S,C)&&d.push([l.get(S),0,y,x])}s<t&&(n.length=s);let g=r.subarray(0,s),_=i.subarray(0,s),v=a.subarray(0,s),y=null;return{getParentIndex(e){return e<0||e>=s?-1:g[e]??-1},paths:n,posInSetByIndex:_,setSizeByIndex:v,get visibleIndexByPath(){if(y==null){y=new Map;for(let e=0;e<s;e+=1)y.set(n[e]??``,e)}return y}}}function Vi(e,t){let n=Array(t),r=0,{nodes:i,directories:a,segmentTable:o}=e.snapshot,s=[[a.get(e.snapshot.rootId),0,-1]],c=o.valueById,l=e.snapshot.options.flattenEmptyDirectories,u=e.pathCacheByNodeId,d=e.pathCacheVersion;for(;s.length>0&&r<t;){let t=s[s.length-1],o=t[0];if(t[1]>=o.childIds.length){s.pop();continue}let f=o.childIds[t[1]++],p=i[f],m=t[2]+1;if(!B(p)){let t=u.get(f);n[r++]={depth:m,flattenedSegments:void 0,hasChildren:!1,id:f,isExpanded:!1,isFlattened:!1,isLoading:!1,kind:`file`,loadState:void 0,name:c[p.nameId],path:t!=null&&t.version===d?t.path:H(e,f)};continue}let h=l?_r(e,f):f,g={headNodeId:f,terminalNodeId:h,visibleDepth:m};n[r++]=Hi(e,g);let _=i[h];_!=null&&B(_)&&In(e,h,_)&&s.push([a.get(h),0,m])}return r<t&&(n.length=r),n}function Hi(e,t){let n=W(e,t.terminalNodeId),r=B(n)?Ui(e,t):null,i=H(e,t.terminalNodeId),a=mn(e.snapshot.segmentTable,n.nameId),o=B(n)&&U(e,t.terminalNodeId).childIds.length>0,s=t.headNodeId!==t.terminalNodeId,c=e.instrumentation,l=s?c==null?vr(e,t.headNodeId).map(n=>{let r=W(e,n);return{isTerminal:n===t.terminalNodeId,name:mn(e.snapshot.segmentTable,r.nameId),nodeId:n,path:H(e,n)}}):V(c,`store.getVisibleSlice.flatten.collectSegments`,()=>vr(e,t.headNodeId).map(n=>{let r=W(e,n);return{isTerminal:n===t.terminalNodeId,name:mn(e.snapshot.segmentTable,r.nameId),nodeId:n,path:H(e,n)}})):void 0;return{depth:t.visibleDepth,flattenedSegments:l,hasChildren:o,id:t.terminalNodeId,isExpanded:B(n)&&In(e,t.terminalNodeId,n),isFlattened:s,isLoading:r===`loading`,kind:B(n)?`directory`:`file`,loadState:r==null||r===`loaded`?void 0:r,name:a,path:i}}function Ui(e,t){if(t.headNodeId===t.terminalNodeId)return zn(e,t.terminalNodeId);let n=vr(e,t.headNodeId),r=!1,i=!1;for(let t of n){let n=zn(e,t);if(n===`loading`)return`loading`;if(n===`error`){i=!0;continue}n===`unloaded`&&(r=!0)}return i?`error`:r?`unloaded`:`loaded`}function Wi(e){let{directories:t,nodes:n,options:r,rootId:i,presortedDirectoryNodeIds:a}=e.snapshot,o=r.flattenEmptyDirectories===!0,s=e=>{let r=n[e];if(r==null||!B(r))return;let i=t.get(e);if(i==null)throw Error(`Unknown directory child index for node ${String(e)}`);let a=i.childIds,s=a.length,c=0,l=0;for(let e=0;e<s;e++){let t=a[e];if(t==null)continue;let r=n[t];c+=r.subtreeNodeCount,l+=r.visibleSubtreeCount}i.totalChildSubtreeNodeCount=c,i.totalChildVisibleSubtreeCount=l,s>=128&&jt(n,i),r.subtreeNodeCount=1+c;let u;if(o&&s===1){let e=n[a[0]];u=e!=null&&B(e)?l:1+l}else u=1+l;r.visibleSubtreeCount=u};if(a!=null)for(let e=a.length-1;e>=0;e--)s(a[e]);else for(let e=n.length-1;e>=1;e--)s(e);let c=n[i],l=t.get(i);if(c==null||l==null)return;let u=l.childIds,d=0,f=0;for(let e=0;e<u.length;e++){let t=u[e];if(t==null)continue;let r=n[t];d+=r.subtreeNodeCount,f+=r.visibleSubtreeCount}l.totalChildSubtreeNodeCount=d,l.totalChildVisibleSubtreeCount=f,jt(n,l),c.subtreeNodeCount=1+d,c.visibleSubtreeCount=f}function Gi(e){return e.initialExpansion===`open`&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var Ki=class e{#e;constructor(e={}){let t=Kt(e),n=V(t,`store.builder.create`,()=>new jn(e));if(e.preparedInput!=null){let t=On(e.preparedInput);t==null?n.appendPreparedPaths(Dn(e.preparedInput),!1):n.appendPresortedPaths(t,kn(e.preparedInput))}else{let r=e.paths??[];e.presorted===!0?n.appendPaths(r):n.appendPreparedPaths(V(t,`store.preparePathEntries`,()=>An(r,e)))}let r=V(t,`store.builder.finish`,()=>n.finish({skipSubtreeCountPass:!0})),i=V(t,`store.state.detectAllDirectoriesExpanded`,()=>(e.initialExpansion??`closed`)===`closed`&&n.didMatchAllInitialExpandedPaths());this.#e=V(t,`store.state.create`,()=>Mn(r,i?`open`:e.initialExpansion??`closed`,t)),i&&(this.#e.collapseNewDirectoriesByDefault=!0);let a=i?this.#e.snapshot.directories.size-1:V(t,`store.state.initializeExpandedPaths`,()=>this.initializeExpandedPaths(e.initialExpandedPaths));i||Gi(e)||(e.initialExpansion??`closed`)===`closed`&&a===this.#e.snapshot.directories.size-1||(e.initialExpandedPaths?.length??0)>0&&V(t,`store.state.checkAllDirectoriesExpanded`,()=>this.hasAllDirectoriesExpanded())?V(t,`store.state.initializeOpenVisibleCounts`,()=>Wi(this.#e)):V(t,`store.state.recomputeCounts`,()=>Er(this.#e,this.#e.snapshot.rootId))}static preparePaths(e,t={}){return wn(e,t)}static prepareInput(e,t={}){return Tn(e,t)}static preparePresortedInput(e){return En(e)}list(e){return V(this.#e.instrumentation,`store.list`,()=>yr(this.#e,e))}add(e){V(this.#e.instrumentation,`store.add`,()=>{let t=xi(this.#e);or(this.#e,ir(this.#e,t,br(this.#e,e)))})}remove(e,t={}){V(this.#e.instrumentation,`store.remove`,()=>{let n=xi(this.#e);or(this.#e,ir(this.#e,n,xr(this.#e,e,t)))})}move(e,t,n={}){V(this.#e.instrumentation,`store.move`,()=>{let r=xi(this.#e),i=Sr(this.#e,e,t,n);i!=null&&or(this.#e,ir(this.#e,r,i))})}batch(e){ar(this.#e,()=>{if(typeof e==`function`){e(this);return}for(let t of e)switch(t.type){case`add`:this.add(t.path);break;case`remove`:this.remove(t.path,{recursive:t.recursive});break;case`move`:this.move(t.from,t.to,{collision:t.collision});break}})}getVisibleCount(){return V(this.#e.instrumentation,`store.getVisibleCount`,()=>xi(this.#e))}getVisibleSlice(e,t){return V(this.#e.instrumentation,`store.getVisibleSlice`,()=>Di(this.#e,e,t))}getVisibleRowContext(e){return V(this.#e.instrumentation,`store.getVisibleRowContext`,()=>Ei(this.#e,e))}getVisibleTreeProjection(){return ki(this.#e)}getVisibleTreeProjectionData(e){return Oi(this.#e,e)}getVisibleIndex(e){return V(this.#e.instrumentation,`store.getVisibleIndex`,()=>Ai(this.#e,e))}getPathInfo(e){return V(this.#e.instrumentation,`store.getPathInfo`,()=>{let t=Or(this.#e,e);if(t==null)return null;let n=W(this.#e,t);return{depth:Rt(n),kind:B(n)?`directory`:`file`,path:H(this.#e,t)}})}isExpanded(e){return V(this.#e.instrumentation,`store.isExpanded`,()=>{let t=this.requireDirectoryNodeId(e),n=W(this.#e,t);return In(this.#e,t,n)})}expand(e){V(this.#e.instrumentation,`store.expand`,()=>{let t=xi(this.#e),n=ji(this.#e,e);n!=null&&or(this.#e,ir(this.#e,t,n))})}collapse(e){V(this.#e.instrumentation,`store.collapse`,()=>{let t=xi(this.#e),n=Mi(this.#e,e);n!=null&&or(this.#e,ir(this.#e,t,n))})}on(e,t){return Kn(this.#e,e,t)}getDirectoryLoadState(e){let t=this.requireDirectoryNodeId(e);return zn(this.#e,t)}markDirectoryUnloaded(e){V(this.#e.instrumentation,`store.markDirectoryUnloaded`,()=>{let t=this.requireDirectoryNodeId(e);if(U(this.#e,t).childIds.length>0)throw Error(`Cannot mark a directory with known children as unloaded: "${e}"`);let n=xi(this.#e);Vn(this.#e,t),or(this.#e,ir(this.#e,n,Qn({affectedAncestorIds:Dr(this.#e,t),affectedNodeIds:[t],path:e,projectionChanged:this.isDirectoryProjectionVisible(t)})))})}beginChildLoad(e){return V(this.#e.instrumentation,`store.beginChildLoad`,()=>{let t=this.requireDirectoryNodeId(e),n=xi(this.#e),r=Bn(this.#e,t);return or(this.#e,ir(this.#e,n,$n({affectedAncestorIds:Dr(this.#e,t),affectedNodeIds:[t],attemptId:r.attemptId,path:e,projectionChanged:this.isDirectoryProjectionVisible(t),reused:r.reused}))),r})}applyChildPatch(e,t){return V(this.#e.instrumentation,`store.applyChildPatch`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null||zn(this.#e,n)!==`loading`||!Un(this.#e,n,e.attemptId))return!1;let r=H(this.#e,n);this.validateChildPatch(r,t);let i=xi(this.#e),a=[];for(let e of t.operations){qi(r,e);let t=xi(this.#e);switch(e.type){case`add`:a.push(ir(this.#e,t,br(this.#e,e.path)));break;case`remove`:a.push(ir(this.#e,t,xr(this.#e,e.path,{recursive:e.recursive})));break;case`move`:{let n=Sr(this.#e,e.from,e.to,{collision:e.collision});n!=null&&a.push(ir(this.#e,t,n));break}}}let o=a.some(e=>e.projectionChanged)||this.isDirectoryProjectionVisible(n);return or(this.#e,ir(this.#e,i,er({affectedAncestorIds:Dr(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,childEvents:a,path:H(this.#e,n),projectionChanged:o}))),!0})}completeChildLoad(e){return V(this.#e.instrumentation,`store.completeChildLoad`,()=>{let t=this.resolveActiveDirectoryNodeId(e.nodeId);if(t==null)return!1;let n=xi(this.#e),r=Hn(this.#e,t,e.attemptId);return or(this.#e,ir(this.#e,n,tr({affectedAncestorIds:Dr(this.#e,t),affectedNodeIds:[t],attemptId:e.attemptId,path:H(this.#e,t),projectionChanged:this.isDirectoryProjectionVisible(t),stale:!r}))),r})}failChildLoad(e,t){return V(this.#e.instrumentation,`store.failChildLoad`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null)return!1;let r=xi(this.#e),i=Wn(this.#e,n,e.attemptId,t);return or(this.#e,ir(this.#e,r,nr({affectedAncestorIds:Dr(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,errorMessage:t,path:H(this.#e,n),projectionChanged:this.isDirectoryProjectionVisible(n),stale:!i}))),i})}cleanup(e={}){return V(this.#e.instrumentation,`store.cleanup`,()=>{if(this.#e.transactionStack.length>0)throw Error(`Cleanup cannot run during an open batch or transaction.`);if(_i(this.#e))throw Error(`Cleanup cannot run while directory loads are active.`);let t=xi(this.#e),n=vi(this.#e,e.mode??`stable`);return or(this.#e,ir(this.#e,t,rr({...n,affectedAncestorIds:[],affectedNodeIds:[],projectionChanged:n.idsPreserved===!1}))),n})}getNodeCount(){return this.#e.activeNodeCount}initializeExpandedPaths(e){if(e==null||e.length===0)return 0;let t=0,n=[],r=[],i=0,a=null,o=this.#e.snapshot.segmentTable,s=o.valueById,c=this.#e.snapshot.nodes,l=new Map;for(let u of e){a!=null&&u<a&&(a=null,i=0,n.length=0,r.length=0);let e=u.length>0&&u.charCodeAt(u.length-1)===47?u.length-1:u.length;if(e===0){a=u,i=e,n.length=0,r.length=0;continue}let d=0,f=0;if(a!=null){let t=Math.min(e,i),n=!0;for(let e=0;e<t;e+=1){let t=u.charCodeAt(e);if(t!==a.charCodeAt(e)){n=!1;break}t===47&&(d+=1,f=e+1)}n&&(t===i&&e>t&&u.charCodeAt(t)===47?(d+=1,f=t+1):t===e&&i>t&&a.charCodeAt(t)===47&&(d+=1,f=e+1)),d=Math.min(d,r.length)}let p=d===0?this.#e.snapshot.rootId:r[d-1]??this.#e.snapshot.rootId,m=d,h=!0,g=f;for(;g<=e;){let t=u.indexOf(`/`,g),i=t===-1||t>e?e:t,a=u.slice(g,i),f=U(this.#e,p).childIds,_=m===d?n[m]??0:0,v=_,y,b=l.get(a)??Xt(a);l.set(a,b);let x=(e,t)=>{for(v=e;v<t;v+=1){let e=f[v],t=c[e],n=s[t.nameId];if(n===a)return y=e,!0;let r=Qt(on(o,t.nameId),b);if(r>0||r===0&&n>a)return!1}return!1};if(!x(_,f.length)&&_>0&&x(0,_),y===void 0){h=!1;break}if(!B(W(this.#e,y))){h=!1;break}if(n[m]=v,r[m]=y,p=y,m+=1,i===e)break;g=i+1}if(a=u,i=e,n.length=m,r.length=m,!h){a=null,i=0,n.length=0,r.length=0;continue}for(let e=d;e<m;e+=1){let n=r[e];if(n==null)continue;let i=W(this.#e,n);In(this.#e,n,i)||(Ln(this.#e,n,!0,i),t+=1)}}return t}hasAllDirectoriesExpanded(){for(let e of this.#e.snapshot.directories.keys()){if(e===this.#e.snapshot.rootId)continue;let t=W(this.#e,e);if(!In(this.#e,e,t))return!1}return!0}requireDirectoryNodeId(e){let t=Or(this.#e,e);if(t==null)throw Error(`Path does not exist: "${e}"`);if(!B(W(this.#e,t)))throw Error(`Path is not a directory: "${e}"`);return t}resolveActiveDirectoryNodeId(e){try{if(!B(W(this.#e,e)))throw Error(`Node is not a directory: ${String(e)}`);return e}catch{return null}}isDirectoryProjectionVisible(e){let t=e;for(;t!==this.#e.snapshot.rootId;){let e=W(this.#e,t).parentId;if(e!==this.#e.snapshot.rootId){let n=W(this.#e,e),r=gr(this.#e,e);if(!In(this.#e,e,n)&&r!==t)return!1}t=e}return!0}validateChildPatch(t,n){new e({paths:this.list(t),presorted:!0,sort:this.#e.snapshot.options.sort}).batch(n.operations)}};function qi(e,t){switch(t.type){case`add`:case`remove`:if(!t.path.startsWith(e)||t.path===e)throw Error(`Child patch operation must stay within ${e}: "${t.path}"`);break;case`move`:if(!t.from.startsWith(e)||!t.to.startsWith(e)||t.from===e||t.to===e)throw Error(`Child patch move must stay within ${e}: "${t.from}" -> "${t.to}"`);break}}var Ji={compact:{itemHeight:24,factor:.8},default:{itemHeight:30,factor:1},relaxed:{itemHeight:36,factor:1.2}};function Yi(e,t){if(typeof e==`number`)return{itemHeight:t??Ji.default.itemHeight,factor:e};let n=Ji[e??`default`];return{itemHeight:t??n.itemHeight,factor:n.factor}}var Xi=Ji.default.itemHeight,Zi=`@layer base, theme, unsafe;
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,Dr as a,El as o,G as s,Ot as c,Pa as l,Qc as u,Wc as d,Yc as f,_a as p,_f as m,al as h,dt as g,ft as _,gt as v,h as y,ht as b,il as x,jl as S,mt as C,n as w,o as T,st as E,vt as D,wt as O,x as ee,xr as k,xt as te,yt as A}from"./previewAssetResource-JdwqlhCI.js";import{n as j,r as M,t as N}from"./renderFileChildren-BvCC5Y3x.js";import{$ as ne,Ar as re,Bn as ie,Cn as ae,Cr as oe,D as se,E as ce,Fn as le,Fr as ue,Gn as de,Gt as fe,Hn as pe,Hr as P,Ht as me,Jr as he,Jt as ge,Kn as F,Kt as _e,Mn as ve,Pr as ye,T as be,Un as xe,Ut as Se,Vn as Ce,Wn as we,Z as Te,Zr as I,_r as Ee,_t as De,an as Oe,b as ke,bn as Ae,br as je,ct as Me,d as Ne,ei as Pe,et as Fe,f as Ie,fn as Le,gt as Re,hr as ze,ii as Be,kr as Ve,l as He,m as Ue,on as We,p as Ge,qn as Ke,ri as qe,ti as Je,tt as Ye,u as Xe,v as Ze,vr as Qe,w as $e,wn as et,x as tt,y as nt,yr as rt,zr as it}from"./index-IA1MLjyL.js";import{a as at,i as ot,n as st,r as L,t as R}from"./fileCommentAnnotations-BAZwrcFy.js";var ct=u(`file-question-mark`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}]]),lt=u(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),ut=`file-tree-container`,dt=`data-file-tree-style`,ft=`data-file-tree-unsafe-css`,pt=`data-file-tree-scrollbar-measure`,mt=`data-file-tree-scrollbar-gutter-measured`,ht=`--trees-scrollbar-gutter-measured`,gt=`header`,_t=`context-menu`,vt=`context-menu-trigger`,yt=5,bt=1<<yt,xt=bt*4;function z(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function St(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function Ct(e,t){if(t.childIdByNameId!=null)return t.childIdByNameId;let n=new Map;for(let r of t.childIds){let t=e[r];t!=null&&n.set(t.nameId,r)}return t.childIdByNameId=n,n}function wt(e){if(e.childPositionById!=null)return e.childPositionById;let t=new Map;for(let n=0;n<e.childIds.length;n++){let r=e.childIds[n];r!=null&&t.set(r,n)}return e.childPositionById=t,t}function Tt(e,t){e.childPositionById!=null&&e.childPositionById.set(t,e.childIds.length),e.childIds.push(t)}function Et(e,t){if(e.childPositionById!=null)for(let n=t;n<e.childIds.length;n++){let t=e.childIds[n];t!=null&&e.childPositionById.set(t,n)}}function Dt(e,t){let n=0,r=0;for(let i of t.childIds){let t=e[i];t!=null&&(n+=t.subtreeNodeCount,r+=t.visibleSubtreeCount)}t.totalChildSubtreeNodeCount=n,t.totalChildVisibleSubtreeCount=r,jt(e,t)}function Ot(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=wt(e).get(t);if(i===void 0)return;let a=i>>yt;e.childVisibleChunkSums[a]+=r}function kt(e,t,n){let r=t.childVisibleChunkSums;if(r!=null){let i=n,a=0;for(let o of r){if(i<o){let r=Mt(e,t,a,i);return{...r,childVisibleIndex:n-r.localVisibleIndex}}i-=o,a+=bt}throw Error(`Visible child index ${String(n)} is out of range`)}let i=n;for(let r=0;r<t.childIds.length;r++){let a=t.childIds[r];if(a==null)continue;let o=e[a];if(o!=null){if(i<o.visibleSubtreeCount)return{childIndex:r,childVisibleIndex:n-i,localVisibleIndex:i};i-=o.visibleSubtreeCount}}throw Error(`Visible child index ${String(n)} is out of range`)}function At(e,t,n){let r=0,i=t.childVisibleChunkSums,a=0;if(i!=null){let e=n>>yt;for(let t=0;t<e;t+=1)r+=i[t]??0;a=e<<yt}for(let i=a;i<n;i+=1){let n=t.childIds[i];if(n==null)continue;let a=e[n];a!=null&&(r+=a.visibleSubtreeCount)}return r}function jt(e,t){if(t.childIds.length<xt){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/bt),r=new Int32Array(n);for(let n=0;n<t.childIds.length;n++){let i=t.childIds[n];if(i==null)continue;let a=e[i];a!=null&&(r[n>>yt]+=a.visibleSubtreeCount)}t.childVisibleChunkSums=r}function Mt(e,t,n,r){let i=Math.min(t.childIds.length,n+bt),a=r;for(let r=n;r<i;r++){let n=t.childIds[r];if(n==null)continue;let i=e[n];if(i!=null){if(a<i.visibleSubtreeCount)return{childIndex:r,localVisibleIndex:a};a-=i.visibleSubtreeCount}}throw Error(`Visible child index ${String(r)} is out of range`)}var Nt=7,Pt=3,Ft=1<<Pt,It=4;function Lt(e,t,n=0){return e<<It|n<<Pt|t}function Rt(e){return e.depthAndFlags>>>It}function zt(e){return(e.depthAndFlags&Ft)>>Pt}function B(e){return(e.depthAndFlags&Ft)!==0}function Bt(e){return e.depthAndFlags&Nt}function Vt(e,t){return(Bt(e)&t)!==0}function Ht(e,t){e.depthAndFlags|=t}function Ut(e,t){e.depthAndFlags=Lt(t,Bt(e),zt(e))}var Wt=Symbol(`benchmarkInstrumentation`);function Gt(e,t){return t==null||Object.defineProperty(e,Wt,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function Kt(e){return e==null?null:e[Wt]??null}function V(e,t,n){return e==null?n():e.measurePhase(t,n)}function qt(e,t,n){!Number.isFinite(n)||e==null||e.setCounter(t,n)}function Jt(e){return e>=48&&e<=57}function Yt(e){let t=[],n=0,r=0;for(;r<e.length;){for(;r<e.length&&!Jt(e.charCodeAt(r));)r+=1;if(r>=e.length)break;r>n&&t.push(e.slice(n,r));let i=0;for(;r<e.length&&Jt(e.charCodeAt(r));)i=i*10+(e.charCodeAt(r)-48),r+=1;t.push(i),n=r}return(n<e.length||t.length===0)&&t.push(e.slice(n)),t}function Xt(e){let t=e.toLowerCase();return{lowerValue:t,tokens:Yt(t)}}function Zt(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let n=e[r],i=t[r];if(n===i)continue;if(typeof n==`number`&&typeof i==`number`)return n<i?-1:1;let a=String(n),o=String(i);if(a!==o)return a<o?-1:1}return e.length===t.length?0:e.length<t.length?-1:1}function Qt(e,t){if(e.tokens.length===1&&t.tokens.length===1&&typeof e.tokens[0]==`string`&&typeof t.tokens[0]==`string`)return e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1;let n=Zt(e.tokens,t.tokens);return n===0?e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1:n}function $t(e,t,n){let r=Qt(n(e),n(t));return r===0?e===t?0:e<t?-1:1:r}function en(e,t){return $t(e,t,Xt)}function tn(e,t){return t===e.segments.length-1?+!!e.isDirectory:1}function nn(e,t){let n=Math.min(e.segments.length,t.segments.length);for(let r=0;r<n;r++){let n=e.segments[r],i=t.segments[r];if(n===i)continue;let a=tn(e,r);return a===tn(t,r)?en(n,i):a===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function rn(e,t){return nn(e,t)}function an(e,t,n){let r=e=>{let t=n.get(e);if(t!=null)return t;let r=Xt(e);return n.set(e,r),r},i=Math.min(e.segments.length,t.segments.length);for(let n=0;n<i;n++){let i=e.segments[n],a=t.segments[n];if(i===a)continue;let o=tn(e,n);return o===tn(t,n)?$t(i,a,r):o===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function on(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=Xt(r);return e.sortKeyById[t]=i,i}function sn(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??`default`}}function cn(e){let t=e.length>0&&e.charCodeAt(e.length-1)===47,n=t?e.length-1:e.length,r=[],i=0;for(let t=0;t<n;t++)e.charCodeAt(t)===47&&(r.push(e.slice(i,t)),i=t+1);return r.push(e.slice(i,n)),{hasTrailingSlash:t,segments:r}}function ln(e){let{hasTrailingSlash:t,segments:n}=cn(e);return{basename:n[n.length-1]??``,isDirectory:t,path:e,segments:n}}function un(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=cn(e);return{requiresDirectory:t,segments:n}}var dn=``;function fn(){let e=new Map;return e.set(dn,0),{idByValue:e,valueById:[dn],sortKeyById:[Xt(dn)]}}function pn(e,t){let n=e.idByValue.get(t);if(n!==void 0)return n;let r=e.valueById.length;return e.idByValue.set(t,r),e.valueById.push(t),r}function mn(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var hn=Symbol(`pathStorePreparedInputKind`);function gn(e,t){return e[hn]=t,e}function _n(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function vn(e,t,n){return n==="default"?rn(e,t):n(_n(e),_n(t))}function yn(){return{depthAndFlags:Lt(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function bn(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return r;return n}function xn(e){return e.isDirectory?e.segments.length:e.segments.length-1}function Sn(e){return Array.isArray(e)&&e.every(e=>typeof e==`object`&&!!e&&typeof e.path==`string`&&Array.isArray(e.segments)&&typeof e.basename==`string`&&typeof e.isDirectory==`boolean`)}function Cn(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function wn(e,t={}){return An(e,t).map(e=>e.path)}function Tn(e,t={}){let n=An(e,t);return gn({paths:n.map(e=>e.path),preparedPaths:n},`prepared`)}function En(e){let t=e.length,n=!1;for(let r=0;r<t;r+=1){let t=e[r];if(t.length>0&&t.charCodeAt(t.length-1)===47){n=!0;break}}return gn({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},`presorted`)}function Dn(e){let t=e,n=t.preparedPaths;if(t[hn]===`prepared`&&n!=null)return n;if(!Sn(n))throw Error(`preparedInput must come from PathStore.prepareInput()`);return n}function On(e){let t=e;return t[hn]===`presorted`&&t.presortedPaths!=null||Cn(t.presortedPaths)?t.presortedPaths:null}function kn(e){let t=e;return typeof t.presortedPathsContainDirectories==`boolean`?t.presortedPathsContainDirectories:null}function An(e,t={}){let n=sn(t),r=Kt(t);qt(r,`workload.inputFiles`,e.length);let i=V(r,`store.preparePathEntries.parse`,()=>e.map(e=>ln(e)));return V(r,`store.preparePathEntries.sort`,()=>i.sort((e,t)=>vn(e,t,n.sort))),i}var jn=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[yn()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=fn();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=Kt(e),this.options=sn(e);let t=e.initialExpandedPaths??null;if(t==null||t.length===0)this.initialExpandedPathSet=null;else{let e=new Set,n=t.length;for(let r=0;r<n;r+=1){let n=t[r],i=n.length;e.add(i>0&&n.charCodeAt(i-1)===47?n.slice(0,i-1):n)}this.initialExpandedPathSet=e,this.createdDirectoriesAllExpanded=!0}this.directories.set(0,z())}appendPaths(e){return V(this.instrumentation,`store.builder.appendPaths.parse`,()=>this.appendPreparedPaths(e.map(e=>ln(e))))}appendPreparedPaths(e,t=!0){return this.createdDirectoriesAllExpanded=!1,V(this.instrumentation,`store.builder.appendPreparedPaths`,()=>{for(let n of e)this.appendPreparedPath(n,t)}),this}appendPresortedPaths(e,t=null){return V(this.instrumentation,`store.builder.appendPresortedPaths`,()=>{if(t===!1){this.appendPresortedFilePaths(e);return}this.createdDirectoriesAllExpanded=!1;let n=null,r=0,i=this.nodes,a=this.segmentTable,o=a.idByValue,s=a.valueById,c=this.directoryStack,l=0,u=``,d=0;for(let t of e){if(n===t)throw Error(`Duplicate path: "${t}"`);let e=t.length>0&&t.charCodeAt(t.length-1)===47,a=e?t.length-1:t.length,f=0,p=0;if(n!=null)if(u.length>0&&t.length>u.length&&t.startsWith(u))f=d,p=u.length;else{let r=Math.min(a,n.length),i=!0;for(let e=0;e<r;e++){let r=t.charCodeAt(e);if(r!==n.charCodeAt(e)){i=!1;break}r===47&&(f++,p=e+1)}i&&e&&r===a&&n.length>a&&n.charCodeAt(a)===47&&(f++,p=a+1)}l=f,r=f;let m=p,h=t.indexOf(`/`,m);for(;h>=0&&h<a;){let e=c[l];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);r++;let n=t.slice(m,h),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n));let u=i.length;i.push({depthAndFlags:Lt(r,0,1),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(t.slice(0,h)),l++,c[l]=u,m=h+1,h=t.indexOf(`/`,m)}if(e){if(m<a){let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory parent for "${t}"`);r++;let n=t.slice(m,a),u=o.get(n);u===void 0&&(u=s.length,o.set(n,u),s.push(n));let d=i.length;i.push({depthAndFlags:Lt(r,0,1),nameId:u,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),l++,c[l]=d}let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory node for "${t}"`);this.promoteDirectoryToExplicit(e,t)}else{let e=c[l];if(e===void 0)throw Error(`Unable to resolve file parent for "${t}"`);let n=t.slice(m),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n)),i.push({depthAndFlags:Lt(r+1,0),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1})}m!==u.length&&(u=t.substring(0,m),d=r),n=t}c.length=l+1,n!=null&&(this.lastPreparedPath=ln(n)),this.hasDeferredDirectoryIndexes=!0}),this}appendPresortedFilePaths(e){let t=null,n=0,r=this.nodes,i=this.segmentTable,a=i.idByValue,o=i.valueById,s=this.directoryStack,c=0,l=``,u=0;for(let i of e){if(t===i)throw Error(`Duplicate path: "${i}"`);let e=i.length,d=0,f=0;if(t!=null)if(l.length>0&&i.length>l.length&&i.startsWith(l))d=u,f=l.length;else{let n=Math.min(e,t.length);for(let e=0;e<n;e++){let n=i.charCodeAt(e);if(n!==t.charCodeAt(e))break;n===47&&(d++,f=e+1)}}c=d,n=d;let p=f,m=i.indexOf(`/`,p);for(;m>=0;){let e=s[c];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);n++;let t=i.slice(p,m),l=a.get(t);l===void 0&&(l=o.length,a.set(t,l),o.push(t));let u=r.length;r.push({depthAndFlags:Lt(n,0,1),nameId:l,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(i.slice(0,m)),this.presortedDirectoryNodeIds.push(u),c++,s[c]=u,p=m+1,m=i.indexOf(`/`,p)}let h=s[c];if(h===void 0)throw Error(`Unable to resolve file parent for "${i}"`);let g=i.slice(p),_=a.get(g);_===void 0&&(_=o.length,a.set(g,_),o.push(g)),r.push({depthAndFlags:Lt(n+1,0),nameId:_,parentId:h,subtreeNodeCount:1,visibleSubtreeCount:1}),p!==l.length&&(l=i.substring(0,p),u=n),t=i}s.length=c+1,t!=null&&(this.lastPreparedPath=ln(t)),this.hasDeferredDirectoryIndexes=!0}finish(e={}){let t=e.skipSubtreeCountPass===!0;return this.hasDeferredDirectoryIndexes?(V(this.instrumentation,`store.builder.buildDirectoryIndexes`,()=>this.buildPresortedFinish(t)),this.hasDeferredDirectoryIndexes=!1):t||V(this.instrumentation,`store.builder.computeSubtreeCounts`,()=>this.computeSubtreeCounts(0)),{directories:this.directories,nodes:this.nodes,options:this.options,rootId:0,segmentTable:this.segmentTable,presortedDirectoryNodeIds:this.presortedDirectoryNodeIds.length>0?this.presortedDirectoryNodeIds:null}}didMatchAllInitialExpandedPaths(){return this.createdDirectoriesAllExpanded&&this.initialExpandedPathSet!=null&&this.createdDirectoryCount===this.initialExpandedPathSet.size}appendPreparedPath(e,t){if(this.hasDeferredDirectoryIndexes&&=(this.buildDirectoryIndexes(),!1),this.lastPreparedPath!=null){if(e.path===this.lastPreparedPath.path)throw Error(`Duplicate path: "${e.path}"`);if(t&&(this.options.sort==="default"?an(this.lastPreparedPath,e,this.segmentSortKeyCache):vn(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}let n=this.lastPreparedPath,r=xn(e),i=n==null?0:xn(n),a=n==null?0:bn(n.segments,e.segments),o=Math.min(a,r,i);this.directoryStack.length=o+1;for(let n=o;n<r;n++){let r=this.directoryStack[this.directoryStack.length-1];if(r===void 0)throw Error(`Directory stack underflow while building the path store`);let i=t?this.getOrCreateDirectoryChild(r,e.segments[n]):this.createDirectoryChild(r,e.segments[n]);this.directoryStack.push(i)}if(e.isDirectory){let t=this.directoryStack[this.directoryStack.length-1];if(t===void 0)throw Error(`Unable to resolve directory node for "${e.path}"`);this.promoteDirectoryToExplicit(t,e.path),this.lastPreparedPath=e;return}let s=this.directoryStack[this.directoryStack.length-1];if(s===void 0)throw Error(`Unable to resolve file parent for "${e.path}"`);t?this.createFileChild(s,e.basename,e.path):this.createFileChildUnchecked(s,e.basename),this.lastPreparedPath=e}recordCreatedDirectoryPath(e){!this.createdDirectoriesAllExpanded||this.initialExpandedPathSet==null||(this.createdDirectoryCount+=1,this.initialExpandedPathSet.has(e)||(this.createdDirectoriesAllExpanded=!1))}createFileChild(e,t,n){let r=pn(this.segmentTable,t),i=this.getDirectoryIndex(e),a=i.childIdByNameId;if(a!=null&&a.get(r)!==void 0)throw Error(`Path collides with an existing entry: "${n}"`);let o=this.nodes[e];if(o===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let s=this.nodes.length;return this.nodes.push({depthAndFlags:Lt(Rt(o)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),a?.set(r,s),Tt(i,s),s}createFileChildUnchecked(e,t){let n=pn(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:Lt(Rt(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Tt(r,a),a}getOrCreateDirectoryChild(e,t){let n=pn(this.segmentTable,t),r=this.getDirectoryIndex(e);if(r.childIdByNameId!=null){let e=r.childIdByNameId.get(n);if(e!==void 0){let n=this.nodes[e];if(n!=null&&!B(n))throw Error(`Path collides with an existing file while creating directory "${t}"`);return e}}let i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:Lt(Rt(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Tt(r,a),this.directories.set(a,z()),a}createDirectoryChild(e,t){let n=pn(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:Lt(Rt(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Tt(r,a),this.directories.set(a,z()),a}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!B(n))throw Error(`Path is not a directory: "${t}"`);if(Vt(n,1))throw Error(`Duplicate path: "${t}"`);Ht(n,1)}getDirectoryIndex(e){let t=this.directories.get(e);if(t!==void 0)return t;throw Error(`Unknown directory child index for node ${String(e)}`)}buildPresortedFinish(e){let t=this.nodes,n=this.directories;n.set(0,St());let r=-1,i=null;for(let e=1;e<t.length;e++){let a=t[e];if(a==null)continue;if(B(a)){let t=St();n.set(e,t),r=e,i=t}let o;a.parentId===r?o=i:(o=n.get(a.parentId),r=a.parentId,i=o??null),o?.childIds.push(e)}if(!e)for(let e=t.length-1;e>=1;e--){let n=t[e];if(n==null)continue;let r=t[n.parentId];r!=null&&(r.subtreeNodeCount+=n.subtreeNodeCount,r.visibleSubtreeCount+=n.visibleSubtreeCount)}}buildDirectoryIndexes(){let e=this.nodes;for(let t=1;t<e.length;t++){let n=e[t];if(n==null)continue;B(n)&&this.directories.set(t,z());let r=this.directories.get(n.parentId);r!=null&&(r.childIdByNameId!=null&&r.childIdByNameId.set(n.nameId,t),Tt(r,t))}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!B(t))return t.subtreeNodeCount=1,t.visibleSubtreeCount=1,1;let n=this.getDirectoryIndex(e),r=1;for(let e of n.childIds)r+=this.computeSubtreeCounts(e);return Dt(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function Mn(e,t=`closed`,n=null){let r=Pn(t);return{activeNodeCount:e.nodes.length-1,collapsedDirectoryIds:new Set,collapseNewDirectoriesByDefault:!1,defaultExpansion:r,directoriesOpenByDefault:r===`open`,hasCollapsedDirectoryOverrides:!1,directoryLoadInfoById:new Map,expandedDirectoryIds:new Set,instrumentation:n,listeners:new Map,pathCacheByNodeId:new Map([[e.rootId,{path:``,version:0}]]),pathCacheVersion:0,snapshot:e,transactionStack:[]}}function Nn(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function Pn(e){if(typeof e!=`number`)return e;if(!Number.isInteger(e)||e<0)throw Error(`initialExpansion must be "open", "closed", or a non-negative integer depth. Received: ${String(e)}`);return e}function Fn(e,t){return Vt(t,2)||e.defaultExpansion===`open`?!0:e.defaultExpansion===`closed`?!1:Rt(t)<=e.defaultExpansion}function In(e,t,n=e.snapshot.nodes[t]){return n==null||!B(n)?!1:e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides?!0:e.collapsedDirectoryIds.has(t)?!1:e.expandedDirectoryIds.has(t)?!0:Fn(e,n)}function Ln(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!B(r))return;let i=Fn(e,r);if(n){if(i){e.collapsedDirectoryIds.delete(t),e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0;return}e.expandedDirectoryIds.add(t);return}if(i){e.collapsedDirectoryIds.add(t),e.hasCollapsedDirectoryOverrides=!0;return}e.expandedDirectoryIds.delete(t)}function Rn(e,t){let n=e.directoryLoadInfoById.get(t);if(n!=null)return n;let r={activeAttemptId:null,errorMessage:null,nextAttemptId:1,state:`loaded`};return e.directoryLoadInfoById.set(t,r),r}function zn(e,t){return e.directoryLoadInfoById.get(t)?.state??`loaded`}function Bn(e,t){let n=Rn(e,t);if(n.state===`loading`&&n.activeAttemptId!=null)return{attemptId:n.activeAttemptId,nodeId:t,reused:!0};let r=n.nextAttemptId;return n.activeAttemptId=r,n.errorMessage=null,n.nextAttemptId+=1,n.state=`loading`,{attemptId:r,nodeId:t,reused:!1}}function Vn(e,t){let n=Rn(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state=`unloaded`}function Hn(e,t,n){let r=e.directoryLoadInfoById.get(t);return r==null||r.activeAttemptId!==n?!1:(r.activeAttemptId=null,r.errorMessage=null,r.state=`loaded`,!0)}function Un(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function Wn(e,t,n,r){let i=e.directoryLoadInfoById.get(t);return i==null||i.activeAttemptId!==n?!1:(i.activeAttemptId=null,i.errorMessage=r??null,i.state=`error`,!0)}function Gn(e,t){e.directoryLoadInfoById.delete(t)}function Kn(e,t,n){let r=n,i=e.listeners.get(t);return i==null?e.listeners.set(t,new Set([r])):i.add(r),()=>{let n=e.listeners.get(t);n!=null&&(n.delete(r),n.size===0&&e.listeners.delete(t))}}function qn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`add`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Jn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`remove`,path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function Yn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:`move`,projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function Xn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`expand`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Zn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`collapse`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Qn(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`mark-directory-unloaded`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function $n(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`begin-child-load`,path:e.path,projectionChanged:e.projectionChanged,reused:e.reused,visibleCountDelta:null}}function er(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:e.childEvents.some(e=>e.canonicalChanged),childEvents:e.childEvents,operation:`apply-child-patch`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function tr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`complete-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function nr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,errorMessage:e.errorMessage,operation:`fail-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function rr(e){return{activeNodeCountAfter:e.activeNodeCountAfter,activeNodeCountBefore:e.activeNodeCountBefore,affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],cachedPathEntryCountAfter:e.cachedPathEntryCountAfter,cachedPathEntryCountBefore:e.cachedPathEntryCountBefore,canonicalChanged:!1,idsPreserved:e.idsPreserved,loadInfoEntryCountAfter:e.loadInfoEntryCountAfter,loadInfoEntryCountBefore:e.loadInfoEntryCountBefore,mode:e.mode,operation:`cleanup`,projectionChanged:e.projectionChanged,reclaimedCachedPathEntryCount:e.reclaimedCachedPathEntryCount,reclaimedLoadInfoEntryCount:e.reclaimedLoadInfoEntryCount,reclaimedNodeSlotCount:e.reclaimedNodeSlotCount,reclaimedSegmentCount:e.reclaimedSegmentCount,segmentCountAfter:e.segmentCountAfter,segmentCountBefore:e.segmentCountBefore,totalNodeSlotCountAfter:e.totalNodeSlotCountAfter,totalNodeSlotCountBefore:e.totalNodeSlotCountBefore,visibleCountDelta:null}}function ir(e,t,n){return{...n,visibleCountDelta:hr(e)-t}}function ar(e,t){let n=hr(e),r=Nn();e.transactionStack.push(r);try{t()}catch(t){throw cr(e,r,!1),t}cr(e,r,!0,hr(e)-n)}function or(e,t){let n=e.instrumentation;if(n==null){sr(e,t);return}V(n,`store.events.record`,()=>sr(e,t))}function sr(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){pr(e,t);return}n.events.push(t),fr(n,t)}function cr(e,t,n,r=null){if(e.transactionStack.pop()!==t)throw Error(`Transaction stack underflow`);if(!n)return;let i=e.transactionStack[e.transactionStack.length-1]??null;if(i!=null){let n=e.instrumentation;n==null?dr(i,t):V(n,`store.events.batch.merge`,()=>dr(i,t));return}let a=lr(t,r),o=e.instrumentation;if(o==null){pr(e,a);return}V(o,`store.events.batch.commit`,()=>pr(e,a))}function lr(e,t){return{affectedAncestorIds:[...e.affectedAncestorIds],affectedNodeIds:[...e.affectedNodeIds],canonicalChanged:e.events.some(e=>e.canonicalChanged),events:[...e.events],operation:`batch`,projectionChanged:e.events.some(e=>e.projectionChanged),visibleCountDelta:t}}function ur(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function dr(e,t){for(let n of t.events)e.events.push(n);ur(e,t)}function fr(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function pr(e,t){let n=e.instrumentation;if(n==null){mr(e,t);return}V(n,`store.events.emit`,()=>mr(e,t))}function mr(e,t){e.listeners.get(t.operation)?.forEach(e=>e(t)),e.listeners.get(`*`)?.forEach(e=>e(t))}function hr(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function gr(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!B(n)||Vt(n,2))return null;let r=e.snapshot.directories.get(t);if(r==null||r.childIds.length!==1)return null;let i=r.childIds[0];if(i==null)return null;let a=e.snapshot.nodes[i];return a==null||!B(a)?null:i}function _r(e,t){let n=t;for(;;){let t=gr(e,n);if(t==null)return n;n=t}}function vr(e,t){let n=[t],r=t;for(;;){let t=gr(e,r);if(t==null)return n;n.push(t),r=t}}function yr(e,t){let n=t==null?e.snapshot.rootId:Or(e,t);return n==null?[]:Ar(e,n)}function br(e,t){let n=ln(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=Gr(e,Wr(e,r)),{createdNodeIds:a,directoryId:o}=jr(e,r),s=new Set(a),c=o;if(n.isDirectory){let n=W(e,o);if(Vt(n,1))throw Error(`Path already exists: "${t}"`);Ht(n,1),e.pathCacheByNodeId.set(o,{path:t,version:e.pathCacheVersion}),s.add(o)}else c=Nr(e,o,n.basename),s.add(c);Tr(e,o);let l=Gr(e,o);return qn({affectedAncestorIds:Dr(e,c),affectedNodeIds:[...s],path:t,projectionChanged:Kr(i,l)})}function xr(e,t,n){let r=Or(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=W(e,r);if(Vt(i,2))throw Error(`The root node cannot be removed`);if(B(i)&&U(e,r).childIds.length>0&&n.recursive!==!0)throw Error(`Cannot remove a non-empty directory without recursive: "${t}"`);let a=i.parentId,o=Gr(e,a),s=Hr(e,r);Ir(e,a,r,i.nameId),Ur(e,a),Tr(e,a);let c=Gr(e,a);return Jn({affectedAncestorIds:Dr(e,a),affectedNodeIds:s,path:t,projectionChanged:Kr(o,c),recursive:n.recursive===!0})}function Sr(e,t,n,r){let i=Or(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let a=W(e,i);if(Vt(a,2))throw Error(`The root node cannot be moved`);let o=r.collision??`error`,s=Br(e,i,n),c=Gr(e,a.parentId),l=Gr(e,s.parentId),u=mn(e.snapshot.segmentTable,a.nameId),d=pn(e.snapshot.segmentTable,s.basename);if(s.parentId===a.parentId&&u===s.basename)return null;if(B(a)&&Xr(e,i,s.parentId))throw Error(`Cannot move a directory into one of its descendants`);let f=Ct(e.snapshot.nodes,U(e,s.parentId)).get(d),p=s.existingNodeId??f??null;if(p!=null&&p!==i&&Vr(e,p,o,zt(a))===`skip`)return null;let m=a.parentId;Ir(e,m,i,a.nameId),a.parentId=s.parentId,a.nameId=d,e.pathCacheByNodeId.delete(i),Yr(e,i),Fr(e,s.parentId,i),Ur(e,m),e.pathCacheVersion++,Tr(e,m),s.parentId!==m&&Tr(e,s.parentId);let h=Gr(e,m),g=Gr(e,s.parentId);return Yn({affectedAncestorIds:[...new Set([...Dr(e,m),...Dr(e,s.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:qr([c,l],[h,g]),to:H(e,i)})}function Cr(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function wr(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function H(e,t){let n=W(e,t),r=Cr(e,t);if(r!=null)return r;if(Vt(n,2))return wr(e,t,``);let i=H(e,n.parentId),a=mn(e.snapshot.segmentTable,n.nameId),o=i.length===0?a:`${i}${a}`;return wr(e,t,B(n)?`${o}/`:o)}function Tr(e,t){let n=e.instrumentation;if(n==null){Qr(e,t);return}V(n,`store.recomputeCountsUpwardFrom`,()=>Qr(e,t))}function Er(e,t){let n=[[t,0]],{nodes:r,directories:i}=e.snapshot;for(;n.length>0;){let t=n[n.length-1],a=t[0],o=r[a];if(o==null||!B(o)){Zr(e,a,o,!0),n.pop();continue}let s=i.get(a);if(s==null||t[1]>=s.childIds.length){Zr(e,a,o,!0),n.pop();continue}let c=s.childIds[t[1]++];n.push([c,0])}}function Dr(e,t){let n=[],r=t;for(;r!=null;){let t=W(e,r);if(n.push(r),r===e.snapshot.rootId)break;r=t.parentId}return n}function Or(e,t){if(t.length===0)return e.snapshot.rootId;let n=un(t);return kr(e,n.segments,n.requiresDirectory)}function kr(e,t,n){let r=e.snapshot.rootId;for(let n of t){let t=e.snapshot.segmentTable.idByValue.get(n);if(t===void 0)return null;let i=U(e,r),a=Ct(e.snapshot.nodes,i).get(t);if(a===void 0)return null;r=a}let i=W(e,r);return n&&!B(i)?null:r}function U(e,t){let n=e.snapshot.directories.get(t);if(n===void 0)throw Error(`Unknown directory child index for node ${String(t)}`);return n}function W(e,t){let n=e.snapshot.nodes[t];if(n===void 0||Vt(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function Ar(e,t){let n=e.snapshot.nodes[t];if(n===void 0||Vt(n,4))return[];if(!B(n))return[H(e,t)];if(U(e,t).childIds.length===0)return Vt(n,1)&&!Vt(n,2)?[H(e,t)]:[];let r=[],i=[{childIndex:0,nodeId:t}];for(;i.length>0;){let t=i[i.length-1];if(t==null)break;let n=e.snapshot.nodes[t.nodeId];if(n===void 0||Vt(n,4)){i.pop();continue}if(!B(n)){r.push(H(e,t.nodeId)),i.pop();continue}let a=U(e,t.nodeId);if(a.childIds.length===0){Vt(n,1)&&!Vt(n,2)&&r.push(H(e,t.nodeId)),i.pop();continue}let o=a.childIds[t.childIndex];if(o==null){i.pop();continue}t.childIndex++,i.push({childIndex:0,nodeId:o})}return r}function jr(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let t=pn(e.snapshot.segmentTable,i),a=U(e,r),o=Ct(e.snapshot.nodes,a).get(t);if(o!==void 0){if(!B(W(e,o)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=o;continue}r=Mr(e,r,t),n.push(r)}return{createdNodeIds:n,directoryId:r}}function Mr(e,t,n){let r=W(e,t),i=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:Lt(Rt(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,z()),Fr(e,t,i),e.collapseNewDirectoriesByDefault&&(e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0),e.activeNodeCount++,i}function Nr(e,t,n){let r=pn(e.snapshot.segmentTable,n),i=U(e,t);if(Ct(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${ei(e,t,n)}"`);let a=W(e,t),o=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:Lt(Rt(a)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),Fr(e,t,o),e.activeNodeCount++,o}function Pr(e,t,n){let r=0,i=t.childIds.length;for(;r<i;){let a=r+i>>>1,o=t.childIds[a];if(o==null){i=a;continue}Lr(e,n,o)<0?i=a:r=a+1}return r}function Fr(e,t,n){let r=U(e,t),i=W(e,n);Ct(e.snapshot.nodes,r).set(i.nameId,n),Ot(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let a=Pr(e,r,n);r.childIds.splice(a,0,n),Et(r,a),jt(e.snapshot.nodes,r)}function Ir(e,t,n,r){let i=U(e,t),a=wt(i),o=a.get(n)??-1;Ct(e.snapshot.nodes,i).delete(r),a.delete(n);let s=e.snapshot.nodes[n];s!=null&&Ot(i,n,-s.subtreeNodeCount,-s.visibleSubtreeCount),o>=0&&(i.childIds.splice(o,1),Et(i,o),jt(e.snapshot.nodes,i))}function Lr(e,t,n){let r=e.snapshot.options.sort;return r==="default"?Rr(e,t,n):r(zr(e,t),zr(e,n))}function Rr(e,t,n){let r=W(e,t),i=W(e,n),a=B(r);if(a!==B(i))return a?-1:1;let o=Qt(on(e.snapshot.segmentTable,r.nameId),on(e.snapshot.segmentTable,i.nameId));if(o!==0)return o;let s=mn(e.snapshot.segmentTable,r.nameId),c=mn(e.snapshot.segmentTable,i.nameId);return s===c?t<n?-1:1:s<c?-1:1}function zr(e,t){let n=W(e,t),r=H(e,t),i=B(n),a=i?r.slice(0,-1):r;return{basename:mn(e.snapshot.segmentTable,n.nameId),depth:Rt(n),isDirectory:i,path:r,segments:a.length===0?[]:a.split(`/`)}}function Br(e,t,n){let r=W(e,t),i=Or(e,n);if(i!=null){let t=W(e,i);if(B(t))return{basename:mn(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let a=un(n).segments;return{basename:a[a.length-1]??``,existingNodeId:i,parentId:t.parentId}}let a=un(n),o=a.segments[a.segments.length-1]??``,s=a.segments.slice(0,-1),c=s.length===0?e.snapshot.rootId:kr(e,s,!0);if(c==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:o,existingNodeId:null,parentId:c}}function Vr(e,t,n,r){if(n===`skip`)return`skip`;if(n===`error`)throw Error(`Destination already exists: "${H(e,t)}"`);let i=W(e,t);if(zt(i)!==r)throw Error(`replace collision requires the same source and destination kinds`);if(B(i)&&U(e,t).childIds.length>0)throw Error(`replace collision does not support non-empty directories`);let a=i.parentId,o=i.nameId;return Hr(e,t),Ir(e,a,t,o),Ur(e,a),Tr(e,a),`handled`}function Hr(e,t){let n=[],r=[{nodeId:t,visitedChildren:!1}];for(;r.length>0;){let t=r.pop();if(t==null)break;let i=W(e,t.nodeId);if(t.visitedChildren||!B(i)){B(i)&&e.snapshot.directories.delete(t.nodeId),Ht(i,4),e.pathCacheByNodeId.delete(t.nodeId),e.collapsedDirectoryIds.delete(t.nodeId)&&(e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0),e.expandedDirectoryIds.delete(t.nodeId),Gn(e,t.nodeId),e.activeNodeCount--,n.push(t.nodeId);continue}r.push({nodeId:t.nodeId,visitedChildren:!0});let a=U(e,t.nodeId);for(let e=a.childIds.length-1;e>=0;e--){let t=a.childIds[e];t!=null&&r.push({nodeId:t,visitedChildren:!1})}}return n}function Ur(e,t){let n=t;for(;n!=null;){let t=W(e,n);if(!B(t)||Vt(t,2)||U(e,n).childIds.length>0)return;Ht(t,1),n=t.parentId===n?null:t.parentId}}function Wr(e,t){let n=e.snapshot.rootId;for(let r of t){let t=e.snapshot.segmentTable.idByValue.get(r);if(t==null)break;let i=Ct(e.snapshot.nodes,U(e,n)).get(t);if(i==null||!B(W(e,i)))break;n=i}return n}function Gr(e,t){let n=Jr(e,t);if(n==null)return null;let r=_r(e,n),i=W(e,r),a=n===r?null:vr(e,n).map(t=>H(e,t));return JSON.stringify({flattenedSegmentPaths:a,hasChildren:U(e,r).childIds.length>0,path:H(e,r),terminalKind:zt(i)})}function Kr(e,t){return qr([e],[t])}function qr(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(r==null||i==null||r!==i)return!0}return!1}function Jr(e,t){let n=t;for(;n!=null;){let t=W(e,n);if(!B(t)||Vt(t,2))return null;if(!In(e,n,t))return n;n=t.parentId}return null}function Yr(e,t){let n=W(e,t);if(Ut(n,(t===e.snapshot.rootId?-1:Rt(W(e,n.parentId)))+1),!B(n))return;let r=U(e,t);for(let t of r.childIds)Yr(e,t)}function Xr(e,t,n){let r=n;for(;r!=null;){if(r===t)return!0;let n=W(e,r);if(r===e.snapshot.rootId)return!1;r=n.parentId}return!1}function Zr(e,t,n=W(e,t),r=!1){let i=e.instrumentation;if(i==null){$r(e,t,n,r);return}V(i,`store.recomputeNodeCounts`,()=>$r(e,t,n,r))}function Qr(e,t){let n=t;for(;n!=null;){let t=W(e,n),r=t.subtreeNodeCount,i=t.visibleSubtreeCount;if(Zr(e,n,t),n===e.snapshot.rootId)return;let a=t.subtreeNodeCount-r,o=t.visibleSubtreeCount-i,s=t.parentId;(a!==0||o!==0)&&Ot(U(e,s),n,a,o),n=s}}function $r(e,t,n,r){if(!B(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=U(e,t);if(r){let t=e.instrumentation;t==null?Dt(e.snapshot.nodes,i):V(t,`store.recomputeNodeCounts.rebuildChildAggregates`,()=>Dt(e.snapshot.nodes,i))}let a=1+i.totalChildSubtreeNodeCount,o=i.totalChildVisibleSubtreeCount;if(n.subtreeNodeCount=a,Vt(n,2)){n.visibleSubtreeCount=o;return}n.visibleSubtreeCount=gr(e,t)==null?In(e,t,n)?1+o:1:o}function ei(e,t,n){let r=H(e,t);return r.length===0?n:`${r}${n}`}function ti(e){return e!=null&&!Vt(e,4)}function ni(e,t){let n=e.snapshot.nodes[t];return!ti(n)||!B(n)||Vt(n,2)?null:n}function ri(e){let t=0;for(let[n,r]of e.pathCacheByNodeId)r.version===e.pathCacheVersion&&ti(e.snapshot.nodes[n])&&(t+=1);return t}function ii(e){return Math.max(0,e.valueById.length-1)}function ai(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:ri(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:ii(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function oi(e,t,n,r){return{activeNodeCountAfter:r.activeNodeCount,activeNodeCountBefore:n.activeNodeCount,cachedPathEntryCountAfter:r.cachedPathEntryCount,cachedPathEntryCountBefore:n.cachedPathEntryCount,idsPreserved:t,loadInfoEntryCountAfter:r.loadInfoEntryCount,loadInfoEntryCountBefore:n.loadInfoEntryCount,mode:e,reclaimedCachedPathEntryCount:n.cachedPathEntryCount-r.cachedPathEntryCount,reclaimedLoadInfoEntryCount:n.loadInfoEntryCount-r.loadInfoEntryCount,reclaimedNodeSlotCount:n.totalNodeSlotCount-r.totalNodeSlotCount,reclaimedSegmentCount:n.segmentCount-r.segmentCount,segmentCountAfter:r.segmentCount,segmentCountBefore:n.segmentCount,totalNodeSlotCountAfter:r.totalNodeSlotCount,totalNodeSlotCountBefore:n.totalNodeSlotCount}}function si(e){let t=[],n=[];for(let n of e.collapsedDirectoryIds)ni(e,n)!=null&&t.push(H(e,n));for(let t of e.expandedDirectoryIds)ni(e,t)!=null&&n.push(H(e,t));return{collapsedPaths:t,expandedPaths:n}}function ci(e){let t=[];for(let[n,r]of e.directoryLoadInfoById)ni(e,n)==null||zn(e,n)===`loaded`||t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:H(e,n)});return t}function li(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let t=Or(e,n);t!=null&&Ln(e,t,!0,W(e,t))}for(let n of t.collapsedPaths){let t=Or(e,n);t!=null&&Ln(e,t,!1,W(e,t))}}function ui(e,t){e.directoryLoadInfoById.clear();for(let n of t){let t=Or(e,n.path);t!=null&&ni(e,t)!=null&&e.directoryLoadInfoById.set(t,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function di(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:``,version:e.pathCacheVersion})}function fi(e){let t=e.snapshot.segmentTable,n=fn();for(let r of e.snapshot.nodes)if(ti(r)){if(Vt(r,2)){r.nameId=0;continue}r.nameId=pn(n,mn(t,r.nameId))}e.snapshot.segmentTable=n}function pi(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!ti(r)||!B(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter(n=>{let r=e.snapshot.nodes[n];return ti(r)&&r.parentId===t});n.childIds=i,n.childIdByNameId=new Map(i.map(t=>[W(e,t).nameId,t])),n.childPositionById=new Map(i.map((e,t)=>[e,t])),Dt(e.snapshot.nodes,n)}}function mi(e){let t=e.snapshot.nodes.length-1;for(;t>e.snapshot.rootId;){let n=e.snapshot.nodes[t];if(ti(n))break;--t}e.snapshot.nodes.length=t+1}function hi(e){let t=si(e),n=ci(e);V(e.instrumentation,`store.cleanup.stable.clearPathCaches`,()=>di(e)),V(e.instrumentation,`store.cleanup.stable.rebuildSegmentTable`,()=>fi(e)),V(e.instrumentation,`store.cleanup.stable.rebuildDirectoryIndexes`,()=>pi(e)),V(e.instrumentation,`store.cleanup.stable.trimTrailingRemovedNodeSlots`,()=>mi(e)),V(e.instrumentation,`store.cleanup.stable.restoreExpansionOverrides`,()=>li(e,t)),V(e.instrumentation,`store.cleanup.stable.restoreDirectoryLoadInfos`,()=>ui(e,n)),V(e.instrumentation,`store.cleanup.stable.recomputeCounts`,()=>Er(e,e.snapshot.rootId))}function gi(e){let t=si(e),n=ci(e),r=V(e.instrumentation,`store.cleanup.aggressive.listPaths`,()=>yr(e)),i=Gt({...e.snapshot.options},e.instrumentation),a=V(e.instrumentation,`store.cleanup.aggressive.rebuildSnapshot`,()=>{let e=new jn(i);return e.appendPaths(r),e.finish()});e.snapshot=a,e.activeNodeCount=a.nodes.length-1,e.pathCacheByNodeId=new Map([[a.rootId,{path:``,version:0}]]),e.pathCacheVersion=0,V(e.instrumentation,`store.cleanup.aggressive.restoreExpansionOverrides`,()=>li(e,t)),V(e.instrumentation,`store.cleanup.aggressive.restoreDirectoryLoadInfos`,()=>ui(e,n)),V(e.instrumentation,`store.cleanup.aggressive.recomputeCounts`,()=>Er(e,e.snapshot.rootId))}function _i(e){for(let t of e.directoryLoadInfoById.values())if(t.state===`loading`&&t.activeAttemptId!=null)return!0;return!1}function vi(e,t){let n=ai(e);t===`stable`?V(e.instrumentation,`store.cleanup.stable`,()=>hi(e)):V(e.instrumentation,`store.cleanup.aggressive`,()=>gi(e));let r=ai(e);return oi(t,t===`stable`,n,r)}var yi=64;function bi(e,t){let n=t+2;if(n<=e.length)return e;let r=e.length;for(;r<n;)r*=2;let i=new Int32Array(r);return i.fill(-1),i.set(e),i}function xi(e){return W(e,e.snapshot.rootId).visibleSubtreeCount}function Si(e,t,n,r){let i=W(e,t.terminalNodeId),a=Math.max(1,i.visibleSubtreeCount);return Math.min(r-1,n+a-1)}function Ci(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:Hi(e,t.cursor),setSize:t.setSize,subtreeEndIndex:Si(e,t.cursor,t.index,n)}}function wi(e,t,n,r,i,a){let o=U(e,t),{childIndex:s,childVisibleIndex:c,localVisibleIndex:l}=kt(e.snapshot.nodes,o,n),u=o.childIds[s];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return Ti(e,u,l,r+c,i+1,s,o.childIds.length,a)}function Ti(e,t,n,r,i,a,o,s){if(!B(W(e,t))){if(n===0)return{ancestors:s,cursor:{headNodeId:t,terminalNodeId:t,visibleDepth:i},index:r,posInSet:a,setSize:o};throw Error(`Visible index ${String(n)} is out of range for file`)}let c=Ii(e,t,i);if(n===0)return{ancestors:s,cursor:c,index:r,posInSet:a,setSize:o};let l=W(e,c.terminalNodeId);if(!B(l)||!In(e,c.terminalNodeId,l))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return wi(e,c.terminalNodeId,n-1,r+1,c.visibleDepth,[...s,{cursor:c,index:r,posInSet:a,setSize:o}])}function Ei(e,t){let n=xi(e);if(t<0||t>=n)return null;let r=wi(e,e.snapshot.rootId,t,0,-1,[]),i=r.ancestors.map(t=>H(e,t.cursor.terminalNodeId)),a=null;return{ancestorPaths:i,get ancestorRows(){if(a!=null)return a;let t=[],i=[];for(let a of r.ancestors){let r=Ci(e,a,n,[...i]);t.push(r),i.push(r.row.path)}return a=t,a},index:r.index,posInSet:r.posInSet,row:Hi(e,r.cursor),setSize:r.setSize,subtreeEndIndex:Si(e,r.cursor,r.index,n)}}function Di(e,t,n){let r=e.instrumentation,i=xi(e);if(i<=0||n<t)return[];let a=Math.max(0,Math.min(t,i-1)),o=Math.max(a,Math.min(n,i-1));if(r==null){if(a===0)return Vi(e,o+1);let t=[],n=Ni(e,a);for(let r=a;r<=o&&n!=null;r++){let r=Hi(e,n);t.push(r),n=Ri(e,n)}return t}let s=[],c=0,l=0,u=V(r,`store.getVisibleSlice.selectFirstRow`,()=>Ni(e,a));for(let t=a;t<=o&&u!=null;t++){let t=V(r,`store.getVisibleSlice.materializeRow`,()=>Hi(e,u));s.push(t),t.isFlattened&&(c++,l+=t.flattenedSegments?.length??0),u=V(r,`store.getVisibleSlice.advanceCursor`,()=>Ri(e,u))}return qt(r,`workload.visibleRowsRead`,s.length),qt(r,`workload.flattenedRowsRead`,c),qt(r,`workload.flattenedSegmentsRead`,l),s}function Oi(e,t=xi(e)){let n=e.instrumentation;return n==null?Bi(e,t):V(n,`store.getVisibleTreeProjection`,()=>Bi(e,t))}function ki(e){return zi(Oi(e))}function Ai(e,t){let n=Or(e,t);if(n==null||n===e.snapshot.rootId||B(W(e,n))&&_r(e,n)!==n)return null;let r=0,i=n,{nodes:a,rootId:o}=e.snapshot;for(;i!==o;){let t=W(e,i).parentId,n=U(e,t),s=wt(n).get(i);if(s==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=At(a,n,s),t!==o){let n=W(e,t),a=gr(e,t);if(!In(e,t,n)&&a!==i)return null;_r(e,t)===t&&(r+=1)}i=t}return r}function ji(e,t){let n=Or(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=W(e,n);if(!B(r))throw Error(`Path is not a directory: "${t}"`);return In(e,n,r)?null:(Ln(e,n,!0,r),Tr(e,n),Xn({affectedAncestorIds:Dr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0}))}function Mi(e,t){let n=Or(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=W(e,n);if(!B(r))throw Error(`Path is not a directory: "${t}"`);return In(e,n,r)?(Ln(e,n,!1,r),Tr(e,n),Zn({affectedAncestorIds:Dr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})):null}function Ni(e,t){return t<0||t>=xi(e)?null:Pi(e,e.snapshot.rootId,t,-1)}function Pi(e,t,n,r){let i=U(e,t),a=e.instrumentation,{childIndex:o,localVisibleIndex:s}=a==null?kt(e.snapshot.nodes,i,n):V(a,`store.getVisibleSlice.selectChildIndex`,()=>kt(e.snapshot.nodes,i,n)),c=i.childIds[o];if(c!=null)return Fi(e,c,s,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function Fi(e,t,n,r){if(!B(W(e,t))){if(n===0)return{headNodeId:t,terminalNodeId:t,visibleDepth:r};throw Error(`Visible index ${String(n)} is out of range for file`)}let i=Ii(e,t,r);if(n===0)return i;let a=W(e,i.terminalNodeId);if(!B(a)||!In(e,i.terminalNodeId,a))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Pi(e,i.terminalNodeId,n-1,i.visibleDepth)}function Ii(e,t,n){return B(W(e,t))?e.instrumentation==null?{headNodeId:t,terminalNodeId:_r(e,t),visibleDepth:n}:{headNodeId:t,terminalNodeId:V(e.instrumentation,`store.getVisibleSlice.flatten.resolveTerminalDirectory`,()=>_r(e,t)),visibleDepth:n}:{headNodeId:t,terminalNodeId:t,visibleDepth:n}}function Li(e,t){let n=W(e,t);if(!B(n))return!0;let r=n.parentId;return r===e.snapshot.rootId?!0:gr(e,r)!==t}function Ri(e,t){let n=W(e,t.terminalNodeId);if(B(n)){let r=U(e,t.terminalNodeId);if(In(e,t.terminalNodeId,n)&&r.childIds.length>0){let n=r.childIds[0];return n==null?null:Fi(e,n,0,t.visibleDepth+1)}}let r=t.terminalNodeId,i=t.visibleDepth;for(;;){let t=W(e,r);if(r===e.snapshot.rootId)return null;let n=t.parentId,a=U(e,n),o=wt(a).get(r)??-1;if(o<0)throw Error(`Child ${String(r)} was not found in its parent index`);let s=a.childIds[o+1]??null;if(s!=null)return Fi(e,s,0,i);Li(e,r)&&i--,r=n}}function zi(e){let t=e.paths.length,n=Array(t);for(let r=0;r<t;r+=1){let t=e.getParentIndex(r);n[r]={index:r,parentPath:t>=0?e.paths[t]??null:null,path:e.paths[r]??``,posInSet:e.posInSetByIndex[r]??0,setSize:e.setSizeByIndex[r]??0}}return{getParentIndex:e.getParentIndex,rows:n,get visibleIndexByPath(){return e.visibleIndexByPath}}}function Bi(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),a=new Int32Array(t),o=new Int32Array(yi);o.fill(-1);let s=0,{nodes:c,directories:l,segmentTable:u}=e.snapshot,d=[[l.get(e.snapshot.rootId),0,-1,``]],f=e.snapshot.options.flattenEmptyDirectories,p=e.pathCacheByNodeId,m=e.pathCacheVersion,h=u.valueById;for(;d.length>0&&s<t;){let t=d[d.length-1],u=t[0];if(t[1]>=u.childIds.length){d.pop();continue}let g=t[1],_=u.childIds[t[1]++],v=c[_],y=t[2]+1,b=t[3];o=bi(o,y);let x,S=_;if(B(v))S=f?_r(e,_):_,x=S===_?`${b}${h[v.nameId]}/`:H(e,S);else{let e=p.get(_);x=e!=null&&e.version===m?e.path:`${b}${h[v.nameId]}`}r[s]=o[y],n[s]=x,i[s]=g,a[s]=u.childIds.length,o[y+1]=s,s+=1;let C=c[S];C!=null&&B(C)&&In(e,S,C)&&d.push([l.get(S),0,y,x])}s<t&&(n.length=s);let g=r.subarray(0,s),_=i.subarray(0,s),v=a.subarray(0,s),y=null;return{getParentIndex(e){return e<0||e>=s?-1:g[e]??-1},paths:n,posInSetByIndex:_,setSizeByIndex:v,get visibleIndexByPath(){if(y==null){y=new Map;for(let e=0;e<s;e+=1)y.set(n[e]??``,e)}return y}}}function Vi(e,t){let n=Array(t),r=0,{nodes:i,directories:a,segmentTable:o}=e.snapshot,s=[[a.get(e.snapshot.rootId),0,-1]],c=o.valueById,l=e.snapshot.options.flattenEmptyDirectories,u=e.pathCacheByNodeId,d=e.pathCacheVersion;for(;s.length>0&&r<t;){let t=s[s.length-1],o=t[0];if(t[1]>=o.childIds.length){s.pop();continue}let f=o.childIds[t[1]++],p=i[f],m=t[2]+1;if(!B(p)){let t=u.get(f);n[r++]={depth:m,flattenedSegments:void 0,hasChildren:!1,id:f,isExpanded:!1,isFlattened:!1,isLoading:!1,kind:`file`,loadState:void 0,name:c[p.nameId],path:t!=null&&t.version===d?t.path:H(e,f)};continue}let h=l?_r(e,f):f,g={headNodeId:f,terminalNodeId:h,visibleDepth:m};n[r++]=Hi(e,g);let _=i[h];_!=null&&B(_)&&In(e,h,_)&&s.push([a.get(h),0,m])}return r<t&&(n.length=r),n}function Hi(e,t){let n=W(e,t.terminalNodeId),r=B(n)?Ui(e,t):null,i=H(e,t.terminalNodeId),a=mn(e.snapshot.segmentTable,n.nameId),o=B(n)&&U(e,t.terminalNodeId).childIds.length>0,s=t.headNodeId!==t.terminalNodeId,c=e.instrumentation,l=s?c==null?vr(e,t.headNodeId).map(n=>{let r=W(e,n);return{isTerminal:n===t.terminalNodeId,name:mn(e.snapshot.segmentTable,r.nameId),nodeId:n,path:H(e,n)}}):V(c,`store.getVisibleSlice.flatten.collectSegments`,()=>vr(e,t.headNodeId).map(n=>{let r=W(e,n);return{isTerminal:n===t.terminalNodeId,name:mn(e.snapshot.segmentTable,r.nameId),nodeId:n,path:H(e,n)}})):void 0;return{depth:t.visibleDepth,flattenedSegments:l,hasChildren:o,id:t.terminalNodeId,isExpanded:B(n)&&In(e,t.terminalNodeId,n),isFlattened:s,isLoading:r===`loading`,kind:B(n)?`directory`:`file`,loadState:r==null||r===`loaded`?void 0:r,name:a,path:i}}function Ui(e,t){if(t.headNodeId===t.terminalNodeId)return zn(e,t.terminalNodeId);let n=vr(e,t.headNodeId),r=!1,i=!1;for(let t of n){let n=zn(e,t);if(n===`loading`)return`loading`;if(n===`error`){i=!0;continue}n===`unloaded`&&(r=!0)}return i?`error`:r?`unloaded`:`loaded`}function Wi(e){let{directories:t,nodes:n,options:r,rootId:i,presortedDirectoryNodeIds:a}=e.snapshot,o=r.flattenEmptyDirectories===!0,s=e=>{let r=n[e];if(r==null||!B(r))return;let i=t.get(e);if(i==null)throw Error(`Unknown directory child index for node ${String(e)}`);let a=i.childIds,s=a.length,c=0,l=0;for(let e=0;e<s;e++){let t=a[e];if(t==null)continue;let r=n[t];c+=r.subtreeNodeCount,l+=r.visibleSubtreeCount}i.totalChildSubtreeNodeCount=c,i.totalChildVisibleSubtreeCount=l,s>=128&&jt(n,i),r.subtreeNodeCount=1+c;let u;if(o&&s===1){let e=n[a[0]];u=e!=null&&B(e)?l:1+l}else u=1+l;r.visibleSubtreeCount=u};if(a!=null)for(let e=a.length-1;e>=0;e--)s(a[e]);else for(let e=n.length-1;e>=1;e--)s(e);let c=n[i],l=t.get(i);if(c==null||l==null)return;let u=l.childIds,d=0,f=0;for(let e=0;e<u.length;e++){let t=u[e];if(t==null)continue;let r=n[t];d+=r.subtreeNodeCount,f+=r.visibleSubtreeCount}l.totalChildSubtreeNodeCount=d,l.totalChildVisibleSubtreeCount=f,jt(n,l),c.subtreeNodeCount=1+d,c.visibleSubtreeCount=f}function Gi(e){return e.initialExpansion===`open`&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var Ki=class e{#e;constructor(e={}){let t=Kt(e),n=V(t,`store.builder.create`,()=>new jn(e));if(e.preparedInput!=null){let t=On(e.preparedInput);t==null?n.appendPreparedPaths(Dn(e.preparedInput),!1):n.appendPresortedPaths(t,kn(e.preparedInput))}else{let r=e.paths??[];e.presorted===!0?n.appendPaths(r):n.appendPreparedPaths(V(t,`store.preparePathEntries`,()=>An(r,e)))}let r=V(t,`store.builder.finish`,()=>n.finish({skipSubtreeCountPass:!0})),i=V(t,`store.state.detectAllDirectoriesExpanded`,()=>(e.initialExpansion??`closed`)===`closed`&&n.didMatchAllInitialExpandedPaths());this.#e=V(t,`store.state.create`,()=>Mn(r,i?`open`:e.initialExpansion??`closed`,t)),i&&(this.#e.collapseNewDirectoriesByDefault=!0);let a=i?this.#e.snapshot.directories.size-1:V(t,`store.state.initializeExpandedPaths`,()=>this.initializeExpandedPaths(e.initialExpandedPaths));i||Gi(e)||(e.initialExpansion??`closed`)===`closed`&&a===this.#e.snapshot.directories.size-1||(e.initialExpandedPaths?.length??0)>0&&V(t,`store.state.checkAllDirectoriesExpanded`,()=>this.hasAllDirectoriesExpanded())?V(t,`store.state.initializeOpenVisibleCounts`,()=>Wi(this.#e)):V(t,`store.state.recomputeCounts`,()=>Er(this.#e,this.#e.snapshot.rootId))}static preparePaths(e,t={}){return wn(e,t)}static prepareInput(e,t={}){return Tn(e,t)}static preparePresortedInput(e){return En(e)}list(e){return V(this.#e.instrumentation,`store.list`,()=>yr(this.#e,e))}add(e){V(this.#e.instrumentation,`store.add`,()=>{let t=xi(this.#e);or(this.#e,ir(this.#e,t,br(this.#e,e)))})}remove(e,t={}){V(this.#e.instrumentation,`store.remove`,()=>{let n=xi(this.#e);or(this.#e,ir(this.#e,n,xr(this.#e,e,t)))})}move(e,t,n={}){V(this.#e.instrumentation,`store.move`,()=>{let r=xi(this.#e),i=Sr(this.#e,e,t,n);i!=null&&or(this.#e,ir(this.#e,r,i))})}batch(e){ar(this.#e,()=>{if(typeof e==`function`){e(this);return}for(let t of e)switch(t.type){case`add`:this.add(t.path);break;case`remove`:this.remove(t.path,{recursive:t.recursive});break;case`move`:this.move(t.from,t.to,{collision:t.collision});break}})}getVisibleCount(){return V(this.#e.instrumentation,`store.getVisibleCount`,()=>xi(this.#e))}getVisibleSlice(e,t){return V(this.#e.instrumentation,`store.getVisibleSlice`,()=>Di(this.#e,e,t))}getVisibleRowContext(e){return V(this.#e.instrumentation,`store.getVisibleRowContext`,()=>Ei(this.#e,e))}getVisibleTreeProjection(){return ki(this.#e)}getVisibleTreeProjectionData(e){return Oi(this.#e,e)}getVisibleIndex(e){return V(this.#e.instrumentation,`store.getVisibleIndex`,()=>Ai(this.#e,e))}getPathInfo(e){return V(this.#e.instrumentation,`store.getPathInfo`,()=>{let t=Or(this.#e,e);if(t==null)return null;let n=W(this.#e,t);return{depth:Rt(n),kind:B(n)?`directory`:`file`,path:H(this.#e,t)}})}isExpanded(e){return V(this.#e.instrumentation,`store.isExpanded`,()=>{let t=this.requireDirectoryNodeId(e),n=W(this.#e,t);return In(this.#e,t,n)})}expand(e){V(this.#e.instrumentation,`store.expand`,()=>{let t=xi(this.#e),n=ji(this.#e,e);n!=null&&or(this.#e,ir(this.#e,t,n))})}collapse(e){V(this.#e.instrumentation,`store.collapse`,()=>{let t=xi(this.#e),n=Mi(this.#e,e);n!=null&&or(this.#e,ir(this.#e,t,n))})}on(e,t){return Kn(this.#e,e,t)}getDirectoryLoadState(e){let t=this.requireDirectoryNodeId(e);return zn(this.#e,t)}markDirectoryUnloaded(e){V(this.#e.instrumentation,`store.markDirectoryUnloaded`,()=>{let t=this.requireDirectoryNodeId(e);if(U(this.#e,t).childIds.length>0)throw Error(`Cannot mark a directory with known children as unloaded: "${e}"`);let n=xi(this.#e);Vn(this.#e,t),or(this.#e,ir(this.#e,n,Qn({affectedAncestorIds:Dr(this.#e,t),affectedNodeIds:[t],path:e,projectionChanged:this.isDirectoryProjectionVisible(t)})))})}beginChildLoad(e){return V(this.#e.instrumentation,`store.beginChildLoad`,()=>{let t=this.requireDirectoryNodeId(e),n=xi(this.#e),r=Bn(this.#e,t);return or(this.#e,ir(this.#e,n,$n({affectedAncestorIds:Dr(this.#e,t),affectedNodeIds:[t],attemptId:r.attemptId,path:e,projectionChanged:this.isDirectoryProjectionVisible(t),reused:r.reused}))),r})}applyChildPatch(e,t){return V(this.#e.instrumentation,`store.applyChildPatch`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null||zn(this.#e,n)!==`loading`||!Un(this.#e,n,e.attemptId))return!1;let r=H(this.#e,n);this.validateChildPatch(r,t);let i=xi(this.#e),a=[];for(let e of t.operations){qi(r,e);let t=xi(this.#e);switch(e.type){case`add`:a.push(ir(this.#e,t,br(this.#e,e.path)));break;case`remove`:a.push(ir(this.#e,t,xr(this.#e,e.path,{recursive:e.recursive})));break;case`move`:{let n=Sr(this.#e,e.from,e.to,{collision:e.collision});n!=null&&a.push(ir(this.#e,t,n));break}}}let o=a.some(e=>e.projectionChanged)||this.isDirectoryProjectionVisible(n);return or(this.#e,ir(this.#e,i,er({affectedAncestorIds:Dr(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,childEvents:a,path:H(this.#e,n),projectionChanged:o}))),!0})}completeChildLoad(e){return V(this.#e.instrumentation,`store.completeChildLoad`,()=>{let t=this.resolveActiveDirectoryNodeId(e.nodeId);if(t==null)return!1;let n=xi(this.#e),r=Hn(this.#e,t,e.attemptId);return or(this.#e,ir(this.#e,n,tr({affectedAncestorIds:Dr(this.#e,t),affectedNodeIds:[t],attemptId:e.attemptId,path:H(this.#e,t),projectionChanged:this.isDirectoryProjectionVisible(t),stale:!r}))),r})}failChildLoad(e,t){return V(this.#e.instrumentation,`store.failChildLoad`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null)return!1;let r=xi(this.#e),i=Wn(this.#e,n,e.attemptId,t);return or(this.#e,ir(this.#e,r,nr({affectedAncestorIds:Dr(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,errorMessage:t,path:H(this.#e,n),projectionChanged:this.isDirectoryProjectionVisible(n),stale:!i}))),i})}cleanup(e={}){return V(this.#e.instrumentation,`store.cleanup`,()=>{if(this.#e.transactionStack.length>0)throw Error(`Cleanup cannot run during an open batch or transaction.`);if(_i(this.#e))throw Error(`Cleanup cannot run while directory loads are active.`);let t=xi(this.#e),n=vi(this.#e,e.mode??`stable`);return or(this.#e,ir(this.#e,t,rr({...n,affectedAncestorIds:[],affectedNodeIds:[],projectionChanged:n.idsPreserved===!1}))),n})}getNodeCount(){return this.#e.activeNodeCount}initializeExpandedPaths(e){if(e==null||e.length===0)return 0;let t=0,n=[],r=[],i=0,a=null,o=this.#e.snapshot.segmentTable,s=o.valueById,c=this.#e.snapshot.nodes,l=new Map;for(let u of e){a!=null&&u<a&&(a=null,i=0,n.length=0,r.length=0);let e=u.length>0&&u.charCodeAt(u.length-1)===47?u.length-1:u.length;if(e===0){a=u,i=e,n.length=0,r.length=0;continue}let d=0,f=0;if(a!=null){let t=Math.min(e,i),n=!0;for(let e=0;e<t;e+=1){let t=u.charCodeAt(e);if(t!==a.charCodeAt(e)){n=!1;break}t===47&&(d+=1,f=e+1)}n&&(t===i&&e>t&&u.charCodeAt(t)===47?(d+=1,f=t+1):t===e&&i>t&&a.charCodeAt(t)===47&&(d+=1,f=e+1)),d=Math.min(d,r.length)}let p=d===0?this.#e.snapshot.rootId:r[d-1]??this.#e.snapshot.rootId,m=d,h=!0,g=f;for(;g<=e;){let t=u.indexOf(`/`,g),i=t===-1||t>e?e:t,a=u.slice(g,i),f=U(this.#e,p).childIds,_=m===d?n[m]??0:0,v=_,y,b=l.get(a)??Xt(a);l.set(a,b);let x=(e,t)=>{for(v=e;v<t;v+=1){let e=f[v],t=c[e],n=s[t.nameId];if(n===a)return y=e,!0;let r=Qt(on(o,t.nameId),b);if(r>0||r===0&&n>a)return!1}return!1};if(!x(_,f.length)&&_>0&&x(0,_),y===void 0){h=!1;break}if(!B(W(this.#e,y))){h=!1;break}if(n[m]=v,r[m]=y,p=y,m+=1,i===e)break;g=i+1}if(a=u,i=e,n.length=m,r.length=m,!h){a=null,i=0,n.length=0,r.length=0;continue}for(let e=d;e<m;e+=1){let n=r[e];if(n==null)continue;let i=W(this.#e,n);In(this.#e,n,i)||(Ln(this.#e,n,!0,i),t+=1)}}return t}hasAllDirectoriesExpanded(){for(let e of this.#e.snapshot.directories.keys()){if(e===this.#e.snapshot.rootId)continue;let t=W(this.#e,e);if(!In(this.#e,e,t))return!1}return!0}requireDirectoryNodeId(e){let t=Or(this.#e,e);if(t==null)throw Error(`Path does not exist: "${e}"`);if(!B(W(this.#e,t)))throw Error(`Path is not a directory: "${e}"`);return t}resolveActiveDirectoryNodeId(e){try{if(!B(W(this.#e,e)))throw Error(`Node is not a directory: ${String(e)}`);return e}catch{return null}}isDirectoryProjectionVisible(e){let t=e;for(;t!==this.#e.snapshot.rootId;){let e=W(this.#e,t).parentId;if(e!==this.#e.snapshot.rootId){let n=W(this.#e,e),r=gr(this.#e,e);if(!In(this.#e,e,n)&&r!==t)return!1}t=e}return!0}validateChildPatch(t,n){new e({paths:this.list(t),presorted:!0,sort:this.#e.snapshot.options.sort}).batch(n.operations)}};function qi(e,t){switch(t.type){case`add`:case`remove`:if(!t.path.startsWith(e)||t.path===e)throw Error(`Child patch operation must stay within ${e}: "${t.path}"`);break;case`move`:if(!t.from.startsWith(e)||!t.to.startsWith(e)||t.from===e||t.to===e)throw Error(`Child patch move must stay within ${e}: "${t.from}" -> "${t.to}"`);break}}var Ji={compact:{itemHeight:24,factor:.8},default:{itemHeight:30,factor:1},relaxed:{itemHeight:36,factor:1.2}};function Yi(e,t){if(typeof e==`number`)return{itemHeight:t??Ji.default.itemHeight,factor:e};let n=Ji[e??`default`];return{itemHeight:t??n.itemHeight,factor:n.factor}}var Xi=Ji.default.itemHeight,Zi=`@layer base, theme, unsafe;
2
2
 
3
3
  @layer base {
4
4
  :host {
@@ -2227,4 +2227,4 @@ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}f
2227
2227
  color: var(--diffs-selection-number-fg) !important;
2228
2228
  }
2229
2229
  `;function Sm(e){let t=(0,Yp.c)(5),n=Ve(e.environmentId,e.resource),[r,i]=(0,J.useState)(null);if(n._tag===`Failure`||n._tag===`Success`&&r===n.url){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:`Unable to load image.`}),t[0]=e):e=t[0],e}let a;return t[1]!==n._tag||t[2]!==n.url||t[3]!==e.alt?(a=n._tag===`Success`?(0,Y.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:(0,Y.jsx)(`img`,{className:`max-h-full max-w-full object-contain`,src:n.url,alt:e.alt,onError:()=>i(n.url)})}):(0,Y.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,Y.jsx)(d,{className:`size-5 animate-spin`})}),t[1]=n._tag,t[2]=n.url,t[3]=e.alt,t[4]=a):a=t[4],a}function Cm(e,t){let n=1;for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);r===10?n+=1:r===13&&(n+=1,e.charCodeAt(t+1)===10&&(t+=1))}return Math.min(Math.max(1,t),n)}function wm(e,t){let n=e.shadowRoot??e;for(let e of n.querySelectorAll(`[${bm}]`))e.removeAttribute(bm);t!==null&&(n.querySelector(`[data-line="${t}"]`)?.setAttribute(bm,``),n.querySelector(`[data-column-number="${t}"]`)?.setAttribute(bm,``))}function Tm(e,t,n){let r=(0,Yp.c)(7),[i]=(0,J.useState)(Om),[a]=(0,J.useState)(Dm),[o]=(0,J.useState)(Em),s;return r[0]!==i||r[1]!==a||r[2]!==o||r[3]!==e||r[4]!==t||r[5]!==n?(s=(r,s,c)=>{if(e===null)return;let l=()=>{let t=o.get(e);t!==void 0&&(cancelAnimationFrame(t),o.delete(e))};if(c===`unmount`){l();return}let u=t===null?null:Cm(s.file?.contents??``,t);if(wm(r,u),!(s instanceof j))return;if(a.get(e)!==n&&(l(),a.set(e,n)),u===null){r.style.minHeight=``;return}let d=r.closest(`.file-preview-virtualizer`);!d||(r.style.minHeight=`${Math.ceil(Math.max(s.height,d.clientHeight))}px`,i.get(e)===n||o.has(e))||o.set(e,requestAnimationFrame(()=>{if(o.delete(e),a.get(e)!==n||!r.isConnected)return;let t=s.getLinePosition(u);if(!t)return;let c=d.scrollTop+r.getBoundingClientRect().top-d.getBoundingClientRect().top,l=Math.max(0,c+t.top-Math.max(0,(d.clientHeight-t.height)/2)),f=Math.max(0,d.scrollHeight-d.clientHeight);d.scrollTop=Math.min(l,f),i.set(e,n)}))},r[0]=i,r[1]=a,r[2]=o,r[3]=e,r[4]=t,r[5]=n,r[6]=s):s=r[6],s}function Em(){return new Map}function Dm(){return new Map}function Om(){return new Map}function km(e){let t=(0,Yp.c)(19),{environmentId:n,cwd:r,relativePath:i,onPendingChange:a}=e,o=A(ye.writeFile),s;t[0]!==a||t[1]!==i?(s=e=>a(i,e),t[0]=a,t[1]=i,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==n||t[5]!==i||t[6]!==o?(c=e=>o({environmentId:n,input:{cwd:r,relativePath:i,contents:e}}),t[3]=r,t[4]=n,t[5]=i,t[6]=o,t[7]=c):c=t[7];let l;t[8]!==r||t[9]!==n||t[10]!==i?(l=e=>{He(n,r,i,e)},t[8]=r,t[9]=n,t[10]=i,t[11]=l):l=t[11];let u;t[12]!==s||t[13]!==c||t[14]!==l?(u=new _m({debounceMs:ym,onPendingChange:s,persist:c,onConfirmed:l}),t[12]=s,t[13]=c,t[14]=l,t[15]=u):u=t[15];let d=u,f,p;return t[16]===d?(f=t[17],p=t[18]):(f=()=>()=>d.dispose(),p=[d],t[16]=d,t[17]=f,t[18]=p),(0,J.useEffect)(f,p),d}function Am(e){let t=(0,Yp.c)(73),{environmentId:n,cwd:r,relativePath:i,composerDraftTarget:o,contents:s,resolvedTheme:c,revealRequestId:l,wordWrap:u,onPostRender:d,onPendingChange:f}=e,p=k(Lm),m=k(Im),h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=[],t[0]=h):h=t[0];let[g,_]=(0,J.useState)(h),[v,y]=(0,J.useState)(null),b=v?.revealRequestId===l?v.range:null,x;t[1]===l?x=t[2]:(x=e=>{y({revealRequestId:l,range:e})},t[1]=l,t[2]=x);let S=x,C=(0,J.useRef)(null),w=(0,J.useRef)(null),T;t[3]!==r||t[4]!==n||t[5]!==f||t[6]!==i?(T={environmentId:n,cwd:r,relativePath:i,onPendingChange:f},t[3]=r,t[4]=n,t[5]=f,t[6]=i,t[7]=T):T=t[7];let E=km(T),D=(0,J.useRef)(null),O;t[8]!==p||t[9]!==o||t[10]!==r||t[11]!==n||t[12]!==i||t[13]!==E?(O=(e,t)=>{if(Ne(n,r,i,e.contents),E.change(e.contents),t){let n=ot(t);_(n);for(let t of n)for(let n of t.metadata.entries)n.kind===`comment`&&p(o,a({id:n.id,filePath:i,startLine:n.startLine,endLine:n.endLine,text:n.text,contents:e.contents}))}},t[8]=p,t[9]=o,t[10]=r,t[11]=n,t[12]=i,t[13]=E,t[14]=O):O=t[14];let ee=O,te;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(te=e=>{let t=new Vp(e);return D.current=t,t},t[15]=te):te=t[15];let A=te,j,M;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>()=>{D.current?.cleanUp(),D.current=null},M=[],t[16]=j,t[17]=M):(j=t[16],M=t[17]),(0,J.useEffect)(j,M);let N;t[18]!==o||t[19]!==m||t[20]!==S?(N=e=>{S(null),m(o,e),_(t=>t.flatMap(t=>{let n=t.metadata.entries.filter(t=>t.id!==e);return n.length>0?[{...t,metadata:{entries:n}}]:[]}))},t[18]=o,t[19]=m,t[20]=S,t[21]=N):N=t[21];let ne=N,re;t[22]!==p||t[23]!==o||t[24]!==s||t[25]!==g||t[26]!==i||t[27]!==S?(re=(e,t)=>{S(null);let n=g.flatMap(Fm).find(t=>t.id===e);n&&p(o,a({id:n.id,filePath:i,startLine:n.startLine,endLine:n.endLine,text:t,contents:s})),_(n=>n.map(n=>({...n,metadata:{entries:n.metadata.entries.map(n=>n.id===e?{...n,kind:`comment`,text:t}:n)}})))},t[22]=p,t[23]=o,t[24]=s,t[25]=g,t[26]=i,t[27]=S,t[28]=re):re=t[28];let ie=re,ae;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(ae=e=>{let{startLine:t,endLine:n}=L(e),r={id:st(),kind:`draft`,startLine:t,endLine:n,text:``};_(e=>{let t=e.flatMap(Nm),i=t.findIndex(e=>e.lineNumber===n);return i<0?[...t,{lineNumber:n,metadata:{entries:[r]}}]:t.map((e,t)=>t===i?{...e,metadata:{entries:[...e.metadata.entries,r]}}:e)})},t[29]=ae):ae=t[29];let oe=ae,se;t[30]===g?se=t[31]:(se=g.some(jm),t[30]=g,t[31]=se);let ce=se,le,ue;t[32]!==ce||t[33]!==S?(le=()=>{let e=C.current;if(e)return dm({root:e,resolveEditor:()=>D.current,isBlocked:()=>ce,onDismiss:()=>S(null)})},ue=[ce,S],t[32]=ce,t[33]=S,t[34]=le,t[35]=ue):(le=t[34],ue=t[35]),(0,J.useEffect)(le,ue);let de;t[36]===S?de=t[37]:(de=e=>{S(e),e&&oe(e)},t[36]=S,t[37]=de);let fe=de,pe;t[38]!==d||t[39]!==b?(pe=(e,t,n)=>{d(e,t,n),w.current!==null&&(cancelAnimationFrame(w.current),w.current=null),n!==`unmount`&&(w.current=requestAnimationFrame(()=>{w.current=null,e.isConnected&&t.setSelectedLines(b,{notify:!1})}))},t[38]=d,t[39]=b,t[40]=pe):pe=t[40];let P=pe,me;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(me={overscrollSize:600,intersectionObserverMargin:1200},t[41]=me):me=t[41];let he;t[42]!==s||t[43]!==r||t[44]!==i?(he=pm(r,i,s),t[42]=s,t[43]=r,t[44]=i,t[45]=he):he=t[45];let ge;t[46]!==s||t[47]!==i||t[48]!==he?(ge={name:i,contents:s,cacheKey:he},t[46]=s,t[47]=i,t[48]=he,t[49]=ge):ge=t[49];let F=!ce,_e=!ce,ve=u?`wrap`:`scroll`,ye;t[50]===c?ye=t[51]:(ye=Me(c),t[50]=c,t[51]=ye);let xe;t[52]!==fe||t[53]!==P||t[54]!==c||t[55]!==S||t[56]!==F||t[57]!==_e||t[58]!==ve||t[59]!==ye?(xe={disableFileHeader:!0,enableGutterUtility:F,enableLineSelection:_e,onGutterUtilityClick:S,onLineSelectionChange:S,onLineSelectionEnd:fe,overflow:ve,theme:ye,themeType:c,unsafeCSS:xm,onPostRender:P},t[52]=fe,t[53]=P,t[54]=c,t[55]=S,t[56]=F,t[57]=_e,t[58]=ve,t[59]=ye,t[60]=xe):xe=t[60];let Se;t[61]!==ne||t[62]!==ie?(Se=e=>(0,Y.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,Y.jsx)(at,{kind:e.kind,rangeLabel:R(e.startLine,e.endLine),text:e.text,onCancel:()=>ne(e.id),onComment:t=>ie(e.id,t),onDelete:()=>ne(e.id)},e.id))}),t[61]=ne,t[62]=ie,t[63]=Se):Se=t[63];let Ce;t[64]===ee?Ce=t[65]:(Ce={onChange:ee},t[64]=ee,t[65]=Ce);let we;return t[66]!==g||t[67]!==b||t[68]!==ge||t[69]!==xe||t[70]!==Se||t[71]!==Ce?(we=(0,Y.jsx)(be,{createEditor:A,children:(0,Y.jsx)(`div`,{ref:C,className:`flex min-h-0 flex-1`,children:(0,Y.jsx)(Ze,{className:`file-preview-virtualizer min-h-0 flex-1 overflow-auto`,config:me,children:(0,Y.jsx)(Jl,{file:ge,options:xe,selectedLines:b,lineAnnotations:g,renderAnnotation:Se,className:`min-h-full`,edit:!0,editorOptions:Ce})})})}),t[66]=g,t[67]=b,t[68]=ge,t[69]=xe,t[70]=Se,t[71]=Ce,t[72]=we):we=t[72],we}function jm(e){return e.metadata.entries.some(Mm)}function Mm(e){return e.kind===`draft`}function Nm(e){let t=e.metadata.entries.filter(Pm);return t.length>0?[{...e,metadata:{entries:t}}]:[]}function Pm(e){return e.kind!==`draft`}function Fm(e){return e.metadata.entries}function Im(e){return e.removeReviewComment}function Lm(e){return e.addReviewComment}function Rm(e){let t=(0,Yp.c)(17),{environmentId:n,cwd:r,relativePath:i,contents:a,threadRef:o,readOnly:s,onPendingChange:c}=e,l;t[0]!==r||t[1]!==n||t[2]!==c||t[3]!==i?(l={environmentId:n,cwd:r,relativePath:i,onPendingChange:c},t[0]=r,t[1]=n,t[2]=c,t[3]=i,t[4]=l):l=t[4];let u=km(l),d;t[5]!==a||t[6]!==r||t[7]!==n||t[8]!==s||t[9]!==i||t[10]!==u?(d=s?{}:{onTaskListChange:e=>{let{markerOffset:t,checked:o}=e,s=Xe(n,r,i)?.contents??a,c=gm(s,t,o);c!==s&&(Ne(n,r,i,c),u.change(c))}},t[5]=a,t[6]=r,t[7]=n,t[8]=s,t[9]=i,t[10]=u,t[11]=d):d=t[11];let f;return t[12]!==a||t[13]!==r||t[14]!==d||t[15]!==o?(f=(0,Y.jsx)(oe,{className:`min-h-0 flex-1`,children:(0,Y.jsx)(ne,{text:a,cwd:r,threadRef:o,className:`mx-auto max-w-4xl px-6 py-5`,...d})}),t[12]=a,t[13]=r,t[14]=d,t[15]=o,t[16]=f):f=t[16],f}function zm(){try{return x(vm,m)??!0}catch(e){return console.error(e),!0}}function Bm(e){let t=(0,Yp.c)(103),{environmentId:n,cwd:r,projectName:i,workspaceRoot:a,relativePath:u,absolutePath:p,isOutsideWorkspace:m,threadRef:h,composerDraftTarget:x,keybindings:C,availableEditors:k,revealLine:j,revealRequestId:M,onOpenFile:N,onPendingChange:ne}=e,{resolvedTheme:ie}=ee(),ae=ue(Hm),se=O(),ce=te(n),le;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(le={reportFailure:!1},t[0]=le):le=t[0];let de=Ee(re.createUrl,le),fe;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(fe={reportFailure:!1},t[1]=fe):fe=t[1];let pe=A(E.open,fe),P=n===se,me;t[2]===u?me=t[3]:(me=u!==null&&T(u),t[2]=u,t[3]=me);let ge=me,F=Ge(n,r,u,!ge,p),[_e,ve]=(0,J.useState)(zm),[ye,be]=(0,J.useState)(!1),xe;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(xe={path:null,revealRequestId:null},t[4]=xe):xe=t[4];let[Se,Ce]=(0,J.useState)(xe),we=(0,J.useRef)(null),De;t[5]===u?De=t[6]:(De=u?hm(u):!1,t[5]=u,t[6]=De);let Oe=De,ke=Oe&&Se.path===u&&(j===null||Se.revealRequestId===M),Ae;t[7]===u?Ae=t[8]:(Ae=u!==null&&s()&&Fe(u),t[7]=u,t[8]=Ae);let je=Ae,Ne;t[9]!==r||t[10]!==p||t[11]!==u?(Ne=p??(u?y(u,r):null),t[9]=r,t[10]=p,t[11]=u,t[12]=Ne):Ne=t[12];let Pe=Ne,Ie;t[13]!==Pe||t[14]!==P||t[15]!==h.threadId||t[16]!==a?(Ie=Pe===null?null:w({filePath:Pe,threadId:h.threadId,workspaceRoot:a,allowLocalFiles:P}),t[13]=Pe,t[14]=P,t[15]=h.threadId,t[16]=a,t[17]=Ie):Ie=t[17];let Le=Ie,Re;t[18]!==r||t[19]!==m||t[20]!==i||t[21]!==u?(Re=u?mm(m?r:i,u):[],t[18]=r,t[19]=m,t[20]=i,t[21]=u,t[22]=Re):Re=t[22];let ze=Re,Ve=Tm(u,j,M),He;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(He=()=>{(we.current?.querySelector(`[data-current-file-crumb='true']`))?.scrollIntoView({block:`nearest`,inline:`end`})},t[23]=He):He=t[23];let We;t[24]===u?We=t[25]:(We=[u],t[24]=u,t[25]=We),(0,J.useEffect)(He,We);let Ke;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=()=>{ve(Vm)},t[26]=Ke):Ke=t[26];let Xe=Ke,Qe;t[27]!==Pe||t[28]!==P||t[29]!==de||t[30]!==ce||t[31]!==pe||t[32]!==ie||t[33]!==h||t[34]!==a?(Qe=()=>{!Pe||!ce||(async()=>{let e=await Ye({threadRef:h,filePath:Pe,httpBaseUrl:ce,workspaceRoot:a,allowLocalFiles:P,theme:ie,createAssetUrl:de,openPreview:pe});if(e._tag===`Success`||o(e))return;let t=S(e);g.add(_({type:`error`,title:`Unable to open file in browser`,description:t instanceof Error?t.message:`An error occurred.`}))})()},t[27]=Pe,t[28]=P,t[29]=de,t[30]=ce,t[31]=pe,t[32]=ie,t[33]=h,t[34]=a,t[35]=Qe):Qe=t[35];let $e=Qe,et;t[36]!==Pe||t[37]!==P||t[38]!==k||t[39]!==x||t[40]!==r||t[41]!==n||t[42]!==F||t[43]!==Le||t[44]!==ge||t[45]!==Oe||t[46]!==m||t[47]!==C||t[48]!==Ve||t[49]!==ne||t[50]!==u||t[51]!==ke||t[52]!==ie||t[53]!==M||t[54]!==h||t[55]!==ae?(et=u&&ge&&Le?(0,Y.jsx)(Sm,{environmentId:n,resource:Le,alt:u},Pe??u):u&&F.error&&F.data===null?(0,Y.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:F.error}):u&&F.data===null?(0,Y.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,Y.jsx)(d,{className:`size-5 animate-spin`})}):u&&F.data?F.data.binary&&Pe?(0,Y.jsx)(om,{environmentId:n,keybindings:C,availableEditors:k,absolutePath:Pe,name:u.slice(u.lastIndexOf(`/`)+1),byteLength:F.data.byteLength,canRevealInFileManager:P&&c()}):Oe&&ke?(0,Y.jsx)(Rm,{environmentId:n,cwd:r,relativePath:u,threadRef:h,contents:F.data.contents,readOnly:m,onPendingChange:ne}):F.data.truncated||m?(0,Y.jsx)(Ze,{className:`file-preview-virtualizer min-h-0 flex-1 overflow-auto`,config:{overscrollSize:600,intersectionObserverMargin:1200},children:(0,Y.jsx)(Jl,{file:{name:u,contents:F.data.contents,cacheKey:pm(r,u,F.data.contents)},options:{disableFileHeader:!0,overflow:ae?`wrap`:`scroll`,theme:Me(ie),themeType:ie,unsafeCSS:xm,onPostRender:Ve},className:`min-h-full`})},`${u}:${ie}:${F.data.byteLength}`):(0,Y.jsx)(Am,{environmentId:n,cwd:r,relativePath:u,composerDraftTarget:x,contents:F.data.contents,resolvedTheme:ie,revealRequestId:M,wordWrap:ae,onPostRender:Ve,onPendingChange:ne},`${u}:${ie}`):null,t[36]=Pe,t[37]=P,t[38]=k,t[39]=x,t[40]=r,t[41]=n,t[42]=F,t[43]=Le,t[44]=ge,t[45]=Oe,t[46]=m,t[47]=C,t[48]=Ve,t[49]=ne,t[50]=u,t[51]=ke,t[52]=ie,t[53]=M,t[54]=h,t[55]=ae,t[56]=et):et=t[56];let tt=et,nt;t[57]!==Pe||t[58]!==k||t[59]!==ze||t[60]!==je||t[61]!==n||t[62]!==ye||t[63]!==_e||t[64]!==$e||t[65]!==Oe||t[66]!==C||t[67]!==se||t[68]!==i||t[69]!==u||t[70]!==ke||t[71]!==M?(nt=u?(0,Y.jsxs)(`div`,{className:`surface-subheader gap-2 px-3`,"data-surface-subheader":!0,children:[(0,Y.jsx)(oe,{ref:we,hideScrollbars:!0,scrollFade:!0,className:`min-w-0 flex-1 rounded-none`,"data-file-breadcrumbs":!0,children:(0,Y.jsx)(`div`,{className:`flex h-full w-max min-w-full items-center text-xs`,children:ze.map((e,t)=>(0,Y.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center`,"data-current-file-crumb":e.kind===`file`,children:[t>0?(0,Y.jsx)(f,{className:`mx-1 size-3.5 shrink-0 text-muted-foreground/60`}):null,(0,Y.jsx)(`span`,{className:l(`max-w-40 truncate`,e.kind===`file`?`font-medium text-foreground`:`text-muted-foreground`),title:e.path||i,children:e.label})]},e.path||`project`))})}),Pe&&n===se?(0,Y.jsx)(Ue,{environmentId:n,keybindings:C,availableEditors:k,openInCwd:Pe,compact:!0,enableShortcut:!1}):null,Oe?(0,Y.jsxs)(b,{children:[(0,Y.jsx)(D,{render:(0,Y.jsx)(Te,{className:`shrink-0`,pressed:ke,onPressedChange:e=>{Ce({path:e?u:null,revealRequestId:e?M:null})},"aria-label":ke?`Show markdown source`:`Show rendered markdown`,variant:`ghost`,size:`sm`,children:ke?(0,Y.jsx)(Be,{className:`size-3.5`}):(0,Y.jsx)(Je,{className:`size-3.5`})})}),(0,Y.jsx)(v,{children:ke?`Show markdown source`:`Show rendered markdown`})]}):null,je?(0,Y.jsxs)(b,{children:[(0,Y.jsx)(D,{render:(0,Y.jsx)(Te,{className:`shrink-0`,pressed:!1,onPressedChange:$e,"aria-label":`Open file in preview browser`,variant:`ghost`,size:`sm`,children:(0,Y.jsx)(qe,{className:`size-3.5`})})}),(0,Y.jsx)(v,{children:`Open file in preview browser`})]}):null,(0,Y.jsxs)(b,{children:[(0,Y.jsx)(D,{render:(0,Y.jsx)(Te,{className:`shrink-0`,pressed:ye,onPressedChange:be,"aria-label":ye?`Collapse file preview`:`Expand file preview`,variant:`ghost`,size:`sm`,children:ye?(0,Y.jsx)(he,{className:`size-3.5`}):(0,Y.jsx)(I,{className:`size-3.5`})})}),(0,Y.jsx)(v,{children:ye?`Collapse file preview`:`Expand file preview`})]}),(0,Y.jsxs)(b,{children:[(0,Y.jsx)(D,{render:(0,Y.jsx)(Te,{className:`shrink-0`,pressed:_e,onPressedChange:Xe,"aria-label":_e?`Hide file explorer`:`Show file explorer`,variant:`ghost`,size:`sm`,children:(0,Y.jsx)(lt,{className:`size-3.5`})})}),(0,Y.jsx)(v,{children:_e?`Hide file explorer`:`Show file explorer`})]})]}):null,t[57]=Pe,t[58]=k,t[59]=ze,t[60]=je,t[61]=n,t[62]=ye,t[63]=_e,t[64]=$e,t[65]=Oe,t[66]=C,t[67]=se,t[68]=i,t[69]=u,t[70]=ke,t[71]=M,t[72]=nt):nt=t[72];let rt;t[73]!==F||t[74]!==u?(rt=u&&F.data?.truncated?(0,Y.jsxs)(`div`,{className:`shrink-0 border-b border-amber-500/20 bg-amber-500/8 px-3 py-1.5 text-[11px] text-amber-700 dark:text-amber-300`,children:[`Preview limited to the first 1 MB of a `,F.data.byteLength.toLocaleString(),` byte file.`]}):null,t[73]=F,t[74]=u,t[75]=rt):rt=t[75];let it=u?`flex`:`hidden`,at;t[76]===it?at=t[77]:(at=l(`min-w-0 flex-1 flex-col overflow-hidden`,it),t[76]=it,t[77]=at);let ot;t[78]!==ye||t[79]!==tt?(ot=ye?(0,Y.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs text-muted-foreground`,children:`Shown in the expanded view.`}):tt,t[78]=ye,t[79]=tt,t[80]=ot):ot=t[80];let st;t[81]!==at||t[82]!==ot?(st=(0,Y.jsx)(`div`,{className:at,children:ot}),t[81]=at,t[82]=ot,t[83]=st):st=t[83];let L;t[84]!==r||t[85]!==n||t[86]!==_e||t[87]!==N||t[88]!==i||t[89]!==u?(L=_e||u===null?(0,Y.jsx)(`aside`,{className:l(`flex min-h-0 shrink-0 bg-background`,u?`w-[min(22rem,46%)] min-w-64 border-l border-border/60`:`min-w-0 flex-1`),children:(0,Y.jsx)(em,{environmentId:n,cwd:r,projectName:i,onOpenFile:N},`${n}:${r}`)}):null,t[84]=r,t[85]=n,t[86]=_e,t[87]=N,t[88]=i,t[89]=u,t[90]=L):L=t[90];let R;t[91]!==st||t[92]!==L?(R=(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[st,L]}),t[91]=st,t[92]=L,t[93]=R):R=t[93];let ct=ye&&u!==null,ut=u??``,dt;t[94]!==tt||t[95]!==ct||t[96]!==ut?(dt=(0,Y.jsx)(tm,{open:ct,title:ut,onOpenChange:be,children:tt}),t[94]=tt,t[95]=ct,t[96]=ut,t[97]=dt):dt=t[97];let ft;return t[98]!==nt||t[99]!==rt||t[100]!==R||t[101]!==dt?(ft=(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[nt,rt,R,dt]}),t[98]=nt,t[99]=rt,t[100]=R,t[101]=dt,t[102]=ft):ft=t[102],ft}function Vm(e){let t=!e;try{h(vm,t,m)}catch(e){console.error(e)}return t}function Hm(e){return e.wordWrap}export{Bm as default};
2230
- //# sourceMappingURL=FilePreviewPanel-BApM9eUh.js.map
2230
+ //# sourceMappingURL=FilePreviewPanel-OQEQEdrB.js.map
@@ -1,2 +1,2 @@
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,Bu as s,Da as c,Df as l,Ea as u,G as d,Gl as f,Hl as p,J as m,K as h,Ma as g,Na as _,Oa as v,Pa as y,Q as b,Qc as x,Ta as S,Tf as C,Ul as w,V 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-JdwqlhCI.js";import{t as oe}from"./arrow-right-Bu5WkIYh.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-BL9HZoA_.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:c,nativePictureInPicture:l,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,h;t[2]===i?h=t[3]:(h=Math.round(i*100),t[2]=i,t[3]=h);let y=`${h}%`,b;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsxs)(te,{children:[(0,$.jsx)(B,{render:(0,$.jsx)(_,{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=l?`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]!==c||t[20]!==ee||t[21]!==f?(A=(0,$.jsx)(V,{onClick:c,disabled:f,children:ee}),t[19]=c,t[20]=ee,t[21]=f,t[22]=A):A=t[22];let j;t[23]===f?j=t[24]:(j=(0,$.jsx)(g,{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)(u,{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)(v,{}),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)(v,{}),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)(c,{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 l()(`PreviewSessionThreadKeyParseError`,{threadKey:C}){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 p(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=h(t).serverEpoch;if(i!==null&&i!==r.value.serverEpoch){e.refresh(n);return}T(t,r.value)};e.addFinalizer(()=>{i=!0});let c=e.once(r);e.subscribe(n,e=>{o(e)}),e.subscribe(r,e=>{a+=1,s(e)}),queueMicrotask(()=>{i||(e.refresh(n),a===0&&s(c))})}).pipe(w(1e3),f(`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,c]=(0,Q.useState)(!1),l=Me(),u=(0,Q.useRef)(!1),d=(0,Q.useRef)(!0),f=b(e),p=ke(t=>q(t.byThreadKey,e)),h=U(e=>e.addPreviewAnnotation),g=U(e=>e.addImage),_=ee(e.environmentId),v=ae(e.environmentId),y=W(z.open),x=W(z.resize,`preview viewport resize`),{resolvedTheme:S}=H();Ot(e),(0,Q.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);let C=t??f.activeTabId,w=C?ue(e,f.serverEpoch,C):null,T=C&&w?l.has(w)?w:Pe(e,C):null,D=C?f.sessions[C]??null:null,O=C?f.desktopByTabId[C]??null:null;(0,Q.useEffect)(()=>{let e=X;if(!(!e||!w||!O?.pictureInPicture))return e.pictureInPicture.setVisible(w,r),()=>{e.pictureInPicture.setVisible(w,!1)}},[O?.pictureInPicture,w,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&&_&&v?Ke({url:j,environmentLabel:_.label,environmentHttpBaseUrl:v})??void 0:void 0,G=D?.viewport??s,K=me(e=>w?e.byTabId[w]?.rect??null:null),J=(0,Q.useCallback)(async t=>{w&&X?(await X.navigate(w,t),m(e,t)):await Re({openPreview:y,threadRef:e,url:t})},[y,w,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&&w&&X.refresh(w)},[w]),pe=(0,Q.useCallback)(()=>{X&&w&&X.zoomIn(w)},[w]),he=(0,Q.useCallback)(()=>{X&&w&&X.zoomOut(w)},[w]),_e=(0,Q.useCallback)(()=>{X&&w&&X.resetZoom(w)},[w]),ve=(0,Q.useCallback)(async t=>{if(!C)return;let n=await x({environmentId:e.environmentId,input:{threadId:e.threadId,tabId:C,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)},[x,C,e]),ye=()=>{if(!w)return;if(G._tag!==`fill`){Ie(w,s).catch(()=>void 0);return}let e=K?Fe(K,O?.zoomFactor):{width:1024,height:768};Ie(w,{_tag:`freeform`,...e}).catch(()=>void 0)};(0,Q.useEffect)(()=>{if(w)return Ae(w,ve)},[ve,w]);let be=(0,Q.useCallback)(()=>{X&&w&&X.goBack(w)},[w]),xe=(0,Q.useCallback)(()=>{X&&w&&X.goForward(w)},[w]),Se=(0,Q.useCallback)(()=>{!It||!j||It.shell.openExternal(j).catch(()=>void 0)},[j]),we=(0,Q.useCallback)(()=>{if(C){if(p?.tabId===C){ke.getState().close(e);return}ke.getState().open(e,C),re.getState().close(e)}},[p?.tabId,C,e]),Te=(0,Q.useCallback)(()=>{!X||!w||(O?.pictureInPicture?X.pictureInPicture.close:X.pictureInPicture.open)(w).catch(e=>{A.add({type:`error`,title:`Unable to update popped-out preview`,description:e instanceof Error?e.message:`An error occurred.`})})},[O?.pictureInPicture,w]),Ee=(0,Q.useCallback)(t=>{if(!X||!w||!C)return;let n=X;if(T){Ce(T).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(w,e,C).catch(e=>{A.add({type:`error`,title:`Unable to start recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}n.captureScreenshot(w).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.`})})},[T,w,C,e]),je=(0,Q.useCallback)(()=>{if(!X||!w)return;if(u.current){X.cancelPickElement(w).catch(()=>void 0);return}let t=typeof document<`u`?document.activeElement:null;u.current=!0,c(!0),(async()=>{try{let t=await X.pickElement(w);if(!t)return;h(e,t);let n=await De(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(u.current=!1,d.current&&c(!1),t&&t.isConnected&&typeof t.focus==`function`)try{t.focus({preventScroll:!0})}catch{}}})()},[g,h,w,e]);return(0,Q.useEffect)(()=>{let e=ie(j,S);e&&J(e).catch(()=>void 0)},[J,S,j]),(0,Q.useEffect)(()=>()=>{u.current&&(u.current=!1,X&&w&&X.cancelPickElement(w).catch(()=>void 0),d.current&&c(!1))},[w]),(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:C?Se:void 0,onCapture:X&&C?Ee:void 0,captureDisabled:!O||L,recording:T!==null,onPictureInPicture:X&&C?we:void 0,pictureInPicture:p?.tabId===C,pictureInPictureDisabled:!O?.hasWebContents||L,onPickElement:X&&C?je:void 0,pickActive:o,pickDisabled:!C||L,pickDisabledReason:L?`Page didn't load — pick unavailable until the page renders`:void 0,trailingActions:X?(0,$.jsx)(it,{tabId:w,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:[w&&D&&!R?(0,$.jsx)(de,{tabId:w,visible:r&&!L,className:`absolute inset-0 h-full w-full`},w):null,R?(0,$.jsx)(nt,{environmentId:e.environmentId,configuredUrls:n,recentlySeenUrls:f.recentlySeenUrls,onOpenUrl:e=>void ce(e)}):null,D&&O?(0,$.jsx)(jt,{zoomFactor:O.zoomFactor}):null,w&&O&&!R&&!L?(0,$.jsx)(Pt,{tabId:w,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(!d()){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-BgNZspAX.js.map
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,Bu as s,Da as c,Df as l,Ea as u,G as d,Gl as f,Hl as p,J as m,K as h,Ma as g,Na as _,Oa as v,Pa as y,Q as b,Qc as x,Ta as S,Tf as C,Ul as w,V 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-JdwqlhCI.js";import{t as oe}from"./arrow-right-Bu5WkIYh.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-IA1MLjyL.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:c,nativePictureInPicture:l,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,h;t[2]===i?h=t[3]:(h=Math.round(i*100),t[2]=i,t[3]=h);let y=`${h}%`,b;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsxs)(te,{children:[(0,$.jsx)(B,{render:(0,$.jsx)(_,{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=l?`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]!==c||t[20]!==ee||t[21]!==f?(A=(0,$.jsx)(V,{onClick:c,disabled:f,children:ee}),t[19]=c,t[20]=ee,t[21]=f,t[22]=A):A=t[22];let j;t[23]===f?j=t[24]:(j=(0,$.jsx)(g,{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)(u,{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)(v,{}),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)(v,{}),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)(c,{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 l()(`PreviewSessionThreadKeyParseError`,{threadKey:C}){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 p(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=h(t).serverEpoch;if(i!==null&&i!==r.value.serverEpoch){e.refresh(n);return}T(t,r.value)};e.addFinalizer(()=>{i=!0});let c=e.once(r);e.subscribe(n,e=>{o(e)}),e.subscribe(r,e=>{a+=1,s(e)}),queueMicrotask(()=>{i||(e.refresh(n),a===0&&s(c))})}).pipe(w(1e3),f(`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,c]=(0,Q.useState)(!1),l=Me(),u=(0,Q.useRef)(!1),d=(0,Q.useRef)(!0),f=b(e),p=ke(t=>q(t.byThreadKey,e)),h=U(e=>e.addPreviewAnnotation),g=U(e=>e.addImage),_=ee(e.environmentId),v=ae(e.environmentId),y=W(z.open),x=W(z.resize,`preview viewport resize`),{resolvedTheme:S}=H();Ot(e),(0,Q.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);let C=t??f.activeTabId,w=C?ue(e,f.serverEpoch,C):null,T=C&&w?l.has(w)?w:Pe(e,C):null,D=C?f.sessions[C]??null:null,O=C?f.desktopByTabId[C]??null:null;(0,Q.useEffect)(()=>{let e=X;if(!(!e||!w||!O?.pictureInPicture))return e.pictureInPicture.setVisible(w,r),()=>{e.pictureInPicture.setVisible(w,!1)}},[O?.pictureInPicture,w,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&&_&&v?Ke({url:j,environmentLabel:_.label,environmentHttpBaseUrl:v})??void 0:void 0,G=D?.viewport??s,K=me(e=>w?e.byTabId[w]?.rect??null:null),J=(0,Q.useCallback)(async t=>{w&&X?(await X.navigate(w,t),m(e,t)):await Re({openPreview:y,threadRef:e,url:t})},[y,w,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&&w&&X.refresh(w)},[w]),pe=(0,Q.useCallback)(()=>{X&&w&&X.zoomIn(w)},[w]),he=(0,Q.useCallback)(()=>{X&&w&&X.zoomOut(w)},[w]),_e=(0,Q.useCallback)(()=>{X&&w&&X.resetZoom(w)},[w]),ve=(0,Q.useCallback)(async t=>{if(!C)return;let n=await x({environmentId:e.environmentId,input:{threadId:e.threadId,tabId:C,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)},[x,C,e]),ye=()=>{if(!w)return;if(G._tag!==`fill`){Ie(w,s).catch(()=>void 0);return}let e=K?Fe(K,O?.zoomFactor):{width:1024,height:768};Ie(w,{_tag:`freeform`,...e}).catch(()=>void 0)};(0,Q.useEffect)(()=>{if(w)return Ae(w,ve)},[ve,w]);let be=(0,Q.useCallback)(()=>{X&&w&&X.goBack(w)},[w]),xe=(0,Q.useCallback)(()=>{X&&w&&X.goForward(w)},[w]),Se=(0,Q.useCallback)(()=>{!It||!j||It.shell.openExternal(j).catch(()=>void 0)},[j]),we=(0,Q.useCallback)(()=>{if(C){if(p?.tabId===C){ke.getState().close(e);return}ke.getState().open(e,C),re.getState().close(e)}},[p?.tabId,C,e]),Te=(0,Q.useCallback)(()=>{!X||!w||(O?.pictureInPicture?X.pictureInPicture.close:X.pictureInPicture.open)(w).catch(e=>{A.add({type:`error`,title:`Unable to update popped-out preview`,description:e instanceof Error?e.message:`An error occurred.`})})},[O?.pictureInPicture,w]),Ee=(0,Q.useCallback)(t=>{if(!X||!w||!C)return;let n=X;if(T){Ce(T).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(w,e,C).catch(e=>{A.add({type:`error`,title:`Unable to start recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}n.captureScreenshot(w).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.`})})},[T,w,C,e]),je=(0,Q.useCallback)(()=>{if(!X||!w)return;if(u.current){X.cancelPickElement(w).catch(()=>void 0);return}let t=typeof document<`u`?document.activeElement:null;u.current=!0,c(!0),(async()=>{try{let t=await X.pickElement(w);if(!t)return;h(e,t);let n=await De(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(u.current=!1,d.current&&c(!1),t&&t.isConnected&&typeof t.focus==`function`)try{t.focus({preventScroll:!0})}catch{}}})()},[g,h,w,e]);return(0,Q.useEffect)(()=>{let e=ie(j,S);e&&J(e).catch(()=>void 0)},[J,S,j]),(0,Q.useEffect)(()=>()=>{u.current&&(u.current=!1,X&&w&&X.cancelPickElement(w).catch(()=>void 0),d.current&&c(!1))},[w]),(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:C?Se:void 0,onCapture:X&&C?Ee:void 0,captureDisabled:!O||L,recording:T!==null,onPictureInPicture:X&&C?we:void 0,pictureInPicture:p?.tabId===C,pictureInPictureDisabled:!O?.hasWebContents||L,onPickElement:X&&C?je:void 0,pickActive:o,pickDisabled:!C||L,pickDisabledReason:L?`Page didn't load — pick unavailable until the page renders`:void 0,trailingActions:X?(0,$.jsx)(it,{tabId:w,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:[w&&D&&!R?(0,$.jsx)(de,{tabId:w,visible:r&&!L,className:`absolute inset-0 h-full w-full`},w):null,R?(0,$.jsx)(nt,{environmentId:e.environmentId,configuredUrls:n,recentlySeenUrls:f.recentlySeenUrls,onOpenUrl:e=>void ce(e)}):null,D&&O?(0,$.jsx)(jt,{zoomFactor:O.zoomFactor}):null,w&&O&&!R&&!L?(0,$.jsx)(Pt,{tabId:w,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(!d()){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-CwhD6R8I.js.map