@av-pi-studio/web-client 0.0.94 → 0.0.96

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 (29) hide show
  1. package/dist/web/assets/{BinaryFallbackViewer-Cl9JXb5q.js → BinaryFallbackViewer-DcA3RWPo.js} +1 -1
  2. package/dist/web/assets/CascadiaMono-95CNhH_0.woff2 +0 -0
  3. package/dist/web/assets/CascadiaMonoNF-DiMa2xBr.woff2 +0 -0
  4. package/dist/web/assets/{ChatPanel-Bef2kpgd.js → ChatPanel-Bqap8qR2.js} +3 -3
  5. package/dist/web/assets/{CodeView-Dw7L2TVS.js → CodeView-BXJFkLt-.js} +1 -1
  6. package/dist/web/assets/{FilePanel-CTwbQ_aO.js → FilePanel-DoNa0K86.js} +1 -1
  7. package/dist/web/assets/{HtmlViewer-Bxh2l5Lv.js → HtmlViewer-DohpKpiN.js} +1 -1
  8. package/dist/web/assets/{ImageViewer-sPGjP66G.js → ImageViewer-D7M7Rq8K.js} +1 -1
  9. package/dist/web/assets/{MarkdownFileViewer-Bo4C4k_g.js → MarkdownFileViewer-BMIFLm38.js} +1 -1
  10. package/dist/web/assets/{ModelProvidersPanel-D3bDWSdy.js → ModelProvidersPanel-BQz7XMZP.js} +1 -1
  11. package/dist/web/assets/{MoleculeViewerPanel-CAd3aCBh.js → MoleculeViewerPanel-DIat3-U6.js} +1 -1
  12. package/dist/web/assets/{SettingsDialog-nfzDXsFW.js → SettingsDialog-jNCx6ea1.js} +7 -7
  13. package/dist/web/assets/TerminalPanel-CylREZXN.js +1 -0
  14. package/dist/web/assets/TerminalPanel-DpxpMm0w.css +1 -0
  15. package/dist/web/assets/{TextViewer-CW33h6Cq.js → TextViewer-BJdo9BQZ.js} +1 -1
  16. package/dist/web/assets/{VideoViewer-BS12rdIx.js → VideoViewer-wqxcK6U7.js} +1 -1
  17. package/dist/web/assets/{href-resolution-62Ae2qpT.js → href-resolution-CxQKzcip.js} +1 -1
  18. package/dist/web/assets/index-CBBgHVBM.js +19 -0
  19. package/dist/web/assets/index-ggD4eKe_.css +1 -0
  20. package/dist/web/assets/{markdown-DEjnznX7.js → markdown-BOpTW_tD.js} +2 -2
  21. package/dist/web/assets/{use-file-download-B0TFCtaB.js → use-file-download-BIZMK0gw.js} +1 -1
  22. package/dist/web/assets/{use-file-watch-CweRDD7C.js → use-file-watch-Do6RBm9E.js} +1 -1
  23. package/dist/web/assets/{use-provider-auth-list-D31i1xT-.js → use-provider-auth-list-Bv1c4-ha.js} +1 -1
  24. package/dist/web/index.html +2 -2
  25. package/package.json +3 -3
  26. package/dist/web/assets/TerminalPanel-DeqOCMpZ.js +0 -1
  27. package/dist/web/assets/TerminalPanel-DoDBqfAg.css +0 -1
  28. package/dist/web/assets/index-BHHAK0f5.js +0 -19
  29. package/dist/web/assets/index-BfVJBlu4.css +0 -1
