@bivy/bivy 0.21.1-staging.2 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/web/assets/{AutomationsView-tGFmNyI7.js → AutomationsView-Cw3-fec-.js} +1 -1
- package/web/assets/{ChangesCard-x8Ci1OJd.js → ChangesCard-CxQKGf6b.js} +1 -1
- package/web/assets/{LibraryView-D4o-Q00g.js → LibraryView-D3uu06xU.js} +1 -1
- package/web/assets/{ProviderConnect-8mZJqRVo.js → ProviderConnect-BVnL5_ML.js} +1 -1
- package/web/assets/{SessionList-CP2yG8sC.js → SessionList-qypmhsdJ.js} +1 -1
- package/web/assets/{Settings-B_0J-UTo.js → Settings-DrK5DKuy.js} +3 -3
- package/web/assets/{Sheet-R7TmTqRs.js → Sheet-C8gx0OoI.js} +1 -1
- package/web/assets/{Terminal-CNTaC3Bo.js → Terminal-DrqMIIhr.js} +1 -1
- package/web/assets/{VoiceSettings-BXzO0bps.js → VoiceSettings-CBBuyKN7.js} +1 -1
- package/web/assets/{abnfDiagram-VCTEODGH-Cq-C3Lr0.js → abnfDiagram-VCTEODGH-CgIjZZoL.js} +1 -1
- package/web/assets/architecture-7GRP2DOG-DjnOFWJ6.js +1 -0
- package/web/assets/{architectureDiagram-5GKGNRK7-wZNIEiGX.js → architectureDiagram-5GKGNRK7-BMOlU5hT.js} +1 -1
- package/web/assets/{blockDiagram-I7D4REHJ-Chp4nb_t.js → blockDiagram-I7D4REHJ-DkwymH1p.js} +1 -1
- package/web/assets/{c4Diagram-7LVT6UL2-BBZgTvoW.js → c4Diagram-7LVT6UL2-B0UDgtWS.js} +1 -1
- package/web/assets/channel-B7AEPkF6.js +1 -0
- package/web/assets/{chunk-4HAMMTFA-BpLEAQIx.js → chunk-4HAMMTFA-1y76NzcS.js} +1 -1
- package/web/assets/{chunk-75Z2AOVW-F40u6_2Y.js → chunk-75Z2AOVW-CPFkG_FO.js} +1 -1
- package/web/assets/{chunk-DU6HZSFF-C88MDoWn.js → chunk-DU6HZSFF-Dy4LQ-iK.js} +1 -1
- package/web/assets/{chunk-F27PBJKO-Bp19aIde.js → chunk-F27PBJKO-cjpOzWOK.js} +1 -1
- package/web/assets/{chunk-GMAD6QVW-Cw1YRFlT.js → chunk-GMAD6QVW-CpYC8bxK.js} +1 -1
- package/web/assets/{chunk-GVQU2GXP-qzDxZ9bJ.js → chunk-GVQU2GXP-DUT271z8.js} +1 -1
- package/web/assets/{chunk-IMKFNOWR-C4YxuO1E.js → chunk-IMKFNOWR-C-G3w5yT.js} +1 -1
- package/web/assets/{chunk-L3NEJ4N5-CnsRJGpX.js → chunk-L3NEJ4N5-C5N0po6u.js} +1 -1
- package/web/assets/{chunk-OSK3NFVY-XFuK4lk5.js → chunk-OSK3NFVY-7_vZDCyQ.js} +1 -1
- package/web/assets/{chunk-P2QGCYS3-Car8pEAm.js → chunk-P2QGCYS3-BhXxw6WP.js} +1 -1
- package/web/assets/{chunk-POPQ4Y6H-C1EKvqZ4.js → chunk-POPQ4Y6H-iw5O0upC.js} +1 -1
- package/web/assets/{chunk-PWAF6VOD-BUoMTcIG.js → chunk-PWAF6VOD-C8u0Giuo.js} +1 -1
- package/web/assets/{chunk-SHT3W25Y-ykYte0jd.js → chunk-SHT3W25Y-BM_QeCu-.js} +1 -1
- package/web/assets/{chunk-SVP7TREG-3Xq4d9je.js → chunk-SVP7TREG-cLDkReFI.js} +1 -1
- package/web/assets/{chunk-TICWLB2K-BMl68KBL.js → chunk-TICWLB2K-C8fbKbO_.js} +1 -1
- package/web/assets/classDiagram-ZZMXUADV-BEtpnW4V.js +1 -0
- package/web/assets/classDiagram-v2-VYDZK3BY-BEtpnW4V.js +1 -0
- package/web/assets/{cynefin-OW5HDTMX-IlsT6Bvi.js → cynefin-OW5HDTMX-6kzYNsQ0.js} +1 -1
- package/web/assets/{cynefinDiagram-5FMLGOSQ-DsFXDffD.js → cynefinDiagram-5FMLGOSQ-B3tl5cyI.js} +1 -1
- package/web/assets/{dagre-GXQ25YYZ-BT9x18HY.js → dagre-GXQ25YYZ-mHX4cPQQ.js} +1 -1
- package/web/assets/{diagram-S7CK7UJ4-h7v7VpuX.js → diagram-S7CK7UJ4-DhOtHdTh.js} +1 -1
- package/web/assets/{diagram-UQ7AKVKN-DiuWIKwN.js → diagram-UQ7AKVKN-B6BD-P5q.js} +1 -1
- package/web/assets/{diagram-VSXAHHWV-BKjRfJo2.js → diagram-VSXAHHWV-DWXWifeJ.js} +1 -1
- package/web/assets/{diagram-VX7I27RA-DnVCmPjE.js → diagram-VX7I27RA-DcU0vblN.js} +1 -1
- package/web/assets/{diagram-Z3DM3KII-CxC5BEc6.js → diagram-Z3DM3KII-Tc32VaTG.js} +1 -1
- package/web/assets/{ebnfDiagram-PWID7BFC-D-1Zewzr.js → ebnfDiagram-PWID7BFC-fbSC7Ytl.js} +1 -1
- package/web/assets/{erDiagram-RLTQ6QDP-ghS1KvWh.js → erDiagram-RLTQ6QDP-VCd4vHPL.js} +1 -1
- package/web/assets/eventmodeling-NTZA5JFV-CYiUVM8V.js +1 -0
- package/web/assets/flowDiagram-HODETNUW-kSHsw5bd.js +1 -0
- package/web/assets/{ganttDiagram-EL5Y4UJY-CKmSuwpO.js → ganttDiagram-EL5Y4UJY-qlPJPHC9.js} +1 -1
- package/web/assets/{gitGraph-4MIJSDKK-CJ8uJDAa.js → gitGraph-4MIJSDKK-Frn6_UlZ.js} +1 -1
- package/web/assets/{gitGraphDiagram-WWUBYQGX-B3SYH-DA.js → gitGraphDiagram-WWUBYQGX-CJv1U3iy.js} +1 -1
- package/web/assets/{index-dgtJdWG6.js → index-DoVsvSyc.js} +2 -2
- package/web/assets/{info-A6RAGUB7-CHMpm9Sw.js → info-A6RAGUB7-x2ehGecF.js} +1 -1
- package/web/assets/{infoDiagram-27XIBGKW-BHmi8_bS.js → infoDiagram-27XIBGKW-CzHIphTX.js} +1 -1
- package/web/assets/{ishikawaDiagram-5VMMS53U-DuEd11bq.js → ishikawaDiagram-5VMMS53U-1aIpAo5f.js} +1 -1
- package/web/assets/{journeyDiagram-3NMN7TZE-C1KezsV9.js → journeyDiagram-3NMN7TZE-DZFs2eed.js} +1 -1
- package/web/assets/{kanban-definition-UXKFOSKX-tOVvDQBr.js → kanban-definition-UXKFOSKX-CFPF7vk4.js} +1 -1
- package/web/assets/{mermaid-parser.core-Dq1OiZoj.js → mermaid-parser.core-eET97OnM.js} +3 -3
- package/web/assets/{mermaid.core-CYjB0fst.js → mermaid.core-D-l2iyMD.js} +4 -4
- package/web/assets/{mindmap-definition-YA3MSWOX-BY2WZE3p.js → mindmap-definition-YA3MSWOX-CzO4WiUd.js} +1 -1
- package/web/assets/{mount-BGs1QFmE.js → mount-Cnz2WLxO.js} +5 -5
- package/web/assets/{packet-AYTQ26CC-tsR35EiE.js → packet-AYTQ26CC-DiT50-0V.js} +1 -1
- package/web/assets/{pegDiagram-XKGWAZYB-Coaafenl.js → pegDiagram-XKGWAZYB-DG3Ad8mS.js} +1 -1
- package/web/assets/{pie-WAS4IAKB-CIlN9kjj.js → pie-WAS4IAKB-BGJZoyxN.js} +1 -1
- package/web/assets/{pieDiagram-E7YTZNPT-CUVdLLU5.js → pieDiagram-E7YTZNPT-C_IdKjBF.js} +1 -1
- package/web/assets/{quadrantDiagram-AXDQQJYC-COv79LP4.js → quadrantDiagram-AXDQQJYC-CVvfK1li.js} +1 -1
- package/web/assets/{radar-RG4KPBEZ-DCZMZllq.js → radar-RG4KPBEZ-C14GlZJM.js} +1 -1
- package/web/assets/{railroad-74A4TZTK-Cuf665ol.js → railroad-74A4TZTK-Cg3OXIZS.js} +1 -1
- package/web/assets/railroad-abnf-HS5TGJTU-CzpKO8Mq.js +1 -0
- package/web/assets/railroad-ebnf-LZEXJU2U-BBhUgg4O.js +1 -0
- package/web/assets/railroad-peg-WCYAUIDC-C2WJ96PH.js +1 -0
- package/web/assets/{railroadDiagram-O6MQD6OU-r3TxV9m7.js → railroadDiagram-O6MQD6OU-_oTlqB8E.js} +1 -1
- package/web/assets/{requirementDiagram-BXWQKSXE-D65szw1G.js → requirementDiagram-BXWQKSXE-6_cpGq7p.js} +1 -1
- package/web/assets/{sankeyDiagram-P5KCCOFB-DGJIDPIs.js → sankeyDiagram-P5KCCOFB-CIDdTiIM.js} +1 -1
- package/web/assets/{sequenceDiagram-WJ2MYXX4-yC5Yj8N1.js → sequenceDiagram-WJ2MYXX4-OmglouV4.js} +1 -1
- package/web/assets/{settingsRoute-CsB3Exnz.js → settingsRoute-Y4aQ907P.js} +1 -1
- package/web/assets/{stateDiagram-D77RDMKH-_AbIjSyZ.js → stateDiagram-D77RDMKH-lmR5zsjq.js} +1 -1
- package/web/assets/stateDiagram-v2-MP3YSRHH-DJ79XS5i.js +1 -0
- package/web/assets/{swimlanes-42K2YHIH-VRYlQaT0.js → swimlanes-42K2YHIH-BRP1y0vF.js} +1 -1
- package/web/assets/swimlanesDiagram-VR7AAH4N-D08eaEQz.js +8 -0
- package/web/assets/{timeline-definition-24CTP7MA-D4xtmeYc.js → timeline-definition-24CTP7MA-74uE748S.js} +1 -1
- package/web/assets/{treeView-Q6P3EWNA-CD3aFEk1.js → treeView-Q6P3EWNA-C7rSzN0q.js} +1 -1
- package/web/assets/{treemap-WGGIJYW6-DviYL4fV.js → treemap-WGGIJYW6-B-Eqh7wJ.js} +1 -1
- package/web/assets/{useStore-CzjbLTh5.js → useStore-TM8ZVr6X.js} +1 -1
- package/web/assets/{vennDiagram-4TSXK5OY-B0DtUoPv.js → vennDiagram-4TSXK5OY-9HXkWxEw.js} +1 -1
- package/web/assets/{wardley-WFR3VGLG-TVLfF7ZC.js → wardley-WFR3VGLG-Bvwh4mZv.js} +1 -1
- package/web/assets/{wardleyDiagram-VM6X3IG4-Wv5CnXD3.js → wardleyDiagram-VM6X3IG4-D_t1chE2.js} +1 -1
- package/web/assets/{xychartDiagram-S5SC5T6Z-b9CK2fje.js → xychartDiagram-S5SC5T6Z-BwaxhGtz.js} +1 -1
- package/web/index.html +1 -1
- package/web/sw.js +1 -1
- package/web/assets/architecture-7GRP2DOG-Cno3tf-L.js +0 -1
- package/web/assets/channel-GDYVufe9.js +0 -1
- package/web/assets/classDiagram-ZZMXUADV-DN8Jvz7c.js +0 -1
- package/web/assets/classDiagram-v2-VYDZK3BY-DN8Jvz7c.js +0 -1
- package/web/assets/eventmodeling-NTZA5JFV-kHQaM7OX.js +0 -1
- package/web/assets/flowDiagram-HODETNUW-YHAGAr8z.js +0 -1
- package/web/assets/railroad-abnf-HS5TGJTU-DrGYU-jG.js +0 -1
- package/web/assets/railroad-ebnf-LZEXJU2U-BFBhzvHT.js +0 -1
- package/web/assets/railroad-peg-WCYAUIDC-CSIEQtd_.js +0 -1
- package/web/assets/stateDiagram-v2-MP3YSRHH-yrf2Tsly.js +0 -1
- package/web/assets/swimlanesDiagram-VR7AAH4N-BswVzQRA.js +0 -8
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-
|
|
2
|
-
import{n as e,t}from"./rolldown-runtime-hePW80VL.js";import{D as n,E as r,I as i,L as a,N as o,R as s,V as c,a as l,b as u,c as d,d as f,f as p,i as m,j as h,l as g,m as _,n as v,o as y,p as b,r as x,s as S,t as C,u as w,z as T}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-DrqMIIhr.js","assets/rolldown-runtime-hePW80VL.js","assets/useStore-TM8ZVr6X.js","assets/index-DoVsvSyc.js","assets/index-CtJDDeFG.css","assets/jsx-runtime-NZYk81nU.js","assets/Sheet-C8gx0OoI.js","assets/ChangesCard-CxQKGf6b.js","assets/Spinner-CPdRfDcT.js","assets/Terminal-B1njb2Cr.css","assets/embed-BXV41wg7.js","assets/linear-CeYXFQza.js","assets/step-BDqHAzds.js","assets/defaultLocale-CNPGWpMu.js","assets/init-ZlXS9mIS.js","assets/ordinal-BdBDtYTt.js","assets/time-Dzw-YSCF.js","assets/range-EplFIxc7.js","assets/treemap-BfjIY-m6.js","assets/colors-Cg5Vh3br.js","assets/arc-BNLueWOY.js","assets/common-DvIV9UK2.js","assets/mermaid.core-D-l2iyMD.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-CFHfg5gg.js","assets/chunk-DU6HZSFF-Dy4LQ-iK.js","assets/chunk-75Z2AOVW-CPFkG_FO.js","assets/dist-kYfyPZP9.js","assets/chunk-PWAF6VOD-C8u0Giuo.js","assets/chunk-GMAD6QVW-CpYC8bxK.js","assets/chunk-P2QGCYS3-BhXxw6WP.js","assets/chunk-4HAMMTFA-1y76NzcS.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-GVQU2GXP-DUT271z8.js","assets/chunk-OSK3NFVY-7_vZDCyQ.js","assets/graphlib-DS17s2tU.js","assets/chunk-L3NEJ4N5-C5N0po6u.js","assets/ReadinessChecklist-Bbgq2GQ8.js","assets/Settings-DrK5DKuy.js","assets/ProviderConnect-BVnL5_ML.js","assets/AutomationsView-Cw3-fec-.js","assets/SessionList-qypmhsdJ.js","assets/LibraryView-D3uu06xU.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{n as e,t}from"./rolldown-runtime-hePW80VL.js";import{D as n,E as r,I as i,L as a,N as o,R as s,V as c,a as l,b as u,c as d,d as f,f as p,i as m,j as h,l as g,m as _,n as v,o as y,p as b,r as x,s as S,t as C,u as w,z as T}from"./index-DoVsvSyc.js";import{A as E,At as D,B as O,C as k,Ct as A,D as ee,E as j,F as M,H as te,L as ne,M as re,O as ie,R as N,S as P,St as ae,T as oe,Tt as se,U as ce,Z as le,_ as ue,_t as de,a as fe,at as pe,b as F,bt as I,c as me,ct as he,d as ge,f as _e,ft as ve,g as L,h as ye,ht as be,i as R,it as xe,j as Se,l as Ce,m as we,n as Te,o as Ee,ot as De,p as Oe,pt as ke,s as Ae,st as je,t as Me,u as Ne,v as Pe,vt as Fe,w as Ie,wt as Le,x as Re,xt as ze,y as Be,yt as Ve,z as He}from"./useStore-TM8ZVr6X.js";import{D as Ue,E as We,M as Ge,S as Ke,T as qe,_ as Je,a as Ye,b as Xe,c as Ze,d as Qe,f as $e,g as et,h as tt,i as nt,j as rt,k as it,l as at,n as ot,o as st,r as z,t as ct,v as lt,w as ut,x as dt,y as ft}from"./Sheet-C8gx0OoI.js";import{a as pt,c as mt,g as ht,h as gt,i as _t,l as vt,m as yt,n as bt,o as xt,p as St,r as Ct,s as wt,t as Tt}from"./ChangesCard-CxQKGf6b.js";import{t as Et}from"./jsx-runtime-NZYk81nU.js";import{C as Dt,S as Ot,_ as kt,a as At,b as jt,c as Mt,d as Nt,f as Pt,g as Ft,h as It,i as Lt,l as Rt,m as zt,n as Bt,p as Vt,t as Ht,u as Ut,v as B,w as Wt,x as Gt,y as Kt}from"./SessionList-qypmhsdJ.js";import{n as qt,t as V}from"./Spinner-CPdRfDcT.js";import{a as Jt,i as Yt,n as Xt,r as Zt,t as Qt}from"./settingsRoute-Y4aQ907P.js";import{a as $t,c as en,d as tn,i as nn,l as rn,n as an,o as on,r as sn,s as cn,u as ln}from"./ProviderConnect-BVnL5_ML.js";var un=[{kind:`fork`,pattern:/^I am continuing an existing Bivy session \(forked from (.+?) to .+?\)\./},{kind:`import`,pattern:/^I am continuing an? (.+?) session that was started outside Bivy and imported here\./}];function dn(e){if(e)for(let t of un){let n=t.pattern.exec(e);if(n)return{kind:t.kind,from:n[1]}}}var fn=[`todos`,`plan`,`entries`,`items`,`steps`,`tasks`],pn=[`content`,`step`,`text`,`title`,`subject`,`description`,`task`],mn={pending:`pending`,todo:`pending`,notstarted:`pending`,open:`pending`,inprogress:`in_progress`,active:`in_progress`,running:`in_progress`,doing:`in_progress`,current:`in_progress`,started:`in_progress`,completed:`completed`,complete:`completed`,done:`completed`,finished:`completed`,success:`completed`,cancelled:`cancelled`,canceled:`cancelled`,skipped:`cancelled`,abandoned:`cancelled`};function hn(e){return mn[String(e??``).toLowerCase().replace(/[^a-z]/g,``)]}function gn(e,t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim())return t.trim()}}function _n(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=fn.map(e=>t[e]).find(Array.isArray);if(!n?.length)return;let r=[];for(let e of n){if(typeof e==`string`){r.push({text:e,status:`pending`});continue}if(!e||typeof e!=`object`)continue;let t=e,n=gn(t,pn),i=hn(t.status??t.state),a=t.id??t.taskId;r.push({...n?{text:n}:{},...i?{status:i}:{},...a!=null&&a!==``?{id:String(a)}:{}})}let i=t.merge===!0;if(i||r.some(e=>e.text))return{entries:r,merge:i}}function vn(e,t){if(!t.merge)return t.entries.filter(e=>e.text).map(e=>({text:e.text,status:e.status??`pending`,...e.id?{id:e.id}:{}}));let n=e.map(e=>({...e}));for(let e of t.entries){let t=e.id?n.find(t=>t.id===e.id):void 0;t?(e.text&&(t.text=e.text),e.status&&(t.status=e.status)):e.text&&n.push({text:e.text,status:e.status??`pending`,...e.id?{id:e.id}:{}})}return n}function yn(e){if(e==null||e===``)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function bn(e){let t=String(e||``).trim();if(!t)return``;let n=t.split(`/`).filter(Boolean);return n.length>2?`…/${n.slice(-2).join(`/`)}`:t}function xn(e){return e?.toolInput??e?.input??e?.args??e?.arguments??e?.toolCall?.arguments??{}}function Sn(e){return String(e?.toolName||e?.name||e?.tool?.name||e?.tool||e?.toolCall?.name||`tool`).toLowerCase()}var Cn={apply_automations:{title:`Apply automations to your account?`,consequence:e=>{let t=Array.isArray(e.changes)?e.changes.length:0;return`The agent wants to make ${t} change${t===1?``:`s`} to your automations.`},severity:e=>Array.isArray(e.changes)&&e.changes.some(e=>String(e).startsWith(`Remove `))?`critical`:`high`,fields:e=>[[`File`,e.file],[`Changes`,Array.isArray(e.changes)?e.changes.join(`
|
|
3
3
|
`):``]]}};function wn(e){let t=xn(e),n=Sn(e),r=Cn[n];if(r)return r.severity(t);let i=`${n} ${Object.values(t).map(yn).join(` `)}`.toLowerCase();return/\b(rm\s+-rf|rm\s+-r|delete|unlink|drop\s+table|shutdown|reboot|format|wipe)\b/.test(i)?`critical`:/\b(send|email|mail|post|publish|deploy|push|scp|curl|wget|ssh|chmod|chown|sudo)\b/.test(i)?`high`:/\b(write|edit|mv|move|cp|copy|install|update|create)\b/.test(i)?`medium`:`low`}function Tn(e){let t=xn(e),n=Sn(e);if(Cn[n])return Cn[n].title;let r=t.path||t.file||t.filePath||t.pathname;return n.includes(`bash`)||n.includes(`shell`)?`Run this command?`:n.includes(`mail`)||n.includes(`email`)||n.includes(`send`)?`Agent wants to send a message`:n.includes(`edit`)?`Edit ${bn(r)||`a file`}?`:n.includes(`write`)?`Write ${bn(r)||`a file`}?`:`Allow ${n}?`}function En(e,t=wn(e)){let n=xn(e),r=Sn(e);if(Cn[r])return Cn[r].consequence(n);let i=String(n.command||n.cmd||n.shell||``).trim(),a=n.path||n.file||n.filePath||n.pathname||n.cwd||n.directory,o=n.to||n.recipients||n.recipient,s=Array.isArray(o)?o.length:o?String(o).split(`,`).filter(Boolean).length:0,c=`${r} ${i}`.toLowerCase();return s||r.includes(`mail`)||r.includes(`email`)||/\b(sendmail|mail)\b/.test(c)?s?`This sends a message to ${s} recipient${s===1?``:`s`} immediately.`:`This sends a message immediately.`:t===`critical`?a?`This can permanently change or delete data in ${a}. This may not be undoable.`:`This can permanently change or delete data. This may not be undoable.`:/\b(curl|wget|ssh|scp|git\s+push|deploy)\b/.test(c)?`This connects to an external service or publishes data outside this machine.`:/\b(npm|bun|pnpm|yarn)\s+(install|add|update)\b/.test(c)?`This changes project dependencies on this machine.`:r.includes(`write`)||r.includes(`edit`)||/\b(write|edit|mv|cp)\b/.test(c)?a?`This changes files at ${a}.`:`This changes files in the workspace.`:`The agent is paused until you approve this action.`}function Dn(e){let t=xn(e),n=Sn(e);return n.includes(`bash`)||n.includes(`shell`)?String(t.command||t.cmd||t.shell||``).trim():``}function On(e){let t=xn(e),n=Sn(e),r=[],i=(e,t,n=420)=>{let i=String(t??``).trim();i&&r.push([e,i.length>n?`${i.slice(0,n)}…`:i])};if(Cn[n]){for(let[e,r]of Cn[n].fields(t))i(e,r,1/0);return r}return i(`Tool`,n),i(`File`,t.path||t.file||t.filePath||t.pathname),i(`Command`,n.includes(`bash`)||n.includes(`shell`)?``:t.command),i(`Find`,t.oldText||t.search||t.find),i(`Replace`,t.newText||t.replace),i(`Text`,t.content||t.text),r}function kn(e){let t=wn(e),n=xn(e),r=``;try{r=JSON.stringify(n,null,2)}catch{r=String(n)}return{severity:t,title:Tn(e),consequence:En(e,t),command:Dn(e),fields:On(e),rawInput:r,canRemember:t!==`critical`}}var An=`receipt.v1`,jn={id:200,text:240,ref:500,list:100,checks:50},Mn=/prompt|transcript|reasoning|diff|secret|token|stdout|stderr|raw.?output|raw.?input|raw.?command|raw.?tool|file.?content|repository.?content/i;function Nn(e,t=new Set){if(e&&typeof e==`object`){if(t.has(e))throw Error(`cyclic Receipt evidence rejected`);t.add(e);for(let[n,r]of Object.entries(e)){if(Mn.test(n))throw Error(`prohibited Receipt field rejected: ${n}`);Nn(r,t)}t.delete(e)}}function H(e,t,n=jn.text){if(e!=null&&e!==``){if(typeof e!=`string`||e.length>n)throw Error(`${t} must be a string of at most ${n} characters`);return e}}function U(e,t,n=jn.id){let r=H(e,t,n)?.trim();if(!r)throw Error(`${t} is required`);return r}function Pn(e,t){let n=H(e,t,40);if(n){if(!Number.isFinite(Date.parse(n)))throw Error(`${t} must be an ISO date-time`);return n}}function Fn(e,t){e.includes(t)||e.push(t)}var In={run_in_progress:`The Run has no evidence-backed terminal outcome yet.`,session_not_correlated:`Run evidence was not correlated to an underlying Session.`,machine_identity_not_reported:`A customer-readable Machine identity was not reported with this Run.`,execution_identity_not_reported:`Provider, runtime, or model version evidence was not fully reported.`,effective_protection_not_observed:`Requested protection is visible, but its effective settings were not observed.`,approval_decisions_not_correlated:`Approval and denial decisions were not durably correlated to this Run.`,governance_events_not_correlated:`Governance audit events were not durably correlated to this Run.`,change_metadata_not_reported:`A bounded file/change summary or explicit no-change evidence was not reported.`,check_metadata_incomplete:`One or more checks lack required, timeout, or other deterministic metadata.`,audit_health_unknown:`Audit storage health or successful writes could not be confirmed.`,audit_write_failed:`At least one required audit write or readable-storage check is missing.`};function Ln(e){if(Nn(e),!e||typeof e!=`object`||!e.run||typeof e.run!=`object`)throw Error(`Receipt evidence is required`);let t=U(e.receiptId,`receiptId`),n=U(e.run.id,`run.id`),r=U(Pn(e.createdAt,`createdAt`),`createdAt`,40),i=H(e.run.output?.sessionId,`sessionId`,jn.id),a=Pn(e.run.startedAt??e.run.claimedAt,`run.startedAt`),o=Pn(e.run.completedAt,`run.completedAt`),s=a&&o?Date.parse(o)-Date.parse(a):void 0;if(s!==void 0&&s<0)throw Error(`Run end precedes start`);let c=(e.run.checks??[]).slice(0,jn.checks).map((e,t)=>({name:U(e.name,`checks[${t}].name`,120),...H(e.commandHash,`checks[${t}].commandHash`,128)?{commandHash:e.commandHash}:{},status:e.status,...typeof e.durationMs==`number`?{durationMs:e.durationMs}:{},...typeof e.exitCode==`number`?{exitCode:e.exitCode}:{}})),l=[`succeeded`,`failed`,`cancelled`,`done`].includes(e.run.status),u,d;e.run.status===`cancelled`?(u=`cancelled`,d=`run_cancelled`):l&&c.some(e=>e.status===`failed`)?(u=`checks_failed`,d=`check_failed`):e.run.status===`failed`?(u=`failed`,d=`run_failed`):l&&(e.run.output?.branch||e.run.output?.commit||e.run.output?.prUrl||e.run.output?.checkpoint||e.run.output?.artifactUrl)?(u=`changes_ready`,d=`artifact_recorded`):e.run.status===`succeeded`&&c.length>0&&c.every(e=>e.status===`passed`)&&(u=`succeeded`,d=`checks_passed`);let f=e.run.repo?`${U(e.run.repo,`run.repo`,200)}${Number.isInteger(e.run.issueNumber)?`#${e.run.issueNumber}`:``}`:H(e.run.externalId,`run.externalId`,200),p=(e.run.events??[]).filter(e=>e.kind===`retry`||e.kind===`fallback`).slice(-jn.list).map(e=>e.kind),m=e.protection?.effective,h=(e.protection?.capabilities??[]).slice(0,20).map((e,t)=>({capability:U(e.capability,`capabilities[${t}].capability`,40),evidenceClass:e.evidenceClass,...H(e.mechanism,`capabilities[${t}].mechanism`,120)?{mechanism:e.mechanism}:{}})),g=e.auditHealth??{correlation:`unknown`,readableStorage:`unknown`,successfulWrites:`unknown`},_=e.governance,v={...H(e.run.output?.branch,`changes.branch`,jn.ref)?{branch:e.run.output.branch}:{},...H(e.run.output?.commit,`changes.commit`,200)?{commit:e.run.output.commit}:{},...H(e.run.output?.prUrl,`changes.pullRequest`,jn.ref)?{pullRequest:e.run.output.prUrl}:{},...H(e.run.output?.checkpoint,`changes.checkpoint`,jn.ref)?{checkpoint:e.run.output.checkpoint}:{},...H(e.run.output?.artifactUrl,`changes.artifact`,jn.ref)?{artifact:e.run.output.artifactUrl}:{},files:(_?.fileChanges.files??[]).slice(0,jn.list).map((e,t)=>({path:U(e.path,`changes.files[${t}].path`,jn.ref),...H(e.op,`changes.files[${t}].op`,20)?{op:e.op}:{},...typeof e.added==`number`?{added:e.added}:{},...typeof e.removed==`number`?{removed:e.removed}:{}})),added:_?.fileChanges.added??0,removed:_?.fileChanges.removed??0},y=[];(!a||!o)&&Fn(y,`run_timing`),u||Fn(y,`terminal_outcome`),i||Fn(y,`session_correlation`),(!e.run.claimedByNodeId||!e.execution?.machineName)&&Fn(y,`machine_identity`),(!e.execution?.profile||!e.execution.controller||!e.run.runtimeId||!e.run.model||!e.execution.modelVersionStatus)&&Fn(y,`execution_identity`),m||Fn(y,`effective_protection`),h.length||Fn(y,`protection_evidence`),_||Fn(y,`approval_decisions`),!v.branch&&!v.commit&&!v.pullRequest&&!v.checkpoint&&!v.artifact&&!v.files.length&&Fn(y,`change_evidence`),_||Fn(y,`file_change_summary`),c.some(e=>!e.commandHash||typeof e.durationMs!=`number`||e.status!==`skipped`&&typeof e.exitCode!=`number`)&&Fn(y,`check_details`),g.correlation!==`healthy`&&Fn(y,`audit_correlation`),g.readableStorage!==`healthy`&&Fn(y,`audit_storage`),g.successfulWrites!==`healthy`&&Fn(y,`audit_writes`);let b=[];return u||b.push(`run_in_progress`),i||b.push(`session_not_correlated`),y.includes(`machine_identity`)&&b.push(`machine_identity_not_reported`),y.includes(`execution_identity`)&&b.push(`execution_identity_not_reported`),y.includes(`effective_protection`)&&b.push(`effective_protection_not_observed`),y.includes(`approval_decisions`)&&b.push(`approval_decisions_not_correlated`),y.includes(`audit_correlation`)&&b.push(`governance_events_not_correlated`),(y.includes(`change_evidence`)||y.includes(`file_change_summary`))&&b.push(`change_metadata_not_reported`),y.includes(`check_details`)&&b.push(`check_metadata_incomplete`),[g.correlation,g.readableStorage,g.successfulWrites].includes(`unknown`)&&b.push(`audit_health_unknown`),[g.readableStorage,g.successfulWrites].includes(`missing`)&&b.push(`audit_write_failed`),{schemaVersion:An,receiptId:t,runId:n,...i?{sessionId:i}:{},createdAt:r,completeness:y.length?`partial`:`complete`,run:{...a?{startedAt:a}:{},...o?{endedAt:o}:{},...s===void 0?{}:{durationMs:s},...u?{terminalOutcome:u,outcomeReason:d}:{},attempts:Math.max(1,Math.min(100,Math.trunc(e.run.attempt??1))),retryFallbackReasons:p,source:{kind:U(e.run.source,`run.source`,40),...f?{reference:f}:{}}},execution:{...e.run.claimedByNodeId?{machineId:U(e.run.claimedByNodeId,`machineId`)}:{},...e.execution?.machineName?{machineName:U(e.execution.machineName,`machineName`,120)}:{},...e.execution?.profile?{profile:e.execution.profile}:{},...e.execution?.controller?{controller:e.execution.controller}:{},...e.execution?.provider?{provider:U(e.execution.provider,`provider`,80)}:{},...e.execution?.region?{region:U(e.execution.region,`region`,80)}:{},...e.execution?.image?{image:U(e.execution.image,`image`,160)}:{},...e.run.runtimeId?{agentId:U(e.run.runtimeId,`agentId`,120)}:{},...e.execution?.agentVersion?{agentVersion:U(e.execution.agentVersion,`agentVersion`,80)}:{},...e.run.model?{modelId:U(e.run.model,`modelId`,160)}:{},...e.execution?.modelVersionStatus?{modelVersionStatus:e.execution.modelVersionStatus}:{}},protection:{requested:{...e.run.sandbox?{sandboxTier:e.run.sandbox}:{},...e.run.approvalMode?{approvalMode:e.run.approvalMode}:{}},effective:m?{...m,...m.trustModes?{trustModes:m.trustModes.slice(0,20).map((e,t)=>U(e,`trustModes[${t}]`,80))}:{}}:{},capabilities:h},approvals:_?.approvals??{requests:0,approved:0,denied:0},changes:v,checks:c,auditHealth:g,missingEvidence:y,observationLimitations:b.map(e=>({code:e,message:In[e]}))}}function Rn(e,t){let n=e.source.kind||`unknown`,[,r,i]=n.length>40&&n.match(/^([^:]{1,40}):(.+)$/)||[],a=r??n.slice(0,40),o=e.source.reference||i?.slice(0,200),s=o?.match(/^([^#]+)#(\d+)$/);return Ln({receiptId:`receipt-${e.id}`,createdAt:t,run:{id:e.id,source:a,status:e.origin.status,createdAt:e.timestamps.createdAt,claimedAt:e.timestamps.claimedAt,startedAt:e.timestamps.startedAt,completedAt:e.timestamps.completedAt,attempt:e.attempt,...s?{repo:s[1],issueNumber:Number(s[2])}:o?{externalId:o}:{},...e.machine?.id?{claimedByNodeId:e.machine.id}:{},...e.requested.runtimeId?{runtimeId:e.requested.runtimeId}:{},...e.requested.model?{model:e.requested.model}:{},...e.requested.approvalMode?{approvalMode:e.requested.approvalMode}:{},...e.requested.sandbox?{sandbox:e.requested.sandbox}:{},output:{...e.sessionId?{sessionId:e.sessionId}:{},...e.references.branch?{branch:e.references.branch}:{},...e.references.commit?{commit:e.references.commit}:{},...e.references.pullRequest?{prUrl:e.references.pullRequest}:{},...e.references.checkpoint?{checkpoint:e.references.checkpoint}:{},...e.references.artifact?{artifactUrl:e.references.artifact}:{}},checks:e.checks,events:e.events},...e.machine?.name||e.receiptEvidence?.execution?{execution:{...e.receiptEvidence?.execution??{},...e.machine?.name?{machineName:e.machine.name}:{}}}:{},...e.receiptEvidence?.protection?{protection:e.receiptEvidence.protection}:{},...e.receiptEvidence?{governance:e.receiptEvidence,auditHealth:e.receiptEvidence.auditHealth}:{}})}function zn(e){Nn(e);let t={schemaVersion:An,receiptId:U(e.receiptId,`receiptId`),runId:U(e.runId,`runId`),...H(e.sessionId,`sessionId`,jn.id)?{sessionId:e.sessionId}:{},createdAt:U(Pn(e.createdAt,`createdAt`),`createdAt`,40),completeness:e.completeness,run:{...Pn(e.run.startedAt,`run.startedAt`)?{startedAt:e.run.startedAt}:{},...Pn(e.run.endedAt,`run.endedAt`)?{endedAt:e.run.endedAt}:{},...typeof e.run.durationMs==`number`?{durationMs:e.run.durationMs}:{},...e.run.terminalOutcome?{terminalOutcome:e.run.terminalOutcome}:{},...e.run.outcomeReason?{outcomeReason:e.run.outcomeReason}:{},attempts:e.run.attempts,retryFallbackReasons:e.run.retryFallbackReasons.slice(0,jn.list),source:{kind:U(e.run.source.kind,`run.source.kind`,40),...H(e.run.source.reference,`run.source.reference`,200)?{reference:e.run.source.reference}:{}}},execution:{...H(e.execution.machineId,`execution.machineId`,jn.id)?{machineId:e.execution.machineId}:{},...H(e.execution.machineName,`execution.machineName`,120)?{machineName:e.execution.machineName}:{},...e.execution.profile?{profile:e.execution.profile}:{},...e.execution.controller?{controller:e.execution.controller}:{},...H(e.execution.provider,`execution.provider`,80)?{provider:e.execution.provider}:{},...H(e.execution.region,`execution.region`,80)?{region:e.execution.region}:{},...H(e.execution.image,`execution.image`,160)?{image:e.execution.image}:{},...H(e.execution.agentId,`execution.agentId`,120)?{agentId:e.execution.agentId}:{},...H(e.execution.agentVersion,`execution.agentVersion`,80)?{agentVersion:e.execution.agentVersion}:{},...H(e.execution.modelId,`execution.modelId`,160)?{modelId:e.execution.modelId}:{},...e.execution.modelVersionStatus?{modelVersionStatus:e.execution.modelVersionStatus}:{}},protection:{requested:{...e.protection.requested.sandboxTier?{sandboxTier:U(e.protection.requested.sandboxTier,`protection.requested.sandboxTier`,40)}:{},...e.protection.requested.approvalMode?{approvalMode:U(e.protection.requested.approvalMode,`protection.requested.approvalMode`,40)}:{}},effective:{...e.protection.effective.executionProfile?{executionProfile:U(e.protection.effective.executionProfile,`protection.effective.executionProfile`,40)}:{},...e.protection.effective.sandboxTier?{sandboxTier:U(e.protection.effective.sandboxTier,`protection.effective.sandboxTier`,40)}:{},...e.protection.effective.approvalMode?{approvalMode:U(e.protection.effective.approvalMode,`protection.effective.approvalMode`,40)}:{},...e.protection.effective.runtimeEnforcement?{runtimeEnforcement:U(e.protection.effective.runtimeEnforcement,`protection.effective.runtimeEnforcement`,120)}:{},...e.protection.effective.trustModes?{trustModes:e.protection.effective.trustModes.slice(0,20).map((e,t)=>U(e,`trustModes[${t}]`,80))}:{}},capabilities:e.protection.capabilities.slice(0,20).map((e,t)=>({capability:U(e.capability,`capabilities[${t}].capability`,40),evidenceClass:e.evidenceClass,...H(e.mechanism,`capabilities[${t}].mechanism`,120)?{mechanism:e.mechanism}:{}}))},approvals:{requests:e.approvals.requests,approved:e.approvals.approved,denied:e.approvals.denied},changes:{...H(e.changes.branch,`changes.branch`,jn.ref)?{branch:e.changes.branch}:{},...H(e.changes.commit,`changes.commit`,200)?{commit:e.changes.commit}:{},...H(e.changes.pullRequest,`changes.pullRequest`,jn.ref)?{pullRequest:e.changes.pullRequest}:{},...H(e.changes.checkpoint,`changes.checkpoint`,jn.ref)?{checkpoint:e.changes.checkpoint}:{},...H(e.changes.artifact,`changes.artifact`,jn.ref)?{artifact:e.changes.artifact}:{},files:e.changes.files.slice(0,jn.list).map((e,t)=>({path:U(e.path,`changes.files[${t}].path`,jn.ref),...H(e.op,`changes.files[${t}].op`,20)?{op:e.op}:{},...typeof e.added==`number`?{added:e.added}:{},...typeof e.removed==`number`?{removed:e.removed}:{}})),added:e.changes.added,removed:e.changes.removed},checks:e.checks.slice(0,jn.checks).map((e,t)=>({name:U(e.name,`checks[${t}].name`,120),...H(e.commandHash,`checks[${t}].commandHash`,128)?{commandHash:e.commandHash}:{},status:e.status,...typeof e.durationMs==`number`?{durationMs:e.durationMs}:{},...typeof e.exitCode==`number`?{exitCode:e.exitCode}:{}})),auditHealth:{correlation:e.auditHealth.correlation,readableStorage:e.auditHealth.readableStorage,successfulWrites:e.auditHealth.successfulWrites},missingEvidence:e.missingEvidence.slice(0,20),observationLimitations:e.observationLimitations.slice(0,20).map(e=>({code:e.code,message:In[e.code]}))};return JSON.stringify(t,null,2)}function Bn(e,t){return t.hash?{id:`${e.id}:${t.hash}`,hash:t.hash,name:t.name,mimeType:t.mimeType,kind:t.kind,size:t.size,caption:e.role===`assistant`&&e.text?e.text:void 0,createdAt:t.createdAt,artifact:!!t.artifact,origin:e.role===`assistant`?`agent`:`user`,entryId:e.id}:null}function Vn(e,t){return{id:`${e.id}:${t.hash}`,hash:t.hash,name:t.name,mimeType:t.mimeType,kind:t.kind,size:t.size,artifact:!1,origin:`inline`,entryId:e.id}}function Hn(e,t){return e&&e.artifact&&!t.artifact?{...t,artifact:!0}:t}function Un(e){let t=new Map;for(let n of e){for(let e of n.attachments??[]){let r=Bn(n,e);r&&t.set(r.hash,Hn(t.get(r.hash),r))}for(let e of Object.values(n.imageRefs??{}))e?.hash&&!t.has(e.hash)&&t.set(e.hash,Vn(n,e))}return[...t.values()].sort((e,t)=>(t.createdAt??-1)-(e.createdAt??-1)).slice(0,500)}function Wn(e){let t=new Map;for(let n of e)n.app&&!t.has(n.app.appId)&&t.set(n.app.appId,n.app);return[...t.values()]}var W=D(),Gn=Ge(),G=Et(),Kn=new Set;function qn(){for(let e of Kn)e()}function Jn(e){return e.kind===`automations`?{section:e.section}:null}var Yn=Jn(j()),Xn=null;typeof window<`u`&&window.addEventListener(`popstate`,()=>{Yn=Jn(j()),qn()});function Zn(e){return Kn.add(e),()=>Kn.delete(e)}function Qn(){return Yn}function $n(e){Xn=e?.setup??null;let t=e?.section??null;oe({kind:`automations`,section:t}),Yn={section:t},qn()}function er(e){oe({kind:`automations`,section:e},{replace:!0}),Yn={section:e},qn()}function tr(){let e=Xn;return Xn=null,e}function nr(e){oe(e,{replace:!0}),Yn=null,Xn=null,qn()}var rr=new Set,ir=!1;function ar(){for(let e of rr)e()}function or(e){return rr.add(e),()=>rr.delete(e)}function sr(){return ir}function cr(){ir=!0,ar()}function lr(){ir=!1,ar()}var ur=`curl -fsSL https://bivy.sh/install.sh | bash`;function dr(e){try{let t=new URL(e).hostname;return t===`bivy.sh`||t.endsWith(`.bivy.sh`)}catch{return!1}}function fr(e,t,n){let r=e.replace(/\/$/,``),i=t?.replace(/\/$/,``),a=[`BIVY_CONTROL_PLANE_URL=${pr(r)}`,...i?[`BIVY_RELAY_URL=${pr(i)}`]:[]],o=n?[`BIVY_ACCOUNT_TOKEN=${pr(n)}`,...a]:a,s=dr(e),c=e=>e.length?`curl -fsSL https://bivy.sh/install.sh | ${e.join(` `)} bash`:ur,l=s?ur:c(a);return{command:n?c(o):l,plainCommand:l,hosted:s,authenticated:!!n}}function pr(e){return/^[A-Za-z0-9_.:/=@%+-]+$/.test(e)?e:`'${e.replace(/'/g,`'\\''`)}'`}function mr({onEnrolled:e}){let[t,n]=(0,W.useState)(null),[r,i]=(0,W.useState)(!0),[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(null),[l,d]=(0,W.useState)(0),f=(0,W.useRef)(null),p=(0,W.useRef)(null),m=(0,W.useRef)(e);m.current=e;let h=fr(u(),R.local.relay);(0,W.useEffect)(()=>{let e=!1;return i(!0),o(null),f.current??=R.createNodeClaim(),f.current.then(t=>{if(!t.command)throw Error(`This server did not return an install command.`);e||n(t)}).catch(t=>{e||o(t instanceof Error?t.message:String(t))}).finally(()=>{e||i(!1)}),()=>{e=!0}},[l]),(0,W.useEffect)(()=>{if(!t||t.status!==`pending`)return;let e=!1,r,i=async()=>{try{if(Date.parse(t.expiresAt)<=Date.now()){e||n({...t,status:`expired`,command:void 0});return}let r=await R.listNodeClaims();if(e)return;let i=r.find(e=>e.id===t.id);if(o(null),i&&i.status!==`pending`){n({...i,command:void 0}),i.status===`used`&&i.nodeId&&m.current?.(i.nodeId);return}}catch{e||o(`Could not check installation progress. Retrying automatically…`)}e||(r=setTimeout(i,3e3))};return i(),()=>{e=!0,clearTimeout(r)}},[t]),(0,W.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]);let g=async(e,t)=>{if(!await nt(e)){o(`Could not copy. Select and copy the command manually.`);return}c(t),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>c(null),1500)};return(0,G.jsxs)(`div`,{className:`settings-form machine-install-instructions`,children:[(0,G.jsx)(`h3`,{children:`Run this on your machine`}),(0,G.jsx)(`p`,{className:`muted`,children:`On your Mac or Linux computer, open a terminal in your repository and paste this command. It installs Bivy and connects your machine to this account.`}),r&&(0,G.jsx)(`p`,{className:`muted`,role:`status`,children:`Preparing your one-time install command…`}),a&&(0,G.jsx)(`p`,{className:`banner inline`,"data-tone":`danger`,role:`alert`,children:a}),t?.status===`pending`&&t.command&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`connect-command`,children:[(0,G.jsx)(`code`,{tabIndex:0,"aria-label":`One-time install command`,children:t.command}),(0,G.jsx)(`button`,{type:`button`,className:`btn sm ghost icon-only${s===`claim`?` is-copied`:``}`,onClick:()=>void g(t.command,`claim`),"aria-label":s===`claim`?`Install command copied`:`Copy install command`,title:s===`claim`?`Copied`:`Copy install command`,children:s===`claim`?(0,G.jsx)(at,{size:16}):(0,G.jsx)(et,{size:16})})]}),(0,G.jsx)(`p`,{className:`muted`,children:`Single-use · expires in 10 minutes. Paste only on a machine you trust. No second Bivy sign-in required.`})]}),t?.status===`used`&&(0,G.jsxs)(`div`,{role:`status`,children:[(0,G.jsx)(`p`,{children:`Machine enrolled. Waiting for it to come online…`}),(0,G.jsx)(`p`,{className:`muted`,children:`Keep the installer running until it finishes. If it reports a service error, follow its recovery instructions on the machine.`})]}),(t?.status===`expired`||t?.status===`revoked`)&&(0,G.jsxs)(`p`,{role:`status`,children:[`This install command has `,t.status===`expired`?`expired`:`been revoked`,`. Create a new one to continue.`]}),!r&&t?.status!==`pending`&&t?.status!==`used`&&(0,G.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{f.current=null,n(null),c(null),d(e=>e+1)},children:t?`Create new install command`:`Retry install command`}),(0,G.jsx)(`p`,{className:`muted`,children:`Bivy runs in the background and detects available agents. Existing agent logins are reused where supported. Keep this machine awake and online while work runs.`}),(0,G.jsxs)(`details`,{children:[(0,G.jsx)(`summary`,{children:`Other ways to install`}),(0,G.jsxs)(`p`,{className:`muted`,children:[`Use this command if you prefer to sign in on the machine.`,!h.hosted&&` It connects to your self-hosted server.`]}),(0,G.jsxs)(`div`,{className:`connect-command`,children:[(0,G.jsx)(`code`,{tabIndex:0,children:h.plainCommand}),(0,G.jsx)(`button`,{type:`button`,className:`btn sm ghost icon-only${s===`plain`?` is-copied`:``}`,onClick:()=>void g(h.plainCommand,`plain`),"aria-label":s===`plain`?`Regular sign-in command copied`:`Copy regular sign-in command`,children:s===`plain`?(0,G.jsx)(at,{size:16}):(0,G.jsx)(et,{size:16})})]})]})]})}function hr({onClose:e}){return(0,G.jsx)(ot,{title:`Add a Machine`,onClose:e,variant:`centered`,children:(0,G.jsx)(mr,{})})}var gr=e=>e?.();function _r({docked:e,...t}){if(!e)return(0,G.jsx)(ot,{...t});let{title:n,headExtra:r,children:i,ariaLabel:a}=t;return(0,G.jsxs)(`section`,{className:`pane-panel`,"data-size":t.size,"aria-label":a??(typeof n==`string`?n:void 0),children:[(0,G.jsxs)(`div`,{className:`pane-panel-head`,children:[(0,G.jsx)(`span`,{className:`pane-panel-title`,children:n}),r]}),(0,G.jsx)(`div`,{className:`pane-panel-content`,children:typeof i==`function`?i(gr):i})]})}function vr({label:e,items:t,onOpen:n}){let[r,i]=(0,W.useState)(!1),a=(0,W.useRef)(null),o=()=>{i(!1),a.current?.querySelector(`[aria-haspopup=menu]`)?.focus()};return rt(o,r),(0,W.useEffect)(()=>{if(!r)return;a.current?.querySelector(`[role^=menuitem]:not(:disabled)`)?.focus();let e=e=>{a.current?.contains(e.target)||i(!1)};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)},[r]),(0,G.jsxs)(`div`,{className:`apps-more`,ref:a,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn ghost icon`,"aria-label":e,title:`More`,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{e.stopPropagation(),r||n?.(),i(e=>!e)},children:(0,G.jsx)(ut,{size:18})}),r&&(0,G.jsx)(`div`,{className:`menu apps-more-menu`,role:`menu`,"aria-label":e,children:t.map(e=>`heading`in e?(0,G.jsx)(`div`,{className:`menu-heading`,role:`presentation`,children:e.heading},e.heading):(0,G.jsxs)(`button`,{type:`button`,role:e.checked===void 0?`menuitem`:e.toggle?`menuitemcheckbox`:`menuitemradio`,"aria-checked":e.checked,className:`menu-item${e.danger?` danger`:``}${e.separated?` separated`:``}`,disabled:e.disabled,onClick:()=>{o(),e.onSelect()},children:[(0,G.jsx)(`span`,{className:`menu-item-label`,children:e.label}),e.checked&&(0,G.jsx)(at,{size:15,"aria-hidden":!0})]},e.label))})]})}function yr({checked:e,onChange:t,disabled:n,label:r}){return(0,G.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":r,disabled:n,className:`settings-toggle${e?` on`:``}`,onClick:()=>t(!e),children:(0,G.jsx)(`span`,{className:`settings-toggle-knob`,"aria-hidden":!0})})}function br(e){let t=e.setups.filter(e=>e.active&&e.id!==`local`);return t.length?t.map(e=>e.label).join(` + `):e.setups.find(e=>e.id===`local`)?.label??`This machine only`}function xr(e,t){let n=e.setups.filter(e=>e.gives[t]===2).map(e=>e.label);return n.length>1?`${n.slice(0,-1).join(`, `)} or ${n.at(-1).replace(/^Your/,`your`)}`:n[0]??``}var Sr=[``,`on your tailnet`,`from anywhere`];function Cr(e=!0){let[t,n]=(0,W.useState)(null),[r,i]=(0,W.useState)(``);return(0,W.useEffect)(()=>{if(!e)return;let t=!0;return R.getAccess().then(e=>{t&&n(e)}).catch(e=>{t&&i(String(e?.message||e))}),()=>{t=!1}},[e]),{report:t,error:r}}function wr({command:e}){let[t,n]=(0,W.useState)(!1);return(0,G.jsxs)(`div`,{className:`repo-connect-command`,children:[(0,G.jsx)(`code`,{children:e}),(0,G.jsx)(`button`,{type:`button`,className:`btn sm ghost${t?` is-copied`:``}`,"aria-label":`Copy ${e}`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),window.setTimeout(()=>n(!1),1500)})},children:t?`Copied`:`Copy`})]})}function Tr(){let{report:e,error:t}=Cr();return(0,G.jsxs)(`section`,{className:`settings-section`,"aria-labelledby":`access-title`,children:[(0,G.jsx)(`h4`,{className:`settings-subhead`,id:`access-title`,children:`How you reach this machine`}),e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`small`,children:[(0,G.jsx)(`strong`,{children:br(e)}),e.tailscaleUrl?(0,G.jsxs)(`span`,{className:`muted`,children:[` · `,e.tailscaleUrl]}):null]}),(0,G.jsx)(`ul`,{className:`readiness-checks`,children:e.features.map(t=>{let n=e.reach[t.id];return(0,G.jsxs)(`li`,{className:`readiness-check${n?``:` state-pending`}`,children:[(0,G.jsx)(`span`,{className:`readiness-mark${n?` mark-passed`:``}`,"aria-hidden":!0,children:n?`✓`:`–`}),(0,G.jsx)(`span`,{className:`readiness-label`,children:t.label}),(0,G.jsx)(`span`,{className:`readiness-detail`,"aria-hidden":!0,children:n?Sr[n]:`not with this setup`}),(0,G.jsx)(`span`,{className:`sr-only`,children:n?`: yes, ${Sr[n]}`:`: not with this setup`})]},t.id)})}),e.next.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h4`,{className:`settings-subhead`,children:`Next`}),e.next.map(t=>{let n=e.setups.find(e=>e.id===t.id);return n?(0,G.jsxs)(`div`,{className:`settings-section`,children:[(0,G.jsxs)(`div`,{className:`small`,children:[(0,G.jsx)(`strong`,{children:n.label}),` `,(0,G.jsxs)(`span`,{className:`muted`,children:[`adds `,t.addsText,`. `,n.summary]})]}),n.command&&(0,G.jsx)(wr,{command:n.command})]},t.id):null}),(0,G.jsx)(`div`,{className:`muted small`,children:`Run these on the machine. Setups stack: adding one never takes away another.`})]})]}):(0,G.jsx)(`p`,{className:`muted small`,role:t?`alert`:`status`,children:t?`Couldn't ask the machine: ${t}`:`Checking…`})]})}function Er({feature:e,inSettings:t=!1}){let{report:n}=Cr(R.direct);if(!n||n.reach[e]>0)return null;let r=n.features.find(t=>t.id===e)?.label??e;return(0,G.jsxs)(`div`,{className:`banner inline`,"data-tone":`accent`,children:[(0,G.jsxs)(`span`,{className:`banner-text`,role:`status`,children:[r,` need `,xr(n,e),`.`]}),(0,G.jsx)(`span`,{className:`banner-actions`,children:(0,G.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>t?Yt(`nodes`):Zt(`nodes`),children:`See options`})})]})}var Dr=`bivy.app-share`;function Or(){try{let e=JSON.parse(localStorage.getItem(Dr)??`{}`);return{duration:re.some(t=>t.id===e.duration)?e.duration:`1d`,controls:e.controls!==!1}}catch{return{duration:`1d`,controls:!0}}}var kr=e=>new Date(e).toLocaleString([],{weekday:`short`,hour:`numeric`,minute:`2-digit`});function Ar({sessionId:e,appId:t,viewId:n,name:r,nodeId:i,address:a,disabled:o,onRevoked:s}){let{connection:c}=Me(),l=!!i&&!R.direct&&i!==c.currentNodeId||c.status===`online`,[u,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)(!1),[g,_]=(0,W.useState)(!1),[v,y]=(0,W.useState)(``),[b,x]=(0,W.useState)(``),[S,C]=(0,W.useState)(``),[w,T]=(0,W.useState)(Or),[E,D]=(0,W.useState)(null),[O,k]=(0,W.useState)(!1),A=e=>T(t=>{let n={...t,...e};try{localStorage.setItem(Dr,JSON.stringify(n))}catch{}return n}),ee=async()=>{let r=(await R.appCommand(`apps.list`,e,{},i)).apps.find(e=>e.id===t)?.views.find(e=>e.id===n);return r?.kind===`web`?r:void 0},j=()=>ee().then(e=>D(e?.sharing??null)).catch(()=>{});(0,W.useEffect)(()=>{u&&l&&j()},[u,l]);let M=async e=>{p(!0),_(!1),x(``),y(``),C(``);try{await e()}catch(e){x(e instanceof Error?e.message:`Could not update app access.`)}finally{p(!1)}},te=async(e,t=!1)=>{let n=new URL(e);if(n.protocol!==`https:`||n.username||n.password||n.origin===location.origin)throw Error(`Machine returned an unsafe preview URL.`);let r=await nt(n.href);t?y(r?`Address copied. Only works when signed in to Bivy.`:`Your address · Bivy sign-in required.`):r?_(!0):y(`Copy this link to share.`),r||C(n.href)},ne=()=>M(async()=>{let e=a??(await ee())?.address;if(!e)throw Error(`Address unavailable. Try republishing the app.`);await te(e,!0)});return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{className:`btn sm ghost`,disabled:o,onClick:()=>d(!0),"aria-label":`Share ${r}`,children:[(0,G.jsx)(dt,{size:15}),`Share`]}),u&&(0,G.jsxs)(ot,{title:`Share ${r}`,onClose:()=>{d(!1),_(!1),y(``),x(``),C(``)},autoFocusSearch:!1,headExtra:(0,G.jsx)(vr,{label:`Sharing options`,items:[{label:`Copy personal address`,disabled:f||!a&&!l,onSelect:()=>void ne()},{label:`Revoke all access…`,danger:!0,separated:!0,disabled:f||!l||o,onSelect:()=>h(!0)}]}),children:[(0,G.jsxs)(`div`,{className:`apps-sheet`,children:[(0,G.jsx)(Er,{feature:`sharing`}),E&&(0,G.jsxs)(`div`,{className:`banner`,"data-tone":`accent`,children:[(0,G.jsxs)(`span`,{className:`banner-text`,role:`status`,children:[`Shared · `,E.links===1?`1 link`:`${E.links} links`,` until `,kr(E.expiresAt)]}),(0,G.jsx)(`span`,{className:`banner-actions`,children:(0,G.jsx)(`button`,{className:`btn sm danger-ghost`,disabled:f||!l,onClick:()=>k(!0),children:`Stop sharing`})})]}),(0,G.jsxs)(`div`,{className:`apps-group`,children:[(0,G.jsx)(`p`,{className:`apps-group-title`,id:`share-for-${n}`,children:`Link works for`}),(0,G.jsx)(`div`,{className:`segmented`,role:`radiogroup`,"aria-labelledby":`share-for-${n}`,children:re.map(e=>(0,G.jsx)(`button`,{type:`button`,role:`radio`,className:`seg-btn`,"aria-checked":w.duration===e.id,onClick:()=>A({duration:e.id}),children:e.label},e.id))})]}),(0,G.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,G.jsxs)(`div`,{className:`settings-toggle-text`,children:[(0,G.jsx)(`span`,{className:`settings-toggle-title`,children:`Feedback tools`}),(0,G.jsx)(`span`,{className:`muted small`,children:w.controls?`People can point, draw and leave you notes.`:`People see only the app.`})]}),(0,G.jsx)(yr,{checked:w.controls,onChange:e=>A({controls:e}),label:`Feedback tools`})]}),(0,G.jsx)(`p`,{className:`apps-foot`,children:`Anyone with the link can use this app, including its live backend, until it expires or you stop sharing.`}),(0,G.jsxs)(`button`,{className:`btn primary`,disabled:f||!l||o,"aria-label":`Copy share link`,onClick:()=>void M(async()=>{let r=await R.appCommand(`apps.share`,e,{appId:t,viewId:n,duration:w.duration,controls:w.controls},i);await te(r.url),j()}),children:[g?(0,G.jsx)(at,{size:16}):(0,G.jsx)(dt,{size:16}),(0,G.jsx)(`span`,{role:`status`,children:f?`Preparing…`:g?`Copied`:`Copy link`})]}),b&&(0,G.jsx)(`p`,{className:`apps-foot`,role:`alert`,children:b}),v&&(0,G.jsx)(`p`,{className:`apps-foot`,role:`status`,children:v}),S&&(0,G.jsx)(`input`,{className:`field`,readOnly:!0,value:S,"aria-label":`Link to ${r}`,onFocus:e=>e.currentTarget.select()})]}),O&&(0,G.jsx)(Ye,{title:`Stop sharing?`,message:`Every share link stops working, and people who have the app open lose it. Your own previews keep working.`,confirmLabel:`Stop sharing`,danger:!0,onCancel:()=>k(!1),onConfirm:()=>{k(!1),M(async()=>{await R.appCommand(`apps.unshare`,e,{appId:t,viewId:n},i),D(null),y(`Sharing stopped.`)})}}),m&&(0,G.jsx)(Ye,{title:`Revoke all access?`,message:`Share links and every open preview, including yours, stop working. The app stays available.`,confirmLabel:`Revoke access`,danger:!0,onCancel:()=>h(!1),onConfirm:()=>{h(!1),M(async()=>{await R.appCommand(`apps.revoke`,e,{appId:t,viewId:n},i),D(null),y(`Access revoked.`),s?.()})}})]})]})}var jr=`Picture: retaken on the machine, so it may not show this page’s state (a cart, a sign-in, an open menu). The marks and elements are exact.`,Mr=`bivy.previewPeekBlocked`,Nr=6048e5;function Pr(){try{let e=JSON.parse(localStorage.getItem(Mr)??`null`);return e?.agent===navigator.userAgent&&typeof e.at==`number`&&Date.now()-e.at<Nr}catch{return!1}}function Fr(){try{localStorage.setItem(Mr,JSON.stringify({agent:navigator.userAgent,at:Date.now()}))}catch{}}function Ir({url:e,name:t,sessionId:n,appId:r,viewId:i,onClose:a,onOpenInTab:o,access:s,onManage:c,revoked:l,docked:u}){let f=(0,W.useRef)(null),[p,m]=(0,W.useState)(!1),{settings:{sttConfig:h}}=Me(),g=vt(h),[_,v]=(0,W.useState)(null),y=new URL(e).origin,[b,x]=(0,W.useState)(null),S=(0,W.useCallback)(e=>{f.current?.contentWindow?.postMessage({source:`bivy`,...e},y)},[y]),C=!!(r&&i),w=(0,W.useCallback)(()=>{S({type:`voice`,available:!!g}),S({type:`draw`,available:C})},[g,C,S]);(0,W.useEffect)(()=>{w()},[w]);let T=(0,W.useCallback)((e,t=[],o=!1)=>{R.prefillComposer(e,t)||d(localStorage,n,e),o&&r&&i&&R.stagePin({sessionId:n,appId:r,viewId:i,context:e.trim().slice(-80)}),x(null),a()},[n,r,i,a]),E=(0,W.useCallback)(async(e,t)=>{if(!r||!i)return T(e);x({state:`working`});try{let a=await R.appCommand(`apps.annotate`,n,{appId:r,viewId:i,...t});if(a.screenshotsOff||!a.image){x({state:`off`,text:e,mark:t});return}let o=a.image,s={kind:`image`,mimeType:o.mimeType,data:o.data,size:Math.round(o.data.length*3/4),name:a.approximate?o.name.replace(/\.png$/,` (approximate).png`):o.name};T(a.approximate?`${e}\n${jr}`:e,[s],!0)}catch(n){x({state:`failed`,text:e,mark:t,message:n instanceof Error?n.message:`Couldn’t take the picture.`})}},[r,i,n,T]),D=async(e,t)=>{x({state:`working`});try{await R.setNodeSettings({appScreenshots:!0}),await E(e,t)}catch(n){x({state:`failed`,text:e,mark:t,message:n instanceof Error?n.message:`Couldn’t turn on screenshots.`})}};return(0,W.useEffect)(()=>{let e=e=>{if(e.origin!==y||e.source!==f.current?.contentWindow)return;let t=e.data;if(t?.source===`bivy-preview`){if(t.type===`draft`&&typeof t.text==`string`){let e=t.text.slice(0,8e3);R.prefillComposer(e)||d(localStorage,n,e),a()}else t.type===`blocked`?(Fr(),m(!0)):t.type===`hello`?w():t.type===`annotation`&&typeof t.text==`string`&&t.mark?E(t.text.slice(0,8e3),t.mark):t.type===`listen`&&(t.state===`start`?g?v(e=>e??{stop:0}):S({type:`transcript`,error:mt}):t.state===`stop`?v(e=>e&&{stop:e.stop+1}):t.state===`cancel`&&v(null))}};return addEventListener(`message`,e),()=>removeEventListener(`message`,e)},[y,n,a,g,S,w,E]),(0,G.jsx)(_r,{docked:u,title:t,ariaLabel:`Preview: ${t}`,onClose:a,size:`full`,autoFocusSearch:!1,headExtra:(0,G.jsxs)(`div`,{className:`preview-head-actions`,children:[(0,G.jsx)(`button`,{className:`btn ghost icon`,onClick:o,"aria-label":`Open in tab ↗`,title:`Open in tab · Only you`,children:(0,G.jsx)(`span`,{"aria-hidden":!0,children:`↗`})}),s,c&&(0,G.jsx)(`button`,{className:`btn ghost icon`,onClick:c,"aria-label":`App options`,title:`App options`,children:(0,G.jsx)(ut,{size:18})})]}),children:l?(0,G.jsx)(`div`,{className:`changes-binary`,role:`status`,children:`Access revoked. Open a new preview to continue.`}):p?(0,G.jsxs)(`div`,{className:`changes-binary`,role:`status`,children:[`This browser doesn’t allow app previews inside Bivy, so previews will open in a tab on this device. `,(0,G.jsx)(`button`,{className:`btn sm`,onClick:o,children:`Open in tab ↗`})]}):(0,G.jsxs)(`div`,{className:`preview-peek-stage`,children:[_&&g&&(0,G.jsx)(`div`,{className:`preview-voice`,children:(0,G.jsx)(wt,{engine:g,stop:_.stop,onResult:e=>S({type:`transcript`,text:e.slice(0,4e3)}),onCancel:()=>{v(null),S({type:`listening`,on:!1})},onError:e=>S({type:`transcript`,error:e})})}),(0,G.jsx)(`iframe`,{ref:f,className:`preview-peek`,src:e,title:t,referrerPolicy:`no-referrer`,sandbox:`allow-scripts allow-same-origin allow-forms allow-downloads allow-popups`,allow:`clipboard-read; clipboard-write`,onLoad:w}),b&&(0,G.jsx)(`div`,{className:`preview-marking`,role:b.state===`working`?`status`:`alert`,children:b.state===`working`?(0,G.jsxs)(`div`,{className:`banner inline`,"data-tone":`neutral`,children:[(0,G.jsx)(V,{size:`sm`}),(0,G.jsx)(`span`,{className:`banner-text`,children:`Adding a picture of what you marked…`})]}):(0,G.jsxs)(`div`,{className:`banner inline`,"data-tone":b.state===`off`?`neutral`:`danger`,children:[(0,G.jsx)(`span`,{className:`banner-text`,children:b.state===`off`?`Screenshots are off on this machine, so there’s no picture. Your marks and the elements you marked still go with your words.`:`Couldn’t add the picture: ${b.message}`}),(0,G.jsxs)(`span`,{className:`banner-actions`,children:[b.state===`off`?(0,G.jsx)(`button`,{className:`btn primary`,onClick:()=>void D(b.text,b.mark),children:`Turn on and add picture`}):(0,G.jsx)(`button`,{className:`btn`,onClick:()=>void E(b.text,b.mark),children:`Try again`}),(0,G.jsx)(`button`,{className:`btn ghost`,onClick:()=>T(b.text,[],!0),children:`Add without picture`})]})]})})]})})}var Lr=e=>`bivy:notes-seen:${e}`,Rr=`bivy:notes-seen`;function zr(e){return Number(localStorage.getItem(Lr(e)))||0}function Br(e,t){t<=zr(e)||(localStorage.setItem(Lr(e),String(t)),window.dispatchEvent(new CustomEvent(Rr,{detail:e})))}function Vr(e,t){let[n,r]=(0,W.useState)(()=>e?zr(e):0);return(0,W.useEffect)(()=>{if(!e)return;r(zr(e));let t=t=>{t.detail===e&&r(zr(e))};return window.addEventListener(Rr,t),()=>window.removeEventListener(Rr,t)},[e]),t.filter(e=>e>n).length}function Hr(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Ur(e,t){try{let n=atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return URL.createObjectURL(new Blob([r],{type:t||`application/octet-stream`}))}catch{return null}}function Wr(e){let t=(0,W.useMemo)(()=>{if(!e||e.omitted)return null;if(e.data)return Ur(e.data,e.mimeType);if(e.text!==void 0)try{return URL.createObjectURL(new Blob([e.text],{type:e.mimeType||`text/plain`}))}catch{return null}return null},[e]);(0,W.useEffect)(()=>()=>{t&&URL.revokeObjectURL(t)},[t]);let[n,r]=(0,W.useState)(null);return(0,W.useEffect)(()=>{if(r(null),t||!e||e.omitted||!e.hash)return;let n=e.mimeType,i=!1,a=null;return R.fetchAttachment(e.hash,e.createdAt).then(e=>{!i&&e&&(a=Ur(e.data,e.mimeType||n),a&&r(a))}),()=>{i=!0,a&&URL.revokeObjectURL(a)}},[t,e]),t??n}function Gr(e){let[t,n]=(0,W.useState)({state:`loading`}),r=e?.hash,i=e?.size??0;return(0,W.useEffect)(()=>{if(n({state:`loading`}),!r)return;if(i>524288){n({state:`error`,reason:`This file is ${Hr(i)} — too large to show here.`});return}let e=!1;return R.fetchAttachment(r).then(t=>{if(!e){if(!t){n({state:`error`,reason:`This file could not be read.`});return}try{let e=atob(t.data),r=Uint8Array.from(e,e=>e.charCodeAt(0));n({state:`ready`,text:new TextDecoder().decode(r)})}catch{n({state:`error`,reason:`This file could not be read as text.`})}}}),()=>{e=!0}},[r,i]),t}function Kr({images:e,index:t,onClose:n}){let[r,i]=(0,W.useState)(t),a=e.length;(0,W.useEffect)(()=>i(t),[t]);let o=(0,W.useCallback)(e=>i(t=>a?(t+e+a)%a:0),[a]),s=e[r],c=Wr(s);return(0,G.jsx)(xt,{src:c,name:s?.name??`Image`,current:r,count:a,onNavigate:o,onClose:n},`${r}:${c}`)}function qr(e){return e.flatMap(e=>e.shot?[{kind:`image`,name:`Reviewer note (approximate).png`,mimeType:`image/png`,hash:e.shot.hash,size:e.shot.size,createdAt:e.at,description:`Retaken on the machine; may differ from the reviewer's browser.`}]:[])}async function Jr(e){return Promise.all(qr(e).map(async e=>{let t=await R.fetchAttachment(e.hash,e.createdAt);if(!t)throw Error(`A reviewer picture is no longer available. The notes have not been added.`);return{...e,...t}}))}function Yr(e){return e.trim().charAt(0).toUpperCase()||`A`}function Xr({tile:e,name:t,meta:n,detail:r,action:i,small:a=!1}){return(0,G.jsxs)(`div`,{className:`app-row${a?` small`:``}`,children:[(0,G.jsx)(`span`,{className:`app-tile`,"aria-hidden":!0,children:e}),(0,G.jsxs)(`div`,{className:`app-row-text`,children:[(0,G.jsx)(`strong`,{className:`app-row-name`,children:t}),n&&(0,G.jsx)(`span`,{className:`app-row-meta`,children:n}),r]}),i&&(0,G.jsx)(`div`,{className:`app-row-action`,children:i})]})}function Zr({sessionId:e,nodeId:t,app:n,view:r,item:i,docked:a,online:o,onBack:s,onClose:c,onDraft:l}){let u=async(i,a={})=>await R.appCommand(i,e,{appId:n.id,viewId:r.id,...a},t),d=Qr[r.backend],[f,p]=(0,W.useState)(null);return(0,G.jsx)(_r,{docked:a,title:r.name,ariaLabel:`${n.name}: ${r.name}`,onClose:c,autoFocusSearch:!1,size:`large`,children:(0,G.jsxs)(`div`,{className:`backend-view`,children:[(0,G.jsxs)(`div`,{className:`backend-toolbar`,children:[(0,G.jsxs)(`button`,{className:`btn sm ghost backend-back`,onClick:f?f.back:s,children:[`‹ `,f?f.label:`Apps`]}),(0,G.jsxs)(`span`,{className:`backend-source`,children:[n.name,` · `,r.detail]})]}),(0,G.jsx)(d,{ask:u,item:i,online:o,onDraft:l,app:n,setBack:p})]})})}var Qr={requests:oi,data:li,logs:_i},$r=e=>{let t=At(e);return t===`now`?`just now`:`${t} ago`},ei=(e,t)=>e instanceof Error?e.message:t,ti=e=>e?e.error||e.status>=500?`danger`:e.status>=400?`warn`:`ok`:void 0,ni=e=>e.error?`No answer`:String(e.status);function ri({value:e,options:t,onChange:n,label:r}){return(0,G.jsx)(`div`,{className:`segmented backend-switch`,role:`radiogroup`,"aria-label":r,children:t.map(t=>(0,G.jsx)(`button`,{type:`button`,role:`radio`,className:`seg-btn`,"aria-checked":e===t.id,disabled:t.disabled,onClick:()=>n(t.id),children:t.label},t.id))})}function ii({changes:e,empty:t}){return e.length?(0,G.jsx)(`ul`,{className:`backend-changes`,children:e.map(e=>(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`backend-path`,children:e.path}),e.before!==void 0&&(0,G.jsxs)(`span`,{className:`backend-was`,children:[(0,G.jsx)(`span`,{className:`sr-only`,children:`was `}),e.before]}),e.after===void 0?(0,G.jsx)(`span`,{className:`backend-gone`,children:`removed`}):(0,G.jsxs)(`span`,{className:`backend-now`,children:[(0,G.jsx)(`span`,{className:`sr-only`,children:`now `}),e.after]})]},e.path))}):(0,G.jsx)(`p`,{className:`backend-empty`,children:t})}function ai(e){if(e.error)return e.error;if(e.json)try{return JSON.stringify(JSON.parse(e.body),null,2)}catch{}return e.body||`(empty body)`}function oi({ask:e,item:t,online:n,onDraft:r,setBack:i}){let[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(t),[l,u]=(0,W.useState)(null),[d,f]=(0,W.useState)(``),[p,m]=(0,W.useState)(``),h=()=>e(`apps.requests`).then(o,e=>f(ei(e,`Could not read the requests.`)));(0,W.useEffect)(()=>{h()},[]),(0,W.useEffect)(()=>(i(s?{label:`Requests`,back:()=>{c(void 0),h()}}:null),()=>i(null)),[s]);let g=async()=>{u(`all`),f(``);try{o(await e(`apps.runRequest`))}catch(e){f(ei(e,`Could not run the requests.`))}finally{u(null)}},_=a?.scenarios??[],v=_.length>0&&(0,G.jsxs)(`label`,{className:`backend-scenario`,children:[(0,G.jsx)(`span`,{children:`Run in`}),(0,G.jsxs)(`select`,{className:`field`,value:p,onChange:e=>m(e.target.value),children:[(0,G.jsx)(`option`,{value:``,children:`Your data (the real server)`}),_.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),y=_.find(e=>e.id===p);if(s)return(0,G.jsxs)(G.Fragment,{children:[v,y&&(0,G.jsxs)(`p`,{className:`backend-meta`,children:[`Simulates `,y.simulated,`; other requests reach the server.`]}),(0,G.jsx)(ci,{ask:e,id:s,online:n,onDraft:r,scenario:p})]});if(!a)return d?(0,G.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,role:`alert`,children:d}):(0,G.jsxs)(`div`,{className:`apps-state`,role:`status`,children:[(0,G.jsx)(V,{size:`sm`}),(0,G.jsx)(`span`,{children:`Reading requests…`})]});let b=[...new Set(a.requests.map(e=>e.file))];return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`backend-toolbar`,children:[(0,G.jsx)(`span`,{className:`backend-meta`,children:a.base?(0,G.jsxs)(G.Fragment,{children:[`Against `,(0,G.jsx)(`code`,{children:a.base})]}):`No server for {{base}}: give the view a base`}),(0,G.jsxs)(`button`,{className:`btn sm`,disabled:!n||l!==null||!a.requests.some(e=>e.auto),onClick:()=>void g(),children:[l===`all`?(0,G.jsx)(V,{size:`xs`}):null,`Run all`]})]}),v,d&&(0,G.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,role:`alert`,children:d}),a.problems.map(e=>(0,G.jsx)(`div`,{className:`banner inline`,"data-tone":`warn`,role:`status`,children:(0,G.jsxs)(`span`,{className:`banner-text`,children:[(0,G.jsx)(`code`,{children:e.file}),` `,e.error]})},e.file)),!a.requests.length&&!a.problems.length&&(0,G.jsxs)(`div`,{className:`apps-empty`,children:[(0,G.jsx)(`strong`,{children:`No requests yet`}),(0,G.jsxs)(`p`,{children:[`Requests are `,(0,G.jsx)(`code`,{children:`.http`}),` files in `,(0,G.jsx)(`code`,{children:`.bivy/requests`}),`, like `,(0,G.jsxs)(`code`,{children:[`GET `,`{{base}}`,`/orders`]}),`. Ask the agent to add the ones that show what it changed.`]})]}),b.map(e=>(0,G.jsxs)(`section`,{className:`backend-group`,"aria-label":e,children:[(0,G.jsx)(`h3`,{className:`apps-group-title`,children:e}),(0,G.jsx)(`ul`,{className:`backend-list`,children:a.requests.filter(t=>t.file===e).map(e=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,className:`backend-row`,onClick:()=>c(e.id),children:[(0,G.jsx)(`span`,{className:`backend-method`,"data-method":e.method,children:e.method}),(0,G.jsxs)(`span`,{className:`backend-row-text`,children:[(0,G.jsx)(`span`,{className:`backend-row-name`,children:e.name}),(0,G.jsx)(`code`,{className:`backend-row-sub`,children:e.url.replace(a.base,``)||`/`})]}),e.external&&(0,G.jsxs)(`span`,{className:`badge`,"data-tone":`warn`,title:`Not this app's server`,children:[`→ `,e.external]}),(0,G.jsx)(si,{request:e})]})},e.id))})]},e)),a.requests.length>0&&(0,G.jsxs)(`p`,{className:`backend-foot`,children:[`GET requests to this app, and those marked `,(0,G.jsx)(`code`,{children:`# @auto`}),`, run before and after each agent run. Others run only when you tap them.`]})]})}function si({request:e}){if(!e.last)return(0,G.jsx)(`span`,{className:`badge`,children:e.auto?`not run yet`:`runs on tap`});if(e.last.simulated)return(0,G.jsxs)(`span`,{className:`badge`,"data-tone":`accent`,children:[ni(e.last),` · simulated`]});let t=e.before&&(e.before.status!==e.last.status||!!e.before.error!=!!e.last.error);return(0,G.jsx)(`span`,{className:`badge`,"data-tone":t?`warn`:ti(e.last),children:t?`${ni(e.before)} → ${ni(e.last)}`:ni(e.last)})}function ci({ask:e,id:t,online:n,onDraft:r,scenario:i}){let[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(`now`),[l,u]=(0,W.useState)(!1),[d,f]=(0,W.useState)(``),[p,m]=(0,W.useState)(!1);(0,W.useEffect)(()=>{e(`apps.request`,{id:t}).then(e=>{o(e),e.changes?.length&&c(`changes`)},e=>f(ei(e,`Could not read the request.`)))},[t]);let h=async()=>{m(!1),u(!0),f(``);try{let n=await e(`apps.runRequest`,{id:t,...i?{scenario:i}:{}});o(n),c(n.changes?.length?`changes`:`now`)}catch(e){f(ei(e,`Could not run the request.`))}finally{u(!1)}};if(!a)return(0,G.jsx)(G.Fragment,{children:d?(0,G.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,role:`alert`,children:d}):(0,G.jsxs)(`div`,{className:`apps-state`,role:`status`,children:[(0,G.jsx)(V,{size:`sm`}),(0,G.jsx)(`span`,{children:`Reading…`})]})});let{item:g,request:_}=a,v=s===`before`?g.before:g.last,y=()=>r(`The request “${g.name}” (${g.method} ${g.url}, .bivy/requests/${g.file})${g.last?.scenario?` in the scenario “${g.last.scenario}”`:``} ${g.last?`answered ${ni(g.last)}${g.before?` (it answered ${ni(g.before)} before your last run)`:``}`:`hasn't run yet`}:\n\n${g.last?ai(g.last).slice(0,3e3):``}\n\nWhat should it answer?`);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`backend-detail-head`,children:[(0,G.jsx)(`span`,{className:`backend-method`,"data-method":g.method,children:g.method}),(0,G.jsxs)(`span`,{className:`backend-row-text`,children:[(0,G.jsx)(`span`,{className:`backend-row-name`,children:g.name}),(0,G.jsx)(`code`,{className:`backend-row-sub`,children:g.url})]})]}),d&&(0,G.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,role:`alert`,children:d}),g.last?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`backend-status`,children:[(0,G.jsx)(`span`,{className:`badge`,"data-tone":ti(g.last),children:g.last.error?`No answer`:`${g.last.status} ${g.last.statusText}`.trim()}),g.before&&!g.last.simulated&&g.before.status!==g.last.status&&(0,G.jsxs)(`span`,{className:`backend-meta`,children:[`was `,ni(g.before)]}),(0,G.jsxs)(`span`,{className:`backend-meta`,children:[g.last.ms,` ms · `,$r(g.last.at)]}),g.last.scenario&&(0,G.jsx)(`span`,{className:`badge`,"data-tone":`accent`,children:g.last.simulated?`Simulated by “${g.last.scenario}”`:`In “${g.last.scenario}”`})]}),(0,G.jsx)(ri,{label:`Show the answer`,value:s,onChange:c,options:[{id:`before`,label:`Before`,disabled:!g.before},{id:`now`,label:`Now`},{id:`changes`,label:`Changes`,disabled:!a.changes}]}),s===`changes`?(0,G.jsx)(ii,{changes:a.changes??[],empty:`The same answer as before the agent's last run.`}):v?(0,G.jsxs)(`pre`,{className:`backend-body`,children:[ai(v),v.truncated?`
|
|
4
4
|
… (cut at 1 MB)`:``]}):null]}):(0,G.jsx)(`p`,{className:`backend-empty`,children:`Not run yet.`}),(0,G.jsxs)(`details`,{className:`backend-request`,children:[(0,G.jsx)(`summary`,{children:`Request`}),(0,G.jsx)(`pre`,{className:`backend-body`,children:[`${_.method} ${_.url}`,..._.headers.map(([e,t])=>`${e}: ${t}`),..._.body?[``,_.body]:[]].join(`
|
|
5
5
|
`)})]}),(0,G.jsxs)(`div`,{className:`backend-actions`,children:[(0,G.jsx)(`button`,{className:`btn ghost`,disabled:!g.last,onClick:y,children:`Send to agent…`}),(0,G.jsxs)(`button`,{className:`btn primary`,disabled:!n||l,onClick:()=>g.auto?void h():m(!0),children:[l?(0,G.jsx)(V,{size:`xs`}):null,g.last?`Run again`:`Run`]})]}),p&&(0,G.jsx)(Ye,{title:`Run ${g.method} ${g.name}?`,message:`This sends ${g.method} ${g.url} from this machine. It may change data${g.external?` on ${g.external}, which isn't this app's server`:``}.`,confirmLabel:`Run it`,danger:!!g.external,onCancel:()=>m(!1),onConfirm:()=>void h()})]})}function li({ask:e,item:t,online:n}){let[r,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(``),l=async t=>{o(!0),c(``);try{i(await e(`apps.data`,t?{run:t}:{}))}catch(e){c(ei(e,`Could not run the queries.`))}finally{o(!1)}};return(0,W.useEffect)(()=>{l(!1)},[]),r?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`backend-toolbar`,children:[(0,G.jsx)(`span`,{className:`backend-meta`,children:r.queries.length===1?`1 saved query`:`${r.queries.length} saved queries`}),(0,G.jsxs)(`button`,{className:`btn sm`,disabled:!n||a,onClick:()=>void l(!0),children:[a?(0,G.jsx)(V,{size:`xs`}):null,`Run again`]})]}),s&&(0,G.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,role:`alert`,children:s}),r.problems.map(e=>(0,G.jsx)(`div`,{className:`banner inline`,"data-tone":`warn`,role:`status`,children:(0,G.jsxs)(`span`,{className:`banner-text`,children:[(0,G.jsx)(`code`,{children:e.file}),` `,e.error]})},e.file)),!r.queries.length&&(0,G.jsxs)(`div`,{className:`apps-empty`,children:[(0,G.jsx)(`strong`,{children:`No saved queries yet`}),(0,G.jsxs)(`p`,{children:[`Queries are `,(0,G.jsx)(`code`,{children:`.sql`}),` files in `,(0,G.jsx)(`code`,{children:`.bivy/queries`}),`. Start one with `,(0,G.jsx)(`code`,{children:`-- key: id`}),` so changed rows can be matched. Ask the agent to add the ones that show what it changed.`]})]}),r.queries.map(e=>(0,G.jsx)(di,{query:e,focused:e.id===t},e.id))]}):s?(0,G.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,role:`alert`,children:s}):(0,G.jsxs)(`div`,{className:`apps-state`,role:`status`,children:[(0,G.jsx)(V,{size:`sm`}),(0,G.jsx)(`span`,{children:`Running queries…`})]})}var ui=e=>e.added.length+e.changed.length+e.removed.length;function di({query:e,focused:t}){let n=e.changes?ui(e.changes):0,[r,i]=(0,W.useState)(e.changes?`changes`:`now`),a=(0,W.useRef)(null);return(0,W.useEffect)(()=>{t&&a.current?.scrollIntoView({block:`start`})},[t]),(0,G.jsxs)(`section`,{ref:a,className:`backend-query`,"aria-label":e.title,children:[(0,G.jsxs)(`div`,{className:`backend-query-head`,children:[(0,G.jsx)(`h3`,{children:e.title}),n>0&&e.changes&&(0,G.jsxs)(`span`,{className:`backend-counts`,"aria-label":`${e.changes.added.length} added, ${e.changes.changed.length} changed, ${e.changes.removed.length} removed since the agent's last run began`,children:[e.changes.added.length>0&&(0,G.jsxs)(`span`,{"data-tone":`ok`,children:[`+`,e.changes.added.length,` `]}),e.changes.changed.length>0&&(0,G.jsxs)(`span`,{"data-tone":`warn`,children:[`~`,e.changes.changed.length,` `]}),e.changes.removed.length>0&&(0,G.jsxs)(`span`,{"data-tone":`danger`,children:[`−`,e.changes.removed.length]})]})]}),e.error?(0,G.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,role:`alert`,children:(0,G.jsx)(`span`,{className:`banner-text`,children:e.error})}):(0,G.jsxs)(G.Fragment,{children:[e.changes&&(0,G.jsx)(ri,{label:`Show ${e.title}`,value:r,onChange:i,options:[{id:`changes`,label:`Changes`},{id:`now`,label:`Now`}]}),r===`changes`&&e.changes?n?(0,G.jsx)(`ul`,{className:`backend-list`,children:[...e.changes.added.map(t=>(0,G.jsx)(pi,{kind:`added`,row:t,keyName:e.key},`+${t.key}`)),...e.changes.changed.map(t=>(0,G.jsx)(pi,{kind:`changed`,row:t,keyName:e.key},`~${t.key}`)),...e.changes.removed.map(t=>(0,G.jsx)(pi,{kind:`removed`,row:t,keyName:e.key},`-${t.key}`))]}):(0,G.jsxs)(`p`,{className:`backend-empty`,children:[`No changes · `,e.count,` `,e.count===1?`row`:`rows`]}):(0,G.jsx)(mi,{query:e})]}),(0,G.jsxs)(`p`,{className:`backend-foot`,children:[(0,G.jsx)(`code`,{children:e.file}),`, keyed by `,(0,G.jsx)(`code`,{children:e.key}),e.at?` · ran ${$r(e.at)}`:``]})]})}var fi={added:`Added`,changed:`Changed`,removed:`Removed`};function pi({kind:e,row:t,keyName:n}){let r=e===`changed`?t.fields??[]:Object.entries(t.row).filter(([e])=>e!==n).map(([e,t])=>({path:e,after:t}));return(0,G.jsxs)(`li`,{className:`backend-rowcard`,"data-kind":e,children:[(0,G.jsxs)(`span`,{className:`backend-row-name`,children:[(0,G.jsxs)(`span`,{className:`sr-only`,children:[fi[e],`: `]}),t.key]}),(0,G.jsx)(`dl`,{className:`backend-fields`,children:r.slice(0,12).map(t=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:t.path}),(0,G.jsxs)(`dd`,{children:[e===`changed`&&t.before!==void 0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`s`,{className:`backend-was`,children:t.before}),` `]}),e===`removed`?(0,G.jsx)(`s`,{children:t.after}):t.after]})]},t.path))})]})}function mi({query:e}){return e.rows.length?(0,G.jsxs)(`div`,{className:`backend-table-wrap`,children:[(0,G.jsxs)(`table`,{className:`backend-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsx)(`tr`,{children:e.columns.map(e=>(0,G.jsx)(`th`,{scope:`col`,children:e},e))})}),(0,G.jsx)(`tbody`,{children:e.rows.map((t,n)=>(0,G.jsx)(`tr`,{children:e.columns.map(e=>(0,G.jsx)(`td`,{children:t[e]},e))},t[e.key]??n))})]}),e.count>e.rows.length&&(0,G.jsxs)(`p`,{className:`backend-foot`,children:[`Showing `,e.rows.length,` of `,e.count,` rows.`]})]}):(0,G.jsx)(`p`,{className:`backend-empty`,children:`No rows.`})}var hi=2e3,gi=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`});function _i({ask:e,onDraft:t,app:n}){let[r,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(`all`),[s,c]=(0,W.useState)(``),l=(0,W.useRef)(!1),u=(0,W.useRef)(null);if((0,W.useEffect)(()=>{let t=!0,n,r=async()=>{try{let n=await e(`apps.serverLog`);t&&(i(n),c(``))}catch(e){t&&c(ei(e,`Could not read the logs.`))}t&&(n=setTimeout(()=>void r(),hi))};return r(),()=>{t=!1,clearTimeout(n)}},[]),(0,W.useEffect)(()=>{r&&!l.current&&u.current&&(l.current=!0,u.current.scrollIntoView({block:`start`}))},[r]),!r)return s?(0,G.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,role:`alert`,children:s}):(0,G.jsxs)(`div`,{className:`apps-state`,role:`status`,children:[(0,G.jsx)(V,{size:`sm`}),(0,G.jsx)(`span`,{children:`Reading logs…`})]});let d=r.marks.at(-1),f=r.lines.filter(e=>!d||e.at>=d.at),p=f.filter(e=>e.level===`error`),m=[...r.lines.filter(e=>a===`all`||e.level===`error`).map(e=>({line:e})),...r.marks.map(e=>({mark:e}))].sort((e,t)=>(`mark`in e?e.mark.at-.5:e.line.at)-(`mark`in t?t.mark.at-.5:t.line.at));return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`backend-toolbar`,children:[(0,G.jsx)(ri,{label:`Show`,value:a,onChange:o,options:[{id:`all`,label:`All`},{id:`errors`,label:`Errors${r.lines.some(e=>e.level===`error`)?` (${r.lines.filter(e=>e.level===`error`).length})`:``}`}]}),!r.running&&(0,G.jsx)(`span`,{className:`badge`,"data-tone":`warn`,children:`Not running`})]}),s&&(0,G.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,role:`alert`,children:s}),!r.lines.length&&(0,G.jsx)(`p`,{className:`backend-empty`,children:r.running?`Nothing logged yet. Use the app, or run a request, and its output shows here.`:`The server isn't running, so there's nothing to show. Open the app's preview to start it.`}),(0,G.jsx)(`ol`,{className:`backend-log`,"aria-label":`Log`,children:m.map((e,t)=>`mark`in e?(0,G.jsxs)(`li`,{ref:e.mark===d?u:void 0,className:`backend-mark`,children:[e.mark===d?`Your last action`:`Action`,` · `,e.mark.label,` · `,gi(e.mark.at)]},`m${e.mark.at}`):(0,G.jsxs)(`li`,{className:`backend-line`,"data-level":e.line.level,children:[e.line.level===`error`&&(0,G.jsx)(`span`,{className:`badge`,"data-tone":`danger`,children:`error`}),(0,G.jsx)(`span`,{className:`backend-line-time`,children:gi(e.line.at)}),` `,e.line.text]},t))}),(0,G.jsx)(`div`,{className:`backend-actions`,children:(0,G.jsx)(`button`,{className:`btn${p.length?` primary`:``}`,disabled:!f.length,onClick:()=>t(`${n.name}'s server logged ${p.length===1?`an error`:`${p.length} errors`}${d?` after “${d.label}” (${gi(d.at)})`:``}:\n\n${f.slice(-40).map(e=>e.text).join(`
|
|
6
|
-
`)}\n\nPlease find the cause and fix it.`),children:p.length?`Send ${p.length===1?`error`:`errors`} to agent…`:`Send to agent…`})})]})}var vi=(0,W.lazy)(()=>C(()=>import(`./Terminal-
|
|
6
|
+
`)}\n\nPlease find the cause and fix it.`),children:p.length?`Send ${p.length===1?`error`:`errors`} to agent…`:`Send to agent…`})})]})}var vi=(0,W.lazy)(()=>C(()=>import(`./Terminal-DrqMIIhr.js`).then(e=>({default:e.TerminalOverlay})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),yi=()=>{},bi={terminal:`Terminal · starts when opened`,static:`Snapshot · refreshed after each turn`,service:`Live server`,managed:`Live server · run by Bivy`,display:`Desktop app · own display`},xi={requests:`Requests · the API as buttons`,data:`Data · rows from saved queries`,logs:`Logs · the server's output`},Si={requests:`Open requests`,data:`Open data`,logs:`Open logs`},Ci={ready:`When ready`,every:`Every change`,off:`Off`};function wi(e,t){return`Notes from people reviewing "${e}":\n`+t.map(e=>`- "${e.note}" on ${e.selector}${e.text?` ("${e.text}")`:``}, page ${e.path}, viewport ${e.viewport.width}×${e.viewport.height}${e.context?`\n${e.context}`:``}${e.shot?`
|
|
7
7
|
Attached picture is approximate: retaken on the machine, not the reviewer’s browser.`:``}`).join(`
|
|
8
8
|
`)}function Ti({sessionId:e,appId:t,nodeId:n,openView:r,onOpenInChat:i,onClose:a,docked:o}){let s=o?yi:a,{connection:c,activeSession:l}=Me(),[f,p]=(0,W.useState)(null),m=!!n&&!R.direct&&n!==c.currentNodeId,h=m?n:c.currentNodeId,[g,_]=(0,W.useState)(null),[v,y]=(0,W.useState)([]),[b,x]=(0,W.useState)(``),[S,C]=(0,W.useState)(!1),[w,T]=(0,W.useState)(0),[E,D]=(0,W.useState)(null),[O,k]=(0,W.useState)(null),[A,ee]=(0,W.useState)(null),[j,M]=(0,W.useState)(!1),[te,ne]=(0,W.useState)(null),[re,ie]=(0,W.useState)(null),N=(0,W.useRef)(0),P=m||c.status===`online`;(0,W.useEffect)(()=>{D(null)},[e,c.currentNodeId]),(0,W.useEffect)(()=>{let r=++N.current;return C(!0),x(``),_(null),ne(null),ie(null),y([]),t||R.appCommand(`apps.offers`,e,{},n).then(e=>{N.current===r&&y(e.offers??[])},()=>{}),R.appCommand(`apps.list`,e,{},n).then(e=>{N.current===r&&_(e)}).catch(e=>{N.current===r&&x(e instanceof Error?e.message:`Could not load apps.`)}).finally(()=>{N.current===r&&C(!1)}),()=>{N.current=r+1}},[e,h,P,w,n,t]),(0,W.useEffect)(()=>R.onAppsChanged(t=>{if(t!==e)return;let r=N.current;R.appCommand(`apps.list`,e,{},n).then(e=>{N.current===r&&_(e)},()=>{})}),[e,n]),(0,W.useEffect)(()=>{let t=g?.apps.flatMap(e=>e.views.flatMap(e=>e.kind===`web`?(e.notes??[]).map(e=>e.at):[]))??[];t.length&&Br(e,Math.max(...t))},[g,e]),(0,W.useEffect)(()=>{if(!te)return;let e=setTimeout(()=>ne(null),55e3);return()=>clearTimeout(e)},[te]);let ae=async(t,r=`peek`,i,a)=>{let o=N.current;C(!0),x(``),ne(null),ie(null);let c=(`offer`in t||t.view.kind===`web`)&&(r===`tab`||Pr()),l=c?window.open(`about:blank`,`_blank`):null;try{if(l){l.opener=null,l.document.title=`Bivy · Opening app`;let e=l.document.createElement(`p`);e.setAttribute(`role`,`status`),e.textContent=`Opening app…`,l.document.body?.append(e)}let r,d;if(`offer`in t){if(r=(await R.appCommand(`apps.adopt`,e,{port:t.offer.port},n)).app,d=r.views[0],N.current===o){let e=r;_(t=>t&&{...t,apps:[...t.apps,e]}),y(e=>e.filter(e=>e.port!==t.offer.port))}}else({app:r,view:d}=t);let f=await R.appCommand(`apps.open`,e,{appId:r.id,viewId:d.id,returnTo:`${u()}/sessions/${encodeURIComponent(e)}`,...i?{path:i}:{},...a?{scenario:a}:{}},n);if(N.current!==o){l?.close();return}if(f.kind===`terminal`)D(f.termId);else if(f.kind===`web`){let e=oe(f.url);c?l&&!l.closed?(l.location.replace(e),s()):ne({viewId:d.id,url:e}):(M(!1),ee({url:e,app:r,view:d}))}else throw Error(`This app view is not supported by this client.`)}catch(e){l?.close(),N.current===o&&x(e instanceof Error?e.message:`Could not open view.`)}finally{N.current===o&&C(!1)}},oe=e=>{let t=new URL(e);if(t.protocol!==`https:`||t.origin===location.origin||t.username||t.password)throw Error(`Machine returned an unsafe preview URL.`);return t.href},se=(0,W.useRef)(!1);(0,W.useEffect)(()=>{if(!r||se.current||!g)return;let e=g.apps.find(e=>e.views.some(e=>e.id===r.viewId)),t=e?.views.find(e=>e.id===r.viewId);e&&t&&(se.current=!0,t.kind===`backend`?k({app:e,view:t,item:r.item}):ae({app:e,view:t},`peek`,r.path,r.scenario))},[r,g]);let ce=async(t,r)=>{x(``);try{await R.appCommand(`apps.reviewMode`,e,{appId:t.id,mode:r},n),_(e=>e&&{...e,apps:e.apps.map(e=>e.id===t.id?{...e,reviewMode:r}:e)})}catch(e){x(e instanceof Error?e.message:`Could not change preview cards.`)}},le=async(t,r)=>{let i=N.current;C(!0),x(``);try{let a=await R.appCommand(`apps.logs`,e,{appId:t.id,viewId:r.id},n);N.current===i&&a.kind===`terminal`&&D(a.termId)}catch(e){N.current===i&&x(e instanceof Error?e.message:`Could not open the server logs.`)}finally{N.current===i&&C(!1)}},ue=async t=>{C(!0),x(``);try{let n=t.notes??[],r=wi(t.name,n),i=await Jr(n);if(m||l.activeSessionId!==e||!R.prefillComposer(r,i)){if(i.length)throw Error(`Open this session’s chat before adding reviewer pictures.`);d(localStorage,e,r)}s()}catch(e){x(e instanceof Error?e.message:`Could not add notes.`)}finally{C(!1)}},de=async(t,r)=>{x(``);try{await R.appCommand(`apps.agentNotes`,e,{appId:t.id,enabled:r},n),_(e=>e&&{...e,apps:e.apps.map(e=>e.id===t.id?{...e,agentNotes:r||void 0}:e)})}catch(e){x(e instanceof Error?e.message:`Could not change who can read notes.`)}},fe=async(t,r)=>{let i=N.current;C(!0),x(``);try{await R.appCommand(`apps.clearNotes`,e,{appId:t.id,viewId:r.id},n),N.current===i&&T(e=>e+1)}catch(e){N.current===i&&x(e instanceof Error?e.message:`Could not clear notes.`)}finally{N.current===i&&C(!1)}},pe=async t=>{let r=N.current;C(!0),x(``),ie(null);try{await R.appCommand(`apps.remove`,e,{appId:t.id},n),N.current===r&&T(e=>e+1)}catch(e){N.current===r&&x(e instanceof Error?e.message:`Could not remove app.`)}finally{N.current===r&&C(!1)}};if(A)return(0,G.jsx)(Ir,{docked:o,url:A.url,name:A.app.name,sessionId:e,appId:A.app.id,viewId:A.view.id,onClose:s,access:(0,G.jsx)(Ar,{sessionId:e,appId:A.app.id,viewId:A.view.id,name:A.view.name,nodeId:n,disabled:!P||!g?.previewAvailable,onRevoked:()=>M(!0)}),revoked:j,onManage:()=>ee(null),onOpenInTab:()=>{let{app:e,view:t}=A;ee(null),ae({app:e,view:t},`tab`)}});let F=t=>{(m||l.activeSessionId!==e||!R.prefillComposer(t))&&d(localStorage,e,t),s()};if(O)return(0,G.jsx)(Zr,{sessionId:e,nodeId:n,app:O.app,view:O.view,item:O.item,docked:o,online:P,onBack:()=>k(null),onClose:a,onDraft:F});if(E)return(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(ot,{title:`App terminal`,onClose:()=>D(null),children:(0,G.jsx)(`p`,{role:`status`,children:`Loading terminal…`})}),children:(0,G.jsx)(vi,{sessionId:e,attachTermId:E,attachOnly:!0,onClose:()=>D(null)})});let I=!!g?.previewAvailable,me=g?.apps.filter(e=>!t||e.id===t)??[];return(0,G.jsxs)(_r,{docked:o,title:`Apps`,ariaLabel:`Session apps`,onClose:a,autoFocusSearch:!1,size:`large`,headExtra:(0,G.jsx)(`button`,{className:`btn ghost icon`,onClick:()=>T(e=>e+1),disabled:S||!P,"aria-label":`Refresh`,title:`Refresh`,children:S&&g?(0,G.jsx)(V,{size:`xs`}):(0,G.jsx)(Ue,{size:18})}),children:[(0,G.jsxs)(`div`,{className:`apps-sheet`,children:[S&&!g&&(0,G.jsxs)(`div`,{className:`apps-state`,role:`status`,children:[(0,G.jsx)(V,{size:`sm`}),(0,G.jsx)(`span`,{children:`Loading apps…`})]}),S&&g&&(0,G.jsx)(`span`,{className:`sr-only`,role:`status`,children:`Preparing…`}),b&&(0,G.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,role:`alert`,children:b}),g&&!I&&(0,G.jsx)(`div`,{className:`banner inline`,"data-tone":`warn`,role:`status`,children:`Bivy’s preview service is unavailable. Try Refresh shortly. Terminal views still work.`}),g&&t&&!g.apps.some(e=>e.id===t)&&(0,G.jsx)(`div`,{className:`banner inline`,"data-tone":`neutral`,role:`status`,children:`This app is no longer available. Ask the agent to republish it; previews expire when the machine restarts.`}),g?.apps.length===0&&v.length===0&&(0,G.jsxs)(`div`,{className:`apps-empty`,children:[(0,G.jsx)(`span`,{className:`app-tile`,"aria-hidden":!0,children:(0,G.jsx)(Xe,{size:20})}),(0,G.jsx)(`strong`,{children:`No apps yet`}),(0,G.jsxs)(`p`,{children:[`When the agent starts a web server in this session’s workspace, it shows up here. Agents can also publish views with `,(0,G.jsx)(`code`,{children:`bivy app publish`}),`.`]})]}),!t&&v.length>0&&(0,G.jsxs)(`section`,{className:`apps-group`,"aria-label":`Running in this workspace`,children:[(0,G.jsx)(`h3`,{className:`apps-group-title`,children:`Running in this workspace`}),v.map(e=>(0,G.jsxs)(`div`,{className:`apps-card`,children:[(0,G.jsx)(Xr,{tile:(0,G.jsx)(`span`,{className:`app-tile-port`,children:e.port}),name:`Port ${e.port}`,meta:`Live server · not previewed yet`,action:(0,G.jsx)(`button`,{className:`btn sm primary`,disabled:S||!P||!I,onClick:()=>void ae({offer:e}),"aria-label":`Preview port ${e.port}`,children:`Preview`})}),(0,G.jsx)(`code`,{className:`apps-cmd`,children:e.command})]},e.port))]}),me.map(t=>(0,G.jsxs)(`section`,{className:`apps-card`,"aria-label":t.name,children:[(0,G.jsx)(Xr,{tile:Yr(t.name),name:t.name,meta:`${t.views.length===1?`1 view`:`${t.views.length} views`}${t.createdAt?` · published ${At(t.createdAt)} ago`:``}`,action:(0,G.jsx)(vr,{label:`More actions for ${t.name}`,items:[{heading:`Preview cards in chat`},...[`ready`,`every`,`off`].map(e=>({label:Ci[e],checked:(t.reviewMode??`ready`)===e,disabled:S||!P,onSelect:()=>void ce(t,e)})),...t.views.some(e=>e.kind===`web`)?[{heading:`Reviewer notes`},{label:`Agents can read notes`,toggle:!0,checked:t.agentNotes===!0,disabled:S||!P,onSelect:()=>void de(t,t.agentNotes!==!0)}]:[],{label:`Remove app…`,danger:!0,disabled:S||!P,onSelect:()=>ie({app:t}),separated:!0}]})}),t.views.map(r=>{if(r.kind===`backend`)return(0,G.jsxs)(`article`,{className:`apps-view`,"aria-label":r.name,children:[(0,G.jsx)(Xr,{small:!0,tile:(0,G.jsx)(Ke,{size:18}),name:r.name,meta:xi[r.backend],action:(0,G.jsx)(`button`,{className:`btn sm`,disabled:S||!P,onClick:()=>k({app:t,view:r}),children:Si[r.backend]})}),(0,G.jsx)(`code`,{className:`apps-cmd`,children:r.detail})]},r.id);let a=r.kind===`terminal`?`terminal`:r.source===`service`&&r.managed?`managed`:r.source,o=r.kind===`terminal`?it:r.source===`display`?lt:Xe;return(0,G.jsxs)(`article`,{className:`apps-view`,"aria-label":r.name,children:[(0,G.jsx)(Xr,{small:!0,tile:(0,G.jsx)(o,{size:18}),name:r.name,meta:bi[a],action:te?.viewId===r.id?(0,G.jsx)(`a`,{className:`btn sm primary`,href:te.url,target:`_blank`,rel:`noopener noreferrer`,onClick:()=>setTimeout(s,0),children:`Open preview ↗`}):r.kind===`terminal`&&m?(0,G.jsx)(`button`,{className:`btn sm`,onClick:()=>{s(),i?.()},children:`Open in chat`}):(0,G.jsx)(`button`,{className:`btn sm${r.kind===`web`?` primary`:``}`,disabled:S||!P||r.kind===`web`&&!I,onClick:()=>r.kind===`terminal`?ie({app:t,view:r}):void ae({app:t,view:r}),children:r.kind===`terminal`?`Open terminal`:`Open preview`})}),r.kind===`terminal`&&(0,G.jsx)(`code`,{className:`apps-cmd`,children:Ei(r.command,r.args)}),r.kind===`web`&&(0,G.jsxs)(`div`,{className:`apps-view-tools`,children:[(0,G.jsx)(Ar,{sessionId:e,appId:t.id,viewId:r.id,name:r.name,nodeId:n,address:r.address,disabled:S||!P||!I,onRevoked:()=>ne(null)}),r.managed&&!m&&(0,G.jsxs)(`button`,{className:`btn sm ghost`,disabled:S||!P,onClick:()=>void le(t,r),"aria-label":`${r.source===`display`?`App`:`Server`} logs for ${r.name}`,children:[(0,G.jsx)(Ke,{size:15}),`Logs`]})]}),r.kind===`web`&&r.notes?.length?(0,G.jsxs)(`div`,{className:`apps-notes`,role:`group`,"aria-label":`Reviewer notes on ${r.name}`,children:[(0,G.jsxs)(`div`,{className:`apps-notes-head`,children:[(0,G.jsx)(`span`,{children:`Reviewer notes`}),(0,G.jsx)(`span`,{className:`apps-count`,"aria-label":`${r.notes.length} from people with a shared link`,children:r.notes.length})]}),(0,G.jsx)(`ul`,{children:r.notes.map(e=>(0,G.jsxs)(`li`,{className:`apps-note`,children:[(0,G.jsxs)(`span`,{className:`apps-note-text`,children:[`“`,e.note,`”`]}),` `,(0,G.jsxs)(`span`,{className:`app-row-meta`,children:[e.text?`on “${e.text}”`:e.selector,` · `,e.path,` · `,e.viewport.width,`×`,e.viewport.height]}),e.shot&&(0,G.jsx)(`button`,{className:`btn sm ghost`,onClick:()=>p(e),children:`View approximate picture`})]},e.id))}),(0,G.jsxs)(`div`,{className:`apps-notes-actions`,children:[(0,G.jsx)(`button`,{className:`btn sm`,disabled:S||!P,onClick:()=>void ue(r),children:`Add to message`}),(0,G.jsx)(`button`,{className:`btn sm ghost`,disabled:S||!P,onClick:()=>void fe(t,r),children:`Clear`})]})]}):null]},r.id)})]},t.id)),(me.length>0||v.length>0)&&(0,G.jsx)(`p`,{className:`apps-foot`,children:`Apps stay available while this machine runs. Removing an app keeps your project files.`})]}),f&&(0,G.jsx)(Kr,{images:qr([f]),index:0,onClose:()=>p(null)}),re&&(0,G.jsx)(Ye,{title:re.view?`Open ${re.view.name}?`:`Remove ${re.app.name}?`,message:re.view?.kind===`terminal`?`This starts or reconnects to “${Ei(re.view.command,re.view.args)}”. It runs with the machine user’s permissions, not in a new sandbox. Only run code you trust.`:`Preview access will be revoked and this app’s terminals stopped. Project files and externally started servers are not removed.`,confirmLabel:re.view?`Open terminal`:`Remove app`,danger:!re.view,onCancel:()=>ie(null),onConfirm:()=>{re.view?ae({app:re.app,view:re.view}):pe(re.app)}})]})}function Ei(e,t=[]){return[e,...t].map(e=>/^[\w@%+=:,./-]+$/.test(e)?e:JSON.stringify(e)).join(` `)}function Di(e){let t={name:``,path:``,type:`dir`,children:[]};for(let n of e){let e=n.path.split(`/`).filter(Boolean),r=t;for(let t=0;t<e.length;t++){let i=t===e.length-1,a=e[t],o=e.slice(0,t+1).join(`/`);r.children??=[];let s=r.children.find(e=>e.name===a&&e.type===(i?`file`:`dir`));s||(s=i?{name:a,path:o,type:`file`,file:n}:{name:a,path:o,type:`dir`,children:[]},r.children.push(s)),r=s}}let n=e=>{e.sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`dir`?-1:1);for(let t of e)t.children&&=r(n(t.children));return e},r=e=>e.map(e=>{let t=e;for(;t.type===`dir`&&t.children?.length===1&&t.children[0].type===`dir`;){let e=t.children[0];t={...e,name:`${t.name}/${e.name}`}}return t});return r(n(t.children??[]))}function Oi(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function ki(e,t){try{let n=atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return URL.createObjectURL(new Blob([r],{type:t||`application/octet-stream`}))}catch{return null}}function Ai(e){return{kind:e.kind,name:e.name,size:e.size,mimeType:e.mimeType,hash:e.hash,createdAt:e.createdAt,artifact:e.artifact}}function ji(e){let[t,n]=(0,W.useState)({status:`loading`});return(0,W.useEffect)(()=>{let t=!1,r=null;return n({status:`loading`}),R.fetchAttachment(e.hash,e.createdAt).then(i=>{if(t)return;let a=i&&ki(i.data,i.mimeType||e.mimeType);a?(r=a,n({status:`ready`,url:a})):n({status:`unavailable`})}),()=>{t=!0,r&&URL.revokeObjectURL(r)}},[e.hash,e.mimeType,e.createdAt]),t}async function Mi(e){let t=await R.fetchAttachment(e.hash,2**53-1),n=t&&ki(t.data,t.mimeType||e.mimeType);if(!n)return!1;let r=document.createElement(`a`);return r.href=n,r.download=e.name,r.click(),URL.revokeObjectURL(n),!0}function Ni({artifact:e,onOpen:t}){let n=ji(e);return n.status===`ready`?(0,G.jsx)(`button`,{type:`button`,className:`artifact-thumb-button`,onClick:t,"aria-label":`View ${e.name}`,children:(0,G.jsx)(`img`,{className:`artifact-thumb`,src:n.url,alt:``})}):(0,G.jsx)(`span`,{className:`artifact-thumb artifact-thumb-${n.status}`,"aria-hidden":!0,children:n.status===`unavailable`?`⚠`:``})}function Pi({artifact:e,onJump:t,onOpenImage:n}){let[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(!1),s=async()=>{i(!0),o(!1);let t=await Mi(e);i(!1),t||o(!0)},c=[Oi(e.size),e.createdAt?Ct(e.createdAt):null].filter(Boolean).join(` · `);return(0,G.jsxs)(`div`,{className:`artifact-row`,children:[e.kind===`image`&&n?(0,G.jsx)(Ni,{artifact:e,onOpen:n}):(0,G.jsx)(`span`,{className:`artifact-thumb artifact-glyph`,"aria-hidden":!0,children:`📄`}),(0,G.jsxs)(`div`,{className:`artifact-main`,children:[(0,G.jsxs)(`div`,{className:`artifact-name-line`,children:[(0,G.jsx)(`span`,{className:`artifact-name`,title:e.name,children:e.name}),e.artifact&&(0,G.jsx)(Te,{tone:`accent`,variant:`solid`,upper:!0,children:`Artifact`})]}),(0,G.jsx)(`div`,{className:`artifact-meta`,children:c}),e.caption&&(0,G.jsx)(`div`,{className:`artifact-caption`,children:e.caption.split(/\r?\n/,1)[0]}),a&&(0,G.jsx)(`div`,{className:`artifact-unavailable`,children:`Not available right now — the Machine may be offline, or this file was pruned.`})]}),(0,G.jsxs)(`div`,{className:`artifact-actions`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>void s(),disabled:r,"aria-busy":r,children:r?`Downloading…`:`Download`}),(0,G.jsx)(`button`,{type:`button`,className:`btn sm ghost`,onClick:()=>t(e.entryId),children:`Jump to turn`})]})]})}function Fi({artifacts:e,onClose:t,docked:n}){let r=(0,W.useMemo)(()=>e.filter(e=>e.kind===`image`),[e]),i=(0,W.useMemo)(()=>r.map(Ai),[r]),[a,o]=(0,W.useState)(null),s=e=>{n||t(),requestAnimationFrame(()=>{document.getElementById(`msg-${e}`)?.scrollIntoView({behavior:`smooth`,block:`center`})})},c=e.filter(e=>e.kind===`file`),l=e.length>0?`${e.length} artifact${e.length===1?``:`s`}`:`Artifacts`;return(0,G.jsxs)(_r,{docked:n,title:l,onClose:t,autoFocusSearch:!1,children:[e.length===0&&(0,G.jsx)(`div`,{className:`changes-binary`,children:`No artifacts yet this session.`}),r.length>0&&(0,G.jsxs)(`div`,{className:`artifacts-group`,children:[(0,G.jsx)(`div`,{className:`artifacts-group-title`,children:`Images`}),r.map((e,t)=>(0,G.jsx)(Pi,{artifact:e,onJump:s,onOpenImage:()=>o(t)},e.id))]}),c.length>0&&(0,G.jsxs)(`div`,{className:`artifacts-group`,children:[(0,G.jsx)(`div`,{className:`artifacts-group-title`,children:`Files`}),c.map(e=>(0,G.jsx)(Pi,{artifact:e,onJump:s},e.id))]}),a!=null&&(0,G.jsx)(Kr,{images:i,index:a,onClose:()=>o(null)})]})}var Ii=`bivy.appIconBadge.enabled`,Li=`bivy.notificationPreferences.snapshot`,Ri=`bivy-notification-settings-change`,zi,Bi=null;function Vi(){window.dispatchEvent(new Event(Ri))}function Hi(){return localStorage.getItem(Ii)!==`0`}function Ui(e){localStorage.setItem(Ii,e?`1`:`0`),Vi()}function Wi(e){let t=t=>{(t.key===Ii||t.key===Li)&&e()};return window.addEventListener(Ri,e),window.addEventListener(`storage`,t),()=>{window.removeEventListener(Ri,e),window.removeEventListener(`storage`,t)}}function Gi(){let e=localStorage.getItem(Li);if(e===zi)return Bi;if(zi=e,!e)return Bi=null,Bi;try{Bi=pe(JSON.parse(e))}catch{Bi=null}return Bi}function Ki(e){localStorage.setItem(Li,JSON.stringify(e)),Vi()}function qi(e){let[t,n]=(0,W.useState)(()=>typeof matchMedia==`function`&&matchMedia(e).matches);return(0,W.useEffect)(()=>{if(typeof matchMedia!=`function`)return;let t=matchMedia(e),r=()=>n(t.matches);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}function Ji(e,t,n,r){return t!==!1||!!(e&&n===e&&r.some(e=>e.configured!==!1))}function Yi(e){let t=e.activeSession.activeSessionId,n=e.sessionIndex.sessions.find(e=>e.sessionId===t);return t?n?.worktree||n?.workspace||e.activeSession.github.repo:e.draft.repo}function Xi(e,t,n,r){let i=r?`project:${r}`:n?.active||`default`;if(!n)return{preset:i};let a=n.presets??{},o=r?.split(/[/\\]/).filter(Boolean)??[],s=(r?.startsWith(`/`)?[r,o.at(-1),...o.filter(e=>e.includes(`__`)).map(e=>e.replace(`__`,`/`))]:[r]).filter(Boolean).map(t=>a[`project:${t}`]?.[e]).find(Boolean)||(n.active?a[n.active]?.[e]:void 0);return s?{preset:i,label:t.find(e=>e.label===s)?.label}:{preset:i,label:(t.find(t=>t.label===a.default?.[e])??t.find(e=>e.label==="default")??(t.length===1?t[0]:void 0))?.label}}function Zi({state:e,model:t,onClose:n}){let[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(null),s=(0,W.useRef)(!0);(0,W.useEffect)(()=>(s.current=!0,()=>{s.current=!1}),[]);let c=String(t.provider||``),l=e.settings.credentialRecords.filter(e=>e.provider===c),u=e.settings.credentialPresets,d=Yi(e),f=Xi(c,l,u,d),p=e.catalogs.providers.find(e=>e.id===c)?.name||c,m=`${t.label||t.id} account`;return(0,G.jsx)(ot,{title:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,className:`btn ghost icon`,onClick:n,"aria-label":`Back to models`,children:`‹`}),` `,m]}),ariaLabel:m,onClose:n,size:`large`,autoFocusSearch:!1,children:(0,G.jsxs)(`div`,{className:`picker-list`,children:[(0,G.jsxs)(`div`,{className:`settings-form`,children:[(0,G.jsx)(`p`,{className:`settings-hint`,children:d?`Applies to all ${p} models in ${d} on this machine.`:`Applies to all ${p} models using this machine’s active credential preset, including other sessions.`}),r&&(0,G.jsx)(`p`,{className:`muted`,role:`status`,children:`Switching account…`}),!u&&(0,G.jsx)(`p`,{className:`muted`,role:`status`,children:`Loading accounts…`}),a&&(0,G.jsx)(`p`,{className:`settings-error`,role:`alert`,children:a})]}),l.length===0&&(0,G.jsx)(`div`,{className:`picker-empty`,children:`No saved accounts available on this machine.`}),l.map(t=>(0,G.jsx)(ct,{title:(0,G.jsxs)(G.Fragment,{children:[t.label,f.label===t.label&&(0,G.jsx)(`span`,{className:`sr-only`,children:` (selected)`})]}),meta:t.kind===`oauth`?`Subscription sign-in`:t.kind===`reference`?`Password-manager reference`:`API key`,active:f.label===t.label,disabled:r||!u||e.connection.status!==`online`,onClick:async()=>{i(!0),o(null);try{await R.setPresetMapping(f.preset,c,t.label),R.listModels(),s.current&&n()}catch(e){s.current&&o(e instanceof Error?e.message:String(e))}finally{s.current&&i(!1)}}},t.label))]})})}var K=new Set([`claude-code-sdk`,`codex-approvals`,`grok`,`opencode`,`pi`]);function Qi(e){return String(e.displayName||e.name||e.id||`Agent`)}function $i(e){return K.has(e.id)}function ea(e,t){let n=t.trim().toLocaleLowerCase();return[...n?e.filter(e=>Qi(e).toLocaleLowerCase().includes(n)):e].sort((e,t)=>Qi(e).localeCompare(Qi(t),void 0,{sensitivity:`base`}))}var ta=Qi,na={off:`Fastest`,minimal:`Minimal`,low:`Light`,medium:`Default`,high:`Deep`,xhigh:`Deeper`,max:`Deepest`};function ra(e){let t=e.capabilities||{},n=e.authOwner;return be({now:new Date().toISOString(),preview:!0,agentId:e.id,agentDisplayName:ta(e),detectedVersion:e.testedVersion,versionSource:e.testedVersion?`tested-pin`:void 0,supportTier:e.supportTier,certification:e.certification,executionMode:e.executionMode,authOrigin:n===`bivy`?`bivy`:n===`agent`?`agent-native`:`unknown`,resumeAdvertised:t.resume===!0,resumeRefIsPath:t.sessionRefIsPath===!0,toolInterceptionEnforced:t.toolInterception===!0,mcpToolApprovalsOnly:t.mcpToolApprovals===!0,runtimeEnforcement:e.protectionLevel})}function ia({state:e,onSetup:t}){let n=e.catalogs.githubConnect;(0,W.useEffect)(()=>{if(n.status!==`waiting`)return;let e=n.intervalMs&&n.intervalMs>0?n.intervalMs:5e3,t=setInterval(()=>R.githubConnectPoll(),e);return()=>clearInterval(t)},[n.status,n.intervalMs]),(0,W.useEffect)(()=>{n.status===`connected`&&R.listRepos()},[n.status]),(0,W.useEffect)(()=>()=>R.githubConnectReset(),[]);let r=n.status===`denied`?`Authorization was denied. Try again.`:n.status===`expired`?`That code expired before you authorized. Try again.`:n.status===`error`?n.error||`Couldn't connect. Try again.`:null;return(0,G.jsxs)(`div`,{className:`repo-connect`,children:[(0,G.jsx)(`p`,{className:`repo-connect-lead`,children:`Connect GitHub to list your repos.`}),n.status===`waiting`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`p`,{className:`repo-connect-sub`,children:[`Open`,` `,(0,G.jsx)(`a`,{href:n.verificationUri||`https://github.com/login/device`,target:`_blank`,rel:`noopener`,children:(n.verificationUri||`github.com/login/device`).replace(/^https?:\/\//,``)}),` `,`and enter this code:`]}),(0,G.jsx)(`div`,{className:`repo-connect-code`,"aria-label":`Device code`,children:n.userCode||`…`}),(0,G.jsx)(`p`,{className:`repo-connect-waiting muted`,children:`Waiting for you to authorize on GitHub…`}),(0,G.jsx)(`button`,{type:`button`,className:`btn link`,onClick:()=>R.githubConnectReset(),children:`Cancel`})]}):n.status===`connected`?(0,G.jsx)(`p`,{className:`repo-connect-sub`,children:`Connected — loading your repos…`}):n.status===`unconfigured`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`repo-connect-sub`,children:`Already installed the GitHub App? Connect its key to this machine in GitHub settings. No reinstall needed.`}),(0,G.jsx)(`button`,{type:`button`,className:`btn primary block`,onClick:t,children:`Connect GitHub App to this machine`}),e.catalogs.reposReason===`gh-unauthed`&&(0,G.jsxs)(`p`,{className:`repo-connect-alt`,children:[`The GitHub CLI is installed but signed out — you can also run `,(0,G.jsx)(`code`,{children:`gh auth login`}),`.`]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`repo-connect-sub`,children:`Connect an existing GitHub App to this machine, or set up a new App.`}),(0,G.jsx)(`button`,{type:`button`,className:`btn primary block`,onClick:t,children:`Connect GitHub App to this machine`}),(0,G.jsx)(`button`,{type:`button`,className:`btn link`,disabled:n.status===`starting`,onClick:()=>R.githubConnectStart(),children:n.status===`starting`?`Starting…`:`Use GitHub device login instead`}),r&&(0,G.jsx)(`p`,{className:`repo-connect-alt`,children:r}),e.catalogs.reposReason===`gh-unauthed`&&(0,G.jsxs)(`p`,{className:`repo-connect-alt`,children:[`The GitHub CLI is installed but signed out — you can also run `,(0,G.jsx)(`code`,{children:`gh auth login`}),`.`]})]}),(0,G.jsxs)(`p`,{className:`repo-connect-note muted`,children:[`You don't need a repo to start — pick `,(0,G.jsx)(`strong`,{children:`Default workspace`}),` above to work in the machine's default workspace.`]})]})}function aa({error:e}){let[t,n]=(0,W.useState)(null),[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(``),[d,f]=(0,W.useState)(``),[p,m]=(0,W.useState)(``);(0,W.useEffect)(()=>{R.centralGithubApp().then(n).catch(e=>o(String(e?.message||e))),R.fetchGithubApp().then(e=>{let t=e.apps.find(e=>e.appId&&!e.hosted);t?.appId&&u(t.appId)}).catch(()=>{})},[]);let h=async()=>{i(!0),o(null);try{let e=await R.createCentralGithubInstall(`/`);window.location.assign(e.installUrl)}catch(e){o(String(e?.message||e)),i(!1)}},g=async()=>{i(!0),o(null);try{await R.setHostedProvisioning({githubIdentity:`central-app`}),R.listRepos()}catch(e){o(String(e?.message||e))}finally{i(!1)}},_=async()=>{i(!0),o(null);try{await R.connectHostedGithubApp({appId:l.trim(),privateKeyPem:p.trim(),...d.trim()?{installationId:d.trim()}:{}}),m(``),R.listRepos()}catch(e){o(String(e?.message||e))}finally{i(!1)}},v=!!t?.installations.length;return(0,G.jsxs)(`div`,{className:`repo-connect`,children:[(0,G.jsx)(`p`,{className:`repo-connect-lead`,children:`Connect the Bivy GitHub App for hosted Machines.`}),(0,G.jsx)(`p`,{className:`repo-connect-sub`,children:`Choose which repositories Bivy Cloud may access. This is separate from any custom GitHub App connected to a personal Machine.`}),t&&!t.configured?(0,G.jsx)(`p`,{className:`repo-connect-alt`,children:`The hosted GitHub App is not available on this deployment.`}):v?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,className:`btn primary block`,disabled:r,onClick:()=>void g(),children:r?`Connecting…`:`Use Bivy GitHub App`}),(0,G.jsx)(`button`,{type:`button`,className:`btn link`,disabled:r,onClick:()=>void h(),children:`Add another GitHub account or organization…`})]}):(0,G.jsx)(`button`,{type:`button`,className:`btn primary block`,disabled:r||t===null,onClick:()=>void h(),children:r?`Opening GitHub…`:t===null?`Checking GitHub App…`:`Install Bivy GitHub App`}),(0,G.jsx)(`button`,{type:`button`,className:`btn link`,disabled:r,onClick:()=>c(e=>!e),children:s?`Cancel custom App setup`:`Use my GitHub App`}),s&&(0,G.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),_()},children:[(0,G.jsx)(`p`,{className:`repo-connect-note muted`,children:`Hosted Machines need an encrypted server-side copy of this App key to mint short-lived, repository-scoped tokens. Your personal Machine's copy is unchanged.`}),(0,G.jsx)(`label`,{className:`field-label`,htmlFor:`hosted-own-app-id`,children:`GitHub App ID`}),(0,G.jsx)(`input`,{id:`hosted-own-app-id`,className:`picker-search`,inputMode:`numeric`,required:!0,value:l,onChange:e=>u(e.target.value)}),(0,G.jsx)(`label`,{className:`field-label`,htmlFor:`hosted-own-app-key`,children:`Private key (.pem contents)`}),(0,G.jsx)(`textarea`,{id:`hosted-own-app-key`,className:`picker-search`,required:!0,rows:4,value:p,onChange:e=>m(e.target.value)}),(0,G.jsx)(`label`,{className:`field-label`,htmlFor:`hosted-own-installation-id`,children:`Installation ID (only when the App has multiple installations)`}),(0,G.jsx)(`input`,{id:`hosted-own-installation-id`,className:`picker-search`,inputMode:`numeric`,value:d,onChange:e=>f(e.target.value)}),(0,G.jsx)(`button`,{type:`submit`,className:`btn primary block`,disabled:r||!l.trim()||!p.trim(),children:r?`Connecting…`:`Use this App on hosted Machines`})]}),(a||e)&&(0,G.jsx)(`p`,{className:`repo-connect-alt`,children:a||e})]})}function oa(){let[e,t]=(0,W.useState)(!1),[n,r]=(0,W.useState)(null),i=async()=>{t(!0),r(null);try{let e=await R.createCentralGithubInstall(`/`);window.location.assign(e.installUrl)}catch(e){r(String(e?.message||e)),t(!1)}};return(0,G.jsxs)(`div`,{className:`repo-connect-note`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn link`,disabled:e,onClick:()=>void i(),children:e?`Opening GitHub…`:`Add another GitHub account or organization…`}),n&&(0,G.jsx)(`p`,{className:`repo-connect-alt`,children:n})]})}function sa({state:e,onClose:t}){let[n,r]=(0,W.useState)(``),[i,a]=(0,W.useState)(null),o=e.draft.ephemeralConfig?.computeSource===`managed`;(0,W.useEffect)(()=>{R.listRepos();let t=e.draft.repo;t&&R.listBranches(t)},[]);let{repos:s,repoTotal:c}=(0,W.useMemo)(()=>{let t=n.trim().toLowerCase(),r=t?e.catalogs.repos.filter(e=>`${e.slug} ${e.description||``}`.toLowerCase().includes(t)):e.catalogs.repos;return{repos:r.slice(0,60),repoTotal:r.length}},[e.catalogs.repos,n]);return i?(0,G.jsx)(ca,{state:e,repo:i,onBack:()=>a(null),onClose:t}):(0,G.jsxs)(ot,{title:`Repository`,onClose:t,children:[(0,G.jsx)(`input`,{className:`picker-search`,placeholder:`Search repos…`,value:n,onChange:e=>r(e.target.value)}),(0,G.jsxs)(`div`,{className:`picker-list`,children:[(0,G.jsx)(`div`,{className:`picker-section-label`,children:`This Machine`}),(0,G.jsx)(ct,{active:!e.draft.repo,title:`Default workspace`,meta:`Work in the machine's default workspace`,onClick:()=>{R.chooseRepo(null),t()}}),e.catalogs.reposLoading&&(0,G.jsx)(`div`,{className:`picker-empty`,children:`Loading repos…`}),!e.catalogs.reposLoading&&!e.catalogs.reposAuthed&&o&&(0,G.jsx)(aa,{error:e.catalogs.reposError}),!e.catalogs.reposLoading&&!e.catalogs.reposAuthed&&!o&&!e.catalogs.reposError&&(0,G.jsx)(ia,{state:e,onSetup:()=>{t(),Zt(`github`)}}),!e.catalogs.reposLoading&&e.catalogs.reposError&&!o&&(0,G.jsxs)(`div`,{className:`picker-empty`,role:`alert`,children:[e.catalogs.reposError,(0,G.jsx)(`button`,{type:`button`,className:`btn link`,onClick:()=>R.listRepos(),children:`Retry`}),(0,G.jsx)(`button`,{type:`button`,className:`btn link`,onClick:()=>{t(),Zt(`github`)},children:`GitHub settings`})]}),!e.catalogs.reposLoading&&e.catalogs.reposAuthed&&!e.catalogs.reposError&&s.length===0&&(0,G.jsxs)(`div`,{className:`picker-empty`,children:[n?`No repositories match your search.`:`No repositories available. Check the App’s repository access on GitHub.`,!n&&(0,G.jsx)(`button`,{type:`button`,className:`btn link`,onClick:()=>{t(),Zt(`github`)},children:`GitHub settings`})]}),s.length>0&&(0,G.jsx)(`div`,{className:`picker-section-label`,children:`GitHub repositories`}),s.map(n=>{let r=n.slug===e.draft.repo;return(0,G.jsx)(ct,{active:r,title:n.slug,meta:[n.private?`private`:null,r?e.draft.branch?`branch: ${e.draft.branch}`:`default branch`:null,n.description].filter(Boolean).join(` · `),right:(0,G.jsx)(`button`,{type:`button`,className:`btn ghost icon repo-branch-arrow`,title:`Choose a branch of ${n.slug}`,"aria-label":`Choose a branch of ${n.slug}`,onClick:e=>{e.stopPropagation(),R.listBranches(n.slug),a(n.slug)},children:`›`}),onClick:()=>{R.chooseRepo(n.slug),t()}},n.slug)}),c>s.length&&(0,G.jsxs)(`div`,{className:`picker-empty`,children:[`Showing first `,s.length,` of `,c,` — search to narrow.`]}),o&&e.catalogs.reposAuthed&&(0,G.jsx)(oa,{})]})]})}function ca({state:e,repo:t,onBack:n,onClose:r}){let[i,a]=(0,W.useState)(``),o=e.catalogs.branchesLoading||e.catalogs.branchesRepo!==t,{branches:s,branchTotal:c}=(0,W.useMemo)(()=>{let t=i.trim().toLowerCase(),n=t?e.catalogs.branches.filter(e=>e.name.toLowerCase().includes(t)):e.catalogs.branches;return{branches:n.slice(0,200),branchTotal:n.length}},[e.catalogs.branches,i]),l=e.catalogs.repos.find(e=>e.slug===t)?.defaultBranch??(e.catalogs.branchesRepo===t?e.catalogs.branchesDefault:null)??null,u=e.draft.repo===t?e.draft.branch:null,d=e=>{R.chooseRepoBranch(t,e&&e!==l?e:null),r()};return(0,G.jsxs)(ot,{title:t,onClose:r,headExtra:(0,G.jsx)(`button`,{className:`sheet-back`,onClick:n,"aria-label":`Back to repositories`,children:`‹`}),children:[(0,G.jsx)(`input`,{className:`picker-search`,placeholder:`Search branches…`,value:i,onChange:e=>a(e.target.value)}),(0,G.jsxs)(`div`,{className:`picker-list`,children:[(0,G.jsx)(ct,{active:!u,title:`Default branch${l?` (${l})`:``}`,meta:`Clone and start from the repo's default branch`,onClick:()=>d(null)}),o&&(0,G.jsx)(`div`,{className:`picker-empty`,children:`Loading branches…`}),!o&&e.catalogs.branchesError&&(0,G.jsx)(`div`,{className:`picker-empty`,children:e.catalogs.branchesError}),!o&&!e.catalogs.branchesError&&s.length===0&&i&&(0,G.jsxs)(`div`,{className:`picker-empty`,children:[`No branches match “`,i,`”.`]}),!o&&s.map(e=>(0,G.jsx)(ct,{active:e.name===u,title:e.name,meta:e.name===l?`Default`:void 0,onClick:()=>d(e.name)},e.name)),!o&&c>s.length&&(0,G.jsxs)(`div`,{className:`picker-empty`,children:[`Showing first `,s.length,` of `,c,` — search to narrow.`]})]})]})}function la({state:e,onClose:t}){let n=e.settings.nodeSettings?.defaultSandbox,[r,i]=(0,W.useState)(!1),a=e.catalogs.runtimes.find(t=>t.id===e.catalogs.selectedAgentId),o=tn(a),s=e.catalogs.currentAgentName||`This agent`;return(0,G.jsxs)(ot,{title:`Protection`,onClose:t,autoFocusSearch:!1,children:[!o&&(0,G.jsxs)(`div`,{className:`banner`,"data-tone":`warn`,role:`note`,children:[s,` can't ask for approval — protection choices are treated as full access.`]}),(0,G.jsxs)(`div`,{className:`picker-list`,children:[(0,G.jsx)(ct,{active:!e.draft.sandbox,title:`Machine default${n?` (${n})`:``}`,meta:`Use this machine's configured protection`,onClick:()=>{R.setSessionSandbox(null),t()}}),ln.map(n=>{let a=n.id===`danger-full-access`,o=a&&r;return(0,G.jsx)(ct,{active:e.draft.sandbox===n.id,title:o?`Confirm full computer access`:n.label,meta:o?`This agent can access anything your OS user can. Bivy is not an isolation boundary. Select again to continue.`:n.hint,onClick:()=>{if(a&&!r){i(!0);return}R.setSessionSandbox(n.id),t()}},n.id)})]})]})}function ua({state:e,currentNodeId:t,onPick:n,onClose:r}){return(0,G.jsx)(ot,{title:`Open terminal on`,onClose:r,autoFocusSearch:!1,children:(0,G.jsxs)(`div`,{className:`picker-list`,children:[e.connection.nodes.length===0&&(0,G.jsx)(`div`,{className:`picker-empty`,children:`No machines available.`}),e.connection.nodes.map(e=>(0,G.jsx)(ct,{active:e.id===t,title:e.name||e.id,meta:Ee[me(e)].label,onClick:()=>n(e.id)},e.id))]})})}function da({state:e,onClose:t}){let n=!!e.activeSession.activeSessionId&&e.activeSession.transcript.some(e=>e.role===`user`),r=n?e.activeSession.activeRuntimeId??e.sessionIndex.sessions.find(t=>t.sessionId===e.activeSession.activeSessionId)?.runtimeId??null:e.catalogs.selectedAgentId??(e.catalogs.runtimes.find(e=>e.current)?.id||null),[i,a]=(0,W.useState)(``),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(null),u=(0,W.useRef)(null),d=(0,W.useRef)(null);(0,W.useEffect)(()=>{R.listRuntimes(),R.prefetchModels()},[]);let f=(0,W.useMemo)(()=>ea(e.catalogs.runtimes,i),[e.catalogs.runtimes,i]),p=f.filter($i),m=f.filter(e=>!$i(e)),h=e.catalogs.runtimes.find(e=>e.id===r);(0,W.useEffect)(()=>{h&&!$i(h)&&s(!0)},[h]),(0,W.useEffect)(()=>{if(!r||d.current===r)return;let e=u.current?.querySelector(`.picker-item-row.active`);e&&(e.scrollIntoView({block:`center`}),d.current=r)},[r,f.length,o]);let g=c?e.catalogs.runtimes.find(e=>e.id===c):void 0,_=(e,t)=>{(n?void 0:ra(e))?.requiresAcknowledgement&&R.acknowledgeSessionAgentReducedProtections(!0),n?R.chooseAgent(e,()=>new Promise(e=>t(e))):t(()=>R.chooseAgent(e))},v=(t,i)=>{let a=String(t.status||`available`)===`available`,o=!a&&!!t.install,s=e.catalogs.installingRuntimeId===t.id,c=t.id===r,u=n?void 0:ra(t),d=!n&&!!u?.requiresAcknowledgement,f=String(t.description||``);return(0,G.jsx)(ct,{active:c,title:ta(t),meta:[s?`Setting up…`:a?n?`Fork and hand off`:null:o?`Install required`:`Needs sign-in`,f].filter(Boolean).join(` · `),disabled:s||!a&&!o,right:o&&!s?(0,G.jsx)(`button`,{type:`button`,className:`btn sm ghost`,onClick:e=>{e.stopPropagation(),R.installAgent(t.id)},children:`Install`}):void 0,onClick:()=>{if(o){R.installAgent(t.id);return}if(a){if(d){l(t.id);return}_(t,i)}}},t.id)};return(0,G.jsx)(ot,{title:n?`Hand off to agent`:`Agent`,onClose:t,autoFocusSearch:!1,size:`large`,children:e=>(0,G.jsxs)(G.Fragment,{children:[n&&(0,G.jsx)(`div`,{className:`picker-empty`,children:`Choosing an agent forks this session with its transcript and working files, then opens the fork in that agent.`}),(0,G.jsx)(`input`,{className:`picker-search`,placeholder:`Search agents…`,value:i,onChange:e=>{a(e.target.value),l(null)}}),(0,G.jsxs)(`div`,{className:`picker-list`,ref:u,children:[f.length===0&&(0,G.jsx)(`div`,{className:`picker-empty`,children:`No agents available.`}),p.length>0&&(0,G.jsx)(`div`,{className:`picker-section-label`,children:`Recommended`}),p.map(t=>v(t,e)),m.length>0&&(0,G.jsxs)(`button`,{type:`button`,className:`picker-section-toggle`,onClick:()=>s(e=>!e),"aria-expanded":o||!!i.trim(),children:[`More agents `,(0,G.jsx)(`span`,{"aria-hidden":!0,children:o||i.trim()?`▾`:`▸`})]}),(o||!!i.trim())&&m.map(t=>v(t,e))]}),g&&(0,G.jsx)(Ye,{title:`Check how ${ta(g)} runs`,message:`Bivy couldn't check which sign-in this agent will use or guarantee its protection level.`,confirmLabel:`Use ${ta(g)}`,onCancel:()=>l(null),onConfirm:()=>_(g,e)})]})})}function fa({state:e}){let[t,n]=(0,W.useState)(!1),r=(0,W.useRef)(null);rt(()=>n(!1),t),(0,W.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&n(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[t]);let i=e.catalogs.thinking;if(!i.supportsThinking||!i.availableThinkingLevels||i.availableThinkingLevels.length<=1)return null;let a=na[i.thinkingLevel]||i.thinkingLevel;return(0,G.jsxs)(`div`,{className:`reasoning-wrap`,ref:r,children:[(0,G.jsxs)(`button`,{className:`reasoning-pill`,onClick:()=>n(e=>!e),children:[`✦ `,a,` `,t?`▾`:`▸`]}),t&&(0,G.jsx)(`div`,{className:`menu reasoning-menu`,role:`menu`,children:i.availableThinkingLevels.map(e=>(0,G.jsx)(`button`,{className:`menu-item reasoning-opt${e===i.thinkingLevel?` active`:``}`,role:`menuitemradio`,"aria-checked":e===i.thinkingLevel,onClick:()=>{R.setThinkingLevel(e),n(!1)},children:na[e]||e},e))})]})}function pa(e,t){let n=e.contextWindow;return[e.provider,t,n?`${Math.round(n/1e3)}k ctx`:null].filter(Boolean).join(` · `)}function ma({state:e,onClose:t}){let[n,r]=(0,W.useState)(``),[i,a]=(0,W.useState)(null),o=(0,W.useRef)(null),s=(0,W.useRef)(null);(0,W.useEffect)(()=>{i||o.current?.focus()},[i]);let[c,l]=(0,W.useState)(null),u=()=>{R.listModels(),R.listProviders(),R.listCredentialRecords(),R.getCredentialPresets()};(0,W.useEffect)(u,[e.connection.currentNodeId]);let[d,f]=(0,W.useState)(!1),p=`${e.catalogs.modelsRuntimeId??``}:${e.catalogs.models.length}:${e.catalogs.models.map(e=>e.id).join(`,`)}`;(0,W.useEffect)(()=>{d&&f(!1)},[p]),(0,W.useEffect)(()=>{if(!d)return;let e=setTimeout(()=>f(!1),2500);return()=>clearTimeout(e)},[d]),(0,W.useEffect)(()=>{c&&e.catalogs.providers.find(e=>e.id===c)?.configured&&(R.listModels(),l(null))},[c,e.catalogs.providers]);let m=t=>e.catalogs.providers.find(e=>e.id===t)?.name||t,h=(0,W.useMemo)(()=>{let t=n.trim().toLowerCase();return t?e.catalogs.models.filter(e=>`${e.id} ${e.label||``} ${e.provider||``} ${m(String(e.provider||``))}`.toLowerCase().includes(t)):e.catalogs.models},[e.catalogs.models,e.catalogs.providers,n]),g=h.filter(e=>e.configured!==!1),_=h.filter(e=>e.configured===!1),v=t=>e.catalogs.currentModel!=null&&t.id===e.catalogs.currentModel.id&&t.provider===e.catalogs.currentModel.provider;return i?(0,G.jsx)(Zi,{state:e,model:i,onClose:()=>a(null)}):c?(0,G.jsx)(ot,{title:m(c),onClose:t,size:`large`,headExtra:(0,G.jsx)(`button`,{className:`sheet-back`,onClick:()=>l(null),"aria-label":`Back`,children:`‹`}),children:(0,G.jsx)(an,{state:e,providerId:c})}):(0,G.jsxs)(ot,{title:`Model`,ariaLabel:`Model`,onClose:t,headExtra:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(fa,{state:e}),(0,G.jsx)(`button`,{type:`button`,className:`btn ghost icon`,onClick:()=>{f(!0),u()},disabled:d,"aria-label":`Refresh models`,title:`Refresh models`,children:d?(0,G.jsx)(V,{size:`xs`}):(0,G.jsx)(Ue,{size:18})}),(0,G.jsx)(`button`,{type:`button`,className:`btn ghost icon`,onClick:()=>{t(),Zt(`providers`)},"aria-label":`Model and provider settings`,title:`Model and provider settings`,children:(0,G.jsx)(ft,{size:18})})]}),autoFocusSearch:!1,size:`large`,children:[(0,G.jsx)(`input`,{className:`picker-search`,placeholder:`Search models…`,value:n,onChange:e=>r(e.target.value)}),(0,G.jsxs)(`div`,{className:`picker-list`,children:[g.length===0&&_.length===0&&(0,G.jsx)(`div`,{className:`picker-empty`,children:`No models available.`}),g.map(n=>{let r=String(n.provider||``),i=e.settings.credentialRecords.filter(e=>e.provider===r),c=Xi(r,i,e.settings.credentialPresets,Yi(e)),l=i.length?c.label||(e.settings.credentialPresets?`Choose account`:`Loading account…`):void 0;return(0,G.jsx)(ct,{active:v(n),title:n.label||n.id,meta:pa(n,l),right:i.length>1?(0,G.jsx)(`button`,{type:`button`,className:`btn ghost icon`,"aria-label":`Change account for ${n.label||n.id}`,ref:s.current===`${r}:${n.id}`?o:void 0,onClick:()=>{s.current=`${r}:${n.id}`,a(n)},children:(0,G.jsx)($e,{})}):void 0,onClick:()=>{R.chooseModel(n),t()}},`${n.provider||``}:${n.id}`)}),_.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`picker-section-label`,children:`Other models`}),_.map(e=>{let t=String(e.provider||``),n=m(t),r=Number(e.modelCount)||0;return(0,G.jsx)(ct,{title:n,meta:`${r} model${r===1?``:`s`} · Not connected`,right:(0,G.jsx)(`button`,{type:`button`,className:`btn sm ghost`,onClick:e=>{e.stopPropagation(),l(t)},children:`Connect`}),onClick:()=>l(t)},`${t}:${e.id}`)})]})]})]})}function ha(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function ga(e){let t=new Date(e),n=t.toDateString()===new Date().toDateString(),r=t.toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`});return n?`Sends today at ${r}`:`Sends ${t.toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`})} at ${r}`}function _a(e,t){if(e.status===`scheduled`)return e.scheduledAt==null?`Scheduled`:ga(e.scheduledAt);if(e.status===`sending`)return`Sending…`;if(e.status===`failed`)return`Failed — will retry`;let n=`Queued · #${t+1}`;return e.scheduledAutomationId?`${n} · sends on close`:n}function va(e){return String(e).padStart(2,`0`)}function ya(e){return`${e.getFullYear()}-${va(e.getMonth()+1)}-${va(e.getDate())}T${va(e.getHours())}:${va(e.getMinutes())}`}function ba({sessionId:e,item:t,position:n,count:r,canSteer:i,busy:a,onError:o}){let[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(t.text),[d,f]=(0,W.useState)(t.attachments??[]),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(()=>t.scheduledAt==null?ya(new Date):ya(new Date(t.scheduledAt))),_=t.status===`scheduled`,v=t.status!==`queued`&&!_,[y,b]=(0,W.useState)(!1),x=async()=>{b(!0);try{await R.startSessionLike(e,t.text,t.attachments),R.removeFollowup(e,t.id)}catch(e){o?.(e instanceof Error?e.message:String(e)),b(!1)}};function S(){v||(u(t.text),f(t.attachments??[]),c(!0))}function C(){c(!1)}function w(){let n=l.trim();if(!n&&d.length===0){o?.(`A follow-up needs some text or an attachment.`);return}let r=R.editFollowup(e,t.id,{text:n,attachments:d.length?d:void 0},t.version);if(!r.ok){let e=r.reason===`stale`?`This follow-up changed elsewhere — refresh and try again.`:r.reason===`not_queued`?`This follow-up is already sending — it can no longer be edited.`:`This follow-up is gone — it may have already been sent.`;o?.(e)}c(!1)}function T(e){f(t=>t.filter((t,n)=>n!==e))}function E(){_&&(g(t.scheduledAt==null?ya(new Date):ya(new Date(t.scheduledAt))),m(!0))}function D(){m(!1)}function O(){let n=new Date(h);if(!Number.isFinite(n.getTime())||n.getTime()<=Date.now()){o?.(`Pick a time in the future.`);return}(async()=>{let r=await R.editScheduledFollowup(e,t.id,n);r?o?.(r):m(!1)})()}let k=a&&i?`Steer now`:`Send next`;return(0,G.jsx)(`div`,{className:`card followup-card${s||p?` editing`:``}${v?` locked`:``}`,"data-tone":`muted`,role:`listitem`,children:s||p?(0,G.jsxs)(`div`,{className:`followup-edit`,children:[p?(0,G.jsxs)(`label`,{className:`schedule-field`,children:[(0,G.jsx)(`span`,{className:`schedule-label`,children:`Send at`}),(0,G.jsx)(`input`,{type:`datetime-local`,className:`field`,value:h,min:ya(new Date),autoFocus:!0,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),D()):e.key===`Enter`&&(e.preventDefault(),O())}})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`textarea`,{className:`field followup-edit-input`,value:l,autoFocus:!0,rows:2,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),C()):e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),w())}}),d.length>0&&(0,G.jsx)(`div`,{className:`attach-chips`,children:d.map((e,t)=>(0,G.jsxs)(`span`,{className:`attach-chip`,title:e.name,children:[(0,G.jsx)(`span`,{className:`attach-glyph`,children:e.kind===`image`?`🖼`:`📄`}),(0,G.jsx)(`span`,{className:`attach-name`,children:e.name}),(0,G.jsx)(`button`,{type:`button`,className:`attach-remove`,onClick:()=>T(t),"aria-label":`Remove ${e.name}`,children:`✕`})]},`${e.name}-${t}`))})]}),(0,G.jsxs)(`div`,{className:`followup-edit-actions`,children:[(0,G.jsx)(`button`,{type:`button`,className:`queue-action-btn`,onClick:p?D:C,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,className:`queue-action-btn active`,onClick:p?O:w,children:`Save`})]})]}):(0,G.jsxs)(`div`,{className:`followup-card-row`,tabIndex:v?-1:0,role:`group`,"aria-label":_?`Scheduled message`:`Follow-up ${n+1} of ${r}`,onKeyDown:r=>{if(!v){if(_){r.key===`Enter`?(r.preventDefault(),E()):(r.key===`Delete`||r.key===`Backspace`)&&(r.preventDefault(),R.removeFollowup(e,t.id));return}r.key===`ArrowUp`?(r.preventDefault(),R.reorderFollowup(e,t.id,n-1)):r.key===`ArrowDown`?(r.preventDefault(),R.reorderFollowup(e,t.id,n+1)):r.key===`Enter`?(r.preventDefault(),S()):(r.key===`Delete`||r.key===`Backspace`)&&(r.preventDefault(),R.removeFollowup(e,t.id))}},children:[!_&&(0,G.jsxs)(`div`,{className:`followup-reorder`,children:[(0,G.jsx)(`button`,{type:`button`,className:`queue-action-btn icon`,disabled:v||n===0,onClick:()=>R.reorderFollowup(e,t.id,n-1),"aria-label":`Move earlier`,title:`Move earlier`,children:`▲`}),(0,G.jsx)(`button`,{type:`button`,className:`queue-action-btn icon`,disabled:v||n===r-1,onClick:()=>R.reorderFollowup(e,t.id,n+1),"aria-label":`Move later`,title:`Move later`,children:`▼`})]}),(0,G.jsxs)(`div`,{className:`followup-body`,children:[(0,G.jsx)(`div`,{className:`followup-status`,children:_a(t,n)}),(0,G.jsx)(`div`,{className:`followup-text`,children:t.text||`(attachment only)`}),t.attachments&&t.attachments.length>0&&(0,G.jsx)(`div`,{className:`followup-attachments`,children:t.attachments.map((e,t)=>(0,G.jsxs)(`span`,{className:`attach-chip`,title:e.name,children:[(0,G.jsx)(`span`,{className:`attach-glyph`,children:e.kind===`image`?`🖼`:`📄`}),(0,G.jsx)(`span`,{className:`attach-name`,children:e.name}),(0,G.jsx)(`span`,{className:`attach-size`,children:ha(e.size)})]},`${e.name}-${t}`))})]}),(0,G.jsx)(`div`,{className:`followup-card-actions`,children:_?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,className:`queue-action-btn icon`,onClick:E,"aria-label":`Change scheduled time`,title:`Change time`,children:`✎`}),(0,G.jsx)(`button`,{type:`button`,className:`queue-action-btn icon danger`,onClick:()=>R.removeFollowup(e,t.id),"aria-label":`Cancel scheduled message`,title:`Cancel`,children:`✕`})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,className:`queue-action-btn icon`,disabled:v,onClick:S,"aria-label":`Edit follow-up`,title:`Edit`,children:`✎`}),(0,G.jsx)(`button`,{type:`button`,className:`queue-action-btn icon danger`,disabled:v,onClick:()=>R.removeFollowup(e,t.id),"aria-label":`Remove follow-up`,title:`Remove`,children:`✕`}),(0,G.jsx)(`button`,{type:`button`,className:`queue-action-btn`,disabled:v||y,onClick:()=>void x(),title:`Start this now in its own session; this one keeps working`,children:y?`Starting…`:`Run in new session`}),(0,G.jsx)(`button`,{type:`button`,className:`queue-action-btn`,disabled:v||y,onClick:()=>R.sendFollowupNow(e,t.id),title:k,children:k})]})})]})})}function xa({sessionId:e,items:t,canSteer:n,busy:r,onError:i}){if(!t.length)return null;let a=t.filter(e=>e.status===`queued`).length,o=t.filter(e=>e.status===`scheduled`).length,s=a>0?`${a} follow-up${a>1?`s`:``} queued${o?` · ${o} scheduled`:``}`:`${o} scheduled message${o>1?`s`:``}`;return(0,G.jsxs)(`div`,{className:`followup-queue`,children:[(0,G.jsx)(`div`,{className:`followup-queue-head`,children:(0,G.jsx)(`span`,{children:s})}),(0,G.jsx)(`div`,{className:`followup-list`,role:`list`,children:t.map((a,o)=>(0,G.jsx)(ba,{sessionId:e,item:a,position:o,count:t.length,canSteer:n,busy:r,onError:i},a.id))})]})}function Sa(e,t,n,r){let i=e?.draft;if(i&&i.device.id!==t.id&&n&&r-i.at<18e5)return{from:i.device.label,text:i.text,at:i.at}}function Ca(e){let{connection:t}=Me(),n=t.status===`online`,[r,i]=(0,W.useState)();return(0,W.useEffect)(()=>{if(i(void 0),!e||!n)return;let t=!0,r=()=>R.getPresence(e).then(e=>{t&&i(e)},()=>{});r();let a=()=>{document.visibilityState===`visible`&&r()};document.addEventListener(`visibilitychange`,a);let o=R.onPresence(n=>{t&&n.sessionId===e&&i(n)});return()=>{t=!1,o(),document.removeEventListener(`visibilitychange`,a)}},[e,n,t.currentNodeId]),r}function wa(e){let t=e.trim().split(`
|
|
9
9
|
`)[0]??``;return t.length>80?`${t.slice(0,79)}…`:t}function Ta({handoff:e,onContinue:t}){return(0,G.jsxs)(`div`,{className:`banner handoff-banner`,"data-tone":`neutral`,role:`status`,children:[(0,G.jsxs)(`span`,{className:`banner-text`,children:[(0,G.jsxs)(`strong`,{children:[`Unsent draft from `,e.from,` · `,Ct(e.at)]}),(0,G.jsx)(`span`,{className:`handoff-preview`,children:wa(e.text)})]}),(0,G.jsx)(`button`,{type:`button`,className:`btn sm banner-action`,onClick:t,children:`Continue draft`})]})}function Ea({sessionId:e,composerEmpty:t,onUseDraft:n}){let r=Ca(e),[i,a]=(0,W.useState)(``),o=Sa(r,fe(),t,Date.now());if(!o)return null;let s=`${e}:${o.at}`;return i===s?null:(0,G.jsx)(Ta,{handoff:o,onContinue:()=>{n(o.text),a(s)}})}function Da({standby:e,onContinueHere:t,onOpenOnOwner:n}){let[r,i]=(0,W.useState)(!1);return e.ownerOnline?(0,G.jsxs)(`div`,{className:`banner handoff-banner`,"data-tone":`neutral`,role:`status`,children:[(0,G.jsx)(`span`,{className:`banner-text`,children:(0,G.jsxs)(`strong`,{children:[`Standby copy. This session is live on `,e.ownerName,`.`]})}),(0,G.jsxs)(`button`,{type:`button`,className:`btn sm banner-action`,onClick:n,children:[`Open on `,e.ownerName]})]}):(0,G.jsxs)(`div`,{className:`banner handoff-banner`,"data-tone":`warn`,role:`status`,children:[(0,G.jsxs)(`span`,{className:`banner-text`,children:[(0,G.jsxs)(`strong`,{children:[e.ownerName,` is offline.`]}),(0,G.jsx)(`span`,{children:`This machine has a standby copy, up to its last finished turn.`})]}),(0,G.jsx)(`button`,{type:`button`,className:`btn sm banner-action`,disabled:r,"aria-busy":r,onClick:()=>{i(!0),t().finally(()=>i(!1))},children:r?`Continuing…`:`Continue here`})]})}function Oa(e,t){if(!e?.startsWith(`replica`))return;let n=e.slice(8),r=n?t.find(e=>e.id===n):void 0;return{ownerId:n,ownerName:r?.name||`another machine`,ownerOnline:!!r?.online}}var ka=10485760,Aa=12,ja=41943040,Ma=524288,Na=1500,Pa=/\.(md|txt|json|ya?ml|csv|ts|tsx|js|jsx|css|html|xml|py|rb|go|rs|java|c|cpp|h|hpp|sh|sql)$/i;function Fa(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result||``)),r.onerror=()=>n(r.error),r.readAsDataURL(e)})}function Ia(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result||``)),r.onerror=()=>n(r.error),r.readAsText(e)})}function La(){return typeof window<`u`&&window.matchMedia(`(max-width: 720px)`).matches}function Ra(e){if(typeof document>`u`)return!0;let t=document.activeElement;if(!t||t===document.body||t===e)return!0;let n=t.tagName;return!(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t.isContentEditable||t.closest?.(`[role="dialog"], .settings-modal`))}function za(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Ba(e){return e.kind!==`image`||!e.data?null:`data:${e.mimeType||`image/png`};base64,${e.data}`}function Va(e){return!!(e&&Array.from(e.types||[]).includes(`Files`))}function Ha(){return(0,G.jsx)(`svg`,{className:`pill-gh`,viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`currentColor`,"aria-hidden":!0,children:(0,G.jsx)(`path`,{d:`M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0016 8c0-4.42-3.58-8-8-8z`})})}function Ua(){return(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`19`,height:`19`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:[(0,G.jsx)(`path`,{d:`M12 15.5a3 3 0 003-3V6a3 3 0 10-6 0v6.5a3 3 0 003 3z`}),(0,G.jsx)(`path`,{d:`M6 11.5v1a6 6 0 0012 0v-1M12 18.5V21M9 21h6`})]})}function Wa(){return(0,G.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:(0,G.jsx)(`path`,{d:`M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48`})})}function Ga(){return(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:[(0,G.jsx)(`circle`,{cx:`12`,cy:`8`,r:`3`}),(0,G.jsx)(`path`,{d:`M5.5 20a6.5 6.5 0 0 1 13 0`})]})}function Ka(){return(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:[(0,G.jsx)(`path`,{d:`m12 3 1.4 4.1L17.5 8.5l-4.1 1.4L12 14l-1.4-4.1-4.1-1.4 4.1-1.4L12 3Z`}),(0,G.jsx)(`path`,{d:`m18.5 14 .8 2.2 2.2.8-2.2.8-.8 2.2-.8-2.2-2.2-.8 2.2-.8.8-2.2Z`})]})}function qa(e,t){let[n,...r]=e.split(` `),i=t.split(` `)[0];return r.length&&n&&i&&n.toLowerCase()===i.toLowerCase()?r.join(` `):e}function Ja({state:e,disabled:t,disabledHint:n,working:r,onSend:i,onAbort:a,onError:o}){let s=(0,W.useRef)(null);s.current||=p(localStorage,e.activeSession.activeSessionId);let[c,l]=(0,W.useState)(()=>s.current?.text??``),[u,d]=(0,W.useState)(null),[m,h]=(0,W.useState)(()=>s.current?.attachments??[]),[_,v]=(0,W.useState)(()=>s.current?.recovered??[]),[y,x]=(0,W.useState)(0),[S,C]=(0,W.useState)(!1),[T,E]=(0,W.useState)(null),[D,k]=(0,W.useState)(!1),[A,ee]=(0,W.useState)(!1),[j,M]=(0,W.useState)(!1),[te,re]=(0,W.useState)(0),[ie,P]=(0,W.useState)(null),ae=(0,W.useRef)(0);(0,W.useEffect)(()=>{if(!r){ee(!1),M(!1);return}if(!A)return;let e=window.setTimeout(()=>M(!0),1e4);return()=>window.clearTimeout(e)},[A,r]);let oe=()=>{A||(ee(!0),M(!1),a())},se=e.activeSession.activeRuntimeId??e.catalogs.selectedAgentId,ce=e.catalogs.runtimes.find(e=>e.id===se),le=ce?.capabilities,de=!!e.sessionIndex.sessions.find(t=>t.sessionId===e.activeSession.activeSessionId)?.pendingLaunch,fe=!de&&Ji(se,le?.modelSelection,e.catalogs.modelsRuntimeId,e.catalogs.models),pe=e.activeSession.activeSessionId?e.sessionIndex.commandsBySession[e.activeSession.activeSessionId]:void 0,F=Array.isArray(le?.commands)?le.commands:[],I=pe??(e.activeSession.activeSessionId?[]:F),me=e.activeSession.activeSessionId?e.sessionIndex.followupsBySession[e.activeSession.activeSessionId]??[]:[],he=R.supportsSteering(),ge=(0,W.useRef)(null),_e=(0,W.useRef)(null),ve=(0,W.useRef)(null),L=!e.activeSession.activeSessionId,ye=Oa(e.sessionIndex.sessions.find(t=>t.sessionId===e.activeSession.activeSessionId)?.source,e.connection.nodes),be=(0,W.useRef)(w(e.activeSession.activeSessionId)),xe=(0,W.useRef)(e.activeSession.activeSessionId),Se=(0,W.useRef)(c),Ce=(0,W.useRef)(m),we=(0,W.useRef)(_);(0,W.useEffect)(()=>{Se.current=c},[c]),(0,W.useEffect)(()=>{Ce.current=m},[m]),(0,W.useEffect)(()=>{we.current=_},[_]),(0,W.useEffect)(()=>{let t=w(e.activeSession.activeSessionId);if(be.current===t)return;b(localStorage,xe.current,Se.current,[...Ce.current,...we.current]),f(xe.current,Ce.current);let n=p(localStorage,e.activeSession.activeSessionId);l(n.text),h(n.attachments),v(n.recovered),C(!1),x(0),requestAnimationFrame(je),be.current=t,xe.current=e.activeSession.activeSessionId},[e.activeSession.activeSessionId]),(0,W.useEffect)(()=>{b(localStorage,xe.current,c,[...m,..._]),f(xe.current,m),ue({hasDraft:!!c.trim(),pendingAttachments:m.length+_.length,readingAttachments:te>0})},[c,m,_,te]),(0,W.useEffect)(()=>()=>ue({hasDraft:!1,pendingAttachments:0,readingAttachments:!1}),[]);let Te=(0,W.useRef)(new Map);(0,W.useEffect)(()=>{let t=e.activeSession.activeSessionId;if(!t)return;let n=setTimeout(()=>{(Te.current.get(t)??``)!==c&&(Te.current.set(t,c),R.publishDraft(t,c))},Na);return()=>clearTimeout(n)},[c,e.activeSession.activeSessionId]),(0,W.useLayoutEffect)(()=>{je()},[c]),(0,W.useEffect)(()=>{let e=ve.current;if(!e||typeof ResizeObserver>`u`)return;let t=document.documentElement,n=()=>t.style.setProperty(`--composer-h`,`${Math.round(e.offsetHeight)}px`);n();let r=new ResizeObserver(n);return r.observe(e),()=>{r.disconnect(),t.style.removeProperty(`--composer-h`)}},[]);let Ee=(0,W.useRef)(!1);(0,W.useEffect)(()=>{!t&&Ee.current&&Ra(ge.current)&&ge.current?.focus()},[t]),(0,W.useEffect)(()=>R.onComposerFocus(()=>{Ee.current=!0,requestAnimationFrame(()=>{Ra(ge.current)&&ge.current?.focus()})}),[]),(0,W.useEffect)(()=>R.onComposerPrefill((e,t)=>{let n=e.trim();t.length&&h(e=>[...e,...t]),(n||t.length)&&(n&&l(e=>e.trim()?`${e.trimEnd()}\n\n${n}`:n),C(!1),Ee.current=!0,requestAnimationFrame(()=>{je();let e=ge.current;Ra(e)&&(e?.focus(),e?.setSelectionRange(e.value.length,e.value.length))}))}),[]),(0,W.useEffect)(()=>R.onOpenSlash(()=>{l(e=>e.trimStart().startsWith(`/`)?e:`/`),C(!1),x(0),Ee.current=!0,requestAnimationFrame(()=>{je(),Ra(ge.current)&&ge.current?.focus()})}),[]),rt(()=>P(null),!!ie),(0,W.useEffect)(()=>{!t&&!e.settings.sttConfig&&R.getSttConfig()},[t,e.settings.sttConfig]);function De(){if(t)return;let n=vt(e.settings.sttConfig);n?E(n):o?.(mt)}function Oe(e){let t=e.trim();t&&(l(e=>`${e}${e&&!/\s$/.test(e)?` `:``}${t}`),requestAnimationFrame(()=>{je(),ge.current?.focus()}))}let ke=!t&&!S?N(c,I):[],Ae=(()=>{if(t||S)return!1;let e=c.trimStart();return e.startsWith(`/`)&&!/\s/.test(e)})()&&ke.length===0;function je(){let e=ge.current;e&&(e.style.height=`auto`,e.style.height=Math.min(e.scrollHeight,200)+`px`)}async function Me(e){if(e&&e.length){re(e=>e+1);try{let t=[],n=m.reduce((e,t)=>e+Number(t.size||0),0),r=m.length;for(let i of Array.from(e)){if(r>=Aa){o?.(`A message can include at most ${Aa} attachments.`);break}if(i.size>ka){o?.(`${i.name} is larger than ${za(ka)} and was not attached.`);continue}if(n+i.size>ja){o?.(`Attachments are limited to ${za(ja)} per message.`);continue}n+=i.size,r+=1;try{if(i.type.startsWith(`image/`)){let e=await Fa(i),n=e.includes(`,`)?e.split(`,`).pop()||``:e;t.push({kind:`image`,name:i.name,size:i.size,mimeType:i.type||`image/png`,data:n});continue}if(!(i.type.startsWith(`text/`)||Pa.test(i.name))){let e=await Fa(i),n=e.includes(`,`)?e.split(`,`).pop()||``:e;t.push({kind:`file`,name:i.name,size:i.size,mimeType:i.type||`application/octet-stream`,data:n});continue}let e=await Ia(i);t.push({kind:`file`,name:i.name,size:i.size,mimeType:i.type||`text/plain`,text:e.slice(0,Ma),truncated:e.length>Ma})}catch{n-=i.size,--r,o?.(`Could not read ${i.name}.`)}}t.length&&(h(e=>[...e,...t]),v(e=>e.filter(e=>!t.some(t=>t.name===e.name)))),_e.current&&(_e.current.value=``)}finally{re(e=>Math.max(0,e-1))}}}function Ne(e){h(t=>t.filter((t,n)=>n!==e))}function Pe(){g(localStorage,xe.current),l(``),h([]),v([]),C(!1),x(0),requestAnimationFrame(je)}function Fe(e,t){e.mode===`protocol`?R.invokeAgentCommand(e.name,t):i(t?`${e.name} ${t}`:e.name)}function Ie(e){l(`${e.name} `),C(!0),x(0),requestAnimationFrame(()=>{je(),ge.current?.focus()})}function Le(){let n=c.trim();if(!n&&!m.length||t)return;let r=e.catalogs.currentModel?.id||e.catalogs.currentModelId;if(L&&fe&&(!r||r===`unknown`)){d(`model`);return}if(ne(n)){let e=He(n);if(e){let t=O(e,I);if(t.kind===`agent`){Fe(t.command,t.args),Pe();return}if(t.hasCatalog){o?.(`Unknown command ${t.name}. Type / to see this agent's commands.`);return}}}i(n,m.length?m:void 0),l(``),h([]),requestAnimationFrame(je)}let Re=de?`Choose model`:e.catalogs.currentModel?.label||e.catalogs.currentModel?.id||`Choose a model`,ze=String(ce?.displayName||ce?.name||ce?.id||e.catalogs.currentAgentName||`Choose an agent`),Be=e.draft.repo?e.draft.branch?`${e.draft.repo} @ ${e.draft.branch}`:e.draft.repo:`Choose repository`,Ve=e.draft.repo?e.draft.branch?`Repository ${e.draft.repo} (branch ${e.draft.branch})`:`Repository ${e.draft.repo} (default branch)`:`Choose repository`,Ue=ln.find(t=>t.id===e.draft.sandbox),We=ln.find(t=>t.id===e.settings.nodeSettings?.defaultSandbox),Ge=Ue?Ue.label:We?We.label:e.settings.nodeSettings?.defaultSandbox??`Default`,Ke=e.catalogs.runtimes.find(t=>t.id===e.catalogs.selectedAgentId),qe=tn(Ke)?Ue?Ue.hint:`Protection for this session (machine default)`:`${e.catalogs.currentAgentName||`This agent`} can't ask for approval — treated as full access`,Je=!t&&(!!c.trim()||m.length>0),Ye=L&&!!e.draft.ephemeralConfig;return(0,G.jsxs)(G.Fragment,{children:[L&&(0,G.jsxs)(`div`,{className:`composer-lead`,"aria-label":`Session setup`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`btn sm ghost repo-pill`,onClick:()=>d(`repo`),title:Ve,children:[(0,G.jsx)(Ha,{}),(0,G.jsx)(`span`,{className:`pill-label`,children:Be})]}),(0,G.jsxs)(`button`,{type:`button`,className:`btn sm ghost sandbox-pill`,onClick:()=>d(`sandbox`),title:qe,"aria-label":`Protection: ${Ge}`,children:[(0,G.jsx)(`span`,{className:`pill-glyph`,children:`◈`}),(0,G.jsx)(`span`,{className:`pill-label`,children:Ge})]})]}),ye&&e.activeSession.activeSessionId&&(()=>{let t=e.activeSession.activeSessionId;return(0,G.jsx)(Da,{standby:ye,onOpenOnOwner:()=>R.openSessionOnNode(t,void 0,ye.ownerId),onContinueHere:async()=>{try{await R.promoteSession(t,e.connection.currentNodeId??``),R.store.setNotice(`Continuing this session on this machine.`)}catch(e){R.store.setError(e instanceof Error?e.message:String(e))}}})})(),e.activeSession.activeSessionId&&(0,G.jsx)(Ea,{sessionId:e.activeSession.activeSessionId,composerEmpty:!c.trim(),onUseDraft:e=>{l(e),requestAnimationFrame(()=>{je(),ge.current?.focus()})}}),e.activeSession.activeSessionId&&(0,G.jsx)(xa,{sessionId:e.activeSession.activeSessionId,items:me,canSteer:he,busy:r,onError:o}),j&&(0,G.jsxs)(`div`,{className:`banner`,"data-tone":`warn`,role:`alert`,children:[(0,G.jsx)(`span`,{className:`banner-text`,children:`The agent didn't confirm it stopped.`}),(0,G.jsx)(`button`,{type:`button`,className:`btn sm banner-action`,onClick:()=>location.reload(),children:`Reload`})]}),(0,G.jsx)(`form`,{ref:ve,className:`composer`,onSubmit:e=>{e.preventDefault(),Le()},children:(0,G.jsxs)(`div`,{className:`composer-card${D?` dragging`:``}`,onDragEnter:e=>{!t&&Va(e.dataTransfer)&&(e.preventDefault(),ae.current+=1,k(!0))},onDragOver:e=>{!t&&Va(e.dataTransfer)&&e.preventDefault()},onDragLeave:()=>{ae.current!==0&&(--ae.current,ae.current===0&&k(!1))},onDrop:e=>{!t&&Va(e.dataTransfer)&&(e.preventDefault(),ae.current=0,k(!1),Me(e.dataTransfer.files))},children:[D&&(0,G.jsx)(`div`,{className:`composer-drop`,"aria-hidden":!0,children:(0,G.jsx)(`span`,{children:`Drop files to attach`})}),ke.length>0&&(0,G.jsx)(`div`,{className:`menu slash-menu`,role:`listbox`,"aria-label":`Commands`,children:ke.map((e,t)=>{let n=Math.min(y,ke.length-1);return(0,G.jsxs)(`button`,{type:`button`,className:`menu-item slash-item${t===n?` active`:``}`,role:`option`,"aria-selected":t===n,onMouseDown:t=>{t.preventDefault(),Ie(e)},children:[(0,G.jsx)(`span`,{className:`slash-name`,children:e.name}),(0,G.jsx)(`span`,{className:`slash-desc`,children:e.description})]},e.name)})}),Ae&&(0,G.jsx)(`div`,{className:`menu slash-menu slash-empty`,role:`status`,children:I.length===0?`This agent has no slash commands.`:`No matching command — press Esc to send as a message.`}),_.length>0&&(0,G.jsxs)(`div`,{className:`attachment-recovery`,role:`status`,children:[(0,G.jsxs)(`span`,{children:[`Reload preserved metadata for `,_.map(e=>e.name).join(`, `),`, not file contents. Re-select before sending.`]}),(0,G.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:()=>v([]),children:`Clear`})]}),(m.length>0||te>0)&&(0,G.jsxs)(`div`,{className:`attach-chips`,children:[te>0&&(0,G.jsxs)(`span`,{className:`attach-chip reading`,"aria-live":`polite`,children:[(0,G.jsx)(V,{size:`xs`}),`Reading file`,te>1?`s`:``,`…`]}),m.map((e,t)=>{let n=Ba(e);return(0,G.jsxs)(`span`,{className:`attach-chip${e.omitted?` omitted`:``}${n?` has-thumb`:``}`,title:e.omitted?`File could not be read — not attached`:e.name,children:[n?(0,G.jsx)(`button`,{type:`button`,className:`attach-thumb-btn`,onClick:()=>P(n),"aria-label":`View ${e.name}`,title:`View ${e.name}`,children:(0,G.jsx)(`img`,{className:`attach-thumb`,src:n,alt:e.name})}):(0,G.jsx)(`span`,{className:`attach-glyph`,children:e.kind===`image`?`🖼`:`📄`}),(0,G.jsx)(`span`,{className:`attach-name`,children:e.name}),(0,G.jsx)(`button`,{type:`button`,className:`attach-remove`,onClick:()=>Ne(t),"aria-label":`Remove ${e.name}`,children:`✕`})]},`${e.name}-${t}`)})]}),T&&(0,G.jsx)(wt,{engine:T,onResult:Oe,onCancel:()=>E(null),onError:e=>o?.(e)}),(0,G.jsx)(`textarea`,{ref:ge,className:`composer-input`,placeholder:t?n||`Connecting…`:Ye?`Describe your first task…`:`Message your agent…`,rows:2,hidden:!!T,value:c,disabled:t,onFocus:()=>{Ee.current=!0},onBlur:()=>{t||(Ee.current=!1)},onPaste:e=>{let t=e.clipboardData?.files;t&&t.length&&Array.from(t).some(e=>e.type.startsWith(`image/`))&&(e.preventDefault(),Me(t))},onChange:e=>{l(e.target.value),C(!1),x(0),je()},onKeyDown:e=>{if(ke.length>0){if(e.key===`ArrowDown`){e.preventDefault(),x(e=>Math.min(e+1,ke.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),x(e=>Math.max(e-1,0));return}if(e.key===`Escape`){e.preventDefault(),C(!0);return}if(e.key===`Enter`&&!e.shiftKey||e.key===`Tab`){e.preventDefault();let t=ke[Math.min(y,ke.length-1)];t&&Ie(t);return}}e.key!==`Enter`||e.shiftKey||La()||(e.preventDefault(),Le())}}),(0,G.jsxs)(`div`,{className:`composer-actions`,hidden:!!T,children:[(0,G.jsx)(`input`,{ref:_e,type:`file`,multiple:!0,hidden:!0,onChange:e=>void Me(e.target.files)}),(0,G.jsxs)(`div`,{className:`composer-meta`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn sm ghost attach-pill`,onClick:()=>_e.current?.click(),disabled:t,title:`Attach files`,"aria-label":`Attach files`,children:(0,G.jsx)(`span`,{className:`pill-glyph`,children:(0,G.jsx)(Wa,{})})}),(0,G.jsxs)(`button`,{type:`button`,className:`btn sm ghost agent-pill`,onClick:()=>d(`agent`),title:`Agent: ${ze}`,children:[(0,G.jsx)(`span`,{className:`pill-glyph`,children:(0,G.jsx)(Ga,{})}),(0,G.jsx)(`span`,{className:`pill-label`,children:ze})]}),(0,G.jsxs)(`button`,{type:`button`,className:`btn sm ghost model-pill`,"data-pending-model":de||void 0,onClick:()=>{fe&&d(`model`)},disabled:!fe,title:fe?`Model: ${Re}`:de?`Choose a model after startup, before your saved first message is sent`:`This agent uses its own default model`,children:[(0,G.jsx)(`span`,{className:`pill-glyph`,children:(0,G.jsx)(Ka,{})}),(0,G.jsx)(`span`,{className:`pill-label`,children:e.catalogs.currentModel&&!de?qa(Re,ze):Re})]})]}),(0,G.jsx)(`button`,{type:`button`,className:`composer-btn mic`,onClick:De,disabled:t,title:`Voice input`,"aria-label":`Voice input`,children:(0,G.jsx)(Ua,{})}),r&&Je&&he&&(0,G.jsx)(`button`,{type:`button`,className:`composer-btn steer`,onClick:()=>{R.steerNow(c,m.length?m:void 0)&&Pe()},title:`Steer current turn — inject this now instead of queueing it`,"aria-label":`Steer current turn`,children:`⚡`}),r&&!c.trim()&&(0,G.jsx)(`button`,{type:`button`,className:`composer-btn stop${A?` is-stopping`:``}`,onClick:oe,title:A?`Stopping`:`Stop`,"aria-label":A?`Stopping current turn`:`Stop current turn`,disabled:A,children:A?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`span`,{className:`working-dots`,"aria-hidden":!0,children:[(0,G.jsx)(`i`,{}),(0,G.jsx)(`i`,{}),(0,G.jsx)(`i`,{})]}),(0,G.jsx)(`span`,{children:`Stopping…`})]}):(0,G.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,"aria-hidden":!0,children:(0,G.jsx)(`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`3`,fill:`currentColor`})})}),(!r||Je)&&(0,G.jsx)(`button`,{type:`submit`,className:`composer-btn send`,disabled:!Je,title:r?`Queue follow-up`:Ye?`Launch Machine and send task`:`Send`,"aria-label":Ye?`Launch Machine and send task`:r?`Queue follow-up`:`Send`,children:(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`20`,height:`20`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:[(0,G.jsx)(`path`,{d:`M12 19V5`}),(0,G.jsx)(`path`,{d:`m5 12 7-7 7 7`})]})})]})]})}),u===`repo`&&(0,G.jsx)(sa,{state:e,onClose:()=>d(null)}),u===`sandbox`&&(0,G.jsx)(la,{state:e,onClose:()=>d(null)}),u===`agent`&&(0,G.jsx)(da,{state:e,onClose:()=>d(null)}),u===`model`&&fe&&(0,G.jsx)(ma,{state:e,onClose:()=>d(null)}),ie&&(0,G.jsx)(xt,{src:ie,name:`Attachment preview`,onClose:()=>P(null)},ie)]})}function Ya(e,t){let n=String(e||``);return!!t.find(e=>e.id===n||e.id===`${n}-approvals`||e.id===`${n}-code-sdk`)?.capabilities?.sessionDiscovery}var Xa=`bivy.speech.preferences.v1`,Za={reader:`browser`,browserVoice:``,rate:1,openaiVoice:`coral`,tone:`natural`},Qa=[`alloy`,`ash`,`ballad`,`coral`,`echo`,`fable`,`nova`,`onyx`,`sage`,`shimmer`,`verse`],$a=[{id:`natural`,label:`Natural`,instructions:`Speak naturally and conversationally, with clear phrasing and subtle expression.`},{id:`calm`,label:`Calm`,instructions:`Speak calmly and evenly at a relaxed pace, with a reassuring tone.`},{id:`warm`,label:`Warm`,instructions:`Speak with a warm, friendly, empathetic tone.`},{id:`energetic`,label:`Energetic`,instructions:`Speak with upbeat energy and engaging emphasis, without sounding exaggerated.`},{id:`professional`,label:`Professional`,instructions:`Speak clearly and confidently in a polished, professional tone.`}];function eo(){try{let e=JSON.parse(localStorage.getItem(Xa)||`{}`);return{reader:e.reader===`openai`?`openai`:`browser`,browserVoice:typeof e.browserVoice==`string`?e.browserVoice:``,rate:typeof e.rate==`number`&&e.rate>=.7&&e.rate<=1.5?e.rate:1,openaiVoice:Qa.includes(e.openaiVoice||``)?e.openaiVoice:Za.openaiVoice,tone:$a.some(t=>t.id===e.tone)?e.tone:Za.tone}}catch{return{...Za}}}function to(e){localStorage.setItem(Xa,JSON.stringify(e))}function no(e){return $a.find(t=>t.id===e)?.instructions??`Speak naturally and conversationally.`}function ro(){return typeof window<`u`&&`speechSynthesis`in window&&typeof SpeechSynthesisUtterance<`u`}function io(){return typeof window<`u`&&(ro()||typeof Audio<`u`)}function ao(e){return e.split(`
|
|
@@ -20,7 +20,7 @@ Error generating stack: `+e.message+`
|
|
|
20
20
|
`).replace(Zf,``)}function $f(e,t){return t=Qf(t),Qf(e)===t}function ep(e,t,n,r,a,o){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||sn(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&sn(e,``+r);else return;break;case`className`:Kt(e,`class`,r);break;case`tabIndex`:Kt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Kt(e,n,r);break;case`style`:un(e,r,o);return;case`data`:if(t!==`object`){Kt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=mn(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof o==`function`&&(n===`formAction`?(t!==`input`&&ep(e,t,`name`,a.name,a,null),ep(e,t,`formEncType`,a.formEncType,a,null),ep(e,t,`formMethod`,a.formMethod,a,null),ep(e,t,`formTarget`,a.formTarget,a,null)):(ep(e,t,`encType`,a.encType,a,null),ep(e,t,`method`,a.method,a,null),ep(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=mn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=hn);return;case`onScroll`:r!=null&&$(`scroll`,e);return;case`onScrollEnd`:r!=null&&$(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=mn(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:$(`beforetoggle`,e),$(`toggle`,e),Gt(e,`popover`,r);break;case`xlinkActuate`:qt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:qt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:qt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:qt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:qt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:qt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:qt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:qt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:qt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Gt(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=fn.get(n)||n,Gt(e,n,r);else return}B=!0}function tp(e,t,n,r,a,o){switch(n){case`style`:un(e,r,o);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)sn(e,r);else if(typeof r==`number`||typeof r==`bigint`)sn(e,``+r);else return;break;case`onScroll`:r!=null&&$(`scroll`,e);return;case`onScrollEnd`:r!=null&&$(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=hn);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!Lt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),o=n.slice(2,a?n.length-7:void 0),t=e[xt]||null,t=t==null?null:t[n],typeof t==`function`&&e.removeEventListener(o,t,a),typeof r==`function`)){typeof t!=`function`&&t!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(o,r,a);break a}B=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):Gt(e,n,r)}return}B=!0}function np(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:$(`error`,e),$(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:ep(e,t,o,s,n,null)}}a&&ep(e,t,`srcSet`,n.srcSet,n,null),r&&ep(e,t,`src`,n.src,n,null);return;case`input`:$(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:ep(e,t,r,d,n,null)}}tn(e,o,c,l,u,s,a,!1);return;case`select`:for(a in $(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:ep(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&rn(e,!!r,n,!0):rn(e,!!r,t,!1);return;case`textarea`:for(s in $(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:ep(e,t,s,c,n,null)}on(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:ep(e,t,l,r,n,null)}return;case`dialog`:$(`beforetoggle`,e),$(`toggle`,e),$(`cancel`,e),$(`close`,e);break;case`iframe`:case`object`:$(`load`,e);break;case`video`:case`audio`:for(r=0;r<Rf.length;r++)$(Rf[r],e);break;case`image`:$(`error`,e),$(`load`,e);break;case`details`:$(`toggle`,e);break;case`embed`:case`source`:case`link`:$(`error`,e),$(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:ep(e,t,u,r,n,null)}return;default:if(dn(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&tp(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&ep(e,t,c,r,n,null))}var rp={};function ip(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||ep(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:m!==f&&(B=!0),o=m;break;case`name`:m!==f&&(B=!0),a=m;break;case`checked`:m!==f&&(B=!0),u=m;break;case`defaultChecked`:m!==f&&(B=!0),d=m;break;case`value`:m!==f&&(B=!0),s=m;break;case`defaultValue`:m!==f&&(B=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&ep(e,t,p,m,r,f)}}en(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||ep(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:o!==l&&(B=!0),p=o;break;case`defaultValue`:o!==l&&(B=!0),c=o;break;case`multiple`:o!==l&&(B=!0),s=o;default:o!==l&&ep(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?rn(e,!!n,n?[]:``,!1):rn(e,!!n,t,!0)):rn(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:ep(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:a!==o&&(B=!0),p=a;break;case`defaultValue`:a!==o&&(B=!0),m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&ep(e,t,s,a,r,o)}an(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:ep(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:p!==m&&(B=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:ep(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&ep(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:ep(e,t,u,p,r,m)}return;default:if(dn(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&tp(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||tp(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&ep(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||ep(e,t,f,p,r,m)}function ap(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function op(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&ap(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&ap(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var sp=null,cp=null;function lp(e){return e.nodeType===9?e:e.ownerDocument}function up(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function dp(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function fp(e,t,n,r){return n=lp(n).createElement(e),n[bt]=r,n[xt]=t,np(n,e,t),Pt(n),n}function pp(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var mp=null;function hp(){var e=window.event;return e&&e.type===`popstate`?e!==mp&&(mp=e,!0):(mp=null,!1)}var gp=typeof setTimeout==`function`?setTimeout:void 0,_p=typeof clearTimeout==`function`?clearTimeout:void 0,vp=typeof Promise==`function`?Promise:void 0,yp=typeof requestAnimationFrame==`function`?requestAnimationFrame:gp,bp=typeof queueMicrotask==`function`?queueMicrotask:vp===void 0?gp:function(e){return vp.resolve(null).then(e).catch(xp)};function xp(e){setTimeout(function(){throw e})}function Sp(e){return e===`head`}function Cp(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Hh(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)_m(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,_m(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[Dt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&_m(e.ownerDocument.body)}n=i}while(n);Hh(t)}function wp(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function Tp(e,t,n){if(t=CSS.escape(t)===t?t:`r-`+btoa(t).replace(/=/g,``),e.style.viewTransitionName=t,n!=null&&(e.style.viewTransitionClass=n),n=getComputedStyle(e),n.display===`inline`){if(t=e.getClientRects(),t.length===1)var r=1;else for(var i=r=0;i<t.length;i++){var a=t[i];0<a.width&&0<a.height&&r++}r===1&&(e=e.style,e.display=t.length===1?`inline-block`:`block`,e.marginTop=`-`+n.paddingTop,e.marginBottom=`-`+n.paddingBottom)}}function Ep(e,t){e=e.style,t=t.style;var n=t==null?null:t.hasOwnProperty(`viewTransitionName`)?t.viewTransitionName:t.hasOwnProperty(`view-transition-name`)?t[`view-transition-name`]:null;e.viewTransitionName=n==null||typeof n==`boolean`?``:(``+n).trim(),n=t==null?null:t.hasOwnProperty(`viewTransitionClass`)?t.viewTransitionClass:t.hasOwnProperty(`view-transition-class`)?t[`view-transition-class`]:null,e.viewTransitionClass=n==null||typeof n==`boolean`?``:(``+n).trim(),e.display===`inline-block`&&(t==null?e.display=e.margin=``:(n=t.display,e.display=n==null||typeof n==`boolean`?``:n,n=t.margin,n==null?(n=t.hasOwnProperty(`marginTop`)?t.marginTop:t[`margin-top`],e.marginTop=n==null||typeof n==`boolean`?``:n,t=t.hasOwnProperty(`marginBottom`)?t.marginBottom:t[`margin-bottom`],e.marginBottom=t==null||typeof t==`boolean`?``:t):e.margin=n))}function Dp(e,t,n){return n=n.ownerDocument.defaultView,{rect:e,abs:t.position===`absolute`||t.position===`fixed`,clip:t.clipPath!==`none`||t.overflow!==`visible`||t.filter!==`none`||t.mask!==`none`||t.mask!==`none`||t.borderRadius!==`0px`,view:0<=e.bottom&&0<=e.right&&e.top<=n.innerHeight&&e.left<=n.innerWidth}}function Op(e){return Dp(e.getBoundingClientRect(),getComputedStyle(e),e)}function kp(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return Dp(t,n,e)}function Ap(e){return e.documentElement.clientHeight}function jp(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function Mp(e,t,n,r,i,a,o,s,c){var l=t.nodeType===9?t:t.ownerDocument;try{var u=l.startViewTransition({update:function(){var t=l.defaultView,n=t.navigation&&t.navigation.transition,o=l.fonts.status;r();var s=[];if(o===`loaded`&&(Ap(l),l.fonts.status===`loading`&&s.push(l.fonts.ready)),o=s.length,e!==null)for(var c=e.suspenseyImages,u=0,d=0;d<c.length;d++){var f=c[d];if(!f.complete){var p=f.getBoundingClientRect();if(0<p.bottom&&0<p.right&&p.top<t.innerHeight&&p.left<t.innerWidth){if(u+=Xm(f),u>$m){s.length=o;break}f=new Promise(jp.bind(f)),s.push(f)}}}if(0<s.length)return t=Promise.race([Promise.all(s),new Promise(function(e){return setTimeout(e,500)})]).then(i,i),(n?Promise.allSettled([n.finished,t]):t).then(a,a);if(i(),n)return n.finished.then(a,a);a()},types:n});l.__reactViewTransition=u;var d=[];return u.ready.then(function(){for(var e=l.documentElement.getAnimations({subtree:!0}),t=0;t<e.length;t++){var n=e[t],r=n.effect,i=r.pseudoElement;if(i!=null&&i.startsWith(`::view-transition`)){d.push(n),n=r.getKeyframes();for(var a=i=void 0,s=!0,c=0;c<n.length;c++){var u=n[c],f=u.width;if(i===void 0)i=f;else if(i!==f){s=!1;break}if(f=u.height,a===void 0)a=f;else if(a!==f){s=!1;break}delete u.width,delete u.height,u.transform===`none`&&delete u.transform}s&&i!==void 0&&a!==void 0&&(r.setKeyframes(n),s=getComputedStyle(r.target,r.pseudoElement),s.width!==i||s.height!==a)&&(s=n[0],s.width=i,s.height=a,s=n[n.length-1],s.width=i,s.height=a,r.setKeyframes(n))}}o()},function(e){l.__reactViewTransition===u&&(l.__reactViewTransition=null);try{if(typeof e==`object`&&e)switch(e.name){case`InvalidStateError`:(e.message===`View transition was skipped because document visibility state is hidden.`||e.message===`Skipping view transition because document visibility state has become hidden.`||e.message===`Skipping view transition because viewport size changed.`||e.message===`Transition was aborted because of invalid state`)&&(e=null)}e!==null&&c(e)}finally{r(),i(),o()}}),u.finished.finally(function(){for(var e=0;e<d.length;e++)d[e].cancel();l.__reactViewTransition===u&&(l.__reactViewTransition=null),s()}),u}catch{return r(),i(),o(),null}}function Np(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Np.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:w({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Np.prototype.getAnimations=function(){for(var e=this._scope,t=this._selector,n=e.getAnimations({subtree:!0}),r=[],i=0;i<n.length;i++){var a=n[i].effect;a!==null&&a.target===e&&a.pseudoElement===t&&r.push(n[i])}return r},Np.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Pp(e){return{name:e,group:new Np(`group`,e),imagePair:new Np(`image-pair`,e),old:new Np(`old`,e),new:new Np(`new`,e)}}function Fp(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}Fp.prototype.addEventListener=function(e,t,n){var r=null,i=null;if(!(n!=null&&typeof n!=`boolean`&&(r=n.signal||null,r!==null&&r.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var a=this._eventListeners;if(Bp(a,e,t,n)===-1){var o=this,s=t;n!=null&&typeof n!=`boolean`&&!0===n.once&&(s=function(r){o.removeEventListener(e,t,n),typeof t==`function`?t.call(this,r):t.handleEvent(r)}),r!==null&&(i=o.removeEventListener.bind(o,e,t,n),r.addEventListener(`abort`,i,{once:!0}),i=r.removeEventListener.bind(r,`abort`,i)),r=Rp(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),f(this._fragmentFiber.child,!1,Ip,e,s,r)}this._eventListeners=a}};function Ip(e,t,n,r){return _(e).addEventListener(t,n,r),!1}Fp.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=Bp(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=Rp(i.optionsOrUseCapture),f(this._fragmentFiber.child,!1,Lp,e,n,i),r.splice(t,1),a!==null&&a()}};function Lp(e,t,n,r){return _(e).removeEventListener(t,n,r),!1}function Rp(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function zp(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function Bp(e,t,n,r){if(e.length===0)return-1;r=zp(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&zp(a.optionsOrUseCapture)===r)return i}return-1}Fp.prototype.dispatchEvent=function(e){var t=p(this._fragmentFiber);if(t===null)return!0;t=_(t);var n=this._eventListeners;if(n!==null&&0<n.length||!e.bubbles){var r=t.nodeType===9?t.createComment(``):document.createTextNode(``);if(n)for(var i=0;i<n.length;i++){var a=n[i];r.addEventListener(a.type,a.attachedListener,Rp(a.optionsOrUseCapture))}if(t.appendChild(r),e=r.dispatchEvent(e),n)for(i=0;i<n.length;i++)a=n[i],r.removeEventListener(a.type,a.attachedListener,Rp(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},Fp.prototype.focus=function(e){f(this._fragmentFiber.child,!0,Vp,e,void 0,void 0)};function Vp(e,t){return e.tag!==6&&(e=_(e),pm(e,t))}Fp.prototype.focusLast=function(e){var t=[];f(this._fragmentFiber.child,!0,Hp,t,void 0,void 0);for(var n=t.length-1;0<=n&&!Vp(t[n],e);n--);};function Hp(e,t){return t.push(e),!1}Fp.prototype.blur=function(){var e=p(this._fragmentFiber);e!==null&&(e=_(e),e=lp(e).activeElement,e!==null&&f(this._fragmentFiber.child,!1,Up,e,void 0,void 0))};function Up(e,t){return e.tag!==6&&(e=_(e),e===t||e.contains(t)?(t.blur(),!0):!1)}Fp.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),f(this._fragmentFiber.child,!1,Wp,e,void 0,void 0)};function Wp(e,t){return e.tag!==6&&(e=_(e),t.observe(e),!1)}Fp.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),f(this._fragmentFiber.child,!1,Gp,e,void 0,void 0);for(var n=t=0;n<Kp.length;n++){var r=Kp[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):Kp[t++]=r}Kp.length=t}};function Gp(e,t){return e.tag!==6&&(e=_(e),t.unobserve(e),!1)}var Kp=[],qp=!1;function Jp(e,t,n){Kp.push({fragmentInstance:e,observer:t,instance:n}),qp||(qp=!0,mm(function(){qp=!1;var e=Kp;Kp=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}Fp.prototype.getClientRects=function(){var e=[];return f(this._fragmentFiber.child,!1,Yp,e,void 0,void 0),e};function Yp(e,t){if(e.tag===6){e=e.stateNode;var n=e.ownerDocument.createRange();n.selectNodeContents(e),t.push.apply(t,n.getClientRects())}else e=_(e),t.push.apply(t,e.getClientRects());return!1}Fp.prototype.getRootNode=function(e){var t=p(this._fragmentFiber);return t===null?this:_(t).getRootNode(e)},Fp.prototype.compareDocumentPosition=function(e){var t=p(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];f(this._fragmentFiber.child,!1,Hp,n,void 0,void 0);var r=_(t);if(n.length===0){if(n=r,m(this._fragmentFiber)){a:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break a}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(n=t)}t=this._fragmentFiber;var i=r=n.compareDocumentPosition(e);return n===e?i=Node.DOCUMENT_POSITION_CONTAINS:r&Node.DOCUMENT_POSITION_CONTAINED_BY&&(n=h(t)[1],n===null?i=Node.DOCUMENT_POSITION_PRECEDING:(e=_(n).compareDocumentPosition(e),i=e===0||e&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),i|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=_(n[0]),i=_(n[n.length-1]);var a=m(this._fragmentFiber)?t.parentElement:r;if(a==null)return Node.DOCUMENT_POSITION_DISCONNECTED;r=a.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,a=a.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY;var o=t.compareDocumentPosition(e),s=i.compareDocumentPosition(e),c=o&Node.DOCUMENT_POSITION_CONTAINED_BY||s&Node.DOCUMENT_POSITION_CONTAINED_BY;return s=r&&a&&o&Node.DOCUMENT_POSITION_FOLLOWING&&s&Node.DOCUMENT_POSITION_PRECEDING,t=r&&t===e||a&&i===e||c||s?Node.DOCUMENT_POSITION_CONTAINED_BY:!r&&t===e||!a&&i===e?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:o,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||Xp(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function Xp(e,t,n,r,i){var a=At(i);if(e&Node.DOCUMENT_POSITION_CONTAINED_BY){if(n=!!a)a:{for(;a!==null;){if(a.tag===7&&(a===t||a.alternate===t)){n=!0;break a}a=a.return}n=!1}return n}if(e&Node.DOCUMENT_POSITION_CONTAINS){if(a===null)return a=i.ownerDocument,i===a||i===a.documentElement||i===a.body;a:{for(a=t,t=p(t);a!==null;){if(!(a.tag!==5&&a.tag!==3&&a.tag!==27||a!==t&&a.alternate!==t)){a=!0;break a}a=a.return}a=!1}return a}return e&Node.DOCUMENT_POSITION_PRECEDING?((t=!!a)&&!(t=a===n)&&(t=C(n,a,S),t===null?t=!1:(f(t,!0,b,a,n),a=v,v=null,t=a!==null)),t):e&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!a)&&!(t=a===r)&&(t=C(r,a,S),t===null?t=!1:(f(t,!0,x,a,r),a=v,y=v=null,t=a!==null)),t):!1}function Zp(e,t){var n=e.ownerDocument.createRange();n.selectNodeContents(e),e=n.getBoundingClientRect(),window.scrollTo(window.scrollX+e.left,t?window.scrollY+e.top:window.scrollY+e.bottom-window.innerHeight)}Fp.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(i(566));var t=[];f(this._fragmentFiber.child,!1,Hp,t,void 0,void 0);var n=!1!==e;if(t.length===0){var r=h(this._fragmentFiber);if(r=n?r[1]||r[0]||p(this._fragmentFiber):r[0]||r[1],r===null)return;if(r.tag===6){e=_(r),Zp(e,n);return}if(r=_(r),r.nodeType!==9){if(r.nodeType===11){n=`host`in r?r.host:null,n!==null&&n.scrollIntoView(e);return}r.scrollIntoView(e)}}for(r=n?t.length-1:0;r!==(n?-1:t.length);){var a=t[r];a.tag===6?(a=_(a),Zp(a,n)):_(a).scrollIntoView(e),r+=n?-1:1}};function Qp(e,t){return e=_(e),$p(e,t),!1}function $p(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function em(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.addEventListener(i.type,i.attachedListener,Rp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<Kp.length;i++){var a=Kp[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(Kp[r++]=a)}Kp.length=r,n.observe(e)}),$p(e,t))}function tm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.removeEventListener(i.type,i.attachedListener,Rp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?Jp(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function nm(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:nm(n),kt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function rm(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[Dt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=lm(e.nextSibling),e===null)break}return null}function im(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=lm(e.nextSibling),e===null))return null;return e}function am(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=lm(e.nextSibling),e===null))return null;return e}function om(e){return e.data===`$?`||e.data===`$~`}function sm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function cm(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function lm(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var um=null;function dm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return lm(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function fm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function pm(e,t){function n(){r=!0}if(e.ownerDocument.activeElement===e)return!0;var r=!1;try{e.ownerDocument.addEventListener(`focus`,n,!0),(e.focus||HTMLElement.prototype.focus).call(e,t)}finally{e.ownerDocument.removeEventListener(`focus`,n,!0)}return r}function mm(e){yp(function(){yp(function(t){return e(t)})})}function hm(e,t,n){switch(t=lp(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function gm(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&ep(e,t,r,null,rp,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===hn&&(e.onclick=null),kt(e)}function _m(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);kt(e)}var vm=new Map,ym=new Set;function bm(e){if(typeof e.getRootNode==`function`){var t=e.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return e.nodeType===9?e:e.ownerDocument}var xm=I.d;I.d={f:Sm,r:Cm,D:Em,C:Dm,L:Om,m:km,X:jm,S:Am,M:Mm};function Sm(){var e=xm.f(),t=Ld();return e||t}function Cm(e){var t=jt(e);t!==null&&t.tag===5&&t.type===`form`?Qs(t):xm.r(e)}var wm=typeof document>`u`?null:document;function Tm(e,t,n){var r=wm;if(r&&typeof t==`string`&&t){var i=$t(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),ym.has(i)||(ym.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),np(t,`link`,e),Pt(t),r.head.appendChild(t)))}}function Em(e){xm.D(e),Tm(`dns-prefetch`,e,null)}function Dm(e,t){xm.C(e,t),Tm(`preconnect`,e,t)}function Om(e,t,n){xm.L(e,t,n);var r=wm;if(r&&e&&t){var i=`link[rel="preload"][as="`+$t(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+$t(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+$t(n.imageSizes)+`"]`)):i+=`[href="`+$t(e)+`"]`;var a=i;switch(t){case`style`:a=Pm(e);break;case`script`:a=Rm(e)}if(!(vm.has(a)||(e=w({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Fm(a))||t===`script`&&r.querySelector(zm(a))))){var o=r.createElement(`link`);np(o,`link`,e),t===`style`&&(o[Ot]=!0,o.onload=o.onerror=function(){Ft(o)}),Pt(o),r.head.appendChild(o)}}}function km(e,t){xm.m(e,t);var n=wm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+$t(r)+`"][href="`+$t(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rm(e)}if(!vm.has(a)&&(e=w({rel:`modulepreload`,href:e},t),vm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zm(a)))return}r=n.createElement(`link`),np(r,`link`,e),Pt(r),n.head.appendChild(r)}}}function Am(e,t,n){xm.S(e,t,n);var r=wm;if(r&&e){var i=Nt(r).hoistableStyles,a=Pm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Fm(a)))s.loading=5;else{e=w({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vm.get(a))&&Hm(e,n);var c=o=r.createElement(`link`);Pt(c),np(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jm(e,t){xm.X(e,t);var n=wm;if(n&&e){var r=Nt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=w({src:e,async:!0},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Pt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mm(e,t){xm.M(e,t);var n=wm;if(n&&e){var r=Nt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=w({src:e,async:!0,type:`module`},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Pt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nm(e,t,n,r){var a=(a=R.current)?bm(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Pm(n.href),t=Nt(a).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pm(n.href);var o=Nt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Fm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=vm.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},vm.set(e,o)),Lm(a,e,o,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Rm(n),t=Nt(a).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Pm(e){return`href="`+$t(e)+`"`}function Fm(e){return`link[rel="stylesheet"][`+e+`]`}function Im(e){return w({},e,{"data-precedence":e.precedence,precedence:null})}function Lm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Ot]){r.loading=1;return}}else t=e.createElement(`link`),t[Ot]=!0,t.onload=t.onerror=Ft.bind(null,t),np(t,`link`,n),Pt(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Rm(e){return`[src="`+$t(e)+`"]`}function zm(e){return`script[async]`+e}function Bm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+$t(n.href)+`"]`);if(r)return t.instance=r,Pt(r),r;var a=w({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Pt(r),np(r,`style`,a),Vm(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Pm(n.href);var o=e.querySelector(Fm(a));if(o)return t.state.loading|=4,t.instance=o,Pt(o),o;r=Im(n),(a=vm.get(a))&&Hm(r,a),o=(e.ownerDocument||e).createElement(`link`),Pt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),np(o,`link`,r),t.state.loading|=4,Vm(o,n.precedence,e),t.instance=o;case`script`:return o=Rm(n.src),(a=e.querySelector(zm(o)))?(t.instance=a,Pt(a),a):(r=n,(a=vm.get(o))&&(r=w({},n),Um(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),Pt(a),np(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vm(r,n.precedence,e));return t.instance}function Vm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Hm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Um(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Wm=null;function Gm(e,t,n){if(Wm===null){var r=new Map,i=Wm=new Map;i.set(n,r)}else i=Wm,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[Dt]||a[bt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Km(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function qm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Ym(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Xm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Zm(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Xm(t),e.suspenseyImages.push(t)),e=rh.bind(e),t.decode().then(e,e))}function Qm(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pm(r.href),a=t.querySelector(Fm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=nh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Pt(a);return}a=t.ownerDocument||t,r=Im(r),(i=vm.get(i))&&Hm(r,i),a=a.createElement(`link`),Pt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),np(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=nh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var $m=0;function eh(e,t){return e.stylesheets&&e.count===0&&ah(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&ah(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&$m===0&&($m=62500*op());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&ah(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>$m?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function th(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)ah(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function nh(){this.count--,th(this)}function rh(){this.imgCount--,th(this)}var ih=null;function ah(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ih=new Map,t.forEach(oh,e),ih=null,nh.call(e))}function oh(e,t){if(!(t.state.loading&4)){var n=ih.get(e);if(n)var r=n.get(null);else{n=new Map,ih.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=nh.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var sh={$$typeof:M,Provider:null,Consumer:null,_currentValue:me,_currentValue2:me,_threadCount:0};function ch(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=lt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=lt(0),this.hiddenUpdates=lt(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function lh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new ch(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Ti(3,null,null,t),e.current=a,a.stateNode=e,t=Ta(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},co(a),e}function uh(e){return e?(e=Ci,e):Ci}function dh(e,t,n,r,i,a){i=uh(i),r.context===null?r.context=i:r.pendingContext=i,r=uo(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=fo(e,r,t),n!==null&&(Md(n,e,t),po(n,e,t))}function fh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ph(e,t){fh(e,t),(e=e.alternate)&&fh(e,t)}function mh(e){if(e.tag===13||e.tag===31){var t=bi(e,67108864);t!==null&&Md(t,e,67108864),ph(e,67108864)}}function hh(e){if(e.tag===13||e.tag===31){var t=kd();t=ht(t);var n=bi(e,t);n!==null&&Md(n,e,t),ph(e,t)}}var gh=!0;function _h(e,t,n,r){var i=F.T;F.T=null;var a=I.p;try{I.p=2,yh(e,t,n,r)}finally{I.p=a,F.T=i}}function vh(e,t,n,r){var i=F.T;F.T=null;var a=I.p;try{I.p=8,yh(e,t,n,r)}finally{I.p=a,F.T=i}}function yh(e,t,n,r){if(gh){var i=bh(r);if(i===null)Gf(e,t,r,xh,n),Mh(e,r);else if(Ph(i,e,t,n,r))r.stopPropagation();else if(Mh(e,r),t&4&&-1<jh.indexOf(e)){for(;i!==null;){var a=jt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=it(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Ze(o);s.entanglements[1]|=c,o&=~c}Tf(a),!(X&6)&&(md=Re()+500,Ef(0,!1))}}break;case 31:case 13:s=bi(a,2),s!==null&&Md(s,a,2),Ld(),ph(a,2)}if(a=bh(r),a===null&&Gf(e,t,r,xh,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Gf(e,t,r,null,n)}}function bh(e){return e=_n(e),Sh(e)}var xh=null;function Sh(e){if(xh=null,e=At(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return xh=e,null}function Ch(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`fullscreenerror`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`resize`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(ze()){case Be:return 2;case Ve:return 8;case He:case Ue:return 32;case We:return 268435456;default:return 32}default:return 32}}var wh=!1,Th=null,Eh=null,Dh=null,Oh=new Map,kh=new Map,Ah=[],jh=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Mh(e,t){switch(e){case`focusin`:case`focusout`:Th=null;break;case`dragenter`:case`dragleave`:Eh=null;break;case`mouseover`:case`mouseout`:Dh=null;break;case`pointerover`:case`pointerout`:Oh.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:kh.delete(t.pointerId)}}function Nh(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=jt(t),t!==null&&mh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Ph(e,t,n,r,i){switch(t){case`focusin`:return Th=Nh(Th,e,t,n,r,i),!0;case`dragenter`:return Eh=Nh(Eh,e,t,n,r,i),!0;case`mouseover`:return Dh=Nh(Dh,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Oh.set(a,Nh(Oh.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,kh.set(a,Nh(kh.get(a)||null,e,t,n,r,i)),!0}return!1}function Fh(e){var t=At(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,vt(e.priority,function(){hh(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,vt(e.priority,function(){hh(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ih(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=bh(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);gn=r,n.target.dispatchEvent(r),gn=null}else return t=jt(n),t!==null&&mh(t),e.blockedOn=n,!1;t.shift()}return!0}function Lh(e,t,n){Ih(e)&&n.delete(t)}function Rh(){wh=!1,Th!==null&&Ih(Th)&&(Th=null),Eh!==null&&Ih(Eh)&&(Eh=null),Dh!==null&&Ih(Dh)&&(Dh=null),Oh.forEach(Lh),kh.forEach(Lh)}function zh(e,n){e.blockedOn===n&&(e.blockedOn=null,wh||(wh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Rh)))}var Bh=null;function Vh(e){Bh!==e&&(Bh=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Bh===e&&(Bh=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(Sh(r||n)===null)continue;break}var a=jt(n);a!==null&&(e.splice(t,3),t-=3,Xs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Hh(e){function t(t){return zh(t,e)}Th!==null&&zh(Th,e),Eh!==null&&zh(Eh,e),Dh!==null&&zh(Dh,e),Oh.forEach(t),kh.forEach(t);for(var n=0;n<Ah.length;n++){var r=Ah[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Ah.length&&(n=Ah[0],n.blockedOn===null);)Fh(n),n.blockedOn===null&&Ah.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[xt]||null;if(typeof a==`function`)o||Vh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[xt]||null)s=o.formAction;else if(Sh(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Vh(n)}}}function Uh(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Wh(e){this._internalRoot=e}Gh.prototype.render=Wh.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;dh(n,kd(),e,t,null,null)},Gh.prototype.unmount=Wh.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;dh(e.current,2,null,e,null,null),Ld(),t[St]=null}};function Gh(e){this._internalRoot=e}Gh.prototype.unstable_scheduleHydration=function(e){if(e){var t=_t();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ah.length&&t!==0&&t<Ah[n].priority;n++);Ah.splice(n,0,e),n===0&&Fh(e)}};var Kh=n.version;if(Kh!==`19.3.0`)throw Error(i(527,Kh,`19.3.0`));I.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:d(e),e=e===null?null:e.stateNode,e};var qh={bundleType:0,version:`19.3.0`,rendererPackageName:`react-dom`,currentDispatcherRef:F,reconcilerVersion:`19.3.0`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Jh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Jh.isDisabled&&Jh.supportsFiber)try{Je=Jh.inject(qh),Ye=Jh}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=yc,s=bc,c=xc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=lh(e,1,!1,null,null,n,r,null,o,s,c,Uh),e[St]=t.current,Uf(e),new Wh(t)}})),lo=t(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=co()}))(),uo=new Set;function fo(e){for(let t of uo)t(e)}function po(e){return uo.add(e),()=>{uo.delete(e)}}function mo({app:e}){return(0,G.jsx)(`div`,{className:`apps-card app-message`,children:(0,G.jsx)(Xr,{tile:Yr(e.name),name:e.name,meta:`App · opens over the chat`,action:(0,G.jsx)(`button`,{className:`btn sm primary`,onClick:()=>fo({sessionId:e.sessionId,appId:e.appId}),"aria-label":`Open app: ${e.name}`,children:`Open`})})})}var ho={present:`Ready to review`,run:`Changed in this run`,asked:`As it looks now`,notes:`Reviewer notes`},go={requests:`Requests`,data:`Data`,logs:`Logs`},_o={ok:`ok`,warn:`changed`,danger:`problem`};function vo(e){let[t,n]=(0,W.useState)({url:null,missing:!1});return(0,W.useEffect)(()=>{if(!e)return;let t=!0,r=null;return R.fetchAttachment(e.hash).then(i=>{if(t){if(i){let e=Uint8Array.from(atob(i.data),e=>e.charCodeAt(0));r=URL.createObjectURL(new Blob([e],{type:i.mimeType||`image/png`}))}n({hash:e.hash,url:r,missing:!i})}},()=>{t&&n({hash:e.hash,url:null,missing:!0})}),()=>{t=!1,r&&URL.revokeObjectURL(r)}},[e?.hash]),e?t.hash===e.hash?{url:t.url,state:t.missing?`missing`:`ready`}:{url:null,state:`loading`}:{url:null,state:`none`}}function yo({review:e}){let{connection:t,activeSession:n}=Me(),r=n.activeSessionId===e.sessionId&&n.working,i=t.status===`online`,a=(0,W.useRef)(null),[o,s]=(0,W.useState)(!1);(0,W.useEffect)(()=>{let e=new IntersectionObserver(([t])=>{t?.isIntersecting&&(s(!0),e.disconnect())},{rootMargin:`300px`});return a.current&&e.observe(a.current),()=>e.disconnect()},[]);let c=vo(!o||e.expired?void 0:e.shot),l=vo(!o||e.expired?void 0:e.before),[u,f]=(0,W.useState)(`now`),[p,m]=(0,W.useState)(null),[h,g]=(0,W.useState)(``),[_,v]=(0,W.useState)(!1),y=l.state===`ready`&&c.state===`ready`,b=u===`before`&&y?l:c,x=()=>{p||R.appCommand(`apps.list`,e.sessionId).then(t=>{let n=t.apps?.find(t=>t.id===e.appId);m(n?.reviewMode??`ready`)},()=>{})},S=async(e,t,n)=>{v(!0),g(``);try{await t(),n&&g(n)}catch(t){g(t instanceof Error?t.message:`Could not ${e}.`)}finally{v(!1)}},C=()=>S(`take a screenshot`,()=>R.appCommand(`apps.showMe`,e.sessionId,{appId:e.appId})),w=t=>S(`change preview cards`,async()=>{await R.appCommand(`apps.reviewMode`,e.sessionId,{appId:e.appId,mode:t}),m(t)},t===`off`?`No more cards for ${e.name}. Show me still works.`:`Preview cards: ${Ci[t].toLowerCase()}.`),T=()=>S(`read the notes`,async()=>{let t=(await R.appCommand(`apps.list`,e.sessionId)).apps?.find(t=>t.id===e.appId)?.views.find(t=>t.id===e.viewId),n=t?.kind===`web`?t.notes??[]:[];if(!n.length){g(`These notes were cleared.`);return}let r=wi(t.name,n),i=await Jr(n);if(!R.prefillComposer(r,i)){if(i.length)throw Error(`Open this session’s chat before adding reviewer pictures.`);d(localStorage,e.sessionId,r)}},`Added to your message. Nothing is sent until you send it.`),E=()=>S(`turn on screenshots`,async()=>{await R.setNodeSettings({appScreenshots:!0}),await R.appCommand(`apps.showMe`,e.sessionId,{appId:e.appId})}),D=t=>fo({sessionId:e.sessionId,appId:e.appId,...t?{openView:{viewId:e.viewId,path:e.path}}:{}}),O=e.evidence??[],k=t=>fo({sessionId:e.sessionId,appId:e.appId,openView:{viewId:t.viewId,...t.item?{item:t.item}:{}}}),A=O.some(t=>t.viewId===e.viewId)&&!e.shot,ee=O.find(e=>e.tone===`warn`||e.tone===`danger`)??O[0],j=A?e.name:`${e.name}${e.view&&e.view!==e.name?` · ${e.view}`:``}`,M=A?`${ho[e.trigger]} · backend`:`${ho[e.trigger]} · ${e.path}`,te=t=>fo({sessionId:e.sessionId,appId:e.appId,openView:{viewId:e.viewId,scenario:t}});return(0,G.jsxs)(`section`,{ref:a,className:`apps-card review-card`,"aria-label":`${e.name}: ${ho[e.trigger].toLowerCase()}`,children:[(0,G.jsx)(Xr,{tile:Yr(e.name),name:j,meta:M,action:(0,G.jsx)(vr,{label:`Preview card options for ${e.name}`,onOpen:x,items:[{label:`App options`,onSelect:()=>D(!1)},{heading:`Preview cards`},...[`ready`,`every`,`off`].map(e=>({label:Ci[e],checked:p?p===e:void 0,disabled:_||!i||!p,onSelect:()=>void w(e)})),...r?[{label:`Mute for this run`,disabled:_||!i,separated:!0,onSelect:()=>void S(`mute`,()=>R.appCommand(`apps.mute`,e.sessionId),`Muted until the agent’s next run.`)}]:[],{label:`Show me now`,disabled:_||!i,separated:!r,onSelect:()=>void C()}]})}),e.trigger===`notes`||A?null:e.screenshotsOff&&!e.shot?(0,G.jsxs)(`div`,{className:`banner inline review-banner`,"data-tone":`neutral`,role:`status`,children:[(0,G.jsx)(`span`,{className:`banner-text`,children:`Turn on agent screenshots to see the app here. Bivy takes them with Chrome on this machine.`}),(0,G.jsx)(`span`,{className:`banner-actions`,children:(0,G.jsx)(`button`,{className:`btn`,disabled:_||!i,onClick:()=>void E(),children:`Turn on`})})]}):(0,G.jsxs)(`div`,{className:`review-stage`,children:[e.expired||b.state===`missing`||!e.shot?(0,G.jsx)(`p`,{className:`review-gone`,children:e.expired||b.state===`missing`?`Screenshot no longer stored`:`No screenshot this time`}):(0,G.jsx)(`button`,{type:`button`,className:`review-shot`,style:e.shot?{aspectRatio:`${e.shot.width} / ${e.shot.height}`,blockSize:`var(--review-shot-height)`,maxInlineSize:`100%`}:void 0,onClick:()=>D(!0),"aria-label":`Open preview of ${e.name} at ${e.path}`,children:b.url?(0,G.jsx)(`img`,{src:b.url,alt:`${e.name} at ${e.path}, ${u===`before`&&y?`before this run`:`now`}`,width:e.shot?.width,height:e.shot?.height}):(0,G.jsxs)(`span`,{className:`review-loading`,children:[(0,G.jsx)(V,{size:`sm`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Loading screenshot…`})]})}),e.before&&!e.expired&&(0,G.jsx)(`div`,{className:`segmented review-side`,role:`radiogroup`,"aria-label":`Show the app`,children:[`before`,`now`].map(e=>(0,G.jsx)(`button`,{type:`button`,role:`radio`,className:`seg-btn`,disabled:!y,"aria-checked":u===e,onClick:()=>f(e),children:e===`before`?`Before`:`Now`},e))})]}),O.length>0&&(0,G.jsx)(`ul`,{className:`review-evidence`,"aria-label":`What changed in the backend`,children:O.map((e,t)=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,className:`review-evidence-row`,onClick:()=>k(e),"aria-label":`${go[e.backend]}: ${e.summary}${e.detail?`, ${e.detail}`:``}. Open ${e.view}`,children:[(0,G.jsx)(`span`,{className:`review-evidence-kind`,children:O[t-1]?.viewId===e.viewId?``:go[e.backend]}),(0,G.jsxs)(`span`,{className:`review-evidence-text`,children:[(0,G.jsx)(`span`,{children:e.summary}),e.detail&&(0,G.jsx)(`code`,{children:e.detail})]}),e.tone!==`neutral`&&(0,G.jsx)(`span`,{className:`badge`,"data-tone":e.tone,"aria-hidden":`true`,children:_o[e.tone]})]})},`${e.viewId}:${e.item??t}`))}),e.note&&(0,G.jsx)(`p`,{className:`review-note`,children:e.note}),e.try?.length?(0,G.jsxs)(`div`,{className:`review-try`,role:`group`,"aria-label":`Try ${e.name} in a scenario`,children:[(0,G.jsx)(`span`,{className:`review-try-label`,"aria-hidden":`true`,children:`Try it:`}),e.try.map(e=>(0,G.jsx)(`button`,{type:`button`,className:`btn sm`,disabled:!i,onClick:()=>te(e.id),children:e.name},e.id))]}):null,e.notes?(0,G.jsxs)(`div`,{className:`banner inline review-banner`,"data-tone":`neutral`,role:`group`,"aria-label":`Reviewer notes on ${j}`,children:[(0,G.jsxs)(`span`,{className:`banner-text`,children:[e.notes===1?`1 note`:`${e.notes} notes`,` from people with a shared link. They reach the agent only if you send them.`]}),(0,G.jsxs)(`span`,{className:`banner-actions`,children:[(0,G.jsx)(`button`,{className:`btn sm`,disabled:_||!i,onClick:()=>void T(),children:`Add to message`}),(0,G.jsx)(`button`,{className:`btn sm ghost`,disabled:!i,onClick:()=>D(!1),children:`Open in Apps`})]})]}):null,h&&(0,G.jsx)(`p`,{className:`review-status`,role:`status`,children:h}),(0,G.jsx)(`div`,{className:`review-actions`,children:A&&ee?(0,G.jsx)(`button`,{className:`btn primary`,disabled:!i,onClick:()=>k(ee),children:`Review changes`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{className:`btn${e.trigger===`notes`?``:` primary`}`,disabled:!i,onClick:()=>D(!0),children:`Open preview`}),(0,G.jsx)(Ar,{sessionId:e.sessionId,appId:e.appId,viewId:e.viewId,name:e.view||e.name,disabled:!i})]})})]})}var bo={open:{label:`Open`,detail:`Nothing has changed here yet.`},changed:{label:`Changed`,tone:`ok`,detail:`A later run changed what you marked. Have a look.`},gone:{label:`Element gone`,tone:`warn`,detail:`What you marked is no longer on the page.`},done:{label:`Done`,tone:`ok`,detail:`You marked this done.`}};function xo({pin:e}){let{connection:t}=Me(),n=t.status===`online`,r=(0,W.useRef)(null),[i,a]=(0,W.useState)(!1),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(``);(0,W.useEffect)(()=>{let e=new IntersectionObserver(([t])=>{t?.isIntersecting&&(a(!0),e.disconnect())},{rootMargin:`300px`});return r.current&&e.observe(r.current),()=>e.disconnect()},[]),(0,W.useEffect)(()=>{if(!i||!e.shot)return;let t=!0,n=null;return R.fetchAttachment(e.shot.hash).then(e=>{if(!t)return;if(!e){l(!0);return}let r=Uint8Array.from(atob(e.data),e=>e.charCodeAt(0));n=URL.createObjectURL(new Blob([r],{type:e.mimeType||`image/png`})),s(n)},()=>{t&&l(!0)}),()=>{t=!1,n&&URL.revokeObjectURL(n)}},[i,e.shot?.hash]);let m=bo[e.state],h=async t=>{d(!0),p(``);try{await R.appCommand(`apps.pinState`,e.sessionId,{pinId:e.id,state:t})}catch(e){p(e instanceof Error?e.message:`Could not update this pin.`)}finally{d(!1)}},g=()=>fo({sessionId:e.sessionId,appId:e.appId,openView:{viewId:e.viewId,path:e.path}});return(0,G.jsxs)(`section`,{ref:r,className:`apps-card review-card pin-card`,"aria-label":`${e.number?`Note ${e.number} p`:`P`}inned on ${e.name}: ${m.label.toLowerCase()}`,children:[(0,G.jsx)(Xr,{tile:Yr(e.name),name:`${e.name}${e.view&&e.view!==e.name?` · ${e.view}`:``}`,meta:`${e.number?`Note ${e.number} · `:``}Pinned · ${e.path}`,action:(0,G.jsx)(Te,{tone:m.tone,children:m.label})}),e.shot&&!c?(0,G.jsx)(`div`,{className:`review-stage`,children:(0,G.jsx)(`button`,{type:`button`,className:`review-shot`,style:{aspectRatio:`${e.shot.width} / ${e.shot.height}`,blockSize:`var(--review-shot-height)`,maxInlineSize:`100%`},onClick:g,"aria-label":`Open the preview of ${e.name} at ${e.path}`,children:o?(0,G.jsx)(`img`,{src:o,alt:`What you marked on ${e.name} at ${e.path}${e.number?`, note ${e.number}`:``}`,width:e.shot.width,height:e.shot.height}):(0,G.jsxs)(`span`,{className:`review-loading`,children:[(0,G.jsx)(V,{size:`sm`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Loading what you marked…`})]})})}):(0,G.jsx)(`p`,{className:`review-gone`,children:c?`Picture no longer stored`:`Marked without a picture`}),e.words&&(0,G.jsx)(`p`,{className:`review-note`,children:e.words}),(0,G.jsx)(`p`,{className:`review-status`,children:m.detail}),f&&(0,G.jsx)(`p`,{className:`review-status`,role:`alert`,children:f}),(0,G.jsxs)(`div`,{className:`review-actions`,children:[(0,G.jsx)(`button`,{className:`btn primary`,disabled:!n,onClick:g,children:`Open preview`}),e.state===`done`?(0,G.jsx)(`button`,{className:`btn ghost`,disabled:u||!n,onClick:()=>void h(`open`),children:`Reopen`}):(0,G.jsx)(`button`,{className:`btn`,disabled:u||!n,onClick:()=>void h(`done`),children:`Mark done`})]})]})}function So({notice:e}){return(0,G.jsxs)(`section`,{className:`card notice-card`,"data-tone":e.urgent?`warn`:`accent`,"aria-label":e.urgent?`Urgent message from the agent`:`Message from the agent`,children:[(0,G.jsxs)(`p`,{className:`notice-eyebrow`,children:[`Message for you`,e.urgent&&(0,G.jsx)(Te,{tone:`warn`,variant:`soft`,children:`Urgent`})]}),(0,G.jsx)(`p`,{className:`notice-text`,children:e.text})]})}var Co={pending:{label:`Queued`,tone:`accent`},claimed:{label:`Starting`,tone:`accent`},running:{label:`Working`,tone:`accent`},waiting:{label:`Waiting`,tone:`accent`},needs_attention:{label:`Needs attention`,tone:`warn`},succeeded:{label:`Done`,tone:`ok`},failed:{label:`Failed`,tone:`danger`},cancelled:{label:`Cancelled`}};function wo(e){let t=Me(),n=e.agent?t.catalogs.runtimes.find(t=>t.id===e.agent)?.displayName||e.agent:`Default agent`;return{agent:n,label:e.machine?`${n} @ ${e.machine}`:n}}function To({status:e}){let t=Co[e]??{label:e};return(0,G.jsx)(`span`,{className:`badge`,"data-tone":t.tone,children:t.label})}function Eo({card:e,target:t,compact:n}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`delegation-head`,children:[(0,G.jsxs)(`span`,{className:`delegation-target`,children:[t.agent,e.machine&&(0,G.jsxs)(`span`,{className:`delegation-machine`,children:[`on `,e.machine]})]}),(0,G.jsx)(To,{status:e.status})]}),!n&&(0,G.jsx)(`p`,{className:`delegation-task`,children:e.task}),e.failure&&(0,G.jsx)(`p`,{className:`delegation-failure`,children:e.failure}),e.answer&&(0,G.jsxs)(`details`,{className:`delegation-answer`,open:n,children:[(0,G.jsx)(`summary`,{children:`Answer`}),(0,G.jsx)(`p`,{children:e.answer})]}),(e.branch||e.prUrl)&&(0,G.jsxs)(`p`,{className:`delegation-refs`,children:[e.branch&&(0,G.jsx)(`code`,{children:e.branch}),e.prUrl&&(0,G.jsx)(`a`,{href:e.prUrl,target:`_blank`,rel:`noreferrer`,children:`Pull request`})]}),e.childSessionId&&(0,G.jsx)(`div`,{className:`delegation-actions`,children:(0,G.jsx)(`button`,{type:`button`,className:`btn sm ghost`,onClick:()=>e.childSessionId&&R.openSessionOnNode(e.childSessionId,void 0,e.nodeId),children:`Open session`})})]})}function Do({card:e}){let t=wo(e),n=e.status===`succeeded`;return(0,G.jsxs)(`section`,{className:`card delegation-member`,"aria-label":`${t.label}: ${Co[e.status]?.label??e.status}`,children:[(0,G.jsx)(Eo,{card:e,target:t,compact:!0}),n&&(0,G.jsx)(`button`,{type:`button`,className:`btn sm primary`,onClick:()=>R.sendPrompt(`Go with ${t.label}'s result (delegated run ${e.id})${e.branch?`. Its work is on branch \`${e.branch}\`: fetch it and merge it into the current branch`:``}.`),children:`Use this`})]})}function Oo({delegation:e}){let t=Me(),n=wo(e);if(e.group){let n=t.activeSession.transcript.flatMap(t=>t.delegation&&t.delegation.group===e.group?[t.delegation]:[]);if(n[0]?.id!==e.id)return null;let r=n.filter(e=>[`succeeded`,`failed`,`cancelled`].includes(e.status)).length;return(0,G.jsxs)(`section`,{className:`delegation-group`,"aria-label":`Compared across ${n.length} agents`,children:[(0,G.jsxs)(`p`,{className:`delegation-eyebrow`,children:[`Compared across `,n.length,` agents · `,r,`/`,n.length,` finished`]}),(0,G.jsx)(`p`,{className:`delegation-task`,children:e.task}),(0,G.jsx)(`div`,{className:`delegation-grid`,children:n.map(e=>(0,G.jsx)(Do,{card:e},e.id))})]})}return(0,G.jsxs)(`section`,{className:`card delegation-card`,"aria-label":`Delegated to ${n.label}`,children:[(0,G.jsx)(`p`,{className:`delegation-eyebrow`,children:`Delegated`}),(0,G.jsx)(Eo,{card:e,target:n})]})}function ko(e){let t=new Map(e.map(e=>[e.callId,e])),n=new Map,r=e=>!!(e.parentToolUseId&&e.parentToolUseId!==e.callId&&t.has(e.parentToolUseId));for(let t of e)if(r(t)){let e=n.get(t.parentToolUseId)??[];e.push(t),n.set(t.parentToolUseId,e)}let i=[],a=new Set,o=(e,t)=>{if(!a.has(e.callId)){a.add(e.callId),i.push({tool:e,depth:t});for(let r of n.get(e.callId)??[])o(r,t+1)}};for(let t of e)r(t)||o(t,0);for(let t of e)a.has(t.callId)||o(t,0);return i}function Ao(e,t){let n=new Map;for(let e of t){let t=e.parentToolUseId;if(!t||t===e.callId)continue;let r=n.get(t)??[];r.push(e),n.set(t,r)}let r=new Set([e]),i=[...n.get(e)??[]],a=0;for(;i.length;){let e=i.pop();if(!r.has(e.callId)){r.add(e.callId),a+=1;for(let t of n.get(e.callId)??[])i.push(t)}}return a}function jo({glyph:e}){let t={width:16,height:16,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`};switch(e){case`terminal`:return(0,G.jsxs)(`svg`,{...t,children:[(0,G.jsx)(`polyline`,{points:`4 17 10 11 4 5`}),(0,G.jsx)(`line`,{x1:`12`,y1:`19`,x2:`20`,y2:`19`})]});case`pencil`:case`create`:return(0,G.jsxs)(`svg`,{...t,children:[(0,G.jsx)(`path`,{d:`M12 20h9`}),(0,G.jsx)(`path`,{d:`M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z`})]});case`search`:return(0,G.jsxs)(`svg`,{...t,children:[(0,G.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,G.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]});case`list`:return(0,G.jsxs)(`svg`,{...t,children:[(0,G.jsx)(`line`,{x1:`8`,y1:`6`,x2:`21`,y2:`6`}),(0,G.jsx)(`line`,{x1:`8`,y1:`12`,x2:`21`,y2:`12`}),(0,G.jsx)(`line`,{x1:`8`,y1:`18`,x2:`21`,y2:`18`}),(0,G.jsx)(`line`,{x1:`3`,y1:`6`,x2:`3.01`,y2:`6`}),(0,G.jsx)(`line`,{x1:`3`,y1:`12`,x2:`3.01`,y2:`12`}),(0,G.jsx)(`line`,{x1:`3`,y1:`18`,x2:`3.01`,y2:`18`})]});case`globe`:return(0,G.jsxs)(`svg`,{...t,children:[(0,G.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,G.jsx)(`line`,{x1:`3`,y1:`12`,x2:`21`,y2:`12`}),(0,G.jsx)(`path`,{d:`M12 3a15 15 0 0 1 0 18a15 15 0 0 1 0-18Z`})]});case`agent`:return(0,G.jsxs)(`svg`,{...t,children:[(0,G.jsx)(`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`}),(0,G.jsx)(`circle`,{cx:`9`,cy:`7`,r:`4`}),(0,G.jsx)(`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`}),(0,G.jsx)(`path`,{d:`M16 3.13a4 4 0 0 1 0 7.75`})]});default:return(0,G.jsxs)(`svg`,{...t,children:[(0,G.jsx)(`path`,{d:`M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7Z`}),(0,G.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]})}}function Mo({added:e,removed:t}){return!e&&!t?null:(0,G.jsxs)(`span`,{className:`tool-stat`,children:[e>0&&(0,G.jsxs)(`span`,{className:`add`,children:[`+`,e]}),t>0&&(0,G.jsxs)(`span`,{className:`del`,children:[`−`,t]})]})}function No(e){if(e.detail?.kind!==`delegation`)return``;let t=Number(e.input?.elapsedSeconds);return!Number.isFinite(t)||t<1?``:t<60?`${Math.floor(t)}s`:`${Math.floor(t/60)}m ${Math.floor(t%60)}s`}function Po({tool:e,f:t,depth:n=0,onSelect:r}){let i=No(e),a=ht(t),o=i?`${a||`Sub-agent`} · ${i}`:a,s=e.status===`running`,c=n>1?{paddingLeft:`${28+(n-1)*16}px`}:void 0;return(0,G.jsx)(`div`,{className:`activity${s?` is-running`:``}${t.isError?` is-error`:``}${n>0?` is-subagent-step`:``}`,"data-depth":n||void 0,children:(0,G.jsxs)(`button`,{className:`activity-row`,style:c,onClick:()=>r(e.callId),children:[(0,G.jsx)(`span`,{className:`activity-ic`,children:(0,G.jsx)(jo,{glyph:t.glyph})}),(0,G.jsx)(`span`,{className:`activity-verb`,children:t.verb}),(0,G.jsx)(`span`,{className:`activity-desc`,children:o}),t.isError&&(0,G.jsx)(Te,{tone:`danger`,variant:`soft`,upper:!0,title:typeof t.exitCode==`number`?`exit ${t.exitCode}`:`failed`,children:`Failed`}),(0,G.jsx)(Mo,{added:t.added,removed:t.removed}),(0,G.jsx)(`span`,{className:`tool-chevron`,children:(0,G.jsx)($e,{size:14})})]})})}function Fo({tool:e,f:t,subSteps:n=0}){let r=e.result||t.output||``,i=r&&(t.diffs.length===0||t.command||t.verb===`Agent output`),a=No(e);return(0,G.jsxs)(`div`,{className:`activity-detail`,children:[e.detail?.kind===`delegation`&&e.status===`running`&&(0,G.jsxs)(`div`,{className:`tool-detail-block`,children:[(0,G.jsx)(`div`,{className:`tool-detail-label`,children:`Status`}),(0,G.jsxs)(`div`,{className:`tool-detail-value`,children:[`Sub-agent active`,a?` · ${a} elapsed`:``]})]}),e.detail?.kind===`delegation`&&n>0&&(0,G.jsxs)(`div`,{className:`tool-detail-block`,children:[(0,G.jsx)(`div`,{className:`tool-detail-label`,children:`Sub-agent work`}),(0,G.jsxs)(`div`,{className:`tool-detail-value`,children:[n,` step`,n===1?``:`s`,` nested below this delegation`]})]}),(t.isError||t.truncated)&&(0,G.jsxs)(`div`,{className:`tool-detail-block`,children:[(0,G.jsx)(`div`,{className:`tool-detail-label`,children:`Outcome`}),(0,G.jsxs)(`div`,{className:`tool-detail-value${t.isError?` is-error`:``}`,children:[t.isError?`Failed`:`Completed`,typeof t.exitCode==`number`?` · exit ${t.exitCode}`:``,t.truncated?` · output truncated`:``]})]}),t.path&&(0,G.jsxs)(`div`,{className:`tool-detail-block`,children:[(0,G.jsx)(`div`,{className:`tool-detail-label`,children:`File`}),(0,G.jsx)(`div`,{className:`tool-detail-value`,children:t.path})]}),t.command&&(0,G.jsxs)(`div`,{className:`tool-detail-block`,children:[(0,G.jsx)(`div`,{className:`tool-detail-label`,children:`Command`}),(0,G.jsx)(`div`,{className:`tool-detail-value`,children:t.command})]}),t.query&&(0,G.jsxs)(`div`,{className:`tool-detail-block`,children:[(0,G.jsx)(`div`,{className:`tool-detail-label`,children:`Query`}),(0,G.jsx)(`div`,{className:`tool-detail-value`,children:t.query})]}),t.diffs.length>0&&(0,G.jsxs)(`div`,{className:`tool-detail-block`,children:[(0,G.jsx)(`div`,{className:`tool-detail-label`,children:`Diff`}),(0,G.jsx)(pt,{hunks:t.diffs,single:t.path})]}),t.diffs.length===0&&t.edits?(0,G.jsx)(`div`,{className:`tool-detail-block`,children:(0,G.jsxs)(`div`,{className:`tool-detail-value output`,children:[t.edits,` targeted edits`]})}):null,i&&(0,G.jsxs)(`div`,{className:`tool-detail-block`,children:[(0,G.jsx)(`div`,{className:`tool-detail-label`,children:e.status===`running`?`Live output`:`Output`}),(0,G.jsx)(`div`,{className:`tool-detail-value output`,dangerouslySetInnerHTML:{__html:ae(r)}})]}),!t.path&&!t.command&&!t.query&&!t.diffs.length&&!i&&(0,G.jsx)(`div`,{className:`tool-detail-value output`,children:e.status===`running`?`Still working. Details will appear here when the agent streams them.`:`No further details.`})]})}function Io(e){let t=St(e.name,e.input,e.detail,{diffStats:!1});if(t.verb===`Agent output`)return`Reading agent output…`;if(e.detail?.kind===`delegation`){let t=e.detail.label?`${e.detail.label} sub-agent`:`Sub-agent`,n=No(e);return`${t} working${n?` · ${n}`:``}…`}let n=ht(t);return t.command?`Running ${n||`command`}…`:n?`${t.verb} ${n}…`:`Agent is working…`}function q({tools:e,summary:t,onClose:n}){let[r,i]=(0,W.useState)(null),a=r?e.find(e=>e.callId===r):void 0,o=a?St(a.name,a.input,a.detail):void 0,s=a?Ao(a.callId,e):0,c=(0,W.useRef)(null);return(0,W.useEffect)(()=>{c.current?.closest(`.sheet-content`)?.scrollTo(0,0)},[r]),(0,G.jsx)(ot,{title:a&&o?o.title:t,onClose:n,headExtra:a?(0,G.jsx)(`button`,{className:`sheet-back`,onClick:()=>i(null),"aria-label":`Back`,children:`‹`}):void 0,children:(0,G.jsx)(`div`,{ref:c,children:a&&o?(0,G.jsx)(Fo,{tool:a,f:o,subSteps:s}):e.length?ko(e).map(({tool:e,depth:t})=>(0,G.jsx)(Po,{tool:e,depth:t,f:St(e.name,e.input,e.detail),onSelect:i},e.callId)):(0,G.jsx)(`div`,{className:`tool-detail-value output`,children:`No tool activity.`})})})}var Lo=(0,W.memo)(function({tools:e}){let[t,n]=(0,W.useState)(!1),r=(0,W.useCallback)(()=>n(!1),[]),i=e.some(e=>e.status===`running`),a=e.some(e=>gt(e.detail)),o=e.filter(e=>e.status===`running`&&e.detail?.kind===`delegation`),s=o.length>1?`${o.length} sub-agents working…`:o.length===1?Io(o[0]):i&&e.every(e=>e.status===`running`)&&e.length===1?Io(e[0]):yt(e),c=i?`Working`:`Worked`,l=s,u=`${i?`Work in progress`:`Work log`} · ${e.length} action${e.length===1?``:`s`}`;return(0,G.jsxs)(`div`,{className:`tool-group`,children:[(0,G.jsxs)(`button`,{className:`tool-group-line${i?` is-running`:``}${a?` is-error`:``}`,onClick:()=>n(!0),"aria-label":`${c}: ${l}. Open work details`,children:[(0,G.jsx)(`span`,{className:`tool-group-state`,"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`tool-group-label`,children:c}),(0,G.jsx)(`span`,{className:`tool-group-summary`,children:l}),(0,G.jsx)(`span`,{className:`tool-chevron`,children:(0,G.jsx)($e,{size:14})})]}),t&&(0,G.jsx)(q,{tools:e,summary:u,onClose:r})]})},(e,t)=>e.tools.length===t.tools.length&&e.tools.every((e,n)=>e===t.tools[n])),Ro={completed:`Done`,in_progress:`In progress`,pending:`To do`,cancelled:`Cancelled`},zo=(0,W.memo)(function({plan:e}){let t=e.filter(e=>e.status===`completed`||e.status===`cancelled`).length,n=e.filter(e=>e.status===`completed`).length,r=e.find(e=>e.status===`in_progress`),[i,a]=(0,W.useState)(null),o=i??t<e.length,s=`${n} of ${e.length} done${r&&!o?` · ${r.text}`:``}`;return(0,G.jsxs)(`div`,{className:`tool-group plan-card`,children:[(0,G.jsxs)(`button`,{className:`tool-group-line`,onClick:()=>a(!o),"aria-expanded":o,children:[(0,G.jsx)(`span`,{className:`tool-group-label`,children:`Plan`}),(0,G.jsx)(`span`,{className:`tool-group-summary`,children:s}),(0,G.jsx)(`span`,{className:`tool-chevron plan-chevron`,children:(0,G.jsx)($e,{size:14})})]}),o&&(0,G.jsx)(`ol`,{className:`plan-steps`,children:e.map((e,t)=>(0,G.jsxs)(`li`,{className:`plan-step is-${e.status}`,children:[(0,G.jsx)(`span`,{className:`plan-mark`,"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`plan-text`,children:e.text}),(0,G.jsxs)(`span`,{className:`sr-only`,children:[`, `,Ro[e.status]]})]},e.id??t))})]})});function Bo(e){let t=R.store.getState().catalogs.runtimes.find(t=>t.id===e);return String(t?.displayName||t?.name||e)}function Vo(){let{activeSession:{activeSessionId:e},sessionIndex:{sessions:t}}=Me(),n=t.find(t=>t.sessionId===e)?.forkedFrom,r=n?t.find(e=>e.sessionId===n):void 0;if(r)return{sessionId:r.sessionId,name:r.name||`Session ${r.sessionId.slice(0,8)}`,nodeId:r.nodeId}}var Ho=(0,W.memo)(function({seed:e,text:t}){let[n,r]=(0,W.useState)(!1),i=(0,W.useCallback)(()=>r(!1),[]),a=Vo(),o=e.kind===`fork`?`Handed over`:`Imported`,s=`from ${Bo(e.from)}`,c=`${o} ${s}. Show what was sent`;return(0,G.jsxs)(`div`,{className:`tool-group handoff-line`,children:[(0,G.jsxs)(`button`,{className:`tool-group-line`,onClick:()=>r(!0),"aria-label":c,children:[(0,G.jsx)(`span`,{className:`tool-group-label`,children:o}),(0,G.jsx)(`span`,{className:`tool-group-summary`,children:s})]}),e.kind===`fork`&&a&&(0,G.jsx)(`button`,{type:`button`,className:`handoff-source`,onClick:()=>R.openSessionOnNode(a.sessionId,void 0,a.nodeId),"aria-label":`Open the original session: ${a.name}`,children:a.name}),(0,G.jsx)(`button`,{className:`tool-group-line handoff-open`,onClick:()=>r(!0),tabIndex:-1,"aria-hidden":`true`,children:(0,G.jsx)(`span`,{className:`tool-chevron`,children:(0,G.jsx)($e,{size:14})})}),n&&(0,G.jsx)(ot,{title:`Context sent to the agent`,onClose:i,children:(0,G.jsx)(`div`,{className:`tool-detail-value output handoff-seed-text`,children:t})})]})});function Uo({attachment:e,onOpenImage:t}){let n=Wr(e);return(0,G.jsxs)(`div`,{className:`msg-attachment`,children:[e.kind===`image`&&n&&(0,G.jsx)(`a`,{className:`attach-preview`,href:n,target:`_blank`,rel:`noopener`,title:e.name,onClick:t?e=>{e.metaKey||e.ctrlKey||e.shiftKey||e.button!==0||(e.preventDefault(),t())}:void 0,children:(0,G.jsx)(`img`,{src:n,alt:e.description||e.name})}),(0,G.jsxs)(`div`,{className:`attach-details`,children:[(0,G.jsxs)(`div`,{className:`attach-copy`,children:[(0,G.jsx)(`div`,{className:`attach-name`,children:e.name}),(0,G.jsx)(`div`,{className:`attach-description`,children:e.description||`${e.mimeType||(e.kind===`image`?`Image`:`File`)} · ${Hr(e.size)}`})]}),n?(0,G.jsx)(`a`,{className:`btn icon attach-download`,href:n,download:e.name,"aria-label":`Download ${e.name}`,title:`Download ${e.name}`,children:(0,G.jsx)(Wo,{})}):(0,G.jsx)(`button`,{className:`btn icon attach-download`,disabled:!0,"aria-label":`Download ${e.name} unavailable`,title:`Content unavailable or still loading`,children:(0,G.jsx)(Wo,{})})]})]})}function Wo(){return(0,G.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,"aria-hidden":`true`,children:(0,G.jsx)(`path`,{d:`M12 3v12m-5-5 5 5 5-5M4 15v5h16v-5`})})}function Go({attachments:e}){let t=(0,W.useMemo)(()=>e.filter(e=>e.kind===`image`&&!e.omitted),[e]),[n,r]=(0,W.useState)(null);return(0,G.jsxs)(`div`,{className:`msg-attachments`,children:[e.map((e,n)=>{let i=t.indexOf(e);return(0,G.jsx)(Uo,{attachment:e,onOpenImage:i>=0?()=>r(i):void 0},`${e.name}-${n}`)}),n!==null&&(0,G.jsx)(Kr,{images:t,index:n,onClose:()=>r(null)})]})}function Ko({appId:e,caption:t,sessionId:n}){let[r,i]=(0,W.useState)({state:`waiting`}),a=(0,W.useRef)(null),o=(0,W.useRef)(!1),s=(0,W.useCallback)(()=>fo({sessionId:n??``,appId:e}),[n,e]),c=(0,W.useCallback)(async()=>{if(n){i({state:`resolving`});try{let t=(await R.appCommand(`apps.list`,n,{})).apps?.find(t=>t.id===e);if(!t){i({state:`unframeable`,name:e,why:`This app is not published on the machine any more.`});return}let r=t.views.find(e=>e.kind===`web`);if(!r){i({state:`unframeable`,name:t.name,why:`Open this one to see it.`});return}let a=await R.appCommand(`apps.open`,n,{appId:t.id,viewId:r.id,returnTo:`${location.origin}/sessions/${encodeURIComponent(n)}`}),o=a.kind===`web`&&a.url?new URL(a.url):null;if(!o||o.protocol!==`https:`||o.origin===location.origin||o.username||o.password){i({state:`unframeable`,name:t.name,why:`This app could not be shown here.`});return}i({state:`ready`,url:o.href,name:t.name})}catch(t){i({state:`unframeable`,name:e,why:t instanceof Error?t.message:`This app could not be shown here.`})}}},[n,e]);return(0,W.useEffect)(()=>{let t=a.current;if(!t||o.current||!n)return;if(Pr()){i({state:`unframeable`,name:e,why:`Previews do not frame in this browser.`});return}if(typeof IntersectionObserver>`u`){o.current=!0,c();return}let r=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&!o.current&&(o.current=!0,r.disconnect(),c())},{rootMargin:`200px`});return r.observe(t),()=>r.disconnect()},[c,n,e]),r.state===`ready`?(0,G.jsxs)(`figure`,{className:`inline-app`,children:[(0,G.jsx)(`iframe`,{className:`inline-app-frame`,src:r.url,title:r.name,referrerPolicy:`no-referrer`,sandbox:`allow-scripts allow-same-origin allow-forms allow-downloads allow-popups`}),(0,G.jsxs)(`figcaption`,{className:`card-sub`,children:[t??r.name,(0,G.jsx)(`button`,{type:`button`,className:`btn sm ghost inline-app-open`,onClick:s,children:`Open full screen`})]})]}):(0,G.jsx)(`div`,{className:`apps-card inline-app-card`,ref:a,children:(0,G.jsx)(Xr,{tile:Yr(r.state===`waiting`||r.state===`resolving`?e:r.name),name:r.state===`waiting`||r.state===`resolving`?t??`App`:r.name,meta:r.state===`resolving`?`Opening the preview…`:r.state===`unframeable`?r.why:`App · opens over the chat`,action:r.state===`resolving`?(0,G.jsx)(V,{size:`sm`}):(0,G.jsx)(`button`,{className:`btn sm primary`,onClick:s,"aria-label":`Open app: ${r.state===`unframeable`?r.name:e}`,children:`Open`})})})}function qo(e){let t=e.slice(0,e.indexOf(`
|
|
21
21
|
`)+1||void 0);return(t.match(/\t/g)?.length??0)>(t.match(/,/g)?.length??0)?` `:`,`}function Jo(e,t=200){let n=String(e??``),r=qo(n),i=[],a=[],o=``,s=!1,c=()=>{a.push(o),o=``},l=()=>{c(),(a.length>1||a[0]!==``)&&i.push(a),a=[]};for(let e=0;e<n.length;e++){let t=n[e];if(s){t===`"`?n[e+1]===`"`?(o+=`"`,e++):s=!1:o+=t;continue}t===`"`?s=!0:t===r?c():t===`
|
|
22
22
|
`||t===`\r`?(t===`\r`&&n[e+1]===`
|
|
23
|
-
`&&e++,l()):o+=t}(o!==``||a.length)&&l();let u=i.shift()??[],d=Math.max(0,i.length-t);return{header:u,rows:i.slice(0,t),omitted:d}}var Yo=5e3;function Xo(e,t=Yo){let{header:n,rows:r}=Jo(e,t);return r.map(e=>{let t={};return n.forEach((n,r)=>{let i=e[r]??``,a=i!==``&&!Number.isNaN(Number(i));t[n]=a?Number(i):i}),t})}var Zo=null;function Qo(){return Zo??=C(async()=>{let{default:e}=await import(`./embed-BXV41wg7.js`);return{default:e}},__vite__mapDeps([10,1,11,12,13,14,15,16,17,18,19,20])).then(({default:e})=>e),Zo}function $o(e,t){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t}function es(e,t,n=0){if(n>8||!e||typeof e!=`object`)return e;if(Array.isArray(e))return e.map(e=>es(e,t,n+1));let r=e;if(typeof r.url==`string`&&t.has(r.url)){let{url:e,format:n,...i}=r;return{...i,values:t.get(r.url)}}return Object.fromEntries(Object.entries(r).map(([e,r])=>[e,es(r,t,n+1)]))}function ts(e,t=0){if(t>8||!e||typeof e!=`object`)return null;if(Array.isArray(e)){for(let n of e){let e=ts(n,t+1);if(e)return e}return null}for(let[n,r]of Object.entries(e)){if(n===`url`&&typeof r==`string`)return r;let e=ts(r,t+1);if(e)return e}return null}async function ns(e,t){let n=ts(t);if(n)return{ok:!1,reason:`A chart can only read data from the workspace, not from “${n}”.`};let r;try{r=await Qo()}catch{return{ok:!1,reason:`The chart renderer could not be loaded.`}}if(!e.isConnected)return{ok:!1};let i=$o(`--ink`,`#1a1a1a`),a=$o(`--muted`,`#6b6b6b`),o=$o(`--line`,`#e0e0e0`),s=$o(`--accent`,`#3b5bdb`);try{let n={width:Math.max(120,e.clientWidth-20),autosize:{type:`fit`,contains:`padding`},...t};return await r(e,n,{actions:!1,renderer:`svg`,loader:{load:async()=>{throw Error(`charts cannot load external data`)}},config:{background:`transparent`,font:$o(`--font-sans`,`system-ui, sans-serif`),view:{stroke:null},axis:{labelColor:a,titleColor:i,gridColor:o,domainColor:o,tickColor:o},axisX:{labelAngle:0,labelOverlap:`parity`},legend:{labelColor:a,titleColor:i},title:{color:i},range:{category:[s,$o(`--ok`,`#2f9e44`),$o(`--warn`,`#e8590c`),$o(`--danger`,`#c92a2a`),a]},mark:{color:s}}}),{ok:!0}}catch(e){return{ok:!1,reason:e instanceof Error?e.message:`This chart could not be drawn.`}}}function rs(e,t){return{kind:e.kind,name:e.name,size:e.size,mimeType:e.mimeType,hash:e.hash,description:t}}function is(e){let t=e.attrs.caption;return typeof t==`string`&&t.trim()?t:void 0}function as({what:e,why:t}){return(0,G.jsxs)(`div`,{className:`card`,"data-tone":`muted`,children:[(0,G.jsx)(`div`,{className:`card-title`,children:e}),(0,G.jsx)(`div`,{className:`card-sub`,children:t})]})}function os({spec:e}){let t=e.value,n=e.label;return t==null||t===``?(0,G.jsx)(as,{what:`A number`,why:`This component has no value to show.`}):(0,G.jsxs)(`div`,{className:`card metric-component`,children:[(0,G.jsx)(`div`,{className:`metric-value`,children:String(t)}),n!=null&&n!==``&&(0,G.jsx)(`div`,{className:`card-sub`,children:String(n)})]})}function ss({placement:e,attachment:t}){let n=e.spec,r=Array.isArray(n?.columns)&&Array.isArray(n?.rows),i=t?rs(t):null,a=Gr(r?null:i),o=(0,W.useMemo)(()=>a.state===`ready`?Jo(a.text):null,[a]);if(r){let t=n.columns.map(String),r=n.rows.map(e=>Array.isArray(e)?e.map(String):[String(e)]);return(0,G.jsx)(cs,{caption:is(e)??(typeof n.title==`string`?n.title:void 0),header:t,rows:r,omitted:0})}return t?a.state===`error`?(0,G.jsx)(as,{what:e.ref??t.name,why:a.reason}):o?o.header.length?(0,G.jsx)(cs,{caption:is(e)??t.name,header:o.header,rows:o.rows,omitted:o.omitted}):(0,G.jsx)(as,{what:e.ref??t.name,why:`This file has no rows to show.`}):(0,G.jsx)(as,{what:e.ref??t.name,why:`Reading this file…`}):(0,G.jsx)(as,{what:e.ref??`A table`,why:`This table is still being prepared, or could not be read.`})}function cs({caption:e,header:t,rows:n,omitted:r}){return(0,G.jsxs)(`figure`,{className:`table-component`,children:[(0,G.jsx)(`div`,{className:`markdown-table-wrap`,children:(0,G.jsxs)(`table`,{children:[(0,G.jsx)(`thead`,{children:(0,G.jsx)(`tr`,{children:t.map((e,t)=>(0,G.jsx)(`th`,{children:e},t))})}),(0,G.jsx)(`tbody`,{children:n.map((e,n)=>(0,G.jsx)(`tr`,{children:t.map((t,n)=>(0,G.jsx)(`td`,{children:e[n]??``},n))},n))})]})}),(e||r>0)&&(0,G.jsxs)(`figcaption`,{className:`card-sub`,children:[e,r>0&&`${e?` · `:``}${r} more row${r===1?``:`s`} not shown`]})]})}async function ls(e,t){if(t.size>524288)return null;let n=await R.fetchAttachment(t.hash);if(!n)return null;let r;try{let e=atob(n.data);r=new TextDecoder().decode(Uint8Array.from(e,e=>e.charCodeAt(0)))}catch{return null}if(/\.json$/i.test(e)||(t.mimeType||``).includes(`json`))try{let e=JSON.parse(r);return Array.isArray(e)?e:null}catch{return null}let i=Xo(r);return i.length?i:null}function us({placement:e,refs:t}){let n=(0,W.useRef)(null),[r,i]=(0,W.useState)(null),a=e.spec,o=Number(e.attrs.height)||0,s=(0,W.useMemo)(()=>JSON.stringify((a?se(a):[]).map(e=>[e,t?.[e]??null])),[a,t]),[c,l]=(0,W.useState)(()=>JSON.parse(s).length?{state:`loading`}:{state:`ready`,byRef:new Map});(0,W.useEffect)(()=>{let e=JSON.parse(s);if(!e.length){l({state:`ready`,byRef:new Map});return}if(e.some(([,e])=>!e)){l({state:`loading`});return}let t=!1;return l({state:`loading`}),Promise.all(e.map(async([e,t])=>[e,await ls(e,t)])).then(e=>{if(t)return;let n=e.find(([,e])=>e===null);if(n){l({state:`error`,reason:`“${n[0]}” could not be read as data.`});return}l({state:`ready`,byRef:new Map(e)})}),()=>{t=!0}},[s]);let u=(0,W.useMemo)(()=>a&&c.state===`ready`?JSON.stringify(es(a,c.byRef)):``,[a,c]);if((0,W.useEffect)(()=>{let e=n.current;if(!e||!u)return;let t=!1;return e.replaceChildren(),i(null),ns(e,JSON.parse(u)).then(e=>{t||e.ok||e.reason&&i(e.reason)}),()=>{t=!0,e.replaceChildren()}},[u]),!a)return(0,G.jsx)(as,{what:`A chart`,why:`This component has no chart to draw.`});let d=typeof a.title==`string`?a.title:`A chart`;if(c.state===`error`)return(0,G.jsx)(as,{what:d,why:c.reason});if(r)return(0,G.jsx)(as,{what:d,why:r});let f=is(e)??(typeof a.description==`string`?a.description:void 0);return(0,G.jsxs)(`figure`,{className:`chart-component`,children:[(0,G.jsx)(`div`,{ref:n,className:`chart-host`,style:o?{minHeight:`${o}px`}:void 0}),f&&(0,G.jsx)(`figcaption`,{className:`card-sub`,children:f})]})}var ds={app:({placement:e,sessionId:t})=>{let n=e.spec?.appId;return typeof n==`string`?(0,G.jsx)(Ko,{appId:n,caption:is(e),sessionId:t}):(0,G.jsx)(as,{what:`An app`,why:`This component names no app to show.`})},chart:e=>(0,G.jsx)(us,{...e}),metric:({placement:e})=>e.spec?(0,G.jsx)(os,{spec:e.spec}):(0,G.jsx)(as,{what:`A number`,why:`This component has no value to show.`}),table:e=>(0,G.jsx)(ss,{...e}),image:({placement:e,attachment:t})=>t?(0,G.jsx)(Uo,{attachment:rs(t,is(e))}):(0,G.jsx)(as,{what:e.ref??`An image`,why:`This image is still being prepared, or could not be read.`}),file:({placement:e,attachment:t})=>t?(0,G.jsx)(Uo,{attachment:rs(t,is(e))}):(0,G.jsx)(as,{what:e.ref??`A file`,why:`This file is still being prepared, or could not be read.`})};Object.keys(ds);function fs({placement:e,refs:t,sessionId:n}){let r=e.ref?t?.[e.ref]??null:null,i=(0,W.useMemo)(()=>A({path:e.ref,mimeType:r?.mimeType,spec:e.spec}),[e.ref,e.spec,r?.mimeType]),a=ds[i];return a?(0,G.jsx)(G.Fragment,{children:a({placement:e,attachment:r,refs:t,sessionId:n})}):(0,G.jsx)(as,{what:e.ref??(typeof e.spec?.title==`string`?e.spec.title:`A “${i}” view`),why:`This version of Bivy cannot show a “${i}” yet.`})}function ps(e){let t=e=>{if(!e)return null;try{let t=JSON.parse(e);return t&&typeof t==`object`&&!Array.isArray(t)?t:null}catch{return null}};return{ref:e.dataset.mdRef??null,spec:t(e.dataset.mdSpec),attrs:t(e.dataset.mdAttrs)??{}}}function ms(e,t){let n=[],r=null,i=null,a=[],o=[],s=()=>{let e=i??r;if(e){if(a.length===0)n.push(e);else{let t=new Set,r=a.filter(e=>{let n=e.hash||`${e.kind}:${e.name}:${e.size}`;return!t.has(n)&&(t.add(n),!0)});n.push({...e,attachments:r})}}n.push(...o.filter(t=>t.id!==e?.id)),r=null,i=null,a=[],o=[]};for(let t of e)if(!(t.tool||t.toolOutput||t.role===`thinking`)){if(t.role===`assistant`){r=t,(t.app||t.review||t.notice)&&o.push(t),(t.text||t.streaming)&&(i=t),t.attachments?.length&&a.push(...t.attachments);continue}s(),n.push(t)}if(s(),!t)return n;let c=n.findLastIndex(e=>e.role===`user`);return n.flatMap((e,t)=>e.role===`assistant`&&(c<0||t>c)?e.app||e.review||e.notice||e.attachments?.length?[{...e,text:``,html:void 0,streaming:!1}]:[]:[e])}var hs=3e4,gs=null;function _s(e,t){gs={sessionId:e,target:t,at:Date.now()}}var vs=(e,t)=>`hash`in t?!!e.attachments?.some(e=>e.hash===t.hash):`reviewId`in t?e.review?.id===t.reviewId:e.app?.appId===t.appId;function ys(e,t){if(!gs||gs.sessionId!==e)return null;if(Date.now()-gs.at>hs)return gs=null,null;let{target:n}=gs,r=t.findLastIndex(e=>vs(e,n));return r>=0?r:null}function bs(){gs=null}var xs=null;function Ss(e){return Array.from(e.classList).some(e=>e.toLowerCase()===`language-mermaid`)}var Cs=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`,ws=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden><polyline points="20 6 9 17 4 12"/></svg>`;function Ts(e){if(!e)return;let t=Array.from(e.querySelectorAll(`pre`)).filter(e=>{let t=e.querySelector(`code`);return t&&!Ss(t)&&!e.parentElement?.classList.contains(`code-block-wrap`)});for(let e of t){let t=document.createElement(`div`);t.className=`code-block-wrap`,e.parentNode?.insertBefore(t,e),t.appendChild(e);let n=document.createElement(`button`);n.type=`button`,n.className=`code-copy-btn`,n.title=`Copy code`,n.setAttribute(`aria-label`,`Copy code`),n.innerHTML=Cs;let r=null;n.addEventListener(`click`,()=>{let t=e.querySelector(`code`)?.textContent??``;nt(t).then(e=>{e&&(n.classList.add(`copied`),n.innerHTML=ws,r&&clearTimeout(r),r=setTimeout(()=>{n.classList.remove(`copied`),n.innerHTML=Cs},1200))})}),t.appendChild(n)}}function Es(e){if(!e)return;let t=Array.from(e.querySelectorAll(`pre code`)).filter(e=>!Ss(e)&&e.dataset.highlighted!==`yes`);t.length!==0&&(xs??=C(()=>import(`./common-DvIV9UK2.js`).then(e=>e.default),__vite__mapDeps([21,1])),xs.then(e=>{for(let n of t){if(!n.isConnected||n.dataset.highlighted===`yes`)continue;let t=Array.from(n.classList).find(e=>e.startsWith(`language-`))?.slice(9);t&&!e.getLanguage(t)&&n.classList.remove(`language-${t}`),e.highlightElement(n)}}))}var Ds=null,Os=Promise.resolve(),ks=0;function As(){return Ds??=C(async()=>{let{default:e}=await import(`./mermaid.core-CYjB0fst.js`);return{default:e}},__vite__mapDeps([22,3,4,23,24,1,12,25,26,27,28,29,30,31,32,33,34,35,36])).then(({default:e})=>(e.initialize({startOnLoad:!1,securityLevel:`strict`,suppressErrorRendering:!0,theme:`base`,fontFamily:`inherit`}),e)),Ds}function js(e){return e instanceof HTMLElement&&Array.from(e.classList).some(e=>e.toLowerCase()===`language-mermaid`)}function Ms(e){if(!e)return;let t=Array.from(e.querySelectorAll(`pre > code`)).filter(js);for(let n of t){let t=n.parentElement;if(!t||t.dataset.mermaidState)continue;t.dataset.mermaidState=`queued`;let r=n.textContent??``;Os=Os.then(async()=>{if(t.isConnected&&e.contains(t))try{let n=await As();if(!t.isConnected||!e.contains(t))return;let i=`bivy-mermaid-${++ks}`,{svg:a,bindFunctions:o}=await n.render(i,r);if(!t.isConnected||!e.contains(t))return;let s=document.createElement(`div`);s.className=`mermaid-diagram`,s.setAttribute(`role`,`img`),s.setAttribute(`aria-label`,`Mermaid diagram`),s.innerHTML=a,t.replaceWith(s),o?.(s)}catch{t.dataset.mermaidState=`error`,t.title=`This Mermaid diagram could not be rendered`}})}}function Ns(e,t,n){return{distanceFromBottom:Math.max(0,e.scrollHeight-e.scrollTop-e.clientHeight),pinned:t,limit:n}}function Ps(e,t){return!t||t.pinned?e.scrollHeight:Math.max(0,e.scrollHeight-e.clientHeight-t.distanceFromBottom)}function Fs(e){return e===`/new`?`New session`:e===`/resume`?`Resume`:e===`fork`?`Fork to another agent`:e===`cancel-resume`?`Cancel auto-retry`:e===`fix-auth`||e.startsWith(`fix-auth:`)?`Fix sign-in`:e===`retry-auth`?`Refresh and retry`:e.startsWith(`connect-provider:`)?`Connect a provider`:e.startsWith(`retry-at-reset:`)?`Retry automatically at ${Is(e.slice(15))}`:`Run ${e}`}function Is(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return`reset`;let n=t.toDateString()===new Date().toDateString();return t.toLocaleString(void 0,n?{hour:`numeric`,minute:`2-digit`}:{weekday:`short`,hour:`numeric`,minute:`2-digit`})}function Ls({actions:e,onAction:t,size:n}){return!e?.length||!t?null:(0,G.jsx)(`div`,{className:`entry-actions`,children:e.map((e,r)=>(0,G.jsx)(`button`,{type:`button`,className:[`btn`,n,r===0?`primary`:``].filter(Boolean).join(` `),onClick:()=>t(e),children:Fs(e)},e))})}function Rs(){return(0,G.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:[(0,G.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`}),(0,G.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]})}function zs(){return(0,G.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:(0,G.jsx)(`polyline`,{points:`20 6 9 17 4 12`})})}function Bs({text:e}){let[t,n]=(0,W.useState)(!1),r=(0,W.useCallback)(()=>{nt(e).then(e=>{e&&(n(!0),setTimeout(()=>n(!1),1200))})},[e]);return(0,G.jsx)(`button`,{type:`button`,className:`msg-copy-btn${t?` copied`:``}`,onClick:r,title:t?`Copied`:`Copy message`,"aria-label":`Copy message`,children:t?(0,G.jsx)(zs,{}):(0,G.jsx)(Rs,{})})}function Vs(){return(0,G.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:[(0,G.jsx)(`polygon`,{points:`11 5 6 9 2 9 2 15 6 15 11 19 11 5`}),(0,G.jsx)(`path`,{d:`M15.54 8.46a5 5 0 0 1 0 7.07`}),(0,G.jsx)(`path`,{d:`M19.07 4.93a10 10 0 0 1 0 14.14`})]})}function Hs(){return(0,G.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:(0,G.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`1.5`})})}var Us=null;function Ws({text:e}){let[t,n]=(0,W.useState)(!1),r=(0,W.useRef)(null),i=(0,W.useRef)(null),a=(0,W.useRef)(0),o=(0,W.useCallback)(()=>{a.current+=1;let e=r.current;e&&(e.onend=null,e.onerror=null,r.current=null),window.speechSynthesis.cancel();let t=i.current;t&&(t.audio.pause(),URL.revokeObjectURL(t.url),i.current=null),n(!1),Us===o&&(Us=null)},[]);(0,W.useEffect)(()=>o,[o]);let s=(0,W.useCallback)(async()=>{if(t){o();return}let s=ao(e);if(!s)return;Us?.(),Us=o,n(!0);let c=eo();if(c.reader===`openai`){let e=++a.current;try{let t=await R.synthesize(s,c.openaiVoice,no(c.tone));if(a.current!==e)return;let n=Ur(t.audio,t.mimeType);if(!n)throw Error(`The generated speech audio was invalid.`);let r=new Audio(n);i.current={audio:r,url:n},r.onended=o,r.onerror=()=>{R.store.setError(`Could not play the generated speech.`),o()},await r.play()}catch(t){a.current===e&&(R.store.setError(t instanceof Error?t.message:String(t)),o())}return}if(!ro()){R.store.setError(`Browser speech is not supported on this device. Choose OpenAI under Settings → Voice.`),o();return}let l=window.speechSynthesis;l.cancel();let u=new SpeechSynthesisUtterance(s);u.rate=c.rate,c.browserVoice&&(u.voice=l.getVoices().find(e=>e.voiceURI===c.browserVoice||e.name===c.browserVoice)??null);let d=()=>{r.current===u&&o()};u.onend=d,u.onerror=d,r.current=u,l.speak(u)},[t,o,e]);return(0,G.jsx)(`button`,{type:`button`,className:`msg-speak-btn${t?` speaking`:``}`,onClick:s,title:t?`Stop`:`Read aloud`,"aria-label":t?`Stop reading`:`Read message aloud`,children:t?(0,G.jsx)(Hs,{}):(0,G.jsx)(Vs,{})})}var Gs=(0,W.memo)(function({entry:e,onAction:t,authAction:n,sessionId:r}){let i=(0,W.useMemo)(()=>e.role===`assistant`&&!e.streaming?e.html??ae(e.text):``,[e.role,e.streaming,e.html,e.text]),a=(0,W.useRef)(null);(0,W.useEffect)(()=>{if(e.role!==`assistant`)return;Ms(a.current),Es(a.current),Ts(a.current);let t=a.current;if(!t||!e.imageRefs)return;let n=!1,r=[];return t.querySelectorAll(`img.md-image[data-md-ref]`).forEach(t=>{let i=t.dataset.mdRef;if(!i||t.dataset.hydrated===`1`)return;let a=e.imageRefs?.[i];a&&(t.dataset.hydrated=`1`,R.fetchAttachment(a.hash).then(e=>{if(n||!e)return;let i=Ur(e.data,e.mimeType||a.mimeType);i&&(t.src=i,r.push(i))}))}),()=>{n=!0,r.forEach(e=>URL.revokeObjectURL(e))}},[e.role,i,e.imageRefs]);let[o,s]=(0,W.useState)([]);(0,W.useEffect)(()=>{if(e.role!==`assistant`||!a.current){s(e=>e.length?[]:e);return}let t=Array.from(a.current.querySelectorAll(`div.md-component`));s(e=>e.length===t.length&&e.every((e,n)=>e===t[n])?e:t)},[e.role,i]);let c=o.map((t,n)=>(0,Gn.createPortal)((0,G.jsx)(fs,{placement:ps(t),refs:e.imageRefs,sessionId:r??null}),t,`md-component-${n}`));if(e.role===`system`)return(0,G.jsxs)(`div`,{className:`msg system`,children:[(0,G.jsx)(`span`,{className:`system-text`,dangerouslySetInnerHTML:{__html:ae(e.text)}}),(0,G.jsx)(Ls,{actions:e.actions,onAction:t,size:`sm`})]});if(e.role===`thinking`)return(0,G.jsx)(`div`,{className:`msg thinking${e.streaming?` streaming`:``}`,children:e.text});if(e.role===`error`){let[r=`The agent hit an error`,...i]=e.text.split(`
|
|
23
|
+
`&&e++,l()):o+=t}(o!==``||a.length)&&l();let u=i.shift()??[],d=Math.max(0,i.length-t);return{header:u,rows:i.slice(0,t),omitted:d}}var Yo=5e3;function Xo(e,t=Yo){let{header:n,rows:r}=Jo(e,t);return r.map(e=>{let t={};return n.forEach((n,r)=>{let i=e[r]??``,a=i!==``&&!Number.isNaN(Number(i));t[n]=a?Number(i):i}),t})}var Zo=null;function Qo(){return Zo??=C(async()=>{let{default:e}=await import(`./embed-BXV41wg7.js`);return{default:e}},__vite__mapDeps([10,1,11,12,13,14,15,16,17,18,19,20])).then(({default:e})=>e),Zo}function $o(e,t){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t}function es(e,t,n=0){if(n>8||!e||typeof e!=`object`)return e;if(Array.isArray(e))return e.map(e=>es(e,t,n+1));let r=e;if(typeof r.url==`string`&&t.has(r.url)){let{url:e,format:n,...i}=r;return{...i,values:t.get(r.url)}}return Object.fromEntries(Object.entries(r).map(([e,r])=>[e,es(r,t,n+1)]))}function ts(e,t=0){if(t>8||!e||typeof e!=`object`)return null;if(Array.isArray(e)){for(let n of e){let e=ts(n,t+1);if(e)return e}return null}for(let[n,r]of Object.entries(e)){if(n===`url`&&typeof r==`string`)return r;let e=ts(r,t+1);if(e)return e}return null}async function ns(e,t){let n=ts(t);if(n)return{ok:!1,reason:`A chart can only read data from the workspace, not from “${n}”.`};let r;try{r=await Qo()}catch{return{ok:!1,reason:`The chart renderer could not be loaded.`}}if(!e.isConnected)return{ok:!1};let i=$o(`--ink`,`#1a1a1a`),a=$o(`--muted`,`#6b6b6b`),o=$o(`--line`,`#e0e0e0`),s=$o(`--accent`,`#3b5bdb`);try{let n={width:Math.max(120,e.clientWidth-20),autosize:{type:`fit`,contains:`padding`},...t};return await r(e,n,{actions:!1,renderer:`svg`,loader:{load:async()=>{throw Error(`charts cannot load external data`)}},config:{background:`transparent`,font:$o(`--font-sans`,`system-ui, sans-serif`),view:{stroke:null},axis:{labelColor:a,titleColor:i,gridColor:o,domainColor:o,tickColor:o},axisX:{labelAngle:0,labelOverlap:`parity`},legend:{labelColor:a,titleColor:i},title:{color:i},range:{category:[s,$o(`--ok`,`#2f9e44`),$o(`--warn`,`#e8590c`),$o(`--danger`,`#c92a2a`),a]},mark:{color:s}}}),{ok:!0}}catch(e){return{ok:!1,reason:e instanceof Error?e.message:`This chart could not be drawn.`}}}function rs(e,t){return{kind:e.kind,name:e.name,size:e.size,mimeType:e.mimeType,hash:e.hash,description:t}}function is(e){let t=e.attrs.caption;return typeof t==`string`&&t.trim()?t:void 0}function as({what:e,why:t}){return(0,G.jsxs)(`div`,{className:`card`,"data-tone":`muted`,children:[(0,G.jsx)(`div`,{className:`card-title`,children:e}),(0,G.jsx)(`div`,{className:`card-sub`,children:t})]})}function os({spec:e}){let t=e.value,n=e.label;return t==null||t===``?(0,G.jsx)(as,{what:`A number`,why:`This component has no value to show.`}):(0,G.jsxs)(`div`,{className:`card metric-component`,children:[(0,G.jsx)(`div`,{className:`metric-value`,children:String(t)}),n!=null&&n!==``&&(0,G.jsx)(`div`,{className:`card-sub`,children:String(n)})]})}function ss({placement:e,attachment:t}){let n=e.spec,r=Array.isArray(n?.columns)&&Array.isArray(n?.rows),i=t?rs(t):null,a=Gr(r?null:i),o=(0,W.useMemo)(()=>a.state===`ready`?Jo(a.text):null,[a]);if(r){let t=n.columns.map(String),r=n.rows.map(e=>Array.isArray(e)?e.map(String):[String(e)]);return(0,G.jsx)(cs,{caption:is(e)??(typeof n.title==`string`?n.title:void 0),header:t,rows:r,omitted:0})}return t?a.state===`error`?(0,G.jsx)(as,{what:e.ref??t.name,why:a.reason}):o?o.header.length?(0,G.jsx)(cs,{caption:is(e)??t.name,header:o.header,rows:o.rows,omitted:o.omitted}):(0,G.jsx)(as,{what:e.ref??t.name,why:`This file has no rows to show.`}):(0,G.jsx)(as,{what:e.ref??t.name,why:`Reading this file…`}):(0,G.jsx)(as,{what:e.ref??`A table`,why:`This table is still being prepared, or could not be read.`})}function cs({caption:e,header:t,rows:n,omitted:r}){return(0,G.jsxs)(`figure`,{className:`table-component`,children:[(0,G.jsx)(`div`,{className:`markdown-table-wrap`,children:(0,G.jsxs)(`table`,{children:[(0,G.jsx)(`thead`,{children:(0,G.jsx)(`tr`,{children:t.map((e,t)=>(0,G.jsx)(`th`,{children:e},t))})}),(0,G.jsx)(`tbody`,{children:n.map((e,n)=>(0,G.jsx)(`tr`,{children:t.map((t,n)=>(0,G.jsx)(`td`,{children:e[n]??``},n))},n))})]})}),(e||r>0)&&(0,G.jsxs)(`figcaption`,{className:`card-sub`,children:[e,r>0&&`${e?` · `:``}${r} more row${r===1?``:`s`} not shown`]})]})}async function ls(e,t){if(t.size>524288)return null;let n=await R.fetchAttachment(t.hash);if(!n)return null;let r;try{let e=atob(n.data);r=new TextDecoder().decode(Uint8Array.from(e,e=>e.charCodeAt(0)))}catch{return null}if(/\.json$/i.test(e)||(t.mimeType||``).includes(`json`))try{let e=JSON.parse(r);return Array.isArray(e)?e:null}catch{return null}let i=Xo(r);return i.length?i:null}function us({placement:e,refs:t}){let n=(0,W.useRef)(null),[r,i]=(0,W.useState)(null),a=e.spec,o=Number(e.attrs.height)||0,s=(0,W.useMemo)(()=>JSON.stringify((a?se(a):[]).map(e=>[e,t?.[e]??null])),[a,t]),[c,l]=(0,W.useState)(()=>JSON.parse(s).length?{state:`loading`}:{state:`ready`,byRef:new Map});(0,W.useEffect)(()=>{let e=JSON.parse(s);if(!e.length){l({state:`ready`,byRef:new Map});return}if(e.some(([,e])=>!e)){l({state:`loading`});return}let t=!1;return l({state:`loading`}),Promise.all(e.map(async([e,t])=>[e,await ls(e,t)])).then(e=>{if(t)return;let n=e.find(([,e])=>e===null);if(n){l({state:`error`,reason:`“${n[0]}” could not be read as data.`});return}l({state:`ready`,byRef:new Map(e)})}),()=>{t=!0}},[s]);let u=(0,W.useMemo)(()=>a&&c.state===`ready`?JSON.stringify(es(a,c.byRef)):``,[a,c]);if((0,W.useEffect)(()=>{let e=n.current;if(!e||!u)return;let t=!1;return e.replaceChildren(),i(null),ns(e,JSON.parse(u)).then(e=>{t||e.ok||e.reason&&i(e.reason)}),()=>{t=!0,e.replaceChildren()}},[u]),!a)return(0,G.jsx)(as,{what:`A chart`,why:`This component has no chart to draw.`});let d=typeof a.title==`string`?a.title:`A chart`;if(c.state===`error`)return(0,G.jsx)(as,{what:d,why:c.reason});if(r)return(0,G.jsx)(as,{what:d,why:r});let f=is(e)??(typeof a.description==`string`?a.description:void 0);return(0,G.jsxs)(`figure`,{className:`chart-component`,children:[(0,G.jsx)(`div`,{ref:n,className:`chart-host`,style:o?{minHeight:`${o}px`}:void 0}),f&&(0,G.jsx)(`figcaption`,{className:`card-sub`,children:f})]})}var ds={app:({placement:e,sessionId:t})=>{let n=e.spec?.appId;return typeof n==`string`?(0,G.jsx)(Ko,{appId:n,caption:is(e),sessionId:t}):(0,G.jsx)(as,{what:`An app`,why:`This component names no app to show.`})},chart:e=>(0,G.jsx)(us,{...e}),metric:({placement:e})=>e.spec?(0,G.jsx)(os,{spec:e.spec}):(0,G.jsx)(as,{what:`A number`,why:`This component has no value to show.`}),table:e=>(0,G.jsx)(ss,{...e}),image:({placement:e,attachment:t})=>t?(0,G.jsx)(Uo,{attachment:rs(t,is(e))}):(0,G.jsx)(as,{what:e.ref??`An image`,why:`This image is still being prepared, or could not be read.`}),file:({placement:e,attachment:t})=>t?(0,G.jsx)(Uo,{attachment:rs(t,is(e))}):(0,G.jsx)(as,{what:e.ref??`A file`,why:`This file is still being prepared, or could not be read.`})};Object.keys(ds);function fs({placement:e,refs:t,sessionId:n}){let r=e.ref?t?.[e.ref]??null:null,i=(0,W.useMemo)(()=>A({path:e.ref,mimeType:r?.mimeType,spec:e.spec}),[e.ref,e.spec,r?.mimeType]),a=ds[i];return a?(0,G.jsx)(G.Fragment,{children:a({placement:e,attachment:r,refs:t,sessionId:n})}):(0,G.jsx)(as,{what:e.ref??(typeof e.spec?.title==`string`?e.spec.title:`A “${i}” view`),why:`This version of Bivy cannot show a “${i}” yet.`})}function ps(e){let t=e=>{if(!e)return null;try{let t=JSON.parse(e);return t&&typeof t==`object`&&!Array.isArray(t)?t:null}catch{return null}};return{ref:e.dataset.mdRef??null,spec:t(e.dataset.mdSpec),attrs:t(e.dataset.mdAttrs)??{}}}function ms(e,t){let n=[],r=null,i=null,a=[],o=[],s=()=>{let e=i??r;if(e){if(a.length===0)n.push(e);else{let t=new Set,r=a.filter(e=>{let n=e.hash||`${e.kind}:${e.name}:${e.size}`;return!t.has(n)&&(t.add(n),!0)});n.push({...e,attachments:r})}}n.push(...o.filter(t=>t.id!==e?.id)),r=null,i=null,a=[],o=[]};for(let t of e)if(!(t.tool||t.toolOutput||t.role===`thinking`)){if(t.role===`assistant`){r=t,(t.app||t.review||t.notice)&&o.push(t),(t.text||t.streaming)&&(i=t),t.attachments?.length&&a.push(...t.attachments);continue}s(),n.push(t)}if(s(),!t)return n;let c=n.findLastIndex(e=>e.role===`user`);return n.flatMap((e,t)=>e.role===`assistant`&&(c<0||t>c)?e.app||e.review||e.notice||e.attachments?.length?[{...e,text:``,html:void 0,streaming:!1}]:[]:[e])}var hs=3e4,gs=null;function _s(e,t){gs={sessionId:e,target:t,at:Date.now()}}var vs=(e,t)=>`hash`in t?!!e.attachments?.some(e=>e.hash===t.hash):`reviewId`in t?e.review?.id===t.reviewId:e.app?.appId===t.appId;function ys(e,t){if(!gs||gs.sessionId!==e)return null;if(Date.now()-gs.at>hs)return gs=null,null;let{target:n}=gs,r=t.findLastIndex(e=>vs(e,n));return r>=0?r:null}function bs(){gs=null}var xs=null;function Ss(e){return Array.from(e.classList).some(e=>e.toLowerCase()===`language-mermaid`)}var Cs=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`,ws=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden><polyline points="20 6 9 17 4 12"/></svg>`;function Ts(e){if(!e)return;let t=Array.from(e.querySelectorAll(`pre`)).filter(e=>{let t=e.querySelector(`code`);return t&&!Ss(t)&&!e.parentElement?.classList.contains(`code-block-wrap`)});for(let e of t){let t=document.createElement(`div`);t.className=`code-block-wrap`,e.parentNode?.insertBefore(t,e),t.appendChild(e);let n=document.createElement(`button`);n.type=`button`,n.className=`code-copy-btn`,n.title=`Copy code`,n.setAttribute(`aria-label`,`Copy code`),n.innerHTML=Cs;let r=null;n.addEventListener(`click`,()=>{let t=e.querySelector(`code`)?.textContent??``;nt(t).then(e=>{e&&(n.classList.add(`copied`),n.innerHTML=ws,r&&clearTimeout(r),r=setTimeout(()=>{n.classList.remove(`copied`),n.innerHTML=Cs},1200))})}),t.appendChild(n)}}function Es(e){if(!e)return;let t=Array.from(e.querySelectorAll(`pre code`)).filter(e=>!Ss(e)&&e.dataset.highlighted!==`yes`);t.length!==0&&(xs??=C(()=>import(`./common-DvIV9UK2.js`).then(e=>e.default),__vite__mapDeps([21,1])),xs.then(e=>{for(let n of t){if(!n.isConnected||n.dataset.highlighted===`yes`)continue;let t=Array.from(n.classList).find(e=>e.startsWith(`language-`))?.slice(9);t&&!e.getLanguage(t)&&n.classList.remove(`language-${t}`),e.highlightElement(n)}}))}var Ds=null,Os=Promise.resolve(),ks=0;function As(){return Ds??=C(async()=>{let{default:e}=await import(`./mermaid.core-D-l2iyMD.js`);return{default:e}},__vite__mapDeps([22,3,4,23,24,1,12,25,26,27,28,29,30,31,32,33,34,35,36])).then(({default:e})=>(e.initialize({startOnLoad:!1,securityLevel:`strict`,suppressErrorRendering:!0,theme:`base`,fontFamily:`inherit`}),e)),Ds}function js(e){return e instanceof HTMLElement&&Array.from(e.classList).some(e=>e.toLowerCase()===`language-mermaid`)}function Ms(e){if(!e)return;let t=Array.from(e.querySelectorAll(`pre > code`)).filter(js);for(let n of t){let t=n.parentElement;if(!t||t.dataset.mermaidState)continue;t.dataset.mermaidState=`queued`;let r=n.textContent??``;Os=Os.then(async()=>{if(t.isConnected&&e.contains(t))try{let n=await As();if(!t.isConnected||!e.contains(t))return;let i=`bivy-mermaid-${++ks}`,{svg:a,bindFunctions:o}=await n.render(i,r);if(!t.isConnected||!e.contains(t))return;let s=document.createElement(`div`);s.className=`mermaid-diagram`,s.setAttribute(`role`,`img`),s.setAttribute(`aria-label`,`Mermaid diagram`),s.innerHTML=a,t.replaceWith(s),o?.(s)}catch{t.dataset.mermaidState=`error`,t.title=`This Mermaid diagram could not be rendered`}})}}function Ns(e,t,n){return{distanceFromBottom:Math.max(0,e.scrollHeight-e.scrollTop-e.clientHeight),pinned:t,limit:n}}function Ps(e,t){return!t||t.pinned?e.scrollHeight:Math.max(0,e.scrollHeight-e.clientHeight-t.distanceFromBottom)}function Fs(e){return e===`/new`?`New session`:e===`/resume`?`Resume`:e===`fork`?`Fork to another agent`:e===`cancel-resume`?`Cancel auto-retry`:e===`fix-auth`||e.startsWith(`fix-auth:`)?`Fix sign-in`:e===`retry-auth`?`Refresh and retry`:e.startsWith(`connect-provider:`)?`Connect a provider`:e.startsWith(`retry-at-reset:`)?`Retry automatically at ${Is(e.slice(15))}`:`Run ${e}`}function Is(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return`reset`;let n=t.toDateString()===new Date().toDateString();return t.toLocaleString(void 0,n?{hour:`numeric`,minute:`2-digit`}:{weekday:`short`,hour:`numeric`,minute:`2-digit`})}function Ls({actions:e,onAction:t,size:n}){return!e?.length||!t?null:(0,G.jsx)(`div`,{className:`entry-actions`,children:e.map((e,r)=>(0,G.jsx)(`button`,{type:`button`,className:[`btn`,n,r===0?`primary`:``].filter(Boolean).join(` `),onClick:()=>t(e),children:Fs(e)},e))})}function Rs(){return(0,G.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:[(0,G.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`}),(0,G.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]})}function zs(){return(0,G.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:(0,G.jsx)(`polyline`,{points:`20 6 9 17 4 12`})})}function Bs({text:e}){let[t,n]=(0,W.useState)(!1),r=(0,W.useCallback)(()=>{nt(e).then(e=>{e&&(n(!0),setTimeout(()=>n(!1),1200))})},[e]);return(0,G.jsx)(`button`,{type:`button`,className:`msg-copy-btn${t?` copied`:``}`,onClick:r,title:t?`Copied`:`Copy message`,"aria-label":`Copy message`,children:t?(0,G.jsx)(zs,{}):(0,G.jsx)(Rs,{})})}function Vs(){return(0,G.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:[(0,G.jsx)(`polygon`,{points:`11 5 6 9 2 9 2 15 6 15 11 19 11 5`}),(0,G.jsx)(`path`,{d:`M15.54 8.46a5 5 0 0 1 0 7.07`}),(0,G.jsx)(`path`,{d:`M19.07 4.93a10 10 0 0 1 0 14.14`})]})}function Hs(){return(0,G.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:(0,G.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`1.5`})})}var Us=null;function Ws({text:e}){let[t,n]=(0,W.useState)(!1),r=(0,W.useRef)(null),i=(0,W.useRef)(null),a=(0,W.useRef)(0),o=(0,W.useCallback)(()=>{a.current+=1;let e=r.current;e&&(e.onend=null,e.onerror=null,r.current=null),window.speechSynthesis.cancel();let t=i.current;t&&(t.audio.pause(),URL.revokeObjectURL(t.url),i.current=null),n(!1),Us===o&&(Us=null)},[]);(0,W.useEffect)(()=>o,[o]);let s=(0,W.useCallback)(async()=>{if(t){o();return}let s=ao(e);if(!s)return;Us?.(),Us=o,n(!0);let c=eo();if(c.reader===`openai`){let e=++a.current;try{let t=await R.synthesize(s,c.openaiVoice,no(c.tone));if(a.current!==e)return;let n=Ur(t.audio,t.mimeType);if(!n)throw Error(`The generated speech audio was invalid.`);let r=new Audio(n);i.current={audio:r,url:n},r.onended=o,r.onerror=()=>{R.store.setError(`Could not play the generated speech.`),o()},await r.play()}catch(t){a.current===e&&(R.store.setError(t instanceof Error?t.message:String(t)),o())}return}if(!ro()){R.store.setError(`Browser speech is not supported on this device. Choose OpenAI under Settings → Voice.`),o();return}let l=window.speechSynthesis;l.cancel();let u=new SpeechSynthesisUtterance(s);u.rate=c.rate,c.browserVoice&&(u.voice=l.getVoices().find(e=>e.voiceURI===c.browserVoice||e.name===c.browserVoice)??null);let d=()=>{r.current===u&&o()};u.onend=d,u.onerror=d,r.current=u,l.speak(u)},[t,o,e]);return(0,G.jsx)(`button`,{type:`button`,className:`msg-speak-btn${t?` speaking`:``}`,onClick:s,title:t?`Stop`:`Read aloud`,"aria-label":t?`Stop reading`:`Read message aloud`,children:t?(0,G.jsx)(Hs,{}):(0,G.jsx)(Vs,{})})}var Gs=(0,W.memo)(function({entry:e,onAction:t,authAction:n,sessionId:r}){let i=(0,W.useMemo)(()=>e.role===`assistant`&&!e.streaming?e.html??ae(e.text):``,[e.role,e.streaming,e.html,e.text]),a=(0,W.useRef)(null);(0,W.useEffect)(()=>{if(e.role!==`assistant`)return;Ms(a.current),Es(a.current),Ts(a.current);let t=a.current;if(!t||!e.imageRefs)return;let n=!1,r=[];return t.querySelectorAll(`img.md-image[data-md-ref]`).forEach(t=>{let i=t.dataset.mdRef;if(!i||t.dataset.hydrated===`1`)return;let a=e.imageRefs?.[i];a&&(t.dataset.hydrated=`1`,R.fetchAttachment(a.hash).then(e=>{if(n||!e)return;let i=Ur(e.data,e.mimeType||a.mimeType);i&&(t.src=i,r.push(i))}))}),()=>{n=!0,r.forEach(e=>URL.revokeObjectURL(e))}},[e.role,i,e.imageRefs]);let[o,s]=(0,W.useState)([]);(0,W.useEffect)(()=>{if(e.role!==`assistant`||!a.current){s(e=>e.length?[]:e);return}let t=Array.from(a.current.querySelectorAll(`div.md-component`));s(e=>e.length===t.length&&e.every((e,n)=>e===t[n])?e:t)},[e.role,i]);let c=o.map((t,n)=>(0,Gn.createPortal)((0,G.jsx)(fs,{placement:ps(t),refs:e.imageRefs,sessionId:r??null}),t,`md-component-${n}`));if(e.role===`system`)return(0,G.jsxs)(`div`,{className:`msg system`,children:[(0,G.jsx)(`span`,{className:`system-text`,dangerouslySetInnerHTML:{__html:ae(e.text)}}),(0,G.jsx)(Ls,{actions:e.actions,onAction:t,size:`sm`})]});if(e.role===`thinking`)return(0,G.jsx)(`div`,{className:`msg thinking${e.streaming?` streaming`:``}`,children:e.text});if(e.role===`error`){let[r=`The agent hit an error`,...i]=e.text.split(`
|
|
24
24
|
`),a=i.join(`
|
|
25
25
|
`).trim(),o=e.actions?.length?e.actions:n&&I(e.text)?[n,`retry-auth`]:void 0;return(0,G.jsxs)(`div`,{className:`card transcript-error`,"data-tone":`danger`,role:`alert`,children:[(0,G.jsx)(`strong`,{children:r}),(0,G.jsx)(Ls,{actions:o,onAction:t}),a&&(0,G.jsxs)(`details`,{className:`settings-disclosure`,children:[(0,G.jsx)(`summary`,{className:`settings-disclosure-summary`,children:`Details`}),(0,G.jsx)(`pre`,{className:`settings-disclosure-body`,children:a})]})]})}if(e.role===`user`){let t=dn(e.text);if(t)return(0,G.jsx)(Ho,{seed:t,text:e.text});let n=!!e.attachments&&e.attachments.length>0,r=n?Se(e.text):e.text;return(0,G.jsxs)(`div`,{className:`msg user`,id:n?`msg-${e.id}`:void 0,children:[n&&(0,G.jsx)(Go,{attachments:e.attachments}),r]})}if(e.streaming)return(0,G.jsx)(`div`,{className:`assistant-row`,children:(0,G.jsx)(`div`,{ref:a,className:`msg assistant streaming streaming-text`,children:e.text})});let l=!!e.attachments&&e.attachments.length>0,u=e.attachments?.length===1&&e.attachments[0]?.description===e.text;return(0,G.jsxs)(`div`,{className:`assistant-row`,id:l||e.app||e.review||e.pin||e.notice||e.delegation?`msg-${e.id}`:void 0,children:[e.app&&(0,G.jsx)(mo,{app:e.app}),e.review&&(0,G.jsx)(yo,{review:e.review}),e.pin&&(0,G.jsx)(xo,{pin:e.pin}),e.notice&&(0,G.jsx)(So,{notice:e.notice}),e.delegation&&(0,G.jsx)(Oo,{delegation:e.delegation}),l&&(0,G.jsx)(Go,{attachments:e.attachments}),(e.text&&!u||!l&&!e.app&&!e.review&&!e.pin&&!e.notice&&!e.delegation)&&(0,G.jsx)(`div`,{ref:a,className:`msg assistant`,dangerouslySetInnerHTML:{__html:i}}),c,e.text&&!u&&(0,G.jsxs)(`div`,{className:`msg-actions`,children:[(0,G.jsx)(Bs,{text:e.text}),io()&&(0,G.jsx)(Ws,{text:e.text})]})]})});function Ks(e){let t=[],n=null;for(let r of e){if(r.kind===`entry`&&r.entry.role===`user`){n={kind:`turn`,key:`turn-${r.key}`,user:r,response:[]},t.push(n);continue}if(r.kind===`entry`&&(r.entry.role===`system`||r.entry.role===`error`)){t.push({kind:`standalone`,key:`standalone-${r.key}`,item:r}),n=null;continue}n||(n={kind:`turn`,key:`turn-${r.key}`,response:[]},t.push(n)),n.response.push(r)}for(let e of t)e.kind===`turn`&&(e.response=Ys(e.response,e.key));return t}function qs(e){return e.detail?.kind===`plan`&&!e.parentToolUseId&&_n(e.input)!==void 0}function Js(e){let t=new Map,n=[];for(let r of e)r.tool&&qs(r.tool)&&(n=vn(n,_n(r.tool.input)),t.set(r.tool.callId,n));return t}function Ys(e,t){let n=-1;if(e.forEach((e,t)=>{e.kind===`plan`&&(n=t)}),n<0)return e;let r=[];return e.forEach((e,i)=>{if(e.kind===`plan`&&i!==n)return;let a=r[r.length-1];if(e.kind===`tools`&&a?.kind===`tools`){r[r.length-1]={...a,tools:[...a.tools,...e.tools]};return}r.push(e.kind===`plan`?{...e,key:`plan-${t}`}:e)}),r}function Xs(e){let t=[],n=[],r=``,i=()=>{n.length&&t.push({kind:`tools`,key:r,tools:n}),n=[]};for(let a of e)a.tool&&qs(a.tool)?(i(),t.push({kind:`plan`,key:`plan-${a.tool.callId}`,callId:a.tool.callId})):a.tool?(n.length||(r=`tools-${a.tool.callId||a.id}`),n.push(a.tool)):(i(),t.push({kind:`entry`,key:a.id,entry:a}));return i(),t}var Zs=20,Qs=40;function $s({entries:e,working:t,workingLabel:n,draftRoute:r,opening:i,sessionKey:a,focusView:o,onAction:s,authAction:c,header:l,footer:u,greeting:d}){let f=(0,W.useRef)(null),p=(0,W.useRef)(null),[m,h]=(0,W.useState)(!0),g=(0,W.useMemo)(()=>o?ms(e,t):e,[e,o,t]),_=g.length,v=(0,W.useRef)(new Map),[y,b]=(0,W.useState)(()=>({sessionKey:a,focusView:o,initialized:_>0,start:Math.max(0,_-Zs)})),x=Math.max(0,_-Zs),S=Math.min(y.start,x);if(y.sessionKey!==a||y.focusView!==o||!y.initialized&&_>0){let e=v.current.get(a??`new`);S=Math.max(0,_-Math.max(Zs,e?.limit??Zs)),b({sessionKey:a,focusView:o,initialized:_>0,start:S})}else(S!==y.start||y.initialized&&_===0)&&b({...y,initialized:_>0,start:S});let C=ys(a,g);C!==null&&C<S&&(S=C,b({sessionKey:a,focusView:o,initialized:!0,start:S}));let w=(0,W.useRef)(_-S);(0,W.useLayoutEffect)(()=>{w.current=_-S},[_,S]);let T=(0,W.useRef)(!0),E=(0,W.useCallback)(e=>{T.current=e,h(e)},[]),D=(0,W.useCallback)(()=>{let e=f.current;return!e||e.scrollHeight-e.scrollTop-e.clientHeight<80},[]),O=(0,W.useCallback)(()=>{let e=f.current;e&&(e.scrollTop=e.scrollHeight)},[]),k=(0,W.useCallback)(()=>{let e=f.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`smooth`}),E(!0)},[E]);(0,W.useLayoutEffect)(()=>{let e=v.current.get(a??`new`);E(e?.pinned??!0);let t=requestAnimationFrame(()=>{let t=f.current;t&&(t.scrollTop=Ps(t,e))});return()=>cancelAnimationFrame(t)},[a,E]),(0,W.useLayoutEffect)(()=>{let e=ys(a,g);if(e===null||e<S)return;let t=`msg-${g[e].id}`;bs(),E(!1),requestAnimationFrame(()=>{let e=document.getElementById(t);e&&(e.scrollIntoView({block:`center`}),e.classList.add(`is-jump-target`),setTimeout(()=>e.classList.remove(`is-jump-target`),2400))})},[a,g,S,E]);let A=(0,W.useCallback)(()=>{let e=f.current;if(!e)return;let t=D();E(t),v.current.set(a??`new`,Ns(e,t,w.current))},[D,a,E]),ee=(0,W.useCallback)(()=>{b(e=>({...e,start:Math.max(0,e.start-Qs)}))},[]);(0,W.useLayoutEffect)(()=>{T.current&&O()}),(0,W.useEffect)(()=>{let e=p.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{T.current&&O()});return t.observe(e),()=>t.disconnect()},[O]);let j=(0,W.useMemo)(()=>Js(g),[g]),M=S>0?g.slice(S):g,te=Ks(Xs(M)),ne=M.at(-1),re=!!(ne?.role===`assistant`||ne?.tool),ie=e=>e.kind===`tools`?(0,G.jsx)(Lo,{tools:e.tools},e.key):e.kind===`plan`?j.get(e.callId)?.length?(0,G.jsx)(zo,{plan:j.get(e.callId)},e.key):null:(0,G.jsx)(Gs,{entry:e.entry,onAction:s,authAction:c,sessionId:a},e.key);return(0,G.jsxs)(`div`,{className:`chat-wrap`,children:[(0,G.jsx)(`div`,{className:`chat`,ref:f,onScroll:A,children:(0,G.jsxs)(`div`,{className:`chat-inner`,ref:p,children:[l,_===0&&!l&&!r&&i&&(0,G.jsxs)(`div`,{className:`chat-loading`,role:`status`,"aria-live":`polite`,children:[(0,G.jsx)(V,{size:`lg`}),(0,G.jsx)(`p`,{children:`Fetching transcript…`})]}),_===0&&!l&&r&&d&&(0,G.jsx)(`div`,{className:`chat-greeting`,children:(0,G.jsx)(`h2`,{children:d})}),_===0&&!l&&!r&&!i&&(0,G.jsxs)(`div`,{className:`chat-empty`,children:[(0,G.jsx)(`p`,{className:`chat-empty-title`,children:`No messages yet`}),(0,G.jsx)(`p`,{className:`chat-empty-sub`,children:`This session has no transcript so far. Send a message below to continue, or open the terminal if it is running there.`})]}),S>0&&(0,G.jsxs)(`button`,{className:`load-earlier`,onClick:ee,children:[`↑ Show earlier messages (`,S,` more)`]}),te.map(e=>e.kind===`standalone`?(0,G.jsx)(`div`,{className:`transcript-standalone`,children:ie(e.item)},e.key):(0,G.jsxs)(`div`,{className:`transcript-turn`,children:[e.user?.kind===`entry`&&(0,G.jsx)(Gs,{entry:e.user.entry,onAction:s,sessionId:a}),e.response.length>0&&(0,G.jsx)(`div`,{className:`turn-response-body`,children:e.response.map(ie)})]},e.key)),t&&!re&&(0,G.jsxs)(`div`,{className:`working-row`,children:[(0,G.jsxs)(`span`,{className:`working-dots`,"aria-hidden":!0,children:[(0,G.jsx)(`i`,{}),(0,G.jsx)(`i`,{}),(0,G.jsx)(`i`,{})]}),(0,G.jsx)(`span`,{className:`working-label`,children:n||`working…`})]}),u]})}),!m&&_>0&&(0,G.jsx)(`button`,{className:`jump-latest`,onClick:k,"aria-label":`Jump to latest`,children:`↓ Latest`})]})}function ec({choice:e,onChoose:t,onRefresh:n,onSetupCredentials:r}){let[i,a]=(0,W.useState)(!1),[o,s]=(0,W.useState)(``),c=e.models.filter(e=>`${e.label??e.id} ${e.provider}`.toLowerCase().includes(o.toLowerCase()));return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{children:`Your prompt is saved. Choose a model on this machine to send it. No message has been sent yet.`}),e.error&&(0,G.jsx)(`p`,{role:`alert`,children:e.error}),(0,G.jsx)(`button`,{type:`button`,className:`btn primary session-launch-action`,disabled:e.loading||e.selecting||!t,onClick:()=>a(!0),children:e.loading?`Loading models…`:e.selecting?`Selecting model…`:`Choose model and send`}),i&&(0,G.jsxs)(ot,{title:`Choose a model`,onClose:()=>a(!1),size:`large`,autoFocusSearch:!1,children:[(0,G.jsx)(`p`,{children:`Selecting a model sends your saved first message.`}),(0,G.jsx)(`input`,{className:`picker-search`,"aria-label":`Search models`,placeholder:`Search models…`,value:o,onChange:e=>s(e.target.value)}),(0,G.jsxs)(`div`,{className:`picker-list`,children:[c.map(n=>(0,G.jsx)(ct,{title:n.label||n.id,meta:`${n.provider}${e.current?.id===n.id&&e.current.provider===n.provider?` · Default on this machine`:``}`,onClick:()=>{a(!1),t?.(n)}},`${n.provider}:${n.id}`)),!!e.models.length&&!c.length&&(0,G.jsx)(`p`,{className:`picker-empty`,children:`No models match your search.`}),!e.models.length&&(0,G.jsx)(`p`,{className:`picker-empty`,children:e.error||`No connected models are available. Set up model credentials, then refresh.`})]}),(0,G.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:n,children:`Refresh models`}),!e.models.length&&!e.error&&r&&(0,G.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:()=>{r()},children:`Set up model credentials`})]})]})}var tc=[{id:`account`,label:`Checking account and provider access`},{id:`capacity`,label:`Reserving Bivy Cloud capacity`},{id:`machine`,label:`Creating the isolated Machine`},{id:`service`,label:`Starting the secure Bivy service`},{id:`credentials`,label:`Checking model credentials`},{id:`repository`,label:`Preparing the repository`,skippedLabel:`No repository selected`},{id:`agent`,label:`Starting the agent and session`},{id:`message`,label:`Delivering your first message`}];function nc(e,t){let n=Math.max(0,Math.floor((t-e)/1e3)),r=Math.floor(n/60),i=n%60;return r?`${r}:${String(i).padStart(2,`0`)}`:`${i}s`}function rc({progress:e,onSetupCredentials:t,onRetryLaunch:n,onChooseModel:r,onRefreshModels:i}){let a=e.modelChoice,o=e.checkpoints.account?.errorCode===`managed_credentials_required`,s=e.firstResponseAt??e.failedAt,[c,l]=(0,W.useState)(()=>s??Date.now()),[u,d]=(0,W.useState)(!1);(0,W.useEffect)(()=>{if(s){l(s);return}let e=window.setInterval(()=>l(Date.now()),1e3);return()=>window.clearInterval(e)},[s]);let f=nc(e.startedAt,s??c),p=e.firstResponseAt?`Agent responded in ${f}`:e.failedAt?`Startup failed after ${f}`:a?a.loading?`Loading models from this machine`:a.selecting?`Confirming model selection`:`Choose a model before your first message`:e.checkpoints.message?.state===`done`?`Waiting for agent response · ${f} elapsed`:`Starting Bivy Cloud · ${f} elapsed`;return(0,G.jsxs)(`section`,{className:`session-launch-progress`,"aria-label":`Bivy Cloud startup progress`,children:[(0,G.jsx)(`div`,{className:`session-launch-progress-title`,"aria-live":`polite`,children:p}),a&&(0,G.jsx)(ec,{choice:a,onChoose:r,onRefresh:i,onSetupCredentials:t}),(0,G.jsx)(`ol`,{className:`session-launch-checkpoints`,children:tc.map(({id:t,label:n,skippedLabel:r})=>{let i=e.checkpoints[t],a=e.failedAt&&i?.state===`active`?`waiting`:i?.state??`waiting`,o=a===`skipped`&&r?r:n;return(0,G.jsxs)(`li`,{className:`session-launch-checkpoint state-${a}`,children:[(0,G.jsx)(`span`,{className:`session-launch-checkpoint-mark`,"aria-hidden":`true`,children:a===`done`?`✓`:a===`failed`?`!`:a===`skipped`?`–`:a===`active`?(0,G.jsx)(V,{size:`xs`}):`○`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`session-launch-checkpoint-label`,children:o}),a===`failed`&&i?.error&&(0,G.jsx)(`span`,{className:`session-launch-checkpoint-error`,children:i.error})]}),(0,G.jsxs)(`span`,{className:`sr-only`,children:[` — `,a]})]},t)})}),e.failedAt&&o&&t&&(0,G.jsx)(`button`,{type:`button`,className:`btn primary session-launch-action`,disabled:u,onClick:()=>{d(!0),t().finally(()=>d(!1))},children:u?`Opening setup…`:`Set up model credentials`}),e.failedAt&&!o&&n&&(0,G.jsx)(`button`,{type:`button`,className:`btn primary session-launch-action`,disabled:u,onClick:()=>{d(!0),n().finally(()=>d(!1))},children:u?`Retrying…`:`Retry this launch`})]})}var ic=8e3;function ac({approval:e,onResolve:t}){let[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(!1),[o,s]=(0,W.useState)(!1),c=kn(e),l=typeof e.rememberKey==`string`&&e.rememberKey?e.rememberKey:null,u=c.canRemember&&l!==null,d=(0,W.useRef)(null),f=(0,W.useRef)(null);(0,W.useEffect)(()=>()=>{f.current&&clearTimeout(f.current)},[]);let p=()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>a(!0),ic)},m=(n,i=!1)=>{d.current={approved:n,remember:i},r(!0),a(!1),t(e.id,n,i),p()},h=()=>{d.current&&(a(!1),t(e.id,d.current.approved,d.current.remember),p())},g=c.severity===`critical`?`Permanent`:c.severity===`high`?`High risk`:c.severity===`medium`?`Medium risk`:`Low risk`,_=c.severity===`critical`||c.severity===`high`?`danger`:c.severity===`medium`?`warn`:`accent`;return(0,G.jsxs)(`div`,{id:`attention-${encodeURIComponent(e.id)}`,className:`card approval-card sev-${c.severity}${n?` pending`:``}`,"data-tone":c.severity===`critical`?`danger`:`accent`,"data-attention-card":!0,tabIndex:-1,children:[(0,G.jsxs)(`div`,{className:`approval-head`,children:[(0,G.jsx)(`span`,{className:`approval-title`,children:c.title}),(0,G.jsx)(Te,{tone:_,variant:`soft`,upper:!0,children:g})]}),(0,G.jsx)(`div`,{className:`approval-consequence`,children:c.consequence}),typeof e.reason==`string`&&e.reason&&(0,G.jsx)(`div`,{className:`approval-reason`,children:e.reason}),c.command&&(0,G.jsx)(`pre`,{className:`approval-command`,children:c.command}),c.fields.length>0&&(0,G.jsx)(`div`,{className:`approval-fields`,children:c.fields.map(([e,t])=>(0,G.jsxs)(`div`,{className:`approval-field`,children:[(0,G.jsx)(`div`,{className:`approval-field-label`,children:e}),(0,G.jsx)(`div`,{className:`approval-field-value`,children:t})]},e))}),(0,G.jsxs)(`button`,{type:`button`,className:`approval-raw-toggle`,onClick:()=>s(e=>!e),children:[o?`Hide`:`Show`,` raw tool input`]}),o&&(0,G.jsx)(`pre`,{className:`approval-summary`,children:c.rawInput}),n?(0,G.jsxs)(`div`,{className:`approval-waiting`,children:[`Waiting for the machine to apply your choice…`,i&&(0,G.jsxs)(`div`,{className:`approval-stalled`,children:[(0,G.jsx)(`span`,{children:`This is taking longer than expected.`}),(0,G.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:h,children:`Retry`})]})]}):(0,G.jsxs)(`div`,{className:`approval-actions`,children:[(0,G.jsx)(`button`,{className:`btn danger-ghost`,onClick:()=>m(!1),children:`Reject`}),u&&(0,G.jsxs)(`button`,{className:`btn ghost`,onClick:()=>m(!0,!0),title:`Approve, and allow “${l}” without asking until this session closes`,children:[`Allow “`,l,`” this session`]}),(0,G.jsx)(`button`,{className:`btn primary`,onClick:()=>m(!0),children:c.severity===`critical`?`Approve destructive action`:`Approve once`})]})]})}function oc({approvals:e,onResolve:t}){return e.length===0?null:(0,G.jsx)(`div`,{className:`approval-stack`,children:e.map(e=>(0,G.jsx)(ac,{approval:e,onResolve:t},e.id))})}var sc=8e3;function cc({request:e,onAnswer:t,onCancel:n}){let[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(!1),s=(0,W.useRef)(null),c=(0,W.useRef)(null);(0,W.useEffect)(()=>()=>{s.current&&clearTimeout(s.current)},[]);let l=()=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>o(!0),sc)},[u,d]=(0,W.useState)({}),[f,p]=(0,W.useState)(()=>Object.fromEntries(e.questions.map((e,t)=>[t,e.options.length===0]))),[m,h]=(0,W.useState)({}),g=(e,t,n)=>{d(r=>{let i=r[e]||[];if(!n)return{...r,[e]:i[0]===t?[]:[t]};let a=i.includes(t);return{...r,[e]:a?i.filter(e=>e!==t):[...i,t]}}),n||p(t=>({...t,[e]:!1}))},_=(e,t)=>{p(n=>{let r=!n[e];return r&&!t&&d(t=>({...t,[e]:[]})),{...n,[e]:r}})},v=e=>(u[e]||[]).length>0||!!f[e]&&(m[e]||``).trim().length>0,y=e.questions.every((e,t)=>v(t)),b=()=>{let t={};return e.questions.forEach((e,n)=>{let r=[...u[n]||[]];if(f[n]){let e=(m[n]||``).trim();e&&r.push(e)}t[e.question]=r.join(`, `)}),t};return(0,G.jsxs)(`div`,{id:`attention-${encodeURIComponent(e.id)}`,className:`card question-card`,"data-tone":`accent`,"data-attention-card":!0,tabIndex:-1,children:[e.questions.map((e,t)=>{let n=u[t]||[];return(0,G.jsxs)(`div`,{className:`question-item`,children:[(0,G.jsx)(`div`,{className:`question-head`,children:(0,G.jsx)(Te,{tone:`accent`,variant:`soft`,upper:!0,children:e.header})}),(0,G.jsx)(`div`,{className:`question-text`,children:e.question}),(0,G.jsxs)(`div`,{className:`question-options`,children:[e.options.map(i=>(0,G.jsxs)(`button`,{type:`button`,className:`question-option${n.includes(i.label)?` selected`:``}`,onClick:()=>g(t,i.label,e.multiSelect),disabled:r,title:i.description,children:[(0,G.jsx)(`span`,{className:`question-option-label`,children:i.label}),i.description&&(0,G.jsx)(`span`,{className:`question-option-desc`,children:i.description})]},i.label)),e.options.length>0&&(0,G.jsxs)(`button`,{type:`button`,className:`question-option${f[t]?` selected`:``}`,onClick:()=>_(t,e.multiSelect),disabled:r,children:[(0,G.jsx)(`span`,{className:`question-option-label`,children:`Other`}),(0,G.jsx)(`span`,{className:`question-option-desc`,children:`Write your own answer`})]}),f[t]&&(0,G.jsx)(`textarea`,{className:`field question-other-input`,value:m[t]||``,onChange:e=>h(n=>({...n,[t]:e.target.value})),placeholder:`Type your answer…`,"aria-label":e.question,rows:2,autoFocus:e.options.length>0,disabled:r})]})]},t)}),r?(0,G.jsxs)(`div`,{className:`approval-waiting`,children:[`Sending your answer…`,a&&(0,G.jsxs)(`div`,{className:`approval-stalled`,children:[(0,G.jsx)(`span`,{children:`This is taking longer than expected.`}),(0,G.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:()=>{o(!1),c.current===`skip`?n(e.id,e.sessionId):t(e.id,e.sessionId,b()),l()},children:`Retry`})]})]}):(0,G.jsxs)(`div`,{className:`approval-actions`,children:[(0,G.jsx)(`button`,{className:`btn danger-ghost`,onClick:()=>{c.current=`skip`,i(!0),o(!1),n(e.id,e.sessionId),l()},children:`Skip`}),(0,G.jsxs)(`button`,{className:`btn primary`,onClick:()=>{c.current=`answer`,i(!0),o(!1),t(e.id,e.sessionId,b()),l()},disabled:!y,children:[`Send answer`,e.questions.length>1?`s`:``]})]})]})}function lc({questions:e,onAnswer:t,onCancel:n}){return e.length===0?null:(0,G.jsx)(`div`,{className:`approval-stack`,children:e.map(e=>(0,G.jsx)(cc,{request:e,onAnswer:t,onCancel:n},e.id))})}function uc({attention:e,onResolve:t}){let[n,r]=(0,W.useState)(null),i=n=>{r(n),t(e.sessionId,n)};return(0,G.jsxs)(`div`,{id:`attention-${encodeURIComponent(e.sessionId)}`,className:`card question-card turn-attention-card`,"data-tone":`warn`,"data-attention-card":!0,tabIndex:-1,role:`alert`,children:[(0,G.jsxs)(`div`,{className:`question-item`,children:[(0,G.jsx)(`div`,{className:`question-head`,children:(0,G.jsx)(Te,{tone:`warn`,variant:`soft`,upper:!0,children:`Turn may be stuck`})}),(0,G.jsx)(`div`,{className:`question-text`,children:e.message}),(0,G.jsx)(`div`,{className:`question-option-desc`,children:`Bivy has not stopped the agent. The normal turn time limit is still active.`})]}),(0,G.jsxs)(`div`,{className:`approval-actions`,children:[(0,G.jsx)(`button`,{className:`btn danger-ghost`,onClick:()=>i(`stop`),disabled:n!==null,children:n===`stop`?`Stopping…`:`Stop turn`}),(0,G.jsx)(`button`,{className:`btn primary`,onClick:()=>i(`continue`),disabled:n!==null,children:n===`continue`?`Continuing…`:`Keep waiting`})]})]})}var dc=`false`,fc=`false`,pc=dc===`true`,mc=fc===`true`;function hc(e={}){let{immediate:t=!1,onNeedReload:n,onNeedRefresh:r,onOfflineReady:i,onRegistered:a,onRegisteredSW:o,onRegisterError:s}=e,c,l,u,d=async(e=!0)=>{await l,pc||u?.()};async function f(){if(`serviceWorker`in navigator){if(c=await C(async()=>{let{Workbox:e}=await import(`./workbox-window.prod.es5-Bd17z0YL.js`);return{Workbox:e}},[]).then(({Workbox:e})=>new e(`/sw.js`,{scope:`/`,type:`classic`})).catch(e=>{s?.(e)}),!c)return;if(u=()=>{c?.messageSkipWaiting()},!mc){if(pc)c.addEventListener(`activated`,e=>{(e.isUpdate||e.isExternal)&&(n?n():window.location.reload())}),c.addEventListener(`installed`,e=>{e.isUpdate||i?.()});else{let e=!1,t=()=>{e=!0,c?.addEventListener(`controlling`,e=>{e.isUpdate&&(n?n():window.location.reload())}),r?.()};c.addEventListener(`installed`,n=>{n.isUpdate===void 0?n.isExternal===void 0?!e&&i?.():n.isExternal?t():!e&&i?.():n.isUpdate||i?.()}),c.addEventListener(`waiting`,t)}}c.register({immediate:t}).then(e=>{o?o(`/sw.js`,e):a?.(e)}).catch(e=>{s?.(e)})}}return l=f(),d}async function gc(e,t=15e3){let n=e?.waiting;n&&n.state!==`activated`&&await new Promise((e,r)=>{let i=t=>{clearTimeout(o),n.removeEventListener(`statechange`,a),t?r(t):e()},a=()=>{n.state===`activated`?i():n.state===`redundant`&&i(Error(`The update was replaced. Please try Reload again.`))},o=setTimeout(()=>i(Error(`The update did not activate. Please try Reload again.`)),t);n.addEventListener(`statechange`,a);try{n.postMessage({type:`SKIP_WAITING`}),a()}catch(e){i(e instanceof Error?e:Error(String(e)))}})}var _c=new Set,vc=!1;function yc(){n||hc({immediate:!0,onNeedReload(){},onNeedRefresh(){vc=!0,F(!0);for(let e of _c)e(!0)}})}function bc(e){return _c.add(e),vc&&e(!0),()=>_c.delete(e)}async function xc(){if(n||!Ce())return!1;let e=await navigator.serviceWorker?.getRegistration();return!Ce()||(await gc(e),!Ce())?!1:(window.location.reload(),!0)}function Sc({tone:e,className:t=``,children:n,...r}){return(0,G.jsx)(`div`,{className:`toast${t?` ${t}`:``}`,"data-tone":e,...r,children:n})}function Cc({tone:e,children:t}){return(0,G.jsx)(`span`,{className:`status-icon`,"data-tone":e,"aria-hidden":!0,children:t})}function wc(){let[e,t]=(0,W.useState)(!1),[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(null),o=(0,W.useSyncExternalStore)(Re,Oe);if((0,W.useEffect)(()=>bc(t),[]),!e)return null;let s=P(o);return(0,G.jsxs)(Sc,{tone:`accent`,className:`update-toast`,role:`status`,children:[(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`strong`,{children:`A Bivy update is ready.`}),` `,s.length?`Reload is available after ${s.join(`, `)}.`:`Draft text and attachment names are stored in this browser; cached transcripts remain when browser storage is available. File contents must be re-selected.`]}),i&&(0,G.jsx)(`span`,{role:`alert`,children:i}),(0,G.jsxs)(`div`,{className:`update-toast-actions`,children:[(0,G.jsx)(`button`,{className:`btn ghost`,onClick:()=>t(!1),disabled:n,children:`Later`}),(0,G.jsx)(`button`,{className:`btn primary`,onClick:async()=>{if(!n){r(!0),a(null);try{await xc()}catch(e){a(e instanceof Error?e.message:`Update failed. Please try Reload again.`)}finally{r(!1)}}},disabled:n||s.length>0,"aria-disabled":n||s.length>0,children:n?`Updating…`:`Reload`})]})]})}function Tc({setupRequired:e,passwordConfigured:t}){let[n,r]=(0,W.useState)(e&&!t),[i,a]=(0,W.useState)(``),[o,s]=(0,W.useState)(``),[c,l]=(0,W.useState)(``),[u,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(``);async function m(e){if(e.preventDefault(),!u){if(p(``),n&&o!==c){p(`Passwords do not match.`);return}d(!0);try{let e=await fetch(`/auth/owner/${n?`setup`:`login`}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({password:o,...n?{setupToken:i}:{}}),signal:AbortSignal.timeout(2e4)}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||`Could not sign in. Please try again.`);if(typeof t.token!=`string`||!t.token)throw Error(`The server did not return a sign-in token.`);typeof t.relayUrl==`string`&&(R.local.relay=t.relayUrl),a(``),s(``),l(``),await R.completeSignIn(t.token)}catch(e){p(e instanceof Error?e.message:`Could not reach your server. Try again.`)}finally{d(!1)}}}return(0,G.jsxs)(`section`,{"aria-labelledby":`owner-sign-in-heading`,children:[(0,G.jsx)(`h2`,{id:`owner-sign-in-heading`,children:n?`Set up owner access`:`Owner sign-in`}),n&&(0,G.jsx)(`p`,{className:`muted`,children:`Choose a password to sign in without an email provider.`}),(0,G.jsxs)(`form`,{className:`setup-email`,onSubmit:m,"aria-busy":u,children:[n&&(0,G.jsxs)(`div`,{className:`settings-field`,children:[(0,G.jsx)(`label`,{className:`field-label`,htmlFor:`owner-secret`,children:`Setup secret`}),(0,G.jsx)(`input`,{id:`owner-secret`,className:`field`,type:`password`,autoComplete:`off`,value:i,onChange:e=>a(e.target.value),required:!0,maxLength:256,disabled:u,"aria-describedby":`owner-secret-help`}),(0,G.jsx)(`span`,{className:`muted`,id:`owner-secret-help`,children:`SELF_HOST_SETUP_TOKEN from your deployment settings. Keep it private.`})]}),(0,G.jsxs)(`div`,{className:`settings-field`,children:[(0,G.jsx)(`label`,{className:`field-label`,htmlFor:`owner-password`,children:n?`New password`:`Password`}),(0,G.jsx)(`input`,{id:`owner-password`,className:`field`,type:`password`,autoComplete:n?`new-password`:`current-password`,value:o,onChange:e=>s(e.target.value),minLength:12,maxLength:256,required:!0,disabled:u,"aria-describedby":n?`owner-password-help`:void 0}),n&&(0,G.jsx)(`span`,{className:`muted`,id:`owner-password-help`,children:`At least 12 characters. Save it in your password manager.`})]}),n&&(0,G.jsxs)(`div`,{className:`settings-field`,children:[(0,G.jsx)(`label`,{className:`field-label`,htmlFor:`owner-confirmation`,children:`Confirm password`}),(0,G.jsx)(`input`,{id:`owner-confirmation`,className:`field`,type:`password`,autoComplete:`new-password`,value:c,onChange:e=>l(e.target.value),required:!0,maxLength:256,disabled:u})]}),f&&(0,G.jsx)(`p`,{className:`setup-error`,role:`alert`,children:f}),f&&n&&(0,G.jsx)(`button`,{type:`button`,className:`btn link`,onClick:()=>location.reload(),children:`Reload sign-in options`}),(0,G.jsx)(`button`,{className:`btn primary block`,type:`submit`,disabled:u||!o||n&&(!i||!c),children:u?`Signing in…`:n?`Save password and continue`:`Sign in as owner`})]}),t&&(0,G.jsxs)(`details`,{className:`setup-note muted`,children:[(0,G.jsx)(`summary`,{className:`btn link`,children:`Forgot your password?`}),(0,G.jsx)(`p`,{className:`muted`,children:`Generate a new random SELF_HOST_SETUP_TOKEN in your deployment settings, redeploy, then reload this page. Old setup secrets cannot be reused. Resetting revokes existing account sign-ins.`}),e&&(0,G.jsx)(`button`,{type:`button`,className:`btn link`,disabled:u,onClick:()=>{r(!n),p(``),s(``),l(``),a(``)},children:n?`Back to password sign-in`:`Reset owner password`})]})]})}function Ec({className:e}){return(0,G.jsxs)(`svg`,{className:e,viewBox:`0 0 32 32`,fill:`none`,"aria-hidden":`true`,focusable:`false`,children:[(0,G.jsx)(`path`,{d:`M23.5 4 L24.45 7.05 L27.5 8 L24.45 8.95 L23.5 12 L22.55 8.95 L19.5 8 L22.55 7.05 Z`,fill:`var(--accent)`}),(0,G.jsx)(`path`,{d:`M28 11.4 L28.35 12.55 L29.5 12.9 L28.35 13.25 L28 14.4 L27.65 13.25 L26.5 12.9 L27.65 12.55 Z`,fill:`var(--accent)`,opacity:`.8`}),(0,G.jsx)(`path`,{d:`M3 25.5 L11.5 11 L16.5 19.5 L20 14 L29 25.5`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`,strokeLinecap:`round`}),(0,G.jsx)(`path`,{d:`M3 25.5 H29`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,opacity:`.35`})]})}function Dc({onDismiss:e}={}){let t=u(),[r,i]=(0,W.useState)(null),[a,c]=(0,W.useState)(``),[l,d]=(0,W.useState)(0);(0,W.useEffect)(()=>{let e=new AbortController,n=setTimeout(()=>e.abort(),1e4),r=!0;return c(``),fetch(`${t}/auth/owner/status`,{signal:e.signal}).then(async e=>{if(e.status===404||e.ok&&!e.headers.get(`content-type`)?.includes(`application/json`))return{enabled:!1,passwordConfigured:!1,setupRequired:!1,github:!0,email:!0};if(!e.ok)throw Error(`Could not load sign-in options.`);let t=await e.json();if(typeof t.enabled!=`boolean`||typeof t.github!=`boolean`||typeof t.email!=`boolean`)throw Error(`Invalid sign-in configuration from server.`);return t}).then(e=>{r&&i(T(e))}).catch(()=>{r&&c(`Could not reach your server. Check the connection and try again.`)}).finally(()=>clearTimeout(n)),()=>{r=!1,e.abort(),clearTimeout(n)}},[t,l]);let f=s.signInFlow===`device`||n||xe(),[p,m]=(0,W.useState)(``),[h,g]=(0,W.useState)(null),[_,v]=(0,W.useState)(!1),[y,b]=(0,W.useState)(null),[x,S]=(0,W.useState)(!1),[C,w]=(0,W.useState)(null),[E,D]=(0,W.useState)(null);(0,W.useEffect)(()=>{let e=``;try{let t=new URLSearchParams(location.search);if(e=(t.get(`authError`)||``).trim(),e){t.delete(`authError`);let e=t.toString();history.replaceState(null,``,location.pathname+(e?`?${e}`:``)+location.hash)}}catch{}e&&D({"github-email":`GitHub didn't share a verified email, so we couldn't sign you in. Add and verify an email on your GitHub account, or use email sign-in below.`,"github-config":`Couldn't complete GitHub sign-in due to a server issue. Please try again in a moment.`,expired:`That sign-in request was invalid or expired. Please try again.`}[e]||`Sign-in failed. Please try again.`)},[]);let[O,k]=(0,W.useState)(null),[A,ee]=(0,W.useState)(!1),j=(0,W.useRef)(!1),[M,te]=(0,W.useState)(!1),ne=(0,W.useRef)(null);(0,W.useEffect)(()=>()=>{j.current=!0,ne.current&&(ne.current.cancelled=!0)},[]);function re(){j.current=!0,S(!1),w(null),k(null)}function ie(){ne.current&&(ne.current.cancelled=!0),ne.current=null,te(!1),g(null),b(null)}async function N(e,t){let n=Date.now()+e.expiresInMs;try{for(;!t.cancelled&&Date.now()<n;){if(await new Promise(t=>setTimeout(t,e.intervalMs)),t.cancelled)return;if(Date.now()>=n)break;let r;try{r=await De(R.local,e.deviceId,e.deviceSecret)}catch{continue}if(t.cancelled)return;if(r.status===`complete`){await R.completeSignIn(r.token,()=>!t.cancelled);return}if(r.status===`expired`||r.status===`error`)throw Error(r.error||`That sign-in link expired. Please request a new one.`)}if(!t.cancelled)throw Error(`Sign-in timed out. Please request a new link.`)}catch(e){t.cancelled||(D(e instanceof Error?e.message:`Sign-in failed.`),te(!1))}finally{ne.current===t&&(ne.current=null)}}async function P(e){if(e&&!_){D(null),v(!0),g({text:`Sending…`});try{if(f){ne.current&&(ne.current.cancelled=!0);let t={cancelled:!1};ne.current=t;let n=await ve(R.local,e);if(t.cancelled)return;n.devLink?g({text:`Dev link:`,href:n.devLink}):g({text:`Check your email — we sent a sign-in link to ${e}. Open it on this device and you'll be signed in here automatically.`}),b(e),te(!0),N(n,t);return}let n=await fetch(`${t}/auth/magic-link/start`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({email:e})}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r?.error||`Could not send sign-in link.`);r?.devLink?g({text:`Dev link:`,href:r.devLink}):g({text:`Check your email — we sent a sign-in link to ${e}.`}),b(e)}catch(e){g({text:e instanceof Error?e.message:`Could not send sign-in link.`}),b(null),te(!1)}finally{v(!1)}}}function ae(e){e.preventDefault(),P(p.trim())}async function oe(){if(x)return;w(null),D(null),S(!0),k(null),j.current=!1;let e=n?null:window.open(``,`_blank`);try{let t=await ke(R.local);if(j.current)return;k(t.authorizeUrl),n?await o(t.authorizeUrl):e?e.location.href=t.authorizeUrl:window.open(t.authorizeUrl,`_blank`,`noopener`);let r=Date.now()+t.expiresInMs;for(;!j.current&&Date.now()<r;){if(await new Promise(e=>setTimeout(e,t.intervalMs)),j.current)return;let n=await De(R.local,t.deviceId,t.deviceSecret);if(n.status===`complete`){try{e?.close()}catch{}await R.completeSignIn(n.token,()=>!j.current);return}if(n.status===`expired`||n.status===`error`)throw Error(n.error||`Sign-in expired. Please try again.`)}if(!j.current)throw Error(`Sign-in timed out. Please try again.`)}catch(t){try{e?.close()}catch{}j.current||w(t instanceof Error?t.message:`GitHub sign-in failed.`)}finally{j.current||(S(!1),k(null))}}return(0,G.jsx)(`div`,{className:`setup`,children:(0,G.jsxs)(`div`,{className:`card setup-card`,children:[e&&(0,G.jsx)(`button`,{type:`button`,className:`btn link setup-back`,onClick:e,children:`‹ Back`}),(0,G.jsx)(Ec,{className:`setup-logo`}),(0,G.jsx)(`h1`,{children:`Bivy`}),(0,G.jsx)(`p`,{children:s.signInDescription??(r?.enabled?`Your self-hosted Bivy workspace.`:`Run Claude Code, Codex, or another coding agent on a Machine you control — then continue it from your browser or phone.`)}),!r&&!a&&(0,G.jsx)(`p`,{className:`muted`,role:`status`,children:`Loading sign-in options…`}),a&&(0,G.jsxs)(`div`,{className:`setup-error`,role:`alert`,children:[(0,G.jsx)(`p`,{children:a}),(0,G.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>d(e=>e+1),children:`Retry`})]}),r?.enabled&&(0,G.jsx)(Tc,{setupRequired:r.setupRequired,passwordConfigured:r.passwordConfigured}),r&&!r.enabled&&!r.github&&!r.email&&(0,G.jsx)(`p`,{className:`muted`,children:s.unavailableSignInMessage??`No browser sign-in method is configured. Use your private server-shell sign-in link, or configure SELF_HOST_SETUP_TOKEN in your deployment settings.`}),E&&(0,G.jsx)(`div`,{className:`setup-error`,role:`alert`,children:E}),r?.github&&(0,G.jsxs)(G.Fragment,{children:[r.enabled&&(0,G.jsx)(`div`,{className:`setup-or`,children:`or`}),f?(0,G.jsx)(`button`,{type:`button`,className:`btn primary block`,onClick:oe,disabled:x,children:x?`Waiting for GitHub…`:`Continue with GitHub`}):(0,G.jsx)(`a`,{className:`btn primary block`,href:`${t}/auth/github/start?return=${encodeURIComponent(location.pathname)}`,onClick:()=>{D(null),ee(!0)},children:A?`Redirecting…`:`Continue with GitHub`}),x&&(0,G.jsxs)(`div`,{className:`setup-note muted`,children:[(0,G.jsx)(`p`,{children:`Finish signing in on the GitHub tab, then return here — this completes automatically.`}),O&&(0,G.jsxs)(`p`,{children:[`Tab didn't open?`,` `,(0,G.jsx)(`a`,{href:O,target:`_blank`,rel:`noopener`,children:`Open GitHub sign-in`})]}),(0,G.jsx)(`button`,{type:`button`,className:`btn link`,onClick:re,children:`Cancel`})]}),C&&(0,G.jsx)(`p`,{className:`setup-note muted`,children:C})]}),r?.email&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`setup-or`,children:r.enabled||r.github?`or with email`:`Sign in with email`}),(0,G.jsxs)(`form`,{className:`setup-email`,onSubmit:ae,children:[(0,G.jsx)(`input`,{className:`field`,type:`email`,inputMode:`email`,autoComplete:`email`,placeholder:`you@example.com`,"aria-label":`Email address`,value:p,onChange:e=>m(e.target.value),required:!0}),(0,G.jsx)(`button`,{className:!r?.enabled&&!r?.github?`btn primary`:`btn`,type:`submit`,disabled:_||M||!p.trim(),children:M?`Waiting for link…`:`Continue with email`})]}),h&&(0,G.jsxs)(`p`,{className:`setup-note muted`,children:[h.text,` `,h.href&&(0,G.jsx)(`a`,{href:h.href,onClick:n?e=>{e.preventDefault(),o(h.href).catch(()=>D(`Could not open the sign-in link.`))}:void 0,children:h.href})]}),M&&(0,G.jsxs)(`p`,{className:`setup-note muted`,children:[`Keep this window open — signing you in automatically once you tap the link.`,` `,(0,G.jsx)(`button`,{type:`button`,className:`btn link`,onClick:ie,children:`Cancel`})]}),y&&!_&&(0,G.jsxs)(`p`,{className:`setup-note muted`,children:[`Didn't get it? Check your spam folder, or`,` `,(0,G.jsx)(`button`,{type:`button`,className:`btn link`,onClick:()=>void P(y),children:`resend the link`}),`. You can also edit the address above and send again.`]})]}),r&&!r.enabled&&(r.github||r.email)&&(0,G.jsxs)(`p`,{className:`setup-foot muted`,children:[`By continuing, you agree to the `,(0,G.jsx)(`a`,{href:`https://bivy.sh/terms.html`,children:`Terms`}),` and acknowledge the`,` `,(0,G.jsx)(`a`,{href:`https://bivy.sh/privacy.html`,children:`Privacy Policy`}),`.`]})]})})}function Oc(){let{connection:{nodes:e,currentNodeId:t,status:n},activeSession:{activeSessionId:r},sessionIndex:{sessions:i},draft:a}=Me(),o=k,[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)([]),[d,f]=(0,W.useState)([]),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(!1),_=(0,W.useRef)(null);rt(()=>c(!1),s);let v=n===`reconnecting`||n===`connecting`;(0,W.useEffect)(()=>{if(!s)return;o&&(R.listEphemeralConfigs().then(u).catch(()=>{}),R.listHostedMachines().then(f).catch(()=>{}));let e=e=>{_.current&&!_.current.contains(e.target)&&c(!1)};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)},[s,o]);let y=i.find(e=>e.sessionId===r),b=y?.nodeId||t,x=e.find(e=>e.id===b),S=y?.pendingLaunch?y.pendingNodeName:void 0,C=o&&!r?a.ephemeralConfig:null,w=x?.name?.replace(/^Hosted\s+/i,``)||b||`Machine`,T=C?C.name:S||w,E=C?`offline`:me(x??(b?{id:b}:void 0)),D=e.filter(e=>!e.id.startsWith(`eph-`)),O=(0,W.useMemo)(()=>Ae(l,d,e),[l,d,e]),A=e=>C?e.config.id===C.id:!!e.nodeId&&e.nodeId===t,ee=e=>{c(!1),en(`cloud`),e.nodeId?R.switchNode(e.nodeId):R.pickDraftEphemeralRunner(e.config)},j=!!r;return(0,G.jsxs)(`div`,{className:`node-switcher`,ref:_,children:[(0,G.jsxs)(`button`,{className:`node-switcher-btn${j?` locked`:``}`,onClick:t=>{t.stopPropagation(),!j&&(e.length===0&&R.refreshNodes(),c(e=>!e))},"aria-haspopup":j?void 0:`menu`,"aria-expanded":j?void 0:s,"aria-label":j?`Runs on ${T}`:void 0,children:[v?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(V,{size:`xs`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Reconnecting — `})]}):(0,G.jsx)(qt,{status:E===`online`?`online`:`idle`,label:`${Ee[E].label} — `}),(0,G.jsx)(`span`,{className:`node-switcher-name`,children:T}),!j&&(0,G.jsx)(`span`,{className:`node-switcher-caret`,children:`▾`})]}),s&&!j&&(0,G.jsxs)(`div`,{className:`menu node-menu`,role:`menu`,children:[v&&(0,G.jsxs)(`div`,{className:`node-menu-status`,role:`status`,children:[(0,G.jsx)(V,{size:`xs`}),`Reconnecting…`]}),(0,G.jsx)(`div`,{className:`node-menu-head`,children:`Your machines`}),D.length===0&&(0,G.jsx)(`div`,{className:`node-menu-empty`,children:`No other machines`}),D.map(e=>(0,G.jsx)(`div`,{className:`node-menu-row`,children:(0,G.jsxs)(`button`,{className:`menu-item node-menu-item${e.id===t?` active`:``}`,role:`menuitem`,onClick:()=>{c(!1),R.switchNode(e.id)},children:[(0,G.jsx)(qt,{status:e.online?`online`:`idle`,label:`${e.online?`Online`:`Offline`} — `}),(0,G.jsx)(`span`,{className:`node-menu-name`,children:e.name||e.id}),e.id===t&&(0,G.jsx)(`span`,{className:`node-menu-check`,children:`✓`})]})},e.id)),o&&O.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`node-menu-head`,children:`Cloud`}),O.map(e=>{let t=A(e);return(0,G.jsxs)(`button`,{className:`menu-item node-menu-item${t?` active`:``}`,role:`menuitem`,onClick:()=>ee(e),children:[(0,G.jsx)(qt,{status:e.online?`online`:`idle`,label:e.online?`Online — `:e.asleep?`Asleep — `:`Not running — `}),(0,G.jsx)(`span`,{className:`node-menu-name`,children:e.label}),!e.online&&(0,G.jsx)(`span`,{className:`node-menu-meta`,children:e.asleep?`asleep · ${Ee.asleep.hint}`:`starts when you send`}),t&&(0,G.jsx)(`span`,{className:`node-menu-check`,children:`✓`})]},e.key)})]}),(0,G.jsx)(`div`,{className:`node-menu-sep`}),(0,G.jsxs)(`button`,{className:`menu-item node-menu-item`,role:`menuitem`,onClick:()=>{c(!1),m(!0)},children:[(0,G.jsx)(`span`,{className:`node-menu-glyph`,children:`+`}),(0,G.jsx)(`span`,{className:`node-menu-name`,children:`Add a Machine…`})]}),(0,G.jsx)(`div`,{className:`node-menu-sep`}),(0,G.jsx)(`button`,{className:`menu-item node-menu-item danger`,role:`menuitem`,onClick:()=>{c(!1),g(!0)},children:`Sign out`})]}),h&&(0,G.jsx)(Ye,{title:`Sign out?`,message:`Sign out of Bivy on this device?`,confirmLabel:`Sign out`,danger:!0,onCancel:()=>g(!1),onConfirm:()=>{g(!1),R.signOut()}}),p&&(0,G.jsx)(hr,{onClose:()=>m(!1)})]})}function kc(){let{connection:{status:e}}=Me(),[t,n]=(0,W.useState)(!1),[r,i]=(0,W.useState)(null),a=(0,W.useRef)(null);rt(()=>n(!1),t),(0,W.useEffect)(()=>{e===`online`&&R.listTailnetMachines().then(i).catch(()=>i([]))},[e,t]),(0,W.useEffect)(()=>{if(!t)return;let e=e=>{a.current&&!a.current.contains(e.target)&&n(!1)};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)},[t]);let o=r?.find(e=>e.self),s=r?.filter(e=>!e.self)??[],c=e===`online`;return(0,G.jsxs)(`div`,{className:`node-switcher`,ref:a,children:[(0,G.jsxs)(`button`,{className:`node-switcher-btn`,"aria-haspopup":`menu`,"aria-expanded":t,onClick:e=>{e.stopPropagation(),n(e=>!e)},children:[(0,G.jsx)(qt,{status:c?`online`:`idle`,label:`${c?`Online`:`Offline`} — `}),(0,G.jsx)(`span`,{className:`node-switcher-name`,children:o?.name||location.hostname.split(`.`)[0]}),(0,G.jsx)(`span`,{className:`node-switcher-caret`,children:`▾`})]}),t&&(0,G.jsxs)(`div`,{className:`menu node-menu`,role:`menu`,children:[(0,G.jsx)(`div`,{className:`node-menu-head`,children:`Your machines`}),r===null&&(0,G.jsxs)(`div`,{className:`node-menu-status`,role:`status`,children:[(0,G.jsx)(V,{size:`xs`}),`Looking…`]}),o&&(0,G.jsx)(`div`,{className:`node-menu-row`,children:(0,G.jsxs)(`span`,{className:`menu-item node-menu-item active`,role:`menuitem`,"aria-current":`true`,children:[(0,G.jsx)(qt,{status:`online`,label:`Online — `}),(0,G.jsx)(`span`,{className:`node-menu-name`,children:o.name}),(0,G.jsx)(`span`,{className:`node-menu-check`,children:`✓`})]})}),s.map(e=>(0,G.jsx)(`div`,{className:`node-menu-row`,children:(0,G.jsxs)(`a`,{className:`menu-item node-menu-item`,role:`menuitem`,href:e.url,children:[(0,G.jsx)(qt,{status:`online`,label:`Online — `}),(0,G.jsx)(`span`,{className:`node-menu-name`,children:e.name})]})},e.url)),r!==null&&s.length===0&&(0,G.jsxs)(`div`,{className:`node-menu-empty`,children:[`No other machines yet. Run `,(0,G.jsx)(`code`,{children:`bivy tailscale`}),` on another machine and it shows up here.`]})]})]})}var Ac=new Set;function jc(){for(let e of Ac)e()}function Mc(e){return e.kind===`library`?e.view:null}var Nc=Mc(j());typeof window<`u`&&window.addEventListener(`popstate`,()=>{Nc=Mc(j()),jc()});function Pc(e){return Ac.add(e),()=>Ac.delete(e)}function Fc(){return Nc}function Ic(e){oe({kind:`library`,view:e},{replace:Nc!==null}),Nc=e,jc()}function Lc(e){oe(e,{replace:!0}),Nc=null,jc()}var Rc=new Set;function zc(){for(let e of Rc)e()}function Bc(e){return e.kind===`run`?{runId:e.id}:null}var Vc=Bc(j());typeof window<`u`&&window.addEventListener(`popstate`,()=>{Vc=Bc(j()),zc()});function Hc(e){return Rc.add(e),()=>Rc.delete(e)}function Uc(){return Vc}function Wc(e){oe({kind:`run`,id:e}),Vc={runId:e},zc()}function Gc(e){oe(e,{replace:!0}),Vc=null,zc()}var Kc={autonomous:`Autonomous`,risky:`Ask before risky actions`,always:`Ask before every action`,never:`Never ask`},qc={"read-only":`Read only`,"workspace-write":`Workspace write`,"danger-full-access":`Full access`},Jc={queued:`Queued`,running:`Running`,waiting:`Waiting`,needs_attention:`Needs attention`,finished:`Finished`},Yc={queued:`idle`,running:`working`,waiting:`idle`,needs_attention:`needs-action`,finished:`idle`};function Xc(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString([],{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}function Zc(e){if(!e)return``;let t=(e.inputTokens??0)+(e.outputTokens??0);return[t?`${t.toLocaleString()} tokens`:``,typeof e.costUsd==`number`?`$${e.costUsd.toFixed(4)}`:``].filter(Boolean).join(` · `)}function Qc(e){if(typeof e!=`number`||e<0)return``;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return n<60?`${n}m ${r}s`:`${Math.floor(n/60)}h ${n%60}m`}function $c({k:e,children:t}){return t==null||t===!1||t===``?null:(0,G.jsxs)(`div`,{className:`run-sheet-row`,children:[(0,G.jsx)(`span`,{className:`k`,children:e}),(0,G.jsx)(`span`,{className:`v`,children:t})]})}function el(e){return!!(e.branch||e.commit||e.pullRequest||e.checkpoint||e.artifact)}function tl({runId:e,load:t,onCancel:n,onRetry:r,onClose:i,onOpenSession:a,onReauthenticate:o,resolveMachineName:s,isSessionResolvable:c,onReceiptReviewed:l}){let[u,d]=(0,W.useState)(`loading`),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)(!1),[g,_]=(0,W.useState)(null),[v,y]=(0,W.useState)(``),[b,x]=(0,W.useState)(!1),S=(0,W.useRef)(!1),C=(0,W.useRef)({value:0}),w=(0,W.useRef)(t);w.current=t;let T=(0,W.useCallback)(async(t={})=>{let n=++C.current.value;try{let r=await w.current(e);if(n!==C.current.value)return;if(r===null){if(t.keepPrevious){h(!0);return}p(null),d(`not_found`);return}p(r),d(`ready`),h(!1)}catch(e){if(n!==C.current.value)return;if((e instanceof te?e.reason:`error`)===`unauthorized`){d(`unauthorized`);return}if(t.keepPrevious){h(!0);return}d(`offline`)}},[e]);(0,W.useEffect)(()=>{S.current=!1,d(`loading`),p(null),h(!1),T();let e=C.current;return()=>{e.value++}},[e,T]);let E=(0,W.useMemo)(()=>f?Fe(f,{resolveMachineName:s}):null,[f,s]),D=E?.lifecycle;(0,W.useEffect)(()=>{if(u!==`ready`||!D||D===`finished`||g)return;let e=!1,t,n=async()=>{await T({keepPrevious:!0}),e||(t=setTimeout(n,5e3))};return t=setTimeout(n,5e3),()=>{e=!0,clearTimeout(t)}},[u,D,g,T]),(0,W.useEffect)(()=>{u===`ready`&&E&&!S.current&&(S.current=!0,l?.())},[l,E,u]);let O=(0,W.useCallback)(async()=>{if(n){_(`cancel`),y(``);try{await n(e),await T({keepPrevious:!0})}catch(e){y(e instanceof Error?e.message:`Could not cancel this Run.`)}finally{_(null)}}},[n,e,T]),k=(0,W.useCallback)(async()=>{if(r){_(`retry`),y(``);try{await r(e),await T({keepPrevious:!0})}catch(e){y(e instanceof Error?e.message:`Could not retry this Run.`)}finally{_(null)}}},[r,e,T]),A=(0,W.useCallback)(async(e,t,n)=>{if(o){_(`reauthenticate`),y(``);try{await o(e,t,n)}catch(e){y(e instanceof Error?e.message:`Could not open model sign-in.`)}finally{_(null)}}},[o]);return(0,G.jsxs)(`div`,{className:`automations-view run-details`,role:`dialog`,"aria-modal":`true`,"aria-label":`Run details`,children:[(0,G.jsxs)(`header`,{className:`automations-view-head`,children:[(0,G.jsxs)(`div`,{className:`automations-view-head-text`,children:[(0,G.jsx)(`h1`,{className:`automations-view-heading`,children:`Run details`}),(0,G.jsx)(`p`,{className:`automations-view-sub`,children:`What this Run did, where it ran, and what remains unknown.`})]}),(0,G.jsx)(`div`,{className:`automations-view-head-actions`,children:(0,G.jsxs)(`button`,{type:`button`,className:`btn ghost icon run-details-close`,onClick:i,title:`Back`,"aria-label":`Close run details`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`‹`}),(0,G.jsx)(`span`,{children:`Back`})]})})]}),(0,G.jsxs)(`div`,{className:`automations-view-body run-details-body`,children:[u===`loading`&&(0,G.jsx)(`div`,{className:`run-details-state`,role:`status`,children:`Loading this Run…`}),u===`offline`&&(0,G.jsxs)(`div`,{className:`banner`,"data-tone":`warn`,role:`alert`,children:[(0,G.jsxs)(`div`,{className:`banner-text`,children:[(0,G.jsx)(`strong`,{children:`Can't reach this Run right now`}),(0,G.jsx)(`span`,{children:`You appear to be offline. This Run is safe on the control plane; reconnect to see its current state.`})]}),(0,G.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>T(),children:`Retry`})]}),u===`unauthorized`&&(0,G.jsxs)(`div`,{className:`banner`,"data-tone":`warn`,role:`alert`,children:[(0,G.jsxs)(`div`,{className:`banner-text`,children:[(0,G.jsx)(`strong`,{children:`Sign in to view this Run`}),(0,G.jsx)(`span`,{children:`Your session isn't authorized. Sign in again to open this Run.`})]}),(0,G.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>window.location.assign(`/`),children:`Sign in`})]}),u===`not_found`&&(0,G.jsxs)(`div`,{className:`run-details-state`,role:`status`,children:[(0,G.jsx)(`strong`,{children:`Run not found`}),(0,G.jsx)(`p`,{children:`This Run doesn't exist or isn't available on your account.`})]}),u===`ready`&&E&&(0,G.jsx)(nl,{run:E,stale:m,busyAction:g,actionError:v,onCancel:n?()=>x(!0):void 0,onRetry:r?k:void 0,onRefresh:()=>T(),onOpenSession:a,onReauthenticate:o?A:void 0,isSessionResolvable:c})]}),b&&(0,G.jsx)(Ye,{title:`Cancel run?`,message:`The agent may take a moment to stop. This page will refresh from the durable run record.`,confirmLabel:`Cancel run`,danger:!0,onCancel:()=>x(!1),onConfirm:()=>{x(!1),O()}})]})}function nl({run:e,stale:t,busyAction:n,actionError:r,onCancel:a,onRetry:o,onRefresh:s,onOpenSession:c,onReauthenticate:l,isSessionResolvable:u}){let d=!!a&&e.actions.some(e=>e.kind===`cancel`),f=!!o&&e.actions.some(e=>e.kind===`retry`),p=e.actions.some(e=>e.kind===`inspect_checks`),m=e.actions.some(e=>e.kind===`review_session`),h=e.actions.find(e=>e.kind===`reauthenticate`&&e.provider),g=!!e.sessionId&&!!c&&(u?u(e.sessionId):!1),_=[e.requested.runtimeId,e.requested.model].filter(Boolean).join(` · `),v=e.timestamps.startedAt??e.timestamps.claimedAt,y=(0,W.useMemo)(()=>{try{return Rn(e,new Date().toISOString())}catch{return null}},[e]),b=(0,W.useRef)(null),x=(0,W.useCallback)(async()=>{l&&h?.provider&&await l(h.provider,e.machine?.id,e.failureSummary||`Authentication failed`)},[l,h,e.failureSummary,e.machine?.id]),S=(0,W.useCallback)(()=>{if(!y)return;let e=new Blob([`${zn(y)}\n`],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${y.receiptId}.json`,n.click(),URL.revokeObjectURL(t)},[y]);return(0,G.jsxs)(G.Fragment,{children:[t&&(0,G.jsxs)(`div`,{className:`banner`,"data-tone":`warn`,role:`status`,children:[(0,G.jsxs)(`div`,{className:`banner-text`,children:[(0,G.jsx)(`strong`,{children:`Showing the last known state`}),(0,G.jsx)(`span`,{children:`This Run couldn't be refreshed just now.`})]}),(0,G.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:s,children:`Refresh`})]}),(0,G.jsx)(`div`,{className:`run-details-title`,children:e.title}),(0,G.jsxs)(`div`,{className:`run-sheet-status`,role:`status`,children:[(0,G.jsx)(qt,{status:Yc[e.lifecycle]}),Jc[e.lifecycle],e.outcome.terminal&&(0,G.jsxs)(G.Fragment,{children:[` · `,(0,G.jsx)(Te,{tone:e.outcome.tone===`success`?`ok`:e.outcome.tone===`warning`?`warn`:e.outcome.tone===`danger`?`danger`:void 0,children:e.outcome.label})]}),e.attempt>1&&(0,G.jsxs)(`span`,{className:`run-details-attempt`,children:[` · attempt `,e.attempt]})]}),e.lifecycle===`needs_attention`&&(0,G.jsx)(`div`,{className:`banner`,"data-tone":`warn`,role:`status`,children:(0,G.jsxs)(`div`,{className:`banner-text`,children:[(0,G.jsx)(`strong`,{children:`Needs attention`}),(0,G.jsx)(`span`,{children:`This Run is waiting on a person before it can continue.`})]})}),e.failureSummary&&(0,G.jsx)(`div`,{className:`run-sheet-failure`,children:e.failureSummary}),(0,G.jsxs)(`div`,{className:`run-sheet-rows`,children:[(0,G.jsxs)($c,{k:`Source`,children:[e.source.kind,e.source.reference?` · ${e.source.reference}`:``]}),(0,G.jsx)($c,{k:`Started`,children:[Xc(v),Xc(e.timestamps.completedAt)?`→ ${Xc(e.timestamps.completedAt)}`:``].filter(Boolean).join(` `)}),(0,G.jsx)($c,{k:`Duration`,children:Qc(e.durationMs)}),(0,G.jsx)($c,{k:`Machine`,children:e.machine?e.machine.name||e.machine.id:`Not reported`}),(0,G.jsx)($c,{k:`Session`,children:e.sessionId?g?(0,G.jsx)(`button`,{type:`button`,className:`btn link`,onClick:()=>c(e.sessionId),children:`Open Session`}):(0,G.jsx)(`span`,{className:`run-details-muted`,children:`Correlated Session isn't available here`}):(0,G.jsx)(`span`,{className:`run-details-muted`,children:`Not correlated`})}),_&&(0,G.jsx)($c,{k:`Ran on`,children:_}),e.requested.approvalMode&&(0,G.jsx)($c,{k:`Approvals`,children:Kc[e.requested.approvalMode]??e.requested.approvalMode}),e.requested.sandbox&&(0,G.jsx)($c,{k:`Sandbox`,children:qc[e.requested.sandbox]??e.requested.sandbox}),(0,G.jsxs)($c,{k:`Attempt`,children:[e.attempt,e.maxAttempts?` of ${e.maxAttempts}`:``,e.attemptReason?` · ${e.attemptReason}`:``]}),(0,G.jsx)($c,{k:`Usage / cost`,children:Zc(e.usage)||`Not reported by the provider`}),(0,G.jsx)($c,{k:`Notification`,children:e.notification?`${e.notification.status.replace(`_`,` `)}${e.notification.channel?` · ${e.notification.channel}`:``}${e.notification.reason?` · ${e.notification.reason}`:``}`:`Not reported`}),(0,G.jsx)($c,{k:`Next action`,children:e.nextAction?.label??`No operator action available`})]}),e.timeline.length>0&&(0,G.jsxs)(`section`,{className:`run-timeline`,"aria-labelledby":`run-timeline-heading`,children:[(0,G.jsx)(`h2`,{id:`run-timeline-heading`,children:`Lifecycle`}),(0,G.jsx)(`ol`,{children:e.timeline.map((e,t)=>(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`run-timeline-dot`,"aria-hidden":!0}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:e.stage.replaceAll(`_`,` `)}),(0,G.jsxs)(`span`,{children:[Xc(e.at),e.attempt?` · attempt ${e.attempt}`:``]}),(0,G.jsx)(`p`,{children:e.reasonCode?i(e.summary):e.summary}),e.evidenceRef&&(0,G.jsx)(`code`,{children:e.evidenceRef})]})]},`${e.stage}-${e.at}-${t}`))})]}),e.checks.length>0&&(0,G.jsx)(`div`,{className:`run-sheet-checks`,ref:b,tabIndex:-1,children:e.checks.map((e,t)=>(0,G.jsxs)(Te,{tone:e.status===`passed`?`ok`:e.status===`failed`?`danger`:void 0,children:[e.name,` `,e.status===`passed`?`✓`:e.status===`failed`?`✗`:`–`]},`${e.name}-${t}`))}),el(e.references)&&(0,G.jsxs)(`div`,{className:`run-sheet-rows`,children:[e.references.pullRequest&&(0,G.jsx)($c,{k:`Pull request`,children:(0,G.jsx)(`a`,{href:e.references.pullRequest,target:`_blank`,rel:`noopener`,children:`Open pull request`})}),e.references.branch&&(0,G.jsx)($c,{k:`Branch`,children:(0,G.jsx)(`code`,{children:e.references.branch})}),e.references.commit&&(0,G.jsx)($c,{k:`Commit`,children:(0,G.jsx)(`code`,{children:e.references.commit.slice(0,12)})}),e.references.checkpoint&&(0,G.jsx)($c,{k:`Checkpoint`,children:(0,G.jsx)(`code`,{children:e.references.checkpoint})}),e.references.artifact&&(0,G.jsx)($c,{k:`Artifact`,children:(0,G.jsx)(`a`,{href:e.references.artifact,target:`_blank`,rel:`noopener`,children:`View artifact`})})]}),e.operationalReferences.length>0&&(0,G.jsx)(`div`,{className:`run-sheet-rows`,children:e.operationalReferences.map((e,t)=>(0,G.jsx)($c,{k:e.kind[0].toUpperCase()+e.kind.slice(1),children:e.url?(0,G.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener`,children:e.ref}):(0,G.jsx)(`code`,{children:e.ref})},`${e.kind}-${e.ref}-${t}`))}),y&&(0,G.jsxs)(`div`,{className:`run-sheet-rows run-details-receipt`,children:[(0,G.jsxs)(`div`,{className:`run-sheet-row`,children:[(0,G.jsx)(`span`,{className:`k`,children:`Receipt`}),(0,G.jsxs)(`span`,{className:`v`,children:[y.completeness===`complete`?`Complete`:`Partial · ${y.missingEvidence.length} evidence gap${y.missingEvidence.length===1?``:`s`}`,` `,(0,G.jsx)(`button`,{type:`button`,className:`btn link`,onClick:S,children:`Export JSON`})]})]}),y.observationLimitations.slice(0,3).map(e=>(0,G.jsxs)(`div`,{className:`run-sheet-row`,children:[(0,G.jsx)(`span`,{className:`k`,children:`Limitation`}),(0,G.jsx)(`span`,{className:`v run-details-muted`,children:e.message})]},e.code))]}),r&&(0,G.jsx)(`div`,{className:`run-sheet-failure`,role:`alert`,children:r}),(d||f||p||m&&g||h&&l)&&(0,G.jsxs)(`div`,{className:`run-sheet-recovery`,role:`group`,"aria-label":`Run actions`,children:[p&&(0,G.jsx)(`button`,{type:`button`,className:`btn sm primary recover-checks`,onClick:()=>{b.current?.scrollIntoView({behavior:`smooth`,block:`center`}),b.current?.focus()},children:`Review failed checks`}),h&&l&&(0,G.jsx)(`button`,{type:`button`,className:`btn sm primary recover-auth`,disabled:n!==null,onClick:()=>void x(),children:n===`reauthenticate`?`Connecting…`:h.label}),m&&g&&(0,G.jsx)(`button`,{type:`button`,className:`btn sm primary recover-review`,onClick:()=>c(e.sessionId),children:`Review Session`}),f&&(0,G.jsx)(`button`,{type:`button`,className:`btn sm primary recover-retry`,disabled:n!==null,onClick:o,children:n===`retry`?`Retrying…`:`Retry Run`}),d&&(0,G.jsx)(`button`,{type:`button`,className:`btn sm recover-cancel`,disabled:n!==null,onClick:a,children:n===`cancel`?`Cancelling…`:`Cancel Run`})]})]})}function rl(e){return JSON.stringify([String(e.provider),String(e.id)])}function il({sessionId:e,intent:t=`fork`,onClose:n}){let{connection:{nodes:r,currentNodeId:i},catalogs:{runtimes:a,models:o,currentModel:s},activeSession:{activeSessionId:c,activeRuntimeId:l},sessionIndex:{sessions:u}}=Me(),d=c===e&&l?l:u.find(t=>t.sessionId===e)?.runtimeId??null,[f,p]=(0,W.useState)(()=>{if(t!==`move`)return i??``;let e=r.filter(e=>e.id!==i);return(e.find(e=>e.online)??e[0])?.id??i??``}),[m,h]=(0,W.useState)(null),[g,_]=(0,W.useState)(d),[v,y]=(0,W.useState)(s),[b,x]=(0,W.useState)(!1),[S,C]=(0,W.useState)(!1),[w,T]=(0,W.useState)(`idle`);(0,W.useEffect)(()=>{g==null&&d&&_(d)},[g,d]),(0,W.useEffect)(()=>{v==null&&s&&y(s)},[v,s]),(0,W.useEffect)(()=>{R.listEphemeralConfigs().then(e=>h(e.find(e=>e.computeSource===`managed`)??null)).catch(()=>h(null))},[]);let E=f===`__managed__`,D=E||!!i&&f!==i,O=b?S:D,k=!g||g===d,[A,ee]=(0,W.useState)(null),[j,M]=(0,W.useState)(``);(0,W.useEffect)(()=>{if(M(``),k||!g||D)return;let e=!0;return R.modelsForRuntime(g).then(t=>{e&&ee({agentId:g,models:t.filter(e=>e.configured!==!1)})}),()=>{e=!1}},[g,k,D]);let te=!k&&A?.agentId===g?A.models:null,ne=te?.find(e=>rl(e)===j),re=(0,W.useMemo)(()=>D?a:a.filter(e=>e.id===d||String(e.status||`available`)===`available`),[D,a,d]),ie=(0,W.useMemo)(()=>{let e=[...r];return i&&!e.some(e=>e.id===i)&&e.unshift({id:i,name:`This machine`,online:!0}),e},[r,i]);function N(t){T(`working`),R.forkSession(e,{destNodeId:D&&!E?f:void 0,managedConfigId:E?m?.id:void 0,agentId:g??void 0,sourceAgentId:d??void 0,model:k?v?{provider:String(v.provider),id:String(v.id)}:void 0:ne?{provider:String(ne.provider),id:String(ne.id)}:void 0,retireSource:O},()=>new Promise(e=>t(e))).then(e=>{let t=e.missing.map(e=>e.detail||e.label).find(Boolean);t&&R.store.setNotice(`Fork created. ${t}`)}).catch(e=>{R.store.setError(e instanceof Error?e.message:String(e))})}let P=w===`working`,ae=v&&(o.find(e=>rl(e)===rl(v))??o.find(e=>e.id===v.id)),oe=ae?rl(ae):``;return(0,G.jsx)(ot,{title:O?`Move session`:`Fork session`,onClose:n,autoFocusSearch:!1,children:e=>(0,G.jsxs)(G.Fragment,{children:[(ie.length>1||m)&&(0,G.jsxs)(`div`,{className:`picker-section fork-select-field`,children:[(0,G.jsx)(`label`,{htmlFor:`fork-destination-node`,children:`Destination machine`}),(0,G.jsxs)(`select`,{id:`fork-destination-node`,value:f,disabled:P,onChange:e=>{let t=e.target.value;p(t),b||C(!!i&&t!==i)},children:[ie.map(e=>(0,G.jsxs)(`option`,{value:e.id,children:[e.name||e.id,` (`,e.id===i?`current`:Ee[me(e)].label.toLowerCase(),`)`]},e.id)),m&&(0,G.jsxs)(`option`,{value:`__managed__`,children:[m.name||`Bivy Cloud`,` (managed · starts on demand)`]})]})]}),(0,G.jsxs)(`div`,{className:`picker-section fork-select-field`,children:[(0,G.jsx)(`label`,{htmlFor:`fork-agent`,children:`Agent`}),(0,G.jsx)(`select`,{id:`fork-agent`,value:g??``,disabled:P,onChange:e=>_(e.target.value),children:re.map(e=>(0,G.jsxs)(`option`,{value:e.id,children:[e.displayName||e.name||e.id,e.id===d?` (current)`:``]},e.id))})]}),k&&o.length>0&&(0,G.jsxs)(`div`,{className:`picker-section fork-select-field`,children:[(0,G.jsx)(`label`,{htmlFor:`fork-model`,children:`Model`}),(0,G.jsxs)(`select`,{id:`fork-model`,value:oe,disabled:P,onChange:e=>{let t=o.find(t=>rl(t)===e.target.value);t&&y(t)},children:[!oe&&(0,G.jsx)(`option`,{value:``,children:`Keep the session’s model`}),o.map(e=>(0,G.jsx)(`option`,{value:rl(e),children:String(e.name||e.id)},rl(e)))]})]}),!k&&!D&&(0,G.jsxs)(`div`,{className:`picker-section fork-select-field`,children:[(0,G.jsx)(`label`,{htmlFor:`fork-target-model`,children:`Model`}),(0,G.jsxs)(`select`,{id:`fork-target-model`,value:j,disabled:P||!te,onChange:e=>M(e.target.value),children:[(0,G.jsx)(`option`,{value:``,children:te?`The agent’s default model`:`Loading models…`}),te?.map(e=>(0,G.jsxs)(`option`,{value:rl(e),children:[String(e.name||e.id),e.provider?` \u00b7 ${String(e.provider)}`:``]},rl(e)))]})]}),D&&O&&(0,G.jsx)(`p`,{className:`picker-section fork-note`,children:`Carries the conversation, its branch and any uncommitted changes. The session here is retired once it’s running on the other machine; if the changes are too large to carry, nothing moves.`}),(0,G.jsx)(`div`,{className:`picker-section`,children:(0,G.jsxs)(`label`,{className:`fork-toggle`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:O,disabled:P,onChange:e=>{x(!0),C(e.target.checked)}}),(0,G.jsx)(`span`,{children:`Retire the original after moving (uncheck to keep both)`})]})}),(0,G.jsx)(`div`,{className:`picker-section`,children:(0,G.jsx)(`button`,{className:`btn primary fork-submit`,onClick:()=>N(e),disabled:P,"aria-busy":P,children:P?`Forking…`:O?`Move session`:`Create fork`})})]})})}var al=2e4;function ol({sessionId:e,name:t,onCancel:n}){let[r,i]=(0,W.useState)(!1),a=(0,W.useRef)(null);rt(n),(0,W.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]);let o=(0,W.useId)();return(0,Gn.createPortal)((0,G.jsxs)(`div`,{className:`app-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":o,children:[(0,G.jsx)(`div`,{className:`app-dialog-backdrop`,onClick:n}),(0,G.jsxs)(`div`,{className:`app-dialog-body`,children:[(0,G.jsx)(`h3`,{id:o,children:`Continue in terminal locally`}),(0,G.jsxs)(`p`,{children:[`Run this in a terminal on any machine with the bivy CLI to pick up “`,t,`” outside the web app:`]}),(0,G.jsxs)(`div`,{className:`repo-connect-command resume-command`,children:[(0,G.jsx)(`code`,{children:`bivy resume ${e}`}),(0,G.jsx)(`button`,{type:`button`,className:`btn sm ghost${r?` is-copied`:``}`,onClick:async()=>{await nt(`bivy resume ${e}`)&&(i(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),1800))},"aria-label":r?`Command copied`:`Copy resume command`,children:r?`Copied`:`Copy`})]}),(0,G.jsx)(`p`,{className:`repo-connect-alt`,children:`It resumes the same conversation — saved sessions relaunch via the agent’s native resume where supported, otherwise it opens the session here in the web app.`}),(0,G.jsx)(`div`,{className:`app-dialog-actions`,children:(0,G.jsx)(`button`,{className:`btn`,onClick:n,children:`Close`})})]})]}),document.body)}function sl({sessionId:e,name:t,isRepo:n,node:r,agent:i,workspace:a,worktree:o,branch:s,sessionFile:c,auditHealth:l,eventLogHealth:d,onBrowseFiles:f}){let[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(!1),[y,b]=(0,W.useState)(!1),[x,S]=(0,W.useState)(!1),[C,w]=(0,W.useState)(!1),{presentation:{prResult:T,error:E}}=Me(),D=(0,W.useRef)(null),O=(0,W.useRef)(null);(0,W.useEffect)(()=>{if(!p)return;let e=e=>{O.current&&!O.current.contains(e.target)&&m(!1)},t=e=>{e.key===`Escape`&&m(!1)};return document.addEventListener(`click`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`click`,e),document.removeEventListener(`keydown`,t)}},[p]),(0,W.useEffect)(()=>{C&&(w(!1),m(!1))},[T,E]),(0,W.useEffect)(()=>()=>{D.current&&clearTimeout(D.current)},[]);let k=()=>m(!1);return(0,G.jsxs)(`div`,{className:`session-actions-wrap`,ref:O,children:[(0,G.jsx)(`button`,{className:`session-actions-btn`,"aria-label":`Session actions`,"aria-haspopup":`menu`,"aria-expanded":p,onClick:e=>{e.stopPropagation(),m(e=>!e)},children:`⋯`}),h&&(0,G.jsx)(st,{title:`Rename session`,initialValue:t,onCancel:()=>g(!1),onSave:t=>{R.renameSession(e,t),g(!1)}}),y&&(0,G.jsx)(il,{sessionId:e,onClose:()=>b(!1)}),x&&(0,G.jsx)(ol,{sessionId:e,name:t,onCancel:()=>S(!1)}),_&&(0,G.jsx)(Ye,{title:`Delete session?`,message:`Delete “${t}”? This can't be undone.`,confirmLabel:`Delete`,danger:!0,onCancel:()=>v(!1),onConfirm:()=>{R.deleteSession(e),v(!1)}}),p&&(0,G.jsxs)(`div`,{className:`menu session-actions-menu`,role:`menu`,children:[l&&([`corrupt`,`unreadable`].includes(l.storage)||l.writes===`degraded`)&&(0,G.jsxs)(`div`,{className:`session-actions-audit-warning`,role:`status`,children:[(0,G.jsx)(`strong`,{children:`Audit evidence degraded`}),(0,G.jsx)(`span`,{children:l.writes===`degraded`?`${l.failedWrites} audit write${l.failedWrites===1?``:`s`} failed.`:`Audit storage is ${l.storage}.`})]}),d?.state===`degraded`&&(0,G.jsxs)(`div`,{className:`session-actions-audit-warning`,role:`status`,children:[(0,G.jsx)(`strong`,{children:`Session history persistence degraded`}),(0,G.jsxs)(`span`,{children:[`The last `,d.operation??`storage`,` operation failed. History may be incomplete.`]})]}),f&&(0,G.jsx)(`button`,{className:`menu-item session-actions-item`,role:`menuitem`,onClick:()=>{k(),f()},disabled:C,children:`Browse files`}),(0,G.jsx)(`button`,{className:`menu-item session-actions-item`,role:`menuitem`,onClick:async()=>{k();let t=`${u()}${ee({kind:`session`,id:e})}`;await nt(z({url:t,sessionId:e,node:r,agent:i,workspace:a,worktree:o,branch:s,sessionFile:c}))?R.store.setNotice(`Session reference copied`):R.store.setError(`Couldn't copy the session reference`)},disabled:C,children:`Copy session reference`}),(0,G.jsx)(`button`,{className:`menu-item session-actions-item`,role:`menuitem`,onClick:()=>{k(),g(!0)},disabled:C,children:`Rename`}),(0,G.jsx)(`button`,{className:`menu-item session-actions-item`,role:`menuitem`,onClick:()=>{k(),b(!0)},disabled:C,children:`Fork / move…`}),(0,G.jsx)(`button`,{className:`menu-item session-actions-item`,role:`menuitem`,onClick:()=>{k(),S(!0)},disabled:C,title:"Copy a `bivy resume` command to run on your own machine",children:`Continue in terminal locally…`}),n&&(0,G.jsx)(`button`,{className:`menu-item session-actions-item`,role:`menuitem`,onClick:()=>{w(!0),R.refreshPrStatus(e),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{w(!1),m(!1)},al)},disabled:C,children:C?`Checking GitHub status…`:`Update GitHub status`}),(0,G.jsx)(`button`,{className:`menu-item session-actions-item danger`,role:`menuitem`,onClick:()=>{k(),v(!0)},disabled:C,children:`Delete`})]})]})}function cl({sessionId:e,sessionName:t,nodeLabel:n,online:r,onOpenTerminal:i,onUseChat:a,children:o}){let s=Ca(e),c=s?.driver?.via===`terminal`&&s.driver.id!==fe().id?s.driver:void 0;return(0,G.jsxs)(`div`,{className:`tui-locked`,children:[(0,G.jsxs)(`div`,{className:`card tui-locked-card`,role:`status`,"aria-live":`polite`,children:[(0,G.jsx)(`span`,{className:`tui-locked-icon`,"aria-hidden":!0,children:(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`26`,height:`26`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,G.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`16`,rx:`2`}),(0,G.jsx)(`path`,{d:`m7 9 3 3-3 3`}),(0,G.jsx)(`path`,{d:`M13 15h4`})]})}),(0,G.jsx)(`h2`,{className:`tui-locked-title`,children:`This session is running in the terminal.`}),(0,G.jsxs)(`p`,{className:`tui-locked-sub`,children:[(0,G.jsxs)(`span`,{className:`tui-locked-name`,children:[`“`,t,`”`]}),` is open in the interactive terminal`,n?(0,G.jsxs)(G.Fragment,{children:[` `,`on `,(0,G.jsx)(`span`,{className:`tui-locked-node`,children:n})]}):null,`. Chat is paused while it’s open — open the terminal to watch it`,a?`, or take it over to message it here`:``,`.`]}),(0,G.jsxs)(`div`,{className:`tui-locked-actions`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn`,onClick:i,disabled:!r,children:`Open terminal`}),a&&(0,G.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:a,disabled:!r,children:`Use chat`})]}),c&&(0,G.jsxs)(`p`,{className:`tui-locked-hint`,children:[`Last input from `,c.label,` · `,Ct(c.at)]}),!r&&(0,G.jsxs)(`p`,{className:`tui-locked-hint`,children:[`Reconnect to the machine to open the terminal`,a?` or take over in chat`:``,`.`]})]}),o]})}function ll(e){return`Pull request${e.number?` #${e.number}`:``} (${e.state===`merged`?`merged`:e.state===`closed`?`closed`:`open`})`}function ul(e){let t=[];e.issueUrl&&t.push({label:`Open issue`,url:e.issueUrl});for(let n of e.prs)t.push({label:ll(n),url:n.url});return e.branch&&e.repo&&t.push({label:`${e.repo} · ${e.branch}`,url:`https://github.com/${e.repo}/tree/${encodeURIComponent(e.branch)}`}),t}function dl(){return(0,G.jsx)(`svg`,{className:`gh-icon`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":!0,children:(0,G.jsx)(`path`,{d:`M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0016 8c0-4.42-3.58-8-8-8z`})})}function fl({gh:e}){let[t,n]=(0,W.useState)(!1),r=ul(e);if(r.length===0)return null;let i=M(e.prs),a=i?`pr`:e.issueUrl?`issue`:`branch`,o=i?.state===`merged`?`merged`:i?.state===`open`?`ok`:a===`issue`?`accent`:void 0,s=e.repo?e.repo.split(`/`).pop()||e.repo:null,c=e.branch?s?`${s} · ${e.branch}`:e.branch:`branch`,l=i?i.state===`merged`?`Merged`:i.state===`closed`?`Closed`:`PR`:a===`issue`?`Issue`:c;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{className:`badge github-pill`,"data-tone":o,"data-variant":`outline`,onClick:()=>n(!0),title:`GitHub context`,children:[(0,G.jsx)(dl,{}),(0,G.jsx)(`span`,{className:`gh-text`,children:l})]}),t&&(0,G.jsx)(ot,{variant:`action`,ariaLabel:`GitHub actions`,title:(0,G.jsxs)(`span`,{className:`run-sheet-title`,children:[(0,G.jsx)(`span`,{className:`gh-head-mark`,"aria-hidden":!0,children:(0,G.jsx)(dl,{})}),`GitHub`]}),onClose:()=>n(!1),autoFocusSearch:!1,children:r.map(e=>(0,G.jsxs)(`a`,{className:`sheet-action gh-link`,href:e.url,target:`_blank`,rel:`noopener`,onClick:()=>n(!1),children:[(0,G.jsx)(dl,{}),(0,G.jsx)(`span`,{children:e.label})]},e.url))})]})}var pl={fix:`Fix`,retry:`Retry checks`,fork:`Fork`};function ml(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:` · resets ${t.toLocaleString([],{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}`}var hl={autonomous:`Autonomous`,risky:`Ask before risky actions`,always:`Ask before every action`,never:`Never ask`},gl={"read-only":`Read only`,"workspace-write":`Workspace write`,"danger-full-access":`Full access`};function _l(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString([],{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}function vl(e){return e>0&&e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function yl(e){return new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e)}var bl={open:`Open`,merged:`Merged`,closed:`Closed`};function xl(e){let t=[];e.issueUrl&&t.push({label:`Open issue`,url:e.issueUrl});for(let n of e.prs)t.push({label:`Pull request${n.number?` #${n.number}`:``}`,detail:bl[n.state]??n.state,url:n.url});return e.branch&&e.repo&&t.push({label:`${e.repo} · ${e.branch}`,url:`https://github.com/${e.repo}/tree/${encodeURIComponent(e.branch)}`}),t}function Sl({item:e}){let t=e.checks??[];return t.length===0?null:(0,G.jsx)(`div`,{className:`run-sheet-checks`,children:t.map((e,t)=>(0,G.jsxs)(Te,{tone:e.status===`passed`?`ok`:e.status===`failed`?`danger`:void 0,children:[e.name,` `,e.status===`passed`?`✓`:e.status===`failed`?`✗`:`–`]},`${e.name}-${t}`))})}function J({k:e,children:t}){return t==null||t===!1||t===``?null:(0,G.jsxs)(`div`,{className:`run-sheet-row`,children:[(0,G.jsx)(`span`,{className:`k`,children:e}),(0,G.jsx)(`span`,{className:`v`,children:t})]})}function Cl({source:e,statusClass:t,statusLabel:n,gh:r,evidence:a,finishedAt:o,usage:s,forkedFrom:c,delegatedFrom:l,filesEdited:u,onOpenChanges:d,artifactsCount:f,onOpenArtifacts:p,onRecover:m,onOpenRun:h,anchorId:g}){let[_,v]=(0,W.useState)(!1),y=xl(r),b=jt(e.kind),x=n===`Open`?`Open on machine`:n,S=a?ze(a):null,C=a?Rt(a):null,w=a?zt(a):null,T=typeof o==`number`?_l(o):``,E=a?.attempt??0,D=a?Vt(a):null,O=a?Mt(a):null,k=a&&m?Pt(a):[],A=[a?.runtimeId,a?.model].filter(Boolean).join(` · `),ee=a?.output?.failure,j=c?c.name||`session ${c.sessionId.slice(0,8)}`:null,M=s?.tokens?.total??0,te=typeof s?.costUsd==`number`,ne=[...s?.plan?.windows??[]].sort((e,t)=>(t.utilizationPct??0)-(e.utilizationPct??0)),re=te||M>0||ne.length>0,ie=u&&u>0?`${u} file${u===1?``:`s`} edited`:null,N=f&&f>0?`${f} artifact${f===1?``:`s`}`:null;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{id:g,className:`run-pill src-${e.kind} ${t}`,onClick:()=>v(!0),title:[e.label,n,ie].filter(Boolean).join(` · `),children:[e.automation&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(It,{kind:e.kind,size:`sm`}),(0,G.jsx)(`span`,{className:`run-pill-label`,children:b})]}),(0,G.jsxs)(`span`,{className:`run-pill-stat`,children:[(0,G.jsx)(qt,{status:t}),n]}),(0,G.jsx)(Bt,{prs:r.prs}),ie&&(0,G.jsx)(`span`,{className:`run-pill-files`,children:ie})]}),_&&(0,G.jsx)(ot,{variant:`action`,ariaLabel:e.label,title:(0,G.jsxs)(`span`,{className:`run-sheet-title`,children:[(0,G.jsx)(It,{kind:e.kind,size:`sm`}),e.label]}),onClose:()=>v(!1),autoFocusSearch:!1,children:e=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`run-sheet-status`,children:[(0,G.jsx)(qt,{status:t}),x]}),ee&&(0,G.jsx)(`div`,{className:`run-sheet-failure`,children:ee}),c&&(0,G.jsx)(`div`,{className:`run-sheet-rows`,children:(0,G.jsx)(J,{k:`Forked from`,children:c.openable?(0,G.jsx)(`button`,{type:`button`,className:`btn sm ghost`,onClick:()=>R.openSessionOnNode(c.sessionId,void 0,c.nodeId),children:j}):j})}),l&&(0,G.jsx)(`div`,{className:`run-sheet-rows`,children:(0,G.jsx)(J,{k:`Delegated from`,children:(0,G.jsxs)(`button`,{type:`button`,className:`btn sm ghost`,onClick:()=>R.openSessionOnNode(l.sessionId,void 0,l.nodeId),children:[l.title||`session ${l.sessionId.slice(0,8)}`,l.machine?` · ${l.machine}`:``]})})}),(T||w)&&(0,G.jsx)(`div`,{className:`run-sheet-rows`,children:(0,G.jsx)(J,{k:`Finished`,children:[T||null,w?`ran ${w}`:null].filter(Boolean).join(` · `)})}),a&&(0,G.jsxs)(`div`,{className:`run-sheet-rows`,children:[S&&(0,G.jsx)(J,{k:`Outcome`,children:(0,G.jsx)(Te,{tone:S.tone===`success`?`ok`:S.tone===`warning`?`warn`:S.tone===`danger`?`danger`:void 0,children:S.label})}),O?.url&&(0,G.jsx)(J,{k:`Artifact`,children:(0,G.jsx)(`a`,{href:O.url,target:`_blank`,rel:`noopener`,children:O.label})}),C&&(0,G.jsx)(J,{k:`Checks`,children:(0,G.jsx)(Sl,{item:a})}),E>1&&(0,G.jsx)(J,{k:`Attempts`,children:D?`${E} · ${D}`:String(E)}),a.routingReason&&(0,G.jsx)(J,{k:`Routing`,children:i(a.routingReason)}),a.output?.branch&&(0,G.jsx)(J,{k:`Branch`,children:(0,G.jsx)(`code`,{children:a.output.branch})}),a.output?.commit&&(0,G.jsx)(J,{k:`Commit`,children:(0,G.jsx)(`code`,{children:a.output.commit.slice(0,12)})}),A&&(0,G.jsx)(J,{k:`Ran on`,children:A}),a.approvalMode&&(0,G.jsx)(J,{k:`Approvals`,children:hl[a.approvalMode]??a.approvalMode}),a.sandbox&&(0,G.jsx)(J,{k:`Sandbox`,children:gl[a.sandbox]??a.sandbox})]}),re&&(0,G.jsxs)(`div`,{className:`run-sheet-rows`,children:[te&&(0,G.jsx)(J,{k:`Cost`,children:(0,G.jsx)(`span`,{title:`$${s.costUsd.toFixed(4)}`,children:vl(s.costUsd)})}),M>0&&(0,G.jsx)(J,{k:`Tokens`,children:(0,G.jsx)(`span`,{title:M.toLocaleString(),children:yl(M)})}),ne.map(e=>(0,G.jsxs)(J,{k:e.label,children:[typeof e.utilizationPct==`number`?`${Math.round(e.utilizationPct)}% used`:`usage unknown`,ml(e.resetsAt)]},e.label))]}),ie&&d&&(0,G.jsxs)(`button`,{type:`button`,className:`sheet-action run-sheet-changes`,onClick:()=>e(d),children:[(0,G.jsx)(`span`,{className:`run-sheet-changes-icon`,"aria-hidden":!0,children:`◈`}),(0,G.jsx)(`span`,{children:ie}),(0,G.jsx)(`span`,{className:`run-sheet-changes-hint`,children:`View diffs`})]}),N&&p&&(0,G.jsxs)(`button`,{type:`button`,className:`sheet-action run-sheet-changes`,onClick:()=>e(p),children:[(0,G.jsx)(`span`,{className:`run-sheet-changes-icon`,"aria-hidden":!0,children:`📎`}),(0,G.jsx)(`span`,{children:N}),(0,G.jsx)(`span`,{className:`run-sheet-changes-hint`,children:`View artifacts`})]}),y.map(e=>(0,G.jsxs)(`a`,{className:`sheet-action gh-link`,href:e.url,target:`_blank`,rel:`noopener`,onClick:()=>v(!1),children:[(0,G.jsx)(Ht,{}),(0,G.jsx)(`span`,{children:e.label}),e.detail&&(0,G.jsx)(`span`,{className:`run-sheet-changes-hint`,children:e.detail})]},e.url)),a?.output?.artifactUrl&&(0,G.jsx)(`a`,{className:`sheet-action`,href:a.output.artifactUrl,target:`_blank`,rel:`noopener`,onClick:()=>v(!1),children:`View artifact`}),a?.id&&h&&(0,G.jsxs)(`button`,{type:`button`,className:`sheet-action run-sheet-open-run`,onClick:()=>e(()=>h(a.id)),children:[(0,G.jsx)(`span`,{"aria-hidden":!0,children:`▸`}),(0,G.jsx)(`span`,{children:`Run details`})]}),k.length>0&&m&&(0,G.jsx)(`div`,{className:`run-sheet-recovery`,role:`group`,"aria-label":`Recover this run`,children:k.map(e=>(0,G.jsx)(`button`,{type:`button`,className:`btn small recover-${e}`,onClick:()=>{m(e),v(!1)},children:pl[e]},e))}),y.length===0&&!a&&!re&&!c&&!l&&!ie&&(0,G.jsx)(`div`,{className:`sheet-action-empty`,children:`This session has nothing to report yet.`})]})})]})}function wl({apps:e,serverPorts:t,newNotes:n,onOpen:r}){let i=e>0?`${e} app${e===1?``:`s`}`:t.length===1?`Preview :${t[0]}`:t.length>1?`${t.length} servers`:null;if(!i)return null;let a=n>0?`${n} new note${n===1?``:`s`}`:null;return(0,G.jsxs)(`button`,{type:`button`,className:`run-pill apps-pill`,onClick:r,"aria-label":[`Open apps`,i,a].filter(Boolean).join(` · `),children:[(0,G.jsx)(Xe,{size:16}),(0,G.jsx)(`span`,{className:`run-pill-label`,children:i}),a&&(0,G.jsx)(Te,{tone:`unseen`,variant:`solid`,children:a})]})}function Tl({entry:e,mode:t}){let[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(!1),o=(0,W.useMemo)(()=>{let t=0,n=0;for(let r of e.files){let e=bt(r);t+=e.added,n+=e.removed}return{added:t,removed:n}},[e.files]),s=(0,W.useMemo)(()=>Di(e.files.map(e=>({path:e.path,status:e.status,added:e.added,removed:e.removed}))),[e.files]),c=(0,W.useMemo)(()=>new Map(e.files.map(e=>[e.path,e])),[e.files]),l=e.files.length;return(0,G.jsxs)(`div`,{className:`session-changes-turn`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`session-changes-turn-head`,onClick:()=>r(e=>!e),"aria-expanded":n,children:[(0,G.jsx)(`span`,{className:`changes-chevron`,"aria-hidden":!0,children:n?`▾`:`▸`}),(0,G.jsxs)(`span`,{className:`session-changes-turn-title`,children:[l,` file`,l===1?``:`s`,` changed`,(o.added>0||o.removed>0)&&(0,G.jsxs)(`span`,{className:`changes-total`,children:[o.added>0&&(0,G.jsxs)(`span`,{className:`add`,children:[`+`,o.added]}),o.removed>0&&(0,G.jsxs)(`span`,{className:`del`,children:[`−`,o.removed]})]})]}),(0,G.jsx)(`span`,{className:`session-changes-turn-time`,children:Ct(e.at)})]}),n&&(0,G.jsxs)(`div`,{className:`session-changes-turn-body`,children:[e.before&&(0,G.jsx)(`button`,{type:`button`,className:`btn danger-ghost changes-undo`,onClick:()=>{e.before&&(a(!0),R.rewind(e.before))},disabled:i,children:i?`Undoing…`:`Rewind to before this turn`}),(0,G.jsx)(`div`,{className:`changes-files`,children:s.map(e=>(0,G.jsx)(Tt,{node:e,byPath:c,mode:t,depth:0},e.path))})]})]})}function El(e){let t=new Set;for(let n of e)for(let e of n.files)t.add(e.path);return t.size}function Dl({history:e,onClose:t,checks:n,docked:r,onComposerFilled:i}){let[a,o]=(0,W.useState)(`unified`),[s,c]=(0,W.useState)(!1),l=(0,W.useMemo)(()=>[...e].reverse(),[e]),u=(0,W.useMemo)(()=>El(e),[e]),d=l[0],f=(0,W.useMemo)(()=>{if(!d)return{added:0,removed:0};let e=0,t=0;for(let n of d.files){let r=bt(n);e+=r.added,t+=r.removed}return{added:e,removed:t}},[d]),p=()=>{d&&(R.prefillComposer(_t(d.files.map(e=>({...e,...bt(e)})),n)),r||t(),i?.())},m=()=>{d?.before&&(c(!0),R.rewind(d.before))},h=u>0?`${u} file${u===1?``:`s`} edited`:`Session changes`;return(0,G.jsxs)(_r,{docked:r,title:h,onClose:t,autoFocusSearch:!1,headExtra:(0,G.jsxs)(`div`,{className:`changes-mode`,role:`group`,"aria-label":`Diff view mode`,children:[(0,G.jsx)(`button`,{type:`button`,className:a===`unified`?`active`:``,onClick:()=>o(`unified`),children:`Unified`}),(0,G.jsx)(`button`,{type:`button`,className:a===`split`?`active`:``,onClick:()=>o(`split`),children:`Split`})]}),children:[d&&(0,G.jsxs)(`div`,{className:`session-changes-toolbar`,children:[(0,G.jsxs)(`span`,{className:`session-changes-toolbar-meta`,children:[`Latest turn`,(f.added>0||f.removed>0)&&(0,G.jsxs)(`span`,{className:`changes-total`,children:[f.added>0&&(0,G.jsxs)(`span`,{className:`add`,children:[`+`,f.added]}),f.removed>0&&(0,G.jsxs)(`span`,{className:`del`,children:[`−`,f.removed]})]})]}),(0,G.jsxs)(`div`,{className:`session-changes-toolbar-actions`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:p,children:`Review with agent`}),d.before&&(0,G.jsx)(`button`,{type:`button`,className:`btn sm danger-ghost`,onClick:m,disabled:s,children:s?`Undoing…`:`Undo turn`})]})]}),(0,G.jsxs)(`div`,{className:`session-changes-list`,children:[l.length===0&&(0,G.jsx)(`div`,{className:`changes-binary`,children:`No file changes yet this session.`}),l.map(e=>(0,G.jsx)(Tl,{entry:e,mode:a},e.id))]})]})}var Ol=8;function kl(e){return e.filter(e=>!e.pendingLaunch).sort((e,t)=>(t.updatedAt??0)-(e.updatedAt??0)).slice(0,Ol)}function Al(e){let t=e.replace(/\s+/g,` `).trim();return t.length>160?`${t.slice(0,159)}…`:t}function jl(e){let[t,n]=(0,W.useState)(new Map);return(0,W.useEffect)(()=>{let t=!0;return e?.().then(e=>{let r=new Map;for(let t of[...e.items].sort((e,t)=>t.createdAt-e.createdAt)){let e=t.views.find(e=>e.kind===`web`&&e.lastPath)??t.views.find(e=>e.kind===`web`);e&&!r.has(t.sessionId)&&r.set(t.sessionId,{name:t.name,path:e.kind===`web`?e.lastPath:void 0})}t&&n(r)},()=>{}),()=>{t=!1}},[e]),t}function Ml({image:e}){let t=(0,W.useMemo)(()=>e.data?`data:${e.mimeType};base64,${e.data}`:``,[e]);return t?(0,G.jsx)(`img`,{className:`share-thumb`,src:t,alt:e.name}):null}function Nl({text:e,images:t=[],sessions:n,listApps:r,onDeliver:i}){let a=kl(n),o=jl(r),s=(0,W.useRef)(!1),c=e=>{s.current||(s.current=!0,i(e,e?o.get(e.sessionId):void 0))},l=t.length?t.length===1?`screenshot`:`${t.length} images`:`text`;return(0,G.jsx)(ot,{title:t.length?`Send the ${l} to…`:`Send shared text to…`,ariaLabel:`Choose where to send the shared ${l}`,onClose:()=>c(null),autoFocusSearch:!1,children:(0,G.jsxs)(`div`,{className:`share-sheet`,children:[(t.length>0||e)&&(0,G.jsxs)(`figure`,{className:`share-shared`,children:[t.length>0&&(0,G.jsx)(`div`,{className:`share-thumbs`,children:t.map((e,t)=>(0,G.jsx)(Ml,{image:e},t))}),e&&(0,G.jsxs)(`figcaption`,{className:`muted small`,children:[`“`,Al(e),`”`]})]}),(0,G.jsxs)(`div`,{className:`share-dests`,role:`list`,"aria-label":`Destinations`,children:[(0,G.jsx)(`button`,{type:`button`,role:`listitem`,className:`share-dest`,onClick:()=>c(null),children:(0,G.jsx)(Xr,{tile:(0,G.jsx)(We,{size:18}),name:`New session`,meta:`Start fresh with what you shared`})}),a.map(e=>{let t=o.get(e.sessionId),n=[e.agentName,e.branch].filter(Boolean).join(` · `);return(0,G.jsx)(`button`,{type:`button`,role:`listitem`,className:`share-dest`,onClick:()=>c(e),children:(0,G.jsx)(Xr,{tile:t?Yr(t.name):(0,G.jsx)(Ze,{size:18}),name:e.name,meta:t?`${t.name} preview${t.path&&t.path!==`/`?` · ${t.path}`:``}`:n||void 0,detail:t&&n?(0,G.jsx)(`span`,{className:`app-row-meta`,children:n}):void 0})},e.sessionId)})]})]})})}var Pl=`bivy-share-inbox`,Fl=/^[a-f0-9]{32}$/,Il=(e,t)=>`/__share-inbox/${e}/${t}`;function Ll(e){let t=new Uint8Array(e),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return btoa(n)}async function Rl(e,t=globalThis.caches){if(!Fl.test(e)||!t)return null;let n=await t.open(Pl),r=await n.match(Il(e,`meta`)).then(e=>e?.json()).catch(()=>void 0);if(!r)return null;let i=[];for(let[t,a]of r.files.entries()){let r=await n.match(Il(e,t));if(!r)continue;let o=Ll(await r.arrayBuffer());i.push({kind:`image`,name:a.name,mimeType:a.type,size:a.size,data:o})}let a=[r.title.trim(),r.text.trim()];return r.url&&!a.some(e=>e.includes(r.url))&&a.push(r.url.trim()),{text:a.filter(Boolean).join(`
|
|
26
26
|
`),attachments:i}}async function zl(e,t=globalThis.caches){if(!Fl.test(e)||!t)return;let n=await t.open(Pl);for(let t of await n.keys())new URL(t.url).pathname.startsWith(`/__share-inbox/${e}/`)&&await n.delete(t)}function Bl(){let{connection:e,activeSession:t}=Me(),[n]=(0,W.useState)(x),[r,i]=(0,W.useState)(n?`Opening your app preview…`:null),a=!!n&&e.status===`online`&&t.activeSessionId===n?.sessionId;return(0,W.useEffect)(()=>{n&&a&&(v(),R.appCommand(`apps.open`,n.sessionId,{appId:n.appId,viewId:n.viewId,direct:!0}).then(e=>{let t=e,r=t.kind===`web`?new URL(t.url):null;if(!r||r.protocol!==`https:`||r.origin===location.origin)throw Error(`Unexpected preview link.`);location.replace(`${r.href}~${encodeURIComponent(n.path)}`)}).catch(e=>i(`Couldn’t reopen the preview: ${e instanceof Error?e.message:`try again from Apps`}.`)))},[n,a]),r}function Vl({progress:e,onClose:t}){let n=(0,W.useRef)(null),r=(0,W.useId)(),i=(0,W.useId)(),a=e.status===`working`;return rt(()=>{a||t()}),(0,W.useEffect)(()=>{let e=n.current;return e.showModal(),()=>e.close()},[]),(0,Gn.createPortal)((0,G.jsxs)(`dialog`,{ref:n,tabIndex:-1,className:`app-dialog-body fork-progress-dialog`,"aria-labelledby":r,"aria-describedby":i,onKeyDown:e=>{a&&e.key===`Tab`&&(e.preventDefault(),n.current?.focus())},onCancel:e=>{e.preventDefault(),a||t()},children:[(0,G.jsxs)(`h3`,{id:r,className:`run-sheet-title`,children:[a&&(0,G.jsx)(V,{size:`sm`}),a?`Forking session`:`Fork needs attention`]}),(0,G.jsx)(`p`,{id:i,role:a?`status`:`alert`,children:e.message}),a?(0,G.jsx)(`p`,{children:`You’ll be taken to the new session when it’s ready.`}):(0,G.jsx)(`div`,{className:`app-dialog-actions`,children:(0,G.jsx)(`button`,{className:`btn primary`,onClick:t,children:`Close`})})]}),document.body)}var Hl={added:`New`,modified:`Modified`,deleted:`Deleted`},Ul={added:`+`,modified:`~`,deleted:`−`},Wl={ts:`typescript`,tsx:`typescript`,mts:`typescript`,cts:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,jsonc:`json`,css:`css`,scss:`scss`,less:`less`,html:`xml`,htm:`xml`,xml:`xml`,svg:`xml`,vue:`xml`,md:`markdown`,mdx:`markdown`,py:`python`,rb:`ruby`,go:`go`,rs:`rust`,java:`java`,kt:`kotlin`,swift:`swift`,c:`c`,h:`c`,cc:`cpp`,cpp:`cpp`,hpp:`cpp`,cs:`csharp`,php:`php`,pl:`perl`,lua:`lua`,r:`r`,sql:`sql`,graphql:`graphql`,sh:`bash`,bash:`bash`,zsh:`bash`,yml:`yaml`,yaml:`yaml`,toml:`ini`,ini:`ini`,diff:`diff`,patch:`diff`,mk:`makefile`},Gl={Makefile:`makefile`,Dockerfile:`dockerfile`,".bashrc":`bash`,".zshrc":`bash`};function Kl(e){let t=e.slice(e.lastIndexOf(`/`)+1);if(Gl[t])return Gl[t];let n=t.lastIndexOf(`.`);return n>0?Wl[t.slice(n+1).toLowerCase()]:void 0}function ql(e,t){return t?e.filter(e=>e.status||e.changed):e}var Jl=new Map,Yl=e=>e instanceof Error?e.message:String(e);function Xl({status:e}){return e?(0,G.jsxs)(`span`,{className:`files-mark`,"data-status":e,title:Hl[e],children:[(0,G.jsx)(`span`,{"aria-hidden":!0,children:Ul[e]}),(0,G.jsx)(`span`,{className:`sr-only`,children:Hl[e]})]}):(0,G.jsx)(`span`,{className:`files-mark`,"aria-hidden":!0})}function Zl({sessionId:e,path:t,reloadKey:n,onBack:r}){let[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(!1),u=(0,W.useRef)(null);(0,W.useEffect)(()=>{let n=!1;return s(null),R.fileCommand(`files.read`,e,t).then(e=>{n||a(e.file)}).catch(e=>{n||(a(null),s(Yl(e)))}),()=>{n=!0}},[e,t,n]);let d=i?.kind===`text`?i.content:null,f=d!==null&&d.length<=2e5;(0,W.useLayoutEffect)(()=>{let e=u.current;e&&d!==null&&(e.textContent=d,delete e.dataset.highlighted,f&&Es(e.parentElement?.parentElement??null))},[d,f]);let p=(0,W.useMemo)(()=>d===null?0:d.split(`
|
|
@@ -29,7 +29,7 @@ Error generating stack: `+e.message+`
|
|
|
29
29
|
`)}),(0,G.jsx)(`pre`,{className:`files-source`,children:(0,G.jsx)(`code`,{ref:u,className:g?`language-${g}`:`nohighlight`})})]})),m&&(0,G.jsx)(`div`,{className:`files-image`,children:(0,G.jsx)(`img`,{src:m,alt:t})}),i?.kind===`binary`&&(0,G.jsx)(`div`,{className:`changes-binary`,children:`Binary file — not shown.`}),i?.kind===`too-large`&&(0,G.jsx)(`div`,{className:`changes-binary`,children:`Too large to show here.`})]})}function Ql({path:e,depth:t,folders:n,expanded:r,changedOnly:i,onToggle:a,onOpen:o}){let s=n.get(e),c={paddingLeft:`calc(${t} * var(--space-4) + var(--space-1))`};if(!s||s.status===`loading`)return(0,G.jsxs)(`div`,{className:`files-row files-row-note`,style:c,role:`status`,children:[(0,G.jsx)(V,{size:`xs`}),(0,G.jsx)(`span`,{children:`Loading…`})]});if(s.status===`error`)return(0,G.jsx)(`div`,{className:`files-row files-row-note files-row-error`,style:c,role:`alert`,children:s.error});let l=ql(s.listing.entries,i);return l.length===0?(0,G.jsx)(`div`,{className:`files-row files-row-note`,style:c,children:i?`No uncommitted changes here.`:`Empty folder.`}):(0,G.jsxs)(G.Fragment,{children:[l.map(e=>{let s=e.type===`dir`&&r.has(e.path);return(0,G.jsxs)(`div`,{role:`none`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`files-row`,style:c,"data-status":e.status,onClick:()=>e.type===`dir`?a(e.path):o(e.path),"aria-expanded":e.type===`dir`?s:void 0,disabled:e.status===`deleted`,title:e.status===`deleted`?`${e.path} — deleted`:e.path,children:[(0,G.jsx)(`span`,{className:`changes-chevron`,"aria-hidden":!0,children:e.type===`dir`?s?`▾`:`▸`:``}),(0,G.jsxs)(`span`,{className:`files-name`,children:[e.name,e.type===`dir`?`/`:``]}),e.symlink&&(0,G.jsx)(`span`,{className:`files-meta`,children:`link`}),e.type===`dir`&&e.changed?(0,G.jsxs)(`span`,{className:`files-meta files-changed`,children:[e.changed,` changed`]}):null,e.type===`file`&&(0,G.jsx)(Xl,{status:e.status})]}),s&&(0,G.jsx)(Ql,{path:e.path,depth:t+1,folders:n,expanded:r,changedOnly:i,onToggle:a,onOpen:o})]},e.path)}),s.listing.entries.length>=2e3&&(0,G.jsx)(`div`,{className:`files-row files-row-note`,style:c,children:`Showing the first 2000 entries.`})]})}function $l({sessionId:e,onClose:t,docked:n,refreshKey:r=0}){let i=Jl.get(e),[a,o]=(0,W.useState)(()=>new Set(i?.expanded??[])),[s,c]=(0,W.useState)(i?.open??null),[l,u]=(0,W.useState)(i?.changedOnly??!1),[d,f]=(0,W.useState)(new Map),[p,m]=(0,W.useState)(0),[h,g]=(0,W.useState)(!1);(0,W.useEffect)(()=>{Jl.set(e,{expanded:[...a],open:s,changedOnly:l})},[e,a,s,l]);let _=(0,W.useCallback)((t,n=!1)=>(n||f(e=>new Map(e).set(t,{status:`loading`})),R.fileCommand(`files.list`,e,t).then(e=>f(n=>new Map(n).set(t,{status:`ready`,listing:e}))).catch(e=>f(n=>new Map(n).set(t,{status:`error`,error:Yl(e)})))),[e]),v=(0,W.useRef)(!0);(0,W.useEffect)(()=>{let e=!v.current;v.current=!1,g(!0),Promise.all([``,...a].map(t=>_(t,e))).finally(()=>g(!1))},[_,r,p]);let y=e=>{let t=new Set(a);t.has(e)?t.delete(e):(t.add(e),d.get(e)?.status!==`ready`&&_(e)),o(t)},b=d.get(``),x=b?.status===`ready`&&b.listing.git,S=b?.status===`ready`?b.listing.entries.reduce((e,t)=>e+(t.changed??+!!t.status),0):0;return(0,G.jsx)(_r,{docked:n,title:`Files`,ariaLabel:`Workspace files`,onClose:t,autoFocusSearch:!1,size:`large`,headExtra:(0,G.jsx)(`button`,{type:`button`,className:`btn ghost icon`,onClick:()=>m(e=>e+1),"aria-label":`Refresh files`,title:`Refresh`,children:h&&b?.status===`ready`?(0,G.jsx)(V,{size:`xs`}):(0,G.jsx)(Ue,{size:18})}),children:s?(0,G.jsx)(Zl,{sessionId:e,path:s,reloadKey:r+p,onBack:()=>c(null)}):(0,G.jsxs)(`div`,{className:`files-browser`,children:[x&&(0,G.jsxs)(`div`,{className:`files-toolbar`,children:[(0,G.jsx)(`span`,{className:`files-toolbar-meta`,children:S===0?`No uncommitted changes`:`${S} uncommitted change${S===1?``:`s`}`}),(0,G.jsxs)(`div`,{className:`changes-mode`,role:`group`,"aria-label":`Which files to show`,children:[(0,G.jsx)(`button`,{type:`button`,className:l?``:`active`,"aria-pressed":!l,onClick:()=>u(!1),children:`All`}),(0,G.jsx)(`button`,{type:`button`,className:l?`active`:``,"aria-pressed":l,onClick:()=>u(!0),children:`Changed`})]})]}),(0,G.jsx)(`div`,{className:`files-tree`,role:`group`,"aria-label":`Workspace files`,children:(0,G.jsx)(Ql,{path:``,depth:0,folders:d,expanded:a,changedOnly:l,onToggle:y,onOpen:c})})]})})}var eu=1e4,Y={published:null,offers:[],noteTimes:[]};function tu(e,t){let{connection:n}=Me(),r=n.status===`online`,i=`${n.currentNodeId??``}:${e??``}`,[a,o]=(0,W.useState)({key:``,...Y});return(0,W.useEffect)(()=>{if(!e||!r)return;let n=!0,a=0,s=()=>{let t=++a,r=R.appCommand(`apps.offers`,e).then(e=>e.offers??[],()=>[]),s=R.appCommand(`apps.list`,e).then(e=>e.apps??null,()=>null);Promise.all([s,r]).then(([e,r])=>{let s=(e??[]).flatMap(e=>e.views.flatMap(e=>e.kind===`web`?(e.notes??[]).map(e=>e.at):[]));n&&t===a&&o({key:i,published:e?.length??null,offers:r,noteTimes:s})})};s();let c=t?setInterval(s,eu):void 0,l=()=>{document.visibilityState===`visible`&&s()};document.addEventListener(`visibilitychange`,l);let u=R.onAppsChanged(t=>{t===e&&s()});return()=>{n=!1,c&&clearInterval(c),document.removeEventListener(`visibilitychange`,l),u()}},[i,e,r,t]),r&&a.key===i?a:Y}function nu(e){return Math.min(3e4,Math.max(6e3,e.trim().length*45))}function ru(){let{presentation:{error:e,errorActions:t}}=Me(),[n,r]=(0,W.useState)(!1),[o,s]=(0,W.useState)(null);if((0,W.useEffect)(()=>{if(r(!1),!e||c()&&t.length>0)return;let n=setTimeout(()=>R.store.setError(``),nu(e));return()=>clearTimeout(n)},[e,t]),!e)return null;let l=!c()&&t.length>0?a():i(e.trim()),u=l.includes(`
|
|
30
30
|
`)||l.length>240;return(0,G.jsxs)(Sc,{tone:`danger`,className:`error-toast${n?` expanded`:``}`,role:`alert`,children:[(0,G.jsx)(Cc,{tone:`danger`,children:`!`}),(0,G.jsxs)(`div`,{className:`error-toast-content`,children:[(0,G.jsx)(`span`,{className:`error-toast-text`,children:l}),u&&(0,G.jsx)(`button`,{className:`error-toast-details`,type:`button`,onClick:()=>r(e=>!e),"aria-expanded":n,children:n?`Hide details`:`Show details`}),c()&&t.length>0&&(0,G.jsx)(`div`,{className:`error-toast-actions`,children:t.map(e=>(0,G.jsx)(`button`,{className:`btn small${e.kind===`primary`?` primary`:``}`,type:`button`,disabled:o!==null,onClick:()=>{s(e.id),R.invokeAccountExtensionAction(e.id).then(async({url:e})=>{e?await h(e):R.store.setError(``)}).catch(e=>R.store.setError(e instanceof Error?e.message:String(e))).finally(()=>s(null))},children:o===e.id?`Opening…`:e.label},e.id))})]}),(0,G.jsx)(`button`,{className:`error-toast-close`,onClick:()=>R.store.setError(``),"aria-label":`Dismiss`,children:`×`})]})}function iu(e){return Math.min(3e4,Math.max(6e3,e.trim().length*45))}function au(){let{presentation:{notice:e}}=Me();return(0,W.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>R.store.setNotice(``),iu(e));return()=>clearTimeout(t)},[e]),e?(0,G.jsxs)(Sc,{tone:`ok`,className:`notice-toast`,role:`status`,children:[(0,G.jsx)(Cc,{tone:`ok`,children:`✓`}),(0,G.jsx)(`span`,{className:`notice-toast-text`,children:e.trim()}),(0,G.jsx)(`button`,{className:`notice-toast-close`,onClick:()=>R.store.setNotice(``),"aria-label":`Dismiss`,children:`×`})]}):null}function ou({state:e}){let t=e.presentation.needsModelAuth;if(!t||t.nodeId!==e.connection.currentNodeId)return null;let n=e.catalogs.providers.find(e=>e.id===t.provider)?.name||t.provider,r=!!t.reason;return(0,G.jsx)(ot,{title:`Sign in to your model`,onClose:()=>R.dismissModelAuthPrompt(),children:(0,G.jsxs)(`div`,{className:`settings-form`,children:[(0,G.jsx)(`p`,{className:`muted settings-intro`,children:r?`Your agent couldn't reach ${n} — its credential is missing or expired. Sign in again to keep going.`:`This Machine needs a model before it can run your task. Sign in once with ${n}. The login runs on this Machine and stays encrypted end to end; it syncs to your other machines like any other credential.`}),(0,G.jsx)(an,{state:e,providerId:t.provider,apiKeyProvider:E(t.provider)})]})})}function su(e){return[`I'm new to Bivy. My app runs with \`${e.command}\` on port ${e.port}; I want to open it in a preview and mark what's wrong.`,`Publish it with \`bivy app publish\` so the preview shows your edits: if you're working in the folder it already runs in, publish port ${e.port}; otherwise have Bivy run it from your folder on a free port (a "start" command in the manifest).`,`Don't change anything else yet; once it's published, reply in one short line that it's ready.`,"When my marks arrive, fix them and check your fix. Then make a share link with `bivy app share` and reply with it."].join(`
|
|
31
31
|
`)}var cu=[`I'm new to Bivy. Make one small, useful change in this workspace that I'd keep: a few minutes of work, not a chore like running the tests. If the workspace is empty, build something small I can open.`,"Pick it yourself. If you really need a decision from me, ask with `bivy ask`.","If it's something I can see, run it and publish a preview with `bivy app publish`.",`Finish with the result in one line. Keep replies short, I'm probably on my phone.`].join(`
|
|
32
|
-
`),lu=4e3,uu=e=>e.split(/[\\/]/).filter(Boolean).pop()||e;function du({machineName:e,onOpenApp:t,onFirstChange:n}){let r=e||`your machine`,[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(!1);(0,W.useEffect)(()=>{let e=!0,t=setTimeout(()=>{e&&a(e=>e??[])},lu);return R.appCommand(`apps.offers`,void 0).then(t=>{let n=t.offers??[];e&&a(e=>e??n.filter(e=>typeof e.project==`string`))},()=>{e&&a([])}),R.direct||R.pushStatus().then(t=>{e&&s(t.supported&&!t.subscribed&&t.permission!==`denied`)},()=>{}),()=>{e=!1,clearTimeout(t)}},[]);let u=async e=>{l(!0),o&&await R.enablePush().catch(()=>{}),e()},[d,...f]=i??[];return(0,G.jsxs)(`section`,{className:`card readiness`,"aria-labelledby":`get-started-title`,"aria-busy":i===null,children:[(0,G.jsx)(`p`,{className:`readiness-passed`,role:`status`,children:`✓ Setup complete`}),i===null?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h2`,{id:`get-started-title`,className:`card-title`,children:`Your agent's first task`}),(0,G.jsxs)(`p`,{className:`card-sub get-started-scan`,role:`status`,children:[(0,G.jsx)(V,{size:`xs`}),`Looking for apps running on `,r,`…`]})]}):d?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`h2`,{id:`get-started-title`,className:`card-title`,children:[`Mark what's wrong in `,uu(d.project)]}),(0,G.jsxs)(`p`,{className:`card-sub`,children:[`It's running on `,r,`. The agent opens it here, you tap what's off, and it fixes it and sends you a link to share. It keeps working when you close this app.`]}),(0,G.jsxs)(`p`,{className:`get-started-app card-sub`,children:[(0,G.jsx)(`code`,{children:d.command}),` · port `,d.port]}),(0,G.jsxs)(`div`,{className:`get-started-actions`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`btn sm primary`,disabled:c,onClick:()=>void u(()=>t(d)),children:[`Open `,uu(d.project),` and mark what's wrong`]}),(0,G.jsx)(`span`,{className:`card-sub`,children:`or type your own task below`})]}),f.length>0&&(0,G.jsxs)(`div`,{className:`get-started-more`,role:`group`,"aria-label":`Other running apps`,children:[(0,G.jsx)(`span`,{className:`card-sub`,children:`Also running:`}),f.slice(0,3).map(e=>(0,G.jsxs)(`button`,{type:`button`,className:`btn sm ghost`,disabled:c,onClick:()=>void u(()=>t(e)),"aria-label":`Open ${uu(e.project)} on port ${e.port} and mark what's wrong`,children:[uu(e.project),` · `,e.port]},e.port))]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h2`,{id:`get-started-title`,className:`card-title`,children:`Give your agent a first task`}),(0,G.jsxs)(`p`,{className:`card-sub`,children:[`It runs on `,r,` and keeps working when you close this app. It'll make one small, useful change here and tell your phone when it's done.`]}),(0,G.jsxs)(`div`,{className:`get-started-actions`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn sm primary`,disabled:c,onClick:()=>void u(n),children:`Make one small improvement`}),(0,G.jsx)(`span`,{className:`card-sub`,children:`or type your own task below`})]})]})]})}var fu=`bivy:notify-offer`;function pu({working:e,machineName:t,onOpenChange:n}){let[r,i]=(0,W.useState)(()=>localStorage.getItem(fu)===`done`),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(!1),[d,f]=(0,W.useState)(null);(0,W.useEffect)(()=>{if(r||a||!e||R.direct)return;let t=!0;return R.pushStatus().then(e=>{t&&o(e.supported&&!e.subscribed&&e.permission!==`denied`)}).catch(()=>{}),()=>{t=!1}},[r,a,e]),(0,W.useEffect)(()=>{if(!l)return;let e=setTimeout(()=>i(!0),5e3);return()=>clearTimeout(e)},[l]);let p=!r&&a;(0,W.useEffect)(()=>n?.(p),[p]);let m=()=>{localStorage.setItem(fu,`done`),i(!0)},h=async()=>{c(!0),f(null);try{await R.enablePush(),localStorage.setItem(fu,`done`),u(!0)}catch(e){f(e instanceof Error?e.message:String(e))}finally{c(!1)}};return p?l?(0,G.jsx)(`section`,{className:`card next-step`,"aria-label":`Notifications`,children:(0,G.jsx)(`p`,{className:`next-step-ok`,role:`status`,children:`✓ Notifications are on. You can close the app; Bivy will let you know.`})}):(0,G.jsxs)(`section`,{className:`card next-step`,"aria-labelledby":`notify-offer-title`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{id:`notify-offer-title`,children:`Get a notification when it's done?`}),(0,G.jsxs)(`p`,{children:[`The agent keeps working on `,t||`your machine`,` if you close this app. Bivy can tell you when it finishes or needs you.`]}),d&&(0,G.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,role:`alert`,children:d})]}),(0,G.jsxs)(`div`,{className:`next-step-actions`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn sm primary`,disabled:s,onClick:()=>void h(),children:s?`Turning on…`:`Turn on notifications`}),(0,G.jsx)(`button`,{type:`button`,className:`btn sm ghost`,disabled:s,onClick:m,children:`Not now`})]})]}):null}function mu({nodes:e,onPickNode:t,onRefresh:n,onUseCloud:r}){let i=e.filter(e=>!e.id.startsWith(`eph-`)),[a,o]=(0,W.useState)(null),s=(0,W.useRef)(i.length===0),c=(0,W.useRef)(!1);return(0,W.useEffect)(()=>{let n=a??(s.current&&e.length===1?e[0]?.id:void 0),r=e.find(e=>e.id===n&&e.online&&!e.id.startsWith(`eph-`));r&&!c.current&&(c.current=!0,t(r.id))},[e,a,t]),(0,G.jsxs)(`section`,{className:`connect-runner`,"aria-labelledby":`connect-runner-title`,children:[(0,G.jsxs)(`div`,{className:`connect-hero compact`,children:[(0,G.jsx)(`h2`,{className:`connect-title`,id:`connect-runner-title`,children:i.length>0?`Choose a Machine`:`Connect a Machine`}),(0,G.jsx)(`p`,{className:`connect-sub`,children:i.length>0?`Pick an online machine to start, or add another machine.`:`Your agents run here, using your existing environment. Keep your repositories, tools, and agent logins.`})]}),(0,G.jsxs)(`div`,{className:`connect-waiting`,role:`status`,children:[(0,G.jsx)(V,{size:`sm`}),(0,G.jsx)(`span`,{className:`connect-waiting-text`,children:i.length>0?`Checking for connected machines automatically…`:`Waiting for your machine. This page updates automatically.`}),(0,G.jsx)(`button`,{type:`button`,className:`btn sm ghost`,onClick:n,children:`Check now`})]}),i.length>0&&(0,G.jsxs)(`div`,{className:`connect-nodes`,children:[(0,G.jsx)(`div`,{className:`connect-nodes-head`,children:`Your machines`}),(0,G.jsx)(`div`,{className:`connect-nodes-list`,children:i.map(e=>(0,G.jsxs)(`button`,{type:`button`,className:`connect-node`,onClick:()=>t(e.id),title:e.online?`Start on this Machine`:`This Machine is offline — selecting it will try to reconnect`,children:[(0,G.jsx)(qt,{status:e.online?`online`:`idle`}),(0,G.jsx)(`span`,{className:`connect-node-name`,children:e.name||e.id}),(0,G.jsx)(`span`,{className:`connect-node-status${e.online?` is-online`:``}`,children:e.online?`Online`:`Offline`}),(0,G.jsx)(`svg`,{className:`connect-node-caret`,viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:(0,G.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]},e.id))})]}),(0,G.jsx)(`div`,{className:`connect-options`,children:(0,G.jsx)(`div`,{className:`connect-option machine-install-card`,children:(0,G.jsx)(mr,{onEnrolled:o})})}),(0,G.jsx)(`p`,{className:`connect-sub`,children:`Next: connect your AI, send your first task, and review the result right here.`}),r&&(0,G.jsx)(`button`,{type:`button`,className:`btn link connect-option-link`,onClick:r,children:`Use Bivy Cloud instead`})]})}function hu({state:e,place:t,startError:n,onRetry:r,onDone:i}){let[a,o]=(0,W.useState)(null),s=e.connection.currentNodeId,c=!!s&&e.connection.status===`online`,l=t===`cloud`||!!s?.startsWith(`eph-`),u=e.connection.nodes.find(e=>e.id===s)?.name||`your computer`,d=e.catalogs.providers,f=e=>d.some(t=>(t.id===e||t.id===E(e))&&t.configured),p=sn.filter(e=>!d.length||d.some(t=>t.id===e.provider)),m=p.filter(e=>f(e.provider)).map(e=>e.provider),h=m.length>0||e.catalogs.activationReadiness?.credential.ok===!0,g=e=>{o(e),R.startOauth(e,void 0,rn(s,t))},_=()=>{let t=nn(e.catalogs.runtimes,e.catalogs.selectedAgentId??``,m);t&&R.chooseAgent(t),cn(),i()};return(0,G.jsxs)(`section`,{className:`card readiness`,"aria-labelledby":`connect-ai-title`,children:[(0,G.jsx)(`h2`,{id:`connect-ai-title`,className:`card-title`,children:`Connect your AI`}),(0,G.jsxs)(`p`,{className:`card-sub`,children:[`Sign in with the plans you already pay for. Connect both to switch agents any time.`,` `,l?`Your sign-in stays encrypted on this cloud computer. Another machine that's online can restore it, and this browser can restore an API key.`:`Your sign-ins stay on ${u}; Bivy's servers never get a copy.`]}),!c&&(n?(0,G.jsxs)(`div`,{className:`banner inline`,"data-tone":`danger`,role:`alert`,children:[(0,G.jsxs)(`span`,{className:`banner-text`,children:[`Bivy Cloud didn't start: `,n]}),(0,G.jsx)(`button`,{type:`button`,className:`btn sm banner-action`,onClick:r,children:`Try again`})]}):(0,G.jsxs)(`p`,{className:`card-sub get-started-scan`,role:`status`,children:[(0,G.jsx)(V,{size:`xs`}),l?`Starting your cloud computer. The first start takes about a minute.`:`Waiting for ${u}…`]})),(0,G.jsx)(`ul`,{className:`ai-accounts`,children:p.map(t=>{let n=f(t.provider),r=a===t.provider&&!n;return(0,G.jsxs)(`li`,{className:`ai-account`,children:[(0,G.jsxs)(`div`,{className:`ai-account-head`,children:[(0,G.jsxs)(`span`,{className:`ai-account-text`,children:[(0,G.jsx)(`span`,{className:`ai-account-name`,children:t.name}),(0,G.jsx)(`span`,{className:`ai-account-plan`,children:t.plan})]}),n?(0,G.jsx)(`span`,{className:`ai-account-ok`,children:`✓ Connected`}):(0,G.jsxs)(`span`,{className:`ai-account-actions`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn sm ghost`,disabled:!c,"aria-expanded":r,onClick:()=>o(r?null:t.provider),children:`API key`}),(0,G.jsxs)(`button`,{type:`button`,className:`btn sm primary`,disabled:!c,onClick:()=>g(t.provider),children:[`Sign in`,(0,G.jsxs)(`span`,{className:`sr-only`,children:[` with `,t.name]})]})]})]}),r&&(0,G.jsx)(an,{state:e,providerId:t.provider,apiKeyProvider:E(t.provider)===t.provider?void 0:E(t.provider),keyOnly:!0})]},t.provider)})}),(0,G.jsxs)(`div`,{className:`get-started-actions`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn sm primary`,disabled:!h,onClick:_,children:`Continue`}),!h&&c&&(0,G.jsx)(`button`,{type:`button`,className:`btn sm ghost`,onClick:_,children:`Set up later`})]})]})}var gu=[{place:`cloud`,name:`Bivy Cloud`,detail:`Nothing to install. Agents keep working when your laptop is closed.`},{place:`own`,name:`My own computer`,detail:`Your files, tools and logins. Your AI sign-ins stay on that computer.`}];function _u({onChoose:e}){return(0,G.jsxs)(`section`,{className:`connect-runner`,"aria-labelledby":`place-choice-title`,children:[(0,G.jsxs)(`div`,{className:`connect-hero compact`,children:[(0,G.jsx)(`h2`,{className:`connect-title`,id:`place-choice-title`,children:`Where should your agents run?`}),(0,G.jsx)(`p`,{className:`connect-sub`,children:`You can add the other one later.`})]}),(0,G.jsx)(`div`,{className:`connect-nodes-list`,children:gu.map(({place:t,name:n,detail:r})=>(0,G.jsxs)(`button`,{type:`button`,className:`connect-node`,onClick:()=>e(t),children:[(0,G.jsxs)(`span`,{className:`connect-node-text`,children:[(0,G.jsx)(`span`,{className:`connect-node-name`,children:n}),(0,G.jsx)(`span`,{className:`connect-node-detail`,children:r})]}),(0,G.jsx)(`svg`,{className:`connect-node-caret`,viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:(0,G.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]},t))})]})}function vu({status:e,hasCachedTranscript:t,machineName:r}){let i=(0,W.useSyncExternalStore)(Re,Oe),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(()=>typeof navigator<`u`&&!navigator.onLine);(0,W.useEffect)(()=>{let e=()=>c(!0),t=()=>c(!1);return window.addEventListener(`offline`,e),window.addEventListener(`online`,t),()=>{window.removeEventListener(`offline`,e),window.removeEventListener(`online`,t)}},[]);let l=ge(s?`offline`:e,t,i,r),u=l.kind!==`live-control`,d=!n&&i.installChoice!==null&&!i.standalone;return!u&&!d?null:(0,G.jsxs)(G.Fragment,{children:[u&&(0,G.jsx)(`aside`,{className:`pwa-lifecycle`,"aria-label":`App availability`,children:(0,G.jsxs)(`div`,{className:`pwa-lifecycle-copy`,"data-availability":l.kind,children:[(0,G.jsx)(`strong`,{children:l.label}),(0,G.jsx)(`span`,{children:l.detail})]})}),d&&(0,G.jsxs)(`aside`,{className:`pwa-install`,"aria-label":`Install Bivy`,children:[(0,G.jsx)(`button`,{type:`button`,className:`pwa-install-dismiss`,onClick:_e,"aria-label":`Dismiss install suggestion`,title:`Don't show again`,children:`×`}),(0,G.jsxs)(`div`,{className:`pwa-install-copy`,children:[(0,G.jsx)(`strong`,{children:`Install Bivy`}),(0,G.jsx)(`span`,{children:`Open Bivy in a dedicated window and return to this device more reliably.`})]}),(0,G.jsx)(`div`,{className:`pwa-install-actions`,children:i.installChoice===`native`?(0,G.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:()=>void L(),children:`Install`}):(0,G.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:()=>o(e=>!e),children:`How to install`})}),a&&i.installChoice===`ios`&&(0,G.jsxs)(`p`,{role:`status`,children:[`In Safari, tap Share, then `,(0,G.jsx)(`strong`,{children:`Add to Home Screen`}),`, then Add. Other iOS browsers cannot install Bivy directly.`]}),a&&i.installChoice===`safari`&&(0,G.jsxs)(`p`,{role:`status`,children:[`On macOS Sonoma or later, choose `,(0,G.jsx)(`strong`,{children:`File → Add to Dock`}),` in Safari 17 or later. Older macOS Safari versions cannot install Bivy as a web app.`]})]})]})}function yu(e,t=document,n=window){let r=()=>{t.visibilityState===`visible`&&e()};return t.addEventListener(`visibilitychange`,r),n.addEventListener(`pageshow`,r),n.addEventListener(`focus`,r),()=>{t.removeEventListener(`visibilitychange`,r),n.removeEventListener(`pageshow`,r),n.removeEventListener(`focus`,r)}}function bu({onOpen:e,onClose:t,isOpen:n,maxWidth:r=720,edge:i=28,threshold:a=60}){let o=(0,W.useRef)(e),s=(0,W.useRef)(t);o.current=e,s.current=t,(0,W.useEffect)(()=>{let e=0,t=0,c=!1,l=!1,u=!1,d=a=>{if(u=!1,a.touches.length!==1||window.innerWidth>r){c=!1;return}let o=a.touches[0];if(!o){c=!1;return}e=o.clientX,t=o.clientY,l=e<=i,c=l||n},f=r=>{if(!c||r.touches.length!==1)return;let i=r.touches[0];if(!i)return;let a=i.clientX-e,o=i.clientY-t;if(!u){if(Math.abs(o)>Math.abs(a)&&Math.abs(o)>6){c=!1;return}Math.abs(a)>Math.abs(o)&&Math.abs(a)>2&&(!n&&l||n&&a<0)&&(u=!0)}u&&r.cancelable&&r.preventDefault()},p=r=>{if(!c)return;c=!1,u=!1;let i=r.changedTouches[0];if(!i)return;let d=i.clientX-e,f=i.clientY-t;Math.abs(d)<=Math.abs(f)||Math.abs(d)<a||(!n&&l&&d>0?o.current():n&&d<0&&s.current())};return window.addEventListener(`touchstart`,d,{passive:!0}),window.addEventListener(`touchmove`,f,{passive:!1}),window.addEventListener(`touchend`,p,{passive:!0}),()=>{window.removeEventListener(`touchstart`,d),window.removeEventListener(`touchmove`,f),window.removeEventListener(`touchend`,p)}},[n,r,i,a])}var xu={chat:{label:`Chat`,Icon:Ze},terminal:{label:`Terminal`,Icon:it},changes:{label:`Changes`,Icon:Je}};function Su({views:e,value:t,onChange:n,changes:r=0}){let i=(0,W.useRef)([]),a=(t,r)=>{let a=t.key===`ArrowRight`?1:t.key===`ArrowLeft`?-1:0;if(!a)return;t.preventDefault();let o=(r+a+e.length)%e.length,s=e[o];s&&(n(s),i.current[o]?.focus())};return(0,G.jsx)(`div`,{className:`segmented session-view-toggle`,role:`radiogroup`,"aria-label":`Session view`,children:e.map((e,o)=>{let{label:s,Icon:c}=xu[e],l=e===`changes`&&r>0?r:null;return(0,G.jsxs)(`button`,{ref:e=>{i.current[o]=e},type:`button`,role:`radio`,className:`seg-btn`,"aria-checked":t===e,tabIndex:t===e?0:-1,onClick:()=>n(e),onKeyDown:e=>a(e,o),"aria-label":l?`${s}, ${l} file${l===1?``:`s`}`:s,title:s,children:[(0,G.jsx)(c,{size:14,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`session-view-label`,children:s}),l&&(0,G.jsx)(`span`,{className:`seg-count`,"aria-hidden":`true`,children:l})]},e)})})}var Cu=`bivy.sessionView`,wu=50;function Tu(e){try{let t=JSON.parse(e.getItem(Cu)||`{}`);return t&&typeof t==`object`?t:{}}catch{return{}}}function Eu(e,t){return t&&Tu(e)[t]===`terminal`?`terminal`:`chat`}function Du(e,t,n){let r=Tu(e);delete r[t],n!==`chat`&&(r[t]=n);let i=Object.keys(r);for(let e of i.slice(0,Math.max(0,i.length-wu)))delete r[e];try{e.setItem(Cu,JSON.stringify(r))}catch{}}function Ou({tabs:e,active:t,onSelect:n,onClose:r,children:i}){let a=(0,W.useRef)([]),o=(t,r)=>{let i=t.key===`ArrowRight`?1:t.key===`ArrowLeft`?-1:0;if(!i)return;t.preventDefault();let o=(r+i+e.length)%e.length,s=e[o];s&&(n(s.id),a.current[o]?.focus())};return(0,G.jsxs)(`aside`,{className:`side-pane`,"aria-label":`Session details`,children:[(0,G.jsxs)(`div`,{className:`side-pane-head`,children:[(0,G.jsx)(`div`,{className:`segmented side-pane-tabs`,role:`tablist`,"aria-label":`Session details`,children:e.map((e,r)=>(0,G.jsxs)(`button`,{ref:e=>{a.current[r]=e},type:`button`,role:`tab`,id:`side-pane-tab-${e.id}`,"aria-controls":`side-pane-body`,"aria-selected":t===e.id,tabIndex:t===e.id?0:-1,className:`seg-btn side-pane-tab`,onClick:()=>n(e.id),onKeyDown:e=>o(e,r),children:[e.label,e.count?(0,G.jsx)(`span`,{className:`seg-count`,children:e.count}):null]},e.id))}),(0,G.jsx)(`button`,{type:`button`,className:`btn ghost icon side-pane-close`,onClick:r,"aria-label":`Hide side pane`,title:`Hide side pane`,children:(0,G.jsx)(tt,{size:18})})]}),(0,G.jsx)(`div`,{className:`side-pane-body`,id:`side-pane-body`,role:`tabpanel`,"aria-labelledby":`side-pane-tab-${t}`,children:i})]})}var ku=`(min-width: 1200px)`,Au=`bivy.sidePane`,ju=new Set([`changes`,`files`,`apps`,`artifacts`,`terminal`]);function Mu(){try{let e=localStorage.getItem(Au);return e&&ju.has(e)?e:null}catch{return null}}function Nu(){let e=qi(ku),[t,n]=(0,W.useState)(Mu),r=(0,W.useCallback)(e=>{n(e);try{e?localStorage.setItem(Au,e):localStorage.removeItem(Au)}catch{}},[]);return{wide:e,tab:t,setTab:r,show:(0,W.useCallback)(t=>e?(r(t),!0):!1,[e,r])}}var Pu=(0,W.lazy)(()=>C(()=>import(`./Terminal-CNTaC3Bo.js`).then(e=>({default:e.TerminalOverlay})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),Fu=(0,W.lazy)(()=>C(()=>import(`./ReadinessChecklist-Bbgq2GQ8.js`).then(e=>({default:e.ReadinessChecklist})),__vite__mapDeps([37,5,1]))),Iu=(0,W.lazy)(()=>C(()=>import(`./Settings-B_0J-UTo.js`).then(e=>({default:e.Settings})),__vite__mapDeps([38,3,4,2,1,5,6,39]))),Lu=(0,W.lazy)(()=>C(()=>import(`./AutomationsView-tGFmNyI7.js`).then(e=>({default:e.AutomationsView})),__vite__mapDeps([40,1,3,4,2,5,6,41,8]))),Ru=(0,W.lazy)(()=>C(()=>import(`./LibraryView-D4o-Q00g.js`).then(e=>({default:e.LibraryView})),__vite__mapDeps([42,2,1,3,4,5,6,41,8]))),zu=`a[href],button:not(:disabled),textarea:not(:disabled),input:not(:disabled),select:not(:disabled),[tabindex]:not([tabindex="-1"])`;function Bu(e,t){return t?e.needsAction||e.status===`needs_action`?t.question_asked||t.approval_requested:e.status===`failed`?t.session_error:Ot(e)?t.session_done:!1:!0}function Vu(){let e=Me(),t=Bl(),n=(0,W.useSyncExternalStore)(Wi,Hi),r=(0,W.useSyncExternalStore)(Wi,Gi),[i,a]=(0,W.useState)(!1),o=(0,W.useRef)(null),s=(0,W.useRef)(null),c=(0,W.useRef)(null),[u,f]=(0,W.useState)(()=>localStorage.getItem(`bivy:automation-next-step`)===`done`),p=(0,W.useSyncExternalStore)(Jt,Xt),h=(0,W.useSyncExternalStore)(Zn,Qn),g=(0,W.useSyncExternalStore)(Pc,Fc),_=(0,W.useSyncExternalStore)(Hc,Uc),v=e.presentation.githubApp?.returning;(0,W.useEffect)(()=>{v&&$n({setup:`github`})},[v]);let[b,x]=(0,W.useState)(!1);(0,W.useEffect)(()=>x(!1),[e.activeSession.activeSessionId]);let[C,w]=(0,W.useState)(!1),[T,E]=(0,W.useState)(!1),[D,O]=(0,W.useState)(null);(0,W.useEffect)(()=>po(O),[]);let A=Nu(),ee=A.show;(0,W.useEffect)(()=>{D&&ee(`apps`)},[D,ee]),(0,W.useEffect)(()=>O(null),[e.activeSession.activeSessionId]);let j=(0,W.useRef)(!1);(0,W.useEffect)(()=>{let t=e.activeSession.activeSessionId;if(!j.current||!t)return;j.current=!1;let n=!1;return R.onAppsChanged(e=>{n||e!==t||R.appCommand(`apps.list`,t).then(e=>{let r=e.apps.find(e=>e.views.some(e=>e.kind===`web`)),i=r?.views.find(e=>e.kind===`web`);!n&&r&&i&&(n=!0,O({sessionId:t,appId:r.id,openView:{viewId:i.id}}))},()=>{})})},[e.activeSession.activeSessionId]);let[M,te]=(0,W.useState)(!1),[ne,re]=(0,W.useState)(()=>l(sessionStorage)),N=(0,W.useCallback)(()=>R.listMachineApps(),[]),[P,ae]=(0,W.useState)(null);(0,W.useEffect)(()=>{let e=y(sessionStorage);e&&Rl(e).then(t=>{t?ae({id:e,items:t}):m(sessionStorage)},()=>m(sessionStorage))},[]);let[oe,se]=(0,W.useState)(null);(0,W.useEffect)(()=>{if(!oe||(e.activeSession.activeSessionId??null)!==oe.sessionId)return;let t=0,n,r=()=>{R.prefillComposer(oe.text,oe.attachments)?(zl(oe.inbox),se(null)):++t<50&&(n=setTimeout(r,100))};return n=setTimeout(r,0),()=>clearTimeout(n)},[oe,e.activeSession.activeSessionId]);let ue=(0,W.useMemo)(()=>Un(e.activeSession.transcript),[e.activeSession.transcript]),fe=(0,W.useMemo)(()=>Wn(e.activeSession.transcript),[e.activeSession.transcript]),pe=e.sessionIndex.sessions.find(t=>t.sessionId===e.activeSession.activeSessionId),F=tu(pe?.sessionId,pe?Wt(pe)===`working`:!1),I=Vr(pe?.sessionId,F.noteTimes),[me,ge]=(0,W.useState)(!1),[_e,ve]=(0,W.useState)(null),[L,be]=(0,W.useState)(!1),[xe,Se]=(0,W.useState)(!1),[Ce,we]=(0,W.useState)(null),[Te,Ee]=(0,W.useState)(!1),[De,Oe]=(0,W.useState)(null),[ke,Ae]=(0,W.useState)(()=>new Set),Fe=(0,W.useCallback)(()=>{!R.direct&&e.connection.signedIn&&R.fetchGithubQueue().then(Oe).catch(()=>{})},[e.connection.signedIn]);(0,W.useEffect)(()=>{if(R.direct||!e.connection.signedIn)return;let t=Fe;t();let n=yu(t),r=setInterval(()=>{document.visibilityState!==`hidden`&&t()},3e4);return()=>{clearInterval(r),n()}},[Fe,e.connection.signedIn]),(0,W.useEffect)(()=>{!R.direct&&e.connection.signedIn&&R.getNotificationPreferences().then(Ki).catch(()=>{})},[e.connection.signedIn]);let Le=(0,W.useMemo)(()=>Nt(De),[De]),Re=(0,W.useMemo)(()=>kt(De),[De]),ze=(0,W.useMemo)(()=>e.sessionIndex.sessions.filter(e=>Gt(e)>0),[e.sessionIndex.sessions]),He=(0,W.useMemo)(()=>n?ze.filter(e=>Bu(e,r)).length:0,[n,ze,r]),Ue=ze.some(e=>!ke.has(e.sessionId)),We=(0,W.useCallback)(()=>{a(!0),Ae(new Set(ze.map(e=>e.sessionId)))},[ze]),Ge=(0,W.useCallback)(()=>a(!1),[]);(0,W.useEffect)(()=>{let e=ze.length,t=He;document.title=e>0?`(${e}) Bivy`:`Bivy`;let n=navigator,r=()=>{(t>0?n.setAppBadge?.(t):n.clearAppBadge?.())?.catch(()=>{})};r();let i=yu(r);return()=>{i(),document.title=`Bivy`}},[He,ze.length]);let Ke=!R.direct&&e.connection.signedIn&&!e.connection.currentNodeId;(0,W.useEffect)(()=>{if(!Ke)return;let e=()=>{document.visibilityState!==`hidden`&&R.refreshNodes()};e();let t=setInterval(e,4e3),n=yu(e);return()=>{clearInterval(t),n()}},[Ke]);let[Je,Ye]=(0,W.useState)(()=>localStorage.getItem(`bivy.focusView`)===`1`),Xe=(0,W.useCallback)(()=>{Ye(e=>{let t=!e;return localStorage.setItem(`bivy.focusView`,t?`1`:`0`),t})},[]),Ze=e.connection.status===`online`;(0,W.useEffect)(()=>Be(e.activeSession.working),[e.activeSession.working]),(0,W.useEffect)(()=>{Ze&&Ne()},[Ze]);let Qe=Object.values(e.sessionIndex.followupsBySession).reduce((e,t)=>e+t.length,0);(0,W.useEffect)(()=>Pe(Qe),[Qe]);let $e=(0,W.useMemo)(()=>de({direct:R.direct,signedIn:e.connection.signedIn,status:e.connection.status,runtimes:e.catalogs.runtimes,readiness:e.catalogs.activationReadiness}),[e.catalogs.activationReadiness,e.catalogs.runtimes,e.connection.signedIn,e.connection.status]),et=e.activeSession.transcript.some(e=>e.role===`assistant`&&!!e.text&&!e.tool);(0,W.useEffect)(()=>{et&&e.activeSession.activeSessionId&&!u&&localStorage.setItem(`bivy:automation-next-step`,`done`)},[et,e.activeSession.activeSessionId,u]);let[nt,it]=(0,W.useState)(!1),at=(0,W.useRef)(!1);Ze&&(at.current=!0);let ot=e.connection.status===`reconnecting`||at.current&&(e.connection.status===`connecting`||e.connection.status===`linking`||e.connection.status===`pairing`),st=!!(e.activeSession.activeSessionId&&e.sessionIndex.tuiSessions.includes(e.activeSession.activeSessionId)),z=e.sessionIndex.sessions.find(t=>t.sessionId===e.activeSession.activeSessionId),ct=z?.runtimeId??e.activeSession.activeRuntimeId,lt=e.catalogs.runtimes.find(e=>e.id===ct)?.capabilities,ut=Ze&&!!lt?.interactiveTui,dt=e.activeSession.activeSessionId,[ft,pt]=(0,W.useState)(()=>({id:dt,view:Eu(sessionStorage,dt)})),mt=ft.view;ft.id!==dt&&(mt=Eu(sessionStorage,dt),pt({id:dt,view:mt}));let ht=(0,W.useCallback)(t=>{dt&&Du(sessionStorage,dt,t),t===`chat`&&dt&&e.sessionIndex.tuiSessions.includes(dt)&&R.closeSessionTui(dt),pt({id:dt,view:t})},[dt,e.sessionIndex.tuiSessions]),gt=!!dt&&ut&&!Ce,_t=gt&&mt===`terminal`,vt=R.direct&&Ie(`directNode`,!1),yt=!R.direct&&!R.solo||vt,bt=(Ze||ot||R.isCurrentNodeResumable()||!!e.draft.ephemeralConfig)&&!st;bu({isOpen:i,onOpen:We,onClose:Ge,maxWidth:900}),rt(Ge,i),(0,W.useEffect)(()=>{if(!i)return;let e=o.current,t=s.current,n=c.current;t?.setAttribute(`inert`,``);let r=()=>e?Array.from(e.querySelectorAll(zu)):[],a=requestAnimationFrame(()=>{(e?.querySelector(`.sidebar-close`)??e)?.focus()}),l=t=>{if(t.key!==`Tab`)return;let n=r();if(!n.length)return;let i=n[0],a=n[n.length-1],o=document.activeElement;t.shiftKey&&(o===i||!e?.contains(o))?(t.preventDefault(),a.focus()):!t.shiftKey&&(o===a||!e?.contains(o))&&(t.preventDefault(),i.focus())};return window.addEventListener(`keydown`,l),()=>{cancelAnimationFrame(a),window.removeEventListener(`keydown`,l),t?.removeAttribute(`inert`),n?.focus()}},[i]);let xt=(0,W.useCallback)((t,n)=>{if(t.startsWith(`connect-provider:`)){let n=t.slice(17),r=e.connection.currentNodeId;n&&r&&R.store.setNeedsModelAuth({nodeId:r,provider:n});return}if(t===`fix-auth`||t.startsWith(`fix-auth:`)){let n=t.startsWith(`fix-auth:`)?t.slice(9):``,r=e.connection.currentNodeId;n&&r?R.store.setNeedsModelAuth({nodeId:r,provider:n}):Zt(`providers`);return}if(t===`retry-auth`){R.sendPrompt(`Continue — your previous request failed to authenticate. Pick up exactly where you left off.`);return}if(t.startsWith(`retry-at-reset:`)){R.setLimitRetry(!0);return}switch(t){case`/new`:R.newSession();break;case`fork`:te(!0);break;case`cancel-resume`:R.setLimitRetry(!1);break;case`/resume`:R.sendPrompt(`Please continue — your previous turn was interrupted by a restart before it finished. Pick up exactly where you left off and finish what you were doing.`)}},[e.connection.currentNodeId]),St=(0,W.useMemo)(()=>{let t=e.activeSession.activeRuntimeId??e.catalogs.selectedAgentId,n=e.catalogs.currentModel?.provider,r=Ve(t,typeof n==`string`?n:void 0);return r?`fix-auth:${r}`:`fix-auth`},[e.activeSession.activeRuntimeId,e.catalogs.selectedAgentId,e.catalogs.currentModel]),Ct=(0,W.useCallback)(()=>{if(a(!1),!R.direct&&e.connection.nodes.length===0&&R.refreshNodes(),R.direct||e.connection.nodes.length<=1){ve(null),be(!0),Se(!1),ge(!0);return}Ee(!0)},[e.connection.nodes]),wt=(0,W.useCallback)(t=>{Ee(!1),!R.direct&&t!==e.connection.currentNodeId&&R.switchNode(t),ve(null),be(!0),Se(!1),ge(!0),a(!1)},[e.connection.currentNodeId]),Tt=(0,W.useCallback)((t,n,r,i)=>{let o=()=>{(!r||R.isCurrentSessionTarget(r,i))&&(we({termId:t,nodeId:n}),ge(!1),ve(null),be(!1),Se(!1))};if(a(!1),!R.direct&&n&&n!==e.connection.currentNodeId){R.connectToNode(n).then(o).catch(e=>{(!r||R.isCurrentSessionTarget(r,i))&&R.store.setError(e instanceof Error?e.message:String(e))});return}o()},[e.connection.currentNodeId]),Et=(0,W.useCallback)((t,n,r)=>{let i=()=>{R.isCurrentSessionTarget(t,r)&&(we(null),ve(t),be(!0),Se(!1),ge(!0))};if(a(!1),!R.direct&&n&&n!==e.connection.currentNodeId){R.connectToNode(n).then(i).catch(e=>{R.store.setError(e instanceof Error?e.message:String(e))});return}i()},[e.connection.currentNodeId]),Ot=(0,W.useCallback)(()=>{Ce&&(ve(Ce.termId),be(!1),Se(!1),ge(!0))},[Ce]),At=(0,W.useCallback)(()=>{if(!Ce)return;let e=Ce;we(null);let t=R.onTerminal(n=>{let r=n;r.type===`terminal.takeover.result`&&r.termId===e.termId&&(t(),r.ok||we(e))});R.sendTerminal({kind:`terminal.takeover`,termId:e.termId})},[Ce]);(0,W.useEffect)(()=>{Ce&&(e.sessionIndex.runTerminals.some(e=>e.termId===Ce.termId)||we(null))},[Ce,e.sessionIndex.runTerminals]);let jt=(0,W.useCallback)(()=>{ve(null),be(!1),Se(!0),ge(!0)},[]),Mt=(0,W.useCallback)(()=>{e.activeSession.activeSessionId&&R.closeSessionTui(e.activeSession.activeSessionId)},[e.activeSession.activeSessionId]);(0,W.useEffect)(()=>{let t=new URLSearchParams(location.search).get(`review`);t&&e.activeSession.activeSessionId&&_s(e.activeSession.activeSessionId,{reviewId:t})},[e.activeSession.activeSessionId]),(0,W.useEffect)(()=>{let t=new URLSearchParams(location.search),n=t.get(`review`);if(!n||!e.activeSession.activeSessionId||e.connection.status!==`online`)return;let r=e.activeSession.transcript.find(e=>e.review?.id===n)?.review;r&&(t.delete(`review`),history.replaceState(history.state,``,`${location.pathname}${t.size?`?${t}`:``}${location.hash}`),O({sessionId:r.sessionId,appId:r.appId,openView:{viewId:r.viewId,path:r.path}}))},[e.activeSession.activeSessionId,e.activeSession.transcript,e.connection.status]),(0,W.useEffect)(()=>{let t=new URLSearchParams(location.search),n=t.get(`apps`);n&&e.activeSession.activeSessionId&&(t.delete(`apps`),history.replaceState(history.state,``,`${location.pathname}${t.size?`?${t}`:``}${location.hash}`),/^[a-f0-9]{32}$/.test(n)&&O({sessionId:e.activeSession.activeSessionId,appId:n}))},[e.activeSession.activeSessionId]),(0,W.useEffect)(()=>{let t=new URLSearchParams(location.search),n=e.activeSession.activeSessionId;t.get(`show`)===`1`&&n&&e.connection.status===`online`&&(t.delete(`show`),history.replaceState(history.state,``,`${location.pathname}${t.size?`?${t}`:``}${location.hash}`),R.appCommand(`apps.showMe`,n).catch(e=>R.store.setError(e instanceof Error?e.message:`Couldn't show the app`)))},[e.activeSession.activeSessionId,e.connection.status]),(0,W.useEffect)(()=>{let t=new URLSearchParams(location.search).get(`attention`);if(!t||!e.activeSession.activeSessionId)return;let n=document.getElementById(`attention-${encodeURIComponent(t)}`);n&&(n.scrollIntoView({block:`center`}),n.setAttribute(`tabindex`,`-1`),n.focus({preventScroll:!0}))},[e.activeSession.activeSessionId,e.activeSession.approvals,e.activeSession.questions,e.activeSession.turnAttentions]);let Pt=e.activeSession.approvals.filter(t=>!t.sessionId||t.sessionId===e.activeSession.activeSessionId),It=e.activeSession.questions.filter(t=>!t.sessionId||t.sessionId===e.activeSession.activeSessionId),Rt=e.activeSession.turnAttentions.find(t=>t.sessionId===e.activeSession.activeSessionId),zt=Pt.length+It.length+ +!!Rt;(0,W.useEffect)(()=>{zt>0&&x(!1)},[zt]);let Bt=(0,W.useRef)(null),Vt=[Pt[0]?.id,It[0]?.id,Rt?.sessionId].filter(Boolean).join(`:`);(0,W.useEffect)(()=>{Vt&&requestAnimationFrame(()=>Bt.current?.querySelector(`[data-attention-card]`)?.focus())},[Vt]);let Ht=!R.direct&&!R.solo&&!e.connection.signedIn,tn=(0,W.useSyncExternalStore)(or,sr),nn=!R.direct&&e.connection.signedIn&&!e.connection.currentNodeId,rn=!e.activeSession.activeSessionId&&e.sessionIndex.sessions.length===0,[an,sn]=(0,W.useState)(on),[cn,ln]=(0,W.useState)($t),[un,dn]=(0,W.useState)(null),[fn,pn]=(0,W.useState)(null),mn=k&&!R.direct&&e.connection.signedIn&&rn;(0,W.useEffect)(()=>{if(!mn)return;let e=!0;return R.centralGithubApp().then(t=>{e&&dn(t.managedComputeAvailable===!0)},()=>{e&&dn(!1)}),()=>{e=!1}},[mn]);let hn=(0,W.useCallback)(()=>{en(`cloud`),sn(`cloud`),pn({}),R.startCloudOnboarding().then(()=>pn(null),e=>pn({error:e instanceof Error?e.message:String(e)}))},[]),gn=nn&&un===!0&&an!==`own`&&!e.connection.nodes.some(e=>!e.id.startsWith(`eph-`)),_n=gn||fn?`Get started`:`Connect a Machine`,vn=(0,W.useCallback)(e=>{if(e===`cloud`)return hn();en(`own`),sn(`own`)},[hn]);if(Ht||tn)return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Dc,{onDismiss:Ht?void 0:lr}),(0,G.jsxs)(`div`,{className:`toast-stack`,children:[(0,G.jsx)(au,{}),(0,G.jsx)(wc,{})]})]});let yn=z?Re.get(z.sessionId)??Ft(z.source):null,bn=z?.forkedFrom?(()=>{let t=e.sessionIndex.sessions.find(e=>e.sessionId===z.forkedFrom);return{sessionId:z.forkedFrom,name:t?.name,nodeId:t?.nodeId,openable:!!t}})():void 0,xn=z?.nodeId||e.connection.currentNodeId||void 0,Sn=e.connection.nodes.find(e=>e.id===xn),Cn=Sn?`${Sn.name||Sn.id} (${Sn.id})`:xn,wn=!!(z?.source&&String(z.source).startsWith(`repo:`)),Tn=A.wide&&z&&!nn?A.tab:null,En=El(e.activeSession.changesHistory),Dn=!A.wide&&!!z&&!nn&&En>0&&!Ce,On=Dn&&b,kn=()=>{A.show(`changes`)||x(!0)},An=[...gt?[`chat`,`terminal`]:Dn?[`chat`]:[],...Dn?[`changes`]:[]],jn=e=>{x(e===`changes`),e!==`changes`&&ht(e)},Mn=()=>{A.show(`artifacts`)||w(!0)};return(0,G.jsxs)(`div`,{className:`app${Tn?` has-pane`:``}`,children:[(0,G.jsxs)(`div`,{ref:o,className:`sidebar${i?` open`:``}`,role:i?`dialog`:`complementary`,"aria-modal":i?`true`:void 0,"aria-label":`Sessions and workspace`,tabIndex:i?-1:void 0,children:[(0,G.jsxs)(`div`,{className:`sidebar-head`,children:[(0,G.jsx)(`span`,{className:`brand`,children:`Bivy`}),(0,G.jsx)(`div`,{className:`sidebar-head-actions`,children:(0,G.jsx)(`button`,{className:`btn ghost icon only-mobile sidebar-close`,onClick:Ge,"aria-label":`Close sessions`,children:(0,G.jsx)(tt,{})})})]}),(0,G.jsx)(Lt,{runEvidence:Le,sessionSources:Re,automationsActive:!!h,onOpenTerminal:Ct,terminalDisabled:!Ze,onOpenAutomations:()=>{$n(),Ge()},libraryActive:g,onOpenLibrary:e=>{Ic(e),Ge()},onPick:(t,n,r)=>{let i=R.selectSessionTarget(t);we(null),Ge();let a=e.sessionIndex.sessions.find(e=>e.sessionId===t);if(a&&Kt(a)){Et(t,r,i);return}if(a&&B(a)){R.findLiveRunTerminal(t,r).then(e=>{R.isCurrentSessionTarget(t,i)&&(e?Tt(e.termId,e.nodeId??r,t,i):R.openSessionOnNode(t,n,r))}).catch(e=>{R.isCurrentSessionTarget(t,i)&&R.store.setError(e instanceof Error?e.message:String(e))});return}R.openSessionOnNode(t,n,r)},onPickTerminal:Tt}),(0,G.jsxs)(`div`,{className:`sidebar-foot`,children:[(0,G.jsxs)(`button`,{className:`btn primary new-session-btn`,onClick:()=>{we(null),R.newSession(),Ge()},children:[(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,G.jsx)(`path`,{d:`M12 20h9`}),(0,G.jsx)(`path`,{d:`M16.4 3.6a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`})]}),(0,G.jsx)(`span`,{children:`New session`})]}),(0,G.jsx)(`button`,{className:`btn icon settings-gear`,onClick:()=>{Zt(),Ge()},title:`Settings`,"aria-label":`Settings`,children:(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`20`,height:`20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,G.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,G.jsx)(`path`,{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z`})]})})]})]}),i&&(0,G.jsx)(`div`,{className:`scrim`,onClick:Ge}),(0,G.jsxs)(`main`,{ref:s,className:`main${nn?` needs-node`:``}${On?` changes-section`:``}`,children:[(0,G.jsxs)(`header`,{className:`topbar`,children:[(0,G.jsxs)(`button`,{ref:c,className:`btn ghost icon only-mobile burger-btn`,onClick:We,"aria-label":Ue?`Open sessions — something needs your attention`:`Open sessions`,children:[`☰`,Ue&&(0,G.jsx)(`span`,{className:`attn-indicator`,"aria-hidden":!0,children:(0,G.jsx)(qt,{status:`needs-action`})})]}),(0,G.jsxs)(`div`,{className:`topbar-title`,children:[(0,G.jsx)(`div`,{className:`topbar-title-row`,children:(0,G.jsx)(`h1`,{className:`title`,title:nn?_n:e.activeSession.activeTitle,children:nn?_n:e.activeSession.activeTitle})}),(yt||An.length>1)&&(0,G.jsxs)(`div`,{className:`topbar-subline`,children:[yt&&(vt?(0,G.jsx)(kc,{}):(0,G.jsx)(Oc,{})),An.length>1&&(0,G.jsx)(Su,{views:An,value:On?`changes`:gt?mt:`chat`,onChange:jn,changes:En})]})]}),(0,G.jsxs)(`div`,{className:`topbar-actions`,children:[A.wide&&z&&!nn&&(0,G.jsx)(`button`,{className:`btn ghost icon side-pane-toggle`,onClick:()=>A.setTab(Tn?null:`changes`),"aria-pressed":!!Tn,"aria-label":Tn?`Hide side pane`:`Show changes, files, apps, artifacts and terminal`,title:Tn?`Hide side pane`:`Show changes, files, apps, artifacts and terminal`,children:(0,G.jsx)(qe,{size:18})}),e.activeSession.activeSessionId&&!_t&&!On&&(0,G.jsxs)(`button`,{className:`btn ghost focus-view-btn`,onClick:Xe,title:Je?`Focus view on — show full transcript`:`Focus view — show only prompts and final answers`,"aria-label":Je?`Show full transcript`:`Show only prompts and final answers`,"aria-pressed":Je,children:[Je?(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,G.jsx)(`path`,{d:`M9.88 9.88a3 3 0 1 0 4.24 4.24`}),(0,G.jsx)(`path`,{d:`M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68`}),(0,G.jsx)(`path`,{d:`M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61`}),(0,G.jsx)(`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`})]}):(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,G.jsx)(`path`,{d:`M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7z`}),(0,G.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]}),(0,G.jsx)(`span`,{className:`focus-view-label`,children:Je?`Focused`:`Focus`})]}),e.activeSession.activeSessionId&&(0,G.jsx)(sl,{sessionId:e.activeSession.activeSessionId,name:e.activeSession.activeTitle,isRepo:wn,node:Cn,agent:z?.agentName||z?.runtimeId,workspace:z?.workspace,worktree:z?.worktree,branch:z?.branch,sessionFile:z?.path,auditHealth:z?.auditHealth,eventLogHealth:z?.eventLogHealth,onBrowseFiles:z&&!nn?()=>{A.show(`files`)||E(!0)}:void 0})]})]}),(e.connection.status===`pairing`||e.connection.status===`linking`)&&(0,G.jsxs)(`div`,{className:`banner`,"data-tone":`neutral`,role:`status`,children:[(0,G.jsx)(V,{size:`xs`}),`Linking this device…`]}),e.connection.nodeUpdate&&!z?.pendingLaunch&&(0,G.jsxs)(`div`,{className:`banner`,"data-tone":`accent`,role:`status`,children:[(0,G.jsxs)(`span`,{className:`banner-text`,children:[`This machine runs Bivy `,e.connection.nodeUpdate.current,` — `,e.connection.nodeUpdate.latest,` is available.`]}),(0,G.jsx)(`button`,{className:`btn sm primary banner-action`,onClick:()=>R.updateNode(),disabled:e.connection.nodeUpdating,children:e.connection.nodeUpdating?`Updating…`:`Update this machine`})]}),!nn&&!e.draft.ephemeralConfig&&!e.activeSession.activeSessionId&&e.activeSession.transcript.length===0&&e.sessionIndex.sessions.length===0&&(0,G.jsx)(W.Suspense,{fallback:null,children:cn?$e.activated?(0,G.jsx)(du,{machineName:e.connection.nodes.find(t=>t.id===e.connection.currentNodeId)?.name||void 0,onOpenApp:e=>{j.current=!0,Be(!0),R.sendPrompt(su(e),void 0,{workspace:e.project,repo:void 0,branch:void 0})},onFirstChange:()=>{Be(!0),R.sendPrompt(cu)}}):(0,G.jsx)(Fu,{activation:$e,onRemediate:{connect_machine:()=>document.querySelector(`.node-switcher-btn`)?.click(),install_agent:()=>document.querySelector(`.agent-pill`)?.click(),authenticate_credential:()=>document.querySelector(`.model-pill`)?.click(),grant_repository:()=>document.querySelector(`.repo-pill`)?.click()}}):(0,G.jsx)(hu,{state:e,place:an,startError:fn?.error,onRetry:hn,onDone:()=>ln(!0)})}),nn&&(0,G.jsx)(`div`,{className:`connect-runner-scroll`,children:fn?(0,G.jsx)(hu,{state:e,place:`cloud`,startError:fn.error,onRetry:hn,onDone:()=>ln(!0)}):gn?(0,G.jsx)(_u,{onChoose:vn}):mn&&un===null?null:(0,G.jsx)(mu,{nodes:e.connection.nodes,onPickNode:e=>R.switchNode(e),onRefresh:()=>R.refreshNodes(),onUseCloud:un===!0?hn:void 0})}),Ce&&!me?(()=>{let t=e.sessionIndex.runTerminals.find(e=>e.termId===Ce.termId),n=t?.name||t?.label||t?.agent||`Terminal session`,r=e.connection.nodes.find(e=>e.id===(t?.nodeId||Ce.nodeId)),i=!!t?.sessionId||Ya(t?.agent,e.catalogs.runtimes),a=t?.sessionId||Ce.termId,o=e.activeSession.questions.filter(e=>e.sessionId===a);return(0,G.jsx)(cl,{sessionId:t?.sessionId,sessionName:n,nodeLabel:r?.name,online:e.connection.status!==`offline`,onOpenTerminal:Ot,onUseChat:i?At:void 0,children:o.length>0&&(0,G.jsx)(`div`,{className:`tui-locked-attention`,role:`region`,"aria-live":`polite`,"aria-label":`Agent needs your response`,children:(0,G.jsx)(lc,{questions:o,onAnswer:(e,t,n)=>R.answerQuestion(e,t,n),onCancel:(e,t)=>R.cancelQuestion(e,t)})})})})():_t?(0,G.jsx)(W.Suspense,{fallback:null,children:(0,G.jsx)(Pu,{embedded:!0,tui:!0,sessionId:dt,onClose:()=>ht(`chat`)},dt)}):st?(0,G.jsx)(cl,{sessionId:e.activeSession.activeSessionId??void 0,sessionName:e.activeSession.activeTitle,nodeLabel:Sn?.name,online:e.connection.status!==`offline`,onOpenTerminal:jt,onUseChat:Mt}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)($s,{entries:e.activeSession.transcript,working:e.activeSession.working,workingLabel:e.activeSession.workingLabel,draftRoute:!e.activeSession.activeSessionId,greeting:e.sessionIndex.sessions.length>0?`What should we work on?`:void 0,opening:e.activeSession.opening,sessionKey:e.activeSession.activeSessionId,focusView:Je,onAction:xt,authAction:St,header:z?.launchProgress?(0,G.jsx)(rc,{progress:z.launchProgress,onChooseModel:e=>R.chooseLaunchModel(z.sessionId,e),onRefreshModels:()=>R.refreshLaunchModels(z.sessionId),onSetupCredentials:async()=>{try{await R.setupManagedCredentials()}catch(e){R.store.setError(e instanceof Error?e.message:String(e))}},onRetryLaunch:z.pendingLaunch?async()=>{try{await R.retryPendingLaunch(z.sessionId)}catch(e){R.store.setError(e instanceof Error?e.message:String(e))}}:void 0}):void 0,footer:(0,G.jsxs)(`div`,{className:`attention-footer`,ref:Bt,role:`region`,"aria-live":`polite`,"aria-label":`Agent needs your response`,children:[(0,G.jsx)(oc,{approvals:Pt,onResolve:(e,t,n)=>R.resolveApproval(e,t,n)}),(0,G.jsx)(lc,{questions:It,onAnswer:(e,t,n)=>R.answerQuestion(e,t,n),onCancel:(e,t)=>R.cancelQuestion(e,t)}),Rt&&(0,G.jsx)(uc,{attention:Rt,onResolve:(e,t)=>R.resolveTurnAttention(e,t)})]})}),z&&(0,G.jsx)(pu,{working:e.activeSession.working,machineName:Sn?.name||void 0,onOpenChange:it}),et&&z&&!u&&!nt&&(0,G.jsxs)(`section`,{className:`card next-step`,"aria-label":`Next step`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:`Make this repeatable`}),(0,G.jsx)(`p`,{children:`Create an automation to run work without you.`})]}),(0,G.jsxs)(`div`,{className:`next-step-actions`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn sm primary`,onClick:()=>{localStorage.setItem(`bivy:automation-next-step`,`done`),f(!0),$n()},children:`Open Automations`}),(0,G.jsx)(`button`,{type:`button`,className:`btn sm ghost`,"aria-label":`Dismiss`,onClick:()=>{localStorage.setItem(`bivy:automation-next-step`,`done`),f(!0)},children:`Dismiss`})]})]}),T&&!A.wide&&z&&(0,G.jsx)($l,{sessionId:z.sessionId,refreshKey:e.activeSession.changesHistory.length,onClose:()=>E(!1)}),C&&!A.wide&&(0,G.jsx)(Fi,{artifacts:ue,onClose:()=>w(!1)}),D&&!A.wide&&D.sessionId===z?.sessionId&&(0,G.jsx)(Ti,{...D,onClose:()=>O(null)},`${D.sessionId}:${D.appId??``}:${D.openView?.viewId??``}:${D.openView?.scenario??``}`),M&&z&&(0,G.jsx)(il,{sessionId:z.sessionId,onClose:()=>te(!1)}),(0,G.jsxs)(`div`,{className:`composer-gh`,children:[z&&yn?(0,G.jsx)(Cl,{anchorId:`attention-${z.sessionId}`,source:yn,statusClass:Wt(z),statusLabel:Dt(z),gh:e.activeSession.github,evidence:Le.get(z.sessionId),finishedAt:z.finishedAt,usage:e.activeSession.usage,forkedFrom:bn,delegatedFrom:z?.delegatedFrom,filesEdited:El(e.activeSession.changesHistory),onOpenChanges:kn,artifactsCount:ue.length,onOpenArtifacts:Mn,onOpenRun:e=>Wc(e),onRecover:e=>{let t=z.sessionId,n=Le.get(t),r=n?Ut(n):[];if(e===`fork`){R.forkSession(t);return}if(e===`fix`){R.sendPrompt(r.length?`The deterministic checks failed (${r.join(`, `)}). Please investigate the failures and fix them, then confirm the checks pass.`:`This run did not finish cleanly. Please investigate what went wrong and fix it.`);return}R.sendPrompt(r.length?`Please re-run the ${r.join(`, `)} check(s) and address anything that still fails.`:`Please re-run the project checks and address anything that fails.`)}}):(0,G.jsx)(fl,{gh:e.activeSession.github}),z&&(0,G.jsx)(wl,{apps:F.published??fe.length,serverPorts:F.offers.map(e=>e.port),newNotes:I,onOpen:()=>{A.show(`apps`)||O({sessionId:z.sessionId})}})]}),(0,G.jsx)(vu,{status:e.connection.status,hasCachedTranscript:e.activeSession.transcript.length>0,machineName:Sn?.name||void 0}),(0,G.jsx)(Ja,{state:e,disabled:!bt,disabledHint:e.connection.status===`offline`?Sn?.name?`${Sn.name} is offline — run \`bivy status\` there`:"Machine offline — run `bivy status` on it":Sn?.name?`Connecting to ${Sn.name}…`:`Connecting…`,working:e.activeSession.working,onSend:(t,n)=>{e.connection.status!==`online`&&ye(),Be(!0),R.sendPrompt(t,n)},onAbort:()=>R.abort(),onError:e=>R.store.setError(e)})]}),On&&(0,G.jsx)(`div`,{className:`main-changes`,children:(0,G.jsx)(Dl,{docked:!0,history:e.activeSession.changesHistory,checks:z?Le.get(z.sessionId)?.checks?.map(e=>({name:e.name,status:e.status})):void 0,onClose:()=>x(!1),onComposerFilled:()=>x(!1)})})]}),Tn&&z&&(0,G.jsxs)(Ou,{tabs:[{id:`changes`,label:`Changes`,count:En},{id:`files`,label:`Files`},{id:`apps`,label:`Apps`,count:F.published??fe.length},{id:`artifacts`,label:`Artifacts`,count:ue.length},{id:`terminal`,label:`Terminal`}],active:Tn,onSelect:e=>{O(null),A.setTab(e)},onClose:()=>A.setTab(null),children:[Tn===`changes`&&(0,G.jsx)(Dl,{docked:!0,history:e.activeSession.changesHistory,checks:Le.get(z.sessionId)?.checks?.map(e=>({name:e.name,status:e.status})),onClose:()=>A.setTab(null)}),Tn===`files`&&(0,G.jsx)($l,{docked:!0,sessionId:z.sessionId,refreshKey:e.activeSession.changesHistory.length,onClose:()=>A.setTab(null)},z.sessionId),Tn===`apps`&&(()=>{let e=D?.sessionId===z.sessionId?D:{sessionId:z.sessionId};return(0,G.jsx)(Ti,{docked:!0,...e,onClose:()=>O(null)},`${e.sessionId}:${e.appId??``}:${e.openView?.viewId??``}:${e.openView?.scenario??``}`)})(),Tn===`artifacts`&&(0,G.jsx)(Fi,{docked:!0,artifacts:ue,onClose:()=>A.setTab(null)}),Tn===`terminal`&&(0,G.jsx)(W.Suspense,{fallback:null,children:(0,G.jsx)(Pu,{embedded:!0,sessionId:z.sessionId,onClose:()=>A.setTab(`changes`)},z.sessionId)})]}),h&&(0,G.jsx)(W.Suspense,{fallback:null,children:(0,G.jsx)(Lu,{state:e,section:h.section,onSectionChange:er,githubQueue:De,onRefreshGithubQueue:Fe,onOpenRun:t=>{nr(e.activeSession.activeSessionId?{kind:`session`,id:e.activeSession.activeSessionId}:{kind:`new`}),Wc(t)},onClose:()=>nr(e.activeSession.activeSessionId?{kind:`session`,id:e.activeSession.activeSessionId}:{kind:`new`}),onOpenSession:t=>{let n=e.sessionIndex.sessions.find(e=>e.sessionId===t);R.openSessionOnNode(t,n?.path,n?.nodeId),nr({kind:`session`,id:t}),Ge()}})}),g&&(0,G.jsx)(W.Suspense,{fallback:null,children:(0,G.jsx)(Ru,{view:g,onClose:()=>Lc(e.activeSession.activeSessionId?{kind:`session`,id:e.activeSession.activeSessionId}:{kind:`new`}),onShowInChat:(t,n,r)=>{_s(t,n),Lc({kind:`session`,id:t});let i=e.sessionIndex.sessions.filter(e=>e.sessionId===t),a=i.find(e=>e.nodeId===r)??i[0];R.openSessionOnNode(t,a?.path,r??a?.nodeId),Ge()}})}),_&&(0,G.jsx)(tl,{runId:_.runId,load:e=>le(R.local,e),onCancel:async e=>{await ce(R.local,e),Fe()},onRetry:async e=>{await he(R.local,e),Fe()},onReauthenticate:async(t,n,r)=>{let i=n||e.connection.currentNodeId;if(!i)throw Error(`The Machine for this Run is not available.`);await R.connectToNode(i),R.store.setNeedsModelAuth({nodeId:i,provider:t,reason:r})},resolveMachineName:t=>e.connection.nodes.find(e=>e.id===t)?.name||void 0,isSessionResolvable:t=>e.sessionIndex.sessions.some(e=>e.sessionId===t),onReceiptReviewed:()=>{je(R.local,`receipt_reviewed`,matchMedia(`(max-width: 700px)`).matches?`mobile`:`desktop`).catch(()=>{})},onOpenSession:t=>{let n=e.sessionIndex.sessions.find(e=>e.sessionId===t);R.openSessionOnNode(t,n?.path,n?.nodeId),Gc({kind:`session`,id:t}),Ge()},onClose:()=>Gc(e.activeSession.activeSessionId?{kind:`session`,id:e.activeSession.activeSessionId}:{kind:`new`})}),p&&(0,G.jsx)(W.Suspense,{fallback:null,children:(0,G.jsx)(Iu,{state:e,view:p.view,onViewChange:Yt,onImported:e=>{Qt({kind:`session`,id:e}),Ge()},onRedirectToAutomations:t=>{Qt(e.activeSession.activeSessionId?{kind:`session`,id:e.activeSession.activeSessionId}:{kind:`new`}),t===`github`||t===`linear`||t===`slack`?$n({setup:t}):t===`queue`||t===`rulesets`?$n({section:t===`queue`?`runs`:t}):$n(),Ge()},onClose:()=>Qt(e.activeSession.activeSessionId?{kind:`session`,id:e.activeSession.activeSessionId}:{kind:`new`})})}),e.presentation.forkProgress&&(0,G.jsx)(Vl,{progress:e.presentation.forkProgress,onClose:()=>R.store.setForkProgress(null)}),e.presentation.needsModelAuth&&(0,G.jsx)(ou,{state:e}),Te&&(0,G.jsx)(ua,{state:e,currentNodeId:e.connection.currentNodeId,onPick:wt,onClose:()=>Ee(!1)}),me&&(0,G.jsx)(W.Suspense,{fallback:null,children:(0,G.jsx)(Pu,{sessionId:L?null:e.activeSession.activeSessionId,attachTermId:_e,standalone:L,tui:xe,onClose:()=>{ge(!1),ve(null),be(!1),Se(!1)}})}),t&&(0,G.jsx)(`div`,{className:`banner`,"data-tone":`accent`,role:`status`,children:t}),(ne||P)&&(0,G.jsx)(Nl,{text:[P?.items.text,ne].filter(Boolean).join(`
|
|
32
|
+
`),lu=4e3,uu=e=>e.split(/[\\/]/).filter(Boolean).pop()||e;function du({machineName:e,onOpenApp:t,onFirstChange:n}){let r=e||`your machine`,[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(!1);(0,W.useEffect)(()=>{let e=!0,t=setTimeout(()=>{e&&a(e=>e??[])},lu);return R.appCommand(`apps.offers`,void 0).then(t=>{let n=t.offers??[];e&&a(e=>e??n.filter(e=>typeof e.project==`string`))},()=>{e&&a([])}),R.direct||R.pushStatus().then(t=>{e&&s(t.supported&&!t.subscribed&&t.permission!==`denied`)},()=>{}),()=>{e=!1,clearTimeout(t)}},[]);let u=async e=>{l(!0),o&&await R.enablePush().catch(()=>{}),e()},[d,...f]=i??[];return(0,G.jsxs)(`section`,{className:`card readiness`,"aria-labelledby":`get-started-title`,"aria-busy":i===null,children:[(0,G.jsx)(`p`,{className:`readiness-passed`,role:`status`,children:`✓ Setup complete`}),i===null?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h2`,{id:`get-started-title`,className:`card-title`,children:`Your agent's first task`}),(0,G.jsxs)(`p`,{className:`card-sub get-started-scan`,role:`status`,children:[(0,G.jsx)(V,{size:`xs`}),`Looking for apps running on `,r,`…`]})]}):d?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`h2`,{id:`get-started-title`,className:`card-title`,children:[`Mark what's wrong in `,uu(d.project)]}),(0,G.jsxs)(`p`,{className:`card-sub`,children:[`It's running on `,r,`. The agent opens it here, you tap what's off, and it fixes it and sends you a link to share. It keeps working when you close this app.`]}),(0,G.jsxs)(`p`,{className:`get-started-app card-sub`,children:[(0,G.jsx)(`code`,{children:d.command}),` · port `,d.port]}),(0,G.jsxs)(`div`,{className:`get-started-actions`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`btn sm primary`,disabled:c,onClick:()=>void u(()=>t(d)),children:[`Open `,uu(d.project),` and mark what's wrong`]}),(0,G.jsx)(`span`,{className:`card-sub`,children:`or type your own task below`})]}),f.length>0&&(0,G.jsxs)(`div`,{className:`get-started-more`,role:`group`,"aria-label":`Other running apps`,children:[(0,G.jsx)(`span`,{className:`card-sub`,children:`Also running:`}),f.slice(0,3).map(e=>(0,G.jsxs)(`button`,{type:`button`,className:`btn sm ghost`,disabled:c,onClick:()=>void u(()=>t(e)),"aria-label":`Open ${uu(e.project)} on port ${e.port} and mark what's wrong`,children:[uu(e.project),` · `,e.port]},e.port))]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h2`,{id:`get-started-title`,className:`card-title`,children:`Give your agent a first task`}),(0,G.jsxs)(`p`,{className:`card-sub`,children:[`It runs on `,r,` and keeps working when you close this app. It'll make one small, useful change here and tell your phone when it's done.`]}),(0,G.jsxs)(`div`,{className:`get-started-actions`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn sm primary`,disabled:c,onClick:()=>void u(n),children:`Make one small improvement`}),(0,G.jsx)(`span`,{className:`card-sub`,children:`or type your own task below`})]})]})]})}var fu=`bivy:notify-offer`;function pu({working:e,machineName:t,onOpenChange:n}){let[r,i]=(0,W.useState)(()=>localStorage.getItem(fu)===`done`),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(!1),[d,f]=(0,W.useState)(null);(0,W.useEffect)(()=>{if(r||a||!e||R.direct)return;let t=!0;return R.pushStatus().then(e=>{t&&o(e.supported&&!e.subscribed&&e.permission!==`denied`)}).catch(()=>{}),()=>{t=!1}},[r,a,e]),(0,W.useEffect)(()=>{if(!l)return;let e=setTimeout(()=>i(!0),5e3);return()=>clearTimeout(e)},[l]);let p=!r&&a;(0,W.useEffect)(()=>n?.(p),[p]);let m=()=>{localStorage.setItem(fu,`done`),i(!0)},h=async()=>{c(!0),f(null);try{await R.enablePush(),localStorage.setItem(fu,`done`),u(!0)}catch(e){f(e instanceof Error?e.message:String(e))}finally{c(!1)}};return p?l?(0,G.jsx)(`section`,{className:`card next-step`,"aria-label":`Notifications`,children:(0,G.jsx)(`p`,{className:`next-step-ok`,role:`status`,children:`✓ Notifications are on. You can close the app; Bivy will let you know.`})}):(0,G.jsxs)(`section`,{className:`card next-step`,"aria-labelledby":`notify-offer-title`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{id:`notify-offer-title`,children:`Get a notification when it's done?`}),(0,G.jsxs)(`p`,{children:[`The agent keeps working on `,t||`your machine`,` if you close this app. Bivy can tell you when it finishes or needs you.`]}),d&&(0,G.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,role:`alert`,children:d})]}),(0,G.jsxs)(`div`,{className:`next-step-actions`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn sm primary`,disabled:s,onClick:()=>void h(),children:s?`Turning on…`:`Turn on notifications`}),(0,G.jsx)(`button`,{type:`button`,className:`btn sm ghost`,disabled:s,onClick:m,children:`Not now`})]})]}):null}function mu({nodes:e,onPickNode:t,onRefresh:n,onUseCloud:r}){let i=e.filter(e=>!e.id.startsWith(`eph-`)),[a,o]=(0,W.useState)(null),s=(0,W.useRef)(i.length===0),c=(0,W.useRef)(!1);return(0,W.useEffect)(()=>{let n=a??(s.current&&e.length===1?e[0]?.id:void 0),r=e.find(e=>e.id===n&&e.online&&!e.id.startsWith(`eph-`));r&&!c.current&&(c.current=!0,t(r.id))},[e,a,t]),(0,G.jsxs)(`section`,{className:`connect-runner`,"aria-labelledby":`connect-runner-title`,children:[(0,G.jsxs)(`div`,{className:`connect-hero compact`,children:[(0,G.jsx)(`h2`,{className:`connect-title`,id:`connect-runner-title`,children:i.length>0?`Choose a Machine`:`Connect a Machine`}),(0,G.jsx)(`p`,{className:`connect-sub`,children:i.length>0?`Pick an online machine to start, or add another machine.`:`Your agents run here, using your existing environment. Keep your repositories, tools, and agent logins.`})]}),(0,G.jsxs)(`div`,{className:`connect-waiting`,role:`status`,children:[(0,G.jsx)(V,{size:`sm`}),(0,G.jsx)(`span`,{className:`connect-waiting-text`,children:i.length>0?`Checking for connected machines automatically…`:`Waiting for your machine. This page updates automatically.`}),(0,G.jsx)(`button`,{type:`button`,className:`btn sm ghost`,onClick:n,children:`Check now`})]}),i.length>0&&(0,G.jsxs)(`div`,{className:`connect-nodes`,children:[(0,G.jsx)(`div`,{className:`connect-nodes-head`,children:`Your machines`}),(0,G.jsx)(`div`,{className:`connect-nodes-list`,children:i.map(e=>(0,G.jsxs)(`button`,{type:`button`,className:`connect-node`,onClick:()=>t(e.id),title:e.online?`Start on this Machine`:`This Machine is offline — selecting it will try to reconnect`,children:[(0,G.jsx)(qt,{status:e.online?`online`:`idle`}),(0,G.jsx)(`span`,{className:`connect-node-name`,children:e.name||e.id}),(0,G.jsx)(`span`,{className:`connect-node-status${e.online?` is-online`:``}`,children:e.online?`Online`:`Offline`}),(0,G.jsx)(`svg`,{className:`connect-node-caret`,viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:(0,G.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]},e.id))})]}),(0,G.jsx)(`div`,{className:`connect-options`,children:(0,G.jsx)(`div`,{className:`connect-option machine-install-card`,children:(0,G.jsx)(mr,{onEnrolled:o})})}),(0,G.jsx)(`p`,{className:`connect-sub`,children:`Next: connect your AI, send your first task, and review the result right here.`}),r&&(0,G.jsx)(`button`,{type:`button`,className:`btn link connect-option-link`,onClick:r,children:`Use Bivy Cloud instead`})]})}function hu({state:e,place:t,startError:n,onRetry:r,onDone:i}){let[a,o]=(0,W.useState)(null),s=e.connection.currentNodeId,c=!!s&&e.connection.status===`online`,l=t===`cloud`||!!s?.startsWith(`eph-`),u=e.connection.nodes.find(e=>e.id===s)?.name||`your computer`,d=e.catalogs.providers,f=e=>d.some(t=>(t.id===e||t.id===E(e))&&t.configured),p=sn.filter(e=>!d.length||d.some(t=>t.id===e.provider)),m=p.filter(e=>f(e.provider)).map(e=>e.provider),h=m.length>0||e.catalogs.activationReadiness?.credential.ok===!0,g=e=>{o(e),R.startOauth(e,void 0,rn(s,t))},_=()=>{let t=nn(e.catalogs.runtimes,e.catalogs.selectedAgentId??``,m);t&&R.chooseAgent(t),cn(),i()};return(0,G.jsxs)(`section`,{className:`card readiness`,"aria-labelledby":`connect-ai-title`,children:[(0,G.jsx)(`h2`,{id:`connect-ai-title`,className:`card-title`,children:`Connect your AI`}),(0,G.jsxs)(`p`,{className:`card-sub`,children:[`Sign in with the plans you already pay for. Connect both to switch agents any time.`,` `,l?`Your sign-in stays encrypted on this cloud computer. Another machine that's online can restore it, and this browser can restore an API key.`:`Your sign-ins stay on ${u}; Bivy's servers never get a copy.`]}),!c&&(n?(0,G.jsxs)(`div`,{className:`banner inline`,"data-tone":`danger`,role:`alert`,children:[(0,G.jsxs)(`span`,{className:`banner-text`,children:[`Bivy Cloud didn't start: `,n]}),(0,G.jsx)(`button`,{type:`button`,className:`btn sm banner-action`,onClick:r,children:`Try again`})]}):(0,G.jsxs)(`p`,{className:`card-sub get-started-scan`,role:`status`,children:[(0,G.jsx)(V,{size:`xs`}),l?`Starting your cloud computer. The first start takes about a minute.`:`Waiting for ${u}…`]})),(0,G.jsx)(`ul`,{className:`ai-accounts`,children:p.map(t=>{let n=f(t.provider),r=a===t.provider&&!n;return(0,G.jsxs)(`li`,{className:`ai-account`,children:[(0,G.jsxs)(`div`,{className:`ai-account-head`,children:[(0,G.jsxs)(`span`,{className:`ai-account-text`,children:[(0,G.jsx)(`span`,{className:`ai-account-name`,children:t.name}),(0,G.jsx)(`span`,{className:`ai-account-plan`,children:t.plan})]}),n?(0,G.jsx)(`span`,{className:`ai-account-ok`,children:`✓ Connected`}):(0,G.jsxs)(`span`,{className:`ai-account-actions`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn sm ghost`,disabled:!c,"aria-expanded":r,onClick:()=>o(r?null:t.provider),children:`API key`}),(0,G.jsxs)(`button`,{type:`button`,className:`btn sm primary`,disabled:!c,onClick:()=>g(t.provider),children:[`Sign in`,(0,G.jsxs)(`span`,{className:`sr-only`,children:[` with `,t.name]})]})]})]}),r&&(0,G.jsx)(an,{state:e,providerId:t.provider,apiKeyProvider:E(t.provider)===t.provider?void 0:E(t.provider),keyOnly:!0})]},t.provider)})}),(0,G.jsxs)(`div`,{className:`get-started-actions`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn sm primary`,disabled:!h,onClick:_,children:`Continue`}),!h&&c&&(0,G.jsx)(`button`,{type:`button`,className:`btn sm ghost`,onClick:_,children:`Set up later`})]})]})}var gu=[{place:`cloud`,name:`Bivy Cloud`,detail:`Nothing to install. Agents keep working when your laptop is closed.`},{place:`own`,name:`My own computer`,detail:`Your files, tools and logins. Your AI sign-ins stay on that computer.`}];function _u({onChoose:e}){return(0,G.jsxs)(`section`,{className:`connect-runner`,"aria-labelledby":`place-choice-title`,children:[(0,G.jsxs)(`div`,{className:`connect-hero compact`,children:[(0,G.jsx)(`h2`,{className:`connect-title`,id:`place-choice-title`,children:`Where should your agents run?`}),(0,G.jsx)(`p`,{className:`connect-sub`,children:`You can add the other one later.`})]}),(0,G.jsx)(`div`,{className:`connect-nodes-list`,children:gu.map(({place:t,name:n,detail:r})=>(0,G.jsxs)(`button`,{type:`button`,className:`connect-node`,onClick:()=>e(t),children:[(0,G.jsxs)(`span`,{className:`connect-node-text`,children:[(0,G.jsx)(`span`,{className:`connect-node-name`,children:n}),(0,G.jsx)(`span`,{className:`connect-node-detail`,children:r})]}),(0,G.jsx)(`svg`,{className:`connect-node-caret`,viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:(0,G.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]},t))})]})}function vu({status:e,hasCachedTranscript:t,machineName:r}){let i=(0,W.useSyncExternalStore)(Re,Oe),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(()=>typeof navigator<`u`&&!navigator.onLine);(0,W.useEffect)(()=>{let e=()=>c(!0),t=()=>c(!1);return window.addEventListener(`offline`,e),window.addEventListener(`online`,t),()=>{window.removeEventListener(`offline`,e),window.removeEventListener(`online`,t)}},[]);let l=ge(s?`offline`:e,t,i,r),u=l.kind!==`live-control`,d=!n&&i.installChoice!==null&&!i.standalone;return!u&&!d?null:(0,G.jsxs)(G.Fragment,{children:[u&&(0,G.jsx)(`aside`,{className:`pwa-lifecycle`,"aria-label":`App availability`,children:(0,G.jsxs)(`div`,{className:`pwa-lifecycle-copy`,"data-availability":l.kind,children:[(0,G.jsx)(`strong`,{children:l.label}),(0,G.jsx)(`span`,{children:l.detail})]})}),d&&(0,G.jsxs)(`aside`,{className:`pwa-install`,"aria-label":`Install Bivy`,children:[(0,G.jsx)(`button`,{type:`button`,className:`pwa-install-dismiss`,onClick:_e,"aria-label":`Dismiss install suggestion`,title:`Don't show again`,children:`×`}),(0,G.jsxs)(`div`,{className:`pwa-install-copy`,children:[(0,G.jsx)(`strong`,{children:`Install Bivy`}),(0,G.jsx)(`span`,{children:`Open Bivy in a dedicated window and return to this device more reliably.`})]}),(0,G.jsx)(`div`,{className:`pwa-install-actions`,children:i.installChoice===`native`?(0,G.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:()=>void L(),children:`Install`}):(0,G.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:()=>o(e=>!e),children:`How to install`})}),a&&i.installChoice===`ios`&&(0,G.jsxs)(`p`,{role:`status`,children:[`In Safari, tap Share, then `,(0,G.jsx)(`strong`,{children:`Add to Home Screen`}),`, then Add. Other iOS browsers cannot install Bivy directly.`]}),a&&i.installChoice===`safari`&&(0,G.jsxs)(`p`,{role:`status`,children:[`On macOS Sonoma or later, choose `,(0,G.jsx)(`strong`,{children:`File → Add to Dock`}),` in Safari 17 or later. Older macOS Safari versions cannot install Bivy as a web app.`]})]})]})}function yu(e,t=document,n=window){let r=()=>{t.visibilityState===`visible`&&e()};return t.addEventListener(`visibilitychange`,r),n.addEventListener(`pageshow`,r),n.addEventListener(`focus`,r),()=>{t.removeEventListener(`visibilitychange`,r),n.removeEventListener(`pageshow`,r),n.removeEventListener(`focus`,r)}}function bu({onOpen:e,onClose:t,isOpen:n,maxWidth:r=720,edge:i=28,threshold:a=60}){let o=(0,W.useRef)(e),s=(0,W.useRef)(t);o.current=e,s.current=t,(0,W.useEffect)(()=>{let e=0,t=0,c=!1,l=!1,u=!1,d=a=>{if(u=!1,a.touches.length!==1||window.innerWidth>r){c=!1;return}let o=a.touches[0];if(!o){c=!1;return}e=o.clientX,t=o.clientY,l=e<=i,c=l||n},f=r=>{if(!c||r.touches.length!==1)return;let i=r.touches[0];if(!i)return;let a=i.clientX-e,o=i.clientY-t;if(!u){if(Math.abs(o)>Math.abs(a)&&Math.abs(o)>6){c=!1;return}Math.abs(a)>Math.abs(o)&&Math.abs(a)>2&&(!n&&l||n&&a<0)&&(u=!0)}u&&r.cancelable&&r.preventDefault()},p=r=>{if(!c)return;c=!1,u=!1;let i=r.changedTouches[0];if(!i)return;let d=i.clientX-e,f=i.clientY-t;Math.abs(d)<=Math.abs(f)||Math.abs(d)<a||(!n&&l&&d>0?o.current():n&&d<0&&s.current())};return window.addEventListener(`touchstart`,d,{passive:!0}),window.addEventListener(`touchmove`,f,{passive:!1}),window.addEventListener(`touchend`,p,{passive:!0}),()=>{window.removeEventListener(`touchstart`,d),window.removeEventListener(`touchmove`,f),window.removeEventListener(`touchend`,p)}},[n,r,i,a])}var xu={chat:{label:`Chat`,Icon:Ze},terminal:{label:`Terminal`,Icon:it},changes:{label:`Changes`,Icon:Je}};function Su({views:e,value:t,onChange:n,changes:r=0}){let i=(0,W.useRef)([]),a=(t,r)=>{let a=t.key===`ArrowRight`?1:t.key===`ArrowLeft`?-1:0;if(!a)return;t.preventDefault();let o=(r+a+e.length)%e.length,s=e[o];s&&(n(s),i.current[o]?.focus())};return(0,G.jsx)(`div`,{className:`segmented session-view-toggle`,role:`radiogroup`,"aria-label":`Session view`,children:e.map((e,o)=>{let{label:s,Icon:c}=xu[e],l=e===`changes`&&r>0?r:null;return(0,G.jsxs)(`button`,{ref:e=>{i.current[o]=e},type:`button`,role:`radio`,className:`seg-btn`,"aria-checked":t===e,tabIndex:t===e?0:-1,onClick:()=>n(e),onKeyDown:e=>a(e,o),"aria-label":l?`${s}, ${l} file${l===1?``:`s`}`:s,title:s,children:[(0,G.jsx)(c,{size:14,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`session-view-label`,children:s}),l&&(0,G.jsx)(`span`,{className:`seg-count`,"aria-hidden":`true`,children:l})]},e)})})}var Cu=`bivy.sessionView`,wu=50;function Tu(e){try{let t=JSON.parse(e.getItem(Cu)||`{}`);return t&&typeof t==`object`?t:{}}catch{return{}}}function Eu(e,t){return t&&Tu(e)[t]===`terminal`?`terminal`:`chat`}function Du(e,t,n){let r=Tu(e);delete r[t],n!==`chat`&&(r[t]=n);let i=Object.keys(r);for(let e of i.slice(0,Math.max(0,i.length-wu)))delete r[e];try{e.setItem(Cu,JSON.stringify(r))}catch{}}function Ou({tabs:e,active:t,onSelect:n,onClose:r,children:i}){let a=(0,W.useRef)([]),o=(t,r)=>{let i=t.key===`ArrowRight`?1:t.key===`ArrowLeft`?-1:0;if(!i)return;t.preventDefault();let o=(r+i+e.length)%e.length,s=e[o];s&&(n(s.id),a.current[o]?.focus())};return(0,G.jsxs)(`aside`,{className:`side-pane`,"aria-label":`Session details`,children:[(0,G.jsxs)(`div`,{className:`side-pane-head`,children:[(0,G.jsx)(`div`,{className:`segmented side-pane-tabs`,role:`tablist`,"aria-label":`Session details`,children:e.map((e,r)=>(0,G.jsxs)(`button`,{ref:e=>{a.current[r]=e},type:`button`,role:`tab`,id:`side-pane-tab-${e.id}`,"aria-controls":`side-pane-body`,"aria-selected":t===e.id,tabIndex:t===e.id?0:-1,className:`seg-btn side-pane-tab`,onClick:()=>n(e.id),onKeyDown:e=>o(e,r),children:[e.label,e.count?(0,G.jsx)(`span`,{className:`seg-count`,children:e.count}):null]},e.id))}),(0,G.jsx)(`button`,{type:`button`,className:`btn ghost icon side-pane-close`,onClick:r,"aria-label":`Hide side pane`,title:`Hide side pane`,children:(0,G.jsx)(tt,{size:18})})]}),(0,G.jsx)(`div`,{className:`side-pane-body`,id:`side-pane-body`,role:`tabpanel`,"aria-labelledby":`side-pane-tab-${t}`,children:i})]})}var ku=`(min-width: 1200px)`,Au=`bivy.sidePane`,ju=new Set([`changes`,`files`,`apps`,`artifacts`,`terminal`]);function Mu(){try{let e=localStorage.getItem(Au);return e&&ju.has(e)?e:null}catch{return null}}function Nu(){let e=qi(ku),[t,n]=(0,W.useState)(Mu),r=(0,W.useCallback)(e=>{n(e);try{e?localStorage.setItem(Au,e):localStorage.removeItem(Au)}catch{}},[]);return{wide:e,tab:t,setTab:r,show:(0,W.useCallback)(t=>e?(r(t),!0):!1,[e,r])}}var Pu=(0,W.lazy)(()=>C(()=>import(`./Terminal-DrqMIIhr.js`).then(e=>({default:e.TerminalOverlay})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),Fu=(0,W.lazy)(()=>C(()=>import(`./ReadinessChecklist-Bbgq2GQ8.js`).then(e=>({default:e.ReadinessChecklist})),__vite__mapDeps([37,5,1]))),Iu=(0,W.lazy)(()=>C(()=>import(`./Settings-DrK5DKuy.js`).then(e=>({default:e.Settings})),__vite__mapDeps([38,3,4,2,1,5,6,39]))),Lu=(0,W.lazy)(()=>C(()=>import(`./AutomationsView-Cw3-fec-.js`).then(e=>({default:e.AutomationsView})),__vite__mapDeps([40,1,3,4,2,5,6,41,8]))),Ru=(0,W.lazy)(()=>C(()=>import(`./LibraryView-D3uu06xU.js`).then(e=>({default:e.LibraryView})),__vite__mapDeps([42,2,1,3,4,5,6,41,8]))),zu=`a[href],button:not(:disabled),textarea:not(:disabled),input:not(:disabled),select:not(:disabled),[tabindex]:not([tabindex="-1"])`;function Bu(e,t){return t?e.needsAction||e.status===`needs_action`?t.question_asked||t.approval_requested:e.status===`failed`?t.session_error:Ot(e)?t.session_done:!1:!0}function Vu(){let e=Me(),t=Bl(),n=(0,W.useSyncExternalStore)(Wi,Hi),r=(0,W.useSyncExternalStore)(Wi,Gi),[i,a]=(0,W.useState)(!1),o=(0,W.useRef)(null),s=(0,W.useRef)(null),c=(0,W.useRef)(null),[u,f]=(0,W.useState)(()=>localStorage.getItem(`bivy:automation-next-step`)===`done`),p=(0,W.useSyncExternalStore)(Jt,Xt),h=(0,W.useSyncExternalStore)(Zn,Qn),g=(0,W.useSyncExternalStore)(Pc,Fc),_=(0,W.useSyncExternalStore)(Hc,Uc),v=e.presentation.githubApp?.returning;(0,W.useEffect)(()=>{v&&$n({setup:`github`})},[v]);let[b,x]=(0,W.useState)(!1);(0,W.useEffect)(()=>x(!1),[e.activeSession.activeSessionId]);let[C,w]=(0,W.useState)(!1),[T,E]=(0,W.useState)(!1),[D,O]=(0,W.useState)(null);(0,W.useEffect)(()=>po(O),[]);let A=Nu(),ee=A.show;(0,W.useEffect)(()=>{D&&ee(`apps`)},[D,ee]),(0,W.useEffect)(()=>O(null),[e.activeSession.activeSessionId]);let j=(0,W.useRef)(!1);(0,W.useEffect)(()=>{let t=e.activeSession.activeSessionId;if(!j.current||!t)return;j.current=!1;let n=!1;return R.onAppsChanged(e=>{n||e!==t||R.appCommand(`apps.list`,t).then(e=>{let r=e.apps.find(e=>e.views.some(e=>e.kind===`web`)),i=r?.views.find(e=>e.kind===`web`);!n&&r&&i&&(n=!0,O({sessionId:t,appId:r.id,openView:{viewId:i.id}}))},()=>{})})},[e.activeSession.activeSessionId]);let[M,te]=(0,W.useState)(!1),[ne,re]=(0,W.useState)(()=>l(sessionStorage)),N=(0,W.useCallback)(()=>R.listMachineApps(),[]),[P,ae]=(0,W.useState)(null);(0,W.useEffect)(()=>{let e=y(sessionStorage);e&&Rl(e).then(t=>{t?ae({id:e,items:t}):m(sessionStorage)},()=>m(sessionStorage))},[]);let[oe,se]=(0,W.useState)(null);(0,W.useEffect)(()=>{if(!oe||(e.activeSession.activeSessionId??null)!==oe.sessionId)return;let t=0,n,r=()=>{R.prefillComposer(oe.text,oe.attachments)?(zl(oe.inbox),se(null)):++t<50&&(n=setTimeout(r,100))};return n=setTimeout(r,0),()=>clearTimeout(n)},[oe,e.activeSession.activeSessionId]);let ue=(0,W.useMemo)(()=>Un(e.activeSession.transcript),[e.activeSession.transcript]),fe=(0,W.useMemo)(()=>Wn(e.activeSession.transcript),[e.activeSession.transcript]),pe=e.sessionIndex.sessions.find(t=>t.sessionId===e.activeSession.activeSessionId),F=tu(pe?.sessionId,pe?Wt(pe)===`working`:!1),I=Vr(pe?.sessionId,F.noteTimes),[me,ge]=(0,W.useState)(!1),[_e,ve]=(0,W.useState)(null),[L,be]=(0,W.useState)(!1),[xe,Se]=(0,W.useState)(!1),[Ce,we]=(0,W.useState)(null),[Te,Ee]=(0,W.useState)(!1),[De,Oe]=(0,W.useState)(null),[ke,Ae]=(0,W.useState)(()=>new Set),Fe=(0,W.useCallback)(()=>{!R.direct&&e.connection.signedIn&&R.fetchGithubQueue().then(Oe).catch(()=>{})},[e.connection.signedIn]);(0,W.useEffect)(()=>{if(R.direct||!e.connection.signedIn)return;let t=Fe;t();let n=yu(t),r=setInterval(()=>{document.visibilityState!==`hidden`&&t()},3e4);return()=>{clearInterval(r),n()}},[Fe,e.connection.signedIn]),(0,W.useEffect)(()=>{!R.direct&&e.connection.signedIn&&R.getNotificationPreferences().then(Ki).catch(()=>{})},[e.connection.signedIn]);let Le=(0,W.useMemo)(()=>Nt(De),[De]),Re=(0,W.useMemo)(()=>kt(De),[De]),ze=(0,W.useMemo)(()=>e.sessionIndex.sessions.filter(e=>Gt(e)>0),[e.sessionIndex.sessions]),He=(0,W.useMemo)(()=>n?ze.filter(e=>Bu(e,r)).length:0,[n,ze,r]),Ue=ze.some(e=>!ke.has(e.sessionId)),We=(0,W.useCallback)(()=>{a(!0),Ae(new Set(ze.map(e=>e.sessionId)))},[ze]),Ge=(0,W.useCallback)(()=>a(!1),[]);(0,W.useEffect)(()=>{let e=ze.length,t=He;document.title=e>0?`(${e}) Bivy`:`Bivy`;let n=navigator,r=()=>{(t>0?n.setAppBadge?.(t):n.clearAppBadge?.())?.catch(()=>{})};r();let i=yu(r);return()=>{i(),document.title=`Bivy`}},[He,ze.length]);let Ke=!R.direct&&e.connection.signedIn&&!e.connection.currentNodeId;(0,W.useEffect)(()=>{if(!Ke)return;let e=()=>{document.visibilityState!==`hidden`&&R.refreshNodes()};e();let t=setInterval(e,4e3),n=yu(e);return()=>{clearInterval(t),n()}},[Ke]);let[Je,Ye]=(0,W.useState)(()=>localStorage.getItem(`bivy.focusView`)===`1`),Xe=(0,W.useCallback)(()=>{Ye(e=>{let t=!e;return localStorage.setItem(`bivy.focusView`,t?`1`:`0`),t})},[]),Ze=e.connection.status===`online`;(0,W.useEffect)(()=>Be(e.activeSession.working),[e.activeSession.working]),(0,W.useEffect)(()=>{Ze&&Ne()},[Ze]);let Qe=Object.values(e.sessionIndex.followupsBySession).reduce((e,t)=>e+t.length,0);(0,W.useEffect)(()=>Pe(Qe),[Qe]);let $e=(0,W.useMemo)(()=>de({direct:R.direct,signedIn:e.connection.signedIn,status:e.connection.status,runtimes:e.catalogs.runtimes,readiness:e.catalogs.activationReadiness}),[e.catalogs.activationReadiness,e.catalogs.runtimes,e.connection.signedIn,e.connection.status]),et=e.activeSession.transcript.some(e=>e.role===`assistant`&&!!e.text&&!e.tool);(0,W.useEffect)(()=>{et&&e.activeSession.activeSessionId&&!u&&localStorage.setItem(`bivy:automation-next-step`,`done`)},[et,e.activeSession.activeSessionId,u]);let[nt,it]=(0,W.useState)(!1),at=(0,W.useRef)(!1);Ze&&(at.current=!0);let ot=e.connection.status===`reconnecting`||at.current&&(e.connection.status===`connecting`||e.connection.status===`linking`||e.connection.status===`pairing`),st=!!(e.activeSession.activeSessionId&&e.sessionIndex.tuiSessions.includes(e.activeSession.activeSessionId)),z=e.sessionIndex.sessions.find(t=>t.sessionId===e.activeSession.activeSessionId),ct=z?.runtimeId??e.activeSession.activeRuntimeId,lt=e.catalogs.runtimes.find(e=>e.id===ct)?.capabilities,ut=Ze&&!!lt?.interactiveTui,dt=e.activeSession.activeSessionId,[ft,pt]=(0,W.useState)(()=>({id:dt,view:Eu(sessionStorage,dt)})),mt=ft.view;ft.id!==dt&&(mt=Eu(sessionStorage,dt),pt({id:dt,view:mt}));let ht=(0,W.useCallback)(t=>{dt&&Du(sessionStorage,dt,t),t===`chat`&&dt&&e.sessionIndex.tuiSessions.includes(dt)&&R.closeSessionTui(dt),pt({id:dt,view:t})},[dt,e.sessionIndex.tuiSessions]),gt=!!dt&&ut&&!Ce,_t=gt&&mt===`terminal`,vt=R.direct&&Ie(`directNode`,!1),yt=!R.direct&&!R.solo||vt,bt=(Ze||ot||R.isCurrentNodeResumable()||!!e.draft.ephemeralConfig)&&!st;bu({isOpen:i,onOpen:We,onClose:Ge,maxWidth:900}),rt(Ge,i),(0,W.useEffect)(()=>{if(!i)return;let e=o.current,t=s.current,n=c.current;t?.setAttribute(`inert`,``);let r=()=>e?Array.from(e.querySelectorAll(zu)):[],a=requestAnimationFrame(()=>{(e?.querySelector(`.sidebar-close`)??e)?.focus()}),l=t=>{if(t.key!==`Tab`)return;let n=r();if(!n.length)return;let i=n[0],a=n[n.length-1],o=document.activeElement;t.shiftKey&&(o===i||!e?.contains(o))?(t.preventDefault(),a.focus()):!t.shiftKey&&(o===a||!e?.contains(o))&&(t.preventDefault(),i.focus())};return window.addEventListener(`keydown`,l),()=>{cancelAnimationFrame(a),window.removeEventListener(`keydown`,l),t?.removeAttribute(`inert`),n?.focus()}},[i]);let xt=(0,W.useCallback)((t,n)=>{if(t.startsWith(`connect-provider:`)){let n=t.slice(17),r=e.connection.currentNodeId;n&&r&&R.store.setNeedsModelAuth({nodeId:r,provider:n});return}if(t===`fix-auth`||t.startsWith(`fix-auth:`)){let n=t.startsWith(`fix-auth:`)?t.slice(9):``,r=e.connection.currentNodeId;n&&r?R.store.setNeedsModelAuth({nodeId:r,provider:n}):Zt(`providers`);return}if(t===`retry-auth`){R.sendPrompt(`Continue — your previous request failed to authenticate. Pick up exactly where you left off.`);return}if(t.startsWith(`retry-at-reset:`)){R.setLimitRetry(!0);return}switch(t){case`/new`:R.newSession();break;case`fork`:te(!0);break;case`cancel-resume`:R.setLimitRetry(!1);break;case`/resume`:R.sendPrompt(`Please continue — your previous turn was interrupted by a restart before it finished. Pick up exactly where you left off and finish what you were doing.`)}},[e.connection.currentNodeId]),St=(0,W.useMemo)(()=>{let t=e.activeSession.activeRuntimeId??e.catalogs.selectedAgentId,n=e.catalogs.currentModel?.provider,r=Ve(t,typeof n==`string`?n:void 0);return r?`fix-auth:${r}`:`fix-auth`},[e.activeSession.activeRuntimeId,e.catalogs.selectedAgentId,e.catalogs.currentModel]),Ct=(0,W.useCallback)(()=>{if(a(!1),!R.direct&&e.connection.nodes.length===0&&R.refreshNodes(),R.direct||e.connection.nodes.length<=1){ve(null),be(!0),Se(!1),ge(!0);return}Ee(!0)},[e.connection.nodes]),wt=(0,W.useCallback)(t=>{Ee(!1),!R.direct&&t!==e.connection.currentNodeId&&R.switchNode(t),ve(null),be(!0),Se(!1),ge(!0),a(!1)},[e.connection.currentNodeId]),Tt=(0,W.useCallback)((t,n,r,i)=>{let o=()=>{(!r||R.isCurrentSessionTarget(r,i))&&(we({termId:t,nodeId:n}),ge(!1),ve(null),be(!1),Se(!1))};if(a(!1),!R.direct&&n&&n!==e.connection.currentNodeId){R.connectToNode(n).then(o).catch(e=>{(!r||R.isCurrentSessionTarget(r,i))&&R.store.setError(e instanceof Error?e.message:String(e))});return}o()},[e.connection.currentNodeId]),Et=(0,W.useCallback)((t,n,r)=>{let i=()=>{R.isCurrentSessionTarget(t,r)&&(we(null),ve(t),be(!0),Se(!1),ge(!0))};if(a(!1),!R.direct&&n&&n!==e.connection.currentNodeId){R.connectToNode(n).then(i).catch(e=>{R.store.setError(e instanceof Error?e.message:String(e))});return}i()},[e.connection.currentNodeId]),Ot=(0,W.useCallback)(()=>{Ce&&(ve(Ce.termId),be(!1),Se(!1),ge(!0))},[Ce]),At=(0,W.useCallback)(()=>{if(!Ce)return;let e=Ce;we(null);let t=R.onTerminal(n=>{let r=n;r.type===`terminal.takeover.result`&&r.termId===e.termId&&(t(),r.ok||we(e))});R.sendTerminal({kind:`terminal.takeover`,termId:e.termId})},[Ce]);(0,W.useEffect)(()=>{Ce&&(e.sessionIndex.runTerminals.some(e=>e.termId===Ce.termId)||we(null))},[Ce,e.sessionIndex.runTerminals]);let jt=(0,W.useCallback)(()=>{ve(null),be(!1),Se(!0),ge(!0)},[]),Mt=(0,W.useCallback)(()=>{e.activeSession.activeSessionId&&R.closeSessionTui(e.activeSession.activeSessionId)},[e.activeSession.activeSessionId]);(0,W.useEffect)(()=>{let t=new URLSearchParams(location.search).get(`review`);t&&e.activeSession.activeSessionId&&_s(e.activeSession.activeSessionId,{reviewId:t})},[e.activeSession.activeSessionId]),(0,W.useEffect)(()=>{let t=new URLSearchParams(location.search),n=t.get(`review`);if(!n||!e.activeSession.activeSessionId||e.connection.status!==`online`)return;let r=e.activeSession.transcript.find(e=>e.review?.id===n)?.review;r&&(t.delete(`review`),history.replaceState(history.state,``,`${location.pathname}${t.size?`?${t}`:``}${location.hash}`),O({sessionId:r.sessionId,appId:r.appId,openView:{viewId:r.viewId,path:r.path}}))},[e.activeSession.activeSessionId,e.activeSession.transcript,e.connection.status]),(0,W.useEffect)(()=>{let t=new URLSearchParams(location.search),n=t.get(`apps`);n&&e.activeSession.activeSessionId&&(t.delete(`apps`),history.replaceState(history.state,``,`${location.pathname}${t.size?`?${t}`:``}${location.hash}`),/^[a-f0-9]{32}$/.test(n)&&O({sessionId:e.activeSession.activeSessionId,appId:n}))},[e.activeSession.activeSessionId]),(0,W.useEffect)(()=>{let t=new URLSearchParams(location.search),n=e.activeSession.activeSessionId;t.get(`show`)===`1`&&n&&e.connection.status===`online`&&(t.delete(`show`),history.replaceState(history.state,``,`${location.pathname}${t.size?`?${t}`:``}${location.hash}`),R.appCommand(`apps.showMe`,n).catch(e=>R.store.setError(e instanceof Error?e.message:`Couldn't show the app`)))},[e.activeSession.activeSessionId,e.connection.status]),(0,W.useEffect)(()=>{let t=new URLSearchParams(location.search).get(`attention`);if(!t||!e.activeSession.activeSessionId)return;let n=document.getElementById(`attention-${encodeURIComponent(t)}`);n&&(n.scrollIntoView({block:`center`}),n.setAttribute(`tabindex`,`-1`),n.focus({preventScroll:!0}))},[e.activeSession.activeSessionId,e.activeSession.approvals,e.activeSession.questions,e.activeSession.turnAttentions]);let Pt=e.activeSession.approvals.filter(t=>!t.sessionId||t.sessionId===e.activeSession.activeSessionId),It=e.activeSession.questions.filter(t=>!t.sessionId||t.sessionId===e.activeSession.activeSessionId),Rt=e.activeSession.turnAttentions.find(t=>t.sessionId===e.activeSession.activeSessionId),zt=Pt.length+It.length+ +!!Rt;(0,W.useEffect)(()=>{zt>0&&x(!1)},[zt]);let Bt=(0,W.useRef)(null),Vt=[Pt[0]?.id,It[0]?.id,Rt?.sessionId].filter(Boolean).join(`:`);(0,W.useEffect)(()=>{Vt&&requestAnimationFrame(()=>Bt.current?.querySelector(`[data-attention-card]`)?.focus())},[Vt]);let Ht=!R.direct&&!R.solo&&!e.connection.signedIn,tn=(0,W.useSyncExternalStore)(or,sr),nn=!R.direct&&e.connection.signedIn&&!e.connection.currentNodeId,rn=!e.activeSession.activeSessionId&&e.sessionIndex.sessions.length===0,[an,sn]=(0,W.useState)(on),[cn,ln]=(0,W.useState)($t),[un,dn]=(0,W.useState)(null),[fn,pn]=(0,W.useState)(null),mn=k&&!R.direct&&e.connection.signedIn&&rn;(0,W.useEffect)(()=>{if(!mn)return;let e=!0;return R.centralGithubApp().then(t=>{e&&dn(t.managedComputeAvailable===!0)},()=>{e&&dn(!1)}),()=>{e=!1}},[mn]);let hn=(0,W.useCallback)(()=>{en(`cloud`),sn(`cloud`),pn({}),R.startCloudOnboarding().then(()=>pn(null),e=>pn({error:e instanceof Error?e.message:String(e)}))},[]),gn=nn&&un===!0&&an!==`own`&&!e.connection.nodes.some(e=>!e.id.startsWith(`eph-`)),_n=gn||fn?`Get started`:`Connect a Machine`,vn=(0,W.useCallback)(e=>{if(e===`cloud`)return hn();en(`own`),sn(`own`)},[hn]);if(Ht||tn)return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Dc,{onDismiss:Ht?void 0:lr}),(0,G.jsxs)(`div`,{className:`toast-stack`,children:[(0,G.jsx)(au,{}),(0,G.jsx)(wc,{})]})]});let yn=z?Re.get(z.sessionId)??Ft(z.source):null,bn=z?.forkedFrom?(()=>{let t=e.sessionIndex.sessions.find(e=>e.sessionId===z.forkedFrom);return{sessionId:z.forkedFrom,name:t?.name,nodeId:t?.nodeId,openable:!!t}})():void 0,xn=z?.nodeId||e.connection.currentNodeId||void 0,Sn=e.connection.nodes.find(e=>e.id===xn),Cn=Sn?`${Sn.name||Sn.id} (${Sn.id})`:xn,wn=!!(z?.source&&String(z.source).startsWith(`repo:`)),Tn=A.wide&&z&&!nn?A.tab:null,En=El(e.activeSession.changesHistory),Dn=!A.wide&&!!z&&!nn&&En>0&&!Ce,On=Dn&&b,kn=()=>{A.show(`changes`)||x(!0)},An=[...gt?[`chat`,`terminal`]:Dn?[`chat`]:[],...Dn?[`changes`]:[]],jn=e=>{x(e===`changes`),e!==`changes`&&ht(e)},Mn=()=>{A.show(`artifacts`)||w(!0)};return(0,G.jsxs)(`div`,{className:`app${Tn?` has-pane`:``}`,children:[(0,G.jsxs)(`div`,{ref:o,className:`sidebar${i?` open`:``}`,role:i?`dialog`:`complementary`,"aria-modal":i?`true`:void 0,"aria-label":`Sessions and workspace`,tabIndex:i?-1:void 0,children:[(0,G.jsxs)(`div`,{className:`sidebar-head`,children:[(0,G.jsx)(`span`,{className:`brand`,children:`Bivy`}),(0,G.jsx)(`div`,{className:`sidebar-head-actions`,children:(0,G.jsx)(`button`,{className:`btn ghost icon only-mobile sidebar-close`,onClick:Ge,"aria-label":`Close sessions`,children:(0,G.jsx)(tt,{})})})]}),(0,G.jsx)(Lt,{runEvidence:Le,sessionSources:Re,automationsActive:!!h,onOpenTerminal:Ct,terminalDisabled:!Ze,onOpenAutomations:()=>{$n(),Ge()},libraryActive:g,onOpenLibrary:e=>{Ic(e),Ge()},onPick:(t,n,r)=>{let i=R.selectSessionTarget(t);we(null),Ge();let a=e.sessionIndex.sessions.find(e=>e.sessionId===t);if(a&&Kt(a)){Et(t,r,i);return}if(a&&B(a)){R.findLiveRunTerminal(t,r).then(e=>{R.isCurrentSessionTarget(t,i)&&(e?Tt(e.termId,e.nodeId??r,t,i):R.openSessionOnNode(t,n,r))}).catch(e=>{R.isCurrentSessionTarget(t,i)&&R.store.setError(e instanceof Error?e.message:String(e))});return}R.openSessionOnNode(t,n,r)},onPickTerminal:Tt}),(0,G.jsxs)(`div`,{className:`sidebar-foot`,children:[(0,G.jsxs)(`button`,{className:`btn primary new-session-btn`,onClick:()=>{we(null),R.newSession(),Ge()},children:[(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,G.jsx)(`path`,{d:`M12 20h9`}),(0,G.jsx)(`path`,{d:`M16.4 3.6a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`})]}),(0,G.jsx)(`span`,{children:`New session`})]}),(0,G.jsx)(`button`,{className:`btn icon settings-gear`,onClick:()=>{Zt(),Ge()},title:`Settings`,"aria-label":`Settings`,children:(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`20`,height:`20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,G.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,G.jsx)(`path`,{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z`})]})})]})]}),i&&(0,G.jsx)(`div`,{className:`scrim`,onClick:Ge}),(0,G.jsxs)(`main`,{ref:s,className:`main${nn?` needs-node`:``}${On?` changes-section`:``}`,children:[(0,G.jsxs)(`header`,{className:`topbar`,children:[(0,G.jsxs)(`button`,{ref:c,className:`btn ghost icon only-mobile burger-btn`,onClick:We,"aria-label":Ue?`Open sessions — something needs your attention`:`Open sessions`,children:[`☰`,Ue&&(0,G.jsx)(`span`,{className:`attn-indicator`,"aria-hidden":!0,children:(0,G.jsx)(qt,{status:`needs-action`})})]}),(0,G.jsxs)(`div`,{className:`topbar-title`,children:[(0,G.jsx)(`div`,{className:`topbar-title-row`,children:(0,G.jsx)(`h1`,{className:`title`,title:nn?_n:e.activeSession.activeTitle,children:nn?_n:e.activeSession.activeTitle})}),(yt||An.length>1)&&(0,G.jsxs)(`div`,{className:`topbar-subline`,children:[yt&&(vt?(0,G.jsx)(kc,{}):(0,G.jsx)(Oc,{})),An.length>1&&(0,G.jsx)(Su,{views:An,value:On?`changes`:gt?mt:`chat`,onChange:jn,changes:En})]})]}),(0,G.jsxs)(`div`,{className:`topbar-actions`,children:[A.wide&&z&&!nn&&(0,G.jsx)(`button`,{className:`btn ghost icon side-pane-toggle`,onClick:()=>A.setTab(Tn?null:`changes`),"aria-pressed":!!Tn,"aria-label":Tn?`Hide side pane`:`Show changes, files, apps, artifacts and terminal`,title:Tn?`Hide side pane`:`Show changes, files, apps, artifacts and terminal`,children:(0,G.jsx)(qe,{size:18})}),e.activeSession.activeSessionId&&!_t&&!On&&(0,G.jsxs)(`button`,{className:`btn ghost focus-view-btn`,onClick:Xe,title:Je?`Focus view on — show full transcript`:`Focus view — show only prompts and final answers`,"aria-label":Je?`Show full transcript`:`Show only prompts and final answers`,"aria-pressed":Je,children:[Je?(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,G.jsx)(`path`,{d:`M9.88 9.88a3 3 0 1 0 4.24 4.24`}),(0,G.jsx)(`path`,{d:`M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68`}),(0,G.jsx)(`path`,{d:`M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61`}),(0,G.jsx)(`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`})]}):(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,G.jsx)(`path`,{d:`M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7z`}),(0,G.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]}),(0,G.jsx)(`span`,{className:`focus-view-label`,children:Je?`Focused`:`Focus`})]}),e.activeSession.activeSessionId&&(0,G.jsx)(sl,{sessionId:e.activeSession.activeSessionId,name:e.activeSession.activeTitle,isRepo:wn,node:Cn,agent:z?.agentName||z?.runtimeId,workspace:z?.workspace,worktree:z?.worktree,branch:z?.branch,sessionFile:z?.path,auditHealth:z?.auditHealth,eventLogHealth:z?.eventLogHealth,onBrowseFiles:z&&!nn?()=>{A.show(`files`)||E(!0)}:void 0})]})]}),(e.connection.status===`pairing`||e.connection.status===`linking`)&&(0,G.jsxs)(`div`,{className:`banner`,"data-tone":`neutral`,role:`status`,children:[(0,G.jsx)(V,{size:`xs`}),`Linking this device…`]}),e.connection.nodeUpdate&&!z?.pendingLaunch&&(0,G.jsxs)(`div`,{className:`banner`,"data-tone":`accent`,role:`status`,children:[(0,G.jsxs)(`span`,{className:`banner-text`,children:[`This machine runs Bivy `,e.connection.nodeUpdate.current,` — `,e.connection.nodeUpdate.latest,` is available.`]}),(0,G.jsx)(`button`,{className:`btn sm primary banner-action`,onClick:()=>R.updateNode(),disabled:e.connection.nodeUpdating,children:e.connection.nodeUpdating?`Updating…`:`Update this machine`})]}),!nn&&!e.draft.ephemeralConfig&&!e.activeSession.activeSessionId&&e.activeSession.transcript.length===0&&e.sessionIndex.sessions.length===0&&(0,G.jsx)(W.Suspense,{fallback:null,children:cn?$e.activated?(0,G.jsx)(du,{machineName:e.connection.nodes.find(t=>t.id===e.connection.currentNodeId)?.name||void 0,onOpenApp:e=>{j.current=!0,Be(!0),R.sendPrompt(su(e),void 0,{workspace:e.project,repo:void 0,branch:void 0})},onFirstChange:()=>{Be(!0),R.sendPrompt(cu)}}):(0,G.jsx)(Fu,{activation:$e,onRemediate:{connect_machine:()=>document.querySelector(`.node-switcher-btn`)?.click(),install_agent:()=>document.querySelector(`.agent-pill`)?.click(),authenticate_credential:()=>document.querySelector(`.model-pill`)?.click(),grant_repository:()=>document.querySelector(`.repo-pill`)?.click()}}):(0,G.jsx)(hu,{state:e,place:an,startError:fn?.error,onRetry:hn,onDone:()=>ln(!0)})}),nn&&(0,G.jsx)(`div`,{className:`connect-runner-scroll`,children:fn?(0,G.jsx)(hu,{state:e,place:`cloud`,startError:fn.error,onRetry:hn,onDone:()=>ln(!0)}):gn?(0,G.jsx)(_u,{onChoose:vn}):mn&&un===null?null:(0,G.jsx)(mu,{nodes:e.connection.nodes,onPickNode:e=>R.switchNode(e),onRefresh:()=>R.refreshNodes(),onUseCloud:un===!0?hn:void 0})}),Ce&&!me?(()=>{let t=e.sessionIndex.runTerminals.find(e=>e.termId===Ce.termId),n=t?.name||t?.label||t?.agent||`Terminal session`,r=e.connection.nodes.find(e=>e.id===(t?.nodeId||Ce.nodeId)),i=!!t?.sessionId||Ya(t?.agent,e.catalogs.runtimes),a=t?.sessionId||Ce.termId,o=e.activeSession.questions.filter(e=>e.sessionId===a);return(0,G.jsx)(cl,{sessionId:t?.sessionId,sessionName:n,nodeLabel:r?.name,online:e.connection.status!==`offline`,onOpenTerminal:Ot,onUseChat:i?At:void 0,children:o.length>0&&(0,G.jsx)(`div`,{className:`tui-locked-attention`,role:`region`,"aria-live":`polite`,"aria-label":`Agent needs your response`,children:(0,G.jsx)(lc,{questions:o,onAnswer:(e,t,n)=>R.answerQuestion(e,t,n),onCancel:(e,t)=>R.cancelQuestion(e,t)})})})})():_t?(0,G.jsx)(W.Suspense,{fallback:null,children:(0,G.jsx)(Pu,{embedded:!0,tui:!0,sessionId:dt,onClose:()=>ht(`chat`)},dt)}):st?(0,G.jsx)(cl,{sessionId:e.activeSession.activeSessionId??void 0,sessionName:e.activeSession.activeTitle,nodeLabel:Sn?.name,online:e.connection.status!==`offline`,onOpenTerminal:jt,onUseChat:Mt}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)($s,{entries:e.activeSession.transcript,working:e.activeSession.working,workingLabel:e.activeSession.workingLabel,draftRoute:!e.activeSession.activeSessionId,greeting:e.sessionIndex.sessions.length>0?`What should we work on?`:void 0,opening:e.activeSession.opening,sessionKey:e.activeSession.activeSessionId,focusView:Je,onAction:xt,authAction:St,header:z?.launchProgress?(0,G.jsx)(rc,{progress:z.launchProgress,onChooseModel:e=>R.chooseLaunchModel(z.sessionId,e),onRefreshModels:()=>R.refreshLaunchModels(z.sessionId),onSetupCredentials:async()=>{try{await R.setupManagedCredentials()}catch(e){R.store.setError(e instanceof Error?e.message:String(e))}},onRetryLaunch:z.pendingLaunch?async()=>{try{await R.retryPendingLaunch(z.sessionId)}catch(e){R.store.setError(e instanceof Error?e.message:String(e))}}:void 0}):void 0,footer:(0,G.jsxs)(`div`,{className:`attention-footer`,ref:Bt,role:`region`,"aria-live":`polite`,"aria-label":`Agent needs your response`,children:[(0,G.jsx)(oc,{approvals:Pt,onResolve:(e,t,n)=>R.resolveApproval(e,t,n)}),(0,G.jsx)(lc,{questions:It,onAnswer:(e,t,n)=>R.answerQuestion(e,t,n),onCancel:(e,t)=>R.cancelQuestion(e,t)}),Rt&&(0,G.jsx)(uc,{attention:Rt,onResolve:(e,t)=>R.resolveTurnAttention(e,t)})]})}),z&&(0,G.jsx)(pu,{working:e.activeSession.working,machineName:Sn?.name||void 0,onOpenChange:it}),et&&z&&!u&&!nt&&(0,G.jsxs)(`section`,{className:`card next-step`,"aria-label":`Next step`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:`Make this repeatable`}),(0,G.jsx)(`p`,{children:`Create an automation to run work without you.`})]}),(0,G.jsxs)(`div`,{className:`next-step-actions`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn sm primary`,onClick:()=>{localStorage.setItem(`bivy:automation-next-step`,`done`),f(!0),$n()},children:`Open Automations`}),(0,G.jsx)(`button`,{type:`button`,className:`btn sm ghost`,"aria-label":`Dismiss`,onClick:()=>{localStorage.setItem(`bivy:automation-next-step`,`done`),f(!0)},children:`Dismiss`})]})]}),T&&!A.wide&&z&&(0,G.jsx)($l,{sessionId:z.sessionId,refreshKey:e.activeSession.changesHistory.length,onClose:()=>E(!1)}),C&&!A.wide&&(0,G.jsx)(Fi,{artifacts:ue,onClose:()=>w(!1)}),D&&!A.wide&&D.sessionId===z?.sessionId&&(0,G.jsx)(Ti,{...D,onClose:()=>O(null)},`${D.sessionId}:${D.appId??``}:${D.openView?.viewId??``}:${D.openView?.scenario??``}`),M&&z&&(0,G.jsx)(il,{sessionId:z.sessionId,onClose:()=>te(!1)}),(0,G.jsxs)(`div`,{className:`composer-gh`,children:[z&&yn?(0,G.jsx)(Cl,{anchorId:`attention-${z.sessionId}`,source:yn,statusClass:Wt(z),statusLabel:Dt(z),gh:e.activeSession.github,evidence:Le.get(z.sessionId),finishedAt:z.finishedAt,usage:e.activeSession.usage,forkedFrom:bn,delegatedFrom:z?.delegatedFrom,filesEdited:El(e.activeSession.changesHistory),onOpenChanges:kn,artifactsCount:ue.length,onOpenArtifacts:Mn,onOpenRun:e=>Wc(e),onRecover:e=>{let t=z.sessionId,n=Le.get(t),r=n?Ut(n):[];if(e===`fork`){R.forkSession(t);return}if(e===`fix`){R.sendPrompt(r.length?`The deterministic checks failed (${r.join(`, `)}). Please investigate the failures and fix them, then confirm the checks pass.`:`This run did not finish cleanly. Please investigate what went wrong and fix it.`);return}R.sendPrompt(r.length?`Please re-run the ${r.join(`, `)} check(s) and address anything that still fails.`:`Please re-run the project checks and address anything that fails.`)}}):(0,G.jsx)(fl,{gh:e.activeSession.github}),z&&(0,G.jsx)(wl,{apps:F.published??fe.length,serverPorts:F.offers.map(e=>e.port),newNotes:I,onOpen:()=>{A.show(`apps`)||O({sessionId:z.sessionId})}})]}),(0,G.jsx)(vu,{status:e.connection.status,hasCachedTranscript:e.activeSession.transcript.length>0,machineName:Sn?.name||void 0}),(0,G.jsx)(Ja,{state:e,disabled:!bt,disabledHint:e.connection.status===`offline`?Sn?.name?`${Sn.name} is offline — run \`bivy status\` there`:"Machine offline — run `bivy status` on it":Sn?.name?`Connecting to ${Sn.name}…`:`Connecting…`,working:e.activeSession.working,onSend:(t,n)=>{e.connection.status!==`online`&&ye(),Be(!0),R.sendPrompt(t,n)},onAbort:()=>R.abort(),onError:e=>R.store.setError(e)})]}),On&&(0,G.jsx)(`div`,{className:`main-changes`,children:(0,G.jsx)(Dl,{docked:!0,history:e.activeSession.changesHistory,checks:z?Le.get(z.sessionId)?.checks?.map(e=>({name:e.name,status:e.status})):void 0,onClose:()=>x(!1),onComposerFilled:()=>x(!1)})})]}),Tn&&z&&(0,G.jsxs)(Ou,{tabs:[{id:`changes`,label:`Changes`,count:En},{id:`files`,label:`Files`},{id:`apps`,label:`Apps`,count:F.published??fe.length},{id:`artifacts`,label:`Artifacts`,count:ue.length},{id:`terminal`,label:`Terminal`}],active:Tn,onSelect:e=>{O(null),A.setTab(e)},onClose:()=>A.setTab(null),children:[Tn===`changes`&&(0,G.jsx)(Dl,{docked:!0,history:e.activeSession.changesHistory,checks:Le.get(z.sessionId)?.checks?.map(e=>({name:e.name,status:e.status})),onClose:()=>A.setTab(null)}),Tn===`files`&&(0,G.jsx)($l,{docked:!0,sessionId:z.sessionId,refreshKey:e.activeSession.changesHistory.length,onClose:()=>A.setTab(null)},z.sessionId),Tn===`apps`&&(()=>{let e=D?.sessionId===z.sessionId?D:{sessionId:z.sessionId};return(0,G.jsx)(Ti,{docked:!0,...e,onClose:()=>O(null)},`${e.sessionId}:${e.appId??``}:${e.openView?.viewId??``}:${e.openView?.scenario??``}`)})(),Tn===`artifacts`&&(0,G.jsx)(Fi,{docked:!0,artifacts:ue,onClose:()=>A.setTab(null)}),Tn===`terminal`&&(0,G.jsx)(W.Suspense,{fallback:null,children:(0,G.jsx)(Pu,{embedded:!0,sessionId:z.sessionId,onClose:()=>A.setTab(`changes`)},z.sessionId)})]}),h&&(0,G.jsx)(W.Suspense,{fallback:null,children:(0,G.jsx)(Lu,{state:e,section:h.section,onSectionChange:er,githubQueue:De,onRefreshGithubQueue:Fe,onOpenRun:t=>{nr(e.activeSession.activeSessionId?{kind:`session`,id:e.activeSession.activeSessionId}:{kind:`new`}),Wc(t)},onClose:()=>nr(e.activeSession.activeSessionId?{kind:`session`,id:e.activeSession.activeSessionId}:{kind:`new`}),onOpenSession:t=>{let n=e.sessionIndex.sessions.find(e=>e.sessionId===t);R.openSessionOnNode(t,n?.path,n?.nodeId),nr({kind:`session`,id:t}),Ge()}})}),g&&(0,G.jsx)(W.Suspense,{fallback:null,children:(0,G.jsx)(Ru,{view:g,onClose:()=>Lc(e.activeSession.activeSessionId?{kind:`session`,id:e.activeSession.activeSessionId}:{kind:`new`}),onShowInChat:(t,n,r)=>{_s(t,n),Lc({kind:`session`,id:t});let i=e.sessionIndex.sessions.filter(e=>e.sessionId===t),a=i.find(e=>e.nodeId===r)??i[0];R.openSessionOnNode(t,a?.path,r??a?.nodeId),Ge()}})}),_&&(0,G.jsx)(tl,{runId:_.runId,load:e=>le(R.local,e),onCancel:async e=>{await ce(R.local,e),Fe()},onRetry:async e=>{await he(R.local,e),Fe()},onReauthenticate:async(t,n,r)=>{let i=n||e.connection.currentNodeId;if(!i)throw Error(`The Machine for this Run is not available.`);await R.connectToNode(i),R.store.setNeedsModelAuth({nodeId:i,provider:t,reason:r})},resolveMachineName:t=>e.connection.nodes.find(e=>e.id===t)?.name||void 0,isSessionResolvable:t=>e.sessionIndex.sessions.some(e=>e.sessionId===t),onReceiptReviewed:()=>{je(R.local,`receipt_reviewed`,matchMedia(`(max-width: 700px)`).matches?`mobile`:`desktop`).catch(()=>{})},onOpenSession:t=>{let n=e.sessionIndex.sessions.find(e=>e.sessionId===t);R.openSessionOnNode(t,n?.path,n?.nodeId),Gc({kind:`session`,id:t}),Ge()},onClose:()=>Gc(e.activeSession.activeSessionId?{kind:`session`,id:e.activeSession.activeSessionId}:{kind:`new`})}),p&&(0,G.jsx)(W.Suspense,{fallback:null,children:(0,G.jsx)(Iu,{state:e,view:p.view,onViewChange:Yt,onImported:e=>{Qt({kind:`session`,id:e}),Ge()},onRedirectToAutomations:t=>{Qt(e.activeSession.activeSessionId?{kind:`session`,id:e.activeSession.activeSessionId}:{kind:`new`}),t===`github`||t===`linear`||t===`slack`?$n({setup:t}):t===`queue`||t===`rulesets`?$n({section:t===`queue`?`runs`:t}):$n(),Ge()},onClose:()=>Qt(e.activeSession.activeSessionId?{kind:`session`,id:e.activeSession.activeSessionId}:{kind:`new`})})}),e.presentation.forkProgress&&(0,G.jsx)(Vl,{progress:e.presentation.forkProgress,onClose:()=>R.store.setForkProgress(null)}),e.presentation.needsModelAuth&&(0,G.jsx)(ou,{state:e}),Te&&(0,G.jsx)(ua,{state:e,currentNodeId:e.connection.currentNodeId,onPick:wt,onClose:()=>Ee(!1)}),me&&(0,G.jsx)(W.Suspense,{fallback:null,children:(0,G.jsx)(Pu,{sessionId:L?null:e.activeSession.activeSessionId,attachTermId:_e,standalone:L,tui:xe,onClose:()=>{ge(!1),ve(null),be(!1),Se(!1)}})}),t&&(0,G.jsx)(`div`,{className:`banner`,"data-tone":`accent`,role:`status`,children:t}),(ne||P)&&(0,G.jsx)(Nl,{text:[P?.items.text,ne].filter(Boolean).join(`
|
|
33
33
|
|
|
34
34
|
`),images:P?.items.attachments,sessions:e.sessionIndex.sessions,listApps:N,onDeliver:(t,n)=>{let r=P,i=[S(r?.items.attachments.length??0,n),r?.items.text,ne].filter(Boolean).join(`
|
|
35
35
|
|