frizz-server 0.15.51 → 0.15.53
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/dist/claude-agent-broker.js +21289 -19953
- package/dist/dev-child.js +21445 -19826
- package/package.json +1 -1
- package/runtime/cc-worker/lib/frizz-tools.mjs +3 -2
- package/web-dist/assets/{abnfDiagram-VCTEODGH-C5Q1E7lp.js → abnfDiagram-VCTEODGH-C5-n-yX3.js} +1 -1
- package/web-dist/assets/architecture-7GRP2DOG-BXfsnnri.js +1 -0
- package/web-dist/assets/{architectureDiagram-5GKGNRK7-s8qHQroP.js → architectureDiagram-5GKGNRK7-v9eLyom7.js} +1 -1
- package/web-dist/assets/{blockDiagram-I7D4REHJ-BmcIwfPO.js → blockDiagram-I7D4REHJ-De0HKZV7.js} +1 -1
- package/web-dist/assets/{c4Diagram-7LVT6UL2-CxeZzDKu.js → c4Diagram-7LVT6UL2-DQFZ6NeQ.js} +1 -1
- package/web-dist/assets/channel-CbqV-FJf.js +1 -0
- package/web-dist/assets/{chunk-2E4U76K2-CggOez3D.js → chunk-2E4U76K2-Cec1rhm9.js} +1 -1
- package/web-dist/assets/{chunk-4HAMMTFA-CGzAun1-.js → chunk-4HAMMTFA-DYmlzCrb.js} +1 -1
- package/web-dist/assets/{chunk-75Z2AOVW-BNE2gKln.js → chunk-75Z2AOVW-D4PgvSWX.js} +1 -1
- package/web-dist/assets/{chunk-CLGD4ZFX-B0hIXfee.js → chunk-CLGD4ZFX-BCRaJRgH.js} +1 -1
- package/web-dist/assets/{chunk-DU6HZSFF-DquuC5at.js → chunk-DU6HZSFF-CXuOpgv7.js} +1 -1
- package/web-dist/assets/{chunk-F27PBJKO-DuVROx-D.js → chunk-F27PBJKO-Cij7-KWq.js} +1 -1
- package/web-dist/assets/{chunk-GMAD6QVW-DqX5jKOH.js → chunk-GMAD6QVW-Vfi9Qodg.js} +1 -1
- package/web-dist/assets/{chunk-GVQU2GXP-NtfCnc_-.js → chunk-GVQU2GXP-eAwOwPRP.js} +1 -1
- package/web-dist/assets/{chunk-IMKFNOWR-D4Z4_MHf.js → chunk-IMKFNOWR-jBkoemYF.js} +1 -1
- package/web-dist/assets/{chunk-L3NEJ4N5-BsHkGTzA.js → chunk-L3NEJ4N5-Xttgzyc5.js} +1 -1
- package/web-dist/assets/{chunk-OSK3NFVY-Bk3sPBix.js → chunk-OSK3NFVY-DR9jXn3P.js} +1 -1
- package/web-dist/assets/{chunk-P2QGCYS3-C15bDEIe.js → chunk-P2QGCYS3-Cpc3emFn.js} +1 -1
- package/web-dist/assets/{chunk-POPQ4Y6H-qdmpiat2.js → chunk-POPQ4Y6H-CuScFkWc.js} +1 -1
- package/web-dist/assets/{chunk-PWAF6VOD-D_g0zmsV.js → chunk-PWAF6VOD-CIdwTlgR.js} +1 -1
- package/web-dist/assets/{chunk-SHT3W25Y-XfCZ9Z0e.js → chunk-SHT3W25Y-Yb5paoPg.js} +1 -1
- package/web-dist/assets/{chunk-SVP7TREG-BcTLp_Eu.js → chunk-SVP7TREG-x8diHpMs.js} +1 -1
- package/web-dist/assets/{chunk-TICWLB2K-oVYczz7g.js → chunk-TICWLB2K-DHsuW_jr.js} +1 -1
- package/web-dist/assets/{chunk-TLUHSLCS-RVRmk0-A.js → chunk-TLUHSLCS-BwiXM_E2.js} +2 -2
- package/web-dist/assets/classDiagram-ZZMXUADV-ChpFNZ6-.js +1 -0
- package/web-dist/assets/classDiagram-v2-VYDZK3BY-ChpFNZ6-.js +1 -0
- package/web-dist/assets/{cynefin-OW5HDTMX-BHoPgGfP.js → cynefin-OW5HDTMX-Cs2PLbXO.js} +1 -1
- package/web-dist/assets/{cynefinDiagram-5FMLGOSQ-Dkbjqslc.js → cynefinDiagram-5FMLGOSQ-DThGVJ4q.js} +1 -1
- package/web-dist/assets/{dagre-GXQ25YYZ-DvAAayi4.js → dagre-GXQ25YYZ-D4QLKHYZ.js} +1 -1
- package/web-dist/assets/{diagram-S7CK7UJ4-D4wiOy2w.js → diagram-S7CK7UJ4-C-oieh0l.js} +1 -1
- package/web-dist/assets/{diagram-UQ7AKVKN-B-gmjANo.js → diagram-UQ7AKVKN-BRTaSxi8.js} +1 -1
- package/web-dist/assets/{diagram-VSXAHHWV-7kP--I3Y.js → diagram-VSXAHHWV-B01NfoBK.js} +1 -1
- package/web-dist/assets/{diagram-VX7I27RA-ClmNhKWZ.js → diagram-VX7I27RA-CIi0wWLy.js} +1 -1
- package/web-dist/assets/{diagram-Z3DM3KII-mqDqbDn6.js → diagram-Z3DM3KII-Bj0bns7N.js} +1 -1
- package/web-dist/assets/{ebnfDiagram-PWID7BFC-2R_30OwT.js → ebnfDiagram-PWID7BFC-DJWjvFhA.js} +1 -1
- package/web-dist/assets/{erDiagram-RLTQ6QDP-DcrS9ah9.js → erDiagram-RLTQ6QDP-OArCjKyL.js} +1 -1
- package/web-dist/assets/eventmodeling-NTZA5JFV-DnLS-G1o.js +1 -0
- package/web-dist/assets/flowDiagram-HODETNUW-DxBcq7hK.js +1 -0
- package/web-dist/assets/{ganttDiagram-EL5Y4UJY-jfhtLteV.js → ganttDiagram-EL5Y4UJY-Sh-yF7Pk.js} +1 -1
- package/web-dist/assets/{gitGraph-4MIJSDKK-vWzfV5Dv.js → gitGraph-4MIJSDKK-diOiZ9jR.js} +1 -1
- package/web-dist/assets/{gitGraphDiagram-WWUBYQGX-jFkqKq9q.js → gitGraphDiagram-WWUBYQGX-CUUUaPk1.js} +1 -1
- package/web-dist/assets/index-C2agpmfX.css +2 -0
- package/web-dist/assets/index-C7R3M7gN.js +242 -0
- package/web-dist/assets/{info-A6RAGUB7-C9Mh-xd_.js → info-A6RAGUB7-RybBrr2w.js} +1 -1
- package/web-dist/assets/{infoDiagram-27XIBGKW-CCCPTXyL.js → infoDiagram-27XIBGKW-Cph6Zwcq.js} +1 -1
- package/web-dist/assets/{ishikawaDiagram-5VMMS53U-DuWD-Oop.js → ishikawaDiagram-5VMMS53U-BANgLDpg.js} +1 -1
- package/web-dist/assets/{journeyDiagram-3NMN7TZE-CSDGNgtQ.js → journeyDiagram-3NMN7TZE-DI-v8VTL.js} +1 -1
- package/web-dist/assets/{kanban-definition-UXKFOSKX-Dx4j74g0.js → kanban-definition-UXKFOSKX-Bzf950KK.js} +1 -1
- package/web-dist/assets/{line-CdchVovc.js → line--92Un6e-.js} +1 -1
- package/web-dist/assets/{mermaid-parser.core-DOvH_iYK.js → mermaid-parser.core-tLBuwbpU.js} +3 -3
- package/web-dist/assets/{mermaid.core-BKnePOrR.js → mermaid.core-eLZc0PEp.js} +3 -3
- package/web-dist/assets/{mindmap-definition-YA3MSWOX-BTBG8MP-.js → mindmap-definition-YA3MSWOX-4_2Ouyga.js} +1 -1
- package/web-dist/assets/{packet-AYTQ26CC-BVhMHF1h.js → packet-AYTQ26CC-DpTDZ1kf.js} +1 -1
- package/web-dist/assets/{pegDiagram-XKGWAZYB-CMUtYA1E.js → pegDiagram-XKGWAZYB-CHCMV4dR.js} +1 -1
- package/web-dist/assets/{pie-WAS4IAKB-Bn8L6tLl.js → pie-WAS4IAKB-DCAUr7Sl.js} +1 -1
- package/web-dist/assets/{pieDiagram-E7YTZNPT-C9StrBf_.js → pieDiagram-E7YTZNPT-ClmhRIOi.js} +1 -1
- package/web-dist/assets/{quadrantDiagram-AXDQQJYC-Dqv3a9MQ.js → quadrantDiagram-AXDQQJYC-C5-AhbaK.js} +1 -1
- package/web-dist/assets/{radar-RG4KPBEZ-D2d9stKI.js → radar-RG4KPBEZ-BcqJ67Ci.js} +1 -1
- package/web-dist/assets/{railroad-74A4TZTK-CzcVELl7.js → railroad-74A4TZTK-BfVmIesg.js} +1 -1
- package/web-dist/assets/railroad-abnf-HS5TGJTU-DmdHOz1X.js +1 -0
- package/web-dist/assets/railroad-ebnf-LZEXJU2U-pF0K7xke.js +1 -0
- package/web-dist/assets/railroad-peg-WCYAUIDC-D-df90Rl.js +1 -0
- package/web-dist/assets/{railroadDiagram-O6MQD6OU-C8hZHIAV.js → railroadDiagram-O6MQD6OU-BV06urHq.js} +1 -1
- package/web-dist/assets/{requirementDiagram-BXWQKSXE-Cf7szJND.js → requirementDiagram-BXWQKSXE-B0kxzubq.js} +1 -1
- package/web-dist/assets/{sankeyDiagram-P5KCCOFB--rnmenv0.js → sankeyDiagram-P5KCCOFB-DjBlKiUQ.js} +1 -1
- package/web-dist/assets/{sequenceDiagram-WJ2MYXX4-Cc_rr0lR.js → sequenceDiagram-WJ2MYXX4-BHxYt7aE.js} +1 -1
- package/web-dist/assets/{stateDiagram-D77RDMKH-CJloEYBY.js → stateDiagram-D77RDMKH-DUMg8VxQ.js} +1 -1
- package/web-dist/assets/stateDiagram-v2-MP3YSRHH-W4P30iTw.js +1 -0
- package/web-dist/assets/{swimlanes-42K2YHIH-BhOe91_8.js → swimlanes-42K2YHIH-yb-iMsnc.js} +1 -1
- package/web-dist/assets/swimlanesDiagram-VR7AAH4N-CY1l7luM.js +8 -0
- package/web-dist/assets/threadSurfaces-i506BiUf.js +143 -0
- package/web-dist/assets/{timeline-definition-24CTP7MA-KS6DUoc4.js → timeline-definition-24CTP7MA-DNW8iOn2.js} +1 -1
- package/web-dist/assets/{treeView-Q6P3EWNA-CpWaQsor.js → treeView-Q6P3EWNA-CuVRJqXc.js} +1 -1
- package/web-dist/assets/{treemap-WGGIJYW6-CHvZNCxH.js → treemap-WGGIJYW6-CqAS1nJa.js} +1 -1
- package/web-dist/assets/{vennDiagram-4TSXK5OY-UjmX6C3i.js → vennDiagram-4TSXK5OY-CayuoPm-.js} +1 -1
- package/web-dist/assets/{wardley-WFR3VGLG-cnG51gSQ.js → wardley-WFR3VGLG-DLBjtOPH.js} +1 -1
- package/web-dist/assets/{wardleyDiagram-VM6X3IG4-CYAbYIIP.js → wardleyDiagram-VM6X3IG4-VjTKjARS.js} +1 -1
- package/web-dist/assets/{xychartDiagram-S5SC5T6Z-DCkEYgZI.js → xychartDiagram-S5SC5T6Z-VztC2hoJ.js} +1 -1
- package/web-dist/index.html +2 -2
- package/web-dist/assets/architecture-7GRP2DOG-BvleZl1n.js +0 -1
- package/web-dist/assets/channel-7TvN1z_n.js +0 -1
- package/web-dist/assets/classDiagram-ZZMXUADV-OHtT-ELM.js +0 -1
- package/web-dist/assets/classDiagram-v2-VYDZK3BY-OHtT-ELM.js +0 -1
- package/web-dist/assets/eventmodeling-NTZA5JFV-DzP9nHU5.js +0 -1
- package/web-dist/assets/flowDiagram-HODETNUW-AcuhvPK1.js +0 -1
- package/web-dist/assets/index-UCKq1o3W.css +0 -2
- package/web-dist/assets/index-aJ01Sr4w.js +0 -241
- package/web-dist/assets/railroad-abnf-HS5TGJTU--UaB3PoN.js +0 -1
- package/web-dist/assets/railroad-ebnf-LZEXJU2U-BeankDqC.js +0 -1
- package/web-dist/assets/railroad-peg-WCYAUIDC-Coy90TSW.js +0 -1
- package/web-dist/assets/stateDiagram-v2-MP3YSRHH-D714Qgfi.js +0 -1
- package/web-dist/assets/swimlanesDiagram-VR7AAH4N-Dujso0fc.js +0 -8
- package/web-dist/assets/threadSurfaces-2aby4XQ1.js +0 -143
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-BKnePOrR.js","assets/index-aJ01Sr4w.js","assets/rolldown-runtime-Bh1tDfsg.js","assets/index-UCKq1o3W.css","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-C4XfhTaE.js","assets/chunk-DU6HZSFF-DquuC5at.js","assets/chunk-75Z2AOVW-BNE2gKln.js","assets/dist-DoH_9pyS.js","assets/chunk-CLGD4ZFX-B0hIXfee.js","assets/chunk-PWAF6VOD-D_g0zmsV.js","assets/chunk-GMAD6QVW-DqX5jKOH.js","assets/chunk-P2QGCYS3-C15bDEIe.js","assets/chunk-4HAMMTFA-CGzAun1-.js","assets/rough.esm-CSKSodPl.js","assets/chunk-GVQU2GXP-NtfCnc_-.js","assets/chunk-OSK3NFVY-Bk3sPBix.js","assets/line-CdchVovc.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-L3NEJ4N5-BsHkGTzA.js","assets/chunk-TLUHSLCS-RVRmk0-A.js","assets/chunk-2E4U76K2-CggOez3D.js","assets/graphlib-B8gBHxth.js","assets/chunk-LNGE3PJU-DNNNwF8Y.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e,t}from"./rolldown-runtime-Bh1tDfsg.js";import{$ as n,$a as r,$i as i,$n as a,$r as o,$s as s,$t as c,A as l,Aa as u,Ai as d,An as f,Ao as p,Ar as m,As as h,At as g,B as _,Ba as v,Bi as y,Bn as b,Bo as x,Br as S,Bs as C,Bt as w,C as T,Ca as E,Ci as D,Cn as O,Co as k,Cr as A,Cs as j,Ct as M,D as N,Da as P,Di as F,Dn as I,Do as L,Dr as R,Ds as z,Dt as B,E as V,Ea as ee,Ei as te,En as ne,Eo as re,Er as ie,Es as ae,Et as oe,F as se,Fa as ce,Fi as le,Fn as ue,Fo as de,Fr as fe,Fs as pe,Ft as me,G as he,Ga as ge,Gi as _e,Gn as ve,Go as ye,Gr as be,Gs as xe,Gt as Se,H as Ce,Ha as we,Hi as Te,Hn as Ee,Ho as De,Hr as Oe,Hs as ke,Ht as Ae,I as je,Ia as Me,Ii as Ne,In as Pe,Io as Fe,Ir as Ie,Is as Le,It as Re,J as ze,Ja as Be,Ji as Ve,Jn as He,Jo as Ue,Jr as We,Js as Ge,Jt as Ke,K as qe,Ka as Je,Ki as Ye,Kn as Xe,Ko as Ze,Kr as Qe,Ks as $e,Kt as et,L as tt,La as nt,Li as rt,Ln as it,Lo as at,Lr as ot,Ls as st,Lt as ct,M as lt,Ma as ut,Mi as dt,Mn as ft,Mo as pt,Mr as mt,Ms as ht,Mt as gt,N as _t,Na as vt,Ni as yt,Nn as bt,No as xt,Nr as St,Ns as Ct,Nt as wt,O as Tt,Oa as Et,Oi as Dt,On as Ot,Oo as kt,Or as At,Os as jt,Ot as Mt,P as Nt,Pa as Pt,Pi as Ft,Pn as It,Po as Lt,Pr as Rt,Ps as zt,Pt as Bt,Q as Vt,Qa as Ht,Qi as Ut,Qn as Wt,Qo as Gt,Qr as Kt,Qs as qt,Qt as Jt,R as Yt,Ra as Xt,Ri as Zt,Rn as Qt,Ro as $t,Rr as en,Rs as tn,Rt as nn,S as rn,Sa as an,Si as on,Sn as sn,So as cn,Sr as ln,Ss as un,St as dn,T as fn,Ta as pn,Ti as mn,Tn as hn,To as gn,Tr as _n,Ts as vn,Tt as yn,U as bn,Ua as H,Ui as xn,Un as Sn,Uo as Cn,Ur as wn,Us as Tn,Ut as En,V as Dn,Va as On,Vi as kn,Vn as An,Vo as jn,Vr as Mn,Vs as Nn,Vt as Pn,W as Fn,Wa as In,Wi as Ln,Wn as Rn,Wo as zn,Wr as Bn,Ws as Vn,Wt as Hn,X as Un,Xa as Wn,Xi as Gn,Xn as Kn,Xo as qn,Xr as Jn,Xs as Yn,Xt as Xn,Y as Zn,Ya as Qn,Yi as $n,Yn as er,Yo as tr,Yr as nr,Ys as rr,Yt as ir,Z as ar,Za as or,Zi as sr,Zn as cr,Zr as lr,Zs as ur,Zt as dr,_ as fr,_a as pr,_c as mr,_i as hr,_n as gr,_o as _r,_r as vr,_s as yr,_t as br,a as xr,aa as Sr,ac as Cr,ai as wr,an as Tr,ao as Er,ar as Dr,as as Or,at as kr,b as Ar,ba as jr,bi as Mr,bn as Nr,bo as Pr,br as Fr,bs as Ir,bt as Lr,c as Rr,ca as zr,cc as Br,ci as Vr,cn as Hr,co as Ur,cr as Wr,cs as Gr,ct as Kr,d as qr,da as Jr,dc as Yr,di as Xr,dn as Zr,do as Qr,dr as $r,ds as ei,dt as ti,ea as ni,ec as ri,ei as ii,en as ai,eo as oi,er as si,es as ci,et as li,f as ui,fa as di,fc as fi,fi as pi,fn as mi,fo as hi,fr as gi,fs as _i,ft as vi,g as yi,ga as bi,gc as xi,gi as Si,gn as Ci,go as wi,gr as Ti,gs as Ei,gt as Di,h as Oi,ha as ki,hc as Ai,hi as ji,hn as U,ho as Mi,hr as Ni,hs as Pi,ht as Fi,i as Ii,ia as Li,ic as Ri,ii as zi,in as Bi,io as Vi,ir as Hi,is as Ui,it as Wi,j as Gi,ja as Ki,ji as qi,jn as Ji,jo as Yi,jr as Xi,js as Zi,jt as Qi,k as $i,ka as ea,ki as ta,kn as na,ko as ra,kr as ia,ks as aa,kt as oa,l as sa,la as ca,lc as la,li as ua,ln as da,lo as W,lr as fa,ls as pa,lt as ma,m as ha,ma as ga,mc as _a,mi as va,mn as ya,mo as ba,mr as xa,ms as Sa,mt as Ca,n as wa,na as Ta,nc as Ea,ni as Da,nn as Oa,no as ka,nr as Aa,ns as ja,nt as Ma,o as Na,oa as Pa,oi as Fa,on as Ia,oo as La,or as Ra,os as za,ot as Ba,p as Va,pa as Ha,pc as G,pi as Ua,pn as Wa,po as Ga,pr as Ka,ps as qa,pt as Ja,q as Ya,qa as Xa,qi as Za,qn as Qa,qo as $a,qr as eo,qs as to,qt as no,r as ro,ra as io,rc as ao,ri as oo,rn as so,ro as co,rr as lo,rs as uo,rt as fo,s as po,sa as mo,sc as ho,si as go,sn as _o,so as K,sr as vo,ss as yo,st as bo,t as xo,ta as So,tc as Co,ti as wo,tn as To,to as Eo,tr as Do,ts as Oo,tt as ko,u as Ao,ua as jo,uc as Mo,ui as No,un as Po,uo as Fo,ur as Io,us as Lo,ut as Ro,v as zo,va as Bo,vi as Vo,vn as Ho,vo as Uo,vr as Wo,vs as Go,vt as Ko,w as qo,wa as Jo,wi as Yo,wn as Xo,wo as Zo,wr as Qo,ws as $o,wt as es,x as ts,xa as ns,xi as rs,xn as is,xo as as,xr as os,xs as ss,xt as cs,y as ls,ya as us,yi as ds,yn as fs,yo as ps,yr as ms,ys as hs,yt as gs,z as _s,za as vs,zi as ys,zn as bs,zo as xs,zr as Ss,zs as Cs,zt as ws}from"./index-aJ01Sr4w.js";var Ts=H(`alarm-clock-off`,[[`path`,{d:`M6.87 6.87a8 8 0 1 0 11.26 11.26`,key:`3on8tj`}],[`path`,{d:`M19.9 14.25a8 8 0 0 0-9.15-9.15`,key:`15ghsc`}],[`path`,{d:`m22 6-3-3`,key:`1opdir`}],[`path`,{d:`M6.26 18.67 4 21`,key:`yzmioq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M4 4 2 6`,key:`1ycko6`}]]),Es=H(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),Ds=H(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Os=H(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),ks=H(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),As=H(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),js=H(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Ms=H(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),Ns=H(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Ps=H(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Fs=H(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),Is=H(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),Ls=H(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Rs=H(`file-diff`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]),zs=H(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Bs=H(`git-branch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),Vs=H(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Hs=H(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),Us=H(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),Ws=H(`list-checks`,[[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}],[`path`,{d:`M13 6h8`,key:`15sg57`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 18h8`,key:`oe0vm4`}]]),Gs=H(`list-todo`,[[`rect`,{x:`3`,y:`5`,width:`6`,height:`6`,rx:`1`,key:`1defrl`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`M13 6h8`,key:`15sg57`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 18h8`,key:`oe0vm4`}]]),Ks=H(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),qs=H(`message-circle-off`,[[`path`,{d:`M20.5 14.9A9 9 0 0 0 9.1 3.5`,key:`1iebmn`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5.6 5.6C3 8.3 2.2 12.5 4 16l-2 6 6-2c3.4 1.8 7.6 1.1 10.3-1.7`,key:`1ov8ce`}]]),Js=H(`message-square-code`,[[`path`,{d:`M10 7.5 8 10l2 2.5`,key:`xb17xw`}],[`path`,{d:`m14 7.5 2 2.5-2 2.5`,key:`5rap1v`}],[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}]]),Ys=H(`messages-square`,[[`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z`,key:`p1xzt8`}],[`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`,key:`1cx29u`}]]),Xs=H(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),Zs=H(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),Qs=H(`package-check`,[[`path`,{d:`m16 16 2 2 4-4`,key:`gfu2re`}],[`path`,{d:`M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14`,key:`e7tb2h`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`12`,key:`a4e8g8`}]]),$s=H(`play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]),ec=H(`repeat`,[[`path`,{d:`m17 2 4 4-4 4`,key:`nntrym`}],[`path`,{d:`M3 11v-1a4 4 0 0 1 4-4h14`,key:`84bu3i`}],[`path`,{d:`m7 22-4-4 4-4`,key:`1wqhfi`}],[`path`,{d:`M21 13v1a4 4 0 0 1-4 4H3`,key:`1rx37r`}]]),tc=H(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),nc=H(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),rc=H(`signpost`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M12 3v3`,key:`1n5kay`}],[`path`,{d:`M18 6a2 2 0 0 1 1.387.56l2.307 2.22a1 1 0 0 1 0 1.44l-2.307 2.22A2 2 0 0 1 18 13H6a2 2 0 0 1-1.387-.56l-2.306-2.22a1 1 0 0 1 0-1.44l2.306-2.22A2 2 0 0 1 6 6z`,key:`gqqp9m`}]]),ic=H(`square-check-big`,[[`path`,{d:`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,key:`2acyp4`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),ac=H(`square-dot`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),oc=H(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),sc=H(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),cc=H(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),lc=H(`zoom-in`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`,key:`1vmskp`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),uc=H(`zoom-out`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),q=e(mr(),1),dc=e(xi(),1);function fc(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var pc=fc();function mc(e){pc=e}var hc={exec:()=>null};function J(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(gc.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var gc={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`)},_c=/^(?:[ \t]*(?:\n|$))+/,vc=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,yc=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,bc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,xc=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Sc=/(?:[*+-]|\d{1,9}[.)])/,Cc=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,wc=J(Cc).replace(/bull/g,Sc).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Tc=J(Cc).replace(/bull/g,Sc).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Ec=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Dc=/^[^\n]+/,Oc=/(?!\s*\])(?:\\.|[^\[\]\\])+/,kc=J(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Oc).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ac=J(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Sc).getRegex(),jc=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Mc=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Nc=J(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Mc).replace(`tag`,jc).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Pc=J(Ec).replace(`hr`,bc).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,jc).getRegex(),Fc={blockquote:J(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Pc).getRegex(),code:vc,def:kc,fences:yc,heading:xc,hr:bc,html:Nc,lheading:wc,list:Ac,newline:_c,paragraph:Pc,table:hc,text:Dc},Ic=J(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,bc).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,jc).getRegex(),Lc={...Fc,lheading:Tc,table:Ic,paragraph:J(Ec).replace(`hr`,bc).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Ic).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,jc).getRegex()},Rc={...Fc,html:J(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Mc).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:hc,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:J(Ec).replace(`hr`,bc).replace(`heading`,` *#{1,6} *[^
|
|
3
|
-
]`).replace(`lheading`,wc).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},zc=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Bc=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Vc=/^( {2,}|\\)\n(?!\s*$)/,Hc=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Uc=/[\p{P}\p{S}]/u,Wc=/[\s\p{P}\p{S}]/u,Gc=/[^\s\p{P}\p{S}]/u,Kc=J(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Wc).getRegex(),qc=/(?!~)[\p{P}\p{S}]/u,Jc=/(?!~)[\s\p{P}\p{S}]/u,Yc=/(?:[^\s\p{P}\p{S}]|~)/u,Xc=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Zc=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Qc=J(Zc,`u`).replace(/punct/g,Uc).getRegex(),$c=J(Zc,`u`).replace(/punct/g,qc).getRegex(),el=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,tl=J(el,`gu`).replace(/notPunctSpace/g,Gc).replace(/punctSpace/g,Wc).replace(/punct/g,Uc).getRegex(),nl=J(el,`gu`).replace(/notPunctSpace/g,Yc).replace(/punctSpace/g,Jc).replace(/punct/g,qc).getRegex(),rl=J(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Gc).replace(/punctSpace/g,Wc).replace(/punct/g,Uc).getRegex(),il=J(/\\(punct)/,`gu`).replace(/punct/g,Uc).getRegex(),al=J(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),ol=J(Mc).replace(`(?:-->|$)`,`-->`).getRegex(),sl=J(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,ol).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),cl=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ll=J(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,cl).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ul=J(/^!?\[(label)\]\[(ref)\]/).replace(`label`,cl).replace(`ref`,Oc).getRegex(),dl=J(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Oc).getRegex(),fl={_backpedal:hc,anyPunctuation:il,autolink:al,blockSkip:Xc,br:Vc,code:Bc,del:hc,emStrongLDelim:Qc,emStrongRDelimAst:tl,emStrongRDelimUnd:rl,escape:zc,link:ll,nolink:dl,punctuation:Kc,reflink:ul,reflinkSearch:J(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,ul).replace(`nolink`,dl).getRegex(),tag:sl,text:Hc,url:hc},pl={...fl,link:J(/^!?\[(label)\]\((.*?)\)/).replace(`label`,cl).getRegex(),reflink:J(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,cl).getRegex()},ml={...fl,emStrongRDelimAst:nl,emStrongLDelim:$c,url:J(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,`i`).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},hl={...ml,br:J(Vc).replace(`{2,}`,`*`).getRegex(),text:J(ml.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},gl={normal:Fc,gfm:Lc,pedantic:Rc},_l={normal:fl,gfm:ml,breaks:hl,pedantic:pl},vl={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},yl=e=>vl[e];function bl(e,t){if(t){if(gc.escapeTest.test(e))return e.replace(gc.escapeReplace,yl)}else if(gc.escapeTestNoEncode.test(e))return e.replace(gc.escapeReplaceNoEncode,yl);return e}function xl(e){try{e=encodeURI(e).replace(gc.percentDecode,`%`)}catch{return null}return e}function Sl(e,t){let n=e.replace(gc.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(gc.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(gc.slashPipe,`|`);return n}function Cl(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function wl(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function Tl(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function El(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
4
|
-
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
|
|
5
|
-
`)}var Dl=class{options;rules;lexer;constructor(e){this.options=e||pc}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:Cl(e,`
|
|
6
|
-
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=El(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=Cl(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:Cl(t[0],`
|
|
7
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Cl(t[0],`
|
|
8
|
-
`).split(`
|
|
9
|
-
`),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
|
|
10
|
-
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
|
|
11
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
|
|
12
|
-
${s}`:s,r=r?`${r}
|
|
13
|
-
${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`)break;if(u?.type===`blockquote`){let t=u,a=t.raw+`
|
|
14
|
-
`+e.join(`
|
|
15
|
-
`),o=this.blockquote(a);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,r=r.substring(0,r.length-t.text.length)+o.text;break}else if(u?.type===`list`){let t=u,a=t.raw+`
|
|
16
|
-
`+e.join(`
|
|
17
|
-
`),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
|
|
18
|
-
`);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=t[2].split(`
|
|
19
|
-
`,1)[0].replace(this.rules.other.listReplaceTabs,e=>` `.repeat(3*e.length)),l=e.split(`
|
|
20
|
-
`,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=t[2].search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
|
|
21
|
-
`,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d);for(;e;){let f=e.split(`
|
|
22
|
-
`,1)[0],p;if(l=f,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),p=l):p=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||t.test(l)||n.test(l))break;if(p.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
|
|
23
|
-
`+p.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
|
|
24
|
-
`+l}!u&&!l.trim()&&(u=!0),r+=f+`
|
|
25
|
-
`,e=e.substring(f.length+1),c=p.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0));let f=null,p;this.options.gfm&&(f=this.rules.other.listIsTask.exec(s),f&&(p=f[0]!==`[ ] `,s=s.replace(this.rules.other.listReplaceTask,``))),i.items.push({type:`list_item`,raw:r,task:!!f,checked:p,loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e=0;e<i.items.length;e++)if(this.lexer.state.top=!1,i.items[e].tokens=this.lexer.blockTokens(i.items[e].text,[]),!i.loose){let t=i.items[e].tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}if(i.loose)for(let e=0;e<i.items.length;e++)i.items[e].loose=!0;return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Sl(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
26
|
-
`):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Sl(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
27
|
-
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=Cl(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=wl(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),Tl(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return Tl(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(r&&!(r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},Ol=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||pc,this.options.tokenizer=this.options.tokenizer||new Dl,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:gc,block:gl.normal,inline:_l.normal};this.options.pedantic?(t.block=gl.pedantic,t.inline=_l.pedantic):this.options.gfm&&(t.block=gl.gfm,this.options.breaks?t.inline=_l.breaks:t.inline=_l.gfm),this.tokenizer.rules=t}static get rules(){return{block:gl,inline:_l}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(gc.carriageReturn,`
|
|
28
|
-
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(gc.tabCharGlobal,` `).replace(gc.spaceLine,``));e;){let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
|
|
29
|
-
`:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=`
|
|
30
|
-
`+r.raw,n.text+=`
|
|
31
|
-
`+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=`
|
|
32
|
-
`+r.raw,n.text+=`
|
|
33
|
-
`+r.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let a=t.at(-1);n&&a?.type===`paragraph`?(a.raw+=`
|
|
34
|
-
`+r.raw,a.text+=`
|
|
35
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=`
|
|
36
|
-
`+r.raw,n.text+=`
|
|
37
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let i=!1,a=``;for(;e;){i||(a=``),i=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,a)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let o=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(o=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(o)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(a=r.raw.slice(-1)),i=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return t}},kl=class{options;parser;constructor(e){this.options=e||pc}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(gc.notSpaceStart)?.[0],i=e.replace(gc.endingNewline,``)+`
|
|
38
|
-
`;return r?`<pre><code class="language-`+bl(r)+`">`+(n?i:bl(i,!0))+`</code></pre>
|
|
39
|
-
`:`<pre><code>`+(n?i:bl(i,!0))+`</code></pre>
|
|
40
|
-
`}blockquote({tokens:e}){return`<blockquote>
|
|
41
|
-
${this.parser.parse(e)}</blockquote>
|
|
42
|
-
`}html({text:e}){return e}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
43
|
-
`}hr(e){return`<hr>
|
|
44
|
-
`}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
|
|
45
|
-
`+r+`</`+i+`>
|
|
46
|
-
`}listitem(e){let t=``;if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?e.tokens[0]?.type===`paragraph`?(e.tokens[0].text=n+` `+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type===`text`&&(e.tokens[0].tokens[0].text=n+` `+bl(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:`text`,raw:n+` `,text:n+` `,escaped:!0}):t+=n+` `}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>
|
|
47
|
-
`}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox">`}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
48
|
-
`}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
|
|
49
|
-
<thead>
|
|
50
|
-
`+t+`</thead>
|
|
51
|
-
`+r+`</table>
|
|
52
|
-
`}tablerow({text:e}){return`<tr>
|
|
53
|
-
${e}</tr>
|
|
54
|
-
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
55
|
-
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${bl(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=xl(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+bl(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=xl(e);if(i===null)return bl(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${bl(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:bl(e.text)}},Al=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}},jl=class e{options;renderer;textRenderer;constructor(e){this.options=e||pc,this.options.renderer=this.options.renderer||new kl,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Al}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e,t=!0){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=i,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(t!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`paragraph`,`text`].includes(e.type)){n+=t||``;continue}}let a=i;switch(a.type){case`space`:n+=this.renderer.space(a);continue;case`hr`:n+=this.renderer.hr(a);continue;case`heading`:n+=this.renderer.heading(a);continue;case`code`:n+=this.renderer.code(a);continue;case`table`:n+=this.renderer.table(a);continue;case`blockquote`:n+=this.renderer.blockquote(a);continue;case`list`:n+=this.renderer.list(a);continue;case`html`:n+=this.renderer.html(a);continue;case`paragraph`:n+=this.renderer.paragraph(a);continue;case`text`:{let i=a,o=this.renderer.text(i);for(;r+1<e.length&&e[r+1].type===`text`;)i=e[++r],o+=`
|
|
56
|
-
`+this.renderer.text(i);t?n+=this.renderer.paragraph({type:`paragraph`,raw:o,text:o,tokens:[{type:`text`,raw:o,text:o,escaped:!0}]}):n+=o;continue}default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}parseInline(e,t=this.renderer){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Ml=class{options;block;constructor(e){this.options=e||pc}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?Ol.lex:Ol.lexInline}provideParser(){return this.block?jl.parse:jl.parseInline}},Nl=class{defaults=fc();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=jl;Renderer=kl;TextRenderer=Al;Lexer=Ol;Tokenizer=Dl;Hooks=Ml;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new kl(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Dl(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Ml;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];Ml.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async)return Promise.resolve(i.call(t,e)).then(e=>a.call(t,e));let n=i.call(t,e);return a.call(t,n)}:t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Ol.lex(e,t??this.defaults)}parser(e,t){return jl.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(t==null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));i.hooks&&(i.hooks.options=i,i.hooks.block=e);let o=i.hooks?i.hooks.provideLexer():e?Ol.lex:Ol.lexInline,s=i.hooks?i.hooks.provideParser():e?jl.parse:jl.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(t):t).then(e=>o(e,i)).then(e=>i.hooks?i.hooks.processAllTokens(e):e).then(e=>i.walkTokens?Promise.all(this.walkTokens(e,i.walkTokens)).then(()=>e):e).then(e=>s(e,i)).then(e=>i.hooks?i.hooks.postprocess(e):e).catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let e=o(t,i);i.hooks&&(e=i.hooks.processAllTokens(e)),i.walkTokens&&this.walkTokens(e,i.walkTokens);let n=s(e,i);return i.hooks&&(n=i.hooks.postprocess(n)),n}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
57
|
-
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+bl(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},Pl=new Nl;function Y(e,t){return Pl.parse(e,t)}Y.options=Y.setOptions=function(e){return Pl.setOptions(e),Y.defaults=Pl.defaults,mc(Y.defaults),Y},Y.getDefaults=fc,Y.defaults=pc,Y.use=function(...e){return Pl.use(...e),Y.defaults=Pl.defaults,mc(Y.defaults),Y},Y.walkTokens=function(e,t){return Pl.walkTokens(e,t)},Y.parseInline=Pl.parseInline,Y.Parser=jl,Y.parser=jl.parse,Y.Renderer=kl,Y.TextRenderer=Al,Y.Lexer=Ol,Y.lexer=Ol.lex,Y.Tokenizer=Dl,Y.Hooks=Ml,Y.parse=Y,Y.options,Y.setOptions,Y.use,Y.walkTokens,Y.parseInline,jl.parse,Ol.lex;var Fl=e(t(((e,t)=>{function n(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw Error(`map is read-only`)}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw Error(`set is read-only`)}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach(t=>{let r=e[t],i=typeof r;(i===`object`||i===`function`)&&!Object.isFrozen(r)&&n(r)}),e}var r=class{constructor(e){e.data===void 0&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function i(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function a(e,...t){let n=Object.create(null);for(let t in e)n[t]=e[t];return t.forEach(function(e){for(let t in e)n[t]=e[t]}),n}var o=`</span>`,s=e=>!!e.scope,c=(e,{prefix:t})=>{if(e.startsWith(`language:`))return e.replace(`language:`,`language-`);if(e.includes(`.`)){let n=e.split(`.`);return[`${t}${n.shift()}`,...n.map((e,t)=>`${e}${`_`.repeat(t+1)}`)].join(` `)}return`${t}${e}`},l=class{constructor(e,t){this.buffer=``,this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=i(e)}openNode(e){if(!s(e))return;let t=c(e.scope,{prefix:this.classPrefix});this.span(t)}closeNode(e){s(e)&&(this.buffer+=o)}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}},u=(e={})=>{let t={children:[]};return Object.assign(t,e),t},d=class e{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){let t=u({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return typeof t==`string`?e.addText(t):t.children&&(e.openNode(t),t.children.forEach(t=>this._walk(e,t)),e.closeNode(t)),e}static _collapse(t){typeof t!=`string`&&t.children&&(t.children.every(e=>typeof e==`string`)?t.children=[t.children.join(``)]:t.children.forEach(t=>{e._collapse(t)}))}},f=class extends d{constructor(e){super(),this.options=e}addText(e){e!==``&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){let n=e.root;t&&(n.scope=`language:${t}`),this.add(n)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function p(e){return e?typeof e==`string`?e:e.source:null}function m(e){return _(`(?=`,e,`)`)}function h(e){return _(`(?:`,e,`)*`)}function g(e){return _(`(?:`,e,`)?`)}function _(...e){return e.map(e=>p(e)).join(``)}function v(e){let t=e[e.length-1];return typeof t==`object`&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function y(...e){return`(`+(v(e).capture?``:`?:`)+e.map(e=>p(e)).join(`|`)+`)`}function b(e){return RegExp(e.toString()+`|`).exec(``).length-1}function x(e,t){let n=e&&e.exec(t);return n&&n.index===0}var S=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function C(e,{joinWith:t}){let n=0;return e.map(e=>{n+=1;let t=n,r=p(e),i=``;for(;r.length>0;){let e=S.exec(r);if(!e){i+=r;break}i+=r.substring(0,e.index),r=r.substring(e.index+e[0].length),e[0][0]===`\\`&&e[1]?i+=`\\`+String(Number(e[1])+t):(i+=e[0],e[0]===`(`&&n++)}return i}).map(e=>`(${e})`).join(t)}var w=/\b\B/,T=`[a-zA-Z]\\w*`,E=`[a-zA-Z_]\\w*`,D=`\\b\\d+(\\.\\d+)?`,O=`(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)`,k=`\\b(0b[01]+)`,A=`!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~`,j=(e={})=>{let t=/^#![ ]*\//;return e.binary&&(e.begin=_(t,/.*\b/,e.binary,/\b.*/)),a({scope:`meta`,begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{e.index!==0&&t.ignoreMatch()}},e)},M={begin:`\\\\[\\s\\S]`,relevance:0},N={scope:`string`,begin:`'`,end:`'`,illegal:`\\n`,contains:[M]},P={scope:`string`,begin:`"`,end:`"`,illegal:`\\n`,contains:[M]},F={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},I=function(e,t,n={}){let r=a({scope:`comment`,begin:e,end:t,contains:[]},n);r.contains.push({scope:`doctag`,begin:`[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)`,end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let i=y(`I`,`a`,`is`,`so`,`us`,`to`,`at`,`if`,`in`,`it`,`on`,/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:_(/[ ]+/,`(`,i,/[.]?[:]?([.][ ]|[ ])/,`){3}`)}),r},L=I(`//`,`$`),R=I(`/\\*`,`\\*/`),z=I(`#`,`$`),B=Object.freeze({__proto__:null,APOS_STRING_MODE:N,BACKSLASH_ESCAPE:M,BINARY_NUMBER_MODE:{scope:`number`,begin:k,relevance:0},BINARY_NUMBER_RE:k,COMMENT:I,C_BLOCK_COMMENT_MODE:R,C_LINE_COMMENT_MODE:L,C_NUMBER_MODE:{scope:`number`,begin:O,relevance:0},C_NUMBER_RE:O,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}})},HASH_COMMENT_MODE:z,IDENT_RE:T,MATCH_NOTHING_RE:w,METHOD_GUARD:{begin:`\\.\\s*[a-zA-Z_]\\w*`,relevance:0},NUMBER_MODE:{scope:`number`,begin:D,relevance:0},NUMBER_RE:D,PHRASAL_WORDS_MODE:F,QUOTE_STRING_MODE:P,REGEXP_MODE:{scope:`regexp`,begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[M,{begin:/\[/,end:/\]/,relevance:0,contains:[M]}]},RE_STARTERS_RE:A,SHEBANG:j,TITLE_MODE:{scope:`title`,begin:T,relevance:0},UNDERSCORE_IDENT_RE:E,UNDERSCORE_TITLE_MODE:{scope:`title`,begin:E,relevance:0}});function V(e,t){e.input[e.index-1]===`.`&&t.ignoreMatch()}function ee(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function te(e,t){t&&e.beginKeywords&&(e.begin=`\\b(`+e.beginKeywords.split(` `).join(`|`)+`)(?!\\.)(?=\\b|\\s)`,e.__beforeBegin=V,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function ne(e,t){Array.isArray(e.illegal)&&(e.illegal=y(...e.illegal))}function re(e,t){if(e.match){if(e.begin||e.end)throw Error(`begin & end are not supported with match`);e.begin=e.match,delete e.match}}function ie(e,t){e.relevance===void 0&&(e.relevance=1)}var ae=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw Error(`beforeMatch cannot be used with starts`);let n=Object.assign({},e);Object.keys(e).forEach(t=>{delete e[t]}),e.keywords=n.keywords,e.begin=_(n.beforeMatch,m(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},oe=[`of`,`and`,`for`,`in`,`not`,`or`,`if`,`then`,`parent`,`list`,`value`],se=`keyword`;function ce(e,t,n=se){let r=Object.create(null);return typeof e==`string`?i(n,e.split(` `)):Array.isArray(e)?i(n,e):Object.keys(e).forEach(function(n){Object.assign(r,ce(e[n],t,n))}),r;function i(e,n){t&&(n=n.map(e=>e.toLowerCase())),n.forEach(function(t){let n=t.split(`|`);r[n[0]]=[e,le(n[0],n[1])]})}}function le(e,t){return t?Number(t):+!ue(e)}function ue(e){return oe.includes(e.toLowerCase())}var de={},fe=e=>{console.error(e)},pe=(e,...t)=>{console.log(`WARN: ${e}`,...t)},me=(e,t)=>{de[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),de[`${e}/${t}`]=!0)},he=Error();function ge(e,t,{key:n}){let r=0,i=e[n],a={},o={};for(let e=1;e<=t.length;e++)o[e+r]=i[e],a[e+r]=!0,r+=b(t[e-1]);e[n]=o,e[n]._emit=a,e[n]._multi=!0}function _e(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw fe(`skip, excludeBegin, returnBegin not compatible with beginScope: {}`),he;if(typeof e.beginScope!=`object`||e.beginScope===null)throw fe(`beginScope must be object`),he;ge(e,e.begin,{key:`beginScope`}),e.begin=C(e.begin,{joinWith:``})}}function ve(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw fe(`skip, excludeEnd, returnEnd not compatible with endScope: {}`),he;if(typeof e.endScope!=`object`||e.endScope===null)throw fe(`endScope must be object`),he;ge(e,e.end,{key:`endScope`}),e.end=C(e.end,{joinWith:``})}}function ye(e){e.scope&&typeof e.scope==`object`&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function be(e){ye(e),typeof e.beginScope==`string`&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope==`string`&&(e.endScope={_wrap:e.endScope}),_e(e),ve(e)}function xe(e){function t(t,n){return new RegExp(p(t),`m`+(e.case_insensitive?`i`:``)+(e.unicodeRegex?`u`:``)+(n?`g`:``))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,t){t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),this.matchAt+=b(e)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let e=this.regexes.map(e=>e[1]);this.matcherRe=t(C(e,{joinWith:`|`}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;let t=this.matcherRe.exec(e);if(!t)return null;let n=t.findIndex((e,t)=>t>0&&e!==void 0),r=this.matchIndexes[n];return t.splice(0,n),Object.assign(t,r)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];let t=new n;return this.rules.slice(e).forEach(([e,n])=>t.addRule(e,n)),t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(e,t){this.rules.push([e,t]),t.type===`begin`&&this.count++}exec(e){let t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex;let n=t.exec(e);if(this.resumingScanAtSamePosition()&&!(n&&n.index===this.lastIndex)){let t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)}return n&&(this.regexIndex+=n.position+1,this.regexIndex===this.count&&this.considerAll()),n}}function i(e){let t=new r;return e.contains.forEach(e=>t.addRule(e.begin,{rule:e,type:`begin`})),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:`end`}),e.illegal&&t.addRule(e.illegal,{type:`illegal`}),t}function o(n,r){let a=n;if(n.isCompiled)return a;[ee,re,be,ae].forEach(e=>e(n,r)),e.compilerExtensions.forEach(e=>e(n,r)),n.__beforeBegin=null,[te,ne,ie].forEach(e=>e(n,r)),n.isCompiled=!0;let s=null;return typeof n.keywords==`object`&&n.keywords.$pattern&&(n.keywords=Object.assign({},n.keywords),s=n.keywords.$pattern,delete n.keywords.$pattern),s||=/\w+/,n.keywords&&=ce(n.keywords,e.case_insensitive),a.keywordPatternRe=t(s,!0),r&&(n.begin||=/\B|\b/,a.beginRe=t(a.begin),!n.end&&!n.endsWithParent&&(n.end=/\B|\b/),n.end&&(a.endRe=t(a.end)),a.terminatorEnd=p(a.end)||``,n.endsWithParent&&r.terminatorEnd&&(a.terminatorEnd+=(n.end?`|`:``)+r.terminatorEnd)),n.illegal&&(a.illegalRe=t(n.illegal)),n.contains||=[],n.contains=[].concat(...n.contains.map(function(e){return Ce(e===`self`?n:e)})),n.contains.forEach(function(e){o(e,a)}),n.starts&&o(n.starts,r),a.matcher=i(a),a}if(e.compilerExtensions||=[],e.contains&&e.contains.includes(`self`))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=a(e.classNameAliases||{}),o(e)}function Se(e){return e?e.endsWithParent||Se(e.starts):!1}function Ce(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return a(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:Se(e)?a(e,{starts:e.starts?a(e.starts):null}):Object.isFrozen(e)?a(e):e}var we=`11.11.1`,Te=class extends Error{constructor(e,t){super(e),this.name=`HTMLInjectionError`,this.html=t}},Ee=i,De=a,Oe=Symbol(`nomatch`),ke=7,Ae=function(e){let t=Object.create(null),i=Object.create(null),a=[],o=!0,s=`Could not find the language '{}', did you forget to load/include a language module?`,c={disableAutodetect:!0,name:`Plain text`,contains:[]},l={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:`hljs-`,cssSelector:`pre code`,languages:null,__emitter:f};function u(e){return l.noHighlightRe.test(e)}function d(e){let t=e.className+` `;t+=e.parentNode?e.parentNode.className:``;let n=l.languageDetectRe.exec(t);if(n){let t=N(n[1]);return t||(pe(s.replace(`{}`,n[1])),pe(`Falling back to no-highlight mode for this block.`,e)),t?n[1]:`no-highlight`}return t.split(/\s+/).find(e=>u(e)||N(e))}function p(e,t,n){let r=``,i=``;typeof t==`object`?(r=e,n=t.ignoreIllegals,i=t.language):(me(`10.7.0`,`highlight(lang, code, ...args) has been deprecated.`),me(`10.7.0`,`Please use highlight(code, options) instead.
|
|
58
|
-
https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(n=!0);let a={code:r,language:i};z(`before:highlight`,a);let o=a.result?a.result:v(a.language,a.code,n);return o.code=a.code,z(`after:highlight`,o),o}function v(e,n,i,a){let c=Object.create(null);function u(e,t){return e.keywords[t]}function d(){if(!A.keywords){M.addText(P);return}let e=0;A.keywordPatternRe.lastIndex=0;let t=A.keywordPatternRe.exec(P),n=``;for(;t;){n+=P.substring(e,t.index);let r=D.case_insensitive?t[0].toLowerCase():t[0],i=u(A,r);if(i){let[e,a]=i;if(M.addText(n),n=``,c[r]=(c[r]||0)+1,c[r]<=ke&&(F+=a),e.startsWith(`_`))n+=t[0];else{let n=D.classNameAliases[e]||e;m(t[0],n)}}else n+=t[0];e=A.keywordPatternRe.lastIndex,t=A.keywordPatternRe.exec(P)}n+=P.substring(e),M.addText(n)}function f(){if(P===``)return;let e=null;if(typeof A.subLanguage==`string`){if(!t[A.subLanguage]){M.addText(P);return}e=v(A.subLanguage,P,!0,j[A.subLanguage]),j[A.subLanguage]=e._top}else e=S(P,A.subLanguage.length?A.subLanguage:null);A.relevance>0&&(F+=e.relevance),M.__addSublanguage(e._emitter,e.language)}function p(){A.subLanguage==null?d():f(),P=``}function m(e,t){e!==``&&(M.startScope(t),M.addText(e),M.endScope())}function h(e,t){let n=1,r=t.length-1;for(;n<=r;){if(!e._emit[n]){n++;continue}let r=D.classNameAliases[e[n]]||e[n],i=t[n];r?m(i,r):(P=i,d(),P=``),n++}}function g(e,t){return e.scope&&typeof e.scope==`string`&&M.openNode(D.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(m(P,D.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),P=``):e.beginScope._multi&&(h(e.beginScope,t),P=``)),A=Object.create(e,{parent:{value:A}}),A}function _(e,t,n){let i=x(e.endRe,n);if(i){if(e[`on:end`]){let n=new r(e);e[`on:end`](t,n),n.isMatchIgnored&&(i=!1)}if(i){for(;e.endsParent&&e.parent;)e=e.parent;return e}}if(e.endsWithParent)return _(e.parent,t,n)}function y(e){return A.matcher.regexIndex===0?(P+=e[0],1):(R=!0,0)}function b(e){let t=e[0],n=e.rule,i=new r(n),a=[n.__beforeBegin,n[`on:begin`]];for(let n of a)if(n&&(n(e,i),i.isMatchIgnored))return y(t);return n.skip?P+=t:(n.excludeBegin&&(P+=t),p(),!n.returnBegin&&!n.excludeBegin&&(P=t)),g(n,e),n.returnBegin?0:t.length}function C(e){let t=e[0],r=n.substring(e.index),i=_(A,e,r);if(!i)return Oe;let a=A;A.endScope&&A.endScope._wrap?(p(),m(t,A.endScope._wrap)):A.endScope&&A.endScope._multi?(p(),h(A.endScope,e)):a.skip?P+=t:(a.returnEnd||a.excludeEnd||(P+=t),p(),a.excludeEnd&&(P=t));do A.scope&&M.closeNode(),!A.skip&&!A.subLanguage&&(F+=A.relevance),A=A.parent;while(A!==i.parent);return i.starts&&g(i.starts,e),a.returnEnd?0:t.length}function w(){let e=[];for(let t=A;t!==D;t=t.parent)t.scope&&e.unshift(t.scope);e.forEach(e=>M.openNode(e))}let T={};function E(t,r){let a=r&&r[0];if(P+=t,a==null)return p(),0;if(T.type===`begin`&&r.type===`end`&&T.index===r.index&&a===``){if(P+=n.slice(r.index,r.index+1),!o){let t=Error(`0 width match regex (${e})`);throw t.languageName=e,t.badRule=T.rule,t}return 1}if(T=r,r.type===`begin`)return b(r);if(r.type===`illegal`&&!i){let e=Error(`Illegal lexeme "`+a+`" for mode "`+(A.scope||`<unnamed>`)+`"`);throw e.mode=A,e}else if(r.type===`end`){let e=C(r);if(e!==Oe)return e}if(r.type===`illegal`&&a===``)return P+=`
|
|
59
|
-
`,1;if(L>1e5&&L>r.index*3)throw Error(`potential infinite loop, way more iterations than matches`);return P+=a,a.length}let D=N(e);if(!D)throw fe(s.replace(`{}`,e)),Error(`Unknown language: "`+e+`"`);let O=xe(D),k=``,A=a||O,j={},M=new l.__emitter(l);w();let P=``,F=0,I=0,L=0,R=!1;try{if(D.__emitTokens)D.__emitTokens(n,M);else{for(A.matcher.considerAll();;){L++,R?R=!1:A.matcher.considerAll(),A.matcher.lastIndex=I;let e=A.matcher.exec(n);if(!e)break;let t=E(n.substring(I,e.index),e);I=e.index+t}E(n.substring(I))}return M.finalize(),k=M.toHTML(),{language:e,value:k,relevance:F,illegal:!1,_emitter:M,_top:A}}catch(t){if(t.message&&t.message.includes(`Illegal`))return{language:e,value:Ee(n),illegal:!0,relevance:0,_illegalBy:{message:t.message,index:I,context:n.slice(I-100,I+100),mode:t.mode,resultSoFar:k},_emitter:M};if(o)return{language:e,value:Ee(n),illegal:!1,relevance:0,errorRaised:t,_emitter:M,_top:A};throw t}}function b(e){let t={value:Ee(e),illegal:!1,relevance:0,_top:c,_emitter:new l.__emitter(l)};return t._emitter.addText(e),t}function S(e,n){n=n||l.languages||Object.keys(t);let r=b(e),i=n.filter(N).filter(F).map(t=>v(t,e,!1));i.unshift(r);let[a,o]=i.sort((e,t)=>{if(e.relevance!==t.relevance)return t.relevance-e.relevance;if(e.language&&t.language){if(N(e.language).supersetOf===t.language)return 1;if(N(t.language).supersetOf===e.language)return-1}return 0}),s=a;return s.secondBest=o,s}function C(e,t,n){let r=t&&i[t]||n;e.classList.add(`hljs`),e.classList.add(`language-${r}`)}function w(e){let t=null,n=d(e);if(u(n))return;if(z(`before:highlightElement`,{el:e,language:n}),e.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);return}if(e.children.length>0&&(l.ignoreUnescapedHTML||(console.warn(`One of your code blocks includes unescaped HTML. This is a potentially serious security risk.`),console.warn(`https://github.com/highlightjs/highlight.js/wiki/security`),console.warn(`The element with unescaped HTML:`),console.warn(e)),l.throwUnescapedHTML))throw new Te(`One of your code blocks includes unescaped HTML.`,e.innerHTML);t=e;let r=t.textContent,i=n?p(r,{language:n,ignoreIllegals:!0}):S(r);e.innerHTML=i.value,e.dataset.highlighted=`yes`,C(e,n,i.language),e.result={language:i.language,re:i.relevance,relevance:i.relevance},i.secondBest&&(e.secondBest={language:i.secondBest.language,relevance:i.secondBest.relevance}),z(`after:highlightElement`,{el:e,result:i,text:r})}function T(e){l=De(l,e)}let E=()=>{k(),me(`10.6.0`,`initHighlighting() deprecated. Use highlightAll() now.`)};function D(){k(),me(`10.6.0`,`initHighlightingOnLoad() deprecated. Use highlightAll() now.`)}let O=!1;function k(){function e(){k()}if(document.readyState===`loading`){O||window.addEventListener(`DOMContentLoaded`,e,!1),O=!0;return}document.querySelectorAll(l.cssSelector).forEach(w)}function A(n,r){let i=null;try{i=r(e)}catch(e){if(fe(`Language definition for '{}' could not be registered.`.replace(`{}`,n)),o)fe(e);else throw e;i=c}i.name||=n,t[n]=i,i.rawDefinition=r.bind(null,e),i.aliases&&P(i.aliases,{languageName:n})}function j(e){delete t[e];for(let t of Object.keys(i))i[t]===e&&delete i[t]}function M(){return Object.keys(t)}function N(e){return e=(e||``).toLowerCase(),t[e]||t[i[e]]}function P(e,{languageName:t}){typeof e==`string`&&(e=[e]),e.forEach(e=>{i[e.toLowerCase()]=t})}function F(e){let t=N(e);return t&&!t.disableAutodetect}function I(e){e[`before:highlightBlock`]&&!e[`before:highlightElement`]&&(e[`before:highlightElement`]=t=>{e[`before:highlightBlock`](Object.assign({block:t.el},t))}),e[`after:highlightBlock`]&&!e[`after:highlightElement`]&&(e[`after:highlightElement`]=t=>{e[`after:highlightBlock`](Object.assign({block:t.el},t))})}function L(e){I(e),a.push(e)}function R(e){let t=a.indexOf(e);t!==-1&&a.splice(t,1)}function z(e,t){let n=e;a.forEach(function(e){e[n]&&e[n](t)})}function V(e){return me(`10.7.0`,`highlightBlock will be removed entirely in v12.0`),me(`10.7.0`,`Please use highlightElement now.`),w(e)}Object.assign(e,{highlight:p,highlightAuto:S,highlightAll:k,highlightElement:w,highlightBlock:V,configure:T,initHighlighting:E,initHighlightingOnLoad:D,registerLanguage:A,unregisterLanguage:j,listLanguages:M,getLanguage:N,registerAliases:P,autoDetection:F,inherit:De,addPlugin:L,removePlugin:R}),e.debugMode=function(){o=!1},e.safeMode=function(){o=!0},e.versionString=we,e.regex={concat:_,lookahead:m,either:y,optional:g,anyNumberOfTimes:h};for(let e in B)typeof B[e]==`object`&&n(B[e]);return Object.assign(e,B),e},je=Ae({});je.newInstance=()=>Ae({}),t.exports=je,je.HighlightJS=je,je.default=je}))()).default;function Il(e){let t=e.regex,n={},r={begin:/\$\{/,end:/\}/,contains:[`self`,{begin:/:-/,contains:[n]}]};Object.assign(n,{className:`variable`,variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,`(?![\\w\\d])(?![$])`)},r]});let i={className:`subst`,begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},a=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:`comment`}}),o={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:`string`})]}},s={className:`string`,begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,i]};i.contains.push(s);let c={match:/\\"/},l={className:`string`,begin:/'/,end:/'/},u={match:/\\'/},d={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:`number`},e.NUMBER_MODE,n]},f=e.SHEBANG({binary:`(${[`fish`,`bash`,`zsh`,`sh`,`csh`,`ksh`,`tcsh`,`dash`,`scsh`].join(`|`)})`,relevance:10}),p={className:`function`,begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},m=[`if`,`then`,`else`,`elif`,`fi`,`time`,`for`,`while`,`until`,`in`,`do`,`done`,`case`,`esac`,`coproc`,`function`,`select`],h=[`true`,`false`],g={match:/(\/[a-z._-]+)+/},_=[`break`,`cd`,`continue`,`eval`,`exec`,`exit`,`export`,`getopts`,`hash`,`pwd`,`readonly`,`return`,`shift`,`test`,`times`,`trap`,`umask`,`unset`],v=[`alias`,`bind`,`builtin`,`caller`,`command`,`declare`,`echo`,`enable`,`help`,`let`,`local`,`logout`,`mapfile`,`printf`,`read`,`readarray`,`source`,`sudo`,`type`,`typeset`,`ulimit`,`unalias`],y=`autoload.bg.bindkey.bye.cap.chdir.clone.comparguments.compcall.compctl.compdescribe.compfiles.compgroups.compquote.comptags.comptry.compvalues.dirs.disable.disown.echotc.echoti.emulate.fc.fg.float.functions.getcap.getln.history.integer.jobs.kill.limit.log.noglob.popd.print.pushd.pushln.rehash.sched.setcap.setopt.stat.suspend.ttyctl.unfunction.unhash.unlimit.unsetopt.vared.wait.whence.where.which.zcompile.zformat.zftp.zle.zmodload.zparseopts.zprof.zpty.zregexparse.zsocket.zstyle.ztcp`.split(`.`),b=`chcon.chgrp.chown.chmod.cp.dd.df.dir.dircolors.ln.ls.mkdir.mkfifo.mknod.mktemp.mv.realpath.rm.rmdir.shred.sync.touch.truncate.vdir.b2sum.base32.base64.cat.cksum.comm.csplit.cut.expand.fmt.fold.head.join.md5sum.nl.numfmt.od.paste.ptx.pr.sha1sum.sha224sum.sha256sum.sha384sum.sha512sum.shuf.sort.split.sum.tac.tail.tr.tsort.unexpand.uniq.wc.arch.basename.chroot.date.dirname.du.echo.env.expr.factor.groups.hostid.id.link.logname.nice.nohup.nproc.pathchk.pinky.printenv.printf.pwd.readlink.runcon.seq.sleep.stat.stdbuf.stty.tee.test.timeout.tty.uname.unlink.uptime.users.who.whoami.yes`.split(`.`);return{name:`Bash`,aliases:[`sh`,`zsh`],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:m,literal:h,built_in:[..._,...v,`set`,`shopt`,...y,...b]},contains:[f,e.SHEBANG(),p,d,a,o,g,s,c,l,u,n]}}var Ll=e=>({IMPORTANT:{scope:`meta`,begin:`!important`},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:`number`,begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:`built_in`,begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:`selector-attr`,begin:/\[/,end:/\]/,illegal:`$`,contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:`number`,begin:e.NUMBER_RE+`(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?`,relevance:0},CSS_VARIABLE:{className:`attr`,begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),Rl=`a.abbr.address.article.aside.audio.b.blockquote.body.button.canvas.caption.cite.code.dd.del.details.dfn.div.dl.dt.em.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hgroup.html.i.iframe.img.input.ins.kbd.label.legend.li.main.mark.menu.nav.object.ol.optgroup.option.p.picture.q.quote.samp.section.select.source.span.strong.summary.sup.table.tbody.td.textarea.tfoot.th.thead.time.tr.ul.var.video`.split(`.`),zl=`defs.g.marker.mask.pattern.svg.switch.symbol.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feFlood.feGaussianBlur.feImage.feMerge.feMorphology.feOffset.feSpecularLighting.feTile.feTurbulence.linearGradient.radialGradient.stop.circle.ellipse.image.line.path.polygon.polyline.rect.text.use.textPath.tspan.foreignObject.clipPath`.split(`.`),Bl=[...Rl,...zl],Vl=`any-hover.any-pointer.aspect-ratio.color.color-gamut.color-index.device-aspect-ratio.device-height.device-width.display-mode.forced-colors.grid.height.hover.inverted-colors.monochrome.orientation.overflow-block.overflow-inline.pointer.prefers-color-scheme.prefers-contrast.prefers-reduced-motion.prefers-reduced-transparency.resolution.scan.scripting.update.width.min-width.max-width.min-height.max-height`.split(`.`).sort().reverse(),Hl=`active.any-link.blank.checked.current.default.defined.dir.disabled.drop.empty.enabled.first.first-child.first-of-type.fullscreen.future.focus.focus-visible.focus-within.has.host.host-context.hover.indeterminate.in-range.invalid.is.lang.last-child.last-of-type.left.link.local-link.not.nth-child.nth-col.nth-last-child.nth-last-col.nth-last-of-type.nth-of-type.only-child.only-of-type.optional.out-of-range.past.placeholder-shown.read-only.read-write.required.right.root.scope.target.target-within.user-invalid.valid.visited.where`.split(`.`).sort().reverse(),Ul=[`after`,`backdrop`,`before`,`cue`,`cue-region`,`first-letter`,`first-line`,`grammar-error`,`marker`,`part`,`placeholder`,`selection`,`slotted`,`spelling-error`].sort().reverse(),Wl=`accent-color.align-content.align-items.align-self.alignment-baseline.all.anchor-name.animation.animation-composition.animation-delay.animation-direction.animation-duration.animation-fill-mode.animation-iteration-count.animation-name.animation-play-state.animation-range.animation-range-end.animation-range-start.animation-timeline.animation-timing-function.appearance.aspect-ratio.backdrop-filter.backface-visibility.background.background-attachment.background-blend-mode.background-clip.background-color.background-image.background-origin.background-position.background-position-x.background-position-y.background-repeat.background-size.baseline-shift.block-size.border.border-block.border-block-color.border-block-end.border-block-end-color.border-block-end-style.border-block-end-width.border-block-start.border-block-start-color.border-block-start-style.border-block-start-width.border-block-style.border-block-width.border-bottom.border-bottom-color.border-bottom-left-radius.border-bottom-right-radius.border-bottom-style.border-bottom-width.border-collapse.border-color.border-end-end-radius.border-end-start-radius.border-image.border-image-outset.border-image-repeat.border-image-slice.border-image-source.border-image-width.border-inline.border-inline-color.border-inline-end.border-inline-end-color.border-inline-end-style.border-inline-end-width.border-inline-start.border-inline-start-color.border-inline-start-style.border-inline-start-width.border-inline-style.border-inline-width.border-left.border-left-color.border-left-style.border-left-width.border-radius.border-right.border-right-color.border-right-style.border-right-width.border-spacing.border-start-end-radius.border-start-start-radius.border-style.border-top.border-top-color.border-top-left-radius.border-top-right-radius.border-top-style.border-top-width.border-width.bottom.box-align.box-decoration-break.box-direction.box-flex.box-flex-group.box-lines.box-ordinal-group.box-orient.box-pack.box-shadow.box-sizing.break-after.break-before.break-inside.caption-side.caret-color.clear.clip.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.color-scheme.column-count.column-fill.column-gap.column-rule.column-rule-color.column-rule-style.column-rule-width.column-span.column-width.columns.contain.contain-intrinsic-block-size.contain-intrinsic-height.contain-intrinsic-inline-size.contain-intrinsic-size.contain-intrinsic-width.container.container-name.container-type.content.content-visibility.counter-increment.counter-reset.counter-set.cue.cue-after.cue-before.cursor.cx.cy.direction.display.dominant-baseline.empty-cells.enable-background.field-sizing.fill.fill-opacity.fill-rule.filter.flex.flex-basis.flex-direction.flex-flow.flex-grow.flex-shrink.flex-wrap.float.flood-color.flood-opacity.flow.font.font-display.font-family.font-feature-settings.font-kerning.font-language-override.font-optical-sizing.font-palette.font-size.font-size-adjust.font-smooth.font-smoothing.font-stretch.font-style.font-synthesis.font-synthesis-position.font-synthesis-small-caps.font-synthesis-style.font-synthesis-weight.font-variant.font-variant-alternates.font-variant-caps.font-variant-east-asian.font-variant-emoji.font-variant-ligatures.font-variant-numeric.font-variant-position.font-variation-settings.font-weight.forced-color-adjust.gap.glyph-orientation-horizontal.glyph-orientation-vertical.grid.grid-area.grid-auto-columns.grid-auto-flow.grid-auto-rows.grid-column.grid-column-end.grid-column-start.grid-gap.grid-row.grid-row-end.grid-row-start.grid-template.grid-template-areas.grid-template-columns.grid-template-rows.hanging-punctuation.height.hyphenate-character.hyphenate-limit-chars.hyphens.icon.image-orientation.image-rendering.image-resolution.ime-mode.initial-letter.initial-letter-align.inline-size.inset.inset-area.inset-block.inset-block-end.inset-block-start.inset-inline.inset-inline-end.inset-inline-start.isolation.justify-content.justify-items.justify-self.kerning.left.letter-spacing.lighting-color.line-break.line-height.line-height-step.list-style.list-style-image.list-style-position.list-style-type.margin.margin-block.margin-block-end.margin-block-start.margin-bottom.margin-inline.margin-inline-end.margin-inline-start.margin-left.margin-right.margin-top.margin-trim.marker.marker-end.marker-mid.marker-start.marks.mask.mask-border.mask-border-mode.mask-border-outset.mask-border-repeat.mask-border-slice.mask-border-source.mask-border-width.mask-clip.mask-composite.mask-image.mask-mode.mask-origin.mask-position.mask-repeat.mask-size.mask-type.masonry-auto-flow.math-depth.math-shift.math-style.max-block-size.max-height.max-inline-size.max-width.min-block-size.min-height.min-inline-size.min-width.mix-blend-mode.nav-down.nav-index.nav-left.nav-right.nav-up.none.normal.object-fit.object-position.offset.offset-anchor.offset-distance.offset-path.offset-position.offset-rotate.opacity.order.orphans.outline.outline-color.outline-offset.outline-style.outline-width.overflow.overflow-anchor.overflow-block.overflow-clip-margin.overflow-inline.overflow-wrap.overflow-x.overflow-y.overlay.overscroll-behavior.overscroll-behavior-block.overscroll-behavior-inline.overscroll-behavior-x.overscroll-behavior-y.padding.padding-block.padding-block-end.padding-block-start.padding-bottom.padding-inline.padding-inline-end.padding-inline-start.padding-left.padding-right.padding-top.page.page-break-after.page-break-before.page-break-inside.paint-order.pause.pause-after.pause-before.perspective.perspective-origin.place-content.place-items.place-self.pointer-events.position.position-anchor.position-visibility.print-color-adjust.quotes.r.resize.rest.rest-after.rest-before.right.rotate.row-gap.ruby-align.ruby-position.scale.scroll-behavior.scroll-margin.scroll-margin-block.scroll-margin-block-end.scroll-margin-block-start.scroll-margin-bottom.scroll-margin-inline.scroll-margin-inline-end.scroll-margin-inline-start.scroll-margin-left.scroll-margin-right.scroll-margin-top.scroll-padding.scroll-padding-block.scroll-padding-block-end.scroll-padding-block-start.scroll-padding-bottom.scroll-padding-inline.scroll-padding-inline-end.scroll-padding-inline-start.scroll-padding-left.scroll-padding-right.scroll-padding-top.scroll-snap-align.scroll-snap-stop.scroll-snap-type.scroll-timeline.scroll-timeline-axis.scroll-timeline-name.scrollbar-color.scrollbar-gutter.scrollbar-width.shape-image-threshold.shape-margin.shape-outside.shape-rendering.speak.speak-as.src.stop-color.stop-opacity.stroke.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke-width.tab-size.table-layout.text-align.text-align-all.text-align-last.text-anchor.text-combine-upright.text-decoration.text-decoration-color.text-decoration-line.text-decoration-skip.text-decoration-skip-ink.text-decoration-style.text-decoration-thickness.text-emphasis.text-emphasis-color.text-emphasis-position.text-emphasis-style.text-indent.text-justify.text-orientation.text-overflow.text-rendering.text-shadow.text-size-adjust.text-transform.text-underline-offset.text-underline-position.text-wrap.text-wrap-mode.text-wrap-style.timeline-scope.top.touch-action.transform.transform-box.transform-origin.transform-style.transition.transition-behavior.transition-delay.transition-duration.transition-property.transition-timing-function.translate.unicode-bidi.user-modify.user-select.vector-effect.vertical-align.view-timeline.view-timeline-axis.view-timeline-inset.view-timeline-name.view-transition-name.visibility.voice-balance.voice-duration.voice-family.voice-pitch.voice-range.voice-rate.voice-stress.voice-volume.white-space.white-space-collapse.widows.width.will-change.word-break.word-spacing.word-wrap.writing-mode.x.y.z-index.zoom`.split(`.`).sort().reverse();function Gl(e){let t=e.regex,n=Ll(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},i=/@-?\w[\w]*(-\w+)*/,a=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:`CSS`,case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:`from to`},classNameAliases:{keyframePosition:`selector-tag`},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:`selector-id`,begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:`selector-class`,begin:`\\.[a-zA-Z-][a-zA-Z0-9_-]*`,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:`selector-pseudo`,variants:[{begin:`:(`+Hl.join(`|`)+`)`},{begin:`:(:)?(`+Ul.join(`|`)+`)`}]},n.CSS_VARIABLE,{className:`attribute`,begin:`\\b(`+Wl.join(`|`)+`)\\b`},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...a,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:`url data-uri`},contains:[...a,{className:`string`,begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:`[{;]`,relevance:0,illegal:/:/,contains:[{className:`keyword`,begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:`and or not only`,attribute:Vl.join(` `)},contains:[{begin:/[a-z-]+(?=:)/,className:`attribute`},...a,n.CSS_NUMBER_MODE]}]},{className:`selector-tag`,begin:`\\b(`+Bl.join(`|`)+`)\\b`}]}}function Kl(e){let t=e.regex;return{name:`Diff`,aliases:[`patch`],contains:[{className:`meta`,relevance:10,match:t.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:`comment`,variants:[{begin:t.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:`addition`,begin:/^\+/,end:/$/},{className:`deletion`,begin:/^-/,end:/$/},{className:`addition`,begin:/^!/,end:/$/}]}}var ql=`[A-Za-z$_][0-9A-Za-z$_]*`,Jl=`as.in.of.if.for.while.finally.var.new.function.do.return.void.else.break.catch.instanceof.with.throw.case.default.try.switch.continue.typeof.delete.let.yield.const.class.debugger.async.await.static.import.from.export.extends.using`.split(`.`),Yl=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],Xl=`Object.Function.Boolean.Symbol.Math.Date.Number.BigInt.String.RegExp.Array.Float32Array.Float64Array.Int8Array.Uint8Array.Uint8ClampedArray.Int16Array.Int32Array.Uint16Array.Uint32Array.BigInt64Array.BigUint64Array.Set.Map.WeakSet.WeakMap.ArrayBuffer.SharedArrayBuffer.Atomics.DataView.JSON.Promise.Generator.GeneratorFunction.AsyncFunction.Reflect.Proxy.Intl.WebAssembly`.split(`.`),Zl=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],Ql=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],$l=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`global`],eu=[].concat(Ql,Xl,Zl);function tu(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=ql,i={begin:`<>`,end:`</>`},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{let r=e[0].length+e.index,i=e.input[r];if(i===`<`||i===`,`){t.ignoreMatch();return}i===`>`&&(n(e,{after:r})||t.ignoreMatch());let a,o=e.input.substring(r);if(a=o.match(/^\s*=/)){t.ignoreMatch();return}if((a=o.match(/^\s+extends\s+/))&&a.index===0){t.ignoreMatch();return}}},s={$pattern:ql,keyword:Jl,literal:Yl,built_in:eu,"variable.language":$l},c=`[0-9](_?[0-9])*`,l=`\\.(${c})`,u=`0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`,d={className:`number`,variants:[{begin:`(\\b(${u})((${l})|\\.)?|(${l}))[eE][+-]?(${c})\\b`},{begin:`\\b(${u})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:`\\b(0|[1-9](_?[0-9])*)n\\b`},{begin:`\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b`},{begin:`\\b0[bB][0-1](_?[0-1])*n?\\b`},{begin:`\\b0[oO][0-7](_?[0-7])*n?\\b`},{begin:`\\b0[0-7]+n?\\b`}],relevance:0},f={className:`subst`,begin:`\\$\\{`,end:`\\}`,keywords:s,contains:[]},p={begin:".?html`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`xml`}},m={begin:".?css`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`css`}},h={begin:".?gql`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`graphql`}},g={className:`string`,begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,f]},_={className:`comment`,variants:[e.COMMENT(/\/\*\*(?!\/)/,`\\*/`,{relevance:0,contains:[{begin:`(?=@[A-Za-z]+)`,relevance:0,contains:[{className:`doctag`,begin:`@[A-Za-z]+`},{className:`type`,begin:`\\{`,end:`\\}`,excludeEnd:!0,excludeBegin:!0,relevance:0},{className:`variable`,begin:`[A-Za-z$_][0-9A-Za-z$_]*(?=\\s*(-)|$)`,endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},v=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,{match:/\$\d+/},d];f.contains=v.concat({begin:/\{/,end:/\}/,keywords:s,contains:[`self`].concat(v)});let y=[].concat(_,f.contains),b=y.concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:[`self`].concat(y)}]),x={className:`params`,begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b},S={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,`(`,t.concat(/\./,r),`)*`)],scope:{1:`keyword`,3:`title.class`,5:`keyword`,7:`title.class.inherited`}},{match:[/class/,/\s+/,r],scope:{1:`keyword`,3:`title.class`}}]},C={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:`title.class`,keywords:{_:[...Xl,...Zl]}},w={label:`use_strict`,className:`meta`,relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},T={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:`keyword`,3:`title.function`},label:`func.def`,contains:[x],illegal:/%/},E={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:`variable.constant`};function D(e){return t.concat(`(?!`,e.join(`|`),`)`)}let O={match:t.concat(/\b/,D([...Ql,`super`,`import`].map(e=>`${e}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:`title.function`,relevance:0},k={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:`prototype`,className:`property`,relevance:0},A={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:`keyword`,3:`title.function`},contains:[{begin:/\(\)/},x]},j=`(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|`+e.UNDERSCORE_IDENT_RE+`)\\s*=>`,M={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(j)],keywords:`async`,className:{1:`keyword`,3:`title.function`},contains:[x]};return{name:`JavaScript`,aliases:[`js`,`jsx`,`mjs`,`cjs`],keywords:s,exports:{PARAMS_CONTAINS:b,CLASS_REFERENCE:C},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:`shebang`,binary:`node`,relevance:5}),w,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,_,{match:/\$\d+/},d,C,{scope:`attr`,match:r+t.lookahead(`:`),relevance:0},M,{begin:`(`+e.RE_STARTERS_RE+`|\\b(case|return|throw)\\b)\\s*`,keywords:`return throw case`,relevance:0,contains:[_,e.REGEXP_MODE,{className:`function`,begin:j,returnBegin:!0,end:`\\s*=>`,contains:[{className:`params`,variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:a},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:`xml`,contains:[{begin:o.begin,end:o.end,skip:!0,contains:[`self`]}]}]},T,{beginKeywords:`while if switch catch for`},{begin:`\\b(?!function)`+e.UNDERSCORE_IDENT_RE+`\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{`,returnBegin:!0,label:`func.def`,contains:[x,e.inherit(e.TITLE_MODE,{begin:r,className:`title.function`})]},{match:/\.\.\./,relevance:0},k,{match:`\\$[A-Za-z$_][0-9A-Za-z$_]*`,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:`title.function`},contains:[x]},O,E,S,A,{match:/\$[(.]/}]}}function nu(e){let t={className:`attr`,begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:`punctuation`,relevance:0},r=[`true`,`false`,`null`],i={scope:`literal`,beginKeywords:r.join(` `)};return{name:`JSON`,aliases:[`jsonc`],keywords:{literal:r},contains:[t,n,e.QUOTE_STRING_MODE,i,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:`\\S`}}function ru(e){let t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:`>`,subLanguage:`xml`,relevance:0},r={begin:`^[-\\*]{3,}`,end:`$`},i={className:`code`,variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:`(~{3,})[^~](.|\\n)*?\\1~*[ ]*`},{begin:"```",end:"```+[ ]*$"},{begin:`~~~`,end:`~~~+[ ]*$`},{begin:"`.+?`"},{begin:`(?=^( {4}|\\t))`,contains:[{begin:`^( {4}|\\t)`,end:`(\\n)$`}],relevance:0}]},a={className:`bullet`,begin:`^[ ]*([*+-]|(\\d+\\.))(?=\\s+)`,end:`\\s+`,excludeEnd:!0},o={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:`symbol`,begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:`link`,begin:/:\s*/,end:/$/,excludeBegin:!0}]},s={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,/[A-Za-z][A-Za-z0-9+.-]*/,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:`string`,relevance:0,begin:`\\[`,end:`\\]`,excludeBegin:!0,returnEnd:!0},{className:`link`,relevance:0,begin:`\\]\\(`,end:`\\)`,excludeBegin:!0,excludeEnd:!0},{className:`symbol`,relevance:0,begin:`\\]\\[`,end:`\\]`,excludeBegin:!0,excludeEnd:!0}]},c={className:`strong`,contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},l={className:`emphasis`,contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},u=e.inherit(c,{contains:[]}),d=e.inherit(l,{contains:[]});c.contains.push(d),l.contains.push(u);let f=[n,s];return[c,l,u,d].forEach(e=>{e.contains=e.contains.concat(f)}),f=f.concat(c,l),{name:`Markdown`,aliases:[`md`,`mkdown`,`mkd`],contains:[{className:`section`,variants:[{begin:`^#{1,6}`,end:`$`,contains:f},{begin:`(?=^.+?\\n[=-]{2,}$)`,contains:[{begin:`^[=-]*$`},{begin:`^`,end:`\\n`,contains:f}]}]},n,a,c,l,{className:`quote`,begin:`^>\\s+`,contains:f,end:`$`},i,r,s,o,{scope:`literal`,match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function iu(e){let t=e.regex,n=/[\p{XID_Start}_]\p{XID_Continue}*/u,r=`and.as.assert.async.await.break.case.class.continue.def.del.elif.else.except.finally.for.from.global.if.import.in.is.lambda.match.nonlocal|10.not.or.pass.raise.return.try.while.with.yield`.split(`.`),i={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:`__import__.abs.all.any.ascii.bin.bool.breakpoint.bytearray.bytes.callable.chr.classmethod.compile.complex.delattr.dict.dir.divmod.enumerate.eval.exec.filter.float.format.frozenset.getattr.globals.hasattr.hash.help.hex.id.input.int.isinstance.issubclass.iter.len.list.locals.map.max.memoryview.min.next.object.oct.open.ord.pow.print.property.range.repr.reversed.round.set.setattr.slice.sorted.staticmethod.str.sum.super.tuple.type.vars.zip`.split(`.`),literal:[`__debug__`,`Ellipsis`,`False`,`None`,`NotImplemented`,`True`],type:[`Any`,`Callable`,`Coroutine`,`Dict`,`List`,`Literal`,`Generic`,`Optional`,`Sequence`,`Set`,`Tuple`,`Type`,`Union`]},a={className:`meta`,begin:/^(>>>|\.\.\.) /},o={className:`subst`,begin:/\{/,end:/\}/,keywords:i,illegal:/#/},s={begin:/\{\{/,relevance:0},c={className:`string`,contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a,s,o]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a,s,o]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,s,o]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,s,o]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},l=`[0-9](_?[0-9])*`,u=`(\\b(${l}))?\\.(${l})|\\b(${l})\\.`,d=`\\b|${r.join(`|`)}`,f={className:`number`,relevance:0,variants:[{begin:`(\\b(${l})|(${u}))[eE][+-]?(${l})[jJ]?(?=${d})`},{begin:`(${u})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${d})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${d})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${d})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${d})`},{begin:`\\b(${l})[jJ](?=${d})`}]},p={className:`comment`,begin:t.lookahead(/# type:/),end:/$/,keywords:i,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},m={className:`params`,variants:[{className:``,begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:i,contains:[`self`,a,f,c,e.HASH_COMMENT_MODE]}]};return o.contains=[c,f,a],{name:`Python`,aliases:[`py`,`gyp`,`ipython`],unicodeRegex:!0,keywords:i,illegal:/(<\/|\?)|=>/,contains:[a,f,{scope:`variable.language`,match:/\bself\b/},{beginKeywords:`if`,relevance:0},{match:/\bor\b/,scope:`keyword`},c,p,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:`keyword`,3:`title.function`},contains:[m]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:`keyword`,3:`title.class`,6:`title.class.inherited`}},{className:`meta`,begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[f,m,c]}]}}function au(e){let t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),i=t.concat(n,e.IDENT_RE),a={className:`title.function.invoke`,relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,i,t.lookahead(/\s*\(/))},o=`abstract.as.async.await.become.box.break.const.continue.crate.do.dyn.else.enum.extern.false.final.fn.for.if.impl.in.let.loop.macro.match.mod.move.mut.override.priv.pub.ref.return.self.Self.static.struct.super.trait.true.try.type.typeof.union.unsafe.unsized.use.virtual.where.while.yield`.split(`.`),s=[`true`,`false`,`Some`,`None`,`Ok`,`Err`],c=`drop .Copy.Send.Sized.Sync.Drop.Fn.FnMut.FnOnce.ToOwned.Clone.Debug.PartialEq.PartialOrd.Eq.Ord.AsRef.AsMut.Into.From.Default.Iterator.Extend.IntoIterator.DoubleEndedIterator.ExactSizeIterator.SliceConcatExt.ToString.assert!.assert_eq!.bitflags!.bytes!.cfg!.col!.concat!.concat_idents!.debug_assert!.debug_assert_eq!.env!.eprintln!.panic!.file!.format!.format_args!.include_bytes!.include_str!.line!.local_data_key!.module_path!.option_env!.print!.println!.select!.stringify!.try!.unimplemented!.unreachable!.vec!.write!.writeln!.macro_rules!.assert_ne!.debug_assert_ne!`.split(`.`),l=[`i8`,`i16`,`i32`,`i64`,`i128`,`isize`,`u8`,`u16`,`u32`,`u64`,`u128`,`usize`,`f32`,`f64`,`str`,`char`,`bool`,`Box`,`Option`,`Result`,`String`,`Vec`];return{name:`Rust`,aliases:[`rs`],keywords:{$pattern:e.IDENT_RE+`!?`,type:l,keyword:o,literal:s,built_in:c},illegal:`</`,contains:[e.C_LINE_COMMENT_MODE,e.COMMENT(`/\\*`,`\\*/`,{contains:[`self`]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:`symbol`,begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:`string`,variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:`char.escape`,match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:`number`,variants:[{begin:`\\b0b([01_]+)([ui](8|16|32|64|128|size)|f(32|64))?`},{begin:`\\b0o([0-7_]+)([ui](8|16|32|64|128|size)|f(32|64))?`},{begin:`\\b0x([A-Fa-f0-9_]+)([ui](8|16|32|64|128|size)|f(32|64))?`},{begin:`\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)([ui](8|16|32|64|128|size)|f(32|64))?`}],relevance:0},{begin:[/fn/,/\s+/,r],className:{1:`keyword`,3:`title.function`}},{className:`meta`,begin:`#!?\\[`,end:`\\]`,contains:[{className:`string`,begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],className:{1:`keyword`,3:`keyword`,4:`variable`}},{begin:[/for/,/\s+/,r,/\s+/,/in/],className:{1:`keyword`,3:`variable`,5:`keyword`}},{begin:[/type/,/\s+/,r],className:{1:`keyword`,3:`title.class`}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],className:{1:`keyword`,3:`title.class`}},{begin:e.IDENT_RE+`::`,keywords:{keyword:`Self`,built_in:c,type:l}},{className:`punctuation`,begin:`->`},a]}}function ou(e){let t=e.regex,n=e.COMMENT(`--`,`$`),r={scope:`string`,variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},i={begin:/"/,end:/"/,contains:[{match:/""/}]},a=[`true`,`false`,`unknown`],o=[`double precision`,`large object`,`with timezone`,`without timezone`],s=`bigint.binary.blob.boolean.char.character.clob.date.dec.decfloat.decimal.float.int.integer.interval.nchar.nclob.national.numeric.real.row.smallint.time.timestamp.varchar.varying.varbinary`.split(`.`),c=[`add`,`asc`,`collation`,`desc`,`final`,`first`,`last`,`view`],l=`abs.acos.all.allocate.alter.and.any.are.array.array_agg.array_max_cardinality.as.asensitive.asin.asymmetric.at.atan.atomic.authorization.avg.begin.begin_frame.begin_partition.between.bigint.binary.blob.boolean.both.by.call.called.cardinality.cascaded.case.cast.ceil.ceiling.char.char_length.character.character_length.check.classifier.clob.close.coalesce.collate.collect.column.commit.condition.connect.constraint.contains.convert.copy.corr.corresponding.cos.cosh.count.covar_pop.covar_samp.create.cross.cube.cume_dist.current.current_catalog.current_date.current_default_transform_group.current_path.current_role.current_row.current_schema.current_time.current_timestamp.current_path.current_role.current_transform_group_for_type.current_user.cursor.cycle.date.day.deallocate.dec.decimal.decfloat.declare.default.define.delete.dense_rank.deref.describe.deterministic.disconnect.distinct.double.drop.dynamic.each.element.else.empty.end.end_frame.end_partition.end-exec.equals.escape.every.except.exec.execute.exists.exp.external.extract.false.fetch.filter.first_value.float.floor.for.foreign.frame_row.free.from.full.function.fusion.get.global.grant.group.grouping.groups.having.hold.hour.identity.in.indicator.initial.inner.inout.insensitive.insert.int.integer.intersect.intersection.interval.into.is.join.json_array.json_arrayagg.json_exists.json_object.json_objectagg.json_query.json_table.json_table_primitive.json_value.lag.language.large.last_value.lateral.lead.leading.left.like.like_regex.listagg.ln.local.localtime.localtimestamp.log.log10.lower.match.match_number.match_recognize.matches.max.member.merge.method.min.minute.mod.modifies.module.month.multiset.national.natural.nchar.nclob.new.no.none.normalize.not.nth_value.ntile.null.nullif.numeric.octet_length.occurrences_regex.of.offset.old.omit.on.one.only.open.or.order.out.outer.over.overlaps.overlay.parameter.partition.pattern.per.percent.percent_rank.percentile_cont.percentile_disc.period.portion.position.position_regex.power.precedes.precision.prepare.primary.procedure.ptf.range.rank.reads.real.recursive.ref.references.referencing.regr_avgx.regr_avgy.regr_count.regr_intercept.regr_r2.regr_slope.regr_sxx.regr_sxy.regr_syy.release.result.return.returns.revoke.right.rollback.rollup.row.row_number.rows.running.savepoint.scope.scroll.search.second.seek.select.sensitive.session_user.set.show.similar.sin.sinh.skip.smallint.some.specific.specifictype.sql.sqlexception.sqlstate.sqlwarning.sqrt.start.static.stddev_pop.stddev_samp.submultiset.subset.substring.substring_regex.succeeds.sum.symmetric.system.system_time.system_user.table.tablesample.tan.tanh.then.time.timestamp.timezone_hour.timezone_minute.to.trailing.translate.translate_regex.translation.treat.trigger.trim.trim_array.true.truncate.uescape.union.unique.unknown.unnest.update.upper.user.using.value.values.value_of.var_pop.var_samp.varbinary.varchar.varying.versioning.when.whenever.where.width_bucket.window.with.within.without.year`.split(`.`),u=`abs.acos.array_agg.asin.atan.avg.cast.ceil.ceiling.coalesce.corr.cos.cosh.count.covar_pop.covar_samp.cume_dist.dense_rank.deref.element.exp.extract.first_value.floor.json_array.json_arrayagg.json_exists.json_object.json_objectagg.json_query.json_table.json_table_primitive.json_value.lag.last_value.lead.listagg.ln.log.log10.lower.max.min.mod.nth_value.ntile.nullif.percent_rank.percentile_cont.percentile_disc.position.position_regex.power.rank.regr_avgx.regr_avgy.regr_count.regr_intercept.regr_r2.regr_slope.regr_sxx.regr_sxy.regr_syy.row_number.sin.sinh.sqrt.stddev_pop.stddev_samp.substring.substring_regex.sum.tan.tanh.translate.translate_regex.treat.trim.trim_array.unnest.upper.value_of.var_pop.var_samp.width_bucket`.split(`.`),d=[`current_catalog`,`current_date`,`current_default_transform_group`,`current_path`,`current_role`,`current_schema`,`current_transform_group_for_type`,`current_user`,`session_user`,`system_time`,`system_user`,`current_time`,`localtime`,`current_timestamp`,`localtimestamp`],f=[`create table`,`insert into`,`primary key`,`foreign key`,`not null`,`alter table`,`add constraint`,`grouping sets`,`on overflow`,`character set`,`respect nulls`,`ignore nulls`,`nulls first`,`nulls last`,`depth first`,`breadth first`],p=u,m=[...l,...c].filter(e=>!u.includes(e)),h={scope:`variable`,match:/@[a-z0-9][a-z0-9_]*/},g={scope:`operator`,match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},_={match:t.concat(/\b/,t.either(...p),/\s*\(/),relevance:0,keywords:{built_in:p}};function v(e){return t.concat(/\b/,t.either(...e.map(e=>e.replace(/\s+/,`\\s+`))),/\b/)}let y={scope:`keyword`,match:v(f),relevance:0};function b(e,{exceptions:t,when:n}={}){let r=n;return t||=[],e.map(e=>e.match(/\|\d+$/)||t.includes(e)?e:r(e)?`${e}|0`:e)}return{name:`SQL`,case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:b(m,{when:e=>e.length<3}),literal:a,type:s,built_in:d},contains:[{scope:`type`,match:v(o)},y,_,h,r,i,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,g]}}var su=`[A-Za-z$_][0-9A-Za-z$_]*`,cu=`as.in.of.if.for.while.finally.var.new.function.do.return.void.else.break.catch.instanceof.with.throw.case.default.try.switch.continue.typeof.delete.let.yield.const.class.debugger.async.await.static.import.from.export.extends.using`.split(`.`),lu=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],uu=`Object.Function.Boolean.Symbol.Math.Date.Number.BigInt.String.RegExp.Array.Float32Array.Float64Array.Int8Array.Uint8Array.Uint8ClampedArray.Int16Array.Int32Array.Uint16Array.Uint32Array.BigInt64Array.BigUint64Array.Set.Map.WeakSet.WeakMap.ArrayBuffer.SharedArrayBuffer.Atomics.DataView.JSON.Promise.Generator.GeneratorFunction.AsyncFunction.Reflect.Proxy.Intl.WebAssembly`.split(`.`),du=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],fu=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],pu=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`global`],mu=[].concat(fu,uu,du);function hu(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=su,i={begin:`<>`,end:`</>`},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{let r=e[0].length+e.index,i=e.input[r];if(i===`<`||i===`,`){t.ignoreMatch();return}i===`>`&&(n(e,{after:r})||t.ignoreMatch());let a,o=e.input.substring(r);if(a=o.match(/^\s*=/)){t.ignoreMatch();return}if((a=o.match(/^\s+extends\s+/))&&a.index===0){t.ignoreMatch();return}}},s={$pattern:su,keyword:cu,literal:lu,built_in:mu,"variable.language":pu},c=`[0-9](_?[0-9])*`,l=`\\.(${c})`,u=`0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`,d={className:`number`,variants:[{begin:`(\\b(${u})((${l})|\\.)?|(${l}))[eE][+-]?(${c})\\b`},{begin:`\\b(${u})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:`\\b(0|[1-9](_?[0-9])*)n\\b`},{begin:`\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b`},{begin:`\\b0[bB][0-1](_?[0-1])*n?\\b`},{begin:`\\b0[oO][0-7](_?[0-7])*n?\\b`},{begin:`\\b0[0-7]+n?\\b`}],relevance:0},f={className:`subst`,begin:`\\$\\{`,end:`\\}`,keywords:s,contains:[]},p={begin:".?html`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`xml`}},m={begin:".?css`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`css`}},h={begin:".?gql`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`graphql`}},g={className:`string`,begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,f]},_={className:`comment`,variants:[e.COMMENT(/\/\*\*(?!\/)/,`\\*/`,{relevance:0,contains:[{begin:`(?=@[A-Za-z]+)`,relevance:0,contains:[{className:`doctag`,begin:`@[A-Za-z]+`},{className:`type`,begin:`\\{`,end:`\\}`,excludeEnd:!0,excludeBegin:!0,relevance:0},{className:`variable`,begin:`[A-Za-z$_][0-9A-Za-z$_]*(?=\\s*(-)|$)`,endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},v=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,{match:/\$\d+/},d];f.contains=v.concat({begin:/\{/,end:/\}/,keywords:s,contains:[`self`].concat(v)});let y=[].concat(_,f.contains),b=y.concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:[`self`].concat(y)}]),x={className:`params`,begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b},S={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,`(`,t.concat(/\./,r),`)*`)],scope:{1:`keyword`,3:`title.class`,5:`keyword`,7:`title.class.inherited`}},{match:[/class/,/\s+/,r],scope:{1:`keyword`,3:`title.class`}}]},C={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:`title.class`,keywords:{_:[...uu,...du]}},w={label:`use_strict`,className:`meta`,relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},T={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:`keyword`,3:`title.function`},label:`func.def`,contains:[x],illegal:/%/},E={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:`variable.constant`};function D(e){return t.concat(`(?!`,e.join(`|`),`)`)}let O={match:t.concat(/\b/,D([...fu,`super`,`import`].map(e=>`${e}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:`title.function`,relevance:0},k={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:`prototype`,className:`property`,relevance:0},A={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:`keyword`,3:`title.function`},contains:[{begin:/\(\)/},x]},j=`(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|`+e.UNDERSCORE_IDENT_RE+`)\\s*=>`,M={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(j)],keywords:`async`,className:{1:`keyword`,3:`title.function`},contains:[x]};return{name:`JavaScript`,aliases:[`js`,`jsx`,`mjs`,`cjs`],keywords:s,exports:{PARAMS_CONTAINS:b,CLASS_REFERENCE:C},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:`shebang`,binary:`node`,relevance:5}),w,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,_,{match:/\$\d+/},d,C,{scope:`attr`,match:r+t.lookahead(`:`),relevance:0},M,{begin:`(`+e.RE_STARTERS_RE+`|\\b(case|return|throw)\\b)\\s*`,keywords:`return throw case`,relevance:0,contains:[_,e.REGEXP_MODE,{className:`function`,begin:j,returnBegin:!0,end:`\\s*=>`,contains:[{className:`params`,variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:a},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:`xml`,contains:[{begin:o.begin,end:o.end,skip:!0,contains:[`self`]}]}]},T,{beginKeywords:`while if switch catch for`},{begin:`\\b(?!function)`+e.UNDERSCORE_IDENT_RE+`\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{`,returnBegin:!0,label:`func.def`,contains:[x,e.inherit(e.TITLE_MODE,{begin:r,className:`title.function`})]},{match:/\.\.\./,relevance:0},k,{match:`\\$[A-Za-z$_][0-9A-Za-z$_]*`,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:`title.function`},contains:[x]},O,E,S,A,{match:/\$[(.]/}]}}function gu(e){let t=e.regex,n=hu(e),r=su,i=[`any`,`void`,`number`,`boolean`,`string`,`object`,`never`,`symbol`,`bigint`,`unknown`],a={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:`keyword`,3:`title.class`}},o={beginKeywords:`interface`,end:/\{/,excludeEnd:!0,keywords:{keyword:`interface extends`,built_in:i},contains:[n.exports.CLASS_REFERENCE]},s={className:`meta`,relevance:10,begin:/^\s*['"]use strict['"]/},c={$pattern:su,keyword:cu.concat([`type`,`interface`,`public`,`private`,`protected`,`implements`,`declare`,`abstract`,`readonly`,`enum`,`override`,`satisfies`]),literal:lu,built_in:mu.concat(i),"variable.language":pu},l={className:`meta`,begin:`@[A-Za-z$_][0-9A-Za-z$_]*`},u=(e,t,n)=>{let r=e.contains.findIndex(e=>e.label===t);if(r===-1)throw Error(`can not find mode to replace`);e.contains.splice(r,1,n)};Object.assign(n.keywords,c),n.exports.PARAMS_CONTAINS.push(l);let d=n.contains.find(e=>e.scope===`attr`),f=Object.assign({},d,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,d,f]),n.contains=n.contains.concat([l,a,o,f]),u(n,`shebang`,e.SHEBANG()),u(n,`use_strict`,s);let p=n.contains.find(e=>e.label===`func.def`);return p.relevance=0,Object.assign(n,{name:`TypeScript`,aliases:[`ts`,`tsx`,`mts`,`cts`]}),n}function _u(e){let t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,i={className:`symbol`,begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},a={begin:/\s/,contains:[{className:`keyword`,begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=e.inherit(a,{begin:/\(/,end:/\)/}),s=e.inherit(e.APOS_STRING_MODE,{className:`string`}),c=e.inherit(e.QUOTE_STRING_MODE,{className:`string`}),l={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:`attr`,begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:`string`,endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[i]},{begin:/'/,end:/'/,contains:[i]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:`HTML, XML`,aliases:[`html`,`xhtml`,`rss`,`atom`,`xjb`,`xsd`,`xsl`,`plist`,`wsf`,`svg`],case_insensitive:!0,unicodeRegex:!0,contains:[{className:`meta`,begin:/<![a-z]/,end:/>/,relevance:10,contains:[a,c,s,o,{begin:/\[/,end:/\]/,contains:[{className:`meta`,begin:/<![a-z]/,end:/>/,contains:[a,o,c,s]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},i,{className:`meta`,end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[c]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:`tag`,begin:/<style(?=\s|>)/,end:/>/,keywords:{name:`style`},contains:[l],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:[`css`,`xml`]}},{className:`tag`,begin:/<script(?=\s|>)/,end:/>/,keywords:{name:`script`},contains:[l],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:[`javascript`,`handlebars`,`xml`]}},{className:`tag`,begin:/<>|<\/>/},{className:`tag`,begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:`name`,begin:n,relevance:0,starts:l}]},{className:`tag`,begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:`name`,begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function vu(e){let t=`true false yes no null`,n={className:`attr`,variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},r={className:`template-variable`,variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},i={className:`string`,relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:`char.escape`,relevance:0}]},a={className:`string`,relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,r]},o=e.inherit(a,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),s={className:`number`,begin:`\\b[0-9]{4}(-[0-9][0-9]){0,2}([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?(\\.[0-9]*)?([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?\\b`},c={end:`,`,endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},l={begin:/\{/,end:/\}/,contains:[c],illegal:`\\n`,relevance:0},u={begin:`\\[`,end:`\\]`,contains:[c],illegal:`\\n`,relevance:0},d=[n,{className:`meta`,begin:`^---\\s*$`,relevance:10},{className:`string`,begin:`[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*`},{begin:`<%[%=-]?`,end:`[%-]?%>`,subLanguage:`ruby`,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:`type`,begin:`!\\w+![\\w#;/?:@&=+$,.~*'()[\\]]+`},{className:`type`,begin:`!<[\\w#;/?:@&=+$,.~*'()[\\]]+>`},{className:`type`,begin:`![\\w#;/?:@&=+$,.~*'()[\\]]+`},{className:`type`,begin:`!![\\w#;/?:@&=+$,.~*'()[\\]]+`},{className:`meta`,begin:`&`+e.UNDERSCORE_IDENT_RE+`$`},{className:`meta`,begin:`\\*`+e.UNDERSCORE_IDENT_RE+`$`},{className:`bullet`,begin:`-(?=[ ]|$)`,relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},s,{className:`number`,begin:e.C_NUMBER_RE+`\\b`,relevance:0},l,u,i,a],f=[...d];return f.pop(),f.push(o),c.contains=f,{name:`YAML`,case_insensitive:!0,aliases:[`yml`],contains:d}}var yu=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`],bu=Object.freeze({bold:!1,dim:!1,italic:!1,underline:!1,inverse:!1,hidden:!1,strike:!1}),xu=`ansi-esc`,Su=/^(?:color:#[0-9a-f]{6}(?:;background-color:#[0-9a-f]{6})?|background-color:#[0-9a-f]{6})$/,Cu=String.raw`(?:\x1b|�|\\x1[bB]|\\u001[bB]|\\033|\\e|\^\[)`,wu=new RegExp(Cu,`g`),Tu=/\[([0-?]{0,64})[ -/]{0,8}([@-~])/y,Eu=new RegExp(String.raw`\][^\n]{0,2048}?(?:${Cu}\\\\?|\x07|�|\\a|\\x07|\\007|\\u0007)`,`y`),Du=/[()][0-9A-Za-z]/y;function Ou(e){let t=``,n={...bu},r=``,i=0,a=n=>{if(n<=i)return;let a=Fu(e.slice(i,n));t+=r?`${r}${a}</span>`:a};wu.lastIndex=0;for(let o=wu.exec(e);o;o=wu.exec(e)){let s=o.index,c=s+o[0].length,l=-1,u;for(let t of[Tu,Eu,Du]){t.lastIndex=c;let n=t.exec(e);if(n){l=c+n[0].length,t===Tu&&n[2]===`m`&&(u=n[1]);break}}l<0&&o[0]===`\x1B`&&(l=c),!(l<0)&&(a(s),t+=`<span class="${xu}">${Fu(e.slice(s,l))}</span>`,u!==void 0&&(n=ku(n,u),r=Pu(n)),i=l,wu.lastIndex=l)}return a(e.length),t}function ku(e,t){if(!/^[0-9:;]*$/.test(t))return e;let n={...e},r=t===``?[`0`]:t.split(`;`);for(let e=0;e<r.length;e++){let[t,...i]=r[e].split(`:`),a=t===``?0:Number(t);if(a===38||a===48||a===58){let t;if(i.length>0)t=Au(i[0],i[0]===`2`&&i.length>4?i.slice(2,5):i.slice(1));else{let n=r[e+1],i=n===`5`?1:n===`2`?3:0;t=Au(n,r.slice(e+2,e+2+i)),e+=1+i}t&&a===38&&(n.fg=t),t&&a===48&&(n.bg=t);continue}a===0?Object.assign(n,bu,{fg:void 0,bg:void 0}):a===1?n.bold=!0:a===2?n.dim=!0:a===3?n.italic=!0:a===4?n.underline=i[0]!==`0`:a===7?n.inverse=!0:a===8?n.hidden=!0:a===9?n.strike=!0:a===21?n.underline=!0:a===22?n.bold=n.dim=!1:a===23?n.italic=!1:a===24?n.underline=!1:a===27?n.inverse=!1:a===28?n.hidden=!1:a===29?n.strike=!1:a>=30&&a<=37?n.fg={index:a-30}:a===39?n.fg=void 0:a>=40&&a<=47?n.bg={index:a-40}:a===49?n.bg=void 0:a>=90&&a<=97?n.fg={index:a-90+8}:a>=100&&a<=107&&(n.bg={index:a-100+8})}return n}function Au(e,t){let n=t.map(e=>e===``?NaN:Number(e));if(n.every(e=>Number.isInteger(e)&&e>=0&&e<=255)){if(e===`5`&&n.length===1)return ju(n[0]);if(e===`2`&&n.length===3)return{hex:Mu(n[0],n[1],n[2])}}}function ju(e){if(e<16)return{index:e};if(e>=232){let t=8+(e-232)*10;return{hex:Mu(t,t,t)}}let t=e=>e===0?0:55+e*40,n=e-16;return{hex:Mu(t(Math.floor(n/36)),t(Math.floor(n/6)%6),t(n%6))}}function Mu(...e){return`#${e.map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function Nu(e){return e<8?yu[e]:`bright-${yu[e-8]}`}function Pu(e){let t=e.inverse?e.bg:e.fg,n=e.inverse?e.fg:e.bg,r=[],i=[];return t&&`index`in t?r.push(`ansi-fg-${Nu(t.index)}`):t?i.push(`color:${t.hex}`):e.inverse&&r.push(`ansi-fg-inverse`),n&&`index`in n?r.push(`ansi-bg-${Nu(n.index)}`):n?i.push(`background-color:${n.hex}`):e.inverse&&r.push(`ansi-bg-inverse`),e.bold&&r.push(`ansi-bold`),e.dim&&r.push(`ansi-dim`),e.italic&&r.push(`ansi-italic`),e.underline&&r.push(`ansi-underline`),e.strike&&r.push(`ansi-strike`),e.hidden&&r.push(`ansi-hidden`),r.length===0&&i.length===0?``:`<span${r.length?` class="${r.join(` `)}"`:``}${i.length?` style="${i.join(`;`)}"`:``}>`}function Fu(e){return e.replace(/[&<>"']/g,e=>e===`&`?`&`:e===`<`?`<`:e===`>`?`>`:e===`"`?`"`:`'`)}var Iu={bash:Il,css:Gl,diff:Kl,javascript:tu,json:nu,markdown:ru,python:iu,rust:au,sql:ou,typescript:gu,xml:_u,yaml:vu};for(let[e,t]of Object.entries(Iu))Fl.registerLanguage(e,t);function Lu(e,t){if(t===`plaintext`)return qo(e);if(t===`ansi`)return Ou(e);try{return Fl.highlight(e,{language:t,ignoreIllegals:!0}).value}catch{return qo(e)}}function Ru(e,t,n=t){return`<code class="hljs language-${n}">${Lu(`${e.replace(/\n$/,``)}\n`,t)}</code>`}var zu=`<button type="button" class="${rn}" title="${T}"></button>`;function Bu(e,t){let n=fn(t);return`<span class="${ts}"><pre>${Ru(e,n,/^\s*(lightbox|mermaid)\s*$/i.exec(t??``)?.[1].toLowerCase()??n)}</pre>${zu}</span>\n`}var Vu=/<span\b[^>]*>|<\/span>|\n|[^<\n]+|</g;function Hu(e){let t=[],n=[],r=``;for(let[i]of e.matchAll(Vu))i===`
|
|
60
|
-
`?(t.push(r+`</span>`.repeat(n.length)),r=n.join(``)):i===`</span>`?(n.pop(),r+=i):(i.startsWith(`<span`)&&n.push(i),r+=i);return t.push(r+`</span>`.repeat(n.length)),t}var Uu=/^(\s*\d+\t)([\s\S]*)$/,Wu=/^\s*\d+$/;function Gu(e){let t=0,n=0,r=0;for(let i of e)i.trim()&&(t++,Uu.test(i)?(n++,r++):Wu.test(i)&&n++);return t>0&&n===t&&r>0}function Ku(e){return e.replace(/[&<>"']/g,e=>e===`&`?`&`:e===`<`?`<`:e===`>`?`>`:e===`"`?`"`:`'`)}var qu=`frizz-code-gutter`;function Ju(e,t){let n=e.split(`
|
|
61
|
-
`);if(!Gu(n))return Lu(e,t);let r=[],i=[];for(let e of n){let t=Uu.exec(e);t?(r.push(t[1]),i.push(t[2])):e.trim()&&Wu.test(e)?(r.push(e),i.push(``)):(r.push(``),i.push(e))}let a=Hu(Lu(i.join(`
|
|
62
|
-
`),t));return r.map((e,t)=>(e?`<span class="${qu}">${Ku(e)}</span>`:``)+(a[t]??``)).join(`
|
|
63
|
-
`)}var Yu=`md-diff-row`,Xu=/(?:^|\s)lang(?:uage)?\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"']+))/i;function Zu(e){let t=(e??``).trim(),n=t.split(/\s+/,1)[0].toLowerCase(),r=Xu.exec(t.slice(n.length)),i=r&&(r[1]??r[2]??r[3]).trim().toLowerCase()||null;if(n===`diff`||n===`patch`)return{declared:i};let a=/^(.+)-diff$/.exec(n)??/^diff-(.+)$/.exec(n);return a?{declared:a[1]}:null}var Qu=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/,$u=/^(?:index [0-9a-f]+\.\.[0-9a-f]+|(?:new|deleted) file mode |(?:old|new) mode |(?:dis)?similarity index |(?:rename|copy) (?:from|to) |Binary files )/;function ed(e){let t=[],n=!1,r=0,i=0,a=null,o=null;for(let s=0;s<e.length;s++){let c=e[s];if(/^diff (?:--git|--cc|--combined|-\S+) /.test(c)||/^Index: /.test(c)){t.push({kind:`file`,raw:c}),n=!0,r=i=0,a=o=null;continue}if(c.startsWith(`@@`)){let e=Qu.exec(c);t.push({kind:`hunk`,raw:c}),n=!1,a=e?Number(e[1]):null,o=e?Number(e[3]):null,r=e?Number(e[2]??1):0,i=e?Number(e[4]??1):0;continue}if(n&&$u.test(c)){t.push({kind:/^index /.test(c)?`file`:`meta`,raw:c});continue}if(r===0&&i===0&&c.startsWith(`--- `)&&e[s+1]?.startsWith(`+++ `)){t.push({kind:`file`,raw:c},{kind:`file`,raw:e[s+1]}),s++,n=!0,a=o=null;continue}n=!1,c.startsWith(`\\ `)?t.push({kind:`meta`,raw:c}):c.startsWith(`+`)?(t.push({kind:`add`,raw:c,line:o??void 0}),o!==null&&o++,i>0&&i--):c.startsWith(`-`)?(t.push({kind:`del`,raw:c,line:a??void 0}),a!==null&&a++,r>0&&r--):(t.push({kind:`ctx`,raw:c,line:o??void 0}),a!==null&&a++,o!==null&&o++,r>0&&r--,i>0&&i--)}return t}function td(e){let t=e.slice(4).split(` `,1)[0].trim().replace(/^[ab]\//,``);return t&&t!==`/dev/null`?t:null}function nd(e){let t=[];for(let n=0;n<e.length;n++){if(e[n].kind!==`file`||!e[n].raw.startsWith(`--- `))continue;let r=e[n+1],i=(r?.raw.startsWith(`+++ `)?td(r.raw):null)??td(e[n].raw);i&&t.push(i)}return t}var rd=e=>e.map(qo);function id(e,t){return e.length===0?[]:t===`plaintext`||t===`ansi`?rd(e):Hu(Lu(e.join(`
|
|
64
|
-
`),t))}function ad(e,t={}){let n=e.replace(/\n$/,``).split(`
|
|
65
|
-
`),r=ed(n),i=nd(r),a=V(t.label),o=t.declared?fn(t.declared):a===`plaintext`?V(i[0]):a,s=r.some(e=>e.kind===`hunk`)||!r.some(e=>e.kind===`ctx`&&e.raw!==``&&!e.raw.startsWith(` `)),c=e=>e.kind===`ctx`&&!(s&&e.raw.startsWith(` `))?[``,e.raw]:[e.raw[0],e.raw.slice(1)],l=r.some(e=>e.line!==void 0),u=[],d=0,f=0,p=0;for(let e=0;e<r.length;){let t=r[e];if(t.kind===`hunk`||t.kind===`file`||t.kind===`meta`){u.push(`<span class="${Yu} md-diff-${t.kind}">${qo(t.raw)}\n</span>`),e++;continue}let n=e;for(;n<r.length&&(r[n].kind===`add`||r[n].kind===`del`||r[n].kind===`ctx`);)n++;let i=r.slice(e,n).map(e=>({row:e,parts:c(e)})),a=id(i.filter(({row:e})=>e.kind!==`add`).map(({parts:e})=>e[1]),o),s=id(i.filter(({row:e})=>e.kind!==`del`).map(({parts:e})=>e[1]),o),m=0,h=0;for(let{row:e,parts:[t]}of i){let n=e.kind===`del`?a[m]:s[h];e.kind!==`add`&&m++,e.kind!==`del`&&h++,e.kind===`add`&&d++,e.kind===`del`&&f++,e.line!==void 0&&(p=Math.max(p,e.line));let r=l?`<span class="md-diff-num"${e.line===void 0?``:` data-line="${e.line}"`}></span>`:``;u.push(`<span class="${Yu} md-diff-${e.kind}">${r}<span class="md-diff-sign">${qo(t)}</span><span class="md-diff-text">${n??``}\n</span></span>`)}e=n}return{html:u.join(``),additions:d,deletions:f,file:i.length===1?i[0]:null,digits:l?String(p).length:0,lines:n.length}}var od=`md-line`,sd=`is-marked`,cd=/\{\s*(\d[\d\s,–-]*)\}/;function ld(e){let t=cd.exec(e??``);if(!t)return null;let n=[];for(let e of t[1].split(/[\s,]+/)){let t=/^(\d{1,7})(?:[–-](\d{1,7}))?$/.exec(e);if(!t)continue;let r=Number(t[1]),i=t[2]===void 0?r:Number(t[2]);r>=1&&i>=r&&n.push([r,i])}return n.length>0?n:null}function ud(e,t){return e.some(([e,n])=>t>=e&&t<=n)}function dd(e,t){let n=Hu(e);return n.at(-1)?.replace(/<[^>]*>/g,``)===``&&n.pop(),n.map((e,n)=>`<span class="${od}${ud(t,n+1)?` ${sd}`:``}">${e}\n</span>`).join(``)}var fd=`md-code-frame`,pd=`md-code-lined`,md=`md-diff`,hd=/^(?:lightbox|mermaid)$/i,gd=!0;function _d(e){let t=gd;gd=!1;try{return e()}finally{gd=t}}function vd(e){if(e.label===void 0)return fn(e.info);let t=Ar(e.info)?.language;return t?fn(t):V(e.label)}function yd(e){let t=`${e.text.replace(/\n$/,``)}\n`,n=t.split(`
|
|
66
|
-
`).length-1,r=Zu(e.info),i=r?null:ld(e.info),a=[],o,s;if(r){let t=ad(e.text,{declared:r.declared,label:e.label});o=`<code class="hljs language-diff">${t.html}</code>`,a.push(md),t.digits>0&&a.push(`md-diff-n${Math.min(t.digits,6)}`),s={file:t.file,additions:t.additions,deletions:t.deletions}}else if(i){let n=vd(e);o=`<code class="hljs language-${n}">${dd(Lu(t,n),i)}</code>`,a.push(pd)}else o=Ru(e.text,vd(e));let c=!1;if(i)for(let e=25;e<=n&&!c;e++)c=ud(i,e);let l=gd&&e.closed&&n>40&&!c,u=l&&xr(e.text);return l&&a.push(u?Ii:`${Ii} ${wa}`),{code:o,classes:a,lines:n,long:l,open:u,diff:s}}var bd=28,xd=e=>e.length>=bd?` title="${qo(e)}"`:``;function Sd({additions:e,deletions:t}){return e===0&&t===0?``:`<span class="md-diff-stat">`+(e>0?`<span class="md-diff-adds">+${e}</span>`:``)+(t>0?`<span class="md-diff-dels">−${t}</span>`:``)+`</span>`}var Cd=e=>`<button type="button" class="${ro}" aria-expanded="${e.open}">${Na(e.lines,e.open)}</button>`;function wd(e){let t=e.length===1;if(t&&hd.test(e[0].info.trim().split(/\s+/,1)[0]))return Bu(e[0].text,e[0].closed?e[0].info:``);let n=e.map(yd),r=t?e[0].label??n[0].diff?.file??void 0:void 0,i=!t||r!==void 0;if(!(i||n.some(e=>e.long))){let[{code:t,classes:r}]=n;return r.length===0?Bu(e[0].text,e[0].info):`<span class="${ts}"><pre class="${r.join(` `)}">${t}</pre>${zu}</span>\n`}let a=t?0:ls(e.map(e=>e.label??``)),o=``;t&&r!==void 0?(e[0].label===void 0&&n[0].classes.push(`md-diff-titled`),o=`<span class="${ui}"><span class="${yi}"${xd(r)}>${qo(r)}</span>${n[0].diff?Sd(n[0].diff):``}</span>`):t||(o=`<span class="${ui}" role="tablist">`+e.map((e,t)=>{let n=t===a,r=e.label??``;return`<button type="button" class="${Oi}${n?` ${ha}`:``}" role="tab" aria-selected="${n}"${xd(r)}>${qo(r)}</button>`}).join(``)+`</span>`);let s=n.map((e,n)=>{let r=[...i?[n===a?`${qr} ${ha}`:qr]:[],...e.classes];return`<pre${r.length>0?` class="${r.join(` `)}"`:``}${t?``:` role="tabpanel"`}>${e.code}</pre>`+(e.long?Cd(e):``)}).join(``);return`<span class="${ts} ${fd}${i?` ${Va}`:``}">${o}${s}${zu}</span>\n`}var Td={name:`codeTabs`,level:`block`,tokenizer(){},renderer(e){return wd(e.tabs)}},Ed=/^[a-zA-Z]:\\(?!\\)/,Dd=/(?<![A-Za-z0-9])[A-Za-z]:\\/,Od=Ol.rules.inline.normal.link;function kd(e,t){let n=t.length;for(;n>0&&!/\s/.test(t[n-1]);)n--;n>0&&(e.inPath=!1,e.tail=``);let r=e.tail+t.slice(n);e.inPath||=Dd.test(r),e.tail=r.slice(-3)}function Ad(e){if(!/^[a-zA-Z]:/.test(e.href))return;let t=Od.exec(e.raw);if(!t)return;let n=t[2].trim();n.startsWith(`<`)&&n.endsWith(`>`)&&(n=n.slice(1,-1)),Ed.test(n)&&(e.href=n)}function jd(e){let t={inPath:!1,tail:``};for(let n=0;n<e.length;n++){let r=e[n];(r.type===`link`||r.type===`image`)&&Ad(r);let i=gn(r);for(let e of i)jd(e);if(r.type===`text`&&i.length===0){kd(t,r.raw);continue}if(r.type===`escape`){kd(t,r.raw),r.raw!==`\\\\`&&t.inPath&&(e[n]={type:`text`,raw:r.raw,text:r.raw});continue}t.inPath=!1,t.tail=``}}var Md=`md-callout`,Nd=`md-callout-title`,Pd={note:`Note`,tip:`Tip`,important:`Important`,warning:`Warning`,caution:`Caution`},Fd={info:`note`,hint:`tip`,attention:`warning`,danger:`caution`,error:`caution`};function Id(e){let t=e.toLowerCase();return Object.hasOwn(Pd,t)?t:Object.hasOwn(Fd,t)?Fd[t]:null}var Ld=/^\[!([A-Za-z]+)\](?=[ \t]|\n|$)/;function Rd(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.type===`list`){for(let e of n.items)Rd(e.tokens);continue}if(n.type!==`blockquote`)continue;let r=n,i=zd(r);i&&(e[t]=i),Rd(i?i.tokens:r.tokens)}}function zd(e){let t=e.tokens.findIndex(e=>e.type!==`space`),n=e.tokens[t];if(n?.type!==`paragraph`)return null;let r=n,i=r.tokens,a=i[0];if(a?.type!==`text`)return null;let o=Ld.exec(a.text);if(!o||!a.raw.startsWith(o[0]))return null;let s=Id(o[1]);if(!s)return null;let c=[],l=i.slice();for(l[0]=Bd(a,o[0].length);l.length>0;){let e=l[0];if(e.type===`br`){l.shift();break}if(e.type===`text`){let t=e.text.indexOf(`
|
|
67
|
-
`);if(t<0){c.push(l.shift());continue}c.push(Bd(e,0,t)),l[0]=Bd(e,t+1);break}if(e.raw.includes(`
|
|
68
|
-
`))break;c.push(l.shift())}Vd(c),Vd(l);let u=e.tokens.slice(t+1);if(l.length>0){let e=l.map(e=>e.raw).join(``);u.unshift({...r,raw:e,text:e,tokens:l})}return{type:`callout`,raw:e.raw,kind:s,titleTokens:Hd(c),tokens:u}}function Bd(e,t,n){return{...e,raw:e.raw.slice(t,n),text:e.text.slice(t,n)}}function Vd(e){for(let[t,n]of[[0,`trimStart`],[-1,`trimEnd`]])for(let r=e.at(t);r?.type===`text`;r=e.at(t)){let i=r,a={...i,raw:i.raw[n](),text:i.text[n]()};if(e.splice(t,1,...a.raw?[a]:[]),a.raw)break}}function Hd(e){return e.map(e=>{if(e.type===`html`)return{type:`text`,raw:e.raw,text:e.raw,escaped:!1};let t=e.tokens;return Array.isArray(t)?{...e,tokens:Hd(t)}:e})}var Ud={name:`callout`,level:`block`,childTokens:[`titleTokens`,`tokens`],tokenizer(){},renderer(e){let{kind:t,titleTokens:n,tokens:r}=e;return`<blockquote class="${Md} ${Md}-${t}"><p class="${Nd}">${n.length>0?this.parser.parseInline(n):Pd[t]}</p>\n${this.parser.parse(r)}</blockquote>\n`}},X=_a();function Wd({caption:e,children:t}){return(0,X.jsxs)(`figure`,{className:Gd,children:[(0,X.jsx)(`div`,{className:Kd,children:t}),e]})}var Gd=`frizz-image-frame max-w-full`,Kd=`flex justify-center bg-panel-2 p-1.5`,qd=`block max-h-[420px] max-w-full w-auto rounded-md object-contain`,Jd=/^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,Yd={del(e){let t=Jd.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}},Xd=/^:?-+:?$/,Zd=/^ {0,3}$/,Qd=/^[ \t]*$/;function $d(e){let t=[],n=``;for(let r=0;r<e.length;r++){let i=e[r];i===`\\`&&r+1<e.length?(n+=i+e[r+1],r++):i===`|`?(t.push(n),n=``):n+=i}return t.push(n),t.length<4||!Zd.test(t[0])||!Qd.test(t.at(-1))?null:t.slice(1,-1).map(e=>e.trim())}function ef(e){let t=[],n=0;for(let r of e.split(`
|
|
69
|
-
`)){let e=$d(r);if(!e)break;if(e.every(e=>Xd.test(e)))return null;t.push(e),n+=r.length+1}return t.length<2?null:{raw:e.slice(0,Math.min(n,e.length)),rows:t}}var tf={name:`headerlessTable`,level:`block`,start(e){let t=0;for(let n of e.split(`
|
|
70
|
-
`)){if(n.includes(`|`)&&ef(e.slice(t)))return t;t+=n.length+1}},tokenizer(e){let t=ef(e);if(!t)return;let n=Math.max(...t.rows.map(e=>e.length)),r=t.rows.map(e=>Array.from({length:n},(t,n)=>({tokens:this.lexer.inline(e[n]??``)})));return{type:`headerlessTable`,raw:t.raw,rows:r}},renderer(e){return`<table>\n<tbody>${e.rows.map(e=>`<tr>${e.map(e=>`<td>${this.parser.parseInline(e.tokens)}</td>`).join(``)}</tr>`).join(`
|
|
71
|
-
`)}</tbody></table>\n`}},nf=/^\[([ xX/\-?])\](?:[ \t]+|[ \t]*$)/,rf={" ":{className:``,label:`To do`},x:{className:`md-task-checked`,label:`Done`},"/":{className:`md-task-in-progress`,label:`In progress`},"-":{className:`md-task-cancelled`,label:`Cancelled`},"?":{className:`md-task-blocked`,label:`Blocked`}},af={name:`frizzTaskStatus`,level:`inline`,tokenizer(){},renderer(e){let{status:t}=e,n=rf[t];return`<span class="md-task${n.className?` ${n.className}`:``}" title="${n.label}"></span>`}},of={name:`frizzTaskText`,level:`inline`,tokenizer(){},renderer(e){return`<span class="md-task-text">${this.parser.parseInline(e.tokens)}</span>`}};function sf(e){let t=e.tokens[0],n=t&&`tokens`in t?t.tokens:void 0;if(!Array.isArray(n)||n[0]?.type===`frizzTaskStatus`)return;let r,i;if(e.task)r=e.checked?`x`:` `,i=``,e.task=!1,e.checked=void 0;else{let t=nf.exec(e.text);if(!t)return;let a=t[0].length,o=[];for(let e=0;e<n.length&&a>0;e++){let t=n[e];if(t.type!==`text`)return;let r=Math.min(a,t.raw.length);o.push({token:t,count:r}),a-=r}if(a>0)return;for(let{token:e,count:t}of o)e.raw=e.raw.slice(t),e.text=e.text.slice(t);for(let e=n.length-1;e>=0;e--)n[e].type===`text`&&!n[e].raw&&n.splice(e,1);e.text=e.text.slice(t[0].length),r=t[1]===`X`?`x`:t[1],i=t[0]}let a=n.splice(0,n.length);n.push({type:`frizzTaskStatus`,raw:i,status:r}),a.length&&n.push({type:`frizzTaskText`,raw:``,tokens:a})}var cf={breaks:!0,extensions:[tf,af,of,Td,Ud],tokenizer:Yd,hooks:{processAllTokens(e){return jd(e),kt(e),fr(e),Rd(e),e}},walkTokens(e){e.type===`list_item`&&sf(e)},renderer:{code:e=>wd([{info:e.lang??``,text:e.text,closed:zo(e)}]),blockquote:sa}},lf=new Nl(cf),uf=new Nl({...cf,breaks:!1});function df(e,t){if(!e.trim())return``;let{result:n,quotes:r}=Ao(()=>Yi(t?.githubRepo,()=>t?.document?_d(()=>uf.parse(e,{async:!1})):lf.parse(e,{async:!1})));return wf(n,{block:!0,baseDir:t?.baseDir,homeDir:t?.homeDir,project:t?.project,quotes:r})}function ff(e,t){if(!e.trim())return``;let{baseDir:n,homeDir:r,project:i,githubRepo:a}=t??{};return wf(Yi(a,()=>lf.parseInline(e,{async:!1})),{baseDir:n,homeDir:r,project:i})}function pf(e){let t=e.match(/^?---\r?\n[\s\S]*?\r?\n---\r?\n?/);return t?e.slice(t[0].length):e}var mf=new Set(`h1.h2.h3.h4.h5.h6.p.br.hr.strong.em.del.code.pre.blockquote.ul.ol.li.a.img.button.table.thead.tbody.tr.th.td.span.details.summary.kbd.sub.sup.mark`.split(`.`)),hf=new Set([`href`,`src`,`alt`,`title`,`type`]),gf=RegExp(`^(?:hljs(?:-[a-z0-9_-]+)?|ansi-[a-z-]+|language-[a-z0-9-]+|md-task(?:-(?:checked|in-progress|cancelled|blocked|text))?|md-diff-(?:row|add|del|ctx|hunk|file|meta|num|sign|text|stat|adds|dels)|${[ts,fd,Va,ui,yi,od,sd].join(`|`)})$`),_f=(...e)=>RegExp(`^(?:${e.join(`|`)})$`),vf={code:gf,span:gf,pre:_f(qr,ha,pd,md,`md-diff-titled`,`md-diff-n[1-6]`,Ii,wa),button:_f(rn,ro,Oi,ha),blockquote:_f(Md,`${Md}-[a-z]+`),p:_f(Nd)};function yf(e,t,n){let r=vf[e];return t.split(/\s+/).filter(t=>r?.test(t)||e===`blockquote`&&Rr(t,n)!==void 0).join(` `)}var bf=new Set([`http:`,`https:`,`mailto:`]);function xf(e){try{return bf.has(new URL(e,`http://frizz.invalid/`).protocol)}catch{return!1}}var Sf={details:{open:/^[^]*$/},ol:{start:/^\d{1,9}$/},span:{style:Su,role:/^tablist$/,"data-line":/^\d{1,9}$/},button:{role:/^tab$/,"aria-selected":/^(?:true|false)$/,"aria-expanded":/^(?:true|false)$/},pre:{role:/^tabpanel$/},th:{align:/^(?:left|center|right)$/},td:{align:/^(?:left|center|right)$/}},Cf=new Set([`script`,`style`,`textarea`,`title`,`xmp`,`iframe`,`frame`,`frameset`,`object`,`embed`,`applet`,`noscript`,`template`,`svg`,`math`]);function wf(e,{block:t=!1,baseDir:n,homeDir:r,project:i,quotes:a}={}){let o=document.createElement(`template`);return o.innerHTML=e,Tf(o.content,{block:t,baseDir:n,homeDir:r,project:i,quotes:a}),o.innerHTML}function Tf(e,t){let{block:n}=t;for(let r of Array.from(e.children)){let e=r.tagName.toLowerCase();if(!mf.has(e)){Cf.has(e)?r.remove():Of(r,t);continue}(e===`a`||e===`img`)&&Ef(r,e===`a`?`href`:`src`,t);let i;if(e===`a`){let e=x(r.getAttribute(`href`),void 0,t.project);e&&r.setAttribute(`href`,e);let n=Za(r.getAttribute(`href`));if(n){let e=Ye(n);if(e)r.setAttribute(`href`,e),r.setAttribute(`title`,n.display),i=n.filePath;else{let e=n.filePath&&Te(n.filePath),i=document.createElement(`button`);for(i.type=`button`,i.className=`local-file-action`,i.title=e?`Read ${n.display}`:n.display,n.filePath&&i.setAttribute(`data-local-path`,n.filePath);r.firstChild;)i.append(r.firstChild);r.replaceWith(i),Tf(i,t);continue}}}if(e===`img`){let e=Za(r.getAttribute(`src`)),t=e&&Ye(e);if(!t){r.remove();continue}r.setAttribute(`src`,t),r.setAttribute(`title`,e.display),i=e.filePath,r.getAttribute(`alt`)||r.setAttribute(`alt`,e.display)}for(let n of Array.from(r.attributes)){let i=n.name.toLowerCase();if(i===`class`){let i=yf(e,n.value,t.quotes);i?r.setAttribute(`class`,i):r.removeAttribute(n.name);continue}let a=Sf[e]?.[i];if(a){a.test(n.value)||r.removeAttribute(n.name);continue}if(!hf.has(i)){r.removeAttribute(n.name);continue}i===`href`&&!xf(n.value)&&r.removeAttribute(n.name)}if(i!==void 0&&(r.setAttribute(`data-local-path`,i),r.setAttribute(`data-local-image`,`true`)),e===`img`&&n&&Df(r),e===`a`){r.setAttribute(`target`,`_blank`),r.setAttribute(`rel`,`noopener noreferrer`),r.removeAttribute(`data-gh-ref`);let e=re(r.getAttribute(`href`));e&&r.setAttribute(`data-gh-ref`,e)}if(Tf(r,t),e===`details`&&xo(r),e===`blockquote`){let e=Rr(r.getAttribute(`class`)??``,t.quotes);e!==void 0&&po(r,e)}}}function Ef(e,t,{baseDir:n,homeDir:r}){if(!n&&!r)return;let i=Ve(e.getAttribute(t),n??``,r);i&&e.setAttribute(t,i)}function Df(e){let t=e.ownerDocument,n=t.createElement(`span`);n.className=`${Gd} md-image-frame`;let r=t.createElement(`span`);r.className=Kd,e.replaceWith(n),n.append(r),r.append(e),e.setAttribute(`class`,qd)}function Of(e,t){let n=e.ownerDocument.createDocumentFragment();for(;e.firstChild;)n.append(e.firstChild);Tf(n,t),e.replaceWith(n)}function kf(){let e=Da(),t=(0,q.useCallback)(()=>L(e),[e]);return(0,q.useSyncExternalStore)(p,t,t)}function Af(){let e=Da(),t=(0,q.useCallback)(()=>ps(e),[e]);return(0,q.useSyncExternalStore)(Pr,t,t)}function jf(e,t){let n=kf(),r=Af(),i=Da(),{baseDir:a,asDocument:o}=t??{},s=a??r.dir,c=(0,q.useMemo)(()=>df(e,{baseDir:s,homeDir:r.home,document:o,project:i,githubRepo:n}),[e,s,r.home,o,i,n]);return Mf(c),c}function Mf(e){let t=(0,q.useMemo)(()=>as(e),[e]);(0,q.useEffect)(()=>{t.length>0&&cn(t)},[t])}function Nf(e){let t=kf(),n=Af(),r=Da(),i=(0,q.useMemo)(()=>ff(e,{baseDir:n.dir,homeDir:n.home,project:r,githubRepo:t}),[e,n.dir,n.home,r,t]);return Mf(i),i}var Pf=e=>new Set(e.split(/\s+/).filter(Boolean)),Ff=Pf(`
|
|
72
|
-
break case catch class const continue debugger default delete do else enum export extends
|
|
73
|
-
false finally for function if import in instanceof new null return super switch this throw
|
|
74
|
-
true try typeof var void while with yield async await let static get set of as from
|
|
75
|
-
interface type namespace declare readonly public private protected implements abstract
|
|
76
|
-
package struct func go defer chan map fn impl trait mut pub use mod match loop where
|
|
77
|
-
int long short float double char boolean byte final synchronized volatile transient native
|
|
78
|
-
`),If=Pf(`
|
|
79
|
-
string number boolean object symbol bigint unknown any never void undefined
|
|
80
|
-
String Number Boolean Object Array Promise Map Set Record Partial
|
|
81
|
-
i8 i16 i32 i64 u8 u16 u32 u64 usize isize f32 f64 str Vec Option Result Box
|
|
82
|
-
int8 int16 int32 int64 uint float32 float64 error rune
|
|
83
|
-
`),Lf={typescript:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:Ff,types:If},javascript:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:Ff,types:If},go:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:Ff,types:If},rust:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:Ff,types:If},java:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:Ff,types:If},c:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:Ff,types:If},cpp:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:Ff,types:If},css:{line:null,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:Pf(`important media supports keyframes import from to`),types:new Set},json:{line:null,block:null,quotes:[`"`],keywords:Pf(`true false null`),types:new Set},python:{line:`#`,block:null,quotes:[`"`,`'`],keywords:Pf(`
|
|
84
|
-
def class return if elif else for while break continue pass import from as with try except
|
|
85
|
-
finally raise lambda yield global nonlocal del assert async await and or not in is None True
|
|
86
|
-
False self lambda`),types:Pf(`int float str bool list dict set tuple bytes object`)},shell:{line:`#`,block:null,quotes:[`"`,`'`],keywords:Pf(`if then else elif fi for while do done case esac in function return export local echo cd exit set unset source`),types:new Set},yaml:{line:`#`,block:null,quotes:[`"`,`'`],keywords:Pf(`true false null yes no on off ~`),types:new Set,lineStart:[{re:/^([ \t]*)(- +)?("[^"\n]*"|'[^'\n]*'|[A-Za-z_][\w.\-/]*)([ \t]*)(:)/,kinds:[`plain`,`punct`,`key`,`plain`,`punct`]}]},toml:{line:`#`,block:null,quotes:[`"`,`'`],keywords:Pf(`true false`),types:new Set,keyChars:`=`,lineStart:[{re:/^([ \t]*)(\[\[?[^\]\n]*\]\]?)/,kinds:[`plain`,`fn`]}]},html:{line:null,block:[`<!--`,`-->`],quotes:[`"`,`'`],keywords:new Set,types:new Set,keyChars:`=`,tagNames:!0}},Rf=(e,t)=>{let n=e.indexOf(`
|
|
87
|
-
`,t);return n===-1?e.length:n},zf=(e,t)=>{let n=t;for(;n<e.length&&(e[n]===` `||e[n]===` `);)n++;return e[n]??``},Bf=new Set(Object.keys(Lf)),Vf=e=>/[A-Za-z_$]/.test(e),Hf=e=>/[A-Za-z0-9_$]/.test(e),Uf=e=>e>=`0`&&e<=`9`,Wf=new Set(`{}()[];,.`),Gf=new Set(`+-*/%=<>!&|^~?:@`);function Kf(e,t){let n=[],r=e.length,i=(e,t)=>e&&n.push({text:e,kind:t}),a=0;for(;a<r;){let n=e[a];if(t.lineStart&&(a===0||e[a-1]===`
|
|
88
|
-
`)){let n=!1;for(let r of t.lineStart){let t=r.re.exec(e.slice(a,Rf(e,a)));if(t){for(let e=1;e<t.length;e++)i(t[e]??``,r.kinds[e-1]??`plain`);a+=t[0].length,n=!0;break}}if(n)continue}if(t.block&&e.startsWith(t.block[0],a)){let n=e.indexOf(t.block[1],a+t.block[0].length),o=n===-1?r:n+t.block[1].length;i(e.slice(a,o),`com`),a=o;continue}if(t.line&&e.startsWith(t.line,a)){let t=e.indexOf(`
|
|
89
|
-
`,a);t===-1&&(t=r),i(e.slice(a,t),`com`),a=t;continue}if(t.quotes.includes(n)){let t=n==="`",o=a+1;for(;o<r;){if(e[o]===`\\`){o+=2;continue}if(e[o]===n){o++;break}if(e[o]===`
|
|
90
|
-
`&&!t)break;o++}i(e.slice(a,o),`str`),a=o;continue}if(Uf(n)){let t=a+1;for(;t<r&&/[0-9a-fA-FxXbBoO_.]/.test(e[t]);)t++;i(e.slice(a,t),`num`),a=t;continue}if(Vf(n)){let n=a+1;for(;n<r&&Hf(e[n]);)n++;let o=e.slice(a,n);i(o,t.keywords.has(o)?`kw`:t.types.has(o)?`type`:t.tagNames&&(e[a-1]===`<`||e[a-1]===`/`&&e[a-2]===`<`)?`kw`:t.keyChars&&t.keyChars.includes(zf(e,n))?`key`:e[n]===`(`?`fn`:`plain`),a=n;continue}if(Wf.has(n)){i(n,`punct`),a++;continue}if(Gf.has(n)){let t=a+1;for(;t<r&&Gf.has(e[t]);)t++;i(e.slice(a,t),`op`),a=t;continue}let o=a+1;for(;o<r&&!Vf(e[o])&&!Uf(e[o])&&!t.quotes.includes(e[o])&&!Wf.has(e[o])&&!Gf.has(e[o])&&!(t.line&&e.startsWith(t.line,o));)o++;i(e.slice(a,o),`plain`),a=o}return n}function qf(e){let t=[[]];for(let n of e){let e=n.text.split(`
|
|
91
|
-
`);for(let r=0;r<e.length;r++)r>0&&t.push([]),e[r]&&t[t.length-1].push({text:e[r],kind:n.kind})}return t}function Jf(e,t){if(e===``)return[];let n=Lf[t];return n?qf(Kf(e,n)):e.split(`
|
|
92
|
-
`).map(e=>e?[{text:e,kind:`plain`}]:[])}var Yf={".ts":`typescript`,".tsx":`typescript`,".mts":`typescript`,".cts":`typescript`,".js":`javascript`,".jsx":`javascript`,".mjs":`javascript`,".cjs":`javascript`,".json":`json`,".jsonc":`json`,".css":`css`,".scss":`css`,".less":`css`,".py":`python`,".go":`go`,".rs":`rust`,".java":`java`,".c":`c`,".h":`c`,".cpp":`cpp`,".hpp":`cpp`,".cc":`cpp`,".sh":`shell`,".bash":`shell`,".zsh":`shell`,".yaml":`yaml`,".yml":`yaml`,".toml":`toml`,".html":`html`,".htm":`html`,".xml":`html`,".svg":`html`},Xf={Dockerfile:`shell`,Makefile:`shell`,".gitignore":`shell`,".env":`shell`,".bashrc":`shell`,".zshrc":`shell`};function Zf(e){let t=Mi(e),n=t.lastIndexOf(`.`),r=n>0?t.slice(n).toLowerCase():``,i=Xf[t]??Yf[r]??`text`;return Bf.has(i)?i:`text`}function Qf(e,t,n){let r=e.length,i=t.length,a=Array.from({length:r+1},()=>new Uint32Array(i+1));for(let n=r-1;n>=0;n--)for(let r=i-1;r>=0;r--)a[n][r]=e[n]===t[r]?a[n+1][r+1]+1:Math.max(a[n+1][r],a[n][r+1]);let o=[],s=0,c=0;for(;s<r&&c<i;)e[s]===t[c]?(o.push({type:`eq`,a:n+s,b:n+c}),s++,c++):a[s+1][c]>=a[s][c+1]?(o.push({type:`del`,a:n+s,b:null}),s++):(o.push({type:`add`,a:null,b:n+c}),c++);for(;s<r;)o.push({type:`del`,a:n+s++,b:null});for(;c<i;)o.push({type:`add`,a:null,b:n+c++});return o}function $f(e,t){let n=e.length,r=t.length,i=0;for(;i<n&&i<r&&e[i]===t[i];)i++;let a=0;for(;a<n-i&&a<r-i&&e[n-1-a]===t[r-1-a];)a++;let o=[];for(let e=0;e<i;e++)o.push({type:`eq`,a:e,b:e});o.push(...Qf(e.slice(i,n-a),t.slice(i,r-a),i));for(let e=0;e<a;e++)o.push({type:`eq`,a:n-a+e,b:r-a+e});return o}var ep=3,tp=e=>e===``?[]:e.split(`
|
|
93
|
-
`);function np(e,t,n){return e.type===`del`?{type:`del`,oldLine:e.a+1,newLine:null,tokens:t[e.a]??[]}:e.type===`add`?{type:`add`,oldLine:null,newLine:e.b+1,tokens:n[e.b]??[]}:{type:`context`,oldLine:e.a+1,newLine:e.b+1,tokens:n[e.b]??[]}}function rp(e){let t=[];for(let n=0;n<e.length;n++)e[n].type!==`context`&&t.push(n);if(t.length===0)return{hunks:[],collapsedAfter:e.length};let n=[],r=Math.max(0,t[0]-ep),i=-1;for(let a=0;a<t.length;a++){let o=t[a],s=t[a+1];i=Math.min(e.length-1,o+ep),!(s!==void 0&&s-o<=7)&&(n.push({collapsedBefore:r,lines:e.slice(r,i+1)}),s!==void 0&&(r=Math.max(i+1,s-ep)))}let a=n.length?n[n.length-1].collapsedBefore+n[n.length-1].lines.length:0;return{hunks:n,collapsedAfter:Math.max(0,e.length-a)}}function ip(e,t,n){let r=Zf(n),i=Jf(e,r),a=Jf(t,r),o=tp(e),s=tp(t),c=e===``?`added`:t===``?`deleted`:`modified`;if(c===`added`){let e=s.map((e,t)=>({type:`add`,oldLine:null,newLine:t+1,tokens:a[t]??[]}));return{file:n,lang:r,status:c,hunks:[{collapsedBefore:0,lines:e}],collapsedAfter:0,additions:e.length,deletions:0}}if(c===`deleted`){let e=o.map((e,t)=>({type:`del`,oldLine:t+1,newLine:null,tokens:i[t]??[]}));return{file:n,lang:r,status:c,hunks:[{collapsedBefore:0,lines:e}],collapsedAfter:0,additions:0,deletions:e.length}}let l=$f(o,s).map(e=>np(e,i,a)),u=l.filter(e=>e.type===`add`).length,d=l.filter(e=>e.type===`del`).length,{hunks:f,collapsedAfter:p}=rp(l);return{file:n,lang:r,status:c,hunks:f,collapsedAfter:p,additions:u,deletions:d}}var ap=`flex min-w-0 items-baseline gap-2`,op=`flex shrink-0 items-baseline gap-2`;function sp(e){return e===`failed`||e===`cancelled`?e:void 0}function cp(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`))+1;return{dir:e.slice(0,t),base:e.slice(t)}}var lp=`a, button, input, select, textarea, summary, label, [role="button"], [role="link"]`;function up(e){let t=e;return typeof t?.closest==`function`&&t.closest(lp)!=null}function dp({children:e,className:t,controls:n,expanded:r,label:i,meta:a,onToggle:o}){function s(e){if(up(e.target))return;let t=typeof window>`u`?null:window.getSelection();t&&!t.isCollapsed&&t.toString().trim()!==``||o()}return(0,q.createElement)(`div`,{className:`${t} w-full cursor-pointer text-left`,"data-expanded":r,onClick:s},(0,q.createElement)(`span`,{className:ap},e),(0,q.createElement)(`span`,{className:op},a,(0,q.createElement)(`button`,{type:`button`,"data-tool-disclosure":!0,"aria-controls":n,"aria-expanded":r,"aria-label":i,title:i,onClick:o,className:`-my-1 -ml-1 inline-flex shrink-0 items-center justify-center rounded py-1 pl-1 text-muted outline-none transition-colors hover:text-fg/80 focus-visible:ring-1 focus-visible:ring-focus-ink-60`},(0,q.createElement)(vs,{"aria-hidden":!0,size:12,className:`frizz-tool-chevron${r?` rotate-90`:``}`}))))}function fp(e){let t=W.board?.projectDir;return t&&e.startsWith(t+`/`)?e.slice(t.length+1):e}function pp({path:e}){let{dir:t,base:n}=cp(e);return(0,X.jsxs)(`span`,{className:`frizz-tool-path`,children:[t&&(0,X.jsx)(`span`,{className:`frizz-tool-path-dir`,children:t}),(0,X.jsx)(`span`,{className:`frizz-tool-path-base`,children:n})]})}function mp({open:e=!1,shown:t=!0}){return t?(0,X.jsx)(vs,{"aria-hidden":`true`,size:12,className:`frizz-tool-chevron${e?` rotate-90`:``}`}):(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`w-3 shrink-0`})}function hp({path:e,className:t=``,children:n}){return(0,X.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),N(e)},title:e,className:`font-mono-keep block max-w-full cursor-pointer truncate text-left hover:underline hover:text-fg/80 ${t}`,children:n??e})}function gp({edits:e,meta:t}){let n=(0,q.useId)(),r=e[0].file,i=(0,q.useMemo)(()=>e.map(e=>ip(e.old,e.new,e.file)),[e]),a=i.reduce((e,t)=>e+t.additions,0),o=i.reduce((e,t)=>e+t.deletions,0),[s,c]=(0,q.useState)(!1);return(0,X.jsxs)(`div`,{className:`frizz-diff`,"data-tool-node":`edit`,children:[(0,X.jsxs)(dp,{className:`frizz-diff-header`,controls:n,expanded:s,label:`${s?`Collapse`:`Expand`} Edit diff: ${r}`,onToggle:()=>c(!s),meta:t,children:[(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:`Edit`}),(0,X.jsx)(`span`,{className:`frizz-diff-file`,children:(0,X.jsx)(hp,{path:r,children:(0,X.jsx)(pp,{path:fp(r)})})}),(a>0||o>0)&&(0,X.jsxs)(`span`,{className:`frizz-diff-stat`,children:[a>0&&(0,X.jsxs)(`span`,{className:`frizz-diff-add`,children:[`+`,a]}),a>0&&o>0&&` `,o>0&&(0,X.jsxs)(`span`,{className:`frizz-diff-del`,children:[`−`,o]})]})]}),(0,X.jsx)(`div`,{id:n,className:`frizz-tool-body frizz-diff-body`,hidden:!s,children:s&&i.map((e,t)=>(0,X.jsx)(`div`,{className:t>0?`frizz-diff-editsep`:void 0,children:(0,X.jsx)(_p,{hunks:e.hunks,collapsedAfter:e.collapsedAfter})},t))})]})}function _p({hunks:e,collapsedAfter:t}){let n=0,r=[];return e.forEach((e,t)=>{let i=e.collapsedBefore-n;i>0&&r.push((0,X.jsx)(vp,{n:i},`s${t}`));for(let n of e.lines){let e=n.type===`del`?n.oldLine:n.newLine,i=n.type===`add`?`+`:n.type===`del`?`-`:` `;r.push((0,X.jsxs)(`div`,{className:`frizz-diff-line`,"data-type":n.type,children:[(0,X.jsx)(`span`,{className:`frizz-diff-gutter`,children:e}),(0,X.jsx)(`span`,{className:`frizz-diff-sign`,children:i}),(0,X.jsx)(`span`,{className:`frizz-diff-code`,children:n.tokens.map((e,t)=>(0,X.jsx)(`span`,{className:`ftk-${e.kind}`,children:e.text},t))})]},`${t}:${n.oldLine}:${n.newLine}`))}n=e.collapsedBefore+e.lines.length}),t>0&&r.push((0,X.jsx)(vp,{n:t},`safter`)),(0,X.jsx)(X.Fragment,{children:r})}function vp({n:e}){return(0,X.jsxs)(`div`,{className:`frizz-diff-sep`,children:[e,` unchanged line`,e===1?``:`s`]})}function yp(e){return(0,q.useMemo)(()=>({__html:e}),[e])}var bp=/^[\w.@+-]+\.[a-z][a-z0-9]{0,7}$/i,xp=/^(?:[A-Za-z]:\\|\\\\)?[\w.@+~-]+(?:\\[\w.@+~-]+)*(?::\d+(?::\d+)?)?$/;function Sp(e){let t=e.trim();return!t||t.length>1024||/\s/.test(t)||/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?!1:t===`~`||t.startsWith(`~/`)||t.startsWith(`/`)||t.includes(`/`)||t.includes(`\\`)&&xp.test(t)?!0:bp.test(t)}var Cp=/^(?:~(?:[\\/]|$)|\/|[A-Za-z]:[\\/]|\\\\)/;function wp(e,t){return e?{key:`project:${e}`,apiFor:()=>Zo(e)}:$t(t)?{key:`console`,apiFor:e=>Cp.test(e)?$n(e):null}:{key:`page:${Cn(t)??``}`,apiFor:()=>k}}var Tp=new Map,Ep=(e,t)=>`${e.key}\n${t}`;function Dp(e,t){return Tp.get(Ep(e,t))}var Op=new Set,kp=0,Ap=new Set,jp=e=>(Ap.add(e),()=>{Ap.delete(e)}),Mp=()=>kp,Np=128;async function Pp(e,t){let n=[...new Set(t)].filter(t=>!Tp.has(Ep(e,t))&&!Op.has(Ep(e,t)));if(!n.length)return;for(let t of n)Op.add(Ep(e,t));let r=new Map;for(let t of n){let n=e.apiFor(t);r.set(n,[...r.get(n)??[],t])}let i=[];for(let[e,t]of r)for(let n=0;n<t.length;n+=Np)i.push({api:e,paths:t.slice(n,n+Np)});let a=await Promise.all(i.map(async({api:e,paths:t})=>{try{if(!e)throw Error(`no project to resolve against`);return(await e.resolveLocalPaths({paths:t})).resolved}catch{return t.map(e=>({input:e,path:null}))}})),o=!1;for(let t of a)for(let n of t){let t=Ep(e,n.input);Tp.has(t)||(Tp.set(t,n.path),o=!0)}for(let t of n)Op.delete(Ep(e,t));if(o){kp+=1;for(let e of Ap)e()}}function Fp(e,t){e.setAttribute(`data-local-path`,t),e.setAttribute(`title`,`Open ${t}`),e.classList.add(`local-file-code`)}function Ip(e,t){let n=(0,q.useSyncExternalStore)(jp,Mp,Mp),r=Da();(0,q.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=wp(r),i=[];for(let e of t.querySelectorAll(`code`)){if(e.closest(`pre`)||e.closest(`a, [data-local-path]`))continue;let t=(e.textContent??``).trim();if(!Sp(t))continue;let r=Dp(n,t);r===void 0?i.push(t):r&&Fp(e,r)}i.length&&Pp(n,i)},[e,t,n,r])}var Lp=0;function Rp(e,t,n,r,i){let[a,o]=(0,q.useState)([]),s=(0,q.useRef)(null);return(0,q.useLayoutEffect)(()=>{let c=e.current;if(s.current&&s.current.root===c&&s.current.html===t)return;s.current={root:c,html:t};let l=[...a],u=[];for(let e of c?.querySelectorAll(`pre > code.language-${n}`)??[]){let t=e.closest(`.md-code`)??e.parentElement,a=e.textContent??``,o=l.findIndex(e=>e.body===a),s;if(o>=0)s=l.splice(o,1)[0];else{let e=document.createElement(`div`);e.className=r,s={key:`${n}-${++Lp}`,host:e,body:a,value:i(a)}}t.replaceWith(s.host),u.push(s)}o(e=>e.length===0&&u.length===0?e:u)}),a}var zp=`[overflow-wrap:anywhere]`,Bp=`rounded-xl`,Vp=`rounded-b-[calc(var(--block-radius)_-_1px)]`,Hp={neutral:{border:`border-border-strong`,head:`text-fg`},attention:{border:`border-accent/45`,head:`text-accent`},caution:{border:`border-border-strong`,head:`text-attention`},risk:{border:`border-border-strong`,head:`text-danger`},danger:{border:`border-danger-fill/45`,head:`text-danger`}},Up=`card-icon-offset`;function Wp(e,t){let n=(0,q.useRef)(null);return(0,q.useLayoutEffect)(()=>{let e=n.current;if(!e||typeof e.getBBox!=`function`)return;let r=e.getBBox(),i=e.viewBox.baseVal;if(!i||i.width===0||r.width===0)return;let a=Number(e.getAttribute(`stroke-width`))||0;if(t!==void 0&&r.height>0){let n=e.width.baseVal.value,o=a*n/i.width,s=e=>r.height*e/i.height+o,c=n;for(;s(c+2)<=t;)c+=2;let l=c>n;e.style.width=e.style.height=l?`${c}px`:``,e.style.marginBlock=l?`${(n-c)/2}px`:``,l&&(a=o*i.width/c),e.style.strokeWidth=l?String(a):``}let o=e.getBoundingClientRect().width/i.width,s=a/2;e.style.marginLeft=`${-Math.max(0,r.x-s-i.x)*o}px`,e.style.marginRight=`${-Math.max(0,i.x+i.width-(r.x+r.width)-s)*o}px`},[e,t]),n}function Gp({icon:e,className:t}){return(0,X.jsx)(e,{ref:Wp(e),"aria-hidden":`true`,size:16,className:`shrink-0 ${Up} ${t}`})}function Kp({icon:e,label:t,head:n=Hp.neutral.head,aside:r}){return(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[e&&(0,X.jsx)(Gp,{icon:e,className:n}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 text-[16px] font-semibold leading-6 tracking-tight ${n}`,children:t}),r&&(0,X.jsx)(`span`,{className:`shrink-0 leading-6`,children:r})]})}var qp=`flex min-w-0 items-center gap-[5px] text-[12px] font-medium leading-4`,Jp=12,Yp=Jp*22/24;function Xp({icon:e,children:t,className:n=`text-muted`,evenInk:r=!1}){let i=Wp(e,r?Yp:void 0);return(0,X.jsxs)(`span`,{"data-card-kind":!0,className:`${qp} ${n}`,children:[e&&(0,X.jsx)(e,{ref:i,"aria-hidden":`true`,size:Jp,className:`shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0`,children:t})]})}function Zp({icon:e,kind:t,kindClass:n,label:r,head:i,aside:a,ruled:o,evenInk:s}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(Xp,{icon:e,className:n,evenInk:s,children:t}),a&&(0,X.jsx)(`span`,{className:`ml-auto flex shrink-0 items-center [--card-icon-offset:0px]`,children:a})]}),r!=null&&r!==!1&&(0,X.jsx)(`div`,{"data-card-title":!0,className:`min-w-0 text-[16px] font-semibold leading-6 tracking-tight ${i}`,children:r})]}),o&&(0,X.jsx)(`div`,{"aria-hidden":!0,"data-card-rule":!0,className:`-mx-4 mt-3.5 border-t border-border`})]})}function Qp({children:e,gap:t=`plain`}){return(0,X.jsx)(`div`,{className:`card-md ${t===`ruled`?`mt-3`:t===`band`?`mt-3.5`:`mt-1`} min-w-0 text-fg/75`,children:e})}function $p({tone:e=`neutral`,icon:t,kind:n,label:r,ruled:i,aside:a,children:o,className:s=``,surface:c=`inset`,...l}){let{border:u,head:d}=Hp[e],f=n!=null&&(i??o!=null);return(0,X.jsxs)(`div`,{...l,className:`min-w-0 ${Bp} border ${c===`question`?`border-question-border bg-question`:`${u} bg-panel-2`} p-4 ${s}`,children:[n==null?(0,X.jsx)(Kp,{icon:t,label:r,head:d,aside:a}):(0,X.jsx)(Zp,{icon:t,kind:n,kindClass:e===`neutral`?`text-muted`:d,label:r,head:e===`neutral`?d:Hp.neutral.head,aside:a,ruled:f,evenInk:c===`question`}),o!=null&&(0,X.jsx)(Qp,{gap:n==null?`plain`:f?`ruled`:`band`,children:o})]})}var em=`block min-w-0 text-[13px] leading-5 text-fg/75`;function tm({children:e,className:t=``,...n}){return(0,X.jsx)(`div`,{...n,"data-card-actions":!0,className:`-mx-4 -mb-4 mt-3 flex flex-wrap items-center justify-start gap-x-2.5 gap-y-2 border-t border-border bg-fg/[0.03] px-4 py-2.5 ${Vp} ${t}`,children:e})}var nm=`min-w-0 flex-1 text-[11px] leading-snug text-muted-70`,rm=`text-accent underline underline-offset-2 decoration-accent/40 hover:decoration-accent`,im=`bg-fg px-2.5 py-1 text-bg hover:opacity-90`,am=`rounded-md`,om=`flex shrink-0 items-center gap-1 ${am} text-[11px] font-medium outline-none transition-colors focus-visible:ring-1 focus-visible:ring-focus-ink-60 ${im}`;function sm(e,t){let n=Promise.resolve();function r(r){let i={...r,palette:{...r.palette}},a=n.then(async()=>{try{return await e(i)}finally{t(i.id)}});return n=a.then(()=>void 0,()=>void 0),a}return{enqueue:r}}var cm=e=>new Promise(t=>setTimeout(t,e));function lm(e,{retryAfterMs:t=800,wait:n=cm}={}){let r;return()=>(r??=e().catch(()=>n(t).then(e)).catch(e=>{throw r=void 0,e}),r)}function um(e,t){let n=e[t];return typeof n==`string`&&n?n:void 0}function dm(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function fm(e,t){let n=um(e,t);if(n)try{let e=new URL(n);return e.protocol===`https:`||e.protocol===`http:`?e.href:void 0}catch{return}}function pm({directive:e,icon:t,title:n,meta:r,children:i}){return(0,X.jsxs)(`section`,{"data-codex-directive":e.name,className:`min-w-0 ${Bp} border border-border bg-panel-2/75 p-4`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center text-muted`,"aria-hidden":!0,children:t}),(0,X.jsx)(`div`,{className:`max-w-[calc(100%-1.5rem)] shrink-0 break-words text-[12px] font-medium leading-4 text-fg`,children:n}),r&&(0,X.jsx)(`div`,{className:`min-w-0 truncate text-[11px] font-normal leading-4 text-muted`,children:r})]}),i]})}function mm({children:e,mono:t=!1}){return(0,X.jsx)(`div`,{className:`ml-6 mt-1 break-words text-[11px] leading-4 text-muted${t?` font-mono-keep`:``}`,children:e})}function hm({directive:e}){let t=e.attrs,n=um(t,`display_name`)??um(t,`skill_name`)??`Artifact template`,r=um(t,`artifact_kind`),i=um(t,`skill_name`),a=um(t,`skill_directory`),[o,s]=(0,q.useState)(!!a);return(0,X.jsxs)(pm,{directive:e,icon:(0,X.jsx)(Us,{size:15}),title:n,meta:r?`${r} template`:`Template`,children:[i&&(0,X.jsx)(mm,{mono:!0,children:i.startsWith(`$`)?i:`$${i}`}),o&&a&&(0,X.jsx)(`img`,{src:_e(`${a}/assets/preview.png`),alt:`${n} template preview`,loading:`lazy`,onError:()=>s(!1),className:`ml-6 mt-2 max-h-44 max-w-[calc(100%-1.5rem)] rounded-md border border-border object-contain`})]})}function gm({directive:e}){let t=e.attrs,n=um(t,`file`),r=dm(t,`start`),i=dm(t,`end`)??r,a=dm(t,`priority`),o=n?`${n}${r?`:${r}${i&&i!==r?`-${i}`:``}`:``}`:`Code location unavailable`;return(0,X.jsxs)(pm,{directive:e,icon:(0,X.jsx)(Js,{size:15}),title:um(t,`title`)??`Review finding`,meta:a===void 0?void 0:`P${a}`,children:[um(t,`body`)&&(0,X.jsx)(mm,{children:um(t,`body`)}),n?(0,X.jsx)(`button`,{type:`button`,className:`local-file-action ml-6 mt-1 max-w-[calc(100%-1.5rem)] break-all text-left font-mono-keep text-[11px] leading-4 text-accent underline decoration-dotted underline-offset-2`,"data-local-path":n,title:o,children:o}):(0,X.jsx)(mm,{mono:!0,children:o})]})}var _m={"git-stage":[Qs,`Changes staged`],"git-commit":[ea,`Commit created`],"git-create-branch":[Bs,`Branch created`],"git-push":[cc,`Branch pushed`],"git-create-pr":[ee,`Pull request created`]};function vm({directive:e}){let[t,n]=_m[e.name],r=um(e.attrs,`branch`),i=fm(e.attrs,`url`),a=`${n}${e.attrs.isDraft===!0?` as draft`:``}`;return(0,X.jsx)(pm,{directive:e,icon:(0,X.jsx)(t,{size:15}),title:i?(0,X.jsx)(`a`,{className:`text-accent underline underline-offset-2`,href:i,target:`_blank`,rel:`noopener noreferrer`,children:a}):a,meta:r&&(0,X.jsx)(`span`,{className:`font-mono-keep`,children:r})})}function ym({directive:e}){let t=um(e.attrs,`threadId`),n=um(e.attrs,`pendingWorktreeId`);return(0,X.jsx)(pm,{directive:e,icon:(0,X.jsx)(Zs,{size:15}),title:n?`Thread setup queued`:`Thread created`,meta:(t||n)&&(0,X.jsx)(`span`,{className:`font-mono-keep`,children:t??n})})}function bm({directive:e}){let t=um(e.attrs,`reason`);return(0,X.jsx)(pm,{directive:e,icon:(0,X.jsx)(Es,{size:15}),title:`Archive suggested`,meta:t})}function xm(e){if(typeof e!=`string`||!e)return;let t=e.match(/(?:^|;)INTERVAL=(\d+)(?:;|$)/)?.[1];return/(?:^|;)FREQ=HOURLY(?:;|$)/.test(e)?`Every ${t??`1`} hour${t===`1`||t===void 0?``:`s`}`:/(?:^|;)FREQ=WEEKLY(?:;|$)/.test(e)?`Weekly schedule`:`Custom schedule`}function Sm({directive:e}){let t=e.attrs,n=um(t,`mode`),r=um(t,`name`)??`Automation`,i=xm(t.rrule),a=[r,n,um(t,`status`),i].filter(Boolean).join(` · `);return(0,X.jsx)(pm,{directive:e,icon:(0,X.jsx)(As,{size:15}),title:`Automation suggested`,meta:a,children:um(t,`prompt`)&&(0,X.jsx)(mm,{children:um(t,`prompt`)})})}function Cm({directive:e}){return e.name===`artifact-template`?(0,X.jsx)(hm,{directive:e}):e.name===`code-comment`?(0,X.jsx)(gm,{directive:e}):e.name.startsWith(`git-`)?(0,X.jsx)(vm,{directive:e}):e.name===`created-thread`?(0,X.jsx)(ym,{directive:e}):e.name===`archive`||e.name===`archive-thread`?(0,X.jsx)(bm,{directive:e}):(0,X.jsx)(Sm,{directive:e})}var wm=0,Tm=lm(()=>Jr(async()=>{let{default:e}=await import(`./mermaid.core-BKnePOrR.js`);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24])).then(({default:e})=>e));function Em(){let e=getComputedStyle(document.documentElement),t=t=>e.getPropertyValue(t).trim();return{background:t(`--color-panel-2`),primaryColor:t(`--color-panel-2`),primaryTextColor:t(`--color-fg`),primaryBorderColor:t(`--color-control-strong`),lineColor:t(`--color-muted`),secondaryColor:t(`--color-border`),tertiaryColor:t(`--color-bg`),fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`}}var Dm=sm(async e=>{let t=await Tm();return t.initialize({startOnLoad:!1,securityLevel:`strict`,theme:e.resolved===`dark`?`dark`:`base`,themeVariables:e.palette}),t.render(e.id,e.source)},e=>document.getElementById(`d${e}`)?.remove());function Om({source:e}){let t=(0,q.useId)(),{resolved:n}=(0,q.useSyncExternalStore)(Nt,_t,_t),[r,i]=(0,q.useState)({}),a=(0,q.useRef)(0),o=yp(r.html??``);return(0,q.useEffect)(()=>{let r=!0,o=++a.current;if(i(e=>e.error?{html:e.html}:e),e.length>5e4)return i({error:`Diagram source exceeds the 50 KB rendering limit`}),()=>{r=!1};let s=`frizz-mermaid-${t.replace(/[^a-zA-Z0-9]/g,``)}-${++wm}`;return Dm.enqueue({id:s,source:e,resolved:n,palette:Em()}).then(({svg:e})=>{r&&a.current===o&&i({html:e})}).catch(e=>{if(!r||a.current!==o)return;let t=e instanceof Error?e.message.split(/\n| for text:/,1)[0]:`Unknown diagram error`;i({error:t.slice(0,240)})}),()=>{r=!1}},[t,n,e]),r.error?(0,X.jsxs)(`section`,{"data-mermaid-state":`error`,className:`${Bp} border border-border bg-panel-2/75 p-4`,children:[(0,X.jsx)(`div`,{className:`text-[12px] font-medium text-fg`,children:`Diagram unavailable`}),(0,X.jsx)(`div`,{className:`mt-1 text-[11px] text-muted`,children:r.error}),(0,X.jsx)(`pre`,{className:`mt-2 overflow-x-auto whitespace-pre-wrap rounded-md bg-bg p-2 font-mono-keep text-[11px] text-muted`,children:e})]}):r.html?(0,X.jsx)(`div`,{"data-mermaid-state":`ready`,className:`overflow-x-auto ${Bp} border border-border bg-panel-2/75 p-4 [&_svg]:mx-auto [&_svg]:h-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:o}):(0,X.jsx)(`div`,{"data-mermaid-state":`loading`,role:`status`,"aria-label":`Rendering diagram`,className:`h-24 animate-pulse ${Bp} bg-panel-2`})}var km=e=>e.replace(/\n$/,``);function Am(e,t){return Rp(e,t,`mermaid`,`md-mermaid`,km).map(({key:e,host:t,value:n})=>(0,dc.createPortal)((0,X.jsx)(Om,{source:n}),t,e))}function jm(e,t,n){let r=e.length;if(r===0||!(t>0))return[];let{gap:i,target:a,maxHeight:o,maxPerRow:s}=n,c=(t,n)=>{let r=0;for(let i=t;i<n;i++)r+=e[i];return r},l=(e,n)=>Math.max(0,t-i*(n-e-1))/c(e,n),u=Array(r+1).fill(1/0),d=Array(r+1).fill(0);u[0]=0;for(let e=1;e<=r;e++)for(let t=1;t<=Math.min(s,e);t++){let n=e-t,r=u[n]+(l(n,e)-a)**2;r<u[e]&&(u[e]=r,d[e]=n)}let f=[];for(let e=r;e>0;e=d[e]){let n=d[e],r=l(n,e),a=Math.min(r,o);f.unshift({start:n,end:e,height:a,width:a<r?a*c(n,e)+i*(e-n-1):t})}return f}var Mm={scale:1,x:0,y:0},Nm=(e,t,n)=>Math.min(Math.max(e,t),n);function Pm(e,t,n,r,i){let a=t*n/2;return 2*a<=i-r?Nm(0,r+a,i-a):Nm(e,i-a,r+a)}function Fm(e,t){let n=Nm(e.scale,1,t.max);return n===1?Mm:{scale:n,x:Pm(e.x,t.width,n,t.left,t.right),y:Pm(e.y,t.height,n,t.top,t.bottom)}}function Im(e,t,n,r){let i=Nm(e.scale*t,1,r.max),a=i/e.scale;return Fm({scale:i,x:n.x-(n.x-e.x)*a,y:n.y-(n.y-e.y)*a},r)}function Lm(e,t,n,r){return Fm({scale:e.scale,x:e.x+t,y:e.y+n},r)}function Rm(e,t,n,r,i,a){let o=Nm(e.scale*(i/Math.max(n,1)),1,a.max),s=o/e.scale;return Fm({scale:o,x:r.x-(t.x-e.x)*s,y:r.y-(t.y-e.y)*s},a)}function zm(e,t){return Nm(t/Math.max(e,1),2,4)}function Bm(e,t){return Nm(2*t/Math.max(e,1),4,12)}var Vm=6,Hm=420,Um=16/10,Wm=.4,Gm=3,Km=(e,t,n)=>Math.min(Math.max(e,t),n),qm=e=>Km(e/4,112,180);function Jm({entries:e,baseDir:t,framed:n=!0}){let i=Af(),a=(0,q.useMemo)(()=>t?{...i,dir:t}:i,[i,t]),o=(0,q.useMemo)(()=>e.map(e=>{let t=A(e.target,a);return{entry:e,path:t,label:os(e,t)}}),[e,a]),[s,c]=(0,q.useState)({}),[l,u]=(0,q.useState)({}),[d,f]=(0,q.useState)(null),p=$m(d),m=o.filter(e=>e.path!==null&&!l[e.path]),h=o.filter(e=>!m.includes(e)),g=e=>Km(s[e.path]||Um,Wm,Gm),_=jm(m.map(g),p,{gap:Vm,target:qm(p),maxHeight:Hm,maxPerRow:8}),v=o.some(e=>e.entry.caption),y=m.map(e=>Fr(e.entry,e.path));if(m.length===0)return(0,X.jsx)(`div`,{"data-lightbox-gallery":!0,className:`flex flex-col gap-1`,children:h.map((e,t)=>(0,X.jsx)(Qm,{tile:e},t))});let b=(0,X.jsxs)(`div`,{ref:f,"data-lightbox-gallery":!0,className:`flex w-full min-w-0 flex-col gap-1.5`,children:[_.map(e=>(0,X.jsx)(`div`,{"data-lightbox-row":!0,className:`mx-auto flex max-w-full gap-1.5`,style:{width:e.width},children:m.slice(e.start,e.end).map((t,n)=>(0,X.jsx)(Xm,{tile:t,ratio:g(t),labelled:v,onOpen:()=>r(y,e.start+n),onShape:e=>c(n=>n[t.path]===e?n:{...n,[t.path]:e}),onBroken:()=>u(e=>({...e,[t.path]:!0}))},e.start+n))},e.start)),h.map((e,t)=>(0,X.jsx)(Qm,{tile:e},t))]});return n?(0,X.jsx)(Wd,{children:b}):(0,X.jsx)(`div`,{className:Kd,children:b})}function Ym(e){return{flex:`${e} 1 0%`}}function Xm({tile:e,ratio:t,labelled:n,onOpen:r,onShape:i,onBroken:a}){let o=Wo(e.path),s=(e,t)=>{e>0&&t>0&&i(e/t)};return(0,X.jsxs)(`button`,{type:`button`,"data-lightbox-tile":!0,"data-lightbox-video":o||void 0,onClick:r,"aria-label":`${o?`Play`:`View`} ${e.label}`,className:`group flex min-w-0 flex-col gap-1 rounded-md text-left outline-none focus-visible:ring-1 focus-visible:ring-focus-ink-60 focus-visible:ring-offset-2 focus-visible:ring-offset-panel-2 ${o?`cursor-pointer`:`cursor-zoom-in`}`,style:Ym(t),children:[(0,X.jsx)(`span`,{className:`relative block w-full overflow-hidden rounded-md`,style:{aspectRatio:t},children:o?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`video`,{src:`${_e(e.path)}#t=0.001`,preload:`metadata`,muted:!0,playsInline:!0,disablePictureInPicture:!0,tabIndex:-1,"aria-hidden":!0,onLoadedMetadata:e=>s(e.currentTarget.videoWidth,e.currentTarget.videoHeight),onError:a,className:`pointer-events-none block h-full w-full object-contain transition-[filter] group-hover:brightness-110`}),(0,X.jsx)(Zm,{})]}):(0,X.jsx)(`img`,{src:_e(e.path),alt:n?``:e.label,draggable:!1,onLoad:e=>s(e.currentTarget.naturalWidth,e.currentTarget.naturalHeight),onError:a,className:`block h-full w-full object-contain transition-[filter] group-hover:brightness-110`})}),n&&(0,X.jsx)(`span`,{title:e.label,className:`block truncate font-sans text-[11px] leading-4 text-muted`,children:e.label})]})}function Zm(){return(0,X.jsx)(`span`,{"data-lightbox-play":!0,"aria-hidden":!0,className:`pointer-events-none absolute left-1/2 top-1/2 flex h-8 w-8 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-black/55 text-white/90 ring-1 ring-white/15 backdrop-blur-sm transition-colors group-hover:bg-black/70 group-hover:text-white`,children:(0,X.jsx)($s,{size:14,strokeWidth:Eh,absoluteStrokeWidth:!0,fill:`currentColor`})})}function Qm({tile:e}){return(0,X.jsx)(`div`,{"data-lightbox-missing":!0,className:`break-all font-mono-keep text-[12px] text-muted-70`,children:e.path??e.entry.target})}function $m(e){let[t,n]=(0,q.useState)(0);return(0,q.useLayoutEffect)(()=>{if(!e)return;n(e.clientWidth);let t=new ResizeObserver(([e])=>n(e.contentRect.width));return t.observe(e),()=>t.disconnect()},[e]),t}function eh(e){let[t,n]=(0,q.useState)(0);return(0,q.useLayoutEffect)(()=>{if(!e){n(0);return}let t=()=>n(e.getBoundingClientRect().height);t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[e]),t}function th(e,t,n){return Rp(e,t,`lightbox`,`md-lightbox`,ln).map(({key:e,host:t,value:r})=>(0,dc.createPortal)((0,X.jsx)(Jm,{entries:r,baseDir:n}),t,e))}function nh(){let{lightbox:e}=Br(W);return e?(0,X.jsx)(na,{children:(0,X.jsx)(hh,{images:e.images,index:e.index})}):null}var rh={x:0,y:0},ih=e=>({path:e,zoom:Mm,pull:rh,animate:!1,max:1/0,panning:!1}),ah={mouse:4,touch:10},oh=48,sh=96,ch=300,lh=40,uh=1.5,dh=1.1,fh=`transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1)`,ph=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),mh=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y);function hh({images:e,index:t}){Xa(pt(),!1,Ht);let n=(0,q.useRef)(document.activeElement instanceof HTMLElement?document.activeElement:null),r=(0,q.useRef)(null),i=(0,q.useRef)(null),[a,s]=(0,q.useState)(null),c=(0,q.useCallback)(e=>{i.current=e,s(e)},[]),l=(0,q.useRef)(null),u=(0,q.useRef)(null),d=e[t],p=d?.path??``,m=Wo(p),h=(0,q.useId)(),[g,_]=(0,q.useState)(null),v=eh(g),y=d?.caption?v:0,b=(0,q.useRef)(ih(p)),[x,S]=(0,q.useState)(b.current),C=()=>b.current.path===p?b.current:ih(p),w=e=>{let t={...C(),...e};b.current=t,S(t)},T=x.path===p?x:ih(p),E=(0,q.useRef)(new Map),D=(0,q.useRef)(`mouse`),O=(0,q.useRef)(null),k=(0,q.useRef)(!1),A=(0,q.useRef)(null),j=()=>{let e=l.current,t=i.current;if(!e||!t||!e.naturalWidth)return null;let n=e.getBoundingClientRect(),r=new DOMMatrixReadOnly(getComputedStyle(e).transform),a=n.width/r.a,o=n.height/r.d;if(!a||!o)return null;let s={x:n.left+n.width/2-r.e,y:n.top+n.height/2-r.f},c=t.getBoundingClientRect();return{centre:s,bounds:{width:a,height:o,left:c.left-s.x,right:c.right-s.x,top:c.top-s.y,bottom:c.bottom-s.y,max:Bm(a,e.naturalWidth)},detail:zm(a,e.naturalWidth)}},M=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),P=(e,t)=>{let n=j();n&&w({zoom:e(C().zoom,n),animate:t,max:n.bounds.max})},F=e=>P((t,n)=>t.scale>1?Mm:Im(Mm,n.detail,M(e,n.centre),n.bounds),!0),I=e=>P((t,n)=>Im(t,e,{x:(n.bounds.left+n.bounds.right)/2,y:(n.bounds.top+n.bounds.bottom)/2},n.bounds),!0);if((0,q.useEffect)(()=>{if(!a)return;let e=e=>{let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?16:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?a.clientHeight:1;if(e.ctrlKey||e.metaKey){e.preventDefault();let n=Math.exp(Km(-e.deltaY*t*.01,-.5,.5));P((t,r)=>Im(t,n,M({x:e.clientX,y:e.clientY},r.centre),r.bounds),!1)}else C().zoom.scale>1&&(e.preventDefault(),P((n,r)=>Lm(n,-e.deltaX*t,-e.deltaY*t,r.bounds),!1))},t=null,n=e=>{e.preventDefault();let n=e;if(e.type===`gesturestart`)t=C().zoom;else if(e.type===`gesturechange`&&t&&E.current.size===0){let e=t;P((t,r)=>Im(e,n.scale,M({x:n.clientX,y:n.clientY},r.centre),r.bounds),!1)}},r=new ResizeObserver(()=>{C().zoom.scale>1&&P((e,t)=>Fm(e,t.bounds),!1)});a.addEventListener(`wheel`,e,{passive:!1});for(let e of[`gesturestart`,`gesturechange`,`gestureend`])a.addEventListener(e,n);return r.observe(a),()=>{a.removeEventListener(`wheel`,e);for(let e of[`gesturestart`,`gesturechange`,`gestureend`])a.removeEventListener(e,n);r.disconnect()}},[a,p]),!d)return null;let L=e.length>1,R=T.zoom.scale>1,z=t=>{let n=!t.ctrlKey&&!t.metaKey&&!t.altKey;if(t.key===`ArrowLeft`)Ur(-1);else if(t.key===`ArrowRight`)Ur(1);else if(t.key===`Home`)Ur(-e.length);else if(t.key===`End`)Ur(e.length);else if(n&&(t.key===`+`||t.key===`=`))I(uh);else if(n&&(t.key===`-`||t.key===`_`))I(1/uh);else if(n&&t.key===`0`)w({zoom:Mm,animate:!0});else if(n&&t.key===` `&&m&&t.target!==u.current){let e=u.current;e?.paused?e.play().catch(()=>void 0):e?.pause()}else if(t.key===`Escape`)Ht();else return;t.preventDefault(),t.stopPropagation()},B=e=>{e.target===e.currentTarget&&Ht()},V=e=>{if(!(e.pointerType===`mouse`&&e.button!==0)&&!e.target.closest(`button, video`)){if(E.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),E.current.size===1)D.current=e.pointerType,k.current=!1,O.current={kind:`press`,id:e.pointerId,x:e.clientX,y:e.clientY};else if(E.current.size===2){let e=j(),[t,n]=[...E.current.values()];k.current=!0,A.current=null,O.current=e?{kind:`pinch`,start:C().zoom,mid:M(ph(t,n),e.centre),distance:mh(t,n)}:null,C().pull!==rh&&w({pull:rh,animate:!0})}}},ee=n=>{if(!E.current.has(n.pointerId))return;E.current.set(n.pointerId,{x:n.clientX,y:n.clientY});let r=O.current;if(r?.kind===`pinch`){let e=r,[t,n]=[...E.current.values()];P((r,i)=>Rm(e.start,e.mid,e.distance,M(ph(t,n),i.centre),mh(t,n),i.bounds),!1);return}if(!(!r||r.id!==n.pointerId)){if(r.kind===`press`){if(Math.hypot(n.clientX-r.x,n.clientY-r.y)<(n.pointerType===`mouse`?ah.mouse:ah.touch))return;if(k.current=!0,A.current=null,C().zoom.scale>1)r={kind:`pan`,id:r.id,x:r.x,y:r.y};else if(n.pointerType!==`mouse`){let e=n.clientX-r.x,t=n.clientY-r.y;r={kind:`swipe`,id:r.id,x:r.x,y:r.y,axis:Math.abs(e)>Math.abs(t)?`x`:`y`}}else r=null;if(O.current=r,!r)return;i.current?.setPointerCapture(n.pointerId),r.kind===`pan`&&w({panning:!0})}if(r.kind===`pan`){let e=n.clientX-r.x,t=n.clientY-r.y;r.x=n.clientX,r.y=n.clientY,P((n,r)=>Lm(n,e,t,r.bounds),!1)}else if(r.kind===`swipe`){let i=n.clientX-r.x,a=n.clientY-r.y,o=i>0&&t===0||i<0&&t===e.length-1;w({pull:r.axis===`x`?{x:o?i/4:i,y:0}:{x:0,y:a},animate:!1})}}},te=e=>{if(!E.current.delete(e.pointerId))return;let t=O.current;if(t?.kind===`pinch`){let[e]=[...E.current.entries()];C().zoom.scale<dh&&w({zoom:Mm,animate:!0}),O.current=e&&C().zoom.scale>1?{kind:`pan`,id:e[0],x:e[1].x,y:e[1].y}:null;return}if(!t||t.id!==e.pointerId)return;O.current=null;let n=e.type===`pointercancel`;if(t.kind===`pan`&&w({panning:!1}),t.kind===`swipe`){let r=e.clientX-t.x,i=e.clientY-t.y;if(w({pull:rh,animate:!0}),n)return;t.axis===`x`&&Math.abs(r)>oh?Ur(r<0?1:-1):t.axis===`y`&&Math.abs(i)>sh&&Ht();return}if(t.kind===`press`&&!n&&e.pointerType!==`mouse`){let t=A.current;t&&e.timeStamp-t.t<ch&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<lh?(A.current=null,k.current=!0,F({x:e.clientX,y:e.clientY})):A.current={t:e.timeStamp,x:e.clientX,y:e.clientY}}},ne=e=>{if(k.current){k.current=!1;return}if(e.target.closest(`button, video, [data-lightbox-caption]`))return;let t=D.current===`mouse`;e.target===l.current?t&&F({x:e.clientX,y:e.clientY}):C().zoom.scale>1?t&&w({zoom:Mm,animate:!0}):Ht()},re=1-Math.min(Math.abs(T.pull.y)/(sh*3),.6);return(0,X.jsx)(Jn,{open:!0,onOpenChange:e=>{e||Ht()},children:(0,X.jsxs)(o,{children:[(0,X.jsx)(Kt,{className:`overlay-in fixed inset-0 ${ge} bg-black/95 backdrop-blur-md`,style:{opacity:re}}),(0,X.jsxs)(lr,{ref:r,"data-lightbox":!0,"aria-modal":`true`,"aria-describedby":d.caption?h:void 0,onEscapeKeyDown:f,onOpenAutoFocus:e=>{e.preventDefault(),r.current?.focus({preventScroll:!0})},onCloseAutoFocus:e=>{e.preventDefault(),n.current?.isConnected&&n.current.focus({preventScroll:!0})},onKeyDown:z,className:`overlay-in fixed inset-0 ${ge} flex flex-col text-white outline-none`,children:[(0,X.jsxs)(`header`,{onClick:B,className:`flex shrink-0 items-center gap-3 pb-2 pl-[max(env(safe-area-inset-left),16px)] pr-[max(env(safe-area-inset-right),16px)] pt-[max(env(safe-area-inset-top),12px)]`,style:{opacity:re},children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(ii,{className:`truncate text-[13px] font-medium leading-5 text-white/90 ${d.titled?``:`font-mono-keep`}`,children:d.label}),(0,X.jsx)(`div`,{className:`truncate font-mono-keep text-[11px] leading-4 text-white/45`,children:d.path})]}),(0,X.jsxs)(`div`,{"data-lightbox-actions":!0,className:`-mr-1 flex shrink-0 items-center gap-0.5 pointer-coarse:-mr-3`,children:[L&&(0,X.jsxs)(`span`,{"data-lightbox-counter":!0,className:`mr-2.5 text-[12px] tabular-nums text-[#787a7d]`,children:[t+1,` / `,e.length]}),!m&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Th,{label:`Zoom out`,onClick:()=>I(1/uh),disabled:!R,className:`pointer-coarse:hidden`,children:(0,X.jsx)(uc,{size:14,strokeWidth:2})}),(0,X.jsx)(Th,{label:`Zoom in`,onClick:()=>I(uh),disabled:T.zoom.scale>=T.max-1e-6,className:`pointer-coarse:hidden`,children:(0,X.jsx)(lc,{size:14,strokeWidth:2})})]}),(0,X.jsx)(Th,{label:`Download`,onClick:()=>gh(d),children:(0,X.jsx)(Is,{size:14,strokeWidth:2,className:wh})}),(0,X.jsx)(Th,{label:m?`Open in default player`:`Open in default viewer`,onClick:()=>N(d.path,!0),children:(0,X.jsx)(Ls,{size:14,strokeWidth:2,className:wh})}),(0,X.jsx)(Th,{label:`Close`,onClick:Ht,children:(0,X.jsx)(bi,{size:15,strokeWidth:2,className:wh})})]})]}),(0,X.jsxs)(`div`,{ref:c,"data-lightbox-stage":!0,onClick:ne,onPointerDown:V,onPointerMove:ee,onPointerUp:te,onPointerCancel:te,className:`relative flex min-h-0 flex-1 flex-col items-center justify-center overflow-hidden px-3 pb-[max(env(safe-area-inset-bottom),16px)] sm:px-16 ${R?T.panning?`cursor-grabbing`:`cursor-grab`:``}`,style:{touchAction:`none`},children:[m?(0,X.jsx)(bh,{image:d,view:T,reserve:y,videoRef:u},d.path):(0,X.jsx)(yh,{image:d,view:T,reserve:y,pictureRef:l},d.path),d.caption&&(0,X.jsx)(`p`,{ref:_,id:h,"data-lightbox-caption":!0,className:`max-w-2xl shrink-0 text-balance pt-3 text-center text-[13px] leading-5 text-white/75 ${R?`pointer-events-none`:``}`,style:{transform:`translate(${T.pull.x}px, ${T.pull.y}px)`,transition:`${T.animate?fh:`transform 0s`}, opacity 150ms ease-out`,opacity:R?0:re},children:d.caption}),L&&t>0&&(0,X.jsx)(Dh,{side:`left`,onClick:()=>Ur(-1)}),L&&t<e.length-1&&(0,X.jsx)(Dh,{side:`right`,onClick:()=>Ur(1)})]})]})]})})}function gh(e){let t=document.createElement(`a`);t.href=_e(e.path),t.download=ms(e),document.body.append(t),t.click(),t.remove()}function _h({what:e,path:t}){return(0,X.jsxs)(`div`,{className:`pointer-events-none max-w-md text-center`,children:[(0,X.jsxs)(`div`,{className:`text-[13px] text-white/70`,children:[e,` unavailable`]}),(0,X.jsx)(`div`,{className:`mt-1 break-all font-mono-keep text-[11px] text-white/45`,children:t})]})}var vh=e=>e?`calc(100% - ${e}px)`:void 0;function yh({image:e,view:t,reserve:n,pictureRef:r}){let[i,a]=(0,q.useState)(!1);if(i)return(0,X.jsx)(_h,{what:`Image`,path:e.path});let{scale:o,x:s,y:c}=t.zoom;return(0,X.jsx)(`img`,{ref:r,src:_e(e.path),alt:e.label,draggable:!1,onError:()=>a(!0),className:`block max-h-full max-w-full select-none object-contain ${o>1?``:`cursor-zoom-in`}`,style:{maxHeight:vh(n),transform:`translate(${s+t.pull.x}px, ${c+t.pull.y}px) scale(${o})`,transition:t.animate?fh:`none`,borderRadius:6/o,boxShadow:`0 0 0 ${1/o}px rgb(255 255 255 / 0.1)`}})}function bh({image:e,view:t,reserve:n,videoRef:r}){let[i,a]=(0,q.useState)(!1);return i?(0,X.jsx)(_h,{what:`Video`,path:e.path}):(0,X.jsx)(`video`,{ref:r,src:_e(e.path),"aria-label":e.label,controls:!0,autoPlay:!0,playsInline:!0,preload:`auto`,onError:()=>a(!0),className:`block max-h-full max-w-full rounded-md bg-black`,style:{maxHeight:vh(n),transform:`translate(${t.pull.x}px, ${t.pull.y}px)`,transition:t.animate?fh:`none`,boxShadow:`0 0 0 1px rgb(255 255 255 / 0.1)`}})}var xh=`icon-focus-outline text-[#787a7d] transition-colors hover:bg-white/[0.04] hover:text-[#e6e7e9]`,Sh=`cursor-default text-[#303132]`,Ch=`pointer-coarse:size-11 pointer-coarse:rounded-full pointer-coarse:text-[#cfd0d2]`,wh=`pointer-coarse:size-[21px] pointer-coarse:[stroke-width:2.1]`;function Th({label:e,onClick:t,disabled:n,className:r=``,children:i}){return(0,X.jsx)(Ot,{label:e,side:`bottom`,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":e,"aria-disabled":n||void 0,onClick:()=>{n||t()},className:`${B} focus-visible:ring-1 focus-visible:ring-white/60 ${n?Sh:xh} ${Ch} ${r}`,children:i})})}var Eh=1.5;function Dh({side:e,onClick:t}){return(0,X.jsx)(`button`,{type:`button`,"data-lightbox-page":e,"aria-label":e===`left`?`Previous image`:`Next image`,onClick:t,className:`absolute top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/55 text-white/85 outline-none ring-1 ring-white/15 backdrop-blur-sm transition-colors hover:bg-black/75 hover:text-white focus-visible:ring-white/60 pointer-coarse:hidden ${e===`left`?`left-3`:`right-3`}`,children:(0,X.jsx)(e===`left`?js:vs,{size:20,strokeWidth:Eh,absoluteStrokeWidth:!0})})}function Oh({as:e=`div`,className:t,html:n}){let r=yp(n),i=(0,q.useRef)(null);Ip(i,n);let a=th(i,n),o=Am(i,n);return(0,X.jsxs)(X.Fragment,{children:[(0,q.createElement)(e,{ref:i,className:t,dangerouslySetInnerHTML:r}),a,o]})}function kh({text:e,language:t,className:n=``,...r}){let i=yp((0,q.useMemo)(()=>Ju(e,t),[e,t]));return(0,X.jsx)(`pre`,{...r,className:`hljs ${n}`,dangerouslySetInnerHTML:i})}var Ah=`Todos`,jh={pending:{Icon:sc,className:`text-muted-50`},in_progress:{Icon:ac,className:`text-accent`},completed:{Icon:ic,className:`text-muted-75`}},Mh={pending:`text-fg/75`,in_progress:`text-fg`,completed:`text-muted-70`};function Nh({status:e}){let{Icon:t,className:n}=jh[e];return(0,X.jsx)(t,{"aria-hidden":`true`,size:`1em`,strokeWidth:2,className:`frizz-todo-mark shrink-0 ${n}`})}var Ph={pending:`to do`,in_progress:`in progress`,completed:`done`};function Fh({todos:e,note:t,meta:n,node:r}){let[i,a]=(0,q.useState)(!1),o=(0,q.useId)(),s=e.filter(e=>e.status===`completed`).length,c=e.find(e=>e.status===`in_progress`),l=e.length>0||!!t,u=e.length>0?`${s}/${e.length}`:void 0,d=c?c.text:e.length===0?`empty`:void 0;return(0,X.jsxs)(`div`,{className:`frizz-bash`,"data-todo-card":!0,"data-tool-node":r,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>l&&a(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":l?o:void 0,"aria-expanded":l?i:void 0,"aria-label":`${l?`${i?`Collapse`:`Expand`} `:``}${Ah}${d?`: ${d}`:``}${u?` — ${s} of ${e.length} done`:``}`,className:`frizz-bash-header w-full text-left outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-focus-ink-60`,children:[(0,X.jsxs)(`span`,{className:ap,children:[(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:Ah}),d&&(0,X.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5`,title:d,"data-todo-headline":!0,children:[c&&(0,X.jsx)(Nh,{status:`in_progress`}),(0,X.jsx)(`span`,{className:`frizz-tool-detail`,children:d})]})]}),(0,X.jsxs)(`span`,{className:op,children:[u&&(0,X.jsx)(`span`,{className:`tabular-nums text-[11.5px] leading-none text-faint`,title:`${s} of ${e.length} done`,children:u}),n,(0,X.jsx)(mp,{shown:l,open:i})]})]}),l&&(0,X.jsxs)(`div`,{id:o,className:`frizz-tool-body`,hidden:!i,children:[i&&e.length>0&&(0,X.jsx)(`ul`,{className:`frizz-todo-list`,children:e.map((e,t)=>(0,X.jsxs)(`li`,{className:`frizz-todo-row`,"data-current":e.status===`in_progress`?`true`:void 0,children:[(0,X.jsx)(Nh,{status:e.status}),(0,X.jsx)(`span`,{className:`min-w-0 ${Mh[e.status]}`,children:e.text}),(0,X.jsx)(`span`,{className:`sr-only`,children:` — ${Ph[e.status]}`})]},t))}),i&&t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`frizz-bash-output-label`,children:`Note`}),(0,X.jsx)(`pre`,{className:`frizz-bash-body frizz-bash-output-body`,children:t})]})]})]})}var Ih=/^```question(?:[ \t]+([A-Za-z][^\r\n]*?))?[ \t]*\r?\n(?:([\s\S]*?)\r?\n)??```[ \t]*$/gm,Lh=/^qst_[a-z0-9]+$/;function Rh(e){let t=(e??``).toLowerCase().split(/\s+/).filter(Boolean),n=e=>t.includes(e),r=t.find(e=>Lh.test(e));return{kind:n(`multi`)?`multi`:`question`,danger:n(`danger`),...r?{registeredId:r}:{}}}function zh(e){let t=[],n=ao(e),r=0;Ih.lastIndex=0;for(let i=Ih.exec(e);i!==null;i=Ih.exec(e)){if(n(i.index)){Ih.lastIndex=i.index+1;continue}let{kind:a,danger:o,registeredId:s}=Rh(i[1]);if(i[2]===void 0&&!s){Ih.lastIndex=i.index+1;continue}let c=e.slice(r,i.index);c.trim()&&t.push({kind:`prose`,text:c}),t.push({kind:`question`,text:i[2]??``,questionKind:a,danger:o,...s?{registeredId:s}:{}}),r=i.index+i[0].length}let i=e.slice(r);return i.trim()&&t.push({kind:`prose`,text:i}),Kh(t)}function Bh(e,t,n){if(!t||!Ri(e))return zh(e);let r=ri(e).filter(e=>e.read.form!==`invalid`||Uh(e.body));if(r.length===0)return zh(e);let i=[],a=0;for(let t of r){if(i.push(...zh(e.slice(a,t.start))),a=t.end,t.read.form===`ref`&&Vh(t.read,n)){i.push({kind:`refusedRef`,id:t.read.id});continue}if(t.read.form===`ask`&&Vh(t.read,n)){i.push({kind:`refusedAsk`,id:t.read.id,spec:t.read.spec});continue}if(t.read.form===`invalid`){let n=Co(t.body);i.push({kind:`invalidFence`,text:e.slice(t.start,t.end),faults:t.read.faults,...n?{draft:n}:{}});continue}let r=t.read;i.push({kind:`question`,text:t.body,questionKind:r.form===`ask`&&r.spec.kind===`multi`?`multi`:`question`,danger:r.form===`ask`&&r.spec.danger===!0,fence:r})}return i.push(...zh(e.slice(a))),i}function Vh(e,t){return t!==void 0&&t.size>0&&t.has(e.id.toLowerCase())}var Hh=RegExp(`^[ \\t]*(?:${s.join(`|`)}):(?:[ \\t]|$)`);function Uh(e){let t=e.split(/\r?\n/).find(e=>e.trim()!==``);return t!==void 0&&Hh.test(t)}function Wh(e,t){if(!Ri(e))return[];let n=[];for(let r of ri(e)){let e=r.read;e.form===`invalid`||Vh(e,t)||(e.form===`ref`||e.form===`ask`&&!e.when)&&n.push(e.id.toLowerCase())}for(let r of Gh(e,t))n.includes(r)||n.push(r);return n}function Gh(e,t){if(!Ri(e)||!e.includes(`when:`))return[];let n=ri(e).map(e=>e.read),r=new Set(n.flatMap(e=>e.form===`invalid`?[]:[e.id.toLowerCase()])),i=[];for(let e of n){if(e.form!==`ask`||!e.when||Vh(e,t))continue;let n=e.when.parent.toLowerCase();!r.has(n)&&!i.includes(n)&&i.push(n)}return i}function Kh(e){for(let t=0;t<e.length-1;t++){let n=e[t],r=e[t+1];if(n.kind!==`question`||r.kind!==`prose`||n.registeredId&&n.text.trim()===``)continue;let i=ig(n.text,n.questionKind,n.danger),a=null;if(i.options.length>0){if(i.trailingMd!==void 0||i.recommendation!==void 0)continue;let e=lg(i.options[i.options.length-1]);if(!/^([A-Z]|\d+)$/.test(e))continue;a=e}let o=qh(r.text,a);o!==null&&(e[t]={...n,text:n.text.replace(/\s+$/,``)+`
|
|
94
|
-
|
|
95
|
-
`+o.run},o.rest.trim()?e[t+1]={kind:`prose`,text:o.rest}:e.splice(t+1,1))}return e}function qh(e,t){let n=e.split(`
|
|
96
|
-
`).map(e=>e.replace(/\r$/,``)),r=0;for(;r<n.length&&n[r].trim()===``;)r++;if(r>=n.length||!Yh.test(n[r]))return null;let i=Qh(n[r]);if(t===null?!eg(i):!$h(t,i))return null;let a=r,o=i;for(let e=r+1;e<n.length;e++){let t=n[e];if(Yh.test(t)){if(!$h(o,Qh(t)))break;o=Qh(t),a=e;continue}if(t.trim()===``)continue;if(Xh.test(t)){a=e;break}let r=n.findIndex((t,n)=>n>e&&Yh.test(t));if(r===-1||!$h(o,Qh(n[r])))break}let s=n.slice(r,a+1);return s.filter(e=>Yh.test(e)).length<(t===null?2:1)?null:{run:s.join(`
|
|
97
|
-
`),rest:n.slice(a+1).join(`
|
|
98
|
-
`)}}function Jh(e,t){return Ri(e)?t!==void 0&&t.size>0?Bh(e,!0,t).some(e=>e.kind===`question`):zh(e).some(e=>e.kind===`question`)||Wh(e).length>0:!1}var Yh=/^\s*(?:[-*+]\s+)?([A-Z]|\d+)[.)]\s+\S/,Xh=/^\s*recommendation\b/i;function Zh(e){return e.trim().replace(/^[-*+]\s+/,``)}function Qh(e){return Zh(e).match(/^([A-Za-z]|\d+)[.)]/)?.[1].toUpperCase()??``}function $h(e,t){return/^\d+$/.test(e)?/^\d+$/.test(t)&&Number(t)===Number(e)+1:/^[A-Z]$/.test(e)&&/^[A-Z]$/.test(t)&&t.charCodeAt(0)===e.charCodeAt(0)+1}var eg=e=>e===`A`||e===`1`,tg=/(^|[^a-z])recommended([^a-z]|$)/i;function ng(e){return e.replace(/\s{2,}/g,` `).trim()}function rg(e){if(!tg.test(e))return{label:e,recommended:!1};let t=e.match(/\s*[—–-]?\s*[([]\s*[*_`~]*recommended\b(?:\s*[::,;—–-]\s*([^)\]]*?))?\s*[*_`~]*\s*[)\]]/i);if(t){let n=t[1]?.trim()||void 0;return{label:ng(e.slice(0,t.index)+e.slice(t.index+t[0].length)),recommended:!0,note:n}}let n=e.match(/\s*[—–:-]?\s*[*_`~]+recommended\b[*_`~]+\s*[—–:-]?\s*/i);if(n)return{label:ng(e.slice(0,n.index)+` `+e.slice(n.index+n[0].length)),recommended:!0};let r=e.match(/\s*[—–:-]?\s*recommended\b\s*$/i);if(r&&r.index>0)return{label:ng(e.slice(0,r.index)),recommended:!0};let i=e.match(/^(\s*(?:[A-Za-z]|\d+)[.)]\s*)?[*_`~]*recommended\b[*_`~]*\s*[::—–-]\s*/i);if(i){let t=ng((i[1]??``)+e.slice(i[0].length));if(t)return{label:t,recommended:!0}}return{label:e,recommended:!1}}function ig(e,t,n=!1){let r=e.split(`
|
|
99
|
-
`).map(e=>e.replace(/\r$/,``)),i=e=>r.findIndex((t,n)=>n>e&&Yh.test(t)),a=e=>{let t=[];for(let n=e;n<r.length;n++){if(Yh.test(r[n])){t.push(n);continue}if(t.length===0||r[n].trim()===``)continue;if(Xh.test(r[n]))break;let e=i(n);if(e===-1||!$h(Qh(r[t[t.length-1]]),Qh(r[e])))break}return t},o=e=>{for(let t=e.length-1;t>0;t--)if(!$h(Qh(r[e[t-1]]),Qh(r[e[t]])))return eg(Qh(r[e[t]]))?t:0;return+(e.length===1&&!/^\s*[-*+]\s/.test(r[e[0]])&&!r.slice(0,e[0]).some(e=>e.trim()))},s=[];for(let e=0;e<r.length;){let t=a(e);if(t.length===0)break;let n=o(t);if(n<t.length){s=t.slice(n);break}e=t[0]+1}if(s.length===0)return{kind:t,danger:n,contextMd:e,options:[],recommendedIdxs:[]};let c=s[0],l=s[s.length-1],u=[],d=[],f,p=[];for(let[e,n]of s.entries()){let{label:i,recommended:a,note:o}=rg(Zh(r[n]));a&&(t===`multi`||d.length===0)&&(d.length===0&&(f=o),d.push(u.length)),u.push(i);let c=e===0?[]:r.slice(s[e-1]+1,n).filter(e=>e.trim());p.push(c.length?c.join(`
|
|
100
|
-
`):void 0)}let m=e=>{let t=0,n=e.length-1;for(;t<=n&&e[t].trim()===``;)t++;for(;n>=t&&e[n].trim()===``;)n--;return e.slice(t,n+1)},h=m(r.slice(0,c)).join(`
|
|
101
|
-
`),g,_=[];for(let e of r.slice(l+1))g===void 0&&Xh.test(e)?g=e.trim():_.push(e);let v=m(_).join(`
|
|
102
|
-
`)||void 0;if(d.length===0&&g){let e=og(g,u);e!==null&&(d=[e],f=g)}return{kind:t,danger:n,contextMd:h,options:u,recommendedIdxs:d,recommendedNote:f,recommendation:g,trailingMd:v,...p.some(Boolean)?{optionHeadings:p}:{}}}var ag=/^[*_`~\s]+/;function og(e,t){if(!e)return null;let n=e.replace(/^\s*recommendation\s*:?\s*/i,``).replace(ag,``).match(/^([A-Za-z]|\d+)(?![A-Za-z0-9])/);if(!n)return null;let r=n[1].toUpperCase(),i=t.findIndex(e=>{let t=e.replace(ag,``).match(/^([A-Za-z]|\d+)[.)]/);return t?t[1].toUpperCase()===r:!1});return i===-1?null:i}function sg(e){let t=e,n=``;do n=String.fromCharCode(65+t%26)+n,t=Math.floor(t/26)-1;while(t>=0);return`${n}.`}function cg(e){let t=e.match(/^\s*([A-Za-z]{1,2}|\d+)[.)]\s+/);return t?{id:t[1].toUpperCase(),rest:e.slice(t[0].length)}:{rest:e}}function lg(e){let t=e.match(/^\s*([A-Za-z]|\d+)[.)]/);return t?t[1].toUpperCase():e.trim()}function ug(e,t){let n=t.text.trim();if(e.kind===`multi`){let r=(t.chosenSet??[]).slice().sort((e,t)=>e-t).map(t=>lg(e.options[t]??``)).filter(Boolean).join(`, `);return r&&n?`${r} — ${n}`:r||n}return t.chosen==null?n:e.options[t.chosen]??``}var dg=/^(`{3,})(done|awaiting)[ \t]*\r?\n([\s\S]*?)\r?\n\1`*[ \t]*$/gm;function fg(e,t){return t===`done`?$e(e):xe(e)}function pg(e){let t=[],n=ao(e),r=0;dg.lastIndex=0;for(let i=dg.exec(e);i!==null;i=dg.exec(e)){if(n(i.index)){dg.lastIndex=i.index+1;continue}let a=e.slice(r,i.index);a.trim()&&t.push({kind:`prose`,text:a});let o=i[2],{body:s,hints:c}=fg(i[3],o);t.push({kind:`fence`,fenceKind:o,body:s,hints:c}),r=i.index+i[0].length}let i=e.slice(r);return i.trim()&&t.push({kind:`prose`,text:i}),t}function mg(e,t){for(let n=Math.min(t,e.length)-1;n>=0;n--){let t=e[n];if(!(t.role!==`assistant`||t.kind===`event`)&&pg(t.text).some(e=>e.kind===`fence`&&e.fenceKind===`awaiting`&&ei(e.hints)))return n}return-1}function hg(e,t){let n=e?.lastFence;return!(!n||n.kind!==`done`||n.registered!==!0||t&&pg(t).some(e=>e.kind===`fence`&&e.fenceKind===`done`))}var gg=(e,t)=>[`registeredDone`,e,t.bodyElided??-1,t.body];function _g(e){return e?.kind===`done`&&e.registered===!0&&e.bodyElided!==void 0}function vg(e,t){return e!==void 0&&e.length===t.bodyElided&&qt(e)===t.body}function yg(e){let t=e?.lastFence,n=e?.id??``,r=(0,q.useRef)(void 0);t?.kind===`done`&&t.bodyElided===void 0&&(r.current={slug:n,body:t.body});let i=_g(t)?t:void 0,a=i&&r.current?.slug===n&&vg(r.current.body,i)?r.current.body:void 0,o=G(),s=fi({queryKey:i?gg(n,i):[`registeredDone`,`none`],queryFn:async()=>(await k.threadRegisteredDone({slug:n})).body,enabled:i!==void 0&&a===void 0&&n!==``,staleTime:1/0,refetchOnWindowFocus:!1});if((0,q.useEffect)(()=>{i&&a!==void 0&&o.getQueryData(gg(n,i))===void 0&&o.setQueryData(gg(n,i),a)},[i,a,o,n]),t)return i?a===void 0?s.data===null||s.isError?t.body:s.data:a:t.body}function bg(e,t,n){if(!e||e.kind!==`session`||e.foreign||e.runtime!==`turn-idle`&&e.runtime!==`exited`||e.needsYou!==!0||e.providerError)return!1;if(e.crashed===!0)return!0;if(e.lastFence||e.pendingQuestion||Sa(e)||e.answersInFlight||e.operatorStopped||e.pendingAsk||e.pendingInteraction||e.awaitingBackground||e.limitPause||e.providerFault||!e.lastAssistantAt||t===void 0||pg(t).some(e=>e.kind===`fence`))return!1;if(!Nn(e.spawnedAt)){let r=new Set((e.questions??[]).flatMap(e=>Ea(e.spec).map(e=>e.toLowerCase()))),i=(e.closedQuestions??[]).filter(e=>!r.has(e.handle.toLowerCase()));return!Bh(t,!0,i.length===0?n:new Set([...n??[],...i.map(e=>e.handle.toLowerCase())])).some(e=>e.kind===`question`)}return!Jh(t)}function xg({thread:e}){return e.crashed===!0?(0,X.jsx)($p,{"data-rested-card":`stalled`,icon:pr,label:`Stalled`,children:(0,X.jsx)(`p`,{className:em,children:`The agent's process exited mid-turn. Retry, in the header, re-sends the last message.`})}):(0,X.jsx)($p,{"data-rested-card":`bare`,icon:nt,label:`Rested without a sign-off`,children:(0,X.jsx)(`p`,{className:em,children:`The worker stopped without a done card, a question or a registered wait. Frizz nudges it for one; a reply here also wakes it.`})})}function Sg(e,t){return t!==void 0&&e.some(e=>e.providerError?.at===t.at&&e.providerError?.message===t.message&&e.providerError?.code===t.code)}function Cg({error:e,provider:t}){return(0,X.jsxs)($p,{"data-codex-error":e.code??`unknown`,tone:e.retrying?`caution`:`danger`,icon:pr,label:e.retrying?`${t} retrying`:`${t} request failed`,children:[e.code&&(0,X.jsx)(`p`,{className:`block min-w-0 text-[13px] leading-5 text-fg/75 font-mono [overflow-wrap:anywhere]`,children:e.code}),(0,X.jsx)(`p`,{className:`${em} whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.message}),e.details&&(0,X.jsx)(`p`,{className:`block min-w-0 text-[13px] leading-5 text-fg/75 whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.details})]})}var wg=e=>Vn(e.replace(/\r\n?/g,`
|
|
103
|
-
`)).answers;function Tg(e){return!e||Ng(e)===null?``:Vn(e.replace(/\r\n?/g,`
|
|
104
|
-
`)).note}var Eg=/^(\d+)\.\s+(.*)$/;function Dg(e,t){let n=t.startsWith(` `)?t.slice(2):t;e.answer=e.answer?`${e.answer}\n${n}`:n}function Og(e){if(!e)return null;let t=wg(e).split(`
|
|
105
|
-
`),n=0;for(;n<t.length&&!t[n].trim();)n++;if(n>=t.length||t[n].trim()!==`Answers:`)return null;n++;let r=[];for(;n<t.length;n++){let e=t[n],i=e.match(Eg);if(i)r.push({n:Number(i[1]),answer:i[2]});else if(r.length>0)Dg(r[r.length-1],e);else if(e.trim())return null}if(r.length===0)return null;for(let e of r)e.answer=e.answer.replace(/\s+$/,``);return r}var kg=$a,Ag=RegExp(`^(\\d+)\\.\\s+(⤷\\s+)?(?:\`(${Ze})\`\\s+)?[“"]`),jg=/[”"]\s+→\s+/;function Mg(e){if(!e)return null;let t=wg(e).split(`
|
|
106
|
-
`),n=0;for(;n<t.length&&!t[n].trim();)n++;if(n>=t.length||t[n].trim()!==kg)return null;n++;let r=[],i=null,a=(e,t,n)=>{let i={n:e.n,answer:n},a=t.trim();a&&(i.question=a),e.followUp&&(i.followUp=!0),e.handle&&(i.handle=e.handle),r.push(i)};for(;n<t.length;n++){let e=t[n];if(i){if(Ag.test(e))return null;let t=e.match(jg);t?(a(i,[...i.lines,e.slice(0,t.index)].join(`
|
|
107
|
-
`),e.slice(t.index+t[0].length)),i=null):i.lines.push(e);continue}let o=e.match(Ag);if(o){let t=e.slice(o[0].length),n={n:Number(o[1]),followUp:!!o[2],handle:o[3],lines:[]},r=t.match(jg);r?a(n,t.slice(0,r.index),t.slice(r.index+r[0].length)):i={...n,lines:[t]}}else if(r.length>0)Dg(r[r.length-1],e);else if(e.trim())return null}if(i||r.length===0)return null;for(let e of r)e.answer=e.answer.replace(/\s+$/,``);return r}function Ng(e){return Mg(e)??Og(e)}function Pg(e){return e.filter(e=>e.answer!==tr).map(e=>Ir(e.answer)?{...e,answer:Gt}:e)}function Fg(e){let t=e.split(`
|
|
108
|
-
`),n=[];for(;n.length<t.length&&t[n.length].startsWith(`- [x] `);)n.push(t[n.length].slice(ye.length));return n.length===0?{picks:n,note:e}:{picks:n,note:t.slice(n.length).join(`
|
|
109
|
-
`).trim()}}var Ig=e=>e.displayText??e.text;function Lg(e){return e.role!==`user`||e.kind===`event`||e.kind===`reasoning`?!1:Ng(Ig(e))!==null}var Rg=e=>`${e.handle??``}${e.question??``}${e.answer}`;function zg(e,t){let n=t?Ng(t):null;if(!n?.length)return null;let r=new Set;for(let t of e)if(!(t.role!==`user`||t.kind===`event`||t.kind===`reasoning`))for(let e of Ng(Ig(t))??[])r.add(Rg(e));let i=n.filter(e=>!r.has(Rg(e)));return Pg(i).length>0?i:null}function Bg(e,t){for(let n=t-1;n>=0;n--){let t=e[n];if(t.kind===`event`||t.kind===`reasoning`||!t.text.trim())continue;if(t.role===`user`)return null;if(!t.text.includes("```question"))continue;let r=zh(t.text).filter(e=>e.kind===`question`);if(r.length>0)return r}return null}var Vg=e=>e.kind===`question`?ig(e.text,e.questionKind,e.danger).contextMd.trim():``;function Hg(e,t){if(t.length!==1)return null;let n=e.trim();if(!n)return null;let r=t[0];if(r.kind!==`question`)return null;let i=ig(r.text,r.questionKind,r.danger);if(!i.options.some(e=>e.trim()===n))return null;let a=i.contextMd.trim();return[a?{n:1,answer:n,question:a}:{n:1,answer:n}]}function Ug(e,t){let n=e[t];if(!n||n.role!==`user`||n.kind===`event`)return null;let r=Ig(n),i=Mg(r);if(i)return i;let a=Og(r),o=Bg(e,t);return a?!o||!a.every((e,t)=>Number.isInteger(e.n)&&e.n>=1&&e.n<=o.length&&(t===0||e.n>a[t-1].n))?a:a.map(e=>{let t=Vg(o[e.n-1]);return t?{...e,question:t}:{...e}}):o?Hg(r,o):null}function Wg(e){return e.map((t,n)=>Ug(e,n))}function Gg(e){return e.displayText??e.text}function Kg(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.role===`user`&&!n.queued&&!n.peerFrom&&!n.agentInstruction&&!n.sessionPeer)return t}return-1}function qg(e){for(let t=e.length-1;t>=0;t--)if(Jg(e[t]))return t;return 0}function Jg(e){return e.role!==`user`||e.kind===`event`||e.kind===`reasoning`||e.queued||e.peerFrom||e.agentInstruction||e.sessionPeer?!1:!e.wake||e.text!==void 0&&Lg({...e,text:e.text})}function Yg(e){return e.role===`user`&&e.kind!==`event`&&e.kind!==`reasoning`}function Xg(e,t){for(let n=t+1;n<e.length;n++)if(Yg(e[n]))return n-1;return e.length-1}function Zg(e,t){let n=Date.parse(t),r=e.length-1;if(!Number.isFinite(n))return r;for(let t=0;t<e.length;t++){let r=e[t];if(!Yg(r))continue;let i=r.at?Date.parse(r.at):NaN;if(!(!Number.isFinite(i)||i<=n))return t-1}let i=r;for(;i>=0&&Yg(e[i])&&!(e[i].at&&Number.isFinite(Date.parse(e[i].at)));)i--;return i<0?r:i}function Qg(e){let t=new Map,n=-1;return e.forEach((e,r)=>{if(Jg(e)&&(n=r),e.role!==`assistant`||!e.text)return;let i=i=>{let a=e.questionOwners?.get(i),o=a===void 0?i:$g(i,a),s=t.get(o);(s===void 0||s<n)&&t.set(o,r)};if(e.text.includes("```awaiting")){for(let t of pg(e.text))if(!(t.kind!==`fence`||t.fenceKind!==`awaiting`))for(let e of Ui(t.hints))i(e.toLowerCase())}for(let t of Wh(e.text,e.refusedFences))i(t)}),t}var $g=(e,t)=>`${e}\u0000${t}`;function e_(e,t){let n,r=r=>{for(let i of t.id?[r.toLowerCase(),$g(r.toLowerCase(),t.id)]:[r.toLowerCase()]){let t=e.get(i);t!==void 0&&(n===void 0||t>n)&&(n=t)}};if(t.id&&r(t.id),t.spec)for(let e of Ea(t.spec))r(e);return n}function t_(e,t,n={}){let r=new Map,i=n.claims===!1||t.length===0?void 0:Qg(e);for(let a of t){let t=Zg(e,a.askedAt),o=i?e_(i,a):void 0;if(o!==void 0&&o>t&&(t=Xg(e,o)),n.from!==void 0&&a.standing===!1&&t<n.from)continue;let s=r.get(t);s?s.push(a):r.set(t,[a])}return r}function n_(e,t){for(let n=t;n>=0;n--)if(r_(e[n]))return n+1;return 0}function r_(e){return e.role===`user`&&e.kind!==`event`&&e.kind!==`reasoning`}function i_(e,t){let n=new Map;for(let[r,i]of t_(e,t,{claims:!1}))for(let t=n_(e,r);t<e.length;t++){if(r_(e[t]))continue;let r=n.get(t);r?r.push(...i):n.set(t,[...i])}return n}var a_=12;function o_(e){return e.replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/[*_~`]/g,``).replace(/\s+/g,` `).trim().toLowerCase()}function s_(e){let t=e.indexOf(`?`);return t===-1?void 0:e.slice(0,t+1)}function c_(e,t){if(t.length===0)return!1;let n=o_(ig(e,`question`).contextMd);if(n.length<a_)return!1;let r=s_(n);return t.some(({spec:e})=>{let t=o_(e.question);if(t.length<a_)return!1;if(n.includes(t)||t.startsWith(n))return!0;let i=s_(t);return i!==void 0&&i.length>=a_&&n.includes(i)?!0:r!==void 0&&r.length>=a_&&t.includes(r)})}function l_(e,t){return e.registeredId?t.find(t=>t.id.toLowerCase()===e.registeredId):t.find(t=>c_(e.text,[t]))}function u_(e){let t=[e.id.toLowerCase()];if(e.spec)for(let n of Ea(e.spec))t.push(n.toLowerCase());else e.handle&&t.push(e.handle.toLowerCase());return t}function d_(e,t,n){let r=e.toLowerCase(),i=n?.get(r);if(i!==void 0){let e=t.find(e=>e.id===i);if(e)return e}return t.find(e=>u_(e).includes(r))}function f_(e,t,n){let r=e.questionOwners?.get(t);return r===void 0||r===n}function p_(e,t){return Ri(e)?[...m_(e),...Wh(e,t)]:[]}function m_(e){return e.includes("```question")?zh(e).flatMap(e=>e.kind===`question`&&e.registeredId&&e.text.trim()===``?[e.registeredId]:[]):[]}function h_(e,t){let n=new Map,r=new Set;if(t.length===0)return{placed:n,placedIds:r};let i=new Map,a=t=>{let n=i.get(t);if(n===void 0){let r=e[t];n=r.role===`assistant`&&r.text?p_(r.text,r.refusedFences):[],i.set(t,n)}return n};for(let[i,o]of t_(e,t))for(let t of o){let o=u_(t),s=[],c=!1;for(let n=n_(e,i);n<e.length;n++)Jg(e[n])&&(c=!0),!r_(e[n])&&a(n).some(r=>o.includes(r)&&f_(e[n],r,t.id))&&(c&&(s=[]),s.push(n),c=!1);if(s.length!==0){for(let e of s){let r=n.get(e);r?r.push(t):n.set(e,[t])}r.add(t.id)}}return{placed:n,placedIds:r}}function g_(e,t,n){let r=new Map;for(let[e,t]of n.placed)for(let n of t)r.set(n.id,Math.max(e,r.get(n.id)??e));let i=t.filter(e=>!n.placedIds.has(e.id));for(let[t,n]of t_(e,i))for(let e of n)r.set(e.id,t);return r}function __(e,t){if(t<=0)return e;let n=new Map,r=new Set;for(let[i,a]of e.placed)if(!(i<t)){n.set(i,a);for(let e of a)r.add(e.id)}return{placed:n,placedIds:r}}function v_(e,t){let n=new Set;for(let r of t.placed.keys())n.add(Xg(e,r));return n}function y_(e,t){if(t.length===0||e?.runtime!==`turn-idle`||e.lastFence?.kind!==`awaiting`)return!1;let n=za(e.lastFence.hints);return n.length===t.length&&n.every((e,n)=>e===t[n])}var b_=la({}),x_=new Map,S_=5e3,C_=(e,t)=>`${e}\u0000${t}`;function w_(e){clearTimeout(x_.get(e)),x_.set(e,setTimeout(()=>T_(e),S_))}function T_(e){clearTimeout(x_.get(e)),x_.delete(e),delete b_[e]}function E_(e,t,n){let r=C_(e,t);clearTimeout(x_.get(r)),x_.delete(r),b_[r]={done:n},k.setHumanTodo({slug:e,id:t,done:n}).then(()=>w_(r),e=>{T_(r),K(`Couldn’t save that tick — ${e.message.slice(0,120)}`)})}function D_(e){let t=Br(b_),n=e?.id,r=e?.humanTodos;return(0,q.useEffect)(()=>{if(n)for(let e of r??[]){let t=C_(n,e.id),r=b_[t];r&&r.done===e.done&&(r.staged===void 0||r.staged===e.staged)&&T_(t)}},[n,r]),e?(e.humanTodos??[]).map(n=>{let r=t[C_(e.id,n.id)];return r?{...n,done:r.done,staged:r.staged??(r.done===n.done?n.staged:!n.staged)}:n}):[]}function O_(e){return e.filter(e=>e.staged||!e.done)}function k_(e,t){let n=e.filter(e=>e.done).length,r=n===e.length?Oo:`${Oo} ${n} of ${e.length}:\n${e.map(e=>`- [${e.done?`x`:` `}] ${e.text}`).join(`
|
|
110
|
-
`)}`,i=t.trim();return i?`${r}\n\n${i}`:r}var A_=RegExp(`^${Oo} \\d+ of \\d+:$`),j_=/^- \[( |x)\] (.*)$/;function M_(e){if(ke(e))return`all`;let[t,...n]=Yn(e).split(`
|
|
111
|
-
`);if(!A_.test(t))return null;let r=new Set;for(let e of n){let t=j_.exec(e);if(!t)break;t[1]===`x`&&r.add(t[2])}return r}function N_(e){let t=new Map;for(let n=0;n<e.length;n++){let r=e[n];if(!(r.role!==`assistant`||r.kind===`event`||!r.text.includes("```awaiting")))for(let r=n+1;r<e.length;r++){let i=e[r];if(i.role===`assistant`&&i.kind!==`event`)break;let a=i.role===`user`?M_(i.text):null;if(a){t.set(n,a);break}}}return t}function P_(e){let t=D_(e),n=t.some(e=>e.staged);return{staged:n,take:()=>{if(!e||!n)return null;let r=O_(t),i=r.map(t=>C_(e.id,t.id));return{todos:r.map(({id:e,done:t})=>({id:e,done:t})),compose:e=>k_(r,e),onOptimistic:()=>r.forEach((e,t)=>{b_[i[t]]={done:e.done,staged:!1},w_(i[t])}),onRollback:()=>i.forEach(T_)}}}}function F_(e){let t=e.kind===`session`&&e.foreign!==!0,n=t&&(e.state===`archived`||e.archived===!0),r=t,i=t&&!n;return{lifecycle:r,done:n,snooze:i,archive:i}}function I_(e){if(e.runtime===`exited`&&e.crashed)return!1;if(e.runtime===`perm-prompt`||e.pendingAsk)return!0;if(e.runtime===`running`||e.runtime===`spawning`)return!1;let t=e=>e.state===`running`||e.state===`stale`;return!(e.subAgents?.some(e=>Ei(e)&&t(e))||e.bgShells?.some(t))}function L_(e){let t={lead:`This thread is still running.`,groups:[],trailer:`Marking it done will stop its agent session, then move it to Done.`};if(!e)return t;if(e.cutOff)return{lead:`This session was cut off mid-turn — its worker ended before the turn finished, so the thread isn’t done.`,groups:[],trailer:`Marking it done files it under Done as it is. Retry resumes it where it left off.`};let n=[R_(`agent`,`sub-agent`,e.subAgents,e.subAgentCount),R_(`shell`,`background shell`,e.bgShells,e.bgShellCount)].filter(e=>e!==null);return e.unobservable?{lead:`This session is live, but its transcript can’t be read right now — it may still be working.`,groups:n,trailer:`Marking it done will stop the session anyway, then move it to Done.`}:!e.turnInFlight&&n.length===0?t:{lead:e.turnInFlight?n.length>0?`The agent is mid-turn, and it still owns background work:`:`The agent is mid-turn — it’s executing right now.`:`The agent is resting, but the background work it launched is still running:`,groups:n,trailer:n.length>0?`Marking it done will stop the session and everything running under it, then move it to Done.`:`Marking it done will stop its agent session mid-turn, then move it to Done.`}}function R_(e,t,n,r){let i=Math.max(r,n.length);return i===0?null:{kind:e,heading:`${i} ${t}${i===1?``:`s`}`,items:n.map(e=>({label:e.label,stale:e.state===`stale`})),overflow:Math.max(0,i-n.length)}}function z_(e,t=[],n=[]){let r=B_(e),i=r.filter(e=>e.kind===`github`),a=e.links??[];return{todos:e.humanTodos??[],agents:To(e.subAgents??[],`card`),children:n,shells:c(e.bgShells??[],t),prs:i.filter(e=>e.subject!==`issue`),issues:i.filter(e=>e.subject===`issue`),commands:r.filter(e=>e.kind===`command`),timers:r.filter(e=>e.kind===`timer`),files:a.filter(e=>e.kind===`file`),links:a.filter(e=>e.kind===`link`)}}function B_(e){return!e||e.state===`archived`?[]:(e.watches??[]).filter(e=>e.state===`armed`)}function V_(e){let t=new Set(B_(e).filter(e=>e.kind===`shell`).map(e=>e.target));return e=>t.has(e.taskId??``)||t.has(e.id??``)||t.has(e.label)}var H_=`Watched — this thread wakes when it finishes`,U_=`icon-label-nudge`,W_=class{send=null;listeners=new Set;set(e){if(this.send===e)return;let t=this.send!==null;if(this.send=e,t!==(e!==null))for(let e of this.listeners)e()}run(){return this.send?(this.send(),!0):!1}present=()=>this.send!==null;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e))},G_=(0,q.createContext)(null),K_=(0,q.createContext)(null);function q_(){return(0,q.useState)(()=>new W_)[0]}function J_(e,t){let{stagedCount:n,takeAnswers:r}=t;return(0,q.useMemo)(()=>({composer:e,fencedCount:n,takeFenced:r}),[e,n,r])}function Y_(e){return(0,q.useSyncExternalStore)(e.subscribe,e.present,Z_)}var X_=()=>()=>{},Z_=()=>!1;function Q_(){let e=(0,q.useContext)(K_);return(0,q.useSyncExternalStore)(e?.subscribe??X_,e?.present??Z_,Z_)}var $_=`md-body ${zp} mt-[var(--md-step)] first:mt-0`;function ev({steps:e,done:t}){return(0,X.jsx)(`div`,{"data-awaiting-steps":!0,className:$_,children:(0,X.jsx)(`ul`,{className:`frizz-todos`,children:e.map((e,n)=>(0,X.jsx)(nv,{step:e,done:t===`all`||t?.has(e.text)===!0},n))})})}function tv({md:e}){return(0,X.jsx)(Oh,{className:`md-body frizz-todo-body`,html:jf(e)})}function nv({step:e,done:t}){let n=jf(e.text),r=(0,q.useId)();return(0,X.jsxs)(`li`,{"data-human-todo":!0,"data-done":t,className:`frizz-todo`,children:[(0,X.jsx)(`span`,{role:`checkbox`,"aria-checked":t,"aria-disabled":`true`,"aria-labelledby":r,className:uv(t,!1),children:t&&(0,X.jsx)(dv,{})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{id:r,children:(0,X.jsx)(Oh,{className:`md-body frizz-todo-text`,html:n})}),e.body&&!t&&(0,X.jsx)(tv,{md:e.body})]})]})}function rv({slug:e,todo:t,onTicked:n}){let r=jf(t.text),i=(0,q.useId)();return(0,X.jsxs)(`li`,{"data-human-todo":!0,"data-done":t.done,"data-staged":t.staged,className:`frizz-todo`,children:[(0,X.jsxs)(`span`,{className:uv(t.done,t.staged),children:[t.done&&(0,X.jsx)(dv,{}),(0,X.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":t.done,"aria-labelledby":i,onClick:r=>{E_(e,t.id,!t.done),n?.(r)},onMouseDown:e=>e.preventDefault(),className:`absolute -inset-[5px] rounded-md outline-none focus-visible:ring-1 focus-visible:ring-focus-ink-60`})]}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{id:i,children:(0,X.jsx)(Oh,{className:`md-body frizz-todo-text`,html:r})}),t.body&&(!t.done||t.staged)&&(0,X.jsx)(tv,{md:t.body})]})]})}function iv({thread:e,sends:t}){let n=D_(e);return(0,X.jsxs)(`div`,{"data-human-todo-list":!0,className:$_,children:[(0,X.jsx)(`ul`,{className:`frizz-todos`,children:n.map(t=>(0,X.jsx)(rv,{slug:e.id,todo:t},t.id))}),t&&(0,X.jsx)(ov,{thread:e})]})}function av({thread:e,onReplied:t,onReplyFailed:n}){let r=D_(e),{staged:i}=P_(e),a=(0,q.useContext)(G_),o=Q_(),s=cv(e,t,n),c=(0,q.useRef)(null),[l,u]=(0,q.useState)(!1),d=r.filter(e=>e.done&&!e.staged),f=r.filter(e=>!e.done||e.staged),p=e=>{if(!i||!Dr({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode}))return;let t=e.target;t.closest(`a`)||t.closest(`button[aria-expanded]`)||t.closest(`button[role=checkbox]`)?.getAttribute(`aria-checked`)!==`false`&&(e.preventDefault(),e.stopPropagation(),a?.composer.run()||s())},m=e=>{let t=document.activeElement;t!==e.currentTarget&&!lv(t)&&c.current?.focus()};return r.length===0?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{ref:c,"data-awaiting-steps":!0,tabIndex:-1,onKeyDown:p,className:`${$_} outline-none`,children:[d.length>0&&(0,X.jsx)(`button`,{type:`button`,"data-todos-earlier":!0,"aria-expanded":l,onClick:()=>u(e=>!e),onMouseDown:e=>e.preventDefault(),className:`mb-2 block rounded text-[12px] leading-[18px] text-muted-70 outline-none hover:text-fg/85 focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:l?`Hide completed`:`Show ${d.length} completed`}),(0,X.jsxs)(`ul`,{className:`frizz-todos`,children:[l&&d.map(t=>(0,X.jsx)(rv,{slug:e.id,todo:t,onTicked:m},t.id)),f.map(t=>(0,X.jsx)(rv,{slug:e.id,todo:t,onTicked:m},t.id))]})]}),!o&&(0,X.jsx)(sv,{staged:i,send:s})]})}function ov({thread:e}){let{staged:t}=P_(e),n=cv(e);return(0,X.jsx)(`button`,{type:`button`,"data-steps-send":!0,disabled:!t,onClick:n,className:`mt-3.5 flex h-[46px] w-full items-center justify-center rounded-xl bg-fg text-[15.5px] font-semibold text-bg outline-none disabled:opacity-45`,children:`Send`})}function sv({staged:e,send:t}){return(0,X.jsx)(tm,{"data-awaiting-steps-reply":!0,children:(0,X.jsx)(`button`,{type:`button`,"data-steps-send":!0,disabled:!e,onClick:t,onMouseDown:e=>e.preventDefault(),className:`${om} disabled:opacity-40`,children:`Send`})})}function cv(e,t,n){let{take:r}=P_(e),i=Di(e.id);return()=>{let e=r();e&&i.submit(e.compose(``),{todos:e.todos,onOptimistic:()=>{e.onOptimistic(),t?.()},onRollback:()=>{e.onRollback(),n?.()}})}}function lv(e){return e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement||e instanceof HTMLElement&&e.isContentEditable}function uv(e,t){return`frizz-todo-box border transition-colors ${e?t?`border-accent bg-accent-fill text-on-accent`:`border-control-strong text-fg`:`border-control-strong bg-panel`}`}function dv(){return(0,X.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:(0,X.jsx)(v,{size:12,strokeWidth:3})})}function fv(e){return(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).length}function pv(e,t={}){let n=(e.subAgents??[]).filter(e=>Ei(e)&&e.state===`running`).length,r=(e.bgShells??[]).filter(e=>e.state===`running`).length,i=t.watchers===!1?0:fv(e),a=[n>0?`${n} sub-agent${n===1?``:`s`}`:null,r>0?`${r} background shell${r===1?``:`s`}`:null,i>0?`${i} PR watcher${i===1?``:`s`}`:null].filter(e=>e!==null);return a.length===0?`0 background shells`:a.length===1?a[0]:`${a.slice(0,-1).join(`, `)} and ${a[a.length-1]}`}function mv(e){return(e.subAgents??[]).some(e=>Ei(e)&&e.state===`running`)}function hv(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length}function gv(e){return mv(e)||hv(e)>0}function _v(e,t){return za(t).length>0?ma:vv(e)?Kr:Ba}function vv(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length>0&&!mv(e)&&fv(e)===0&&yv(e).length===0&&bv(e).length===0}function yv(e){return(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`)}function bv(e){return(e.watches??[]).filter(e=>e.kind===`command`&&e.state===`armed`)}var xv={id:``,subAgents:[],bgShells:[],watches:[]},Sv=[];function Cv(e,t){let n=new Set((e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).map(e=>e.target));return vi(t).filter(e=>!n.has(e.ref))}function wv({watch:e}){return(0,q.useEffect)(()=>{e.url&&cn([e.ref])},[e.url,e.ref]),e.url?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,"data-gh-ref":e.ref,className:`${rm} text-[12px]`,children:e.ref}):(0,X.jsx)(`span`,{className:`text-[12px] text-muted`,children:e.ref})}var Tv={mergeable:`no conflicts`,blocked:`merge blocked`,conflicting:`has conflicts`,unknown:null};function Ev(e){return e.state!==`open`||e.merge===`blocked`&&e.checks!==`passing`&&e.checks!==`none`?null:Tv[e.merge]}var Z=`shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)]`;function Dv({tone:e}){return(0,X.jsx)(`span`,{"aria-hidden":!0,className:`inline-block size-3 rounded-full border ${e} border-t-transparent motion-safe:animate-spin ${Z}`})}function Ov(){return(0,X.jsxs)(`svg`,{"aria-hidden":!0,viewBox:`0 0 16 16`,width:12,height:12,fill:`none`,stroke:`currentColor`,overflow:`visible`,className:Z,style:{color:b.fgAttention},children:[(0,X.jsx)(`circle`,{cx:`8`,cy:`8`,r:`4`,fill:`currentColor`,stroke:`none`}),(0,X.jsxs)(`g`,{strokeWidth:`2`,className:`origin-center motion-safe:animate-spin`,children:[(0,X.jsx)(`circle`,{cx:`8`,cy:`8`,r:`7`,opacity:`0.25`}),(0,X.jsx)(`path`,{d:`M15 8A7 7 0 0 1 8 15`})]})]})}function kv({status:e,now:t}){return e?e.state===`merged`?(0,X.jsx)(Et,{size:12,className:Z,style:{color:b.fgDone}}):e.state===`closed`?(0,X.jsx)(P,{size:12,className:Z,style:{color:b.fgDanger}}):qa(e,t)||e.newHeadSince?(0,X.jsx)(nt,{size:12,className:`${Z} text-muted-60`}):e.checks===`failing`?(0,X.jsx)(Fs,{size:12,className:Z,style:{color:b.fgDanger}}):e.checks===`passing`?(0,X.jsx)(Xt,{size:12,className:Z,style:{color:b.fgSuccess}}):e.gated>0&&e.running===0?(0,X.jsx)(Ps,{size:12,className:Z,style:{color:b.fgAttention}}):e.checks===`running`?(0,X.jsx)(Ov,{}):(0,X.jsx)(nt,{size:12,className:`${Z} text-muted-60`}):(0,X.jsx)(nt,{size:12,className:`${Z} text-muted-60`})}function Av(e){return[e.failed>0?`${e.failed} failing`:null,e.gated>0?`${e.gated} awaiting approval`:null,e.running>0?`${e.running} in progress`:null,e.passed>0?`${e.passed} successful`:null,e.skipped>0?`${e.skipped} skipped`:null].filter(e=>e!==null).join(`, `)}function jv(e,t=Date.now()){if(!e)return`Checking…`;if(e.state===`merged`)return`Merged`;if(e.state===`closed`)return`Closed`;let n=e.head?Tn(e.head):void 0,r=Av(e),i=Ev(e),a=[e.newHeadSince?`Waiting for CI${n?` on ${n}`:``}`:r||`No checks`,i].filter(e=>e!==null).join(` · `),o=n&&!e.newHeadSince?` · on ${n}`:``;return qa(e,t)?`Last read ${eo(e.polledAt,t)}: ${a}${o}`:`${a}${o}`}function Mv(e,t=Date.now()){if(!e)return`Checking…`;if(e.state===`open`&&e.failed===0&&!qa(e,t)){if(e.merge===`conflicting`)return`conflicts`;if(e.merge===`blocked`&&e.checks===`passing`)return`blocked`}return Xn(e,t)}var Nv=`group relative flex items-baseline rounded-sm px-2 text-[12px] leading-5`,Pv=`ml-1.5 font-medium text-fg/90`,Fv=`${Pv} line-clamp-2 break-words`,Iv=`${Pv} min-w-0 flex-1 truncate`,Lv=`ml-3 min-w-0 truncate text-right text-muted-70`,Rv=`min-w-1/2 flex-1`,zv=`outline-none after:absolute after:inset-0 after:rounded-sm focus-visible:after:ring-1 focus-visible:after:ring-fg/60`;function Bv(){return(0,X.jsx)(vs,{size:13,"aria-hidden":!0,className:`${Z} ml-[3px] -mr-[4px] text-muted-35 transition-colors group-hover:text-muted-70`})}function Vv({mark:e,name:t,status:n,onOpen:r,onPrewarm:i,href:a,ghRef:o,title:s,testKind:c,testId:l,indent:u,dismiss:d,oneLine:f}){let p=u!==void 0,m=f?`${Pv} truncate`:Fv,h=p?Iv:d?`${m} min-w-0`:`${m} ${Rv}`,g=a?(0,X.jsx)(`a`,{href:a,target:`_blank`,rel:`noreferrer noopener`,title:s,"data-gh-ref":o,onMouseDown:e=>e.stopPropagation(),className:`${h} ${zv} group-hover:underline group-hover:decoration-fg/40 group-hover:underline-offset-2`,children:t}):r?(0,X.jsx)(`button`,{type:`button`,onClick:r,onMouseDown:e=>e.stopPropagation(),title:s,className:`${h} ${zv} text-left group-hover:underline group-hover:decoration-fg/40 group-hover:underline-offset-2`,children:t}):(0,X.jsx)(`span`,{className:h,title:s,children:t}),_=!!(a||r),v=d&&(0,X.jsx)(`button`,{type:`button`,onClick:d.onDismiss,onMouseDown:e=>e.stopPropagation(),title:d.title,"aria-label":d.label,className:`relative ml-0.5 shrink-0 self-start mt-[2.5px] rounded-sm p-0.5 text-muted-45 outline-none transition-colors hover:text-fg focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:(0,X.jsx)(bi,{size:11})});return(0,X.jsxs)(`div`,{"data-wait-row":l,"data-wait-kind":c,onMouseEnter:i,onFocus:i,style:p?{paddingLeft:8+u}:void 0,className:`${Nv} ${_?`cursor-pointer transition-colors hover:bg-fg/[0.045]`:``}`,children:[(0,X.jsx)(`span`,{className:`flex shrink-0`,children:e}),v?(0,X.jsxs)(`span`,{className:`flex items-baseline ${Rv}`,children:[g,v]}):g,(0,X.jsx)(`span`,{"data-wait-status":!0,className:Lv,children:n}),_?(0,X.jsx)(Bv,{}):(0,X.jsx)(`span`,{"aria-hidden":!0,className:`w-3 shrink-0`})]})}function Hv({status:e}){return e?e.state===`closed`?e.stateReason===`not_planned`||e.stateReason===`duplicate`?(0,X.jsx)(Pt,{size:12,className:`${Z} text-muted`}):(0,X.jsx)(Xt,{size:12,className:Z,style:{color:b.fgDone}}):(0,X.jsx)(Me,{size:12,className:Z,style:{color:b.fgSuccess}}):(0,X.jsx)(nt,{size:12,className:`${Z} text-muted-60`})}function Uv(e){if(!e)return`Checking…`;if(e.state===`closed`){let t=e.stateReason===`not_planned`?`not planned`:e.stateReason===`duplicate`?`duplicate`:null;return t?`Closed as ${t}`:`Closed`}return`Open · ${e.comments} comment${e.comments===1?``:`s`}`}function Wv({watch:e}){if(e.subject===`issue`)return(0,X.jsx)(Gv,{watch:e});let t=e.github,n=Ja(e.target),r=da();return(0,q.useEffect)(()=>{n&&cn([e.target])},[n,e.target]),(0,X.jsx)(Vv,{testKind:`github`,testId:e.target,mark:(0,X.jsx)(kv,{status:t,now:r}),name:e.target,href:n??void 0,ghRef:n?e.target:void 0,title:n?`Open ${e.target} on GitHub — ${jv(t,r)}`:e.target,status:t&&t.state===`open`&&t.failed>0&&n&&!qa(t,r)?(0,X.jsx)(`a`,{href:`${n}/checks`,target:`_blank`,rel:`noreferrer noopener`,title:`View the failing checks on ${e.target}`,onMouseDown:e=>e.stopPropagation(),className:`relative underline underline-offset-2 ${An}`,children:Mv(t,r)}):Mv(t,r)})}function Gv({watch:e}){let t=e.issue,n=Ja(e.target,`issue`);return(0,q.useEffect)(()=>{n&&cn([e.target])},[n,e.target]),(0,X.jsx)(Vv,{testKind:`github`,testId:`issue:${e.target}`,mark:(0,X.jsx)(Hv,{status:t}),name:t?.title?`${e.target} ${t.title}`:e.target,href:n??void 0,ghRef:n?e.target:void 0,title:n?`Open ${e.target} on GitHub — ${Uv(t)}`:e.target,status:t?Jt(t):`Checking…`})}function Kv(e,t){return(e.bgShells??[]).find(e=>e.id===t||e.taskId===t||e.label===t)}function qv(e){return(e.watches??[]).filter(e=>e.kind===`shell`&&e.state===`armed`)}function Jv({watch:e,thread:t,slug:n,now:r}){let i=Kv(t,e.target);if(i)return(0,X.jsx)(Xv,{shell:i,slug:n,now:r,testId:e.target});let a=Ss(e.createdAt,r);return(0,X.jsx)(Vv,{testKind:`shell`,testId:e.target,mark:(0,X.jsx)(oc,{size:12,className:`${Z} text-shell`}),name:e.target,title:e.target,status:a})}function Yv(e,t,n,r,i){if(!e||t&&n)return;let a=t?`running`:`settled`;return{onDismiss:e,title:Bt[a],label:`${me[a]} ${wt[r]}: ${i}`}}function Xv({shell:e,slug:t,now:n,testId:r,onDismiss:i,watched:a}){let o=Ss(e.startedAt,n),s=e.state===`running`,c=e.id&&!e.outputUnavailable,l=s?`running for ${o}`:Ae;return(0,X.jsx)(Vv,{testKind:`shell`,testId:r??e.id??e.label,mark:(0,X.jsx)(oc,{size:12,className:`${Z} ${s?`text-shell`:`text-muted-60`}`}),name:e.label,onOpen:c?()=>ka(t,e.id,{label:e.label,startedAt:e.startedAt}):void 0,title:[c?`Read this shell's output — ${l}`:s?e.label:`${e.label} — ${l}`,a?H_:null].filter(Boolean).join(`
|
|
112
|
-
`),status:o,dismiss:Yv(i,s,!!c,`SHELL`,e.label)})}function Zv({watch:e,now:t}){let n=e.timer?.prompt;return(0,X.jsx)(Vv,{testKind:`timer`,testId:e.target,mark:(0,X.jsx)(vt,{size:12,className:`${Z} text-muted-60`}),name:n||e.target,oneLine:!0,title:Qv(e),status:$v(e,t)})}function Qv(e){return[e.timer?.prompt,e.timer?.fireAt?`One-off timer, set for ${e.timer.fireAt}`:e.target].filter(Boolean).join(`
|
|
113
|
-
|
|
114
|
-
`)}function $v(e,t){let n=Date.parse(e.timer?.fireAt??``);return Number.isFinite(n)?n>t?`in ${Oe(n-t)}`:`firing…`:`armed`}function ey(e){return e.trim().replace(/\s+/g,` `).replace(/(^|[\s'"=])\/(?:[^\s'"/]*\/){2,}(?=[^\s'"/])/g,`$1`)}function ty(e){return e.command?.monitor?.description||ey(e.command?.command??e.target)}function ny({watch:e,slug:t,now:n}){let r=e.command?.monitor,i=r?ns:jr,a=ty(e);return(0,X.jsx)(Vv,{testKind:`command`,testId:e.target,mark:(0,X.jsx)(i,{size:12,className:`${Z} text-muted-60`}),name:a,oneLine:!0,title:ry(e,n),status:iy(e),onOpen:r?()=>Vi(t,e.target,{label:a}):void 0})}function ry(e,t){let n=e.command,r=n?.monitor;if(n&&r){let e=r.lastEvent;return[n.command,`Kept running by Frizz; every line it prints wakes the thread.`,e?`${r.events} event${r.events===1?``:`s`} so far. The last, ${Ss(e.at,t)} ago:`:`No events yet.`,e?.text.trim()||null].filter(Boolean).join(`
|
|
115
|
-
|
|
116
|
-
`)}let i=n?.lastRun,a=n&&i?`${n.runs} check${n.runs===1?``:`s`} so far. The last, ${Ss(i.at,t)} ago, ${pa(i)}.`:null;return[n?.command??e.target,n?`Re-run every ${n.every} until it exits 0.`:null,a,i?.output.trim()||null].filter(Boolean).join(`
|
|
117
|
-
|
|
118
|
-
`)}function iy(e){let t=e.command?.monitor;return t?t.events===0?`running`:`${t.events} event${t.events===1?``:`s`}`:e.command?`every ${e.command.every}`:`armed`}function ay(e){return(e.subAgents??[]).filter(e=>Ei(e)&&e.state===`running`)}function oy({agent:e,slug:t,now:n,onDismiss:r}){let i=Ss(e.startedAt,n),a=Po(e.subagentType),o=e.state===`stale`;return(0,X.jsx)(Vv,{testKind:`agent`,testId:e.id??e.label,mark:o?(0,X.jsx)(`span`,{"aria-hidden":!0,className:`inline-block size-3 p-[3px] ${Z}`,children:(0,X.jsx)(`span`,{className:Pn})}):(0,X.jsx)(Dv,{tone:`border-accent`}),name:e.label,onOpen:e.id?()=>Er(t,e.id,{label:e.label,subagentType:e.subagentType,startedAt:e.startedAt}):void 0,title:e.id?`Open this sub-agent${a?` (${a})`:``} — ${o?En:`working for ${i}`}`:e.label,status:i,dismiss:Yv(r,e.state===`running`,!!e.id,`AGENT`,e.label)})}function sy({child:e,now:t}){let n=Lo(e),r=mo(e),i=Ss(Pa(e),t),a=r===`running`?(0,X.jsx)(Dv,{tone:`border-accent`}):(0,X.jsx)(`span`,{"aria-hidden":!0,className:`inline-block size-3 p-[3px] ${Z}`,children:(0,X.jsx)(`span`,{className:r===`stale`?Pn:ws})}),o=r===`rested`&&!e.needsYou&&e.waitStatus!==void 0,s=e.needsYou?Hn:r===`running`?i:r===`stale`?`stale`:o?no:`rested`;return(0,X.jsx)(Vv,{testKind:`thread`,testId:e.id,mark:a,name:n,onOpen:()=>oi(e.id),title:`Open child thread — ${r===`running`?`working for ${i}`:r===`stale`?et:e.needsYou?Hn:o?Ke:Se}`,status:s})}function cy(e,t,n){let r=new Set(n.map(e=>e.target)),i=[];for(let n of t){if(n.kind!==`shell`)continue;let t=n.value.trim();if(!t||r.has(t))continue;let a=Kv(e,t);!a||a.state!==`running`||(r.add(t),i.push({id:`shell:${e.id}:${t}`,kind:`shell`,target:t,state:`armed`,createdAt:a.startedAt}))}return i}function ly(e,t={}){let n=(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`),r=n.filter(e=>e.subject!==`issue`),i=n.filter(e=>e.subject===`issue`),a=qv(e),o=[...a,...cy(e,t.hints??[],a)],s=ay(e),c=new Set((t.hints??[]).filter(e=>e.kind===`thread`).map(e=>e.value));return{prs:r,issues:i,shells:o,agents:s,children:(t.childThreads??[]).filter(e=>mo(e)===`running`||c.has(e.id)),timers:yv(e),commands:bv(e)}}function uy(e,t,n={}){let{prs:r,issues:i,shells:a,agents:o,children:s,timers:c,commands:l}=ly(e,n);return[{head:`Sub-agents`,rows:o.map(n=>(0,X.jsx)(oy,{agent:n,slug:e.id,now:t},n.id??n.label))},{head:`Child threads`,rows:s.map(e=>(0,X.jsx)(sy,{child:e,now:t},e.id))},{head:`Background shells`,rows:a.map(n=>(0,X.jsx)(Jv,{watch:n,thread:e,slug:e.id,now:t},n.id))},{head:`Pull requests`,rows:r.map(e=>(0,X.jsx)(Wv,{watch:e},e.id))},{head:`Issues`,rows:i.map(e=>(0,X.jsx)(Wv,{watch:e},e.id))},{head:`Monitors`,rows:l.map(n=>(0,X.jsx)(ny,{watch:n,slug:e.id,now:t},n.id))},{head:`Timers`,rows:c.map(e=>(0,X.jsx)(Zv,{watch:e,now:t},e.id))}].filter(e=>e.rows.length>0)}function dy({group:e,first:t}){let n=`px-2 text-[10.5px] uppercase tracking-wide text-muted-45 ${t?``:`mt-4`}`;return e.onToggle?(0,X.jsxs)(`button`,{type:`button`,onClick:e.onToggle,"aria-expanded":!e.collapsed,onMouseDown:e=>e.stopPropagation(),className:`${n} flex items-baseline rounded-sm text-left transition-colors hover:text-muted-80`,children:[(0,X.jsx)(`span`,{children:e.head}),e.count!==void 0&&(0,X.jsx)(`span`,{className:`ml-1.5 tabular-nums`,children:e.count}),(0,X.jsx)(vs,{size:10,"aria-hidden":!0,className:`${Z} ml-[5px] transition-transform ${e.collapsed?``:`rotate-90`}`})]}):(0,X.jsx)(`div`,{className:n,children:e.head})}function fy({groups:e,divider:t}){return e.length===0?null:(0,X.jsxs)(X.Fragment,{children:[t&&(0,X.jsx)(`div`,{"aria-hidden":!0,className:`-mx-4 mt-3 border-t border-border`}),(0,X.jsx)(`div`,{className:`-mx-2 mt-3 flex flex-col gap-y-px`,children:e.map((e,t)=>(0,X.jsxs)(q.Fragment,{children:[(0,X.jsx)(dy,{group:e,first:t===0}),!e.collapsed&&e.rows]},e.head))})]})}function py(e){return e?.lastFence?.kind===`awaiting`&&Ro(e.lastFence.hints)?!1:e?.awaitingBackground===!0&&e.runtime===`turn-idle`&&e.bgSnoozed!==!0}var my=`Hides card until new activity is detected`;function hy({thread:e,onSnooze:t,onSnoozeFailed:n}){let[r,i]=(0,q.useState)(!1);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{i(!0),t?.(),k.snoozeAwaitingBackground({slug:e.id,sessionId:e.sessionId??``}).then(()=>K(`Snoozed until the background work returns`)).catch(e=>{n?.(),K(`Couldn’t snooze: ${e.message.slice(0,80)}`),i(!1)})},disabled:r,onMouseDown:e=>e.preventDefault(),title:my,className:`disabled:opacity-45 ${om}`,children:[(0,X.jsx)(Jo,{size:12,className:U_}),`Snooze`]}),(0,X.jsx)(`span`,{className:nm,children:my})]})}function gy({thread:e,fence:t,onSnooze:n,onSnoozeFailed:r,onReplied:i,onReplyFailed:a,stepsDone:o}){let s=e??xv,c=t??(e?.lastFence?.kind===`awaiting`?e.lastFence:void 0),l=c?.hints??Sv,u=za(l),d=uo(l),f=e!==void 0&&y_(e,u),p=mv(s),m=ti(c?.body),h=jf(m??``),g=da(),_=u.length===0,v=ta(s.id),y=_?uy(s,g,{hints:l,childThreads:v}):[],b=_?Cv(s,l):[],x=e!==void 0&&t===void 0&&u.length===0&&e.waitStatus!==`watching`&&py(e)&&F_(e).snooze;return(0,X.jsxs)($p,{"data-awaiting-background":!0,icon:u.length>0?Gs:vv(s)?oc:Jo,kind:_v(s,l),label:d?(0,X.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:d}):null,children:[m?(0,X.jsx)(Oh,{className:`md-body ${zp}`,html:h}):y.length===0&&!gv(s)&&u.length===0?(0,X.jsx)(`p`,{className:em,children:bo}):null,u.length>0&&(f?(0,X.jsx)(av,{thread:e,onReplied:i,onReplyFailed:a}):(0,X.jsx)(ev,{steps:Or(l),done:o})),b.length>0&&(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:b.map(e=>(0,X.jsx)(wv,{watch:e},e.ref))}),_&&y.length===0&&gv(s)&&(0,X.jsx)(`p`,{className:`block min-w-0 text-[13px] leading-5 text-fg/75`,children:p?(0,X.jsxs)(X.Fragment,{children:[`It’s awaiting the results from `,pv(s,{watchers:!1}),` it dispatched. It returns to the queue on its own when the work comes back.`]}):(0,X.jsxs)(X.Fragment,{children:[pv(s,{watchers:!1}),` `,hv(s)===1?`is`:`are`,` still running. It resumes on its own when`,` `,hv(s)===1?`it finishes`:`one of them finishes`,`.`]})}),(0,X.jsx)(fy,{groups:y,divider:!!m}),x?(0,X.jsx)(tm,{"data-awaiting-snooze":!0,children:(0,X.jsx)(hy,{thread:e,onSnooze:n,onSnoozeFailed:r})}):null]})}function _y(e){let t=e?Date.parse(e):NaN;return Number.isFinite(t)?t:null}function vy(e,t){let n=_y(e),r=_y(t);return n===null||r===null?null:new Date(n).toDateString()!==new Date(r).toDateString()||r-n>=12e5?t:null}function yy(e,t){let n=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();return Math.round((n(t)-n(e))/864e5)}function by(e,t=new Date,n){let r=new Date(Date.parse(e)),i=r.toLocaleTimeString(n,{hour:`numeric`,minute:`2-digit`}),a=yy(r,t);return{day:a===0?`Today`:a===1?`Yesterday`:a>1&&a<7?r.toLocaleDateString(n,{weekday:`long`}):r.toLocaleDateString(n,r.getFullYear()===t.getFullYear()?{month:`short`,day:`numeric`}:{month:`short`,day:`numeric`,year:`numeric`}),time:i}}function xy(e,t=new Date,n){let r=_y(e);if(r===null)return null;let i=new Date(r),a=i.toLocaleTimeString(n,{hour:`numeric`,minute:`2-digit`}),o=yy(i,t);return`${o===0?`Today`:o===1?`Yesterday`:i.toLocaleDateString(n,i.getFullYear()===t.getFullYear()?{weekday:`long`,month:`long`,day:`numeric`}:{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})} at ${a}`}function Q({icon:e,children:t,sourceId:n,ariaLabel:r,marker:i,at:a,trailing:o,onClick:s,ariaExpanded:c,ariaControls:l}){let u=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:Cy}),(0,X.jsx)(Sy,{icon:e,at:a,trailing:o,children:t}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:Cy})]});return s?(0,X.jsx)(`button`,{type:`button`,"data-wake-divider":i,onClick:s,onMouseDown:e=>e.preventDefault(),"aria-label":r,"aria-expanded":c,"aria-controls":l,className:`group/wake @container/wake my-1 flex w-full items-center gap-3 rounded-sm text-left outline-none focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:u}):(0,X.jsx)(`div`,{"data-frizz-msg":n,"data-wake-divider":i,className:`@container/wake my-1 flex items-center gap-3`,role:r?`separator`:void 0,"aria-label":r,children:u})}function Sy({icon:e,children:t,at:n,trailing:r}){return(0,X.jsxs)(`span`,{className:`petite-caps flex min-w-0 items-center gap-1 overflow-x-clip break-words text-center text-[12px] text-muted-70 transition-colors group-hover/wake:text-fg${r?` pr-px`:``}`,children:[e&&(0,X.jsx)(e,{"aria-hidden":`true`,size:12,className:`shrink-0 translate-y-[0.04em]`}),t,(0,X.jsx)(ky,{at:n}),r]})}var Cy=`h-px min-w-[50px] flex-1 bg-border/70 transition-colors group-hover/wake:bg-border`,wy=`@max-[34rem]/wake:hidden`,Ty=`@min-[34rem]/wake:hidden`,Ey=`@max-[19.5rem]/wake:hidden`;function Dy({open:e}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50 ${Ey}`,children:`·`}),(0,X.jsxs)(`span`,{className:`shrink-0 ${Ey}`,children:[(0,X.jsx)(`span`,{className:wy,children:`Click to `}),e?`collapse`:`expand`]})]})}function Oy({lead:e,title:t,tail:n,note:r}){return(0,X.jsxs)(X.Fragment,{children:[e&&(0,X.jsxs)(`span`,{className:`shrink-0 @max-[34rem]/wake:hidden`,children:[e,` `]}),(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center`,title:t,children:[(0,X.jsx)(`span`,{className:`shrink-0`,children:`«`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,X.jsx)(`span`,{className:`shrink-0`,children:`»`})]}),n&&(0,X.jsxs)(`span`,{className:`shrink-0`,children:[` `,n]}),r&&(0,X.jsxs)(`span`,{className:`shrink-0 @max-[34rem]/wake:hidden`,children:[` `,r]})]})}function ky({at:e}){let t=eo(e,da());return t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,X.jsx)(`span`,{title:xy(e)??void 0,className:`shrink-0 tabular-nums`,children:t})]}):null}var Ay=`shrink-0 translate-y-[0.04em]`;function jy({bump:e,sourceId:t,at:n}){let r=e.kind===`schedule`;if(e.kind===`signoff`){let e=`Frizz asked for a sign-off`;return(0,X.jsx)(Q,{icon:rc,sourceId:t,marker:`rest`,ariaLabel:e,at:n,children:(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,X.jsx)(`span`,{className:wy,children:e}),(0,X.jsx)(`span`,{className:Ty,children:`Sign-off requested`})]})})}let i=r?`Goal${e.every?` · every ${e.every}`:``}`:`Goal · at rest`;return(0,X.jsx)(Q,{icon:r?Bo:ec,sourceId:t,marker:r?`schedule`:`rest`,ariaLabel:i,at:n,children:(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:i})})}function My({h:e=14}){return(0,X.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0`,style:{height:e}})}function Ny(e,t,n){return e===1?n?`New ${t} from @${n}`:`New ${t}`:`${e} new items`}var Py=`rounded-sm underline decoration-muted/30 underline-offset-2 outline-none transition-colors hover:text-fg hover:decoration-fg/60 focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`;function Fy({steer:e,text:t,sourceId:n,at:r}){let i=jt(t);if(i)return(0,X.jsx)(Iy,{parts:i,sourceId:n,at:r});let a=st(t);if(a)return(0,X.jsx)(jy,{bump:a,sourceId:n,at:r});let o=tn(t);if(o)return(0,X.jsx)(Zy,{wake:o,sourceId:n,at:r});let s=Cs(t);if(s)return(0,X.jsx)(Ry,{wake:s,sourceId:n});let c=z(t);if(c)return(0,X.jsx)(Yy,{window:c.window,sourceId:n,at:r});let l=ae(t);if(l)return(0,X.jsx)(Xy,{capped:l.capped,to:l.to,sourceId:n,at:r});let u=Zi(t);if(u)return(0,X.jsx)(By,{wake:u,sourceId:n,at:r});let d=ht(t);if(d)return(0,X.jsx)(Vy,{watchRef:d.ref,sourceId:n,at:r});let f=Ct(t);if(f)return(0,X.jsx)(Vy,{watchRef:f.ref,sentence:`Not found — watcher ended`,sourceId:n,at:r});let p=h(t);if(p)return(0,X.jsx)(Gy,{kind:p.kind,sourceId:n,at:r});let m=j(t);if(m)return(0,X.jsx)(Ky,{wake:m,sourceId:n,at:r});let g=aa(t);if(g)return(0,X.jsx)(qy,{wake:g,sourceId:n,at:r});let _=vn(t);if(_)return(0,X.jsx)(Jy,{agents:_.agents,sourceId:n,at:r});let v=Le(t);if(v)return(0,X.jsx)(zy,{count:v.count,sourceId:n,at:r});let y=pe(t),b=zt(t),x=e??$o(y||b?t.split(`
|
|
119
|
-
`).filter(e=>!pe(e)&&!zt(e)).join(`
|
|
120
|
-
`):t);return!x&&!y&&!b?(0,X.jsx)(`div`,{"data-frizz-msg":n,"data-frizz-wake":!0,className:`min-w-0 max-w-[85%]`,children:(0,X.jsx)($p,{icon:Os,label:`Frizz`,children:(0,X.jsx)(Ly,{text:to(t)})})}):y||b?(0,X.jsxs)(`div`,{"data-frizz-wake":!0,className:`flex flex-col`,children:[y&&(0,X.jsx)(Qy,{wake:y,sourceId:n,at:r}),b&&(0,X.jsxs)(X.Fragment,{children:[y&&(0,X.jsx)(My,{}),(0,X.jsx)($y,{wake:b,sourceId:y?void 0:n,at:r})]}),x&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(My,{}),(0,X.jsx)(eb,{steer:x,text:t,at:r})]})]}):(0,X.jsx)(eb,{steer:x,text:t,sourceId:n,at:r})}function Iy({parts:e,sourceId:t,at:n}){let r=e.map(e=>to(e.body)).filter(e=>!hs(e)&&!Go(e));return r.length?(0,X.jsx)(`div`,{"data-frizz-wake":`merged`,className:`flex flex-col`,children:r.map((e,r)=>(0,X.jsxs)(q.Fragment,{children:[r>0&&(0,X.jsx)(My,{}),(0,X.jsx)(Fy,{text:e,sourceId:r===0?t:void 0,at:n})]},r))}):null}function Ly({text:e}){let t=jf(e),n=yp(t),r=(0,q.useRef)(null),i=Am(r,t);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{ref:r,className:`md-body [overflow-wrap:anywhere]`,dangerouslySetInnerHTML:n}),i]})}function Ry({wake:e,sourceId:t}){let[n,r]=(0,q.useState)(!1),i=(0,q.useId)();return(0,X.jsxs)(`div`,{"data-frizz-msg":t,className:`flex flex-col`,children:[(0,X.jsxs)(Q,{icon:we,marker:`timer`,at:e.at,onClick:()=>r(e=>!e),ariaExpanded:n,ariaControls:i,ariaLabel:`${n?`Collapse`:`Expand`} the text this timer handed back`,children:[(0,X.jsx)(`span`,{className:`shrink-0`,children:`Timer`}),(0,X.jsx)(Dy,{open:n})]}),n&&(0,X.jsx)(`div`,{id:i,className:`mt-1.5 whitespace-pre-wrap border-l border-border/70 pl-3 text-[13px] text-muted [overflow-wrap:anywhere]`,children:e.prompt})]})}function zy({count:e,sourceId:t,at:n}){let r=`${e} question${e===1?``:`s`} cancelled`,i=` — the worker decides ${e===1?`it`:`them`} itself`;return(0,X.jsx)(Q,{icon:qs,sourceId:t,marker:`event`,ariaLabel:`${r}${i}`,at:n,children:(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[r,(0,X.jsx)(`span`,{className:wy,children:i})]})})}function By({wake:e,sourceId:t,at:n}){let[r,i]=(0,q.useState)(!1),a=(0,q.useId)(),o=e.kind===`expired`?`Wait expired`:`Wait over`,s=e.kind===`expired`?` — nothing resolved`:` — its work finished`,c=(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[o,(0,X.jsx)(`span`,{className:wy,children:s})]});return e.items.length?(0,X.jsxs)(`div`,{"data-frizz-msg":t,className:`flex flex-col`,children:[(0,X.jsxs)(Q,{icon:Jo,marker:`event`,at:n,onClick:()=>i(e=>!e),ariaExpanded:r,ariaControls:a,ariaLabel:`${r?`Collapse`:`Expand`} what this wait named`,children:[c,(0,X.jsx)(Dy,{open:r})]}),r&&(0,X.jsx)(`div`,{id:a,className:`mt-1.5 whitespace-pre-wrap border-l border-border/70 pl-3 text-[13px] text-muted [overflow-wrap:anywhere]`,children:e.items.join(`
|
|
121
|
-
`)})]}):(0,X.jsx)(Q,{icon:Jo,sourceId:t,marker:`event`,ariaLabel:`${o}${s}`,at:n,children:c})}function Vy({watchRef:e,sentence:t=`Watcher expired`,sourceId:n,at:r}){let i=Ja(e);return(0,X.jsx)(Q,{icon:pn,sourceId:n,marker:`event`,ariaLabel:`${t} on ${e}`,at:r,children:(0,X.jsx)(Hy,{sentence:t,children:i?(0,X.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,className:Py,children:(0,X.jsx)(Wy,{value:e})}):(0,X.jsx)(Wy,{value:e})})})}function Hy({sentence:e,children:t}){return(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),(0,X.jsxs)(`span`,{className:`shrink-0 whitespace-pre`,children:[(0,X.jsx)(Uy,{}),` `,t]})]})}function Uy(){return(0,X.jsx)(`span`,{className:wy,children:` on`})}function Wy({value:e}){let t=e.lastIndexOf(`#`);return t<=0?(0,X.jsx)(X.Fragment,{children:e}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:wy,children:e.slice(0,t)}),e.slice(t)]})}function Gy({kind:e,sourceId:t,at:n}){let r=` on a ${e===`agent`?`sub-agent`:`background shell`}`;return(0,X.jsx)(Q,{icon:e===`agent`?ks:oc,sourceId:t,marker:`event`,ariaLabel:`Watch expired${r}`,at:n,children:(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`Watch expired`,(0,X.jsx)(`span`,{className:wy,children:r})]})})}function Ky({wake:e,sourceId:t,at:n}){let[r,i]=(0,q.useState)(!1),a=(0,q.useId)(),o=e.kind===`cancelled`?`stopped`:e.kind;return(0,X.jsxs)(`div`,{"data-frizz-msg":t,className:`flex flex-col`,children:[(0,X.jsxs)(Q,{icon:jr,marker:`event`,at:n,onClick:()=>i(e=>!e),ariaExpanded:r,ariaControls:a,ariaLabel:`${r?`Collapse`:`Expand`} how this monitor ended`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate ${Ty}`,children:`${o.charAt(0).toUpperCase()}${o.slice(1)}`}),(0,X.jsx)(`span`,{className:`flex min-w-0 items-center gap-1 ${wy}`,children:(0,X.jsx)(Oy,{lead:`Monitor`,title:ey(e.command),tail:e.kind===`cancelled`?`stopped by Frizz`:o})}),(0,X.jsx)(Dy,{open:r})]}),r&&(0,X.jsxs)(`div`,{id:a,className:`mt-1.5 flex flex-col gap-1.5 border-l border-border/70 pl-3 text-[13px] text-muted [overflow-wrap:anywhere]`,children:[(0,X.jsx)(`div`,{className:`whitespace-pre-wrap font-mono text-[12px]`,children:e.command}),(0,X.jsx)(`div`,{children:e.summary}),e.output!==void 0&&(0,X.jsx)(`div`,{className:`whitespace-pre-wrap font-mono text-[12px]`,children:e.output})]})]})}function qy({wake:e,sourceId:t,at:n}){let[r,i]=(0,q.useState)(!1),a=(0,q.useId)(),o=`${e.count} line${e.count===1?``:`s`}`,s=e.kind===`event`?o:e.kind===`exited`?`Ended`:e.kind===`expired`?`Expired`:`Stopped`,c=e.kind===`event`?o:e.kind===`exited`?`ended`:e.kind===`expired`?`expired`:e.by===`human`?`stopped by you`:`stopped by Frizz`;return(0,X.jsxs)(`div`,{"data-frizz-msg":t,className:`flex flex-col`,children:[(0,X.jsxs)(Q,{icon:ns,marker:`event`,at:n,onClick:()=>i(e=>!e),ariaExpanded:r,ariaControls:a,ariaLabel:`${r?`Collapse`:`Expand`} ${e.kind===`event`?`what this monitor printed`:`how this monitor ended`}`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate ${Ty}`,children:s}),(0,X.jsx)(`span`,{className:`flex min-w-0 items-center gap-1 ${wy}`,children:(0,X.jsx)(Oy,{lead:`Monitor`,title:e.label??ey(e.command??e.id),tail:c})}),(0,X.jsx)(Dy,{open:r})]}),r&&(0,X.jsxs)(`div`,{id:a,className:`mt-1.5 flex flex-col gap-1.5 border-l border-border/70 pl-3 text-[13px] text-muted [overflow-wrap:anywhere]`,children:[e.command!==void 0&&(0,X.jsx)(`div`,{className:`whitespace-pre-wrap font-mono text-[12px]`,children:e.command}),(0,X.jsx)(`div`,{children:e.summary}),e.output!==void 0&&(0,X.jsx)(`div`,{className:`whitespace-pre-wrap font-mono text-[12px]`,children:e.output})]})]})}function Jy({agents:e,sourceId:t,at:n}){return(0,X.jsx)(`div`,{"data-frizz-msg":t,className:`flex flex-col`,children:e.map((e,t)=>(0,X.jsxs)(q.Fragment,{children:[t>0&&(0,X.jsx)(My,{}),(0,X.jsx)(Q,{icon:ks,marker:`event`,ariaLabel:`Sub-agent ${e.label} stopped by the interrupt`,at:n,children:(0,X.jsx)(Oy,{lead:`Sub-agent`,title:e.label,tail:`stopped`,note:`by the interrupt`})})]},t))})}function Yy({window:e,sourceId:t,at:n}){let r=e===`weekly`?`Weekly usage limit`:e===`session`?`Session usage limit`:`Usage limit`,i=`${r} reset — resuming`,a=e===`weekly`?`Weekly`:e===`session`?`Session`:null;return(0,X.jsx)(Q,{icon:Jo,sourceId:t,marker:`limit-resume`,ariaLabel:i,at:n,children:(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[a?(0,X.jsxs)(X.Fragment,{children:[a,(0,X.jsx)(`span`,{className:wy,children:` usage`}),` limit`]}):r,` reset`,(0,X.jsx)(`span`,{className:wy,children:` — resuming`})]})})}function Xy({capped:e,to:t,sourceId:n,at:r}){return(0,X.jsx)(Q,{icon:Jo,sourceId:n,marker:`limit-model-switch`,ariaLabel:`${e} limit — switched to ${t}`,at:r,children:(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[e,(0,X.jsx)(`span`,{className:wy,children:` limit — switched to `}),(0,X.jsx)(`span`,{className:Ty,children:` → `}),t]})})}function Zy({wake:e,sourceId:t,at:n}){let r=e.label.length>64?`${e.label.slice(0,63)}…`:e.label;return(0,X.jsx)(Q,{icon:oc,sourceId:t,marker:`event`,ariaLabel:`Background task «${r}» ${e.outcome}`,at:n,children:(0,X.jsx)(Oy,{lead:`Background task`,title:r,tail:e.outcome})})}function Qy({wake:e,sourceId:t,at:n}){let r=Ja(e.ref),i=r?(0,X.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:Py,children:(0,X.jsx)(Wy,{value:e.ref})}):(0,X.jsx)(`span`,{children:(0,X.jsx)(Wy,{value:e.ref})}),a=e.kind===`ci`?e.verdict===`passing`?`passed`:e.verdict===`failing`?`failed`:`awaiting approval`:``,o=e.kind===`ci`?`CI ${a}`:`PR ${e.kind}`,s=e.kind===`ci`?e.verdict===`failing`&&e.failing.length?`: ${e.failing.join(`, `)}`:e.verdict===`gated`&&e.gating.length?`: ${e.gating.join(`, `)}`:``:``,c=e.kind===`ci`&&e.verdict!==`gated`&&e.commit?` at ${e.commit}`:``,l=e.kind===`ci`?e.verdict===`passing`&&e.passed!==void 0?`${e.passed} ${e.passed===1?`check`:`checks`} green${e.skipped?`, ${e.skipped} skipped`:``}`:e.verdict===`gated`?`${e.gated} ${e.gated===1?`workflow`:`workflows`} held`:null:null;return(0,X.jsxs)(Q,{icon:pn,sourceId:t,marker:`github`,at:n,ariaLabel:r?void 0:`${o} on ${e.ref}${c}${s}${l?` · ${l}`:``}`,children:[(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[o,(0,X.jsx)(Uy,{}),` `,i,c,s]}),l&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50 @max-[34rem]/wake:hidden`,children:`·`}),(0,X.jsx)(`span`,{className:`shrink-0 tabular-nums @max-[34rem]/wake:hidden`,children:l})]})]})}function $y({wake:e,sourceId:t,at:n}){let r=Ja(e.ref),i=r?(0,X.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:Py,children:(0,X.jsx)(Wy,{value:e.ref})}):(0,X.jsx)(`span`,{children:(0,X.jsx)(Wy,{value:e.ref})});return(0,X.jsx)(Q,{icon:pn,sourceId:t,marker:`github`,at:n,ariaLabel:r?void 0:`PR updated on ${e.ref}: ${e.detail}`,children:(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`PR updated`,(0,X.jsx)(Uy,{}),` `,i,`: ${e.detail}`]})})}function eb({steer:e,text:t,sourceId:n,at:r}){let i=Ja(e.ref),a=e.items.length+e.omitted,o=yr(t),s=!o&&e.items.length===1&&e.omitted===0?e.items[0]:null,c=s?.url??i,l=o?`${a} ${a===1?`item`:`items`} already`:Ny(a,e.items[0]?.label??`item`,s?.actor),u=!o&&s?.actor&&l.endsWith(` from @${s.actor}`)?` from @${s.actor}`:``,d=!o&&l.startsWith(`New `)?`New `:``,f=c?(0,X.jsx)(`a`,{href:c,target:`_blank`,rel:`noreferrer noopener`,className:Py,children:(0,X.jsx)(Wy,{value:e.ref})}):(0,X.jsx)(`span`,{children:(0,X.jsx)(Wy,{value:e.ref})});return(0,X.jsx)(Q,{icon:pn,sourceId:n,marker:`github`,at:s?.at??r,ariaLabel:c?void 0:`${l} on ${e.ref}`,children:(0,X.jsx)(Hy,{sentence:(0,X.jsxs)(X.Fragment,{children:[d&&(0,X.jsx)(`span`,{className:`@max-[34rem]/wake:hidden`,children:d}),l.slice(d.length,l.length-u.length),u&&(0,X.jsx)(`span`,{className:`@max-[34rem]/wake:hidden`,children:u})]}),children:f})})}var tb=/(^|[^\w/.@-])(https?:\/\/[^\s<>`]+|www\.[a-z0-9-]+(?:\.[a-z0-9-]+)+(?:[^\s<>`]*)?)/gi,nb=new Set([`.`,`,`,`:`,`;`,`!`,`?`,`*`,`_`,`~`,`'`,`"`]),rb={")":`(`,"]":`[`,"}":`{`};function ib(e){let t=e;for(;;){let e=t[t.length-1];if(e!==void 0&&nb.has(e)){t=t.slice(0,-1);continue}let n=e===void 0?void 0:rb[e];if(n){let r=0;for(let i of t)i===n?r++:i===e&&r--;if(r<0){t=t.slice(0,-1);continue}}break}return t}function ab(e,t,n){if(t===``)return;let r=0;for(let i of ra(t,n))i.start>r&&e.push({kind:`text`,text:t.slice(r,i.start)}),e.push({kind:`link`,text:i.text,href:i.href,title:i.title,ghRef:re(i.href)}),r=i.start+i.text.length;r<t.length&&e.push({kind:`text`,text:t.slice(r)})}function ob(e,t){let n=[],r=0;tb.lastIndex=0;for(let i=tb.exec(e);i;i=tb.exec(e)){let[,a,o]=i,s=ib(o);if(/^https?:\/\/$/i.test(s)||s===``)continue;let c=i.index+a.length;tb.lastIndex=c+s.length;let l=/^www\./i.test(s)?`http://${s}`:s;c>r&&ab(n,e.slice(r,c),t),n.push({kind:`link`,text:s,href:l,ghRef:re(l)}),r=c+s.length}return r<e.length&&ab(n,e.slice(r),t),n}function sb({text:e}){let t=kf(),n=(0,q.useMemo)(()=>ob(e,t),[e,t]),r=(0,q.useMemo)(()=>n.flatMap(e=>e.kind===`link`&&e.ghRef?[e.ghRef]:[]),[n]);return(0,q.useEffect)(()=>{r.length>0&&cn(r)},[r]),(0,X.jsx)(X.Fragment,{children:n.map((e,t)=>e.kind===`text`?e.text:(0,X.jsx)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,title:e.title,"data-gh-ref":e.ghRef??void 0,className:`underline underline-offset-2`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:e.text},t))})}function cb({answers:e,queued:t,sourceId:n}){return(0,X.jsx)(`div`,{"data-frizz-msg":n,"data-answers-card":!0,className:`self-end flex w-full max-w-[85%] flex-col items-end ${t?`opacity-50`:``}`,children:(0,X.jsxs)(`div`,{className:`w-full min-w-0 ${Bp} rounded-br-sm border border-border-strong bg-elevated p-4`,children:[(0,X.jsx)(Kp,{icon:Ws,label:`Answers`}),(0,X.jsx)(Qp,{children:(0,X.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:Pg(e).map((e,t)=>(0,X.jsxs)(`div`,{"data-answer-id":e.handle,className:e.followUp?`ml-3 flex flex-col gap-1 border-l border-border pl-3`:`flex flex-col gap-1`,children:[e.question&&(0,X.jsx)(`div`,{title:e.question,className:`line-clamp-2 min-w-0 [overflow-wrap:anywhere] text-[11px] leading-snug text-muted`,children:e.question}),(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[!e.question&&(0,X.jsx)(`span`,{className:`mt-1.5 shrink-0 text-[10px] uppercase tabular-nums tracking-wide text-muted-70`,children:e.n}),(0,X.jsx)(ub,{answer:e.answer})]})]},t))})})]})})}var lb=`min-w-0 [overflow-wrap:anywhere] rounded-md border border-border-strong border-l-2 border-l-accent/40 bg-bg/50 px-2.5 py-1.5 text-[12px] leading-snug text-fg`;function ub({answer:e}){let{picks:t,note:n}=Fg(e);return t.length===0?(0,X.jsx)(`span`,{className:`${lb} flex-1 whitespace-pre-wrap`,children:(0,X.jsx)(sb,{text:e})}):(0,X.jsxs)(`div`,{className:`${lb} flex flex-1 flex-col`,children:[(0,X.jsx)(`ul`,{className:`flex flex-col gap-1`,children:t.map((e,t)=>(0,X.jsxs)(`li`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`mt-px flex h-3.5 w-3.5 shrink-0 self-start items-center justify-center rounded-[3px] border border-control-strong text-fg`,children:(0,X.jsx)(v,{size:10,strokeWidth:3})}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,X.jsx)(sb,{text:e})})]},t))}),n&&(0,X.jsx)(`div`,{className:`mt-1.5 whitespace-pre-wrap border-t border-border pt-1.5`,children:(0,X.jsx)(sb,{text:n})})]})}var db=(0,q.createContext)(null),fb=(0,q.createContext)(null),pb=(0,q.createContext)(null);function mb(e){for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`&&e[t].kind!==`event`)return t;return-1}function hb(e){return e.sourceId??`legacy-${wb(e.text)}`}function gb(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.kind===`event`||n.kind===`reasoning`)&&n.role===`assistant`&&n.text.trim())return t}return-1}var _b=e=>zh(e).filter(e=>e.kind===`question`).map(e=>e.kind===`question`?ig(e.text,e.questionKind,e.danger):ig(``,`question`));function vb(){let e=new Set;return(t,n)=>{let r=hb(t);return e.has(r)&&(r=`${r}#${n}`),e.add(r),r}}function yb(e){let t=gb(e),n=vb(),r=[];for(let i=0;i<e.length;i++){let a=e[i];if(a.kind===`event`||a.kind===`reasoning`||a.role!==`assistant`||!a.text.trim()||!a.text.includes("```question"))continue;let o=_b(a.text);o.length>0&&r.push({idx:i,identity:n(a,i),blocks:o,isLive:i===t})}return r}function bb(e){let{answered:t,live:n}=e;return t.length>0&&t.every(e=>e.isLive)&&n?`Answers:\n${n.numbered.map(({n:e,a:t})=>`${e}. ${Pi(t)}`).join(`
|
|
122
|
-
`)}`:`${$a}\n${t.map((e,t)=>`${t+1}. “${e.question}” → ${Pi(e.answer)}`).join(`
|
|
123
|
-
`)}`}function xb(e,t,n,r={}){let i=Di(e),[a,o]=(0,q.useState)({}),s=(0,q.useMemo)(()=>yb(t),[t]),c=(0,q.useMemo)(()=>{for(let e=t.length-1;e>=0;e--)if(!(t[e].kind===`event`||t[e].kind===`reasoning`)&&t[e].role===`assistant`&&t[e].text.trim())return t[e]},[t]),l=Nr(),u=is(e),d=(0,q.useCallback)((t,n)=>U.answer(l,e,u,t,n),[l,e,u]),f=(0,q.useMemo)(()=>s.flatMap(e=>e.blocks.map((t,n)=>d(e.identity,n))),[s,d]),p=fs(f),m=(0,q.useRef)(n);m.current=n;let h=(0,q.useRef)(r.onSendFailed);h.current=r.onSendFailed;let g=(0,q.useCallback)((e,t)=>({...a[`${e}::${t}`]??{chosen:null,text:``},text:p.get(d(e,t))??``}),[a,p,d]),_=(0,q.useMemo)(()=>{let e=new Map;for(let t of s)e.set(t.identity,t);return e},[s]),v=(0,q.useCallback)((e,t,n)=>{let r=_.get(e)?.blocks[t],i=`${e}::${t}`;o(e=>{let t=e[i]??{chosen:null,text:``};if(r?.kind===`multi`){let r=new Set(t.chosenSet??[]);return r.has(n)?r.delete(n):r.add(n),{...e,[i]:{chosen:null,text:t.text,chosenSet:[...r].sort((e,t)=>e-t)}}}return{...e,[i]:{chosen:t.chosen===n?null:n,text:t.text}}})},[_]),y=(0,q.useCallback)((e,t,n)=>{let r=_.get(e)?.blocks[t];Ci.set(d(e,t),n),o(i=>{let a=`${e}::${t}`,o=i[a]??{chosen:null,text:``};return r?.kind===`multi`?{...i,[a]:{chosen:null,text:n,chosenSet:o.chosenSet??[]}}:{...i,[a]:{chosen:null,text:n}}})},[_,d]),b=s.reduce((e,t)=>e+t.blocks.filter((e,n)=>ug(e,g(t.identity,n))!==``).length,0),x=b>0,S=(0,q.useCallback)((e,t={})=>{i.submit(e,{...t,onRollback:e=>{t.onRollback?.(e),h.current?.()}})&&m.current?.()},[i]),C=(0,q.useCallback)(e=>{let t=e?s.filter(t=>t.identity===e):s,n=e?t.flatMap(e=>e.blocks.map((t,n)=>d(e.identity,n))):f,r=t.flatMap(e=>e.blocks.map((t,n)=>`${e.identity}::${n}`)),i=(e,t)=>ug(e.blocks[t],g(e.identity,t)),c=t.flatMap(e=>e.blocks.map((t,n)=>({ask:e,bi:n,question:Cb(t),answer:i(e,n)})).filter(e=>e.answer!==``));if(c.length===0)return null;let l=t.find(e=>e.isLive),u=bb({answered:c.map(e=>({isLive:e.ask.isLive,question:e.question,answer:e.answer})),live:l&&{numbered:l.blocks.map((e,t)=>({n:t+1,a:i(l,t)})).filter(({a:e})=>e!==``)}}),p=a,m=n.map(e=>[e,Ci.get(e)]);return{wire:u,onOptimistic:()=>{n.forEach(e=>Ci.clear(e)),o(e=>{let t={...e};for(let e of r)delete t[e];return t})},onRollback:()=>{o(e=>{let t={...e};for(let e of r)p[e]?t[e]=p[e]:delete t[e];return t}),m.forEach(([e,t])=>{t&&!Ci.get(e)&&Ci.set(e,t)})}}},[a,s,g,f,d]),w=(0,q.useCallback)(()=>C(),[C]),T=r.composer,E=(0,q.useCallback)(e=>{if(T?.run())return;let t=C(typeof e==`string`?e:void 0);t&&S(t.wire,{onOptimistic:t.onOptimistic,onRollback:t.onRollback})},[T,C,S]),D=(0,q.useCallback)(e=>{let t=_.get(hb(e));if(t)return{answerFor:e=>g(t.identity,e),onChip:(e,n)=>v(t.identity,e,n),onText:(e,n)=>y(t.identity,e,n),onSubmit:()=>E(t.identity),anyAnswered:t.blocks.some((e,n)=>ug(e,g(t.identity,n))!==``),sending:i.pending}},[_,g,v,y,E,i.pending]);return{liveMsg:c,answering:(0,q.useMemo)(()=>c?D(c):void 0,[c,D]),answeringForMessage:D,anyAnswered:x,sending:i.pending,sendAnswers:E,sendMessage:S,stagedCount:b,takeAnswers:w}}function Sb(e){let t=e.split(`
|
|
124
|
-
`).map(e=>e.trim()).find(e=>e.length>0)??``;return t.length>120?`${t.slice(0,117)}…`:t}function Cb(e){return Sb(e.contextMd)||Sb(e.options.join(` / `))||`earlier question`}function wb(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return(t>>>0).toString(36)}function Tb(e){let t=new Set,n=new Set;for(let r of e)for(let e of r.tools)e.agentId&&(t.add(e.agentId),e.agentStatus&&n.add(e.agentId));return{launched:t,finished:n}}function Eb(e,t,n){if(n.length===0)return{agents:e,key:void 0};let{launched:r,finished:i}=Tb(n),a=new Set(t.flatMap(e=>e.id?[e.id]:[])),o=new Set(e.flatMap(e=>e.id?[e.id]:[])),s=e.filter(e=>e.id&&!a.has(e.id)&&!r.has(e.id)),c=t.filter(e=>e.id&&!o.has(e.id)&&r.has(e.id)&&!i.has(e.id));if(s.length===0&&c.length===0)return{agents:e,key:void 0};let l=[...s.map(e=>`+${e.id}`),...c.map(e=>`-${e.id}`)].join(` `);return{agents:[...e.filter(e=>!s.includes(e)),...c],key:l}}function Db(e,t){let n=(0,q.useRef)(void 0),[r,i]=(0,q.useState)(void 0),a=e?.subAgents??[],o=n.current===void 0?{agents:a,key:void 0}:Eb(a,n.current,t),s=o.key;(0,q.useEffect)(()=>{if(s===void 0)return;let e=setTimeout(()=>i(s),go);return()=>clearTimeout(e)},[s]);let c=s!==void 0&&r!==s?o.agents:a;return(0,q.useEffect)(()=>{n.current=c},[c]),!e||c===a?e:{...e,subAgents:[...c]}}function Ob(e,t,n){return e===t||n(e,t)?e:t}function kb(e,t){let n=(0,q.useRef)(e);return n.current=t(n.current,e),n.current}function Ab(e,t){return kb(e,(e,n)=>Ob(e,n,t))}function jb(e,t,n){if(e===t)return e;let r=e.size!==t.size,i=new Map;for(let[a,o]of t){let t=e.get(a),s=e.has(a)&&n(t,o);s||(r=!0),i.set(a,s?t:o)}return r?i:e}function Mb(e,t){return jb(e,t,Pb)}function Nb(e,t){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(t.get(n),r))return!1;return!0}function Pb(e,t){return!e||!t?e===t:e.length===t.length&&e.every((e,n)=>Object.is(e,t[n]))}function Fb(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!fo(n))return n.kind===`event`&&n.boundary===`rest`?n.sourceId??`rest@${n.at??t}`:void 0}}function Ib(e,t,n){if(!e||e.runtime!==`running`&&e.runtime!==`spawning`)return;let r=Fb(t);return r!==void 0&&r!==n?r:void 0}function Lb(e,t){let n=(0,q.useRef)(null),[r,i]=(0,q.useState)(void 0),a=n.current&&n.current.messages.length>0?Ib(e,t,n.current.restKey):void 0;(0,q.useEffect)(()=>{if(a===void 0)return;let e=setTimeout(()=>i(a),400);return()=>clearTimeout(e)},[a]);let o=a!==void 0&&r!==a?n.current.messages:t;return(0,q.useEffect)(()=>{n.current?.messages!==o&&(n.current={messages:o,restKey:Fb(o)})},[o]),o}function Rb(e,t,n=!0){return e.held>0&&n?`release`:e.steered>0&&t?`interrupt`:null}function zb(e){if(!e)return!1;let t=Qr(W.board,e);return yo(t?.backend).interrupt&&t?.runtime===`running`}function Bb(e){return yo(e?Qr(W.board,e)?.backend:void 0).steer}function Vb(e){return(0,q.useSyncExternalStore)(e=>Mo(W,e),()=>Bb(e),()=>!0)}function Hb(e){return(0,q.useSyncExternalStore)(e=>Mo(W,e),()=>zb(e),()=>!1)}var Ub=new Set,Wb=new Set;function Gb(e,t){if(t!==Ub.has(e)){t?Ub.add(e):Ub.delete(e);for(let e of Wb)e()}}function Kb(e){return(0,q.useSyncExternalStore)((0,q.useCallback)(e=>(Wb.add(e),()=>Wb.delete(e)),[]),()=>e?Ub.has(e):!1,()=>!1)}function qb(e,t){let n=Rb(t,zb(e),Bb(e));if(!n)return!1;if(Ub.has(e))return!0;let r=Qr(W.board,e)?.sessionId;if(!r)return K(`This thread has no live session to send to`),!0;Gb(e,!0);let i=n===`release`;return k.deliverQueuedNow({slug:e,sessionId:r,...i?{releaseOnly:!0}:{}}).then(t=>{Gb(e,!1),i?t.released||K(t.reason??`That message could not be sent now`):!t.interrupted&&!t.released&&K(t.reason??`That message could not be pushed through`)},t=>{Gb(e,!1);let n=(t instanceof Error?t.message:String(t)).slice(0,160);K(i?`Couldn't send it now — ${n}`:`Couldn't push it through — ${n}`)}),!0}var Jb=`input, textarea, select, [contenteditable]:not([contenteditable='false'])`;function Yb(e,t){if(e.defaultPrevented||e.repeat||!Hi(e))return!1;let n=e.target;if(!(n instanceof Element)||!t.contains(n))return!1;let r=n.closest(Jb);return r?r instanceof HTMLTextAreaElement&&r.closest(`[data-thread-composer-box]`)!==null&&r.value.trim()===``:!0}var Xb=new Set;function Zb(e){if(e.defaultPrevented||e.repeat||!Hi(e))return;let t=document.activeElement;if(t&&t!==document.body&&t!==document.documentElement)return;let n=[...Xb],r=hi();(r?n.find(e=>e.slug===r):new Set(n.map(e=>e.slug)).size===1?n[0]:void 0)?.press()&&e.preventDefault()}function Qb(e,t){let n=(0,q.useRef)(t);return n.current=t,(0,q.useEffect)(()=>{let t={slug:e,press:()=>qb(e,n.current)};return Xb.size===0&&window.addEventListener(`keydown`,Zb),Xb.add(t),()=>{Xb.delete(t),Xb.size===0&&window.removeEventListener(`keydown`,Zb)}},[e]),(0,q.useCallback)(t=>{Yb(t.nativeEvent,t.currentTarget)&&qb(e,n.current)&&t.preventDefault()},[e])}function $b(e,t){for(let n=0;n<e.length;n++){let r=e[n].at?Date.parse(e[n].at):NaN;if(Number.isFinite(r)&&r>t)return n}return e.length}function ex(e,t){let n=t;for(;n>0&&e[n].kind===`event`;)n--;return n}function tx(e){let t=e.findIndex(e=>e.queued===!0);return t<0?e.length:t}function nx(e,t){let n=new Map,r=new Map;if(t.length===0||e.length===0)return{placed:n,anchored:r};let i=new Map;for(let e of t){let t=e.pending?`pending`:e.settledAt,n=i.get(t);n?n.push(e):i.set(t,[e])}let a=(e,t,n)=>{let r=e.get(t);r?r.push(...n):e.set(t,[...n])};for(let[t,o]of i){let i=t===`pending`?1/0:Date.parse(t),s=Number.isFinite(i)?$b(e,i):tx(e);if(s===0)continue;let c=e.slice(0,s),l=h_(c,o);for(let[e,t]of l.placed)a(n,e,t);let u=o.filter(e=>!l.placedIds.has(e.id));for(let[e,t]of t_(c,u))e<0||a(r,ex(c,e),t)}let o=(e,t)=>Date.parse(e.askedAt)-Date.parse(t.askedAt);for(let e of n.values())e.sort(o);for(let e of r.values())e.sort(o);return{placed:n,anchored:r}}var rx=e=>e.role===`user`&&!e.queued,ix=e=>e.wake===!0&&e.text.trimStart().startsWith(`**This message is from frizz, not from the human.**`);function ax(e,t){let n=e.length-1;for(;n>t&&e[n].signOff!==!0;)n--;if(n<=t)return[];let r=[n];for(;;){let i=n-1;for(;i>t&&!rx(e[i]);)i--;if(i<=t||!ix(e[i]))break;let a=i-1;for(;a>t&&e[a].signOff!==!0&&!rx(e[a]);)a--;if(a<=t||e[a].signOff!==!0)break;r.push(a),n=a}return r.reverse()}function ox(e){return e.status===`pending`&&e.backgroundState===`background`}function sx(e){let t=[];for(let n of e)for(let e of n.tools)ox(e)&&n.at&&t.push({label:e.desc??e.detail??e.command??`Background command`,startedAt:n.at,state:`running`,...e.shellId?{launchId:e.shellId}:{},...e.command?{command:e.command}:{}});return t}function cx(e){return e.map(e=>{if(!e.tools.some(ox))return e;let t=e.tools.filter(e=>!ox(e)),n=e.parts?.map(e=>e.kind===`tools`?{...e,tools:e.tools.filter(e=>!ox(e))}:e).filter(e=>e.kind!==`tools`||e.tools.length>0);return{...e,tools:t,parts:n}})}var lx=2e3;function ux(e,t){if(!e.spec.handle)return!1;let n=Date.parse(e.askedAt);if(!Number.isFinite(n))return!1;let r;for(let i=t.length-1;i>=0;i--){let a=t[i],o=a.at?Date.parse(a.at):NaN;if(Number.isFinite(o)&&o>=n)return!1;if(a.role===`assistant`&&a.text&&Ri(a.text)){r??=u_(e);for(let e of ri(a.text))if(e.read.form!==`invalid`&&r.includes(e.read.id.toLowerCase()))return!1}if(Number.isFinite(o))break}return!0}function dx(e,t,n,r){let i,a=new Set;for(let o of e){if(!ux(o,t)){n.delete(o.id);continue}let e=n.get(o.id)??r;n.set(o.id,e);let s=e+lx;r>=s||(a.add(o.id),i=i===void 0?s:Math.min(i,s))}if(n.size>a.size){let t=new Set(e.map(e=>e.id));for(let e of n.keys())t.has(e)||n.delete(e)}return a.size===0?{shown:e}:{shown:e.filter(e=>!a.has(e.id)),wakeAt:i}}function fx(e,t){let n=-1;if(!Number.isFinite(t))return n;for(let r=0;r<e.length;r++){let i=e[r];if(i.kind===`event`||i.kind===`reasoning`)continue;let a=i.at?Date.parse(i.at):NaN;Number.isFinite(a)&&a<=t&&(n=r)}return n}function px(e,t,n=[]){let r=new Map;if(!t?.length||e.length===0)return r;let i=new Map,a=t=>{let n=i.get(t);if(!n){n=new Set;let r=e[t].text;if(e[t].role===`assistant`&&r&&Ri(r))for(let e of ri(r))e.read.form!==`invalid`&&n.add(e.read.id.toLowerCase());i.set(t,n)}return n};for(let i of t){if(!i.id)continue;let t=i.id.toLowerCase(),o=fx(e,Date.parse(i.at));if(o<0||!a(o).has(t)||n.some(n=>u_(n).includes(t)&&fx(e,Date.parse(n.askedAt))===o))continue;let s=r.get(o);s||r.set(o,s=new Map),s.set(t,[...s.get(t)??[],...i.faults])}return r}var mx=new WeakMap;function hx(e,t,n=[]){let r=px(e,t,n);return r.size===0?e:e.map((e,t)=>{let n=r.get(t);if(!n)return e;let i=[...n].map(([e,t])=>`${e}\u0000${t.join(`\0`)}`).sort().join(`
|
|
125
|
-
`),a=mx.get(e);if(a?.key===i)return a.message;let o={...e,refusedFences:new Set(n.keys()),refusedReasons:n};return mx.set(e,{key:i,message:o}),o})}function gx(e){return e?.length?e.map(e=>`${e.at}|${e.id??``}|${e.faults.join(`\0`)}`).join(`
|
|
126
|
-
`):``}function _x(e){let t=e?.find(e=>e.trim());if(!t)return;let n=t.indexOf(` — `);return n!==-1&&/^`[^`]*`$/.test(t.slice(0,n).trim())&&(n=t.indexOf(` — `,n+3)),(n===-1?t:t.slice(0,n)).trim().replace(/[.;:]+$/,``)}function vx(e,t){let n=new Map;if(t.length<2||e.length===0)return n;let r=new Map,i=new Set;for(let e of t)if(!i.has(e.id)){i.add(e.id);for(let t of u_(e)){let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[...r].filter(([,e])=>e.length>1);if(a.length===0)return n;let o=a.map(([t,n])=>({name:t,rows:n.map(t=>({id:t.id,askedMs:Date.parse(t.askedAt),at:fx(e,Date.parse(t.askedAt))})).sort((e,t)=>e.askedMs-t.askedMs)}));return e.forEach((e,t)=>{if(e.role!==`assistant`||!e.text||!(Ri(e.text)||e.text.includes("```awaiting")))return;let r=e.text.toLowerCase();for(let{name:e,rows:i}of o){if(!r.includes(e))continue;let a;for(let e of i)e.at<=t&&(a=e.id);if(a===void 0)continue;let o=n.get(t);o||n.set(t,o=new Map),o.set(e,a)}}),n}var yx=new WeakMap;function bx(e,t){let n=vx(e,t);return n.size===0?e:e.map((e,t)=>{let r=n.get(t);if(!r)return e;let i=[...r].map(([e,t])=>`${e}\u0000${t}`).sort().join(`
|
|
127
|
-
`),a=yx.get(e);if(a?.key===i)return a.message;let o={...e,questionOwners:r};return yx.set(e,{key:i,message:o}),o})}function xx(e,t){let n=t.description?.trim(),r=n&&!n.includes(`
|
|
128
|
-
`)?n:void 0,i=[r?void 0:n,t.preview?.trim()].filter(Boolean).join(`
|
|
129
|
-
|
|
130
|
-
`)||void 0;return{line:`${sg(e)} ${t.label}${r?` — ${r}`:``}`,...i?{body:i}:{}}}var Sx=`root`;function Cx(e,t,n){return`${e}/${t}.${n}`}function wx(e){let t=e.options??[],n=t.map((e,t)=>xx(t,e));return{question:{kind:e.kind,danger:e.danger===!0,...e.secret?{secret:!0}:{},contextMd:e.question,...e.context?.trim()?{detailMd:e.context.trim()}:{},options:n.map(e=>e.line),recommendedIdxs:t.flatMap((e,t)=>e.recommended?[t]:[]),...n.some(e=>e.body)?{optionBodies:n.map(e=>e.body)}:{}},optionLabels:t.map(e=>e.label)}}function Tx(e){return e.secret||e.danger||!e.options?.length?!0:e.options.some(e=>e.followUps?.some(Tx))}function Ex(e,t){return!t||e.kind===`multi`?null:t.chosen}function Dx(e,t){let n=[],r=(e,i,a)=>{let{question:o,optionLabels:s}=wx(e);n.push({path:i,spec:e,question:o,optionLabels:s,depth:a});let c=Ex(e,t.get(i));c!==null&&(e.options?.[c]?.followUps??[]).forEach((e,t)=>r(e,Cx(i,c,t),a+1))};return r(e,Sx,1),n}function Ox(e,t){return t?t.text.trim()?!0:e.kind===`multi`?(t.chosenSet??[]).length>0:t.chosen!==null:!1}function kx(e,t){if(!Ox(e.spec,t.get(`root`)))return;let n=(r,i)=>{let a=t.get(i),o=(r.options??[]).map(e=>e.label),s=Ex(r,a),c=r.kind===`multi`?(a?.chosenSet??[]).slice().sort((e,t)=>e-t).flatMap(e=>o[e]===void 0?[]:[o[e]]):s===null?[]:[o[s]].filter(e=>e!==void 0),l=r.kind===`multi`||s===null?a?.text.trim():void 0,u=s===null?[]:(r.options?.[s]?.followUps??[]).map((e,t)=>n(e,Cx(i,s,t)));return{questionId:e.id,question:r.question,chosen:c,...l?{text:l}:{},...u.length>0?{followUps:u}:{}}};return n(e.spec,Sx)}function Ax(e,t){let n=[],r=(e,t,i,a)=>{let o=e.options??[],{question:s}=wx(e),c=[],l=[];for(let e of t.chosen){let t=o.findIndex(t=>t.label===e);t===-1?l.push(e):c.includes(t)||c.push(t)}c.sort((e,t)=>e-t);let u=[l.join(`, `),t.text?.trim()].filter(Boolean).join(` — `)||void 0;if(n.push({path:i,question:{...s,options:c.map(e=>s.options[e]),recommendedIdxs:c.flatMap((e,t)=>s.recommendedIdxs.includes(e)?[t]:[]),...s.optionBodies?{optionBodies:c.map(e=>s.optionBodies[e])}:{}},settled:{chosenIdxs:c.map((e,t)=>t),...u?{text:u}:{}},depth:a}),e.kind===`multi`||c.length!==1)return;let d=c[0];(o[d]?.followUps??[]).forEach((e,n)=>{let o=t.followUps?.[n];o&&r(e,o,Cx(i,d,n),a+1)})};return r(e,t,Sx,1),n}function jx(e,t){let n=e.options??[];if(t.chosen===null&&t.chosenSet.length===0)return``;let r=e=>n[e]?{index:e,label:n[e].label}:null;return JSON.stringify({chosen:t.chosen===null?null:r(t.chosen),chosenSet:t.chosenSet.flatMap(e=>{let t=r(e);return t?[t]:[]})})}function Mx(e,t){let n={chosen:null,chosenSet:[]};if(!t)return n;try{let r=JSON.parse(t);if(!r||typeof r!=`object`)return n;let{chosen:i,chosenSet:a}=r;if(!Array.isArray(a))return n;let o=e.options??[],s=e=>{if(!e||typeof e!=`object`)return null;let{index:t,label:n}=e;return typeof t==`number`&&Number.isInteger(t)&&t>=0&&typeof n==`string`&&o[t]?.label===n?t:null},c=new Set(a.map(s).filter(e=>e!==null));return e.kind===`multi`?{chosen:null,chosenSet:o.flatMap((e,t)=>c.has(t)?[t]:[])}:{chosen:s(i),chosenSet:[]}}catch{return n}}function Nx(e,t){let[n,...r]=t.split(`/`);if(n!==`root`)return;let i=e;for(let e of r){if(!/^\d+\.\d+$/.test(e))return;let[t,n]=e.split(`.`).map(Number);i=i?.options?.[t]?.followUps?.[n]}return i}function Px({className:e}){return(0,X.jsxs)(`div`,{className:`flex items-baseline gap-[0.3em] ${e}`,children:[(0,X.jsx)(Ks,{"aria-hidden":!0,strokeWidth:2.25,className:`size-[0.9em] shrink-0 self-baseline translate-y-[calc(0.45em_-_0.5cap)]`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 text-pretty`,children:`Value stored only in memory. It will not show up in transcripts.`})]})}function Fx({raw:e,question:t,questionKind:n,danger:r,interactive:i,aside:a,label:o,settled:s,pending:c}){let l=(0,q.useMemo)(()=>t??ig(e??``,n??`question`,r),[t,e,n,r]),u=jf(l.contextMd),d=jf(l.detailMd??``),f=jf(l.trailingMd??``),p=l.recommendedIdxs,m=Nf(l.recommendation??``),h=l.kind===`multi`,g=l.danger,_=i?.answer.chosen??null,v=i?.answer.chosenSet??[],y=i?.answer.text??``,b=(0,q.useRef)(null),x=(0,q.useRef)(null),S=(0,q.useId)();(0,q.useLayoutEffect)(()=>{let e=b.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight+e.offsetHeight-e.clientHeight}px`)},[y]);let C=g?pr:l.secret?Vs:h?Ws:ce,w=o??(l.secret?`Secret`:h?`Select multiple`:`Question`);return(0,X.jsxs)($p,{tone:g?`risk`:`neutral`,surface:`question`,icon:C,kind:w,label:null,aside:a,children:[u&&(0,X.jsx)(`div`,{id:S,className:`text-fg`,children:(0,X.jsx)(Oh,{className:`md-body`,html:u})}),l.detailMd&&(0,X.jsx)(`div`,{"data-question-context":!0,className:u?`mt-[13px]`:void 0,children:(0,X.jsx)(Oh,{className:`md-body`,html:d})}),(l.options.length>0||i||c)&&(0,X.jsxs)(`div`,{ref:x,tabIndex:-1,onKeyDown:e=>{!i||e.target!==e.currentTarget||Dr({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),e.stopPropagation(),i.onSubmit())},"data-question-grid":!0,role:`group`,"aria-labelledby":u?S:void 0,"aria-label":u?void 0:w,className:`mt-2 grid grid-cols-1 gap-1.5 outline-none`,children:[l.options.map((e,t)=>(0,X.jsxs)(q.Fragment,{children:[l.optionHeadings?.[t]&&(0,X.jsx)(Ix,{md:l.optionHeadings[t]}),(0,X.jsx)(Lx,{label:e,index:t,bodyMd:l.optionBodies?.[t],multi:h,recommended:p.includes(t),recTitle:p[0]===t?l.recommendedNote:void 0,selected:h?v.includes(t):_===t,settledPick:s?.chosenIdxs.includes(t)??!1,disabled:!i,onClick:()=>{i?.onChip(t,e),!(h&&b.current&&document.activeElement===b.current)&&x.current?.focus()}})]},t)),i&&!i.optionsOnly&&(0,X.jsxs)(`div`,{className:`relative col-span-full${l.options.length>0?` flex items-baseline`:``}`,children:[l.options.length>0&&(0,X.jsx)(`span`,{className:`pointer-events-none relative ml-[13px] -mr-[29px] flex`,children:(0,X.jsx)(zx,{id:sg(l.options.length).slice(0,-1),live:!0})}),l.secret?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`input`,{type:`password`,"data-secret-answer":!0,"data-surface":`questionAnswer`,"data-claims-escape":!0,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,spellCheck:!1,"aria-label":`Secret value`,value:y,onChange:e=>i.onText(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`){e.preventDefault(),x.current?.focus();return}e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),i.onSubmit())},placeholder:`Paste the value…`,className:`block w-full rounded-md border py-1.5 pl-3 pr-3 text-[12px] leading-snug text-fg/90 outline-none placeholder:text-muted-80 transition-colors ${y.trim()?`border-selection-border bg-selection`:`border-border bg-transparent hover:bg-panel-2 focus:border-accent`}`}),(0,X.jsx)(Px,{className:`mt-2 text-[11px] leading-snug text-muted`})]}):(0,X.jsx)(`textarea`,{ref:b,"data-1p-ignore":!0,rows:1,"data-surface":`questionAnswer`,"data-claims-escape":!0,value:y,onChange:e=>i.onText(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`){e.preventDefault(),x.current?.focus();return}Dr({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),i.onSubmit())},onFocus:()=>{!h&&_!==null&&i.onText(y)},placeholder:h?`Add a note…`:l.options.length?`Something else…`:`Type your answer…`,className:`block w-full min-w-0 flex-1 resize-none overflow-hidden rounded-md border py-1.5 pr-3 ${l.options.length>0?Rx:`pl-3`} text-[12px] leading-snug text-fg/90 outline-none placeholder:text-muted-80 transition-colors ${y.trim()&&(h||_===null)?`border-selection-border bg-selection`:`border-border bg-transparent hover:bg-panel-2 focus:border-accent`}`})]}),!i&&c&&(0,X.jsx)(`div`,{"data-question-pending-text":!0,className:`relative col-span-full`,children:l.secret?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`input`,{type:`password`,disabled:!0,tabIndex:-1,"aria-hidden":!0,placeholder:`Paste the value…`,className:`block w-full rounded-md border border-border bg-transparent py-1.5 pl-3 pr-3 text-[12px] leading-snug text-fg/90 outline-none placeholder:text-muted-80`}),(0,X.jsx)(Px,{className:`mt-2 text-[11px] leading-snug text-muted`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`textarea`,{ref:b,"data-1p-ignore":!0,rows:1,disabled:!0,tabIndex:-1,"aria-hidden":!0,placeholder:l.options.length>0?void 0:`Type your answer…`,className:`block w-full min-w-0 resize-none overflow-hidden rounded-md border border-border bg-transparent px-3 py-1.5 text-[12px] leading-snug outline-none placeholder:text-muted-80`}),l.options.length>0&&(0,X.jsxs)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 flex items-baseline border border-transparent py-1.5 pr-3 text-[12px] leading-snug text-muted-80`,children:[(0,X.jsx)(`span`,{className:`ml-3 mr-2 flex`,children:(0,X.jsx)(zx,{id:sg(l.options.length).slice(0,-1)})}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:h?`Add a note…`:`Something else…`})]})]})})]}),s?.text&&(0,X.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap [overflow-wrap:anywhere] rounded-md border border-border-strong border-l-2 border-l-accent/40 bg-bg/50 py-1.5 pl-[11px] pr-3 text-[12px] leading-snug text-fg`,children:l.secret?`••••••••••••`:s.text}),s&&s.chosenIdxs.length===0&&!s.text&&(0,X.jsx)(`div`,{className:`mt-2 text-[11px] text-muted-70`,children:`Not answered`}),l.trailingMd&&(0,X.jsx)(`div`,{"data-question-note":!0,className:`mt-2 text-muted-70`,children:(0,X.jsx)(Oh,{className:`md-body`,html:f})}),l.recommendation&&p.length===0&&(0,X.jsx)(Oh,{className:`md-inline mt-1.5 text-[11px] text-muted-70`,html:m})]})}function Ix({md:e}){return(0,X.jsx)(`div`,{className:`mt-1 text-fg`,children:(0,X.jsx)(Oh,{className:`md-body`,html:Nf(e.split(`
|
|
131
|
-
`).join(` `))})})}function Lx({label:e,index:t,bodyMd:n,selected:r,settledPick:i,disabled:a,multi:o,recommended:s,recTitle:c,onClick:l}){let u=cg(e),d=u.id??sg(t).slice(0,-1),f=Nf(u.rest),p=jf(n??``),m=(0,q.useId)();return(0,X.jsxs)(`div`,{"data-question-option":!0,title:c,onClick:e=>{a||e.target.closest(`a, button, summary, img[data-local-path], .local-file-action, .local-file-code`)||window.getSelection()?.toString()||l()},className:`relative flex items-baseline gap-2 rounded-md border px-3 py-1.5 text-[12px] leading-snug transition-colors ${r?`border-selection-border bg-selection text-fg`:i?`border-border-strong border-l-2 border-l-accent/40 bg-bg/50 pl-[11px] text-fg`:a?`border-border text-muted-80`:`border-border text-fg/90 hover:bg-elevated`}`,children:[(0,X.jsx)(`button`,{type:`button`,disabled:a,"aria-labelledby":m,"aria-pressed":r||i,onClick:l,onMouseDown:e=>e.preventDefault(),className:`absolute inset-0 rounded-md outline-none`}),(0,X.jsx)(zx,{id:d,live:!a,selected:r}),o&&(0,X.jsx)(`span`,{"aria-hidden":!0,className:`mt-px flex h-3.5 w-3.5 shrink-0 self-start items-center justify-center rounded-[3px] border ${r?`border-accent bg-accent-fill text-on-accent`:i?`border-control-strong text-fg`:`border-control-strong`}`,children:(r||i)&&(0,X.jsx)(v,{size:10,strokeWidth:3})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{id:m,children:[s&&(0,X.jsx)(`span`,{className:`pointer-events-none float-right ml-2 mt-px rounded-full border border-border-strong px-1.5 py-px text-[9.5px] leading-none uppercase tracking-wide text-muted`,children:`Recommended`}),(0,X.jsx)(Oh,{as:`span`,className:`md-inline`,html:f})]}),n!==void 0&&(0,X.jsx)(Oh,{className:`md-body mt-1.5 opacity-90`,html:p})]})]})}var Rx=`pl-9`;function zx({id:e,live:t=!1,selected:n=!1}){return(0,X.jsxs)(`span`,{"aria-hidden":!0,className:`flex w-4 shrink-0 justify-end whitespace-nowrap text-[11px] transition-colors ${n&&t?`text-fg`:`text-muted`}`,children:[e,`.`]})}var Bx=(0,q.createContext)(null);function Vx(){return(0,q.useContext)(Bx)}function Hx({questions:e}){let t=Vx();return e.length===0?null:(0,X.jsx)(`div`,{"data-compact-questions":!0,className:`min-w-0 overflow-hidden rounded-[12px] border border-border-strong bg-panel pb-2.5 text-[14px] leading-5`,children:e.map((e,n)=>(0,X.jsx)(`div`,{"data-question-id":e.id,className:n>0?`mt-2.5 border-t border-border`:void 0,children:(0,X.jsx)(Ux,{q:e,n:t?.numberOf(e.id)??n+1})},e.id))})}function Ux({q:e,n:t}){let n=jf(e.spec.question),r=e.spec.options??[],i=ie();return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex gap-2 px-3.5 pb-1 pt-[11px] font-semibold`,children:[(0,X.jsx)(`span`,{className:`shrink-0 tabular-nums text-accent`,children:t}),(0,X.jsx)(Oh,{className:`min-w-0 flex-1 ${Wx}`,html:n})]}),r.map((e,t)=>(0,X.jsxs)(`div`,{"data-compact-option":!0,className:`flex gap-2 py-0.5 pl-[30px] pr-3.5 text-muted`,children:[(0,X.jsx)(`span`,{className:`w-3 shrink-0 font-bold`,children:sg(t).slice(0,-1)}),(0,X.jsxs)(`span`,{className:`min-w-0`,children:[(0,X.jsx)(Kx,{md:e.label}),e.recommended&&(0,X.jsx)(`span`,{className:`ml-1 text-[11px] font-semibold leading-none text-accent`,children:`RECOMMENDED`})]})]},t)),i&&Tx(e.spec)&&(0,X.jsxs)(Qo,{className:`px-3.5 pt-1 text-[13px] text-muted`,children:[`This question has to be answered on `,i,`.`]})]})}var Wx=`md-inline break-words [&_p+*]:mt-2 [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5 [&_li+li]:mt-1 [&_pre]:[white-space:var(--code-wrap,pre-wrap)] [&_pre]:overflow-x-auto [&_pre]:text-[0.85em] [&_code]:text-[0.9em] [&_a]:underline`;function Gx({count:e,onAnswer:t,onReply:n}){return(0,X.jsxs)(X.Fragment,{children:[n&&(0,X.jsx)(`button`,{type:`button`,"data-phone-answer-reply":!0,onClick:n,"aria-label":`Write a reply instead`,title:`Write a reply instead`,className:`flex size-[42px] shrink-0 items-center justify-center rounded-full border border-border-strong bg-panel text-fg active:bg-hover`,children:(0,X.jsx)(Hs,{"aria-hidden":!0,size:19,strokeWidth:1.8})}),(0,X.jsx)(`button`,{type:`button`,"data-phone-answer-open":!0,onClick:t,className:`flex h-[42px] min-w-0 flex-1 items-center justify-center rounded-full bg-fg px-4 text-[15px] font-semibold text-bg active:opacity-90`,children:e>1?`Answer ${e} questions`:`Answer`})]})}function Kx({md:e}){return(0,X.jsx)(Oh,{as:`span`,className:`md-inline`,html:Nf(e)})}function qx(e){let t=e instanceof Error?e.message:`The answer could not be sent.`;return t.length>240?`${t.slice(0,239)}…`:t}var Jx=(0,q.createContext)(null);function Yx(e){let t=e?.id,n=e?.questions??[],r=Nr(),i=ie(),[a,o]=(0,q.useState)(()=>new Map),[s,c]=(0,q.useState)(),l=(0,q.useContext)(fb),u=(0,q.useContext)(G_),d=fs((0,q.useMemo)(()=>t?n.flatMap(e=>e.spec.secret?[]:wS(e).flatMap(n=>[U.question(r,t,e.id,n),U.questionPick(r,t,e.id,n)])):[],[r,t,n])),f=(e,n)=>{if(e.spec.secret)return{chosen:null,chosenSet:[],text:a.get(e.id)??``};let i=Nx(e.spec,n),o=i?Mx(i,t?d.get(U.questionPick(r,t,e.id,n))??``:``):void 0;return{chosen:o?.chosen??null,chosenSet:o?.chosenSet??[],text:(t?d.get(U.question(r,t,e.id,n)):void 0)??``}},p=e=>new Map(wS(e).map(t=>[t,f(e,t)])),m=n.flatMap(e=>{let t=kx(e,p(e));return t?[{q:e,answer:t}]:[]}),h=m.map(e=>e.answer),g=G(),_=Yr({mutationFn:async e=>k.answerQuestions({slug:t,answers:e.answers}),onSuccess:(e,t)=>{for(let n of e.answered){o(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t});for(let e of t.drafts.find(e=>e.id===n)?.keys??[])Ci.clear(e)}},onError:e=>{l?.cancel(),t&&Vr(t),c(qx(e))},onSettled:()=>{t&&g.invalidateQueries({queryKey:Zx(t)})}}),v=Yr({mutationFn:async e=>k.dismissQuestions({slug:t,ids:[e]}),onError:e=>c(qx(e))}),y=e=>e.map(({q:e,answer:t})=>e.spec.secret?{...t,text:`(secret sent)`}:t),b=(e,t)=>{let n=Zx(e);g.cancelQueries({queryKey:n});let r=new Date().toISOString(),i=new Set(t.map(e=>e.q.id));ua(e,[...i]);let a=y(t);g.setQueryData(n,e=>({closed:e?.closed??[],questions:[...(e?.questions??[]).filter(e=>!i.has(e.id)),...t.map(({q:e},t)=>({id:e.id,spec:e.spec,askedAt:e.askedAt,settledAt:r,pending:!0,answer:a[t]}))]}))},x=(e,t)=>t.map(({q:t})=>({id:t.id,keys:t.spec.secret?[]:wS(t).flatMap(n=>[U.question(r,e,t.id,n),U.questionPick(r,e,t.id,n)])})),S=()=>{!t||h.length===0||_.isPending||(c(void 0),(l?.sent??l?.dismiss)?.(),No(t),b(t,m),_.mutate({answers:h,drafts:x(t,m)}))},C=()=>{if(!t||h.length===0)return null;let e=m,n=x(t,e),r=()=>void g.invalidateQueries({queryKey:Zx(t)}),i=()=>{o(t=>{if(!e.some(({q:e})=>t.has(e.id)))return t;let n=new Map(t);for(let{q:t}of e)n.delete(t.id);return n});for(let e of n)for(let t of e.keys)Ci.clear(t)};return{answers:h,display:y(e).map((t,n)=>ss(t,e[n].q.spec,e[n].q.handle)),onOptimistic:()=>{c(void 0),b(t,e)},onSuccess:()=>{i(),r()},onRollback:e=>{e&&i(),r()}}},w=()=>{u?.composer.run()||S()};return{slug:t,answerFor:f,answersOf:p,onChip:(e,n,i,a)=>{let o=Nx(e.spec,n);if(!t||!o||e.spec.secret||!o.options?.[a])return;let s=U.questionPick(r,t,e.id,n),c=Mx(o,Ci.get(s)),l=i?{...c,chosenSet:c.chosenSet.includes(a)?c.chosenSet.filter(e=>e!==a):[...c.chosenSet,a]}:{...c,chosen:c.chosen===a?null:a};Ci.set(s,jx(o,l))},onText:(e,n,a,s)=>{if(!(!t||i)){if(e.spec.secret){o(t=>t.get(e.id)===s?t:new Map(t).set(e.id,s));return}Ci.set(U.question(r,t,e.id,n),s),a||Ci.clear(U.questionPick(r,t,e.id,n))}},dismiss:e=>v.mutate(e),dismissing:v.isPending,submit:()=>w(),take:C,staged:h.length,sending:_.isPending,error:s,readAndAnswerHost:i}}var Xx=[],Zx=e=>[`settledQuestions`,e],Qx=[],$x=e=>e.questions,eS=e=>e.closed;function tS(e,t){return fi({queryKey:Zx(e??``),queryFn:async()=>{let t=await k.threadSettledQuestions({slug:e});return{questions:t.questions,closed:t.closed??[]}},enabled:!!e,refetchOnWindowFocus:!1,select:t})}function nS(e){let t=e?.id,n=G(),r=tS(t,$x),i=(e?.questions??[]).map(e=>e.id).join(` `),a=(0,q.useRef)(i);return(0,q.useEffect)(()=>{let e=a.current;if(a.current=i,!t||e===i)return;let r=new Set(i.split(` `));e.split(` `).some(e=>e&&!r.has(e))&&n.invalidateQueries({queryKey:Zx(t)})},[i,n,t]),r.data??Xx}function rS(e){return tS(e?.id,eS).data??Qx}var iS=[];function aS(e,t){let n=e?.questions??iS;if(t.length===0||n.length===0)return n;let r=new Set(t.map(e=>e.id));return n.some(e=>r.has(e.id))?n.filter(e=>!r.has(e.id)):n}function oS({s:e,copy:t}){let n=(0,q.useMemo)(()=>Ax(e.spec,e.answer),[e.spec,e.answer]),r=e=>(0,X.jsx)(Fx,{question:e.question,label:e.depth>1?`Follow-up`:void 0,settled:e.settled},e.path),i=n.slice(1);return(0,X.jsxs)(`article`,{...t?{"data-question-copy":e.id}:{"data-question-id":e.id},"data-settled-question":!0,"aria-label":`Answered question`,className:`flex min-w-0 flex-col gap-2 opacity-60`,children:[r(n[0]),i.length>0&&(0,X.jsx)(`div`,{className:`ml-3 flex flex-col gap-2 border-l border-border pl-3`,children:i.map(e=>(0,X.jsx)(`div`,{className:e.depth>2?`ml-3 border-l border-border pl-3`:void 0,children:r(e)},e.path))})]})}function sS({questions:e,className:t=``}){return e.length===0?null:(0,X.jsx)(`section`,{"data-settled-questions":!0,"aria-label":`${e.length} answered question${e.length===1?``:`s`}`,className:`flex min-w-0 flex-col gap-3 ${t}`,children:e.map(e=>(0,X.jsx)(oS,{s:e},e.id))})}function cS(e){return`settledAt`in e?e:void 0}function lS(e,t,n,r,i=Qx){let a=r?.closedQuestions,o=(0,q.useMemo)(()=>{let e=new Map(i.map(e=>[e.id,e.spec]));return(a??[]).map(t=>({id:t.id,handle:t.handle,closed:t.state,asked:e.get(t.id)}))},[a?.length?a.map(e=>`${e.id}:${e.state}`).join(` `):``,i]);return(0,q.useMemo)(()=>e?void 0:[...t,...n,...o],[e,t,n,o])}function uS(e,t){let n=(0,q.useRef)(new Map),[,r]=(0,q.useState)(0),{shown:i,wakeAt:a}=dx(e,t,n.current,Date.now());return(0,q.useEffect)(()=>{if(a===void 0)return;let e=setTimeout(()=>r(e=>e+1),Math.max(0,a-Date.now()));return()=>clearTimeout(e)},[a]),(0,q.useMemo)(()=>i,[e,i===e?``:e.filter(e=>!i.includes(e)).map(e=>e.id).join(` `)])}function dS(e,t,n,r){let i=t?.questionFaults,a=(0,q.useMemo)(()=>i,[gx(i)]),o=t?.closedQuestions,s=(0,q.useMemo)(()=>a?.length?[...n,...r,...o??[]]:[],[a,n,r,o]);return(0,q.useMemo)(()=>a?.length?hx(e,a,s):e,[e,a,s])}function fS(e,t,n,r){let i=t?.closedQuestions,a=(0,q.useMemo)(()=>[...n,...r,...i??[]],[n,r,i?.length?i.map(e=>e.id).join(` `):``]);return(0,q.useMemo)(()=>bx(e,a),[e,a])}function pS({spec:e}){let t=(0,q.useMemo)(()=>wx(e).question,[e]);return(0,X.jsx)(`article`,{"data-question-fence":e.handle,"data-question-unregistered":!0,className:`flex min-w-0 flex-col gap-2`,children:(0,X.jsx)(Fx,{question:t,pending:!0})})}function mS({spec:e,state:t,copyOf:n}){let r=(0,q.useMemo)(()=>wx(e).question,[e]);return(0,X.jsx)(`article`,{...n?{"data-question-copy":n}:{"data-question-fence":e.handle},"data-question-closed":t,"aria-label":t===`dismissed`?`Dismissed question`:`Withdrawn question`,className:`flex min-w-0 flex-col gap-2 opacity-60`,children:(0,X.jsx)(Fx,{question:r,label:t===`dismissed`?`Question dismissed`:`Question withdrawn`,settled:hS})})}var hS={chosenIdxs:[]};function gS({q:e,above:t}){let n=(0,q.useMemo)(()=>wx(e.spec).question,[e.spec]);return(0,X.jsx)(`article`,{"data-question-copy":e.id,"data-question-open":t?`above`:`below`,"aria-label":t?`Open question, answered further up`:`Open question, answered further down`,className:`flex min-w-0 flex-col gap-2 opacity-60`,children:(0,X.jsx)(Fx,{question:n,label:t?`Still open, answer it above`:`Still open, answer it below`})})}function _S({spec:e,reasons:t,unread:n}){let r=(0,q.useMemo)(()=>wx(e).question,[e]);return(0,X.jsx)(yS,{reasons:t,...n?{"data-question-invalid":e.handle}:{"data-question-refused-ask":e.handle},children:(0,X.jsx)(`div`,{className:`opacity-60`,children:(0,X.jsx)(Fx,{question:r})})})}function vS({faults:e,children:t}){return(0,X.jsx)(yS,{reasons:e,"data-question-invalid":``,children:t})}function yS({reasons:e,children:t,...n}){let r=_x(e),i=Nf(r?`Question not asked: ${r}.`:`Question not asked.`);return(0,X.jsxs)(`div`,{...n,className:`flex min-w-0 flex-col gap-1.5`,children:[(0,X.jsx)(`p`,{"data-question-not-asked":!0,className:`text-[13px] leading-snug text-muted`,children:(0,X.jsx)(Oh,{as:`span`,className:`md-inline`,html:i})}),t]})}function bS({id:e,closed:t}){return(0,X.jsxs)(`p`,{"data-question-refused":e,className:`md-inline text-[13px] leading-snug text-muted`,children:[`Refers to `,(0,X.jsx)(`code`,{children:e}),`, `,t===`withdrawn`?`a question the worker withdrew`:t===`dismissed`?`a question that was dismissed`:`a question this thread never asked`,`.`]})}function xS({thread:e,children:t}){let n=Yx(e);return(0,X.jsx)(Jx.Provider,{value:n,children:t})}function SS({q:e,answering:t}){let n=(0,q.useContext)(Jx),r=Vx(),i=t??n;if(!i||!i.slug)return null;if(r)return(0,X.jsx)(Hx,{questions:[e]});if(i.readAndAnswerHost&&Tx(e.spec))return(0,X.jsxs)(`article`,{"data-question-id":e.id,className:`flex min-w-0 flex-col gap-2`,children:[(0,X.jsx)(Fx,{question:wx(e.spec).question}),(0,X.jsxs)(Qo,{className:`text-[12px] text-muted`,children:[`This question has to be answered on `,i.readAndAnswerHost,`.`]})]});let a=Dx(e.spec,i.answersOf(e)),o=t=>(0,X.jsx)(Fx,{question:t.question,label:t.depth>1?`Follow-up`:void 0,aside:t.depth===1&&!e.spec.danger&&!i.readAndAnswerHost?(0,X.jsx)(`button`,{type:`button`,"data-dismiss-question":!0,"aria-label":`Dismiss this question`,title:`Dismiss — the worker decides it itself`,disabled:i.dismissing,onClick:()=>i.dismiss(e.id),className:`icon-focus-outline card-icon-offset -mx-2 -my-1 flex rounded-md p-1 text-muted-70 outline-none transition-colors hover:bg-hover-strong hover:text-fg disabled:opacity-40`,children:(0,X.jsx)(bi,{size:16})}):void 0,interactive:{answer:i.answerFor(e,t.path),onChip:n=>i.onChip(e,t.path,t.spec.kind===`multi`,n),onText:n=>i.onText(e,t.path,t.spec.kind===`multi`,n),onSubmit:i.submit,...i.readAndAnswerHost?{optionsOnly:!0}:{}}},t.path),s=a.slice(1);return(0,X.jsxs)(`article`,{"data-question-id":e.id,className:`flex min-w-0 flex-col gap-2`,children:[o(a[0]),s.length>0&&(0,X.jsx)(`div`,{className:`ml-3 flex flex-col gap-2 border-l border-border pl-3`,children:s.map(e=>(0,X.jsx)(`div`,{className:e.depth>2?`ml-3 border-l border-border pl-3`:void 0,children:o(e)},e.path))})]})}function CS({thread:e,questions:t,inFlight:n=null,showSend:r=!1,className:i=``}){let a=e?.id,o=t??e?.questions??[],s=(0,q.useContext)(Jx),c=Yx(s?void 0:e),l=s??c,u=Vx(),d=Q_(),f=r&&!d;return!a||o.length===0&&(!f||u)?!a||!n?.length?null:(0,X.jsx)(`section`,{"data-answers-in-flight":!0,"aria-label":`Your answer, on its way to the worker`,className:`flex min-w-0 flex-col items-end ${i}`,children:(0,X.jsx)(cb,{answers:n,queued:!0})}):u?(0,X.jsxs)(`section`,{"data-registered-questions":!0,"aria-label":`${o.length} question${o.length===1?``:`s`} waiting for an answer`,className:`flex min-w-0 flex-col gap-3 ${i}`,children:[(0,X.jsx)(Hx,{questions:o}),l.error&&(0,X.jsx)(`div`,{role:`alert`,className:`break-words text-[13px] leading-snug text-danger-soft`,children:l.error}),l.sending&&(0,X.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[13px] leading-snug text-muted`,children:`Sending…`})]}):(0,X.jsxs)(`section`,{"data-registered-questions":!0,"aria-label":o.length>0?`${o.length} question${o.length===1?``:`s`} waiting for an answer`:`Send the answers above`,className:`flex min-w-0 flex-col gap-3 ${i}`,children:[o.map(e=>(0,X.jsx)(SS,{q:e,answering:l},e.id)),l.error&&(0,X.jsx)(`div`,{role:`alert`,className:`break-words text-[11px] leading-snug text-danger-soft`,children:l.error}),l.sending&&(0,X.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[11px] leading-snug text-muted`,children:`Sending…`}),!d&&(0,X.jsx)(`div`,{className:`flex justify-start`,children:(0,X.jsx)(`button`,{type:`button`,"data-send-answers":!0,disabled:l.staged===0||l.sending,onClick:l.submit,onMouseDown:e=>e.preventDefault(),className:`button-outline rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-all hover:opacity-90 active:scale-95 disabled:opacity-30 disabled:hover:opacity-30`,children:`Send answers`})})]})}function wS(e){let t=[],n=(e,r)=>{t.push(r),e.options?.forEach((e,t)=>{e.followUps?.forEach((e,i)=>n(e,`${r}/${t}.${i}`))})};return n(e.spec,Sx),t}function TS(e,t){let n=nS(e);yg(e);let r=(0,q.useMemo)(()=>aS(e,n),[e,n]),i=Lb(e,t),a=(0,q.useMemo)(()=>sx(i),[i]),o=(0,q.useMemo)(()=>cx(i),[i]),s=uS(r,i);return{messages:ES(fS(dS(o,e,s,n),e,s,n),e),openQuestions:s,settledQuestions:n,transcriptShells:a}}function ES(e,t){let n=t?.runtime===`running`||t?.runtime===`spawning`;return(0,q.useMemo)(()=>{if(n)return e;let t=ax(e,qg(e));if(t.length===0)return e;let r=[...e];for(let e of t)r[e]={...r[e],latestSignOff:!0};return r},[e,n])}var DS=(0,q.createContext)(null),OS=(0,q.createContext)(null);function kS(){let e=(0,q.useContext)(DS);if(!e)throw Error(`A thread's prompt box must be rendered inside a <ThreadSurface>`);return e}function AS(){let e=(0,q.useContext)(OS);if(!e)throw Error(`A thread's transcript must be rendered inside a <ThreadSurface>`);return e}function jS(e){let t=(0,q.useContext)(OS)?.opsThread;return t&&t.id===e.id?t:e}var MS=(e,t)=>e===t||e!==`all`&&t!==`all`&&e.size===t.size&&[...e].every(e=>t.has(e)),NS=(e,t)=>jb(e,t,MS);function PS(e,t={}){let{slug:n,thread:r,messages:i}=e,a=kb(e.openQuestions,Ai),o=kb(e.settledQuestions,Ai),{exit:s}=t,c=q_(),l=Y_(c),u=xb(n,i,s?()=>{if(s.sent){s.sent();return}document.activeElement?.blur(),s.dismiss()}:void 0,{onSendFailed:s?.cancel,composer:c}),{stagedCount:d,takeAnswers:f,answeringForMessage:p}=u,m=J_(c,{stagedCount:d,takeAnswers:f}),h=r?.runtime===`running`||r?.runtime===`spawning`,g=(0,q.useMemo)(()=>mb(i),[i]),_=h?i.length:g,v=(0,q.useMemo)(()=>r?.heldHandoff?mg(i,_):-1,[r?.heldHandoff,i,_]),y=py(r),b=Nn(r?.spawnedAt),x=Ab(lS(b,a,o,r,rS(r)),Pb),S=kb((0,q.useMemo)(()=>i_(i,a),[i,a]),Mb),C=(0,q.useMemo)(()=>h_(i,a),[i,a]),w=kb(C.placed,Mb),T=(0,q.useMemo)(()=>({...C,placed:w}),[C,w]),E=Ab((0,q.useMemo)(()=>g_(i,a,T),[i,a,T]),Nb),D=(0,q.useMemo)(()=>nx(i,o),[i,o]),O=kb(D.placed,Mb),k=(0,q.useMemo)(()=>({...D,placed:O}),[D,O]),A=kb((0,q.useMemo)(()=>Wg(i),[i]),Ai),j=kb((0,q.useMemo)(()=>N_(i),[i]),NS),M=(0,q.useMemo)(()=>zg(i,r?.answersInFlight),[i,r?.answersInFlight]),N=Db(r,i),P=(0,q.useMemo)(()=>Wi(i),[i]),F=(0,q.useMemo)(()=>({held:P.held,steered:P.steered}),[P.held,P.steered]),I=(0,q.useMemo)(()=>({thread:r,messages:i,running:h,lastAgentIdx:g,awaitingCut:_,heldIdx:v,restingShown:y,hidesAwaiting:e=>[_>=0&&e<_&&e!==v,e===g&&y],stepsDone:j,openQuestions:a,fencesLive:b,fenceQuestions:x,shadowedByMessage:S,placement:T,questionHomes:E,settledPlacement:k,paired:A,inFlightAnswers:M,answeringForMessage:p,opsThread:N}),[r,i,h,g,_,v,y,j,a,b,x,S,T,E,k,A,M,p,N]),L=cr(),R=Kn(e=>L.give(e)),z=(0,q.useMemo)(()=>({fileDrop:{over:R.over,intake:L}}),[R.over,L]),B=s?.dismiss,V=s?.cancel,ee=s?.sent,te=(0,q.useMemo)(()=>B&&V?{dismiss:B,cancel:V,sent:ee}:null,[B,V,ee]);return{slug:n,answering:u,transcript:I,promptBoxSends:l,fileOver:R.over,queuedRun:F,exit:te,sendScope:m,zone:R.handlers,box:z}}function FS({surface:e,children:t,...n}){let r=Yt(),i=Qb(e.slug,e.queuedRun),a=e.zone;return(0,q.useEffect)(()=>{if(r)return r.current=a,()=>{r.current===a&&(r.current=null)}}),(0,X.jsx)(db.Provider,{value:e.slug,children:(0,X.jsx)(fb.Provider,{value:e.exit,children:(0,X.jsx)(G_.Provider,{value:e.sendScope,children:(0,X.jsx)(K_.Provider,{value:e.sendScope.composer,children:(0,X.jsx)(xS,{thread:e.transcript.thread,children:(0,X.jsx)(OS.Provider,{value:e.transcript,children:(0,X.jsx)(pb.Provider,{value:e.queuedRun,children:(0,X.jsx)(DS.Provider,{value:e.box,children:(0,X.jsx)(`div`,{...n,...r?null:a,"data-thread-surface":e.slug,onKeyDown:e=>{n.onKeyDown?.(e),i(e)},children:t})})})})})})})})})}function IS({blocks:e,answering:t,onClose:n}){let[r,i]=(0,q.useState)(0),[a,o]=(0,q.useState)(!1);(0,q.useEffect)(()=>{let e=requestAnimationFrame(()=>o(!0));return()=>cancelAnimationFrame(e)},[]),(0,q.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),n())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n]);let s=e[Math.min(r,e.length-1)];if(!s)return null;let c=r>=e.length-1;return(0,X.jsxs)(Gi,{"data-mobile-answer-sheet":!0,label:`Answer questions`,className:`fixed inset-0 ${Je} flex flex-col justify-end`,children:[(0,X.jsx)(`button`,{"aria-label":`Close`,onClick:n,className:`absolute inset-0 bg-scrim-50 transition-opacity duration-200 ${a?`opacity-100`:`opacity-0`}`}),(0,X.jsxs)(`div`,{className:`relative flex max-h-[86%] flex-col overflow-hidden rounded-t-[14px] border-t border-border-strong bg-panel pb-[env(safe-area-inset-bottom)] shadow-[0_-20px_60px_-10px_var(--sheet-shadow)] transition-transform duration-200 ease-out motion-reduce:transition-none ${a?`translate-y-0`:`translate-y-full`}`,children:[(0,X.jsx)(`div`,{className:`mx-auto mt-[6px] h-[5px] w-[36px] shrink-0 rounded-full bg-muted/35`}),(0,X.jsxs)(`div`,{className:`flex h-[48px] shrink-0 items-center gap-2 border-b border-border/70 px-3`,children:[(0,X.jsx)(`button`,{onClick:n,className:`flex h-[44px] items-center px-2 text-[16px] text-fg/85`,children:`Cancel`}),(0,X.jsx)(`span`,{className:`flex-1 text-center text-[15px] font-semibold tracking-[-0.01em] text-fg`,children:e.length>1?`Question ${r+1} of ${e.length}`:`Question`}),(0,X.jsx)(`span`,{className:`flex h-[44px] w-[44px] items-center justify-center`,children:(0,X.jsx)(bi,{size:19,className:`opacity-0`,"aria-hidden":!0})})]}),(0,X.jsx)(`div`,{"data-mobile-answer-body":!0,className:`min-h-0 flex-1 overflow-y-auto px-3 py-3`,children:(0,X.jsx)(Fx,{raw:s.raw,questionKind:s.kind,danger:s.danger,interactive:{answer:t.answerFor(s.bi),onChip:(e,n)=>t.onChip(s.bi,e,n),onText:e=>t.onText(s.bi,e),onSubmit:()=>c?l():i(e=>e+1)}},s.bi)}),(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center gap-3 border-t border-border/70 px-4 pb-[30px] pt-3`,children:[e.length>1?(0,X.jsx)(`div`,{className:`flex items-center gap-1.5`,children:e.map((e,t)=>(0,X.jsx)(`span`,{className:`size-[6px] rounded-full ${t===r?`bg-accent`:`bg-muted/35`}`},e.bi))}):null,(0,X.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[r>0?(0,X.jsx)(`button`,{onClick:()=>i(e=>e-1),className:`flex h-[50px] shrink-0 items-center justify-center rounded-[14px] border border-border-strong bg-elevated px-5 text-[17px] text-fg active:bg-panel-2`,children:`Back`}):null,(0,X.jsx)(`button`,{onClick:()=>c?l():i(e=>e+1),disabled:c?!t.anyAnswered||t.sending:!1,className:`button-outline flex h-[50px] flex-1 items-center justify-center rounded-[14px] bg-accent-fill px-5 text-[17px] font-semibold text-on-accent transition-[filter,opacity] active:brightness-90 disabled:opacity-40`,children:c?t.sending?`Sending…`:`Send answers`:`Continue`})]})]})]})]});function l(){t.onSubmit(),n()}}var LS=(e,t)=>`${e}|${t}`;function RS(e,t){return e.flatMap(e=>Dx(e.spec,t(e)).map(t=>({key:LS(e.id,t.path),q:e,path:t.path,spec:t.spec,depth:t.depth})))}function zS(e,t,n,r){return BS(RS(e,e=>{let i=t(e);if(e.id!==n.q.id)return i;let a=i.get(n.path)??{chosen:null,chosenSet:[],text:``};return new Map(i).set(n.path,{...a,chosen:r})}),n.key)}function BS(e,t){let n=e.findIndex(e=>e.key===t);return n===-1?null:e[n+1]?.key??null}function VS(e,t){return e.find(e=>!Ox(e.spec,t(e.q).get(e.path)))?.key??null}var HS=`••••••••`;function US(e,t){if(!t||!Ox(e,t))return null;if(e.secret)return HS;let n=(e.options??[]).map(e=>WS(e.label)),r=t.text.trim();return e.kind===`multi`?[(t.chosenSet??[]).slice().sort((e,t)=>e-t).flatMap(e=>n[e]===void 0?[]:[n[e]]).join(`, `),r].filter(Boolean).join(` — `):t.chosen!==null&&n[t.chosen]!==void 0?n[t.chosen]:r||null}function WS(e){return e.replace(/[`*_~]/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\s+/g,` `).trim()}function GS(e){let t=e?.trim();return t&&!t.includes(`
|
|
132
|
-
`)?t:void 0}function KS({title:e,onRequestClose:t,children:n,footer:r,className:i=``,dataAttr:a}){let[s,c]=(0,q.useState)(!1),l=(0,q.useRef)(null);(0,q.useEffect)(()=>{let e=requestAnimationFrame(()=>c(!0));return()=>cancelAnimationFrame(e)},[]);let u=a?{[a]:``}:{};return(0,X.jsx)(Jn,{open:!0,onOpenChange:e=>{e||t()},children:(0,X.jsxs)(o,{children:[(0,X.jsx)(Kt,{className:`fixed inset-0 ${Je} bg-scrim-50 transition-opacity duration-200 motion-reduce:transition-none ${s?`opacity-100`:`opacity-0`}`}),(0,X.jsxs)(lr,{ref:l,...u,"aria-describedby":void 0,onOpenAutoFocus:e=>{e.preventDefault(),l.current?.focus({preventScroll:!0})},onEscapeKeyDown:f,className:`fixed inset-x-0 bottom-0 ${Je} flex max-h-[86%] flex-col overflow-hidden rounded-t-[14px] border-t border-border-strong bg-panel pb-[calc(14px+env(safe-area-inset-bottom))] shadow-[0_-20px_60px_-10px_var(--sheet-shadow)] outline-none transition-transform duration-200 ease-out motion-reduce:transition-none ${s?`translate-y-0`:`translate-y-full`} ${i}`,children:[(0,X.jsx)(ii,{className:`sr-only`,children:e}),(0,X.jsx)(`div`,{"aria-hidden":!0,className:`mx-auto mt-[6px] mb-[6px] h-[5px] w-[36px] shrink-0 rounded-full bg-muted/35`}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:n}),r]})]})})}function qS({questions:e,onClose:t}){let n=(0,q.useContext)(Jx),r=Be(t),i=n?RS(e,n.answersOf):[],[a,o]=(0,q.useState)(()=>n?VS(i,n.answersOf):null),[s,c]=(0,q.useState)(!1),l=e.length===0;if((0,q.useEffect)(()=>{l&&r()},[l,r]),!n||!n.slug||l)return null;let u=a===null?-1:i.findIndex(e=>e.key===a),d=u===-1?void 0:i[u],f=e=>{c(!1),o(e)},p=d?u:i.length,m=(0,X.jsx)(`span`,{"aria-hidden":!0,className:`flex gap-[5px]`,children:Array.from({length:i.length+1},(e,t)=>(0,X.jsx)(`i`,{className:`size-[6px] rounded-full ${t<=p?`bg-fg`:`bg-border-strong`}`},t))});return(0,X.jsxs)(KS,{title:d?`Question ${u+1} of ${i.length}`:`Review your answers`,onRequestClose:()=>r(),dataAttr:`data-answer-sheet`,footer:d?(0,X.jsx)(tC,{a:n,step:d,first:u===0,writing:s,onBack:()=>f(i[u-1]?.key??d.key),onNext:()=>f(BS(i,d.key))}):(0,X.jsx)(rC,{a:n,onSent:()=>r()}),children:[(0,X.jsxs)(`div`,{"data-answer-step":d?d.key:`review`,className:`flex items-center gap-2 px-[18px] pb-1 text-[12.5px] text-muted`,children:[m,(0,X.jsxs)(`span`,{children:[d?`Question ${u+1} of ${i.length}`:`Review`,d&&d.depth>1&&` · follow-up`,d?.spec.danger&&(0,X.jsx)(`span`,{className:`text-danger-soft`,children:` · destructive`})]})]}),d?(0,X.jsx)(JS,{a:n,step:d,writing:s,onWrite:()=>c(!0),onPick:t=>{let r=zS(e,n.answersOf,d,t);n.answerFor(d.q,d.path).chosen!==t&&n.onChip(d.q,d.path,!1,t),f(r)}},d.key):(0,X.jsx)(nC,{a:n,steps:i,onChange:e=>f(e)})]})}function JS({a:e,step:t,writing:n,onWrite:r,onPick:i}){let a=jf(t.spec.question),o=jf(t.spec.context?.trim()??``),s=e.answerFor(t.q,t.path),c=t.spec.options??[],l=t.spec.kind===`multi`,u=!e.readAndAnswerHost&&(c.length===0||n||!l&&s.chosen===null&&s.text.trim()!==``);return(0,X.jsxs)(`div`,{"data-answer-question":!0,children:[(0,X.jsx)(Oh,{className:`px-[18px] pb-3 pt-1 text-[17px] font-semibold leading-[23px] text-fg ${Wx}`,html:a}),o&&(0,X.jsx)(`div`,{"data-question-context":!0,className:`card-md min-w-0 overflow-x-auto px-[18px] pb-3 text-fg/75`,children:(0,X.jsx)(Oh,{className:`md-body`,html:o})}),c.length>0&&(0,X.jsxs)(`div`,{role:l?`group`:`radiogroup`,className:`border-b border-border`,children:[c.map((n,r)=>(0,X.jsx)(XS,{option:n,multi:l,on:l?(s.chosenSet??[]).includes(r):s.chosen===r,onClick:()=>l?e.onChip(t.q,t.path,!0,r):i(r)},r)),!u&&!e.readAndAnswerHost&&(0,X.jsxs)(`button`,{type:`button`,"data-answer-write":!0,onClick:r,className:`${YS} text-left`,children:[(0,X.jsx)(QS,{multi:l,on:!1,dashed:!0}),(0,X.jsx)(`span`,{className:`text-[15.5px] font-medium leading-[21px] text-muted`,children:l?`Add a note…`:`Write a different answer…`})]})]}),u&&t.spec.secret&&(0,X.jsx)(eC,{a:e,step:t,text:s.text}),u&&!t.spec.secret&&(0,X.jsx)($S,{a:e,step:t,autoFocus:n,placeholder:c.length===0?`Type your answer…`:l?`Add a note…`:`Write a different answer…`})]})}var YS=`flex w-full items-start gap-3 border-t border-border px-[18px] py-3 outline-none active:bg-hover focus-visible:bg-hover`;function XS({option:e,multi:t,on:n,onClick:r}){let i=GS(e.description),a=[i?void 0:e.description?.trim(),e.preview?.trim()].filter(Boolean).join(`
|
|
133
|
-
|
|
134
|
-
`);return(0,X.jsxs)(`button`,{type:`button`,role:t?`checkbox`:`radio`,"aria-checked":n,"data-answer-option":!0,"data-on":n||void 0,onClick:e=>{e.target.closest(`[data-lightbox-tile], img[data-local-path]`)||r()},className:`${YS} text-left`,children:[(0,X.jsx)(QS,{multi:t,on:n}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`span`,{className:`block text-[15.5px] font-medium leading-[21px] text-fg`,children:[(0,X.jsx)(Kx,{md:e.label}),e.recommended&&(0,X.jsx)(`span`,{className:`ml-1.5 text-[11px] font-bold leading-none tracking-[0.02em] text-accent`,children:`RECOMMENDED`})]}),i&&(0,X.jsx)(`span`,{className:`mt-px block text-[13px] leading-[18px] text-muted`,children:i}),a&&(0,X.jsx)(ZS,{md:a})]})]})}function ZS({md:e}){return(0,X.jsx)(`div`,{className:`card-md mt-1 text-muted`,children:(0,X.jsx)(Oh,{className:`md-body`,html:jf(e)})})}function QS({multi:e,on:t,dashed:n=!1}){return(0,X.jsx)(`span`,{"aria-hidden":!0,className:`mt-[0.5px] flex size-5 shrink-0 items-center justify-center border-[1.5px] ${e?`rounded-[5px]`:`rounded-full`} ${n?`border-dashed`:``} ${t?e?`border-fg bg-fg text-bg`:`border-fg`:`border-border-strong`}`,children:t&&(e?(0,X.jsx)(v,{size:14,strokeWidth:3}):(0,X.jsx)(`span`,{className:`size-2.5 rounded-full bg-fg`}))})}function $S({a:e,step:t,autoFocus:n,placeholder:r}){let i=(0,q.useRef)(null),a=e.answerFor(t.q,t.path).text,o=t.spec.kind===`multi`;return(0,q.useLayoutEffect)(()=>{let e=i.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight+e.offsetHeight-e.clientHeight}px`)},[a]),(0,q.useEffect)(()=>{n&&i.current?.focus()},[n]),(0,X.jsx)(`div`,{className:`px-[18px] ${(t.spec.options??[]).length===0?``:`pt-3`}`,children:(0,X.jsx)(`textarea`,{ref:i,"data-answer-text":!0,"data-1p-ignore":!0,"data-claims-escape":!0,rows:(t.spec.options??[]).length===0?3:1,value:a,placeholder:r,onChange:n=>e.onText(t.q,t.path,o,n.target.value),onFocus:()=>{o||e.onText(t.q,t.path,!1,a)},className:`block max-h-[40vh] w-full resize-none overflow-y-auto rounded-[12px] border border-border-strong bg-bg px-3 py-[11px] text-[16px] leading-[22px] text-fg outline-none placeholder:text-faint focus:border-fg/40`})})}function eC({a:e,step:t,text:n}){return(0,X.jsxs)(`div`,{className:`px-[18px]`,children:[(0,X.jsx)(`input`,{type:`password`,"data-answer-text":!0,"data-secret-answer":!0,"data-claims-escape":!0,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,spellCheck:!1,"aria-label":`Secret value`,value:n,placeholder:`Paste the value…`,onChange:n=>e.onText(t.q,t.path,!1,n.target.value),className:`block w-full rounded-[12px] border border-border-strong bg-bg px-3 py-[11px] text-[16px] leading-[22px] text-fg outline-none placeholder:text-faint focus:border-fg/40`}),(0,X.jsx)(Px,{className:`mt-2 text-[13px] leading-[18px] text-muted`})]})}function tC({a:e,step:t,first:n,writing:r,onBack:i,onNext:a}){let o=e.answerFor(t.q,t.path),s=Ox(t.spec,o),c=t.spec.options??[],l=t.spec.kind!==`multi`&&o.chosen===null&&o.text.trim()!==``,u=t.spec.kind===`multi`||c.length===0||r||l;return(0,X.jsxs)(sC,{children:[(0,X.jsx)(`button`,{type:`button`,"data-answer-back":!0,disabled:n,onClick:i,className:`${iC} ${aC} disabled:opacity-35`,children:`Back`}),(0,X.jsx)(`span`,{className:`flex-1`}),!(u&&s)&&(0,X.jsx)(`button`,{type:`button`,"data-answer-skip":!0,onClick:a,className:`${iC} ${aC}`,children:s?`Next`:`Skip`}),u&&(0,X.jsx)(`button`,{type:`button`,"data-answer-continue":!0,disabled:!s,onClick:a,className:`${iC} ${oC} px-6 disabled:opacity-35`,children:`Continue`})]})}function nC({a:e,steps:t,onChange:n}){let r=t.map(t=>({s:t,said:US(t.spec,e.answerFor(t.q,t.path))})),i=r.filter(e=>e.said!==null).length;return(0,X.jsxs)(`div`,{"data-answer-review":!0,children:[(0,X.jsx)(`div`,{className:`px-[18px] pb-3 pt-1 text-[17px] font-semibold leading-[23px] text-fg`,children:i===0?`No answers yet`:`${i} answer${i===1?``:`s`}`}),(0,X.jsx)(`div`,{className:`border-b border-border`,children:r.map(({s:e,said:t})=>(0,X.jsxs)(`button`,{type:`button`,"data-answer-change":e.key,onClick:()=>n(e.key),className:`block w-full border-t border-border px-[18px] py-2.5 text-left outline-none active:bg-hover focus-visible:bg-hover`,children:[(0,X.jsx)(`span`,{className:`line-clamp-2 block text-[13px] leading-[18px] text-muted`,children:cC(e.spec.question)}),(0,X.jsxs)(`span`,{className:`mt-0.5 flex items-baseline justify-between gap-2.5`,children:[(0,X.jsx)(`span`,{className:`min-w-0 break-words text-[15.5px] leading-[21px] ${t===null?`text-muted`:`font-medium text-fg`}`,children:t??`Skipped`}),(0,X.jsx)(`span`,{className:`shrink-0 text-[13.5px] text-muted`,children:`Change`})]})]},e.key))})]})}function rC({a:e,onSent:t}){return(0,X.jsx)(sC,{children:(0,X.jsx)(`button`,{type:`button`,"data-answer-send":!0,disabled:e.staged===0||e.sending,onClick:()=>{e.submit(),t()},className:`${iC} ${oC} flex-1 disabled:opacity-35`,children:e.sending?`Sending…`:`Send answers`})})}var iC=`flex h-[46px] shrink-0 items-center justify-center rounded-[12px] text-[15.5px] font-semibold outline-none`,aC=`px-[18px] text-muted active:bg-hover focus-visible:bg-hover`,oC=`bg-fg text-bg active:opacity-90`;function sC({children:e}){let t=(0,q.useRef)(null),[n,r]=(0,q.useState)(!1);(0,q.useEffect)(()=>{let e=0,n=()=>{cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e=document.activeElement;r((e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement)&&t.current?.parentElement?.contains(e)===!0)})};return n(),document.addEventListener(`focusin`,n),document.addEventListener(`focusout`,n),()=>{cancelAnimationFrame(e),document.removeEventListener(`focusin`,n),document.removeEventListener(`focusout`,n)}},[]);let i=Wt(t,n);return(0,X.jsxs)(`div`,{ref:t,"data-answer-footer":!0,className:`shrink-0`,children:[(0,X.jsx)(`div`,{className:`flex items-center gap-2.5 px-[18px] pt-3.5`,children:e}),i>0&&(0,X.jsx)(`div`,{"aria-hidden":!0,style:{height:i}})]})}function cC(e){return WS(e.trim().split(/\n\s*\n/)[0]??``)}function lC(e){return(0,q.useSyncExternalStore)(e=>Mo(W,e),()=>e?uC(e)!==`codex`:!1,()=>!1)}function uC(e){return Qr(W.board,e)?.backend}function dC(e,t,n,r){let i=U.followUp(e,t,n);return gr(i,r),i}function fC(e){if(!(typeof document>`u`)){for(let t=e;t;t=t.parentElement){let e=t.querySelector(`[data-thread-composer-box] textarea`);if(e){e.focus(),e.setSelectionRange(e.value.length,e.value.length);return}}document.getElementById(`followup-input`)?.focus()}}function pC(e){let t=G(),n=Nr(),[r,i]=(0,q.useState)(!1);return{unqueue:(0,q.useCallback)(a=>{if(!e||r)return;let o=Qr(W.board,e)?.sessionId;if(!o){K(`This thread has no live session to unqueue from`);return}i(!0),k.unqueueFollowUp({slug:e,sessionId:o,deliveryId:a.deliveryId}).then(r=>{if(i(!1),!r.unqueued){K(r.reason??`That message could not be taken back`);return}mn(t,e,a.rawText,a.deliveryId),dC(n,e,o,a.text),fC(a.from)},e=>{i(!1),K(`Couldn't unqueue — ${(e instanceof Error?e.message:String(e)).slice(0,160)}`)})},[r,n,t,e]),pending:r}}function mC(e){let t=G(),n=Nr(),[r,i]=(0,q.useState)(!1),a=(0,q.useCallback)(n=>{!e||r||Fi(t,e,n.text,{supersedes:n.deliveryId,failureToast:e=>`Retry failed — ${e.slice(0,160)}`})},[r,t,e]),o=(0,q.useCallback)(async t=>{if(!e)return!1;i(!0);try{return await k.dismissFailedFollowUp({slug:e,deliveryId:t}),!0}catch(e){return K(`Couldn't dismiss — ${(e instanceof Error?e.message:String(e)).slice(0,160)}`),!1}finally{i(!1)}},[e]);return{retry:a,edit:(0,q.useCallback)(t=>{!e||r||(dC(n,e,Qr(W.board,e)?.sessionId,t.text),fC(t.from),o(t.deliveryId))},[o,r,n,e]),dismiss:(0,q.useCallback)(t=>{!e||r||o(t.deliveryId)},[o,r,e]),pending:r}}var hC=new Map;function gC(e,t){let n=(hC.get(e)??[]).filter(e=>e.deliveryId!==t.deliveryId);n.push(t),hC.set(e,n.slice(-8))}var _C=e=>e.replace(/\s+/g,` `).trim();function vC(e,t){let n=hC.get(e);if(!n?.length)return;let r=_C(t);for(let t=n.length-1;t>=0;t--){let i=_C(n[t].text);if(!i||!r.includes(i))continue;let[a]=n.splice(t,1);return n.length||hC.delete(e),a.deliveryId}}function yC(e){return e.project?`${De(e.project)}/thread/${e.slug}`:xs(`/thread/${e.slug}`)}function bC({peer:e,text:t,queued:n,sourceId:r,at:i}){let[a,o]=(0,q.useState)(!1),s=(0,q.useId)(),c=e.thread,l=Ne(c&&!c.project?c.slug:void 0),u=l?Lo(l):c?.title,d=jf(t),f=yp(d),p=(0,q.useRef)(null),m=Am(p,d),h=(0,q.useRef)(null),g=(0,q.useRef)(!1),_=()=>{g.current=document.activeElement===h.current,o(e=>!e)};(0,q.useLayoutEffect)(()=>{g.current&&(g.current=!1,h.current?.focus())},[a]);let v=e=>{e.target.closest(`a, button`)||_()},y=e=>e.preventDefault(),b=c?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`shrink-0 ${wy}`,children:`Message from `}),(0,X.jsx)(`a`,{href:yC(c),"data-session-peer-link":!0,title:`Open the thread that sent this`,onMouseDown:y,className:`min-w-0 truncate [font-variant-caps:normal] ${Py}`,children:u})]}):(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name?`Message from session ${e.name}`:`Message from another session`}),x=(0,X.jsx)(`button`,{ref:h,type:`button`,"data-session-message-toggle":!0,onClick:_,onMouseDown:y,"aria-expanded":a,"aria-controls":s,"aria-label":a?`Collapse the message`:`Expand the message`,className:`shrink-0 rounded-sm outline-none focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:(0,X.jsx)(vs,{"aria-hidden":`true`,size:12,className:`${Ay} ${a?`-mx-[0.15em] rotate-90`:`-mx-[0.275em]`}`})});return(0,X.jsx)(`div`,{"data-frizz-msg":r,"data-session-message":!0,className:`flex flex-col ${n?`opacity-50`:``}`,children:a?(0,X.jsxs)(`fieldset`,{className:`@container/wake my-1 min-w-0 rounded-xl border border-border/70 px-4 pb-3.5 pt-1 transition-colors has-[>legend:hover]:border-border`,children:[(0,X.jsx)(`legend`,{onClick:v,onMouseDown:y,className:`group/wake mx-auto max-w-[calc(100%-66px)] cursor-pointer px-3`,children:(0,X.jsx)(Sy,{icon:Ys,at:i,trailing:x,children:b})}),(0,X.jsxs)(`div`,{id:s,className:`card-md text-fg/85`,children:[(0,X.jsx)(`div`,{ref:p,className:`md-body [overflow-wrap:anywhere]`,dangerouslySetInnerHTML:f}),m]})]}):(0,X.jsx)(`div`,{onClick:v,onMouseDown:y,className:`group/wake cursor-pointer`,children:(0,X.jsx)(Q,{icon:Ys,marker:`session-message`,at:i,trailing:x,children:b})})})}function xC(e,t,n){return{type:`frizz-inline-vis-theme`,requestId:e,colorScheme:t,vars:n}}function SC(e,t){return typeof e==`object`&&!!e&&e.type===`frizz-inline-vis-applied`&&e.requestId===t}var CC=new Set([`planning`,`planned`,`active`,`needs-human`,`blocked`]);function wC(e){return!!(e&&e.kind===`legacy`&&!e.foreign&&e.runtime===`none`&&!e.sessionId&&!e.threadName&&!e.owner&&e.agents.length===0&&e.errors.length===0&&CC.has(e.status))}function TC(e,t){return e.pending?`loading`:e.failed?`failed`:t.running?`starting`:t.adoptable?`adopt`:`empty`}var EC=`sticky top-0 z-10 flex min-w-0 shrink-0 items-center gap-2.5 border-b border-border bg-panel px-3 ${ki} max-[640px]:h-auto max-[640px]:min-h-12 max-[640px]:flex-wrap max-[640px]:items-start max-[640px]:gap-y-2 max-[640px]:px-4 max-[640px]:py-2.5`,DC=`flex min-w-0 flex-1 items-center gap-2.5 pl-1 max-[640px]:basis-full`,OC=`flex shrink-0 items-center max-[640px]:w-full`;function kC(e){return e?.trim()?{kind:`profile-error`,message:`Profile controls unavailable: ${e.trim().slice(0,160)}`}:null}function AC(e){if(e.foreign)return`Read-only external thread`;if(e.permissionChangePending||e.permissionPending)return`A permission change is already in progress`;if(e.profileChangePending)return`A model and effort change is already in progress`;if(e.runtimeControlPending)return`Another runtime control is already in progress`;if(e.pendingAsk||e.runtime===`perm-prompt`)return`Resolve the open approval or question first`;if(e.backend===`codex`||e.backend===`acp`||e.backend===`opencode`)return null;let t=[...e.subAgents??[],...e.bgShells??[]].filter(e=>e.state===`running`||e.state===`stale`).length;return t>0?`Wait for ${t} unresolved background operation${t===1?``:`s`}`:e.runtime===`running`||e.runtime===`spawning`?`Wait for the current turn to finish`:null}function jC(e){return e.permissionChangePending===!0||e.permissionPending!==void 0||e.profileChangePending===!0||e.runtimeControlPending===!0}function MC(e,t){let n=t===`codex`?`Sandbox`:`Permissions`;return e===`applied`?`${n} applied to the live session`:e===`next-turn`?t===`codex`?`${n} applied — takes effect on the next turn`:`${n} saved — the worker restarts on the next turn`:`${n} saved for the next resume`}function NC(e,t,n,r){let i=e.find(e=>e.model===t),a=!!i,o=!!(i&&n&&i.efforts.includes(n)),s=a&&o;return{selectedProfile:i,modelKnown:a,effortKnown:o,profileKnown:s,modelSelectable:r||a,effortSelectable:!!i&&(r||s)}}function PC(e){let t=Ne(e),n=fi({queryKey:[`threadProfileOptions`,e],queryFn:()=>k.threadProfileOptions({slug:e}),enabled:!!(t&&!t.foreign&&t.kind===`session`),staleTime:5e3}),r=Yr({mutationFn:t=>k.setThreadProfile({slug:e,model:t.model,...t.effort?{effort:t.effort}:{}})}),i=Yr({mutationFn:t=>k.setThreadPermission({slug:e,permissionMode:t})}),a=Yr({mutationFn:t=>k.upgradeThreadModel({slug:e,sessionId:t})}),o=pt(),s=Yr({mutationFn:t=>k.stopThreadTurn({slug:e,sessionId:t})}),c=r.isPending||i.isPending||a.isPending,l=t?.backend===`codex`?`codex`:t?.backend===`acp`?`acp`:t?.backend===`opencode`?`opencode`:`claude`,u=t?de(t.id):void 0,d=fi({queryKey:wo([`acpAgents`],u),queryFn:()=>Zo(u).acpAgents(),enabled:!!t&&l===`acp`}),f=He(u,!!t&&l===`opencode`),p=l===`acp`?ja(t?.model?.trim()):void 0,m=Qa(u,p?[p]:[],p);if(!t||t.foreign||t.kind!==`session`)return{busy:c,footer:null,phoneTools:null,status:null};let h=c||jC(t),g=t.model?.trim(),_=t.effort?.trim(),v=l===`acp`?ja(g):void 0,y=r.isPending?r.variables:void 0,b=t.profilePendingModel??y?.model,x=t.profilePendingEffort??y?.effort,S=n.data?.options??[],{modelSelectable:C}=NC(S,g,_,t.runtime===`exited`),w=n.data!==void 0,T=d.data?.find(e=>e.id===v)?.label??v,E=[{id:l,label:l===`codex`?`Codex`:`Claude Code`,options:S}],D=kC(n.isError?n.error.message:void 0),O=t.permissionMode?en(t.permissionMode):`auto`,A=Ie.some(e=>e.value===O)?O:`auto`,j=i.isPending?i.variables:A,M=AC(t);function N(e){e!==A&&i.mutate(e,{onSuccess:e=>K(MC(e.effect,`claude`)),onError:e=>K(`Permission change failed: ${e.message.slice(0,120)}`)})}let P=l===`claude`?AC(t):null;function F(){t?.sessionId&&a.mutate(t.sessionId,{onSuccess:e=>K(`${e.label} from the next turn — the worker restarts then`),onError:e=>K(`Upgrade failed: ${e.message.slice(0,120)}`)})}function L(e){r.mutate(e,{onSuccess:e=>K(l===`acp`?e.effect===`next-resume`?`Model saved for the next resume`:`Model applied`:e.effect===`next-resume`?`Model and effort saved for the next resume`:`Model and effort applied`),onError:e=>K(`Profile change failed: ${e.message.slice(0,120)}`)})}let R=(0,X.jsxs)(X.Fragment,{children:[(l===`claude`||l===`codex`)&&(0,X.jsx)(hn,{groups:E,value:{provider:l,model:g,effort:_},pending:b||x?{provider:l,model:b,effort:x}:void 0,onValueChange:({model:e,effort:t})=>L({model:e,effort:t}),placeholder:n.isPending?`Profile loading…`:`Profile unknown`,ariaLabel:`Thread model and effort`,menuAriaLabel:`Choose ${l===`codex`?`Codex`:`Claude Code`} model and effort`,title:C?t.runtime===`exited`?`Saved per thread and applied when this conversation resumes`:`Change this idle conversation's model and reasoning effort`:`The current live backend profile is unavailable; controls fail closed`,disabled:h||!w||!C||n.isError,compact:!0,side:`top`,className:`max-w-[20rem]`,runningModelLabel:t.runningModelLabel,upgrade:t.modelUpgrade&&t.runningModelLabel?{latest:t.modelUpgrade.label,staged:t.modelUpgrade.staged,blockedReason:P,pending:a.isPending,onUpgrade:F}:void 0}),l===`acp`&&v&&g&&(0,X.jsx)(hn,{groups:[Ee({agent:{id:v,label:T??v},models:m.models[v],loading:m.loading[v]??!1,saved:g,onRequestOptions:()=>m.request(v)})],value:Sn(g),pending:b?Sn(b):void 0,onValueChange:e=>L({model:e.model,effort:``}),ariaLabel:`Thread model and effort`,menuAriaLabel:`Choose ${T??v} model`,title:`This thread's ${T??v} model`,disabled:h,compact:!0,side:`top`,className:`max-w-[20rem]`}),l===`opencode`&&(0,X.jsx)(hn,{groups:[Rn({models:f.models,loading:f.loading,saved:g,onRequestOptions:f.request})],value:ve(g),pending:b?ve(b):void 0,onValueChange:e=>L({model:Xe(e),effort:``}),ariaLabel:`Thread model and effort`,menuAriaLabel:`Choose OpenCode model and effort`,title:`This thread's OpenCode model and reasoning level`,disabled:h,compact:!0,side:`top`,className:`max-w-[20rem]`})]});return{busy:h,footer:(0,X.jsxs)(`div`,{"data-thread-composer-controls":!0,className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-1.5 gap-y-0.5`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-center gap-x-1.5`,children:[(0,X.jsxs)(I,{children:[R,l===`claude`&&(0,X.jsx)(ne,{variant:`readout`,side:`top`,value:j,onValueChange:e=>N(e),options:Ie,ariaLabel:`Thread permission mode`,title:M?`${M} — changing permissions restarts this thread's worker process`:j===`bypassPermissions`?`Bypass: the worker never asks for approval. Changing this restarts the worker process; the conversation resumes from disk on the next turn.`:`Auto: risky actions raise an approval card here. Changing this restarts the worker process; the conversation resumes from disk on the next turn.`,disabled:h||M!==null,className:`shrink-0`}),l===`opencode`&&(0,X.jsx)(ne,{variant:`readout`,side:`top`,value:i.isPending?i.variables:t.permissionMode??`auto`,onValueChange:e=>{i.mutate(e,{onSuccess:()=>K(`Permissions applied to the session`),onError:e=>K(`Permission change failed: ${e.message.slice(0,120)}`)})},options:ot,ariaLabel:`Thread permission mode`,title:`Applied to the session at once, and to its sub-agents.`,disabled:h,className:`shrink-0`})]}),l===`opencode`&&t.runtime===`running`&&t.sessionId&&(0,X.jsxs)(`button`,{type:`button`,"data-stop-turn":!0,onClick:()=>s.mutate(t.sessionId,{onError:e=>K(`Stop failed: ${e.message.slice(0,120)}`)}),disabled:s.isPending,"aria-label":`Stop this turn`,title:`Stop this turn. The thread stays open for your next message.`,className:`-ml-px -mr-[6.5px] flex h-[22px] shrink-0 items-center gap-1 rounded-md px-1.5 text-[11px] text-muted hover:bg-fill-hover hover:text-fg disabled:opacity-50`,children:[(0,X.jsx)(sc,{size:8,fill:`currentColor`,strokeWidth:0,"aria-hidden":!0}),!o&&`Stop`]}),(0,X.jsx)(bt,{gauge:l===`acp`||l===`opencode`?void 0:{backend:l,model:g},mcp:{slug:e},side:`top`})]}),b&&x&&(0,X.jsxs)(`span`,{className:`min-w-0 truncate text-[9px] text-muted-50`,children:[`→ `,b,` · `,x,` pending`]})]}),phoneTools:R,status:D?(0,X.jsx)(`div`,{"data-thread-control-error":``,className:`px-1 pt-1 text-[9.5px] leading-tight text-muted-65`,children:D.message}):null}}function FC(e,t=va.queueOrder){let n=jo(e,t),r=n.active.filter(un),i=n.active.filter(e=>!un(e));return[...n.pinned,...r,...i]}function IC(e,t,n=va.queueOrder,r=oo()){return FC(e.map(e=>Fa(e,r[e.id])),n).find(e=>e.id!==t&&Gr(e))}function LC(e){let t=IC(W.board?.threads??[],e);if(io()){t&&window.addEventListener(`popstate`,()=>setTimeout(()=>oi(t.id),0),{once:!0}),history.back();return}if(t){oi(t.id);return}let n=W.drawers.filter(e=>!e.closing).map(e=>e.id);n.length&&Wn(n)}var RC=new Map;async function zC(e,t={}){let n=e.id,r=t.terminateLive===!0,i=r||I_(e),a=Lo(e),o=()=>{wr(n),LC(n),K(`“${a}” marked done`,{action:{label:`Undo`,run:()=>void BC(n)}})};i&&o();let s=k.completeThread({slug:n,sessionId:e.sessionId??``,terminateLive:r});RC.set(n,s);try{let e=await s;return e.needsConfirmation?(zi(n),i?(K(e.hold?.cutOff?`Cut off mid-turn — open the thread to retry it, or to mark it done anyway`:`Still running — open the thread to finish it`,{link:{label:`Open`,slug:n}}),{kind:`declined`}):{kind:`needs-confirmation`,hold:e.hold}):(i||o(),{kind:`done`})}catch(e){return zi(n),K(`Couldn’t finish: ${e.message.slice(0,80)}`,i?{link:{label:`Open`,slug:n}}:void 0),{kind:`failed`}}finally{RC.get(n)===s&&RC.delete(n)}}async function BC(e){await RC.get(e)?.catch(()=>void 0);try{await k.setThreadState({slug:e,state:`open`}),zi(e),oi(e)}catch(e){K(`Couldn’t undo: ${e.message.slice(0,80)}`)}}function VC({thread:e,compact:t}){let[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(null);async function o(t){r(!0),t&&a(null);let n=await zC(e,{terminateLive:t});n.kind===`needs-confirmation`&&a({hold:n.hold}),n.kind!==`done`&&r(!1)}let s=L_(i?.hold);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,"data-phone-done":!0,onMouseDown:e=>e.preventDefault(),onClick:()=>void o(!1),disabled:n,"aria-label":`Mark as done`,className:`flex shrink-0 items-center justify-center gap-1 rounded-full bg-fg font-semibold text-bg disabled:opacity-45 ${t?`relative h-[36px] pl-[11px] pr-[14px] text-[14px] after:absolute after:inset-x-0 after:-inset-y-[4px] after:content-['']`:`h-[42px] pl-[13px] pr-[16px] text-[15px]`}`,children:[n&&!i?(0,X.jsx)(E,{"aria-hidden":!0,size:t?15:17,className:`animate-spin`}):(0,X.jsx)(v,{"aria-hidden":!0,size:t?15:17,strokeWidth:2.6,className:`translate-y-[0.1em]`}),`Done`]}),(0,X.jsx)(lt,{open:i!==null,onOpenChange:e=>{!e&&!n&&a(null)},title:i?.hold?.cutOff?`Mark an unfinished thread done?`:`End this session?`,className:`w-[390px] max-w-[92vw]`,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>a(null),className:`button-outline h-[40px] rounded-md px-4 text-[14px] text-muted outline-none disabled:opacity-45`,children:`Cancel`}),(0,X.jsxs)(`button`,{type:`button`,"data-phone-done-confirm":!0,disabled:n,onClick:()=>void o(!0),className:`button-outline flex h-[40px] items-center gap-1.5 rounded-md bg-fg px-4 text-[14px] font-medium text-bg outline-none disabled:opacity-45`,children:[n&&(0,X.jsx)(E,{size:14,className:`animate-spin`}),i?.hold?.cutOff?`Mark done anyway`:`End session & mark done`]})]}),children:(0,X.jsxs)(`div`,{"data-completion-hold":!0,className:`flex flex-col gap-2 p-4 text-[14px] leading-relaxed text-muted`,children:[(0,X.jsx)(`p`,{children:s.lead}),s.groups.map(e=>(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`div`,{className:`text-[12px] font-medium text-fg/70`,children:e.heading}),(0,X.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[e.items.map((e,t)=>(0,X.jsxs)(`li`,{className:`min-w-0 truncate text-fg/80`,children:[e.label,e.stale&&(0,X.jsx)(`span`,{className:`text-muted-60`,children:` · no recent output`})]},`${e.label}-${t}`)),e.overflow>0&&(0,X.jsxs)(`li`,{className:`text-muted-60`,children:[`+`,e.overflow,` more`]})]})]},e.kind)),(0,X.jsx)(`p`,{children:s.trailer})]})})]})}var HC={sm:{track:`h-[16px] w-[28px]`,thumb:`size-[12px]`,travel:`translate-x-[12px]`,onCap:`translate-y-[calc(6px_-_0.5cap)]`},md:{track:`h-[20px] w-[34px]`,thumb:`size-[16px]`,travel:`translate-x-[14px]`,onCap:`translate-y-[calc(8px_-_0.5cap)]`}};function UC({checked:e,onChange:t,disabled:n,label:r,size:i=`sm`,testId:a}){let o=HC[i];return(0,X.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":r,disabled:n,"data-switch":a,"data-state":e?`checked`:`unchecked`,onMouseDown:e=>e.preventDefault(),onClick:()=>t(!e),className:`inline-flex shrink-0 cursor-pointer items-center self-baseline rounded-full p-[2px] outline-none transition-colors focus-visible:ring-1 focus-visible:ring-focus-ink-60 disabled:cursor-default disabled:opacity-45 ${o.track} ${o.onCap} ${e?`bg-fg`:`bg-border hover:bg-border-strong`}`,children:(0,X.jsx)(`span`,{className:`pointer-events-none block rounded-full transition-transform duration-150 ease-out ${o.thumb} ${e?`bg-bg ${o.travel}`:`translate-x-0 bg-muted/70`}`})})}function WC({size:e=12,viewBox:t=`0 0 24 24`,strokeWidth:n=2,className:r=``}){return(0,X.jsxs)(`svg`,{width:e,height:e,viewBox:t,fill:`none`,stroke:`currentColor`,strokeWidth:n,strokeLinecap:`round`,strokeLinejoin:`round`,className:r,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{d:`M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,X.jsx)(`path`,{d:`M12 7a5 5 0 1 0 5 5`}),(0,X.jsx)(`path`,{d:`M13 3.055a9 9 0 1 0 7.941 7.945`}),(0,X.jsx)(`path`,{d:`M15 6v3h3l3 -3h-3v-3l-3 3`}),(0,X.jsx)(`path`,{d:`M15 9l-3 3`})]})}function GC({thread:e}){let[t,n]=(0,q.useState)(`closed`),r=(0,q.useRef)(null),i=(0,q.useRef)(void 0);(0,q.useEffect)(()=>()=>clearTimeout(i.current),[]);let a=t!==`closed`,[o,s]=(0,q.useState)(null);(0,q.useLayoutEffect)(()=>{if(!a)return;let e=r.current?.closest(`[role="dialog"], main`);if(!e){s(null);return}let t=e.getBoundingClientRect().left+e.clientLeft,n=r.current?.closest(`[data-composer-box]`)?.getBoundingClientRect(),i=r.current?.getBoundingClientRect();s({surface:e,left:Math.max(12,n?n.left-t:0),right:Math.max(12,n?t+e.clientWidth-n.right:0),width:si(n?.width??e.clientWidth,KC),toBoxEnd:n&&i?n.right-i.right:0})},[a]);let c=o?{collisionBoundary:o.surface,collisionPadding:{top:12,bottom:12,left:o.left,right:o.right}}:{},l=e.recurringPrompt,u=l?.stopHook===!0||l?.heartbeat===!0||l?.postCompaction===!0;function d(){clearTimeout(i.current),i.current=setTimeout(()=>n(e=>e===`closed`?`preview`:e),qC)}function f(){clearTimeout(i.current),n(e=>e===`preview`?`closed`:e)}let p=e=>{r.current?.contains(e.detail.originalEvent.target)&&e.preventDefault()};return(0,X.jsxs)(it,{open:t!==`closed`,onOpenChange:e=>{e||(clearTimeout(i.current),n(`closed`))},children:[(0,X.jsx)(Qt,{asChild:!0,children:(0,X.jsx)(`button`,{ref:r,type:`button`,"data-recurring-prompt":!0,"data-recurring-prompt-on":u?`true`:`false`,"aria-label":u?`Goal (on)`:`Goal`,"aria-haspopup":`dialog`,"aria-expanded":t===`full`,onClick:()=>{clearTimeout(i.current),n(e=>e===`full`?`closed`:`full`)},onPointerEnter:e=>{e.pointerType===`mouse`&&d()},onPointerLeave:e=>{e.pointerType===`mouse`&&f()},onFocus:()=>n(e=>e===`closed`?`preview`:e),onBlur:f,className:`group/goal icon-focus-outline flex ${Aa} items-center justify-center outline-none transition-[color,background-color] hover:bg-hover-strong`,children:(0,X.jsx)(WC,{...Do,className:u?`text-attention-90`:`text-muted group-hover/goal:text-fg group-focus-visible/goal:text-fg`})})}),t===`preview`?(0,X.jsx)(bs,{side:`top`,align:`end`,...c,"data-recurring-preview":!0,onPointerDownOutside:p,className:`pointer-events-none max-w-[min(22rem,calc(100vw-1.5rem))] p-2.5 text-[11px] leading-snug text-fg`,onOpenAutoFocus:e=>e.preventDefault(),children:(0,X.jsx)(JC,{armed:l})}):(0,X.jsx)(bs,{side:`top`,align:`end`,...c,className:`w-[min(46rem,calc(100vw-1.5rem))] p-3 text-[11px] leading-relaxed text-fg`,style:o?{width:o.width}:void 0,alignOffset:o?-o.toBoxEnd:0,onPointerDownOutside:p,onOpenAutoFocus:e=>e.preventDefault(),onDragOver:e=>e.stopPropagation(),onDragLeave:e=>e.stopPropagation(),onDrop:e=>{e.stopPropagation(),e.dataTransfer.files.length>0&&e.preventDefault()},children:(0,X.jsx)(iw,{thread:e,armed:l,close:()=>n(`closed`)})})]})}var KC=736,qC=260;function JC({armed:e}){let t=e?.prompt?.trim(),n=e?rw({stopHook:e.stopHook===!0,heartbeat:e.heartbeat===!0,postCompaction:e.postCompaction===!0,seconds:e.intervalSeconds??ZC}):[];return(0,X.jsxs)(`div`,{"data-recurring-preview-body":!0,children:[(0,X.jsxs)(`div`,{className:`mb-1 flex items-baseline gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Goal`}),(0,X.jsx)(`span`,{className:`text-muted-70`,children:n.length>0?`sent ${n.join(`, `)}`:t?`no trigger is on`:`not set`})]}),(0,X.jsx)(`p`,{className:`line-clamp-4 whitespace-pre-wrap ${t?`text-fg/90`:`text-muted`}`,children:t||`Click to write what this thread is trying to achieve.`})]})}var YC=1,XC=1440,ZC=600;function QC(e,t){if(e===String(Math.round(t/60)))return t;let n=Math.round(Number(e));return Number.isFinite(n)&&n>0?Math.min(XC,Math.max(YC,n))*60:t}var $C=null;function ew(e){return{prompt:e.text.trim(),stopHook:e.stopHook,heartbeat:e.heartbeat,postCompaction:e.postCompaction,seconds:e.seconds}}function tw(e,t){return(e.text.trim()||null)===(t.prompt||null)&&e.stopHook===t.stopHook&&e.heartbeat===t.heartbeat&&e.postCompaction===t.postCompaction&&e.seconds===t.seconds}function nw(e,t){return!e.archived&&!t}function rw(e){return[e.stopHook?`at every rest`:null,e.heartbeat?`every ${Math.round(e.seconds/60)}m`:null,e.postCompaction?`after every compaction`:null].filter(e=>e!==null)}function iw({thread:e,armed:t,close:n,heading:r=!0}){let i=nw(e,t)?Ue:``,a=$C?.slug===e.id?$C.draft:null,[o,s]=(0,q.useState)(a?.text??t?.prompt??i),[c,l]=(0,q.useState)(a?.stopHook??t?.stopHook??!1),[u,d]=(0,q.useState)(a?.heartbeat??t?.heartbeat??!1),[f,p]=(0,q.useState)(a?.postCompaction??t?.postCompaction??!1),[m,h]=(0,q.useState)(a?.seconds??t?.intervalSeconds??ZC),g=c||u||f,[_,v]=(0,q.useState)(String(Math.round((a?.seconds??t?.intervalSeconds??ZC)/60))),y=(0,q.useRef)(null),b=(0,q.useRef)({prompt:t?.prompt??i,stopHook:t?.stopHook??!1,heartbeat:t?.heartbeat??!1,postCompaction:t?.postCompaction??!1,seconds:t?.intervalSeconds??ZC}),x=e=>({text:o,stopHook:c,heartbeat:u,postCompaction:f,seconds:QC(_,m),...e}),S=(0,q.useRef)(x());S.current=x(),(0,q.useEffect)(()=>()=>{let n=S.current;if(tw(n,b.current)){$C?.slug===e.id&&($C=null);return}if(n.text.trim()===``&&!t){$C={slug:e.id,draft:n};return}w(n)},[]);let C=(0,q.useRef)(Promise.resolve(!0));function w(t){let n=C.current.catch(()=>!1).then(async()=>{let n=await T(t);return n?$C?.slug===e.id&&($C=null):$C={slug:e.id,draft:t},n});return C.current=n,n}async function T(t){let n=t.text.trim()||null;if(tw(t,b.current))return!0;try{await k.setThreadRecurringPrompt({slug:e.id,sessionId:e.sessionId??``,prompt:n,stopHook:t.stopHook,heartbeat:t.heartbeat,postCompaction:t.postCompaction,...n===null?{}:{intervalSeconds:t.seconds}}),b.current={...ew(t),prompt:n??``};let r=rw(t);K(n===null?`Goal cleared`:r.length===0?`Goal saved — no trigger is on, so nothing is sent`:`Goal: sent ${r.join(`, `)}`)}catch(e){return K((e instanceof Error?e.message:`Could not save the recurring prompt`).slice(0,100)),!1}return!0}function E(){if(tw(x(),b.current)||o.trim()===``&&!t){n();return}w(x()).then(e=>{e&&n()})}function D(){let e=QC(_,m);v(String(Math.round(e/60))),h(e)}let O=[{at:t?.lastRestFiredAt,how:`at rest`},{at:t?.lastScheduleFiredAt,how:`on schedule`},{at:t?.lastCompactFiredAt,how:`after a compaction`}].filter(e=>e.at!==void 0),A=O.reduce((e,t)=>e&&Date.parse(e.at)>=Date.parse(t.at)?e:t,void 0),j=A===void 0?null:O.length>1?`Last sent ${Mn(A.at)}`:`Last sent ${A.how} ${Mn(A.at)}`;return(0,X.jsxs)(`section`,{"data-recurring-panel":!0,children:[r?(0,X.jsxs)(`div`,{className:`mb-2 flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Goal`}),j&&(0,X.jsx)(`span`,{className:`ml-auto truncate text-muted-55`,children:j})]}):j?(0,X.jsx)(`div`,{className:`mb-2 truncate text-muted-55`,children:j}):null,(0,X.jsx)(`textarea`,{ref:y,"data-recurring-text":!0,"data-1p-ignore":!0,value:o,maxLength:qn,onChange:e=>s(e.target.value),onKeyDown:e=>{Dr({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),E())},placeholder:`What is this thread trying to achieve?`,className:`field-sizing-content max-h-[28vh] min-h-[4rem] w-full resize-none overflow-y-auto rounded-md border border-border bg-bg px-2 py-1.5 text-[12px] leading-snug outline-none placeholder:text-muted-50 focus:border-border-strong ${g?`text-fg`:`text-muted`}`}),(0,X.jsxs)(`div`,{className:`mt-3 grid grid-cols-[auto_auto_1fr] items-baseline gap-x-2.5 gap-y-2`,children:[(0,X.jsx)(UC,{testId:`stop-hook`,label:`Stop hook`,checked:c,onChange:e=>{l(e),e&&!o.trim()&&requestAnimationFrame(()=>y.current?.focus())}}),(0,X.jsx)(`span`,{className:`font-medium ${c?`text-fg`:`text-muted`}`,children:`Stop hook`}),(0,X.jsx)(`span`,{className:`text-muted`,children:`every rest — unless it signed off or parked on a wait`}),(0,X.jsx)(UC,{testId:`heartbeat`,label:`Heartbeat`,checked:u,onChange:e=>{d(e),e&&!o.trim()&&requestAnimationFrame(()=>y.current?.focus())}}),(0,X.jsx)(`span`,{className:`font-medium ${u?`text-fg`:`text-muted`}`,children:`Heartbeat`}),u?(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted`,children:[`every`,(0,X.jsx)(`input`,{type:`number`,"data-recurring-minutes":!0,inputMode:`numeric`,min:YC,max:XC,value:_,onChange:e=>v(e.target.value),onBlur:D,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),D())},"aria-label":`Heartbeat interval in minutes`,className:`w-[4.5ch] rounded-md border border-border bg-bg px-1 py-[3px] text-center text-[11px] leading-none tabular-nums text-fg outline-none focus:border-border-strong disabled:opacity-45 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none`}),`min, even mid-turn`]}):(0,X.jsx)(`span`,{className:`text-muted`,children:`on a clock, even mid-turn`}),(0,X.jsx)(UC,{testId:`post-compaction`,label:`Compaction`,checked:f,onChange:e=>{p(e),e&&!o.trim()&&requestAnimationFrame(()=>y.current?.focus())}}),(0,X.jsx)(`span`,{className:`font-medium ${f?`text-fg`:`text-muted`}`,children:`Compaction`}),(0,X.jsx)(`span`,{className:`text-muted`,children:`when the context is summarized away — link the doc to re-read`})]})]})}var aw=`frizz:send-mode`;function ow(){try{return localStorage.getItem(aw)===`queue`?`queue`:`steer`}catch{return`steer`}}var sw=la({mode:typeof window>`u`?`steer`:ow()});typeof window<`u`&&typeof window.addEventListener==`function`&&window.addEventListener(`storage`,e=>{(e.key===aw||e.key===null)&&(sw.mode=ow())});function cw(e){sw.mode!==e&&(sw.mode=e);try{e===`steer`?localStorage.removeItem(aw):localStorage.setItem(aw,e)}catch{}}function lw(){return Br(sw).mode}function uw(e){return e.staged>0?e.staged===1?`Add a note to send with your answer…`:`Add a note to send with your ${e.staged} answers…`:e.openQuestions?`Or skip the questions and reply…`:e.running&&e.steerable===!1?`Queue a message for when this turn ends…`:e.running&&e.mode===`queue`?`Queue a message for when the agent rests…`:`Reply to the agent…`}var dw=new Map;function fw(e){let t=dw.get(e);if(t)return t;let n=k.threadSkills({slug:e}).then(e=>e.skills,()=>(dw.delete(e),[]));return dw.set(e,n),n}function pw({className:e,above:t,phoneBarOverride:n,phoneChrome:r,readAndAnswerHost:i}){let a=(0,q.useContext)(Jx),o=pt(),s=r??o;return(0,X.jsxs)(`div`,{"data-thread-composer-box":mw,"data-remote-composer":!0,"data-thread-action-bar":``,className:s?`flex flex-col gap-2 px-3 py-2.5`:e,children:[t,s&&n&&(0,X.jsx)(`div`,{className:`flex items-center gap-2`,children:n({editReply:()=>{}})}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 ${s?``:`px-3 py-2`}`,children:[(0,X.jsx)(_n,{host:i}),!s&&(a?.staged??0)>0&&(0,X.jsx)(`button`,{type:`button`,"data-remote-send-answers":!0,disabled:a.sending,onClick:a.submit,className:`shrink-0 rounded-md bg-fg px-3 py-1.5 text-[13px] font-medium text-bg outline-none disabled:opacity-40`,children:a.sending?`Sending…`:`Send answers`})]})]})}var mw=`chatComposer`;function hw(e){let t=ie();return t?(0,X.jsx)(pw,{...e,readAndAnswerHost:t}):(0,X.jsx)(gw,{...e})}function gw({slug:e,className:t,id:n,above:r,phoneBarOverride:i,phoneChrome:a}){let{fileDrop:o}=kS(),s=Br(W),c=Ne(e),l=(0,q.useContext)(Jx),u=(0,q.useContext)(G_),d=(0,q.useContext)(fb),f=P_(c),p=(l?.staged??0)+(u?.fencedCount??0)+ +!!f.staged,m=c?.runtime===`running`,h=(0,q.useContext)(pb)?.held??0,g=m||h>0,{steer:_}=yo(c?.backend),v=lw(),y=_?v:`queue`,b=c?.foreign?`Send a message to take over this session…`:uw({staged:p,openQuestions:!!c?.pendingQuestion||(c?Sa(c):!1),running:g,mode:y,steerable:_}),x=Nr(),S=U.followUp(x,e,c?.sessionId),[w,T,E]=Ho(S),D=PC(e),k=Di(e),[A,j]=(0,q.useState)(null),M=(0,q.useMemo)(()=>()=>fw(e),[e]),[N,P]=(0,q.useState)(null),F=s.composerContext[e],I=(0,q.useMemo)(()=>F?.map(e=>e.token)??[],[F]);(0,q.useEffect)(()=>{let t=W.composerContext[e];if(!t?.length)return;let{prose:n}=Ti(w),r=t.filter(e=>Wr(n,e.token));r.length!==t.length&&(W.composerContext[e]=r)},[e,w,F]);let L=lo(c),R=pt(),z=a??R,B=c?.runtime===`running`||c?.runtime===`spawning`,V=c?.lastFence?.kind===`awaiting`&&za(c.lastFence.hints).length>0,ee=c?F_(c).archive&&!B&&!V:!1,te=c&&c.kind===`session`&&c.foreign!==!0?(0,X.jsx)(GC,{thread:c}):void 0;function ne(t=!1){let n=w.trim(),r=z?null:l?.take()??null,i=z?null:u?.takeFenced()??null,a=z?null:f.take();if(!n&&!r&&!i&&!a)return;let o=ue(n);if(o){if(E(),c?.backend===`acp`){K(`An ACP agent signs in through its own CLI — Frizz holds no account for it`);return}if(c?.backend===`opencode`){K("OpenCode signs in through its own CLI: run `opencode auth login`");return}let e=c?.backend===`codex`?`codex`:`claude`;o===`login`?j(e):P(e);return}let s=Fo(e),p=n?Ra(n,s,x):``,m=a?a.compose(p):p,h=i?rr(i.wire,m):m,v=r?rr(C(r.display),h):h,b={onOptimistic:()=>{E(),r?.onOptimistic(),i?.onOptimistic(),a?.onOptimistic()},onSuccess:()=>r?.onSuccess(),...r?{answers:r.answers,displayText:v}:{},...a?{todos:a.todos}:{},...y===`queue`&&!t&&(g||c?.deliveryInFlight===!0)?{hold:!0}:{},..._?{}:{failureToast:e=>`Send failed — ${e.slice(0,160)}`},supersedes:vC(S,h),onRollback:t=>{gr(S,w),La(e,s),gC(S,{...t,text:w}),r?.onRollback(t.kept),i?.onRollback(),a?.onRollback()}};k.submit(h,{...b,interrupt:t}),d?.sent?.()}let re=(0,q.useRef)(ne);re.current=ne;let ie=z?void 0:u?.composer;return(0,q.useEffect)(()=>ie?(ie.set(()=>re.current()),()=>ie.set(null)):void 0,[ie]),z?(0,X.jsxs)(`div`,{"data-thread-composer-box":mw,"data-thread-action-bar":``,"data-phone-thread-bar":``,children:[(0,X.jsx)(er,{contextTokens:I,id:n,surface:mw,value:w,onChange:T,onSubmit:()=>ne(),onInterruptSubmit:L?()=>ne(!0):void 0,slashSuggest:M,placeholder:c?.foreign?b:B?_?`Steer…`:`Queue…`:`Reply…`,busy:D.busy,fileDrop:o,phone:{layout:`bar`,tools:D.phoneTools,idlePrimary:ee&&c?e=>(0,X.jsx)(VC,{thread:c,compact:e}):void 0,override:i,onLongPressSend:L?()=>ne(!0):void 0}}),D.status,A&&(0,X.jsx)(O,{backend:A,onClose:()=>j(null),onAuthed:()=>j(null)}),N&&(0,X.jsx)(sn,{backend:N,onClose:()=>P(null)})]}):(0,X.jsxs)(`div`,{"data-thread-composer-box":mw,"data-thread-action-bar":``,className:t,children:[r,(0,X.jsx)(er,{contextTokens:I,id:n,surface:mw,value:w,onChange:T,onSubmit:()=>ne(),onInterruptSubmit:L?()=>ne(!0):void 0,slashSuggest:M,placeholder:b,busy:D.busy,footer:D.footer,railLead:te,fileDrop:o,send:c?.foreign?void 0:{mode:y,onMode:cw,running:g,staged:p,steerable:_}}),D.status,A&&(0,X.jsx)(O,{backend:A,onClose:()=>j(null),onAuthed:()=>j(null)}),N&&(0,X.jsx)(sn,{backend:N,onClose:()=>P(null)})]})}function _w({slug:e,above:t,phoneBarOverride:n,phoneChrome:r}){return Ne(e)?(0,X.jsx)(hw,{slug:e,id:`followup-input`,className:`shrink-0 px-3 py-3`,above:t,phoneBarOverride:n,phoneChrome:r}):null}var vw=24,yw=2;function bw(e,t,n,r,i,a){return(n-e)*(a-t)-(r-t)*(i-e)}function xw(e,t){return e.y>=t.bottom?[t.left,t.bottom,t.right,t.bottom]:e.y<=t.top?[t.left,t.top,t.right,t.top]:e.x<=t.left?[t.left,t.top,t.left,t.bottom]:e.x>=t.right?[t.right,t.top,t.right,t.bottom]:null}function Sw(e,t,n){if(Math.hypot(t.x-e.x,t.y-e.y)<yw)return!1;if(t.x>=n.left&&t.x<=n.right&&t.y>=n.top&&t.y<=n.bottom)return!0;let r=xw(e,n);if(!r)return!1;let[i,a,o,s]=r,c=bw(e.x,e.y,i,a,t.x,t.y),l=bw(i,a,o,s,t.x,t.y),u=bw(o,s,e.x,e.y,t.x,t.y);return!((c<0||l<0||u<0)&&(c>0||l>0||u>0))}function Cw(e,t){let n=e.filter(e=>t.at-e.at<=150),r=e[e.length-1];return n.length>0?[...n,t]:r?[r,t]:[t]}function ww(e,t,n){let r=e[e.length-1];if(!r||e.length<2||t-r.at>250)return!1;let i=e[0];for(let t=e.length-2;t>=0;t--){let n=e[t];if(Math.hypot(r.x-n.x,r.y-n.y)>=vw){i=n;break}}return Sw(i,r,n)}function Tw(e,t=[],n=[]){let{todos:r,agents:i,children:a,shells:o,prs:s,issues:c,commands:l,timers:u,files:d,links:f}=z_(e,t,n),p=r.filter(e=>!e.done).length;return[{key:`todo`,n:e.runtime===`turn-idle`&&e.lastFence?.kind===`awaiting`&&za(e.lastFence.hints).length>0?0:p||r.length,one:p?`to-do`:`to-do done`,many:p?`to-dos`:`to-dos done`,states:[]},{key:`agent`,n:i.length,one:`agent`,many:`agents`,states:i.map(e=>e.state)},{key:`child`,n:a.length,one:`child thread`,many:`child threads`,states:a.map(mo)},{key:`shell`,n:o.length,one:`shell`,many:`shells`,states:o.map(e=>e.state)},{key:`pr`,n:s.length,one:`PR`,many:`PRs`,states:[`running`]},{key:`issue`,n:c.length,one:`issue`,many:`issues`,states:[`running`]},{key:`command`,n:l.length,one:`monitor`,many:`monitors`,states:[`running`]},{key:`timer`,n:u.length,one:`timer`,many:`timers`,states:[`running`]},{key:`file`,n:d.length,one:`file`,many:`files`,states:[]},{key:`link`,n:f.length,one:`link`,many:`links`,states:[]}].filter(e=>e.n>0)}function Ew({slug:e,subAgents:t,className:n=`px-1 pt-1.5`,density:r=`card`}){let i=To(t,`card`);return i.length===0?null:(0,X.jsx)(`div`,{"data-queue-subagents":!0,className:`flex min-w-0 flex-col ${r===`panel`?``:`gap-0.5`} ${n}`,children:i.map((t,n)=>(0,X.jsx)(Qi,{kind:`AGENT`,label:t.label,state:t.state,density:r,depth:t.depth,startedAt:t.startedAt,parentSlug:e,onOpen:t.id?()=>Er(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:es(e,t)},t.id??`${t.startedAt}-${n}`))})}var Dw=300,Ow=50,kw=480,Aw=12,jw=6,Mw={todo:`What this thread needs a person to do`,agent:`Sub-agents running for this thread`,child:`Child threads this thread started`,shell:`Background shells running for this thread`,pr:`Pull requests this thread is watching`,issue:`Issues this thread is watching`,command:`Monitors this thread is waiting on`,timer:`Timers this thread has set`,file:`Files saved for this thread`,link:`Links saved for this thread`};function Nw({thread:e,transcriptShells:t=[]}){let n=jS(e),r=ta(n.id),[i,a]=(0,q.useState)(null),o=(0,q.useRef)(void 0),s=(0,q.useRef)(void 0);(0,q.useEffect)(()=>()=>{clearTimeout(o.current),clearTimeout(s.current)},[]);let c=Tw(n,t,r),l=(0,q.useRef)(null),u=(0,q.useRef)([]),d=i!==null,f=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!d){f.current=null;return}let e=e=>{u.current=Cw(u.current,{x:e.clientX,y:e.clientY,at:performance.now()})};return document.addEventListener(`pointermove`,e,{capture:!0,passive:!0}),()=>{document.removeEventListener(`pointermove`,e,{capture:!0}),u.current=[]}},[d]);let p=(0,q.useRef)(null),m=(0,q.useCallback)(e=>{e&&(p.current=e)},[]),h=()=>{let e=p.current?.isConnected?p.current.getBoundingClientRect():void 0;return!!e&&ww(u.current,performance.now(),e)},_=i!==null&&!c.some(e=>e.key===i);if((0,q.useEffect)(()=>{_&&(clearTimeout(o.current),clearTimeout(s.current),a(null))},[_]),c.length===0)return null;let v=e=>{clearTimeout(o.current),clearTimeout(s.current),a(e)},y=e=>{if(clearTimeout(o.current),clearTimeout(s.current),i===null||i===e||!h()){a(e);return}s.current=setTimeout(()=>y(e),Ow)},b=()=>{clearTimeout(o.current),clearTimeout(s.current)},x=()=>{clearTimeout(o.current),clearTimeout(s.current);let e=()=>{h()?o.current=setTimeout(e,Ow):a(null)};o.current=setTimeout(e,Dw)};return(0,X.jsxs)(`div`,{"data-queue-ops-summary":!0,ref:l,className:`-mt-3 flex h-8 min-w-0 items-baseline justify-end text-[11.5px]`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-[calc(16px_+_0.5cap)] w-0 shrink-0`}),c.map(e=>(0,X.jsx)(Pw,{group:e,line:l,open:i===e.key,onOpen:()=>v(e.key),onHover:t=>{u.current=Cw(u.current,{x:t.clientX,y:t.clientY,at:performance.now()}),y(e.key)},onHoverPanel:b,onCloseSoon:x,registerPanel:m,caretAt:f,onOpenChange:t=>t?v(e.key):a(t=>t===e.key?null:t),children:e.key===`todo`?(0,X.jsx)(`div`,{className:`px-2 py-1.5`,children:(0,X.jsx)(iv,{thread:n})}):e.key===`agent`?(0,X.jsx)(Ew,{slug:n.id,subAgents:n.subAgents??[],className:``,density:`panel`}):e.key===`child`?(0,X.jsx)(`div`,{"data-queue-child-threads":!0,className:`flex min-w-0 flex-col`,children:(0,X.jsx)(g,{parent:n.id,childThreads:r,density:`panel`})}):e.key===`command`||e.key===`timer`?(0,X.jsx)(Rw,{thread:n,kind:e.key}):(0,X.jsx)(YO,{slug:n.id,includeAgents:!1,only:e.key,transcriptShells:t,className:``,density:`panel`})},e.key))]})}function Pw({group:e,line:t,open:n,onOpen:r,onHover:i,onHoverPanel:a,onCloseSoon:o,registerPanel:s,caretAt:c,onOpenChange:l,children:u}){let d=(0,q.useRef)(null),f=(0,q.useRef)(null),[p]=(0,q.useState)(()=>({current:{getBoundingClientRect:()=>t.current?.getBoundingClientRect()??new DOMRect,get contextElement(){return t.current??void 0}}})),m=e.n===1?e.one:e.many,h=()=>{r(),requestAnimationFrame(()=>f.current?.querySelector(`button, a[href], [tabindex]:not([tabindex='-1'])`)?.focus())};return(0,X.jsxs)(it,{open:n,onOpenChange:l,children:[(0,X.jsx)(Qt,{virtualRef:p}),(0,X.jsxs)(`button`,{type:`button`,"data-ops-count":e.key,"aria-label":`${e.n} ${m} — show ${e.n===1?`it`:`them`}`,"aria-haspopup":`dialog`,"aria-expanded":n,onMouseEnter:i,onMouseLeave:o,onFocus:r,ref:d,onClick:e=>{e.stopPropagation(),e.detail===0?h():r()},onKeyDown:e=>{e.key===`ArrowDown`&&(e.preventDefault(),h())},onMouseDown:e=>e.preventDefault(),className:`flex shrink-0 items-baseline gap-1.5 whitespace-nowrap rounded-md px-1.5 py-0.5 outline-none transition-colors focus-visible:ring-1 focus-visible:ring-focus-ink-60 ${n?`bg-panel-2 text-fg/85`:`text-muted-70 hover:bg-panel-2 hover:text-fg/85`}`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`relative block h-[1em] w-[1em] shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)]`,children:(0,X.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,X.jsx)(Iw,{kind:e.key,states:e.states})})}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`tabular-nums text-fg/85`,children:e.n}),` `,m]})]}),(0,X.jsxs)(bs,{side:`top`,align:`end`,sideOffset:0,"data-queue-ops-panel":e.key,"aria-label":Mw[e.key],onMouseEnter:a,onMouseLeave:o,onOpenAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>{t.current?.contains(e.target)&&e.preventDefault()},onEscapeKeyDown:e=>{e.stopPropagation(),f.current?.contains(document.activeElement)&&d.current?.focus()},ref:e=>{f.current=e,s(e)},onClick:e=>e.stopPropagation(),className:`group/panel relative flex max-w-[calc(100vw-1.5rem)] flex-col p-1 before:absolute before:inset-x-0 before:top-full before:h-1.5 before:content-[''] data-[side=bottom]:before:top-auto data-[side=bottom]:before:bottom-full`,style:n?{width:si(t.current?.getBoundingClientRect().width??kw,kw)}:void 0,children:[(0,X.jsx)(`div`,{className:`max-h-[min(20rem,50vh)] overflow-y-auto scrollbar-none`,children:u}),(0,X.jsx)(Fw,{count:d,line:t,caretAt:c})]})]})}function Fw({count:e,line:t,caretAt:n}){let r=()=>{let n=t.current?.getBoundingClientRect(),r=e.current?.getBoundingClientRect();return n&&r?n.right-(r.left+r.width/2)-Aw/2-1:0},[i,a]=(0,q.useState)(()=>n.current??r());return(0,q.useEffect)(()=>{let e=r();n.current=e;let t=requestAnimationFrame(()=>a(e));return()=>cancelAnimationFrame(t)}),(0,X.jsxs)(`svg`,{"aria-hidden":!0,"data-queue-ops-caret":!0,width:Aw,height:jw,viewBox:`0 0 ${Aw} ${jw}`,style:{right:i},className:`pointer-events-none absolute top-full transition-[right] duration-100 ease-out motion-reduce:transition-none group-data-[side=bottom]/panel:top-auto group-data-[side=bottom]/panel:bottom-full group-data-[side=bottom]/panel:rotate-180`,children:[(0,X.jsx)(`path`,{d:`M1 0 L6 5 L11 0 Z`,className:`fill-elevated`}),(0,X.jsx)(`path`,{d:`M.5 .75 L5.5 5.1 Q6 5.5 6.5 5.1 L11.5 .75`,fill:`none`,strokeLinejoin:`round`,className:`stroke-border`})]})}function Iw({kind:e,states:t}){switch(e){case`todo`:return(0,X.jsx)(Gs,{"aria-hidden":!0,className:`h-[1em] w-[1em] text-muted-45`});case`agent`:case`child`:return(0,X.jsx)(Lw,{hue:`agent`,states:t});case`shell`:return(0,X.jsx)(Lw,{hue:`shell`,states:t});case`pr`:case`issue`:return(0,X.jsx)(Lw,{hue:`github`,states:t});case`command`:case`timer`:return(0,X.jsx)(Lw,{hue:`github`,states:t});case`file`:return(0,X.jsx)(u,{"aria-hidden":!0,className:`h-[1em] w-[1em] text-muted-45`});case`link`:return(0,X.jsx)(Ls,{"aria-hidden":!0,className:`h-[1em] w-[1em] text-muted-45`})}}function Lw({hue:e,states:t}){return t.some(Ia)?(0,X.jsx)(Hr,{hue:e}):(0,X.jsx)(`span`,{className:t.includes(`rested`)?ws:Pn})}function Rw({thread:e,kind:t}){let n=da(),{commands:r,timers:i}=z_(e);return(0,X.jsx)(`div`,{className:`flex flex-col`,children:t===`timer`?i.map(e=>(0,X.jsx)(Qi,{kind:`TIMER`,label:e.timer?.prompt?.split(`
|
|
135
|
-
`)[0]||e.target,state:`running`,density:`panel`,counter:$v(e,n),title:Qv(e)},e.id)):r.map(t=>(0,X.jsx)(Qi,{kind:`COMMAND`,label:ty(t),state:`running`,density:`panel`,startedAt:t.createdAt,counter:iy(t),title:ry(t,n),onOpen:t.command?.monitor?()=>Vi(e.id,t.target,{label:ty(t)}):void 0},t.id))})}function zw(e,t){let n=e.trim();if(!(!n||n===t.trim()))return n}function Bw(e,t){let n=e.trim();return!n||n===t||n===`Untitled thread`||n===`Spinning up a thread…`?``:n}function Vw(e){return e.kind!==`session`||e.foreign||e.backend===`codex`||e.backend===`acp`||e.backend===`opencode`||e.claudeRuntime!==void 0&&e.claudeRuntime!==`broker`?{show:!1,enabled:!1,label:``}:e.runtime===`exited`||e.runtime===`none`?{show:!0,enabled:!1,label:`Resume this Claude thread to rename it with Claude`}:e.runtime===`spawning`?{show:!0,enabled:!1,label:`Rename with Claude once this thread has started`}:{show:!0,enabled:!0,label:`Rename with Claude — a fresh title from the opening request`}}function Hw(e,t){return new Promise(n=>{Fi(e,t,`Your worker process was restarted so it picks up frizz's current tooling (hooks and worker contract). Re-read whatever you left in your scratch directory, then continue exactly where you left off.`,{freshProcess:!0,onSuccess:()=>{K(`Restarting worker…`),n()},onRollback:()=>n(),failureToast:e=>`Restart failed: ${e.slice(0,80)}`})||n()})}function Uw(){return nr(R().data??null)}function Ww(e,t){return!t||e.kind!==`session`||e.foreign||e.backend===`codex`||e.backend===`acp`||e.backend===`opencode`?!1:e.runtime!==`exited`}function Gw({thread:e,onSnoozed:t}){let[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(``),[f,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(``),g=(0,q.useId)(),_=(0,q.useId)(),v=(0,q.useId)(),y=_i(e),b=e.snoozePrompt?.trim(),x=(0,q.useMemo)(()=>ds(new Date(Date.now()+6e4)),[c]),S=(0,q.useMemo)(()=>ji.map(e=>{let t=Vo(rs(e.value));return e.value===`tomorrow`?{value:e.value,label:`Tomorrow`,wake:t.replace(/^Tomorrow at /,``)}:{value:e.value,label:e.label,wake:t}}),[n]),C=(0,q.useMemo)(()=>Si(e),[n,e.runtime,e.wakesOnItsOwn]),w=!y&&hr(e),T=!!y||w,D=y?b?`Bumps ${Vo(y)}`:`Snoozed until ${Vo(y)}`:w?`Snoozed until activity`:null,O=D?b?`${D}\n${b}`:D:`Snooze`;async function A(){s(!0);try{await k.snoozeAwaitingBackground({slug:e.id,sessionId:e.sessionId??``}),K(`Snoozed until activity`),t?.()}catch(e){K((e instanceof Error?e.message:`Snooze failed`).slice(0,100))}finally{s(!1)}}async function j(n,r=null){s(!0);try{await k.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:n,prompt:n?r:null}),n?(K(`${r?`Bump scheduled`:`Snoozed`} · ${Vo(n)}`),t?.()):K(`Snooze cleared`),l(!1),h(``)}catch(e){let t=e instanceof Error?e.message:`Snooze failed`;K(t.slice(0,100)),h(t)}finally{s(!1)}}function N(){d(ds(new Date(y??rs(`1d`)))),p(e.snoozePrompt??``),h(``),l(!0)}function P(){let e=Mr(u);if(!e.ok){h(e.message);return}let t=f.trim();if(t.length>4e3){h(`Prompt is too long (${t.length}/${ci})`);return}j(e.until,t||null)}return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(gs,{open:n,onOpenChange:e=>{r(e),e||a(!0)},children:[(0,X.jsx)(Ot,{label:O,multiline:!!b,disabled:n||i,children:(0,X.jsx)(M,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,disabled:o,"data-snooze-menu":!0,"data-snoozed":T?`true`:`false`,"aria-label":D??`Snooze`,"aria-description":y&&b?b:void 0,onMouseDown:e=>e.preventDefault(),onBlur:()=>a(!1),onPointerLeave:()=>a(!1),className:`${T?oe.replace(/(^| )text-muted( |$)/,`$1text-attention-90$2`):oe} ${n?`bg-panel-2`:``}`,children:o?(0,X.jsx)(E,{size:14,strokeWidth:2,className:`animate-spin`}):(0,X.jsx)(we,{size:14,strokeWidth:2})})})}),(0,X.jsxs)(Lr,{align:`end`,children:[(0,X.jsx)(`div`,{className:`px-2.5 pb-1 pt-1.5 text-[11px] text-muted-60`,children:D??`Snooze`}),T&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(cs,{onSelect:()=>void j(null),icon:(0,X.jsx)(Ts,{size:12}),children:`Wake now`}),(0,X.jsx)(dn,{})]}),S.map(e=>(0,X.jsx)(cs,{onSelect:()=>void j(rs(e.value)),icon:(0,X.jsx)(we,{size:12}),children:(0,X.jsxs)(`span`,{"data-snooze-preset":e.value,className:`flex min-w-0 flex-1 items-center justify-between gap-6`,children:[(0,X.jsx)(`span`,{children:e.label}),(0,X.jsx)(`span`,{className:`text-[10.5px] text-muted-55`,children:e.wake})]})},e.value)),(0,X.jsx)(cs,{onSelect:()=>void A(),disabled:!C.enabled,children:(0,X.jsx)(Ot,{label:C.enabled?``:C.reason,side:`left`,disabled:C.enabled,children:(0,X.jsxs)(`span`,{"data-snooze-activity":!0,className:`-mx-2.5 -my-1.5 flex min-w-0 flex-1 items-center gap-2 px-2.5 py-1.5`,children:[(0,X.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:(0,X.jsx)(we,{size:12})}),(0,X.jsx)(`span`,{children:`Until activity`})]})})}),(0,X.jsx)(dn,{}),(0,X.jsx)(cs,{onSelect:N,children:`Custom time & prompt…`})]})]}),(0,X.jsx)(lt,{open:c,onOpenChange:e=>{o||l(e)},title:`Snooze thread`,className:`w-[360px] max-w-[92vw]`,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>l(!1),className:`button-outline rounded-md px-3 py-1.5 text-[12px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg disabled:opacity-45`,children:`Cancel`}),(0,X.jsxs)(`button`,{type:`submit`,form:v,disabled:o,className:`button-outline flex items-center gap-1.5 rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-opacity hover:opacity-90 disabled:opacity-45`,children:[o&&(0,X.jsx)(E,{size:12,className:`animate-spin`}),f.trim()?`Snooze & bump`:`Snooze`]})]}),children:(0,X.jsxs)(`form`,{id:v,className:`flex flex-col gap-2.5 p-4`,onSubmit:e=>{e.preventDefault(),P()},children:[(0,X.jsx)(`label`,{htmlFor:g,className:`text-[11px] font-medium text-muted`,children:`Wake at this local time`}),(0,X.jsx)(`input`,{id:g,type:`datetime-local`,required:!0,min:x,value:u,onChange:e=>{d(e.target.value),h(``)},className:`w-full rounded-md border border-border bg-bg px-2.5 py-2 text-[13px] text-fg outline-none focus:border-accent`}),(0,X.jsx)(`p`,{className:`text-[10.5px] text-muted-65`,children:`Stored as an exact instant; shown here in your browser’s local time zone.`}),(0,X.jsxs)(`label`,{htmlFor:_,className:`mt-1 text-[11px] font-medium text-muted`,children:[`Then send this prompt `,(0,X.jsx)(`span`,{className:`font-normal text-muted-55`,children:`(optional)`})]}),(0,X.jsx)(`textarea`,{id:_,"data-1p-ignore":!0,autoFocus:!0,rows:3,maxLength:ci,placeholder:`e.g. Check whether CI went green and land it if so.`,value:f,onChange:e=>{p(e.target.value),h(``)},onKeyDown:e=>{Dr({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),P())},className:`w-full resize-y rounded-md border border-border bg-bg px-2.5 py-2 text-[13px] leading-5 text-fg outline-none placeholder:text-muted-40 focus:border-accent`}),(0,X.jsx)(`p`,{className:`min-h-4 text-[10.5px] text-muted-65`,children:f.trim()?`frizz will resume this thread with the prompt at the wake time.`:`Leave empty to just bring the card back to your queue.`}),m&&(0,X.jsx)(`p`,{role:`alert`,className:`text-[11px] text-danger`,children:m})]})})]})}function Kw({thread:e,onArchived:t,onDismissCancel:n,onSnoozed:r}){let i=F_(e);return i.lifecycle?(0,X.jsxs)(`span`,{"data-thread-lifecycle":!0,role:`group`,"aria-label":`Thread lifecycle actions`,className:`flex shrink-0 items-center gap-0.5`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,"data-lifecycle-rule":!0,className:`mx-2.5 h-4 w-px shrink-0 bg-border`}),i.done?(0,X.jsx)(qw,{}):(0,X.jsxs)(X.Fragment,{children:[i.snooze&&(0,X.jsx)(Gw,{thread:e,onSnoozed:r}),(0,X.jsx)(Yw,{thread:e,onArchived:t,onDismissCancel:n,iconOnly:!0})]})]}):null}function qw(){return(0,X.jsx)(Jw,{"data-thread-done":``,check:!0,tooltip:`Marked done — send a message to reopen it`,children:`Done`})}function Jw({check:e=!1,tooltip:t,children:n,...r}){return(0,X.jsx)(Ot,{label:t,children:(0,X.jsxs)(`span`,{...r,"aria-label":t,className:`flex h-7 items-center gap-1 rounded-md px-2 text-[12px] font-medium text-muted`,children:[e&&(0,X.jsx)(v,{size:12}),n]})})}function Yw({thread:e,onArchived:t,onDismissCancel:n,className:r=`rounded-md border border-border-strong bg-panel-2/60 px-2.5 py-1 text-[12px] text-fg/80 hover:bg-panel-2 hover:text-fg`,iconClassName:i=``,iconSize:a=12,iconOnly:o=!1}){let[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(void 0),p=(r,i)=>{c(!0),i&&t?.(),(r||I_(e))&&wr(e.id),k.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:r}).then(r=>{if(r.needsConfirmation){zi(e.id),i&&n?.(),f(r.hold),u(!0),c(!1);return}u(!1),_(`Done`,e),i||t?.()}).catch(t=>{zi(e.id),i&&n?.(),K(`Couldn’t finish: ${t.message.slice(0,80)}`),c(!1)})},m=!!t&&!!n&&I_(e);return(0,X.jsxs)(X.Fragment,{children:[o?(0,X.jsx)(Ot,{label:`Mark as done`,children:(0,X.jsx)(`button`,{type:`button`,onClick:()=>p(!1,m),disabled:s,"aria-label":`Mark as done`,onMouseDown:e=>e.preventDefault(),className:oe,children:(0,X.jsx)(v,{size:15,strokeWidth:2})})}):(0,X.jsxs)(`button`,{type:`button`,onClick:()=>p(!1,m),disabled:s,"aria-label":`Mark as done`,title:`Mark as done`,onMouseDown:e=>e.preventDefault(),className:`flex items-center gap-1 font-medium outline-none transition-colors focus-visible:ring-1 focus-visible:ring-focus-ink-60 disabled:opacity-45 ${r}`,children:[(0,X.jsx)(v,{size:a,className:i}),`Mark as done`]}),(0,X.jsx)(lt,{open:l,onOpenChange:e=>{s||u(e)},title:d?.cutOff?`Mark an unfinished thread done?`:`End this session?`,className:`w-[390px] max-w-[92vw]`,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,disabled:s,onClick:()=>u(!1),className:`button-outline rounded-md px-3 py-1.5 text-[12px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg disabled:opacity-45`,children:`Cancel`}),(0,X.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>p(!0,!1),className:`button-outline flex items-center gap-1.5 rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-opacity hover:opacity-90 disabled:opacity-45`,children:[s&&(0,X.jsx)(E,{size:12,className:`animate-spin`}),d?.cutOff?`Mark done anyway`:`End session & mark done`]})]}),children:(0,X.jsx)(Xw,{hold:d})})]})}function Xw({hold:e}){let t=L_(e);return(0,X.jsxs)(`div`,{"data-completion-hold":!0,className:`flex flex-col gap-2 p-4 text-[12px] leading-relaxed text-muted`,children:[(0,X.jsx)(`p`,{children:t.lead}),t.groups.map(e=>(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-fg/70`,children:e.heading}),(0,X.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[e.items.map((e,t)=>(0,X.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:gt,children:`⤷`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate text-fg/80`,children:e.label}),e.stale&&(0,X.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted-60`,children:`no recent output`})]},`${e.label}-${t}`)),e.overflow>0&&(0,X.jsxs)(`li`,{className:`pl-[15px] text-muted-60`,children:[`+`,e.overflow,` more`]})]})]},e.kind)),(0,X.jsx)(`p`,{children:t.trailer})]})}function Zw({slug:e,onClose:t,onArchived:n,initialView:r=`actions`}){let i=Br(W),a=Qr(i.board,e),[o,s]=(0,q.useState)(r),c=Be(t);if((0,q.useEffect)(()=>{i.board&&!a&&c()},[i.board,a,c]),!a)return null;let l=Lo(a);return(0,X.jsx)(KS,{title:`Thread actions: ${l}`,onRequestClose:()=>c(),dataAttr:`data-thread-actions-sheet`,children:o===`actions`?(0,X.jsx)(Qw,{thread:a,title:l,setView:s,dismiss:c,onArchived:n}):o===`snooze`?(0,X.jsx)(eT,{thread:a,back:()=>s(`actions`),custom:()=>s(`snooze-custom`),dismiss:c}):o===`snooze-custom`?(0,X.jsx)(tT,{thread:a,back:()=>s(`snooze`),dismiss:c}):o===`goal`?(0,X.jsx)(nT,{thread:a,back:()=>s(`actions`)}):o===`todos`?(0,X.jsx)(rT,{thread:a,back:()=>s(`actions`)}):o===`files`?(0,X.jsx)(iT,{thread:a,back:r===`files`?void 0:()=>s(`actions`),dismiss:c}):(0,X.jsx)(sT,{thread:a,back:()=>s(`actions`),dismiss:c})})}function Qw({thread:e,title:t,setView:n,dismiss:r,onArchived:i}){let a=G(),o=Uw(),s=Br(va).snoozePreset,c=F_(e),l=e.kind===`session`&&e.foreign!==!0,d=_i(e),f=e.recurringPrompt?.stopHook===!0||e.recurringPrompt?.heartbeat===!0||e.recurringPrompt?.postCompaction===!0,p=e.links??[],m=e.humanTodos??[],h=e.runtime===`running`||e.runtime===`spawning`,g=l&&ca(e),_=Ww(e,o),v=cT(e),y=[ia(e.context),v].filter(Boolean).join(` · `);return(0,X.jsxs)(`div`,{"data-thread-actions-list":!0,children:[(0,X.jsx)(dT,{children:t}),c.snooze&&(0,X.jsx)(uT,{data:`snooze`,icon:(0,X.jsx)(we,{size:19}),label:`Snooze`,value:d?Vo(d):on(s),chevron:!0,onClick:()=>n(`snooze`)}),l&&(0,X.jsx)(uT,{data:`goal`,icon:(0,X.jsx)(WC,{size:19,className:f?`text-attention-90`:void 0}),label:`Goal`,value:f?`on`:`off`,chevron:!0,onClick:()=>n(`goal`)}),m.length>0&&(0,X.jsx)(uT,{data:`todos`,icon:(0,X.jsx)(Gs,{size:19}),label:`To-do`,value:String(m.filter(e=>!e.done).length),chevron:!0,onClick:()=>n(`todos`)}),p.length>0&&(0,X.jsx)(uT,{data:`files`,icon:(0,X.jsx)(u,{size:19}),label:`Files and links`,value:String(p.length),chevron:!0,onClick:()=>n(`files`)}),h&&c.archive&&(0,X.jsx)(Yw,{thread:e,iconSize:19,iconClassName:`shrink-0 text-muted`,onArchived:()=>r(i),className:`${lT} !gap-[14px] !font-normal`}),(0,X.jsx)(`div`,{className:`my-1 h-px bg-border`}),l&&(0,X.jsx)(uT,{data:`rename`,icon:(0,X.jsx)(an,{size:19}),label:`Rename`,onClick:()=>n(`rename`)}),(0,X.jsx)(uT,{data:`copy-link`,icon:(0,X.jsx)(ut,{size:19}),label:`Copy link`,onClick:()=>{let t=new URL(Lt(e.id),location.origin).href;r(()=>{Xo(t).then(()=>K(`Link copied`)).catch(e=>K(`Couldn’t copy: ${e.message.slice(0,80)}`))})}}),g&&(0,X.jsx)(uT,{data:`retry`,icon:(0,X.jsx)(us,{size:19}),label:`Retry`,onClick:()=>r(()=>void Ca(a,e.id))}),_&&(0,X.jsx)(uT,{data:`restart-worker`,icon:(0,X.jsx)(jr,{size:19}),label:`Restart worker`,onClick:()=>r(()=>void Hw(a,e.id))}),y&&(0,X.jsx)(`div`,{"data-thread-actions-foot":!0,className:`px-[18px] pt-2.5 text-[12.5px] leading-[17px] text-muted`,children:y})]})}function $w(e,t){let[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(``);async function o(n,i=null){r(!0),a(``);try{await k.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:n,prompt:n?i:null}),t(()=>K(n?`${i?`Bump scheduled`:`Snoozed`} · ${Vo(n)}`:`Snooze cleared`))}catch(e){let t=e instanceof Error?e.message:`Snooze failed`;K(t.slice(0,100)),a(t)}finally{r(!1)}}return{busy:n,error:i,setError:a,apply:o}}function eT({thread:e,back:t,custom:n,dismiss:r}){let i=Br(va).snoozePreset,a=_i(e),{busy:o,apply:s}=$w(e,r),c=e=>{va.snoozePreset=e,s(rs(e))};return(0,X.jsxs)(`div`,{"data-thread-actions-snooze":!0,children:[(0,X.jsx)(fT,{back:t,children:`Snooze`}),a&&(0,X.jsxs)(`p`,{className:`px-[18px] pb-2 text-[13px] text-muted`,children:[`Snoozed until `,Vo(a).replace(/^(Today|Tomorrow)/,e=>e.toLowerCase())]}),ji.map(e=>(0,X.jsx)(uT,{data:`snooze-${e.value}`,disabled:o,icon:(0,X.jsx)(we,{size:19}),label:e.label,value:e.detail,trailing:e.value===i?(0,X.jsx)(v,{size:16,className:`text-fg/80`}):(0,X.jsx)(`span`,{className:`w-4`}),onClick:()=>c(e.value)},e.value)),(0,X.jsx)(`div`,{className:`my-1 h-px bg-border`}),(0,X.jsx)(uT,{data:`snooze-custom`,disabled:o,icon:(0,X.jsx)(an,{size:19}),label:`Custom time & prompt…`,chevron:!0,onClick:n}),a&&(0,X.jsx)(uT,{data:`snooze-wake`,disabled:o,icon:(0,X.jsx)(us,{size:19}),label:`Wake now`,onClick:()=>void s(null)})]})}function tT({thread:e,back:t,dismiss:n}){let r=Br(va).snoozePreset,i=_i(e),{busy:a,error:o,setError:s,apply:c}=$w(e,n),[l,u]=(0,q.useState)(()=>ds(new Date(i??rs(r)))),[d,f]=(0,q.useState)(e.snoozePrompt??``),p=(0,q.useMemo)(()=>ds(new Date(Date.now()+6e4)),[]),m=(0,q.useId)(),h=(0,q.useId)(),g=()=>{let e=Mr(l);if(!e.ok)return s(e.message);let t=d.trim();if(t.length>4e3)return s(`Prompt is too long (${t.length}/${ci})`);c(e.until,t||null)};return(0,X.jsxs)(`form`,{"data-thread-actions-snooze-custom":!0,className:`flex flex-col`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,X.jsx)(fT,{back:t,children:`Custom snooze`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 px-[18px]`,children:[(0,X.jsx)(`label`,{htmlFor:m,className:`text-[13px] font-medium text-muted`,children:`Wake at this local time`}),(0,X.jsx)(`input`,{id:m,type:`datetime-local`,required:!0,min:p,value:l,onChange:e=>{u(e.target.value),s(``)},className:`h-11 w-full rounded-lg border border-border bg-bg px-3 text-[16px] text-fg outline-none focus:border-border-strong`}),(0,X.jsxs)(`label`,{htmlFor:h,className:`mt-2 text-[13px] font-medium text-muted`,children:[`Then send this prompt `,(0,X.jsx)(`span`,{className:`font-normal text-muted-70`,children:`(optional)`})]}),(0,X.jsx)(`textarea`,{id:h,"data-1p-ignore":!0,rows:3,maxLength:ci,placeholder:`e.g. Check whether CI went green and land it if so.`,value:d,onChange:e=>{f(e.target.value),s(``)},className:`w-full resize-none rounded-lg border border-border bg-bg px-3 py-2 text-[16px] leading-[22px] text-fg outline-none placeholder:text-muted-50 focus:border-border-strong`}),(0,X.jsx)(`p`,{className:`text-[12.5px] text-muted`,children:d.trim()?`Frizz will resume this thread with the prompt at the wake time.`:`Leave it empty to just bring the thread back to your queue.`}),o&&(0,X.jsx)(`p`,{role:`alert`,className:`text-[13px] text-danger`,children:o}),(0,X.jsxs)(`button`,{type:`submit`,disabled:a,className:`mt-1 flex h-[46px] items-center justify-center gap-2 rounded-xl bg-fg text-[15.5px] font-semibold text-bg outline-none disabled:opacity-45`,children:[a&&(0,X.jsx)(E,{size:16,className:`animate-spin`}),d.trim()?`Snooze and bump`:`Snooze`]})]})]})}function nT({thread:e,back:t}){return(0,X.jsxs)(`div`,{"data-thread-actions-goal":!0,children:[(0,X.jsx)(fT,{back:t,children:`Goal`}),(0,X.jsx)(`div`,{className:`px-[18px] text-[13.5px] leading-relaxed text-fg [&_input]:!text-[16px] [&_textarea]:!min-h-[6rem] [&_textarea]:!text-[16px] [&_textarea]:!leading-[22px]`,children:(0,X.jsx)(iw,{thread:e,armed:e.recurringPrompt,close:t,heading:!1})})]})}function rT({thread:e,back:t}){return(0,X.jsxs)(`div`,{"data-thread-actions-todos":!0,children:[(0,X.jsx)(fT,{back:t,count:(e.humanTodos??[]).filter(e=>!e.done).length,children:`To-do`}),(0,X.jsx)(`div`,{className:`px-[18px] pb-3 text-[14px] leading-[21px]`,children:(0,X.jsx)(iv,{thread:e,sends:!0})})]})}function iT({thread:e,back:t,dismiss:n}){let r=[...e.links??[]].reverse();return(0,X.jsxs)(`div`,{"data-thread-actions-files":!0,children:[t?(0,X.jsx)(fT,{back:t,count:r.length,children:`Files and links`}):(0,X.jsx)(dT,{count:r.length,children:`Files and links`}),r.length===0&&(0,X.jsx)(`p`,{className:`px-[18px] pb-2 text-[14px] text-muted`,children:`Nothing registered yet.`}),r.map(e=>(0,X.jsx)(aT,{link:e,dismiss:n},e.id))]})}function aT({link:e,dismiss:t}){let n=e.kind===`link`,r=n&&mt(e.target),i=Br(W).board?.projectDir,a=n?r?`${m(e.target)} — not reachable from this phone`:m(e.target):oT(e.target,i),o=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex h-[21px] w-[19px] shrink-0 items-center justify-center text-muted`,children:n?(0,X.jsx)(Ls,{size:19}):(0,X.jsx)(u,{size:19})}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{"data-link-label":!0,className:`block truncate text-[15.5px] leading-[21px] text-fg`,children:e.label}),(0,X.jsx)(`span`,{"data-link-destination":!0,className:`block truncate text-[12.5px] leading-[17px] text-muted`,children:a})]}),!r&&(0,X.jsx)(vs,{size:15,className:`shrink-0 self-center text-muted-70`})]}),s=`flex min-h-[56px] w-full items-start gap-[14px] px-[18px] py-[9px] text-left outline-none focus-visible:bg-hover`;return r?(0,X.jsx)(`div`,{"data-thread-link":e.id,"data-link-unreachable":!0,title:e.target,className:s,children:o}):n?(0,X.jsx)(`a`,{"data-thread-link":e.id,title:e.target,href:e.target,target:`_blank`,rel:`noopener noreferrer`,className:`${s} active:bg-hover`,onClick:()=>t(),children:o}):(0,X.jsx)(`button`,{type:`button`,"data-thread-link":e.id,title:e.target,className:`${s} active:bg-hover`,onClick:()=>t(()=>N(e.target)),children:o})}function oT(e,t){if(t&&e.startsWith(`${t.replace(/\/+$/,``)}/`))return e.slice(t.replace(/\/+$/,``).length+1);let n=e.split(`/`).filter(Boolean);return n.length>2?`…/${n.slice(-2).join(`/`)}`:e}function sT({thread:e,back:t,dismiss:n}){let r=Lo(e),[i,a]=(0,q.useState)(()=>Bw(r,e.id)),o=(0,q.useRef)(null),s=Yr({mutationFn:t=>k.renameThread({slug:e.id,title:t})}),c=Yr({mutationFn:()=>k.aiRenameThread({slug:e.id})}),l=Vw(e);(0,q.useEffect)(()=>{let e=requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>cancelAnimationFrame(e)},[]);let u=()=>{let e=zw(i,r);if(!e)return t();s.mutate(e,{onSuccess:()=>n(()=>K(`Thread renamed`)),onError:e=>K(e instanceof Error?e.message:`Could not rename thread`)})};return(0,X.jsxs)(`form`,{"data-thread-actions-rename":!0,onSubmit:e=>{e.preventDefault(),u()},children:[(0,X.jsx)(fT,{back:t,children:`Rename`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 px-[18px]`,children:[(0,X.jsx)(`input`,{ref:o,"aria-label":`Thread title`,value:i,maxLength:200,onChange:e=>a(e.target.value),"data-claims-escape":!0,className:`h-11 w-full rounded-lg border border-border bg-bg px-3 text-[16px] text-fg outline-none focus:border-border-strong`}),(0,X.jsxs)(`button`,{type:`submit`,disabled:s.isPending,className:`flex h-[46px] items-center justify-center gap-2 rounded-xl bg-fg text-[15.5px] font-semibold text-bg outline-none disabled:opacity-45`,children:[s.isPending&&(0,X.jsx)(E,{size:16,className:`animate-spin`}),`Save`]})]}),l.show&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`mt-3 mb-1 h-px bg-border`}),(0,X.jsx)(uT,{data:`ai-rename`,disabled:c.isPending,icon:c.isPending?(0,X.jsx)(E,{size:19,className:`animate-spin`}):(0,X.jsx)(tc,{size:19}),label:c.isPending?`Claude is naming it…`:`Rename with Claude`,onClick:()=>{if(!l.enabled)return K(l.label);c.mutate(void 0,{onSuccess:({title:e})=>n(()=>K(`Renamed to “${e}”`)),onError:e=>K(e instanceof Error?e.message:`Could not rename with Claude`,{duration:7e3})})}})]})]})}function cT(e){let t=!!(e&&!e.foreign&&e.kind===`session`),n=ie(),r=fi({queryKey:[`threadProfileOptions`,e?.id??``],queryFn:()=>k.threadProfileOptions({slug:e.id}),enabled:t&&!n,staleTime:5e3});if(!e)return null;let i=e.model?.trim(),a=e.effort?.trim();if(!i&&!a&&!e.runningModelLabel)return null;let o=Ji([{id:e.backend??`claude`,label:``,options:r.data?.options??[]}],{model:i,effort:a},``,e.runningModelLabel);return[[o.name,o.edition].filter(Boolean).join(` `)||null,Xi(o.effort)].filter(Boolean).join(` · `)||null}var lT=`flex min-h-[50px] w-full items-center gap-[14px] px-[18px] text-left text-[15.5px] leading-[21px] text-fg outline-none transition-colors active:bg-hover focus-visible:bg-hover disabled:opacity-45`;function uT({icon:e,label:t,value:n,chevron:r,trailing:i,onClick:a,disabled:o,data:s}){return(0,X.jsxs)(`button`,{type:`button`,"data-thread-action":s,disabled:o,onClick:a,className:lT,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`flex w-[19px] shrink-0 items-center justify-center text-muted`,children:e}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),(n||r||i)&&(0,X.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 text-[14px] text-muted`,children:[n,r&&(0,X.jsx)(vs,{size:15,className:`text-muted-70`}),i]})]})}function dT({children:e,count:t}){return(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2 px-[18px] pb-2.5 pt-1`,children:[(0,X.jsx)(`span`,{"data-thread-actions-title":!0,className:`min-w-0 flex-1 truncate text-[16px] font-semibold leading-[22px]`,children:e}),t!==void 0&&(0,X.jsx)(`span`,{className:`shrink-0 text-[12.5px] text-muted`,children:t})]})}function fT({children:e,back:t,count:n}){return(0,X.jsxs)(`div`,{className:`flex items-center gap-0.5 pb-1 pl-[6px] pr-[18px]`,children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":`Back`,onClick:t,className:`flex size-11 shrink-0 items-center justify-center rounded-full text-fg/85 outline-none active:bg-hover focus-visible:bg-hover`,children:(0,X.jsx)(js,{size:21})}),(0,X.jsx)(`span`,{"data-thread-actions-title":!0,className:`min-w-0 flex-1 truncate text-[16px] font-semibold leading-[22px]`,children:e}),n!==void 0&&(0,X.jsx)(`span`,{className:`shrink-0 text-[12.5px] text-muted`,children:n})]})}function pT({slug:e,onClose:t}){let n=Ne(e),[r,i]=(0,q.useState)(!1),a=da(),o=rt(e,{poll:n?.runtime===`running`||n?.runtime===`spawning`}),s=(0,q.useMemo)(()=>fe(o.data?.messages??[]),[o.data]),c=cT(n);if(!n)return null;let l=Rt(n),u=St(n,l,s,a),d=l===`needs-you`?`font-semibold text-accent`:l===`working`?`font-semibold text-live`:``,f=Lo(n);return(0,X.jsxs)(`header`,{"data-thread-header":!0,"data-mobile-thread-header":!0,className:`flex min-h-14 shrink-0 items-center gap-0.5 border-b border-border bg-panel py-1 pl-1 pr-[5px]`,children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":`Back`,"data-mobile-thread-back":!0,onClick:()=>{io()?history.back():t()},className:`flex size-11 shrink-0 items-center justify-center rounded-full text-fg/90 outline-none active:bg-hover focus-visible:bg-hover`,children:(0,X.jsx)(On,{size:21,strokeWidth:2.1})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 pl-0.5 leading-[1.25]`,children:[(0,X.jsx)(`div`,{"data-mobile-thread-title":!0,className:`truncate text-[16.5px] font-semibold tracking-[-0.01em]`,title:f,children:f}),(0,X.jsxs)(`div`,{"data-mobile-thread-subtitle":!0,"data-state":l,className:`truncate text-[13px] text-muted`,children:[(0,X.jsx)(`span`,{className:d,children:At[l]}),u&&(0,X.jsxs)(X.Fragment,{children:[` · `,u]}),c&&(0,X.jsxs)(X.Fragment,{children:[` · `,c]})]})]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Thread actions`,"aria-haspopup":`dialog`,"aria-expanded":r,"data-mobile-thread-more":!0,onClick:()=>i(!0),className:`flex size-11 shrink-0 items-center justify-center rounded-full text-fg/90 outline-none active:bg-hover focus-visible:bg-hover`,children:(0,X.jsx)(Ki,{size:21,strokeWidth:2.1})}),r&&(0,X.jsx)(Zw,{slug:e,onClose:()=>i(!1),onArchived:()=>LC(e)})]})}function mT({thread:e}){let t=G(),[n,r]=(0,q.useState)(!1);return Ww(e,Uw())?(0,X.jsx)(Ot,{label:`Restart worker — same conversation, fresh process on current tooling`,side:`top`,children:(0,X.jsx)(`button`,{type:`button`,disabled:n,"aria-label":`Restart worker`,onMouseDown:e=>e.preventDefault(),onClick:()=>{r(!0),Hw(t,e.id).finally(()=>r(!1))},className:`${oe} mr-[2px]`,children:n?(0,X.jsx)(E,{size:14,strokeWidth:2,className:`animate-spin`}):(0,X.jsx)(jr,{size:14,strokeWidth:2})})}):null}function hT(e){return Mt(e)??Li(`/`)}function gT(e){Sr(hT(e),{viewTransition:!ba()})}function _T({slug:e,label:t=`Exit fullscreen`}){let n=hT(e);function r(t){if(xt(t)){if(t.preventDefault(),Eo()){a(!1);return}gT(e)}}return(0,X.jsx)(Ot,{label:t,children:(0,X.jsx)(`a`,{href:n,"aria-label":t,"data-standalone-return":!0,onMouseDown:e=>e.preventDefault(),onClick:r,className:oe,children:(0,X.jsx)(Xs,{size:14})})})}function vT({thread:e,expand:t,collapse:n,onDoc:r,onDone:i,onCollapse:a,collapsed:o,doneBusy:s,onStatusMutate:c,onStatusApplied:l,onStatusFailed:d}){let f=e.kind===`session`;return(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[a&&(0,X.jsx)(bT,{label:o?`Expand`:`Collapse`,icon:o?Ns:Ms,size:13,onClick:a}),(0,X.jsx)(mT,{thread:e}),r&&(0,X.jsx)(bT,{label:`Frizz document`,icon:u,size:14,onClick:r}),t&&(0,X.jsx)(yn,{slug:e.id}),n&&(0,X.jsx)(_T,{slug:e.id}),f?ca(e)?(0,X.jsx)(yT,{slug:e.id}):null:(0,X.jsx)(`div`,{className:`ml-1`,children:(0,X.jsx)(Ko,{slug:e.id,onDone:i,doneBusy:s,onMutateStart:c,onApplied:l,onFailed:d})})]})}function yT({slug:e}){let t=G(),[n,r]=(0,q.useState)(!1);return(0,X.jsx)(Ot,{label:`Retry — resume this session where it left off`,children:(0,X.jsxs)(`button`,{onClick:()=>{r(!0),Ca(t,e).finally(()=>r(!1))},disabled:n,"aria-label":`Retry exited session`,"data-header-pill":!0,onMouseDown:e=>e.preventDefault(),className:`ml-1 flex items-center gap-1.5 rounded-md border border-accent/45 bg-accent/10 px-2.5 py-1 text-[12px] font-medium text-accent outline-none transition-colors hover:bg-accent/15 disabled:opacity-50`,children:[n?(0,X.jsx)(E,{size:12,className:`animate-spin`}):(0,X.jsx)(us,{size:12}),`Retry`]})})}function bT({label:e,icon:t,size:n,busy:r,...i}){return(0,X.jsx)(Ot,{label:e,children:(0,X.jsx)(`button`,{...i,"aria-label":e,onMouseDown:e=>e.preventDefault(),className:oe,children:r?(0,X.jsx)(E,{size:n,strokeWidth:2,className:`animate-spin`}):(0,X.jsx)(t,{size:n,strokeWidth:2})})})}var xT=1.25,ST=7.5-xT/2,CT=2*Math.PI*ST;function wT(e,t){return Math.max(0,Math.min(100,Math.floor(e/t*100)))}var TT=150;function ET(e){return!!e.context&&e.context.window>0}function DT({thread:e}){let t=e.context;if(!t||!ET(e))return null;let n=MT(e,t.tokens);return(0,X.jsx)(OT,{context:t,action:Ge(e)?t=>(0,X.jsx)(NT,{thread:e,compacting:n,onRequested:t}):void 0})}function OT({context:e,action:t}){let[n,r]=(0,q.useState)(!1),i=(0,q.useRef)(void 0),a=(0,q.useRef)(null),o=(0,q.useRef)(null);if((0,q.useEffect)(()=>()=>clearTimeout(i.current),[]),!(e.window>0))return null;let s=()=>{clearTimeout(i.current),r(!0)},c=()=>{clearTimeout(i.current),i.current=setTimeout(()=>r(!1),TT)},l=e=>{a.current?.contains(e.target)&&e.preventDefault()},u=wT(e.tokens,e.window),d=Math.max(0,Math.min(1,e.tokens/e.window)),f=`Context ${u}% full`,p=`${e.tokens.toLocaleString()} of ${e.window.toLocaleString()} tokens`;return(0,X.jsxs)(it,{open:n,onOpenChange:r,children:[(0,X.jsx)(Qt,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"data-context-meter":!0,"data-context-percent":u,"aria-label":`${f}\n${p}`,"aria-haspopup":`dialog`,"aria-expanded":n,onMouseEnter:s,onMouseLeave:c,onFocus:s,ref:a,onClick:e=>{e.stopPropagation(),s(),e.detail===0&&requestAnimationFrame(()=>o.current?.querySelector(`button:not(:disabled)`)?.focus())},className:`flex shrink-0 items-baseline gap-1 rounded-sm outline-none transition-colors hover:text-fg/85 focus-visible:ring-1 focus-visible:ring-focus-ink-60 ${n?`text-fg/85`:``}`,children:[(0,X.jsxs)(`svg`,{viewBox:`0 0 16 16`,className:`-mt-[1em] h-[1.05em] w-[1.05em] shrink-0 self-baseline translate-y-[calc(0.525em_-_0.5cap)]`,"aria-hidden":!0,children:[(0,X.jsx)(`circle`,{cx:`8`,cy:`8`,r:ST,fill:`none`,stroke:`currentColor`,strokeOpacity:.3,strokeWidth:xT}),(0,X.jsx)(`circle`,{cx:`8`,cy:`8`,r:ST,fill:`none`,stroke:`currentColor`,strokeWidth:xT,strokeDasharray:`${CT*d} ${CT}`,transform:`rotate(-90 8 8)`})]}),(0,X.jsxs)(`span`,{children:[u,`% context`]})]})}),(0,X.jsxs)(bs,{side:`bottom`,align:`start`,sideOffset:5,ref:o,"data-context-panel":!0,"aria-label":f,onInteractOutside:e=>l({target:e.detail.originalEvent.target,preventDefault:()=>e.preventDefault()}),onMouseEnter:s,onMouseLeave:c,onOpenAutoFocus:e=>e.preventDefault(),onClick:e=>e.stopPropagation(),className:`flex w-max max-w-[min(22rem,calc(100vw-1.5rem))] flex-col gap-2 px-3 py-2 text-[11px] leading-relaxed text-fg`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{children:f}),(0,X.jsx)(`span`,{className:`text-muted`,children:p})]}),t?.(()=>r(!1))]})]})}function kT(e){return e.runtime===`running`||e.runtime===`spawning`||e.runtime===`perm-prompt`}var AT=new Map,jT=2*6e4;function MT(e,t){let n=e.sessionId;if(!n)return!1;let r=AT.get(n);return r?!kT(e)&&(r.tokens!==t||e.lastActivityAt!==r.activity)||Date.now()-r.at>jT?(AT.delete(n),!1):!0:!1}function NT({thread:e,compacting:t,onRequested:n}){let[r,i]=(0,q.useState)(!1),a=e.context?.tokens??0,o=kT(e)&&!t;return(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsxs)(`button`,{type:`button`,"data-compact-now":!0,disabled:o||r||t||!e.sessionId,onClick:()=>{let t=e.sessionId;t&&(i(!0),k.compactThread({slug:e.id,sessionId:t}).then(()=>{AT.set(t,{tokens:a,activity:e.lastActivityAt,at:Date.now()}),K(`Compacting context`),n()}).catch(e=>K(`Couldn’t compact: ${e.message.slice(0,80)}`)).finally(()=>i(!1)))},onMouseDown:e=>e.preventDefault(),className:`flex items-center justify-center gap-1 rounded-md border border-border-strong bg-panel-2/60 px-2.5 py-1 text-[12px] font-medium text-fg/80 outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60 disabled:opacity-45 disabled:hover:bg-panel-2/60 disabled:hover:text-fg/80`,children:[(r||t)&&(0,X.jsx)(E,{size:12,className:`animate-spin`}),t?`Compacting…`:`Compact now`]}),o&&(0,X.jsx)(`span`,{className:`text-muted`,children:`Available once the current turn ends`})]})}function PT({thread:e}){let t=de(e.id);return(0,X.jsx)(FT,{"data-thread-header-facts":``,lead:t?(0,X.jsx)(IT,{slug:t}):null,lastActiveAt:zr(e),fallbackAt:e.spawnedAt,reading:ET(e)?(0,X.jsx)(DT,{thread:e}):null})}function FT({lead:e,lastActiveAt:t,fallbackAt:n,reading:r,...i}){return(0,X.jsxs)(`div`,{...i,className:`mt-0.5 flex min-w-0 items-center gap-1.5 text-[11px] leading-tight text-muted-75 empty:hidden`,children:[e?(0,X.jsxs)(X.Fragment,{children:[e,(0,X.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-muted-45`,children:`·`})]}):null,(0,X.jsx)(je,{at:t,fallbackAt:n,className:`min-w-0 truncate`}),r?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`hidden shrink-0 text-muted-45 [time+&]:inline`,children:`·`}),r]}):null]})}function IT({slug:e}){let t=fi({queryKey:[`projectsList`],queryFn:()=>k.projectsList()}).data?.find(t=>t.slug===e),n=t?.name??e,r=De(e);function i(e){e.stopPropagation(),xt(e)&&(e.preventDefault(),Sr(r))}return(0,X.jsxs)(`a`,{href:r,"data-thread-project":e,title:`Open ${n}`,onClick:i,className:`flex min-w-0 shrink-0 items-center gap-1.5 rounded-sm font-medium text-fg/80 no-underline outline-none transition-colors hover:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:[t?(0,X.jsx)(br,{project:t,size:14}):null,(0,X.jsx)(`span`,{className:`truncate`,children:n})]})}function LT({thread:e,hidden:t=!1}){let n=Yr({mutationFn:()=>k.aiRenameThread({slug:e.id}),onSuccess:({title:e})=>K(`Renamed to “${e}”`),onError:e=>K(e instanceof Error?e.message:`Could not rename with Claude`,{duration:7e3})}),r=Vw(e);if(!r.show||t)return null;let i=n.isPending?`Claude is generating a title…`:n.error instanceof Error?n.error.message:r.label,a=n.isPending||!!n.error;return(0,X.jsx)(Ot,{label:i,children:(0,X.jsx)(`button`,{type:`button`,"data-ai-rename":!0,"aria-label":n.isPending?`Renaming with Claude`:r.label,"aria-busy":n.isPending,"aria-disabled":!r.enabled,onMouseDown:e=>e.preventDefault(),onClick:()=>{if(!n.isPending){if(!r.enabled){K(r.label);return}n.reset(),n.mutate()}},className:`title-refresh-offset -mx-[7px] -my-3 flex h-6 w-6 shrink-0 items-center justify-center rounded-md outline-none transition-[color,background-color,opacity] focus-visible:opacity-100 group-hover/thread-title:opacity-100 ${a?`opacity-100`:`opacity-0`} ${n.error?`text-danger hover:bg-danger-fill/10`:r.enabled?`text-muted hover:bg-hover-strong hover:text-fg`:`cursor-not-allowed text-muted-50 hover:bg-hover-strong`}`,children:n.isPending?(0,X.jsx)(E,{size:12,className:`animate-spin`}):(0,X.jsx)(tc,{size:12})})})}function RT({thread:e,className:t=``}){let n=e.id,r=Yr({mutationFn:e=>k.renameThread({slug:n,title:e})}),[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(``),c=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!i)return;let e=requestAnimationFrame(()=>{c.current?.focus(),c.current?.select()});return()=>cancelAnimationFrame(e)},[i]),(0,q.useEffect)(()=>{a(!1),s(``)},[n]);let l=e.kind===`session`&&e.foreign!==!0,u=Lo(e);function d(){a(!1),s(``)}function f(){let e=zw(o,u);if(a(!1),!e){s(``);return}r.mutate(e,{onSuccess:()=>{s(``),K(`Thread renamed`)},onError:t=>{s(e),a(!0),K(t instanceof Error?t.message:`Could not rename thread`)}})}return(0,X.jsxs)(`div`,{className:`group/thread-title flex min-w-0 items-center gap-2`,children:[i?(0,X.jsx)(`input`,{ref:c,"aria-label":`Thread title`,value:o,maxLength:200,onChange:e=>s(e.target.value),onBlur:f,"data-claims-escape":!0,onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),f()):e.key===`Escape`&&(e.preventDefault(),d())},className:`min-w-0 flex-1 -mx-1.5 -my-px rounded-md border border-border bg-elevated px-1.5 py-0 font-semibold text-[15px] text-fg outline-none focus:border-accent ${t}`}):l?(0,X.jsx)(`button`,{type:`button`,title:`Edit title`,"aria-label":`Edit thread title: ${u}`,disabled:r.isPending,onClick:()=>{s(Bw(u,n)),a(!0)},className:`min-w-0 max-w-full shrink truncate rounded px-0.5 -mx-0.5 font-semibold text-[15px] text-left outline-none transition-colors hover:bg-panel-2 focus-visible:ring-1 focus-visible:ring-focus-ink-60 disabled:cursor-not-allowed disabled:opacity-40 ${t}`,children:u}):(0,X.jsx)(`div`,{className:`min-w-0 max-w-full shrink truncate px-0.5 -mx-0.5 font-semibold text-[15px] ${t}`,title:u,children:u}),(0,X.jsx)(LT,{thread:e,hidden:i})]})}function zT(e){if(e.kind!==void 0||e.role!==`assistant`||e.text.trim())return;let t=e.parts??[],n=t.length>0?t.length===1&&t[0].kind===`tools`?t[0].tools:[]:e.tools??[],r=n.length===1?n[0]:void 0;return r?.agentCompletion?r:void 0}var BT={completed:`finished`,killed:`stopped`,failed:`failed`};function VT(e){let t=BT[e.agentStatus??`completed`],n=e.agentElapsedMs===void 0?void 0:Bn(e.agentElapsedMs);return{outcome:t,tail:`${t}${n?` · ${n}`:``}`}}var HT=e=>e===void 0?void 0:Qe(e),UT=e=>{if(e!==void 0)return Bn(e)||void 0};function WT(e){let{agentStatus:t,agentElapsedMs:n,liveState:r,liveElapsedMs:i,status:a,durationMs:o}=e;if(t){let e=t===`killed`,r=t===`failed`,i=HT(n);return{label:t===`completed`?void 0:BT[t],duration:UT(n),tone:r?`failed`:`muted`,title:`${e?`Stopped`:r?`Failed`:`Ran for`}${e||r?` after`:``} ${i??`an unknown time`}`}}if(r){let e=HT(i);return{label:void 0,duration:UT(i),tone:`muted`,title:r===`running`?`Working for ${e??`an unknown time`}`:`Dispatched ${e??`an unknown time`} ago`}}if(a===`pending`||a!==`failed`&&a!==`cancelled`)return null;let s=a===`failed`,c=a===`cancelled`,l=HT(o);return{label:c?BT.killed:s?BT.failed:void 0,duration:UT(o),tone:s?`failed`:`muted`,title:`${c?`Stopped after`:s?`Failed after`:`Ran for`} ${l??`an unknown time`}`}}var GT=`group flex min-w-0 items-baseline gap-1.5 rounded-sm text-left text-[11.5px] outline-none focus-visible:ring-1 focus-visible:ring-focus-ink-60`,KT=`${ct} -mt-[1em] self-baseline`,qT=`h-[1em] w-[1em] shrink-0 translate-y-[calc(0.5em_-_0.5cap)] text-muted-45`,JT=`group flex min-w-0 items-baseline gap-2 rounded-md px-2.5 py-1.5 text-left text-[12px] outline-none transition-colors hover:bg-hover-strong focus-visible:bg-hover-strong`;function YT({links:e}){return(0,X.jsx)(`div`,{"data-thread-links":!0,"aria-label":`Registered links`,className:`flex min-w-0 flex-col`,children:e.map(e=>{let t=e.kind===`link`,n=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:ir,children:(0,X.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,X.jsx)(t?Ls:u,{"aria-hidden":!0,className:`h-[1em] w-[1em] text-muted-60`})})}),(0,X.jsx)(`span`,{"data-link-label":!0,className:`min-w-0 shrink truncate text-fg/85 group-hover:text-fg`,children:e.label}),(0,X.jsx)(`span`,{"data-link-destination":!0,className:`font-mono-keep min-w-0 flex-1 truncate text-right text-[10.5px] text-muted-50`,children:t?e.target:e.target.split(`/`).pop()})]});return t?(0,X.jsx)(`a`,{"data-thread-link":e.id,href:e.target,target:`_blank`,rel:`noopener noreferrer`,title:e.target,className:JT,onClick:e=>e.stopPropagation(),children:n},e.id):(0,X.jsx)(`button`,{"data-thread-link":e.id,type:`button`,title:e.target,className:`${JT} cursor-pointer`,onClick:t=>{t.stopPropagation(),N(e.target)},children:n},e.id)})})}function XT({links:e,panel:t=!1}){return e.length?t?(0,X.jsx)(YT,{links:e}):(0,X.jsx)(`div`,{"data-thread-links":!0,"aria-label":`Registered links`,className:`mt-2 flex min-w-0 flex-col gap-0.5 border-t border-border pt-1.5`,children:e.map(e=>{let t=e.kind===`link`,n=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:gt,children:`⤷`}),(0,X.jsx)(`span`,{className:KT,children:(0,X.jsx)(t?Ls:u,{"aria-hidden":!0,className:qT})}),(0,X.jsx)(`span`,{"data-link-kind":!0,className:Re,children:t?`Link`:`File`}),(0,X.jsx)(`span`,{"data-link-label":!0,className:`min-w-0 flex-1 truncate text-muted-70 group-hover:text-fg/80 group-hover:underline`,children:e.label}),t&&(0,X.jsx)(`span`,{"data-link-destination":!0,className:`font-mono-keep ml-auto -mb-[0.5em] max-w-[45%] min-w-0 truncate text-right text-[10px] text-muted-45`,children:e.target})]});return t?(0,X.jsx)(`a`,{"data-thread-link":e.id,href:e.target,target:`_blank`,rel:`noopener noreferrer`,title:e.target,className:GT,onClick:e=>e.stopPropagation(),children:n},e.id):(0,X.jsx)(`button`,{"data-thread-link":e.id,type:`button`,title:e.target,className:`${GT} cursor-pointer`,onClick:t=>{t.stopPropagation(),N(e.target)},children:n},e.id)})}):null}var ZT=`text-[14px] leading-5 text-muted`,QT=`size-[1em] shrink-0 self-baseline -mt-[calc(1em_-_1cap)] translate-y-[calc(0.5em_-_0.5cap)] text-muted-70 transition-transform group-hover:text-fg`;function $T(e){return`${QT} ${e?`-mx-[0.208em] rotate-90`:`-mx-[0.333em]`}`}var $=q.createElement;function eE({payload:e}){return e.kind===`command-approval`?$(q.Fragment,null,$(`div`,{className:`text-[12px] text-muted`},`Command`),$(`div`,{className:`mt-0.5 break-words text-[13px] font-medium text-fg`},e.command.summary),e.command.workingDirectoryLabel?$(`div`,{className:`mt-1 break-all text-[10.5px] text-muted-70`},`Working directory: `,e.command.workingDirectoryLabel):null,$(tE,{label:`Redacted command preview`,text:e.command.preview}),e.command.actions?$(nE,{actions:e.command.actions}):null,e.capabilities?$(iE,{capabilities:e.capabilities}):null):e.kind===`file-approval`?$(q.Fragment,null,$(`div`,{className:`text-[12px] text-muted`},cE(e.operation)),$(`div`,{className:`mt-0.5 break-all font-mono-keep text-[12px] text-fg`},e.pathLabel),e.destinationLabel?$(`div`,{className:`mt-1 break-all font-mono-keep text-[11px] text-muted`},`→ `,e.destinationLabel):null,e.grantRootLabel?$(`section`,{"aria-label":`Requested session write root`,className:`mt-2.5 min-w-0 rounded-md border border-attention/35 bg-attention-fill/[0.06] px-2.5 py-2`},$(`h4`,{className:`text-[10px] font-medium uppercase tracking-[0.07em] text-attention-soft-80`},`Requested session write root`),$(`div`,{className:`mt-1 min-w-0 break-all font-mono-keep text-[10.5px] text-fg/85`},e.grantRootLabel),e.scopeLabel?$(`div`,{className:`mt-1.5 whitespace-pre-wrap break-words text-[10.5px] leading-snug text-attention-soft-75`},e.scopeLabel):null):null,e.diffPreview?$(tE,{label:`Plain-text diff preview`,text:e.diffPreview}):null,e.changes?$(rE,{changes:e.changes}):null):$(q.Fragment,null,e.preview?$(`pre`,{className:`max-h-64 max-w-full min-w-0 overflow-auto rounded-md border border-border/70 bg-bg/40 px-2.5 py-2 whitespace-pre-wrap break-words font-mono-keep text-[11.5px] leading-relaxed text-fg/90`},e.promptLabel?$(`span`,{className:`text-shell/90`},e.promptLabel):null,e.promptLabel?$(`span`,{className:`text-accent`},` ❯ `):null,e.preview):null,e.resourceLabel?$(`div`,{className:`mt-1 break-all text-[11px] text-muted`},`Resource: `,e.resourceLabel):null,e.workingDirectoryLabel?$(`div`,{className:`mt-1.5 break-all text-[10.5px] text-muted-70`},`Working directory: `,e.workingDirectoryLabel):null,e.scopeLabel?$(`div`,{className:`mt-2 whitespace-pre-wrap break-words text-[11px] leading-snug text-muted`},e.scopeLabel):null,e.capabilities?$(iE,{capabilities:e.capabilities}):null)}function tE({label:e,text:t}){return $(`details`,{className:`mt-2.5 min-w-0 rounded-md border border-border/70 bg-bg/35`,open:t.length<1200},$(`summary`,{className:`cursor-pointer px-2.5 py-2 text-[10.5px] text-muted outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-focus-ink-50`},e),$(`pre`,{className:`max-h-64 max-w-full min-w-0 overflow-auto border-t border-border/60 px-2.5 py-2 whitespace-pre-wrap break-words font-mono-keep text-[11px] leading-relaxed text-fg/80`},t))}function nE({actions:e}){return $(`section`,{"aria-label":`Parsed command actions`,className:`mt-3 min-w-0`},$(`h4`,{className:`text-[10px] font-medium uppercase tracking-[0.07em] text-muted-75`},`Parsed actions`),$(`ul`,{className:`mt-1.5 flex min-w-0 flex-col gap-2`},e.map((e,t)=>$(`li`,{key:t,className:`min-w-0 rounded-md border border-border/65 bg-bg/25 px-2.5 py-2`},$(`div`,{className:`text-[11px] font-medium text-fg/90`},sE(e.kind)),e.resourceLabel?$(`div`,{className:`mt-0.5 break-all font-mono-keep text-[10.5px] text-muted`},e.resourceLabel):null,e.queryLabel?$(`div`,{className:`mt-0.5 break-all text-[10.5px] text-muted`},`Query: `,e.queryLabel):null,$(tE,{label:`${sE(e.kind)} command detail`,text:e.commandPreview})))))}function rE({changes:e}){return $(`section`,{"aria-label":`Affected file changes`,className:`mt-3 min-w-0`},$(`h4`,{className:`text-[10px] font-medium uppercase tracking-[0.07em] text-muted-75`},`Affected changes`),$(`ol`,{className:`mt-1.5 flex min-w-0 flex-col gap-2`},e.map((e,t)=>$(`li`,{key:t,className:`min-w-0 rounded-md border border-border/65 bg-bg/25 px-2.5 py-2`},$(`div`,{className:`text-[11px] font-medium text-fg/90`},cE(e.operation)),$(`div`,{className:`mt-0.5 break-all font-mono-keep text-[10.5px] text-fg/80`},e.pathLabel),e.destinationLabel?$(`div`,{className:`mt-0.5 min-w-0 break-all font-mono-keep text-[10.5px] text-muted`},`→ `,e.destinationLabel):null,e.diffPreview?$(tE,{label:`${cE(e.operation)} plain-text diff`,text:e.diffPreview}):null))))}function iE({capabilities:e}){return $(`section`,{"aria-label":`Requested capabilities`,className:`mt-3 min-w-0`},$(`h4`,{className:`text-[10px] font-medium uppercase tracking-[0.07em] text-muted-75`},`Requested capabilities`),$(`ul`,{className:`mt-1.5 flex min-w-0 flex-col gap-2`},e.map((e,t)=>$(`li`,{key:t,className:`min-w-0 rounded-md border border-border/65 bg-bg/25 px-2.5 py-2`},$(aE,{capability:e})))))}function aE({capability:e}){if(e.kind===`network`){let t=e.enabled===!0?`Enable network access`:e.enabled===!1?`Disable network access`:`Network access request`;return $(q.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},t),e.hosts.length>0?$(oE,{label:`Hosts and protocols`,values:e.hosts}):null)}if(e.kind===`filesystem`){let t=e.access===`read`?`Read filesystem paths`:e.access===`write`?`Write filesystem paths`:`Deny filesystem paths`;return $(q.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},t),$(oE,{label:`Paths`,values:e.resources}))}return e.kind===`glob-scan`?$(q.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},`Filesystem glob scanning`),$(`div`,{className:`mt-0.5 text-[10.5px] text-muted`},`Maximum depth: `,String(e.depth))):e.kind===`exec-policy`?$(q.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},`Future command policy amendment`),$(oE,{label:`Command prefix tokens`,values:e.prefixes})):$(q.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},e.access===`allow`?`Allow future network hosts`:`Deny future network hosts`),$(oE,{label:`Hosts`,values:e.hosts}))}function oE({label:e,values:t}){return $(`div`,{className:`mt-1 min-w-0`},$(`div`,{className:`sr-only`},e),$(`ul`,{"aria-label":e,className:`flex min-w-0 flex-col gap-0.5`},t.map((e,t)=>$(`li`,{key:t,className:`min-w-0 break-all font-mono-keep text-[10.5px] text-muted`},e))))}function sE(e){switch(e){case`read`:return`Read a file`;case`list-files`:return`List files`;case`search`:return`Search files`;case`unknown`:return`Unclassified command`}}function cE(e){switch(e){case`read`:return`Read file`;case`create`:return`Create file`;case`write`:return`Modify file`;case`move`:return`Move file`;case`delete`:return`Delete file`;case`execute`:return`Execute file`;case`other`:return`File operation`}}function lE(e){return e===`sending`?{actionsEnabled:!1,status:`Sending to runtime…`}:e===`reconnect-required`?{actionsEnabled:!1,status:`Runtime reconnect required before this request can be answered.`}:{actionsEnabled:!0}}var uE={semantic:`approve`,label:`Approve once`,order:10,tone:`primary`,durable:!1,scope:`Applies only to this request.`},dE={semantic:`approve`,label:`Approve for session`,order:20,tone:`primary`,durable:!0,scope:`Persists for later matching requests in this thread session.`},fE={semantic:`approve`,label:`Grant for turn`,order:10,tone:`primary`,durable:!1,scope:`Applies to this turn only.`},pE={semantic:`approve`,label:`Grant for session`,order:20,tone:`primary`,durable:!0,scope:`Persists until this thread session ends.`},mE={semantic:`deny`,label:`Deny`,order:70,tone:`danger`,durable:!1,scope:`Rejects this request.`},hE={semantic:`decline`,label:`Decline`,order:70,tone:`danger`,durable:!1,scope:`Declines this request.`},gE={semantic:`cancel`,label:`Cancel request`,order:80,tone:`neutral`,durable:!1,scope:`Cancels this pending request.`};function _E(e,t){let{id:n,semantic:r}=t;if(e.kind===`command-approval`||e.kind===`file-approval`)return(n===`accept`||n===`approve-once`)&&r===`approve`?uE:n===`acceptForSession`&&r===`approve`?dE:(n===`decline`||n===`deny`)&&r===`deny`?mE:n===`cancel`&&r===`cancel`?gE:void 0;if(e.kind===`permission-approval`)return n===`grant-turn`&&r===`approve`?fE:n===`grant-session`&&r===`approve`?pE:(n===`deny`||n===`decline`)&&r===`deny`?mE:n===`cancel`&&r===`cancel`?gE:void 0;if(e.kind===`mcp-elicitation-form`||e.kind===`mcp-elicitation-url`)return n===`accept`&&r===`accept`?{semantic:`accept`,label:e.kind===`mcp-elicitation-form`?`Submit`:`Continue`,order:10,tone:`primary`,durable:!1,scope:`Applies only to this request.`}:n===`decline`&&r===`decline`?hE:n===`cancel`&&r===`cancel`?gE:void 0;if(n===`answer`&&r===`answer`)return{semantic:`answer`,label:`Send answer`,order:10,tone:`primary`,durable:!1,scope:`Sends these answers to this request only.`};if(n===`decline`&&r===`decline`)return hE;if(n===`cancel`&&r===`cancel`)return gE}function vE(e){let t=t=>e.payload.kind===`mcp-elicitation-form`&&t===`accept`||e.payload.kind===`agent-question`&&t===`answer`;return e.allowedDecisions.flatMap(n=>{let r=_E(e.payload,n);return r?[{...r,id:n.id,semantic:n.semantic,requiresValues:t(n.semantic)}]:[]}).sort((e,t)=>e.order-t.order||e.id.localeCompare(t.id))}function yE(e){switch(e){case`claude`:return`Claude`;case`codex`:return`Codex`;case`acp`:return`ACP agent`;case`opencode`:return`OpenCode`;case`frizz`:return`Frizz`}}function bE(e){switch(e){case`runtime`:return`Runtime`;case`agent`:return`Agent`;case`tool`:return`Tool`;case`mcp-server`:return`MCP server`;case`frizz`:return`Frizz`}}function xE(e,t){let n=e.options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t));return n<0?``:String(n)}function SE(e){let t=Object.create(null);for(let n of e)if(n.input===`text`||n.input===`multiline`)t[n.id]=n.default??``;else if(n.input===`number`||n.input===`integer`)t[n.id]=n.default===void 0?``:String(n.default);else if(n.input===`boolean`)t[n.id]=n.default??!1;else if(n.input===`select`)t[n.id]=n.default===void 0?``:xE(n,n.default);else if(n.input===`multi-select`){let e=new Set(n.default??[]);t[n.id]=n.options.flatMap((t,n)=>e.has(t.value)?[String(n)]:[])}return t}function CE(e,t,n){let r=Object.create(null);for(let t of Object.keys(e))r[t]=e[t];return r[t]=n,r}function wE(e,t){if(e.some(e=>e.secret))return{errors:{},formError:`Secret responses cannot be sent through this Frizz connection.`};let n=Object.create(null),r={};for(let i of e){let e=t[i.id],a;if(i.input===`text`||i.input===`multiline`){let t=typeof e==`string`?e:``;if(!i.required&&t===``)continue;i.required&&t===``?r[i.id]=`This field is required.`:a=t}else if(i.input===`number`||i.input===`integer`){let t=typeof e==`string`?e.trim():``;if(!i.required&&t===``)continue;if(t===``)r[i.id]=`This field is required.`;else{let e=Number(t);Number.isFinite(e)?a=e:r[i.id]=`Enter a valid number.`}}else if(i.input===`boolean`)a=e===!0;else if(i.input===`select`){let t=typeof e==`string`&&/^\d+$/.test(e)?Number(e):-1;if(t<0||t>=i.options.length)if(i.required)r[i.id]=`Choose an option.`;else continue;else a=i.options[t].value}else if(i.input===`multi-select`){let t=(Array.isArray(e)?e:[]).flatMap(e=>/^\d+$/.test(e)?[Number(e)]:[]);if(t.some(e=>e<0||e>=i.options.length))r[i.id]=`Choose only advertised options.`;else if(i.required&&t.length===0)r[i.id]=`Choose at least one option.`;else if(t.length>0)a=t.map(e=>i.options[e].value);else continue}if(a!==void 0&&!r[i.id]){let e=ho(i,a);e?r[i.id]=`Value ${e}.`:n[i.id]=a}}if(Object.keys(r).length>0)return{errors:r};let i=Cr.safeParse(n);return i.success?{errors:r,values:i.data}:{errors:r,formError:`The response is too large or contains invalid values.`}}function TE(e,t){return JSON.stringify([e,t??null])}function EE(e,t){let n=e??t;if(!n)return null;let r=e&&(e.input===`select`||e.input===`multi-select`)?e.options:[];return{question:{kind:e?.input===`multi-select`?`multi`:`question`,danger:!1,contextMd:n.description??n.label,options:r.map((e,t)=>`${sg(t)} ${e.label}`),recommendedIdxs:[]},...e?{optionFieldId:e.id}:{},optionValues:r.map(e=>e.value),...t?{notesFieldId:t.id}:{}}}function DE(e){if(e.payload.kind!==`agent-question`)return null;let t=e.payload.fields,n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r.secret)return null;if(r.id.endsWith(`_notes`))continue;let i=t[e+1],a=i&&i.id===`${r.id}_notes`?i:void 0;if(r.input===`select`||r.input===`multi-select`){let e=EE(r,a);if(!e)return null;n.push(e)}else if(r.input===`text`||r.input===`multiline`){let e=EE(void 0,r);if(!e)return null;n.push(e)}else return null}return n.length>0?n:null}function OE(e,t){let n=[],r;if(t){let i=e.multiSelect?t.split(`, `):[t];e.options.forEach((e,t)=>{i.includes(e.label)&&n.push(t)}),n.length===0&&(r=t)}return{question:{kind:e.multiSelect?`multi`:`question`,danger:!1,contextMd:e.question,options:e.options.map((e,t)=>`${sg(t)} ${e.label}${e.description?` — ${e.description}`:``}`),recommendedIdxs:[]},chosenIdxs:n,text:r}}function kE(e,t){let n={};return e.forEach((e,r)=>{let i=t[r];if(!i)return;let a=i.text.trim();if(e.question.kind===`multi`){let t=(i.chosenSet??[]).slice().sort((e,t)=>e-t).flatMap(t=>{let n=e.optionValues[t];return n===void 0?[]:[n]});e.optionFieldId&&t.length>0&&(n[e.optionFieldId]=t),e.notesFieldId&&a&&(n[e.notesFieldId]=a);return}let o=i.chosen;if(e.optionFieldId&&o!==null&&e.optionValues[o]!==void 0){n[e.optionFieldId]=e.optionValues[o];return}a&&e.notesFieldId&&(n[e.notesFieldId]=a)}),Object.keys(n).length>0?n:void 0}function AE(e){let t=e instanceof Error?e.message:`The request could not be updated.`;return t.length>240?`${t.slice(0,239)}…`:t}function jE(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`frizz-response-${Date.now()}-${Math.random().toString(36).slice(2)}`}function ME({thread:e,className:t=``,autoFocusFirst:n=!1}){let r=Yo(e),i=yt(e),a=(0,q.useMemo)(()=>[...i.data?.interactions??[]].sort((e,t)=>e.createdAt.localeCompare(t.createdAt)||e.id.localeCompare(t.id)),[i.data?.interactions]);return r?i.isError&&a.length===0?(0,X.jsxs)(`div`,{"data-interactions-error":!0,role:`alert`,className:`${Bp} border border-attention-fill/35 bg-attention-fill/[0.07] p-4 text-[12px] text-attention-soft ${t}`,children:[(0,X.jsx)(`div`,{className:`font-medium`,children:`Pending requests could not be loaded.`}),(0,X.jsx)(`div`,{className:`mt-1 break-words text-attention-soft-75`,children:AE(i.error)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void i.refetch(),className:`mt-2 rounded-md border border-attention/40 px-2 py-1 text-[11px] hover:bg-attention-fill/10`,children:`Try again`})]}):a.length===0?null:(0,X.jsx)(`section`,{"data-typed-interactions":!0,"aria-label":`${a.length} pending request${a.length===1?``:`s`}`,className:`flex min-w-0 flex-col gap-3 ${t}`,children:a.map((e,t)=>(0,X.jsx)(PE,{record:e,autoFocus:n&&t===0,siblings:a},e.id))}):null}function NE({record:e,questions:t,autoFocus:n,siblings:r}){let a=G(),o=ie(),s=RE(e,r),c=(0,q.useRef)(null),l=(0,q.useRef)(new Map),u=Nr(),d=lE(e.delivery?.effect),f=(0,q.useMemo)(()=>vE(e).find(e=>e.semantic===`answer`),[e]),p=fs(t.flatMap(t=>t.notesFieldId?[U.interaction(u,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId)]:[])),[m,h]=(0,q.useState)(()=>t.map(()=>({chosen:null,chosenSet:[]}))),g=t.map((t,n)=>({chosen:m[n]?.chosen??null,chosenSet:m[n]?.chosenSet??[],text:t.notesFieldId?p.get(U.interaction(u,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId))??``:``})),_=kE(t,g),[v,y]=(0,q.useState)(),[b,x]=(0,q.useState)(!1);(0,q.useEffect)(()=>{if(!n)return;let e=document.activeElement;e&&e!==document.body||requestAnimationFrame(()=>c.current?.focus())},[n,e.id]);let S=Yr({mutationFn:async t=>k.interactionResolve({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id,sessionEpoch:e.owner.sessionEpoch,capabilityRevision:e.owner.capabilityRevision,expectedRecordRevision:e.recordRevision,responseId:t.responseId,decisionId:t.decisionId,values:t.values}),onSuccess:t=>{x(!0),Ta(a,t.interaction),a.invalidateQueries({queryKey:So(e.owner.threadSlug,e.owner.sessionId)}),a.invalidateQueries({queryKey:ni(e.owner.threadSlug,e.owner.sessionId,e.id)})},onError:t=>{i(a,e),s.rollback(),y(AE(t)),k.interactionGet({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id}).then(({interaction:t})=>{Ta(a,t),a.setQueryData(ni(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t}),a.invalidateQueries({queryKey:So(e.owner.threadSlug,e.owner.sessionId),exact:!0})}).catch(()=>{})}}),C=()=>{if(!f||!_||S.isPending||b||!d.actionsEnabled)return;y(void 0);let e=TE(f.id,_),t=l.current.get(e)??jE();l.current.set(e,t),s.release(!0),S.mutate({decisionId:f.id,values:_,responseId:t})},w=(t,n)=>{t.notesFieldId&&Ci.set(U.interaction(u,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId),n)};return(0,X.jsxs)(`article`,{ref:c,tabIndex:-1,"data-interaction-id":e.id,"data-interaction-kind":e.payload.kind,"data-interaction-question":`native`,"data-delivery-effect":e.delivery?.effect,className:`flex min-w-0 flex-col gap-2 outline-none`,children:[t.map((e,t)=>(0,X.jsx)(Fx,{question:e.question,interactive:d.actionsEnabled&&!b?{answer:g[t],onChip:n=>{h(r=>r.map((r,i)=>{if(i!==t)return r;if(e.question.kind===`multi`){let e=r.chosenSet.includes(n)?r.chosenSet.filter(e=>e!==n):[...r.chosenSet,n];return{...r,chosenSet:e}}return{...r,chosen:r.chosen===n?null:n}}))},onText:n=>{w(e,n),e.question.kind!==`multi`&&h(e=>e[t]?.chosen===null||e[t]===void 0?e:e.map((e,n)=>n===t?{...e,chosen:null}:e))},onSubmit:C}:void 0},e.optionFieldId??e.notesFieldId??t)),v&&(0,X.jsx)(`div`,{role:`alert`,className:`break-words text-[11px] leading-snug text-danger-soft`,children:v}),(d.status||S.isPending||b)&&(0,X.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[11px] leading-snug text-muted`,children:d.status??(b?`Answer sent.`:`Sending…`)}),o&&(0,X.jsxs)(Qo,{className:`text-[12px] text-muted`,children:[`This has to be answered on `,o,`.`]}),d.actionsEnabled&&!b&&!o&&(0,X.jsx)(`div`,{className:`flex justify-start`,children:(0,X.jsx)(`button`,{type:`button`,"data-send-answers":!0,disabled:!_||S.isPending,onClick:C,onMouseDown:e=>e.preventDefault(),className:`button-outline rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-all hover:opacity-90 active:scale-95 disabled:opacity-30 disabled:hover:opacity-30`,children:`Send answers`})})]})}function PE({record:e,autoFocus:t=!1,siblings:n}){let r=(0,q.useMemo)(()=>DE(e),[e]),i=n??[e];return r?(0,X.jsx)(NE,{record:e,questions:r,autoFocus:t,siblings:i}):(0,X.jsx)(zE,{record:e,autoFocus:t,siblings:i})}function FE(e){return e.semantic!==`cancel`}var IE=new Set,LE=new Set;function RE(e,t){let n=(0,q.useContext)(fb),r=e.owner.threadSlug;return{release:i=>{IE.add(e.id),i&&t.every(t=>t.id===e.id||IE.has(t.id)||t.delivery?.effect===`sending`)&&(LE.add(r),No(r),(n?.sent??n?.dismiss)?.())},rollback:()=>{IE.delete(e.id),LE.delete(r)&&(Vr(r),n?.cancel())}}}function zE({record:e,autoFocus:t=!1,siblings:n}){let r=G(),a=ie(),o=RE(e,n),s=(0,q.useId)(),c=(0,q.useRef)(null),l=(0,q.useRef)(new Map),u=e.payload.kind===`mcp-elicitation-form`||e.payload.kind===`agent-question`?e.payload.fields:[],d=u.some(e=>e.secret),f=Nr(),p=u.filter(e=>!e.secret&&(e.input===`text`||e.input===`multiline`)).map(t=>U.interaction(f,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.id)),m=fs(p),[h,g]=(0,q.useState)(()=>SE(u)),_=(0,q.useMemo)(()=>{let t={...h};return u.forEach(n=>{if(!n.secret&&(n.input===`text`||n.input===`multiline`)){let r=U.interaction(f,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,n.id);t[n.id]=m.get(r)??``}}),t},[u,h,m,f,e.id,e.owner]),[v,y]=(0,q.useState)({}),[b,x]=(0,q.useState)(),[S,C]=(0,q.useState)(),[w,T]=(0,q.useState)(!1),[E,D]=(0,q.useState)(),[O,A]=(0,q.useState)(!1),j=lE(e.delivery?.effect),M=(0,q.useMemo)(()=>vE(e),[e]).filter(e=>!(d&&e.requiresValues)),N=e.allowedDecisions.length-M.length,P=(0,q.useCallback)(t=>{for(let n of u)if(!n.secret&&(n.input===`text`||n.input===`multiline`)){let r=t[n.id];typeof r==`string`&&Ci.set(U.interaction(f,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,n.id),r)}g(t)},[u,f,e.id,e.owner]);(0,q.useEffect)(()=>{if(!t)return;let e=document.activeElement;e&&e!==document.body||requestAnimationFrame(()=>c.current?.focus())},[t,e.id]),(0,q.useEffect)(()=>{j.actionsEnabled||(D(void 0),A(!1))},[j.actionsEnabled]);let F=Yr({mutationFn:async({decision:t,values:n,responseId:r})=>{if(t.semantic===`cancel`&&e.provider.kind===`frizz`){let t=await k.interactionCancel({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id,sessionEpoch:e.owner.sessionEpoch,capabilityRevision:e.owner.capabilityRevision,expectedRecordRevision:e.recordRevision});return{effect:t.effect,interaction:t.interaction,waitingForProvider:!1}}let i=await k.interactionResolve({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id,sessionEpoch:e.owner.sessionEpoch,capabilityRevision:e.owner.capabilityRevision,expectedRecordRevision:e.recordRevision,responseId:r,decisionId:t.id,...n===void 0?{}:{values:n}});return{effect:i.effect,interaction:i.interaction,waitingForProvider:i.interaction.delivery?.effect===`sending`||i.effect===`queued`||i.effect===`already-queued`}},onSuccess:(t,n)=>{t.waitingForProvider||l.current.delete(TE(n.decision.id,n.values)),x(void 0),D(void 0),A(!1),T(!0),p.forEach(e=>Ci.clear(e)),C(t.waitingForProvider?`Response sent. Waiting for the provider to acknowledge it…`:`Request completed.`),Ta(r,t.interaction),r.setQueryData(ni(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t.interaction}),r.invalidateQueries({queryKey:So(e.owner.threadSlug,e.owner.sessionId),exact:!0}),t.waitingForProvider&&window.setTimeout(()=>{r.invalidateQueries({queryKey:So(e.owner.threadSlug,e.owner.sessionId),exact:!0})},1e3)},onError:t=>{C(void 0),o.rollback(),x(AE(t)),i(r,e),k.interactionGet({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id}).then(({interaction:t})=>{Ta(r,t),r.setQueryData(ni(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t}),t.delivery?.effect===`sending`?(x(void 0),C(void 0),T(!0)):t.delivery?.effect===`reconnect-required`?(x(void 0),C(void 0)):(t.lifecycle!==`pending`||t.recordRevision!==e.recordRevision)&&(x(void 0),C(t.lifecycle===`expired`?`This request expired.`:`This request changed in another client.`),r.invalidateQueries({queryKey:So(e.owner.threadSlug,e.owner.sessionId),exact:!0})),r.invalidateQueries({queryKey:So(e.owner.threadSlug,e.owner.sessionId),exact:!0})}).catch(()=>{})}});function I(e){if(!e.requiresValues){y({});return}let t=wE(u,_);return y(t.errors),t.formError?(x(t.formError),null):t.values?t.values:null}function L(e,t=!1){if(!j.actionsEnabled||F.isPending||w)return;x(void 0);let n=I(e);if(n===null)return;if(e.durable&&!t){D(e),A(!1);return}let r=TE(e.id,n),i=l.current.get(r)??jE();l.current.set(r,i),o.release(FE(e)),F.mutate({decision:e,values:n,responseId:i})}let R=M.find(e=>e.requiresValues&&e.tone===`primary`);function z(e){e.preventDefault(),j.actionsEnabled&&R&&L(R)}return(0,X.jsxs)(`article`,{ref:c,tabIndex:-1,"aria-labelledby":s,"data-interaction-id":e.id,"data-interaction-kind":e.payload.kind,"data-delivery-effect":e.delivery?.effect,className:`min-w-0 ${Bp} border border-question-border bg-question outline-none focus-visible:ring-2 focus-visible:ring-focus-accent-60`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 border-b border-question-border px-4 py-3`,children:[(0,X.jsx)(nc,{"aria-hidden":`true`,size:16,className:`shrink-0 text-accent`}),(0,X.jsx)(`h3`,{id:s,className:`min-w-0 flex-1 break-words text-[14px] font-semibold leading-snug text-fg`,children:e.payload.title})]}),(0,X.jsx)(`form`,{onSubmit:z,onKeyDown:e=>{e.target instanceof HTMLButtonElement||Dr({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),j.actionsEnabled&&R&&L(R))},className:`min-w-0 px-4 py-3.5`,noValidate:!0,children:(0,X.jsxs)(`fieldset`,{disabled:!j.actionsEnabled,className:`min-w-0 border-0 p-0`,children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:`Interaction request`}),(0,X.jsx)(VE,{record:e,instanceId:s,draft:_,setDraft:P,errors:v,autoFocus:t}),d&&(0,X.jsxs)(`div`,{"data-secret-fallback":!0,className:`mt-3 rounded-md border border-attention-fill/35 bg-attention-fill/[0.07] p-3 text-[12px] leading-snug text-attention-soft-90`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(Vs,{"aria-hidden":`true`,size:14,className:`mt-0.5 shrink-0`}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`font-medium`,children:`Secret input is unavailable in this page.`}),(0,X.jsx)(`div`,{className:`mt-1 text-attention-soft-70`,children:`Frizz will not persist or send secret values through the current RPC.`})]})]}),(0,X.jsx)(`div`,{className:`mt-2 font-medium`,children:`Use the provider's trusted secret-input flow. The thread terminal cannot answer this typed request.`})]}),N>0&&(0,X.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-md border border-attention-fill/25 bg-attention-fill/[0.05] px-3 py-2 text-[11px] leading-snug text-attention-soft-75`,children:[(0,X.jsx)(pr,{"aria-hidden":`true`,size:13,className:`mt-0.5 shrink-0`}),(0,X.jsxs)(`span`,{children:[N===1?`One advertised choice`:`${N} advertised choices`,` cannot be safely labeled or delivered in Frizz and is not shown.`]})]}),E&&(0,X.jsxs)(`div`,{"data-durable-confirmation":!0,role:`group`,"aria-label":`Confirm ${E.label}`,className:`mt-3 rounded-md border border-attention/45 bg-attention-fill/[0.08] p-3`,children:[(0,X.jsx)(`div`,{className:`text-[12px] font-semibold text-attention-soft`,children:`This approval persists beyond the current request.`}),(0,X.jsx)(`div`,{className:`mt-1 text-[11px] leading-snug text-attention-soft-75`,children:E.scope}),(0,X.jsxs)(`label`,{className:`mt-2.5 flex cursor-pointer items-start gap-2 text-[11px] leading-snug text-fg/85`,children:[(0,X.jsx)(`input`,{type:`checkbox`,autoFocus:!0,checked:O,onChange:e=>A(e.target.checked),className:`mt-0.5 accent-[var(--color-accent)]`}),(0,X.jsx)(`span`,{children:`I understand this may authorize later matching actions in this session.`})]}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-start gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>{D(void 0),A(!1)},className:`rounded-md border border-border px-2.5 py-1.5 text-[11px] text-muted hover:bg-panel-2 hover:text-fg`,children:`Back`}),(0,X.jsxs)(`button`,{type:`button`,disabled:!O||F.isPending,onClick:()=>L(E,!0),className:`rounded-md border border-attention/50 bg-attention-fill/15 px-2.5 py-1.5 text-[11px] font-semibold text-attention-faint hover:bg-attention-fill/25 disabled:opacity-35`,children:[`Confirm `,E.label.toLowerCase()]})]})]}),b&&(0,X.jsx)(`div`,{role:`alert`,className:`mt-3 break-words text-[11px] leading-snug text-danger-soft`,children:b}),(j.status??S)&&(0,X.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`mt-3 text-[11px] leading-snug text-muted`,children:j.status??S}),a&&(0,X.jsxs)(Qo,{className:`mt-3 text-[12px] text-muted`,children:[`This has to be answered on `,a,`.`]}),j.actionsEnabled&&!E&&!w&&M.length>0&&!a&&(0,X.jsxs)(`div`,{className:`mt-4 flex flex-wrap justify-start gap-2`,children:[M.map(e=>(0,X.jsxs)(`button`,{type:e===R?`submit`:`button`,"data-interaction-decision":e.id,disabled:F.isPending,"aria-describedby":e.durable?`${s}-scope-${e.id}`:void 0,onClick:e===R?void 0:()=>L(e),className:BE(e),children:[F.isPending?`Sending…`:e.label,e.durable&&(0,X.jsx)(`span`,{className:`sr-only`,children:`; persistent approval`})]},e.id)),M.filter(e=>e.durable).map(e=>(0,X.jsx)(`span`,{id:`${s}-scope-${e.id}`,className:`sr-only`,children:e.scope},`scope-${e.id}`))]}),!HE.has(e.payload.kind)&&(0,X.jsx)(GE,{record:e})]})})]})}function BE(e){let t=`rounded-md border px-2.5 py-1.5 text-[11px] font-medium outline-none transition-colors focus-visible:ring-2 focus-visible:ring-focus-ink-50 disabled:opacity-40`;return e.tone===`primary`?`${t} border-border-strong bg-panel-2 text-fg hover:bg-inset`:e.tone===`danger`?`${t} border-danger/35 bg-danger-fill/[0.07] text-danger-faint hover:bg-danger-fill/15`:`${t} border-border bg-panel text-muted hover:bg-panel-2 hover:text-fg`}function VE({record:e,instanceId:t,draft:n,setDraft:r,errors:i,autoFocus:a}){let o=e.payload,s=(e,t)=>r(CE(n,e,t)),c;return c=o.kind===`command-approval`||o.kind===`file-approval`||o.kind===`permission-approval`?(0,X.jsx)(eE,{payload:o}):o.kind===`mcp-elicitation-url`?(0,X.jsx)(WE,{url:o.url}):(0,X.jsx)(KE,{instanceId:t,fields:o.fields,draft:n,setValue:s,errors:i,autoFocus:a}),(0,X.jsxs)(X.Fragment,{children:[`message`in o&&o.message&&(0,X.jsx)(UE,{text:o.message}),(0,X.jsx)(`div`,{className:`message`in o&&o.message?`mt-3`:``,children:c})]})}var HE=new Set([`command-approval`,`file-approval`,`permission-approval`]);function UE({text:e}){return e.length>600||e.split(`
|
|
136
|
-
`).length>6?(0,X.jsxs)(`details`,{className:`rounded-md border border-border/70 bg-panel/60`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer px-2.5 py-2 text-[11px] text-muted outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-focus-ink-50`,children:`Request message`}),(0,X.jsx)(`div`,{className:`max-h-52 overflow-auto border-t border-border/60 px-2.5 py-2 whitespace-pre-wrap break-words text-[12px] leading-relaxed text-fg/80`,children:e})]}):(0,X.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-[12px] leading-relaxed text-fg/80`,children:e})}function WE({url:e}){let t=$i(e,location.href);return(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-[11px] font-medium text-fg`,children:`Open this page to continue`}),(0,X.jsx)(`code`,{className:`mt-1.5 block max-h-24 overflow-auto break-all rounded-md border border-border bg-bg/40 px-2.5 py-2 font-mono-keep text-[10.5px] text-fg/80`,children:e}),t?(0,X.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:`mt-2 inline-flex items-center gap-1.5 rounded-md border border-border bg-panel px-2.5 py-1.5 text-[11px] font-medium text-fg hover:bg-panel-2`,children:[(0,X.jsx)(Ls,{"aria-hidden":`true`,size:12}),`Open page`]}):(0,X.jsx)(`div`,{role:`alert`,className:`mt-1.5 break-words text-[11px] text-danger-soft`,children:`This request did not provide a safe http(s) URL.`})]})}function GE({record:e}){return(0,X.jsxs)(`details`,{className:`mt-3 border-t border-border/50 pt-2 text-[10.5px] text-muted-70`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer w-fit outline-none hover:text-muted focus-visible:ring-1 focus-visible:ring-focus-ink-50`,children:`Request details`}),(0,X.jsxs)(`dl`,{className:`mt-2 grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1`,children:[(0,X.jsx)(`dt`,{children:`Provider`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:yE(e.provider.kind)}),e.provider.name&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{children:`Reported name`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.provider.name})]}),e.provider.version&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{children:`Reported version`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.provider.version})]}),(0,X.jsx)(`dt`,{children:`Source`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:bE(e.source.kind)}),e.source.label&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{children:`Reported source`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.source.label})]}),(0,X.jsx)(`dt`,{children:`Scope`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:`This thread · this request`}),e.expiresAt&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{children:`Expires`}),(0,X.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.expiresAt})]})]})]})}function KE({instanceId:e,fields:t,draft:n,setValue:r,errors:i,autoFocus:a}){let o=t.findIndex(e=>!e.secret);return(0,X.jsxs)(`fieldset`,{className:`min-w-0`,children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:`Requested information`}),(0,X.jsx)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:t.map((t,s)=>(0,X.jsx)(qE,{instanceId:e,field:t,value:n[t.id],setValue:e=>r(t.id,e),error:i[t.id],autoFocus:a&&s===o},t.id))})]})}function qE({instanceId:e,field:t,value:n,setValue:r,error:i,autoFocus:a}){let o=`${e}-${t.id}`,s=t.description?`${o}-description`:void 0,c=i?`${o}-error`:void 0,l=[s,c].filter(Boolean).join(` `)||void 0,u=(0,X.jsxs)(X.Fragment,{children:[t.label,t.required&&(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`ml-0.5 text-accent`,children:`*`})]}),d=`mt-1 w-full min-w-0 rounded-md border border-border bg-bg/45 px-2.5 py-2 text-[12px] text-fg outline-none focus:border-accent focus:ring-1 focus:ring-focus-accent-40`,f;if(t.secret)f=(0,X.jsx)(`div`,{className:`mt-1 text-[11px] text-attention-soft-70`,children:`Use the secure fallback below.`});else if(t.input===`multiline`)f=(0,X.jsx)(`textarea`,{id:o,name:t.id,"data-1p-ignore":!0,value:typeof n==`string`?n:``,onChange:e=>r(e.target.value),required:t.required,minLength:t.minLength,maxLength:t.maxLength,"aria-describedby":l,"aria-invalid":!!i,autoFocus:a,rows:4,className:`${d} resize-y`});else if(t.input===`text`){let e=t.format===`email`?`email`:t.format===`uri`?`url`:t.format===`date`?`date`:`text`;f=(0,X.jsx)(`input`,{id:o,name:t.id,type:e,value:typeof n==`string`?n:``,onChange:e=>r(e.target.value),required:t.required,minLength:t.minLength,maxLength:t.maxLength,placeholder:t.format===`date-time`?`2026-07-13T12:00:00Z`:void 0,"aria-describedby":l,"aria-invalid":!!i,autoFocus:a,className:d})}else if(t.input===`number`||t.input===`integer`)f=(0,X.jsx)(`input`,{id:o,name:t.id,type:`number`,step:t.input===`integer`?1:`any`,min:t.minimum,max:t.maximum,value:typeof n==`string`?n:``,onChange:e=>r(e.target.value),required:t.required,"aria-describedby":l,"aria-invalid":!!i,autoFocus:a,className:d});else if(t.input===`boolean`)f=(0,X.jsxs)(`label`,{htmlFor:o,className:`mt-1 flex cursor-pointer items-center gap-2 rounded-md border border-border bg-bg/30 px-2.5 py-2 text-[12px] text-fg/85`,children:[(0,X.jsx)(`input`,{id:o,name:t.id,type:`checkbox`,checked:n===!0,onChange:e=>r(e.target.checked),"aria-describedby":l,autoFocus:a,className:`accent-[var(--color-accent)]`}),(0,X.jsx)(`span`,{children:u})]});else if(t.input===`select`)f=(0,X.jsxs)(`select`,{id:o,name:t.id,value:typeof n==`string`?n:``,onChange:e=>r(e.target.value),required:t.required,"aria-describedby":l,"aria-invalid":!!i,autoFocus:a,className:d,children:[(0,X.jsx)(`option`,{value:``,children:`Choose an option…`}),t.options.map((e,t)=>(0,X.jsx)(`option`,{value:String(t),children:e.label},t))]});else if(t.input===`multi-select`){let e=Array.isArray(n)?n:[];f=(0,X.jsxs)(`fieldset`,{id:o,"aria-describedby":l,className:`mt-1 rounded-md border border-border bg-bg/30 px-2.5 py-2`,children:[(0,X.jsx)(`legend`,{className:`px-1 text-[11px] font-medium text-fg/85`,children:u}),(0,X.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:t.options.map((n,i)=>{let o=String(i);return(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-[12px] text-fg/85`,children:[(0,X.jsx)(`input`,{type:`checkbox`,name:t.id,value:o,checked:e.includes(o),onChange:t=>r(t.target.checked?[...e,o]:e.filter(e=>e!==o)),autoFocus:a&&i===0,className:`mt-0.5 accent-[var(--color-accent)]`}),(0,X.jsx)(`span`,{children:n.label})]},o)})})]})}return(0,X.jsxs)(`div`,{className:`min-w-0`,children:[t.secret?(0,X.jsx)(`div`,{className:`text-[11px] font-medium text-fg/85`,children:u}):t.input!==`boolean`&&t.input!==`multi-select`?(0,X.jsx)(`label`,{htmlFor:o,className:`block text-[11px] font-medium text-fg/85`,children:u}):null,t.description&&(0,X.jsx)(`div`,{id:s,className:`mt-0.5 whitespace-pre-wrap break-words text-[10.5px] leading-snug text-muted`,children:t.description}),f,i&&(0,X.jsx)(`div`,{id:c,role:`alert`,className:`mt-1 text-[10.5px] text-danger-soft`,children:i})]})}function JE(e,t=Date.now()){return e!==void 0&&_i(e,t)!==void 0}function YE(){let[e,t]=(0,q.useState)(()=>Date.now());return(0,q.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(e)},[]),e}function XE({thread:e}){let t=YE(),[n,r]=(0,q.useState)(!1),i=_i(e,t);if(!i)return null;let a=Date.parse(i),o=Vo(i,t).replace(/^(Today|Tomorrow)/,e=>e.toLowerCase()),s=e.snoozePrompt?.trim();async function c(){r(!0);try{await k.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:null,prompt:null}),K(`Snooze cleared`)}catch(e){K((e instanceof Error?e.message:`Wake failed`).slice(0,100))}finally{r(!1)}}return(0,X.jsxs)($p,{"data-snooze-card":!0,icon:we,label:`Snoozed`,children:[(0,X.jsx)(`div`,{"data-snooze-countdown":!0,title:new Date(a).toLocaleString(),className:`text-[22px] font-semibold leading-8 tracking-tight text-fg tabular-nums`,children:wn(a-t)}),(0,X.jsx)(`p`,{className:em,children:s?(0,X.jsxs)(X.Fragment,{children:[`Resumes `,o,` and sends: “`,D(s),`”`]}):(0,X.jsxs)(X.Fragment,{children:[`Returns to the queue `,o,`.`]})}),e.foreign!==!0&&(0,X.jsx)(tm,{children:(0,X.jsx)(`button`,{type:`button`,"data-snooze-wake-now":!0,disabled:n,onClick:()=>void c(),className:`${om} disabled:cursor-not-allowed disabled:opacity-45`,children:`Wake now`})})]})}function ZE(e){return e?.foreign&&e.pendingInteraction!==!0?e.pendingAsk:void 0}function QE(e,t){return e?.actionableInteraction===!0?!1:t||e?.runtime===`perm-prompt`}async function $E({slug:e,cursor:t,expectedKey:n,queryClient:r,refetch:i,beforePrepend:a}){let o=await k.threadTranscriptEarlier({slug:e,cursor:t}),s=r.getQueryData([`transcript`,e]);return!s?.transcriptKey||s.transcriptKey!==n||o.transcriptKey!==n?(await i(),K(`Transcript changed while loading history; refreshed the current session`),null):(a?.(o),r.setQueryData([`transcript`,e],sr(s,o)),o)}function eD(e){let t=Math.max(e.scrollHeight-e.clientHeight,0),n=t-e.scrollTop,r=e.scrollHeight!==e.previousScrollHeight||e.previousClientHeight!==void 0&&e.previousClientHeight>=0&&e.clientHeight!==e.previousClientHeight,i=r&&!e.readerMoved?e.following||n<=1:n<=4;return!i||!r||t<=0||n<=1?{following:i,scrollTop:null}:{following:i,scrollTop:t}}function tD(e){let t=e.scrollTop>640?!0:e.armed,n=t&&e.readerMoved&&e.scrollTop<=480&&e.hasEarlier&&!e.loading;return{armed:n?!1:t,shouldLoad:n}}function nD(e){return`legacy:${e.role}:${e.kind??`message`}:${e.at??``}:${e.text}`}function rD(e,t,n){let r=[],i=new Map,a=null;return e.forEach((e,o)=>{if(fo(e)||t(e))return;let s=e.sourceId??nD(e),c=i.get(s)??0;i.set(s,c+1),r.push({key:c===0?s:`${s}:${c}`,message:e,messageIndex:o,gap:a===null?0:n(a,e)}),a=e}),r}function iD(e,t,n){let r=e[t];if(!r||r.kind!==`event`||r.boundary!==`rest`)return!1;for(let r=t+1;r<e.length;r++){let t=e[r];if(!(fo(t)||n(t)))return!!t.boundary||t.wake===!0||zT(t)!==void 0}return!0}function aD(e,t){let n=e.map(e=>e.message);return e.filter((e,r)=>!iD(n,r,t))}var oD=(0,q.createContext)(null);function sD(){let e=(0,q.useContext)(db),t=(0,q.useContext)(oD);return e??t}function cD({slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r=!1,pane:i}){Ne(e);let a=pt()&&n!==void 0,{splitFileViewer:o}=Br(W);return(0,X.jsx)(lD,{slug:e,phone:a,railBeside:(i?i.railBeside===!0:r)&&o,pane:i,header:a?(0,X.jsx)(pT,{slug:e,onClose:n}):(0,X.jsx)(ED,{slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r,pane:i})})}function lD({slug:e,phone:t=!1,railBeside:n=!1,header:r,pane:i}){let a=Ne(e),o=rt(e,{poll:a?.runtime===`running`||a?.runtime===`spawning`}),s=G(),c=(0,q.useRef)(!1),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(null),{messages:p,openQuestions:m,settledQuestions:h,transcriptShells:g}=TS(a,(0,q.useMemo)(()=>o.data?.messages??[],[o.data])),_=(0,q.useMemo)(()=>t?{numberOf:e=>m.findIndex(t=>t.id===e)+1}:null,[t,m]),[v,y]=(0,q.useState)(!1),[b,x]=(0,q.useState)(void 0);if(i?.queueWindow&&b===void 0&&p.length>0){let e=qg(p);x(e>0?p[e]?.sourceId??null:null)}let S=b?Math.max(0,p.findIndex(e=>e.sourceId===b)):0,C=ie(),w=(0,q.useMemo)(()=>C?m.filter(e=>!Tx(e.spec)):m,[C,m]),T=pi()[e],E=(0,q.useMemo)(()=>kr(p,T===void 0?void 0:new Date(T).toISOString()),[p,T]),D=(0,q.useMemo)(()=>mb(E),[E]),O=(0,q.useMemo)(()=>Xr(a,E,D,T),[a,E,D,T]),A=Ua(O,E),j=A?.runtime===`running`||A?.runtime===`spawning`,M=O===a?void 0:O?.lastUserAt,N=PS({slug:e,thread:A,messages:p,openQuestions:m,settledQuestions:h},i?{exit:i.exit}:void 0),{inFlightAnswers:P}=N.transcript,F=(0,q.useRef)(null),[I,L]=(0,q.useState)(null),R=o.data?.messages.length??0,z=TC({pending:o.isPending,failed:o.isError},{running:j,adoptable:wC(A)}),B=(0,q.useCallback)(async()=>{if(c.current)return;let t=s.getQueryData([`transcript`,e]),n=t?.beforeCursor,r=t?.transcriptKey;if(!(!t?.hasEarlier||!n||!r)){c.current=!0,u(!0),f(null);try{await $E({slug:e,cursor:n,expectedKey:r,queryClient:s,refetch:()=>o.refetch()})}catch(e){let t=e instanceof Error?e.message:`Could not load earlier transcript history`;f(t)}finally{c.current=!1,u(!1)}}},[o,s,e]),V=(0,q.useCallback)(()=>{if(S===0)return void B();let e=Ut(p,S);x(e!==null&&e>0?p[e]?.sourceId??null:null)},[B,p,S]);return(0,X.jsxs)(FS,{surface:N,className:`flex-1 min-h-0 flex flex-col`,children:[r,(0,X.jsx)(Bx.Provider,{value:_,children:(0,X.jsxs)(`div`,{"data-drawer-scroll-ready":o.isPending?`false`:`true`,className:`flex-1 min-h-0 flex flex-col overflow-hidden outline-none`,children:[(0,X.jsxs)(`div`,{className:`relative min-h-0 flex-1 flex flex-col`,children:[(0,X.jsx)(`div`,{ref:F,"data-drawer-transcript-scroll":!0,"data-virtualized-transcript-scroll":!0,tabIndex:0,role:`region`,"aria-label":`Thread conversation`,"aria-busy":l?!0:void 0,className:`relative min-h-0 flex-1 overflow-y-auto pb-3 outline-none [overflow-anchor:none] focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-focus-ink-60`,children:R>0?(0,X.jsx)(wD,{slug:e,transcriptRef:F,transcriptKey:o.data?.transcriptKey,messages:E,steerSince:M,transportFallback:o.transportFallback,isFetching:o.isFetching,refresh:()=>void o.refetch(),retryLiveUpdates:o.retryLiveUpdates,hasEarlier:o.data?.hasEarlier===!0,beforeCursor:o.data?.beforeCursor,loadingEarlier:l,earlierError:d,loadEarlier:V,jumpOverlay:I,openAtLastMessage:(t||i!==void 0)&&!j,windowStart:S,openAtTop:i?.queueWindow===!0,sentAt:i?T:void 0}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ME,{thread:A,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,X.jsx)(CS,{thread:A,inFlight:P,className:`px-6 pt-5`}),o.transportFallback&&(0,X.jsx)(gD,{fallback:o.transportFallback,isFetching:o.isFetching,onRefresh:()=>void o.refetch(),onRetryLive:o.retryLiveUpdates,className:`mx-6 mt-3`}),(0,X.jsx)(`div`,{className:`flex min-h-full flex-col px-6 py-5`,children:(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted`,children:z===`loading`?(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(nk,{}),` Loading…`]}):z===`failed`?(0,X.jsx)(_D,{error:o.error,retry:()=>o.refetch()}):z===`starting`?(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(nk,{}),` Session starting…`]}):z===`adopt`?(0,X.jsxs)(`div`,{className:`text-center`,children:[(0,X.jsx)(`p`,{className:`mb-3`,children:`No session is attached to this thread yet.`}),(0,X.jsx)(`button`,{className:`btn-ghost border border-border text-[12px]`,onClick:()=>k.adoptThread({slug:e}).catch(()=>{}),children:`Start a session on this thread`})]}):`No conversation yet.`})})]})}),(0,X.jsx)(`div`,{ref:L,"data-transcript-overlay":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 z-20 flex justify-end p-4 [&>*]:pointer-events-auto`})]}),(0,X.jsx)(`div`,{"data-thread-chat-footer":!0,className:`z-10 shrink-0 border-t border-border/60 bg-panel ${t?``:`pb-[env(safe-area-inset-bottom)]`}`,children:(0,X.jsx)(_w,{slug:e,above:t||n||!A?void 0:(0,X.jsx)(Nw,{thread:A,transcriptShells:g}),phoneBarOverride:t&&w.length>0?e=>(0,X.jsx)(Gx,{count:w.length,onAnswer:()=>y(!0),onReply:C?void 0:e.editReply}):void 0,phoneChrome:t})}),t&&v&&(0,X.jsx)(qS,{questions:w,onClose:()=>y(!1)})]})})]})}var uD=700,dD=`button, a[href], input, textarea, select, summary, label, [role='button'], [role='checkbox'], [role='radio'], [contenteditable='true']`;function fD(e){return e.target instanceof Element&&e.target.closest(dD)!==null}var pD=250,mD=900,hD=(()=>{try{return localStorage.getItem(`frizz.debugScroll`)===`1`}catch{return!1}})();function gD({fallback:e,isFetching:t,onRefresh:n,onRetryLive:r,className:i=``}){return(0,X.jsxs)(`div`,{"data-transcript-sync-fallback":!0,className:`flex flex-wrap items-center gap-2.5 ${Bp} border border-border-strong bg-panel-2 px-4 py-2.5 text-[12px] ${i}`,title:e.kind===`payload-too-large`?`Live payload ${e.actualBytes} bytes; socket limit ${e.maxBytes} bytes`:`Transcript read budget reached (${e.scope}); retry after about ${e.retryAfterMs}ms`,children:[(0,X.jsx)(pr,{size:13,className:`shrink-0 text-muted`}),(0,X.jsxs)(`div`,{className:`min-w-[180px] flex-1 leading-snug text-fg/85`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Live transcript updates paused.`}),` `,e.kind===`payload-too-large`?`The transcript is too large for push; it refreshes over HTTP each time the thread moves.`:`The live read budget was reached; the last complete copy remains visible. Retry in a moment.`]}),(0,X.jsx)(`button`,{type:`button`,disabled:t,onClick:n,className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel disabled:opacity-40`,children:t?`Refreshing…`:`Refresh once`}),(0,X.jsx)(`button`,{type:`button`,onClick:r,className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel`,children:`Retry live`})]})}function _D({error:e,retry:t}){let[n,r]=(0,q.useState)(!1),i=(e instanceof Error?e.message:String(e??``)).slice(0,200);return(0,X.jsxs)(`div`,{"data-transcript-read-failed":!0,role:`status`,className:`text-center`,children:[(0,X.jsx)(`p`,{children:`Could not load this conversation.`}),i&&(0,X.jsx)(`p`,{className:`font-mono-keep mt-1.5 break-words text-[11.5px]`,children:i}),(0,X.jsx)(`button`,{type:`button`,disabled:n,className:`btn-ghost mt-3 border border-border text-[12px] disabled:opacity-40`,onClick:()=>{r(!0),t().finally(()=>r(!1))},children:n?`Retrying…`:`Retry`})]})}function vD({thread:e,showWorking:t,registeredDone:n,restedCard:r,errorVisible:i}){return e?.providerError?.retrying?`provider-error`:e?.providerFault&&!e.foreign?`provider-fault`:e?.limitPause&&!e.foreign?`limit-pause`:ZE(e)?`pending-ask`:QE(e,t)?`working`:e?.providerError?i?null:`provider-error`:JE(e)?`snooze`:py(e)?`resting`:n?`registered-done`:r?`rested`:null}function yD(e,t){return vD(e)===`working`?JD(t):14}function bD({state:e,slug:t,retryText:n,liveRuntimeStart:r,liveActivityLabel:i,liveToolRun:a,onRestingExit:o,onRestingExitFailed:s,onRestingReplied:c}){let l=e.thread;switch(vD(e)){case`provider-fault`:return(0,X.jsx)(KO,{slug:t,sessionId:l.sessionId,fault:l.providerFault,retryText:n});case`provider-error`:return(0,X.jsx)(IO,{error:l.providerError});case`limit-pause`:return(0,X.jsx)(qO,{slug:t,sessionId:l.sessionId,pause:l.limitPause});case`pending-ask`:return(0,X.jsx)(XO,{ask:ZE(l)});case`working`:return(0,X.jsx)(rk,{since:l?.lastUserAt,startedAt:r,activityLabel:i,run:a});case`snooze`:return(0,X.jsx)(XE,{thread:l});case`resting`:return(0,X.jsx)(gy,{thread:l,onSnooze:o,onSnoozeFailed:s,onReplied:c??o,onReplyFailed:s});case`registered-done`:return(0,X.jsx)(xD,{thread:l});case`rested`:return(0,X.jsx)(xg,{thread:l});default:return null}}function xD({thread:e}){let t=yg(e);return t===void 0?null:(0,X.jsx)(GO,{fenceKind:`done`,body:t,hints:e.lastFence.hints})}function SD(e,t,n,r){let{thread:i,messages:a,running:o,lastAgentIdx:s}=e,c=Ft(),l=(0,q.useMemo)(()=>Kg(a),[a]);return(0,q.useMemo)(()=>{let e=s>=0?a[s]:void 0,u={thread:i,showWorking:o,registeredDone:hg(i,e?.text),restedCard:bg(i,e?.text,e?.refusedFences),errorVisible:Sg(t.map(e=>e.message),i?.providerError)},d=vD(u),f=o?Vt(t):void 0;return{state:u,rung:d,shown:d!==null||!!i?.permPolicy,gap:yD(u,n.map(e=>e.message)),retryText:l>=0?a[l]?.text:void 0,liveRuntimeStart:o?UD(Un(t),r):void 0,liveActivityLabel:f?Ma(f,c):void 0,liveToolRun:o?ar(t):void 0}},[i,a,o,s,l,t,n,r,c])}function CD({tail:e}){let t=(0,q.useContext)(db),n=(0,q.useContext)(fb),r=e.state.thread;return!e.shown||!t?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(My,{h:e.gap}),(0,X.jsx)(bD,{state:e.state,slug:t,retryText:e.retryText,liveRuntimeStart:e.liveRuntimeStart,liveActivityLabel:e.liveActivityLabel,liveToolRun:e.liveToolRun,onRestingExit:n?.dismiss,onRestingExitFailed:n?.cancel,onRestingReplied:n?.sent}),r?.permPolicy?(0,X.jsx)(`div`,{className:e.rung===null?``:`mt-3`,children:(0,X.jsx)(JO,{policy:r.permPolicy,denies:r.permDenies})}):null]})}function wD({slug:e,transcriptRef:t,transcriptKey:n,messages:r,steerSince:i,transportFallback:a,isFetching:o,refresh:s,retryLiveUpdates:c,hasEarlier:l,beforeCursor:u,loadingEarlier:d,earlierError:f,loadEarlier:p,jumpOverlay:m,openAtLastMessage:h=!1,windowStart:g=0,openAtTop:_=!1,sentAt:v}){let y=AS(),{thread:b,running:x,lastAgentIdx:S,awaitingCut:C,restingShown:w,heldIdx:T,paired:D,inFlightAnswers:O,settledPlacement:k,openQuestions:A}=y,j=(0,q.useMemo)(()=>__(y.placement,g),[y.placement,g]),M=(0,q.useMemo)(()=>{let e=Fn(r);return g>0?e.filter(e=>e.messageIndex>=g):e},[r,g]),N=(0,q.useMemo)(()=>{let e=x?qe(M):M;return aD(e,WD(e,C,w,T))},[M,x,C,w,T]),P=(0,q.useMemo)(()=>{let e=rD(N.map(e=>e.message),WD(N,C,w,T),BD);return e.map((t,n)=>({...t,messageIndex:N[t.messageIndex].messageIndex,restGap:RD(t.message,e[n+1]?.message)}))},[N,C,w,T]),F=SD(y,M,N,i),I=F.shown,L=(0,q.useMemo)(()=>{let e=[],t=new Map,n=r.length-1,i=e=>{let t=-1;for(let n=0;n<P.length&&!(P[n].messageIndex>e);n++)t=n;return t},a=A.filter(e=>!j.placedIds.has(e.id));for(let[o,s]of t_(r,a,{from:g})){if(o>=n){e.push(...s);continue}let r=i(o),a=t.get(r);a?a.push(...s):t.set(r,[...s])}let o=!1,s=new Set;for(let e of v_(r,j)){if(e>=n){o=!0;continue}let r=i(e);s.add(r),t.has(r)||t.set(r,[])}return{byRow:t,tail:e,tailSend:o,sendRows:s}},[P,r,A,j,g]),R=(0,q.useMemo)(()=>{let e=new Map;for(let[t,n]of k.anchored){let r=-1;for(let e=0;e<P.length&&!(P[e].messageIndex>t);e++)r=e;if(r<0)continue;let i=e.get(r);i?i.push(...n):e.set(r,[...n])}return e},[P,k.anchored]),z=(0,q.useMemo)(()=>{let e=[{key:`head-anchor`,kind:`head-anchor`}];a&&e.push({key:`transport-fallback`,kind:`transport-fallback`}),(l||d||f||g>0)&&e.push({key:`earlier-history:${u??`complete`}`,kind:`earlier-history`});let t=L.byRow.get(-1);t&&e.push({key:`questions:head`,kind:`questions`,questions:t,send:L.sendRows.has(-1)}),P.forEach((t,n)=>{e.push({...t,kind:`message`});let r=R.get(n);r&&e.push({key:`settled-questions:${t.key}`,kind:`settled-questions`,questions:r});let i=L.byRow.get(n);i&&e.push({key:`questions:${t.key}`,kind:`questions`,questions:i,send:L.sendRows.has(n)})}),e.push({key:`interactions`,kind:`interactions`}),I&&e.push({key:`runtime-status`,kind:`runtime-status`});let n=null;return r.forEach((t,r)=>{if(!fo(t))return;let i=`queued:${t.deliveryId??t.sourceId??r}`,a=n?BD(n,t):I||P.length>0?14:0;e.push({key:i,kind:`queued`,message:t,messageIndex:r,gap:a}),n=t}),n&&e.push({key:`queued-send-now`,kind:`queued-send-now`}),e},[u,f,l,I,d,P,r,L,R,a,g]),B=(0,q.useRef)(null),V=Wa({count:z.length,getScrollElement:()=>t.current,getItemKey:e=>z[e]?.key??e,estimateSize:e=>{let t=z[e];return t?t.kind===`head-anchor`||t.kind===`interactions`?1:t.kind===`queued-send-now`?22:t.kind===`earlier-history`?42:t.kind===`transport-fallback`?76:t.kind===`runtime-status`?54:t.kind===`questions`?220:t.kind===`settled-questions`?140:t.kind===`message`?108+t.gap:82+t.gap:80},overscan:8,rangeExtractor:e=>{let t=ya(e),n=B.current?.rowKey,r=n?z.findIndex(e=>e.key===n):-1;if(r<0)return t;let i=[];for(let e=Math.max(0,r-2);e<=Math.min(z.length-1,r+24);e++)i.push(e);return[...new Set([...t,...i])].sort((e,t)=>e-t)},paddingStart:20,paddingEnd:20,anchorTo:`end`,scrollEndThreshold:4,scrollToFn:(e,{adjustments:t,behavior:n},r)=>{let i=r.scrollElement;i&&i.scrollTo({top:t===void 0?e:i.scrollTop+t,behavior:n})}}),[ee,te]=(0,q.useState)(!0),ne=(0,q.useRef)(!0),re=(0,q.useRef)(-1),ie=(0,q.useRef)(-1),ae=(0,q.useRef)(0),oe=(0,q.useRef)(null),se=(0,q.useRef)(!1),ce=(0,q.useRef)(!1),le=(0,q.useRef)(!0),ue=(0,q.useRef)(void 0),de=(0,q.useRef)(null),fe=(0,q.useRef)(void 0),pe=(0,q.useRef)(0),me=(0,q.useRef)(0),he=(0,q.useCallback)(()=>{let e=t.current;if(e){let t=e.getBoundingClientRect().top,n=Array.from(e.querySelectorAll(`[data-transcript-source-id]`)).find(e=>e.getBoundingClientRect().bottom>t+1),r=n?.dataset.transcriptRowKey;n&&r&&(B.current={rowKey:r,viewportTop:n.getBoundingClientRect().top-t})}p()},[p,t]),ge=(0,q.useCallback)((e,n)=>{let r=t.current;if(!r)return;let i=Array.from(r.querySelectorAll(`[data-transcript-source-id]`)).find(t=>t.dataset.transcriptSourceId===e);i&&(r.scrollTop+=i.getBoundingClientRect().top-n)},[t]);(0,q.useLayoutEffect)(()=>{if(!n||z.length===0||ue.current===n)return;ue.current=n,se.current=!1,ce.current=!1,le.current=!0;let r=oa(e)?.candidates.map(e=>({candidate:e,index:z.findIndex(t=>t.kind===`message`&&t.message.sourceId===e.sourceId)})).find(e=>e.index>=0),i=!r&&h&&S>=0?z.reduce((e,t,n)=>t.kind===`message`&&t.messageIndex<=S&&t.message.role===`assistant`&&t.message.kind!==`event`?n:e,-1):-1,a=requestAnimationFrame(()=>{if(!r&&(_||i>=0)){let e=_?null:z[i].key;_?t.current?.scrollTo({top:0}):V.scrollToIndex(i,{align:`start`,behavior:`instant`}),ne.current=!1,te(!1),se.current=!0;let n=performance.now()+mD;pe.current=n;let r=()=>{let i=t.current;if(!i||performance.now()>=n||performance.now()<ae.current){pe.current=0,me.current=0,i&&i.scrollHeight-i.clientHeight-i.scrollTop<=4&&(ne.current=!0,re.current=i.scrollHeight,te(!0));return}if(e===null)i.scrollTop=0;else{let t=i.querySelector(`[data-transcript-row-key="${CSS.escape(e)}"]`);t&&(i.scrollTop+=t.getBoundingClientRect().top-i.getBoundingClientRect().top)}me.current=requestAnimationFrame(r)};r();return}if(!r){V.scrollToEnd({behavior:`instant`}),te(!0),se.current=!0;return}V.scrollToIndex(r.index,{align:`start`,behavior:`instant`}),ne.current=!1,te(!1),se.current=!0;let e=performance.now()+pD;pe.current=e;let n=()=>{performance.now()>=e||performance.now()<ae.current||(ge(r.candidate.sourceId,r.candidate.screenTop),a=requestAnimationFrame(n))};n()});return()=>cancelAnimationFrame(a)},[ge,z.length,e,n,V]),(0,q.useEffect)(()=>()=>cancelAnimationFrame(me.current),[]);let _e=(0,q.useRef)(v);(0,q.useEffect)(()=>{let e=v!==_e.current;_e.current=v;let n=t.current;!e||v===void 0||!n||(pe.current=0,ne.current=!0,te(!0),n.scrollTop=n.scrollHeight)},[v,t]);let ve=(0,q.useCallback)(()=>{let e=t.current;if(!e)return null;let n=e.getBoundingClientRect().top,r=Array.from(e.querySelectorAll(`[data-transcript-row-key]`)).find(e=>e.getBoundingClientRect().bottom>n+1),i=r?.dataset.transcriptRowKey;return!r||!i?null:{rowKey:i,viewportTop:r.getBoundingClientRect().top-n}},[t]),ye=(0,q.useCallback)(e=>{let n=t.current;if(!n)return;let r=Array.from(n.querySelectorAll(`[data-transcript-row-key]`)).find(t=>t.dataset.transcriptRowKey===e.rowKey);if(!r)return;let i=r.getBoundingClientRect().top-n.getBoundingClientRect().top;n.scrollTop+=i-e.viewportTop},[t]),be=P[0]?.key;(0,q.useLayoutEffect)(()=>{let e=fe.current;if(fe.current=be,e===void 0||e===be||!se.current||ne.current||B.current)return;let t=de.current;if(!t)return;ye(t);let n=()=>{if(performance.now()<ae.current)return;let e=de.current;e&&ye(e)},r=0,i=requestAnimationFrame(()=>{n(),r=requestAnimationFrame(n)});return()=>{cancelAnimationFrame(i),cancelAnimationFrame(r)}},[ye,be]);let xe=(0,q.useCallback)(()=>{let e=t.current;if(!e||B.current||performance.now()<pe.current)return;let n=eD({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight,previousScrollHeight:re.current,previousClientHeight:ie.current,following:ne.current,readerMoved:performance.now()<ae.current});if(ne.current=n.following,n.scrollTop!==null&&(e.scrollTop=n.scrollTop),re.current=e.scrollHeight,ie.current=e.clientHeight,te(e=>e===n.following?e:n.following),hD&&!n.following&&performance.now()>=ae.current){let t=de.current,n=t&&Array.from(e.querySelectorAll(`[data-transcript-row-key]`)).find(e=>e.dataset.transcriptRowKey===t.rowKey);if(t&&n){let r=Math.round(n.getBoundingClientRect().top-e.getBoundingClientRect().top-t.viewportTop);Math.abs(r)>2&&console.warn(`[frizz] transcript moved ${r}px under a still reader — row=${t.rowKey}`)}}de.current=ve()??de.current},[ve,t]);(0,q.useLayoutEffect)(()=>{let e=oe.current;if(!e)return;let t=new Map(V.getVirtualItems().map(e=>[e.index,e.size])),n=[],r=0;for(let i of e.querySelectorAll(`:scope > [data-index]`)){let e=V.indexFromElement(i),a=Math.round(i.getBoundingClientRect().height),o=t.get(e);e<0||o===void 0||o===a||(n.push({index:e,size:a}),r+=a-o)}if(n.length!==0){e.style.height=`${V.getTotalSize()+r}px`;for(let{index:e,size:t}of n)V.resizeItem(e,t)}});let Se=(0,q.useRef)(null);(0,q.useLayoutEffect)(()=>{let e=B.current,n=t.current;if(!e||!n||d)return;let r=()=>{let t=Array.from(n.querySelectorAll(`[data-transcript-row-key]`)).find(t=>t.dataset.transcriptRowKey===e.rowKey);if(!t){let t=z.findIndex(t=>t.key===e.rowKey),r=t>=0?V.getOffsetForIndex(t,`start`)?.[0]:void 0;return r!==void 0&&(n.scrollTop=r-e.viewportTop),!1}let r=t.getBoundingClientRect().top-n.getBoundingClientRect().top-e.viewportTop;return Math.abs(r)<.5?!0:(n.scrollTop+=r,!1)};if(r(),Se.current?.anchor===e)return;let i=0,a=0,o=()=>{if(i=r()?i+1:0,a++,i>=2||a>=10){B.current===e&&(B.current=null),Se.current=null;return}Se.current&&(Se.current.frame=requestAnimationFrame(o))};Se.current={anchor:e,frame:requestAnimationFrame(o)}}),(0,q.useEffect)(()=>()=>{Se.current&&cancelAnimationFrame(Se.current.frame)},[]),(0,q.useLayoutEffect)(xe),(0,q.useEffect)(()=>{let e=oe.current;if(!e)return;let n=new ResizeObserver(xe);n.observe(e);let r=t.current;return r&&n.observe(r),()=>n.disconnect()},[xe,t]),(0,q.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>{xe();let t=tD({armed:le.current,scrollTop:e.scrollTop,readerMoved:se.current&&ce.current,hasEarlier:l&&g===0,loading:d});le.current=t.armed,t.shouldLoad&&he()},r=()=>{ce.current=!0,ae.current=performance.now()+uD,requestAnimationFrame(n)},i=t=>{![`ArrowUp`,`PageUp`,`Home`,` `].includes(t.key)||fD(t)||(e.scrollTop<=480&&(le.current=!0),r())},a=t=>{t.deltaY<0&&e.scrollTop<=480&&(le.current=!0),r()},o=t=>{t.type===`touchstart`&&fD(t)||(e.scrollTop<=480&&(le.current=!0),r())},s=e=>{fD(e)||r()};e.addEventListener(`scroll`,n,{passive:!0}),e.addEventListener(`wheel`,a,{passive:!0}),e.addEventListener(`touchstart`,o,{passive:!0}),e.addEventListener(`touchmove`,o,{passive:!0}),e.addEventListener(`pointerdown`,s,{passive:!0}),e.addEventListener(`keydown`,i);let c=requestAnimationFrame(n);return()=>{cancelAnimationFrame(c),e.removeEventListener(`scroll`,n),e.removeEventListener(`wheel`,a),e.removeEventListener(`touchstart`,o),e.removeEventListener(`touchmove`,o),e.removeEventListener(`pointerdown`,s),e.removeEventListener(`keydown`,i)}},[l,d,he,xe,t,g]);let Ce=V.getVirtualItems(),we=V.getTotalSize();return(0,X.jsxs)(`div`,{ref:oe,"data-virtualized-transcript":!0,"data-virtual-row-count":Ce.length,className:`relative w-full`,style:{height:we},children:[Ce.map(e=>{let t=z[e.index];return t?(0,X.jsx)(`div`,{ref:V.measureElement,"data-index":e.index,"data-transcript-row-key":t.key,"data-transcript-source-id":t.kind===`message`?t.message.sourceId:void 0,className:`absolute left-0 top-0 w-full`,style:{transform:`translateY(${e.start}px)`},children:t.kind===`head-anchor`?null:t.kind===`interactions`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ME,{thread:b,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,X.jsx)(CS,{thread:b,questions:L.tail,inFlight:O,showSend:L.tailSend,className:`px-6 pt-5`})]}):t.kind===`questions`?(0,X.jsx)(CS,{thread:b,questions:t.questions,showSend:t.send,className:`px-6 pt-5`}):t.kind===`settled-questions`?(0,X.jsx)(sS,{questions:t.questions,className:`px-6 pt-5`}):t.kind===`transport-fallback`?a?(0,X.jsx)(`div`,{className:`px-6 pt-3`,children:(0,X.jsx)(gD,{fallback:a,isFetching:o,onRefresh:s,onRetryLive:c})}):null:t.kind===`earlier-history`?(0,X.jsx)(`div`,{className:`flex min-h-10 items-center justify-center px-6 text-[11px] text-muted`,role:`status`,children:f?(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center justify-center gap-2 text-center`,children:[(0,X.jsx)(`span`,{children:f}),(0,X.jsx)(`button`,{type:`button`,onClick:he,className:`rounded-md border border-border px-2 py-1 text-fg/90 hover:bg-panel-2`,children:`Retry`})]}):d?(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(E,{size:12,className:`animate-spin`}),` Loading earlier messages…`]}):(0,X.jsx)(`button`,{type:`button`,onClick:he,className:`button-outline rounded-md px-2 py-1 outline-none hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:`Load earlier messages`})}):t.kind===`message`?(0,X.jsx)(`div`,{className:`relative flex flex-col px-6`,style:{paddingTop:t.gap},children:t.restGap?(0,X.jsx)(zD,{rest:t.message,at:t.restGap}):(0,X.jsx)(PO,{m:t.message,index:t.messageIndex,showSendButton:!0})}):t.kind===`runtime-status`?(0,X.jsx)(`div`,{className:`px-6`,children:(0,X.jsx)(CD,{tail:F})}):t.kind===`queued-send-now`?(0,X.jsx)(`div`,{className:`flex flex-col px-6`,children:(0,X.jsx)(jO,{})}):(0,X.jsx)(`div`,{className:`relative flex flex-col px-6`,style:{paddingTop:t.gap},children:(0,X.jsx)(FO,{m:t.message,paired:D[t.messageIndex]})})},t.key):null}),(0,X.jsx)(TD,{overlay:m,hidden:ee,onJump:()=>V.scrollToEnd({behavior:`smooth`})})]})}function TD({overlay:e,hidden:t,onJump:n}){return!e||t?null:(0,dc.createPortal)((0,X.jsxs)(`button`,{type:`button`,"data-jump-to-latest":!0,onClick:n,className:`flex items-center gap-1.5 rounded-full border border-border-strong bg-elevated px-3 py-1.5 text-[11px] font-medium text-fg shadow-lg shadow-shadow-ink/30 hover:bg-panel-2`,children:[(0,X.jsx)(Ds,{size:12}),`Jump to latest`]}),e)}function ED({slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r=!1,pane:i}){let a=Ne(e),o=Yr({mutationFn:()=>k.markComplete({slug:e})}),s=pf(fi({queryKey:[`threadBody`,e],queryFn:()=>k.threadBody({slug:e})}).data?.markdown??``).trim().length>0;return a?(0,X.jsxs)(`header`,{"data-thread-header":!0,className:EC,children:[(0,X.jsxs)(`div`,{className:DC,children:[n&&(0,X.jsx)(Ha,{onClose:n}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 leading-tight`,children:[(0,X.jsx)(RT,{thread:a}),(0,X.jsx)(PT,{thread:a})]})]}),(0,X.jsx)(`div`,{className:OC,children:(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,X.jsx)(vT,{thread:a,collapse:r,expand:!!n||i?.expand===!0,onDoc:s?()=>co(`doc`,a.id):void 0,onDone:()=>o.mutate(void 0,{onSuccess:t??i?.exit.dismiss}),doneBusy:o.isPending,onStatusApplied:t}),(0,X.jsx)(Kw,{thread:a,onArchived:t??i?.exit.dismiss,onDismissCancel:i?.exit.cancel,onSnoozed:t??i?.exit.dismiss})]})})]}):null}function DD(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||zT(e))return null;if(e.parts&&e.parts.length>0){for(let t=e.parts.length-1;t>=0;t--){let n=e.parts[t];if(n.kind===`tools`?n.tools.length>0:n.text.trim())return n.kind===`tools`?n.tools:null}return null}return(e.tools?.length??0)>0&&!e.text.trim()?e.tools:null}function OD(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||zT(e))return null;if(e.parts&&e.parts.length>0){for(let t of e.parts)if(t.kind===`tools`?t.tools.length>0:t.text.trim())return t.kind===`tools`?t.tools:null;return null}return(e.tools?.length??0)>0?e.tools:null}function kD(e){return DD(e)!==null}function AD(e){return OD(e)!==null}function jD(e){return e.kind===`event`&&!e.boundary||e.kind===`reasoning`}function MD(e){return jD(e)||kD(e)}function ND(e){return jD(e)||AD(e)}function PD(e){if(jD(e))return!0;let t=DD(e);return t!==null&&!Zn(t[t.length-1])}function FD(e){if(jD(e))return!0;let t=OD(e);return t!==null&&!Zn(t[0])}function ID(e){let t=DD(e);return t!==null&&Ya(t[t.length-1])}function LD(e){let t=OD(e);return t!==null&&Ya(t[0])}function RD(e,t){return e.kind!==`event`||e.boundary!==`rest`||!t||!VD(t)?null:vy(e.at,t.at)}function zD({rest:e,at:t}){let{day:n,time:r}=by(t),i=xy(e.at)?.replace(/^(Today|Yesterday)/,e=>e.toLowerCase());return(0,X.jsx)(`div`,{title:i?`Agent rested ${i}`:void 0,className:`contents`,children:(0,X.jsx)(Q,{sourceId:e.sourceId,marker:`rest-gap`,ariaLabel:`${n}, ${r}`,children:(0,X.jsxs)(`time`,{dateTime:t,className:`flex shrink-0 items-center gap-1 tabular-nums`,children:[(0,X.jsx)(`span`,{children:n}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`opacity-50`,children:`·`}),(0,X.jsx)(`span`,{children:r})]})})})}function BD(e,t){if(VD(e)&&VD(t))return 6;let n=ID(e)||LD(t),r=!n&&MD(e)&&ND(t)&&!(PD(e)&&FD(t));return(n?22:r?6:14)+(e.role===`user`&&t.role!==`user`?3:0)}function VD(e){return e.role!==`user`||e.kind===`event`||e.kind===`reasoning`||e.providerError||e.sessionPeer||e.peerFrom||e.agentInstruction?!1:!e.wake||Lg(e)}function HD(e,t,n){return e.kind===`event`||e.kind===`reasoning`||e.role===`user`?!1:e.parts&&e.parts.length>0?e.parts.every(r=>r.kind===`tools`?r.tools.length===0:GD(e,r.text,t,n)):(e.tools?.length??0)===0&&GD(e,e.text,t,n)}function UD(e,t){let n=Date.parse(e??``),r=Date.parse(t??``);return Number.isFinite(r)?Number.isFinite(n)&&n>=r?e:t:e}function WD(e,t,n=!1,r=-1){let i=new WeakSet,a=new WeakSet;if(t>=0)for(let n of e)n.messageIndex<t&&n.messageIndex!==r&&i.add(n.message);if(t>=0&&n)for(let n of e)n.messageIndex===t&&a.add(n.message);return e=>HD(e,i.has(e),a.has(e))}function GD(e,t,n,r){return!e.fenceRefused&&!n&&!r?t.includes("```awaiting")?pg(t).every(e=>e.kind===`fence`&&e.fenceKind===`awaiting`&&Ro(e.hints)&&!ti(e.body)):!t.trim():pg(t).every(t=>t.kind===`fence`&&t.fenceKind===`awaiting`&&(e.fenceRefused||r||!(KD(t.hints)||qD(e,t))))}function KD(e){return za(e).length>0}function qD(e,t){return e.latestSignOff?!Ro(t.hints)||ti(t.body)!==null:!1}function JD(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(fo(n)||HD(n)))return ID(n)?22:MD(n)&&!PD(n)?6:14+(n.role===`user`?3:0)}return 0}function YD(e,t,n){let r=[],i=null;return e.forEach((e,a)=>{n?.(e,a)||HD(e)||(i!==null&&r.push((0,X.jsx)(My,{h:BD(i,e)},`s${a}`)),r.push(t(e,a)),i=e)}),r}function XD(e){let t=[];for(let n of e){if(n.kind===`text`){if(!n.text.trim())continue;t.push(n);continue}if(n.tools.length===0)continue;let e=t[t.length-1];e&&e.kind===`tools`?t[t.length-1]={kind:`tools`,tools:[...e.tools,...n.tools]}:t.push(n)}return t}function ZD(e,t=14){let n=e.filter(e=>e!=null&&e!==!1),r=[];return n.forEach((e,n)=>{let i=n===0?0:typeof t==`number`?t:t(n);i>0&&r.push((0,X.jsx)(My,{h:i},`vs${n}`)),r.push(e)}),r}var QD={head:!1,tail:!1};function $D(e,t){return n=>e[n-1]?.tail||e[n]?.head?22:t}function eO(e){return{head:Ya(e[0]),tail:Ya(e[e.length-1])}}function tO(e){let t=[];for(let n of e){let e=t[t.length-1];if(n.edit){let r=!!(n.input||n.output||n.status||n.exitCode!==void 0);e&&e.edits&&!r&&!e.input&&!e.output&&!e.status&&e.edits[0].file===n.edit.file?e.edits.push(n.edit):t.push({name:n.name,detail:n.detail,edits:[n.edit],input:n.input,output:n.output,status:n.status,backgroundState:n.backgroundState,exitCode:n.exitCode,cwd:n.cwd,sessionId:n.sessionId,durationMs:n.durationMs,count:1})}else n.command?t.push({name:n.name,detail:n.detail,command:n.command,desc:n.desc,input:n.input,output:n.output,status:n.status,backgroundState:n.backgroundState,exitCode:n.exitCode,cwd:n.cwd,sessionId:n.sessionId,durationMs:n.durationMs,count:1}):n.outputImage?t.push({name:n.name,detail:n.detail,outputImage:n.outputImage,output:n.output??n.read,status:n.status,durationMs:n.durationMs,count:1}):n.read?t.push({name:n.name,detail:n.detail,read:n.read,status:n.status,durationMs:n.durationMs,count:1}):n.prompt||n.agentId?t.push({name:n.name,detail:n.detail,prompt:n.prompt,input:n.input,subagentType:n.subagentType,agentId:n.agentId,agentStatus:n.agentStatus,agentElapsedMs:n.agentElapsedMs,output:n.output,status:n.status,durationMs:n.durationMs,count:1}):n.sendTo!==void 0||n.sendBody!==void 0?t.push({name:n.name,detail:n.detail,sendTo:n.sendTo,sendSummary:n.sendSummary,sendBody:n.sendBody,sendType:n.sendType,sendDispatchId:n.sendDispatchId,sendTargetLabel:n.sendTargetLabel,status:n.status,durationMs:n.durationMs,count:1}):n.todos?t.push({name:n.name,detail:n.detail,todos:n.todos,input:n.input,status:n.status,durationMs:n.durationMs,count:1}):ze(n)?t.push({name:n.name,detail:n.detail,ask:n.ask,askAnswers:n.askAnswers,status:n.status,durationMs:n.durationMs,count:1}):n.sentImages||n.sentFiles?t.push({name:n.name,detail:n.detail,sentImages:n.sentImages,sentFiles:n.sentFiles,caption:n.caption,status:n.status,durationMs:n.durationMs,count:1}):n.input||n.output?t.push({name:n.name,detail:n.detail,input:n.input,output:n.output,status:n.status,backgroundState:n.backgroundState,exitCode:n.exitCode,cwd:n.cwd,sessionId:n.sessionId,durationMs:n.durationMs,count:1}):e&&!e.edits&&!e.command&&!e.input&&!e.output&&!e.read&&!e.prompt&&!e.outputImage&&!e.sentImages&&!e.sentFiles&&e.sendTo===void 0&&e.sendBody===void 0&&e.name===n.name&&e.detail===n.detail&&e.status===n.status&&e.backgroundState===n.backgroundState&&e.exitCode===n.exitCode&&e.cwd===n.cwd&&e.sessionId===n.sessionId&&e.durationMs===n.durationMs?e.count++:t.push({name:n.name,detail:n.detail,status:n.status,backgroundState:n.backgroundState,exitCode:n.exitCode,cwd:n.cwd,sessionId:n.sessionId,durationMs:n.durationMs,count:1})}return t}function nO(e){return e.split(`__`).pop()||e}function rO({tools:e,at:t}){let[n,r]=(0,q.useState)(!1),i=(0,q.useId)(),a=e.reduce((e,t)=>e+t.count,0),o=li(a,he(e));return(0,X.jsxs)(`div`,{"data-tool-activity":!0,"data-tool-activity-state":`settled`,className:`flex min-w-0 flex-col`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":i,"aria-expanded":n,"aria-label":`${n?`Collapse`:`Expand`} ${a} tool ${a===1?`call`:`calls`}: ${o}`,className:`group flex w-full min-w-0 items-baseline gap-1.5 rounded -my-0.5 py-0.5 text-left outline-none transition-colors hover:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60 ${ZT}`,children:[(0,X.jsx)(`span`,{"data-tool-activity-label":!0,title:o,className:`min-w-0 truncate text-muted`,children:o}),(0,X.jsx)(vs,{"data-tool-activity-chevron":!0,"aria-hidden":`true`,size:13,className:$T(n)})]}),n&&(0,X.jsx)(`div`,{id:i,className:`mt-1.5 flex flex-col`,children:(0,X.jsx)(iO,{tools:e,at:t})}),!n&&(0,X.jsx)(`div`,{id:i,hidden:!0})]})}function iO({tools:e,at:t}){let n=(0,q.useContext)(db)!==null,r=e=>!ze(e)&&!(n&&(e.sendTo!==void 0||e.sendBody!==void 0));return(0,X.jsx)(X.Fragment,{children:ZD(e.map((e,n)=>(0,X.jsx)(oO,{t:e,startedAt:t},n)),t=>Ya(e[t-1])||Ya(e[t])?22:r(e[t-1])&&r(e[t])?0:6)})}function aO({tools:e,at:t}){let n=[];for(let t of e){let e=Zn(t),r=n[n.length-1];r?.exceptional===e?r.tools.push(t):n.push({exceptional:e,tools:[t]})}return(0,X.jsx)(`div`,{className:`flex flex-col`,children:ZD(n.map((e,n)=>e.exceptional?(0,X.jsx)(`div`,{className:`flex flex-col`,children:(0,X.jsx)(iO,{tools:e.tools,at:t})},`exceptions-${n}`):(0,X.jsx)(rO,{tools:e.tools,at:t},`activity-${n}`)),$D(n.map(e=>eO(e.tools)),6))})}function oO({t:e,startedAt:t}){let n=_o(e,Ne((0,q.useContext)(db))?.bgShells??[]);return e.edits&&e.status!==`failed`&&e.status!==`cancelled`?(0,X.jsx)(gp,{edits:e.edits,meta:(0,X.jsx)(dO,{status:e.status,backgroundState:e.backgroundState,liveBackgroundState:n,exitCode:e.exitCode,durationMs:e.durationMs})}):e.command?(0,X.jsx)(bO,{command:e.command,desc:e.desc??e.detail,literalDesc:e.desc===void 0,output:e.output,status:e.status,backgroundState:e.backgroundState,liveBackgroundState:n,exitCode:e.exitCode,sessionId:e.sessionId,durationMs:e.durationMs,startedAt:t}):e.outputImage?(0,X.jsx)(_O,{name:e.name,detail:e.detail,outputImage:e.outputImage,output:e.output,status:e.status,durationMs:e.durationMs}):e.read?(0,X.jsx)(SO,{detail:e.detail,read:e.read,status:e.status,durationMs:e.durationMs}):e.prompt||e.agentId?(0,X.jsx)(wO,{detail:e.detail,prompt:e.prompt,subagentType:e.subagentType,agentId:e.agentId,agentStatus:e.agentStatus,agentElapsedMs:e.agentElapsedMs,status:e.status,durationMs:e.durationMs}):e.sendTo!==void 0||e.sendBody!==void 0?(0,X.jsx)(EO,{to:e.sendTo,summary:e.sendSummary,body:e.sendBody??``,type:e.sendType,dispatchId:e.sendDispatchId,targetLabel:e.sendTargetLabel,status:e.status,durationMs:e.durationMs,at:t}):e.sentImages||e.sentFiles?(0,X.jsx)(vO,{images:e.sentImages??[],files:e.sentFiles??[],caption:e.caption,status:e.status,durationMs:e.durationMs}):e.todos?(0,X.jsx)(Fh,{todos:e.todos,note:e.input,node:sp(e.status),meta:(0,X.jsx)(dO,{status:e.status,durationMs:e.durationMs})}):ze(e)?(0,X.jsx)(sO,{ask:e.ask??[],askAnswers:e.askAnswers}):e.input||e.output?(0,X.jsx)(bO,{name:e.name,command:e.input??``,desc:e.detail,literalDesc:!0,output:e.output,status:e.status,backgroundState:e.backgroundState,liveBackgroundState:n,exitCode:e.exitCode,sessionId:e.sessionId,durationMs:e.durationMs,inputLabel:`Input`,startedAt:t}):(0,X.jsx)(gO,{name:e.name,detail:e.detail,count:e.count,status:e.status,backgroundState:e.backgroundState,liveBackgroundState:n,exitCode:e.exitCode,cwd:e.cwd,sessionId:e.sessionId,durationMs:e.durationMs,startedAt:t})}function sO({ask:e,askAnswers:t}){return(0,X.jsx)(`div`,{"data-settled-ask":!0,className:`flex flex-col gap-1.5`,children:e.map((e,n)=>{let r=OE(e,t?.[n]);return(0,X.jsx)(Fx,{question:r.question,settled:{chosenIdxs:r.chosenIdxs,text:r.text}},n)})})}function cO({tone:e,indicator:t,label:n,duration:r,title:i}){return(0,X.jsxs)(`span`,{className:`flex shrink-0 items-baseline gap-1 whitespace-nowrap text-[11.5px] leading-none tabular-nums ${e}`,title:i,"aria-label":i,children:[t,(0,X.jsx)(`span`,{children:[n,r].filter(Boolean).join(` · `)})]})}function lO(e,t,n){let[r,i]=(0,q.useState)(()=>Date.now()),a=Tr(e,t),o=so(e,t,n,r);return(0,q.useEffect)(()=>{if(!a||o)return;let e=n?Date.parse(n):NaN;if(!Number.isFinite(e))return;let t=setTimeout(()=>i(Date.now()),Math.max(Oa-(Date.now()-e),0));return()=>clearTimeout(t)},[a,o,n]),o}function uO({status:e,backgroundState:t,liveBackgroundState:n,startedAt:r}){let i=lO(e,t,r),a=n===`running`?(0,X.jsx)(Hr,{"aria-hidden":!0,hue:`shell`,"data-running-indicator":`tool-disclosure`}):n===`stale`?(0,X.jsx)(`span`,{className:Pn,title:Ae}):Bi(e,t)||i?(0,X.jsx)(Hr,{"aria-hidden":!0,hue:`shell`,"data-running-indicator":`tool-disclosure`}):null;return a?(0,X.jsx)(`span`,{className:`frizz-tool-mark`,children:a}):null}function dO({status:e,backgroundState:t,liveBackgroundState:n,exitCode:r,durationMs:i}){if(!e&&i===void 0)return null;let[a,o]=n===`running`?[`running`,`background running`]:n===`stale`?[`stale`,`background stale`]:e===`pending`?t===`unknown`?[`unknown`,`background / unknown`]:[`running`,t===`background`?`background running`:`running`]:e===`failed`?r===void 0?[`failed`,`failed`]:[`exit ${r}`,`exit ${r}`]:e===`cancelled`?[`cancelled`,`cancelled`]:e===`completed`?[void 0,`done`]:[void 0,void 0],s=i===void 0?void 0:Qe(i);if(!a&&!s)return null;let c=[o,s].filter(Boolean).join(` · `);return(0,X.jsx)(cO,{tone:e===`failed`?`frizz-tool-failed`:e===`cancelled`?`text-attention`:`text-faint`,title:c,label:a,duration:s})}function fO(e,t,n){let r=t?Date.parse(t):NaN,i=e===`pending`&&Number.isFinite(r),[a,o]=(0,q.useState)(()=>Date.now());return(0,q.useEffect)(()=>{if(!i)return;let e=()=>o(Date.now()),t,n=setTimeout(()=>{e(),t=setInterval(e,1e3)},1e3-Date.now()%1e3);return()=>{clearTimeout(n),t&&clearInterval(t)}},[i,t]),i?Math.max(a-r,0):n}function pO(e,t,n){let r=t&&t!==W.board?.projectDir?`in ${fp(t)}`:void 0;return[e,t?r:n!==void 0&&!e?.includes(String(n))?`session ${n}`:void 0].filter(Boolean).join(` · `)||void 0}function mO(e){return e.startsWith(`/`)&&!e.includes(` `)&&!e.includes(`…`)}function hO({detail:e,shown:t=e}){return t?e&&mO(e)?(0,X.jsx)(`span`,{className:`min-w-0`,children:(0,X.jsx)(hp,{path:e,children:(0,X.jsx)(pp,{path:fp(e)})})}):(0,X.jsx)(`span`,{className:`frizz-tool-detail frizz-tool-detail--mono`,title:t,children:fp(t)}):null}function gO({name:e,detail:t,count:n,status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,cwd:s,sessionId:c,durationMs:l,startedAt:u}){let d=pO(t,s,c);return(0,X.jsx)(`div`,{className:`frizz-bash`,title:d,"data-tool-node":sp(r),children:(0,X.jsxs)(`div`,{className:`frizz-bash-header`,children:[(0,X.jsxs)(`span`,{className:ap,children:[(0,X.jsx)(uO,{status:r,backgroundState:i,liveBackgroundState:a,startedAt:u}),(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:nO(e)}),(0,X.jsx)(hO,{detail:t,shown:d})]}),(0,X.jsxs)(`span`,{className:op,children:[(0,X.jsx)(dO,{status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,durationMs:l}),n>1&&(0,X.jsxs)(`span`,{className:`tabular-nums text-[11.5px] leading-none text-faint`,children:[`×`,n]}),(0,X.jsx)(mp,{shown:!1})]})]})})}function _O({name:e,detail:t,outputImage:n,output:r,status:i,durationMs:a}){let[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(!1),u=(0,q.useId)(),d=nO(e),f=t?fp(t):void 0;return(0,X.jsxs)(`div`,{"data-tool-image":!0,className:`frizz-bash`,"data-tool-node":sp(i),children:[(0,X.jsxs)(dp,{className:`frizz-bash-header`,controls:u,expanded:o,label:`${o?`Collapse`:`Expand`} ${d}${t?`: ${t}`:``}`,onToggle:()=>s(e=>!e),meta:(0,X.jsx)(dO,{status:i,durationMs:a}),children:[(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:d}),(0,X.jsx)(hO,{detail:t})]}),(0,X.jsx)(`div`,{id:u,className:`frizz-tool-body`,hidden:!o,children:o&&(0,X.jsxs)(X.Fragment,{children:[c?(0,X.jsx)(`div`,{className:`frizz-bash-body break-all text-muted-70`,children:n}):(0,X.jsx)(`div`,{className:`flex justify-center bg-panel-2 p-1.5`,children:(0,X.jsx)(`img`,{src:_e(n),alt:f?`${d}: ${f}`:d,"data-local-path":n,"data-local-image":`true`,onError:()=>l(!0),className:`cursor-zoom-in block max-h-[420px] max-w-full w-auto rounded-md object-contain`})}),r&&(0,X.jsx)(`pre`,{className:`frizz-bash-body frizz-bash-output-body`,children:r})]})})]})}function vO({images:e,files:t,caption:n,status:r,durationMs:i}){let[a,o]=(0,q.useState)(!0),s=(0,q.useId)(),c=(0,q.useMemo)(()=>e.map(e=>({target:e,title:n??`Delivered image`})),[e,n]),l=[e.length?`${e.length} image${e.length===1?``:`s`}`:``,t.length?`${t.length} file${t.length===1?``:`s`}`:``].filter(Boolean).join(` · `);return(0,X.jsxs)(`div`,{className:`frizz-bash`,"data-tool-node":sp(r),children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":s,"aria-expanded":a,"aria-label":`${a?`Collapse`:`Expand`} files sent to you${l?`: ${l}`:``}`,className:`frizz-bash-header w-full text-left outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-focus-ink-60`,children:[(0,X.jsxs)(`span`,{className:ap,children:[(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:`Sent to you`}),l&&(0,X.jsx)(`span`,{className:`frizz-tool-detail`,children:l})]}),(0,X.jsxs)(`span`,{className:op,children:[(0,X.jsx)(dO,{status:r,durationMs:i}),(0,X.jsx)(mp,{open:a})]})]}),(0,X.jsx)(`div`,{id:s,className:`frizz-tool-body`,hidden:!a,children:a&&(0,X.jsxs)(X.Fragment,{children:[e.length>0&&(0,X.jsx)(Jm,{entries:c,framed:!1}),(t.length>0||n)&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-2.5 pb-2.5 pt-1.5`,children:[t.length>0&&(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map((e,t)=>(0,X.jsx)(BO,{path:e},`f${t}`))}),n&&(0,X.jsx)(`div`,{className:`max-w-[65%] font-sans text-[12px] leading-snug text-muted`,children:n})]})]})})]})}var yO=16;function bO({command:e,desc:t,literalDesc:n,output:r,name:i=`Bash`,status:a,backgroundState:o,liveBackgroundState:s,exitCode:c,sessionId:l,durationMs:u,inputLabel:d,startedAt:f}){let[p,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(!1),y=(0,q.useId)(),b=fO(a,f,u),x=(0,q.useMemo)(()=>e.split(`
|
|
137
|
-
`).length,[e]),S=x>yO,C=(0,q.useMemo)(()=>r?r.split(`
|
|
138
|
-
`).length:0,[r]),w=C>yO,T=pO(t,void 0,l),E=!!(e||r);return(0,X.jsxs)(`div`,{className:`frizz-bash`,"data-tool-node":sp(a),children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>E&&m(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":E?y:void 0,"aria-expanded":E?p:void 0,"aria-label":`${E?`${p?`Collapse`:`Expand`} `:``}${nO(i)}${T?`: ${T}`:``}`,className:`frizz-bash-header w-full text-left outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-focus-ink-60`,children:[(0,X.jsxs)(`span`,{className:ap,children:[(0,X.jsx)(uO,{status:a,backgroundState:o,liveBackgroundState:s,startedAt:f}),(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:nO(i)}),(0,X.jsx)(`span`,{className:`frizz-tool-detail${n?` frizz-tool-detail--mono`:``}`,title:T,children:T??``})]}),(0,X.jsxs)(`span`,{className:op,children:[(0,X.jsx)(dO,{status:a,backgroundState:o,liveBackgroundState:s,exitCode:c,durationMs:b}),(0,X.jsx)(mp,{shown:E,open:p})]})]}),E&&(0,X.jsxs)(`div`,{id:y,className:`frizz-tool-body`,hidden:!p,children:[p&&e&&(0,X.jsxs)(X.Fragment,{children:[d&&(0,X.jsx)(`div`,{className:`frizz-bash-output-label`,children:d}),(0,X.jsx)(kh,{text:e,language:d?`plaintext`:`bash`,className:`frizz-bash-body${d?``:` frizz-bash-command`}${S&&!h?` frizz-bash-clamp`:``}`}),S&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>g(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand px-2.5 pb-1.5`,children:h?`Collapse`:`Show all ${x} lines`})]}),p&&r&&(0,X.jsxs)(X.Fragment,{children:[d&&(0,X.jsx)(`div`,{className:`frizz-bash-output-label`,children:`Output`}),(0,X.jsx)(`pre`,{className:`frizz-bash-body frizz-bash-output-body${w&&!_?` frizz-bash-clamp`:``}`,children:r}),w&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>v(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand px-2.5 pb-1.5`,children:_?`Collapse`:`Show all ${C} lines`})]})]})]})}var xO=16;function SO({detail:e,read:t,status:n,durationMs:r}){let[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1),c=(0,q.useId)(),l=(0,q.useMemo)(()=>t.split(`
|
|
139
|
-
`).length,[t]),u=l>xO;return(0,X.jsxs)(`div`,{className:`frizz-bash`,"data-tool-node":sp(n),children:[(0,X.jsxs)(dp,{className:`frizz-bash-header`,controls:c,expanded:i,label:`${i?`Collapse`:`Expand`} Read${e?`: ${e}`:``}`,onToggle:()=>a(e=>!e),meta:(0,X.jsx)(dO,{status:n,durationMs:r}),children:[(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:`Read`}),(0,X.jsx)(hO,{detail:e})]}),(0,X.jsx)(`div`,{id:c,className:`frizz-tool-body`,hidden:!i,children:i&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(kh,{text:t,language:V(e),className:`frizz-bash-body${u&&!o?` frizz-bash-clamp`:``}`}),u&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>s(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand px-2.5 pb-1.5`,children:o?`Collapse`:`Show all ${l} lines`})]})})]})}var CO=16;function wO({detail:e,prompt:t,subagentType:n,agentId:r,agentStatus:i,agentElapsedMs:a,status:o,durationMs:s}){let[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(!1),f=(0,q.useId)(),p=t||`Initial prompt unavailable.`,m=(0,q.useMemo)(()=>p?p.split(`
|
|
140
|
-
`).length:0,[p]),h=m>CO,g=sD(),_=Ne(g),v=!i&&r?(_?.subAgents??[]).find(e=>e.id===r):void 0,y=v?.state===`running`,b=!!(g&&r),x=e??`sub-agent`,S=Po(n),C=da(),T=WT({agentStatus:i,agentElapsedMs:a,liveState:v?.state,liveElapsedMs:v?.startedAt?Math.max(C-Date.parse(v.startedAt),0):void 0,status:o,durationMs:s}),E=y?(0,X.jsx)(Hr,{"aria-hidden":!0,hue:`agent`,"data-running-indicator":`subagent-disclosure`}):v?.state===`stale`?(0,X.jsx)(`span`,{className:Pn,title:En}):v?.state===`rested`?(0,X.jsx)(`span`,{className:ws,title:w}):null;function D(){!g||!r||Er(g,r,{label:x,subagentType:n,startedAt:v?.startedAt})}return(0,X.jsxs)(`div`,{className:`frizz-bash`,"data-tool-node":T?.tone===`failed`?`failed`:void 0,children:[(0,X.jsxs)(dp,{className:`frizz-bash-header`,controls:f,expanded:c,label:`${c?`Collapse`:`Expand`} Agent dispatch: ${x}`,onToggle:()=>l(e=>!e),meta:(S||T)&&(0,X.jsxs)(`span`,{className:`flex shrink-0 items-baseline gap-2.5`,children:[S&&(0,X.jsx)(`span`,{"data-subagent-profile":!0,className:`shrink-0 whitespace-nowrap text-[11.5px] leading-none text-faint`,title:`Sub-agent profile: ${S}`,children:S}),T&&(0,X.jsx)(cO,{tone:T.tone===`failed`?`frizz-tool-failed`:`text-faint`,title:T.title,label:T.label,duration:T.duration})]}),children:[E&&(0,X.jsx)(`span`,{className:`frizz-tool-mark`,children:E}),(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:`Agent`}),b?(0,X.jsx)(`button`,{type:`button`,"aria-label":`Open sub-agent transcript: ${x}`,title:`Open sub-agent transcript`,onClick:D,className:`frizz-tool-detail frizz-tool-drill min-w-[4rem] flex-1 text-left outline-none`,children:x}):(0,X.jsx)(`span`,{className:`frizz-tool-detail min-w-[4rem] flex-1`,title:x,children:x})]}),(0,X.jsx)(`div`,{id:f,className:`frizz-tool-body`,hidden:!c,children:c&&(0,X.jsxs)(X.Fragment,{children:[p&&(0,X.jsx)(`pre`,{className:`frizz-bash-body frizz-tool-prose${h&&!u?` frizz-bash-clamp`:``}`,children:p}),h&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>d(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand px-2.5 pb-1.5`,children:u?`Collapse`:`Show all ${m} lines`})]})})]})}function TO(e,t){return t===`shutdown_request`?`Shutdown`:t===`codex_followup`?`Followed up`:e===`main`?`Reported`:`Steered`}function EO({to:e,summary:t,body:n,type:r,dispatchId:i,targetLabel:a,status:o,durationMs:s,at:c}){return(0,q.useContext)(db)===null?(0,X.jsx)(OO,{to:e,summary:t,body:n,type:r,status:o,durationMs:s}):(0,X.jsx)($O,{to:e,type:r,dispatchId:i,targetLabel:a,at:c})}var DO=16;function OO({to:e,summary:t,body:n,type:r,status:i,durationMs:a}){let[o,s]=(0,q.useState)(!t),[c,l]=(0,q.useState)(!1),u=(0,q.useId)(),d=jf(n),f=(0,q.useMemo)(()=>n.split(`
|
|
141
|
-
`).length,[n]),p=f>DO,m=!!n.trim(),h=TO(e,r);return(0,X.jsxs)(`div`,{className:`frizz-bash`,"data-tool-node":sp(i),children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":m?u:void 0,"aria-expanded":m?o:void 0,"aria-label":`${m?`${o?`Collapse`:`Expand`} `:``}${h}${e?` to ${e}`:``}`,className:`frizz-bash-header w-full text-left outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-focus-ink-60`,disabled:!m,children:[(0,X.jsxs)(`span`,{className:ap,children:[(0,X.jsx)(`span`,{className:`frizz-bash-label shrink-0`,children:h}),t&&(0,X.jsx)(`span`,{className:`frizz-tool-detail`,children:t})]}),(0,X.jsxs)(`span`,{className:op,children:[(0,X.jsx)(dO,{status:i,durationMs:a}),(0,X.jsx)(mp,{shown:m,open:o})]})]}),m&&(0,X.jsx)(`div`,{id:u,className:`frizz-tool-body`,hidden:!o,children:o&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`px-2.5 py-2${p&&!c?` frizz-bash-clamp`:``}`,children:(0,X.jsx)(Oh,{className:`md-body`,html:d})}),p&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand px-2.5 pb-1.5`,children:c?`Collapse`:`Show all ${f} lines`})]})})]})}function kO({body:e,items:t}){let[n,r]=(0,q.useState)(null),i=(0,q.useMemo)(()=>new Map(t.map(e=>[e.token,e])),[t]),a=n===null?void 0:i.get(n);return(0,X.jsxs)(X.Fragment,{children:[(0,q.useMemo)(()=>gi(e,[...i.keys()]),[e,i]).map((e,t)=>{let a=e.token?i.get(e.token):void 0;if(!a)return(0,X.jsx)(sb,{text:e.text},t);let o=n===a.token;return(0,X.jsx)(`button`,{type:`button`,title:a.display,"aria-expanded":o,onClick:e=>{e.stopPropagation(),r(o?null:a.token)},onKeyDown:e=>e.stopPropagation(),className:`inline-flex max-w-56 items-baseline rounded border px-1 align-baseline font-mono-keep text-[11px] leading-snug transition-colors ${o?`border-bg/40 bg-bg/15`:`border-bg/25 bg-bg/[0.08] hover:bg-bg/15`}`,children:(0,X.jsx)(`span`,{className:`truncate`,children:Ka(a.token)})},t)}),a&&(0,X.jsxs)(`span`,{className:`mt-2 block cursor-auto rounded-md border border-bg/20 bg-bg/[0.06] px-2 py-1.5`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`span`,{className:`block truncate font-mono-keep text-[11px] text-user-bubble-fg/60`,children:[a.display,a.startLine===void 0?``:` · ${a.startLine===a.endLine?`line ${a.startLine}`:`lines ${a.startLine}-${a.endLine}`}`]}),(0,X.jsx)(`span`,{className:`mt-1 block max-h-40 overflow-y-auto whitespace-pre-wrap break-words font-mono-keep text-[11.5px] leading-4 text-user-bubble-fg/80`,children:a.text})]})]})}function AO({deliveryId:e,text:t,rawText:n,error:r}){let i=(0,q.useContext)(db),{retry:a,edit:o,dismiss:s,pending:c}=mC(i),l=`rounded-md border border-border-strong bg-panel-2/60 px-2.5 py-1 text-[12px] font-medium text-fg/80 outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60 disabled:opacity-45 disabled:hover:bg-panel-2/60 disabled:hover:text-fg/80`;return(0,X.jsxs)(`div`,{"data-failed-send":e,className:`mt-1 flex flex-col items-end gap-1.5`,children:[(0,X.jsxs)(`div`,{role:`alert`,className:`text-left text-[12px] leading-snug text-danger-soft [overflow-wrap:anywhere]`,children:[`Not delivered`,r?` — ${r.split(`
|
|
142
|
-
`,1)[0]}`:``]}),i&&(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`button`,{type:`button`,className:l,disabled:c,title:`Send this message again`,onClick:()=>a({deliveryId:e,text:n}),children:`Retry`}),(0,X.jsx)(`button`,{type:`button`,className:l,disabled:c,title:`Put this message back in the prompt box`,onClick:n=>o({deliveryId:e,text:t,from:n.currentTarget}),children:`Edit`}),(0,X.jsx)(`button`,{type:`button`,className:l,disabled:c,title:`Discard this message`,onClick:()=>s({deliveryId:e}),children:`Dismiss`})]})]})}function jO(){let e=(0,q.useContext)(db),t=(0,q.useContext)(pb),n=Hb(e),r=Vb(e),i=Kb(e);if(!e||!t)return null;let a=Rb(t,n,r);if(!a)return r||t.held+t.steered===0?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(My,{h:6}),(0,X.jsx)(`div`,{"data-queued-waits-for-turn":!0,className:`flex items-baseline justify-end text-[11.5px] leading-[16px] text-muted`,children:`Waits for this turn to end`})]});let o=t.held>1?`Send the next one now — the agent reads it at its next step`:`Send it now — the agent reads it at its next step`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(My,{h:6}),(0,X.jsx)(`div`,{"data-queued-send-now":a,className:`flex items-baseline justify-end text-[11.5px] leading-[16px] text-muted`,children:(0,X.jsxs)(`button`,{type:`button`,"data-send-now":!0,onMouseDown:e=>e.preventDefault(),onClick:()=>qb(e,t),disabled:i,"aria-keyshortcuts":`Meta+Enter Control+Enter`,title:`${a===`release`?o:`Send now — the worker reads the queue immediately, and a command it is running carries on in the background`} (⌘⏎)`,className:`relative flex cursor-pointer items-baseline outline-none transition-colors duration-50 before:absolute before:-inset-x-2 before:-inset-y-1 before:content-[''] hover:text-fg focus-visible:text-fg disabled:cursor-default disabled:opacity-50`,children:[i?(0,X.jsx)(E,{"aria-hidden":!0,className:`mr-1 size-[1em] shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)] animate-spin`,strokeWidth:2.4}):(0,X.jsx)(`span`,{"aria-hidden":!0,className:`mr-[0.44em] shrink-0`,children:(0,X.jsx)(`kbd`,{className:`send-now-key`,children:`⌘⏎`})}),(0,X.jsx)(`span`,{className:`underline decoration-border underline-offset-2`,children:`Send now`})]})})]})}function MO({m:e,answers:t,note:n}){let r=(t,n)=>{if(!t)return null;let i=n<2?Ng(t):null;return i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(cb,{answers:i,queued:e.queued}),r(Tg(t),n+1)]}):(0,X.jsx)(NO,{text:t,rawText:e.text,queued:e.queued})};return(0,X.jsxs)(`div`,{"data-frizz-msg":e.sourceId,"data-answers-with-note":!0,className:`flex w-full flex-col gap-2 self-end`,children:[(0,X.jsx)(cb,{answers:t,queued:e.queued}),r(n,0)]})}function NO({text:e,rawText:t,queued:n,held:r,deliveryUnconfirmed:i,deliveryFailed:a,deliveryError:o,deliveryId:s,sourceId:c}){let l=(0,q.useContext)(db),u=lC(l),{unqueue:d,pending:f}=pC(l),p=!!(n&&s&&l&&(u||r)),{prose:m,attachments:h}=(0,q.useMemo)(()=>Ti(e),[e]),g=(0,q.useMemo)(()=>$r(m),[m]);return(0,X.jsxs)(`div`,{"data-frizz-msg":c,className:`self-end flex flex-col items-end gap-0.5 max-w-[85%]`,children:[m.trim()!==``&&(0,X.jsx)(`div`,{...p?{role:`button`,tabIndex:0,"data-unqueue":s,"aria-label":`Unqueue this message and put it back in the prompt box`,title:f?`Taking it back…`:void 0,onClick:n=>d({deliveryId:s,text:e,rawText:t??e,from:n.currentTarget}),onKeyDown:n=>{n.key!==`Enter`&&n.key!==` `||(n.preventDefault(),d({deliveryId:s,text:e,rawText:t??e,from:n.currentTarget}))}}:{},className:`relative rounded-xl rounded-br-sm bg-user-bubble px-3.5 py-3 text-[14px] whitespace-pre-wrap [overflow-wrap:anywhere] text-user-bubble-fg ${n||a?`opacity-50`:``} ${p?`cursor-pointer transition-opacity hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-bg`:``} ${f?`!opacity-30`:``}`,children:g?(0,X.jsx)(kO,{body:g.body,items:g.items}):(0,X.jsx)(sb,{text:m})}),h.length>0&&(0,X.jsxs)(`div`,{className:`mt-1 flex flex-col items-end gap-1.5`,children:[h.filter(e=>e.kind===`image`).map((e,t)=>(0,X.jsx)(zO,{path:e.path,hideCaption:!0},`i${t}-${e.path}`)),h.some(e=>e.kind===`file`)&&(0,X.jsx)(`div`,{className:`flex flex-wrap justify-end gap-1.5`,children:h.filter(e=>e.kind===`file`).map((e,t)=>(0,X.jsx)(BO,{path:e.path},`f${t}-${e.path}`))})]}),i&&(0,X.jsx)(`div`,{className:`text-[11px] text-attention-80`,children:`Delivery unconfirmed — no receipt from the worker`}),a&&s&&(0,X.jsx)(AO,{deliveryId:s,text:e,rawText:t??e,error:o}),p&&f&&(0,X.jsx)(`div`,{"aria-hidden":!0,className:`h-0 overflow-visible text-[11px] text-muted`,children:`Taking it back…`})]})}function PO({m:e,index:t,showSendButton:n}){let r=AS(),[i,a]=r.hidesAwaiting(t);return(0,X.jsx)(FO,{m:e,showSendButton:n,answering:r.fencesLive?r.answeringForMessage(e):void 0,paired:r.paired[t],staleAwaiting:i,restingCardShown:a,stepsDone:r.stepsDone.get(t),shadowedBy:r.shadowedByMessage.get(t),placed:r.placement.placed.get(t),settledPlaced:r.settledPlacement.placed.get(t),fenceQuestions:r.fenceQuestions,index:t,questionHomes:r.questionHomes})}var FO=(0,q.memo)(function(e){return(0,X.jsx)(`div`,{title:(e.m.queued?null:xy(e.m.at))??void 0,className:`contents`,children:(0,X.jsx)(LO,{...e})})});function IO({error:e}){let t=(0,q.useContext)(db);return(0,X.jsx)(Cg,{error:e,provider:(0,q.useSyncExternalStore)(e=>Mo(W,e),()=>{let e=t?Qr(W.board,t):void 0;return Pe(e?.backend,e?.model)},()=>`Agent`)})}function LO({m:e,answering:t,paired:n,showSendButton:r,staleAwaiting:i,shadowedBy:a,placed:o,settledPlaced:s,fenceQuestions:c,index:l,questionHomes:u,restingCardShown:d,stepsDone:f}){let p=pt(),[m,h]=(0,q.useState)(!1),g=Q_();if(e.providerError)return(0,X.jsx)(IO,{error:e.providerError});if(e.kind===`event`)return(0,X.jsx)(ek,{text:e.text,boundary:e.boundary,sourceId:e.sourceId,at:e.at});if(e.kind===`reasoning`)return(0,X.jsx)(tk,{text:e.text,sourceId:e.sourceId});let _=zT(e);if(_)return(0,X.jsx)(ZO,{call:_,sourceId:e.sourceId,at:e.at});if(e.role===`user`){let t=Gg(e).replace(/\r\n?/g,`
|
|
143
|
-
`),r=n===void 0?Ng(t):n;if(r&&e.deliveryState!==`failed`){let n=Tg(t);return!n&&e.deliveryState!==`held`?(0,X.jsx)(cb,{answers:r,queued:e.queued,sourceId:e.sourceId}):(0,X.jsx)(MO,{m:e,answers:r,note:n})}return e.wake?(0,X.jsx)(Fy,{steer:e.wakeSteer,text:t,sourceId:e.sourceId,at:e.at}):e.sessionPeer?(0,X.jsx)(bC,{peer:e.sessionPeer,text:t,queued:e.queued,sourceId:e.sourceId,at:e.at}):e.peerFrom?(0,X.jsx)(QO,{from:e.peerFrom,unnamed:e.peerUnnamed,dispatchId:e.peerDispatchId,sourceId:e.sourceId,at:e.at}):(0,X.jsx)(NO,{text:t,rawText:e.text,queued:e.queued,held:e.deliveryState===`held`,deliveryUnconfirmed:e.deliveryState===`unconfirmed`,deliveryFailed:e.deliveryState===`failed`,deliveryError:e.deliveryError,deliveryId:e.deliveryId,sourceId:e.sourceId})}let v=[],y=[],b=(e,t=QD)=>{v.push(e),y.push(t)},x={n:-1},S=[],C=new Set,w,T=()=>w??=new Set(Gh(e.text,e.refusedFences)),E=(n,r)=>{for(let[m,h]of pg(n).entries()){if(h.kind===`fence`){if(h.fenceKind===`awaiting`&&i&&!e.fenceRefused&&!d&&KD(h.hints)){b((0,X.jsx)(gy,{fence:{body:h.body,hints:h.hints},stepsDone:f},`${r}-f${m}`));continue}if(h.fenceKind===`awaiting`&&i&&!e.fenceRefused&&!d&&e.latestSignOff){if(Ro(h.hints)){let e=ti(h.body);e&&b((0,X.jsx)(RO,{md:e},`${r}-f${m}`))}else b((0,X.jsx)(gy,{fence:{body:h.body,hints:h.hints}},`${r}-f${m}`));continue}if(h.fenceKind===`awaiting`&&(e.fenceRefused||i||d))continue;if(h.fenceKind===`awaiting`&&Ro(h.hints)){let e=ti(h.body);e&&b((0,X.jsx)(RO,{md:e},`${r}-f${m}`));continue}b((0,X.jsx)(GO,{fenceKind:h.fenceKind,body:h.body,hints:h.hints,pastRest:i},`${r}-f${m}`));continue}for(let[n,i]of Bh(h.text,c!==void 0,e.refusedFences).entries()){if(i.kind===`prose`){for(let[e,t]of vr(i.text).entries()){let i=`${r}-${m}-p${n}-${e}`;b(t.kind===`image`?(0,X.jsx)(zO,{path:t.path},i):t.kind===`file`?(0,X.jsx)(BO,{path:t.path},i):t.kind===`visualization`?(0,X.jsx)(UO,{file:t.file},i):t.kind===`directive`?(0,X.jsx)(Cm,{directive:t.directive},i):t.kind===`mermaid`?(0,X.jsx)(Om,{source:t.source},i):t.kind===`lightbox`?(0,X.jsx)(Jm,{entries:t.entries},i):(0,X.jsx)(RO,{md:t.text},i))}continue}if(i.kind===`refusedRef`){let t=d_(i.id,c??[],e.questionOwners)?.closed;b((0,X.jsx)(bS,{id:i.id,closed:t},`${r}-${m}-r${n}`));continue}if(i.kind===`refusedAsk`){b((0,X.jsx)(_S,{spec:i.spec,reasons:e.refusedReasons?.get(i.id.toLowerCase())},`${r}-${m}-x${n}`));continue}if(i.kind===`invalidFence`){b(i.draft?(0,X.jsx)(_S,{spec:i.draft,reasons:i.faults,unread:!0},`${r}-${m}-i${n}`):(0,X.jsx)(vS,{faults:i.faults,children:(0,X.jsx)(RO,{md:`<details>\n<summary>What the worker wrote</summary>\n\n${i.text}\n\n</details>`})},`${r}-${m}-i${n}`));continue}x.n+=1;let d=x.n;if(i.fence){let t=i.fence.form===`ask`?i.fence.when:void 0;if(t&&!T().has(t.parent.toLowerCase()))continue;let a=d_(t?t.parent:i.fence.id,c??[],e.questionOwners);if(a&&C.has(a.id))continue;if(a?.closed){let e=i.fence.form===`ask`&&!t?i.fence.spec:void 0,o=e??a.asked;o&&(C.add(a.id),b((0,X.jsx)(mS,{spec:o,state:a.closed,copyOf:e?void 0:a.id},`${r}-${m}-q${n}`)));continue}if(a){C.add(a.id);let e=o?.find(e=>e.id===a.id);if(e){b((0,X.jsx)(SS,{q:e},`${r}-${m}-q${n}`));continue}let t=s?.find(e=>e.id===a.id);if(t){b((0,X.jsx)(oS,{s:t},`${r}-${m}-q${n}`));continue}let i=cS(a),c=u?.get(a.id);b(i?(0,X.jsx)(oS,{s:i,copy:!0},`${r}-${m}-q${n}`):(0,X.jsx)(gS,{q:a,above:c!==void 0&&l!==void 0&&c<l},`${r}-${m}-q${n}`));continue}i.fence.form===`ask`&&!t&&!C.has(`fence:${i.fence.id}`)&&(C.add(`fence:${i.fence.id}`),b((0,X.jsx)(pS,{spec:i.fence.spec},`${r}-${m}-q${n}`)));continue}let f=o&&i.registeredId?o.find(e=>e.id.toLowerCase()===i.registeredId):void 0;if(f&&!C.has(f.id)){C.add(f.id),b((0,X.jsx)(SS,{q:f},`${r}-${m}-q${n}`));continue}if(a&&l_(i,a)!==void 0)continue;let h=s&&i.registeredId?s.find(e=>e.id.toLowerCase()===i.registeredId):void 0;if(h&&!C.has(h.id)){C.add(h.id),b((0,X.jsx)(oS,{s:h},`${r}-${m}-q${n}`));continue}if(i.registeredId&&i.text.trim()===``)continue;t&&S.push({raw:i.text,kind:i.questionKind,danger:i.danger,bi:d});let g=t&&!p?{answer:t.answerFor(d),onChip:(e,n)=>t.onChip(d,e,n),onText:e=>t.onText(d,e),onSubmit:t.onSubmit}:void 0;b((0,X.jsx)(Fx,{raw:i.text,questionKind:i.questionKind,danger:i.danger,interactive:g},`${r}-${m}-q${n}`))}}};if(e.parts&&e.parts.length>0)XD(e.parts).forEach((t,n)=>{if(t.kind===`tools`){let r=tO(t.tools);r.length&&b((0,X.jsx)(aO,{tools:r,at:e.at},`t${n}`),eO(r))}else E(t.text,`x${n}`)});else{let t=tO(e.tools);t.length>0&&b((0,X.jsx)(aO,{tools:t,at:e.at},`tools`),eO(t)),E(e.text,`leg`)}return v.length===0?null:(r&&t&&p&&S.length>0?b((0,X.jsx)(`div`,{className:`flex justify-start`,children:(0,X.jsx)(`button`,{type:`button`,"data-mobile-answer-open":!0,onClick:()=>h(!0),className:`button-outline flex h-[40px] items-center justify-center rounded-[12px] bg-accent-fill px-4 text-[15px] font-semibold text-on-accent active:brightness-90`,children:S.length>1?`Answer ${S.length} questions`:`Answer`})},`answer-open`)):r&&t&&S.length>0&&!g&&b((0,X.jsx)(`div`,{className:`flex justify-start`,children:(0,X.jsx)(`button`,{type:`button`,"data-send-answers":!0,disabled:!t.anyAnswered||t.sending,onClick:t.onSubmit,onMouseDown:e=>e.preventDefault(),className:`button-outline rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-all hover:opacity-90 active:scale-95 disabled:opacity-30 disabled:hover:opacity-30`,children:`Send answers`})},`send-answers`)),(0,X.jsxs)(`div`,{"data-frizz-msg":e.sourceId,className:`flex flex-col text-[13px] min-w-0`,children:[ZD(v,$D(y,14)),m&&t&&S.length>0?(0,X.jsx)(IS,{blocks:S,answering:t,onClose:()=>h(!1)}):null]}))}function RO({md:e,wrap:t}){let n=jf(e);return n?(0,X.jsx)(Oh,{className:`md-body${t?` ${zp}`:``}`,html:n}):null}function zO({path:e,hideCaption:t,altText:n}){let[r,i]=(0,q.useState)(!1);if(r)return(0,X.jsx)(`div`,{className:`font-mono-keep text-[12px] text-muted-70 break-all`,children:e});let a=Mi(e);return(0,X.jsx)(Wd,{caption:t?void 0:(0,X.jsx)(`figcaption`,{className:`bg-panel-2 px-2 pb-1.5 font-mono-keep text-[11px] text-muted-60 break-all`,children:a}),children:(0,X.jsx)(`img`,{src:_e(e),alt:n??a,"data-local-path":e,"data-local-image":`true`,onError:()=>i(!0),className:`cursor-zoom-in ${qd}`})})}function BO({path:e}){let t=Mi(e);return(0,X.jsxs)(`button`,{type:`button`,className:`local-file-action inline-flex max-w-full items-center gap-1.5 ${Bp} border border-border bg-panel-2 px-3 py-1.5 text-left align-top no-underline hover:border-accent`,"data-local-path":e,title:e,children:[(0,X.jsx)(u,{size:14,strokeWidth:2,className:`shrink-0 text-muted`}),(0,X.jsx)(`span`,{className:`font-mono-keep truncate text-[12px] text-fg`,children:t})]})}var VO={"--background":`--color-bg`,"--foreground":`--color-fg`,"--card":`--color-panel-2`,"--card-foreground":`--color-fg`,"--popover":`--color-elevated`,"--popover-foreground":`--color-fg`,"--primary":`--color-fg`,"--primary-foreground":`--color-bg`,"--secondary":`--color-panel-2`,"--secondary-foreground":`--color-fg`,"--muted":`--color-panel-2`,"--muted-foreground":`--color-muted`,"--accent":`--color-border-strong`,"--accent-foreground":`--color-fg`,"--border":`--color-border-strong`,"--input":`--color-control-strong`,"--ring":`--color-accent`,"--destructive":`--viz-destructive`,"--viz-series-1":`--viz-series-1`,"--viz-series-2":`--viz-series-2`,"--viz-series-3":`--viz-series-3`,"--viz-series-4":`--viz-series-4`,"--viz-series-5":`--viz-series-5`,"--viz-series-6":`--viz-series-6`};function HO(e){let t=getComputedStyle(document.documentElement),n=Object.fromEntries(Object.entries(VO).map(([e,n])=>[e,t.getPropertyValue(n).trim()]));return n[`--font-size-base`]=getComputedStyle(document.body).fontSize,xC(e,t.colorScheme===`light`?`light`:`dark`,n)}function UO({file:e}){let t=(0,q.useContext)(db),n=(0,q.useRef)(null),[r,i]=(0,q.useState)(360),[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)(null),l=(0,q.useRef)(void 0),u=(0,q.useRef)(0),d=(0,q.useRef)(null),{resolved:f}=(0,q.useSyncExternalStore)(Nt,_t,_t),p=t?Fe(t):null,m=t?`${p?jn(p.project):at()}/local-visualization?slug=${encodeURIComponent(p?.slug??t)}&file=${encodeURIComponent(e)}`:null;(0,q.useEffect)(()=>{if(!m){o(!1);return}let e=new AbortController;return o(null),c(null),d.current=null,window.clearTimeout(l.current),fetch(m,{method:`HEAD`,signal:e.signal}).then(t=>{e.signal.aborted||o(t.ok)}).catch(()=>{e.signal.aborted||o(!1)}),()=>e.abort()},[m]);let h=(0,q.useCallback)(()=>{if(!m||d.current!==m)return;let e=++u.current;n.current?.contentWindow?.postMessage(HO(e),`*`)},[m]);return(0,q.useEffect)(()=>{let e=e=>{if(e.source!==n.current?.contentWindow)return;if(e.data?.type===`frizz-inline-vis-ready`){h();return}if(SC(e.data,u.current)&&m&&d.current===m){window.clearTimeout(l.current),c(m);return}if(e.data?.type!==`frizz-inline-vis-height`)return;let t=Number(e.data.height);Number.isFinite(t)&&i(Math.max(80,Math.min(2400,Math.ceil(t))))};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[h,m]),(0,q.useEffect)(()=>{h()},[f,h]),(0,q.useEffect)(()=>()=>window.clearTimeout(l.current),[]),a===!1||!m?(0,X.jsxs)(`div`,{role:`status`,className:`${Bp} border border-border bg-panel-2 px-4 py-2.5 text-[12px] text-muted`,children:[`Visualization unavailable: `,(0,X.jsx)(`span`,{className:`font-mono-keep break-all`,children:e})]}):a===null?(0,X.jsx)(`div`,{role:`status`,className:`h-20 animate-pulse ${Bp} bg-panel-2`,"aria-label":`Loading ${e}`}):(0,X.jsx)(`iframe`,{ref:n,src:m,title:e.replace(/\.html$/,``).replaceAll(`-`,` `),sandbox:`allow-scripts`,onLoad:()=>{m&&(c(null),d.current=m,h(),window.clearTimeout(l.current),l.current=window.setTimeout(()=>o(!1),5e3))},className:`block w-full border-0 bg-transparent`,style:{height:r,visibility:s===m?`visible`:`hidden`}})}function WO(e,t,n){return e?.kind===`awaiting`&&e.body===t&&JSON.stringify(e.hints)===JSON.stringify(n)}function GO({fenceKind:e,body:t,hints:n,pastRest:r}){let i=jf(t),a=(0,q.useContext)(db),o=(0,q.useContext)(fb),s=Ne(a),c=s?F_(s):void 0,l=!!(s&&c?.archive),u=(0,q.useRef)(null);l&&s&&(u.current=s);let d=l&&s?s:u.current,f=pt();if(e===`done`){let e=uo(n),t=d&&!f&&!r?(0,X.jsx)(tm,{children:(0,X.jsx)(Yw,{thread:d,className:`${am} text-[11px] ${im}`,iconClassName:U_,onArchived:o?.dismiss,onDismissCancel:o?.cancel})}):null;return(0,X.jsx)($p,{icon:v,kind:`Done`,label:e?(0,X.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:e}):null,ruled:!!i,children:i||t?(0,X.jsxs)(X.Fragment,{children:[i&&(0,X.jsx)(Oh,{className:`md-body`,html:i}),t]}):null})}return s&&py(s)&&WO(s.lastFence,t,n)?null:(0,X.jsx)(gy,{thread:s,fence:{body:t,hints:n}})}function KO({slug:e,sessionId:t,fault:n,retryText:r}){let[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1),c=G(),l=It[n.backend],u=t=>{s(!0),Fi(c,e,t,{onSuccess:()=>{s(!1),K(`Retrying with the previous message…`)},onRollback:()=>s(!1),failureToast:e=>`Retry failed: ${e.slice(0,80)}`})||s(!1)};return(0,X.jsxs)($p,{"data-provider-fault":!0,tone:`danger`,icon:Vs,label:`${l} sign-in required`,children:[(0,X.jsx)(`span`,{className:em,children:`The provider rejected this session's credential. Sign in, then retry.`}),(0,X.jsxs)(tm,{children:[r?.trim()&&(0,X.jsx)(`button`,{onClick:()=>u(r),disabled:o,onMouseDown:e=>e.preventDefault(),className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel disabled:opacity-60`,children:`Retry`}),(0,X.jsx)(`button`,{onClick:()=>a(!0),onMouseDown:e=>e.preventDefault(),className:om,children:`Sign in`})]}),i&&(0,X.jsx)(O,{backend:n.backend,onClose:()=>a(!1),onAuthed:()=>a(!1)})]})}function qO({slug:e,sessionId:t,pause:n}){let r=n.backend===`acp`?`The agent`:n.backend===`opencode`?`OpenCode`:It[n.backend],i=n.window===`weekly`?`weekly limit`:n.window===`session`?`5-hour limit`:`usage limit`,[a,o]=(0,q.useState)(!1),s=G();return(0,X.jsxs)($p,{"data-limit-pause":!0,tone:`caution`,icon:Jo,label:`Paused by the ${r} ${i}`,children:[(0,X.jsx)(`span`,{className:em,children:n.autoResume?n.resumesAt?`Continuing automatically at ${We(n.resumesAt)}.`:`Continuing automatically once the window resets.`:`Continue it whenever you have capacity again.`}),(0,X.jsx)(tm,{children:(0,X.jsx)(`button`,{onClick:()=>{o(!0),Fi(s,e,`Continue exactly where you left off.`,{onSuccess:()=>{o(!1),K(`Continuing…`)},onRollback:()=>o(!1),failureToast:e=>`Continue failed: ${e.slice(0,80)}`})||o(!1)},disabled:a,onMouseDown:e=>e.preventDefault(),className:`disabled:opacity-45 ${om}`,children:`Continue now`})})]})}function JO({policy:e,denies:t}){let n=[e.tool,e.command].filter(Boolean).join(`: `);return(0,X.jsxs)($p,{tone:`caution`,icon:pr,label:`Blocked by frizz's permission policy`,children:[n?(0,X.jsx)(`code`,{className:`mb-1.5 block min-w-0 break-all rounded bg-panel px-1.5 py-1 text-[11px] text-fg/85`,children:n}):null,(0,X.jsx)(`span`,{className:em,children:e.reason}),(0,X.jsxs)(`span`,{className:`mt-1.5 block text-[11px] text-muted`,children:[`Rule `,(0,X.jsx)(`code`,{className:`rounded bg-panel px-1 py-0.5`,children:e.rule}),t&&t>1?` · ${t} denials this session`:``]})]})}function YO({slug:e,className:t=`px-4 pb-2 pt-1`,includeAgents:n=!0,only:r,transcriptShells:i=[],parentAgentId:a,density:o=`sheet`}){let s=Ne(e),c=s?.subAgents??[],l=n?a?dr(c,a):c:[],u=s&&!a?z_(s,i):void 0,d=r&&r!==`shell`?[]:a?[...i]:u?.shells??[],f=!u||r&&r!==`pr`&&r!==`issue`?[]:r===`pr`?u.prs:r===`issue`?u.issues:[...u.prs,...u.issues],p=u?r===`file`?u.files:r===`link`?u.links:r?[]:s?.links??[]:[],m=l.length+d.length+f.length,h=V_(s),[,g]=(0,q.useState)(0);(0,q.useEffect)(()=>{if(m===0)return;let e=setInterval(()=>g(e=>e+1),3e4);return()=>clearInterval(e)},[m]);let _=te(e,d.flatMap(e=>e.id&&!e.outputUnavailable?[e.id]:[]));return m===0&&p.length===0?null:(0,X.jsxs)(`div`,{className:`flex flex-col ${o===`panel`?``:`gap-0.5`} ${t}`,"data-background-ops":!0,children:[To(l,`sheet`).map((t,n)=>(0,X.jsx)(Qi,{kind:`AGENT`,label:t.label,state:t.state,density:o,depth:t.displayDepth??t.depth,startedAt:t.startedAt,onOpen:t.id?()=>Er(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:es(e,t)},`a${n}`)),To(d,`sheet`).map((t,n)=>(0,X.jsx)(Qi,{kind:`SHELL`,label:t.label,state:t.state,density:o,startedAt:t.startedAt,counter:t.id?ai(_.get(t.id)):void 0,counterTitle:`Lines of output so far — open the row to read them`,onOpen:t.id&&!t.outputUnavailable?()=>ka(e,t.id,{label:t.label,startedAt:t.startedAt}):void 0,onDismiss:es(e,t,`SHELL`),title:h(t)?`${t.label}\n${H_}`:void 0},`s${n}`)),f.map(e=>(0,X.jsx)(Qi,{kind:`GITHUB`,label:e.target,state:`running`,density:o,startedAt:e.createdAt,counter:e.subject===`issue`?Jt(e.issue):Xn(e.github),counterTone:e.github?.checks===`failing`&&!qa(e.github,Date.now())?`danger`:void 0,counterTitle:e.subject===`issue`?e.issue?`${e.target} — ${Uv(e.issue)}`:void 0:e.github?`${e.target} — ${jv(e.github)}`:void 0,onOpen:()=>window.open(Ja(e.target,e.subject===`issue`?`issue`:`pull`)??`https://github.com/${e.target.replace(`#`,e.subject===`issue`?`/issues/`:`/pull/`)}`,`_blank`,`noreferrer,noopener`)},e.id)),(0,X.jsx)(XT,{links:p,panel:o===`panel`})]})}function XO({ask:e}){return(0,X.jsx)($p,{tone:`attention`,icon:ce,label:`Waiting on your answer — in your external terminal`,children:(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e.header&&(0,X.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-55`,children:e.header}),(0,X.jsx)(`div`,{className:`min-w-0 text-[12px] font-medium leading-5 text-fg`,children:e.question}),e.options.length>0&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.options.map((e,t)=>(0,X.jsxs)(`div`,{className:`rounded-md border border-border bg-elevated px-3 py-1.5 text-[12px] text-fg/80`,children:[(0,X.jsx)(`span`,{className:`font-medium text-fg/90`,children:e.label}),e.description&&(0,X.jsxs)(`span`,{className:`text-muted-70`,children:[` — `,e.description]})]},t)),e.multiSelect&&(0,X.jsx)(`div`,{className:`text-[10px] text-muted-50`,children:`select one or more`})]})]},t))})})}function ZO({call:e,sourceId:t,at:n}){let r=sD(),i=e.detail??`sub-agent`,{outcome:a,tail:o}=VT(e),s=o.slice(a.length).trim(),c=!!(r&&e.agentId);return(0,X.jsxs)(Q,{icon:ks,sourceId:t,marker:`agent`,ariaLabel:c?void 0:`Sub-agent ${i} ${o}`,at:n,children:[(0,X.jsx)(`span`,{className:`shrink-0 ${wy}`,children:`Sub-agent`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,X.jsx)(`span`,{className:`shrink-0`,children:`«`}),c?(0,X.jsx)(`button`,{type:`button`,"data-subagent-completion-open":!0,title:nn.AGENT,"aria-label":`${nn.AGENT}: ${i}`,onClick:()=>Er(r,e.agentId,{label:i,subagentType:e.subagentType}),onMouseDown:e=>e.preventDefault(),className:`min-w-0 truncate rounded-sm underline decoration-muted/30 underline-offset-2 outline-none transition-colors hover:text-fg hover:decoration-fg/60 focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:i}):(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:i}),(0,X.jsx)(`span`,{className:`shrink-0`,children:`»`})]}),(0,X.jsx)(`span`,{className:`shrink-0`,children:a}),s&&(0,X.jsx)(`span`,{className:`shrink-0 @max-[34rem]/wake:hidden`,children:s})]})}function QO({from:e,unnamed:t,dispatchId:n,sourceId:r,at:i}){let a=sD(),o=!!(a&&n),s=t?void 0:e,c=t&&e?`${nn.AGENT} — ${e}`:nn.AGENT;return s===void 0?(0,X.jsx)(Q,{icon:ks,sourceId:r,marker:`agent-report`,ariaLabel:o?void 0:`Sub-agent reported`,at:i,children:o?(0,X.jsx)(`button`,{type:`button`,"data-subagent-report-open":!0,title:c,"aria-label":`${nn.AGENT}${e?`: ${e}`:``}`,onClick:()=>Er(a,n,{label:`Sub-agent`,subagentType:e}),onMouseDown:e=>e.preventDefault(),className:`shrink-0 rounded-sm underline decoration-muted/30 underline-offset-2 outline-none transition-colors hover:text-fg hover:decoration-fg/60 focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:`Sub-agent reported`}):(0,X.jsx)(`span`,{className:`shrink-0`,title:e||void 0,children:`Sub-agent reported`})}):(0,X.jsxs)(Q,{icon:ks,sourceId:r,marker:`agent-report`,ariaLabel:o?void 0:`Sub-agent ${s} reported`,at:i,children:[(0,X.jsx)(`span`,{className:`shrink-0 ${wy}`,children:`Sub-agent`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,X.jsx)(`span`,{className:`shrink-0`,children:`«`}),o?(0,X.jsx)(`button`,{type:`button`,"data-subagent-report-open":!0,title:nn.AGENT,"aria-label":`${nn.AGENT}: ${s}`,onClick:()=>Er(a,n,{label:s,subagentType:e}),onMouseDown:e=>e.preventDefault(),className:`min-w-0 truncate rounded-sm underline decoration-muted/30 underline-offset-2 outline-none transition-colors hover:text-fg hover:decoration-fg/60 focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:s}):(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:s}),(0,X.jsx)(`span`,{className:`shrink-0`,children:`»`})]}),(0,X.jsx)(`span`,{className:`shrink-0`,children:`reported`})]})}function $O({to:e,type:t,dispatchId:n,targetLabel:r,sourceId:i,at:a}){let o=sD(),s=TO(e,t),c=e===`main`?void 0:r??e,l=!!(o&&n);return(0,X.jsxs)(Q,{icon:ks,sourceId:i,marker:`agent-steer`,ariaLabel:l?void 0:`${s}${c?` ${c}`:``}`,at:a,children:[(0,X.jsx)(`span`,{className:`shrink-0`,children:s}),c&&(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,X.jsx)(`span`,{className:`shrink-0`,children:`«`}),l?(0,X.jsx)(`button`,{type:`button`,"data-subagent-steer-open":!0,title:nn.AGENT,"aria-label":`${nn.AGENT}: ${c}`,onClick:()=>Er(o,n,{label:c}),onMouseDown:e=>e.preventDefault(),className:`min-w-0 truncate rounded-sm underline decoration-muted/30 underline-offset-2 outline-none transition-colors hover:text-fg hover:decoration-fg/60 focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:c}):(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:c}),(0,X.jsx)(`span`,{className:`shrink-0`,children:`»`})]})]})}function ek({text:e,boundary:t,sourceId:n,at:r}){if(t){let i=t===`wake`?/^([^«]+?) «(.+)» ([^»(]+?)(?: (\([^»]*\)))?$/.exec(e):null;return(0,X.jsx)(Q,{icon:t===`wake`?oc:void 0,sourceId:n,marker:t===`rest`?`rest`:`event`,ariaLabel:e,at:r,children:i?(0,X.jsx)(Oy,{lead:i[1],title:i[2],tail:i[3],note:i[4]}):(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e})})}return(0,X.jsx)(`div`,{"data-frizz-msg":n,className:ZT,children:e})}function tk({text:e,sourceId:t}){let[n,r]=(0,q.useState)(!1),i=(0,q.useId)();return(0,X.jsxs)(`div`,{"data-frizz-msg":t,className:`flex flex-col`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":i,"aria-expanded":n,"aria-label":`${n?`Collapse`:`Expand`} model reasoning`,className:`${ZT} flex items-baseline gap-1.5 self-start rounded outline-none transition-colors hover:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:[(0,X.jsx)(`span`,{children:`Reasoning`}),(0,X.jsx)(vs,{"aria-hidden":`true`,size:13,className:$T(n)})]}),n&&(0,X.jsx)(`div`,{id:i,className:`frizz-reasoning mt-1.5 ml-[5px] border-l border-border/70 pl-3`,children:(0,X.jsx)(RO,{md:e,wrap:!0})})]})}function nk(){return(0,X.jsx)(`span`,{className:`inline-block w-2.5 h-2.5 rounded-full border border-muted/70 border-t-transparent animate-spin`})}function rk({since:e,startedAt:t,activityLabel:n,run:r}){let[i]=(0,q.useState)(()=>Date.now()),a=(0,q.useMemo)(()=>{for(let n of[t,e]){let e=Date.parse(n??``);if(Number.isFinite(e)&&e<=Date.now())return e}return i},[t,e,i]),[o,s]=(0,q.useState)(()=>Date.now()),[c,l]=(0,q.useState)(!1),u=(0,q.useId)();(0,q.useEffect)(()=>{let e=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(e)},[]);let d=be(Math.max(0,o-a)),f=(0,q.useMemo)(()=>tO([...r?.tools??[]]),[r]),p=f.reduce((e,t)=>e+t.count,0),m=p>0,h=`group flex min-w-0 items-baseline justify-between gap-3 rounded text-left outline-none focus-visible:ring-1 focus-visible:ring-focus-ink-60 ${ZT}`,g=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate shimmer-text`,children:n??ko(p)}),m&&(0,X.jsx)(vs,{"data-working-chevron":!0,"aria-hidden":`true`,size:13,className:$T(c)})]}),(0,X.jsx)(`span`,{className:`shrink-0 whitespace-nowrap tabular-nums text-[12px] leading-none text-muted-60`,children:d})]});return(0,X.jsxs)(`div`,{"data-working-indicator":!0,"data-working-activity":n?`tool`:`generic`,className:`flex min-w-0 flex-col`,children:[m?(0,X.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":u,"aria-expanded":c,"aria-label":`${c?`Collapse`:`Expand`} ${p} tool ${p===1?`call`:`calls`}${n?`: ${n}`:``}`,className:`${h} w-full`,children:g}):(0,X.jsx)(`div`,{className:h,children:g}),m&&c&&(0,X.jsx)(`div`,{id:u,className:`mt-1.5 flex flex-col`,children:(0,X.jsx)(iO,{tools:f,at:r?.at})}),m&&!c&&(0,X.jsx)(`div`,{id:u,hidden:!0})]})}function ik({label:e,stopping:t,onStop:n,...r}){return(0,X.jsx)(Ot,{label:e,children:(0,X.jsx)(`button`,{type:`button`,...r,"aria-label":e,disabled:t,onClick:n,onMouseDown:e=>e.preventDefault(),className:oe,children:t?(0,X.jsx)(E,{size:14,className:`animate-spin`}):(0,X.jsx)(v,{size:15,strokeWidth:2})})})}function ak({id:e,slug:t,subId:n,label:r,subagentType:i,startedAt:a,depth:o,widthDepth:s}){let[c,l]=(0,q.useState)(!1),u=(0,q.useRef)(null),[d,f]=(0,q.useState)(!1),p=G(),m=le(t,n),h=Ft(),g=(0,q.useMemo)(()=>m.data?.messages??[],[m.data]),_=m.data?.state,v=_===`running`,y=(0,q.useMemo)(()=>sx(g),[g]),b=(0,q.useMemo)(()=>cx(g),[g]),x=(0,q.useMemo)(()=>Fn(b),[b]),S=v?ar(x):void 0,C=v?Vt(x):void 0,w=C?Ma(C,h):void 0,T=v?Un(x):void 0,E=(0,q.useMemo)(()=>v?qe(x):x,[x,v]),D=v,O=m.isError||_===`gone`||g.length===0&&(_===`done`||_===`stale`);(0,q.useEffect)(()=>{let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>l(!0))});return()=>{cancelAnimationFrame(t),e&&cancelAnimationFrame(e)}},[]);let[A,j]=(0,q.useState)(null),M=(0,q.useRef)(!0);(0,q.useLayoutEffect)(()=>{let e=u.current;e&&A&&M.current&&e.scrollHeight-e.scrollTop-e.clientHeight>.5&&(e.scrollTop=e.scrollHeight)}),(0,q.useLayoutEffect)(()=>{let e=u.current;if(!e||!A)return;M.current=!0;let t=()=>{M.current&&(e.scrollTop=e.scrollHeight)},n=()=>{M.current=e.scrollHeight-e.scrollTop-e.clientHeight<160};e.addEventListener(`scroll`,n,{passive:!0});let r=new ResizeObserver(t);return r.observe(A),r.observe(e),t(),()=>{e.removeEventListener(`scroll`,n),r.disconnect()}},[A]);function N(){d||(f(!0),k.subAgentStop({slug:t,id:n}).then(({descendantsStopped:e,note:r})=>{r?K(`Sub-agent stopped. ${r}`,{duration:7e3}):K(e>0?`Sub-agent and ${e} descendant${e===1?``:`s`} stopped`:`Sub-agent stopped`),p.invalidateQueries({queryKey:[`subAgentTranscript`,t,n]})}).catch(e=>{K(e instanceof Error?e.message:`Could not stop this sub-agent`)}).finally(()=>f(!1)))}let P=m.data?.stoppable?(0,X.jsx)(ik,{"data-stop-subagent":``,label:`Stop sub-agent`,stopping:d,onStop:N}):m.data?.outcome?(0,X.jsx)(ck,{outcome:m.data.outcome,startedAt:m.data.startedAt??a,finishedAt:m.data.finishedAt}):null;return(0,X.jsx)(In,{id:e,depth:o,widthDepth:s,children:e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`header`,{"data-subagent-header":!0,className:`flex ${ki} min-w-0 shrink-0 items-center gap-2.5 border-b border-border bg-panel px-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2.5 pl-1`,children:[(0,X.jsx)(Ha,{onClose:e}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 leading-tight`,children:[(0,X.jsx)(`div`,{className:`flex min-w-0 items-center`,children:(0,X.jsx)(`div`,{className:`min-w-0 max-w-full shrink truncate px-0.5 -mx-0.5 font-semibold text-[15px]`,title:r,children:r})}),(0,X.jsx)(FT,{"data-subagent-header-facts":``,lastActiveAt:m.data?.lastActivityAt,fallbackAt:m.data?.startedAt??a,reading:m.data?.context?(0,X.jsx)(OT,{context:m.data.context}):null})]})]}),P&&(0,X.jsx)(`div`,{className:`flex shrink-0 items-center`,children:P})]}),(0,X.jsx)(`div`,{ref:u,className:`flex-1 min-h-0 overflow-y-auto`,children:O?(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center px-8 text-center text-[13px] text-muted`,children:`Transcript unavailable (agent completed or cleaned up).`}):!c||m.isLoading||g.length===0?(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,X.jsx)(`span`,{className:`block h-5 w-5 rounded-full border-2 border-muted/50 border-t-transparent animate-spin`})}):(0,X.jsx)(oD.Provider,{value:t,children:(0,X.jsxs)(`div`,{ref:j,"data-transcript-column":!0,className:`flex flex-col px-6 py-5`,children:[YD(E.map(e=>e.message),(e,t)=>(0,X.jsx)(FO,{m:e},t)),D&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(My,{h:JD(E.map(e=>e.message))}),(0,X.jsx)(rk,{since:a,startedAt:T,activityLabel:w,run:S})]})]})})}),(0,X.jsx)(ok,{slug:t,subId:n,subagentType:i,observedModel:m.data?.model,steerable:m.data?.steerable===!0,note:m.data?.steerNote??null,stoppable:m.data?.stoppable===!0,stopNote:m.data?.stopNote??null,stopping:d,ops:e=>(0,X.jsx)(YO,{slug:t,parentAgentId:n,transcriptShells:y,className:e})})]})})}function ok({slug:e,subId:t,subagentType:n,observedModel:r,steerable:i,note:a,stoppable:o,stopNote:s,stopping:c,ops:l}){let[u,d]=(0,q.useState)(``),[f,p]=(0,q.useState)(!1),m=G();function h(){let n=u.trim();!n||f||(p(!0),d(``),k.subAgentSteer({slug:e,id:t,message:n,deliveryId:crypto.randomUUID()}).then(()=>{m.invalidateQueries({queryKey:[`subAgentTranscript`,e,t]}),K(`Steer sent`)}).catch(e=>{d(n),K(e instanceof Error?e.message:`Could not steer this sub-agent`)}).finally(()=>p(!1)))}if(!i){let e=a??(o?null:s);return e?(0,X.jsxs)(`div`,{"data-subagent-steer-note":!0,className:`w-full shrink-0 border-t border-border bg-panel px-3 py-3`,children:[(0,X.jsx)(`div`,{className:`px-1 pb-2 text-[11.5px] text-muted-70`,children:e}),(0,X.jsx)(`div`,{className:`pl-1.5`,children:(0,X.jsx)(sk,{subagentType:n,observedModel:r})}),l?.(`px-1 pt-1.5 ops-column-optical-inset`)]}):(0,X.jsx)(X.Fragment,{children:l?.(`w-full shrink-0 border-t border-border bg-panel px-4 pb-2 pt-3`)})}return(0,X.jsxs)(`div`,{"data-subagent-steer":!0,className:`w-full shrink-0 border-t border-border bg-panel px-3 py-3`,children:[(0,X.jsx)(er,{value:u,onChange:d,onSubmit:h,surface:`subAgentComposer`,placeholder:`Steer this sub-agent…`,busy:f||c,footer:(0,X.jsx)(sk,{subagentType:n,observedModel:r})}),!o&&s&&(0,X.jsx)(`div`,{className:`mt-2 px-1 text-[11.5px] text-muted-70`,children:s}),l?.(`px-1 pt-1.5 ops-column-optical-inset`)]})}function sk({subagentType:e,observedModel:t}){let n=Zr(e,t),r=n?mi(n):`Profile unknown`;return(0,X.jsx)(`span`,{"data-subagent-profile":!0,"aria-label":`Sub-agent profile: ${r}`,title:n?r:`The provider did not report this sub-agent's model and effort`,className:`inline-flex h-6 min-w-0 max-w-[min(72%,20rem)] items-center rounded-md border border-border/50 bg-transparent px-1.5 text-muted ${ft}`,children:(0,X.jsx)(`span`,{className:`profile-grid-value relative -top-px min-w-0 truncate`,children:n&&n.verbatim===void 0?(0,X.jsxs)(X.Fragment,{children:[n.role&&`${n.role} · `,n.model,n.edition&&(0,X.jsxs)(X.Fragment,{children:[` `,(0,X.jsx)(`span`,{className:`profile-grid-edition text-edition`,children:n.edition})]}),n.effort&&`${n.model?` › `:``}${n.effort}`]}):r})})}function ck({outcome:e,startedAt:t,finishedAt:n}){let r=BT[e],i=`${r[0].toUpperCase()}${r.slice(1)}`,a=t&&n?Date.parse(n)-Date.parse(t):NaN,o=Number.isFinite(a)&&a>=0?`${i} after ${Bn(a)}`:i;return(0,X.jsx)(Jw,{"data-subagent-outcome":e,check:e===`completed`,tooltip:o,children:i})}function lk({id:e,slug:t,title:n,depth:r,widthDepth:i}){let a=fi({queryKey:[`threadBody`,t],queryFn:()=>k.threadBody({slug:t})}),o=Br(W);(0,q.useEffect)(()=>{a.refetch()},[o.board]);let s=wC(Qr(o.board,t)),c=Nr(),l=U.adopt(c,t),[u,d,f]=Ho(l),p=Yr({mutationFn:async e=>{await k.adoptThread({slug:t,message:e.trim()||void 0})},onSuccess:()=>{W.drawers.find(t=>t.id===e)?.closing||(W.drawers=W.drawers.map(t=>t.id===e?{...t,kind:`thread`}:t))},onError:(e,t)=>{Ci.get(l)||d(t),K(`Start failed: ${e.message.slice(0,80)}`)}}),m=jf(pf(a.data?.markdown??``)),h=yp(m),g=(0,q.useRef)(null),_=Am(g,m);return(0,X.jsx)(In,{id:e,depth:r,widthDepth:i,widthOffset:1,subagentParent:t,children:e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ga,{title:n,subtitle:`${t}.md`,onClose:e}),(0,X.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4`,children:a.isLoading?(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):m?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{ref:g,className:`md-body`,dangerouslySetInnerHTML:h}),_]}):(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`No thread file found.`})}),s&&(0,X.jsxs)(`div`,{className:`shrink-0 border-t border-border/60 px-5 pb-4 pt-3`,children:[(0,X.jsx)(`p`,{className:`mb-2.5 text-[11.5px] text-muted-80`,children:`No session is attached to this thread yet. Send a message below to start one on this plan.`}),(0,X.jsx)(er,{surface:`adoptComposer`,value:u,onChange:d,onSubmit:()=>{if(!u.trim()||p.isPending)return;let e=u;f(),K(`Starting thread…`,{spinner:!0,sticky:!0}),p.mutate(e)},placeholder:`Kick off work on this thread…`,minHeight:44,busy:p.isPending})]})]})})}var uk=`font-mono-keep overflow-x-auto whitespace-pre-wrap break-words ${Bp} border border-border bg-bg/75 px-4 py-2.5 text-[12px] leading-relaxed text-fg/85`;function dk({id:e,slug:t,shellId:n,label:r,startedAt:i,depth:a,widthDepth:o}){let s=F(t,n),c=s.data?.state,[l,u]=(0,q.useState)(!1),d=G(),f=S(i),p=c===`running`?`running${f?` ${f}`:``}`:c===`done`?`finished`:c===`gone`?`unavailable`:``,m=s.isError||c===`gone`;function h(){l||(u(!0),k.subAgentStop({slug:t,id:n}).then(({note:e})=>{e?K(`Background shell stopped. ${e}`,{duration:7e3}):K(`Background shell stopped — the worker was told`),d.invalidateQueries({queryKey:[`backgroundShellOutput`,t,n]})}).catch(e=>{K(e instanceof Error?e.message:`Could not stop this background shell`)}).finally(()=>u(!1)))}return(0,X.jsx)(pk,{id:e,depth:a,widthDepth:o,kind:`background-shell`,title:r,icon:(0,X.jsx)(oc,{"aria-hidden":!0,size:14,className:`shrink-0 text-muted-60`}),stateLabel:p,command:s.data?.command,output:s.data?.output??``,truncated:s.data?.truncated===!0,running:c===`running`,loading:s.isLoading,unavailable:m,unavailableText:`Background shell output is no longer available.`,noCommandText:`Command unavailable for this background operation.`,emptyText:c===`done`?`No output was captured.`:`No output yet.`,stop:!m&&s.data?.stoppable?{label:`Stop shell`,stopping:l,onStop:h}:void 0,footer:!m&&!s.data?.stoppable&&c===`running`?s.data?.stopNote??void 0:void 0})}function fk({id:e,slug:t,monitorId:n,label:r,depth:i,widthDepth:a}){let o=dt(t,n),s=o.data,[c,l]=(0,q.useState)(!1),u=G(),d=s?`${s.events} event${s.events===1?``:`s`}`:``,f=S(s?.startedAt??void 0),p=s?.state===`running`?[`running${f?` ${f}`:``}`,d].join(` · `):s?.state===`ended`?[s.ended??`ended`,d].join(` · `):s?.state===`gone`?`unavailable`:``,m=o.isError||s?.state===`gone`;function h(){c||(l(!0),k.stopMonitor({slug:t,id:n}).then(({stopped:e})=>{K(e?`Monitor stopped — the worker was told`:`This monitor had already ended`),u.invalidateQueries({queryKey:[`monitorOutput`,t,n]})}).catch(e=>{K(e instanceof Error?e.message:`Could not stop this monitor`)}).finally(()=>l(!1)))}return(0,X.jsx)(pk,{id:e,depth:i,widthDepth:a,kind:`monitor`,title:s?.description||r,icon:(0,X.jsx)(ns,{"aria-hidden":!0,size:14,className:`shrink-0 text-muted-60`}),stateLabel:p,command:s?.command,output:s?.output??``,truncated:s?.truncated===!0,running:s?.state===`running`,loading:o.isLoading,unavailable:m,unavailableText:`This monitor is no longer available.`,noCommandText:`Script unavailable for this monitor.`,emptyText:s?.state===`ended`?`It printed nothing.`:`Nothing printed yet.`,stop:!m&&s?.stoppable?{label:`Stop monitor`,stopping:c,onStop:h}:void 0})}function pk({id:e,depth:t,widthDepth:n,kind:r,title:i,icon:a,stateLabel:o,command:s,output:c,truncated:l,running:u,loading:d,unavailable:f,unavailableText:p,noCommandText:m,emptyText:h,stop:g,footer:_}){let v=(0,q.useRef)(null),y=e=>({[`data-${r}-${e}`]:``});(0,q.useEffect)(()=>{let e=v.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight<160&&(e.scrollTop=e.scrollHeight)},[c]);async function b(){if(s)try{await Xo(s),K(`Command copied`)}catch{K(`Could not copy command`)}}return(0,X.jsx)(In,{id:e,depth:t,widthDepth:n,children:e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ga,{title:i,icon:a,meta:o?(0,X.jsx)(`span`,{className:`shrink-0 whitespace-nowrap text-[11.5px] text-muted-60`,children:o}):void 0,actions:g?(0,X.jsx)(`span`,{className:`-mr-1 flex shrink-0`,children:(0,X.jsx)(ik,{...y(`stop`),...r===`background-shell`?{"data-stop-background-shell":``}:{},label:g.label,stopping:g.stopping,onStop:g.onStop})}):void 0,onClose:e}),(0,X.jsx)(`div`,{ref:v,className:`min-h-0 flex-1 overflow-y-auto px-5 py-5`,children:f?(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center px-8 text-center text-[13px] text-muted`,children:p}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsxs)(`section`,{children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,X.jsx)(`h2`,{className:`petite-caps text-[10px] text-muted-65`,children:`Command`}),s&&(0,X.jsxs)(`button`,{type:`button`,onClick:b,className:`button-outline flex items-center gap-1 rounded px-1.5 py-1 text-[10.5px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:[(0,X.jsx)(ut,{"aria-hidden":!0,size:11}),` Copy`]})]}),s?(0,X.jsx)(kh,{...y(`command`),text:s,language:`bash`,className:uk}):(0,X.jsx)(`pre`,{...y(`command`),className:uk,children:d?`Loading…`:m})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,X.jsx)(`h2`,{className:`petite-caps text-[10px] text-muted-65`,children:`Output`}),u&&(0,X.jsx)(Hr,{"aria-hidden":!0,hue:`shell`,"data-running-indicator":r===`monitor`?`monitor-drawer`:`shell-drawer`}),l&&(0,X.jsx)(`span`,{className:`text-[10.5px] text-muted-50`,children:`Showing latest 512 KB`})]}),c?(0,X.jsx)(`pre`,{...y(`output`),className:`font-mono-keep min-h-40 whitespace-pre-wrap break-words ${Bp} border border-border bg-inset px-4 py-3 text-[12px] leading-relaxed text-fg/85`,children:c}):(0,X.jsx)(`div`,{...y(`output`),className:`flex min-h-40 items-center justify-center ${Bp} border border-border bg-inset px-4 text-center text-[12px] text-muted-60`,children:h})]})]})}),_&&(0,X.jsx)(`footer`,{...y(`stop-note`),className:`w-full shrink-0 border-t border-border/70 bg-panel/95 px-4 pt-2 pb-[max(0.5rem,env(safe-area-inset-bottom))] text-[11.5px] text-muted-70`,children:_})]})})}var mk=64,hk=12,gk=mk-hk-4,_k=16,vk=`#4a9eff`,yk,bk,xk=!1;function Sk(){return yk??=[...document.querySelectorAll(`link[rel~="icon"]`)].map(e=>({link:e,href:e.getAttribute(`href`)??``,type:e.getAttribute(`type`),sizes:e.getAttribute(`sizes`)})),yk}function Ck(e){let t=document.createElement(`canvas`);t.width=t.height=mk;let n=t.getContext(`2d`);return n.drawImage(e,0,0,mk,mk),n.globalCompositeOperation=`destination-out`,n.beginPath(),n.arc(gk,_k,16,0,Math.PI*2),n.fill(),n.globalCompositeOperation=`source-over`,n.fillStyle=vk,n.beginPath(),n.arc(gk,_k,hk,0,Math.PI*2),n.fill(),t.toDataURL(`image/png`)}function wk(e){return bk??=new Promise((t,n)=>{let r=e.find(e=>e.type===`image/svg+xml`)??e[0];if(!r)return n(Error(`no favicon link`));let i=new Image;i.onload=()=>t(Ck(i)),i.onerror=()=>n(Error(`favicon did not load`)),i.src=r.href}),bk}function Tk(e){xk=e;let t=Sk();if(!e){for(let{link:e,href:n,type:r,sizes:i}of t)e.href=n,r===null?e.removeAttribute(`type`):e.type=r,i===null?e.removeAttribute(`sizes`):e.setAttribute(`sizes`,i);return}wk(t).then(e=>{if(xk)for(let{link:n}of t)n.type=`image/png`,n.removeAttribute(`sizes`),n.href=e}).catch(()=>{bk=void 0})}var Ek=new Map,Dk=12;function Ok(e,t){let n=Ek.get(e);if(n&&n.raw===t)return n.html;let r=Ju(t,V(e));if(Ek.set(e,{raw:t,html:r}),Ek.size>Dk){let e=Ek.keys().next();e.done||Ek.delete(e.value)}return r}function kk(e){let t=globalThis.requestIdleCallback;t?t(e,{timeout:500}):setTimeout(e,0)}function Ak(e,t){kn(t)||e.prefetchQuery(ys(t)).then(()=>{let n=e.getQueryData(ys(t).queryKey);!n?.markdown||n.binary||Te(t)||kk(()=>Ok(n.path,n.markdown))}).catch(()=>{})}function jk(e){let t=/^---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/.exec(e);return t?{front:t[1],body:e.slice(t[0].length)}:{front:null,body:e}}var Mk={paddingBottom:`max(0.75rem, env(safe-area-inset-bottom))`};function Nk({path:e}){return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>void Pk(e),onMouseDown:e=>e.preventDefault(),className:`-mr-2.5 flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[12px] font-medium text-fg/80 outline-none transition-colors hover:bg-hover-strong hover:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,title:`Open ${e} outside Frizz`,"aria-label":`Open`,children:[(0,X.jsx)(Ls,{size:12,"aria-hidden":`true`}),` Open`]})}function Pk(e){return $n(e).openLocalFile({path:e}).then(Tt).catch(e=>K(`Could not open local file: ${e.message.slice(0,100)}`))}function Fk({path:e,revision:t,title:n}){return(0,X.jsx)(`iframe`,{"data-pdf-view":!0,src:`${Gn(e)}${t===void 0?``:`&v=${t}`}`,title:n,className:`block min-h-0 w-full flex-1 border-0`})}function Ik({phone:e=!1}){return(0,X.jsxs)(`div`,{className:`text-[13px] text-muted`,children:[`This file isn’t text, so Frizz can’t show it.`,e?``:` Open sends it to its default app.`]})}function Lk({source:e}){return(0,X.jsx)(kh,{text:e,language:`yaml`,className:`mb-4 whitespace-pre-wrap break-words rounded-md border border-border/60 bg-panel-2/40 px-3 py-2 font-mono-keep text-[12px] leading-5 text-muted`})}function Rk({id:e,path:t,title:n,depth:r,widthDepth:i}){let a=qi(t),o=fi({...ys(t),refetchInterval:a?!1:Zt}),s=o.data?.path??t,c=Te(t),l=xn(t)&&y(),{front:u,body:d}=jk(c?o.data?.markdown??``:``),f=Ln(s),p=jf(d,{baseDir:f,asDocument:!0}),m=yp(p),h=(0,q.useRef)(null);Ip(h,p);let g=th(h,p,f),_=Am(h,p),v=pt(),b=o.data?.markdown??``,x=yp((0,q.useMemo)(()=>c?``:Ok(s,b),[c,b,s]));return(0,X.jsx)(In,{id:e,depth:r,widthDepth:i,children:e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ga,{title:n,subtitle:s,onClose:e}),(0,X.jsxs)(`div`,{className:`flex-1 min-h-0 ${l&&o.data?`flex flex-col`:`overflow-y-auto px-5 py-4`}`,children:[l&&o.data?(0,X.jsx)(Fk,{path:s,revision:o.data.modifiedAt,title:n}):o.isLoading?(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):o.error?(0,X.jsxs)(`div`,{className:`text-[13px] text-danger-90`,children:[`Couldn’t read this file: `,o.error.message]}):o.data?.binary?(0,X.jsx)(Ik,{phone:v}):c?p?(0,X.jsxs)(X.Fragment,{children:[u&&(0,X.jsx)(Lk,{source:u}),(0,X.jsx)(`div`,{ref:h,className:`md-body`,dangerouslySetInnerHTML:m}),g,_,o.data?.truncated&&(0,X.jsxs)(`p`,{className:`mt-4 border-t border-border/60 pt-3 text-[12px] text-muted`,children:[`This file is too long to render in full — everything above the cut is shown.`,v?``:` Open it to read the rest.`]})]}):(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}):b?(0,X.jsx)(`pre`,{"data-file-source":!0,className:`hljs whitespace-pre-wrap break-words bg-transparent font-mono-keep text-[12px] leading-5 text-fg/90`,style:{tabSize:2},dangerouslySetInnerHTML:x}):(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}),!c&&!o.isLoading&&!o.error&&o.data?.truncated&&(0,X.jsx)(`p`,{className:`mt-4 border-t border-border/60 pt-3 text-[12px] text-muted`,children:`This file is too long to show in full — everything above the cut is shown.`})]}),v?(0,X.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0`,style:{height:`env(safe-area-inset-bottom)`}}):(0,X.jsx)(`div`,{className:`shrink-0 flex items-center justify-end gap-1.5 border-t border-border/60 bg-panel px-5 pt-3`,style:Mk,children:(0,X.jsx)(Nk,{path:s})})]})})}function zk(e,t,n){let r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=0;for(let e=r.nextNode();e;e=r.nextNode()){if(e===t)return i+n;i+=e.textContent?.length??0}if(t instanceof Element&&e.contains(t)){let n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=0;for(let e=n.nextNode();e;e=n.nextNode())(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING||t.contains(e))&&(r+=e.textContent?.length??0);return r}return null}function Bk(e,t){let n=1,r=Math.min(t,e.length);for(let t=0;t<r;t++)e.charCodeAt(t)===10&&n++;return n}function Vk({slug:e,path:t,active:n}){let r=Te(t),i=xn(t)&&y(),a=qi(t),o=fi({...ys(t),refetchInterval:a?!1:Zt}),s=o.data?.path??t,c=o.data?.markdown??``,{front:l,body:u}=jk(r?c:``),[f,p]=(0,q.useState)(r?`rendered`:`source`),m=Ln(s),h=jf(u,{baseDir:m,asDocument:!0}),g=yp(h),_=yp((0,q.useMemo)(()=>f===`source`?Ok(s,c):``,[c,s,f])),v=(0,q.useRef)(null),b=(0,q.useRef)(null),x=(0,q.useRef)(null);Ip(v,h);let S=th(v,h,m),C=Am(v,h),w=Mi(s),T=d(),E=Nr(),D=is(e);return(0,q.useEffect)(()=>{if(!n)return;let t=()=>document.querySelector(`main[data-standalone-thread] textarea`);function r(e,t){return e?document.activeElement!==e&&e.selectionStart===0&&e.selectionEnd===0&&e.value.length>0?t.length:Math.min(e.selectionStart??t.length,t.length):t.length}function i(n){if(!(n.metaKey||n.ctrlKey)||n.altKey||n.shiftKey||n.key.toLowerCase()!==`i`)return;let i=x.current,a=window.getSelection(),o=a&&!a.isCollapsed&&a.rangeCount>0?a.getRangeAt(0):null,l=!!(i&&o&&i.contains(o.commonAncestorContainer)),u=l?a.toString():``;if(!l||!u.trim()){n.preventDefault(),n.stopPropagation();let e=t();if(!e)return;document.activeElement!==e&&e.selectionStart===0&&e.selectionEnd===0&&e.value.length>0&&e.setSelectionRange(e.value.length,e.value.length),e.focus();return}n.preventDefault(),n.stopPropagation();let d=null,f=b.current;if(f&&f.contains(o.commonAncestorContainer)){let e=zk(f,o.startContainer,o.startOffset),t=zk(f,o.endContainer,o.endOffset);e!==null&&t!==null&&(d={startLine:Bk(c,Math.min(e,t)),endLine:Bk(c,Math.max(0,Math.max(e,t)-1))})}else d=Io(c,u);let p=t(),m=U.followUp(E,e,D),{prose:h,attachments:g}=Ti(Ci.get(m)),_=xa(vo({path:s,...d??{}}),W.composerContext[e]??[],h),v=fa(h,r(p,h),_);Ci.set(m,Ni(v.prose,g.map(e=>e.path))),Qn(e,{token:_,path:s,text:u,...d??{}}),a.removeAllRanges(),requestAnimationFrame(()=>{let e=t();e&&(e.setSelectionRange(v.caret,v.caret),e.focus())})}return window.addEventListener(`keydown`,i,!0),()=>window.removeEventListener(`keydown`,i,!0)},[n,e,s,c,E,D]),(0,X.jsxs)(`div`,{ref:x,"data-file-viewer-panel":!0,className:`flex h-full min-h-0 flex-col`,children:[(0,X.jsx)(ga,{title:w,subtitle:Uo(s,T),onClose:or,actions:r?(0,X.jsx)(`div`,{className:`-mr-0.5 flex shrink-0 items-center gap-0.5 text-[11px] font-medium`,role:`group`,"aria-label":`File view`,children:[`rendered`,`source`].map(e=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>p(e),"aria-pressed":f===e,className:`rounded px-2 py-0.5 transition-colors ${f===e?`bg-hover-strong text-fg`:`text-muted hover:text-fg`}`,children:e===`rendered`?`Rendered`:`Source`},e))}):null}),(0,X.jsxs)(`div`,{className:`flex-1 min-h-0 ${i&&o.data?`flex flex-col`:`overflow-y-auto px-5 py-4`}`,children:[i&&o.data?(0,X.jsx)(Fk,{path:s,revision:o.data.modifiedAt,title:w}):o.isLoading?(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):o.error?(0,X.jsxs)(`div`,{className:`text-[13px] text-danger-90`,children:[`Couldn’t read this file: `,o.error.message]}):o.data?.binary?(0,X.jsx)(Ik,{}):f===`source`?c?(0,X.jsx)(`pre`,{ref:b,className:`hljs whitespace-pre-wrap break-words bg-transparent font-mono-keep text-[12px] leading-5 text-fg/90`,style:{tabSize:2},dangerouslySetInnerHTML:_}):(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}):h?(0,X.jsxs)(X.Fragment,{children:[l&&(0,X.jsx)(Lk,{source:l}),(0,X.jsx)(`div`,{ref:v,className:`md-body`,dangerouslySetInnerHTML:g}),S,C]}):(0,X.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}),!o.isLoading&&!o.error&&o.data?.truncated&&(0,X.jsx)(`p`,{className:`mt-4 border-t border-border/60 pt-3 text-[12px] text-muted`,children:`This file is too long to render in full — everything above the cut is shown. Open it to read the rest.`})]}),(0,X.jsxs)(`div`,{className:`shrink-0 flex items-center justify-between gap-3 border-t border-border/60 bg-panel px-5 pt-3`,style:Mk,children:[i||o.data?.binary?(0,X.jsx)(`span`,{}):(0,X.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-muted-70`,children:`Select text and press ⌘I to add it to the chat`}),(0,X.jsx)(Nk,{path:s})]})]})}function Hk(){return{dirs:new Map,files:new Map}}function Uk(e,t,n){let r=e.replace(/[\\/]+$/,``);if(t){let e=wi(t,r);if(e!==null)return _r(e)}if(n){let e=wi(n,r);if(e!==null)return[`~`,..._r(e)]}let i=_r(r);return/^[\\/]/.test(r)?[`/`,...i]:i}var Wk=(e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`,numeric:!0});function Gk(e,t,n=``){let r=[];for(let i of[...e.dirs.keys()].sort(Wk)){let a=e.dirs.get(i),o=i;for(;a.files.size===0&&a.dirs.size===1;){let[e,t]=[...a.dirs.entries()][0];o=o===`/`?`/${e}`:`${o}/${e}`,a=t}let s=n===``||n===`/`?`${n}${o}`:`${n}/${o}`;r.push({kind:`dir`,name:o,path:s,depth:t,children:Gk(a,t+1,s)})}for(let n of[...e.files.keys()].sort(Wk))r.push({kind:`file`,name:n,depth:t,file:e.files.get(n)});return r}function Kk(e,t,n){let r=Hk();for(let i of e){let e=Uk(i.path,t,n);if(e.length===0)continue;let a=r;for(let t of e.slice(0,-1)){let e=a.dirs.get(t);e||(e=Hk(),a.dirs.set(t,e)),a=e}a.files.set(e[e.length-1],i)}return Gk(r,0)}function qk(e){let t=[],n=e=>{for(let r of e)t.push(r),r.kind===`dir`&&n(r.children)};return n(e),t}var Jk=/(?:^|[\s;&|(])(?:rm|mv|unlink|git\s+(?:rm|mv|clean|checkout|restore|reset|stash|apply))\b/;function Yk(e){if(e.edit||e.edits?.length)return!0;let t=n(e.name);return bn.has(t)?!0:t!==`bash`||!e.command?!1:Jk.test(e.command)||ur(e.command).length>0}function Xk(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=n.tools??[];for(let e=r.length-1;e>=0;e--)if(Yk(r[e]))return`${n.sourceId??n.at??`#${t}`}:${e}:${r[e].status??``}`}}var Zk=10;function Qk({name:e,depth:t}){return(0,X.jsxs)(`div`,{"data-file-dir":e,className:`flex items-baseline pr-2 text-[12px] leading-5 text-muted-70`,style:{paddingLeft:8+t*Zk},children:[(0,X.jsx)(`span`,{className:`flex shrink-0`,children:(0,X.jsx)(zs,{size:12,className:`${Z} text-muted-45`})}),(0,X.jsx)(`span`,{className:`ml-[5px] min-w-0 truncate`,title:e,children:e})]})}function $k({files:e}){let t=Ft(),n=d();return(0,X.jsx)(`div`,{"data-edited-file-tree":!0,className:`flex flex-col gap-y-px`,children:qk(Kk(e,t,n)).map(e=>e.kind===`dir`?(0,X.jsx)(Qk,{name:e.name,depth:e.depth},`d:${e.path}`):(0,X.jsx)(eA,{file:e.file,name:e.name,depth:e.depth,homeDir:n},e.file.path))})}function eA({file:e,name:t,depth:n,homeDir:r}){let i=G();return(0,X.jsx)(Vv,{testKind:`file`,testId:e.path,mark:(0,X.jsx)(Rs,{size:12,className:`${Z} -mr-[2px] text-muted-60`}),name:t,indent:n*Zk,onOpen:()=>N(e.path),onPrewarm:()=>Ak(i,e.path),title:Uo(e.path,r),status:(0,X.jsxs)(X.Fragment,{children:[(e.added??0)>0&&(0,X.jsxs)(`span`,{style:{color:b.fgSuccess},children:[`+`,e.added]}),(e.added??0)>0&&(e.removed??0)>0&&` `,(e.removed??0)>0&&(0,X.jsxs)(`span`,{style:{color:b.fgDanger},children:[`−`,e.removed]})]})})}function tA({link:e}){let t=G(),n=d();return e.kind===`link`?(0,X.jsx)(Vv,{testKind:`link`,testId:e.id,mark:(0,X.jsx)(Ls,{size:12,className:`${Z} text-muted-60`}),name:e.label,href:e.target,title:e.target,status:nA(e.target)}):(0,X.jsx)(Vv,{testKind:`link`,testId:e.id,mark:(0,X.jsx)(u,{size:12,className:`${Z} text-muted-60`}),name:e.label,onOpen:()=>N(e.target),onPrewarm:()=>Ak(t,e.target),title:Uo(e.target,n),status:null})}function nA(e){try{return new URL(e).host||e}catch{return e}}var rA=1500;function iA(e,t,n,r){let i=G(),a=(0,q.useRef)({slug:e,loaded:t,changeKey:n,turnLive:r}),o=(0,q.useRef)(void 0);(0,q.useEffect)(()=>()=>clearTimeout(o.current),[e]),(0,q.useEffect)(()=>{let s=a.current;if(a.current={slug:e,loaded:t,changeKey:n,turnLive:r},s.slug!==e||!s.loaded)return;let c=n!==void 0&&n!==s.changeKey,l=s.turnLive&&!r;!c&&!l||(clearTimeout(o.current),o.current=setTimeout(()=>{i.refetchQueries({queryKey:[`transcript`,e],exact:!0,type:`active`})},rA))},[i,e,t,n,r])}function aA({thread:e,centred:t=!1}){let n=da(),r=rt(e.id,{poll:!1}),i=r.data?.editedFiles??[],a=(0,q.useMemo)(()=>Xk(r.data?.messages??[]),[r.data?.messages]);iA(e.id,r.data!==void 0,a,e.runtime===`running`||e.runtime===`spawning`);let{agents:o,children:s,shells:c,prs:l,issues:u,commands:d,timers:f}=z_(e,(0,q.useMemo)(()=>sx(r.data?.messages??[]),[r.data?.messages]),ta(e.id)),p=V_(e),m=o.filter(Ei),{railFilesCollapsed:h}=Br(va),g=[{head:`To-do`,rows:e.humanTodos?.length?[(0,X.jsx)(`div`,{className:`px-2 text-[12px] leading-[18px]`,children:(0,X.jsx)(iv,{thread:e})},`todos`)]:[]},{head:`Sub-agents`,rows:m.map(t=>(0,X.jsx)(oy,{agent:t,slug:e.id,now:n,onDismiss:es(e.id,t)},t.id??t.label))},{head:`Child threads`,rows:s.map(e=>(0,X.jsx)(sy,{child:e,now:n},e.id))},{head:`Background shells`,rows:c.map(t=>(0,X.jsx)(Xv,{shell:t,slug:e.id,now:n,onDismiss:es(e.id,t,`SHELL`),watched:p(t)},t.id??t.label))},{head:`Pull requests`,rows:l.map(e=>(0,X.jsx)(Wv,{watch:e},e.id))},{head:`Issues`,rows:u.map(e=>(0,X.jsx)(Wv,{watch:e},e.id))},{head:`Monitors`,rows:d.map(t=>(0,X.jsx)(ny,{watch:t,slug:e.id,now:n},t.id))},{head:`Timers`,rows:f.map(e=>(0,X.jsx)(Zv,{watch:e,now:n},e.id))},{head:`Files and links`,rows:(e.links??[]).map(e=>(0,X.jsx)(tA,{link:e},e.id))},{head:`Edited files`,rows:i.length>0?[(0,X.jsx)($k,{files:i},`tree`)]:[],count:i.length,collapsed:h,onToggle:()=>va.railFilesCollapsed=!va.railFilesCollapsed}].filter(e=>e.rows.length>0);return(0,X.jsx)(`aside`,{"data-focus-rail":!0,"aria-label":`Thread activity`,className:`flex h-full shrink-0 flex-col overflow-y-auto px-4 [view-transition-name:thread-rail]`,style:{width:340},children:(0,X.jsx)(`div`,{className:g.length===0||t?`my-auto py-6`:`pb-6 pt-14`,children:g.length===0?(0,X.jsx)(`div`,{className:`text-[11.5px] text-muted-50`,children:`Nothing running, watched or edited yet.`}):(0,X.jsx)(fy,{groups:g,divider:!1})})})}function oA(e,t){return`${De(e)}${Lt(t,`/`)}`}function sA({slug:e}){let t=Br(W),n=t.filePanels.some(e=>!e.closing),r=Dt(),i=Ne(e),a=zn(r,e,()=>i),o=a.kind===`found`?a.thread:void 0;r?.projectDir,(0,q.useEffect)(()=>{let e=window.matchMedia?.(`(min-width: ${Ga}px)`);if(!e)return;let t=()=>{W.splitFileViewer=e.matches};return t(),e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t),W.splitFileViewer=!1,W.filePanels=[]}},[]);let s=(0,q.useRef)(null),c=!t.splitFileViewer,u=a.kind===`found`;(0,q.useEffect)(()=>{if(!c||!u)return;let t=s.current?.querySelector(`[data-thread-chat-footer]`);if(t)return Dn(`thread-page:${e}`,t)},[c,u,e]);let d=o?.runtime===`turn-idle`||o?.runtime===`exited`||o?.runtime===`none`;(0,q.useEffect)(()=>{!o||!d||k.threadSeen({slug:e}).catch(()=>{})},[d,e,o?.lastActivityAt]),(0,q.useEffect)(()=>{let t=r?.projectLabel??r?.projectName,n=o?Lo(o):e;document.title=t?`${n} · ${t} — Frizz`:`${n} · Frizz`},[r?.projectLabel,r?.projectName,e,o]);let f=o!==void 0&&Gr(o);return(0,q.useEffect)(()=>(Tk(f),()=>Tk(!1)),[f]),(0,X.jsx)(na,{children:(0,X.jsxs)(l,{className:`h-dvh min-h-0 bg-bg text-sm text-fg`,children:[(0,X.jsx)(tt,{className:`h-full w-full overflow-hidden`,children:(0,X.jsxs)(`div`,{className:`flex h-full w-full justify-center transition-transform duration-200 ease-out motion-reduce:transition-none split:justify-start`,style:{...se,transform:n?`translateX(calc(-1 * var(--full-gutter)))`:void 0},children:[(0,X.jsx)(`div`,{className:`hidden w-[var(--full-gutter)] shrink-0 split:block`,"aria-hidden":`true`}),(0,X.jsx)(`main`,{ref:s,"data-standalone-thread":!0,className:`flex h-full w-[var(--full-thread-narrow)] min-w-0 shrink-0 flex-col overflow-hidden border-border bg-panel sm:border-x split:w-[var(--full-thread)] [view-transition-name:thread-chat]`,children:a.kind===`loading`?(0,X.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,role:`status`,"aria-label":`Loading thread`,children:(0,X.jsx)(`span`,{className:`block h-5 w-5 animate-spin rounded-full border-2 border-muted/50 border-t-transparent`})}):a.kind===`missing`?(0,X.jsx)(uA,{slug:e}):(0,X.jsx)(di,{label:`this thread`,resetKeys:[e],children:(0,X.jsx)(Ce,{slug:e,showReturnToQueue:!0})})}),o?(0,X.jsx)(di,{label:`this thread's side pane`,resetKeys:[e],children:(0,X.jsx)(cA,{slug:e,thread:o})}):(0,X.jsx)(`div`,{className:`hidden w-[var(--full-pane)] shrink-0 split:block`,"aria-hidden":`true`})]})}),(0,X.jsx)(_s,{onEscapeAtRest:()=>gT(e)})]})})}function cA({slug:e,thread:t,rail:n=!0,centredRail:r=!1}){let i=Br(W);return(0,X.jsxs)(`div`,{"data-side-pane":!0,className:`relative hidden h-full w-[var(--full-pane)] min-h-0 min-w-0 shrink-0 grow-0 overflow-hidden split:block`,children:[n&&(0,X.jsx)(`div`,{inert:i.filePanels.length>0?!0:void 0,className:`h-full min-h-0`,children:(0,X.jsx)(aA,{thread:t,centred:r})}),i.filePanels.map((t,n)=>(0,X.jsx)(lA,{slug:e,path:t.path,closing:!!t.closing,active:n===i.filePanels.length-1&&!t.closing&&i.splitFileViewer},t.id))]})}function lA({slug:e,path:t,closing:n,active:r}){let[i,a]=(0,q.useState)(!1),o=(0,q.useRef)(null);return(0,q.useLayoutEffect)(()=>{o.current?.getBoundingClientRect();let e=()=>a(!0),t=requestAnimationFrame(e),n=window.setTimeout(e,120);return()=>{cancelAnimationFrame(t),window.clearTimeout(n)}},[]),(0,q.useEffect)(()=>{r&&o.current?.focus({preventScroll:!0})},[r]),(0,X.jsx)(`aside`,{ref:o,tabIndex:-1,"data-file-viewer-slot":!0,"aria-hidden":!r,inert:!r,className:`absolute inset-0 outline-none transition-[translate,opacity] duration-200 ease-out motion-reduce:transition-none ${i&&!n?`translate-x-0 opacity-100`:`translate-x-full opacity-0`}`,children:(0,X.jsx)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-panel`,children:(0,X.jsx)(Vk,{slug:e,path:t,active:r})})})}function uA({slug:e}){let{data:t,isPending:n}=fi({queryKey:[`threadLocate`,e],queryFn:()=>k.threadLocate({slug:e})});return(0,q.useEffect)(()=>{t?.length===1&&location.replace(oA(t[0].projectSlug,e))},[t,e]),(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-4 px-6 text-center`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h1`,{className:`font-medium text-fg`,children:`Thread unavailable`}),n?(0,X.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`Looking for “`,e,`” in your other projects…`]}):t&&t.length>0?(0,X.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`“`,e,`” lives in `,t.length===1?`another project`:`these projects`,` — opening it there.`]}):(0,X.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`Thread “`,e,`” was not found in any project on this machine.`]})]}),t&&t.length>1?(0,X.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:t.map(t=>(0,X.jsx)(`a`,{href:oA(t.projectSlug,e),className:`rounded-md border border-border px-3 py-1.5 text-[12px] text-fg/90 hover:bg-panel-2`,children:t.projectName},t.projectSlug))}):(0,X.jsx)(`a`,{href:`/`,className:`rounded-md border border-border px-3 py-1.5 text-[12px] text-fg/90 hover:bg-panel-2`,children:`All projects`})]})}export{dk as BackgroundShellSheet,nh as LightboxHost,Rk as MarkdownDrawer,fk as MonitorSheet,cA as SidePane,sA as StandaloneThreadPage,ak as SubAgentSheet,Zw as ThreadActionsSheet,lk as ThreadDrawer,cD as ThreadView};
|