@av-pi-studio/web-client 0.0.89 → 0.0.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. package/dist/web/assets/{BinaryFallbackViewer-C5mL51vj.js → BinaryFallbackViewer-lvGSRI8m.js} +1 -1
  2. package/dist/web/assets/{ChatPanel-o1LQTTPg.js → ChatPanel-dNQvYFah.js} +1 -1
  3. package/dist/web/assets/{CodeView-DWNPh5RV.js → CodeView-GqSGzzdY.js} +1 -1
  4. package/dist/web/assets/{FilePanel-WBjvhtIF.js → FilePanel-CiEL9P07.js} +1 -1
  5. package/dist/web/assets/{HtmlViewer-C1BVt6Jc.js → HtmlViewer-DhHisgo0.js} +1 -1
  6. package/dist/web/assets/{ImageViewer-h9C9D8v9.js → ImageViewer-DBf1slSX.js} +1 -1
  7. package/dist/web/assets/{MarkdownFileViewer-BQeO16YO.js → MarkdownFileViewer-ConompLL.js} +1 -1
  8. package/dist/web/assets/{MoleculeViewerPanel-DfwAiUFo.js → MoleculeViewerPanel-t2xCBXAO.js} +1 -1
  9. package/dist/web/assets/{TerminalPanel-3Xef8_VS.js → TerminalPanel-DLFQvU4h.js} +1 -1
  10. package/dist/web/assets/{TextViewer-DQlVqrhS.js → TextViewer-BKC2bW7m.js} +1 -1
  11. package/dist/web/assets/{VideoViewer-CUwy7vap.js → VideoViewer-CGpLyjak.js} +1 -1
  12. package/dist/web/assets/{href-resolution-Bu3Ezb0Z.js → href-resolution-Djd1Zdrz.js} +1 -1
  13. package/dist/web/assets/{index-CRcOAGBq.js → index-CWQ7GUFk.js} +3 -3
  14. package/dist/web/assets/markdown-Bbsr2xVg.js +5 -0
  15. package/dist/web/assets/markdown-C15eCO0s.css +1 -0
  16. package/dist/web/assets/{use-file-download-C5RZM273.js → use-file-download-zBrxUX0K.js} +1 -1
  17. package/dist/web/assets/{use-file-watch-C6t0UJSi.js → use-file-watch-BLigZDy5.js} +1 -1
  18. package/dist/web/index.html +1 -1
  19. package/package.json +3 -3
  20. package/dist/web/assets/markdown-DEMXo8TU.css +0 -1
  21. package/dist/web/assets/markdown-S4LuDRgo.js +0 -5