@@ -1 +1 @@
1
- import{r as l,j as e}from"./vendor-react-DQUAl2K8.js";import{S as d,B as a}from"./index-BHHAK0f5.js";import{u as m}from"./use-file-download-B0TFCtaB.js";import{F as c}from"./vendor-icons-oIrAStms.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-CIkm_8TG.js";import"./vendor-overlays-DAY3g68r.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-CBBgHVBM.js";import{u as m}from"./use-file-download-BIZMK0gw.js";import{F as c}from"./vendor-icons-oIrAStms.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-CIkm_8TG.js";import"./vendor-overlays-DAY3g68r.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,8 +1,8 @@
1
- import{r as p,j as t}from"./vendor-react-DQUAl2K8.js";import{a as ot,b as rt,m as at,u as Ae}from"./vendor-query-i7fr__Xm.js";import{y as fe,z as P,u as Q,A as it,I as M,D as ct,F as lt,B as T,T as dt,G as Re,S as _e,w as ut,H as mt,k as ft,n as pt,J as ht,K as _t,j as gt,M as xt,E as vt,N as pe,a as Ie,O as Pe,Q as oe,f as jt,R as kt,x as bt,P as Se}from"./index-BHHAK0f5.js";import{L as yt,G as Nt,S as wt,a as St,P as Ct,E as Dt,T as Me,C as ie,b as Oe,B as Bt,c as Et,d as Tt,A as At,e as Rt,U as It,f as Pt,g as Mt,h as Ot,i as qt,j as Ft,k as Lt,N as Kt,l as Ht}from"./vendor-icons-oIrAStms.js";import{u as zt}from"./use-provider-auth-list-D31i1xT-.js";import{M as S}from"./vendor-CIkm_8TG.js";import{S as qe,M as Fe,r as $t}from"./markdown-DEjnznX7.js";import{D as Ut,p as Wt}from"./DiffView-DYwtgWeX.js";import{R as Le,T as Ke,I as Gt}from"./vendor-overlays-DAY3g68r.js";import"./vendor-dnd-CayJj8TC.js";import"./vendor-highlight-A9hNQ6ne.js";import"./vendor-markdown-Bu3Y4y-M.js";import"./href-resolution-62Ae2qpT.js";function He(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 Jt={shell:Me,read:Dt,edit:Ct,write:St,search:wt,fetch:Nt,task:yt};function Qt(e){return Jt[e.kind]??Me}function ze(e){switch(e.kind){case"read":case"write":case"edit":return e.path??null;default:return null}}function Vt(e){return e.kind==="write"||e.kind==="edit"||e.kind==="shell"}function Yt(e){const n=[];if(e.kind==="edit"&&e.diff)n.push({kind:"diff",patch:e.diff});else{const s=fe(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 Xt(e){return Ce[e.kind]??Ce.task}function Zt(e){if(!e)return{added:0,removed:0};let n=0,s=0;for(const o of e.split(`
1
+ import{r as p,j as t}from"./vendor-react-DQUAl2K8.js";import{a as ot,b as rt,m as at,u as Ae}from"./vendor-query-i7fr__Xm.js";import{A as fe,D as P,u as Q,F as it,I as M,G as ct,H as lt,B as T,J as dt,K as Re,S as _e,y as ut,M as mt,m as ft,n as pt,N as ht,O as _t,l as gt,Q as xt,E as vt,R as pe,a as Ie,U as Pe,W as oe,g as jt,X as kt,z as bt,P as Se}from"./index-CBBgHVBM.js";import{L as yt,G as Nt,S as wt,a as St,P as Ct,E as Dt,T as Me,C as ie,b as Oe,B as Bt,c as Et,d as Tt,A as At,e as Rt,U as It,f as Pt,g as Mt,h as Ot,i as qt,j as Ft,k as Lt,N as Kt,l as Ht}from"./vendor-icons-oIrAStms.js";import{u as zt}from"./use-provider-auth-list-Bv1c4-ha.js";import{M as S}from"./vendor-CIkm_8TG.js";import{S as qe,M as Fe,r as $t}from"./markdown-BOpTW_tD.js";import{D as Ut,p as Wt}from"./DiffView-DYwtgWeX.js";import{R as Le,T as Ke,I as Gt}from"./vendor-overlays-DAY3g68r.js";import"./vendor-dnd-CayJj8TC.js";import"./vendor-highlight-A9hNQ6ne.js";import"./vendor-markdown-Bu3Y4y-M.js";import"./href-resolution-CxQKzcip.js";function He(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 Jt={shell:Me,read:Dt,edit:Ct,write:St,search:wt,fetch:Nt,task:yt};function Qt(e){return Jt[e.kind]??Me}function ze(e){switch(e.kind){case"read":case"write":case"edit":return e.path??null;default:return null}}function Vt(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=fe(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 Yt(e){return Ce[e.kind]??Ce.task}function Zt(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 en(e){return e?(e.endsWith(`
3
3
  `)?e.slice(0,-1):e).split(`
4
4
  `).length:0}const tn=500;let le;function nn(e,n,s,o){clearTimeout(le),le=setTimeout(()=>{le=void 0,e.invalidateQueries({queryKey:["file"]}),e.invalidateQueries({queryKey:["explorer"]}),n&&s&&n.connection.request("checkout_refresh_request",{cwd:s}).catch(()=>{})},tn)}function sn({sessionId:e,event:n,timestamp:s,client:o,queryClient:r}){const a=P.getState();switch(a.applyStreamEvent(e,n,s),n.kind){case"turn_started":a.setStatus(e,"running");break;case"turn_completed":a.setStatus(e,"idle");break;case"turn_failed":a.setStatus(e,"error");break;case"turn_canceled":a.setStatus(e,"idle");break;case"tool_call":{if(n.status==="completed"&&Vt(n.tool)){const l=a.sessions[e],i=(l==null?void 0:l.cwd)||null;nn(r,o,i,ze(n.tool))}break}}}function on(e){const n=Q(r=>r.client),s=P(r=>{var a;return((a=r.sessions[e])==null?void 0:a.agentId)??null}),o=ot();p.useEffect(()=>!n||!s?void 0:n.agent(s).timeline.subscribe((a,l)=>{const i=typeof l.timestamp=="number"?new Date(l.timestamp).toISOString():l.timestamp;sn({sessionId:e,event:a,timestamp:i,client:n,queryClient:o})}),[n,s,e,o])}const $e=64;function de(e){return e.clientHeight>0}function rn(e,n,s,o=$e){switch(n.kind){case"scroll":return de(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&&de(s)};case"shown":return{pinned:e,stick:e};case"pin":return{pinned:!0,stick:de(s)}}}function an(e){const n=e[e.length-1];return(n==null?void 0:n.kind)==="user"?n.id:null}const cn="_shellRow_5a5cb_2",ln="_rail_5a5cb_10",dn="_disc_5a5cb_18",un="_connector_5a5cb_28",mn="_content_5a5cb_2",fn="_metaLine_5a5cb_40",pn="_metaTime_5a5cb_52",I={shellRow:cn,rail:ln,disc:dn,connector:un,content:mn,metaLine:fn,metaTime:pn};function O({disc:e,discClassName:n,connector:s,meta:o,metaTrailing:r,className:a,children:l}){return t.jsxs("div",{className:I.shellRow,children:[t.jsxs("div",{className:I.rail,children:[t.jsx("span",{className:S(I.disc,n),children:e}),s&&t.jsx("span",{className:I.connector})]}),t.jsxs("div",{className:S(I.content,a),children:[o&&t.jsxs("div",{className:I.metaLine,children:[o,r]}),l]})]})}function De(e){return typeof e=="number"?e:Date.parse(e)}function hn(e,n){const s=De(e.entry.createdAt),o=De(n.entry.createdAt);return s!==o?s-o:e.entry.requestId<n.entry.requestId?-1:e.entry.requestId>n.entry.requestId?1:0}function _n(e,n){return[...e.map(o=>({kind:"pending",entry:o})),...n.map(o=>({kind:"resolved",entry:o}))].toSorted(hn)}function gn(e){return e.entry.requestId}function Ue(e){return e.receivedAt===void 0}const xn=4;function vn(e,n){let s=0;const o=e.map(i=>i.kind!=="pending"?{item:i,collapsed:!1}:(s++,{item:i,collapsed:!n&&s>xn})),r=o.filter(i=>i.collapsed).length,a=o.findIndex(i=>i.collapsed),l=[];return o.forEach((i,h)=>{h===a&&l.push({kind:"more",count:r}),l.push({kind:"card",item:i.item,collapsed:i.collapsed})}),l}function jn(e,n){if(e.timeoutMs===void 0)return{show:!1,fraction:0,approximate:!1};const s=it(e,n)??0;return{show:!0,fraction:Math.max(0,Math.min(1,s/e.timeoutMs)),approximate:e.receivedAt===void 0}}function We(e){return e==="editor"}const kn="Esc again to dismiss — the extension gets an empty answer";function bn(e,n){return n?{kind:"warning",text:kn}:{kind:"keys",segments:[{key:We(e)?"⇧↵":"↵",label:"submit"},{key:"Esc",label:"dismiss"}]}}function yn(e){return e?{armed:!1,resolve:!0}:{armed:!0,resolve:!1}}const Nn=5,wn=40,Sn=6;function Cn(e){return{mode:e.length>=Nn||e.some(s=>s.length>wn)?"stack":"row",scrolls:e.length>Sn}}function he(e){const n=e.split(`
5
- `),s=[];let o=!1;for(const r of n)if(r===""){if(o)continue;o=!0,s.push("")}else o=!1,s.push(r);return s}function Dn(e,n){return{title:he(e),...n!==void 0?{message:he(n)}:{}}}const Bn="_askDisc_ffqf1_5",En="_card_ffqf1_9",Tn="_cardInert_ffqf1_41",An="_askDiscInert_ffqf1_47",Rn="_reconnectingNote_ffqf1_52",In="_reconnectingDot_ffqf1_61",Pn="_deadlineBar_ffqf1_71",Mn="_deadlineApproximate_ffqf1_80",On="_header_ffqf1_85",qn="_askBadge_ffqf1_16",Fn="_methodName_ffqf1_101",Ln="_title_ffqf1_107",Kn="_titleEmphasised_ffqf1_115",Hn="_message_ffqf1_119",zn="_emptyOptionsNote_ffqf1_127",$n="_controls_ffqf1_133",Un="_controlsStack_ffqf1_141",Wn="_controlsScroll_ffqf1_148",Gn="_optionButton_ffqf1_153",Jn="_field_ffqf1_161",Qn="_editorField_ffqf1_168",Vn="_rawPayload_ffqf1_176",Yn="_resolvedCard_ffqf1_190",Xn="_askBadgeNeutral_ffqf1_204",Zn="_resolvedMethodName_ffqf1_209",es="_outcome_ffqf1_218",ts="_outcomeSuccess_ffqf1_229",ns="_outcomeText_ffqf1_233",ss="_hint_ffqf1_255",os="_hintKey_ffqf1_270",rs="_hintSep_ffqf1_278",as="_recoveredChip_ffqf1_285",is="_collapsedPendingCard_ffqf1_297",cs="_moreRow_ffqf1_303",f={askDisc:Bn,card:En,cardInert:Tn,askDiscInert:An,reconnectingNote:Rn,reconnectingDot:In,deadlineBar:Pn,deadlineApproximate:Mn,header:On,askBadge:qn,methodName:Fn,title:Ln,titleEmphasised:Kn,message:Hn,emptyOptionsNote:zn,controls:$n,controlsStack:Un,controlsScroll:Wn,optionButton:Gn,field:Jn,editorField:Qn,rawPayload:Vn,resolvedCard:Yn,askBadgeNeutral:Xn,resolvedMethodName:Zn,outcome:es,outcomeSuccess:ts,outcomeText:ns,hint:ss,hintKey:os,hintSep:rs,recoveredChip:as,collapsedPendingCard:is,moreRow:cs},ls=250,ds=320;function U(e,n){const s=e[n];return typeof s=="string"?s:void 0}function us(e,n){const s=e[n];return Array.isArray(s)?s.filter(o=>typeof o=="string"):[]}function ms({item:e,connector:n,collapsed:s=!1,autoFocus:o=!1,sessionTitle:r}){return e.kind==="resolved"?t.jsx(hs,{entry:e.entry,connector:n}):s?t.jsx(fs,{entry:e.entry,connector:n}):t.jsx(gs,{entry:e.entry,connector:n,autoFocus:o,sessionTitle:r})}function Ge(){return t.jsx("span",{className:f.recoveredChip,children:"still waiting"})}function fs({entry:e,connector:n}){return t.jsx(O,{disc:t.jsx(M,{icon:ie,size:"xs",color:"var(--pi-color-statusWarning)"}),discClassName:f.askDisc,connector:n,children:t.jsxs("div",{className:S(f.resolvedCard,f.collapsedPendingCard),children:[t.jsx("span",{className:f.askBadge,children:"ASK"}),t.jsx("span",{className:f.resolvedMethodName,children:e.method}),Ue(e)&&t.jsx(Ge,{})]})})}function ps({count:e,connector:n,onExpand:s}){return t.jsx(O,{disc:t.jsx(M,{icon:ie,size:"xs",color:"var(--pi-color-foregroundMuted)"}),discClassName:f.askDiscInert,connector:n,children:t.jsxs("button",{type:"button",className:f.moreRow,onClick:s,children:[e," more waiting"]})})}function hs({entry:e,connector:n}){const s=ct(e);return t.jsx(O,{disc:t.jsx(M,{icon:ie,size:"xs",color:"var(--pi-color-foregroundMuted)"}),discClassName:f.askDiscInert,connector:n,children:t.jsxs("div",{className:f.resolvedCard,children:[t.jsx("span",{className:S(f.askBadge,f.askBadgeNeutral),children:"ASK"}),t.jsx("span",{className:f.resolvedMethodName,children:e.method}),t.jsxs("span",{className:S(f.outcome,s.tone==="success"&&f.outcomeSuccess),children:[s.glyph==="check"&&t.jsx(Oe,{size:11,"aria-hidden":!0}),t.jsx("span",{className:S(s.truncate&&f.outcomeText),children:s.text})]})]})})}function L(e,n){return e.answerable?e.submitting?n?{loading:!0,style:{opacity:1}}:{disabled:!0}:{}:{disabled:!0,style:{opacity:1}}}function _s({hint:e}){return e.kind==="warning"?t.jsx("p",{className:f.hint,children:e.text}):t.jsx("p",{className:f.hint,children:e.segments.map((n,s)=>t.jsxs(p.Fragment,{children:[s>0&&t.jsx("span",{className:f.hintSep,children:"·"}),t.jsx("span",{className:f.hintKey,children:n.key}),n.label]},n.label))})}function gs({entry:e,connector:n,autoFocus:s=!1,sessionTitle:o}){const[r,a]=p.useState(()=>Date.now()),l=jn(e,r),[i,h]=p.useState(!1),m=p.useRef(null),u=p.useRef(null),d=p.useRef(null);p.useEffect(()=>{if(!l.show)return;const y=setInterval(()=>a(Date.now()),ls);return()=>clearInterval(y)},[e.requestId,e.timeoutMs,l.show]),p.useEffect(()=>{var w,j;if(!s||!e.answerable)return;const y=document.activeElement;(y instanceof HTMLTextAreaElement||y instanceof HTMLInputElement)&&y.value.length>0&&!((w=m.current)!=null&&w.contains(y))||(j=u.current)==null||j.focus()},[s,e.answerable]);function x(y){var g,w;e.answerable&&(y.target.closest("button, input, textarea, a, select")||(g=m.current)!=null&&g.contains(document.activeElement)||(w=m.current)==null||w.focus())}function B(y){lt(e.requestId,y)}function A(y){var w;if(y.key!=="Escape"||!e.answerable)return;y.preventDefault(),y.stopPropagation();const g=yn(i);if(h(g.armed),!g.resolve){(w=d.current)==null||w.focus();return}d.current?d.current.click():B({cancelled:!0})}function C(y){y.currentTarget.contains(y.relatedTarget)||h(!1)}return t.jsxs(O,{disc:t.jsx(M,{icon:ie,size:"xs",color:e.answerable?"var(--pi-color-statusWarning)":"var(--pi-color-foregroundMuted)"}),discClassName:e.answerable?f.askDisc:f.askDiscInert,connector:n,children:[t.jsxs("div",{ref:m,className:S(f.card,!e.answerable&&f.cardInert),role:"group","aria-label":`Question in ${o}`,tabIndex:-1,onKeyDown:A,onMouseDown:x,onBlur:C,children:[l.show&&t.jsx("div",{className:S(f.deadlineBar,l.approximate&&f.deadlineApproximate),style:{width:`${l.fraction*100}%`}}),t.jsxs("div",{className:f.header,children:[t.jsx("span",{className:S(f.askBadge,!e.answerable&&f.askBadgeNeutral),"aria-hidden":"true",children:"ASK"}),t.jsx("span",{className:f.methodName,children:e.method}),Ue(e)&&t.jsx(Ge,{})]}),t.jsx(xs,{entry:e,onSubmit:B,primaryRef:u,dismissRef:d})]}),t.jsx(_s,{hint:bn(e.method,i)}),!e.answerable&&t.jsxs("p",{className:f.reconnectingNote,children:[t.jsx("span",{className:f.reconnectingDot}),"Reconnecting — you can answer again in a moment"]})]})}function xs({entry:e,onSubmit:n,primaryRef:s,dismissRef:o}){const{method:r,payload:a}=e;return r==="select"?t.jsx(vs,{entry:e,payload:a,onSubmit:n,primaryRef:s,dismissRef:o}):r==="confirm"?t.jsx(js,{entry:e,payload:a,onSubmit:n,primaryRef:s,dismissRef:o}):r==="input"?t.jsx(ks,{entry:e,payload:a,onSubmit:n,primaryRef:s}):r==="editor"?t.jsx(bs,{entry:e,payload:a,onSubmit:n,primaryRef:s,dismissRef:o}):t.jsx(ys,{entry:e,method:r,payload:a,onSubmit:n,primaryRef:s,dismissRef:o})}function ae({text:e}){return t.jsx("div",{className:f.title,children:he(e).join(`
5
+ `),s=[];let o=!1;for(const r of n)if(r===""){if(o)continue;o=!0,s.push("")}else o=!1,s.push(r);return s}function Dn(e,n){return{title:he(e),...n!==void 0?{message:he(n)}:{}}}const Bn="_askDisc_ffqf1_5",En="_card_ffqf1_9",Tn="_cardInert_ffqf1_41",An="_askDiscInert_ffqf1_47",Rn="_reconnectingNote_ffqf1_52",In="_reconnectingDot_ffqf1_61",Pn="_deadlineBar_ffqf1_71",Mn="_deadlineApproximate_ffqf1_80",On="_header_ffqf1_85",qn="_askBadge_ffqf1_16",Fn="_methodName_ffqf1_101",Ln="_title_ffqf1_107",Kn="_titleEmphasised_ffqf1_115",Hn="_message_ffqf1_119",zn="_emptyOptionsNote_ffqf1_127",$n="_controls_ffqf1_133",Un="_controlsStack_ffqf1_141",Wn="_controlsScroll_ffqf1_148",Gn="_optionButton_ffqf1_153",Jn="_field_ffqf1_161",Qn="_editorField_ffqf1_168",Vn="_rawPayload_ffqf1_176",Xn="_resolvedCard_ffqf1_190",Yn="_askBadgeNeutral_ffqf1_204",Zn="_resolvedMethodName_ffqf1_209",es="_outcome_ffqf1_218",ts="_outcomeSuccess_ffqf1_229",ns="_outcomeText_ffqf1_233",ss="_hint_ffqf1_255",os="_hintKey_ffqf1_270",rs="_hintSep_ffqf1_278",as="_recoveredChip_ffqf1_285",is="_collapsedPendingCard_ffqf1_297",cs="_moreRow_ffqf1_303",f={askDisc:Bn,card:En,cardInert:Tn,askDiscInert:An,reconnectingNote:Rn,reconnectingDot:In,deadlineBar:Pn,deadlineApproximate:Mn,header:On,askBadge:qn,methodName:Fn,title:Ln,titleEmphasised:Kn,message:Hn,emptyOptionsNote:zn,controls:$n,controlsStack:Un,controlsScroll:Wn,optionButton:Gn,field:Jn,editorField:Qn,rawPayload:Vn,resolvedCard:Xn,askBadgeNeutral:Yn,resolvedMethodName:Zn,outcome:es,outcomeSuccess:ts,outcomeText:ns,hint:ss,hintKey:os,hintSep:rs,recoveredChip:as,collapsedPendingCard:is,moreRow:cs},ls=250,ds=320;function U(e,n){const s=e[n];return typeof s=="string"?s:void 0}function us(e,n){const s=e[n];return Array.isArray(s)?s.filter(o=>typeof o=="string"):[]}function ms({item:e,connector:n,collapsed:s=!1,autoFocus:o=!1,sessionTitle:r}){return e.kind==="resolved"?t.jsx(hs,{entry:e.entry,connector:n}):s?t.jsx(fs,{entry:e.entry,connector:n}):t.jsx(gs,{entry:e.entry,connector:n,autoFocus:o,sessionTitle:r})}function Ge(){return t.jsx("span",{className:f.recoveredChip,children:"still waiting"})}function fs({entry:e,connector:n}){return t.jsx(O,{disc:t.jsx(M,{icon:ie,size:"xs",color:"var(--pi-color-statusWarning)"}),discClassName:f.askDisc,connector:n,children:t.jsxs("div",{className:S(f.resolvedCard,f.collapsedPendingCard),children:[t.jsx("span",{className:f.askBadge,children:"ASK"}),t.jsx("span",{className:f.resolvedMethodName,children:e.method}),Ue(e)&&t.jsx(Ge,{})]})})}function ps({count:e,connector:n,onExpand:s}){return t.jsx(O,{disc:t.jsx(M,{icon:ie,size:"xs",color:"var(--pi-color-foregroundMuted)"}),discClassName:f.askDiscInert,connector:n,children:t.jsxs("button",{type:"button",className:f.moreRow,onClick:s,children:[e," more waiting"]})})}function hs({entry:e,connector:n}){const s=ct(e);return t.jsx(O,{disc:t.jsx(M,{icon:ie,size:"xs",color:"var(--pi-color-foregroundMuted)"}),discClassName:f.askDiscInert,connector:n,children:t.jsxs("div",{className:f.resolvedCard,children:[t.jsx("span",{className:S(f.askBadge,f.askBadgeNeutral),children:"ASK"}),t.jsx("span",{className:f.resolvedMethodName,children:e.method}),t.jsxs("span",{className:S(f.outcome,s.tone==="success"&&f.outcomeSuccess),children:[s.glyph==="check"&&t.jsx(Oe,{size:11,"aria-hidden":!0}),t.jsx("span",{className:S(s.truncate&&f.outcomeText),children:s.text})]})]})})}function L(e,n){return e.answerable?e.submitting?n?{loading:!0,style:{opacity:1}}:{disabled:!0}:{}:{disabled:!0,style:{opacity:1}}}function _s({hint:e}){return e.kind==="warning"?t.jsx("p",{className:f.hint,children:e.text}):t.jsx("p",{className:f.hint,children:e.segments.map((n,s)=>t.jsxs(p.Fragment,{children:[s>0&&t.jsx("span",{className:f.hintSep,children:"·"}),t.jsx("span",{className:f.hintKey,children:n.key}),n.label]},n.label))})}function gs({entry:e,connector:n,autoFocus:s=!1,sessionTitle:o}){const[r,a]=p.useState(()=>Date.now()),l=jn(e,r),[i,h]=p.useState(!1),m=p.useRef(null),u=p.useRef(null),d=p.useRef(null);p.useEffect(()=>{if(!l.show)return;const y=setInterval(()=>a(Date.now()),ls);return()=>clearInterval(y)},[e.requestId,e.timeoutMs,l.show]),p.useEffect(()=>{var w,j;if(!s||!e.answerable)return;const y=document.activeElement;(y instanceof HTMLTextAreaElement||y instanceof HTMLInputElement)&&y.value.length>0&&!((w=m.current)!=null&&w.contains(y))||(j=u.current)==null||j.focus()},[s,e.answerable]);function x(y){var g,w;e.answerable&&(y.target.closest("button, input, textarea, a, select")||(g=m.current)!=null&&g.contains(document.activeElement)||(w=m.current)==null||w.focus())}function B(y){lt(e.requestId,y)}function A(y){var w;if(y.key!=="Escape"||!e.answerable)return;y.preventDefault(),y.stopPropagation();const g=yn(i);if(h(g.armed),!g.resolve){(w=d.current)==null||w.focus();return}d.current?d.current.click():B({cancelled:!0})}function C(y){y.currentTarget.contains(y.relatedTarget)||h(!1)}return t.jsxs(O,{disc:t.jsx(M,{icon:ie,size:"xs",color:e.answerable?"var(--pi-color-statusWarning)":"var(--pi-color-foregroundMuted)"}),discClassName:e.answerable?f.askDisc:f.askDiscInert,connector:n,children:[t.jsxs("div",{ref:m,className:S(f.card,!e.answerable&&f.cardInert),role:"group","aria-label":`Question in ${o}`,tabIndex:-1,onKeyDown:A,onMouseDown:x,onBlur:C,children:[l.show&&t.jsx("div",{className:S(f.deadlineBar,l.approximate&&f.deadlineApproximate),style:{width:`${l.fraction*100}%`}}),t.jsxs("div",{className:f.header,children:[t.jsx("span",{className:S(f.askBadge,!e.answerable&&f.askBadgeNeutral),"aria-hidden":"true",children:"ASK"}),t.jsx("span",{className:f.methodName,children:e.method}),Ue(e)&&t.jsx(Ge,{})]}),t.jsx(xs,{entry:e,onSubmit:B,primaryRef:u,dismissRef:d})]}),t.jsx(_s,{hint:bn(e.method,i)}),!e.answerable&&t.jsxs("p",{className:f.reconnectingNote,children:[t.jsx("span",{className:f.reconnectingDot}),"Reconnecting — you can answer again in a moment"]})]})}function xs({entry:e,onSubmit:n,primaryRef:s,dismissRef:o}){const{method:r,payload:a}=e;return r==="select"?t.jsx(vs,{entry:e,payload:a,onSubmit:n,primaryRef:s,dismissRef:o}):r==="confirm"?t.jsx(js,{entry:e,payload:a,onSubmit:n,primaryRef:s,dismissRef:o}):r==="input"?t.jsx(ks,{entry:e,payload:a,onSubmit:n,primaryRef:s}):r==="editor"?t.jsx(bs,{entry:e,payload:a,onSubmit:n,primaryRef:s,dismissRef:o}):t.jsx(ys,{entry:e,method:r,payload:a,onSubmit:n,primaryRef:s,dismissRef:o})}function ae({text:e}){return t.jsx("div",{className:f.title,children:he(e).join(`
6
6
  `)})}function vs({entry:e,payload:n,onSubmit:s,primaryRef:o,dismissRef:r}){const a=U(n,"title")??"",l=us(n,"options"),[i,h]=p.useState(null);if(l.length===0){const u=L(e,i===0);return t.jsxs(t.Fragment,{children:[t.jsx(ae,{text:a}),t.jsx("p",{className:f.emptyOptionsNote,children:"The extension offered no options."}),t.jsx("div",{className:f.controls,children:t.jsx(T,{ref:d=>{o.current=d,r.current=d},size:"xs",variant:"secondary",onClick:()=>{h(0),s({cancelled:!0})},...u,children:"Cancel"})})]})}const m=Cn(l);return t.jsxs(t.Fragment,{children:[t.jsx(ae,{text:a}),t.jsx("div",{className:S(f.controls,m.mode==="stack"&&f.controlsStack,m.scrolls&&f.controlsScroll),children:l.map((u,d)=>t.jsx(T,{ref:d===0?x=>{o.current=x}:void 0,size:"xs",variant:"secondary",className:f.optionButton,onClick:()=>{h(d),s({value:u})},...L(e,i===d),children:u},d))})]})}function js({entry:e,payload:n,onSubmit:s,primaryRef:o,dismissRef:r}){const a=U(n,"title")??"",l=U(n,"message"),i=Dn(a,l),[h,m]=p.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:S(f.title,i.message&&f.titleEmphasised),children:i.title.join(`
7
7
  `)}),i.message&&t.jsx("div",{className:f.message,children:i.message.join(`
8
- `)}),t.jsxs("div",{className:f.controls,children:[t.jsx(T,{ref:u=>{o.current=u},size:"xs",variant:"default",onClick:()=>{m("yes"),s({confirmed:!0})},...L(e,h==="yes"),children:"Yes"}),t.jsx(T,{ref:u=>{r.current=u},size:"xs",variant:"secondary",onClick:()=>{m("no"),s({confirmed:!1})},...L(e,h==="no"),children:"No"})]})]})}function ks({entry:e,payload:n,onSubmit:s,primaryRef:o}){const r=U(n,"title")??"",a=U(n,"placeholder"),[l,i]=p.useState(""),h=L(e,e.submitting===!0),m=h.disabled===!0||h.loading===!0;return t.jsxs(t.Fragment,{children:[t.jsx(ae,{text:r}),t.jsxs("div",{className:f.controls,children:[t.jsx(dt,{ref:u=>{o.current=u},className:f.field,value:l,placeholder:a,disabled:m,onChange:u=>i(u.target.value),onKeyDown:u=>{u.key!=="Enter"||m||(u.preventDefault(),u.stopPropagation(),s({value:l}))}}),t.jsx(T,{size:"xs",variant:"default",onClick:()=>s({value:l}),...h,children:"Submit"})]})]})}function bs({entry:e,payload:n,onSubmit:s,primaryRef:o,dismissRef:r}){const a=U(n,"title")??"",l=U(n,"prefill")??"",[i,h]=p.useState(l),[m,u]=p.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(ae,{text:a}),t.jsx(Re,{ref:d=>{o.current=d},className:f.editorField,rows:3,value:i,disabled:!e.answerable||e.submitting,onChange:d=>{h(d.target.value);const x=d.target;x.style.height="auto",x.style.height=`${Math.min(x.scrollHeight,ds)}px`},onKeyDown:d=>{d.key!=="Enter"||d.shiftKey!==We(e.method)||(d.preventDefault(),d.stopPropagation(),u("submit"),s({value:i}))}}),t.jsxs("div",{className:f.controls,children:[t.jsx(T,{size:"xs",variant:"default",onClick:()=>{u("submit"),s({value:i})},...L(e,m==="submit"),children:"Submit"}),t.jsx(T,{ref:d=>{r.current=d},size:"xs",variant:"secondary",onClick:()=>{u("cancel"),s({cancelled:!0})},...L(e,m==="cancel"),children:"Cancel"})]})]})}function ys({entry:e,method:n,payload:s,onSubmit:o,primaryRef:r,dismissRef:a}){const l={method:n,...s},i=L(e,e.submitting===!0);return t.jsxs(t.Fragment,{children:[t.jsx("p",{className:f.title,children:"This extension asked something this version of Pi-Studio can't display."}),t.jsx("pre",{className:f.rawPayload,children:JSON.stringify(l,null,2)}),t.jsx("div",{className:f.controls,children:t.jsx(T,{ref:h=>{r.current=h,a.current=h},size:"xs",variant:"secondary",onClick:()=>o({cancelled:!0}),...i,children:"Cancel"})})]})}function Be(e){if(e===void 0)return null;const n=typeof e=="number"?e:Date.parse(e);return Number.isNaN(n)?null:n}function Ns(e,n,s,o){if(n.length===0)return e.map(s);const r=[];let a=0;const l=i=>{for(;a<e.length;){const h=e[a];if(h===void 0)break;if(i!==null){const m=Be(h.timestamp);if(m!==null&&m>i)break}r.push(s(h)),a++}};for(const i of n){if(i.kind==="more"){r.push(o(i));continue}l(Be(i.item.entry.createdAt)),r.push(o(i))}for(;a<e.length;a++){const i=e[a];i!==void 0&&r.push(s(i))}return r}function ws(e,n){return!e||n===void 0?!1:n.every(s=>s.configured===!1)}const Ss=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ee(e){return String(e).padStart(2,"0")}function ge(e){if(!e)return;const n=new Date(e);if(!Number.isNaN(n.getTime()))return`${Ss[n.getMonth()]} ${n.getDate()}, ${Ee(n.getHours())}:${Ee(n.getMinutes())}`}const Cs="_queuedBadge_mdmbp_8",Ds="_finalChip_mdmbp_20",Bs="_userDisc_mdmbp_30",Es="_userAligned_mdmbp_34",Ts="_userPendingRow_mdmbp_40",As="_userBubble_mdmbp_44",Rs="_userBubbleFailed_mdmbp_58",Is="_userImages_mdmbp_63",Ps="_userImage_mdmbp_63",Ms="_imageDialog_mdmbp_79",Os="_imageDialogPreview_mdmbp_83",qs="_assistantDisc_mdmbp_93",Fs="_assistantBody_mdmbp_97",Ls="_reasoningDisc_mdmbp_108",Ks="_reasoningBody_mdmbp_112",Hs="_toolDisc_mdmbp_123",zs="_toolCardBody_mdmbp_127",$s="_toolCardBodyRunning_mdmbp_134",Us="_toolCardBodyCompleted_mdmbp_138",Ws="_toolCardBodyError_mdmbp_142",Gs="_toolHeader_mdmbp_146",Js="_toolHeaderRunning_mdmbp_172",Qs="_toolChevron_mdmbp_182",Vs="_toolChevronOpen_mdmbp_188",Ys="_kindBadge_mdmbp_192",Xs="_toolPath_mdmbp_204",Zs="_toolTrailing_mdmbp_213",eo="_toolStatusRunning_mdmbp_221",to="_toolStatusSuccess_mdmbp_228",no="_toolStatusError_mdmbp_232",so="_toolStatusUnknown_mdmbp_236",oo="_toolDiffAdded_mdmbp_240",ro="_toolDiffRemoved_mdmbp_244",ao="_toolOpenButton_mdmbp_248",io="_toolBody_mdmbp_266",co="_toolCode_mdmbp_272",lo="_toolOutputStrip_mdmbp_283",uo="_toolDiffPreview_mdmbp_293",mo="_toolDiffPreviewLine_mdmbp_301",fo="_toolDiffPreviewAdd_mdmbp_305",po="_toolDiffPreviewDel_mdmbp_310",ho="_toolDiffPreviewMore_mdmbp_315",_o="_errorDisc_mdmbp_322",go="_errorCard_mdmbp_326",xo="_errorLead_mdmbp_335",vo="_systemRow_mdmbp_342",_={queuedBadge:Cs,finalChip:Ds,userDisc:Bs,userAligned:Es,userPendingRow:Ts,userBubble:As,userBubbleFailed:Rs,userImages:Is,userImage:Ps,imageDialog:Ms,imageDialogPreview:Os,assistantDisc:qs,assistantBody:Fs,reasoningDisc:Ls,reasoningBody:Ks,toolDisc:Hs,toolCardBody:zs,toolCardBodyRunning:$s,toolCardBodyCompleted:Us,toolCardBodyError:Ws,toolHeader:Gs,toolHeaderRunning:Js,toolChevron:Qs,toolChevronOpen:Vs,kindBadge:Ys,toolPath:Xs,toolTrailing:Zs,toolStatusRunning:eo,toolStatusSuccess:to,toolStatusError:no,toolStatusUnknown:so,toolDiffAdded:oo,toolDiffRemoved:ro,toolOpenButton:ao,toolBody:io,toolCode:co,toolOutputStrip:lo,toolDiffPreview:uo,toolDiffPreviewLine:mo,toolDiffPreviewAdd:fo,toolDiffPreviewDel:po,toolDiffPreviewMore:ho,errorDisc:_o,errorCard:go,errorLead:xo,systemRow:vo};function jo({row:e,assetBase:n=null,owningPaneId:s=null,workspaceCwd:o=null,connector:r}){const a=ge(e.timestamp);return t.jsx(O,{disc:t.jsx(M,{icon:Bt,size:"xs",color:"var(--pi-color-accentForeground)"}),discClassName:_.assistantDisc,connector:r,meta:t.jsxs(t.Fragment,{children:["Assistant",a&&t.jsxs("span",{className:I.metaTime,children:[" · ",a]})]}),children:t.jsx("div",{className:_.assistantBody,children:e.streaming?t.jsx(qe,{text:e.text,assetBase:n,owningPaneId:s,workspaceCwd:o}):t.jsx(Fe,{text:e.text,assetBase:n,owningPaneId:s,workspaceCwd:o})})})}function ko({row:e,owningPaneId:n=null,workspaceCwd:s=null,connector:o}){const r=ge(e.timestamp);return t.jsx(O,{disc:t.jsx(M,{icon:Et,size:"xs",color:"var(--pi-color-foregroundMuted)"}),discClassName:_.reasoningDisc,connector:o,meta:t.jsxs(t.Fragment,{children:["Reasoning",r&&t.jsxs("span",{className:I.metaTime,children:[" · ",r]})]}),metaTrailing:!e.streaming&&t.jsx("span",{className:_.finalChip,children:"final"}),children:t.jsx("div",{className:_.reasoningBody,children:e.streaming?t.jsx(qe,{text:e.text,owningPaneId:n,workspaceCwd:s}):t.jsx(Fe,{text:e.text,owningPaneId:n,workspaceCwd:s})})})}function bo(e){const n=Wt(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 yo(e){return e.status==="completed"?t.jsx("span",{className:_.toolStatusSuccess,children:"✓ completed"}):e.status==="error"?t.jsx("span",{className:_.toolStatusError,children:e.statusText||"error"}):e.statusText&&e.statusText!=="running"?t.jsx("span",{className:_.toolStatusUnknown,children:e.statusText}):t.jsxs("span",{className:_.toolStatusRunning,children:[t.jsx(_e,{size:"xs",color:"var(--pi-color-accentBright)"}),"running"]})}function No({row:e,assetBase:n=null,owningPaneId:s=null,workspaceCwd:o=null,connector:r}){const[a,l]=p.useState(!1),i=Xt(e.tool),h=Yt(e.tool),m=h.length>0,u=en(e.tool.output),d=e.tool.kind==="edit"||e.tool.kind==="write"?ze(e.tool):null,x=e.tool.kind==="edit"?Zt(e.tool.diff):null,B=e.tool.kind==="edit"&&e.tool.diff&&!a?bo(e.tool.diff):null;function A(){m&&l(g=>!g)}function C(g){g.target===g.currentTarget&&(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),A())}function y(g){if(g.stopPropagation(),!d)return;const w=$t(n,s,o);ut(d,w.workspaceCwd,w.targetPaneId)}return t.jsx(O,{disc:t.jsx(M,{icon:Qt(e.tool),size:"xs",color:"var(--pi-color-foregroundMuted)"}),discClassName:_.toolDisc,connector:r,children:t.jsxs("div",{className:S(_.toolCardBody,e.status==="running"&&_.toolCardBodyRunning,e.status==="completed"&&_.toolCardBodyCompleted,e.status==="error"&&_.toolCardBodyError),children:[t.jsxs("div",{role:"button",tabIndex:m?0:-1,"aria-expanded":m?a:void 0,"aria-disabled":!m,className:S(_.toolHeader,e.status==="running"&&_.toolHeaderRunning),onClick:A,onKeyDown:C,children:[m&&t.jsx(Tt,{size:12,className:S(_.toolChevron,a&&_.toolChevronOpen)}),t.jsx("span",{className:_.kindBadge,style:{"--kindToken":`var(--pi-color-${i.token})`},children:i.label}),t.jsx("span",{className:_.toolPath,title:fe(e.tool),children:fe(e.tool)}),t.jsxs("span",{className:_.toolTrailing,children:[x&&(x.added>0||x.removed>0)&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:_.toolDiffAdded,children:["+",x.added]}),t.jsxs("span",{className:_.toolDiffRemoved,children:["−",x.removed]})]}),yo(e),d&&t.jsxs("button",{type:"button",className:_.toolOpenButton,onClick:y,onKeyDown:g=>g.stopPropagation(),children:["Open",t.jsx(At,{size:10})]})]})]}),u>0&&t.jsxs("div",{className:_.toolOutputStrip,children:["output · ",u," lines"]}),B&&t.jsxs("div",{className:_.toolDiffPreview,children:[t.jsx("div",{className:S(_.toolDiffPreviewLine,B.kind==="add"?_.toolDiffPreviewAdd:_.toolDiffPreviewDel),children:B.text}),B.moreCount>0&&t.jsxs("div",{className:_.toolDiffPreviewMore,children:["… ",B.moreCount," more lines"]})]}),a&&m&&t.jsx("div",{className:_.toolBody,children:h.map((g,w)=>g.kind==="diff"?t.jsx(Ut,{patch:g.patch},w):t.jsx("pre",{className:_.toolCode,children:g.text},w))})]})})}function wo({row:e,connector:n}){const[s,o]=p.useState(null),r=ge(e.timestamp);return t.jsxs(O,{disc:t.jsx(M,{icon:It,size:"xs",color:"var(--pi-color-successForeground)"}),discClassName:_.userDisc,connector:n,className:S(_.userAligned,e.pending&&_.userPendingRow),meta:t.jsxs(t.Fragment,{children:["You",r&&t.jsxs("span",{className:I.metaTime,children:[" · ",r]}),e.failed&&" · failed to send"]}),metaTrailing:e.queued&&!e.failed&&t.jsxs("span",{className:_.queuedBadge,children:[t.jsx(Rt,{size:9}),"queued"]}),children:[t.jsx("span",{className:S(_.userBubble,e.failed&&_.userBubbleFailed),children:e.text}),e.images&&e.images.length>0&&t.jsx("div",{className:_.userImages,children:e.images.map((a,l)=>{const i=`data:${a.mimeType??"image/png"};base64,${a.data??""}`;return t.jsx("img",{className:_.userImage,src:i,alt:"",role:"button",tabIndex:0,onClick:()=>o(i),onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&o(i)}},l)})}),t.jsx(mt,{open:s!==null,onOpenChange:a=>{a||o(null)},title:"Image",width:"auto",bare:!0,className:_.imageDialog,children:s&&t.jsx("img",{className:_.imageDialogPreview,src:s,alt:""})})]})}function So({row:e,connector:n}){return t.jsx(O,{disc:t.jsx(M,{icon:Pt,size:"xs",color:"var(--pi-color-destructive)"}),discClassName:_.errorDisc,connector:n,children:t.jsxs("div",{className:_.errorCard,children:[t.jsx("span",{className:_.errorLead,children:"Error"})," · ",e.text]})})}function Co({row:e}){return t.jsx("div",{className:_.systemRow,children:e.text})}const Do=500;function Bo(e,n){const s=p.useRef(!0),[o,r]=p.useState(!0),a=p.useRef(0),l=p.useCallback(m=>{const u=n.current,d=u?{scrollTop:u.scrollTop,scrollHeight:u.scrollHeight,clientHeight:u.clientHeight}:{scrollTop:0,scrollHeight:0,clientHeight:0},x=rn(s.current,m,d);x.pinned!==s.current&&(s.current=x.pinned,r(x.pinned)),x.stick&&e.options.count>0&&e.scrollToEnd({behavior:"auto"})},[n,e]);p.useEffect(()=>{const m=n.current;if(!m)return;const u=()=>{a.current=performance.now()},d=()=>{l({kind:"scroll",gesture:performance.now()-a.current<Do})};m.addEventListener("scroll",d,{passive:!0}),m.addEventListener("wheel",u,{passive:!0}),m.addEventListener("touchmove",u,{passive:!0}),m.addEventListener("pointerdown",u,{passive:!0}),m.addEventListener("keydown",u,{passive:!0});const x=new ResizeObserver(()=>{m.clientHeight>0&&l({kind:"shown"})});return x.observe(m),()=>{x.disconnect(),m.removeEventListener("scroll",d),m.removeEventListener("wheel",u),m.removeEventListener("touchmove",u),m.removeEventListener("pointerdown",u),m.removeEventListener("keydown",u)}},[l,n]);const i=p.useCallback(()=>l({kind:"tail"}),[l]),h=p.useCallback(()=>l({kind:"pin"}),[l]);return{pinned:o,followTail:i,pinToBottom:h}}const Eo="_root_1xg4h_6",To="_viewport_1xg4h_13",Ao="_inner_1xg4h_20",Ro="_rowWrap_1xg4h_25",Io="_empty_1xg4h_35",Po="_nudge_1xg4h_47",Mo="_jumpToLatest_1xg4h_56",$={root:Eo,viewport:To,inner:Ao,rowWrap:Ro,empty:Io,nudge:Po,jumpToLatest:Mo},Oo=160;function qo(e){return e.kind==="ask"?`ask:${gn(e.item)}`:e.kind==="ask-more"?"ask-more":e.row.id}function Fo(e,n,s,o,r){switch(e.kind){case"user":return t.jsx(wo,{row:e,connector:!n});case"assistant":return t.jsx(jo,{row:e,assetBase:s,owningPaneId:o,workspaceCwd:r,connector:!n});case"reasoning":return t.jsx(ko,{row:e,owningPaneId:o,workspaceCwd:r,connector:!n});case"tool":return t.jsx(No,{row:e,assetBase:s,owningPaneId:o,workspaceCwd:r,connector:!n});case"error":return t.jsx(So,{row:e,connector:!n});case"system":return t.jsx(Co,{row:e})}}function Lo(e,n,s,o,r,a,l,i){return e.kind==="ask"?t.jsx(ms,{item:e.item,collapsed:e.collapsed,connector:!n,autoFocus:e.item.kind==="pending"&&e.item.entry.requestId===l,sessionTitle:i}):e.kind==="ask-more"?t.jsx(ps,{count:e.count,connector:!n,onExpand:a}):Fo(e.row,n,s,o,r)}function Ko({session:e,owningPaneId:n,workspaceCwd:s}){var q,F;const o=e.timeline.rows,r=e.status==="running",a=ft(),l=pt(e.cwd,a),i=p.useRef(null),h=ht(e.agentId??""),m=_t(e.agentId??""),[u,d]=p.useState(!1),x=P(v=>v.activeSessionId===e.id),B=gt(v=>{var D;return((D=v.layouts[s])==null?void 0:D.focusedPaneId)===n}),A=x&&B?((q=h[0])==null?void 0:q.requestId)??null:null,C=p.useMemo(()=>{const v=vn(_n(h,m),u);return Ns(o,v,D=>({kind:"row",row:D}),D=>D.kind==="more"?{kind:"ask-more",count:D.count}:{kind:"ask",item:D.item,collapsed:D.collapsed})},[o,h,m,u]),y=Q(v=>v.status==="open"),g=Q(v=>v.serverInfo),w=!!((F=g==null?void 0:g.features)!=null&&F.providerAuth),j=xt(v=>v.openSettings),{data:V}=zt(o.length===0&&y&&w),te=ws(w,V),K=rt({count:C.length,getScrollElement:()=>i.current,estimateSize:()=>Oo,overscan:8,getItemKey:v=>{const D=C[v];return D?qo(D):v},measureElement:(v,D,H)=>{if(v.offsetParent!==null)return at(v,D,H);const ee=H.indexFromElement(v),ce=H.options.getItemKey(ee);return H.itemSizeCache.get(ce)??H.options.estimateSize(ee)},anchorTo:"end",scrollEndThreshold:$e}),{pinned:ne,followTail:Y,pinToBottom:X}=Bo(K,i),Z=an(o);return p.useEffect(()=>{Y()},[C.length,Y]),p.useEffect(()=>{Z!==null&&X()},[Z,X]),t.jsxs("div",{className:$.root,children:[t.jsx("div",{className:$.viewport,ref:i,children:C.length===0?!r&&(te?t.jsxs(vt,{className:$.nudge,children:[t.jsx("span",{children:"No messages yet — connect a model provider to get started."}),t.jsx(T,{size:"xs",variant:"secondary",onClick:()=>j(),children:"Connect a model provider"})]}):t.jsx("div",{className:$.empty,children:"No messages yet — say something to start."})):t.jsx("div",{className:$.inner,style:{height:K.getTotalSize()},children:K.getVirtualItems().map(v=>{const D=C[v.index];return D?t.jsx("div",{ref:K.measureElement,"data-index":v.index,className:$.rowWrap,style:{transform:`translateY(${v.start}px)`},children:Lo(D,v.index===C.length-1,l,n,s,()=>d(!0),A,e.title)},v.key):null})})}),!ne&&C.length>0&&t.jsx("button",{type:"button",className:$.jumpToLatest,onClick:X,title:"Jump to latest","aria-label":"Jump to latest",children:t.jsx(Mt,{size:16,"aria-hidden":"true"})})]})}function Ho(e,n=!0){const s=Q(o=>o.client);return Ae({queryKey:Ie.agentCommands(e),queryFn:async()=>{if(!s)throw new Error("not connected");const o=await pe(s,e),{commands:r}=await s.agent(o).listCommands();return r},enabled:!!s&&!!e&&n})}const zo="_strip_nzfk5_4",$o="_thumb_nzfk5_11",Uo="_remove_nzfk5_28",ue={strip:zo,thumb:$o,remove:Uo};function Wo({images:e,onRemove:n}){return e.length===0?null:t.jsx("div",{className:ue.strip,children:e.map((s,o)=>t.jsxs("div",{className:ue.thumb,children:[t.jsx("img",{src:s.thumbUrl,alt:""}),t.jsx("button",{type:"button",className:ue.remove,title:"Remove",onClick:()=>n(o),children:"×"})]},o))})}function Go(e){const{promise:n,resolve:s,reject:o}=Promise.withResolvers(),r=new FileReader;return r.onload=()=>{const a=r.result;if(typeof a!="string"){o(new Error("Unexpected FileReader result"));return}const l=a.indexOf(","),i=l>=0?a.slice(l+1):a;s({mimeType:e.type,data:i,thumbUrl:a})},r.onerror=()=>o(r.error??new Error("Failed to read file")),r.readAsDataURL(e),n}function Jo(e,n,s){return e?s:n}const Qo="_picker_1jy8c_4",Vo="_search_1jy8c_10",Yo="_list_1jy8c_28",Xo="_item_1jy8c_33",Zo="_itemActive_1jy8c_47",er="_checkSlot_1jy8c_51",tr="_label_1jy8c_60",nr="_modelId_1jy8c_66",sr="_state_1jy8c_73",or="_stateError_1jy8c_82",rr="_commandContent_1jy8c_92",ar="_commandList_1jy8c_95",ir="_commandItem_1jy8c_100",cr="_commandItemHeader_1jy8c_132",lr="_commandKindBadge_1jy8c_146",dr="_commandKindExtension_1jy8c_165",ur="_commandKindPrompt_1jy8c_170",mr="_commandKindSkill_1jy8c_175",fr="_commandDescription_1jy8c_180",N={picker:Qo,search:Vo,list:Yo,item:Xo,itemActive:Zo,checkSlot:er,label:tr,modelId:nr,state:sr,stateError:or,commandContent:rr,commandList:ar,commandItem:ir,commandItemHeader:cr,commandKindBadge:lr,commandKindExtension:dr,commandKindPrompt:ur,commandKindSkill:mr,commandDescription:fr},pr={onOpenAutoFocus:e=>e.preventDefault()};function hr(e){switch(e){case"extension":return N.commandKindExtension;case"prompt":return N.commandKindPrompt;case"skill":return N.commandKindSkill;default:return}}function _r({open:e,onOpenChange:n,options:s,highlightedIndex:o,onSelect:r,isLoading:a,isError:l,errorMessage:i,hiddenExtensionCount:h,renderTrigger:m}){const u=p.useRef(null);return p.useEffect(()=>{var d,x;e&&((x=(d=u.current)==null?void 0:d.querySelector('[aria-selected="true"]'))==null||x.scrollIntoView({block:"nearest"}))},[e,o]),t.jsxs(Le,{open:e,onOpenChange:n,modal:!1,children:[t.jsx(Ke,{asChild:!0,children:m()}),t.jsxs(Pe,{className:S(N.picker,N.commandContent),side:"top",sideOffset:4,...pr,onCloseAutoFocus:d=>d.preventDefault(),children:[a&&t.jsx("div",{className:N.state,children:t.jsx(_e,{size:"sm"})}),!a&&l&&t.jsx("div",{className:N.stateError,children:i??"Failed to load commands"}),!a&&!l&&s.length===0&&t.jsx("div",{className:N.state,children:"No commands found"}),!a&&!l&&s.length>0&&t.jsx("div",{ref:u,className:S(N.list,N.commandList),children:s.map((d,x)=>t.jsxs("div",{role:"option","aria-selected":x===o,className:S(N.item,N.commandItem,x===o&&N.itemActive),title:d.description,onMouseDown:B=>{B.preventDefault(),r(d.value)},children:[t.jsxs("div",{className:N.commandItemHeader,children:[t.jsx("span",{className:N.label,children:d.label}),d.kind&&t.jsx("span",{className:S(N.commandKindBadge,hr(d.kind)),children:d.kind})]}),d.description&&t.jsx("div",{className:N.commandDescription,children:d.description})]},d.value))}),!a&&!l&&h>0&&t.jsxs("div",{className:N.state,children:[h," extension command(s) unavailable while the agent is running"]})]})]})}function gr(e,n=!0){const s=Q(o=>o.client);return Ae({queryKey:Ie.providerModels(e),queryFn:async()=>{if(!s)throw new Error("not connected");return(await s.providers.listModels(e)).models},enabled:!!s&&!!e&&n})}function xr(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 vr(e){const n=new Set;return e.filter(s=>n.has(s.id)?!1:(n.add(s.id),!0))}function jr({currentModel:e,provider:n,onSelect:s,renderTrigger:o}){const[r,a]=p.useState(!1),[l,i]=p.useState(""),h=p.useRef(null),{data:m=[],isLoading:u,isError:d,error:x}=gr(n,r),B=vr(xr(m,e));p.useEffect(()=>{var j;r&&(i(""),(j=h.current)==null||j.focus())},[r]);const A=new Map(B.map(j=>[j.id,j.provider])),C=B.map(j=>({value:j.id,label:j.label??j.id,description:j.id})),y=He(C,l),g=x instanceof Error?x.message:"Failed to load models";function w(j){j.stopPropagation(),j.key==="Escape"&&a(!1)}return t.jsxs(Le,{open:r,onOpenChange:a,modal:!1,children:[t.jsx(Ke,{asChild:!0,children:o(e)}),t.jsxs(Pe,{minWidth:240,align:"end",sideOffset:6,className:N.picker,children:[t.jsx("input",{ref:h,className:N.search,placeholder:"Search models…",value:l,onChange:j=>i(j.target.value),onKeyDown:w}),u&&t.jsx("div",{className:N.state,children:t.jsx(_e,{size:"sm"})}),!u&&d&&t.jsx("div",{className:N.stateError,children:g}),!u&&!d&&y.length===0&&t.jsx("div",{className:N.state,children:"No models found"}),!u&&!d&&y.length>0&&t.jsx("div",{className:N.list,children:y.map(j=>t.jsxs(Gt,{className:N.item,onSelect:()=>s(j.value,A.get(j.value)),children:[t.jsx("span",{className:N.checkSlot,"aria-hidden":!0,children:j.value===e&&t.jsx(Oe,{size:14})}),t.jsx("span",{className:N.label,children:j.label}),t.jsxs("span",{className:N.modelId,children:["(",j.value,")"]})]},j.value))})]})]})}function xe(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 kr(e){return/^\/\S*$/.test(e)}function br(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 yr(e,n,s){return s<=0?0:(e+n+s)%s}function Nr(e,n){const s=xe(e);return s?s.hasArgs?`/${n}${e.slice(s.end)}`:`/${n} `:`/${n} ${e}`}function wr(e,n){const s=xe(e);return!s||!n.includes(s.name)?null:{end:s.end}}const Sr="_composer_ipwxh_4",Cr="_card_ipwxh_13",Dr="_flash_ipwxh_27",Br="_note_ipwxh_41",Er="_textarea_ipwxh_49",Tr="_textareaWrap_ipwxh_73",Ar="_highlightLayer_ipwxh_61",Rr="_commandMark_ipwxh_96",Ir="_hiddenFileInput_ipwxh_121",Pr="_toolbar_ipwxh_127",Mr="_toolbarRight_ipwxh_134",Or="_toolBtn_ipwxh_142",qr="_roundBtn_ipwxh_148",Fr="_modelBtn_ipwxh_153",Lr="_modelLabel_ipwxh_179",Kr="_modelChevron_ipwxh_184",E={composer:Sr,card:Cr,flash:Dr,note:Br,textarea:Er,textareaWrap:Tr,highlightLayer:Ar,commandMark:Rr,hiddenFileInput:Ir,toolbar:Pr,toolbarRight:Mr,toolBtn:Or,roundBtn:qr,modelBtn:Fr,modelLabel:Lr,modelChevron:Kr},Hr=160;function re(e){e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,Hr)}px`}function zr(e){return typeof e=="object"&&e!==null&&"ok"in e&&e.ok===!1}function $r(){return typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Ur({sessionId:e}){const n=Q(c=>c.client),s=P(c=>c.sessions[e]),o=P(c=>c.addOptimisticUserMessage),r=P(c=>c.markUserMessageFailed),a=P(c=>c.setCwd),l=P(c=>c.setModel),i=oe(c=>c.drafts[e]??""),h=oe(c=>c.setDraft),[m,u]=p.useState([]),[d,x]=p.useState(!1),[B,A]=p.useState(!1),C=p.useRef(null),y=p.useRef(null),[g,w]=p.useState(!1),[j,V]=p.useState(0),te=jt(kt.chat(e)),K=oe(c=>c.pendingFeedback[e]),[ne,Y]=p.useState(null),[X,Z]=p.useState(!1),q=p.useRef(null),F=p.useRef(null);p.useEffect(()=>{if(!te||K===void 0)return;const c=oe.getState().consumeFeedback(e);if(!c)return;Y(c.copy==="filled"?"Your message was filled in":"Your draft was replaced"),q.current!==null&&window.clearTimeout(q.current),q.current=window.setTimeout(()=>Y(null),4e3);const k=C.current;k&&k.setSelectionRange(k.value.length,k.value.length),c.flash&&(Z(!0),F.current!==null&&window.clearTimeout(F.current),F.current=window.setTimeout(()=>Z(!1),$r()?1e3:400))},[te,K,e]),p.useEffect(()=>()=>{q.current!==null&&window.clearTimeout(q.current),F.current!==null&&window.clearTimeout(F.current)},[]);const v=(s==null?void 0:s.status)==="running",D=Jo(v,d,B),H=!!n&&!D&&(i.trim().length>0||m.length>0),{data:ee=[],isLoading:ce,isError:Je,error:ve}=Ho(e,g),{options:je,hiddenExtensionCount:Qe}=br(ee,{running:v}),ke=xe(i),se=ke?He(je,ke.name):je,Ve=ee.map(c=>c.name),W=wr(i,Ve);async function be(c){if(c.type.startsWith("image/"))try{const k=await Go(c);u(b=>[...b,k])}catch{}}function Ye(c){for(const k of c.target.files??[])be(k);c.target.value=""}function Xe(c){for(const k of c.clipboardData.items)if(k.type.startsWith("image/")){c.preventDefault();const b=k.getAsFile();b&&be(b)}}function Ze(c){u(k=>k.filter((b,R)=>R!==c))}function et(c){const k=c.target.value;h(e,k),re(c.target);const b=kr(k);b!==g&&w(b),b&&V(0)}function tt(c){var k;if(!g&&W&&c.key==="Backspace"){const b=c.currentTarget,R=b.selectionStart;if(R!==null&&R===b.selectionEnd){const G=W.end+(i[W.end]===" "?1:0);if(R>0&&R<=G){c.preventDefault();const z=i.slice(G);h(e,z),b.setSelectionRange(0,0),re(b);return}}}if(g&&se.length>0){if(c.key==="ArrowDown"||c.key==="ArrowUp"){c.preventDefault(),V(b=>yr(b,c.key==="ArrowDown"?1:-1,se.length));return}if(c.key==="Enter"&&!c.shiftKey||c.key==="Tab"){c.preventDefault();const b=(k=se[j])==null?void 0:k.value;b&&ye(b);return}}if(g&&c.key==="Escape"){c.preventDefault(),w(!1);return}c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),Ne(v?"steer":"send"))}function ye(c){const k=Nr(i,c);h(e,k),w(!1),V(0);const b=C.current;b&&(b.focus(),b.setSelectionRange(k.length,k.length),re(b))}async function Ne(c){if(!n||!s||(c==="steer"?B:d)||c==="steer"&&!s.agentId)return;const k=i.trim();if(!k&&m.length===0)return;h(e,""),w(!1),C.current&&re(C.current);const b=m;u([]);const R=k||"Describe this image",G=b.length>0?b.map(J=>({mimeType:J.mimeType,data:J.data})):void 0,z=bt();o(e,z,R,G,c==="steer");const we=c==="steer"?A:x;we(!0);try{if(c==="steer"){const J=await n.agent(s.agentId).steer(R,{clientMessageId:z,images:G});zr(J)&&r(e,z)}else{s.agentId||a(e,s.cwd||"~");const J=await pe(n,e);await n.agent(J).send(R,{clientMessageId:z,images:G})}}catch{r(e,z)}finally{we(!1)}}function nt(){s!=null&&s.agentId&&(n==null||n.agent(s.agentId).interrupt())}function st(c,k){l(e,c,k),!(!n||!k)&&(async()=>{const b=await pe(n,e);await n.agent(b).setModel(k,c)})().catch(()=>{})}return t.jsxs("div",{className:E.composer,children:[t.jsxs("div",{className:S(E.card,X&&E.flash),children:[t.jsxs("div",{className:E.textareaWrap,children:[t.jsx("div",{className:E.highlightLayer,"aria-hidden":!0,children:W?t.jsxs(t.Fragment,{children:[t.jsx("mark",{className:E.commandMark,children:i.slice(0,W.end)}),i.slice(W.end)]}):i}),t.jsx(Re,{ref:C,className:E.textarea,rows:1,value:i,placeholder:v?"Steer the running turn… ⏎ steer · ⇧⏎ newline":"Ask anything… ⏎ send · ⇧⏎ newline · / commands",onChange:et,onKeyDown:tt,onPaste:Xe})]}),t.jsx(Wo,{images:m,onRemove:Ze}),t.jsxs("div",{className:E.toolbar,children:[t.jsx(T,{className:E.toolBtn,variant:"ghost",size:"sm",iconOnly:!0,title:"Attach image","aria-label":"Attach image",onClick:()=>{var c;return(c=y.current)==null?void 0:c.click()},children:t.jsx(Ot,{size:16})}),t.jsx(_r,{open:g,onOpenChange:w,options:se,highlightedIndex:j,onSelect:ye,isLoading:ce,isError:Je,errorMessage:ve instanceof Error?ve.message:void 0,hiddenExtensionCount:Qe,renderTrigger:()=>t.jsx(T,{className:E.toolBtn,variant:"ghost",size:"sm",iconOnly:!0,title:"Slash commands","aria-label":"Slash commands",children:t.jsx(qt,{size:16})})}),t.jsxs("div",{className:E.toolbarRight,children:[t.jsx(jr,{currentModel:s==null?void 0:s.model,provider:"pi",onSelect:st,renderTrigger:c=>t.jsxs("button",{type:"button",className:E.modelBtn,disabled:!n,title:c?`Model: ${c}`:"Select model",children:[t.jsx("span",{className:E.modelLabel,children:c??"Model"}),t.jsx(Ft,{size:13,className:E.modelChevron,"aria-hidden":"true"})]})}),v&&t.jsx(T,{className:E.roundBtn,variant:"destructive",size:"sm",iconOnly:!0,title:"Stop the running turn","aria-label":"Stop",onClick:nt,children:t.jsx(Lt,{size:14})}),t.jsx(T,{className:E.roundBtn,size:"sm",iconOnly:!0,disabled:!H,title:v?"Steer the running turn":"Send","aria-label":v?"Steer":"Send",onClick:()=>void Ne(v?"steer":"send"),children:v?t.jsx(Kt,{size:16}):t.jsx(Ht,{size:18})})]})]})]}),ne!==null&&t.jsx("div",{className:E.note,children:ne}),t.jsx("input",{ref:y,className:E.hiddenFileInput,type:"file",accept:"image/*",multiple:!0,onChange:Ye})]})}const Wr="_track_oxvl6_2",Gr="_sweep_oxvl6_24",Jr="_visuallyHidden_oxvl6_64",me={track:Wr,sweep:Gr,visuallyHidden:Jr};function Qr({running:e}){return e?t.jsxs("div",{className:me.track,role:"progressbar","aria-label":"Turn in progress",children:[t.jsx("div",{className:me.sweep,"aria-hidden":"true"}),t.jsx("span",{className:me.visuallyHidden,role:"status","aria-live":"polite",children:"Agent is working…"})]}):null}const Vr="_panel_1tq06_1",Yr="_empty_1tq06_5",Te={panel:Vr,empty:Yr};function ua({tab:e,owningPaneId:n}){const{sessionId:s}=e.data,o=P(r=>r.sessions[s]);return on(s),o?t.jsxs(Se,{className:Te.panel,children:[t.jsx(Qr,{running:o.status==="running"}),t.jsx(Ko,{session:o,owningPaneId:n,workspaceCwd:e.workspaceCwd}),t.jsx(Ur,{sessionId:o.id})]}):t.jsx(Se,{children:t.jsx("div",{className:Te.empty,children:"Session not found."})})}export{ua as ChatPanel};
8
+ `)}),t.jsxs("div",{className:f.controls,children:[t.jsx(T,{ref:u=>{o.current=u},size:"xs",variant:"default",onClick:()=>{m("yes"),s({confirmed:!0})},...L(e,h==="yes"),children:"Yes"}),t.jsx(T,{ref:u=>{r.current=u},size:"xs",variant:"secondary",onClick:()=>{m("no"),s({confirmed:!1})},...L(e,h==="no"),children:"No"})]})]})}function ks({entry:e,payload:n,onSubmit:s,primaryRef:o}){const r=U(n,"title")??"",a=U(n,"placeholder"),[l,i]=p.useState(""),h=L(e,e.submitting===!0),m=h.disabled===!0||h.loading===!0;return t.jsxs(t.Fragment,{children:[t.jsx(ae,{text:r}),t.jsxs("div",{className:f.controls,children:[t.jsx(dt,{ref:u=>{o.current=u},className:f.field,value:l,placeholder:a,disabled:m,onChange:u=>i(u.target.value),onKeyDown:u=>{u.key!=="Enter"||m||(u.preventDefault(),u.stopPropagation(),s({value:l}))}}),t.jsx(T,{size:"xs",variant:"default",onClick:()=>s({value:l}),...h,children:"Submit"})]})]})}function bs({entry:e,payload:n,onSubmit:s,primaryRef:o,dismissRef:r}){const a=U(n,"title")??"",l=U(n,"prefill")??"",[i,h]=p.useState(l),[m,u]=p.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(ae,{text:a}),t.jsx(Re,{ref:d=>{o.current=d},className:f.editorField,rows:3,value:i,disabled:!e.answerable||e.submitting,onChange:d=>{h(d.target.value);const x=d.target;x.style.height="auto",x.style.height=`${Math.min(x.scrollHeight,ds)}px`},onKeyDown:d=>{d.key!=="Enter"||d.shiftKey!==We(e.method)||(d.preventDefault(),d.stopPropagation(),u("submit"),s({value:i}))}}),t.jsxs("div",{className:f.controls,children:[t.jsx(T,{size:"xs",variant:"default",onClick:()=>{u("submit"),s({value:i})},...L(e,m==="submit"),children:"Submit"}),t.jsx(T,{ref:d=>{r.current=d},size:"xs",variant:"secondary",onClick:()=>{u("cancel"),s({cancelled:!0})},...L(e,m==="cancel"),children:"Cancel"})]})]})}function ys({entry:e,method:n,payload:s,onSubmit:o,primaryRef:r,dismissRef:a}){const l={method:n,...s},i=L(e,e.submitting===!0);return t.jsxs(t.Fragment,{children:[t.jsx("p",{className:f.title,children:"This extension asked something this version of Pi-Studio can't display."}),t.jsx("pre",{className:f.rawPayload,children:JSON.stringify(l,null,2)}),t.jsx("div",{className:f.controls,children:t.jsx(T,{ref:h=>{r.current=h,a.current=h},size:"xs",variant:"secondary",onClick:()=>o({cancelled:!0}),...i,children:"Cancel"})})]})}function Be(e){if(e===void 0)return null;const n=typeof e=="number"?e:Date.parse(e);return Number.isNaN(n)?null:n}function Ns(e,n,s,o){if(n.length===0)return e.map(s);const r=[];let a=0;const l=i=>{for(;a<e.length;){const h=e[a];if(h===void 0)break;if(i!==null){const m=Be(h.timestamp);if(m!==null&&m>i)break}r.push(s(h)),a++}};for(const i of n){if(i.kind==="more"){r.push(o(i));continue}l(Be(i.item.entry.createdAt)),r.push(o(i))}for(;a<e.length;a++){const i=e[a];i!==void 0&&r.push(s(i))}return r}function ws(e,n){return!e||n===void 0?!1:n.every(s=>s.configured===!1)}const Ss=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ee(e){return String(e).padStart(2,"0")}function ge(e){if(!e)return;const n=new Date(e);if(!Number.isNaN(n.getTime()))return`${Ss[n.getMonth()]} ${n.getDate()}, ${Ee(n.getHours())}:${Ee(n.getMinutes())}`}const Cs="_queuedBadge_mdmbp_8",Ds="_finalChip_mdmbp_20",Bs="_userDisc_mdmbp_30",Es="_userAligned_mdmbp_34",Ts="_userPendingRow_mdmbp_40",As="_userBubble_mdmbp_44",Rs="_userBubbleFailed_mdmbp_58",Is="_userImages_mdmbp_63",Ps="_userImage_mdmbp_63",Ms="_imageDialog_mdmbp_79",Os="_imageDialogPreview_mdmbp_83",qs="_assistantDisc_mdmbp_93",Fs="_assistantBody_mdmbp_97",Ls="_reasoningDisc_mdmbp_108",Ks="_reasoningBody_mdmbp_112",Hs="_toolDisc_mdmbp_123",zs="_toolCardBody_mdmbp_127",$s="_toolCardBodyRunning_mdmbp_134",Us="_toolCardBodyCompleted_mdmbp_138",Ws="_toolCardBodyError_mdmbp_142",Gs="_toolHeader_mdmbp_146",Js="_toolHeaderRunning_mdmbp_172",Qs="_toolChevron_mdmbp_182",Vs="_toolChevronOpen_mdmbp_188",Xs="_kindBadge_mdmbp_192",Ys="_toolPath_mdmbp_204",Zs="_toolTrailing_mdmbp_213",eo="_toolStatusRunning_mdmbp_221",to="_toolStatusSuccess_mdmbp_228",no="_toolStatusError_mdmbp_232",so="_toolStatusUnknown_mdmbp_236",oo="_toolDiffAdded_mdmbp_240",ro="_toolDiffRemoved_mdmbp_244",ao="_toolOpenButton_mdmbp_248",io="_toolBody_mdmbp_266",co="_toolCode_mdmbp_272",lo="_toolOutputStrip_mdmbp_283",uo="_toolDiffPreview_mdmbp_293",mo="_toolDiffPreviewLine_mdmbp_301",fo="_toolDiffPreviewAdd_mdmbp_305",po="_toolDiffPreviewDel_mdmbp_310",ho="_toolDiffPreviewMore_mdmbp_315",_o="_errorDisc_mdmbp_322",go="_errorCard_mdmbp_326",xo="_errorLead_mdmbp_335",vo="_systemRow_mdmbp_342",_={queuedBadge:Cs,finalChip:Ds,userDisc:Bs,userAligned:Es,userPendingRow:Ts,userBubble:As,userBubbleFailed:Rs,userImages:Is,userImage:Ps,imageDialog:Ms,imageDialogPreview:Os,assistantDisc:qs,assistantBody:Fs,reasoningDisc:Ls,reasoningBody:Ks,toolDisc:Hs,toolCardBody:zs,toolCardBodyRunning:$s,toolCardBodyCompleted:Us,toolCardBodyError:Ws,toolHeader:Gs,toolHeaderRunning:Js,toolChevron:Qs,toolChevronOpen:Vs,kindBadge:Xs,toolPath:Ys,toolTrailing:Zs,toolStatusRunning:eo,toolStatusSuccess:to,toolStatusError:no,toolStatusUnknown:so,toolDiffAdded:oo,toolDiffRemoved:ro,toolOpenButton:ao,toolBody:io,toolCode:co,toolOutputStrip:lo,toolDiffPreview:uo,toolDiffPreviewLine:mo,toolDiffPreviewAdd:fo,toolDiffPreviewDel:po,toolDiffPreviewMore:ho,errorDisc:_o,errorCard:go,errorLead:xo,systemRow:vo};function jo({row:e,assetBase:n=null,owningPaneId:s=null,workspaceCwd:o=null,connector:r}){const a=ge(e.timestamp);return t.jsx(O,{disc:t.jsx(M,{icon:Bt,size:"xs",color:"var(--pi-color-accentForeground)"}),discClassName:_.assistantDisc,connector:r,meta:t.jsxs(t.Fragment,{children:["Assistant",a&&t.jsxs("span",{className:I.metaTime,children:[" · ",a]})]}),children:t.jsx("div",{className:_.assistantBody,children:e.streaming?t.jsx(qe,{text:e.text,assetBase:n,owningPaneId:s,workspaceCwd:o}):t.jsx(Fe,{text:e.text,assetBase:n,owningPaneId:s,workspaceCwd:o})})})}function ko({row:e,owningPaneId:n=null,workspaceCwd:s=null,connector:o}){const r=ge(e.timestamp);return t.jsx(O,{disc:t.jsx(M,{icon:Et,size:"xs",color:"var(--pi-color-foregroundMuted)"}),discClassName:_.reasoningDisc,connector:o,meta:t.jsxs(t.Fragment,{children:["Reasoning",r&&t.jsxs("span",{className:I.metaTime,children:[" · ",r]})]}),metaTrailing:!e.streaming&&t.jsx("span",{className:_.finalChip,children:"final"}),children:t.jsx("div",{className:_.reasoningBody,children:e.streaming?t.jsx(qe,{text:e.text,owningPaneId:n,workspaceCwd:s}):t.jsx(Fe,{text:e.text,owningPaneId:n,workspaceCwd:s})})})}function bo(e){const n=Wt(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 yo(e){return e.status==="completed"?t.jsx("span",{className:_.toolStatusSuccess,children:"✓ completed"}):e.status==="error"?t.jsx("span",{className:_.toolStatusError,children:e.statusText||"error"}):e.statusText&&e.statusText!=="running"?t.jsx("span",{className:_.toolStatusUnknown,children:e.statusText}):t.jsxs("span",{className:_.toolStatusRunning,children:[t.jsx(_e,{size:"xs",color:"var(--pi-color-accentBright)"}),"running"]})}function No({row:e,assetBase:n=null,owningPaneId:s=null,workspaceCwd:o=null,connector:r}){const[a,l]=p.useState(!1),i=Yt(e.tool),h=Xt(e.tool),m=h.length>0,u=en(e.tool.output),d=e.tool.kind==="edit"||e.tool.kind==="write"?ze(e.tool):null,x=e.tool.kind==="edit"?Zt(e.tool.diff):null,B=e.tool.kind==="edit"&&e.tool.diff&&!a?bo(e.tool.diff):null;function A(){m&&l(g=>!g)}function C(g){g.target===g.currentTarget&&(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),A())}function y(g){if(g.stopPropagation(),!d)return;const w=$t(n,s,o);ut(d,w.workspaceCwd,w.targetPaneId)}return t.jsx(O,{disc:t.jsx(M,{icon:Qt(e.tool),size:"xs",color:"var(--pi-color-foregroundMuted)"}),discClassName:_.toolDisc,connector:r,children:t.jsxs("div",{className:S(_.toolCardBody,e.status==="running"&&_.toolCardBodyRunning,e.status==="completed"&&_.toolCardBodyCompleted,e.status==="error"&&_.toolCardBodyError),children:[t.jsxs("div",{role:"button",tabIndex:m?0:-1,"aria-expanded":m?a:void 0,"aria-disabled":!m,className:S(_.toolHeader,e.status==="running"&&_.toolHeaderRunning),onClick:A,onKeyDown:C,children:[m&&t.jsx(Tt,{size:12,className:S(_.toolChevron,a&&_.toolChevronOpen)}),t.jsx("span",{className:_.kindBadge,style:{"--kindToken":`var(--pi-color-${i.token})`},children:i.label}),t.jsx("span",{className:_.toolPath,title:fe(e.tool),children:fe(e.tool)}),t.jsxs("span",{className:_.toolTrailing,children:[x&&(x.added>0||x.removed>0)&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:_.toolDiffAdded,children:["+",x.added]}),t.jsxs("span",{className:_.toolDiffRemoved,children:["−",x.removed]})]}),yo(e),d&&t.jsxs("button",{type:"button",className:_.toolOpenButton,onClick:y,onKeyDown:g=>g.stopPropagation(),children:["Open",t.jsx(At,{size:10})]})]})]}),u>0&&t.jsxs("div",{className:_.toolOutputStrip,children:["output · ",u," lines"]}),B&&t.jsxs("div",{className:_.toolDiffPreview,children:[t.jsx("div",{className:S(_.toolDiffPreviewLine,B.kind==="add"?_.toolDiffPreviewAdd:_.toolDiffPreviewDel),children:B.text}),B.moreCount>0&&t.jsxs("div",{className:_.toolDiffPreviewMore,children:["… ",B.moreCount," more lines"]})]}),a&&m&&t.jsx("div",{className:_.toolBody,children:h.map((g,w)=>g.kind==="diff"?t.jsx(Ut,{patch:g.patch},w):t.jsx("pre",{className:_.toolCode,children:g.text},w))})]})})}function wo({row:e,connector:n}){const[s,o]=p.useState(null),r=ge(e.timestamp);return t.jsxs(O,{disc:t.jsx(M,{icon:It,size:"xs",color:"var(--pi-color-successForeground)"}),discClassName:_.userDisc,connector:n,className:S(_.userAligned,e.pending&&_.userPendingRow),meta:t.jsxs(t.Fragment,{children:["You",r&&t.jsxs("span",{className:I.metaTime,children:[" · ",r]}),e.failed&&" · failed to send"]}),metaTrailing:e.queued&&!e.failed&&t.jsxs("span",{className:_.queuedBadge,children:[t.jsx(Rt,{size:9}),"queued"]}),children:[t.jsx("span",{className:S(_.userBubble,e.failed&&_.userBubbleFailed),children:e.text}),e.images&&e.images.length>0&&t.jsx("div",{className:_.userImages,children:e.images.map((a,l)=>{const i=`data:${a.mimeType??"image/png"};base64,${a.data??""}`;return t.jsx("img",{className:_.userImage,src:i,alt:"",role:"button",tabIndex:0,onClick:()=>o(i),onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&o(i)}},l)})}),t.jsx(mt,{open:s!==null,onOpenChange:a=>{a||o(null)},title:"Image",width:"auto",bare:!0,className:_.imageDialog,children:s&&t.jsx("img",{className:_.imageDialogPreview,src:s,alt:""})})]})}function So({row:e,connector:n}){return t.jsx(O,{disc:t.jsx(M,{icon:Pt,size:"xs",color:"var(--pi-color-destructive)"}),discClassName:_.errorDisc,connector:n,children:t.jsxs("div",{className:_.errorCard,children:[t.jsx("span",{className:_.errorLead,children:"Error"})," · ",e.text]})})}function Co({row:e}){return t.jsx("div",{className:_.systemRow,children:e.text})}const Do=500;function Bo(e,n){const s=p.useRef(!0),[o,r]=p.useState(!0),a=p.useRef(0),l=p.useCallback(m=>{const u=n.current,d=u?{scrollTop:u.scrollTop,scrollHeight:u.scrollHeight,clientHeight:u.clientHeight}:{scrollTop:0,scrollHeight:0,clientHeight:0},x=rn(s.current,m,d);x.pinned!==s.current&&(s.current=x.pinned,r(x.pinned)),x.stick&&e.options.count>0&&e.scrollToEnd({behavior:"auto"})},[n,e]);p.useEffect(()=>{const m=n.current;if(!m)return;const u=()=>{a.current=performance.now()},d=()=>{l({kind:"scroll",gesture:performance.now()-a.current<Do})};m.addEventListener("scroll",d,{passive:!0}),m.addEventListener("wheel",u,{passive:!0}),m.addEventListener("touchmove",u,{passive:!0}),m.addEventListener("pointerdown",u,{passive:!0}),m.addEventListener("keydown",u,{passive:!0});const x=new ResizeObserver(()=>{m.clientHeight>0&&l({kind:"shown"})});return x.observe(m),()=>{x.disconnect(),m.removeEventListener("scroll",d),m.removeEventListener("wheel",u),m.removeEventListener("touchmove",u),m.removeEventListener("pointerdown",u),m.removeEventListener("keydown",u)}},[l,n]);const i=p.useCallback(()=>l({kind:"tail"}),[l]),h=p.useCallback(()=>l({kind:"pin"}),[l]);return{pinned:o,followTail:i,pinToBottom:h}}const Eo="_root_1xg4h_6",To="_viewport_1xg4h_13",Ao="_inner_1xg4h_20",Ro="_rowWrap_1xg4h_25",Io="_empty_1xg4h_35",Po="_nudge_1xg4h_47",Mo="_jumpToLatest_1xg4h_56",$={root:Eo,viewport:To,inner:Ao,rowWrap:Ro,empty:Io,nudge:Po,jumpToLatest:Mo},Oo=160;function qo(e){return e.kind==="ask"?`ask:${gn(e.item)}`:e.kind==="ask-more"?"ask-more":e.row.id}function Fo(e,n,s,o,r){switch(e.kind){case"user":return t.jsx(wo,{row:e,connector:!n});case"assistant":return t.jsx(jo,{row:e,assetBase:s,owningPaneId:o,workspaceCwd:r,connector:!n});case"reasoning":return t.jsx(ko,{row:e,owningPaneId:o,workspaceCwd:r,connector:!n});case"tool":return t.jsx(No,{row:e,assetBase:s,owningPaneId:o,workspaceCwd:r,connector:!n});case"error":return t.jsx(So,{row:e,connector:!n});case"system":return t.jsx(Co,{row:e})}}function Lo(e,n,s,o,r,a,l,i){return e.kind==="ask"?t.jsx(ms,{item:e.item,collapsed:e.collapsed,connector:!n,autoFocus:e.item.kind==="pending"&&e.item.entry.requestId===l,sessionTitle:i}):e.kind==="ask-more"?t.jsx(ps,{count:e.count,connector:!n,onExpand:a}):Fo(e.row,n,s,o,r)}function Ko({session:e,owningPaneId:n,workspaceCwd:s}){var q,F;const o=e.timeline.rows,r=e.status==="running",a=ft(),l=pt(e.cwd,a),i=p.useRef(null),h=ht(e.agentId??""),m=_t(e.agentId??""),[u,d]=p.useState(!1),x=P(v=>v.activeSessionId===e.id),B=gt(v=>{var D;return((D=v.layouts[s])==null?void 0:D.focusedPaneId)===n}),A=x&&B?((q=h[0])==null?void 0:q.requestId)??null:null,C=p.useMemo(()=>{const v=vn(_n(h,m),u);return Ns(o,v,D=>({kind:"row",row:D}),D=>D.kind==="more"?{kind:"ask-more",count:D.count}:{kind:"ask",item:D.item,collapsed:D.collapsed})},[o,h,m,u]),y=Q(v=>v.status==="open"),g=Q(v=>v.serverInfo),w=!!((F=g==null?void 0:g.features)!=null&&F.providerAuth),j=xt(v=>v.openSettings),{data:V}=zt(o.length===0&&y&&w),te=ws(w,V),K=rt({count:C.length,getScrollElement:()=>i.current,estimateSize:()=>Oo,overscan:8,getItemKey:v=>{const D=C[v];return D?qo(D):v},measureElement:(v,D,H)=>{if(v.offsetParent!==null)return at(v,D,H);const ee=H.indexFromElement(v),ce=H.options.getItemKey(ee);return H.itemSizeCache.get(ce)??H.options.estimateSize(ee)},anchorTo:"end",scrollEndThreshold:$e}),{pinned:ne,followTail:X,pinToBottom:Y}=Bo(K,i),Z=an(o);return p.useEffect(()=>{X()},[C.length,X]),p.useEffect(()=>{Z!==null&&Y()},[Z,Y]),t.jsxs("div",{className:$.root,children:[t.jsx("div",{className:$.viewport,ref:i,children:C.length===0?!r&&(te?t.jsxs(vt,{className:$.nudge,children:[t.jsx("span",{children:"No messages yet — connect a model provider to get started."}),t.jsx(T,{size:"xs",variant:"secondary",onClick:()=>j(),children:"Connect a model provider"})]}):t.jsx("div",{className:$.empty,children:"No messages yet — say something to start."})):t.jsx("div",{className:$.inner,style:{height:K.getTotalSize()},children:K.getVirtualItems().map(v=>{const D=C[v.index];return D?t.jsx("div",{ref:K.measureElement,"data-index":v.index,className:$.rowWrap,style:{transform:`translateY(${v.start}px)`},children:Lo(D,v.index===C.length-1,l,n,s,()=>d(!0),A,e.title)},v.key):null})})}),!ne&&C.length>0&&t.jsx("button",{type:"button",className:$.jumpToLatest,onClick:Y,title:"Jump to latest","aria-label":"Jump to latest",children:t.jsx(Mt,{size:16,"aria-hidden":"true"})})]})}function Ho(e,n=!0){const s=Q(o=>o.client);return Ae({queryKey:Ie.agentCommands(e),queryFn:async()=>{if(!s)throw new Error("not connected");const o=await pe(s,e),{commands:r}=await s.agent(o).listCommands();return r},enabled:!!s&&!!e&&n})}const zo="_strip_nzfk5_4",$o="_thumb_nzfk5_11",Uo="_remove_nzfk5_28",ue={strip:zo,thumb:$o,remove:Uo};function Wo({images:e,onRemove:n}){return e.length===0?null:t.jsx("div",{className:ue.strip,children:e.map((s,o)=>t.jsxs("div",{className:ue.thumb,children:[t.jsx("img",{src:s.thumbUrl,alt:""}),t.jsx("button",{type:"button",className:ue.remove,title:"Remove",onClick:()=>n(o),children:"×"})]},o))})}function Go(e){const{promise:n,resolve:s,reject:o}=Promise.withResolvers(),r=new FileReader;return r.onload=()=>{const a=r.result;if(typeof a!="string"){o(new Error("Unexpected FileReader result"));return}const l=a.indexOf(","),i=l>=0?a.slice(l+1):a;s({mimeType:e.type,data:i,thumbUrl:a})},r.onerror=()=>o(r.error??new Error("Failed to read file")),r.readAsDataURL(e),n}function Jo(e,n,s){return e?s:n}const Qo="_picker_1jy8c_4",Vo="_search_1jy8c_10",Xo="_list_1jy8c_28",Yo="_item_1jy8c_33",Zo="_itemActive_1jy8c_47",er="_checkSlot_1jy8c_51",tr="_label_1jy8c_60",nr="_modelId_1jy8c_66",sr="_state_1jy8c_73",or="_stateError_1jy8c_82",rr="_commandContent_1jy8c_92",ar="_commandList_1jy8c_95",ir="_commandItem_1jy8c_100",cr="_commandItemHeader_1jy8c_132",lr="_commandKindBadge_1jy8c_146",dr="_commandKindExtension_1jy8c_165",ur="_commandKindPrompt_1jy8c_170",mr="_commandKindSkill_1jy8c_175",fr="_commandDescription_1jy8c_180",N={picker:Qo,search:Vo,list:Xo,item:Yo,itemActive:Zo,checkSlot:er,label:tr,modelId:nr,state:sr,stateError:or,commandContent:rr,commandList:ar,commandItem:ir,commandItemHeader:cr,commandKindBadge:lr,commandKindExtension:dr,commandKindPrompt:ur,commandKindSkill:mr,commandDescription:fr},pr={onOpenAutoFocus:e=>e.preventDefault()};function hr(e){switch(e){case"extension":return N.commandKindExtension;case"prompt":return N.commandKindPrompt;case"skill":return N.commandKindSkill;default:return}}function _r({open:e,onOpenChange:n,options:s,highlightedIndex:o,onSelect:r,isLoading:a,isError:l,errorMessage:i,hiddenExtensionCount:h,renderTrigger:m}){const u=p.useRef(null);return p.useEffect(()=>{var d,x;e&&((x=(d=u.current)==null?void 0:d.querySelector('[aria-selected="true"]'))==null||x.scrollIntoView({block:"nearest"}))},[e,o]),t.jsxs(Le,{open:e,onOpenChange:n,modal:!1,children:[t.jsx(Ke,{asChild:!0,children:m()}),t.jsxs(Pe,{className:S(N.picker,N.commandContent),side:"top",sideOffset:4,...pr,onCloseAutoFocus:d=>d.preventDefault(),children:[a&&t.jsx("div",{className:N.state,children:t.jsx(_e,{size:"sm"})}),!a&&l&&t.jsx("div",{className:N.stateError,children:i??"Failed to load commands"}),!a&&!l&&s.length===0&&t.jsx("div",{className:N.state,children:"No commands found"}),!a&&!l&&s.length>0&&t.jsx("div",{ref:u,className:S(N.list,N.commandList),children:s.map((d,x)=>t.jsxs("div",{role:"option","aria-selected":x===o,className:S(N.item,N.commandItem,x===o&&N.itemActive),title:d.description,onMouseDown:B=>{B.preventDefault(),r(d.value)},children:[t.jsxs("div",{className:N.commandItemHeader,children:[t.jsx("span",{className:N.label,children:d.label}),d.kind&&t.jsx("span",{className:S(N.commandKindBadge,hr(d.kind)),children:d.kind})]}),d.description&&t.jsx("div",{className:N.commandDescription,children:d.description})]},d.value))}),!a&&!l&&h>0&&t.jsxs("div",{className:N.state,children:[h," extension command(s) unavailable while the agent is running"]})]})]})}function gr(e,n=!0){const s=Q(o=>o.client);return Ae({queryKey:Ie.providerModels(e),queryFn:async()=>{if(!s)throw new Error("not connected");return(await s.providers.listModels(e)).models},enabled:!!s&&!!e&&n})}function xr(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 vr(e){const n=new Set;return e.filter(s=>n.has(s.id)?!1:(n.add(s.id),!0))}function jr({currentModel:e,provider:n,onSelect:s,renderTrigger:o}){const[r,a]=p.useState(!1),[l,i]=p.useState(""),h=p.useRef(null),{data:m=[],isLoading:u,isError:d,error:x}=gr(n,r),B=vr(xr(m,e));p.useEffect(()=>{var j;r&&(i(""),(j=h.current)==null||j.focus())},[r]);const A=new Map(B.map(j=>[j.id,j.provider])),C=B.map(j=>({value:j.id,label:j.label??j.id,description:j.id})),y=He(C,l),g=x instanceof Error?x.message:"Failed to load models";function w(j){j.stopPropagation(),j.key==="Escape"&&a(!1)}return t.jsxs(Le,{open:r,onOpenChange:a,modal:!1,children:[t.jsx(Ke,{asChild:!0,children:o(e)}),t.jsxs(Pe,{minWidth:240,align:"end",sideOffset:6,className:N.picker,children:[t.jsx("input",{ref:h,className:N.search,placeholder:"Search models…",value:l,onChange:j=>i(j.target.value),onKeyDown:w}),u&&t.jsx("div",{className:N.state,children:t.jsx(_e,{size:"sm"})}),!u&&d&&t.jsx("div",{className:N.stateError,children:g}),!u&&!d&&y.length===0&&t.jsx("div",{className:N.state,children:"No models found"}),!u&&!d&&y.length>0&&t.jsx("div",{className:N.list,children:y.map(j=>t.jsxs(Gt,{className:N.item,onSelect:()=>s(j.value,A.get(j.value)),children:[t.jsx("span",{className:N.checkSlot,"aria-hidden":!0,children:j.value===e&&t.jsx(Oe,{size:14})}),t.jsx("span",{className:N.label,children:j.label}),t.jsxs("span",{className:N.modelId,children:["(",j.value,")"]})]},j.value))})]})]})}function xe(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 kr(e){return/^\/\S*$/.test(e)}function br(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 yr(e,n,s){return s<=0?0:(e+n+s)%s}function Nr(e,n){const s=xe(e);return s?s.hasArgs?`/${n}${e.slice(s.end)}`:`/${n} `:`/${n} ${e}`}function wr(e,n){const s=xe(e);return!s||!n.includes(s.name)?null:{end:s.end}}const Sr="_composer_ipwxh_4",Cr="_card_ipwxh_13",Dr="_flash_ipwxh_27",Br="_note_ipwxh_41",Er="_textarea_ipwxh_49",Tr="_textareaWrap_ipwxh_73",Ar="_highlightLayer_ipwxh_61",Rr="_commandMark_ipwxh_96",Ir="_hiddenFileInput_ipwxh_121",Pr="_toolbar_ipwxh_127",Mr="_toolbarRight_ipwxh_134",Or="_toolBtn_ipwxh_142",qr="_roundBtn_ipwxh_148",Fr="_modelBtn_ipwxh_153",Lr="_modelLabel_ipwxh_179",Kr="_modelChevron_ipwxh_184",E={composer:Sr,card:Cr,flash:Dr,note:Br,textarea:Er,textareaWrap:Tr,highlightLayer:Ar,commandMark:Rr,hiddenFileInput:Ir,toolbar:Pr,toolbarRight:Mr,toolBtn:Or,roundBtn:qr,modelBtn:Fr,modelLabel:Lr,modelChevron:Kr},Hr=160;function re(e){e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,Hr)}px`}function zr(e){return typeof e=="object"&&e!==null&&"ok"in e&&e.ok===!1}function $r(){return typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Ur({sessionId:e}){const n=Q(c=>c.client),s=P(c=>c.sessions[e]),o=P(c=>c.addOptimisticUserMessage),r=P(c=>c.markUserMessageFailed),a=P(c=>c.setCwd),l=P(c=>c.setModel),i=oe(c=>c.drafts[e]??""),h=oe(c=>c.setDraft),[m,u]=p.useState([]),[d,x]=p.useState(!1),[B,A]=p.useState(!1),C=p.useRef(null),y=p.useRef(null),[g,w]=p.useState(!1),[j,V]=p.useState(0),te=jt(kt.chat(e)),K=oe(c=>c.pendingFeedback[e]),[ne,X]=p.useState(null),[Y,Z]=p.useState(!1),q=p.useRef(null),F=p.useRef(null);p.useEffect(()=>{if(!te||K===void 0)return;const c=oe.getState().consumeFeedback(e);if(!c)return;X(c.copy==="filled"?"Your message was filled in":"Your draft was replaced"),q.current!==null&&window.clearTimeout(q.current),q.current=window.setTimeout(()=>X(null),4e3);const k=C.current;k&&k.setSelectionRange(k.value.length,k.value.length),c.flash&&(Z(!0),F.current!==null&&window.clearTimeout(F.current),F.current=window.setTimeout(()=>Z(!1),$r()?1e3:400))},[te,K,e]),p.useEffect(()=>()=>{q.current!==null&&window.clearTimeout(q.current),F.current!==null&&window.clearTimeout(F.current)},[]);const v=(s==null?void 0:s.status)==="running",D=Jo(v,d,B),H=!!n&&!D&&(i.trim().length>0||m.length>0),{data:ee=[],isLoading:ce,isError:Je,error:ve}=Ho(e,g),{options:je,hiddenExtensionCount:Qe}=br(ee,{running:v}),ke=xe(i),se=ke?He(je,ke.name):je,Ve=ee.map(c=>c.name),W=wr(i,Ve);async function be(c){if(c.type.startsWith("image/"))try{const k=await Go(c);u(b=>[...b,k])}catch{}}function Xe(c){for(const k of c.target.files??[])be(k);c.target.value=""}function Ye(c){for(const k of c.clipboardData.items)if(k.type.startsWith("image/")){c.preventDefault();const b=k.getAsFile();b&&be(b)}}function Ze(c){u(k=>k.filter((b,R)=>R!==c))}function et(c){const k=c.target.value;h(e,k),re(c.target);const b=kr(k);b!==g&&w(b),b&&V(0)}function tt(c){var k;if(!g&&W&&c.key==="Backspace"){const b=c.currentTarget,R=b.selectionStart;if(R!==null&&R===b.selectionEnd){const G=W.end+(i[W.end]===" "?1:0);if(R>0&&R<=G){c.preventDefault();const z=i.slice(G);h(e,z),b.setSelectionRange(0,0),re(b);return}}}if(g&&se.length>0){if(c.key==="ArrowDown"||c.key==="ArrowUp"){c.preventDefault(),V(b=>yr(b,c.key==="ArrowDown"?1:-1,se.length));return}if(c.key==="Enter"&&!c.shiftKey||c.key==="Tab"){c.preventDefault();const b=(k=se[j])==null?void 0:k.value;b&&ye(b);return}}if(g&&c.key==="Escape"){c.preventDefault(),w(!1);return}c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),Ne(v?"steer":"send"))}function ye(c){const k=Nr(i,c);h(e,k),w(!1),V(0);const b=C.current;b&&(b.focus(),b.setSelectionRange(k.length,k.length),re(b))}async function Ne(c){if(!n||!s||(c==="steer"?B:d)||c==="steer"&&!s.agentId)return;const k=i.trim();if(!k&&m.length===0)return;h(e,""),w(!1),C.current&&re(C.current);const b=m;u([]);const R=k||"Describe this image",G=b.length>0?b.map(J=>({mimeType:J.mimeType,data:J.data})):void 0,z=bt();o(e,z,R,G,c==="steer");const we=c==="steer"?A:x;we(!0);try{if(c==="steer"){const J=await n.agent(s.agentId).steer(R,{clientMessageId:z,images:G});zr(J)&&r(e,z)}else{s.agentId||a(e,s.cwd||"~");const J=await pe(n,e);await n.agent(J).send(R,{clientMessageId:z,images:G})}}catch{r(e,z)}finally{we(!1)}}function nt(){s!=null&&s.agentId&&(n==null||n.agent(s.agentId).interrupt())}function st(c,k){l(e,c,k),!(!n||!k)&&(async()=>{const b=await pe(n,e);await n.agent(b).setModel(k,c)})().catch(()=>{})}return t.jsxs("div",{className:E.composer,children:[t.jsxs("div",{className:S(E.card,Y&&E.flash),children:[t.jsxs("div",{className:E.textareaWrap,children:[t.jsx("div",{className:E.highlightLayer,"aria-hidden":!0,children:W?t.jsxs(t.Fragment,{children:[t.jsx("mark",{className:E.commandMark,children:i.slice(0,W.end)}),i.slice(W.end)]}):i}),t.jsx(Re,{ref:C,className:E.textarea,rows:1,value:i,placeholder:v?"Steer the running turn… ⏎ steer · ⇧⏎ newline":"Ask anything… ⏎ send · ⇧⏎ newline · / commands",onChange:et,onKeyDown:tt,onPaste:Ye})]}),t.jsx(Wo,{images:m,onRemove:Ze}),t.jsxs("div",{className:E.toolbar,children:[t.jsx(T,{className:E.toolBtn,variant:"ghost",size:"sm",iconOnly:!0,title:"Attach image","aria-label":"Attach image",onClick:()=>{var c;return(c=y.current)==null?void 0:c.click()},children:t.jsx(Ot,{size:16})}),t.jsx(_r,{open:g,onOpenChange:w,options:se,highlightedIndex:j,onSelect:ye,isLoading:ce,isError:Je,errorMessage:ve instanceof Error?ve.message:void 0,hiddenExtensionCount:Qe,renderTrigger:()=>t.jsx(T,{className:E.toolBtn,variant:"ghost",size:"sm",iconOnly:!0,title:"Slash commands","aria-label":"Slash commands",children:t.jsx(qt,{size:16})})}),t.jsxs("div",{className:E.toolbarRight,children:[t.jsx(jr,{currentModel:s==null?void 0:s.model,provider:"pi",onSelect:st,renderTrigger:c=>t.jsxs("button",{type:"button",className:E.modelBtn,disabled:!n,title:c?`Model: ${c}`:"Select model",children:[t.jsx("span",{className:E.modelLabel,children:c??"Model"}),t.jsx(Ft,{size:13,className:E.modelChevron,"aria-hidden":"true"})]})}),v&&t.jsx(T,{className:E.roundBtn,variant:"destructive",size:"sm",iconOnly:!0,title:"Stop the running turn","aria-label":"Stop",onClick:nt,children:t.jsx(Lt,{size:14})}),t.jsx(T,{className:E.roundBtn,size:"sm",iconOnly:!0,disabled:!H,title:v?"Steer the running turn":"Send","aria-label":v?"Steer":"Send",onClick:()=>void Ne(v?"steer":"send"),children:v?t.jsx(Kt,{size:16}):t.jsx(Ht,{size:18})})]})]})]}),ne!==null&&t.jsx("div",{className:E.note,children:ne}),t.jsx("input",{ref:y,className:E.hiddenFileInput,type:"file",accept:"image/*",multiple:!0,onChange:Xe})]})}const Wr="_track_oxvl6_2",Gr="_sweep_oxvl6_24",Jr="_visuallyHidden_oxvl6_64",me={track:Wr,sweep:Gr,visuallyHidden:Jr};function Qr({running:e}){return e?t.jsxs("div",{className:me.track,role:"progressbar","aria-label":"Turn in progress",children:[t.jsx("div",{className:me.sweep,"aria-hidden":"true"}),t.jsx("span",{className:me.visuallyHidden,role:"status","aria-live":"polite",children:"Agent is working…"})]}):null}const Vr="_panel_1tq06_1",Xr="_empty_1tq06_5",Te={panel:Vr,empty:Xr};function ua({tab:e,owningPaneId:n}){const{sessionId:s}=e.data,o=P(r=>r.sessions[s]);return on(s),o?t.jsxs(Se,{className:Te.panel,children:[t.jsx(Qr,{running:o.status==="running"}),t.jsx(Ko,{session:o,owningPaneId:n,workspaceCwd:e.workspaceCwd}),t.jsx(Ur,{sessionId:o.id})]}):t.jsx(Se,{children:t.jsx("div",{className:Te.empty,children:"Session not found."})})}export{ua 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-BHHAK0f5.js";import{u as x}from"./use-file-download-B0TFCtaB.js";import{P as S,Q as _,S as b,T as B,U as z,V as U}from"./vendor-CIkm_8TG.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-CBBgHVBM.js";import{u as x}from"./use-file-download-BIZMK0gw.js";import{P as S,Q as _,S as b,T as B,U as z,V as U}from"./vendor-CIkm_8TG.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-CIkm_8TG.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-BHHAK0f5.js";import{u as k,a as q}from"./vendor-query-i7fr__Xm.js";import{u as z}from"./use-file-watch-CweRDD7C.js";import{D as N}from"./DiffView-DYwtgWeX.js";import"./vendor-icons-oIrAStms.js";import"./vendor-overlays-DAY3g68r.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-CIkm_8TG.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-CBBgHVBM.js";import{u as k,a as q}from"./vendor-query-i7fr__Xm.js";import{u as z}from"./use-file-watch-Do6RBm9E.js";import{D as N}from"./DiffView-DYwtgWeX.js";import"./vendor-icons-oIrAStms.js";import"./vendor-overlays-DAY3g68r.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-BHHAK0f5.js";import{M as me}from"./vendor-CIkm_8TG.js";import{u as pe,C as he}from"./CodeView-Dw7L2TVS.js";import{p as ge,S as xe}from"./href-resolution-62Ae2qpT.js";import"./vendor-icons-oIrAStms.js";import"./vendor-overlays-DAY3g68r.js";import"./vendor-dnd-CayJj8TC.js";import"./use-file-download-B0TFCtaB.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,m as de,E as N,S as R,B as A,a as M,t as fe}from"./index-CBBgHVBM.js";import{M as me}from"./vendor-CIkm_8TG.js";import{u as pe,C as he}from"./CodeView-BXJFkLt-.js";import{p as ge,S as xe}from"./href-resolution-CxQKzcip.js";import"./vendor-icons-oIrAStms.js";import"./vendor-overlays-DAY3g68r.js";import"./vendor-dnd-CayJj8TC.js";import"./use-file-download-BIZMK0gw.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-BHHAK0f5.js";import{u as t}from"./use-file-download-B0TFCtaB.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-CIkm_8TG.js";import"./vendor-icons-oIrAStms.js";import"./vendor-overlays-DAY3g68r.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-CBBgHVBM.js";import{u as t}from"./use-file-download-BIZMK0gw.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-CIkm_8TG.js";import"./vendor-icons-oIrAStms.js";import"./vendor-overlays-DAY3g68r.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-BHHAK0f5.js";import{u as w,C as h}from"./CodeView-Dw7L2TVS.js";import{M as v}from"./markdown-DEjnznX7.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-CIkm_8TG.js";import"./vendor-icons-oIrAStms.js";import"./vendor-overlays-DAY3g68r.js";import"./vendor-dnd-CayJj8TC.js";import"./use-file-download-B0TFCtaB.js";import"./vendor-highlight-A9hNQ6ne.js";import"./vendor-markdown-Bu3Y4y-M.js";import"./href-resolution-62Ae2qpT.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-CBBgHVBM.js";import{u as w,C as h}from"./CodeView-BXJFkLt-.js";import{M as v}from"./markdown-BOpTW_tD.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-CIkm_8TG.js";import"./vendor-icons-oIrAStms.js";import"./vendor-overlays-DAY3g68r.js";import"./vendor-dnd-CayJj8TC.js";import"./use-file-download-BIZMK0gw.js";import"./vendor-highlight-A9hNQ6ne.js";import"./vendor-markdown-Bu3Y4y-M.js";import"./href-resolution-CxQKzcip.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{r as b,j as t}from"./vendor-react-DQUAl2K8.js";import{a as A}from"./vendor-query-i7fr__Xm.js";import{u as E,E as u,S as P,B as x,a as C}from"./index-BHHAK0f5.js";import{S as v}from"./StatusBadge-BMKAPA9O.js";import{u as R}from"./use-provider-auth-list-D31i1xT-.js";import{u as y}from"./SettingsDialog-nfzDXsFW.js";import"./vendor-CIkm_8TG.js";import"./vendor-icons-oIrAStms.js";import"./vendor-overlays-DAY3g68r.js";import"./vendor-dnd-CayJj8TC.js";const N="env:";function I(e){var i;return e.configured==="unknown"?{label:"Unknown",variant:"warning"}:e.configured===!1?{label:"Not configured",variant:"muted"}:(i=e.configuredSource)!=null&&i.startsWith(N)?{label:`env: ${e.configuredSource.slice(N.length)}`,variant:"success"}:e.configuredType==="oauth"?{label:"OAuth",variant:"success"}:{label:"API key",variant:"success"}}function M(e){const i=e.configured===!0?"Re-login":"Log in";if(e.authTypes.length<=1){const s=e.authTypes[0]??"api_key";return[{authType:s,label:s==="oauth"?e.oauthLoginLabel??i:i}]}return e.authTypes.map(s=>s==="oauth"?{authType:s,label:e.oauthLoginLabel??"Log in with OAuth"}:{authType:s,label:"API key"})}const O="_list_vm1k7_1",T="_row_vm1k7_7",q="_rowMain_vm1k7_18",B="_name_vm1k7_25",z="_tag_vm1k7_33",F="_rowActions_vm1k7_37",U="_pendingNote_vm1k7_44",K="_note_vm1k7_49",Q="_errorState_vm1k7_55",a={list:O,row:T,rowMain:q,name:B,tag:z,rowActions:F,pendingNote:U,note:K,errorState:Q};function nn(){const e=E(n=>n.client),i=A(),s=y(n=>n.pendingLogin),j=y(n=>n.requestLogin),[d,g]=b.useState(null),[k,m]=b.useState({}),{data:r,isLoading:L,isError:S,error:h}=R();async function p(n){if(e&&window.confirm(`Log out of ${n.name}? Running agents keep working until their current credential use fails.`)){m(o=>({...o,[n.id]:""})),g(n.id);try{const o=await e.logoutProvider(n.id);m(l=>({...l,[n.id]:o.stillConfigured?"Removed the stored credential — still configured via an environment variable.":""})),await i.invalidateQueries({queryKey:C.providerAuthList()})}finally{g(null)}}}return L?t.jsxs(u,{children:[t.jsx(P,{size:"sm"})," Loading providers…"]}):S?t.jsx(u,{className:a.errorState,children:h instanceof Error?h.message:"Failed to load providers."}):!r||r.length===0?t.jsx(u,{children:"No providers available."}):t.jsx("div",{className:a.list,children:r.map(n=>{const o=I(n),l=M(n),f=(s==null?void 0:s.provider)===n.id,_=s!==null&&!f,w=k[n.id];return t.jsxs("div",{className:a.row,children:[t.jsxs("div",{className:a.rowMain,children:[t.jsx("span",{className:a.name,children:n.name}),n.oauthIsSubscription&&t.jsx(v,{label:"Subscription",variant:"muted",className:a.tag}),t.jsx(v,{label:o.label,variant:o.variant,className:a.tag})]}),t.jsx("div",{className:a.rowActions,children:f?t.jsx("span",{className:a.pendingNote,children:"Logging in…"}):t.jsxs(t.Fragment,{children:[l.map(c=>t.jsx(x,{size:"xs",variant:"secondary",disabled:_,onClick:()=>j(n.id,n.name,c.authType),children:c.label},c.authType)),n.configured!==!1&&t.jsx(x,{size:"xs",variant:"ghost",disabled:_||d===n.id,loading:d===n.id,onClick:()=>void p(n),children:"Log out"})]})}),w&&t.jsx("div",{className:a.note,children:w})]},n.id)})})}export{nn as ModelProvidersPanel};
1
+ import{r as b,j as t}from"./vendor-react-DQUAl2K8.js";import{a as A}from"./vendor-query-i7fr__Xm.js";import{u as E,E as u,S as P,B as x,a as C}from"./index-CBBgHVBM.js";import{S as v}from"./StatusBadge-BMKAPA9O.js";import{u as R}from"./use-provider-auth-list-Bv1c4-ha.js";import{u as y}from"./SettingsDialog-jNCx6ea1.js";import"./vendor-CIkm_8TG.js";import"./vendor-icons-oIrAStms.js";import"./vendor-overlays-DAY3g68r.js";import"./vendor-dnd-CayJj8TC.js";const N="env:";function I(e){var i;return e.configured==="unknown"?{label:"Unknown",variant:"warning"}:e.configured===!1?{label:"Not configured",variant:"muted"}:(i=e.configuredSource)!=null&&i.startsWith(N)?{label:`env: ${e.configuredSource.slice(N.length)}`,variant:"success"}:e.configuredType==="oauth"?{label:"OAuth",variant:"success"}:{label:"API key",variant:"success"}}function M(e){const i=e.configured===!0?"Re-login":"Log in";if(e.authTypes.length<=1){const s=e.authTypes[0]??"api_key";return[{authType:s,label:s==="oauth"?e.oauthLoginLabel??i:i}]}return e.authTypes.map(s=>s==="oauth"?{authType:s,label:e.oauthLoginLabel??"Log in with OAuth"}:{authType:s,label:"API key"})}const O="_list_vm1k7_1",T="_row_vm1k7_7",q="_rowMain_vm1k7_18",B="_name_vm1k7_25",z="_tag_vm1k7_33",F="_rowActions_vm1k7_37",U="_pendingNote_vm1k7_44",K="_note_vm1k7_49",Q="_errorState_vm1k7_55",a={list:O,row:T,rowMain:q,name:B,tag:z,rowActions:F,pendingNote:U,note:K,errorState:Q};function nn(){const e=E(n=>n.client),i=A(),s=y(n=>n.pendingLogin),j=y(n=>n.requestLogin),[d,g]=b.useState(null),[k,m]=b.useState({}),{data:r,isLoading:L,isError:S,error:h}=R();async function p(n){if(e&&window.confirm(`Log out of ${n.name}? Running agents keep working until their current credential use fails.`)){m(o=>({...o,[n.id]:""})),g(n.id);try{const o=await e.logoutProvider(n.id);m(l=>({...l,[n.id]:o.stillConfigured?"Removed the stored credential — still configured via an environment variable.":""})),await i.invalidateQueries({queryKey:C.providerAuthList()})}finally{g(null)}}}return L?t.jsxs(u,{children:[t.jsx(P,{size:"sm"})," Loading providers…"]}):S?t.jsx(u,{className:a.errorState,children:h instanceof Error?h.message:"Failed to load providers."}):!r||r.length===0?t.jsx(u,{children:"No providers available."}):t.jsx("div",{className:a.list,children:r.map(n=>{const o=I(n),l=M(n),f=(s==null?void 0:s.provider)===n.id,_=s!==null&&!f,w=k[n.id];return t.jsxs("div",{className:a.row,children:[t.jsxs("div",{className:a.rowMain,children:[t.jsx("span",{className:a.name,children:n.name}),n.oauthIsSubscription&&t.jsx(v,{label:"Subscription",variant:"muted",className:a.tag}),t.jsx(v,{label:o.label,variant:o.variant,className:a.tag})]}),t.jsx("div",{className:a.rowActions,children:f?t.jsx("span",{className:a.pendingNote,children:"Logging in…"}):t.jsxs(t.Fragment,{children:[l.map(c=>t.jsx(x,{size:"xs",variant:"secondary",disabled:_,onClick:()=>j(n.id,n.name,c.authType),children:c.label},c.authType)),n.configured!==!1&&t.jsx(x,{size:"xs",variant:"ghost",disabled:_||d===n.id,loading:d===n.id,onClick:()=>void p(n),children:"Log out"})]})}),w&&t.jsx("div",{className:a.note,children:w})]},n.id)})})}export{nn as ModelProvidersPanel};
@@ -1 +1 @@
1
- import{r as c,j as t}from"./vendor-react-DQUAl2K8.js";import{u as I,l as W,P as w,E as L,S as k,j as q,o as C,d as U,m as X,C as Y,p as z,f as D}from"./index-BHHAK0f5.js";import{L as G}from"./vendor-molviewer-DSzG6_a2.js";import{S as v}from"./StatusBadge-BMKAPA9O.js";import{u as H}from"./use-file-download-B0TFCtaB.js";import{u as K}from"./use-file-watch-CweRDD7C.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-CIkm_8TG.js";import"./vendor-icons-oIrAStms.js";import"./vendor-overlays-DAY3g68r.js";import"./vendor-dnd-CayJj8TC.js";function J(e,r){return!e||!r?null:{url:r,name:e.split("/").pop()||e}}function Q({changedAt:e,lastAppliedAt:r,modified:n}){return!(e===null||n||e===r)}const Z={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 ee(e,r,n){const a=await e.connection.request("file_write_request",{path:r,content:n});if(!a.ok){const l=a.error??"";throw new Error(Z[l]??l??"Failed to save")}}const re="mol2";function oe(e){const{sourcePath:r,monomers:n,attempt:a}=e,l=a>0?`_${a+1}`:"";return`${te(r)}_polymer_${n}${l}.${re}`}function te(e){return(e.split("/").pop()??"").replace(/\.[^.]+$/,"").trim()||"polymer"}const se={"--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)"},ne="_wrap_tixu9_1",ae="_molViewer_tixu9_4",le="_badges_tixu9_8",g={wrap:ne,molViewer:ae,badges:le},ie=50;async function ce(e){const{client:r,upload:n,sourcePath:a,monomers:l,text:f}=e,p=U(a);let s=null,i="";for(let u=0;u<ie&&s===null;u+=1){i=oe({sourcePath:a,monomers:l,attempt:u});try{s=await X(r,p,i,"file")}catch(m){if(m instanceof Y&&m.code==="exists")continue;throw m}}if(s===null)throw new Error(`No free name for ${i} — too many builds in this folder.`);try{await n(p,new File([f],i,{type:"chemical/x-mol2"}))}catch(u){throw await z(r,s).catch(()=>{}),u}return s}function ue({path:e,workspaceCwd:r,tabId:n,isActive:a,onModifiedChange:l}){var F;const f=I(o=>o.client),{upload:p}=W(),s=H(e??"",!!e),{changedAt:i}=K(e),u=c.useRef(null),m=c.useRef(!1),[E,_]=c.useState(null),[h,N]=c.useState(!1),[S,x]=c.useState(null),[j,y]=c.useState(null),[M,P]=c.useState(null),b=c.useRef(null),R=((F=s.data)==null?void 0:F.objectUrl)??null,A=c.useMemo(()=>J(e,R),[e,R]);c.useEffect(()=>{Q({changedAt:i,lastAppliedAt:b.current,modified:h})&&(b.current=i,s.refetch())},[i,h,s.refetch]);const $=i!==null&&i!==b.current&&h;async function V(o){if(e){if(!f){x("Not connected — cannot save.");return}x(null);try{await ee(f,e,o.text()),o.saved()}catch(d){x(d instanceof Error?d.message:"Failed to save")}}}async function B(o){if(e){if(!f){y("Not connected — cannot save the polymer.");return}y(null),P(null);try{const d=await ce({client:f,upload:p,sourcePath:e,monomers:o.monomers,text:o.text()});o.report.clashes>0&&P(`${o.report.clashes} close contacts — relax the geometry before simulating`);const O=q.getState().paneOfTab(r,n);C(d,r,O??void 0)}catch(d){y(d instanceof Error?d.message:"Failed to save the polymer")}}}const T=(s.isError?s.error instanceof Error?s.error.message:"download failed":null)??(E==null?void 0:E.message)??null;return e&&s.isPending?t.jsx(w,{children:t.jsxs(L,{children:[t.jsx(k,{size:"sm"})," Loading..."]})}):T?t.jsx(w,{children:t.jsxs(L,{children:["Error: ",T]})}):t.jsxs(w,{className:g.wrap,"data-molecule-active":a?"true":"false",children:[t.jsxs("div",{className:g.badges,children:[$&&t.jsx(v,{label:"File changed on disk",variant:"muted"}),S&&t.jsx(v,{label:`Save failed: ${S}`,variant:"error"}),j&&t.jsx(v,{label:`Polymer build: ${j}`,variant:"error"}),M&&t.jsx(v,{label:M,variant:"warning"})]}),t.jsx(G,{ref:u,className:g.molViewer,theme:se,source:A,sourceMode:m.current?"update":"replace",onLoad:()=>{m.current=!0,_(null)},onLoadError:o=>_(o.error),onModifiedChange:o=>{N(o),l==null||l(o)},onSave:e?V:void 0,onPolymerBuild:e?B:void 0})]})}function _e({tab:e}){const{path:r}=e.data,n=D(e.id);return t.jsx(w,{children:t.jsx(ue,{path:r,workspaceCwd:e.workspaceCwd,tabId:e.id,isActive:n})})}export{_e as MoleculeViewerPanel};
1
+ import{r as c,j as t}from"./vendor-react-DQUAl2K8.js";import{u as I,o as W,P as w,E as L,S as k,l as q,p as C,d as U,q as X,C as Y,s as z,g as D}from"./index-CBBgHVBM.js";import{L as G}from"./vendor-molviewer-DSzG6_a2.js";import{S as v}from"./StatusBadge-BMKAPA9O.js";import{u as H}from"./use-file-download-BIZMK0gw.js";import{u as K}from"./use-file-watch-Do6RBm9E.js";import"./vendor-query-i7fr__Xm.js";import"./vendor-CIkm_8TG.js";import"./vendor-icons-oIrAStms.js";import"./vendor-overlays-DAY3g68r.js";import"./vendor-dnd-CayJj8TC.js";function J(e,r){return!e||!r?null:{url:r,name:e.split("/").pop()||e}}function Q({changedAt:e,lastAppliedAt:r,modified:n}){return!(e===null||n||e===r)}const Z={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 ee(e,r,n){const a=await e.connection.request("file_write_request",{path:r,content:n});if(!a.ok){const l=a.error??"";throw new Error(Z[l]??l??"Failed to save")}}const re="mol2";function oe(e){const{sourcePath:r,monomers:n,attempt:a}=e,l=a>0?`_${a+1}`:"";return`${te(r)}_polymer_${n}${l}.${re}`}function te(e){return(e.split("/").pop()??"").replace(/\.[^.]+$/,"").trim()||"polymer"}const se={"--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)"},ne="_wrap_tixu9_1",ae="_molViewer_tixu9_4",le="_badges_tixu9_8",b={wrap:ne,molViewer:ae,badges:le},ie=50;async function ce(e){const{client:r,upload:n,sourcePath:a,monomers:l,text:f}=e,p=U(a);let s=null,i="";for(let u=0;u<ie&&s===null;u+=1){i=oe({sourcePath:a,monomers:l,attempt:u});try{s=await X(r,p,i,"file")}catch(m){if(m instanceof Y&&m.code==="exists")continue;throw m}}if(s===null)throw new Error(`No free name for ${i} — too many builds in this folder.`);try{await n(p,new File([f],i,{type:"chemical/x-mol2"}))}catch(u){throw await z(r,s).catch(()=>{}),u}return s}function ue({path:e,workspaceCwd:r,tabId:n,isActive:a,onModifiedChange:l}){var F;const f=I(o=>o.client),{upload:p}=W(),s=H(e??"",!!e),{changedAt:i}=K(e),u=c.useRef(null),m=c.useRef(!1),[E,_]=c.useState(null),[h,N]=c.useState(!1),[S,x]=c.useState(null),[j,y]=c.useState(null),[M,P]=c.useState(null),g=c.useRef(null),R=((F=s.data)==null?void 0:F.objectUrl)??null,A=c.useMemo(()=>J(e,R),[e,R]);c.useEffect(()=>{Q({changedAt:i,lastAppliedAt:g.current,modified:h})&&(g.current=i,s.refetch())},[i,h,s.refetch]);const $=i!==null&&i!==g.current&&h;async function V(o){if(e){if(!f){x("Not connected — cannot save.");return}x(null);try{await ee(f,e,o.text()),o.saved()}catch(d){x(d instanceof Error?d.message:"Failed to save")}}}async function B(o){if(e){if(!f){y("Not connected — cannot save the polymer.");return}y(null),P(null);try{const d=await ce({client:f,upload:p,sourcePath:e,monomers:o.monomers,text:o.text()});o.report.clashes>0&&P(`${o.report.clashes} close contacts — relax the geometry before simulating`);const O=q.getState().paneOfTab(r,n);C(d,r,O??void 0)}catch(d){y(d instanceof Error?d.message:"Failed to save the polymer")}}}const T=(s.isError?s.error instanceof Error?s.error.message:"download failed":null)??(E==null?void 0:E.message)??null;return e&&s.isPending?t.jsx(w,{children:t.jsxs(L,{children:[t.jsx(k,{size:"sm"})," Loading..."]})}):T?t.jsx(w,{children:t.jsxs(L,{children:["Error: ",T]})}):t.jsxs(w,{className:b.wrap,"data-molecule-active":a?"true":"false",children:[t.jsxs("div",{className:b.badges,children:[$&&t.jsx(v,{label:"File changed on disk",variant:"muted"}),S&&t.jsx(v,{label:`Save failed: ${S}`,variant:"error"}),j&&t.jsx(v,{label:`Polymer build: ${j}`,variant:"error"}),M&&t.jsx(v,{label:M,variant:"warning"})]}),t.jsx(G,{ref:u,className:b.molViewer,theme:se,source:A,sourceMode:m.current?"update":"replace",onLoad:()=>{m.current=!0,_(null)},onLoadError:o=>_(o.error),onModifiedChange:o=>{N(o),l==null||l(o)},onSave:e?V:void 0,onPolymerBuild:e?B:void 0})]})}function _e({tab:e}){const{path:r}=e.data,n=D(e.id);return t.jsx(w,{children:t.jsx(ue,{path:r,workspaceCwd:e.workspaceCwd,tabId:e.id,isActive:n})})}export{_e as MoleculeViewerPanel};