@@ -1 +1 @@
1
- import{r as l,j as e}from"./vendor-react-DQUAl2K8.js";import{S as d,B as a}from"./index-CRcOAGBq.js";import{u as m}from"./use-file-download-C5RZM273.js";import{F as c}from"./vendor-icons-CQPWxe0u.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-DVp0ZLQo.js";import"./vendor-overlays-BfyojyuH.js";import"./vendor-dnd-CayJj8TC.js";const p="_wrap_inn1j_1",j="_name_inn1j_12",n={wrap:p,name:j};function z({path:s,workspaceCwd:f}){const[i,t]=l.useState(!1),r=m(s,i),o=s.split("/").pop()||s;return e.jsxs("div",{className:n.wrap,children:[e.jsx(c,{size:32}),e.jsx("div",{className:n.name,children:o}),e.jsx("div",{children:"No preview available for this file type."}),r.isError&&e.jsxs("div",{children:["Error: ",r.error instanceof Error?r.error.message:"download failed"]}),i&&r.isLoading?e.jsx(d,{size:"sm"}):r.data?e.jsx("a",{href:r.data.objectUrl,download:r.data.fileName||o,children:e.jsx(a,{size:"sm",children:"Save file"})}):e.jsx(a,{size:"sm",onClick:()=>t(!0),children:"Download"})]})}export{z as BinaryFallbackViewer};
1
+ import{r as l,j as e}from"./vendor-react-DQUAl2K8.js";import{S as d,B as a}from"./index-CWQ7GUFk.js";import{u as m}from"./use-file-download-zBrxUX0K.js";import{F as c}from"./vendor-icons-CQPWxe0u.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-DVp0ZLQo.js";import"./vendor-overlays-BfyojyuH.js";import"./vendor-dnd-CayJj8TC.js";const p="_wrap_inn1j_1",j="_name_inn1j_12",n={wrap:p,name:j};function z({path:s,workspaceCwd:f}){const[i,t]=l.useState(!1),r=m(s,i),o=s.split("/").pop()||s;return e.jsxs("div",{className:n.wrap,children:[e.jsx(c,{size:32}),e.jsx("div",{className:n.name,children:o}),e.jsx("div",{children:"No preview available for this file type."}),r.isError&&e.jsxs("div",{children:["Error: ",r.error instanceof Error?r.error.message:"download failed"]}),i&&r.isLoading?e.jsx(d,{size:"sm"}):r.data?e.jsx("a",{href:r.data.objectUrl,download:r.data.fileName||o,children:e.jsx(a,{size:"sm",children:"Save file"})}):e.jsx(a,{size:"sm",onClick:()=>t(!0),children:"Download"})]})}export{z as BinaryFallbackViewer};
@@ -1,4 +1,4 @@
1
- import{r as g,j as t}from"./vendor-react-DQUAl2K8.js";import{a as Pe,b as Oe,m as Me,u as me}from"./vendor-query-i7fr__Xm.js";import{y as Q,z as R,u as $,I as z,S as X,w as ze,D as Le,k as Fe,n as He,A as V,a as pe,M as fe,T as Ke,B as H,x as $e,P as le}from"./index-CRcOAGBq.js";import{L as Ue,G as We,S as qe,a as Ge,P as Je,E as Qe,T as he,B as Ve,b as Xe,C as Ye,A as Ze,c as et,U as tt,d as nt,e as st,f as ot,g as at,h as rt,i as it,j as lt,N as ct,k as dt}from"./vendor-icons-CQPWxe0u.js";import{S as _e,M as ge,r as ut}from"./markdown-S4LuDRgo.js";import{M as D}from"./vendor-DVp0ZLQo.js";import{D as mt,p as pt}from"./DiffView-CRrnffpG.js";import{R as xe,T as be,I as ft}from"./vendor-overlays-BfyojyuH.js";import"./vendor-dnd-CayJj8TC.js";import"./vendor-highlight-BjiGXuEM.js";import"./vendor-markdown-Bc_dOmsB.js";import"./href-resolution-Bu3Ezb0Z.js";function ve(e,n){if(n.trim()==="")return e;const s=n.toLowerCase();return e.filter(o=>o.label.toLowerCase().includes(s)||o.description!==void 0&&o.description.toLowerCase().includes(s))}const ht={shell:he,read:Qe,edit:Je,write:Ge,search:qe,fetch:We,task:Ue};function _t(e){return ht[e.kind]??he}function ye(e){switch(e.kind){case"read":case"write":case"edit":return e.path??null;default:return null}}function gt(e){return e.kind==="write"||e.kind==="edit"||e.kind==="shell"}function xt(e){const n=[];if(e.kind==="edit"&&e.diff)n.push({kind:"diff",patch:e.diff});else{const s=Q(e);s&&n.push({kind:"code",text:s})}return e.output&&n.push({kind:"code",text:e.output}),n}const ce={shell:{label:"SHELL",token:"statusInfo"},read:{label:"READ",token:"statusInfo"},write:{label:"WRITE",token:"statusSuccess"},edit:{label:"EDIT",token:"statusWarning"},search:{label:"SEARCH",token:"statusInfo"},fetch:{label:"FETCH",token:"statusInfo"},task:{label:"TASK",token:"foregroundMuted"}};function bt(e){return ce[e.kind]??ce.task}function vt(e){if(!e)return{added:0,removed:0};let n=0,s=0;for(const o of e.split(`
1
+ import{r as g,j as t}from"./vendor-react-DQUAl2K8.js";import{a as Pe,b as Oe,m as Me,u as me}from"./vendor-query-i7fr__Xm.js";import{y as Q,z as R,u as $,I as z,S as X,w as ze,D as Le,k as Fe,n as He,A as V,a as pe,M as fe,T as Ke,B as H,x as $e,P as le}from"./index-CWQ7GUFk.js";import{L as Ue,G as We,S as qe,a as Ge,P as Je,E as Qe,T as he,B as Ve,b as Xe,C as Ye,A as Ze,c as et,U as tt,d as nt,e as st,f as ot,g as at,h as rt,i as it,j as lt,N as ct,k as dt}from"./vendor-icons-CQPWxe0u.js";import{S as _e,M as ge,r as ut}from"./markdown-Bbsr2xVg.js";import{M as D}from"./vendor-DVp0ZLQo.js";import{D as mt,p as pt}from"./DiffView-CRrnffpG.js";import{R as xe,T as be,I as ft}from"./vendor-overlays-BfyojyuH.js";import"./vendor-dnd-CayJj8TC.js";import"./vendor-highlight-BjiGXuEM.js";import"./vendor-markdown-Bc_dOmsB.js";import"./href-resolution-Djd1Zdrz.js";function ve(e,n){if(n.trim()==="")return e;const s=n.toLowerCase();return e.filter(o=>o.label.toLowerCase().includes(s)||o.description!==void 0&&o.description.toLowerCase().includes(s))}const ht={shell:he,read:Qe,edit:Je,write:Ge,search:qe,fetch:We,task:Ue};function _t(e){return ht[e.kind]??he}function ye(e){switch(e.kind){case"read":case"write":case"edit":return e.path??null;default:return null}}function gt(e){return e.kind==="write"||e.kind==="edit"||e.kind==="shell"}function xt(e){const n=[];if(e.kind==="edit"&&e.diff)n.push({kind:"diff",patch:e.diff});else{const s=Q(e);s&&n.push({kind:"code",text:s})}return e.output&&n.push({kind:"code",text:e.output}),n}const ce={shell:{label:"SHELL",token:"statusInfo"},read:{label:"READ",token:"statusInfo"},write:{label:"WRITE",token:"statusSuccess"},edit:{label:"EDIT",token:"statusWarning"},search:{label:"SEARCH",token:"statusInfo"},fetch:{label:"FETCH",token:"statusInfo"},task:{label:"TASK",token:"foregroundMuted"}};function bt(e){return ce[e.kind]??ce.task}function vt(e){if(!e)return{added:0,removed:0};let n=0,s=0;for(const o of e.split(`
2
2
  `))o.startsWith("+++")||o.startsWith("---")||(o.startsWith("+")?n++:o.startsWith("-")&&s++);return{added:n,removed:s}}function yt(e){return e?(e.endsWith(`
3
3
  `)?e.slice(0,-1):e).split(`
4
4
  `).length:0}const jt=500;let W;function kt(e,n,s,o){clearTimeout(W),W=setTimeout(()=>{W=void 0,e.invalidateQueries({queryKey:["file"]}),e.invalidateQueries({queryKey:["explorer"]}),n&&s&&n.connection.request("checkout_refresh_request",{cwd:s}).catch(()=>{})},jt)}function St({sessionId:e,event:n,timestamp:s,client:o,queryClient:r}){const i=R.getState();switch(i.applyStreamEvent(e,n,s),n.kind){case"turn_started":i.setStatus(e,"running");break;case"turn_completed":i.setStatus(e,"idle");break;case"turn_failed":i.setStatus(e,"error");break;case"turn_canceled":i.setStatus(e,"idle");break;case"tool_call":{if(n.status==="completed"&&gt(n.tool)){const c=i.sessions[e],d=(c==null?void 0:c.cwd)||null;kt(r,o,d,ye(n.tool))}break}}}function Nt(e){const n=$(r=>r.client),s=R(r=>{var i;return((i=r.sessions[e])==null?void 0:i.agentId)??null}),o=Pe();g.useEffect(()=>!n||!s?void 0:n.agent(s).timeline.subscribe((i,c)=>{const d=typeof c.timestamp=="number"?new Date(c.timestamp).toISOString():c.timestamp;St({sessionId:e,event:i,timestamp:d,client:n,queryClient:o})}),[n,s,e,o])}const je=64;function q(e){return e.clientHeight>0}function Ct(e,n,s,o=je){switch(n.kind){case"scroll":return q(s)?s.scrollHeight-s.scrollTop-s.clientHeight<=o?{pinned:!0,stick:!1}:{pinned:n.gesture?!1:e,stick:!1}:{pinned:e,stick:!1};case"tail":return{pinned:e,stick:e&&q(s)};case"shown":return{pinned:e,stick:e};case"pin":return{pinned:!0,stick:q(s)}}}function Dt(e){const n=e[e.length-1];return(n==null?void 0:n.kind)==="user"?n.id:null}const wt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function de(e){return String(e).padStart(2,"0")}function Y(e){if(!e)return;const n=new Date(e);if(!Number.isNaN(n.getTime()))return`${wt[n.getMonth()]} ${n.getDate()}, ${de(n.getHours())}:${de(n.getMinutes())}`}const Bt="_shellRow_5a5cb_2",Tt="_rail_5a5cb_10",Et="_disc_5a5cb_18",Rt="_connector_5a5cb_28",At="_content_5a5cb_2",It="_metaLine_5a5cb_40",Pt="_metaTime_5a5cb_52",E={shellRow:Bt,rail:Tt,disc:Et,connector:Rt,content:At,metaLine:It,metaTime:Pt};function L({disc:e,discClassName:n,connector:s,meta:o,metaTrailing:r,className:i,children:c}){return t.jsxs("div",{className:E.shellRow,children:[t.jsxs("div",{className:E.rail,children:[t.jsx("span",{className:D(E.disc,n),children:e}),s&&t.jsx("span",{className:E.connector})]}),t.jsxs("div",{className:D(E.content,i),children:[o&&t.jsxs("div",{className:E.metaLine,children:[o,r]}),c]})]})}const Ot="_queuedBadge_mdmbp_8",Mt="_finalChip_mdmbp_20",zt="_userDisc_mdmbp_30",Lt="_userAligned_mdmbp_34",Ft="_userPendingRow_mdmbp_40",Ht="_userBubble_mdmbp_44",Kt="_userBubbleFailed_mdmbp_58",$t="_userImages_mdmbp_63",Ut="_userImage_mdmbp_63",Wt="_imageDialog_mdmbp_79",qt="_imageDialogPreview_mdmbp_83",Gt="_assistantDisc_mdmbp_93",Jt="_assistantBody_mdmbp_97",Qt="_reasoningDisc_mdmbp_108",Vt="_reasoningBody_mdmbp_112",Xt="_toolDisc_mdmbp_123",Yt="_toolCardBody_mdmbp_127",Zt="_toolCardBodyRunning_mdmbp_134",en="_toolCardBodyCompleted_mdmbp_138",tn="_toolCardBodyError_mdmbp_142",nn="_toolHeader_mdmbp_146",sn="_toolHeaderRunning_mdmbp_172",on="_toolChevron_mdmbp_182",an="_toolChevronOpen_mdmbp_188",rn="_kindBadge_mdmbp_192",ln="_toolPath_mdmbp_204",cn="_toolTrailing_mdmbp_213",dn="_toolStatusRunning_mdmbp_221",un="_toolStatusSuccess_mdmbp_228",mn="_toolStatusError_mdmbp_232",pn="_toolStatusUnknown_mdmbp_236",fn="_toolDiffAdded_mdmbp_240",hn="_toolDiffRemoved_mdmbp_244",_n="_toolOpenButton_mdmbp_248",gn="_toolBody_mdmbp_266",xn="_toolCode_mdmbp_272",bn="_toolOutputStrip_mdmbp_283",vn="_toolDiffPreview_mdmbp_293",yn="_toolDiffPreviewLine_mdmbp_301",jn="_toolDiffPreviewAdd_mdmbp_305",kn="_toolDiffPreviewDel_mdmbp_310",Sn="_toolDiffPreviewMore_mdmbp_315",Nn="_errorDisc_mdmbp_322",Cn="_errorCard_mdmbp_326",Dn="_errorLead_mdmbp_335",wn="_systemRow_mdmbp_342",l={queuedBadge:Ot,finalChip:Mt,userDisc:zt,userAligned:Lt,userPendingRow:Ft,userBubble:Ht,userBubbleFailed:Kt,userImages:$t,userImage:Ut,imageDialog:Wt,imageDialogPreview:qt,assistantDisc:Gt,assistantBody:Jt,reasoningDisc:Qt,reasoningBody:Vt,toolDisc:Xt,toolCardBody:Yt,toolCardBodyRunning:Zt,toolCardBodyCompleted:en,toolCardBodyError:tn,toolHeader:nn,toolHeaderRunning:sn,toolChevron:on,toolChevronOpen:an,kindBadge:rn,toolPath:ln,toolTrailing:cn,toolStatusRunning:dn,toolStatusSuccess:un,toolStatusError:mn,toolStatusUnknown:pn,toolDiffAdded:fn,toolDiffRemoved:hn,toolOpenButton:_n,toolBody:gn,toolCode:xn,toolOutputStrip:bn,toolDiffPreview:vn,toolDiffPreviewLine:yn,toolDiffPreviewAdd:jn,toolDiffPreviewDel:kn,toolDiffPreviewMore:Sn,errorDisc:Nn,errorCard:Cn,errorLead:Dn,systemRow:wn};function Bn({row:e,assetBase:n=null,owningPaneId:s=null,workspaceCwd:o=null,connector:r}){const i=Y(e.timestamp);return t.jsx(L,{disc:t.jsx(z,{icon:Ve,size:"xs",color:"var(--pi-color-accentForeground)"}),discClassName:l.assistantDisc,connector:r,meta:t.jsxs(t.Fragment,{children:["Assistant",i&&t.jsxs("span",{className:E.metaTime,children:[" · ",i]})]}),children:t.jsx("div",{className:l.assistantBody,children:e.streaming?t.jsx(_e,{text:e.text,assetBase:n,owningPaneId:s,workspaceCwd:o}):t.jsx(ge,{text:e.text,assetBase:n,owningPaneId:s,workspaceCwd:o})})})}function Tn({row:e,owningPaneId:n=null,workspaceCwd:s=null,connector:o}){const r=Y(e.timestamp);return t.jsx(L,{disc:t.jsx(z,{icon:Xe,size:"xs",color:"var(--pi-color-foregroundMuted)"}),discClassName:l.reasoningDisc,connector:o,meta:t.jsxs(t.Fragment,{children:["Reasoning",r&&t.jsxs("span",{className:E.metaTime,children:[" · ",r]})]}),metaTrailing:!e.streaming&&t.jsx("span",{className:l.finalChip,children:"final"}),children:t.jsx("div",{className:l.reasoningBody,children:e.streaming?t.jsx(_e,{text:e.text,owningPaneId:n,workspaceCwd:s}):t.jsx(ge,{text:e.text,owningPaneId:n,workspaceCwd:s})})})}function En(e){const n=pt(e).filter(o=>o.kind==="add"||o.kind==="del"),s=n[0];return s?{text:s.text,kind:s.kind,moreCount:n.length-1}:null}function Rn(e){return e.status==="completed"?t.jsx("span",{className:l.toolStatusSuccess,children:"✓ completed"}):e.status==="error"?t.jsx("span",{className:l.toolStatusError,children:e.statusText||"error"}):e.statusText&&e.statusText!=="running"?t.jsx("span",{className:l.toolStatusUnknown,children:e.statusText}):t.jsxs("span",{className:l.toolStatusRunning,children:[t.jsx(X,{size:"xs",color:"var(--pi-color-accentBright)"}),"running"]})}function An({row:e,assetBase:n=null,owningPaneId:s=null,workspaceCwd:o=null,connector:r}){const[i,c]=g.useState(!1),d=bt(e.tool),j=xt(e.tool),m=j.length>0,p=yt(e.tool.output),u=e.tool.kind==="edit"||e.tool.kind==="write"?ye(e.tool):null,_=e.tool.kind==="edit"?vt(e.tool.diff):null,x=e.tool.kind==="edit"&&e.tool.diff&&!i?En(e.tool.diff):null;function S(){m&&c(b=>!b)}function N(b){b.target===b.currentTarget&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),S())}function w(b){if(b.stopPropagation(),!u)return;const C=ut(n,s,o);ze(u,C.workspaceCwd,C.targetPaneId)}return t.jsx(L,{disc:t.jsx(z,{icon:_t(e.tool),size:"xs",color:"var(--pi-color-foregroundMuted)"}),discClassName:l.toolDisc,connector:r,children:t.jsxs("div",{className:D(l.toolCardBody,e.status==="running"&&l.toolCardBodyRunning,e.status==="completed"&&l.toolCardBodyCompleted,e.status==="error"&&l.toolCardBodyError),children:[t.jsxs("div",{role:"button",tabIndex:m?0:-1,"aria-expanded":m?i:void 0,"aria-disabled":!m,className:D(l.toolHeader,e.status==="running"&&l.toolHeaderRunning),onClick:S,onKeyDown:N,children:[m&&t.jsx(Ye,{size:12,className:D(l.toolChevron,i&&l.toolChevronOpen)}),t.jsx("span",{className:l.kindBadge,style:{"--kindToken":`var(--pi-color-${d.token})`},children:d.label}),t.jsx("span",{className:l.toolPath,title:Q(e.tool),children:Q(e.tool)}),t.jsxs("span",{className:l.toolTrailing,children:[_&&(_.added>0||_.removed>0)&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:l.toolDiffAdded,children:["+",_.added]}),t.jsxs("span",{className:l.toolDiffRemoved,children:["−",_.removed]})]}),Rn(e),u&&t.jsxs("button",{type:"button",className:l.toolOpenButton,onClick:w,onKeyDown:b=>b.stopPropagation(),children:["Open",t.jsx(Ze,{size:10})]})]})]}),p>0&&t.jsxs("div",{className:l.toolOutputStrip,children:["output · ",p," lines"]}),x&&t.jsxs("div",{className:l.toolDiffPreview,children:[t.jsx("div",{className:D(l.toolDiffPreviewLine,x.kind==="add"?l.toolDiffPreviewAdd:l.toolDiffPreviewDel),children:x.text}),x.moreCount>0&&t.jsxs("div",{className:l.toolDiffPreviewMore,children:["… ",x.moreCount," more lines"]})]}),i&&m&&t.jsx("div",{className:l.toolBody,children:j.map((b,C)=>b.kind==="diff"?t.jsx(mt,{patch:b.patch},C):t.jsx("pre",{className:l.toolCode,children:b.text},C))})]})})}function In({row:e,connector:n}){const[s,o]=g.useState(null),r=Y(e.timestamp);return t.jsxs(L,{disc:t.jsx(z,{icon:tt,size:"xs",color:"var(--pi-color-successForeground)"}),discClassName:l.userDisc,connector:n,className:D(l.userAligned,e.pending&&l.userPendingRow),meta:t.jsxs(t.Fragment,{children:["You",r&&t.jsxs("span",{className:E.metaTime,children:[" · ",r]}),e.failed&&" · failed to send"]}),metaTrailing:e.queued&&!e.failed&&t.jsxs("span",{className:l.queuedBadge,children:[t.jsx(et,{size:9}),"queued"]}),children:[t.jsx("span",{className:D(l.userBubble,e.failed&&l.userBubbleFailed),children:e.text}),e.images&&e.images.length>0&&t.jsx("div",{className:l.userImages,children:e.images.map((i,c)=>{const d=`data:${i.mimeType??"image/png"};base64,${i.data??""}`;return t.jsx("img",{className:l.userImage,src:d,alt:"",role:"button",tabIndex:0,onClick:()=>o(d),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&o(d)}},c)})}),t.jsx(Le,{open:s!==null,onOpenChange:i=>{i||o(null)},title:"Image",width:"auto",bare:!0,className:l.imageDialog,children:s&&t.jsx("img",{className:l.imageDialogPreview,src:s,alt:""})})]})}function Pn({row:e,connector:n}){return t.jsx(L,{disc:t.jsx(z,{icon:nt,size:"xs",color:"var(--pi-color-destructive)"}),discClassName:l.errorDisc,connector:n,children:t.jsxs("div",{className:l.errorCard,children:[t.jsx("span",{className:l.errorLead,children:"Error"})," · ",e.text]})})}function On({row:e}){return t.jsx("div",{className:l.systemRow,children:e.text})}const Mn=500;function zn(e,n){const s=g.useRef(!0),[o,r]=g.useState(!0),i=g.useRef(0),c=g.useCallback(m=>{const p=n.current,u=p?{scrollTop:p.scrollTop,scrollHeight:p.scrollHeight,clientHeight:p.clientHeight}:{scrollTop:0,scrollHeight:0,clientHeight:0},_=Ct(s.current,m,u);_.pinned!==s.current&&(s.current=_.pinned,r(_.pinned)),_.stick&&e.options.count>0&&e.scrollToEnd({behavior:"auto"})},[n,e]);g.useEffect(()=>{const m=n.current;if(!m)return;const p=()=>{i.current=performance.now()},u=()=>{c({kind:"scroll",gesture:performance.now()-i.current<Mn})};m.addEventListener("scroll",u,{passive:!0}),m.addEventListener("wheel",p,{passive:!0}),m.addEventListener("touchmove",p,{passive:!0}),m.addEventListener("pointerdown",p,{passive:!0}),m.addEventListener("keydown",p,{passive:!0});const _=new ResizeObserver(()=>{m.clientHeight>0&&c({kind:"shown"})});return _.observe(m),()=>{_.disconnect(),m.removeEventListener("scroll",u),m.removeEventListener("wheel",p),m.removeEventListener("touchmove",p),m.removeEventListener("pointerdown",p),m.removeEventListener("keydown",p)}},[c,n]);const d=g.useCallback(()=>c({kind:"tail"}),[c]),j=g.useCallback(()=>c({kind:"pin"}),[c]);return{pinned:o,followTail:d,pinToBottom:j}}const Ln="_root_166ob_6",Fn="_viewport_166ob_13",Hn="_inner_166ob_20",Kn="_rowWrap_166ob_25",$n="_empty_166ob_35",Un="_jumpToLatest_166ob_46",M={root:Ln,viewport:Fn,inner:Hn,rowWrap:Kn,empty:$n,jumpToLatest:Un},Wn=160;function qn(e,n,s,o,r){switch(e.kind){case"user":return t.jsx(In,{row:e,connector:!n});case"assistant":return t.jsx(Bn,{row:e,assetBase:s,owningPaneId:o,workspaceCwd:r,connector:!n});case"reasoning":return t.jsx(Tn,{row:e,owningPaneId:o,workspaceCwd:r,connector:!n});case"tool":return t.jsx(An,{row:e,assetBase:s,owningPaneId:o,workspaceCwd:r,connector:!n});case"error":return t.jsx(Pn,{row:e,connector:!n});case"system":return t.jsx(On,{row:e})}}function Gn({session:e,owningPaneId:n,workspaceCwd:s}){const o=e.timeline.rows,r=e.status==="running",i=Fe(),c=He(e.cwd,i),d=g.useRef(null),j=Oe({count:o.length,getScrollElement:()=>d.current,estimateSize:()=>Wn,overscan:8,getItemKey:x=>{var S;return((S=o[x])==null?void 0:S.id)??x},measureElement:(x,S,N)=>{if(x.offsetParent!==null)return Me(x,S,N);const w=N.indexFromElement(x),b=N.options.getItemKey(w);return N.itemSizeCache.get(b)??N.options.estimateSize(w)},anchorTo:"end",scrollEndThreshold:je}),{pinned:m,followTail:p,pinToBottom:u}=zn(j,d),_=Dt(o);return g.useEffect(()=>{p()},[o.length,p]),g.useEffect(()=>{_!==null&&u()},[_,u]),t.jsxs("div",{className:M.root,children:[t.jsx("div",{className:M.viewport,ref:d,children:o.length===0?!r&&t.jsx("div",{className:M.empty,children:"No messages yet — say something to start."}):t.jsx("div",{className:M.inner,style:{height:j.getTotalSize()},children:j.getVirtualItems().map(x=>{const S=o[x.index];return S?t.jsx("div",{ref:j.measureElement,"data-index":x.index,className:M.rowWrap,style:{transform:`translateY(${x.start}px)`},children:qn(S,x.index===o.length-1,c,n,s)},x.key):null})})}),!m&&o.length>0&&t.jsx("button",{type:"button",className:M.jumpToLatest,onClick:u,title:"Jump to latest","aria-label":"Jump to latest",children:t.jsx(st,{size:16,"aria-hidden":"true"})})]})}function Jn(e,n=!0){const s=$(o=>o.client);return me({queryKey:pe.agentCommands(e),queryFn:async()=>{if(!s)throw new Error("not connected");const o=await V(s,e),{commands:r}=await s.agent(o).listCommands();return r},enabled:!!s&&!!e&&n})}const Qn="_strip_nzfk5_4",Vn="_thumb_nzfk5_11",Xn="_remove_nzfk5_28",G={strip:Qn,thumb:Vn,remove:Xn};function Yn({images:e,onRemove:n}){return e.length===0?null:t.jsx("div",{className:G.strip,children:e.map((s,o)=>t.jsxs("div",{className:G.thumb,children:[t.jsx("img",{src:s.thumbUrl,alt:""}),t.jsx("button",{type:"button",className:G.remove,title:"Remove",onClick:()=>n(o),children:"×"})]},o))})}function Zn(e){const{promise:n,resolve:s,reject:o}=Promise.withResolvers(),r=new FileReader;return r.onload=()=>{const i=r.result;if(typeof i!="string"){o(new Error("Unexpected FileReader result"));return}const c=i.indexOf(","),d=c>=0?i.slice(c+1):i;s({mimeType:e.type,data:d,thumbUrl:i})},r.onerror=()=>o(r.error??new Error("Failed to read file")),r.readAsDataURL(e),n}const es="_picker_1jy8c_4",ts="_search_1jy8c_10",ns="_list_1jy8c_28",ss="_item_1jy8c_33",os="_itemActive_1jy8c_47",as="_checkSlot_1jy8c_51",rs="_label_1jy8c_60",is="_modelId_1jy8c_66",ls="_state_1jy8c_73",cs="_stateError_1jy8c_82",ds="_commandContent_1jy8c_92",us="_commandList_1jy8c_95",ms="_commandItem_1jy8c_100",ps="_commandItemHeader_1jy8c_132",fs="_commandKindBadge_1jy8c_146",hs="_commandKindExtension_1jy8c_165",_s="_commandKindPrompt_1jy8c_170",gs="_commandKindSkill_1jy8c_175",xs="_commandDescription_1jy8c_180",h={picker:es,search:ts,list:ns,item:ss,itemActive:os,checkSlot:as,label:rs,modelId:is,state:ls,stateError:cs,commandContent:ds,commandList:us,commandItem:ms,commandItemHeader:ps,commandKindBadge:fs,commandKindExtension:hs,commandKindPrompt:_s,commandKindSkill:gs,commandDescription:xs},bs={onOpenAutoFocus:e=>e.preventDefault()};function vs(e){switch(e){case"extension":return h.commandKindExtension;case"prompt":return h.commandKindPrompt;case"skill":return h.commandKindSkill;default:return}}function ys({open:e,onOpenChange:n,options:s,highlightedIndex:o,onSelect:r,isLoading:i,isError:c,errorMessage:d,hiddenExtensionCount:j,renderTrigger:m}){const p=g.useRef(null);return g.useEffect(()=>{var u,_;e&&((_=(u=p.current)==null?void 0:u.querySelector('[aria-selected="true"]'))==null||_.scrollIntoView({block:"nearest"}))},[e,o]),t.jsxs(xe,{open:e,onOpenChange:n,modal:!1,children:[t.jsx(be,{asChild:!0,children:m()}),t.jsxs(fe,{className:D(h.picker,h.commandContent),side:"top",sideOffset:4,...bs,onCloseAutoFocus:u=>u.preventDefault(),children:[i&&t.jsx("div",{className:h.state,children:t.jsx(X,{size:"sm"})}),!i&&c&&t.jsx("div",{className:h.stateError,children:d??"Failed to load commands"}),!i&&!c&&s.length===0&&t.jsx("div",{className:h.state,children:"No commands found"}),!i&&!c&&s.length>0&&t.jsx("div",{ref:p,className:D(h.list,h.commandList),children:s.map((u,_)=>t.jsxs("div",{role:"option","aria-selected":_===o,className:D(h.item,h.commandItem,_===o&&h.itemActive),title:u.description,onMouseDown:x=>{x.preventDefault(),r(u.value)},children:[t.jsxs("div",{className:h.commandItemHeader,children:[t.jsx("span",{className:h.label,children:u.label}),u.kind&&t.jsx("span",{className:D(h.commandKindBadge,vs(u.kind)),children:u.kind})]}),u.description&&t.jsx("div",{className:h.commandDescription,children:u.description})]},u.value))}),!i&&!c&&j>0&&t.jsxs("div",{className:h.state,children:[j," extension command(s) unavailable while the agent is running"]})]})]})}function js(e,n=!0){const s=$(o=>o.client);return me({queryKey:pe.providerModels(e),queryFn:async()=>{if(!s)throw new Error("not connected");return(await s.providers.listModels(e)).models},enabled:!!s&&!!e&&n})}function ks(e,n){if(!n)return e;const s=e.find(o=>o.id===n);return s?[s,...e.filter(o=>o.id!==n)]:e}function Ss(e){const n=new Set;return e.filter(s=>n.has(s.id)?!1:(n.add(s.id),!0))}function Ns({currentModel:e,provider:n,onSelect:s,renderTrigger:o}){const[r,i]=g.useState(!1),[c,d]=g.useState(""),j=g.useRef(null),{data:m=[],isLoading:p,isError:u,error:_}=js(n,r),x=Ss(ks(m,e));g.useEffect(()=>{var v;r&&(d(""),(v=j.current)==null||v.focus())},[r]);const S=new Map(x.map(v=>[v.id,v.provider])),N=x.map(v=>({value:v.id,label:v.label??v.id,description:v.id})),w=ve(N,c),b=_ instanceof Error?_.message:"Failed to load models";function C(v){v.stopPropagation(),v.key==="Escape"&&i(!1)}return t.jsxs(xe,{open:r,onOpenChange:i,modal:!1,children:[t.jsx(be,{asChild:!0,children:o(e)}),t.jsxs(fe,{minWidth:240,align:"end",sideOffset:6,className:h.picker,children:[t.jsx("input",{ref:j,className:h.search,placeholder:"Search models…",value:c,onChange:v=>d(v.target.value),onKeyDown:C}),p&&t.jsx("div",{className:h.state,children:t.jsx(X,{size:"sm"})}),!p&&u&&t.jsx("div",{className:h.stateError,children:b}),!p&&!u&&w.length===0&&t.jsx("div",{className:h.state,children:"No models found"}),!p&&!u&&w.length>0&&t.jsx("div",{className:h.list,children:w.map(v=>t.jsxs(ft,{className:h.item,onSelect:()=>s(v.value,S.get(v.value)),children:[t.jsx("span",{className:h.checkSlot,"aria-hidden":!0,children:v.value===e&&t.jsx(ot,{size:14})}),t.jsx("span",{className:h.label,children:v.label}),t.jsxs("span",{className:h.modelId,children:["(",v.value,")"]})]},v.value))})]})]})}function Z(e){if(!e.startsWith("/"))return null;const n=/^\/(\S*)/.exec(e),s=(n==null?void 0:n[1])??"",o=1+s.length,r=/\S/.test(e.slice(o));return{name:s,end:o,hasArgs:r}}function Cs(e){return/^\/\S*$/.test(e)}function Ds(e,n){let s=0;const o=[];for(const r of e){if(n.running&&r.source==="extension"){s+=1;continue}o.push({value:r.name,label:`/${r.name}`,description:r.description,kind:r.source})}return{options:o,hiddenExtensionCount:s}}function ws(e,n,s){return s<=0?0:(e+n+s)%s}function Bs(e,n){const s=Z(e);return s?s.hasArgs?`/${n}${e.slice(s.end)}`:`/${n} `:`/${n} ${e}`}function Ts(e,n){const s=Z(e);return!s||!n.includes(s.name)?null:{end:s.end}}const Es="_composer_3wzps_4",Rs="_card_3wzps_13",As="_textarea_3wzps_26",Is="_textareaWrap_3wzps_50",Ps="_highlightLayer_3wzps_38",Os="_commandMark_3wzps_73",Ms="_hiddenFileInput_3wzps_98",zs="_toolbar_3wzps_104",Ls="_toolbarRight_3wzps_111",Fs="_toolBtn_3wzps_119",Hs="_roundBtn_3wzps_125",Ks="_modelBtn_3wzps_130",$s="_modelLabel_3wzps_156",Us="_modelChevron_3wzps_161",k={composer:Es,card:Rs,textarea:As,textareaWrap:Is,highlightLayer:Ps,commandMark:Os,hiddenFileInput:Ms,toolbar:zs,toolbarRight:Ls,toolBtn:Fs,roundBtn:Hs,modelBtn:Ks,modelLabel:$s,modelChevron:Us},Ws=160;function K(e){e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,Ws)}px`}function qs(e){return typeof e=="object"&&e!==null&&"ok"in e&&e.ok===!1}function Gs({sessionId:e}){const n=$(a=>a.client),s=R(a=>a.sessions[e]),o=R(a=>a.addOptimisticUserMessage),r=R(a=>a.markUserMessageFailed),i=R(a=>a.setCwd),c=R(a=>a.setModel),[d,j]=g.useState(""),[m,p]=g.useState([]),[u,_]=g.useState(!1),[x,S]=g.useState(!1),N=g.useRef(null),w=g.useRef(null),[b,C]=g.useState(!1),[v,U]=g.useState(0),T=(s==null?void 0:s.status)==="running",ke=!!n&&!(T?x:u)&&(d.trim().length>0||m.length>0),{data:ee=[],isLoading:Se,isError:Ne,error:te}=Jn(e,b),{options:ne,hiddenExtensionCount:Ce}=Ds(ee,{running:T}),se=Z(d),F=se?ve(ne,se.name):ne,De=ee.map(a=>a.name),I=Ts(d,De);async function oe(a){if(a.type.startsWith("image/"))try{const y=await Zn(a);p(f=>[...f,y])}catch{}}function we(a){for(const y of a.target.files??[])oe(y);a.target.value=""}function Be(a){for(const y of a.clipboardData.items)if(y.type.startsWith("image/")){a.preventDefault();const f=y.getAsFile();f&&oe(f)}}function Te(a){p(y=>y.filter((f,B)=>B!==a))}function Ee(a){const y=a.target.value;j(y),K(a.target);const f=Cs(y);f!==b&&C(f),f&&U(0)}function Re(a){var y;if(!b&&I&&a.key==="Backspace"){const f=a.currentTarget,B=f.selectionStart;if(B!==null&&B===f.selectionEnd){const P=I.end+(d[I.end]===" "?1:0);if(B>0&&B<=P){a.preventDefault();const A=d.slice(P);j(A),f.setSelectionRange(0,0),K(f);return}}}if(b&&F.length>0){if(a.key==="ArrowDown"||a.key==="ArrowUp"){a.preventDefault(),U(f=>ws(f,a.key==="ArrowDown"?1:-1,F.length));return}if(a.key==="Enter"&&!a.shiftKey||a.key==="Tab"){a.preventDefault();const f=(y=F[v])==null?void 0:y.value;f&&ae(f);return}}if(b&&a.key==="Escape"){a.preventDefault(),C(!1);return}a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),re(T?"steer":"send"))}function ae(a){const y=Bs(d,a);j(y),C(!1),U(0);const f=N.current;f&&(f.focus(),f.setSelectionRange(y.length,y.length),K(f))}async function re(a){if(!n||!s||(a==="steer"?x:u)||a==="steer"&&!s.agentId)return;const y=d.trim();if(!y&&m.length===0)return;j(""),C(!1),N.current&&K(N.current);const f=m;p([]);const B=y||"Describe this image",P=f.length>0?f.map(O=>({mimeType:O.mimeType,data:O.data})):void 0,A=$e();o(e,A,B,P,a==="steer");const ie=a==="steer"?S:_;ie(!0);try{if(a==="steer"){const O=await n.agent(s.agentId).steer(B,{clientMessageId:A,images:P});qs(O)&&r(e,A)}else{s.agentId||i(e,s.cwd||"~");const O=await V(n,e);await n.agent(O).send(B,{clientMessageId:A,images:P})}}catch{r(e,A)}finally{ie(!1)}}function Ae(){s!=null&&s.agentId&&(n==null||n.agent(s.agentId).interrupt())}function Ie(a,y){c(e,a,y),!(!n||!y)&&(async()=>{const f=await V(n,e);await n.agent(f).setModel(y,a)})().catch(()=>{})}return t.jsxs("div",{className:k.composer,children:[t.jsxs("div",{className:k.card,children:[t.jsxs("div",{className:k.textareaWrap,children:[t.jsx("div",{className:k.highlightLayer,"aria-hidden":!0,children:I?t.jsxs(t.Fragment,{children:[t.jsx("mark",{className:k.commandMark,children:d.slice(0,I.end)}),d.slice(I.end)]}):d}),t.jsx(Ke,{ref:N,className:k.textarea,rows:1,value:d,placeholder:T?"Steer the running turn… ⏎ steer · ⇧⏎ newline":"Ask anything… ⏎ send · ⇧⏎ newline · / commands",onChange:Ee,onKeyDown:Re,onPaste:Be})]}),t.jsx(Yn,{images:m,onRemove:Te}),t.jsxs("div",{className:k.toolbar,children:[t.jsx(H,{className:k.toolBtn,variant:"ghost",size:"sm",iconOnly:!0,title:"Attach image","aria-label":"Attach image",onClick:()=>{var a;return(a=w.current)==null?void 0:a.click()},children:t.jsx(at,{size:16})}),t.jsx(ys,{open:b,onOpenChange:C,options:F,highlightedIndex:v,onSelect:ae,isLoading:Se,isError:Ne,errorMessage:te instanceof Error?te.message:void 0,hiddenExtensionCount:Ce,renderTrigger:()=>t.jsx(H,{className:k.toolBtn,variant:"ghost",size:"sm",iconOnly:!0,title:"Slash commands","aria-label":"Slash commands",children:t.jsx(rt,{size:16})})}),t.jsxs("div",{className:k.toolbarRight,children:[t.jsx(Ns,{currentModel:s==null?void 0:s.model,provider:"pi",onSelect:Ie,renderTrigger:a=>t.jsxs("button",{type:"button",className:k.modelBtn,disabled:!n,title:a?`Model: ${a}`:"Select model",children:[t.jsx("span",{className:k.modelLabel,children:a??"Model"}),t.jsx(it,{size:13,className:k.modelChevron,"aria-hidden":"true"})]})}),T&&t.jsx(H,{className:k.roundBtn,variant:"destructive",size:"sm",iconOnly:!0,title:"Stop the running turn","aria-label":"Stop",onClick:Ae,children:t.jsx(lt,{size:14})}),t.jsx(H,{className:k.roundBtn,size:"sm",iconOnly:!0,disabled:!ke,title:T?"Steer the running turn":"Send","aria-label":T?"Steer":"Send",onClick:()=>void re(T?"steer":"send"),children:T?t.jsx(ct,{size:16}):t.jsx(dt,{size:18})})]})]})]}),t.jsx("input",{ref:w,className:k.hiddenFileInput,type:"file",accept:"image/*",multiple:!0,onChange:we})]})}const Js="_track_oxvl6_2",Qs="_sweep_oxvl6_24",Vs="_visuallyHidden_oxvl6_64",J={track:Js,sweep:Qs,visuallyHidden:Vs};function Xs({running:e}){return e?t.jsxs("div",{className:J.track,role:"progressbar","aria-label":"Turn in progress",children:[t.jsx("div",{className:J.sweep,"aria-hidden":"true"}),t.jsx("span",{className:J.visuallyHidden,role:"status","aria-live":"polite",children:"Agent is working…"})]}):null}const Ys="_panel_1tq06_1",Zs="_empty_1tq06_5",ue={panel:Ys,empty:Zs};function fo({tab:e,owningPaneId:n}){const{sessionId:s}=e.data,o=R(r=>r.sessions[s]);return Nt(s),o?t.jsxs(le,{className:ue.panel,children:[t.jsx(Xs,{running:o.status==="running"}),t.jsx(Gn,{session:o,owningPaneId:n,workspaceCwd:e.workspaceCwd}),t.jsx(Gs,{sessionId:o.id})]}):t.jsx(le,{children:t.jsx("div",{className:ue.empty,children:"Session not found."})})}export{fo as ChatPanel};
@@ -1 +1 @@
1
- var j=Object.defineProperty;var q=(r,n,e)=>n in r?j(r,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[n]=e;var d=(r,n,e)=>q(r,typeof n!="symbol"?n+"":n,e);import{r as u,j as w}from"./vendor-react-DQUAl2K8.js";import{u as y}from"./vendor-query-i7fr__Xm.js";import{u as F,a as p}from"./index-CRcOAGBq.js";import{u as x}from"./use-file-download-C5RZM273.js";import{P as S,Q as _,S as b,T as B,U as z,V as U}from"./vendor-DVp0ZLQo.js";function D(r){const{maxDisplayBytes:n,inline:e,streamed:o,download:a}=r;if(e.isLoading)return{kind:"loading"};if(e.tooLarge){const{size:t}=e.tooLarge;return t>n?{kind:"too-large",size:t,maxDisplayBytes:n,downloading:a.requested&&a.isLoading,downloadUrl:a.objectUrl,downloadName:a.fileName}:o.isLoading?{kind:"streaming",size:t}:o.isError?{kind:"stream-error",size:t,message:o.errorMessage??"stream failed"}:o.content!==null?{kind:"streamed",size:t,content:o.content}:{kind:"loading"}}return e.isError?{kind:"error",message:e.errorMessage??"unknown error"}:e.content!==null?{kind:"inline",content:e.content}:{kind:"loading"}}class h extends Error{constructor(e,o){super("file_too_large");d(this,"size");d(this,"maxBytes");this.name="FileTooLargeError",this.size=e,this.maxBytes=o}}function R(r){if(!r.ok)throw r.error==="file_too_large"?new h(r.size??0,r.maxBytes):new Error(r.error??"file read failed");return{content:r.content??"",size:r.size??0}}function T(r,n=!0){const e=F(o=>o.client);return y({queryKey:p.fileRead(r),queryFn:async()=>{if(!e)throw new Error("not connected");const o=await e.connection.request("file_read_request",{path:r});return R(o)},enabled:!!e&&!!r&&n})}function M(r){const{enabled:n,download:e,decode:o}=r;return{isLoading:n&&(e.isLoading||e.hasObjectUrl&&o.isLoading),isError:e.isError||o.isError,error:e.isError?e.error:o.error,data:o.data}}function C(r,n=!0){var t;const e=x(r,n),o=(t=e.data)==null?void 0:t.objectUrl,a=y({queryKey:p.fileText(r,o??null),queryFn:async()=>({content:await(await fetch(o)).text()}),enabled:n&&!!o});return M({enabled:n,download:{isLoading:e.isLoading,isError:e.isError,error:e.error,hasObjectUrl:!!o},decode:{isLoading:a.isLoading,isError:a.isError,error:a.error,data:a.data}})}const E=30*1024*1024;function Y(r,n=!0){var c,f,g,m;const e=T(r,n),o=e.error instanceof h?e.error:null,a=o!==null&&o.size<=E,t=C(r,n&&a),[i,k]=u.useState(!1),s=x(r,n&&i),l=D({maxDisplayBytes:E,inline:{isLoading:e.isLoading,isError:e.isError,tooLarge:o?{size:o.size}:null,errorMessage:e.error instanceof Error?e.error.message:null,content:((c=e.data)==null?void 0:c.content)??null},streamed:{isLoading:t.isLoading,isError:t.isError,errorMessage:t.error instanceof Error?t.error.message:null,content:((f=t.data)==null?void 0:f.content)??null},download:{requested:i,isLoading:s.isLoading,objectUrl:((g=s.data)==null?void 0:g.objectUrl)??null,fileName:((m=s.data)==null?void 0:m.fileName)??null}});return l.kind==="too-large"?{...l,requestDownload:()=>k(!0)}:l}const N="_wrap_1feu3_1",v={wrap:N},L=new Map;function K(r){const[n,e]=u.useState(null);return u.useEffect(()=>{const o=z.matchFilename(U,r);if(!o){e(null);return}const a=L.get(o.name);if(a){e(a);return}let t=!1;return e(null),o.load().then(i=>{L.set(o.name,i),t||e(i)}),()=>{t=!0}},[r]),n?[n]:[]}function I({path:r,content:n}){const e=K(r),o=[S.lineWrapping,_(),...e];return w.jsx("div",{className:v.wrap,children:w.jsx(b,{value:n,theme:B,extensions:o,editable:!1,readOnly:!0,basicSetup:{highlightActiveLine:!1,foldGutter:!1,searchKeymap:!1},height:"100%"})})}export{I as C,Y as u};
1
+ var j=Object.defineProperty;var q=(r,n,e)=>n in r?j(r,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[n]=e;var d=(r,n,e)=>q(r,typeof n!="symbol"?n+"":n,e);import{r as u,j as w}from"./vendor-react-DQUAl2K8.js";import{u as y}from"./vendor-query-i7fr__Xm.js";import{u as F,a as p}from"./index-CWQ7GUFk.js";import{u as x}from"./use-file-download-zBrxUX0K.js";import{P as S,Q as _,S as b,T as B,U as z,V as U}from"./vendor-DVp0ZLQo.js";function D(r){const{maxDisplayBytes:n,inline:e,streamed:o,download:a}=r;if(e.isLoading)return{kind:"loading"};if(e.tooLarge){const{size:t}=e.tooLarge;return t>n?{kind:"too-large",size:t,maxDisplayBytes:n,downloading:a.requested&&a.isLoading,downloadUrl:a.objectUrl,downloadName:a.fileName}:o.isLoading?{kind:"streaming",size:t}:o.isError?{kind:"stream-error",size:t,message:o.errorMessage??"stream failed"}:o.content!==null?{kind:"streamed",size:t,content:o.content}:{kind:"loading"}}return e.isError?{kind:"error",message:e.errorMessage??"unknown error"}:e.content!==null?{kind:"inline",content:e.content}:{kind:"loading"}}class h extends Error{constructor(e,o){super("file_too_large");d(this,"size");d(this,"maxBytes");this.name="FileTooLargeError",this.size=e,this.maxBytes=o}}function R(r){if(!r.ok)throw r.error==="file_too_large"?new h(r.size??0,r.maxBytes):new Error(r.error??"file read failed");return{content:r.content??"",size:r.size??0}}function T(r,n=!0){const e=F(o=>o.client);return y({queryKey:p.fileRead(r),queryFn:async()=>{if(!e)throw new Error("not connected");const o=await e.connection.request("file_read_request",{path:r});return R(o)},enabled:!!e&&!!r&&n})}function M(r){const{enabled:n,download:e,decode:o}=r;return{isLoading:n&&(e.isLoading||e.hasObjectUrl&&o.isLoading),isError:e.isError||o.isError,error:e.isError?e.error:o.error,data:o.data}}function C(r,n=!0){var t;const e=x(r,n),o=(t=e.data)==null?void 0:t.objectUrl,a=y({queryKey:p.fileText(r,o??null),queryFn:async()=>({content:await(await fetch(o)).text()}),enabled:n&&!!o});return M({enabled:n,download:{isLoading:e.isLoading,isError:e.isError,error:e.error,hasObjectUrl:!!o},decode:{isLoading:a.isLoading,isError:a.isError,error:a.error,data:a.data}})}const E=30*1024*1024;function Y(r,n=!0){var c,f,g,m;const e=T(r,n),o=e.error instanceof h?e.error:null,a=o!==null&&o.size<=E,t=C(r,n&&a),[i,k]=u.useState(!1),s=x(r,n&&i),l=D({maxDisplayBytes:E,inline:{isLoading:e.isLoading,isError:e.isError,tooLarge:o?{size:o.size}:null,errorMessage:e.error instanceof Error?e.error.message:null,content:((c=e.data)==null?void 0:c.content)??null},streamed:{isLoading:t.isLoading,isError:t.isError,errorMessage:t.error instanceof Error?t.error.message:null,content:((f=t.data)==null?void 0:f.content)??null},download:{requested:i,isLoading:s.isLoading,objectUrl:((g=s.data)==null?void 0:g.objectUrl)??null,fileName:((m=s.data)==null?void 0:m.fileName)??null}});return l.kind==="too-large"?{...l,requestDownload:()=>k(!0)}:l}const N="_wrap_1feu3_1",v={wrap:N},L=new Map;function K(r){const[n,e]=u.useState(null);return u.useEffect(()=>{const o=z.matchFilename(U,r);if(!o){e(null);return}const a=L.get(o.name);if(a){e(a);return}let t=!1;return e(null),o.load().then(i=>{L.set(o.name,i),t||e(i)}),()=>{t=!0}},[r]),n?[n]:[]}function I({path:r,content:n}){const e=K(r),o=[S.lineWrapping,_(),...e];return w.jsx("div",{className:v.wrap,children:w.jsx(b,{value:n,theme:B,extensions:o,editable:!1,readOnly:!0,basicSetup:{highlightActiveLine:!1,foldGutter:!1,searchKeymap:!1},height:"100%"})})}export{I as C,Y as u};
@@ -1 +1 @@
1
- import{r as u,j as s}from"./vendor-react-DQUAl2K8.js";import{M as v}from"./vendor-DVp0ZLQo.js";import{u as j,a as d,L as w,r as E,b as D,V as K,P as b,B as x,E as l,S as y}from"./index-CRcOAGBq.js";import{u as k,a as q}from"./vendor-query-i7fr__Xm.js";import{u as z}from"./use-file-watch-C6t0UJSi.js";import{D as N}from"./DiffView-CRrnffpG.js";import"./vendor-icons-CQPWxe0u.js";import"./vendor-overlays-BfyojyuH.js";import"./vendor-dnd-CayJj8TC.js";function S(e,t,r,i=!0){const a=j(n=>n.client);return k({queryKey:d.fileDiff(e,t,r),queryFn:async()=>{if(!a)throw new Error("not connected");return{patch:(await a.connection.request("file_diff_request",{path:e,cwd:t,staged:r})).patch??""}},enabled:!!a&&!!e&&!!t&&i})}function B(e,t,r){const i=q(),a=w.has(r)?E(e,t):null,{changedAt:n}=z(a);u.useEffect(()=>{n!==null&&(i.invalidateQueries({queryKey:d.fileRead(e)}),i.invalidateQueries({queryKey:d.fileDownload(e)}),i.invalidateQueries({queryKey:d.fileDiffByPath(e)}))},[n,e,i])}const C="_header_10rse_1",F="_path_10rse_11",V="_size_10rse_18",L="_viewToggle_10rse_23",P="_body_10rse_28",c={header:C,path:F,size:V,viewToggle:L,body:P};function g(e){return"path"in e}function Q(e){return"staged"in e}function J({tab:e}){var m;const t=e.kind==="diff",r=e.data,i=g(r)?r.path:"",a=g(r)&&Q(r)?r.staged:!1,[n,h]=u.useState(t?"diff":"file"),f=e.workspaceCwd||"~",p=D(i);B(i,f,p);const o=S(i,f,a,n==="diff"),_=K[p];return s.jsxs(b,{children:[s.jsxs("div",{className:c.header,children:[s.jsx("span",{className:c.path,children:i}),s.jsx("span",{className:c.size,children:n==="diff"?a?"staged":"unstaged":null}),s.jsxs("div",{className:c.viewToggle,children:[s.jsx(x,{size:"xs",variant:n==="file"?"default":"ghost",onClick:()=>h("file"),children:"File"}),s.jsx(x,{size:"xs",variant:n==="diff"?"default":"ghost",onClick:()=>h("diff"),children:"Diff"})]})]}),s.jsx("div",{className:v(c.body,"file-body"),children:n==="file"?s.jsx(u.Suspense,{fallback:s.jsxs(l,{children:[s.jsx(y,{size:"sm"})," Loading..."]}),children:s.jsx(_,{path:i,workspaceCwd:f})}):o.isLoading?s.jsxs(l,{children:[s.jsx(y,{size:"sm"})," Loading diff..."]}):o.isError?s.jsxs(l,{children:["Error: ",o.error instanceof Error?o.error.message:"unknown error"]}):(m=o.data)!=null&&m.patch?s.jsx(N,{patch:o.data.patch}):s.jsx(l,{style:{padding:"var(--pi-spacing-30)"},children:"No changes (file matches HEAD)"})})]})}export{J as FilePanel};
1
+ import{r as u,j as s}from"./vendor-react-DQUAl2K8.js";import{M as v}from"./vendor-DVp0ZLQo.js";import{u as j,a as d,L as w,r as E,b as D,V as K,P as b,B as x,E as l,S as y}from"./index-CWQ7GUFk.js";import{u as k,a as q}from"./vendor-query-i7fr__Xm.js";import{u as z}from"./use-file-watch-BLigZDy5.js";import{D as N}from"./DiffView-CRrnffpG.js";import"./vendor-icons-CQPWxe0u.js";import"./vendor-overlays-BfyojyuH.js";import"./vendor-dnd-CayJj8TC.js";function S(e,t,r,i=!0){const a=j(n=>n.client);return k({queryKey:d.fileDiff(e,t,r),queryFn:async()=>{if(!a)throw new Error("not connected");return{patch:(await a.connection.request("file_diff_request",{path:e,cwd:t,staged:r})).patch??""}},enabled:!!a&&!!e&&!!t&&i})}function B(e,t,r){const i=q(),a=w.has(r)?E(e,t):null,{changedAt:n}=z(a);u.useEffect(()=>{n!==null&&(i.invalidateQueries({queryKey:d.fileRead(e)}),i.invalidateQueries({queryKey:d.fileDownload(e)}),i.invalidateQueries({queryKey:d.fileDiffByPath(e)}))},[n,e,i])}const C="_header_10rse_1",F="_path_10rse_11",V="_size_10rse_18",L="_viewToggle_10rse_23",P="_body_10rse_28",c={header:C,path:F,size:V,viewToggle:L,body:P};function g(e){return"path"in e}function Q(e){return"staged"in e}function J({tab:e}){var m;const t=e.kind==="diff",r=e.data,i=g(r)?r.path:"",a=g(r)&&Q(r)?r.staged:!1,[n,h]=u.useState(t?"diff":"file"),f=e.workspaceCwd||"~",p=D(i);B(i,f,p);const o=S(i,f,a,n==="diff"),_=K[p];return s.jsxs(b,{children:[s.jsxs("div",{className:c.header,children:[s.jsx("span",{className:c.path,children:i}),s.jsx("span",{className:c.size,children:n==="diff"?a?"staged":"unstaged":null}),s.jsxs("div",{className:c.viewToggle,children:[s.jsx(x,{size:"xs",variant:n==="file"?"default":"ghost",onClick:()=>h("file"),children:"File"}),s.jsx(x,{size:"xs",variant:n==="diff"?"default":"ghost",onClick:()=>h("diff"),children:"Diff"})]})]}),s.jsx("div",{className:v(c.body,"file-body"),children:n==="file"?s.jsx(u.Suspense,{fallback:s.jsxs(l,{children:[s.jsx(y,{size:"sm"})," Loading..."]}),children:s.jsx(_,{path:i,workspaceCwd:f})}):o.isLoading?s.jsxs(l,{children:[s.jsx(y,{size:"sm"})," Loading diff..."]}):o.isError?s.jsxs(l,{children:["Error: ",o.error instanceof Error?o.error.message:"unknown error"]}):(m=o.data)!=null&&m.patch?s.jsx(N,{patch:o.data.patch}):s.jsx(l,{style:{padding:"var(--pi-spacing-30)"},children:"No changes (file matches HEAD)"})})]})}export{J as FilePanel};
@@ -1 +1 @@
1
- import{j as r,r as v}from"./vendor-react-DQUAl2K8.js";import{a as ie,u as ce}from"./vendor-query-i7fr__Xm.js";import{n as le,r as X,c as ue,d as Y,u as K,k as de,E as N,S as R,B as A,a as M,t as fe}from"./index-CRcOAGBq.js";import{M as me}from"./vendor-DVp0ZLQo.js";import{u as pe,C as he}from"./CodeView-DWNPh5RV.js";import{p as ge,S as xe}from"./href-resolution-Bu3Ezb0Z.js";import"./vendor-icons-CQPWxe0u.js";import"./vendor-overlays-BfyojyuH.js";import"./vendor-dnd-CayJj8TC.js";import"./use-file-download-C5RZM273.js";const we="_track_841zp_3",_e="_checked_841zp_23",ve="_disabled_841zp_27",ke="_thumb_841zp_32",z={track:we,checked:_e,disabled:ve,thumb:ke};function ye({checked:s,onCheckedChange:t,disabled:e=!1,id:n,"aria-label":a,className:o}){return r.jsx("button",{id:n,role:"switch","aria-checked":s,"aria-label":a,disabled:e,className:me(z.track,s&&z.checked,e&&z.disabled,o),onClick:()=>!e&&t(!s),type:"button",children:r.jsx("span",{className:z.thumb})})}const O={maxCount:64,maxBytesPerAsset:2*1024*1024,maxBytesTotal:16*1024*1024};function q(s,t,e){return!(s>=O.maxCount||e>O.maxBytesPerAsset||t+e>O.maxBytesTotal)}function J(s){return s===""||s.startsWith("#")?"unsupported":s.startsWith("//")||xe.test(s)?"external":null}function be(s,t,e){return e!==null&&t===e?s:t}function ee(s,t,e,n,a=null){const o=s.trim(),u=J(o);if(u)return{kind:"skip",raw:s,reason:u};const i=ge(o);let p;if(i.startsWith("/")?p=i:i==="~"||i.startsWith("~/")?p=a!==null?le(i,a):null:p=X(i,t),!p)return{kind:"skip",raw:s,reason:"unsupported"};const h=ue(p);return h!==e&&!h.startsWith(`${e}/`)?{kind:"skip",raw:s,reason:"outside-workspace"}:{kind:"local",raw:s,path:h,context:n}}const je={css:"text/css",js:"text/javascript",mjs:"text/javascript",html:"text/html",htm:"text/html",json:"application/json",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",ico:"image/x-icon",bmp:"image/bmp",avif:"image/avif",mp4:"video/mp4",webm:"video/webm",mov:"video/quicktime",m4v:"video/x-m4v",ogv:"video/ogg",mp3:"audio/mpeg",wav:"audio/wav",oga:"audio/ogg",ogg:"audio/ogg",m4a:"audio/mp4",woff:"font/woff",woff2:"font/woff2",ttf:"font/ttf",otf:"font/otf",eot:"application/vnd.ms-fontobject"};function Ee(s){const t=s.lastIndexOf("/"),e=s.lastIndexOf(".");return e<=t?"application/octet-stream":je[s.slice(e+1).toLowerCase()]??"application/octet-stream"}function Se(s){let t="";for(let n=0;n<s.length;n+=32768)t+=String.fromCharCode(...s.subarray(n,n+32768));return btoa(t)}function U(s,t){return`data:${s};base64,${Se(t)}`}const P=/<([a-zA-Z][a-zA-Z0-9]*)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*)(\s*\/?>)/g,$=/([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+))/g;function te(s){const t=new Map;$.lastIndex=0;let e;for(;e=$.exec(s);){const n=e[1].toLowerCase();t.has(n)||t.set(n,e[2]??e[3]??e[4]??"")}return t}function se(s,t){switch(s){case"link":{const e=t.get("rel")??"";return/(^|\s)stylesheet(\s|$)/i.test(e)?t.has("href")?[{name:"href",context:"style",multi:!1}]:[]:[]}case"script":return t.has("src")?[{name:"src",context:"script",multi:!1}]:[];case"img":{const e=[];return t.has("src")&&e.push({name:"src",context:"image",multi:!1}),t.has("srcset")&&e.push({name:"srcset",context:"image",multi:!0}),e}case"source":{const e=[];return t.has("src")&&e.push({name:"src",context:"media",multi:!1}),t.has("srcset")&&e.push({name:"srcset",context:"media",multi:!0}),e}case"video":{const e=[];return t.has("src")&&e.push({name:"src",context:"media",multi:!1}),t.has("poster")&&e.push({name:"poster",context:"media",multi:!1}),e}case"audio":return t.has("src")?[{name:"src",context:"media",multi:!1}]:[];default:return[]}}function ne(s){return s.split(",").map(t=>t.trim()).filter(t=>t!=="").map(t=>{const e=t.search(/\s/);return e===-1?{url:t,descriptor:""}:{url:t.slice(0,e),descriptor:t.slice(e).trim()}})}function Le(s){return s.map(t=>t.descriptor?`${t.url} ${t.descriptor}`:t.url).join(", ")}function D(s,t,e){J(t.trim())||s.has(t)||s.set(t,{raw:t,context:e})}function Ne(s){const t=new Map;P.lastIndex=0;let e;for(;e=P.exec(s);){const n=e[1].toLowerCase(),a=te(e[2]??"");for(const o of se(n,a)){const u=a.get(o.name)??"";if(o.multi)for(const i of ne(u))D(t,i.url,o.context);else D(t,u,o.context)}}return[...t.values()]}function Ae(s,t){let e=!1;const n=ne(s).map(a=>{const o=t[a.url];return o===void 0?a:(e=!0,{url:o,descriptor:a.descriptor})});return e?Le(n):null}function Ce(s,t){return Object.keys(t).length===0?s:(P.lastIndex=0,s.replace(P,(e,n,a,o)=>{const u=te(a),i=se(n.toLowerCase(),u);if(i.length===0)return e;const p=new Map(i.map(d=>[d.name,d]));let h=!1;const S=a.replace($,(d,f,l,w,k)=>{const _=p.get(f.toLowerCase());if(!_)return d;const g=l??w??k??"",j=_.multi?Ae(g,t):t[g]??null;return j===null?d:(h=!0,`${f}="${j}"`)});return h?`<${n}${S}${o}`:e}))}const I=/url\(\s*(?:"([^"]*)"|'([^']*)'|([^'")\s]*))\s*\)/gi,V=/@font-face\s*\{[^}]*\}/gi;function oe(s,t,e){return s??t??e??""}function Te(s){const t=[];V.lastIndex=0;let e;for(;e=V.exec(s);)t.push([e.index,e.index+e[0].length]);return t}function Re(s){const t=Te(s),e=new Map;I.lastIndex=0;let n;for(;n=I.exec(s);){const a=oe(n[1],n[2],n[3]),o=t.some(([u,i])=>n.index>=u&&n.index<i)?"font":"image";D(e,a,o)}return[...e.values()]}function Me(s,t){return Object.keys(t).length===0?s:(I.lastIndex=0,s.replace(I,(e,n,a,o)=>{const u=t[oe(n,a,o)];return u===void 0?e:`url("${u}")`}))}const ze=Object.freeze(["allow-scripts"]),Be="https://pi-studio-preview.invalid/",Pe="default-src 'none'; img-src data:; style-src 'unsafe-inline' data:; script-src 'unsafe-inline' data:; font-src data:; media-src data:",Ie=`<script>(function(){document.addEventListener("click",function(e){var a=e.target&&e.target.closest&&e.target.closest('a[href^="#"]');if(!a)return;var frag=a.getAttribute("href").slice(1);e.preventDefault();if(!frag){window.scrollTo(0,0);return;}var el=document.getElementById(frag)||document.getElementsByName(frag)[0];if(el)el.scrollIntoView();},true);})();<\/script>`,Oe=/<head(\s[^>]*)?>/i,$e=/<html(\s[^>]*)?>/i,De=/<base[\s/>]/i;function He(s,t){const e=Ce(s,t.assets??{}),n=[];t.blockRemote&&n.push(`<meta http-equiv="Content-Security-Policy" content="${Pe}">`),De.test(e)||(n.push(`<base href="${Be}">`),n.push(Ie));const a=n.join("");if(a==="")return e;const o=Oe.exec(e);if(o){const i=o.index+o[0].length;return e.slice(0,i)+a+e.slice(i)}const u=$e.exec(e);if(u){const i=u.index+u[0].length;return e.slice(0,i)+`<head>${a}</head>`+e.slice(i)}return`<head>${a}</head>`+e}const W=6;async function Q(s,t,e){let n=0;async function a(){for(;n<s.length;){const o=s[n];n+=1,await e(o)}}await Promise.all(Array.from({length:Math.min(t,s.length)},a))}function Z(s){const t=new Map;for(const e of s){const n=t.get(e.path);n?n.push(e):t.set(e.path,[e])}return t}async function Fe(s,t){const e={},n=[];let a=0,o=0,u=!1;const i=[];for(const d of s)d.kind==="skip"?n.push({raw:d.raw,reason:d.reason}):i.push(d);function p(d,f){for(const l of d)n.push({raw:l.raw,reason:f})}async function h(d,f){if(u){p(f,"over-cap");return}let l;try{l=await t.fetchBytes(d)}catch{p(f,"fetch-failed");return}if(!q(a,o,l.byteLength)){u=!0,p(f,"over-cap");return}if(a+=1,o+=l.byteLength,f[0].context!=="style"){const m=U(Ee(d),l);for(const b of f)e[b.raw]=m;return}const w=new TextDecoder().decode(l),k=Y(d),_=Re(w).map(m=>ee(m.raw,k,t.root,m.context,t.homeDir)),g=[];for(const m of _)m.kind==="skip"?n.push({raw:m.raw,reason:m.reason}):g.push(m);const j=Z(g);await Q([...j.entries()],W,([m,b])=>h(m,b));const C={};for(const m of g){const b=e[m.raw];b!==void 0&&(C[m.raw]=b)}const L=Me(w,C),E=new TextEncoder().encode(L),y=E.byteLength-l.byteLength;if(y>0&&!q(a-1,o-l.byteLength,E.byteLength)){u=!0,p(f,"over-cap");return}o+=y;const T=U("text/css",E);for(const m of f)e[m.raw]=T}const S=Z(i);return await Q([...S.entries()],W,([d,f])=>h(d,f)),{assets:e,skipped:n}}const Ke="_wrap_1et27_1",qe="_toolbar_1et27_7",Ue="_modeToggle_1et27_20",Ve="_controls_1et27_24",We="_switchLabel_1et27_29",Qe="_streamedNote_1et27_37",Ze="_skippedNote_1et27_45",Ge="_skippedToggle_1et27_52",Xe="_skippedList_1et27_64",Ye="_body_1et27_69",Je="_frame_1et27_73",et="_tooLarge_1et27_79",x={wrap:Ke,toolbar:qe,modeToggle:Ue,controls:Ve,switchLabel:We,streamedNote:Qe,skippedNote:Ze,skippedToggle:Ge,skippedList:Xe,body:Ye,frame:Je,tooLarge:et},tt=ze.join(" "),G=Object.freeze({}),st=Object.freeze([]),re={external:"external","outside-workspace":"outside workspace",unsupported:"unsupported","over-cap":"over cap","fetch-failed":"not found"};function nt(s){const t=new Map;for(const e of s){const n=re[e.reason];t.set(n,(t.get(n)??0)+1)}return[...t.entries()].map(([e,n])=>`${n} ${e}`).join(", ")}function ot(s){let t=2166136261;for(let e=0;e<s.length;e++)t^=s.charCodeAt(e),t=Math.imul(t,16777619);return(t>>>0).toString(16)}function B(s){return`${(s/(1024*1024)).toFixed(1)} MB`}function gt({path:s,workspaceCwd:t}){var H,F;const e=pe(s),[n,a]=v.useState("preview"),[o,u]=v.useState(!1),[i,p]=v.useState(!1),h=ie(),S=K(c=>c.client),d=K(c=>c.daemon),f=de(),l=e.kind==="inline"||e.kind==="streamed"?e.content:null,w=v.useMemo(()=>{const c=X(s,t);return c?Y(c):null},[s,t]),k=v.useMemo(()=>w!==null?be(w,t,f):null,[w,t,f]),_=v.useMemo(()=>l===null||w===null||k===null?[]:Ne(l).map(c=>ee(c.raw,w,k,c.context,f)),[l,w,k,f]),g=v.useMemo(()=>_.some(c=>c.kind==="local"),[_]),j=v.useMemo(()=>_.flatMap(c=>c.kind==="skip"?[{raw:c.raw,reason:c.reason}]:[]),[_]),C=v.useMemo(()=>g&&l!==null?ot(l):"",[l,g]),L=ce({queryKey:M.htmlAssetBundle(s,C),queryFn:()=>k===null?Promise.resolve({assets:{},skipped:[]}):Fe(_,{root:k,homeDir:f,fetchBytes:async ae=>{if(!S||!d)throw new Error("not connected");return(await fe(d).download(ae)).bytes}}),enabled:g,staleTime:1/0}),E=g?((H=L.data)==null?void 0:H.assets)??G:G,y=g?((F=L.data)==null?void 0:F.skipped)??st:j,T=v.useMemo(()=>l===null?null:He(l,{assets:E,blockRemote:o}),[l,E,o]);function m(){h.invalidateQueries({queryKey:M.fileRead(s)}),h.invalidateQueries({queryKey:M.fileDownload(s)}),h.invalidateQueries({queryKey:M.htmlAssetBundleByPath(s)})}switch(e.kind){case"loading":return r.jsxs(N,{children:[r.jsx(R,{size:"sm"})," Loading..."]});case"streaming":return r.jsxs(N,{children:[r.jsx(R,{size:"sm"})," Streaming ",B(e.size)," file..."]});case"stream-error":case"error":return r.jsxs(N,{children:["Error: ",e.message]});case"too-large":{const c=s.split("/").pop()||s;return r.jsx(N,{children:r.jsxs("div",{className:x.tooLarge,children:[r.jsxs("div",{children:[B(e.size)," — too large to display (display ceiling is"," ",B(e.maxDisplayBytes),")."]}),e.downloading?r.jsx(R,{size:"sm"}):e.downloadUrl?r.jsx("a",{href:e.downloadUrl,download:e.downloadName||c,children:r.jsx(A,{size:"sm",children:"Save file"})}):r.jsx(A,{size:"sm",onClick:()=>e.requestDownload(),children:"Download"})]})})}}if(l===null||T===null)return null;if(g&&L.data===void 0)return r.jsxs(N,{children:[r.jsx(R,{size:"sm"})," Loading assets..."]});const b=s.split("/").pop()||s;return r.jsxs("div",{className:x.wrap,children:[r.jsxs("div",{className:x.toolbar,children:[r.jsxs("div",{className:x.modeToggle,children:[r.jsx(A,{size:"xs",variant:n==="preview"?"default":"ghost",onClick:()=>a("preview"),children:"Preview"}),r.jsx(A,{size:"xs",variant:n==="source"?"default":"ghost",onClick:()=>a("source"),children:"Source"})]}),r.jsxs("div",{className:x.controls,children:[r.jsxs("label",{className:x.switchLabel,children:[r.jsx(ye,{checked:o,onCheckedChange:u,"aria-label":"Block remote resources"}),"Block remote resources"]}),r.jsx(A,{size:"xs",variant:"ghost",onClick:m,children:"Reload"})]})]}),e.kind==="streamed"?r.jsxs("div",{className:x.streamedNote,children:[B(e.size)," file streamed"]}):null,y.length>0?r.jsxs("div",{className:x.skippedNote,children:[r.jsxs("button",{type:"button",className:x.skippedToggle,onClick:()=>p(c=>!c),children:[y.length," reference",y.length===1?"":"s"," not inlined (",nt(y),")"]}),i?r.jsx("ul",{className:x.skippedList,children:y.map(c=>r.jsxs("li",{children:[c.raw," — ",re[c.reason]]},c.raw))}):null]}):null,r.jsxs("div",{className:x.body,children:[r.jsx("iframe",{sandbox:tt,srcDoc:T,referrerPolicy:"no-referrer",allow:"",className:x.frame,style:n==="preview"?void 0:{display:"none"},title:b}),n==="source"?r.jsx(he,{path:s,content:l}):null]})]})}export{gt as HtmlViewer};
1
+ import{j as r,r as v}from"./vendor-react-DQUAl2K8.js";import{a as ie,u as ce}from"./vendor-query-i7fr__Xm.js";import{n as le,r as X,c as ue,d as Y,u as K,k as de,E as N,S as R,B as A,a as M,t as fe}from"./index-CWQ7GUFk.js";import{M as me}from"./vendor-DVp0ZLQo.js";import{u as pe,C as he}from"./CodeView-GqSGzzdY.js";import{p as ge,S as xe}from"./href-resolution-Djd1Zdrz.js";import"./vendor-icons-CQPWxe0u.js";import"./vendor-overlays-BfyojyuH.js";import"./vendor-dnd-CayJj8TC.js";import"./use-file-download-zBrxUX0K.js";const we="_track_841zp_3",_e="_checked_841zp_23",ve="_disabled_841zp_27",ke="_thumb_841zp_32",z={track:we,checked:_e,disabled:ve,thumb:ke};function ye({checked:s,onCheckedChange:t,disabled:e=!1,id:n,"aria-label":a,className:o}){return r.jsx("button",{id:n,role:"switch","aria-checked":s,"aria-label":a,disabled:e,className:me(z.track,s&&z.checked,e&&z.disabled,o),onClick:()=>!e&&t(!s),type:"button",children:r.jsx("span",{className:z.thumb})})}const O={maxCount:64,maxBytesPerAsset:2*1024*1024,maxBytesTotal:16*1024*1024};function q(s,t,e){return!(s>=O.maxCount||e>O.maxBytesPerAsset||t+e>O.maxBytesTotal)}function J(s){return s===""||s.startsWith("#")?"unsupported":s.startsWith("//")||xe.test(s)?"external":null}function be(s,t,e){return e!==null&&t===e?s:t}function ee(s,t,e,n,a=null){const o=s.trim(),u=J(o);if(u)return{kind:"skip",raw:s,reason:u};const i=ge(o);let p;if(i.startsWith("/")?p=i:i==="~"||i.startsWith("~/")?p=a!==null?le(i,a):null:p=X(i,t),!p)return{kind:"skip",raw:s,reason:"unsupported"};const h=ue(p);return h!==e&&!h.startsWith(`${e}/`)?{kind:"skip",raw:s,reason:"outside-workspace"}:{kind:"local",raw:s,path:h,context:n}}const je={css:"text/css",js:"text/javascript",mjs:"text/javascript",html:"text/html",htm:"text/html",json:"application/json",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",ico:"image/x-icon",bmp:"image/bmp",avif:"image/avif",mp4:"video/mp4",webm:"video/webm",mov:"video/quicktime",m4v:"video/x-m4v",ogv:"video/ogg",mp3:"audio/mpeg",wav:"audio/wav",oga:"audio/ogg",ogg:"audio/ogg",m4a:"audio/mp4",woff:"font/woff",woff2:"font/woff2",ttf:"font/ttf",otf:"font/otf",eot:"application/vnd.ms-fontobject"};function Ee(s){const t=s.lastIndexOf("/"),e=s.lastIndexOf(".");return e<=t?"application/octet-stream":je[s.slice(e+1).toLowerCase()]??"application/octet-stream"}function Se(s){let t="";for(let n=0;n<s.length;n+=32768)t+=String.fromCharCode(...s.subarray(n,n+32768));return btoa(t)}function U(s,t){return`data:${s};base64,${Se(t)}`}const P=/<([a-zA-Z][a-zA-Z0-9]*)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*)(\s*\/?>)/g,$=/([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+))/g;function te(s){const t=new Map;$.lastIndex=0;let e;for(;e=$.exec(s);){const n=e[1].toLowerCase();t.has(n)||t.set(n,e[2]??e[3]??e[4]??"")}return t}function se(s,t){switch(s){case"link":{const e=t.get("rel")??"";return/(^|\s)stylesheet(\s|$)/i.test(e)?t.has("href")?[{name:"href",context:"style",multi:!1}]:[]:[]}case"script":return t.has("src")?[{name:"src",context:"script",multi:!1}]:[];case"img":{const e=[];return t.has("src")&&e.push({name:"src",context:"image",multi:!1}),t.has("srcset")&&e.push({name:"srcset",context:"image",multi:!0}),e}case"source":{const e=[];return t.has("src")&&e.push({name:"src",context:"media",multi:!1}),t.has("srcset")&&e.push({name:"srcset",context:"media",multi:!0}),e}case"video":{const e=[];return t.has("src")&&e.push({name:"src",context:"media",multi:!1}),t.has("poster")&&e.push({name:"poster",context:"media",multi:!1}),e}case"audio":return t.has("src")?[{name:"src",context:"media",multi:!1}]:[];default:return[]}}function ne(s){return s.split(",").map(t=>t.trim()).filter(t=>t!=="").map(t=>{const e=t.search(/\s/);return e===-1?{url:t,descriptor:""}:{url:t.slice(0,e),descriptor:t.slice(e).trim()}})}function Le(s){return s.map(t=>t.descriptor?`${t.url} ${t.descriptor}`:t.url).join(", ")}function D(s,t,e){J(t.trim())||s.has(t)||s.set(t,{raw:t,context:e})}function Ne(s){const t=new Map;P.lastIndex=0;let e;for(;e=P.exec(s);){const n=e[1].toLowerCase(),a=te(e[2]??"");for(const o of se(n,a)){const u=a.get(o.name)??"";if(o.multi)for(const i of ne(u))D(t,i.url,o.context);else D(t,u,o.context)}}return[...t.values()]}function Ae(s,t){let e=!1;const n=ne(s).map(a=>{const o=t[a.url];return o===void 0?a:(e=!0,{url:o,descriptor:a.descriptor})});return e?Le(n):null}function Ce(s,t){return Object.keys(t).length===0?s:(P.lastIndex=0,s.replace(P,(e,n,a,o)=>{const u=te(a),i=se(n.toLowerCase(),u);if(i.length===0)return e;const p=new Map(i.map(d=>[d.name,d]));let h=!1;const S=a.replace($,(d,f,l,w,k)=>{const _=p.get(f.toLowerCase());if(!_)return d;const g=l??w??k??"",j=_.multi?Ae(g,t):t[g]??null;return j===null?d:(h=!0,`${f}="${j}"`)});return h?`<${n}${S}${o}`:e}))}const I=/url\(\s*(?:"([^"]*)"|'([^']*)'|([^'")\s]*))\s*\)/gi,V=/@font-face\s*\{[^}]*\}/gi;function oe(s,t,e){return s??t??e??""}function Te(s){const t=[];V.lastIndex=0;let e;for(;e=V.exec(s);)t.push([e.index,e.index+e[0].length]);return t}function Re(s){const t=Te(s),e=new Map;I.lastIndex=0;let n;for(;n=I.exec(s);){const a=oe(n[1],n[2],n[3]),o=t.some(([u,i])=>n.index>=u&&n.index<i)?"font":"image";D(e,a,o)}return[...e.values()]}function Me(s,t){return Object.keys(t).length===0?s:(I.lastIndex=0,s.replace(I,(e,n,a,o)=>{const u=t[oe(n,a,o)];return u===void 0?e:`url("${u}")`}))}const ze=Object.freeze(["allow-scripts"]),Be="https://pi-studio-preview.invalid/",Pe="default-src 'none'; img-src data:; style-src 'unsafe-inline' data:; script-src 'unsafe-inline' data:; font-src data:; media-src data:",Ie=`<script>(function(){document.addEventListener("click",function(e){var a=e.target&&e.target.closest&&e.target.closest('a[href^="#"]');if(!a)return;var frag=a.getAttribute("href").slice(1);e.preventDefault();if(!frag){window.scrollTo(0,0);return;}var el=document.getElementById(frag)||document.getElementsByName(frag)[0];if(el)el.scrollIntoView();},true);})();<\/script>`,Oe=/<head(\s[^>]*)?>/i,$e=/<html(\s[^>]*)?>/i,De=/<base[\s/>]/i;function He(s,t){const e=Ce(s,t.assets??{}),n=[];t.blockRemote&&n.push(`<meta http-equiv="Content-Security-Policy" content="${Pe}">`),De.test(e)||(n.push(`<base href="${Be}">`),n.push(Ie));const a=n.join("");if(a==="")return e;const o=Oe.exec(e);if(o){const i=o.index+o[0].length;return e.slice(0,i)+a+e.slice(i)}const u=$e.exec(e);if(u){const i=u.index+u[0].length;return e.slice(0,i)+`<head>${a}</head>`+e.slice(i)}return`<head>${a}</head>`+e}const W=6;async function Q(s,t,e){let n=0;async function a(){for(;n<s.length;){const o=s[n];n+=1,await e(o)}}await Promise.all(Array.from({length:Math.min(t,s.length)},a))}function Z(s){const t=new Map;for(const e of s){const n=t.get(e.path);n?n.push(e):t.set(e.path,[e])}return t}async function Fe(s,t){const e={},n=[];let a=0,o=0,u=!1;const i=[];for(const d of s)d.kind==="skip"?n.push({raw:d.raw,reason:d.reason}):i.push(d);function p(d,f){for(const l of d)n.push({raw:l.raw,reason:f})}async function h(d,f){if(u){p(f,"over-cap");return}let l;try{l=await t.fetchBytes(d)}catch{p(f,"fetch-failed");return}if(!q(a,o,l.byteLength)){u=!0,p(f,"over-cap");return}if(a+=1,o+=l.byteLength,f[0].context!=="style"){const m=U(Ee(d),l);for(const b of f)e[b.raw]=m;return}const w=new TextDecoder().decode(l),k=Y(d),_=Re(w).map(m=>ee(m.raw,k,t.root,m.context,t.homeDir)),g=[];for(const m of _)m.kind==="skip"?n.push({raw:m.raw,reason:m.reason}):g.push(m);const j=Z(g);await Q([...j.entries()],W,([m,b])=>h(m,b));const C={};for(const m of g){const b=e[m.raw];b!==void 0&&(C[m.raw]=b)}const L=Me(w,C),E=new TextEncoder().encode(L),y=E.byteLength-l.byteLength;if(y>0&&!q(a-1,o-l.byteLength,E.byteLength)){u=!0,p(f,"over-cap");return}o+=y;const T=U("text/css",E);for(const m of f)e[m.raw]=T}const S=Z(i);return await Q([...S.entries()],W,([d,f])=>h(d,f)),{assets:e,skipped:n}}const Ke="_wrap_1et27_1",qe="_toolbar_1et27_7",Ue="_modeToggle_1et27_20",Ve="_controls_1et27_24",We="_switchLabel_1et27_29",Qe="_streamedNote_1et27_37",Ze="_skippedNote_1et27_45",Ge="_skippedToggle_1et27_52",Xe="_skippedList_1et27_64",Ye="_body_1et27_69",Je="_frame_1et27_73",et="_tooLarge_1et27_79",x={wrap:Ke,toolbar:qe,modeToggle:Ue,controls:Ve,switchLabel:We,streamedNote:Qe,skippedNote:Ze,skippedToggle:Ge,skippedList:Xe,body:Ye,frame:Je,tooLarge:et},tt=ze.join(" "),G=Object.freeze({}),st=Object.freeze([]),re={external:"external","outside-workspace":"outside workspace",unsupported:"unsupported","over-cap":"over cap","fetch-failed":"not found"};function nt(s){const t=new Map;for(const e of s){const n=re[e.reason];t.set(n,(t.get(n)??0)+1)}return[...t.entries()].map(([e,n])=>`${n} ${e}`).join(", ")}function ot(s){let t=2166136261;for(let e=0;e<s.length;e++)t^=s.charCodeAt(e),t=Math.imul(t,16777619);return(t>>>0).toString(16)}function B(s){return`${(s/(1024*1024)).toFixed(1)} MB`}function gt({path:s,workspaceCwd:t}){var H,F;const e=pe(s),[n,a]=v.useState("preview"),[o,u]=v.useState(!1),[i,p]=v.useState(!1),h=ie(),S=K(c=>c.client),d=K(c=>c.daemon),f=de(),l=e.kind==="inline"||e.kind==="streamed"?e.content:null,w=v.useMemo(()=>{const c=X(s,t);return c?Y(c):null},[s,t]),k=v.useMemo(()=>w!==null?be(w,t,f):null,[w,t,f]),_=v.useMemo(()=>l===null||w===null||k===null?[]:Ne(l).map(c=>ee(c.raw,w,k,c.context,f)),[l,w,k,f]),g=v.useMemo(()=>_.some(c=>c.kind==="local"),[_]),j=v.useMemo(()=>_.flatMap(c=>c.kind==="skip"?[{raw:c.raw,reason:c.reason}]:[]),[_]),C=v.useMemo(()=>g&&l!==null?ot(l):"",[l,g]),L=ce({queryKey:M.htmlAssetBundle(s,C),queryFn:()=>k===null?Promise.resolve({assets:{},skipped:[]}):Fe(_,{root:k,homeDir:f,fetchBytes:async ae=>{if(!S||!d)throw new Error("not connected");return(await fe(d).download(ae)).bytes}}),enabled:g,staleTime:1/0}),E=g?((H=L.data)==null?void 0:H.assets)??G:G,y=g?((F=L.data)==null?void 0:F.skipped)??st:j,T=v.useMemo(()=>l===null?null:He(l,{assets:E,blockRemote:o}),[l,E,o]);function m(){h.invalidateQueries({queryKey:M.fileRead(s)}),h.invalidateQueries({queryKey:M.fileDownload(s)}),h.invalidateQueries({queryKey:M.htmlAssetBundleByPath(s)})}switch(e.kind){case"loading":return r.jsxs(N,{children:[r.jsx(R,{size:"sm"})," Loading..."]});case"streaming":return r.jsxs(N,{children:[r.jsx(R,{size:"sm"})," Streaming ",B(e.size)," file..."]});case"stream-error":case"error":return r.jsxs(N,{children:["Error: ",e.message]});case"too-large":{const c=s.split("/").pop()||s;return r.jsx(N,{children:r.jsxs("div",{className:x.tooLarge,children:[r.jsxs("div",{children:[B(e.size)," — too large to display (display ceiling is"," ",B(e.maxDisplayBytes),")."]}),e.downloading?r.jsx(R,{size:"sm"}):e.downloadUrl?r.jsx("a",{href:e.downloadUrl,download:e.downloadName||c,children:r.jsx(A,{size:"sm",children:"Save file"})}):r.jsx(A,{size:"sm",onClick:()=>e.requestDownload(),children:"Download"})]})})}}if(l===null||T===null)return null;if(g&&L.data===void 0)return r.jsxs(N,{children:[r.jsx(R,{size:"sm"})," Loading assets..."]});const b=s.split("/").pop()||s;return r.jsxs("div",{className:x.wrap,children:[r.jsxs("div",{className:x.toolbar,children:[r.jsxs("div",{className:x.modeToggle,children:[r.jsx(A,{size:"xs",variant:n==="preview"?"default":"ghost",onClick:()=>a("preview"),children:"Preview"}),r.jsx(A,{size:"xs",variant:n==="source"?"default":"ghost",onClick:()=>a("source"),children:"Source"})]}),r.jsxs("div",{className:x.controls,children:[r.jsxs("label",{className:x.switchLabel,children:[r.jsx(ye,{checked:o,onCheckedChange:u,"aria-label":"Block remote resources"}),"Block remote resources"]}),r.jsx(A,{size:"xs",variant:"ghost",onClick:m,children:"Reload"})]})]}),e.kind==="streamed"?r.jsxs("div",{className:x.streamedNote,children:[B(e.size)," file streamed"]}):null,y.length>0?r.jsxs("div",{className:x.skippedNote,children:[r.jsxs("button",{type:"button",className:x.skippedToggle,onClick:()=>p(c=>!c),children:[y.length," reference",y.length===1?"":"s"," not inlined (",nt(y),")"]}),i?r.jsx("ul",{className:x.skippedList,children:y.map(c=>r.jsxs("li",{children:[c.raw," — ",re[c.reason]]},c.raw))}):null]}):null,r.jsxs("div",{className:x.body,children:[r.jsx("iframe",{sandbox:tt,srcDoc:T,referrerPolicy:"no-referrer",allow:"",className:x.frame,style:n==="preview"?void 0:{display:"none"},title:b}),n==="source"?r.jsx(he,{path:s,content:l}):null]})]})}export{gt as HtmlViewer};
@@ -1 +1 @@
1
- import{j as o}from"./vendor-react-DQUAl2K8.js";import{E as s,S as a}from"./index-CRcOAGBq.js";import{u as t}from"./use-file-download-C5RZM273.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-DVp0ZLQo.js";import"./vendor-icons-CQPWxe0u.js";import"./vendor-overlays-BfyojyuH.js";import"./vendor-dnd-CayJj8TC.js";const n="_wrap_1vzo5_1",m="_image_1vzo5_15",i={wrap:n,image:m};function x({path:e,workspaceCwd:p}){const r=t(e);return r.isLoading?o.jsxs(s,{children:[o.jsx(a,{size:"sm"})," Loading image..."]}):r.isError?o.jsxs(s,{children:["Error: ",r.error instanceof Error?r.error.message:"unknown error"]}):r.data?o.jsx("div",{className:i.wrap,children:o.jsx("img",{className:i.image,src:r.data.objectUrl,alt:e.split("/").pop()||e})}):null}export{x as ImageViewer};
1
+ import{j as o}from"./vendor-react-DQUAl2K8.js";import{E as s,S as a}from"./index-CWQ7GUFk.js";import{u as t}from"./use-file-download-zBrxUX0K.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-DVp0ZLQo.js";import"./vendor-icons-CQPWxe0u.js";import"./vendor-overlays-BfyojyuH.js";import"./vendor-dnd-CayJj8TC.js";const n="_wrap_1vzo5_1",m="_image_1vzo5_15",i={wrap:n,image:m};function x({path:e,workspaceCwd:p}){const r=t(e);return r.isLoading?o.jsxs(s,{children:[o.jsx(a,{size:"sm"})," Loading image..."]}):r.isError?o.jsxs(s,{children:["Error: ",r.error instanceof Error?r.error.message:"unknown error"]}):r.data?o.jsx("div",{className:i.wrap,children:o.jsx("img",{className:i.image,src:r.data.objectUrl,alt:e.split("/").pop()||e})}):null}export{x as ImageViewer};
@@ -1 +1 @@
1
- import{r as x,j as e}from"./vendor-react-DQUAl2K8.js";import{r as j,d as g,B as i,E as a,S as c}from"./index-CRcOAGBq.js";import{u as w,C as h}from"./CodeView-DWNPh5RV.js";import{M as v}from"./markdown-S4LuDRgo.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-DVp0ZLQo.js";import"./vendor-icons-CQPWxe0u.js";import"./vendor-overlays-BfyojyuH.js";import"./vendor-dnd-CayJj8TC.js";import"./use-file-download-C5RZM273.js";import"./vendor-highlight-BjiGXuEM.js";import"./vendor-markdown-Bc_dOmsB.js";import"./href-resolution-Bu3Ezb0Z.js";const _="_wrap_g5iym_1",f="_toolbar_g5iym_6",y="_rendered_g5iym_17",z="_streamedNote_g5iym_21",N="_tooLarge_g5iym_29",t={wrap:_,toolbar:f,rendered:y,streamedNote:z,tooLarge:N};function n(r){return`${(r/(1024*1024)).toFixed(1)} MB`}function q({path:r,workspaceCwd:d}){const s=w(r),[l,m]=x.useState("preview"),p=x.useMemo(()=>{const o=j(r,d);return o?g(o):null},[r,d]);switch(s.kind){case"loading":return e.jsxs(a,{children:[e.jsx(c,{size:"sm"})," Loading..."]});case"streaming":return e.jsxs(a,{children:[e.jsx(c,{size:"sm"})," Streaming ",n(s.size)," file..."]});case"stream-error":case"error":return e.jsxs(a,{children:["Error: ",s.message]});case"too-large":{const o=r.split("/").pop()||r;return e.jsx(a,{children:e.jsxs("div",{className:t.tooLarge,children:[e.jsxs("div",{children:[n(s.size)," — too large to display (display ceiling is"," ",n(s.maxDisplayBytes),")."]}),s.downloading?e.jsx(c,{size:"sm"}):s.downloadUrl?e.jsx("a",{href:s.downloadUrl,download:s.downloadName||o,children:e.jsx(i,{size:"sm",children:"Save file"})}):e.jsx(i,{size:"sm",onClick:()=>s.requestDownload(),children:"Download"})]})})}case"inline":case"streamed":{const o=s.content,u=s.kind==="streamed";return e.jsxs("div",{className:t.wrap,children:[e.jsxs("div",{className:t.toolbar,children:[e.jsx(i,{size:"xs",variant:l==="preview"?"default":"ghost",onClick:()=>m("preview"),children:"Preview"}),e.jsx(i,{size:"xs",variant:l==="source"?"default":"ghost",onClick:()=>m("source"),children:"Source"})]}),u?e.jsxs("div",{className:t.streamedNote,children:[n(s.size)," file streamed"]}):null,l==="preview"?e.jsx("div",{className:t.rendered,children:e.jsx(v,{text:o,assetBase:p,workspaceCwd:d})}):e.jsx(h,{path:r,content:o})]})}}}export{q as MarkdownFileViewer};
1
+ import{r as x,j as e}from"./vendor-react-DQUAl2K8.js";import{r as j,d as g,B as i,E as a,S as c}from"./index-CWQ7GUFk.js";import{u as w,C as h}from"./CodeView-GqSGzzdY.js";import{M as v}from"./markdown-Bbsr2xVg.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-DVp0ZLQo.js";import"./vendor-icons-CQPWxe0u.js";import"./vendor-overlays-BfyojyuH.js";import"./vendor-dnd-CayJj8TC.js";import"./use-file-download-zBrxUX0K.js";import"./vendor-highlight-BjiGXuEM.js";import"./vendor-markdown-Bc_dOmsB.js";import"./href-resolution-Djd1Zdrz.js";const _="_wrap_g5iym_1",f="_toolbar_g5iym_6",y="_rendered_g5iym_17",z="_streamedNote_g5iym_21",N="_tooLarge_g5iym_29",t={wrap:_,toolbar:f,rendered:y,streamedNote:z,tooLarge:N};function n(r){return`${(r/(1024*1024)).toFixed(1)} MB`}function q({path:r,workspaceCwd:d}){const s=w(r),[l,m]=x.useState("preview"),p=x.useMemo(()=>{const o=j(r,d);return o?g(o):null},[r,d]);switch(s.kind){case"loading":return e.jsxs(a,{children:[e.jsx(c,{size:"sm"})," Loading..."]});case"streaming":return e.jsxs(a,{children:[e.jsx(c,{size:"sm"})," Streaming ",n(s.size)," file..."]});case"stream-error":case"error":return e.jsxs(a,{children:["Error: ",s.message]});case"too-large":{const o=r.split("/").pop()||r;return e.jsx(a,{children:e.jsxs("div",{className:t.tooLarge,children:[e.jsxs("div",{children:[n(s.size)," — too large to display (display ceiling is"," ",n(s.maxDisplayBytes),")."]}),s.downloading?e.jsx(c,{size:"sm"}):s.downloadUrl?e.jsx("a",{href:s.downloadUrl,download:s.downloadName||o,children:e.jsx(i,{size:"sm",children:"Save file"})}):e.jsx(i,{size:"sm",onClick:()=>s.requestDownload(),children:"Download"})]})})}case"inline":case"streamed":{const o=s.content,u=s.kind==="streamed";return e.jsxs("div",{className:t.wrap,children:[e.jsxs("div",{className:t.toolbar,children:[e.jsx(i,{size:"xs",variant:l==="preview"?"default":"ghost",onClick:()=>m("preview"),children:"Preview"}),e.jsx(i,{size:"xs",variant:l==="source"?"default":"ghost",onClick:()=>m("source"),children:"Source"})]}),u?e.jsxs("div",{className:t.streamedNote,children:[n(s.size)," file streamed"]}):null,l==="preview"?e.jsx("div",{className:t.rendered,children:e.jsx(v,{text:o,assetBase:p,workspaceCwd:d})}):e.jsx(h,{path:r,content:o})]})}}}export{q as MarkdownFileViewer};
@@ -1 +1 @@
1
- import{j as o,r as i}from"./vendor-react-DQUAl2K8.js";import{u as O,l as W,P as g,E as F,S as C,j as I,o as q,d as D,m as U,C as X,p as Y,f as z}from"./index-CRcOAGBq.js";import{L as G}from"./vendor-molviewer-DSzG6_a2.js";import{u as H}from"./use-file-download-C5RZM273.js";import{u as K}from"./use-file-watch-C6t0UJSi.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-DVp0ZLQo.js";import"./vendor-icons-CQPWxe0u.js";import"./vendor-overlays-BfyojyuH.js";import"./vendor-dnd-CayJj8TC.js";const J="_badge_iymy8_3",Q={badge:J};function Z(e){switch(e){case"success":return{token:"statusSuccess"};case"error":return{token:"statusDanger"};case"warning":return{token:"statusWarning"};case"muted":return{token:"foregroundMuted"}}}function v({label:e,variant:r,className:t}){const{token:l}=Z(r),n=`var(--pi-color-${l})`;return o.jsx("span",{className:`${Q.badge}${t?` ${t}`:""}`,style:{backgroundColor:`color-mix(in srgb, ${n} 18%, transparent)`,borderColor:`color-mix(in srgb, ${n} 45%, transparent)`,color:n},children:e})}function ee(e,r){return!e||!r?null:{url:r,name:e.split("/").pop()||e}}function re({changedAt:e,lastAppliedAt:r,modified:t}){return!(e===null||t||e===r)}const oe={empty_path:"Nothing to save.",too_large:"File is too large to save (over 5 MiB).",not_found:"The file no longer exists.",unreadable:"The file could not be read.",not_a_file:"That path is not a file."};async function te(e,r,t){const l=await e.connection.request("file_write_request",{path:r,content:t});if(!l.ok){const n=l.error??"";throw new Error(oe[n]??n??"Failed to save")}}const ne="mol2";function se(e){const{sourcePath:r,monomers:t,attempt:l}=e,n=l>0?`_${l+1}`:"";return`${ae(r)}_polymer_${t}${n}.${ne}`}function ae(e){return(e.split("/").pop()??"").replace(/\.[^.]+$/,"").trim()||"polymer"}const le={"--canvas":"var(--pi-color-surface0)","--well":"var(--pi-color-surface0)","--recess":"var(--pi-color-surface1)","--chrome":"var(--pi-color-surface1)","--control":"var(--pi-color-surface2)","--control-hover":"var(--pi-color-surface3)","--control-strong-hover":"var(--pi-color-surface4)","--border-control":"var(--pi-color-border)","--border-input":"var(--pi-color-border)","--popover":"var(--pi-color-surface1)","--popover-item-hover":"var(--pi-color-surface2)","--row-hover":"var(--pi-color-surface2)","--border-popover":"var(--pi-color-border)","--text-primary":"var(--pi-color-foreground)","--text-on-control":"var(--pi-color-foreground)"},ce="_wrap_tixu9_1",ie="_molViewer_tixu9_4",ue="_badges_tixu9_8",y={wrap:ce,molViewer:ie,badges:ue},de=50;async function fe(e){const{client:r,upload:t,sourcePath:l,monomers:n,text:f}=e,p=D(l);let a=null,c="";for(let u=0;u<de&&a===null;u+=1){c=se({sourcePath:l,monomers:n,attempt:u});try{a=await U(r,p,c,"file")}catch(m){if(m instanceof X&&m.code==="exists")continue;throw m}}if(a===null)throw new Error(`No free name for ${c} — too many builds in this folder.`);try{await t(p,new File([f],c,{type:"chemical/x-mol2"}))}catch(u){throw await Y(r,a).catch(()=>{}),u}return a}function me({path:e,workspaceCwd:r,tabId:t,isActive:l,onModifiedChange:n}){var T;const f=O(s=>s.client),{upload:p}=W(),a=H(e??"",!!e),{changedAt:c}=K(e),u=i.useRef(null),m=i.useRef(!1),[w,_]=i.useState(null),[h,L]=i.useState(!1),[S,E]=i.useState(null),[j,x]=i.useState(null),[$,M]=i.useState(null),b=i.useRef(null),P=((T=a.data)==null?void 0:T.objectUrl)??null,N=i.useMemo(()=>ee(e,P),[e,P]);i.useEffect(()=>{re({changedAt:c,lastAppliedAt:b.current,modified:h})&&(b.current=c,a.refetch())},[c,h,a.refetch]);const k=c!==null&&c!==b.current&&h;async function A(s){if(e){if(!f){E("Not connected — cannot save.");return}E(null);try{await te(f,e,s.text()),s.saved()}catch(d){E(d instanceof Error?d.message:"Failed to save")}}}async function B(s){if(e){if(!f){x("Not connected — cannot save the polymer.");return}x(null),M(null);try{const d=await fe({client:f,upload:p,sourcePath:e,monomers:s.monomers,text:s.text()});s.report.clashes>0&&M(`${s.report.clashes} close contacts — relax the geometry before simulating`);const V=I.getState().paneOfTab(r,t);q(d,r,V??void 0)}catch(d){x(d instanceof Error?d.message:"Failed to save the polymer")}}}const R=(a.isError?a.error instanceof Error?a.error.message:"download failed":null)??(w==null?void 0:w.message)??null;return e&&a.isPending?o.jsx(g,{children:o.jsxs(F,{children:[o.jsx(C,{size:"sm"})," Loading..."]})}):R?o.jsx(g,{children:o.jsxs(F,{children:["Error: ",R]})}):o.jsxs(g,{className:y.wrap,"data-molecule-active":l?"true":"false",children:[o.jsxs("div",{className:y.badges,children:[k&&o.jsx(v,{label:"File changed on disk",variant:"muted"}),S&&o.jsx(v,{label:`Save failed: ${S}`,variant:"error"}),j&&o.jsx(v,{label:`Polymer build: ${j}`,variant:"error"}),$&&o.jsx(v,{label:$,variant:"warning"})]}),o.jsx(G,{ref:u,className:y.molViewer,theme:le,source:N,sourceMode:m.current?"update":"replace",onLoad:()=>{m.current=!0,_(null)},onLoadError:s=>_(s.error),onModifiedChange:s=>{L(s),n==null||n(s)},onSave:e?A:void 0,onPolymerBuild:e?B:void 0})]})}function je({tab:e}){const{path:r}=e.data,t=z(e.id);return o.jsx(g,{children:o.jsx(me,{path:r,workspaceCwd:e.workspaceCwd,tabId:e.id,isActive:t})})}export{je as MoleculeViewerPanel};
1
+ import{j as o,r as i}from"./vendor-react-DQUAl2K8.js";import{u as O,l as W,P as g,E as F,S as C,j as I,o as q,d as D,m as U,C as X,p as Y,f as z}from"./index-CWQ7GUFk.js";import{L as G}from"./vendor-molviewer-DSzG6_a2.js";import{u as H}from"./use-file-download-zBrxUX0K.js";import{u as K}from"./use-file-watch-BLigZDy5.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-DVp0ZLQo.js";import"./vendor-icons-CQPWxe0u.js";import"./vendor-overlays-BfyojyuH.js";import"./vendor-dnd-CayJj8TC.js";const J="_badge_iymy8_3",Q={badge:J};function Z(e){switch(e){case"success":return{token:"statusSuccess"};case"error":return{token:"statusDanger"};case"warning":return{token:"statusWarning"};case"muted":return{token:"foregroundMuted"}}}function v({label:e,variant:r,className:t}){const{token:l}=Z(r),n=`var(--pi-color-${l})`;return o.jsx("span",{className:`${Q.badge}${t?` ${t}`:""}`,style:{backgroundColor:`color-mix(in srgb, ${n} 18%, transparent)`,borderColor:`color-mix(in srgb, ${n} 45%, transparent)`,color:n},children:e})}function ee(e,r){return!e||!r?null:{url:r,name:e.split("/").pop()||e}}function re({changedAt:e,lastAppliedAt:r,modified:t}){return!(e===null||t||e===r)}const oe={empty_path:"Nothing to save.",too_large:"File is too large to save (over 5 MiB).",not_found:"The file no longer exists.",unreadable:"The file could not be read.",not_a_file:"That path is not a file."};async function te(e,r,t){const l=await e.connection.request("file_write_request",{path:r,content:t});if(!l.ok){const n=l.error??"";throw new Error(oe[n]??n??"Failed to save")}}const ne="mol2";function se(e){const{sourcePath:r,monomers:t,attempt:l}=e,n=l>0?`_${l+1}`:"";return`${ae(r)}_polymer_${t}${n}.${ne}`}function ae(e){return(e.split("/").pop()??"").replace(/\.[^.]+$/,"").trim()||"polymer"}const le={"--canvas":"var(--pi-color-surface0)","--well":"var(--pi-color-surface0)","--recess":"var(--pi-color-surface1)","--chrome":"var(--pi-color-surface1)","--control":"var(--pi-color-surface2)","--control-hover":"var(--pi-color-surface3)","--control-strong-hover":"var(--pi-color-surface4)","--border-control":"var(--pi-color-border)","--border-input":"var(--pi-color-border)","--popover":"var(--pi-color-surface1)","--popover-item-hover":"var(--pi-color-surface2)","--row-hover":"var(--pi-color-surface2)","--border-popover":"var(--pi-color-border)","--text-primary":"var(--pi-color-foreground)","--text-on-control":"var(--pi-color-foreground)"},ce="_wrap_tixu9_1",ie="_molViewer_tixu9_4",ue="_badges_tixu9_8",y={wrap:ce,molViewer:ie,badges:ue},de=50;async function fe(e){const{client:r,upload:t,sourcePath:l,monomers:n,text:f}=e,p=D(l);let a=null,c="";for(let u=0;u<de&&a===null;u+=1){c=se({sourcePath:l,monomers:n,attempt:u});try{a=await U(r,p,c,"file")}catch(m){if(m instanceof X&&m.code==="exists")continue;throw m}}if(a===null)throw new Error(`No free name for ${c} — too many builds in this folder.`);try{await t(p,new File([f],c,{type:"chemical/x-mol2"}))}catch(u){throw await Y(r,a).catch(()=>{}),u}return a}function me({path:e,workspaceCwd:r,tabId:t,isActive:l,onModifiedChange:n}){var T;const f=O(s=>s.client),{upload:p}=W(),a=H(e??"",!!e),{changedAt:c}=K(e),u=i.useRef(null),m=i.useRef(!1),[w,_]=i.useState(null),[h,L]=i.useState(!1),[S,E]=i.useState(null),[j,x]=i.useState(null),[$,M]=i.useState(null),b=i.useRef(null),P=((T=a.data)==null?void 0:T.objectUrl)??null,N=i.useMemo(()=>ee(e,P),[e,P]);i.useEffect(()=>{re({changedAt:c,lastAppliedAt:b.current,modified:h})&&(b.current=c,a.refetch())},[c,h,a.refetch]);const k=c!==null&&c!==b.current&&h;async function A(s){if(e){if(!f){E("Not connected — cannot save.");return}E(null);try{await te(f,e,s.text()),s.saved()}catch(d){E(d instanceof Error?d.message:"Failed to save")}}}async function B(s){if(e){if(!f){x("Not connected — cannot save the polymer.");return}x(null),M(null);try{const d=await fe({client:f,upload:p,sourcePath:e,monomers:s.monomers,text:s.text()});s.report.clashes>0&&M(`${s.report.clashes} close contacts — relax the geometry before simulating`);const V=I.getState().paneOfTab(r,t);q(d,r,V??void 0)}catch(d){x(d instanceof Error?d.message:"Failed to save the polymer")}}}const R=(a.isError?a.error instanceof Error?a.error.message:"download failed":null)??(w==null?void 0:w.message)??null;return e&&a.isPending?o.jsx(g,{children:o.jsxs(F,{children:[o.jsx(C,{size:"sm"})," Loading..."]})}):R?o.jsx(g,{children:o.jsxs(F,{children:["Error: ",R]})}):o.jsxs(g,{className:y.wrap,"data-molecule-active":l?"true":"false",children:[o.jsxs("div",{className:y.badges,children:[k&&o.jsx(v,{label:"File changed on disk",variant:"muted"}),S&&o.jsx(v,{label:`Save failed: ${S}`,variant:"error"}),j&&o.jsx(v,{label:`Polymer build: ${j}`,variant:"error"}),$&&o.jsx(v,{label:$,variant:"warning"})]}),o.jsx(G,{ref:u,className:y.molViewer,theme:le,source:N,sourceMode:m.current?"update":"replace",onLoad:()=>{m.current=!0,_(null)},onLoadError:s=>_(s.error),onModifiedChange:s=>{L(s),n==null||n(s)},onSave:e?A:void 0,onPolymerBuild:e?B:void 0})]})}function je({tab:e}){const{path:r}=e.data,t=z(e.id);return o.jsx(g,{children:o.jsx(me,{path:r,workspaceCwd:e.workspaceCwd,tabId:e.id,isActive:t})})}export{je as MoleculeViewerPanel};
@@ -1 +1 @@
1
- var X=Object.defineProperty;var J=(r,e,t)=>e in r?X(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var D=(r,e,t)=>J(r,typeof e!="symbol"?e+"":e,t);import{r as s,j as T}from"./vendor-react-DQUAl2K8.js";import{x as K,a as Q}from"./vendor-terminal-BhzX2_ts.js";import{e as L,u as Z,f as $,g as ee,h as Y,S as te,i as re,j as ne}from"./index-CRcOAGBq.js";import"./vendor-DVp0ZLQo.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-icons-CQPWxe0u.js";import"./vendor-overlays-BfyojyuH.js";import"./vendor-dnd-CayJj8TC.js";class se{constructor(e){D(this,"subscribers",new Map);D(this,"detach",null);this.daemon=e}start(){this.detach||(this.detach=this.daemon.onTerminalFrame(e=>this.dispatch(e)))}stop(){var e;(e=this.detach)==null||e.call(this),this.detach=null}subscribeSlot(e,t){return this.subscribers.set(e,t),()=>{this.subscribers.get(e)===t&&this.subscribers.delete(e)}}hasSlot(e){return this.subscribers.has(e)}sendInput(e,t){this.daemon.sendBinary(L({opcode:"Input",slot:e,data:t}))}sendResize(e,t,d){this.daemon.sendBinary(L({opcode:"Resize",slot:e,rows:t,cols:d}))}dispatch(e){var d,y,h;const t=this.subscribers.get(e.slot);if(t)switch(e.opcode){case"Output":(d=t.onOutput)==null||d.call(t,e.data);return;case"Snapshot":(y=t.onSnapshot)==null||y.call(t,e.data);return;case"Restore":(h=t.onRestore)==null||h.call(t,e.data);return;default:return}}}const oe=2,ce=1;function _(r){if(r==null)return!1;const{cols:e,rows:t}=r;return typeof e=="number"&&Number.isInteger(e)&&e>=oe&&typeof t=="number"&&Number.isInteger(t)&&t>=ce}function ue(r,e){return r===null||e===null?r===e:r.cols===e.cols&&r.rows===e.rows}function ie(r,e){return _(r)?!ue(r,e):!1}const ae="_wrap_7fmht_1",le="_terminal_7fmht_12",fe="_statusOverlay_7fmht_19",k={wrap:ae,terminal:le,statusOverlay:fe},de=64*1024,G=new TextEncoder,W=new WeakMap;function me(r){let e=W.get(r);return e||(e=new se(r),e.start(),W.set(r,e)),e}function V(r){const e=Y.getState(),t=e.tabs.find(d=>d.id===r);return!t||t.workspaceCwd!==e.activeWorkspaceCwd?!1:re(ne.getState().layouts[t.workspaceCwd],r)}const he={background:"#181b1a",foreground:"#fafafa",cursor:"#a2b4d7",cursorAccent:"#181b1a",selectionBackground:"rgba(255,255,255,0.18)",black:"#18181b",red:"#ef4444",green:"#22c55e",yellow:"#f59e0b",blue:"#3b82f6",magenta:"#a855f7",cyan:"#14b8a6",white:"#d4d4d8",brightBlack:"#52525b",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#fbbf24",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#2dd4bf",brightWhite:"#fafafa"};function Ae({tab:r}){const e=r.data,t=Z(n=>n.client),d=$(r.id),y=s.useRef(null),h=s.useRef(null),R=s.useRef(null),v=s.useRef(e.slot),q=s.useRef(null),I=s.useRef([]),z=s.useRef(0),F=s.useRef(null),A=s.useRef(null),w=s.useRef(null),E=s.useRef(null),N=s.useRef(!1),j=s.useRef(t);j.current=t;const[g,H]=s.useState(e.slot),[O,M]=s.useState({isAttaching:!0,error:null}),x=()=>{var c,a;const n=(c=R.current)==null?void 0:c.proposeDimensions();(a=A.current)==null||a.call(A,_(n)?n:null)},U=()=>{var n;E.current=null,N.current=!0,(n=R.current)==null||n.fit(),x(),requestAnimationFrame(()=>{N.current=!1})},P=()=>{w.current!==null&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{w.current=null,E.current===null&&(E.current=requestAnimationFrame(U))},60)};s.useEffect(()=>{const n=y.current;if(!n)return;const c=new K.Terminal({cursorBlink:!0,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:ee.sm,scrollback:5e3,theme:he,allowProposedApi:!0}),a=new Q.FitAddon;c.loadAddon(a),c.open(n);const m=o=>{if(!V(r.id))return;const i=v.current,b=q.current;i===null||!b||ie(o,F.current)&&(F.current=o,b.sendResize(i,o.rows,o.cols))},l=c.onData(o=>{const i=v.current,b=q.current;if(i===null||!b){const C=G.encode(o);z.current+C.length<=de&&(I.current.push(C),z.current+=C.length);return}b.sendInput(i,G.encode(o))}),f=c.onResize(({cols:o,rows:i})=>{m({cols:o,rows:i})}),p=()=>{a.fit(),x()};n.addEventListener("focusin",p),a.fit(),h.current=c,R.current=a,A.current=m;const u=new ResizeObserver(o=>{if(N.current)return;const i=o[0];i&&(i.contentRect.width===0||i.contentRect.height===0)||P()});return u.observe(n),()=>{u.disconnect(),w.current!==null&&window.clearTimeout(w.current),E.current!==null&&cancelAnimationFrame(E.current),n.removeEventListener("focusin",p),l.dispose(),f.dispose(),c.dispose(),h.current=null,R.current=null,A.current=null}},[]);const S=s.useRef(!1),B=s.useRef(!1);return s.useEffect(()=>{var m;if(S.current=!0,!t||v.current!==null||B.current)return()=>{S.current=!1};B.current=!0;const n=e.cwd||"~",c=(m=R.current)==null?void 0:m.proposeDimensions(),a=_(c)?c:null;return t.connection.request("create_terminal_request",{workspaceId:"",cwd:n,...a?{cols:a.cols,rows:a.rows}:{}}).then(l=>{const f=l.terminal.slot;if(!S.current){t.connection.request("kill_terminal_request",{slot:f}).catch(()=>{});return}v.current=f,H(f),Y.getState().updateData(r.id,{slot:f});const p={cols:l.terminal.cols,rows:l.terminal.rows};F.current=_(p)?p:null}).catch(l=>{S.current&&M({isAttaching:!1,error:l instanceof Error?l.message:String(l)})}).finally(()=>{B.current=!1}),()=>{S.current=!1}},[t,r.id]),s.useEffect(()=>()=>{const n=v.current;n!==null&&setTimeout(()=>{var c;S.current||(c=j.current)==null||c.connection.request("kill_terminal_request",{slot:n}).catch(()=>{})},0)},[]),s.useEffect(()=>{var p;if(!t||g===null)return;M({isAttaching:!0,error:null});const n=me(t.connection);q.current=n;const c=u=>{var o,i;(o=h.current)==null||o.reset(),(i=h.current)==null||i.write(u)},a=n.subscribeSlot(g,{onOutput:u=>{var o;return(o=h.current)==null?void 0:o.write(u)},onSnapshot:c,onRestore:c});let m=!1;const l=(p=R.current)==null?void 0:p.proposeDimensions(),f=_(l)&&V(r.id)?l:null;return t.connection.request("subscribe_terminal_request",{slot:g,...f?{cols:f.cols,rows:f.rows}:{}}).then(u=>{if(m)return;M({isAttaching:!1,error:null});const o=I.current;I.current=[],z.current=0;for(const b of o)n.sendInput(g,b);const i={cols:u==null?void 0:u.cols,rows:u==null?void 0:u.rows};F.current=_(i)?i:f,x()}).catch(u=>{m||(I.current=[],z.current=0,M({isAttaching:!1,error:u instanceof Error?u.message:String(u)}))}),()=>{m=!0,a(),q.current=null,t.connection.request("unsubscribe_terminal_request",{slot:g}).catch(()=>{})}},[t,g]),s.useEffect(()=>{d&&P()},[d]),T.jsxs("div",{className:k.wrap,children:[T.jsx("div",{ref:y,className:k.terminal}),O.error?T.jsxs("div",{className:k.statusOverlay,children:["Terminal error: ",O.error]}):O.isAttaching?T.jsxs("div",{className:k.statusOverlay,children:[T.jsx(te,{size:"sm"})," Starting terminal…"]}):null]})}export{Ae as TerminalPanel};
1
+ var X=Object.defineProperty;var J=(r,e,t)=>e in r?X(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var D=(r,e,t)=>J(r,typeof e!="symbol"?e+"":e,t);import{r as s,j as T}from"./vendor-react-DQUAl2K8.js";import{x as K,a as Q}from"./vendor-terminal-BhzX2_ts.js";import{e as L,u as Z,f as $,g as ee,h as Y,S as te,i as re,j as ne}from"./index-CWQ7GUFk.js";import"./vendor-DVp0ZLQo.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-icons-CQPWxe0u.js";import"./vendor-overlays-BfyojyuH.js";import"./vendor-dnd-CayJj8TC.js";class se{constructor(e){D(this,"subscribers",new Map);D(this,"detach",null);this.daemon=e}start(){this.detach||(this.detach=this.daemon.onTerminalFrame(e=>this.dispatch(e)))}stop(){var e;(e=this.detach)==null||e.call(this),this.detach=null}subscribeSlot(e,t){return this.subscribers.set(e,t),()=>{this.subscribers.get(e)===t&&this.subscribers.delete(e)}}hasSlot(e){return this.subscribers.has(e)}sendInput(e,t){this.daemon.sendBinary(L({opcode:"Input",slot:e,data:t}))}sendResize(e,t,d){this.daemon.sendBinary(L({opcode:"Resize",slot:e,rows:t,cols:d}))}dispatch(e){var d,y,h;const t=this.subscribers.get(e.slot);if(t)switch(e.opcode){case"Output":(d=t.onOutput)==null||d.call(t,e.data);return;case"Snapshot":(y=t.onSnapshot)==null||y.call(t,e.data);return;case"Restore":(h=t.onRestore)==null||h.call(t,e.data);return;default:return}}}const oe=2,ce=1;function _(r){if(r==null)return!1;const{cols:e,rows:t}=r;return typeof e=="number"&&Number.isInteger(e)&&e>=oe&&typeof t=="number"&&Number.isInteger(t)&&t>=ce}function ue(r,e){return r===null||e===null?r===e:r.cols===e.cols&&r.rows===e.rows}function ie(r,e){return _(r)?!ue(r,e):!1}const ae="_wrap_7fmht_1",le="_terminal_7fmht_12",fe="_statusOverlay_7fmht_19",k={wrap:ae,terminal:le,statusOverlay:fe},de=64*1024,G=new TextEncoder,W=new WeakMap;function me(r){let e=W.get(r);return e||(e=new se(r),e.start(),W.set(r,e)),e}function V(r){const e=Y.getState(),t=e.tabs.find(d=>d.id===r);return!t||t.workspaceCwd!==e.activeWorkspaceCwd?!1:re(ne.getState().layouts[t.workspaceCwd],r)}const he={background:"#181b1a",foreground:"#fafafa",cursor:"#a2b4d7",cursorAccent:"#181b1a",selectionBackground:"rgba(255,255,255,0.18)",black:"#18181b",red:"#ef4444",green:"#22c55e",yellow:"#f59e0b",blue:"#3b82f6",magenta:"#a855f7",cyan:"#14b8a6",white:"#d4d4d8",brightBlack:"#52525b",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#fbbf24",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#2dd4bf",brightWhite:"#fafafa"};function Ae({tab:r}){const e=r.data,t=Z(n=>n.client),d=$(r.id),y=s.useRef(null),h=s.useRef(null),R=s.useRef(null),v=s.useRef(e.slot),q=s.useRef(null),I=s.useRef([]),z=s.useRef(0),F=s.useRef(null),A=s.useRef(null),w=s.useRef(null),E=s.useRef(null),N=s.useRef(!1),j=s.useRef(t);j.current=t;const[g,H]=s.useState(e.slot),[O,M]=s.useState({isAttaching:!0,error:null}),x=()=>{var c,a;const n=(c=R.current)==null?void 0:c.proposeDimensions();(a=A.current)==null||a.call(A,_(n)?n:null)},U=()=>{var n;E.current=null,N.current=!0,(n=R.current)==null||n.fit(),x(),requestAnimationFrame(()=>{N.current=!1})},P=()=>{w.current!==null&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{w.current=null,E.current===null&&(E.current=requestAnimationFrame(U))},60)};s.useEffect(()=>{const n=y.current;if(!n)return;const c=new K.Terminal({cursorBlink:!0,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:ee.sm,scrollback:5e3,theme:he,allowProposedApi:!0}),a=new Q.FitAddon;c.loadAddon(a),c.open(n);const m=o=>{if(!V(r.id))return;const i=v.current,b=q.current;i===null||!b||ie(o,F.current)&&(F.current=o,b.sendResize(i,o.rows,o.cols))},l=c.onData(o=>{const i=v.current,b=q.current;if(i===null||!b){const C=G.encode(o);z.current+C.length<=de&&(I.current.push(C),z.current+=C.length);return}b.sendInput(i,G.encode(o))}),f=c.onResize(({cols:o,rows:i})=>{m({cols:o,rows:i})}),p=()=>{a.fit(),x()};n.addEventListener("focusin",p),a.fit(),h.current=c,R.current=a,A.current=m;const u=new ResizeObserver(o=>{if(N.current)return;const i=o[0];i&&(i.contentRect.width===0||i.contentRect.height===0)||P()});return u.observe(n),()=>{u.disconnect(),w.current!==null&&window.clearTimeout(w.current),E.current!==null&&cancelAnimationFrame(E.current),n.removeEventListener("focusin",p),l.dispose(),f.dispose(),c.dispose(),h.current=null,R.current=null,A.current=null}},[]);const S=s.useRef(!1),B=s.useRef(!1);return s.useEffect(()=>{var m;if(S.current=!0,!t||v.current!==null||B.current)return()=>{S.current=!1};B.current=!0;const n=e.cwd||"~",c=(m=R.current)==null?void 0:m.proposeDimensions(),a=_(c)?c:null;return t.connection.request("create_terminal_request",{workspaceId:"",cwd:n,...a?{cols:a.cols,rows:a.rows}:{}}).then(l=>{const f=l.terminal.slot;if(!S.current){t.connection.request("kill_terminal_request",{slot:f}).catch(()=>{});return}v.current=f,H(f),Y.getState().updateData(r.id,{slot:f});const p={cols:l.terminal.cols,rows:l.terminal.rows};F.current=_(p)?p:null}).catch(l=>{S.current&&M({isAttaching:!1,error:l instanceof Error?l.message:String(l)})}).finally(()=>{B.current=!1}),()=>{S.current=!1}},[t,r.id]),s.useEffect(()=>()=>{const n=v.current;n!==null&&setTimeout(()=>{var c;S.current||(c=j.current)==null||c.connection.request("kill_terminal_request",{slot:n}).catch(()=>{})},0)},[]),s.useEffect(()=>{var p;if(!t||g===null)return;M({isAttaching:!0,error:null});const n=me(t.connection);q.current=n;const c=u=>{var o,i;(o=h.current)==null||o.reset(),(i=h.current)==null||i.write(u)},a=n.subscribeSlot(g,{onOutput:u=>{var o;return(o=h.current)==null?void 0:o.write(u)},onSnapshot:c,onRestore:c});let m=!1;const l=(p=R.current)==null?void 0:p.proposeDimensions(),f=_(l)&&V(r.id)?l:null;return t.connection.request("subscribe_terminal_request",{slot:g,...f?{cols:f.cols,rows:f.rows}:{}}).then(u=>{if(m)return;M({isAttaching:!1,error:null});const o=I.current;I.current=[],z.current=0;for(const b of o)n.sendInput(g,b);const i={cols:u==null?void 0:u.cols,rows:u==null?void 0:u.rows};F.current=_(i)?i:f,x()}).catch(u=>{m||(I.current=[],z.current=0,M({isAttaching:!1,error:u instanceof Error?u.message:String(u)}))}),()=>{m=!0,a(),q.current=null,t.connection.request("unsubscribe_terminal_request",{slot:g}).catch(()=>{})}},[t,g]),s.useEffect(()=>{d&&P()},[d]),T.jsxs("div",{className:k.wrap,children:[T.jsx("div",{ref:y,className:k.terminal}),O.error?T.jsxs("div",{className:k.statusOverlay,children:["Terminal error: ",O.error]}):O.isAttaching?T.jsxs("div",{className:k.statusOverlay,children:[T.jsx(te,{size:"sm"})," Starting terminal…"]}):null]})}export{Ae as TerminalPanel};
@@ -1 +1 @@
1
- import{j as e}from"./vendor-react-DQUAl2K8.js";import{E as r,S as t,B as a,P as c}from"./index-CRcOAGBq.js";import{u as m,C as d}from"./CodeView-DWNPh5RV.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-DVp0ZLQo.js";import"./vendor-icons-CQPWxe0u.js";import"./vendor-overlays-BfyojyuH.js";import"./vendor-dnd-CayJj8TC.js";import"./use-file-download-C5RZM273.js";const x="_note_1g5yz_1",j="_body_1g5yz_9",g="_tooLarge_1g5yz_13",i={note:x,body:j,tooLarge:g};function n(o){return`${(o/(1024*1024)).toFixed(1)} MB`}function b({path:o}){const s=m(o);switch(s.kind){case"loading":return e.jsxs(r,{children:[e.jsx(t,{size:"sm"})," Loading..."]});case"inline":return e.jsx(d,{path:o,content:s.content});case"streaming":return e.jsxs(r,{children:[e.jsx(t,{size:"sm"})," Streaming ",n(s.size)," file..."]});case"stream-error":return e.jsxs(r,{children:["Error: ",s.message]});case"streamed":return e.jsxs(c,{children:[e.jsxs("div",{className:i.note,children:[n(s.size)," file streamed"]}),e.jsx("div",{className:i.body,children:e.jsx(d,{path:o,content:s.content})})]});case"too-large":{const l=o.split("/").pop()||o;return e.jsx(r,{children:e.jsxs("div",{className:i.tooLarge,children:[e.jsxs("div",{children:[n(s.size)," — too large to display (display ceiling is"," ",n(s.maxDisplayBytes),")."]}),s.downloading?e.jsx(t,{size:"sm"}):s.downloadUrl?e.jsx("a",{href:s.downloadUrl,download:s.downloadName||l,children:e.jsx(a,{size:"sm",children:"Save file"})}):e.jsx(a,{size:"sm",onClick:()=>s.requestDownload(),children:"Download"})]})})}case"error":return e.jsxs(r,{children:["Error: ",s.message]})}}export{b as TextViewer};
1
+ import{j as e}from"./vendor-react-DQUAl2K8.js";import{E as r,S as t,B as a,P as c}from"./index-CWQ7GUFk.js";import{u as m,C as d}from"./CodeView-GqSGzzdY.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-DVp0ZLQo.js";import"./vendor-icons-CQPWxe0u.js";import"./vendor-overlays-BfyojyuH.js";import"./vendor-dnd-CayJj8TC.js";import"./use-file-download-zBrxUX0K.js";const x="_note_1g5yz_1",j="_body_1g5yz_9",g="_tooLarge_1g5yz_13",i={note:x,body:j,tooLarge:g};function n(o){return`${(o/(1024*1024)).toFixed(1)} MB`}function b({path:o}){const s=m(o);switch(s.kind){case"loading":return e.jsxs(r,{children:[e.jsx(t,{size:"sm"})," Loading..."]});case"inline":return e.jsx(d,{path:o,content:s.content});case"streaming":return e.jsxs(r,{children:[e.jsx(t,{size:"sm"})," Streaming ",n(s.size)," file..."]});case"stream-error":return e.jsxs(r,{children:["Error: ",s.message]});case"streamed":return e.jsxs(c,{children:[e.jsxs("div",{className:i.note,children:[n(s.size)," file streamed"]}),e.jsx("div",{className:i.body,children:e.jsx(d,{path:o,content:s.content})})]});case"too-large":{const l=o.split("/").pop()||o;return e.jsx(r,{children:e.jsxs("div",{className:i.tooLarge,children:[e.jsxs("div",{children:[n(s.size)," — too large to display (display ceiling is"," ",n(s.maxDisplayBytes),")."]}),s.downloading?e.jsx(t,{size:"sm"}):s.downloadUrl?e.jsx("a",{href:s.downloadUrl,download:s.downloadName||l,children:e.jsx(a,{size:"sm",children:"Save file"})}):e.jsx(a,{size:"sm",onClick:()=>s.requestDownload(),children:"Download"})]})})}case"error":return e.jsxs(r,{children:["Error: ",s.message]})}}export{b as TextViewer};
@@ -1 +1 @@
1
- import{j as o}from"./vendor-react-DQUAl2K8.js";import{E as e,S as t}from"./index-CRcOAGBq.js";import{u as n}from"./use-file-download-C5RZM273.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-DVp0ZLQo.js";import"./vendor-icons-CQPWxe0u.js";import"./vendor-overlays-BfyojyuH.js";import"./vendor-dnd-CayJj8TC.js";const a="_wrap_gy3e6_1",d="_video_gy3e6_10",s={wrap:a,video:d};function v({path:i,workspaceCwd:m}){const r=n(i);return r.isLoading?o.jsxs(e,{children:[o.jsx(t,{size:"sm"})," Loading video..."]}):r.isError?o.jsxs(e,{children:["Error: ",r.error instanceof Error?r.error.message:"unknown error"]}):r.data?o.jsx("div",{className:s.wrap,children:o.jsx("video",{className:s.video,src:r.data.objectUrl,controls:!0})}):null}export{v as VideoViewer};
1
+ import{j as o}from"./vendor-react-DQUAl2K8.js";import{E as e,S as t}from"./index-CWQ7GUFk.js";import{u as n}from"./use-file-download-zBrxUX0K.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-DVp0ZLQo.js";import"./vendor-icons-CQPWxe0u.js";import"./vendor-overlays-BfyojyuH.js";import"./vendor-dnd-CayJj8TC.js";const a="_wrap_gy3e6_1",d="_video_gy3e6_10",s={wrap:a,video:d};function v({path:i,workspaceCwd:m}){const r=n(i);return r.isLoading?o.jsxs(e,{children:[o.jsx(t,{size:"sm"})," Loading video..."]}):r.isError?o.jsxs(e,{children:["Error: ",r.error instanceof Error?r.error.message:"unknown error"]}):r.data?o.jsx("div",{className:s.wrap,children:o.jsx("video",{className:s.video,src:r.data.objectUrl,controls:!0})}):null}export{v as VideoViewer};
@@ -1 +1 @@
1
- import{n as l,r as o,c as i}from"./index-CRcOAGBq.js";const u=/^([a-zA-Z][a-zA-Z0-9+.-]*):/;function d(n){try{return decodeURIComponent(n)}catch{return n}}function p(n,a,r){const s=n.trim();if(!s)return null;const e=s.split(/[?#]/,1)[0];if(!e||u.exec(e))return null;let t;if(e.startsWith("/")?t=e:e==="~"||e.startsWith("~/")?t=r?l(e,r):null:t=o(e,a??""),!t)return null;const c=i(t);return d(c)}export{u as S,d as p,p as r};
1
+ import{n as l,r as o,c as i}from"./index-CWQ7GUFk.js";const u=/^([a-zA-Z][a-zA-Z0-9+.-]*):/;function d(n){try{return decodeURIComponent(n)}catch{return n}}function p(n,a,r){const s=n.trim();if(!s)return null;const e=s.split(/[?#]/,1)[0];if(!e||u.exec(e))return null;let t;if(e.startsWith("/")?t=e:e==="~"||e.startsWith("~/")?t=r?l(e,r):null:t=o(e,a??""),!t)return null;const c=i(t);return d(c)}export{u as S,d as p,p as r};