@sentry/junior-dashboard 0.294.0 → 0.295.0
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/app.js +7 -5
- package/dist/client-manifest.json +1 -1
- package/dist/index.js +7 -5
- package/dist/public/chunks/{AdminPage-mn71yp2v.js → AdminPage-lctmhvpg.js} +1 -1
- package/dist/public/chunks/{AnchorHeading-cp3vx8qa.js → AnchorHeading-ixbupfij.js} +1 -1
- package/dist/public/chunks/{Area-h08sxa33.js → Area-d95rfkv5.js} +1 -1
- package/dist/public/chunks/AutomationPage-m78li1hv.js +3 -0
- package/dist/public/chunks/{AutomationRunDetails-jjdhbqtn.js → AutomationRunDetails-dx5lutte.js} +1 -1
- package/dist/public/chunks/{AutomationRunsPage-j50ps7nt.js → AutomationRunsPage-cba6nbxd.js} +1 -1
- package/dist/public/chunks/{AutomationStatus-czfg6ayl.js → AutomationStatus-eqq5lrad.js} +1 -1
- package/dist/public/chunks/AutomationsPage-cp7wtt2v.js +8 -0
- package/dist/public/chunks/{BarChart-e3oi6in1.js → BarChart-lbkezxbi.js} +1 -1
- package/dist/public/chunks/{BoardPage-f0uxqg7u.js → BoardPage-m4zqf62q.js} +1 -1
- package/dist/public/chunks/{CodeChangeRow-dk3gkjut.js → CodeChangeRow-d620nk75.js} +2 -2
- package/dist/public/chunks/CodePage-h2ayars2.js +1 -0
- package/dist/public/chunks/{CodeSummaryCards-o1po2jis.js → CodeSummaryCards-iotfblbp.js} +1 -1
- package/dist/public/chunks/{ConnectionsPage-mholegdk.js → ConnectionsPage-nm7w1i05.js} +2 -2
- package/dist/public/chunks/{DirectoryMetric-dgzufji4.js → DirectoryMetric-huy2ptzz.js} +1 -1
- package/dist/public/chunks/{DrawerContent-ovjgr16m.js → DrawerContent-n3biwp5m.js} +1 -1
- package/dist/public/chunks/{FilterBar-mtnh7fbi.js → FilterBar-dqnt967g.js} +1 -1
- package/dist/public/chunks/FormNotice-kj5pzsl7.js +1 -0
- package/dist/public/chunks/{LocationDetailPage-ggd6zgzp.js → LocationDetailPage-iqtx76w6.js} +2 -2
- package/dist/public/chunks/{LocationsPage-fh6vzxa1.js → LocationsPage-ju5jfejt.js} +2 -2
- package/dist/public/chunks/{McpSettingsPage-fm3fh2ux.js → McpSettingsPage-brav5c42.js} +1 -1
- package/dist/public/chunks/{PeoplePage-odrbcmhj.js → PeoplePage-lfq8nrto.js} +2 -2
- package/dist/public/chunks/{PersonProfilePage-gynexe89.js → PersonProfilePage-ep45sxr6.js} +1 -1
- package/dist/public/chunks/{PersonalTokensPage-4o4zj02w.js → PersonalTokensPage-jbt4q7uz.js} +1 -1
- package/dist/public/chunks/PluginReportRecordSet-ml18z19r.js +1 -0
- package/dist/public/chunks/{PluginUserPage-kwylbbpr.js → PluginUserPage-ilar25ic.js} +2 -2
- package/dist/public/chunks/RepositoryPage-o9m3vty4.js +1 -0
- package/dist/public/chunks/SettingsPage-jc9et1qq.js +1 -0
- package/dist/public/chunks/SystemPage-bbp8cdds.js +15 -0
- package/dist/public/chunks/{WorkspaceFormPage-hwvyvnuk.js → WorkspaceFormPage-kshmsdek.js} +2 -2
- package/dist/public/chunks/{WorkspacesPage-lu9w3ugz.js → WorkspacesPage-ohasc10u.js} +1 -1
- package/dist/public/chunks/alert-ifqo1uj7.js +1 -0
- package/dist/public/chunks/{automationFormat-hd7pnocr.js → automationFormat-kv314fzh.js} +1 -1
- package/dist/public/chunks/{chart-myr1oeen.js → chart-il2ahs5y.js} +1 -1
- package/dist/public/chunks/{circle-dollar-sign-fpl4dmok.js → circle-dollar-sign-h7k4kr7s.js} +1 -1
- package/dist/public/chunks/{code-highlighter-i3ux67or.js → code-highlighter-ea4j0ys1.js} +1 -1
- package/dist/public/chunks/{coins-bqkaxeba.js → coins-l2c8c17w.js} +1 -1
- package/dist/public/chunks/{format-gle1s0ri.js → format-flkutk9e.js} +2 -2
- package/dist/public/chunks/junior-g62bxb2t.js +4 -0
- package/dist/public/chunks/{native-select-jfknh8t4.js → native-select-fxs3p0bj.js} +1 -1
- package/dist/public/chunks/{plus-gndielka.js → plus-54e3zzys.js} +1 -1
- package/dist/public/chunks/vendor-icons-blmhaswc.js +698 -0
- package/dist/public/chunks/{workspaceQueries-m1ksz95c.js → workspaceQueries-onxawhg4.js} +1 -1
- package/dist/public/client-ctcthgam.js +165 -0
- package/dist/public/styles-4CIT7L7K.css +2 -0
- package/dist/tailwind.css +1 -1
- package/package.json +4 -4
- package/src/client/api.ts +16 -0
- package/src/client/components/MarkdownViewToggle.tsx +24 -0
- package/src/client/components/SkillLink.tsx +119 -0
- package/src/client/conversations/ConversationHomeList.tsx +87 -76
- package/src/client/conversations/ConversationListStatusIcon.tsx +39 -55
- package/src/client/conversations/ConversationSectionList.tsx +101 -0
- package/src/client/conversations/ConversationSidebar.tsx +159 -169
- package/src/client/conversations/ConversationWorkspace.tsx +5 -16
- package/src/client/conversations/TextAttachmentPreview.tsx +5 -14
- package/src/client/conversations/WaitingChip.tsx +78 -0
- package/src/client/conversations/conversationSections.ts +78 -55
- package/src/client/conversations/heldListOrder.ts +170 -0
- package/src/client/conversations/toolCallPreview.ts +3 -1
- package/src/client/conversations/transcriptSource.ts +7 -2
- package/src/client/conversations/useMarkConversationUnread.ts +2 -2
- package/src/client/format.ts +18 -2
- package/src/client/pages/automations/AutomationDraftChanges.tsx +2 -1
- package/src/client/pages/automations/AutomationOverview.tsx +3 -3
- package/src/client/pages/automations/AutomationSkillPicker.tsx +75 -31
- package/src/client/pages/automations/AutomationTaskFields.tsx +3 -13
- package/src/client/pages/automations/AutomationVersionsTab.tsx +2 -5
- package/src/client/pages/automations/skillSearch.ts +50 -0
- package/src/client/pages/code/RepositorySections.tsx +14 -5
- package/src/client/pages/code/RepositoryTabs.tsx +5 -11
- package/src/client/pages/system/PluginDetails.tsx +15 -8
- package/src/client/pages/system/SkillInventory.tsx +2 -6
- package/src/client/review-desk/queries.ts +30 -23
- package/src/client/review-desk/reviewItemFormat.ts +3 -1
- package/src/client/types.ts +5 -1
- package/src/mock-reporting/review-items.ts +6 -2
- package/dist/public/chunks/AutomationPage-e1l74ezg.js +0 -10
- package/dist/public/chunks/AutomationsPage-cphxl4l6.js +0 -8
- package/dist/public/chunks/CodePage-i97ivyji.js +0 -1
- package/dist/public/chunks/FormNotice-eyo2kdte.js +0 -1
- package/dist/public/chunks/PluginReportRecordSet-hm1cwp6c.js +0 -1
- package/dist/public/chunks/RepositoryPage-fti2vfu4.js +0 -1
- package/dist/public/chunks/SettingsPage-kxspx37h.js +0 -1
- package/dist/public/chunks/SystemPage-jurblfgy.js +0 -15
- package/dist/public/chunks/SystemPlugins-jr37f1cv.js +0 -1
- package/dist/public/chunks/junior-hdb4wc4q.js +0 -4
- package/dist/public/chunks/vendor-icons-mxz7yi04.js +0 -692
- package/dist/public/client-f7asutg5.js +0 -165
- package/dist/public/styles-ZJJGBKKX.css +0 -2
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./chunks/rolldown-runtime-bnnw9q4a.js";import{A as t,C as n,D as r,E as i,G as a,I as o,K as s,O as c,Q as l,R as u,S as d,T as f,X as p,_ as m,_t as h,a as g,at as _,b as v,c as y,ct as b,dt as x,ft as S,g as C,gt as w,h as T,ht as E,i as D,it as O,j as k,k as A,lt as j,mt as M,n as ee,ot as N,pt as P,r as te,rt as F,s as ne,st as re,t as ie,tt as I,ut as L,v as ae,w as oe,x as se,y as ce}from"./chunks/vendor-lthmb2su.js";import{C as le,S as ue,_ as R,a as de,b as fe,c as pe,f as me,g as he,h as ge,i as _e,l as z,m as ve,n as ye,o as B,p as be,r as V,s as xe,t as Se,u as Ce,v as we,x as Te,y as Ee}from"./chunks/vendor-react-ggbyvons.js";import{A as De,B as Oe,C as ke,Ct as Ae,D as je,E as Me,F as Ne,H as Pe,I as Fe,It as Ie,L as Le,Lt as Re,M as ze,P as Be,Pt as Ve,R as He,S as Ue,St as We,Tt as Ge,U as Ke,V as qe,W as Je,_ as Ye,a as Xe,b as Ze,c as Qe,d as $e,f as et,g as tt,h as nt,i as rt,j as it,l as at,m as ot,n as st,o as ct,p as lt,r as ut,s as dt,st as ft,t as pt,u as mt,ut as ht,v as gt,vt as _t,w as vt,wt as yt,x as bt,y as xt,yt as St,z as Ct}from"./chunks/vendor-ui-j25lilhx.js";import{n as wt,t as H}from"./chunks/button-ygjnb239.js";import{$ as Tt,A as Et,At as Dt,B as Ot,Bt as kt,C as At,Ct as jt,D as Mt,Dt as Nt,E as Pt,Et as Ft,F as It,Ft as Lt,G as Rt,Gt as zt,H as Bt,Ht as Vt,I as Ht,It as Ut,J as Wt,Jt as Gt,K as Kt,Kt as qt,L as Jt,Lt as Yt,M as Xt,Mt as Zt,N as Qt,Nt as $t,O as en,Ot as tn,P as nn,Pt as U,Q as rn,R as an,Rt as on,S as sn,St as cn,T as ln,Tt as un,U as dn,Ut as fn,V as pn,Vt as mn,W as hn,Wt as gn,X as _n,Xt as vn,Y as yn,Yt as bn,Z as xn,Zt as Sn,_ as Cn,_t as wn,a as Tn,at as En,b as Dn,bt as On,c as kn,ct as An,d as jn,dt as Mn,et as Nn,f as Pn,ft as Fn,g as In,gt as Ln,h as Rn,ht as zn,i as Bn,it as Vn,j as Hn,jt as Un,k as Wn,kt as Gn,l as Kn,lt as qn,m as Jn,mt as Yn,n as Xn,nt as Zn,o as Qn,ot as $n,p as er,pt as tr,q as nr,qt as rr,r as ir,rt as ar,s as or,st as sr,t as cr,tt as lr,u as ur,ut as dr,v as fr,vt as pr,w as mr,wt as hr,x as gr,xt as _r,y as vr,yt as yr,z as br,zt as xr}from"./chunks/vendor-icons-mxz7yi04.js";import{a as W,i as Sr,n as Cr,r as wr,t as Tr}from"./chunks/tooltip-h1yceend.js";import{A as Er,At as Dr,B as Or,Bt as kr,Ct as Ar,D as jr,Dt as Mr,E as Nr,Et as Pr,F as Fr,G as Ir,H as Lr,Ht as Rr,J as zr,K as Br,M as Vr,N as Hr,P as Ur,Q as Wr,St as Gr,T as Kr,Tt as qr,V as Jr,Vt as Yr,Wt as Xr,X as Zr,Y as Qr,Z as $r,_ as ei,_t as ti,a as ni,b as ri,bt as ii,c as ai,d as oi,dt as si,f as ci,ft as li,g as ui,gt as di,h as fi,i as pi,it as mi,j as hi,jt as gi,k as _i,l as vi,lt as yi,m as bi,mt as xi,n as Si,o as Ci,p as wi,pt as Ti,q as Ei,r as Di,rt as Oi,s as ki,st as Ai,t as ji,tt as Mi,v as Ni,w as Pi,wt as Fi,xt as Ii,y as Li,z as Ri}from"./chunks/junior-hdb4wc4q.js";import{n as zi,r as Bi,t as Vi}from"./chunks/schema-m4v0mjyv.js";import{_ as Hi,a as Ui,c as Wi,d as Gi,f as Ki,g as qi,h as Ji,i as G,l as Yi,m as Xi,n as Zi,o as Qi,p as $i,s as ea,t as ta,u as na}from"./chunks/http-cdq677qt.js";import{a as ra,i as ia,n as aa,o as oa,r as sa,t as K}from"./chunks/styles-j0007fov.js";import{t as ca}from"./chunks/Card-hy4bfgq7.js";import{t as q}from"./chunks/skeleton-h6p83ux1.js";import{t as la}from"./chunks/PageContentSkeleton-b7dkba0l.js";import{d as ua,f as da,l as fa,m as pa,t as ma,u as ha}from"./chunks/PageHeader-bhl3orzi.js";import{A as ga,B as _a,C as va,E as ya,F as ba,G as xa,H as Sa,I as Ca,L as wa,M as Ta,N as Ea,O as Da,P as Oa,R as ka,S as Aa,T as ja,V as Ma,W as Na,_ as Pa,a as Fa,b as Ia,d as La,f as Ra,g as za,h as Ba,i as Va,j as Ha,k as Ua,l as Wa,m as Ga,n as Ka,o as qa,p as Ja,r as Ya,s as Xa,t as Za,u as Qa,v as $a,w as eo,x as to,y as no,z as ro}from"./chunks/format-gle1s0ri.js";import{a as io,c as ao,d as oo,f as so,i as co,l as lo,n as uo,o as fo,r as po,s as mo,t as ho,u as go}from"./chunks/SecondaryNavigation-m358iuko.js";import{t as _o}from"./chunks/PageLayout-l6dhbimv.js";import{t as vo}from"./chunks/AnchorHeading-cp3vx8qa.js";import{n as yo,t as bo}from"./chunks/searchParams-moqjgi65.js";import{t as xo}from"./chunks/SegmentedNav-eik9tbzh.js";import{i as So}from"./chunks/SystemPlugins-jr37f1cv.js";var Co=fe(),J=/* @__PURE__ */ e(le(),1),Y=ue();function wo({...e}){return/* @__PURE__ */ (0,Y.jsx)(Re,{...e})}function To({...e}){return/* @__PURE__ */ (0,Y.jsx)(ht,{"data-slot":`toast-portal`,...e})}function Eo({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(Ve,{"data-slot":`toast-viewport`,className:F(`pointer-events-none fixed inset-x-4 bottom-[max(5.25rem,env(safe-area-inset-bottom))] z-[60] mx-auto w-auto max-w-sm outline-none sm:right-4 sm:left-auto sm:mx-0 sm:w-full`,e),...t})}function Do({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(Ge,{"data-slot":`toast`,className:F(`group/toast pointer-events-auto absolute right-0 bottom-0 z-[calc(1000-var(--toast-index))] w-full origin-bottom rounded-lg border border-dashboard-border-emphasis bg-dashboard-surface-raised text-dashboard-text shadow-lg will-change-transform outline-none select-none focus-visible:outline-2 focus-visible:outline-dashboard-focus`,`[--gap:0.75rem] [--height:var(--toast-frontmost-height,var(--toast-height))] [--offset-y:calc(var(--toast-offset-y)*-1+calc(var(--toast-index)*var(--gap)*-1)+var(--toast-swipe-movement-y))] [--peek:0.75rem] [--scale:calc(max(0,1-(var(--toast-index)*0.1)))] [--shrink:calc(1-var(--scale))]`,`h-(--height) [transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-(var(--toast-index)*var(--peek))-(var(--shrink)*var(--height))))_scale(var(--scale))] [transition:transform_180ms_ease-out,opacity_180ms,height_180ms] motion-reduce:transition-none`,`after:absolute after:top-full after:left-0 after:h-[calc(var(--gap)+1px)] after:w-full after:content-['']`,`data-expanded:h-(--toast-height) data-expanded:[transform:translateX(var(--toast-swipe-movement-x))_translateY(var(--offset-y))]`,`data-limited:opacity-0 data-starting-style:[transform:translateY(150%)]`,`[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(150%)]`,`data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]`,`data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]`,`data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]`,`data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]`,`data-expanded:data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]`,`data-expanded:data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]`,`data-expanded:data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]`,`data-expanded:data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]`,e),...t})}function Oo({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(yt,{"data-slot":`toast-content`,className:F(`flex h-full items-center gap-3 overflow-hidden p-4 transition-opacity duration-180 motion-reduce:transition-none ease-[cubic-bezier(0.22,1,0.36,1)] data-behind:opacity-0 data-expanded:opacity-100`,e),...t})}function ko({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(We,{"data-slot":`toast-title`,className:F(`break-words text-sm font-medium`,e),...t})}function Ao({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(Ae,{"data-slot":`toast-description`,className:F(`break-words text-sm text-dashboard-text-muted`,e),...t})}function jo({className:e,render:t=/* @__PURE__ */ (0,Y.jsx)(H,{}),...n}){return/* @__PURE__ */ (0,Y.jsx)(_t,{"data-slot":`toast-action`,render:t,className:F(`shrink-0`,e),...n})}function Mo({className:e,children:t,render:n=/* @__PURE__ */ (0,Y.jsx)(H,{size:`icon`}),...r}){return/* @__PURE__ */ (0,Y.jsx)(St,{"data-slot":`toast-close`,"aria-label":`Close toast`,render:n,className:F(`relative shrink-0 text-dashboard-text-muted after:absolute after:-inset-2 after:content-[''] hover:text-dashboard-text`,e),...r,children:t??/* @__PURE__ */ (0,Y.jsx)(Xn,{"aria-hidden":`true`})})}function No({type:e}){let t=null;return e===`success`&&(t=/* @__PURE__ */ (0,Y.jsx)(tn,{"aria-hidden":`true`})),e===`info`&&(t=/* @__PURE__ */ (0,Y.jsx)(Nn,{"aria-hidden":`true`})),e===`warning`&&(t=/* @__PURE__ */ (0,Y.jsx)(kn,{"aria-hidden":`true`})),e===`error`&&(t=/* @__PURE__ */ (0,Y.jsx)(It,{className:`text-rose-300`,"aria-hidden":`true`})),e===`loading`&&(t=/* @__PURE__ */ (0,Y.jsx)(yn,{className:`animate-spin motion-reduce:animate-none`,"aria-hidden":`true`})),t?/* @__PURE__ */ (0,Y.jsx)(`span`,{"data-slot":`toast-icon`,className:`shrink-0 translate-y-0.5 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4`,children:t}):null}function Po(){let{toasts:e}=ft();return e.map(e=>/* @__PURE__ */ (0,Y.jsx)(Do,{toast:e,children:/* @__PURE__ */ (0,Y.jsxs)(Oo,{children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[/* @__PURE__ */ (0,Y.jsx)(No,{type:e.type}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[/* @__PURE__ */ (0,Y.jsx)(ko,{}),/* @__PURE__ */ (0,Y.jsx)(Ao,{})]})]}),e.actionProps?/* @__PURE__ */ (0,Y.jsx)(jo,{}):null,/* @__PURE__ */ (0,Y.jsx)(Mo,{})]})},e.id))}function Fo({children:e,...t}){return/* @__PURE__ */ (0,Y.jsxs)(wo,{limit:3,timeout:4e3,...t,children:[e,/* @__PURE__ */ (0,Y.jsx)(To,{children:/* @__PURE__ */ (0,Y.jsx)(Eo,{children:/* @__PURE__ */ (0,Y.jsx)(Po,{})})})]})}const Io=ft,Lo=[`dashboard`,`pin-order`],Ro={queryKey:[`dashboard`,`conversations`]};function zo(){let e=P(),[,t]=(0,J.useReducer)(e=>e+1,0),{mutate:n}=N({mutationKey:Lo,scope:{id:`pin-order`},mutationFn:({conversationIds:e})=>ea(Er,`/api/conversations/pin-order`,{conversationIds:e}),onError:(e,t)=>t.onError(),onSettled:()=>e.isMutating({mutationKey:Lo})===1?e.invalidateQueries(Ro):void 0});return(0,J.useCallback)(r=>{e.cancelQueries(Ro),Vo(e,r.conversationIds),t(),n(r)},[n,e])}function Bo(){return re({mutationKey:Lo})>0}function Vo(e,t){let n=new Map(t.map((e,t)=>[e,t]));e.setQueriesData(Ro,e=>e&&{...e,conversations:e.conversations.map(e=>{let t=n.get(e.conversationId);return t===void 0?e:{...e,pinPosition:t}})})}const Ho=3e5;function Uo(){if(typeof window>`u`)return;let e=window.__JUNIOR_DASHBOARD_BOOTSTRAP__;delete window.__JUNIOR_DASHBOARD_BOOTSTRAP__;let t=Vi.safeParse(e);return t.success?t.data:void 0}function Wo(){return j({queryKey:[`dashboard`,`core`],queryFn:async({signal:e})=>{let[t,n]=await Promise.all([G(Bi,`/api/me`,e),G(zi,`/api/config`,e)]);return{config:n,me:t}},initialData:Uo,initialDataUpdatedAt:()=>performance.timeOrigin,retry:!1,staleTime:Ho})}function Go(){return L(Wo())}function Ko(){return L({queryKey:[`dashboard`,`plugins`],queryFn:({signal:e})=>G(Zr,`/api/plugins`,e),retry:!1,staleTime:Ho})}function qo(){return L({queryKey:[`dashboard`,`plugin-user-pages`],queryFn:({signal:e})=>G(Xr,`/api/user-pages`,e),retry:!1,staleTime:Ho})}function Jo(e=``){let t=Bo();return L({enabled:!t,queryKey:[`dashboard`,`conversations`,`viewer`,{search:e}],queryFn:({signal:t})=>G(Ar,`/api/conversations${e?`?q=${encodeURIComponent(e)}`:``}`,t),placeholderData:h,retry:!1})}function Yo(){return L({queryKey:[`dashboard`,`code`],queryFn:({signal:e})=>G(ki,`/api/code`,e),retry:!1})}function Xo(){return L({queryKey:[`dashboard`,`board`],queryFn:({signal:e})=>G(Ci,`/api/board`,e),retry:!1})}function Zo(e){return L({enabled:!!e,queryKey:[`dashboard`,`code`,`repositories`,e],queryFn:({signal:t})=>G(vi,`/api/code/repositories/${encodeURIComponent(e)}`,t),retry:!1})}function Qo(e,t=``){return L({enabled:!!e,queryKey:[`dashboard`,`conversations`,`code-repository`,{repositoryId:e,search:t}],queryFn:({signal:n})=>{let r=new URLSearchParams({codeRepositoryId:e});return t&&r.set(`q`,t),G(Ar,`/api/conversations?${r.toString()}`,n)},placeholderData:h,retry:!1})}function $o(e,t){return L({enabled:e,queryKey:[`dashboard`,`automations`,t],queryFn:({signal:e})=>G(Oi,`/api/automations${t?`?${t}`:``}`,e),placeholderData:h,retry:!1})}function es(e,t){return L({enabled:e&&!!t,queryKey:[`dashboard`,`automations`,`detail`,t],queryFn:({signal:e})=>G(Ai,`/api/automations/${encodeURIComponent(t)}`,e),retry:!1})}function ts(e){return L({enabled:e,queryKey:[`dashboard`,`automations`,`runs`],queryFn:({signal:e})=>G(mi,`/api/automations/runs`,e),retry:!1})}function ns(e,t){return L({enabled:e&&!!t,queryKey:[`dashboard`,`automations`,t,`executions`],queryFn:({signal:e})=>G(Mi,`/api/automations/${encodeURIComponent(t)}/executions`,e),retry:!1})}function rs(e,t){return L({enabled:e&&!!t,queryKey:[`dashboard`,`automations`,t,`versions`],queryFn:({signal:e})=>G(yi,`/api/automations/${encodeURIComponent(t)}/versions`,e),retry:!1})}function is(){return L({queryKey:[`dashboard`,`people`],queryFn:({signal:e})=>G(Si,`/api/people`,e),retry:!1})}function as(e){return L({enabled:!!e,queryKey:[`dashboard`,`people`,e],queryFn:async({signal:t})=>G(Di,`/api/people/${encodeURIComponent(e)}`,t),retry:!1})}function os(e){return L({enabled:!!e,queryKey:[`dashboard`,`people`,e,`plugin-reports`],queryFn:({signal:t})=>G(Qr,`/api/people/${encodeURIComponent(e)}/plugin-reports`,t),retry:!1})}function ss(e){return L({enabled:!!e,queryKey:[`dashboard`,`people`,e,`code`],queryFn:({signal:t})=>G(ai,`/api/people/${encodeURIComponent(e)}/code`,t),retry:!1})}function cs(e){return L({enabled:e,queryKey:[`dashboard`,`personal-spend`],queryFn:({signal:e})=>G(jr,`/api/people/me/spend`,e),retry:!1,staleTime:0})}function ls(){return L({queryKey:[`dashboard`,`locations`],queryFn:({signal:e})=>G(Kr,`/api/locations`,e),retry:!1})}function us(e){return L({enabled:!!e,queryKey:[`dashboard`,`locations`,e],queryFn:async({signal:t})=>G(Pi,`/api/locations/${encodeURIComponent(e)}`,t),retry:!1})}function ds(){return L({queryKey:[`dashboard`,`skills`],queryFn:({signal:e})=>G($r,`/api/skills`,e),retry:!1,staleTime:Ho})}function fs(){return L({queryKey:[`dashboard`,`plugin-reports`],queryFn:({signal:e})=>G(Qr,`/api/plugin-reports`,e),retry:!1})}function ps(){return L({queryKey:[`dashboard`,`stats`],queryFn:({signal:e})=>G(Ri,`/api/stats`,e),retry:!1})}function ms(e){let t=Ko(),n=L({queryKey:[`dashboard`,`conversation-stats`],queryFn:({signal:e})=>G(ei,`/api/conversations/stats`,e),retry:!1}),r=L({queryKey:[`dashboard`,`reply-times`],queryFn:({signal:e})=>G(hi,`/api/reply-times`,e),retry:!1}),i=ds(),a=fs();return{data:t.data&&i.data?{...e,conversationStatsError:!!n.error,...n.data?{conversationStats:n.data}:void 0,conversationStatsLoading:n.isPending,pluginReportsError:!!a.error,...a.data?{pluginReports:a.data}:void 0,pluginReportsLoading:a.isPending,plugins:t.data,...r.data?{replyTimes:r.data}:void 0,replyTimesError:!!r.error,skills:i.data}:void 0,error:t.error??i.error,isPending:t.isPending||i.isPending}}function hs(){return(0,J.useSyncExternalStore)(e=>w.subscribe(e),()=>w.isOnline(),()=>!0)}const gs=I(`group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`border-dashboard-border-strong bg-dashboard-surface-raised text-dashboard-text`,destructive:`border-rose-300/20 bg-rose-300/[0.08] text-rose-100 *:data-[slot=alert-description]:text-rose-100/70 *:[svg]:text-rose-300`}},defaultVariants:{variant:`default`}});function _s({className:e,variant:t,...n}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`alert`,role:`alert`,className:F(gs({variant:t}),e),...n})}function vs({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`alert-title`,className:F(`font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-dashboard-text`,e),...t})}function ys({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`alert-description`,className:F(`text-sm text-balance text-dashboard-text-muted md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-dashboard-text [&_p:not(:last-child)]:mb-4`,e),...t})}function bs(){return hs()?null:/* @__PURE__ */ (0,Y.jsx)(_s,{"aria-live":`polite`,className:`block rounded-none border-0 border-t border-amber-300/15 bg-amber-300/[0.07] px-3 py-1.5 text-center font-sans text-xs text-amber-100/80`,role:`status`,children:`You’re offline. Drafts stay on this device.`})}var xs=`/_junior/dashboard/assets/junior-avatar-c8fohwwv.webp`;function Ss(){return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`relative grid size-10 shrink-0 select-none place-items-center overflow-visible`,children:/* @__PURE__ */ (0,Y.jsx)(`img`,{alt:``,className:`relative -m-0.5 size-11 max-w-none object-contain opacity-90 drop-shadow-[0_0_7px_rgba(255,255,255,0.16)]`,draggable:!1,src:xs})})}function Cs(e){return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:K(sa,`grid min-h-[calc(100dvh-5rem)] place-items-center px-4 py-8 md:px-8`),children:/* @__PURE__ */ (0,Y.jsxs)(`section`,{className:`grid w-full max-w-lg grid-cols-[auto_minmax(0,1fr)] items-center gap-3 rounded-lg border border-dashboard-border-emphasis bg-dashboard-surface-raised p-4`,children:[/* @__PURE__ */ (0,Y.jsx)(Ss,{}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`font-bold`,children:e.label}),/* @__PURE__ */ (0,Y.jsx)(`div`,{"aria-label":e.label,className:`relative overflow-hidden bg-white/15 before:absolute before:inset-0 before:content-[''] before:bg-[linear-gradient(90deg,#ff4d6d,#ffb703,#56f39a,#4cc9f0,#9b5de5,#ff4d6d)] before:bg-[length:200%_100%] before:animate-[junior-rainbow-flow_1.2s_linear_infinite] motion-reduce:before:animate-none mt-3 h-1.5 w-full`,role:`progressbar`})]})]})})}function ws(e){return Ts(e.serverVersion)?/* @__PURE__ */ (0,Y.jsxs)(_s,{"aria-live":`polite`,className:`flex flex-wrap items-center justify-center gap-x-3 gap-y-1 rounded-none border-0 border-t border-dashboard-accent/15 bg-dashboard-accent/[0.07] px-3 py-1.5 text-center font-sans text-xs text-dashboard-accent-text/80`,role:`status`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{children:`The dashboard changed. Refresh to load the latest version.`}),/* @__PURE__ */ (0,Y.jsx)(H,{className:`h-auto border-0 bg-transparent p-0 text-xs font-semibold leading-normal text-dashboard-accent-text underline decoration-dashboard-accent/40 underline-offset-2 hover:bg-transparent hover:text-dashboard-text-solid`,onClick:()=>window.location.reload(),children:`Refresh`})]}):null}function Ts(e){return!!e&&ji!==`unknown`&&e!==`unknown`&&e!==ji}const Es={automations:cr,code:yr,"memory:memories":xr,review:lr,system:An};function Ds(e){return Es[e]??kt}function Os(){let[e,n]=t(`junior:nav:layout`,`adaptive`);return[e===`sidebar`||e===`top-bar`?e:`adaptive`,n]}function ks(){let[e]=Os(),t=k(`(min-height: 68.75rem)`);return e===`top-bar`||e===`adaptive`&&t}function As(e){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:K(`flex items-center justify-between gap-3`,e.className),children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-sans text-sm font-semibold text-dashboard-text`,children:e.label}),/* @__PURE__ */ (0,Y.jsx)(ha,{"aria-label":e.label,className:`gap-0.5 rounded-lg border border-dashboard-border p-0.5`,onValueChange:([t])=>{t&&e.onChange(t)},value:[e.value],children:e.choices.map(t=>/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[/* @__PURE__ */ (0,Y.jsx)(W,{render:/* @__PURE__ */ (0,Y.jsx)(ua,{"aria-label":e.itemLabel(t),value:t.value,children:/* @__PURE__ */ (0,Y.jsx)(t.Icon,{"aria-hidden":`true`,size:14,strokeWidth:2})})}),/* @__PURE__ */ (0,Y.jsx)(Cr,{size:`compact`,children:t.label})]},t.value))})]})}const js=[{description:`Top bar on tall windows, sidebar on shorter ones.`,Icon:Et,label:`Adaptive`,value:`adaptive`},{description:`Always show the top bar.`,Icon:Hn,label:`Top bar`,value:`top-bar`},{description:`Always show the sidebar.`,Icon:Qt,label:`Sidebar`,value:`sidebar`}];function Ms(e){let[t,n]=Os();return/* @__PURE__ */ (0,Y.jsx)(As,{choices:js,className:e.className,itemLabel:e=>`${e.label} navigation`,label:`Navigation`,onChange:n,value:t})}const Ns=`junior-dashboard-theme`,Ps=`junior:dashboard-theme`,Fs={dark:`#000000`,light:`#ffffff`};`${JSON.stringify(Ns)}${JSON.stringify(Fs.light)}${JSON.stringify(Fs.dark)}${JSON.stringify(Ns)}${JSON.stringify(Ps)}`;function Is(){try{let e=window.localStorage.getItem(Ns);return e===`light`||e===`dark`?e:`system`}catch{return`system`}}function Ls(e){return window.addEventListener(Ps,e),window.addEventListener(`storage`,e),()=>{window.removeEventListener(Ps,e),window.removeEventListener(`storage`,e)}}function Rs(e){try{e===`system`?window.localStorage.removeItem(Ns):window.localStorage.setItem(Ns,e)}catch{return}window.dispatchEvent(new Event(Ps))}function zs(){return[(0,J.useSyncExternalStore)(Ls,Is),Rs]}const Bs=[{Icon:Jt,label:`System`,value:`system`},{Icon:Jn,label:`Light`,value:`light`},{Icon:Ht,label:`Dark`,value:`dark`}];function Vs(e){let[t,n]=zs();return/* @__PURE__ */ (0,Y.jsx)(As,{choices:Bs,className:e.className,itemLabel:e=>`${e.label} theme`,label:`Theme`,onChange:n,value:t})}function Hs({className:e,size:t=`default`,...n}){return/* @__PURE__ */ (0,Y.jsx)(Je,{"data-slot":`avatar`,"data-size":t,className:F(`group/avatar relative inline-grid size-7 shrink-0 place-items-center overflow-hidden rounded-full border-2 border-dashboard-bg bg-dashboard-focus shadow-sm select-none data-[size=sm]:size-6`,e),...n})}function Us({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(Ke,{"data-slot":`avatar-image`,className:F(`size-full object-cover`,e),...t})}function Ws({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(Pe,{"data-slot":`avatar-fallback`,className:F(`grid size-full place-items-center font-sans text-xs leading-none font-semibold tracking-tight text-dashboard-text-inverse group-data-[size=sm]/avatar:text-2xs`,e),...t})}function Gs(e){return/* @__PURE__ */ (0,Y.jsx)(qe,{...e})}function Ks(e){return/* @__PURE__ */ (0,Y.jsx)(Oe,{"data-slot":`popover-trigger`,...e})}function qs({className:e,align:t=`center`,side:n=`bottom`,...r}){return/* @__PURE__ */ (0,Y.jsx)(Ct,{children:/* @__PURE__ */ (0,Y.jsx)(He,{align:t,side:n,sideOffset:8,className:`isolate z-50`,children:/* @__PURE__ */ (0,Y.jsx)(Le,{"data-slot":`popover-content`,className:F(`w-80 max-w-[calc(100vw-2rem)] max-h-(--available-height) origin-(--transform-origin) overflow-y-auto rounded-lg border border-dashboard-border-emphasis bg-dashboard-surface-raised p-4 text-sm text-dashboard-text shadow-lg outline-none focus-visible:outline-2 focus-visible:outline-dashboard-focus transition-[opacity,scale] duration-180 motion-reduce:transition-none data-ending-style:opacity-0 data-starting-style:opacity-0 data-ending-style:scale-95 data-starting-style:scale-95`,e),...r})})})}function Js({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(Fe,{className:F(`m-0 text-sm font-medium`,e),...t})}function Ys({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(Ne,{className:F(`m-0 leading-relaxed text-dashboard-text-muted`,e),...t})}const Xs=J.createContext(null);function Zs(){let e=J.useContext(Xs);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function Qs({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:a,...o}){let[s,c]=J.useState(e),l=t??s,u=J.useCallback(e=>{let t=typeof e==`function`?e(l):e;n?n(t):c(t)},[n,l]),d=J.useCallback(()=>{u(e=>!e)},[u]),f=l?`expanded`:`collapsed`,p=J.useMemo(()=>({state:f,open:l,setOpen:u,toggleSidebar:d}),[f,l,u,d]);return/* @__PURE__ */ (0,Y.jsx)(Xs.Provider,{value:p,children:/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:{"--sidebar-width":`16rem`,"--sidebar-width-icon":`3rem`,...i},className:F(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),...o,children:a})})}function $s({side:e=`left`,variant:t=`sidebar`,collapsible:n=`offcanvas`,className:r,children:i,...a}){let{state:o}=Zs();return n===`none`?/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`sidebar`,className:F(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),...a,children:i}):/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":o,"data-collapsible":o===`collapsed`?n:``,"data-variant":t,"data-side":e,"data-slot":`sidebar`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`sidebar-gap`,className:F(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,t===`floating`||t===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`)}),/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`sidebar-container`,"data-side":e,className:F(`fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex`,t===`floating`||t===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,r),...a,children:/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border`,children:i})})]})}function ec({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`sidebar-header`,"data-sidebar":`header`,className:F(`flex flex-col gap-2 p-2`,e),...t})}function tc({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:F(`flex flex-col gap-2 p-2`,e),...t})}function nc({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:F(`no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,e),...t})}function rc({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`sidebar-group`,"data-sidebar":`group`,className:F(`relative flex w-full min-w-0 flex-col p-2`,e),...t})}function ic({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:F(`flex w-full min-w-0 flex-col gap-0`,e),...t})}function ac({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:F(`group/menu-item relative`,e),...t})}const oc=I(`peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate`,{variants:{variant:{default:`hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`default`}});function sc({render:e,isActive:t=!1,variant:n=`default`,size:r=`default`,tooltip:i,className:a,...o}){let{state:s}=Zs(),c=Be({defaultTagName:`button`,props:Ie({className:F(oc({variant:n,size:r}),a)},o),render:i?/* @__PURE__ */ (0,Y.jsx)(W,{render:e}):e,state:{slot:`sidebar-menu-button`,sidebar:`menu-button`,size:r,active:t}});return i?(typeof i==`string`&&(i={children:i}),/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[c,/* @__PURE__ */ (0,Y.jsx)(Cr,{side:`right`,align:`center`,hidden:s!==`collapsed`,...i})]})):c}function cc({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`sidebar-menu-badge`,"data-sidebar":`menu-badge`,className:F(`pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground`,e),...t})}function lc(e,t){let n=e?.trim().split(/\s+/).filter(Boolean)??[];return n.length>0?n.slice(0,2).map(e=>e[0]).join(``).toUpperCase():t.slice(0,1).toUpperCase()}function uc({className:e,user:t}){return/* @__PURE__ */ (0,Y.jsxs)(Hs,{"aria-hidden":`true`,className:K(`border-0 shadow-black/40`,e),children:[/* @__PURE__ */ (0,Y.jsx)(Us,{alt:`User avatar`,src:t.avatarUrl}),/* @__PURE__ */ (0,Y.jsx)(Ws,{className:`font-bold tracking-wide`,children:lc(t.name,t.email)})]})}function dc({value:e}){let[t,n]=(0,J.useState)(e),[r,i]=(0,J.useState)(!1),a=(0,J.useRef)(e);return(0,J.useEffect)(()=>{let t=a.current;if(e===void 0||t===void 0||t===e||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches){a.current=e,n(e),i(!1);return}let r=performance.now(),o=0,s=c=>{let l=Math.min(1,(c-r)/700),u=1-(1-l)**3,d=l<1?t+(e-t)*u:e;a.current=d,n(d),l<1?o=requestAnimationFrame(s):i(!1)};return i(!0),o=requestAnimationFrame(s),()=>cancelAnimationFrame(o)},[e]),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:K(`transition-colors duration-700 motion-reduce:transition-none`,r&&`text-dashboard-accent-text`),children:t===void 0?`—`:Ja({total:t})})}const fc=wt({size:`menu`});function pc({identity:e,onSignOut:t,spend:n,pages:r,variant:i=`popover`}){let[a,o]=(0,J.useState)(!1),s=e.user.email,c=e.user.name?.trim()||s,l=n?Ja({total:n.sevenDaysUsd}):`—`,u=n?Ja({total:n.thirtyDaysUsd}):`—`,d=/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`border-b border-dashboard-border-strong px-2.5 py-2.5`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[/* @__PURE__ */ (0,Y.jsx)(uc,{className:`size-8`,user:e.user}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 truncate text-sm font-semibold text-dashboard-text`,children:c}),c===s?null:/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`mt-0.5 mb-0 truncate text-xs text-dashboard-text-muted`,children:s})]})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{"aria-label":`Personal model spend`,className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 font-sans text-xs tabular-nums text-dashboard-text-muted`,role:`group`,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{children:[`7d`,` `,/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-semibold text-dashboard-text`,children:/* @__PURE__ */ (0,Y.jsx)(dc,{value:n?.sevenDaysUsd})})]}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{children:[`30d`,` `,/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-semibold text-dashboard-text`,children:/* @__PURE__ */ (0,Y.jsx)(dc,{value:n?.thirtyDaysUsd})})]})]})]}),f=n=>/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(V,{className:K(fc,`mt-1`),onClick:n,to:Ua(s),children:[/* @__PURE__ */ (0,Y.jsx)(Qn,{"aria-hidden":`true`,size:16,strokeWidth:2}),`My profile`]}),/* @__PURE__ */ (0,Y.jsxs)(V,{className:fc,onClick:n,to:`/settings`,children:[/* @__PURE__ */ (0,Y.jsx)(gr,{"aria-hidden":`true`,size:16,strokeWidth:2}),`Settings`]}),r.map(e=>{let t=Ds(e.key);return/* @__PURE__ */ (0,Y.jsxs)(V,{className:fc,onClick:n,to:e.to,children:[/* @__PURE__ */ (0,Y.jsx)(t,{"aria-hidden":`true`,size:16,strokeWidth:2}),e.label]},e.key)}),e.user.isAdmin?/* @__PURE__ */ (0,Y.jsxs)(V,{className:fc,onClick:n,to:`/admin`,children:[/* @__PURE__ */ (0,Y.jsx)(vr,{"aria-hidden":`true`,size:16,strokeWidth:2}),`Admin`]}):null,/* @__PURE__ */ (0,Y.jsxs)(H,{onClick:()=>{n(),t()},size:`menu`,children:[/* @__PURE__ */ (0,Y.jsx)(Kt,{"aria-hidden":`true`,size:16,strokeWidth:2}),`Log out`]})]});if(i===`sheet-spend`)return/* @__PURE__ */ (0,Y.jsxs)(`div`,{"aria-label":`Personal model spend: 7 days ${l}, 30 days ${u}`,className:`grid gap-1.5 rounded-lg border border-dashboard-border bg-dashboard-fill-soft px-3 py-2.5 font-sans text-xs tabular-nums text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-xs font-medium`,children:`Spend`}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`whitespace-nowrap`,children:[`7d`,` `,/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-semibold text-dashboard-text`,children:/* @__PURE__ */ (0,Y.jsx)(dc,{value:n?.sevenDaysUsd})})]}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`whitespace-nowrap`,children:[`30d`,` `,/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-semibold text-dashboard-text`,children:/* @__PURE__ */ (0,Y.jsx)(dc,{value:n?.thirtyDaysUsd})})]})]});if(i===`sheet-links`){let n=K(`rounded-lg border-0 bg-transparent px-3 py-3 text-left font-sans text-sm font-medium no-underline transition-colors hover:bg-dashboard-fill-soft focus-visible:bg-dashboard-fill-soft focus-visible:outline-none`,oa);return/* @__PURE__ */ (0,Y.jsxs)(`nav`,{"aria-label":`Account menu for ${c}`,className:`grid gap-1`,children:[/* @__PURE__ */ (0,Y.jsx)(V,{className:n,to:Ua(s),children:`My profile`}),/* @__PURE__ */ (0,Y.jsx)(V,{className:n,to:`/settings`,children:`Settings`}),r.map(e=>/* @__PURE__ */ (0,Y.jsx)(V,{className:n,to:e.to,children:e.label},e.key)),e.user.isAdmin?/* @__PURE__ */ (0,Y.jsx)(V,{className:n,to:`/admin`,children:`Admin`}):null,/* @__PURE__ */ (0,Y.jsx)(`button`,{className:K(n,`w-full cursor-pointer`),"data-mobile-nav-dismiss":!0,onClick:()=>{t()},type:`button`,children:`Log out`}),/* @__PURE__ */ (0,Y.jsx)(Vs,{className:`px-3 py-2`})]})}if(i===`sheet-identity`)return/* @__PURE__ */ (0,Y.jsxs)(`div`,{"aria-label":`Signed in as ${c}`,className:`flex min-w-0 items-center gap-2.5 px-1`,children:[/* @__PURE__ */ (0,Y.jsx)(uc,{user:e.user}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 truncate text-xs font-semibold text-dashboard-text`,children:c}),c===s?null:/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`mt-0.5 mb-0 truncate font-sans text-xs text-dashboard-text-muted`,children:s})]})]});let p=i===`top-bar`,m=`${a?`Close`:`Open`} profile menu for ${c}`,h={closeDelay:140,delay:80,openOnHover:!0};return/* @__PURE__ */ (0,Y.jsxs)(Gs,{onOpenChange:(e,t)=>{let n=t.event instanceof MouseEvent&&t.event.detail>0;(e||t.reason!==`trigger-press`||!n)&&o(e)},open:a,children:[p?/* @__PURE__ */ (0,Y.jsxs)(Ks,{"aria-label":`${m}. Personal model spend: 7 days ${l}, 30 days ${u}.`,className:K(`group flex h-10 cursor-pointer items-center gap-2 rounded-lg border-0 bg-transparent px-1.5 text-dashboard-text transition-colors hover:bg-dashboard-fill-hover hover:text-dashboard-text focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus/70`,a&&`bg-dashboard-fill-hover text-dashboard-text`),...h,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`flex items-baseline gap-1 whitespace-nowrap tabular-nums`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-xs font-medium tracking-[0.08em] text-dashboard-text-muted`,children:`7d`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-xs font-semibold text-dashboard-text`,children:/* @__PURE__ */ (0,Y.jsx)(dc,{value:n?.sevenDaysUsd})})]}),/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px bg-dashboard-fill-strong`}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`flex items-baseline gap-1 whitespace-nowrap tabular-nums`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-xs font-medium tracking-[0.08em] text-dashboard-text-muted`,children:`30d`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-xs font-semibold text-dashboard-text`,children:/* @__PURE__ */ (0,Y.jsx)(dc,{value:n?.thirtyDaysUsd})})]})]}),/* @__PURE__ */ (0,Y.jsx)(uc,{user:e.user}),/* @__PURE__ */ (0,Y.jsx)(Ut,{"aria-hidden":`true`,className:K(`text-dashboard-text-muted transition-[color,transform] group-hover:text-dashboard-text`,a&&`rotate-180 text-dashboard-text`),size:14,strokeWidth:2})]}):/* @__PURE__ */ (0,Y.jsx)(ac,{children:/* @__PURE__ */ (0,Y.jsxs)(sc,{"aria-label":m,className:K(`h-10 gap-2.5 rounded-lg px-1.5 group-data-[collapsible=icon]:size-10! group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:p-0! [&_svg]:size-3.5`,a&&`bg-sidebar-accent`),render:/* @__PURE__ */ (0,Y.jsx)(Ks,{...h}),children:[/* @__PURE__ */ (0,Y.jsx)(uc,{user:e.user}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium group-data-[collapsible=icon]:hidden`,children:c}),/* @__PURE__ */ (0,Y.jsx)(Dt,{"aria-hidden":`true`,className:`text-dashboard-text-muted group-data-[collapsible=icon]:hidden`,strokeWidth:2})]})}),/* @__PURE__ */ (0,Y.jsxs)(qs,{align:`end`,side:p?`bottom`:`right`,className:`w-64 rounded-xl border-0 bg-dashboard-surface-raised/95 p-1.5 shadow-2xl shadow-black/75 backdrop-blur-xl`,id:`profile-popover`,children:[d,/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid gap-1 border-b border-dashboard-border-strong px-2.5 py-2`,children:[/* @__PURE__ */ (0,Y.jsx)(Vs,{}),/* @__PURE__ */ (0,Y.jsx)(Ms,{})]}),f(()=>o(!1))]})]})}const mc={key:`pinned`,label:`Pinned`,order:-2},hc={key:`attention`,label:`Needs attention`,order:-1};function gc(e,t){let n=Ec(t.nowMs,t.timeZone),r=/* @__PURE__ */ new Map,i=[...e].sort((e,t)=>Sc(t)-Sc(e));for(let e of i){let i=e.pinnedAt?mc:_c(e,t.attentionIds)?hc:Cc(Sc(e),n,t.nowMs,t.timeZone),a=r.get(i.key);a?a.conversations.push(e):r.set(i.key,{...i,conversations:[e]})}return r.get(mc.key)?.conversations.sort(bc),[...r.values()].sort((e,t)=>e.order-t.order).map(({order:e,...t})=>t)}function _c(e,t){return t.has(e.id)||e.awaitingAuthorization===!0||e.unfinishedWork===!0&&e.status!==`active`}function vc(e,t){return/* @__PURE__ */ new Set([...t,...e.filter(e=>e.unread).map(e=>e.id)])}function yc(e,t){let n=e=>e.pinnedAt?0:_c(e,t)?1:2;return[...e].sort((e,t)=>n(e)-n(t)||(e.pinnedAt&&t.pinnedAt?bc(e,t):0))}function bc(e,t){return(e.pinPosition??-1/0)-(t.pinPosition??-1/0)||xc(t)-xc(e)||e.id.localeCompare(t.id)}function xc(e){return e.pinnedAt&&Date.parse(e.pinnedAt)||0}function Sc(e){let t=Date.parse(e.lastSeenAt);return Number.isFinite(t)?t:-1/0}function Cc(e,t,n,r){if(!Number.isFinite(e))return{key:`older`,label:`Older`,order:1/0};let i=Math.max(0,Tc(e,t,r));if(i===0)return{key:`today`,label:`Today`,order:0};if(i===1)return{key:`yesterday`,label:`Yesterday`,order:1};if(i<=7)return{key:`previous-7-days`,label:`Previous 7 days`,order:2};if(i<=30)return{key:`previous-30-days`,label:`Previous 30 days`,order:3};let a=wc(e,r),o=wc(n,r);return{key:`month-${a.year}-${a.month}`,label:new Intl.DateTimeFormat(`en-US`,{month:`long`,timeZone:r,...a.year===o.year?void 0:{year:`numeric`}}).format(e),order:4+(o.year-a.year)*12+(o.month-a.month)}}function wc(e,t){let n=new Intl.DateTimeFormat(`en-US`,{month:`numeric`,timeZone:t,year:`numeric`}).formatToParts(e),r=new Map(n.map(e=>[e.type,Number(e.value)]));return{month:r.get(`month`)??1,year:r.get(`year`)??0}}function Tc(e,t,n){return Math.round((t-Ec(e,n))/864e5)}function Ec(e,t){let n=new Intl.DateTimeFormat(`en-US`,{day:`numeric`,month:`numeric`,timeZone:t,year:`numeric`}).formatToParts(e),r=new Map(n.map(e=>[e.type,Number(e.value)]));return Date.UTC(r.get(`year`)??0,(r.get(`month`)??1)-1,r.get(`day`)??1)}function Dc(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return``;let r=Math.floor(Math.max(0,t-n)/6e4);if(r<1)return`now`;if(r<60)return`${r}m`;let i=Math.floor(r/60);if(i<24)return`${i}h`;let a=Math.floor(i/24);return a<7?`${a}d`:a<30?`${Math.floor(a/7)}w`:new Date(n).toLocaleDateString(`en-US`,{day:`numeric`,month:`short`,timeZone:ja()})}function Oc(e,t=Date.now(),n=ja()){let r=Date.parse(e);if(!Number.isFinite(r))return``;let i=Tc(r,Ec(t,n),n);if(i<=0)return new Date(r).toLocaleTimeString(`en-US`,{hour:`numeric`,minute:`2-digit`,timeZone:n});if(i===1)return`Yesterday`;if(i<7)return new Date(r).toLocaleDateString(`en-US`,{timeZone:n,weekday:`short`});let a=e=>new Date(e).toLocaleDateString(`en-US`,{timeZone:n,year:`numeric`});return new Date(r).toLocaleDateString(`en-US`,{day:`numeric`,month:`short`,timeZone:n,...a(r)===a(t)?void 0:{year:`numeric`}})}function kc(e,t){let n=`/conversations/${encodeURIComponent(e)}`,r=new URLSearchParams;t?.turnId&&r.set(zc,t.turnId),t?.reviewItems&&r.set(Lc,Rc);let i=r.toString();return i?`${n}?${i}`:n}const Ac={focusReply:!0};function jc(e){if(typeof e==`object`&&e&&`focusReply`in e&&e.focusReply===!0)return{draftFrom:`draftFrom`in e&&typeof e.draftFrom==`string`?e.draftFrom:void 0,focusReply:!0}}const Mc={eventLog:!0};function Nc(e){return typeof e==`object`&&!!e&&`eventLog`in e&&e.eventLog===!0}function Pc(e){return e===`/`||e===`/conversations/new`}const Fc=`event`;function Ic(e){return e&&/^\d+$/.test(e)?Number(e):void 0}const Lc=`review`,Rc=`open`,zc=`turn`;function Bc(e,t){return e?.find(({data:e})=>e.type===`turn_lifecycle`&&e.state===`started`&&e.turnId===t)?.seq}function Vc(e,t=250){let[n,r]=(0,J.useState)(e);return(0,J.useEffect)(()=>{let n=window.setTimeout(()=>r(e),t);return()=>window.clearTimeout(n)},[t,e]),n}const Hc=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.userAgent);function Uc(e){return Hc?`⌘${e.toUpperCase()}`:`Ctrl ${e.toUpperCase()}`}function Wc(e,t){return e.key.toLowerCase()===t&&(Hc?e.metaKey:e.ctrlKey)&&!e.altKey&&!e.shiftKey}function Gc(e){let{label:t,matches:n}=e;if(!n?.length)return/* @__PURE__ */ (0,Y.jsx)(Y.Fragment,{children:t});let r=new Set(n),i=[];for(let e=0;e<t.length;e+=1){let n=r.has(e),a=i.at(-1);a?.matched===n?a.chars+=t[e]:i.push({chars:t[e],matched:n})}return i.map((e,t)=>e.matched?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-semibold text-dashboard-accent-text`,children:e.chars},t):e.chars)}const Kc=1e3,qc=/[\p{L}\p{N}]/u,Jc=/\p{Lu}/u,Yc=/\p{Ll}/u;function Xc(e,t){let n=tl(e),r=nl(e),i=tl(t).split(/\s+/).filter(Boolean),a=/* @__PURE__ */ new Set,o=0;for(let e of i){let t=Zc(n,r,e);if(!t)return;o+=t.score;for(let e of t.indices)a.add(e)}return{indices:[...a].sort((e,t)=>e-t),score:o}}function Zc(e,t,n){let r=-1;for(let i=e.indexOf(n);i!==-1;i=e.indexOf(n,i+1)){if(t.has(i))return{indices:rl(i,n.length),score:3*Kc-i};r===-1&&(r=i)}if(r!==-1)return{indices:rl(r,n.length),score:2*Kc-r};let i=Qc(e,t,n);if(i&&i.score>=600)return i;let a=$c(e,t,n);return!i||!a?i??a:i.score>=a.score?i:a}function Qc(e,t,n){let r=[],i=0,a=0;for(let o of n){let n=e.indexOf(o,a);if(n===-1)return;t.has(n)&&(i+=1),r.push(...rl(n,o.length)),a=n+o.length}let o=r.at(-1)-r[0],s=Kc-o*20+i*10;return{indices:r,score:Math.min(Math.max(s,1),999)}}function $c(e,t,n){if(n.length<4)return;let r=n.length<6?1:2,i;for(let a of t){if(!qc.test(e[a]))continue;let t=el(n,e.slice(a,a+n.length+r));for(let e=0;e<=2*r;e++){let o=n.length+(e%2?-1:1)*Math.ceil(e/2),s=t[o];s!==void 0&&s<=r&&(!i||s<i.distance)&&(i={at:a,length:o,distance:s})}}if(i)return{indices:rl(i.at,i.length),score:Math.max(600/i.distance-i.at,1)}}function el(e,t){let n=Array.from({length:t.length+1},()=>0),r=Array.from({length:t.length+1},(e,t)=>t),i=Array.from({length:t.length+1},()=>0);for(let a=1;a<=e.length;a++){i[0]=a;for(let o=1;o<=t.length;o++)i[o]=Math.min(r[o]+1,i[o-1]+1,r[o-1]+(e[a-1]===t[o-1]?0:1)),a>1&&o>1&&e[a-1]===t[o-2]&&e[a-2]===t[o-1]&&(i[o]=Math.min(i[o],n[o-2]+1));[n,r,i]=[r,i,n]}return r}function tl(e){let t=``;for(let n of e)t+=n.toLowerCase().slice(0,n.length);return t}function nl(e){let t=/* @__PURE__ */ new Set([0]);for(let n=1;n<e.length;n++){let r=e[n],i=e[n-1];(!qc.test(i)||Jc.test(r)&&Yc.test(i))&&t.add(n)}return t}function rl(e,t){return Array.from({length:t},(t,n)=>e+n)}function il(e){return/* @__PURE__ */ (0,Y.jsx)(vt,{"data-slot":`dialog`,...e})}function al(e){return/* @__PURE__ */ (0,Y.jsx)(it,{"data-slot":`dialog-close`,...e})}function ol({className:e,...t}){return/* @__PURE__ */ (0,Y.jsxs)(Me,{"data-slot":`dialog-portal`,children:[/* @__PURE__ */ (0,Y.jsx)(ze,{forceRender:!0,"data-slot":`dialog-overlay`,className:`fixed inset-0 z-50 bg-dashboard-overlay transition-opacity duration-180 motion-reduce:transition-none data-ending-style:opacity-0 data-starting-style:opacity-0`}),/* @__PURE__ */ (0,Y.jsx)(je,{"data-dashboard-modal":``,"data-slot":`dialog-content`,className:F(`fixed top-[max(1rem,env(safe-area-inset-top))] left-1/2 z-50 grid max-h-[calc(100dvh-max(1rem,env(safe-area-inset-top))-max(1rem,env(safe-area-inset-bottom)))] w-[calc(100%-2rem)] max-w-md -translate-x-1/2 gap-4 overflow-y-auto rounded-xl border border-dashboard-border-emphasis bg-dashboard-surface-raised p-5 text-sm text-dashboard-text shadow-lg outline-none transition-[opacity,scale] duration-180 motion-reduce:transition-none data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0 sm:top-1/2 sm:max-h-[calc(100dvh-2rem)] sm:-translate-y-1/2`,e),...t})]})}function sl({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(ke,{"data-slot":`dialog-title`,className:F(`m-0 font-display text-lg font-medium`,e),...t})}function cl({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`dialog-footer`,className:F(`flex flex-wrap justify-end gap-2`,e),...t})}function ll({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(A,{"data-slot":`command`,className:F(`flex size-full min-h-0 flex-col overflow-hidden text-dashboard-text`,e),...t})}function ul({children:e,className:t,title:n,...r}){return/* @__PURE__ */ (0,Y.jsx)(il,{...r,children:/* @__PURE__ */ (0,Y.jsxs)(ol,{className:F(`flex max-w-xl flex-col gap-0 overflow-hidden p-0 sm:top-[15vh] sm:translate-y-0`,t),children:[/* @__PURE__ */ (0,Y.jsx)(sl,{className:`sr-only`,children:n}),e]})})}function dl({children:e,className:t,...n}){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex items-center gap-3 border-b border-dashboard-border-subtle px-4`,children:[/* @__PURE__ */ (0,Y.jsx)(At,{"aria-hidden":`true`,className:`size-4 shrink-0 text-dashboard-text-muted`}),/* @__PURE__ */ (0,Y.jsx)(A.Input,{"data-slot":`command-input`,className:F(`h-12 min-w-0 flex-1 border-0 bg-transparent font-sans text-sm text-dashboard-text outline-none placeholder:text-dashboard-text-faint`,t),...n}),e]})}function fl({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(A.List,{"data-slot":`command-list`,className:F(`thin-scrollbar min-h-0 scroll-py-2 overflow-y-auto overscroll-contain p-2 sm:max-h-[min(24rem,60dvh)]`,e),...t})}function pl({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(A.Empty,{"data-slot":`command-empty`,className:F(`px-3 py-6 text-center font-sans text-sm text-dashboard-text-muted`,e),...t})}function ml({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(A.Group,{"data-slot":`command-group`,className:F(`**:[[cmdk-group-heading]]:px-3 **:[[cmdk-group-heading]]:pt-2 **:[[cmdk-group-heading]]:pb-1 **:[[cmdk-group-heading]]:font-sans **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-dashboard-text-muted`,e),...t})}function hl({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(A.Item,{"data-slot":`command-item`,className:F(`flex cursor-pointer items-center gap-3 rounded-lg px-3 py-2 font-sans text-sm text-dashboard-text outline-none select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-dashboard-fill-hover [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-dashboard-text-muted`,e),...t})}const gl=Uc(`k`),_l=`Go to conversation`;function vl(e){let{onOpenChange:t,open:n}=e;return(0,J.useEffect)(()=>{let e=e=>{Wc(e,`k`)&&!e.repeat&&(e.preventDefault(),t(!n))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,n]),/* @__PURE__ */ (0,Y.jsx)(ul,{onOpenChange:t,open:n,title:_l,children:/* @__PURE__ */ (0,Y.jsx)(yl,{currentConversationId:e.currentConversationId,navItems:e.navItems,onClose:()=>t(!1)})})}function yl(e){let[t,n]=(0,J.useState)(``),r=Vc(t.trim()),i=Jo(),a=Jo(r),o=ge(),s=(0,J.useRef)(null),c=!!r&&t.trim()===r&&!a.isPlaceholderData,l=(0,J.useMemo)(()=>bl({currentConversationId:e.currentConversationId,feed:Ya(i.data?.conversations??[]),navItems:e.navItems,query:t.trim(),searched:c?Ya(a.data?.conversations??[]):[]}),[i.data?.conversations,e.currentConversationId,e.navItems,t,a.data?.conversations,c]);(0,J.useEffect)(()=>{s.current?.querySelector(`[cmdk-item][data-selected="true"]`)?.scrollIntoView({block:`nearest`})},[l]);let u=[...new Set(l.map(e=>e.group))].map(e=>[e,l.filter(t=>t.group===e)]),d=t.trim()!==r||a.isFetching;return/* @__PURE__ */ (0,Y.jsxs)(ll,{loop:!0,shouldFilter:!1,vimBindings:!1,children:[/* @__PURE__ */ (0,Y.jsx)(dl,{"aria-label":`Conversation or page`,onValueChange:n,placeholder:`Go to a conversation or page…`,spellCheck:!1,value:t,children:/* @__PURE__ */ (0,Y.jsx)(`kbd`,{className:`shrink-0 rounded border border-dashboard-border px-1.5 py-0.5 font-sans text-xs text-dashboard-text-faint max-sm:hidden`,children:`esc`})}),/* @__PURE__ */ (0,Y.jsxs)(fl,{ref:s,children:[/* @__PURE__ */ (0,Y.jsx)(pl,{children:d?`Searching…`:`No matches.`}),u.map(([t,n])=>/* @__PURE__ */ (0,Y.jsx)(ml,{heading:t,children:n.map(t=>{let n=t.icon;return/* @__PURE__ */ (0,Y.jsxs)(hl,{onSelect:()=>{o(t.to,{state:t.state}),e.onClose()},value:t.id,children:[/* @__PURE__ */ (0,Y.jsx)(n,{"aria-hidden":`true`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:/* @__PURE__ */ (0,Y.jsx)(Gc,{label:t.label,matches:t.matches})}),t.meta?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-xs tabular-nums text-dashboard-text-faint`,children:t.meta}):null]},t.id)})},t))]})]})}function bl(e){let t=t=>t.filter(t=>t.id!==e.currentConversationId),n=[{icon:In,key:`new-conversation`,label:`New conversation`,to:`/`},...e.navItems.map(e=>({icon:Ds(e.key),key:e.key,label:e.label,to:e.to}))],r=e=>({group:`Go to`,icon:e.icon,id:`page-${e.key}`,label:e.label,score:0,to:e.to});if(!e.query)return[...t(e.feed).sort((e,t)=>Date.parse(t.lastSeenAt)-Date.parse(e.lastSeenAt)).slice(0,8).map(e=>xl(e,`Recent`)),...n.map(r)];let i=e=>e.filter(e=>e.score>0).sort((e,t)=>t.score-e.score),a=i(t(e.feed).map(t=>xl(t,`Conversations`,e.query))),o=i(n.map(t=>{let n=Xc(t.label,e.query);return{...r(t),matches:n?.indices,score:n?.score??0}})),s=new Set(e.feed.map(e=>e.id)),c=t(e.searched).filter(e=>!s.has(e.id)).slice(0,8).map(t=>xl(t,`More conversations`,e.query));return(o[0]?.score??0)>(a[0]?.score??0)?[...o,...a,...c]:[...a,...o,...c]}function xl(e,t,n){let r=Fa(e),i=n?Xc(r,n):void 0;return{group:t,icon:e.visibility===`private`?Wt:Ot,id:`conversation-${e.id}`,label:r,matches:i?.indices,meta:e.archivedAt?`Archived`:Dc(e.lastSeenAt),score:i?.score??0,state:Ac,to:kc(e.id)}}function Sl({...e}){return/* @__PURE__ */ (0,Y.jsx)(vt,{"data-slot":`sheet`,...e})}function Cl({...e}){return/* @__PURE__ */ (0,Y.jsx)(it,{"data-slot":`sheet-close`,...e})}function wl({...e}){return/* @__PURE__ */ (0,Y.jsx)(Me,{"data-slot":`sheet-portal`,...e})}function Tl({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(ze,{"data-slot":`sheet-overlay`,className:F(`fixed inset-0 z-50 bg-dashboard-overlay transition-opacity duration-180 motion-reduce:transition-none data-ending-style:opacity-0 data-starting-style:opacity-0`,e),...t})}function El({className:e,children:t,side:n=`right`,showCloseButton:r=!0,closeButtonProps:i,...a}){let o=J.useRef(null);return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{ref:o,className:`contents`}),/* @__PURE__ */ (0,Y.jsxs)(wl,{container:o,children:[/* @__PURE__ */ (0,Y.jsx)(Tl,{}),/* @__PURE__ */ (0,Y.jsxs)(je,{"data-slot":`sheet-content`,"data-dashboard-modal":``,"data-side":n,className:F(`fixed z-50 flex flex-col gap-4 border-dashboard-border-strong bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition-[opacity,transform] duration-180 ease-[cubic-bezier(0.2,0.8,0.2,1)] motion-reduce:transition-none data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm`,e),...a,children:[t,r&&/* @__PURE__ */ (0,Y.jsxs)(it,{"data-slot":`sheet-close`,render:/* @__PURE__ */ (0,Y.jsx)(H,{...i,className:F(`absolute top-3 right-3`,i?.className),size:`icon`}),children:[/* @__PURE__ */ (0,Y.jsx)(Xn,{"aria-hidden":`true`,size:15,strokeWidth:2.25}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})]})}function Dl({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`sheet-header`,className:F(`flex flex-col gap-1 p-4 pr-14`,e),...t})}function Ol({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(ke,{"data-slot":`sheet-title`,className:F(`text-lg font-semibold text-foreground`,e),...t})}function kl(){let e=0,t;return{acquire(){if(typeof document<`u`){if(e===0){let e=document.documentElement,n=document.body,r=typeof window>`u`?0:window.scrollX||window.pageXOffset||0,i=typeof window>`u`?0:window.scrollY||window.pageYOffset||0;t={bodyHeight:n.style.height,bodyLeft:n.style.left,bodyOverflow:n.style.overflow,bodyOverscroll:n.style.overscrollBehavior,bodyPosition:n.style.position,bodyRight:n.style.right,bodyTop:n.style.top,bodyWidth:n.style.width,htmlHeight:e.style.height,htmlOverflow:e.style.overflow,htmlOverscroll:e.style.overscrollBehavior,scrollX:r,scrollY:i},e.style.overflow=`hidden`,e.style.overscrollBehavior=`none`,e.style.height=`100%`,n.style.overflow=`hidden`,n.style.overscrollBehavior=`none`,n.style.position=`fixed`,n.style.top=`-${i}px`,n.style.left=`-${r}px`,n.style.right=`0`,n.style.width=`100%`,n.style.height=`100%`}e+=1}},release(){if(typeof document>`u`||e===0||(e=Math.max(0,e-1),e>0||t===void 0))return;let n=document.documentElement,r=document.body;n.style.overflow=t.htmlOverflow,n.style.overscrollBehavior=t.htmlOverscroll,n.style.height=t.htmlHeight,r.style.overflow=t.bodyOverflow,r.style.overscrollBehavior=t.bodyOverscroll,r.style.position=t.bodyPosition,r.style.top=t.bodyTop,r.style.left=t.bodyLeft,r.style.right=t.bodyRight,r.style.width=t.bodyWidth,r.style.height=t.bodyHeight;let{scrollX:i,scrollY:a}=t;t=void 0,typeof window<`u`&&window.scrollTo(i,a)}}}const Al=kl();function jl(){Al.acquire()}function Ml(){Al.release()}function Nl(e){let t=new MutationObserver(e);return t.observe(document.body,{childList:!0,subtree:!0}),()=>t.disconnect()}function Pl(e,t){let[n,r]=(0,J.useState)(!1),i=(0,J.useRef)(!1),a=(0,J.useRef)(null),o=(0,J.useSyncExternalStore)(Nl,()=>{let e=document.querySelectorAll(`[data-dashboard-modal]`),t=e[e.length-1];return a.current?t===a.current:!t},()=>!0);return(0,J.useEffect)(()=>(jl(),r(!0),Ml),[]),{rootProps:{open:n,modal:o?`trap-focus`:!1,disablePointerDismissal:!o,onOpenChange(e,t){!e&&!o?t.cancel():(i.current=!e,r(e))},onOpenChangeComplete(t){!t&&i.current&&e()}},contentProps:{ref:a,"aria-modal":o?!0:void 0,finalFocus:()=>!!(i.current&&o),initialFocus:()=>{let e=document.querySelectorAll(`[data-dashboard-modal]`);return e[e.length-1]===a.current?t?.current??!0:!1}}}}const Fl=`(width >= 48rem) and ((width >= 64rem) or (height >= 30rem))`,Il=`(width < 48rem) or ((width < 64rem) and (height < 30rem))`,Ll=`grid size-10 place-items-center rounded-lg text-dashboard-text no-underline transition-colors hover:bg-dashboard-fill-hover focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus/70`;function Rl(e){return e.count?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`ml-1.5 rounded-full bg-violet-300/20 px-1.5 py-0.5 text-xs text-violet-200`,children:e.count.toLocaleString(`en-US`)}):null}function zl(e){let t=(0,J.useRef)(null),n=(0,J.useRef)(e.onMobileNavigationOpenChange);n.current=e.onMobileNavigationOpenChange;let r=lo(),i=!!(e.mobileBackTo||r),a=e.mobileTitle??r?.title,o=a===void 0?`Conversation`:a.trim();so(()=>{n.current(!0)});let s=({isActive:e})=>K(`shrink-0 whitespace-nowrap rounded-lg px-3 py-2 font-sans text-sm font-medium tracking-normal no-underline transition-colors`,e?`bg-dashboard-accent/[0.1] text-dashboard-accent-text`:K(`hover:bg-dashboard-fill-soft`,oa)),c=({isActive:e})=>K(`rounded-lg px-3 py-3 font-sans text-sm font-medium no-underline transition-colors`,e?`bg-dashboard-accent/[0.1] text-dashboard-accent-text`:K(`hover:bg-dashboard-fill-soft`,oa));return(0,J.useEffect)(()=>{if(!e.mobileNavigationOpen)return;let t=window.matchMedia(Il),r=()=>{t.matches||n.current(!1)};return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e.mobileNavigationOpen]),/* @__PURE__ */ (0,Y.jsxs)(`header`,{className:K(`relative bg-dashboard-bg`,!e.desktopTopBar&&`md:hidden`),children:[e.desktopTopBar?/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`hidden w-full min-w-0 grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-x-5 px-7 py-3 md:grid lg:grid-cols-[minmax(auto,1fr)_minmax(0,36rem)_minmax(auto,1fr)]`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex items-center gap-5 max-lg:min-w-0`,children:[/* @__PURE__ */ (0,Y.jsx)(V,{"aria-label":`${pa()} home`,className:`flex items-center text-inherit no-underline`,to:`/`,children:/* @__PURE__ */ (0,Y.jsx)(Ss,{})}),/* @__PURE__ */ (0,Y.jsxs)(`nav`,{"aria-label":`Primary`,className:`flex items-center gap-1 [scrollbar-width:none] max-lg:min-w-0 max-lg:overflow-x-auto [&::-webkit-scrollbar]:hidden`,children:[/* @__PURE__ */ (0,Y.jsx)(V,{"aria-current":e.workspaceActive?`page`:void 0,className:s({isActive:e.workspaceActive}),to:`/`,children:`Conversations`}),e.navItems.map(e=>/* @__PURE__ */ (0,Y.jsxs)(_e,{className:s,to:e.to,children:[e.label,/* @__PURE__ */ (0,Y.jsx)(Rl,{count:e.count})]},e.key))]})]}),/* @__PURE__ */ (0,Y.jsxs)(H,{"aria-keyshortcuts":`Meta+K Control+K`,className:`w-full font-normal text-dashboard-text-faint hover:text-dashboard-text-muted`,onClick:e.onSearch,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center justify-center gap-2`,children:[/* @__PURE__ */ (0,Y.jsx)(At,{"aria-hidden":`true`,className:`size-4 shrink-0`}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`truncate max-lg:sr-only`,children:[_l,`…`]})]}),/* @__PURE__ */ (0,Y.jsx)(`kbd`,{className:`font-sans text-xs max-xl:hidden`,children:gl})]}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`flex items-center gap-3 justify-self-end`,children:e.profile})]}):null,/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid w-full min-w-0 grid-cols-[2.5rem_minmax(0,1fr)_2.5rem] items-center gap-x-2 px-3 py-2 md:hidden`,children:[i&&r?/* @__PURE__ */ (0,Y.jsx)(`button`,{"aria-label":r.label,className:K(Ll,`cursor-pointer border-0 bg-transparent disabled:cursor-default`),disabled:!r.onClick,onClick:r.onClick,type:`button`,children:/* @__PURE__ */ (0,Y.jsx)(rr,{"aria-hidden":`true`,size:20,strokeWidth:2})}):i&&e.mobileBackTo?/* @__PURE__ */ (0,Y.jsx)(V,{"aria-label":`Back to conversations`,className:Ll,to:e.mobileBackTo,children:/* @__PURE__ */ (0,Y.jsx)(rr,{"aria-hidden":`true`,size:20,strokeWidth:2})}):/* @__PURE__ */ (0,Y.jsx)(`button`,{"aria-controls":`mobile-navigation`,"aria-expanded":e.mobileNavigationOpen,"aria-hidden":e.mobileNavigationOpen||void 0,"aria-label":`Open navigation`,className:`grid size-10 cursor-pointer place-items-center rounded-lg border-0 bg-transparent text-dashboard-text transition-colors hover:bg-dashboard-fill-hover focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus/70`,onClick:()=>e.onMobileNavigationOpenChange(!0),tabIndex:e.mobileNavigationOpen?-1:void 0,type:`button`,children:/* @__PURE__ */ (0,Y.jsx)(dn,{"aria-hidden":`true`,size:20,strokeWidth:2})}),i?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`col-start-2 row-start-1 flex min-w-0 items-center gap-2`,children:o?/* @__PURE__ */ (0,Y.jsx)(`h1`,{className:`m-0 min-w-0 truncate text-left font-display text-sm font-medium text-dashboard-text`,children:o}):null}):null,/* @__PURE__ */ (0,Y.jsx)(V,{"aria-label":`${pa()} home`,className:K(`col-start-2 row-start-1 min-w-0 max-w-full items-center justify-self-center text-inherit no-underline`,i?`hidden`:`flex`),to:`/`,children:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`truncate font-sans text-sm font-semibold`,children:pa()})}),i?/* @__PURE__ */ (0,Y.jsx)(io,{}):null,i?/* @__PURE__ */ (0,Y.jsx)(mo,{}):null]}),e.mobileNavigationOpen?/* @__PURE__ */ (0,Y.jsxs)(Bl,{closeRef:t,onClose:()=>n.current(!1),children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-dashboard-border-subtle bg-dashboard-surface-raised px-3 py-2 pt-[max(0.5rem,env(safe-area-inset-top))]`,children:[/* @__PURE__ */ (0,Y.jsx)(V,{"aria-label":`${pa()} home`,className:`min-w-0 truncate font-sans text-sm font-semibold text-inherit no-underline`,to:`/`,children:pa()}),/* @__PURE__ */ (0,Y.jsx)(Cl,{"aria-label":`Close navigation`,className:`grid size-10 cursor-pointer place-items-center rounded-lg border-0 bg-transparent text-dashboard-text transition-colors hover:bg-dashboard-fill-hover focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus/70`,ref:t,children:/* @__PURE__ */ (0,Y.jsx)(Xn,{"aria-hidden":`true`,size:20,strokeWidth:2})})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-3`,children:[e.mobileSpend?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`mb-3`,children:e.mobileSpend}):null,/* @__PURE__ */ (0,Y.jsxs)(`nav`,{"aria-label":`Primary`,className:`grid gap-1`,children:[/* @__PURE__ */ (0,Y.jsxs)(H,{className:K(c({isActive:!1}),`gap-2`),"data-mobile-nav-dismiss":``,onClick:e.onSearch,size:`menu`,children:[/* @__PURE__ */ (0,Y.jsx)(At,{"aria-hidden":`true`,className:`size-4`}),_l]}),/* @__PURE__ */ (0,Y.jsx)(V,{"aria-current":e.workspaceActive?`page`:void 0,className:c({isActive:e.workspaceActive}),to:`/`,children:`Conversations`}),e.navItems.map(e=>/* @__PURE__ */ (0,Y.jsxs)(_e,{className:c,to:e.to,children:[e.label,/* @__PURE__ */ (0,Y.jsx)(Rl,{count:e.count})]},e.key))]}),/* @__PURE__ */ (0,Y.jsx)(ao,{}),e.mobileProfile?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`mt-4 border-t border-dashboard-border-subtle pt-3`,children:e.mobileProfile}):null]}),e.mobileIdentity||e.version?/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`border-t border-dashboard-border-subtle px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[e.mobileIdentity?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:e.version?`mb-2.5`:void 0,children:e.mobileIdentity}):null,e.version?/* @__PURE__ */ (0,Y.jsxs)(`p`,{className:`m-0 font-sans text-xs text-dashboard-text-muted`,children:[`junior version `,e.version]}):null]}):null]})]}):null]})}function Bl(e){let t=Pl(e.onClose,e.closeRef);return/* @__PURE__ */ (0,Y.jsx)(Sl,{...t.rootProps,children:/* @__PURE__ */ (0,Y.jsx)(El,{...t.contentProps,"aria-label":`Navigation`,className:`inset-0 gap-0 bg-dashboard-bg-elevated outline-none data-[side=left]:w-full data-[side=left]:border-r-0 data-[side=left]:sm:max-w-none md:hidden`,id:`mobile-navigation`,onClick:t=>{t.target instanceof Element&&t.target.closest(`a[href], [data-mobile-nav-dismiss]`)&&e.onClose()},showCloseButton:!1,side:`left`,children:e.children})})}function Vl({className:e,orientation:t=`horizontal`,...n}){return/* @__PURE__ */ (0,Y.jsx)(Ue,{"data-slot":`separator`,orientation:t,className:F(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...n})}const Hl=`h-10 gap-3 rounded-lg px-2.5 text-dashboard-text-muted group-data-[collapsible=icon]:size-10! group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:p-0! data-active:bg-dashboard-accent/[0.12] data-active:font-normal data-active:text-dashboard-accent-text [&_svg]:size-5`,Ul=`group-data-[collapsible=icon]:hidden`,Wl={"--sidebar-width":`13rem`,"--sidebar-width-icon":`3.5rem`};function Gl(e){let[n,r]=t(`junior:nav:sidebar-open`,!1);return/* @__PURE__ */ (0,Y.jsx)(Qs,{onOpenChange:r,open:n,style:Wl,children:e.children})}function Kl(e){let t=e.icon,n=e.count?`${e.label} ${e.count.toLocaleString(`en-US`)}`:e.label;return/* @__PURE__ */ (0,Y.jsxs)(ac,{children:[/* @__PURE__ */ (0,Y.jsxs)(sc,{"aria-label":n,className:Hl,isActive:e.active,render:/* @__PURE__ */ (0,Y.jsx)(V,{"aria-current":e.active?`page`:void 0,to:e.to}),tooltip:{children:n,size:`compact`,sideOffset:6},children:[/* @__PURE__ */ (0,Y.jsx)(t,{"aria-hidden":`true`,strokeWidth:1.9}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:Ul,children:e.label})]}),e.count?/* @__PURE__ */ (0,Y.jsx)(cc,{"aria-hidden":`true`,className:`top-1/2 right-2 h-4 min-w-4 -translate-y-1/2 rounded-full bg-dashboard-accent px-1 text-2xs font-semibold leading-none normal-nums text-dashboard-text-inverse peer-data-[size=default]/menu-button:top-1/2 peer-data-active/menu-button:text-dashboard-text-inverse peer-hover/menu-button:text-dashboard-text-inverse group-data-[collapsible=icon]:top-0! group-data-[collapsible=icon]:right-0 group-data-[collapsible=icon]:flex group-data-[collapsible=icon]:translate-y-0 group-data-[collapsible=icon]:ring-2 group-data-[collapsible=icon]:ring-sidebar`,children:e.count>99?`99+`:e.count.toLocaleString(`en-US`)}):null]})}function ql(e){return/* @__PURE__ */ (0,Y.jsx)(ic,{className:`mt-3 group-data-[collapsible=icon]:items-center`,children:/* @__PURE__ */ (0,Y.jsx)(ac,{children:/* @__PURE__ */ (0,Y.jsxs)(sc,{"aria-keyshortcuts":`Meta+K Control+K`,"aria-label":_l,className:Hl,onClick:e.onSearch,tooltip:{children:`${_l} ${gl}`,size:`compact`,sideOffset:6},children:[/* @__PURE__ */ (0,Y.jsx)(At,{"aria-hidden":`true`,strokeWidth:1.9}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:Ul,children:_l})]})})})}function Jl(e){let t=ve({end:!1,path:e.item.to})!==null;return/* @__PURE__ */ (0,Y.jsx)(Kl,{active:t,count:e.item.count,icon:Ds(e.item.key),label:e.item.label,to:e.item.to})}function Yl(){let{open:e,toggleSidebar:t}=Zs();(0,J.useEffect)(()=>{let e=e=>{Wc(e,`b`)&&!e.repeat&&(e.preventDefault(),t())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let n=e?`Collapse sidebar`:`Expand sidebar`;return/* @__PURE__ */ (0,Y.jsx)(sc,{"aria-expanded":e,"aria-keyshortcuts":`Meta+B Control+B`,"aria-label":n,className:`size-8! justify-center rounded-lg p-0! text-dashboard-text-faint hover:text-dashboard-text [&_svg]:size-4`,onClick:t,tooltip:{children:n,size:`compact`,sideOffset:6},children:/* @__PURE__ */ (0,Y.jsx)(e?Zt:Un,{"aria-hidden":`true`,strokeWidth:2})})}function Xl(e){return/* @__PURE__ */ (0,Y.jsxs)($s,{className:`border-dashboard-border-strong pt-[env(safe-area-inset-top)]`,collapsible:`icon`,children:[/* @__PURE__ */ (0,Y.jsxs)(ec,{className:`px-3 pt-3 pb-4 group-data-[collapsible=icon]:items-center group-data-[collapsible=icon]:px-2`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 group-data-[collapsible=icon]:flex-col`,children:[/* @__PURE__ */ (0,Y.jsxs)(V,{"aria-label":`${pa()} home`,className:`flex min-w-0 items-center gap-2 text-inherit no-underline`,to:`/`,children:[/* @__PURE__ */ (0,Y.jsx)(Ss,{}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:K(`truncate font-sans text-sm font-semibold`,Ul),children:pa()})]}),/* @__PURE__ */ (0,Y.jsx)(Yl,{})]}),/* @__PURE__ */ (0,Y.jsx)(ql,{onSearch:e.onSearch}),/* @__PURE__ */ (0,Y.jsx)(Vl,{className:`mt-1 bg-dashboard-border-strong group-data-[collapsible=icon]:data-horizontal:w-6`})]}),/* @__PURE__ */ (0,Y.jsx)(nc,{className:`group-data-[collapsible=icon]:overflow-auto`,children:/* @__PURE__ */ (0,Y.jsx)(rc,{className:`px-3 py-0 group-data-[collapsible=icon]:items-center group-data-[collapsible=icon]:px-2`,children:/* @__PURE__ */ (0,Y.jsx)(`nav`,{"aria-label":`Primary`,className:`w-full`,children:/* @__PURE__ */ (0,Y.jsxs)(ic,{className:`gap-1 group-data-[collapsible=icon]:items-center group-data-[collapsible=icon]:gap-1.5`,children:[/* @__PURE__ */ (0,Y.jsx)(Kl,{active:e.workspaceActive,icon:br,label:`Conversations`,to:`/`}),e.navItems.map(e=>/* @__PURE__ */ (0,Y.jsx)(Jl,{item:e},e.key))]})})})}),e.profile?/* @__PURE__ */ (0,Y.jsx)(tc,{className:`px-3 pb-3 group-data-[collapsible=icon]:items-center group-data-[collapsible=icon]:px-2`,children:/* @__PURE__ */ (0,Y.jsx)(ic,{className:`group-data-[collapsible=icon]:items-center`,children:e.profile})}):null]})}const Zl=`--dashboard-viewport-height`,Ql=`--dashboard-viewport-offset-top`,$l=`--dashboard-keyboard-open`,eu=`--dashboard-composer-dock-padding`;function tu(e){if(!e.mobile)return null;let t=Math.max(0,Math.round(e.layoutHeight)),n=Math.max(0,Math.round(e.visualHeight)),r=Math.max(0,Math.round(e.restingLayoutHeight)),i=Math.max(0,Math.round(e.visualOffsetTop)),a=t-n,o=a>=100,s=Math.abs(a)<100&&r-Math.min(t,n)>=100&&(e.editableFocused||i>0);if(!(o||s))return{heightPx:t,keyboardOpen:!1,offsetTopPx:0};let c=Math.max(t,Math.round(e.documentClientHeight)),l=Math.max(0,c-n);return{heightPx:n,keyboardOpen:!0,offsetTopPx:Math.min(i,l)}}function nu(e){let t=Math.max(0,Math.round(e.layoutHeight));return e.keyboardOpen?Math.max(0,Math.round(e.previousRestingLayoutHeight)):t}function ru(e,t){(0,J.useEffect)(()=>{let n=e.current;if(!t||!n||typeof window>`u`)return;let r=window.matchMedia(Il),i=window.visualViewport,a,o=``,s=``,c=``,l=``,u=Math.round(window.innerHeight),d=r.matches,f=!1,p=e=>{f!==e&&(f=e,e?jl():Ml())},m=()=>{o!==``&&(n.style.removeProperty(Zl),o=``),s!==``&&(n.style.removeProperty(Ql),s=``),c!==``&&(n.style.removeProperty($l),c=``),l!==``&&(n.style.removeProperty(eu),l=``)},h=()=>{a===void 0&&(a=requestAnimationFrame(()=>{let e=window.innerHeight,t=document.documentElement.clientHeight||e,f=i?.height??e,h=i?.offsetTop??0,g=iu(document.activeElement);if(!r.matches){u=nu({keyboardOpen:!1,layoutHeight:e,previousRestingLayoutHeight:u}),d=!1,p(!1),m(),a=void 0;return}d||=(u=Math.round(e),!0);let _=tu({documentClientHeight:t,editableFocused:g,layoutHeight:e,mobile:!0,restingLayoutHeight:u,visualHeight:f,visualOffsetTop:h});if(!_){p(!1),m(),a=void 0;return}u=nu({keyboardOpen:_.keyboardOpen,layoutHeight:e,previousRestingLayoutHeight:u}),p(!0);let v=`${_.heightPx}px`,y=`${_.offsetTopPx}px`,b=_.keyboardOpen?`1`:`0`,x=_.keyboardOpen?`0.375rem`:`max(0.375rem, env(safe-area-inset-bottom))`;o!==v&&(n.style.setProperty(Zl,v),o=v),s!==y&&(n.style.setProperty(Ql,y),s=y),c!==b&&(n.style.setProperty($l,b),c=b),l!==x&&(n.style.setProperty(eu,x),l=x),a=void 0}))};return h(),r.addEventListener(`change`,h),window.addEventListener(`resize`,h),i?.addEventListener(`resize`,h),i?.addEventListener(`scroll`,h),document.addEventListener(`focusin`,h),document.addEventListener(`focusout`,h),()=>{a!==void 0&&cancelAnimationFrame(a),r.removeEventListener(`change`,h),window.removeEventListener(`resize`,h),i?.removeEventListener(`resize`,h),i?.removeEventListener(`scroll`,h),document.removeEventListener(`focusin`,h),document.removeEventListener(`focusout`,h),p(!1),m()}},[t,e])}function iu(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function au(e){let t=(0,J.useRef)(null);return ru(t,e.enabled),/* @__PURE__ */ (0,Y.jsx)(`main`,{className:K(`grid font-sans text-dashboard-text`,e.enabled?`fixed inset-x-0 top-[var(--dashboard-viewport-offset-top,0px)] h-[var(--dashboard-viewport-height,100dvh)] max-h-[var(--dashboard-viewport-height,100dvh)] min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden overscroll-none md:relative md:inset-auto md:h-dvh md:max-h-none md:overscroll-auto`:`relative min-h-screen grid-rows-[auto_1fr]`,e.className),ref:t,style:e.style,children:e.children})}var ou=/* @__PURE__ */ e(Te(),1);const su=[`dashboard`,`review-items`];function cu(e){let t=new URLSearchParams;e.conversationId&&t.set(`conversationId`,e.conversationId),e.forViewer&&t.set(`for`,`viewer`),e.q&&t.set(`q`,e.q);let n=t.toString(),r=O({initialPageParam:void 0,queryKey:[...su,`list`,n],queryFn:({pageParam:e,signal:t})=>{let r=new URLSearchParams(n);return e&&r.set(`cursor`,e),G(Hr,`/api/review-items?${r.toString()}`,t)},getNextPageParam:e=>e.nextCursor,placeholderData:h,retry:!1}),i=r.data?.pages;return{items:(0,J.useMemo)(()=>(i??[]).flatMap(e=>e.items),[i]),moreArchived:!!i?.[0]?.moreArchived,query:r}}function lu(e){return L({enabled:!!e,queryKey:[...su,`detail`,e],queryFn:({signal:t})=>G(Ur,`/api/review-items/${encodeURIComponent(e)}`,t),retry:!1})}function uu(e){return x({queries:e.map(e=>({queryKey:[`dashboard`,`conversation-title`,e],queryFn:async({signal:t})=>Va(await G(Ii,`/api/conversations/${encodeURIComponent(e)}?limit=1`,t))??null,retry:!1,staleTime:3e5}))}).map(e=>e.data??void 0)}function du(e){return L({enabled:e,queryKey:[...su,`count`],queryFn:({signal:e})=>G(Vr,`/api/review-items/count`,e),retry:!1})}function fu(e){return L({enabled:e,queryKey:[`dashboard`,`automations`,`scope=mine&state=blocked`],queryFn:({signal:e})=>G(Oi,`/api/automations?scope=mine&state=blocked&pageSize=100`,e),retry:!1})}function pu(){let e=P();return N({mutationFn:e=>Qi(Ur,`/api/review-items/${encodeURIComponent(e.id)}/actions`,e.body),onSettled:()=>e.invalidateQueries({queryKey:su})})}const mu=/* @__PURE__ */ new Map;function hu(){let e=L({queryKey:[...su,`waiting-conversations`],queryFn:({signal:e})=>G(Fr,`/api/review-items/waiting-conversations`,e),retry:!1}).data?.conversations;return(0,J.useMemo)(()=>e?new Map(e.map(({conversationId:e,count:t,title:n})=>[e,{count:t,title:n}])):mu,[e])}function gu(){let e=hu();return(0,J.useMemo)(()=>new Set(e.keys()),[e])}function _u(e){let t=e.getQueryData([`dashboard`,`core`])?.me.user;if(t?.email)return{...t.avatarUrl?{avatarUrl:t.avatarUrl}:void 0,email:t.email,fullName:t.name||void 0}}function vu(e){return[`conversation`,e,`outbox`]}function yu(e){let t=e.now??(/* @__PURE__ */ new Date()).toISOString();return{actorIdentity:e.actorIdentity,createdAt:t,idempotencyKey:e.idempotencyKey,...e.inline?{inline:!0}:void 0,message:e.message,...e.images?.length?{images:e.images}:void 0,messageId:e.messageId,status:`sending`}}function bu(e){return{actorIdentity:e.actorIdentity,clientStatus:e.status,createdAt:e.createdAt,delivery:`defer`,idempotencyKey:e.idempotencyKey,inboundMessageId:e.messageId,messageId:e.messageId,receivedAt:e.createdAt,role:`user`,source:`web`,text:e.message,...e.images?.length?{images:e.images}:void 0}}function xu(e,t,n){let r=e??[],i=t??[],a=r;if(i.length>0){let e=new Set(r.map(e=>e.messageId)),t=i.filter(t=>!e.has(t.messageId)).map(bu);t.length>0&&(a=[...r,...t])}return Su(n,a)}function Su(e,t){if(!e)return t;if(e===t)return e;if(e.length!==t.length)return t;for(let n=0;n<e.length;n+=1)if(!Cu(e[n],t[n]))return t;return e}function Cu(e,t){return e.inboundMessageId===t.inboundMessageId&&e.messageId===t.messageId&&e.clientStatus===t.clientStatus&&e.delivery===t.delivery&&e.text===t.text&&e.images===t.images&&JSON.stringify(e.attachments)===JSON.stringify(t.attachments)&&e.redacted===t.redacted&&e.source===t.source&&e.role===t.role&&e.createdAt===t.createdAt&&e.receivedAt===t.receivedAt&&e.idempotencyKey===t.idempotencyKey&&Tu(e.actorIdentity,t.actorIdentity)&&wu(e.mentions,t.mentions)}function wu(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((e,n)=>Tu(e,t[n]))}function Tu(e,t){return e===t?!0:!e||!t?!1:e.avatarUrl===t.avatarUrl&&e.email===t.email&&e.fullName===t.fullName&&e.slackUserId===t.slackUserId&&e.slackUserName===t.slackUserName}function Eu(e){return!!e.inline&&e.status!==`failed`}function Du(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set;for(let r of e)if(r.data.type===`message`&&t.add(r.data.messageId),r.data.type===`turn_lifecycle`&&r.data.state===`started`)for(let e of r.data.inputMessageIds??[])n.add(e);return{messageIds:t,turnInputIds:n}}function Ou(e,t){let n=new Set(t.queued.map(e=>e.messageId)),{messageIds:r,turnInputIds:i}=Du(t.events),a=e=>{let a=n.has(e.messageId);if(!(r.has(e.messageId)||!a&&i.has(e.messageId)))return a?Eu(e)?e:void 0:e.acceptedAtMs!==void 0&&t.mailboxReadAtMs!==void 0&&t.mailboxReadAtMs>e.acceptedAtMs?void 0:e},o=e.flatMap(e=>a(e)??[]);return o.length===e.length&&o.every((t,n)=>t===e[n])?e:o}function ku(e,t,n){let r=n.filter(Eu);if(r.length===0)return{inline:[],queued:e};let i=new Set(r.map(e=>e.messageId)),a=new Map((t??[]).map(e=>[e.messageId,e]));return{inline:r.map(e=>a.get(e.messageId)??bu(e)),queued:e.filter(e=>!i.has(e.messageId))}}function Au(e,t){let n=e??[],r=n.findIndex(e=>e.idempotencyKey===t.idempotencyKey);if(r<0)return[...n,t];let i=n.slice();return i[r]=t,i}function ju(e,t,n){return(e??[]).map(e=>e.idempotencyKey===t?{...e,acceptedAtMs:Date.now(),messageId:n,status:`accepted`}:e)}function Mu(e,t){return(e??[]).map(e=>e.idempotencyKey===t?{...e,status:`failed`}:e)}const Nu=[];function Pu(e){if(!e)return Nu;let t=[];for(let n of e)n.data.type===`message`&&t.push(n.data.messageId);return t}function Fu(e,t){return Ku(e,t)||(t.length===0?e:{...e,events:Gu([...t.flatMap(e=>e.events),...e.events]),previousCursor:Bu(e.previousCursor,t)??(t.length?Wu(t):e.previousCursor)})}function Iu(e,t,n){return Ku(e,t)||{...e,events:Gu([...t.flatMap(e=>e.events),...n]),previousCursor:Wu(t)}}async function Lu(e){let t=new Map(e.historyPages.map(e=>[e.requestedBefore,e])),n=[],r=/* @__PURE__ */ new Set,i=e.detail.previousCursor;for(;i;){if(r.has(i))throw Error(`Conversation history cursor did not advance`);r.add(i);let a=t.get(i)??{...await e.readPage(i),requestedBefore:i};n.push(a),i=a.previousCursor}return Fu(e.detail,n)}function Ru(e){let t=Hu(e);return t===void 0?`empty`:String(t)}function zu(e,t){return Bu(e,t)??Wu(t)}function Bu(e,t){if(!e)return;let n=new Map(t.map(e=>[e.requestedBefore,e])),r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Set,a=e;for(;a;){if(i.has(a))return;i.add(a);let e=n.get(a);if(!e)return r.size>0&&r.size===t.length?void 0:a;r.add(e);let o=Hu(r),s=Uu(t.filter(e=>!r.has(e)));if(o!==void 0&&s!==void 0&&o<=s+1)return;a=e.previousCursor}}function Vu(e,t){return t.some(t=>t.eventHistory.status!==e.eventHistory.status)}function Hu(e){let t;for(let n of e){let e=n.events[0]?.seq;e!==void 0&&(t===void 0||e<t)&&(t=e)}return t}function Uu(e){let t;for(let n of e){let e=n.events.at(-1)?.seq;e!==void 0&&(t===void 0||e>t)&&(t=e)}return t}function Wu(e){let t;for(let n of e){let e=n.events[0]?.seq,r=t?.events[0]?.seq;e!==void 0&&(r===void 0||e<r)&&(t=n)}return t?.previousCursor}function Gu(e){return[...new Map(e.map(e=>[e.seq,e])).values()].sort((e,t)=>e.seq-t.seq)}function Ku(e,t){if(e.eventHistory.status!==`available`)return qu(e);let n=t.find(e=>e.eventHistory.status!==`available`);if(n)return qu({...e,eventHistory:n.eventHistory,events:n.events,previousCursor:n.previousCursor})}function qu(e){let{modelUsage:t,...n}=e;return n}function Ju(e,t){if(!e)return t;let n=Yu(e.events,t.events)?e.events:t.events,r=JSON.stringify(e.annotations)===JSON.stringify(t.annotations)?e.annotations:t.annotations,i=JSON.stringify(e.authors)===JSON.stringify(t.authors)?e.authors:t.authors;return n===t.events&&r===t.annotations&&i===t.authors?t:{...t,events:n,annotations:r,authors:i}}function Yu(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(r.seq!==i.seq||r.createdAt!==i.createdAt||r.data.type===`message`&&i.data.type===`message`&&JSON.stringify(r.data.attachments)!==JSON.stringify(i.data.attachments))return!1}return!0}function Xu(e){if(e?.status!==`active`)return!1;for(let t=e.events.length-1;t>=0;--t){let n=e.events[t].data;if(n.type===`turn_lifecycle`)return n.state===`started`}return!!e.previousCursor}function Zu(e){return!!e?.agentTree}function X(e){return[`conversation`,e,`detail`]}function Qu(e){return{id:`conversation:${e}:read`}}function $u(e){return[`conversation`,e,`unread`]}function ed(e,t){let n=X(t),r=e.getQueryState(n);if(!r?.data?.prefetchedAtMs)return;let{prefetchedAtMs:i,...a}=r.data;e.setQueryData(n,a,{updatedAt:r.dataUpdatedAt})}function td(e){return!!(e?.prefetchedAtMs&&Date.now()-e.prefetchedAtMs<3e4)}const nd=[`agents`,`memories`,`watches`];function rd(e,t){return[`conversation`,e,t]}function id(e,t,n,r){if(n?.detailEtag&&r.detailEtag&&n.detailEtag!==r.detailEtag){for(let n of nd)e.invalidateQueries({queryKey:rd(t,n)});e.invalidateQueries({queryKey:su})}}function ad(e){return e?.status===`active`||!!e?.mailbox?.messages.length||!!e?.mailbox?.authorization}function od(e,t){return j({enabled:!!e,queryKey:X(e),queryFn:async({signal:n,client:r})=>{let i=r.getQueryData(X(e)),a=await gd(e,n,i,{mailbox:!0,unreadPage:t?.unreadPage});return id(r,e,i,a),a},structuralSharing:(e,t)=>!t||typeof t!=`object`||!e||typeof e!=`object`?t:sd(e,Ju(e,t)),refetchInterval:e=>t?.fastPollUntilMs&&Date.now()<t.fastPollUntilMs?500:t?.awaitingMessage||ad(e.state.data)?2e3:!t?.versionsPoll&&1e4,retry:!1})}function sd(e,t){let n=e.readPosition;if(!n||t.unread||(t.readPosition?.lastReadSeq??-1)>=n.lastReadSeq)return t;let{unreadCursor:r,unreadPage:i,...a}=t;return{...a,readPosition:n,...e.unreadCursor?{unreadCursor:e.unreadCursor,unreadPage:e.unreadPage}:void 0}}function cd(){let e=P();return N({mutationFn:e=>Qi(ii,`/api/conversations`,e),onSuccess:(t,n)=>{e.setQueryData(vu(t.conversationId),r=>Au(r,{...yu({...n,actorIdentity:_u(e),inline:!0,messageId:t.messageId}),acceptedAtMs:Date.now(),status:`accepted`})),e.invalidateQueries({queryKey:[`dashboard`,`conversations`]}),e.invalidateQueries({exact:!0,queryKey:X(t.conversationId)})}})}function ld(e){let t=P();return N({mutationFn:async t=>{let n=await Qi(qr,`/api/conversations/${encodeURIComponent(e)}/forks`,{messageId:t.messageId,idempotencyKey:t.idempotencyKey});return Qi(ii,`/api/conversations/${encodeURIComponent(n.conversationId)}/messages`,{idempotencyKey:t.idempotencyKey,message:t.message})},onSuccess:(e,n)=>{t.setQueryData(vu(e.conversationId),r=>Au(r,{...yu({idempotencyKey:n.idempotencyKey,message:n.message,actorIdentity:_u(t),inline:!0,messageId:e.messageId}),acceptedAtMs:Date.now(),status:`accepted`})),t.invalidateQueries({queryKey:[`dashboard`,`conversations`]})}})}function ud(e){let t=P(),n=vu(e);return N({mutationFn:({inline:t,...n})=>Qi(ii,`/api/conversations/${encodeURIComponent(e)}/messages`,n),onMutate:async r=>{let i=await di({conversationId:e,idempotencyKey:r.idempotencyKey}),a=yu({...r,actorIdentity:_u(t),messageId:i});t.setQueryData(n,e=>Au(e,a))},onError:(e,r)=>{t.setQueryData(n,e=>Mu(e,r.idempotencyKey))},onSuccess:(r,i)=>{t.setQueryData(n,e=>ju(e,i.idempotencyKey,r.messageId)),t.invalidateQueries({queryKey:[`dashboard`,`conversations`]}),t.invalidateQueries({exact:!0,queryKey:X(e)})}})}function dd(e){let t=P();return N({mutationFn:t=>Zi(Br,`/api/conversations/${encodeURIComponent(e)}/pending-messages`,t),onMutate:async n=>{await t.cancelQueries({exact:!0,queryKey:X(e)});let r=t.getQueryData(X(e));return r?.mailbox&&t.setQueryData(X(e),{...r,mailbox:{...r.mailbox,messages:r.mailbox.messages.filter(e=>!n.inboundMessageIds.includes(e.inboundMessageId))}}),{previousPending:r}},onError:(n,r,i)=>{i?.previousPending&&t.setQueryData(X(e),e=>e&&{...e,mailbox:i.previousPending?.mailbox})},onSettled:async()=>{await Promise.all([t.invalidateQueries({queryKey:[`dashboard`,`conversations`]}),t.invalidateQueries({exact:!0,queryKey:X(e)})])}})}function fd(e){let t=P();return N({mutationFn:t=>Qi(Wr,`/api/conversations/${encodeURIComponent(e)}/pending-messages/steer`,t),onSuccess:async n=>{let r=new Set(n.steeredInboundMessageIds);r.size!==0&&(await t.cancelQueries({exact:!0,queryKey:X(e)}),t.setQueryData(X(e),e=>e?.mailbox?{...e,mailbox:{...e.mailbox,messages:e.mailbox.messages.map(e=>r.has(e.inboundMessageId)?{...e,delivery:`interrupt`}:e)}}:e))},onSettled:async()=>{await t.invalidateQueries({exact:!0,queryKey:X(e)})}})}function pd(e){return[`conversation`,e,`stopped-messages`]}function md(e){let t=P();return N({mutationFn:()=>Qi(Or,`/api/conversations/${encodeURIComponent(e)}/stop`,{}),onSuccess:n=>{let r=n.stoppedInboundMessageIds;r.length&&(t.setQueryData(pd(e),e=>[...e??[],...r]),t.setQueryData(vu(e),e=>e?.filter(e=>!r.includes(e.messageId))))},onSettled:async()=>{await t.invalidateQueries({exact:!0,queryKey:X(e)})}})}function hd(e,t){let n=P(),r=()=>{let t=td(n.getQueryData(X(e)));return{conversationId:e,fetched:t,prefetched:t}},[i,a]=(0,J.useState)(r);i.conversationId!==e&&a(r());let o=i.conversationId===e&&i.fetched,s=i.conversationId===e&&i.prefetched,c=L({enabled:!!e,queryFn:async()=>n.getQueryData(vu(e))??[],queryKey:vu(e),initialData:[],staleTime:1/0,gcTime:1/0}),l=L({enabled:!!e,queryFn:async()=>n.getQueryData(pd(e))??[],queryKey:pd(e),initialData:[],staleTime:1/0,gcTime:1/0}),u=c.data.filter(e=>e.status!==`failed`),d=Math.max(0,...u.map(e=>Date.parse(e.createdAt))),f=L({...od(e,{awaitingMessage:u.length>0,fastPollUntilMs:d?d+6e3:void 0,unreadPage:!!t?.unreadPageAtOpen&&!o,versionsPoll:t?.versionsPoll})}),p=f.refetch;(0,J.useEffect)(()=>{if(e)return p({cancelRefetch:!1}),()=>ed(n,e)},[e,n,p]),!o&&f.isFetchedAfterMount&&!f.isFetching&&a({conversationId:e,fetched:!0,prefetched:s});let m=(0,J.useDeferredValue)(f.data),h=m&&m.conversationId===e?m:f.data,g=h?.mailbox;(0,J.useEffect)(()=>{g&&h&&n.setQueryData(vu(e),e=>e&&Ou(e,{events:h.events,mailboxReadAtMs:h.mailboxReadAtMs,queued:g.messages}))},[e,h,g,c.data,n]);let _=f.data?.displayTitle,v=f.dataUpdatedAt;(0,J.useEffect)(()=>{if(!e||!_)return;let t=n.getQueryCache().findAll({queryKey:[`dashboard`,`conversations`]});for(let r of t){let t=r.state.data;!t||r.state.dataUpdatedAt>v||t.conversations.some(t=>t.conversationId===e&&t.displayTitle!==_)&&n.setQueryData(r.queryKey,{...t,conversations:t.conversations.map(t=>t.conversationId===e?{...t,displayTitle:_}:t)})}},[e,v,_,n]);let y=h?.eventHistory.status,b=(0,J.useMemo)(()=>[`conversation`,e,`history`,y],[e,y]),x=O({enabled:!1,queryKey:b,queryFn:async({pageParam:t,signal:n})=>({...await yd(e,t,n),requestedBefore:t}),initialPageParam:h?.previousCursor??``,getNextPageParam:(e,t)=>zu(h?.previousCursor,t),retry:!1}),S=x.data?.pages,C=(0,J.useMemo)(()=>h?Fu(h,S??[]):void 0,[h,S]),w=(0,J.useRef)(void 0),T=(0,J.useRef)(void 0),{inlineMessages:E,pendingMessages:D}=(0,J.useMemo)(()=>{let e=l.data,t=e.length?g?.messages.filter(t=>!e.includes(t.inboundMessageId)):g?.messages,n=e.length?c.data.filter(t=>!e.includes(t.messageId)):c.data,r=ku(xu(t,n),t,n),i=Su(w.current,r.queued),a=Su(T.current,r.inline);return w.current=i,T.current=a,{inlineMessages:a,pendingMessages:i}},[c.data,g?.messages,l.data]),k=bd(x.error),A=!!(h&&(Vu(h,S??[])||k)),j=k?null:x.error,M=!(!h?.previousCursor||!x.data||!Bu(h.previousCursor,x.data.pages)||A||x.error||x.isFetchingNextPage),ee=x.isFetchingNextPage||M;(0,J.useEffect)(()=>{A&&p()},[p,A]),(0,J.useEffect)(()=>{k&&n.resetQueries({exact:!0,queryKey:b})},[b,k,n]);let N=x.fetchNextPage;return(0,J.useEffect)(()=>{M&&N({cancelRefetch:!1})},[N,M]),{data:C,latest:f.data,error:f.error,historyError:j,historyVersion:Ru(S??[]),hasPreviousPage:x.data?x.hasNextPage:!!h?.previousCursor,isPending:f.isPending,fetchedAtOpen:o,fetchedDetail:s||f.isFetchedAfterMount&&!f.isFetching?f.data:void 0,isLoadingPreviousPage:ee,pendingAuthorization:g?.authorization,pendingGeneratedAt:g?.generatedAt,inlineMessages:E,pendingMessages:D,loadCompleteTranscript:()=>{if(!e||!h)throw Error(`Cannot load a conversation without an id`);return Lu({detail:h,historyPages:x.data?.pages??[],readPage:t=>yd(e,t)})},loadPreviousPage:()=>{let t=x.data?x.hasNextPage:!!h?.previousCursor;e&&t&&x.fetchNextPage({cancelRefetch:!1})}}}async function gd(e,t,n,r){let i=new URLSearchParams;r?.unreadPage&&i.set(`unreadPage`,`true`),r?.mailbox&&i.set(`mailbox`,`true`);let a=r?.unreadPage?void 0:n?.appendCursor;a&&i.set(`after`,a);let o=i.size?`?${i}`:``,s=Date.now(),c=await Yi(`/api/conversations/${encodeURIComponent(e)}${o}`,t,n?.detailEtag?{[ti]:n.detailEtag}:void 0);if(c.status===304&&n)return n;if(!r?.mailbox)return vd(_d(await $i(c,Ii),n),c);let u=await $i(c,l([zr,Ei]));if(!(`unchanged`in u))return{...vd(_d(u,n),c),mailboxReadAtMs:s};if(!n)throw Error(`Unchanged detail without a cached copy`);return{...n,mailbox:u.mailbox,mailboxReadAtMs:s}}function _d(e,t){if(!e.appended)return e;if(!t)throw Error(`Appended detail without a cached copy`);let{appended:n,...r}=e,i=t.events.at(-1)?.seq??-1,a=t.events[0]?.seq,o=r.readPosition!==void 0&&a!==void 0&&r.readPosition.lastReadSeq+1<a;return{...r,events:[...t.events,...e.events.filter(e=>e.seq>i)],...t.previousCursor?{previousCursor:t.previousCursor}:void 0,...o&&t.unreadCursor?{unreadCursor:t.unreadCursor,unreadPage:t.unreadPage}:void 0}}function vd(e,t){return{...e,conversationVersion:t.headers.get(`x-junior-conversation-version`)??void 0,detailEtag:t.headers.get(`x-junior-detail-version`)??void 0}}function yd(e,t,n){let r=new URLSearchParams({before:t});return G(Gr,`/api/conversations/${encodeURIComponent(e)}/events?${r}`,n).then(e=>{if(e.previousCursor===t)throw Error(`Conversation history cursor did not advance`);return e})}function bd(e){return e instanceof ta&&e.status===400}function xd(e,t,n){return e.map(e=>e.conversationId===t?{...e,...n}:e.threads?{...e,threads:xd(e.threads,t,n)}:e)}function Sd(e,t,n){for(let r of e){if(r.conversationId===t)return{parentConversationId:n,row:r};let e=r.threads&&Sd(r.threads,t,r.conversationId);if(e)return e}}function Cd(e,t,n){return e.map(e=>e.conversationId===t?{...e,threads:[...e.threads??[],n].sort((e,t)=>t.lastSeenAt.localeCompare(e.lastSeenAt))}:e.threads?{...e,threads:Cd(e.threads,t,n)}:e)}function wd({queryKey:e}){return e[0]===`conversation`&&(e[2]===`detail`||e[2]===`agents`)}function Td(e){return[`dashboard`,`archived-conversation`,e]}function Ed(e){let t=e[e.length-1];return t===`active`||t===`archived`?t:void 0}const Dd=[`dashboard`,`archive-conversation`];function Od(){return b({filters:{mutationKey:Dd,status:`pending`},select:e=>{let t=e.state.variables,n=e.state.context,r=e.options.mutationKey?.[2];return{archived:t.archived,conversation:n?.archivedSnapshot?.parentConversationId?void 0:n?.archivedSnapshot?.conversation,conversationId:typeof r==`string`?r:``}}})}function kd(e){let t=b({filters:{exact:!0,mutationKey:[...Dd,e]},select:e=>e.state.status});return e?t.at(-1):void 0}function Ad(e,t){let n=be(),r=ge(),i=n.state?.archivedConversation,a=kd(i?.id);(0,J.useEffect)(()=>{!i||a!==`success`&&a!==`error`||(a===`success`?e(i):t(i,!0),r({hash:n.hash,search:n.search},{replace:!0,state:null}))},[i,n.hash,n.search,r,t,e,a])}function jd(e,t){let n=P();return N(Md(n,e,t))}function Md(e,t,n){return _({mutationKey:[...Dd,t],mutationFn:e=>Ui(pi,`/api/conversations/${encodeURIComponent(t)}/archive`,{...e,applyToChildren:!0}),onMutate:async n=>{let r={queryKey:[`dashboard`,`conversations`]},i=X(t),a=Td(t);await Promise.all([e.cancelQueries(r),e.cancelQueries({queryKey:i})]);let o=e.getQueriesData(r),s=e.getQueryData(i),c=e.getQueryData(a),l=n.archived?(/* @__PURE__ */ new Date()).toISOString():null,u=n.archived?{archivedAt:l,unread:void 0}:{archivedAt:l},d=Nd(o,t)??c,f=d&&n.archived?{...d,conversation:{...d.conversation,unread:void 0}}:d;return o.forEach(([r,i])=>{if(!i)return;let a=!!Sd(i.conversations,t),o=Ed(r),s=!n.archived&&!a&&!!f&&o!==`archived`,c=f?.parentConversationId,l=s?c?Cd(i.conversations,c,{...f.conversation,archivedAt:null}):[...i.conversations,{...f.conversation,archivedAt:null}].sort((e,t)=>t.lastSeenAt.localeCompare(e.lastSeenAt)):xd(i.conversations,t,u);e.setQueryData(r,{...i,conversations:n.archived?Fd(l,e=>e.conversationId===t):l})}),e.setQueryData(i,e=>e&&{...e,...u,detailEtag:void 0}),f&&e.setQueryData(a,f),{archivedQueryKey:a,archivedSnapshot:f,detailQueryKey:i,previousArchivedSnapshot:c,previousDetail:s,previousFeeds:o}},onError:(t,r,i)=>{i?.previousFeeds.forEach(([t,n])=>{e.setQueryData(t,n)}),i&&(e.setQueryData(i.detailQueryKey,i.previousDetail),i.previousArchivedSnapshot?e.setQueryData(i.archivedQueryKey,i.previousArchivedSnapshot):e.removeQueries({exact:!0,queryKey:i.archivedQueryKey})),n?.onError?.()},onSuccess:(r,i)=>{e.setQueryData(X(t),e=>e&&{...e,archivedAt:r.archivedAt,detailEtag:void 0}),i.archived||e.removeQueries({exact:!0,queryKey:Td(t)}),n?.onSuccess?.(r.archivedAt)},onSettled:async()=>{await Promise.all([e.invalidateQueries({queryKey:[`dashboard`,`conversations`]}),e.invalidateQueries({queryKey:[`dashboard`,`locations`]}),e.invalidateQueries({queryKey:[`dashboard`,`people`]}),e.invalidateQueries({predicate:wd})])}})}function Nd(e,t){let n,r=[];for(let[i,a]of e){let e=a&&Sd(a.conversations,t);e&&(n??=e,r.push(JSON.stringify(i)))}return n?{conversation:n.row,feedQueryHashes:r,parentConversationId:n.parentConversationId}:void 0}function Pd(e,t){let n=e??(t?.conversation?Ya([t.conversation])[0]:void 0);if(!n||!t)return n;let r=t.archived?n.archivedAt??n.lastSeenAt:null;return{...n,archivedAt:r}}function Fd(e,t){return e.map(e=>{if(!e.threads)return e;let{threads:n,...r}=e,i=Fd(n.filter(e=>!t(e)),t);return i.length?{...r,threads:i}:r})}const Id=`conversation-archived`,Ld=6e3;function Rd(e){return`conversation-action-error:${e}`}function zd(){let{add:e,close:t,update:n}=Io(),r=P(),i=(0,J.useCallback)((t,n)=>{e({description:Fa(t),id:Rd(t.id),priority:`high`,title:n,type:`error`})},[e]),a=(0,J.useCallback)((e,t)=>{i(e,t?`Could not archive`:`Could not restore`)},[i]),o=(0,J.useCallback)(e=>{t(Rd(e.id))},[t]),s=(0,J.useCallback)(a=>{o(a);let s=Fa(a),c={"aria-label":`Undo archive for ${s}`,children:`Undo`,onClick:l};function l(){n(Id,{actionProps:{...c,children:`Restoring…`,disabled:!0},type:`loading`}),new E(r,Md(r,a.id)).mutate({archived:!1,lastSeenAt:a.lastSeenAt}).then(()=>t(Id),u)}function u(){let e=!1;n(Id,t=>t.data?.conversationId===a.id?(e=!0,{actionProps:c,timeout:Ld,title:`Could not restore`,type:`error`}):{}),e||i(a,`Could not restore`)}e({actionProps:c,data:{conversationId:a.id},description:s,id:Id,timeout:Ld,title:`Conversation archived`,type:`success`})},[e,o,t,r,i,n]);return(0,J.useMemo)(()=>({clearActionError:o,showActionError:i,showArchiveError:a,showArchived:s}),[o,i,a,s])}function Bd(e,t){let n=P(),r={queryKey:[`dashboard`,`conversations`]},i=X(e);return N({mutationKey:$u(e),scope:Qu(e),mutationFn:t=>Ui(Li,`/api/conversations/${encodeURIComponent(e)}/unread`,{unread:t}),onMutate:async t=>{await Promise.all([n.cancelQueries(r),n.cancelQueries({queryKey:i})]);let a={detail:n.getQueryData(i),feeds:n.getQueriesData(r)},o={unread:t||void 0};return n.setQueriesData(r,t=>t&&{...t,conversations:t.conversations.map(t=>t.conversationId===e?{...t,...o}:t)}),n.setQueryData(i,e=>e&&{...e,...o,detailEtag:void 0}),a},onError:(e,r,a)=>{a?.feeds.forEach(([e,t])=>{n.setQueryData(e,t)}),n.setQueryData(i,a?.detail),t?.onError?.(r)},onSettled:()=>Promise.all([n.invalidateQueries(r),n.invalidateQueries({exact:!0,queryKey:i})])})}function Vd(e,t){let n=P(),r={queryKey:[`dashboard`,`conversations`]},i=X(e),a=t=>{let a=t?{archivedAt:null,pinnedAt:t,pinPosition:void 0}:{pinnedAt:t,pinPosition:void 0};n.setQueriesData(r,t=>t&&{...t,conversations:t.conversations.map(t=>t.conversationId===e?{...t,...a}:t)}),n.setQueryData(i,e=>e&&{...e,...a,detailEtag:void 0})};return N({mutationFn:t=>Ui(_i,`/api/conversations/${encodeURIComponent(e)}/pin`,{pinned:t}),onMutate:async e=>{await Promise.all([n.cancelQueries(r),n.cancelQueries({queryKey:i})]);let t={detail:n.getQueryData(i),feeds:n.getQueriesData(r)};return a(e?(/* @__PURE__ */ new Date()).toISOString():null),t},onError:(e,r,a)=>{a?.feeds.forEach(([e,t])=>{n.setQueryData(e,t)}),n.setQueryData(i,a?.detail),t?.onError?.(r)},onSuccess:e=>{a(e.pinnedAt),t?.onSuccess?.()},onSettled:()=>Promise.all([n.invalidateQueries(r),n.invalidateQueries({exact:!0,queryKey:i})])})}function Hd(e,t){let n=P(),r={queryKey:[`dashboard`,`conversations`]},i=X(e),a=t=>{n.setQueriesData(r,n=>n&&{...n,conversations:n.conversations.map(n=>n.conversationId===e?{...n,displayTitle:t}:n)}),n.setQueryData(i,e=>e&&{...e,displayTitle:t,detailEtag:void 0})};return N({mutationFn:t=>Ui(Mr,`/api/conversations/${encodeURIComponent(e)}/title`,{title:t}),onMutate:async e=>{await Promise.all([n.cancelQueries(r),n.cancelQueries({queryKey:i})]);let t={detail:n.getQueryData(i),feeds:n.getQueriesData(r)};return a(e),t},onError:(e,r,a)=>{a?.feeds.forEach(([e,t])=>{n.setQueryData(e,t)}),n.setQueryData(i,a?.detail),t?.onError?.()},onSuccess:e=>a(e.title),onSettled:()=>Promise.all([n.invalidateQueries(r),n.invalidateQueries({exact:!0,queryKey:i})])})}function Ud(e){if(e.defaultPrevented||e.key!==`Enter`||!(e.ctrlKey||e.metaKey)||e.nativeEvent.isComposing)return;let t=e.currentTarget.form;t&&(e.preventDefault(),t.requestSubmit())}const Wd=`block w-full rounded-md border border-dashboard-border-emphasis bg-dashboard-ink px-3 py-2 font-sans text-sm text-dashboard-text placeholder:text-dashboard-text-muted/70 focus:border-dashboard-focus focus:outline-none focus:ring-1 focus:ring-dashboard-focus/25 aria-invalid:border-rose-300 disabled:cursor-not-allowed disabled:opacity-50`,Gd=I(Wd,{variants:{size:{default:``,comfortable:`min-h-11 text-base sm:min-h-10 sm:text-sm`}},defaultVariants:{size:`default`}});function Kd({className:e,size:t,...n}){return/* @__PURE__ */ (0,Y.jsx)(bt,{"data-slot":`input`,className:F(Gd({size:t}),e),...n,onKeyDown:e=>{n.onKeyDown?.(e),Ud(e)}})}function qd({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`field`,className:F(`grid gap-2`,e),...t})}function Jd({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`label`,{"data-slot":`field-label`,className:F(`text-sm font-semibold text-dashboard-text`,e),...t})}function Yd({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`p`,{"data-slot":`field-description`,className:F(`m-0 text-xs leading-relaxed text-dashboard-text-muted sm:text-sm`,e),...t})}function Xd({className:e,...t}){return t.children?/* @__PURE__ */ (0,Y.jsx)(`p`,{role:`alert`,"data-slot":`field-error`,className:F(`m-0 text-xs leading-relaxed text-rose-300`,e),...t}):null}function Zd(e){let t=(0,J.useId)(),n=(0,J.useRef)(null),[r,i]=(0,J.useState)(e.title),a=Pl(e.onClose,n),o=r.trim(),s=o.length>0&&o!==e.title;return/* @__PURE__ */ (0,Y.jsx)(il,{...a.rootProps,children:/* @__PURE__ */ (0,Y.jsx)(ol,{...a.contentProps,children:/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:`grid gap-4`,onSubmit:t=>{t.preventDefault(),s&&e.onSave(o),a.rootProps.onOpenChange(!1,{cancel(){}})},children:[/* @__PURE__ */ (0,Y.jsx)(sl,{children:`Rename conversation`}),/* @__PURE__ */ (0,Y.jsxs)(qd,{children:[/* @__PURE__ */ (0,Y.jsx)(Jd,{htmlFor:t,children:`Title`}),/* @__PURE__ */ (0,Y.jsx)(Kd,{ref:n,id:t,maxLength:200,value:r,onChange:e=>i(e.target.value),onFocus:e=>e.target.select()})]}),/* @__PURE__ */ (0,Y.jsxs)(cl,{children:[/* @__PURE__ */ (0,Y.jsx)(al,{render:/* @__PURE__ */ (0,Y.jsx)(H,{children:`Cancel`})}),/* @__PURE__ */ (0,Y.jsx)(H,{variant:`primary`,type:`submit`,disabled:!s,children:`Save`})]})]})})})}function Qd(e,t){let n=P(),r=X(e);return N({onError:()=>t?.onError?.(),mutationFn:t=>Ui(fi,`/api/conversations/${encodeURIComponent(e)}/delivery`,{paused:t}),onSuccess:e=>{n.setQueryData(r,t=>t&&{...t,deliveryPaused:e.paused,detailEtag:void 0})}})}function $d(e,t){let n=P(),r=X(e);return N({onError:()=>t?.onError?.(),mutationFn:t=>Ui(Ni,`/api/conversations/${encodeURIComponent(e)}/subscription`,{subscribed:t}),onSuccess:e=>{n.setQueryData(r,t=>t&&{...t,archivedAt:e.archivedAt,...e.subscribed?void 0:{pinnedAt:null,pinPosition:void 0},subscribed:e.subscribed,detailEtag:void 0})},onSettled:()=>n.invalidateQueries({queryKey:[`dashboard`,`conversations`]})})}function ef(){return/* @__PURE__ */ (0,Y.jsx)(Fn,{"aria-hidden":`true`,className:`ml-1 inline size-[0.8em] shrink-0 align-[-0.05em] opacity-60`})}function tf({children:e,...t}){return/* @__PURE__ */ (0,Y.jsxs)(`a`,{...t,rel:`noreferrer`,target:`_blank`,children:[e,/* @__PURE__ */ (0,Y.jsx)(ef,{})]})}function nf(e){let t=(0,J.useId)(),n=(0,J.useRef)(null),r=Pl(e.onClose,n),i=P(),a=ls(),o=(0,J.useMemo)(()=>(a.data?.locations??[]).filter(e=>e.provider===`slack`&&e.kind===`channel`).sort((e,t)=>e.label.localeCompare(t.label)),[a.data]),[s,c]=(0,J.useState)(``),l=(0,J.useMemo)(()=>af(o,s.trim()),[o,s]),[u,d]=(0,J.useState)(``),f=l.some(e=>e.channel.id===u)?u:l[0]?.channel.id??``,p=N({mutationFn:t=>Qi(oi,`/api/conversations/${encodeURIComponent(e.conversationId)}/continue-in-slack`,{locationId:t}),onSuccess:()=>Promise.all([i.invalidateQueries({queryKey:[`dashboard`,`conversations`]}),i.invalidateQueries({queryKey:[`dashboard`,`locations`]}),i.invalidateQueries({queryKey:X(e.conversationId)})])}),m=()=>{f&&!p.isPending&&p.mutate(f)},h=p.error?p.error instanceof ta&&p.error.apiError||`Could not move the conversation. Try again.`:a.error?`Could not load channels. Try again.`:void 0;return/* @__PURE__ */ (0,Y.jsx)(il,{...r.rootProps,onOpenChange:(e,t)=>{!e&&p.isPending?t.cancel():r.rootProps.onOpenChange(e,t)},children:/* @__PURE__ */ (0,Y.jsx)(ol,{...r.contentProps,children:p.data?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(sl,{children:`Moved to Slack`}),/* @__PURE__ */ (0,Y.jsxs)(`p`,{className:`m-0 text-dashboard-text-muted`,children:[`Mention Junior in the`,` `,p.data.channelName?`#${p.data.channelName} `:``,`thread to continue. Replies to dashboard messages stay here.`]}),/* @__PURE__ */ (0,Y.jsxs)(cl,{children:[/* @__PURE__ */ (0,Y.jsx)(al,{render:/* @__PURE__ */ (0,Y.jsx)(H,{children:`Close`})}),p.data.locationUrl?/* @__PURE__ */ (0,Y.jsx)(tf,{className:wt({variant:`primary`}),href:p.data.locationUrl,children:`Open in Slack`}):null]})]}):/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),m()},children:[/* @__PURE__ */ (0,Y.jsx)(sl,{children:`Continue in Slack`}),/* @__PURE__ */ (0,Y.jsxs)(qd,{children:[/* @__PURE__ */ (0,Y.jsx)(Jd,{children:`Channel`}),/* @__PURE__ */ (0,Y.jsxs)(ll,{className:`rounded-lg border border-dashboard-border`,disablePointerSelection:!0,label:`Channel`,loop:!0,onKeyDown:e=>{e.key!==`Enter`||e.nativeEvent.isComposing||(e.preventDefault(),m())},onValueChange:d,shouldFilter:!1,value:f,vimBindings:!1,children:[/* @__PURE__ */ (0,Y.jsx)(dl,{ref:n,"aria-describedby":h?t:void 0,"aria-invalid":h?!0:void 0,disabled:p.isPending,onValueChange:c,placeholder:`Search channels…`,spellCheck:!1,value:s}),/* @__PURE__ */ (0,Y.jsxs)(fl,{className:`max-h-64 sm:max-h-64`,children:[/* @__PURE__ */ (0,Y.jsx)(pl,{children:a.isPending?`Loading channels…`:o.length?`No matching channels.`:`No public channels yet.`}),l.slice(0,rf).map(e=>/* @__PURE__ */ (0,Y.jsxs)(hl,{disabled:p.isPending,onSelect:d,value:e.channel.id,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:/* @__PURE__ */ (0,Y.jsx)(Gc,{label:e.channel.label,matches:e.matches})}),e.channel.id===f?/* @__PURE__ */ (0,Y.jsx)(Yt,{"aria-hidden":`true`}):null]},e.channel.id))]}),l.length>rf?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 border-t border-dashboard-border-subtle px-4 py-2 font-sans text-xs text-dashboard-text-muted`,children:`Type to find more channels.`}):null]}),/* @__PURE__ */ (0,Y.jsx)(Yd,{children:`Junior starts a thread there with this conversation. You can move a conversation once.`}),/* @__PURE__ */ (0,Y.jsx)(Xd,{id:t,children:h})]}),/* @__PURE__ */ (0,Y.jsxs)(cl,{children:[/* @__PURE__ */ (0,Y.jsx)(al,{disabled:p.isPending,render:/* @__PURE__ */ (0,Y.jsx)(H,{children:`Cancel`})}),/* @__PURE__ */ (0,Y.jsx)(H,{variant:`primary`,type:`submit`,disabled:!f||p.isPending,children:p.isPending?`Moving…`:`Move to channel`})]})]})})})}const rf=50;function af(e,t){return t?e.flatMap(e=>{let n=Xc(e.label,t);return n?[{channel:e,matches:n.indices,score:n.score}]:[]}).sort((e,t)=>t.score-e.score):e.map(e=>({channel:e}))}function of({...e}){return/* @__PURE__ */ (0,Y.jsx)(tt,{"data-slot":`context-menu`,...e})}function sf({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(nt,{"data-slot":`context-menu-trigger`,className:F(`select-none`,e),...t})}function cf({className:e,align:t=`start`,alignOffset:n=4,side:r=`right`,sideOffset:i=0,...a}){return/* @__PURE__ */ (0,Y.jsx)(Ye,{children:/* @__PURE__ */ (0,Y.jsx)(ot,{className:`isolate z-50 outline-none`,align:t,alignOffset:n,side:r,sideOffset:i,children:/* @__PURE__ */ (0,Y.jsx)(gt,{"data-slot":`context-menu-content`,className:F(`z-50 max-h-(--available-height) min-w-44 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...a})})})}const lf=`group/context-menu-item relative flex cursor-default items-center gap-2 rounded-md px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7.5 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg]:text-muted-foreground [&_svg:not([class*='size-'])]:size-3.5 data-[variant=destructive]:[&_svg]:text-destructive`;function uf({className:e,inset:t,variant:n=`default`,...r}){return/* @__PURE__ */ (0,Y.jsx)(Ze,{"data-slot":`context-menu-item`,"data-inset":t,"data-variant":n,className:F(lf,e),...r})}function df({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(xt,{"data-slot":`context-menu-item`,className:F(lf,e),...t})}function ff({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(Ue,{"data-slot":`context-menu-separator`,className:F(`-mx-1 my-1 h-px bg-border`,e),...t})}const pf=s({memories:u(s({id:p(),content:p(),observedAtMs:a(),scope:o([`personal`,`conversation`]),kind:o([`preference`,`procedure`,`knowledge`])}).strict())}).strict();function mf(e){if(e.pluginName!==`memory`||e.kind!==`recall`||e.version!==1)return;let t=pf.safeParse(e.content);return t.success?t.data:void 0}const hf=s({text:p()}).strict();function gf(e){if(e.pluginName!==`junior`||e.kind!==`user_customization`||e.version!==1)return;let t=hf.safeParse(e.content);return t.success?t.data:void 0}function _f(e){return e.role===`user`&&e.eventType!==void 0&&Ir(e.eventType)}function vf(e){return e.contexts?.some(e=>mf(e))===!0}function yf(e){let t=[];for(let n of e){if(_f(n)&&!vf(n))continue;let e=n.pending?void 0:n.sourceSeq,r=e===void 0?{}:{seq:e},i=[],a=0,o=()=>{if(i.length===0)return;let e=a===0&&i.length===n.parts.length?n:{...n,parts:i};t.push({key:`${n.sourceSeq}:message:${a}`,kind:`message`,message:e,...r}),i=[],a+=1};for(let[e,a]of n.parts.entries())a.type===`text`?i.push(a):(o(),a.type===`tool_call`?t.push({key:`tool:${a.id}`,kind:`tool`,...r,part:a,timestamp:a.startedTimestamp??n.timestamp}):a.type===`reasoning`?t.push({key:`${n.sourceSeq}:reasoning:${e}`,kind:`reasoning`,...r,part:a,timestamp:n.timestamp}):a.type===`subagent`?t.push({key:`subagent:${a.id}`,kind:`subagent`,...r,part:a,timestamp:n.timestamp}):a.type===`structured_event`?t.push({key:`${n.sourceSeq}:structured-event:${a.namespace}:${a.name}`,kind:`structured_event`,...r,part:a,timestamp:n.timestamp}):a.type===`attachments_delivered`?t.push({key:`${n.sourceSeq}:attachments-delivered`,kind:`attachments_delivered`,...r,part:a,timestamp:n.timestamp}):t.push({key:`${n.sourceSeq}:context:${e}`,kind:`context`,...r,part:a,timestamp:n.timestamp}));o(),n.failureCode&&t.push({key:`${n.sourceSeq}:failure`,kind:`failure`,...r,failureCode:n.failureCode,...n.failureReason?{failureReason:n.failureReason}:void 0,...n.eventId?{eventId:n.eventId}:void 0,...n.sentryEventUrl?{sentryEventUrl:n.sentryEventUrl}:void 0,timestamp:n.timestamp})}return t}function bf(e){return[e.parts.map(e=>e.type===`text`?e.text??``:e.type===`reasoning`?e.text??`reasoning redacted`:e.type===`tool_call`?`tool_call ${e.name}`:e.type===`subagent`?[`subagent ${e.agentName??e.subagentKind}`,...e.title?[`title ${e.title}`]:[],...e.task?[`task ${e.task}`]:[],`status ${e.status}`].join(`
|
|
2
|
-
`):e.type===`structured_event`?[e.presentation.title,e.presentation.preview,...(e.presentation.details??[]).flatMap(e=>[e.title,e.description,e.content,...e.metadata??[]])].filter(e=>e!==void 0).join(`
|
|
3
|
-
`):e.type===`attachments_delivered`?e.attachments.map(e=>e.filename).join(`
|
|
4
|
-
`):[`context compacted`,e.event.summary].filter(e=>e!==void 0).join(`
|
|
5
|
-
`)).filter(e=>e.trim().length>0).join(`
|
|
6
|
-
|
|
7
|
-
`),...(e.attachments??[]).map(e=>`[attachment] ${e.filename} (${e.contentType}, ${e.bytes} bytes)`),...(e.cards??[]).map(Pr)].filter(Boolean).join(`
|
|
8
|
-
|
|
9
|
-
`)}function xf(e,t){if(e===`model_execution_failed`&&t)switch(t){case`auth`:return`Model credentials rejected`;case`permission`:return`Model access denied`;case`rate_limit`:return`Model rate limited`;case`capacity`:return`Model at capacity`;case`timeout`:return`Model timed out`;case`network`:return`Model connection failed`;case`server`:return`Model service error`;case`invalid_request`:return`Invalid model request`;case`invalid_response`:return`Invalid model response`;case`quota`:return`Model quota exhausted`;case`content_policy`:return`Blocked by content policy`;case`empty_output`:return`Empty model response`;case`tool_errors`:return`Tool failed`;case`suppressed_output`:return`Model output was dropped`;case`unknown`:return`Model service error`}switch(e){case`delivery_failed`:return`Message delivery failed`;case`model_execution_failed`:return`Model failed`;case`persistence_failed`:return`Save failed`;case`agent_run_failed`:return`Internal error`}}function Sf(e,t){let n=pa();if(e===`model_execution_failed`&&t)switch(t){case`auth`:return`The model service rejected credentials. An admin needs to fix configuration.`;case`permission`:return`The model service denied access to this model or request.`;case`rate_limit`:return`The model is rate limited. Try again shortly.`;case`capacity`:return`The selected model is at capacity. Try again shortly.`;case`timeout`:return`The model service timed out before the turn finished.`;case`network`:return`The model service had a connection problem before the turn finished.`;case`server`:return`The model service returned an error.`;case`invalid_request`:return`The model service rejected this request as invalid.`;case`invalid_response`:return`The model service returned an invalid response.`;case`quota`:return`The model service quota is exhausted. An admin needs to fix billing or limits.`;case`content_policy`:return`The model service blocked this request under its content policy.`;case`empty_output`:return`The model returned no usable text before ${n} finished this turn.`;case`tool_errors`:return`A tool failed and the turn could not finish.`;case`suppressed_output`:return`The model produced text that ${n} could not deliver.`;case`unknown`:return`The model service failed for an unknown reason.`}switch(e){case`delivery_failed`:return`${n} could not deliver this message.`;case`model_execution_failed`:return`The model stopped before ${n} finished this turn.`;case`persistence_failed`:return`${n} could not save the result of this turn.`;case`agent_run_failed`:return`${n} hit an internal error during this turn.`}}function Cf(e,t,n){return[xf(e,t),Sf(e,t),e.replaceAll(`_`,` `),...t?[t.replaceAll(`_`,` `)]:[],...n?[`event_id=${n}`,n]:[]].join(` `)}function wf(e,t){if(e.previousCursor)throw Error(`Cannot export a partial conversation transcript`);let n=[];return n.push(`# ${Uf(Lf(e,t))}`,``),Z(n,`Conversation ID`,Wf(e.conversationId)),Z(n,`Generated`,e.generatedAt),Z(n,`Actor`,Rf(t,e)),Z(n,`Location`,zf(t,e)),Z(n,`Usage`,[eo(e.cumulativeUsage),Qa(e.cumulativeUsage,e.auxiliaryCosts)].filter(Boolean).join(` · `)),Z(n,`Sentry conversation`,e.sentryConversationUrl),n.push(``,`## Transcript`),Tf(n,e),Kf(n)}function Tf(e,t){let n=Na(t);t.eventHistory.status===`available`?Ef(e,t,n,!1):t.eventHistory.status===`redacted`&&n.length?(e.push(``,`Transcript hidden because this conversation is not public.`),Ef(e,t,n,!0)):n.length?Ef(e,t,n,!1):e.push(``,Ma(t))}function Ef(e,t,n,r){for(let i of yf(n))if(i.kind===`message`)i.message.eventType?Af(e,t,i.message,r):i.message.context?jf(e,t,i.message,r):Mf(e,t,i.message,r);else if(i.kind===`failure`)Of(e,t,i.failureCode,i.failureReason,i.eventId,i.sentryEventUrl,i.timestamp);else if(i.kind===`subagent`)Pf(e,t,i.part,i.timestamp);else if(i.kind===`context`)kf(e,t,i.part,i.timestamp);else if(i.kind===`reasoning`)Df(e,t,i.part,i.timestamp);else if(i.kind===`structured_event`){e.push(``,`### ${i.part.presentation.title}`),If(e,t,i.timestamp),i.part.presentation.preview&&e.push(``,i.part.presentation.preview);for(let t of i.part.presentation.details??[])e.push(``,`- ${t.title}`),t.description&&e.push(` ${t.description}`),t.content&&e.push(``,Gf(t.content,`md`)),t.metadata?.length&&e.push(` ${t.metadata.join(` · `)}`)}else if(i.kind===`attachments_delivered`){let n=i.part.attachments.length;e.push(``,`### ${n===1?`1 file delivered`:`${n} files delivered`}`),If(e,t,i.timestamp);for(let t of i.part.attachments)e.push(``,`- ${t.filename} (${t.contentType}, ${t.bytes} bytes)`)}else Ff(e,t,i.part,i.timestamp)}function Df(e,t,n,r){e.push(``,`### Reasoning`),If(e,t,r),e.push(``,n.redacted?`<redacted>`:n.text)}function Of(e,t,n,r,i,a,o){e.push(``,`### ${xf(n,r)}`),If(e,t,o),e.push(``,Sf(n,r)),Z(e,`Code`,n),r&&Z(e,`Reason`,r),i&&Z(e,`Event id`,a?`[${i}](${a})`:i)}function kf(e,t,n,r){let i=n.event;e.push(``,`### Context compacted`),If(e,t,r),Z(e,`Model`,i.modelId),i.details&&(Z(e,`Estimated input tokens`,String(i.details.estimatedInputTokens)),i.details.replacementInputTokens!==void 0&&Z(e,`Replacement input tokens`,String(i.details.replacementInputTokens)),Z(e,`Compaction trigger`,String(i.details.triggerTokens)),Z(e,`Input limit`,String(i.details.inputLimitTokens)),Z(e,`Input messages`,String(i.details.inputMessageCount)),Z(e,`Retained messages`,String(i.details.retainedMessageCount)),Z(e,`Summary characters`,String(i.details.summaryChars))),i.summary&&e.push(``,`#### Continuation summary`,``,i.summary)}function Af(e,t,n,r){if(e.push(``,`### Event: ${Uf(n.eventType??``)}`),If(e,t,n.timestamp),r){e.push(``,`- <redacted>`);return}let i=bf(n);e.push(``,i.trim().length?i:`_No content._`)}function jf(e,t,n,r){e.push(``,`### Context from ${Bf(n,t)}`),If(e,t,n.timestamp),e.push(``,r?`<redacted>`:bf(n)),r||Nf(e,n.contexts)}function Mf(e,t,n,r){if(e.push(``,`### ${Bf(n,t)}`),If(e,t,n.timestamp),r){e.push(``,...n.parts.map(()=>`- <redacted>`));return}let i=bf(n);e.push(``,i.trim().length?i:`_No content._`),Nf(e,n.contexts)}function Nf(e,t){for(let n of t??[]){let t=mf(n);if(e.push(``,t?`#### Recalled memories`:`#### ${Uf(n.kind)} context`),Z(e,`Plugin`,n.pluginName),Z(e,`Loaded`,n.loadedAt),!t)e.push(``,"```json",JSON.stringify(n.content,null,2),"```");else for(let n of t.memories)e.push(``,`- ${n.content}`,` - ID: ${Wf(n.id)}`,` - Observed: ${new Date(n.observedAtMs).toISOString()}`,` - Scope: ${n.scope}`,` - Kind: ${n.kind}`)}}function Pf(e,t,n,r){e.push(``,`### ${n.childKind===`thread`?`Thread`:`Task`}: ${Uf(n.agentName??n.subagentKind)}`),If(e,t,r),Z(e,`Status`,n.status),Z(e,`Title`,n.title),Z(e,`Task`,n.task)}function Ff(e,t,n,r){e.push(``,`### Tool: ${Uf(n.name)}`),If(e,t,r),Z(e,`Status`,n.status),Z(e,`Duration`,Ga(r,n.resultTimestamp)),n.input!==void 0&&e.push(``,`#### Arguments`,``,Gf(Ta(n.input),`json`)),n.output!==void 0&&e.push(``,`#### Result`,``,Gf(Ta(n.output),`json`))}function If(e,t,n){let r=[Vf(n),Hf(t,n)].filter(qf);r.length&&e.push(``,`_${r.join(` - `)}_`)}function Lf(e,t){return e.displayTitle.trim()||(t?Fa(t):`Conversation`)}function Rf(e,t){return Za(e?.actorIdentity??t?.actorIdentity)??``}function zf(e,t){return e?Ha(e)??``:t?Ha(t)??``:``}function Bf(e,t){return Uf(ro(t,e))}function Vf(e){return typeof e!=`number`||!Number.isFinite(e)?``:new Date(e).toISOString()}function Hf(e,t){if(typeof t!=`number`||!Number.isFinite(t))return``;let n=Date.parse(e.startedAt);return!Number.isFinite(n)||t<n?``:`+${za(t-n)}`}function Z(e,t,n){n&&e.push(`- ${t}: ${n}`)}function Uf(e){return e.replace(/\s+/g,` `).trim()||`Untitled`}function Wf(e){let t=e.includes("`")?"``":"`";return`${t}${e}${t}`}function Gf(e,t){let n=[...e.matchAll(/`+/g)].reduce((e,t)=>Math.max(e,t[0].length),0),r="`".repeat(Math.max(3,n+1));return`${r}${t}\n${e}\n${r}`}function Kf(e){return`${e.join(`
|
|
10
|
-
`)}\n`}function qf(e){return e.length>0}function Jf(e){let[t,n]=(0,J.useState)(`idle`),r=t===`copied`?`Copied`:t===`copying`?e.copyingLabel??`Copying`:t===`failed`?`Copy failed`:e.label,i={copied:Yt,copying:pr,failed:Gn,idle:pr}[t];async function a(){if(e.getText)try{n(`copying`),await navigator.clipboard.writeText(await e.getText()),n(`copied`)}catch{n(`failed`)}}return{copy:a,disabled:!e.getText||t===`copying`,failed:t===`failed`,icon:i,label:r}}function Yf(e){let{copy:t,disabled:n,failed:r,icon:i,label:a}=Jf(e);return/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[/* @__PURE__ */ (0,Y.jsx)(W,{render:/* @__PURE__ */ (0,Y.jsx)(H,{focusableWhenDisabled:!0,"aria-label":a,disabled:n,onClick:()=>void t(),size:`icon`,children:/* @__PURE__ */ (0,Y.jsx)(i,{"aria-hidden":`true`,className:r?`text-rose-300`:void 0,size:15,strokeWidth:2})})}),/* @__PURE__ */ (0,Y.jsx)(Cr,{size:`compact`,children:a})]})}function Xf(e){return/* @__PURE__ */ (0,Y.jsxs)(`svg`,{"aria-label":`Slack`,className:e.className,fill:`currentColor`,role:`img`,viewBox:`0 0 127 127`,children:[/* @__PURE__ */ (0,Y.jsx)(`path`,{className:`[--slack-mark-color:#E01E5A]`,d:`M27.2 80c0 7.3-5.9 13.2-13.2 13.2C6.7 93.2.8 87.3.8 80c0-7.3 5.9-13.2 13.2-13.2h13.2V80zm6.6 0c0-7.3 5.9-13.2 13.2-13.2 7.3 0 13.2 5.9 13.2 13.2v33c0 7.3-5.9 13.2-13.2 13.2-7.3 0-13.2-5.9-13.2-13.2V80z`}),/* @__PURE__ */ (0,Y.jsx)(`path`,{className:`[--slack-mark-color:#36C5F0]`,d:`M47 27c-7.3 0-13.2-5.9-13.2-13.2C33.8 6.5 39.7.6 47 .6c7.3 0 13.2 5.9 13.2 13.2V27H47zm0 6.7c7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2H13.9C6.6 60.1.7 54.2.7 46.9c0-7.3 5.9-13.2 13.2-13.2H47z`}),/* @__PURE__ */ (0,Y.jsx)(`path`,{className:`[--slack-mark-color:#2EB67D]`,d:`M99.9 46.9c0-7.3 5.9-13.2 13.2-13.2 7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2H99.9V46.9zm-6.6 0c0 7.3-5.9 13.2-13.2 13.2-7.3 0-13.2-5.9-13.2-13.2V13.8C66.9 6.5 72.8.6 80.1.6c7.3 0 13.2 5.9 13.2 13.2v33.1z`}),/* @__PURE__ */ (0,Y.jsx)(`path`,{className:`[--slack-mark-color:#ECB22E]`,d:`M80.1 99.8c7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2-7.3 0-13.2-5.9-13.2-13.2V99.8h13.2zm0-6.6c-7.3 0-13.2-5.9-13.2-13.2 0-7.3 5.9-13.2 13.2-13.2h33.1c7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2H80.1z`})]})}function Zf(e){let t=me(kc(e)),[n,r]=(0,J.useState)(`idle`),i=n===`copied`?`Link copied`:n===`copy-failed`?`Copy failed — retry`:n===`share-failed`?`Share failed — retry`:`Share`,a=n===`copied`?`Conversation link copied. Access has not changed.`:n===`copy-failed`?`Could not copy the link. Try again or copy it from the address bar.`:n===`share-failed`?`Could not share the link. Try again or copy it from the address bar.`:``;async function o(){r(`sharing`);let e=new URL(t,window.location.origin).href;if(window.matchMedia(`(pointer: coarse)`).matches&&typeof navigator.share==`function`)try{await navigator.share({url:e}),r(`idle`)}catch(e){r(e instanceof DOMException&&e.name===`AbortError`?`idle`:`share-failed`)}else try{await navigator.clipboard.writeText(e),r(`copied`)}catch{r(`copy-failed`)}}return{disabled:n===`sharing`,feedback:a,icon:n===`copied`?Yt:Dn,label:i,share:o}}function Qf(e){let t=Zf(e.conversationId),n=Jf({copyingLabel:`Preparing Markdown`,getText:e.getMarkdown,label:`Copy as Markdown`}),{actions:r,conversation:i,detail:a,pending:o}=e,s=!!i?.archivedAt,c=!!i?.pinnedAt,l=!!i?.unread,u=!!(i&&(a?.isParticipant??i.isParticipant)),d=a?a.status===`active`:i&&Sa(i)===`active`,f=[{disabled:t.disabled,feedback:t.feedback,icon:t.icon,key:`share`,label:t.label,onClick:()=>void t.share(),stayOpen:!0},{disabled:n.disabled,icon:n.icon,key:`copy-markdown`,label:n.label,onClick:()=>void n.copy(),stayOpen:!0}];a?.canContinueInSlack&&f.push({disabled:!!d,icon:$f,key:`continue-in-slack`,label:`Continue in Slack`,onClick:r.continueInSlack}),a?.deliveryPaused!==void 0&&f.push({disabled:o.delivery,icon:a.deliveryPaused?Bt:or,key:`delivery`,label:a.deliveryPaused?`Reattach to Slack`:`Detach from Slack`,onClick:()=>r.delivery(!a.deliveryPaused),toggle:!0}),f.push({icon:e.eventLogOpen?br:mr,key:`event-log`,label:e.eventLogOpen?`Back to conversation`:`Open event log`,onClick:r.eventLog}),a?.sentryConversationUrl&&f.push({href:a.sentryConversationUrl,icon:ep,key:`sentry`,label:`Open in Sentry`});let p=[{disabled:!u||o.read||!l&&!(i&&ya(i)),icon:l?Rt:hn,key:`read`,label:l?`Mark as read`:`Mark as unread`,onClick:()=>r.read(!l),toggle:!0}];return s||p.push({disabled:!u||!!i?.parentConversationId||o.pin,icon:c?Pt:Mt,key:`pin`,label:c?`Unpin`:`Pin`,onClick:()=>r.pin(!c),toggle:!0}),p.push({disabled:!u,icon:en,key:`rename`,label:`Rename`,onClick:r.rename},{disabled:a?.subscribed===void 0||o.subscription,icon:a?.subscribed?gn:fn,key:`subscription`,label:a?.subscribed?`Unsubscribe`:`Subscribe`,onClick:()=>r.subscription(!a?.subscribed),toggle:!0},{disabled:!u||o.archive,icon:s?vn:bn,key:`archive`,label:o.archive?`Saving archive state`:s?`Restore`:`Archive`,onClick:r.archive}),[f,p]}function $f(e){return/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex`,children:/* @__PURE__ */ (0,Y.jsx)(Xf,{className:e.className})})}function ep(e){return/* @__PURE__ */ (0,Y.jsx)(`svg`,{"aria-hidden":`true`,className:e.className,fill:`currentColor`,viewBox:`0 0 24 24`,children:/* @__PURE__ */ (0,Y.jsx)(`path`,{d:`M13.91 2.505c-.873-1.448-2.972-1.448-3.844 0L6.904 7.92a15.478 15.478 0 0 1 8.53 12.811h-2.221A13.301 13.301 0 0 0 5.784 9.814l-2.926 5.06a7.65 7.65 0 0 1 4.435 5.848H2.194a.365.365 0 0 1-.298-.534l1.413-2.402a5.16 5.16 0 0 0-1.614-.913L.296 19.275a2.182 2.182 0 0 0 .812 2.999 2.24 2.24 0 0 0 1.086.288h6.983a9.322 9.322 0 0 0-3.845-8.318l1.11-1.922a11.47 11.47 0 0 1 4.95 10.24h5.915a17.242 17.242 0 0 0-7.885-15.28l2.244-3.845a.37.37 0 0 1 .504-.13c.255.14 9.75 16.708 9.928 16.9a.365.365 0 0 1-.327.543h-2.287c.029.612.029 1.223 0 1.831h2.297a2.206 2.206 0 0 0 1.922-3.31z`})})}function tp(e){let t=L({...od(e.conversationId),enabled:!1}).data;return Qf({...e,detail:t,getMarkdown:t?async()=>wf(await Lu({detail:t,historyPages:[],readPage:t=>yd(e.conversationId,t)}),e.conversation):void 0}).map((e,t)=>/* @__PURE__ */ (0,Y.jsxs)(J.Fragment,{children:[t>0?/* @__PURE__ */ (0,Y.jsx)(ff,{}):null,e.map(e=>e.href?/* @__PURE__ */ (0,Y.jsxs)(df,{href:e.href,rel:`noreferrer`,target:`_blank`,children:[/* @__PURE__ */ (0,Y.jsx)(e.icon,{"aria-hidden":`true`}),e.label]},e.key):/* @__PURE__ */ (0,Y.jsxs)(J.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(uf,{closeOnClick:!e.stayOpen,disabled:e.disabled,onClick:e.onClick,children:[/* @__PURE__ */ (0,Y.jsx)(e.icon,{"aria-hidden":`true`}),e.label]}),e.feedback===void 0?null:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`sr-only`,role:`status`,children:e.feedback})]},e.key))]},t))}const np=(0,J.createContext)(null);function rp(e){let{conversations:t,onError:i,reorder:a}=e,o=(0,J.useMemo)(()=>t.map(e=>e.id),[t]),s=(0,J.useCallback)((e,n)=>{let r=o.indexOf(e);r<0||n<0||n>=o.length||r!==n&&a?.({conversationIds:ce(o,r,n),onError:()=>i(t[r])})},[t,o,i,a]),l=!a||o.length<2,u=(0,J.useMemo)(()=>({disabled:l,move:s}),[l,s]),p=c(r(n,{activationConstraint:{distance:4}}),r(oe,{activationConstraint:{delay:250,tolerance:5}})),m=(0,J.useMemo)(()=>sp(t),[t]);return/* @__PURE__ */ (0,Y.jsxs)(se,{accessibility:{announcements:m},collisionDetection:f,onDragEnd:e=>{e.over&&s(String(e.active.id),o.indexOf(String(e.over.id)))},sensors:p,children:[/* @__PURE__ */ (0,Y.jsx)(ae,{items:o,children:/* @__PURE__ */ (0,Y.jsx)(np.Provider,{value:u,children:e.children})}),(0,ou.createPortal)(/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(d,{dropAnimation:null,children:/* @__PURE__ */ (0,Y.jsx)(op,{conversations:t})}),/* @__PURE__ */ (0,Y.jsx)(ap,{ids:o})]}),document.body)]})}function ip(e){let t=(0,J.useContext)(np),n=!t||t.disabled,r=v({disabled:n,id:e}),{index:i}=r;if(!n)return{dragging:r.isDragging,listeners:r.listeners,onKeyDown:n=>{if(!n.altKey)return;let r=n.key===`ArrowUp`?-1:+(n.key===`ArrowDown`);r!==0&&(n.preventDefault(),t.move(e,i+r))},setNodeRef:r.setNodeRef}}function ap(e){let{active:t,over:n}=i();if(!t||!n||n.id===t.id)return null;let r=e.ids.indexOf(String(t.id))<e.ids.indexOf(String(n.id));return/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none fixed h-0.5 -translate-y-1/2 rounded-full bg-dashboard-accent`,style:{left:n.rect.left+8,top:r?n.rect.top+n.rect.height:n.rect.top,width:n.rect.width-16,zIndex:1e3}})}function op(e){let{active:t}=i(),n=e.conversations.find(e=>e.id===t?.id);return n?/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 max-w-sm cursor-grabbing items-center gap-2 rounded-lg border border-dashboard-border-strong bg-dashboard-surface-raised px-3 py-1.5 font-sans text-sm leading-snug text-dashboard-text shadow-lg`,children:[/* @__PURE__ */ (0,Y.jsx)(Mt,{"aria-hidden":`true`,className:`size-3 shrink-0 text-dashboard-text-muted`,fill:`currentColor`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:Fa(n)})]}):null}function sp(e){let t=t=>{let n=e.find(e=>e.id===t);return n?Fa(n):`pin`};return{onDragCancel:({active:e})=>`Stopped moving ${t(e.id)}.`,onDragEnd:({active:e,over:n})=>n?`Moved ${t(e.id)} to the place of ${t(n.id)}.`:`Stopped moving ${t(e.id)}.`,onDragOver:({active:e,over:n})=>n?`${t(e.id)} is over ${t(n.id)}.`:void 0,onDragStart:({active:e})=>`Picked up ${t(e.id)}.`}}function cp(e){let t=fp(),n=t?0:e.durationMs??180,[r,i]=(0,J.useState)(()=>e.items.map(t=>({item:t,key:e.getKey(t),state:`present`}))),a=(0,J.useRef)(e.items.length>0),o=r.some(e=>e.state===`exiting`),s=(0,J.useCallback)(e=>{i(t=>t.filter(t=>t.key!==e))},[]);return(0,J.useLayoutEffect)(()=>{i(t=>lp(t,e.items,e.getKey,a.current)),e.items.length>0&&(a.current=!0)},[e.getKey,e.items]),(0,J.useEffect)(()=>{if(!r.some(e=>e.state===`entering`))return;if(t){i(e=>dp(e));return}let e=window.requestAnimationFrame(()=>{i(e=>dp(e))});return()=>window.cancelAnimationFrame(e)},[r,t]),/* @__PURE__ */ (0,Y.jsx)(`div`,{"aria-label":r.length>0?e.ariaLabel:void 0,className:K(e.className,o&&`pointer-events-none`),role:r.length>0?e.role:void 0,children:r.length>0?r.map(t=>/* @__PURE__ */ (0,Y.jsx)(up,{animatedItem:t,durationMs:n,onExited:s,renderItem:e.renderItem},t.key)):e.empty})}function lp(e,t,n,r){let i=new Map(e.map(e=>[e.key,e])),a=new Set(t.map(n)),o=t.map(e=>{let t=n(e),a=i.get(t);return{item:e,key:t,state:a?.state===`exiting`?`entering`:a?.state??(r?`entering`:`present`)}});return e.forEach((e,t)=>{a.has(e.key)||o.splice(Math.min(t,o.length),0,{...e,state:`exiting`})}),o}function up(e){let{animatedItem:t,durationMs:n,onExited:r}=e;return(0,J.useEffect)(()=>{if(t.state!==`exiting`)return;let e=window.setTimeout(()=>r(t.key),n);return()=>window.clearTimeout(e)},[t.key,t.state,n,r]),/* @__PURE__ */ (0,Y.jsx)(`div`,{"aria-hidden":t.state===`exiting`||void 0,className:K(`grid min-w-0 origin-center transition-[grid-template-rows,opacity,transform] motion-reduce:transition-none`,t.state===`present`?`grid-rows-[1fr] translate-x-0 scale-100 opacity-100`:`pointer-events-none grid-rows-[0fr] translate-x-2 scale-[0.98] opacity-0`),"data-presence":t.state,inert:t.state===`exiting`||void 0,style:{transitionDuration:`${e.durationMs}ms`,transitionTimingFunction:`cubic-bezier(0.2, 0.8, 0.2, 1)`},children:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`min-h-0 min-w-0 overflow-hidden`,children:e.renderItem(t.item)})})}function dp(e){return e.map(e=>e.state===`entering`?{...e,state:`present`}:e)}function fp(){let[e,t]=(0,J.useState)(!1);return(0,J.useEffect)(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function pp(e){return/* @__PURE__ */ (0,Y.jsx)(`h3`,{className:K(`m-0 font-sans text-xs font-medium text-dashboard-text-muted`,e.className),id:e.id,children:/* @__PURE__ */ (0,Y.jsxs)(`button`,{"aria-expanded":!e.collapsed,className:`grid cursor-pointer grid-cols-[0.875rem_auto] items-center gap-x-2 rounded-sm border-0 bg-transparent p-0 font-[inherit] text-inherit transition-colors hover:text-dashboard-text focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus`,onClick:e.onToggle,type:`button`,children:[/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,className:K(`size-3 shrink-0 justify-self-center transition-transform motion-reduce:transition-none`,!e.collapsed&&`rotate-90`)}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e.label,e.collapsed?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`tabular-nums text-dashboard-text-faint`,children:e.count}):null]})]})})}const mp={accent:`text-dashboard-accent`,danger:`text-rose-300`,info:`text-cyan-300`,neutral:`text-dashboard-text-muted`,success:`text-emerald-300`,warning:`text-amber-300`},hp={compact:`text-xs`,default:`text-sm`};function gp(e){return/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:K(`inline-flex w-fit items-center gap-1.5 font-sans font-medium normal-case leading-snug tracking-normal`,hp[e.size??`default`],mp[e.tone??`neutral`],e.className),children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 shrink-0 rounded-full bg-current`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`block first-letter:uppercase`,children:e.children})]})}function _p({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(yn,{"data-slot":`spinner`,role:`status`,"aria-label":`Loading`,className:F(`size-4 animate-spin motion-reduce:animate-none`,e),...t})}function vp(e,t){return t?`waiting`:Sa(e)}const yp={active:`Running`,failed:`Failed`,idle:`Idle`,stopped:`Stopped`,waiting:`Waiting on you`},bp={active:`info`,failed:`danger`,idle:`neutral`,stopped:`neutral`,waiting:`warning`};function xp(e){let t=yp[e.status],n=K(`size-3.5 shrink-0`,e.className);if(e.status===`active`)return/* @__PURE__ */ (0,Y.jsx)(_p,{"aria-label":t,className:K(n,`text-dashboard-text-muted`)});let r=e.status===`waiting`?Gn:e.status===`failed`?cn:e.status===`stopped`?jt:tn;return/* @__PURE__ */ (0,Y.jsx)(r,{"aria-label":t,className:K(n,e.status===`waiting`&&`text-amber-400`,e.status===`failed`&&`text-rose-400`,(e.status===`idle`||e.status===`stopped`)&&`text-dashboard-text-faint`),role:`img`})}function Sp(e){return/* @__PURE__ */ (0,Y.jsx)(gp,{className:K(`shrink-0`,e.status===`active`&&`animate-pulse motion-reduce:animate-none`),size:`compact`,tone:bp[e.status],children:yp[e.status]})}const Cp=`junior:conversation:start-position`,wp=`data-scroll-anchor`;function Tp(e,t,n){let r=0,i=e;for(;r<i;){let e=r+i>>1;t(e).bottom<=n.top?r=e+1:i=e}return r>=e?null:t(r).top>=n.top?r:r+1<e&&t(r+1).top<n.bottom?r+1:r}function Ep(e,t){let n=e.querySelectorAll(`[${wp}]`),r=/* @__PURE__ */ new Map,i=e=>{let t=r.get(e);return t||(t=n[e].getBoundingClientRect(),r.set(e,t)),t},a=Tp(n.length,i,t);if(a===null)return null;let o=n[a];return{element:o,key:o.getAttribute(wp)??``,offset:i(a).top-t.top}}function Dp(e,t,n){let r=n.element.isConnected?n.element:Op(e,n.key);return r?r.getBoundingClientRect().top-t.top-n.offset:null}function Op(e,t){for(let n of e.querySelectorAll(`[${wp}]`))if(n.getAttribute(wp)===t)return n;return null}const kp=typeof window>`u`?J.useEffect:J.useLayoutEffect;function Ap(e,t=96){return e.scrollHeight-e.scrollTop-e.clientHeight<=t}function jp(e){if(!e)return`empty`;for(let t=e.events.length-1;t>=0;--t){let n=e.events[t],r=n.data;if(r.type===`message`&&r.role===`assistant`)return[n.seq,n.createdAt,r.messageId,r.redacted?`redacted`:r.text?.length??0].join(`:`);if(r.type===`assistant_message`&&r.parts.length>0){let e=r.parts.at(-1);return[n.seq,n.createdAt,r.parts.length,e?.redacted?`redacted`:e?.text?.length??0].join(`:`)}}return`empty`}function Mp(e,t=`rich`){if(!e)return`empty`;let n;for(let r=e.events.length-1;r>=0;--r){let i=e.events[r];if(t!==`rich`||Np(i)){n=i;break}}return[e.conversationId,e.status,n?.seq??``,n?.createdAt??``,Pp(n)].join(`|`)}function Np(e){let t=e.data;return t.type===`turn_lifecycle`?t.state===`failed`:t.type===`message`||t.type===`assistant_message`&&t.parts.length>0||t.type===`tool_calls`||t.type===`subagent`||t.type===`structured_event`||t.type===`attachments_delivered`||t.type===`compaction`}function Pp(e){if(!e)return``;let t=e.data;switch(t.type){case`message`:return[t.type,t.role,t.messageId,t.redacted?`redacted`:t.text?.length??0,t.eventType??``].join(`:`);case`assistant_message`:{let e=t.parts,n=e.at(-1);return[t.type,e.length,n?.redacted?`redacted`:n?.text?.length??0].join(`:`)}case`tool_calls`:{let e=t.calls.at(-1);return[t.type,t.calls.length,e?.toolCallId??``,e?.name??``,e?.status??``,e?.output===void 0?``:`output`].join(`:`)}case`subagent`:return[t.type,t.childConversationId,t.status,t.subagentKind,t.parentToolCallId??``].join(`:`);case`turn_lifecycle`:return[t.type,t.turnId,t.state,`failureCode`in t?t.failureCode:``,`failureReason`in t?t.failureReason??``:``].join(`:`);case`structured_event`:return[t.type,t.namespace,t.name,t.version,t.presentation.title,t.presentation.preview?.length??0].join(`:`);case`message_handled`:return[t.type,t.messageId].join(`:`);case`attachments_delivered`:return[t.type,t.attachments.length,...t.attachments.map(e=>`${e.id}:${e.filename}:${e.bytes}`)].join(`:`);case`compaction`:return[t.type,t.summary?.length??0,e.createdAt].join(`:`);case`guardian_action_reviewed`:return[t.type,t.turnId,t.toolCallId,t.decision].join(`:`);case`turn_context`:return[t.type,t.turnId,t.pluginName,t.kind,t.version].join(`:`);default:return`${t.type??`unknown`}:${e.seq}`}}function Fp(e){return e.enabled&&e.following}function Ip(e){if(e.enabled)return{pending:!1,pin:!1};let t=e.pending||e.wasEnabled&&!e.enabled&&e.following;return t&&e.juniorMessageChanged?{pending:!1,pin:!0}:{pending:t,pin:!1}}function Lp(e){return!e.following&&(e.endsAtLatest===!1||!!e.openedAtUnread||e.enabled&&e.hasPendingUpdate)}function Rp(e){return e.source===`scroll`&&e.previousScrollTop!=null&&e.snapshot.scrollTop<e.previousScrollTop-2?`pause`:e.source===`scroll`&&Ap(e.snapshot)?`follow`:`preserve`}function zp(e){return e.intent===`pause`&&!Ap(e.snapshot)?`pause`:`ignore`}function Bp(e){let t=(0,J.useRef)(null),n=(0,J.useRef)(null),r=(0,J.useRef)(e.enabled),i=(0,J.useRef)(!0);i.current=e.endsAtLatest??!0;let a=(0,J.useRef)(!1),o=(0,J.useRef)(!1),s=(0,J.useRef)(null),c=(0,J.useRef)(null),l=(0,J.useRef)(null),u=(0,J.useRef)(null),d=(0,J.useRef)(e.pinRequestVersion??0),f=(0,J.useRef)(e.juniorMessageVersion),p=(0,J.useRef)(e.enabled),m=(0,J.useRef)(!1),h=(0,J.useRef)(e.versions),g=(0,J.useRef)(0),[_,v]=(0,J.useState)(!1),[y,b]=(0,J.useState)(!1),[x,S]=(0,J.useState)(!1),[C,w]=(0,J.useState)(null),T=(0,J.useCallback)(e=>{n.current=e,w(e)},[]);(0,J.useEffect)(()=>{r.current=e.enabled,e.enabled||b(!1)},[e.enabled]);let E=(0,J.useRef)(!1),D=(0,J.useCallback)(e=>{a.current=e,v(e),e?S(!1):E.current=!1},[]),O=(0,J.useCallback)(()=>{let e=n.current,t=Up(e);e&&t&&(u.current=Ep(e,Kp(t)))},[]),k=(0,J.useCallback)(()=>{let e=n.current,t=Up(e),r=u.current;if(!e||!t)return;let i=r?Dp(e,Kp(t),r):null;if(i!==null&&Math.abs(i)>=1){Gp(t,Wp(t).scrollTop+i);let e=Wp(t).scrollTop;c.current=e,l.current=e}O()},[O]),A=(0,J.useCallback)(()=>{if(!a.current)return;let e=Up(n.current);!e||Wp(e).scrollTop<=0||(g.current=0,D(!1))},[D]),j=(0,J.useCallback)(e=>{let t=Up(n.current);if(!t)return;let r=Wp(t),a=c.current;if(c.current=r.scrollTop,e===`scroll`){let e=l.current;if(l.current=null,e!==null&&Math.abs(r.scrollTop-e)<1)return;O()}let o=Rp({previousScrollTop:a,snapshot:r,source:e});if(e===`scroll`&&g.current>0)zp({intent:o,snapshot:r})===`pause`&&(g.current=0,D(!1));else if(o===`follow`){if(!i.current)return;D(!0),b(!1)}else o===`pause`&&D(!1)},[O,D]),M=(0,J.useCallback)(e=>{let t=Up(n.current);if(!t)return;let i=a.current,o=i?++g.current:0;Gp(t,Wp(t).scrollHeight,e);let s=()=>{if(i&&g.current!==o)return;i&&(g.current=0);let e=Wp(t);c.current=e.scrollTop,r.current&&a.current&&Ap(e)&&(D(!0),b(!1))};e===`smooth`?window.setTimeout(s,400):requestAnimationFrame(()=>{requestAnimationFrame(s)})},[D]),ee=(0,J.useCallback)((e,t)=>{let r=Up(n.current);if(!r||t.arrived&&!a.current)return!1;let i=Kp(r),o=e.getBoundingClientRect(),s=t.arrived?Math.max(0,o.bottom-i.bottom):o.top-i.top-(i.bottom-i.top-o.height)/2;if(Math.abs(s)<1)return!0;s<0&&A();let d=Jp();if(Gp(r,Math.max(0,Wp(r).scrollTop+s),d),d===`smooth`)return u.current=null,!0;let f=Wp(r);return c.current=f.scrollTop,l.current=f.scrollTop,O(),!0},[A,O]),N=(0,J.useCallback)(()=>{let e=n.current,t=Up(e),r=e?.querySelector(`[data-transcript-unread-marker]`);if(!t||!r)return!1;E.current=!1;let a=r.getBoundingClientRect().top-Kp(t).top;Gp(t,Math.max(0,Wp(t).scrollTop+a-48));let o=Wp(t);c.current=o.scrollTop,l.current=o.scrollTop;let s=i.current&&Ap(o);return D(s),S(!s),O(),!0},[O,D]);kp(()=>{if(!C||!e.conversationId)return;let t=`${e.conversationId}:${e.startAtLink?`link`:`start`}`;if(s.current===t)return;let n=Up(C);n&&(s.current=t,b(!1),e.startAtLink?(c.current=Wp(n).scrollTop,D(!1)):e.startAtUnread&&N()||(Gp(n,Wp(n).scrollHeight),c.current=Wp(n).scrollTop,D(!0),E.current=!!e.startAtUnread))},[C,e.conversationId,e.startAtLink,e.startAtUnread,N,D]);let P=(0,J.useCallback)(()=>{E.current&&N()||(i.current?M(`auto`):(D(!1),k()))},[N,k,M,D]),te=(0,J.useCallback)(()=>{a.current?P():(k(),j(`measure`))},[P,j,k]);kp(()=>{te()},[e.historyVersion,te]),kp(()=>{let t=h.current[e.view]!==e.versions[e.view];h.current=e.versions;let i=r.current;if(o.current&&!t&&i===e.enabled)return;let s=e.enabled||i;if(r.current=e.enabled,!s)return;let c=o.current;if(o.current||=!0,e.enabled&&!i){let e=Up(n.current);e&&D(Ap(Wp(e)))}Fp({enabled:e.enabled,following:a.current})?(P(),b(!1)):e.enabled&&c&&b(!0)},[e.enabled,e.view,e.versions.rich,e.versions.raw,P,D]),(0,J.useEffect)(()=>{if(typeof window>`u`||!C)return;let e=Up(C);if(!e)return;let t=e,n=()=>j(`scroll`),r=e=>{e.deltaY<0&&A()},i=null,a=e=>{i=e.touches[0]?.clientY??null},o=e=>{let t=e.touches[0]?.clientY;t!==void 0&&i!==null&&(t>i+2&&A(),i=Math.min(i,t))};return j(`measure`),O(),t.addEventListener(`scroll`,n,{capture:!0,passive:!0}),t.addEventListener(`wheel`,r,{passive:!0}),t.addEventListener(`touchstart`,a,{passive:!0}),t.addEventListener(`touchmove`,o,{passive:!0}),window.addEventListener(`resize`,te),()=>{t.removeEventListener(`scroll`,n,{capture:!0}),t.removeEventListener(`wheel`,r),t.removeEventListener(`touchstart`,a),t.removeEventListener(`touchmove`,o),window.removeEventListener(`resize`,te)}},[C,A,j,O,te]),(0,J.useEffect)(()=>{if(typeof ResizeObserver>`u`||!C)return;let e=new ResizeObserver(()=>{te()});e.observe(C);let t=Up(C);return t&&!qp(t)&&e.observe(t),()=>e.disconnect()},[C,te]);let F=(0,J.useCallback)(()=>{E.current=!1,D(!0),b(!1),M(Jp())},[M,D]);kp(()=>{let t=f.current!==e.juniorMessageVersion;f.current=e.juniorMessageVersion;let n=Ip({enabled:e.enabled,following:a.current,juniorMessageChanged:t,pending:m.current,wasEnabled:p.current});p.current=e.enabled,m.current=n.pending,n.pin&&(D(!0),b(!1),M(`auto`))},[e.enabled,e.juniorMessageVersion,M,D]),kp(()=>{let t=e.pinRequestVersion??0;t!==d.current&&(d.current=t,E.current=!1,D(!0),b(!1),M(`auto`))},[e.pinRequestVersion,M,D]);let ne=(0,J.useCallback)(()=>u.current?.key,[]);return(0,J.useMemo)(()=>({anchorRef:t,contentElement:C,contentRef:T,hasPendingUpdate:y,jumpToBottom:F,scrollAnchorKey:ne,showRow:ee,showJumpToLatest:Lp({enabled:e.enabled,endsAtLatest:e.endsAtLatest,following:_,hasPendingUpdate:y,openedAtUnread:x})}),[C,T,_,y,e.enabled,e.endsAtLatest,F,x,ne,ee])}const Vp=(0,J.createContext)(void 0);function Hp(e){let[t,n]=(0,J.useState)(null),r=(0,J.useRef)(e.onLoad);return r.current=e.onLoad,(0,J.useEffect)(()=>{if(!e.enabled||!t||typeof IntersectionObserver>`u`)return;let n=Up(t),i=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(i.disconnect(),r.current())},{root:n&&!qp(n)?n:null,rootMargin:e.edge===`top`?`600px 0px 0px 0px`:`0px 0px 600px 0px`});return i.observe(t),()=>i.disconnect()},[e.edge,e.enabled,e.historyVersion,t]),n}function Up(e){if(typeof window>`u`)return null;if(!e)return window;let t=e.parentElement;for(;t&&t!==document.body;){let e=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(e.overflowY))return t;t=t.parentElement}return window}function Wp(e){if(qp(e)){let e=document.scrollingElement??document.documentElement;return{clientHeight:window.innerHeight,scrollHeight:e.scrollHeight,scrollTop:window.scrollY||e.scrollTop}}return{clientHeight:e.clientHeight,scrollHeight:e.scrollHeight,scrollTop:e.scrollTop}}function Gp(e,t,n=`auto`){qp(e)?window.scrollTo({behavior:n,top:t}):e.scrollTo({behavior:n,top:t})}function Kp(e){if(qp(e))return{bottom:window.innerHeight,top:0};let t=e.getBoundingClientRect().top;return{bottom:t+e.clientHeight,top:t}}function qp(e){return e===window}function Jp(){return typeof window>`u`||typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}const Yp=`data-transcript-seq`,Xp=`[${Yp}]`,Zp=/* @__PURE__ */ new Set([` `,`ArrowDown`,`ArrowUp`,`End`,`Home`,`PageDown`,`PageUp`]);function Qp(){return t(Cp,`unread`)}function $p(){if(typeof window>`u`)return`unread`;try{let e=window.localStorage.getItem(Cp);return e&&JSON.parse(e)===`latest`?`latest`:`unread`}catch{return`unread`}}function em(e,t){let[n,r]=(0,J.useState)(),[i,a]=(0,J.useState)(),o=n??(e?{lastReadSeq:e.readPosition?.lastReadSeq}:void 0);!n&&o&&r(o);let s=i??(t?{throughSeq:t.events.at(-1)?.seq,unreadCursor:t.unreadCursor,unreadPage:t.unreadPage}:void 0);return!i&&s&&a(s),{...tm(o?.lastReadSeq,s?s.throughSeq:e?.events.at(-1)?.seq),...s?.unreadCursor?{unreadCursor:s.unreadCursor,unreadPage:s.unreadPage}:void 0}}function tm(e,t){return e===void 0?{}:t===void 0||t<=e?{lastReadSeq:e}:{lastReadSeq:e,unread:{afterSeq:e,throughSeq:t}}}function nm(e,t){let n=e.events[0]?.seq;if(!e.unreadCursor||n!==void 0&&t.lastReadSeq+1<n)return{...e,readPosition:t};let{unreadCursor:r,unreadPage:i,...a}=e;return{...a,readPosition:t}}function rm(e){let t=P(),{mutate:n}=N({scope:Qu(e),mutationFn:t=>ea(Fi,`/api/conversations/${encodeURIComponent(e)}/read-position`,{lastReadSeq:t}),onSuccess:async({unreadReply:n,...r})=>{let i=X(e),a={queryKey:[`dashboard`,`conversations`]},o=!n&&t.isMutating({mutationKey:$u(e)})===0&&(t.getQueryData(i)?.unread||t.getQueriesData(a).some(([,t])=>t?.conversations.some(t=>t.conversationId===e&&t.unread)));o&&(await Promise.all([t.cancelQueries(a),t.cancelQueries({exact:!0,queryKey:i})]),t.setQueriesData(a,t=>t&&{...t,conversations:t.conversations.map(t=>t.conversationId===e?{...t,unread:void 0}:t)})),t.setQueryData(i,e=>e&&{...nm(e,r),...o?{unread:void 0}:void 0})}});return(0,J.useCallback)(r=>{let i=t.getQueryData(X(e))?.readPosition?.lastReadSeq;i!==void 0&&r<=i||t.isMutating({mutationKey:$u(e)})>0||n(r)},[e,n,t])}function im(e){let t=(0,J.useRef)(e.onRead);t.current=e.onRead;let n=(0,J.useRef)(e.paused);n.current=e.paused;let r=(0,J.useRef)(e.lastReadSeq??-1),i=(0,J.useRef)(!1),a=(0,J.useRef)(void 0),o=(0,J.useRef)(e.engaged);o.current=e.engaged,(0,J.useEffect)(()=>{e.lastReadSeq!==void 0&&e.lastReadSeq<r.current&&(r.current=e.lastReadSeq)},[e.lastReadSeq]);let s=!!e.onRead;(0,J.useEffect)(()=>{e.engaged&&a.current?.()},[e.engaged]),(0,J.useEffect)(()=>{let c=e.content,l=Up(c);if(!s||!c||!l||typeof IntersectionObserver>`u`)return;let u=/* @__PURE__ */ new Set,d,f=null,p=()=>{d!==void 0&&window.clearTimeout(d),d=void 0;let e=f;f=null,!(e===null||e<=r.current)&&(r.current=e,t.current?.(e))},m=()=>{if(i.current&&!n.current&&document.visibilityState===`visible`){for(let e of u){let t=Number(e.dataset.transcriptSeq);Number.isSafeInteger(t)&&(f=Math.max(f??-1,t))}f!==null&&(d??=window.setTimeout(p,750))}},h=()=>{document.visibilityState===`visible`?m():p()},g=new IntersectionObserver(e=>{for(let t of e){let e=t.target;t.isIntersecting&&e.isConnected?u.add(e):u.delete(e)}m()},{root:l===window?null:l}),_=e=>{if(!(e instanceof HTMLElement))return[];let t=[...e.querySelectorAll(Xp)];return e.matches(Xp)?[e,...t]:t},v=e=>{for(let t of _(e))g.observe(t)},y=e=>{for(let t of _(e))g.unobserve(t),u.delete(t)},b=new MutationObserver(e=>{let t=!1;for(let n of e)if(n.addedNodes.forEach(v),n.removedNodes.forEach(y),n.type===`attributes`){let e=n.target;g.observe(e),t||=u.has(e)}t&&m()});b.observe(c,{attributeFilter:[Yp],childList:!0,subtree:!0}),v(c);let x=()=>{i.current||(i.current=!0,m())};a.current=x;let S=l===window?c:l,C=[`wheel`,`touchstart`,`pointerdown`,`keydown`];for(let e of C)S.addEventListener(e,x,{passive:!0});let w=e=>{document.activeElement===document.body&&Zp.has(e.key)&&x()};return document.addEventListener(`keydown`,w),o.current&&x(),document.addEventListener(`visibilitychange`,h),()=>{p(),a.current=void 0;for(let e of C)S.removeEventListener(e,x);document.removeEventListener(`keydown`,w),g.disconnect(),b.disconnect(),document.removeEventListener(`visibilitychange`,h)}},[s,e.content])}async function am(e,t){e.getQueryCache().find({exact:!0,queryKey:X(t)})?.getObserversCount()||await e.prefetchQuery({...od(t),queryFn:async({signal:n})=>{let r=await gd(t,n,void 0,{mailbox:!0,unreadPage:$p()===`unread`});return id(e,t,e.getQueryData(X(t)),r),{...r,prefetchedAtMs:Date.now()}}})}function om(e){let t=P(),n=(0,J.useRef)(void 0);(0,J.useEffect)(()=>()=>clearTimeout(n.current),[]);let r=()=>{clearTimeout(n.current),n.current=setTimeout(()=>void am(t,e),150)},i=()=>clearTimeout(n.current);return{onBlur:i,onFocus:r,onPointerEnter:e=>{e.pointerType!==`touch`&&r()},onPointerLeave:i}}const sm=[`pl-[2.125rem]`,`pl-[3.125rem]`,`pl-[4.125rem]`],cm=(0,J.memo)(function(e){let t=om(e.conversation.id);return/* @__PURE__ */ (0,Y.jsxs)(V,{...t,"aria-current":e.selected?`page`:void 0,className:K(`grid min-w-0 grid-cols-[0.875rem_minmax(0,1fr)_auto] items-center gap-x-2 rounded-lg py-1 pr-3 text-inherit no-underline transition-colors hover:bg-dashboard-fill-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus`,sm[Math.min(e.depth,sm.length-1)],e.selected&&`bg-dashboard-surface-active`),to:kc(e.conversation.id),children:[/* @__PURE__ */ (0,Y.jsx)(xp,{status:vp(e.conversation,e.waiting)}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:K(`min-w-0 truncate font-sans text-sm leading-snug`,e.selected?`font-medium text-dashboard-text`:`text-dashboard-text-muted`),children:Fa(e.conversation)}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-sans text-xs tabular-nums text-dashboard-text-faint`,children:Dc(e.conversation.lastSeenAt)})]})});function lm(e){return/* @__PURE__ */ (0,Y.jsxs)(`button`,{"aria-expanded":e.expanded,className:K(`group grid min-w-0 cursor-pointer grid-cols-[0.875rem_minmax(0,1fr)] items-center gap-x-2 rounded-lg py-1 pr-3 text-left font-sans text-xs text-dashboard-text-faint transition-colors hover:bg-dashboard-fill-hover hover:text-dashboard-text-muted focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus`,sm[0]),onClick:e.onToggle,type:`button`,children:[/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,className:ia}),e.expanded?`Show fewer`:`Show ${e.hiddenCount} more`]})}function um(e,t){let n=e??[],r=fm(n,0),i=n.length>3;if(t.expanded||!i)return{collapsible:i,hiddenCount:0,threads:r};let a=new Set([...n].sort((e,t)=>Date.parse(t.lastSeenAt)-Date.parse(e.lastSeenAt)).slice(0,3).map(e=>e.id)),o=t.selectedId,s=o?n.find(e=>dm(e,o)):void 0;s&&a.add(s.id);let c=fm(n.filter(e=>a.has(e.id)),0);return{collapsible:i,hiddenCount:r.length-c.length,threads:c}}function dm(e,t){return e.id===t||(e.threads??[]).some(e=>dm(e,t))}function fm(e,t){return e.flatMap(e=>[{conversation:e,depth:t},...fm(e.threads??[],t+1)])}const pm=`junior:conversation-collapsed-sections`;function mm(){let[e,t]=(0,J.useState)(hm);return{collapsedKeys:e,toggle:(0,J.useCallback)(e=>{t(t=>{let n=new Set(t);return n.delete(e)||n.add(e),gm(n),n})},[])}}function hm(){if(typeof window>`u`)return/* @__PURE__ */ new Set;try{let e=JSON.parse(window.localStorage.getItem(pm)??`[]`);return Array.isArray(e)?new Set(e.filter(e=>typeof e==`string`)):/* @__PURE__ */ new Set}catch{return/* @__PURE__ */ new Set}}function gm(e){if(typeof window<`u`)try{window.localStorage.setItem(pm,JSON.stringify([...e]))}catch{}}function _m({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`empty`,className:F(`min-w-0 rounded-lg border border-dashboard-border-strong bg-dashboard-bg px-4 py-3`,e),...t})}function vm({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{"aria-hidden":`true`,"data-slot":`empty-media`,className:F(`grid size-8 shrink-0 place-items-center rounded-md bg-dashboard-fill-strong text-dashboard-text-subtle [&_svg:not([class*='size-'])]:size-4`,e),...t})}function ym({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`empty-title`,className:F(`font-display text-base font-medium leading-tight text-dashboard-text`,e),...t})}function bm({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`empty-description`,className:F(`text-base leading-relaxed text-dashboard-text-muted`,e),...t})}function xm(e){return/* @__PURE__ */ (0,Y.jsx)(_m,{children:/* @__PURE__ */ (0,Y.jsx)(bm,{children:e.children})})}function Sm({className:e,children:t,viewportClassName:n,...r}){return/* @__PURE__ */ (0,Y.jsxs)(lt,{"data-slot":`scroll-area`,className:F(`relative min-h-0`,e),...r,children:[/* @__PURE__ */ (0,Y.jsx)(et,{"data-slot":`scroll-area-viewport`,className:F(`size-full overscroll-contain outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-dashboard-focus`,n),children:t}),/* @__PURE__ */ (0,Y.jsx)($e,{"data-slot":`scroll-area-scrollbar`,className:`flex h-full w-1.5 touch-none px-px opacity-0 transition-opacity delay-500 duration-300 select-none hover:opacity-100 hover:delay-0 data-scrolling:opacity-100 data-scrolling:delay-0 data-scrolling:duration-75 motion-reduce:transition-none`,children:/* @__PURE__ */ (0,Y.jsx)(mt,{className:`flex-1 rounded-full bg-dashboard-scrollbar-thumb/80 hover:bg-dashboard-scrollbar-thumb-hover`})})]})}const Cm=`grid size-7 cursor-pointer place-items-center rounded-md text-dashboard-text-muted transition hover:text-dashboard-text focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-dashboard-focus disabled:cursor-not-allowed`,wm=e=>e.key;function Tm(e){let{clearActionError:t,showActionError:n,showArchiveError:r,showArchived:i}=zd(),a=(0,J.useCallback)((e,t)=>{n(e,t?`Could not pin`:`Could not unpin`)},[n]),o=(0,J.useCallback)((e,t)=>{n(e,t?`Could not mark as unread`:`Could not mark as read`)},[n]),{collapsedKeys:s,toggle:c}=mm(),[l,u]=(0,J.useState)(()=>/* @__PURE__ */ new Set),d=(0,J.useCallback)(e=>{u(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},[]),f=(0,J.useMemo)(()=>Om(gc(e.conversations,{attentionIds:vc(e.conversations,e.waitingConversations.keys()),nowMs:Date.now(),timeZone:e.timeZone}),s,{expandedThreadRoots:l,selectedId:e.selectedId}),[s,l,e.selectedId,e.conversations,e.timeZone,e.waitingConversations]),p=(0,J.useMemo)(()=>f.flatMap(e=>e.kind===`conversation`&&e.conversation.pinnedAt?[e.conversation]:[]),[f]),m=(0,J.useCallback)(e=>n(e,`Could not reorder`),[n]);return/* @__PURE__ */ (0,Y.jsxs)(`aside`,{className:`relative grid h-full min-h-0 min-w-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden border-r border-dashboard-border bg-dashboard-surface-panel`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`px-3 pb-1.5 pt-2.5`,children:/* @__PURE__ */ (0,Y.jsxs)(H,{className:`grid grid-cols-[0.875rem_minmax(0,1fr)] gap-2 rounded-lg px-3 py-2 font-medium leading-snug hover:bg-dashboard-fill-hover focus-visible:bg-dashboard-fill-hover [&_svg]:text-dashboard-accent-text hover:[&_svg]:text-dashboard-accent-text focus-visible:[&_svg]:text-dashboard-accent-text`,onClick:e.onNewConversation,size:`menu`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-[1.125rem] place-items-center justify-self-center rounded-md bg-dashboard-accent/[0.14] dark:bg-dashboard-accent/[0.22]`,children:/* @__PURE__ */ (0,Y.jsx)(In,{className:`size-3`,strokeWidth:2.25})}),`New conversation`]})}),/* @__PURE__ */ (0,Y.jsx)(Sm,{viewportClassName:`px-3 pb-[max(0.5rem,env(safe-area-inset-bottom))]`,children:e.error?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`p-2`,children:/* @__PURE__ */ (0,Y.jsx)(xm,{children:e.error})}):e.loading&&f.length===0?/* @__PURE__ */ (0,Y.jsx)(Em,{}):/* @__PURE__ */ (0,Y.jsx)(rp,{conversations:p,onError:m,reorder:e.onReorderPins,children:/* @__PURE__ */ (0,Y.jsx)(cp,{ariaLabel:`Your conversations`,className:`grid gap-0.5`,empty:e.loading?void 0:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`p-2`,children:/* @__PURE__ */ (0,Y.jsx)(xm,{children:`No conversations match this view.`})}),getKey:wm,items:f,renderItem:s=>s.kind===`section`?/* @__PURE__ */ (0,Y.jsx)(pp,{className:K(`px-3 pb-1`,s.first?`pt-1`:`pt-3`),collapsed:s.collapsed,count:s.count,label:s.label,onToggle:()=>c(s.sectionKey)}):s.kind===`thread-toggle`?/* @__PURE__ */ (0,Y.jsx)(lm,{expanded:s.expanded,hiddenCount:s.hiddenCount,onToggle:()=>d(s.rootId)}):s.kind===`thread`?/* @__PURE__ */ (0,Y.jsx)(cm,{conversation:s.conversation,depth:s.depth,selected:s.conversation.id===e.selectedId,waiting:e.waitingConversations.has(s.conversation.id)}):/* @__PURE__ */ (0,Y.jsx)(Am,{conversation:s.conversation,onArchiveError:r,onArchived:i,onPinError:a,onPinned:t,onUnreadError:o,onActionError:n,selected:s.conversation.id===e.selectedId,waiting:e.waitingConversations.get(s.conversation.id)}),role:`navigation`})})})]})}function Em(){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{"aria-busy":`true`,"aria-live":`polite`,role:`status`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`sr-only`,children:`Loading your conversations`}),/* @__PURE__ */ (0,Y.jsx)(Dm,{})]})}function Dm(){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{"aria-hidden":`true`,className:`grid gap-0.5`,children:[/* @__PURE__ */ (0,Y.jsx)(q,{className:`mb-1 ml-3 mt-1.5 h-2.5 w-12`}),Array.from({length:10},(e,t)=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg py-2 pl-[2.125rem] pr-3`,children:[/* @__PURE__ */ (0,Y.jsx)(q,{className:K(`h-4`,t%3==0?`w-4/5`:`w-3/5`)}),/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-3 w-6 opacity-70`})]},t))]})}function Om(e,t,n){return e.flatMap((e,r)=>{let i=t.has(e.key);return[{collapsed:i,count:e.conversations.length,first:r===0,key:`section-${e.key}`,kind:`section`,label:e.label,sectionKey:e.key},...(i?[]:e.conversations).flatMap(e=>[{conversation:e,key:`conversation-${e.id}`,kind:`conversation`},...km(e,n.expandedThreadRoots.has(e.id),n.selectedId)])]})}function km(e,t,n){let{collapsible:r,hiddenCount:i,threads:a}=um(e.threads,{expanded:t,selectedId:n}),o=a.map(e=>({...e,key:`thread-${e.conversation.id}`,kind:`thread`}));return r&&(t||i>0)&&o.push({expanded:t,hiddenCount:i,key:`thread-toggle-${e.id}`,kind:`thread-toggle`,rootId:e.id}),o}function Am(e){return e.conversation.pinnedAt?/* @__PURE__ */ (0,Y.jsx)(jm,{...e}):/* @__PURE__ */ (0,Y.jsx)(Mm,{...e})}function jm(e){let t=ip(e.conversation.id);return/* @__PURE__ */ (0,Y.jsx)(Mm,{...e,drag:t})}const Mm=(0,J.memo)(function(e){let t=jd(e.conversation.id,{onError:()=>e.onArchiveError(e.conversation,t.variables?.archived??!0),onSuccess:t=>{t&&e.onArchived(e.conversation)}}),n=Vd(e.conversation.id,{onError:t=>e.onPinError(e.conversation,t),onSuccess:()=>e.onPinned(e.conversation)}),r=Bd(e.conversation.id,{onError:t=>e.onUnreadError(e.conversation,t)}),i=Hd(e.conversation.id,{onError:()=>e.onActionError(e.conversation,`Could not rename`)}),a=$d(e.conversation.id,{onError:()=>e.onActionError(e.conversation,`Could not update subscription`)}),o=Qd(e.conversation.id,{onError:()=>e.onActionError(e.conversation,`Could not change Slack updates`)}),[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(!1),d=ge(),f=P(),p=om(e.conversation.id),m=!!e.conversation.pinnedAt,h=Sa(e.conversation),g=Fa(e.conversation),_=!!e.conversation.unread,v=_||!!e.waiting,y=e.drag,b=ya(e.conversation),x=!!e.conversation.archivedAt,S=e.conversation.isParticipant,C=S&&!e.waiting&&(_||b),w=()=>n.mutate(!m),T=()=>t.mutate({archived:!x,lastSeenAt:e.conversation.lastSeenAt});return/* @__PURE__ */ (0,Y.jsxs)(of,{onOpenChange:t=>{t&&am(f,e.conversation.id)},children:[/* @__PURE__ */ (0,Y.jsxs)(sf,{...p,...y?.listeners,className:K(`mobile-conversation-row group relative min-w-0 rounded-lg transition-colors hover:bg-dashboard-fill-hover data-popup-open:bg-dashboard-fill-hover`,e.selected&&`bg-dashboard-surface-active`,y?.dragging&&`opacity-40`,x?`[--row-actions-width:2.25rem]`:`[--row-actions-width:4.25rem]`),onKeyDown:y?.onKeyDown,ref:y?.setNodeRef,children:[/* @__PURE__ */ (0,Y.jsxs)(V,{"aria-current":e.selected?`page`:void 0,"aria-keyshortcuts":y?`Alt+ArrowUp Alt+ArrowDown`:void 0,className:K(`grid min-w-0 grid-cols-[0.875rem_minmax(0,1fr)_auto] items-center gap-x-2 rounded-lg px-3 py-1.5 text-inherit no-underline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus`,S&&`max-sm:pr-10 sm:group-hover:[mask-image:linear-gradient(to_left,transparent_var(--row-actions-width),black_calc(var(--row-actions-width)+2rem))] sm:group-focus-within:[mask-image:linear-gradient(to_left,transparent_var(--row-actions-width),black_calc(var(--row-actions-width)+2rem))]`,`[-webkit-touch-callout:none]`),draggable:!y&&void 0,to:kc(e.conversation.id),children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`grid place-items-center`,children:v?/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-label":e.waiting?`Waiting on you`:`Unread`,className:`size-1.5 shrink-0 rounded-full bg-dashboard-accent`,role:`img`}):e.conversation.visibility===`private`?/* @__PURE__ */ (0,Y.jsx)(Wt,{"aria-label":`Private conversation`,className:`size-3 shrink-0 text-dashboard-text-faint`}):null}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:K(`min-w-0 overflow-hidden whitespace-nowrap font-sans text-sm leading-snug [mask-image:linear-gradient(to_left,transparent,black_2rem)]`,v?`font-semibold`:e.selected&&`font-medium`,v||e.selected||h===`active`?`text-dashboard-text`:`text-dashboard-text-muted`),children:g}),/* @__PURE__ */ (0,Y.jsx)(Nm,{lastSeenAt:e.conversation.lastSeenAt,status:h})]}),C?/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[/* @__PURE__ */ (0,Y.jsx)(W,{render:/* @__PURE__ */ (0,Y.jsx)(`button`,{"aria-label":`Mark ${g} as ${_?`read`:`unread`}`,className:`group/read absolute top-1 left-[0.4375rem] z-10 grid size-6 cursor-pointer place-items-center rounded-md transition hover:bg-dashboard-surface-active focus-visible:bg-dashboard-surface-active focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-dashboard-focus disabled:cursor-not-allowed`,disabled:r.isPending,onClick:()=>r.mutate(!_),type:`button`,children:/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:K(`hidden size-1.5 rounded-full group-hover/read:block group-focus-visible/read:block`,_?`border border-dashboard-text-muted`:`bg-dashboard-accent`)})})}),/* @__PURE__ */ (0,Y.jsx)(Cr,{size:`compact`,children:_?`Mark as read`:`Mark as unread`})]}):null,e.waiting?/* @__PURE__ */ (0,Y.jsxs)(V,{className:`mb-1.5 ml-[2.125rem] mr-3 flex min-w-0 items-center gap-1.5 rounded-md border border-dashboard-border-strong bg-dashboard-surface-raised px-2 py-1 font-sans text-xs text-dashboard-text no-underline transition-colors hover:border-dashboard-border-interactive focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-dashboard-focus`,to:kc(e.conversation.id,{reviewItems:!0}),children:[/* @__PURE__ */ (0,Y.jsx)(lr,{"aria-hidden":`true`,className:`size-3 shrink-0 text-dashboard-text-muted`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:e.waiting.title}),e.waiting.count>1?/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`ml-auto shrink-0 text-dashboard-text-faint`,children:[`+`,e.waiting.count-1,` more`]}):null,/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,className:K(`size-3 shrink-0 text-dashboard-text-muted`,e.waiting.count>1?void 0:`ml-auto`)})]}):null,S?/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`absolute top-0.5 right-1.5 z-10 flex gap-0.5 transition sm:pointer-events-none sm:opacity-0 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100`,children:[x?null:/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[/* @__PURE__ */ (0,Y.jsx)(W,{render:/* @__PURE__ */ (0,Y.jsx)(`button`,{"aria-label":`${m?`Unpin`:`Pin`} ${g}`,"aria-pressed":m,className:K(Cm,`max-sm:hidden`),disabled:n.isPending,onClick:w,type:`button`,children:/* @__PURE__ */ (0,Y.jsx)(Mt,{"aria-hidden":`true`,fill:m?`currentColor`:`none`,size:14})})}),/* @__PURE__ */ (0,Y.jsx)(Cr,{size:`compact`,children:m?`Unpin`:`Pin`})]}),/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[/* @__PURE__ */ (0,Y.jsx)(W,{render:/* @__PURE__ */ (0,Y.jsx)(`button`,{"aria-label":`${x?`Restore`:`Archive`} ${g}`,className:Cm,disabled:t.isPending,onClick:T,type:`button`,children:x?/* @__PURE__ */ (0,Y.jsx)(vn,{"aria-hidden":`true`,size:14}):/* @__PURE__ */ (0,Y.jsx)(bn,{"aria-hidden":`true`,size:14})})}),/* @__PURE__ */ (0,Y.jsx)(Cr,{size:`compact`,children:x?`Restore`:`Archive`})]})]}):null]}),/* @__PURE__ */ (0,Y.jsx)(cf,{children:/* @__PURE__ */ (0,Y.jsx)(tp,{actions:{archive:T,continueInSlack:()=>u(!0),delivery:e=>o.mutate(e),eventLog:()=>d(kc(e.conversation.id),{replace:e.selected,state:Mc}),pin:e=>n.mutate(e),read:e=>r.mutate(e),rename:()=>c(!0),subscription:e=>a.mutate(e)},conversation:e.conversation,conversationId:e.conversation.id,pending:{archive:t.isPending,delivery:o.isPending,pin:n.isPending,read:r.isPending,subscription:a.isPending}})}),s?/* @__PURE__ */ (0,Y.jsx)(Zd,{onClose:()=>c(!1),onSave:e=>i.mutate(e),title:g}):null,l?/* @__PURE__ */ (0,Y.jsx)(nf,{conversationId:e.conversation.id,onClose:()=>u(!1)}):null]})});function Nm(e){return e.status===`active`?/* @__PURE__ */ (0,Y.jsx)(_p,{"aria-label":`Running`,className:`size-3.5 text-dashboard-text-muted`}):e.status===`failed`?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-sans text-xs text-rose-400`,children:`Failed`}):e.status===`stopped`?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-sans text-xs text-dashboard-text-muted`,children:`Stopped`}):/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-sans text-xs tabular-nums text-dashboard-text-faint`,children:Dc(e.lastSeenAt)})}function Pm({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`input-group`,role:`group`,className:F(`group/input-group relative flex h-9 w-full min-w-0 items-center rounded-md border border-dashboard-border bg-dashboard-overlay-soft transition-colors outline-none hover:border-dashboard-border-emphasis has-[[data-slot=input-group-control]:focus-visible]:border-dashboard-focus has-[[data-slot=input-group-control]:focus-visible]:ring-1 has-[[data-slot=input-group-control]:focus-visible]:ring-dashboard-focus/25`,e),...t})}const Fm=I(`flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-dashboard-text-muted select-none`,{variants:{align:{"inline-start":`order-first pl-2.5`,"inline-end":`order-last pr-1.5`}},defaultVariants:{align:`inline-start`}});function Im({className:e,align:t=`inline-start`,...n}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{role:`group`,"data-slot":`input-group-addon`,"data-align":t,className:F(Fm({align:t}),e),onClick:e=>{e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()},...n})}function Lm({className:e,type:t=`button`,...n}){return/* @__PURE__ */ (0,Y.jsx)(H,{type:t,size:`icon`,className:F(`size-6`,e),...n})}function Rm({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(Kd,{"data-slot":`input-group-control`,className:F(`h-full min-w-0 flex-1 rounded-none border-0 bg-transparent px-2 focus:ring-0`,e),...t})}function zm(e){let t=Bm[e.size??`compact`];return/* @__PURE__ */ (0,Y.jsxs)(Pm,{className:K(t.group,e.className),children:[/* @__PURE__ */ (0,Y.jsx)(Rm,{"aria-label":e.label,className:K(`[&::-webkit-search-cancel-button]:appearance-none`,t.input),onChange:t=>e.onChange(t.currentTarget.value),placeholder:e.placeholder,ref:e.inputRef,type:`search`,value:e.value}),/* @__PURE__ */ (0,Y.jsx)(Im,{className:t.icon,children:/* @__PURE__ */ (0,Y.jsx)(At,{"aria-hidden":`true`,size:t.iconSize,strokeWidth:2.5})}),/* @__PURE__ */ (0,Y.jsx)(Im,{align:`inline-end`,className:t.clear,children:/* @__PURE__ */ (0,Y.jsx)(Lm,{"aria-label":`Clear search`,className:e.value?void 0:`invisible`,onClick:t=>{e.onChange(``),t.currentTarget.closest(`[data-slot=input-group]`)?.querySelector(`input`)?.focus()},children:/* @__PURE__ */ (0,Y.jsx)(Xn,{"aria-hidden":`true`,size:14,strokeWidth:2.5})})})]})}const Bm={compact:{clear:`pr-1.25`,group:`h-9`,icon:`pl-2.25`,iconSize:13,input:`pr-1 pl-2.5`},default:{clear:`pr-1.75`,group:`h-10`,icon:`pl-2.75`,iconSize:14,input:`pr-1 pl-2.75`}};function Vm({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(T,{"data-slot":`resizable-panel-group`,className:F(`flex h-full w-full aria-[orientation=vertical]:flex-col`,e),...t})}function Hm({...e}){return/* @__PURE__ */ (0,Y.jsx)(m,{"data-slot":`resizable-panel`,...e})}function Um({withHandle:e,className:t,...n}){return/* @__PURE__ */ (0,Y.jsx)(C,{"data-slot":`resizable-handle`,className:F(`relative flex w-px items-center justify-center bg-border ring-offset-background after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90`,t),...n,children:e&&/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border`})})}const Wm=`max-h-[min(calc(var(--dashboard-viewport-height,100dvh)*0.55),24rem)] bg-dashboard-bg px-2 pt-1.5 pb-[var(--dashboard-composer-dock-padding,0.375rem)]`;function Gm(e){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:K(`flex w-full min-h-0 shrink-0 flex-col overflow-hidden`,Wm,`md:max-h-none md:overflow-visible md:px-7 md:pt-3 md:pb-5`,e.className),"data-composer-dock":``,children:[e.above?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`mx-auto w-full max-w-[52.5rem] min-h-0 min-w-0 shrink overflow-y-auto overscroll-contain md:overflow-visible`,children:e.above}):null,/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`mx-auto w-full max-w-[52.5rem] min-w-0 shrink-0`,children:e.children})]})}function Km(e){let t=e.name.trim().split(/\s+/).filter(Boolean),n=e.size===`list`?e.name.trim().slice(0,1):t.length>1?`${t[0][0]}${t.at(-1)[0]}`:e.name.slice(0,2);return/* @__PURE__ */ (0,Y.jsxs)(Hs,{"aria-hidden":`true`,size:e.size===`list`?`sm`:`default`,children:[/* @__PURE__ */ (0,Y.jsx)(Us,{alt:`User avatar`,loading:`lazy`,referrerPolicy:`no-referrer`,src:e.imageUrl}),/* @__PURE__ */ (0,Y.jsx)(Ws,{children:n.toUpperCase()})]})}function qm(e){return e.fullName?.trim()||e.slackUserName?.trim()||e.email?.trim()||e.slackUserId?.trim()||`Unknown actor`}function Jm(e){let t=qm(e),n=e.email?.trim();return n&&n!==t?`${t}, ${n}`:t}function Ym(e,t){return e.email?.trim().toLowerCase()||e.slackUserId?.trim()||e.slackUserName?.trim()||`${Za(e)??`actor`}:${t}`}function Xm(e){let t=qm(e.participant),n=e.participant.email?.trim();return/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`grid gap-0.5 font-sans`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-semibold text-dashboard-text`,children:t}),n&&n!==t?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-sans text-dashboard-text-muted`,children:n}):null]})}function Zm(e){let t=Jm(e.participant);return/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[/* @__PURE__ */ (0,Y.jsx)(W,{render:/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-label":t,role:`img`,className:`relative -ml-1 inline-flex rounded-full first:ml-0 pointer-events-none focus-visible:z-10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-dashboard-focus [@media(hover:hover)_and_(pointer:fine)]:pointer-events-auto`,onKeyDown:e=>e.stopPropagation(),tabIndex:0,children:/* @__PURE__ */ (0,Y.jsx)(Km,{imageUrl:e.participant.avatarUrl,name:qm(e.participant),size:e.size})})}),/* @__PURE__ */ (0,Y.jsx)(Cr,{children:/* @__PURE__ */ (0,Y.jsx)(Xm,{participant:e.participant})})]})}function Qm(e){return e?.participants?.length?e.participants:e?.actorIdentity?[e.actorIdentity]:[]}function $m(e){if(e.participants.length===0)return null;let t=e.participants.slice(0,3),n=e.participants.slice(3),r=e.participants.map(Jm).join(`; `);return/* @__PURE__ */ (0,Y.jsxs)(`span`,{"aria-label":`Conversation participants: ${r}`,className:`inline-flex items-center`,role:`group`,children:[t.map((t,n)=>/* @__PURE__ */ (0,Y.jsx)(Zm,{participant:t,size:e.size},Ym(t,n))),n.length>0?/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[/* @__PURE__ */ (0,Y.jsx)(W,{render:/* @__PURE__ */ (0,Y.jsx)(Hs,{"aria-label":`${n.length} more participants: ${n.map(Jm).join(`; `)}`,className:`-ml-1 pointer-events-none bg-dashboard-surface-active shadow-none focus-visible:z-10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-dashboard-focus [@media(hover:hover)_and_(pointer:fine)]:pointer-events-auto`,onKeyDown:e=>e.stopPropagation(),size:e.size===`list`?`sm`:`default`,tabIndex:0,children:/* @__PURE__ */ (0,Y.jsxs)(Ws,{className:`tabular-nums tracking-normal text-dashboard-text-muted`,children:[`+`,n.length]})})}),/* @__PURE__ */ (0,Y.jsx)(Cr,{children:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`grid gap-1 font-sans`,children:n.map((e,t)=>/* @__PURE__ */ (0,Y.jsx)(`span`,{children:Jm(e)},Ym(e,t)))})})]}):null]})}const eh={neutral:`text-dashboard-text-muted`,success:`text-emerald-500`,danger:`text-rose-500`,warning:`text-amber-500`,info:`text-cyan-500`,accent:`text-violet-400`};function th(e){let t=Rr(e),n=[t.label,e.status].filter(Boolean).join(`: `);return/* @__PURE__ */ (0,Y.jsx)(`svg`,{"aria-hidden":e.decorative?!0:void 0,"aria-label":e.decorative?void 0:n,role:e.decorative?void 0:`img`,className:K(`inline-block shrink-0 align-middle`,eh[t.tone],e.className),width:e.size??16,height:e.size??16,viewBox:`0 0 16 16`,fill:`currentColor`,children:Yr[t.icon].map(e=>/* @__PURE__ */ (0,Y.jsx)(`path`,{d:e},e))})}function nh({...e}){return/* @__PURE__ */ (0,Y.jsx)(at,{"data-slot":`collapsible`,...e})}function rh({...e}){return/* @__PURE__ */ (0,Y.jsx)(Qe,{"data-slot":`collapsible-trigger`,...e})}function ih({...e}){return/* @__PURE__ */ (0,Y.jsx)(dt,{"data-slot":`collapsible-content`,...e})}const ah=(0,J.createContext)({query:``,normalizedQuery:``,active:!1,match:0});function oh({children:e,match:t=0,onMatches:n,query:r}){let i=r.trim().toLowerCase();return/* @__PURE__ */ (0,Y.jsx)(ah.Provider,{value:{query:r,normalizedQuery:i,active:i.length>0,match:t,onMatches:n},children:e})}function sh(){return(0,J.useContext)(ah)}function ch(e){let[t,n]=(0,J.useState)({index:0,query:e}),[r,i]=(0,J.useState)(0),a=t.query===e?Math.max(0,Math.min(t.index,r-1)):0;return{count:r,index:a,setMatches:(0,J.useCallback)((t,r)=>{i(t),r!==0&&n(t=>({index:(t.query===e?t.index:0)+r,query:e}))},[e]),step(t){r!==0&&n({index:(a+t+r)%r,query:e})}}}function lh(e){let{anchorRef:t,inputRef:n,onOpen:r,open:i}=e;(0,J.useEffect)(()=>{let e=e=>{if(e.defaultPrevented||!Wc(e,`f`))return;let a=n.current;(!a||document.activeElement!==a||e.repeat)&&uh(t.current)&&(e.preventDefault(),!e.repeat&&(i&&a?(a.focus(),a.select()):r()))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,n,r,i])}function uh(e){if(!e)return!1;let t=document.querySelectorAll(`[data-dashboard-modal]`),n=t[t.length-1]??null;return e.closest(`[data-dashboard-modal]`)===n}function Q({text:e}){let{normalizedQuery:t,active:n}=sh();if(!n||!e)return/* @__PURE__ */ (0,Y.jsx)(Y.Fragment,{children:e});let r=e.toLowerCase();if(!r.includes(t))return/* @__PURE__ */ (0,Y.jsx)(Y.Fragment,{children:e});let i=[],a=0,o=r.indexOf(t),s=0;for(;o!==-1;)o>a&&i.push(e.slice(a,o)),i.push(/* @__PURE__ */ (0,Y.jsx)(`mark`,{className:`rounded-[2px] bg-amber-400/20 text-inherit not-italic`,children:e.slice(o,o+t.length)},s++)),a=o+t.length,o=r.indexOf(t,a);return a<e.length&&i.push(e.slice(a)),/* @__PURE__ */ (0,Y.jsx)(Y.Fragment,{children:i})}function dh(e,t){if(!t||!e)return[];let n=e.toLowerCase(),r=[],i=n.indexOf(t);for(;i!==-1;)r.push({end:i+t.length,properties:{class:`search-match`},start:i,tagName:`mark`}),i=n.indexOf(t,i+t.length);return r}function fh(e,t){if(!t)return!0;if(e.kind===`message`)return ph(e.message.trustedSummary,t)||ph(e.message.eventType,t)||ph(bf(e.message),t);if(e.kind===`failure`)return ph(Cf(e.failureCode,e.failureReason,e.eventId),t);if(e.kind===`tool`)return[e.part.name,e.part.status,Ta(e.part.input),Ta(e.part.output)].some(e=>ph(e,t));if(e.kind===`reasoning`)return ph(e.part.redacted?`reasoning redacted`:e.part.text,t);if(e.kind===`subagent`)return ph(e.part.agentName??e.part.subagentKind,t)||ph(e.part.title,t)||ph(e.part.task,t)||ph(e.part.status,t);if(e.kind===`structured_event`){let n=e.part.presentation;return[n.title,n.preview,...(n.details??[]).flatMap(e=>[e.title,e.description,e.content,...e.metadata??[]])].some(e=>ph(e,t))}return e.kind===`attachments_delivered`?e.part.attachments.some(e=>ph(e.filename,t)||ph(e.contentType,t)):e.kind===`context`&&[`context compacted`,e.part.event.summary].some(e=>ph(e,t))}function ph(e,t){return e?e.toLowerCase().includes(t):!1}function mh(e){let t=sh(),n=t.active?t.normalizedQuery:void 0,r=L({queryKey:[`highlight`,e.language,e.code,n],queryFn:async()=>{let t=n?dh(e.code,n):[],{codeToHtml:r}=await import(`./chunks/code-highlighter-i3ux67or.js`);return await r(e.code,{decorations:t.length?t:void 0,lang:e.language,themes:{dark:`github-dark`,light:`github-light`},defaultColor:`dark`})},staleTime:1/0});return r.data?/* @__PURE__ */ (0,Y.jsx)(gh,{html:r.data}):/* @__PURE__ */ (0,Y.jsx)(hh,{children:e.code})}function hh(e){return/* @__PURE__ */ (0,Y.jsx)(`pre`,{className:K(`m-0 min-w-0 whitespace-pre-wrap break-words bg-transparent p-0 text-dashboard-text`,e.variant===`prose`?`font-display text-base leading-7`:`font-mono text-sm leading-relaxed`),children:/* @__PURE__ */ (0,Y.jsx)(`code`,{children:e.children})})}function gh(e){return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:K(`min-w-0 overflow-hidden [&_.line]:block [&_.line]:min-h-[1lh] [&_.line]:max-w-full [&_.line]:whitespace-pre-wrap [&_.line]:break-words [&_.line]:[overflow-wrap:anywhere] [&_code]:block [&_code]:max-w-full [&_code]:whitespace-normal [&_code]:break-words [&_code]:[overflow-wrap:anywhere] [&_pre]:!m-0 [&_pre]:!max-w-full [&_pre]:!overflow-hidden [&_pre]:!bg-transparent [&_pre]:!p-0 [&_pre]:whitespace-normal [&_pre]:break-words [&_pre]:[overflow-wrap:anywhere] [&_span]:whitespace-pre-wrap [&_span]:break-words [&_span]:[overflow-wrap:anywhere] [&_mark.search-match]:bg-amber-400/20 [&_mark.search-match]:rounded-[2px] [&_mark.search-match]:text-inherit [&_mark.search-match]:not-italic light:[&_pre]:!text-(--shiki-light) light:[&_span]:!text-(--shiki-light)`,e.variant===`prose`?`[&_pre]:font-display [&_pre]:text-base [&_pre]:leading-7`:`[&_pre]:font-mono [&_pre]:text-sm [&_pre]:leading-relaxed`),dangerouslySetInnerHTML:{__html:e.html}})}const _h={"angular-html":()=>import(`./chunks/angular-html-clfz6bhr.js`),"angular-ts":()=>import(`./chunks/angular-ts-n7z07b2o.js`),astro:()=>import(`./chunks/astro-qlph616s.js`),blade:()=>import(`./chunks/blade-cav5wkjm.js`),c:()=>import(`./chunks/c-kxn51gis.js`),coffee:()=>import(`./chunks/coffee-hl2a7gun.js`),coffeescript:()=>import(`./chunks/coffee-hl2a7gun.js`),cpp:()=>import(`./chunks/cpp-hwtnd277.js`),"c++":()=>import(`./chunks/cpp-hwtnd277.js`),css:()=>import(`./chunks/css-ewdgjkdz.js`),csv:()=>import(`./chunks/csv-cgvlu7j9.js`),glsl:()=>import(`./chunks/glsl-ix1pa71e.js`),graphql:()=>import(`./chunks/graphql-ggo69kcz.js`),gql:()=>import(`./chunks/graphql-ggo69kcz.js`),haml:()=>import(`./chunks/haml-k2ijcl38.js`),handlebars:()=>import(`./chunks/handlebars-ktllr9zq.js`),hbs:()=>import(`./chunks/handlebars-ktllr9zq.js`),html:()=>import(`./chunks/html-jyc4lhdi.js`),"html-derivative":()=>import(`./chunks/html-derivative-jgakjzpm.js`),http:()=>import(`./chunks/http-jy6tqbse.js`),hurl:()=>import(`./chunks/hurl-e6h21wqd.js`),imba:()=>import(`./chunks/imba-n9x1ej2f.js`),java:()=>import(`./chunks/java-d0keys1s.js`),javascript:()=>import(`./chunks/javascript-kaqq44gk.js`),js:()=>import(`./chunks/javascript-kaqq44gk.js`),cjs:()=>import(`./chunks/javascript-kaqq44gk.js`),mjs:()=>import(`./chunks/javascript-kaqq44gk.js`),jinja:()=>import(`./chunks/jinja-b21mxvee.js`),jison:()=>import(`./chunks/jison-n79pgrj4.js`),json:()=>import(`./chunks/json-k42aauzr.js`),json5:()=>import(`./chunks/json5-e4tr07tg.js`),jsonc:()=>import(`./chunks/jsonc-jbmkhoep.js`),jsonl:()=>import(`./chunks/jsonl-j35ke6at.js`),jsx:()=>import(`./chunks/jsx-k73xlnxm.js`),julia:()=>import(`./chunks/julia-d8alj1gb.js`),jl:()=>import(`./chunks/julia-d8alj1gb.js`),less:()=>import(`./chunks/less-i87mlere.js`),markdown:()=>import(`./chunks/markdown-jx8k2top.js`),md:()=>import(`./chunks/markdown-jx8k2top.js`),marko:()=>import(`./chunks/marko-lnngnl00.js`),mdc:()=>import(`./chunks/mdc-mfb1bep1.js`),mdx:()=>import(`./chunks/mdx-mmgeh26h.js`),php:()=>import(`./chunks/php-or0rxp4f.js`),postcss:()=>import(`./chunks/postcss-nsjwyg8o.js`),pug:()=>import(`./chunks/pug-h3pglivg.js`),jade:()=>import(`./chunks/pug-h3pglivg.js`),python:()=>import(`./chunks/python-k87jn6rm.js`),py:()=>import(`./chunks/python-k87jn6rm.js`),r:()=>import(`./chunks/r-de6n1oun.js`),regexp:()=>import(`./chunks/regexp-c42dsc43.js`),regex:()=>import(`./chunks/regexp-c42dsc43.js`),sass:()=>import(`./chunks/sass-m1yncbwu.js`),scss:()=>import(`./chunks/scss-co67zlf1.js`),shellscript:()=>import(`./chunks/shellscript-i4hbmj3f.js`),bash:()=>import(`./chunks/shellscript-i4hbmj3f.js`),sh:()=>import(`./chunks/shellscript-i4hbmj3f.js`),shell:()=>import(`./chunks/shellscript-i4hbmj3f.js`),zsh:()=>import(`./chunks/shellscript-i4hbmj3f.js`),sql:()=>import(`./chunks/sql-mimz0sqs.js`),stylus:()=>import(`./chunks/stylus-daxemm87.js`),styl:()=>import(`./chunks/stylus-daxemm87.js`),svelte:()=>import(`./chunks/svelte-ey4spk6r.js`),"ts-tags":()=>import(`./chunks/ts-tags-oxyy2333.js`),lit:()=>import(`./chunks/ts-tags-oxyy2333.js`),tsx:()=>import(`./chunks/tsx-h88eg2o7.js`),typescript:()=>import(`./chunks/typescript-fpz3vkbd.js`),ts:()=>import(`./chunks/typescript-fpz3vkbd.js`),cts:()=>import(`./chunks/typescript-fpz3vkbd.js`),mts:()=>import(`./chunks/typescript-fpz3vkbd.js`),vue:()=>import(`./chunks/vue-khp070sv.js`),"vue-html":()=>import(`./chunks/vue-html-os6fklhb.js`),"vue-vine":()=>import(`./chunks/vue-vine-hf71dfd0.js`),wasm:()=>import(`./chunks/wasm-g1zrybde.js`),wgsl:()=>import(`./chunks/wgsl-gotoh48n.js`),wit:()=>import(`./chunks/wit-neu67rwu.js`),xml:()=>import(`./chunks/xml-g2a2ksxd.js`),yaml:()=>import(`./chunks/yaml-ltw3wav4.js`),yml:()=>import(`./chunks/yaml-ltw3wav4.js`)},vh=/^javascript:|=>|\b(?:const|let|var)\s+[\w$]+\s*=|\bfunction\b\s*[\w$]*\s*\(|^\s*(?:import\s.+\sfrom\s|export\s+(?:(?:async|class|const|default|enum|function|interface|let|type|var)\s|[{*]))/m,yh=/^\s*(?:(?:async\s+)?def\s+\w+\s*\(.*\)\s*(?:->.*)?:|class\s+\w+(?:\([^)]*\))?\s*:|from\s+[\w.]+\s+import\s|import\s+[\w.]+\s*$)/m,bh=/^\s*(?:\$\s|(?:bun|brew|cargo|cat|cd|cp|curl|docker|echo|export|gh|git|go|grep|kubectl|ls|make|mkdir|mv|npm|npx|pip|pnpm|rm|ssh|sudo|uv|wget|yarn)\s)/,xh={console:`shellscript`,htm:`html`,js:`javascript`,jsonl:`json`,md:`markdown`,ndjson:`json`,sh:`shellscript`,text:`markdown`,txt:`markdown`,xml:`xml`,yml:`yaml`};function Sh(e){let t=[],n=/^([ \t]*)```([^\n`]*)\n([\s\S]*?)```/gm,r=0,i;for(;i=n.exec(e);){let n=e.slice(r,i.index).trim();n&&t.push(Ch(n));let a=i[2]?.trim().split(/\s+/)[0],o=Eh(i[3]??``,i[1]?.length??0),s=a?wh(a):Th(o);t.push({code:Dh(o,s),fenced:!0,language:s}),r=i.index+i[0].length}let a=e.slice(r).trim();return a&&t.push(Ch(a)),t.length>0?t:[Ch(e)]}function Ch(e){let t=Xa(e);return{code:Dh(e,t),fenced:!1,language:t}}function wh(e){let t=e.toLowerCase(),n=xh[t]??t;return Object.hasOwn(_h,n)?n:`markdown`}function Th(e){return Xa(e)===`json`?`json`:vh.test(e)?`tsx`:yh.test(e)?`python`:bh.test(e)?`shellscript`:`markdown`}function Eh(e,t){return t===0?e:e.split(`
|
|
11
|
-
`).map(e=>{let n=e.length-e.trimStart().length;return e.slice(Math.min(t,n))}).join(`
|
|
12
|
-
`)}function Dh(e,t){return t===`json`?ga(e)??e:e}function Oh({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:/* @__PURE__ */ (0,Y.jsx)(`table`,{"data-slot":`table`,className:F(`w-full border-collapse text-left text-sm`,e),...t})})}function kh({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`thead`,{"data-slot":`table-header`,className:F(`[&_tr]:hover:bg-transparent`,e),...t})}function Ah({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`tbody`,{"data-slot":`table-body`,className:F(`[&_tr:last-child]:border-0`,e),...t})}function jh({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`tfoot`,{"data-slot":`table-footer`,className:F(`border-t border-dashboard-border font-medium [&>tr]:last:border-b-0`,e),...t})}function Mh({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`tr`,{"data-slot":`table-row`,className:F(`border-b border-dashboard-border-subtle transition-colors hover:bg-dashboard-fill-soft has-aria-expanded:bg-dashboard-fill-soft data-[state=selected]:bg-dashboard-surface-active`,e),...t})}function Nh({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`th`,{"data-slot":`table-head`,className:F(`px-2 py-2.5 text-left align-middle font-sans text-xs font-medium whitespace-nowrap text-dashboard-text-muted [&:has([role=checkbox])]:pr-0`,e),...t})}function Ph({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`td`,{"data-slot":`table-cell`,className:F(`p-2 align-middle whitespace-nowrap text-dashboard-text [&:has([role=checkbox])]:pr-0`,e),...t})}const Fh=`font-medium text-dashboard-accent-text underline decoration-dashboard-accent/35 underline-offset-2 transition-colors hover:text-dashboard-text hover:decoration-dashboard-text-solid`;function Ih(e){let t=e.trim(),n=[...t].some(e=>{let t=e.charCodeAt(0);return t<32||t===127});if(!(!t||n||/\s/.test(t)))try{let e=new URL(t);return e.protocol===`http:`||e.protocol===`https:`||e.protocol===`mailto:`?t:void 0}catch{return}}const Lh=/<((?:https?|mailto):[^\s|<>]+)(?:\|([^<>]*))?>/g;function Rh(e){return e.replace(Lh,(e,t,n)=>n?.trim()?`[${n.trim()}](${t})`:e)}const zh=D,Bh=/:([a-z0-9_+-]+):(?::(skin-tone-[2-6]):)?/g,Vh=65039;function Hh(e){return e.split(`-`).map(e=>Number.parseInt(e,16))}const Uh=/* @__PURE__ */ new Map;for(let[e,t]of Object.entries(zh)){let n=Hh(e);for(let e of typeof t==`string`?[t]:t)Uh.set(e,n)}function Wh(e,t){let n=Uh.get(e);if(!n)return``;let[r,...i]=n,a=t?Uh.get(t)?.[0]:void 0;if(a!==void 0){let e=i[0]===Vh?i.slice(1):i;return String.fromCodePoint(r,a,...e)}return i.length===0&&r<126976?String.fromCodePoint(r,Vh):String.fromCodePoint(...n)}function Gh(e){return e.includes(`:`)?e.replace(Bh,(e,t,n)=>Wh(t,n)||e):e}const Kh=/<([@#])([A-Z0-9]+)(?:\|([^<>]*))?>/g,qh=(0,J.createContext)({links:!0,people:/* @__PURE__ */ new Map});function Jh(e){return/* @__PURE__ */ (0,Y.jsx)(qh.Provider,{value:{links:e.links,people:Zh(e.mentions)},children:e.children})}function Yh(e,t){let n=[],r=0;for(let i of $h(e))i.start>r&&n.push(/* @__PURE__ */ (0,Y.jsx)(Q,{text:Gh(e.slice(r,i.start))},`${t}-m-${r}`)),n.push(/* @__PURE__ */ (0,Y.jsx)(eg,{mention:i},`${t}-m-${i.start}`)),r=i.end;return r<e.length&&n.push(/* @__PURE__ */ (0,Y.jsx)(Q,{text:Gh(e.slice(r))},`${t}-m-${r}`)),n}function Xh(e,t){let n=Zh(t),r=``,i=0;for(let t of $h(e))r+=Gh(e.slice(i,t.start)),r+=Qh(t,n),i=t.end;return r+Gh(e.slice(i))}function Zh(e){let t=/* @__PURE__ */ new Map;for(let n of e)n.slackUserId&&t.set(n.slackUserId,n);return t}function Qh(e,t){let{id:n,label:r,sigil:i}=e,a=i===`@`?t.get(n):void 0;return`${i}${(a?.fullName??a?.slackUserName??r??n).replace(/^[@#]/,``)}`}function $h(e){return[...e.matchAll(Kh)].map(e=>({end:e.index+e[0].length,id:e[2],label:e[3]?.trim()||void 0,sigil:e[1],start:e.index}))}function eg(e){let{links:t,people:n}=(0,J.useContext)(qh),{id:r,sigil:i}=e.mention,a=i===`@`?n.get(r):void 0,o=/* @__PURE__ */ (0,Y.jsx)(Q,{text:Qh(e.mention,n)});return t&&a?.email?/* @__PURE__ */ (0,Y.jsx)(V,{className:K(`pointer-events-auto`,Fh),title:r,to:Ua(a.email),children:o}):/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-medium text-dashboard-accent-text`,title:r,children:o})}function tg(e){if(!e.text.trim())return null;let t=e.document?e.text:ng(Rh(e.text));return e.inline?/* @__PURE__ */ (0,Y.jsx)(y,{components:pg,remarkPlugins:[g],urlTransform:Ih,children:t}):/* @__PURE__ */ (0,Y.jsx)(`div`,{className:K(`min-w-0 break-words text-dashboard-text [overflow-wrap:anywhere]`,e.chat?`font-sans text-base leading-relaxed`:`font-sans text-sm leading-6`,!e.chat&&!e.compact&&`md:leading-7`),children:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:K(`grid min-w-0`,e.chat?`gap-3`:`gap-2`),children:/* @__PURE__ */ (0,Y.jsx)(y,{components:cg,remarkPlugins:e.document?[g]:[g,ne,rg,ag],urlTransform:Ih,children:t})})})}function ng(e){return e.replace(/^([ \t]*)[•◦](?=[ \t])/gm,`$1-`)}function rg(){return(e,t)=>{ig(e,String(t.value))}}function ig(e,t){e.children=e.children?.flatMap(e=>{ig(e,t);let n=e.children?.[0],r=e.url?.indexOf(`*`)??-1;if(e.type!==`link`||e.children?.length!==1||n?.value!==e.url||t[e.position?.start.offset??-1]===`<`||r<=0)return[e];let i=e.url.slice(0,r);return[{...e,children:[{type:`text`,value:i}],url:i},{type:`text`,value:e.url.slice(r)}]})}function ag(){return e=>{e.children=e.children?.flatMap(og)}}function og(e){let[t,...n]=e.children??[];if(e.type!==`paragraph`||t?.type!==`strong`)return[e];let r=n[0]?.type===`text`&&n[0].value===`:`,i=r?n.slice(1):n;if(i.length>0&&i[0]?.type!==`break`)return[e];let a={children:r?[t,n[0]]:[t],depth:3,type:`heading`},o=i.slice(1);return o.length>0?[a,{children:o,type:`paragraph`}]:[a]}const sg=`m-0 min-w-0 font-semibold tracking-[-0.01em] text-dashboard-text [&:not(:first-child)]:mt-1 [&+*]:-mt-1`,cg={a:({children:e,href:t})=>/* @__PURE__ */ (0,Y.jsx)(hg,{href:t,children:e}),blockquote:({children:e})=>/* @__PURE__ */ (0,Y.jsx)(`blockquote`,{className:`m-0 grid min-w-0 gap-2 border-l-2 border-dashboard-border pl-3 text-dashboard-text-muted`,children:e}),code:({children:e})=>/* @__PURE__ */ (0,Y.jsx)(`code`,{className:`rounded-[0.25rem] bg-dashboard-fill-strong px-1 py-0.5 font-mono text-[0.9em] text-dashboard-text`,children:J.Children.map(e,e=>typeof e==`string`?/* @__PURE__ */ (0,Y.jsx)(Q,{text:e}):e)}),del:({children:e})=>/* @__PURE__ */ (0,Y.jsx)(`del`,{className:`text-dashboard-text-muted`,children:lg(e)}),em:({children:e})=>/* @__PURE__ */ (0,Y.jsx)(`em`,{className:`italic text-dashboard-text`,children:lg(e)}),h1:({children:e})=>/* @__PURE__ */ (0,Y.jsx)(`h1`,{className:K(sg,`text-[1.05em]`),children:lg(e)}),h2:({children:e})=>/* @__PURE__ */ (0,Y.jsx)(`h2`,{className:K(sg,`text-[1.05em]`),children:lg(e)}),h3:({children:e})=>/* @__PURE__ */ (0,Y.jsx)(`h3`,{className:K(sg,`text-[1em]`),children:lg(e)}),h4:({children:e})=>/* @__PURE__ */ (0,Y.jsx)(`h4`,{className:K(sg,`text-[1em]`),children:lg(e)}),h5:({children:e})=>/* @__PURE__ */ (0,Y.jsx)(`h5`,{className:K(sg,`text-[1em]`),children:lg(e)}),h6:({children:e})=>/* @__PURE__ */ (0,Y.jsx)(`h6`,{className:K(sg,`text-[1em]`),children:lg(e)}),hr:()=>/* @__PURE__ */ (0,Y.jsx)(`hr`,{className:`m-0 w-full border-dashboard-border`}),img:({alt:e,src:t})=>/* @__PURE__ */ (0,Y.jsx)(hg,{href:typeof t==`string`?t:void 0,children:e||t}),li:({children:e,className:t})=>/* @__PURE__ */ (0,Y.jsx)(`li`,{className:K(`min-w-0 pl-1 [&>*+*]:mt-1.5`,t?.includes(`task-list-item`)&&`-ml-5 list-none`),children:lg(e)}),ol:({children:e,start:t})=>/* @__PURE__ */ (0,Y.jsx)(`ol`,{className:`m-0 grid min-w-0 list-outside list-decimal gap-1.5 pl-6 text-dashboard-text marker:text-dashboard-text-muted`,start:t,children:e}),p:({children:e})=>/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 min-w-0 whitespace-normal`,children:lg(e)}),pre:({children:e})=>/* @__PURE__ */ (0,Y.jsx)(`pre`,{className:`m-0 min-w-0 overflow-x-auto rounded-md border border-dashboard-border-subtle bg-dashboard-surface-panel px-3 py-2.5 font-mono text-sm [&>code]:bg-transparent [&>code]:p-0`,children:e}),strong:({children:e})=>/* @__PURE__ */ (0,Y.jsx)(`strong`,{className:`font-semibold text-dashboard-text`,children:lg(e)}),table:({children:e})=>/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`min-w-0 max-w-full overflow-hidden rounded-md border border-dashboard-border bg-dashboard-fill-faint`,children:/* @__PURE__ */ (0,Y.jsx)(Oh,{className:`w-max min-w-full`,children:e})}),tbody:({children:e})=>/* @__PURE__ */ (0,Y.jsx)(Ah,{children:e}),td:({children:e,style:t})=>/* @__PURE__ */ (0,Y.jsx)(Ph,{className:K(`px-2.5 py-1.5 align-top`,mg(t?.textAlign)),children:lg(e)}),th:({children:e,style:t})=>/* @__PURE__ */ (0,Y.jsx)(Nh,{className:K(`px-2.5 py-1.5`,mg(t?.textAlign)),scope:`col`,children:lg(e)}),thead:({children:e})=>/* @__PURE__ */ (0,Y.jsx)(kh,{className:`bg-dashboard-overlay-soft`,children:e}),tr:({children:e})=>/* @__PURE__ */ (0,Y.jsx)(Mh,{className:`[thead_&]:border-dashboard-border`,children:e}),ul:({children:e})=>/* @__PURE__ */ (0,Y.jsx)(`ul`,{className:`m-0 grid min-w-0 list-outside list-disc gap-1.5 pl-6 text-dashboard-text marker:text-dashboard-text-muted`,children:e})};function lg(e){return J.Children.map(e,(e,t)=>typeof e==`string`?Yh(e,`t-${t}`):e)}function ug(e){return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[lg(e.children),`
|
|
13
|
-
`]})}function dg(e){return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[lg(e.children),` `]})}function fg(e){return/* @__PURE__ */ (0,Y.jsx)(Y.Fragment,{children:e.children})}const pg={a:({children:e})=>/* @__PURE__ */ (0,Y.jsx)(Y.Fragment,{children:lg(e)}),blockquote:fg,code:cg.code,del:cg.del,em:cg.em,h1:ug,h2:ug,h3:ug,h4:ug,h5:ug,h6:ug,hr:()=>`
|
|
14
|
-
`,img:({alt:e})=>e??null,li:ug,ol:fg,p:ug,pre:fg,strong:cg.strong,table:fg,tbody:fg,td:dg,th:dg,thead:fg,tr:ug,ul:fg};function mg(e){if(e===`center`)return`text-center`;if(e===`right`)return`text-right`}function hg(e){if(!e.href)return/* @__PURE__ */ (0,Y.jsx)(Y.Fragment,{children:lg(e.children)});let t=typeof e.children==`string`?/* @__PURE__ */ (0,Y.jsx)(gg,{href:e.href,label:e.children}):e.children;return/^https?:/i.test(e.href)?/* @__PURE__ */ (0,Y.jsx)(tf,{className:Fh,href:e.href,children:t}):/* @__PURE__ */ (0,Y.jsx)(`a`,{className:Fh,href:e.href,children:t})}function gg(e){let t=sh(),n=t.active&&e.href.toLowerCase().includes(t.normalizedQuery),r=e.label.toLowerCase().includes(t.normalizedQuery);return n&&!r?/* @__PURE__ */ (0,Y.jsx)(`mark`,{className:`rounded-[2px] bg-amber-400/20 text-inherit not-italic`,title:`Matched URL: ${e.href}`,children:e.label}):/* @__PURE__ */ (0,Y.jsx)(Q,{text:e.label})}const _g=[],$=(0,J.memo)(function(e){return/* @__PURE__ */ (0,Y.jsx)(Jh,{links:e.links??!0,mentions:e.mentions??_g,children:e.inline?/* @__PURE__ */ (0,Y.jsx)(tg,{inline:!0,text:e.text}):e.document?/* @__PURE__ */ (0,Y.jsx)(tg,{document:!0,text:e.text}):/* @__PURE__ */ (0,Y.jsx)(vg,{chat:e.chat,compact:e.compact,text:e.text})})});function vg(e){return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`grid min-w-0 gap-2`,children:Sh(e.text).map((t,n)=>t.language===`markdown`&&!t.fenced?/* @__PURE__ */ (0,Y.jsx)(tg,{chat:e.chat,compact:e.compact,text:t.code},n):/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`group/code relative min-w-0 overflow-hidden rounded-md border border-dashboard-border-subtle bg-dashboard-surface-panel py-2.5 pl-3 pr-10`,"data-code-language":t.language===`markdown`?void 0:t.language,children:[/* @__PURE__ */ (0,Y.jsx)(mh,{code:t.code,language:t.language}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`absolute right-0.5 top-0.5 transition-opacity [@media(hover:hover)_and_(pointer:fine)]:opacity-0 [@media(hover:hover)_and_(pointer:fine)]:group-hover/code:opacity-100 [@media(hover:hover)_and_(pointer:fine)]:group-focus-within/code:opacity-100`,children:/* @__PURE__ */ (0,Y.jsx)(Yf,{getText:()=>t.code,label:`Copy code`})})]},n))})}function yg(e){return/* @__PURE__ */ (0,Y.jsxs)(`section`,{"aria-label":e.label,className:K(`grid min-w-0 border-dashboard-border-subtle`,e.flat?`gap-1.5 border-t px-1 pt-3 pb-1`:`gap-2.5 rounded-lg border bg-dashboard-surface-panel p-3`),children:[e.title?/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[/* @__PURE__ */ (0,Y.jsxs)(`h3`,{className:K(`m-0 flex min-w-0 items-center gap-1.5 break-words font-sans text-xs`,e.flat?`font-semibold text-dashboard-text`:`font-medium text-dashboard-text-muted`),children:[e.title,e.count?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-normal tabular-nums text-dashboard-text-faint`,children:e.count.toLocaleString(`en-US`)}):null]}),e.action]}):null,/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`min-w-0 break-words font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.children})]})}function bg(e){let[t,n]=(0,J.useState)(!1),r=e.items.length-3,i=t||r<=0?e.items:e.items.slice(0,3);return/* @__PURE__ */ (0,Y.jsxs)(`ul`,{className:`-mx-1.5 -mb-1.5 -mt-1 grid list-none gap-0.5 p-0`,children:[i.map(t=>/* @__PURE__ */ (0,Y.jsx)(`li`,{children:e.renderItem(t)},e.itemKey(t))),r>0?/* @__PURE__ */ (0,Y.jsx)(`li`,{children:/* @__PURE__ */ (0,Y.jsxs)(`button`,{"aria-expanded":t,className:`group flex min-h-8 w-full items-center gap-2.5 rounded-md px-1.5 py-1.5 text-left text-xs font-medium leading-4 text-dashboard-text-muted transition-colors hover:bg-dashboard-surface-hover hover:text-dashboard-text focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus`,onClick:()=>n(e=>!e),type:`button`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center`,children:/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,className:ia})}),t?`Show fewer`:`Show ${r} more`]})}):null]})}function xg(e){let t=e.href!==void 0||e.to!==void 0||e.onClick!==void 0||e.disclosure===!0,n=K(`grid w-full min-w-0 grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-x-2.5 gap-y-1 rounded-md px-1.5 py-1.5 text-left text-inherit no-underline`,t&&`group transition-colors hover:bg-dashboard-surface-hover focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus`),r=/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center text-dashboard-text-muted`,children:e.icon}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center text-sm font-medium leading-5 text-dashboard-text`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`truncate`,children:e.title}),e.href?/* @__PURE__ */ (0,Y.jsx)(ef,{}):null]}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`shrink-0 text-xs leading-5 tabular-nums text-dashboard-text-muted`,children:e.meta}),e.children]});return e.href?/* @__PURE__ */ (0,Y.jsx)(`a`,{className:n,href:e.href,rel:`noreferrer`,target:`_blank`,title:e.tooltip,children:r}):e.to?/* @__PURE__ */ (0,Y.jsx)(V,{className:n,title:e.tooltip,to:e.to,children:r}):e.onClick?/* @__PURE__ */ (0,Y.jsx)(`button`,{className:K(n,`cursor-pointer`),onClick:e.onClick,title:e.tooltip,type:`button`,children:r}):e.disclosure?/* @__PURE__ */ (0,Y.jsx)(rh,{className:n,title:e.tooltip,children:r}):/* @__PURE__ */ (0,Y.jsx)(`div`,{className:n,title:e.tooltip,children:r})}function Sg(e){return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:K(`col-start-2 col-end-4 min-w-0 text-xs leading-4 text-dashboard-text-muted`,e.className),children:e.children})}function Cg(e){return L({queryFn:({signal:t})=>G(ri,`/api/conversations/${encodeURIComponent(e)}/watches`,t),queryKey:rd(e,`watches`),retry:!1})}function wg(e){return/* @__PURE__ */ (0,Y.jsx)(bg,{itemKey:e=>e.id,items:e.watches,renderItem:e=>/* @__PURE__ */ (0,Y.jsx)(Eg,{watch:e})})}const Tg={channel:Vn,deployment:ln,deployment_source:ln,issue:Ft,pull_request:En,release_source:er,repository:qn,team:Tn,timer:ur,workspace_snapshot:nn};function Eg(e){let{watch:t}=e,n=t.redacted?Wt:Tg[t.resourceType]??Mn,r=`${t.namespace} ${t.resourceType.replaceAll(`_`,` `)}`,i=/* @__PURE__ */ (0,Y.jsx)(n,{"aria-hidden":`true`,className:`size-3.5`}),a=t.label??`Private ${r}`;return/* @__PURE__ */ (0,Y.jsxs)(nh,{className:`min-w-0`,children:[t.url?/* @__PURE__ */ (0,Y.jsx)(Dg,{label:a,children:/* @__PURE__ */ (0,Y.jsx)(xg,{href:t.url,icon:i,title:a})}):/* @__PURE__ */ (0,Y.jsx)(xg,{disclosure:!0,icon:i,meta:/* @__PURE__ */ (0,Y.jsx)(Og,{}),title:a}),/* @__PURE__ */ (0,Y.jsx)(kg,{watches:[t]})]})}function Dg(e){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 items-start gap-0.5`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:e.children}),/* @__PURE__ */ (0,Y.jsx)(rh,{"aria-label":`Details for ${e.label}`,className:`group grid size-8 shrink-0 place-items-center rounded-md text-dashboard-text-muted transition-colors hover:bg-dashboard-surface-hover hover:text-dashboard-text focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus`,children:/* @__PURE__ */ (0,Y.jsx)(Og,{})})]})}function Og(){return/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`grid size-5 place-items-center`,children:/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,className:ia})})}function kg(e){return/* @__PURE__ */ (0,Y.jsx)(ih,{className:`grid min-w-0 gap-3 pb-2 pl-9 pr-1.5 pt-0.5 text-xs leading-4 text-dashboard-text-muted`,children:e.watches.map(e=>/* @__PURE__ */ (0,Y.jsx)(Ag,{watch:e},e.id))})}function Ag(e){let{watch:t}=e,n=t.firesAt?[]:t.events,r=Object.entries(t.match??{});return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-1.5`,children:[t.intent?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 break-words`,children:/* @__PURE__ */ (0,Y.jsx)($,{inline:!0,text:t.intent})}):null,t.firesAt?/* @__PURE__ */ (0,Y.jsxs)(`p`,{className:`m-0`,children:[`Fires`,` `,/* @__PURE__ */ (0,Y.jsx)(`time`,{dateTime:t.firesAt,children:to(t.firesAt,{dateStyle:`medium`,timeStyle:`short`})})]}):null,n.length>0||r.length>0?/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[n.map(e=>/* @__PURE__ */ (0,Y.jsx)(jg,{children:Mg(e,t.resourceType)},e)),r.map(([e,t])=>/* @__PURE__ */ (0,Y.jsxs)(jg,{filter:!0,children:[e.replaceAll(`_`,` `),`: `,[t].flat().join(`, `)]},`match:${e}`))]}):null,t.childAgent?/* @__PURE__ */ (0,Y.jsxs)(`p`,{className:`m-0 flex min-w-0 items-center gap-1`,children:[/* @__PURE__ */ (0,Y.jsx)(mn,{"aria-hidden":`true`,className:`size-3 shrink-0`}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`truncate`,children:[`via `,t.childAgent.name??`child conversation`]})]}):null]})}function jg(e){return/* @__PURE__ */ (0,Y.jsx)(`span`,{className:e.filter?`min-w-0 truncate rounded-md border border-dashed border-dashboard-border px-1.5 py-px text-xs leading-4 text-dashboard-text-muted`:`min-w-0 truncate rounded-md bg-dashboard-fill-soft px-1.5 py-px text-xs leading-4 text-dashboard-text-subtle`,children:e.children})}function Mg(e,t){let n=e.split(`.`);return(n[0]===t&&n.length>1?n.slice(1):n).join(` `).replaceAll(`_`,` `)}const Ng={closed:`Closed`,draft:`Draft`,merged:`Merged`,open:`Open`,warning:`Needs attention`};function Pg(e){return e?Ng[e]??e.charAt(0).toUpperCase()+e.slice(1):``}function Fg(e){return(e?.annotations??[]).flatMap(t=>{if(!t.url)return[];let n=e?.sidebarAnnotations?.find(e=>e.key===t.key),r=t.objectType??n?.objectType??`item`,i=t.kind===`object`?t.title===t.label?t.description:t.title:t.description;return[{...i?{description:i}:void 0,...t.kind===`object`&&t.facts?{facts:t.facts}:void 0,key:`${t.plugin}:${t.key}`,label:t.label,objectType:r,plugin:t.plugin,...n?{shortLabel:n.label}:void 0,...t.status?{status:t.status}:void 0,url:t.url}]})}function Ig(e){return/* @__PURE__ */ (0,Y.jsx)(bg,{itemKey:e=>e.key,items:e.links,renderItem:t=>{let n=/* @__PURE__ */ (0,Y.jsx)(Rg,{link:t}),r=e.watchesByUrl.get(t.url);return r?/* @__PURE__ */ (0,Y.jsxs)(nh,{className:`min-w-0`,children:[/* @__PURE__ */ (0,Y.jsx)(Dg,{label:t.label,children:n}),/* @__PURE__ */ (0,Y.jsx)(kg,{watches:r})]}):e.watchesByUrl.size>0?/* @__PURE__ */ (0,Y.jsx)(Lg,{children:n}):n}})}function Lg(e){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 items-start gap-0.5`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:e.children}),/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`size-8 shrink-0`})]})}function Rg(e){let{link:t}=e,n=Pg(t.status),r=/* @__PURE__ */ (0,Y.jsx)(th,{decorative:!0,facts:t.facts,objectType:t.objectType,size:14,status:t.status});return/* @__PURE__ */ (0,Y.jsx)(xg,{href:t.url,icon:n?/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[/* @__PURE__ */ (0,Y.jsx)(W,{render:/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-label":n,className:`inline-flex`,role:`img`,children:r})}),/* @__PURE__ */ (0,Y.jsx)(Cr,{size:`compact`,children:n})]}):r,title:t.label,tooltip:[t.label,t.plugin,n,t.description].filter(Boolean).join(` · `),children:t.description?/* @__PURE__ */ (0,Y.jsx)(Sg,{className:`line-clamp-2 break-words`,children:t.description}):null})}function zg(e){return/* @__PURE__ */ (0,Y.jsx)(`svg`,{"aria-label":`GitHub`,className:e.className,fill:`currentColor`,role:`img`,viewBox:`0 0 24 24`,children:/* @__PURE__ */ (0,Y.jsx)(`path`,{d:`M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12`})})}function Bg(e){let t=new URL(e);if(t.origin!==`https://github.com`)return;let[,n,r]=t.pathname.split(`/`);if(n&&r)return{label:`${n}/${r}`,href:`${t.origin}/${n}/${r}`}}function Vg(e){let t;for(let n of e??[]){if(n.plugin!==`github`||!n.url)continue;let e=Bg(n.url);if(e){if(t&&t.href.toLowerCase()!==e.href.toLowerCase())return;t??=e}}return t}function Hg(e){let t=K(`group/context-tag inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-dashboard-border-subtle px-1.5 font-sans text-2xs font-medium text-dashboard-text-muted`,e.className),n=/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[e.icon,/* @__PURE__ */ (0,Y.jsx)(`span`,{className:e.detail?`shrink-0`:`truncate`,children:e.label}),e.detail?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`truncate font-normal text-dashboard-text`,children:e.detail}):null]});return e.href?/* @__PURE__ */ (0,Y.jsx)(tf,{className:K(t,`no-underline transition-colors hover:border-dashboard-border-strong hover:bg-dashboard-fill-soft hover:text-dashboard-text focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-dashboard-focus`),href:e.href,title:e.title??e.label,children:n}):/* @__PURE__ */ (0,Y.jsx)(`span`,{className:t,title:e.label,children:n})}function Ug(e){let t=Ha(e.conversation,{includeId:!1});return t?/* @__PURE__ */ (0,Y.jsx)(Hg,{className:e.className,href:e.conversation.locationUrl,icon:/* @__PURE__ */ (0,Y.jsx)(Xf,{className:`size-3 shrink-0 group-hover/context-tag:[&>path]:fill-(--slack-mark-color) group-focus-visible/context-tag:[&>path]:fill-(--slack-mark-color)`}),label:t,title:`Open ${t} in Slack`}):null}function Wg(e,t){let n=Ha(e,{includeId:!1}),r=!!n&&n!==t,i=Fg(e);return!r&&i.length===0?null:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[r?/* @__PURE__ */ (0,Y.jsx)(Ug,{className:`max-w-40 shrink-0`,conversation:e}):null,i.slice(0,2).map((e,t)=>/* @__PURE__ */ (0,Y.jsx)(Hg,{className:K(`max-w-96`,t>0&&`max-sm:hidden`),detail:e.description,href:e.url,icon:/* @__PURE__ */ (0,Y.jsx)(th,{decorative:!0,facts:e.facts,objectType:e.objectType,size:12,status:e.status}),label:e.description&&e.shortLabel||e.label,title:[e.label,Pg(e.status),e.description].filter(Boolean).join(` · `)},e.key)),/* @__PURE__ */ (0,Y.jsx)(Gg,{className:`sm:hidden`,count:i.length-1}),/* @__PURE__ */ (0,Y.jsx)(Gg,{className:`max-sm:hidden`,count:i.length-2})]})}function Gg(e){return e.count<=0?null:/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:K(`shrink-0 font-sans text-2xs tabular-nums text-dashboard-text-muted`,e.className),children:[`+`,e.count]})}function Kg(e){let t=e&&Ha(e,{includeId:!1}),n=Vg(e?.annotations);return!t&&!n?null:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[t&&e?/* @__PURE__ */ (0,Y.jsx)(Ug,{conversation:e}):null,n?/* @__PURE__ */ (0,Y.jsx)(Hg,{...n,icon:/* @__PURE__ */ (0,Y.jsx)(zg,{className:`size-3 shrink-0 transition-colors group-hover/context-tag:text-dashboard-text-solid group-focus-visible/context-tag:text-dashboard-text-solid`})}):null]})}function qg(e){return e.waitingOnViewer?/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-label":`Waiting on you`,className:`size-2 shrink-0 rounded-full bg-violet-300 shadow-[0_0_6px_rgba(196,181,253,0.7)]`,role:`img`}):e.status===`active`?/* @__PURE__ */ (0,Y.jsx)(_p,{"aria-label":`Running`,className:`size-3 text-emerald-300`}):e.unread?/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-label":`Unread`,className:`size-1.5 shrink-0 rounded-full bg-orange-300`,role:`img`}):e.isPrivate?/* @__PURE__ */ (0,Y.jsx)(Wt,{"aria-label":`Private conversation`,className:K(`size-3 shrink-0`,e.status===`failed`&&`text-rose-300`,(e.status===`idle`||e.status===`stopped`)&&`text-dashboard-text-muted`)}):e.status===`stopped`?/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-label":`Stopped`,className:`size-1.5 shrink-0 bg-dashboard-text-muted`,role:`img`}):e.status===`failed`?/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-label":`Failed`,className:`size-1.5 shrink-0 rounded-full bg-rose-300`,role:`img`}):/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 shrink-0 rounded-full bg-dashboard-text-faint`})}function Jg(e){let{collapsedKeys:t,toggle:n}=mm(),{showActionError:r,showArchiveError:i,showArchived:a}=zd(),o=(0,J.useCallback)(e=>r(e,`Could not reorder`),[r]);if(e.loading&&e.conversations.length===0)return/* @__PURE__ */ (0,Y.jsx)(Yg,{label:`Loading conversations`});if(e.conversations.length===0)return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`rounded-lg border border-dashboard-border-subtle bg-dashboard-fill-faint p-4`,children:/* @__PURE__ */ (0,Y.jsx)(xm,{children:e.emptyLabel??`No conversations match this view.`})});let s=gc(e.conversations,{attentionIds:vc(e.conversations,e.waitingConversationIds),nowMs:Date.now(),timeZone:e.timeZone}),c=s.find(e=>e.key===`pinned`);return/* @__PURE__ */ (0,Y.jsx)(rp,{conversations:c?.conversations??[],onError:o,reorder:e.onReorderPins,children:/* @__PURE__ */ (0,Y.jsx)(`div`,{"aria-label":`Your conversations`,className:`grid gap-5`,role:`list`,children:s.map(r=>/* @__PURE__ */ (0,Y.jsx)(Zg,{collapsed:t.has(r.key),onArchiveError:i,onArchived:a,onToggle:()=>n(r.key),waitingConversationIds:e.waitingConversationIds,section:r},r.key))})})}function Yg(e){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{"aria-busy":e.label?`true`:void 0,"aria-live":e.label?`polite`:void 0,className:`grid gap-5`,role:e.label?`status`:void 0,children:[e.label?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`sr-only`,children:e.label}):null,[3,2].map((e,t)=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{children:[/* @__PURE__ */ (0,Y.jsx)(q,{className:K(`mb-2 ml-1 h-3`,t===0?`w-16`:`w-12`)}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`grid gap-2`,children:Array.from({length:e},(e,n)=>/* @__PURE__ */ (0,Y.jsx)(Xg,{index:n+t*3},n))})]},e))]})}function Xg(e){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-3 rounded-lg border border-dashboard-border-subtle bg-dashboard-fill-faint px-3 py-2.5 sm:px-4`,children:[/* @__PURE__ */ (0,Y.jsx)(q,{className:`mt-0.5 size-8 rounded-md`}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`flex h-6 min-w-0 flex-1 items-center`,children:/* @__PURE__ */ (0,Y.jsx)(q,{className:K(`h-3.5`,e.index%2==0?`w-56 max-w-4/5`:`w-44 max-w-3/5`)})}),/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-3 w-14 opacity-70`}),/* @__PURE__ */ (0,Y.jsx)(q,{className:`size-4`})]}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`flex h-5 min-w-0 items-center`,children:/* @__PURE__ */ (0,Y.jsx)(q,{className:K(`h-3 opacity-70`,e.index%2==0?`w-full max-w-xl`:`w-1/2 max-w-md`)})}),/* @__PURE__ */ (0,Y.jsx)(q,{className:`mt-1 h-6 w-28 rounded-md opacity-70`})]})]})}function Zg(e){return/* @__PURE__ */ (0,Y.jsxs)(`section`,{"aria-labelledby":`conversation-section-${e.section.key}`,children:[/* @__PURE__ */ (0,Y.jsx)(pp,{className:K(`sticky top-0 z-10 -mx-1 bg-dashboard-bg px-2 py-1.5`,!e.collapsed&&`mb-0.5`),collapsed:e.collapsed,count:e.section.conversations.length,id:`conversation-section-${e.section.key}`,label:e.section.label,onToggle:e.onToggle}),e.collapsed?null:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`grid gap-2`,children:e.section.conversations.map(t=>{let n={conversation:t,onArchiveError:e.onArchiveError,onArchived:e.onArchived,waitingOnViewer:e.waitingConversationIds.has(t.id)};return t.pinnedAt?/* @__PURE__ */ (0,J.createElement)(Qg,{...n,key:t.id}):/* @__PURE__ */ (0,J.createElement)($g,{...n,key:t.id})})})]})}function Qg(e){let t=ip(e.conversation.id);return/* @__PURE__ */ (0,Y.jsx)($g,{...e,drag:t})}function $g(e){let t=e.conversation,n=e.drag,r=jd(t.id,{onError:()=>e.onArchiveError(t,r.variables?.archived??!0),onSuccess:n=>{n&&e.onArchived(t)}}),i=Sa(t),a=Fa(t),o=Qm(t),s=t.visibility===`private`,c=Wg(t,a),l=om(t.id),u=s?Wt:Ot,d=!!t.unread,f=e.waitingOnViewer||d||i===`active`||i===`failed`;return/* @__PURE__ */ (0,Y.jsxs)(`article`,{...l,...n?.listeners,className:K(`group relative grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-3 rounded-lg border border-dashboard-border-subtle bg-dashboard-fill-faint px-3 py-2.5 transition-[background-color,border-color,scale] duration-100 ease-out hover:border-dashboard-border hover:bg-dashboard-fill-soft has-[>a:active]:scale-[0.99] has-[>a:active]:bg-dashboard-fill-soft motion-reduce:has-[>a:active]:scale-100 sm:px-4`,n?.dragging&&`opacity-40`),onKeyDown:n?.onKeyDown,ref:n?.setNodeRef,role:`listitem`,children:[/* @__PURE__ */ (0,Y.jsx)(V,{"aria-keyshortcuts":n?`Alt+ArrowUp Alt+ArrowDown`:void 0,"aria-label":`Open ${a}`,className:K(`absolute inset-0 z-0 rounded-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-dashboard-focus`,n&&`[-webkit-touch-callout:none]`),draggable:!n&&void 0,to:kc(t.id)}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`pointer-events-none relative z-[1] mt-0.5 grid size-8 place-items-center rounded-md border border-dashboard-border-subtle bg-dashboard-surface-panel text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,Y.jsx)(u,{"aria-label":s?`Private conversation`:`Public conversation`,role:`img`,size:15}),f?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`absolute -bottom-1 -right-1 grid size-3.5 place-items-center rounded-full bg-dashboard-surface-panel`,children:/* @__PURE__ */ (0,Y.jsx)(qg,{isPrivate:!1,status:i,unread:d,waitingOnViewer:e.waitingOnViewer})}):null]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[/* @__PURE__ */ (0,Y.jsx)(`h4`,{className:`pointer-events-none relative z-[1] m-0 min-w-0 flex-1 truncate font-display text-sm font-medium leading-6 text-dashboard-text`,children:a}),o.length>0?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`pointer-events-none relative z-[1] hidden sm:inline-flex`,children:/* @__PURE__ */ (0,Y.jsx)($m,{participants:o,size:`list`})}):null,i===`active`?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`pointer-events-none relative z-[1] flex min-w-14 justify-end`,children:/* @__PURE__ */ (0,Y.jsx)(_p,{"aria-label":`Running`,className:`size-3.5 text-dashboard-text-muted`})}):/* @__PURE__ */ (0,Y.jsx)(`time`,{className:`pointer-events-none relative z-[1] min-w-14 whitespace-nowrap text-right font-sans text-xs tabular-nums text-dashboard-text-muted`,dateTime:t.lastSeenAt,title:to(t.lastSeenAt,{dateStyle:`medium`,timeStyle:`short`}),children:Oc(t.lastSeenAt)}),/* @__PURE__ */ (0,Y.jsx)(`button`,{"aria-label":`${t.archivedAt?`Restore`:`Archive`} ${a}`,className:`relative z-[1] shrink-0 cursor-pointer border-0 bg-transparent p-0 text-dashboard-text-muted transition before:absolute before:-inset-2 hover:text-dashboard-text focus:outline-none focus:ring-2 focus:ring-dashboard-focus focus:ring-offset-2 focus:ring-offset-dashboard-canvas disabled:cursor-not-allowed disabled:opacity-50`,disabled:r.isPending,onClick:()=>r.mutate({archived:!t.archivedAt,lastSeenAt:t.lastSeenAt}),type:`button`,children:t.archivedAt?/* @__PURE__ */ (0,Y.jsx)(vn,{"aria-hidden":`true`,size:15}):/* @__PURE__ */ (0,Y.jsx)(bn,{"aria-hidden":`true`,size:15})})]}),t.activityPreview||i===`active`?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:K(`pointer-events-none relative z-[1] m-0 min-w-0 truncate font-sans text-sm leading-5`,t.activityPreview?`text-dashboard-text-subtle`:`text-dashboard-text-muted`),children:t.activityPreview?/* @__PURE__ */ (0,Y.jsx)($,{inline:!0,mentions:t.activityPreview.mentions,text:t.activityPreview.text}):`Working…`}):null,c?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`pointer-events-none relative z-[1] mt-1 min-w-0 overflow-hidden [&_a]:pointer-events-auto`,children:c}):null]})]})}function e_(e){return!e.defaultPrevented&&e.button===0&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey}function t_(e,t){return e.src===t.src&&e.filename===t.filename}function n_(e){let[t,n]=(0,J.useState)(!1),{context:r,filename:i,gallery:a,imageClassName:o,src:s,triggerClassName:c,...l}=e,u={context:r,filename:i,src:s},d=a?.findIndex(e=>t_(e,u))??-1;return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`a`,{className:c,href:s,onClick:e=>{e_(e)&&(e.preventDefault(),n(!0))},rel:`noreferrer`,target:`_blank`,children:/* @__PURE__ */ (0,Y.jsx)(`img`,{...l,alt:i,className:o,src:s})}),t?/* @__PURE__ */ (0,Y.jsx)(i_,{images:a&&d>=0?a:[u],initialIndex:Math.max(d,0),onClose:()=>n(!1)}):null]})}const r_=`h-10 w-10 border-0 bg-transparent p-0 text-dashboard-text-muted hover:bg-dashboard-fill-hover hover:text-dashboard-text`;function i_(e){let t=Pl(e.onClose),n=(0,J.useRef)(null),[r,i]=(0,J.useState)(e.images[e.initialIndex]),a=e.images.length,o=Math.max(e.images.findIndex(e=>t_(e,r)),0),s=e.images[o],c=t=>i(e.images[(t+a)%a]);return/* @__PURE__ */ (0,Y.jsx)(il,{...t.rootProps,actionsRef:n,children:/* @__PURE__ */ (0,Y.jsx)(ol,{...t.contentProps,className:`top-0 left-0 h-dvh w-screen max-w-none translate-x-0 translate-y-0 gap-0 overflow-hidden rounded-none border-0 bg-dashboard-ink p-0 shadow-none max-h-none sm:top-0 sm:translate-y-0 md:top-1/2 md:left-1/2 md:h-[min(90dvh,960px)] md:w-[min(92vw,1440px)] md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-lg md:border`,onKeyDown:e=>{if(!(a<2)){if(e.key===`ArrowLeft`)c(o-1);else if(e.key===`ArrowRight`)c(o+1);else return;e.preventDefault()}},children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid h-full min-h-0 grid-rows-[auto_minmax(0,1fr)] bg-dashboard-bg-elevated`,children:[/* @__PURE__ */ (0,Y.jsxs)(`header`,{className:`grid grid-cols-[minmax(0,1fr)_auto_auto_auto] items-center gap-1.5 border-b border-dashboard-border-strong bg-dashboard-surface-raised px-3 py-2 pt-[max(0.5rem,env(safe-area-inset-top))] md:px-4`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,Y.jsx)(sl,{className:`truncate font-mono text-xs leading-normal font-normal`,children:s.filename}),s.context?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`truncate font-mono text-2xs text-dashboard-text-muted`,children:s.context}):null]}),a>1?/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[/* @__PURE__ */ (0,Y.jsx)(H,{"aria-label":`Previous image`,className:r_,onClick:()=>c(o-1),children:/* @__PURE__ */ (0,Y.jsx)(Lt,{"aria-hidden":`true`,size:16})}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`min-w-12 text-center font-mono text-xs text-dashboard-text-muted tabular-nums`,children:[o+1,` of `,a]}),/* @__PURE__ */ (0,Y.jsx)(H,{"aria-label":`Next image`,className:r_,onClick:()=>c(o+1),children:/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,size:16})})]}):/* @__PURE__ */ (0,Y.jsx)(`span`,{}),/* @__PURE__ */ (0,Y.jsxs)(`a`,{className:`inline-flex min-h-10 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium text-dashboard-text-muted no-underline transition-colors hover:bg-dashboard-fill-hover hover:text-dashboard-text`,href:s.src,rel:`noreferrer`,target:`_blank`,children:[/* @__PURE__ */ (0,Y.jsx)(Fn,{"aria-hidden":`true`,size:14}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`max-sm:sr-only`,children:`Open raw file`})]}),/* @__PURE__ */ (0,Y.jsxs)(al,{render:/* @__PURE__ */ (0,Y.jsx)(H,{className:`h-10 gap-1.5 border-0 bg-transparent px-2.5 text-xs text-dashboard-text-muted hover:bg-dashboard-fill-hover hover:text-dashboard-text`}),children:[/* @__PURE__ */ (0,Y.jsx)(Xn,{"aria-hidden":`true`,size:16}),/* @__PURE__ */ (0,Y.jsx)(`span`,{children:`Close`})]})]}),/* @__PURE__ */ (0,Y.jsx)(o_,{alt:s.filename,onSwipe:e=>{e===`dismiss`?n.current?.close():c(o+(e===`next`?1:-1))},pageable:a>1,src:s.src},`${s.src}\n${s.filename}`)]})})})}const a_={scale:1,x:0,y:0};function o_(e){let[t,n]=(0,J.useState)(a_),[r,i]=(0,J.useState)(),a=(0,J.useRef)(null),o=(0,J.useRef)(/* @__PURE__ */ new Map),s=(0,J.useRef)(void 0),c=(0,J.useRef)(void 0),l=(0,J.useRef)(0),u=e=>{let n=[...o.current.values()],r=a.current.getBoundingClientRect();s.current={center:{x:r.left+r.width/2-t.x,y:r.top+r.height/2-t.y},distance:d_(n),start:u_(n),zoom:e}},d=e=>{if(e.pointerType===`mouse`)return;e.currentTarget.setPointerCapture(e.pointerId);let d={x:e.clientX,y:e.clientY};if(o.current.set(e.pointerId,d),c.current=o.current.size>1?`none`:void 0,r&&i(void 0),o.current.size===1&&e.timeStamp-l.current<300){l.current=0,u(t);let e=t.scale>1?a_:l_(s.current,d,2.5,a.current);n(e),u(e)}else o.current.size===1&&(l.current=e.timeStamp),u(t)},f=t=>{let r=s.current;if(!r||!o.current.has(t.pointerId))return;o.current.set(t.pointerId,{x:t.clientX,y:t.clientY});let u=[...o.current.values()];if(u.length===1&&r.zoom.scale===1&&c.current!==`none`){let t=u[0].x-r.start.x,n=u[0].y-r.start.y,a=c.current??s_(t,n,e.pageable);c.current=a,(a===`x`||a===`y`)&&(l.current=0,i({axis:a,offset:a===`x`?t:Math.max(n,0)}));return}let d=u.length>1&&r.distance>0?r.zoom.scale*d_(u)/r.distance:r.zoom.scale;n(l_(r,u_(u),d,a.current))},p=a=>{if(!o.current.delete(a.pointerId))return;if(r&&!r.settling){let t=a.type===`pointerup`?c_(r):void 0;t?e.onSwipe(t):i({...r,offset:0,settling:!0})}let c=t.scale<1.05?a_:t;c!==t&&n(c),o.current.size>0?u(c):s.current=void 0};return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`grid min-h-0 touch-none place-items-center overflow-hidden p-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] md:p-6`,onPointerCancel:p,onPointerDown:d,onPointerMove:f,onPointerUp:p,children:/* @__PURE__ */ (0,Y.jsx)(`img`,{alt:e.alt,className:`max-h-full max-w-full object-contain select-none ${r?.settling?`transition-[opacity,transform] duration-180 ease-out motion-reduce:transition-none`:``}`,draggable:!1,onTransitionEnd:()=>{r?.settling&&i(void 0)},ref:a,src:e.src,style:r?{opacity:r.axis===`y`?1-.6*Math.min(r.offset/320,1):void 0,transform:r.axis===`x`?`translateX(${r.offset}px)`:`translateY(${r.offset}px)`}:{transform:`translate(${t.x}px, ${t.y}px) scale(${t.scale})`}})})}function s_(e,t,n){if(!(Math.hypot(e,t)<10))return Math.abs(e)>Math.abs(t)?n?`x`:`none`:t>0?`y`:`none`}function c_(e){if(!(Math.abs(e.offset)<64))return e.axis===`y`?`dismiss`:e.offset<0?`next`:`previous`}function l_(e,t,n,r){let i=f_(n,1,4),a=i/e.zoom.scale,o=t.x-e.center.x-a*(e.start.x-e.center.x-e.zoom.x),s=t.y-e.center.y-a*(e.start.y-e.center.y-e.zoom.y),c=(i-1)*r.offsetWidth/2,l=(i-1)*r.offsetHeight/2;return{scale:i,x:f_(o,-c,c),y:f_(s,-l,l)}}function u_(e){let t=e.reduce((e,t)=>e+t.x,0),n=e.reduce((e,t)=>e+t.y,0);return{x:t/e.length,y:n/e.length}}function d_(e){let[t,n]=e;return!t||!n?0:Math.hypot(n.x-t.x,n.y-t.y)}function f_(e,t,n){return Math.min(Math.max(e,t),n)}const p_=(0,J.lazy)(()=>import(`./chunks/DrawerContent-ovjgr16m.js`).then(e=>({default:e.DrawerContent})));function m_(e){return/* @__PURE__ */ (0,Y.jsx)(J.Suspense,{fallback:null,children:/* @__PURE__ */ (0,Y.jsx)(p_,{...e},e.openKey)})}function h_(e){return/* @__PURE__ */ (0,Y.jsx)(_s,{className:K(`block rounded-none border-0 bg-transparent p-0 text-rose-300`,e.className),variant:`destructive`,children:e.children})}const g_=524288,__={htm:`html`,md:`markdown`,ndjson:`jsonl`},v_=/* @__PURE__ */ new Set([`conf`,`diff`,`env`,`go`,`ini`,`log`,`patch`,`rb`,`rs`,`text`,`toml`,`txt`]),y_={"application/javascript":`javascript`,"application/json":`json`,"application/toml":`plain`,"application/x-ndjson":`jsonl`,"application/x-sh":`shellscript`,"application/x-yaml":`yaml`,"application/xml":`xml`,"application/yaml":`yaml`},b_={"text/css":`css`,"text/csv":`csv`,"text/html":`html`,"text/javascript":`javascript`,"text/markdown":`markdown`,"text/xml":`xml`,"text/yaml":`yaml`};function x_(e){let t=e.lastIndexOf(`.`);if(t<0)return;let n=e.slice(t+1).toLowerCase();if(v_.has(n))return`plain`;let r=__[n]??n;return Object.hasOwn(_h,r)?r:void 0}function S_(e){let t=e.split(`;`,1)[0]?.trim().toLowerCase()??``;if(t in y_)return y_[t];if(t.startsWith(`text/`))return b_[t]??`plain`}function C_(e){return x_(e.filename)??S_(e.contentType)}function w_(e,t){if(!e.includes(0))return new TextDecoder().decode(e,{stream:t})}const T_=[`w-3/4`,`w-full`,`w-5/6`,`w-2/3`,`w-full`];function E_(e){let t=(0,J.useId)(),{bytes:n,filename:r}=e.attachment,i=n>g_,a=e.language===`markdown`,[o,s]=(0,J.useState)(`formatted`),c=L({queryKey:[`attachment-text`,e.href,n,i],queryFn:async({signal:t})=>n===0?``:w_(await Wi(e.href,524288,t),i)??null,staleTime:1/0});return(0,ou.createPortal)(/* @__PURE__ */ (0,Y.jsx)(m_,{actions:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[a?/* @__PURE__ */ (0,Y.jsxs)(ha,{"aria-label":`Markdown view`,onValueChange:e=>{let t=e[0];t&&s(t)},value:[o],children:[/* @__PURE__ */ (0,Y.jsx)(ua,{value:`formatted`,children:`Formatted`}),/* @__PURE__ */ (0,Y.jsx)(ua,{value:`raw`,children:`Raw`})]}):null,/* @__PURE__ */ (0,Y.jsx)(`a`,{"aria-label":`Download ${r}`,className:wt({size:`icon`}),download:r,href:e.href,rel:`noreferrer`,target:`_blank`,children:/* @__PURE__ */ (0,Y.jsx)(zn,{"aria-hidden":`true`,size:15})})]}),closeLabel:`Close ${r}`,header:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:[/* @__PURE__ */ (0,Y.jsx)(`h2`,{className:`m-0 font-mono text-sm font-semibold text-dashboard-text`,id:t,children:r}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`font-mono text-xs text-dashboard-text-muted`,children:e.meta})]}),onClose:e.onClose,openKey:t,titleId:t,width:`wide`,children:c.isPending?/* @__PURE__ */ (0,Y.jsx)(`div`,{"aria-label":`Loading file`,className:`grid gap-2`,role:`status`,children:T_.map((e,t)=>/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-4 ${e}`},t))}):c.isError?/* @__PURE__ */ (0,Y.jsx)(h_,{children:`Could not load this file.`}):c.data===null?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:`This file is not text. Download it to open it.`}):/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-3`,children:[i?/* @__PURE__ */ (0,Y.jsxs)(`p`,{className:`m-0 text-xs text-dashboard-text-muted`,children:[`Showing the first `,g_/1024,` KB. Download the file to see all of it.`]}):null,/* @__PURE__ */ (0,Y.jsx)(D_,{language:e.language,text:c.data,view:o})]})}),document.body)}function D_(e){return e.text?e.language===`markdown`&&e.view===`formatted`?/* @__PURE__ */ (0,Y.jsx)($,{document:!0,text:e.text}):e.language===`plain`?/* @__PURE__ */ (0,Y.jsx)(hh,{children:e.text}):/* @__PURE__ */ (0,Y.jsx)(mh,{code:e.text,language:e.language}):/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:`Empty file.`})}function O_(e){return`data:${e.contentType};base64,${e.data}`}function k_(e,t){return`/api/conversations/${encodeURIComponent(e)}/attachments/${encodeURIComponent(t)}`}function A_(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function j_(e){return gi.some(t=>t===e.contentType)}function M_(e){return Dr.some(t=>t===e.contentType)}function N_(e){return[e.contentType,A_(e.bytes)].join(` · `)}function P_(e,t){return t.filter(j_).map(t=>({context:N_(t),filename:t.filename,src:k_(e,t.id)}))}function F_(e,t){let n=[],r;for(let i of t){if(i.role===`user`){let t=P_(e,i.attachments??[]);t.length>0&&n.push(t),i.context||(r=void 0);continue}let t=P_(e,[...i.attachments??[],...i.parts.flatMap(e=>e.type===`attachments_delivered`?e.attachments:[])]);t.length!==0&&(r||(r=[],n.push(r)),r.push(...t))}return n}const I_=(0,J.createContext)([]);function L_(e){let t=(0,J.useMemo)(()=>F_(e.conversationId,e.messages),[e.conversationId,e.messages]);return/* @__PURE__ */ (0,Y.jsx)(I_.Provider,{value:t,children:e.children})}const R_=`sm:grid-cols-[repeat(auto-fill,15rem)]`,z_=`grid min-w-0 grid-cols-2 gap-2 ${R_}`,B_=`grid min-w-0 grid-cols-1 gap-2 ${R_}`,V_=`block aspect-[4/3] w-full overflow-hidden rounded-lg border border-dashboard-border bg-dashboard-fill-faint`,H_=`size-full object-cover`,U_=`${V_} transition-colors hover:border-dashboard-border-interactive focus-visible:outline-2 focus-visible:outline-dashboard-focus`;function W_(e){let t=sh();if(e.attachments.length===0)return null;let n=e=>!t.active&&(j_(e)||M_(e)),r=e.attachments.map((e,t)=>({attachment:e,key:`${e.id}:${t}`})),i=r.filter(e=>n(e.attachment)),a=r.filter(e=>!n(e.attachment));return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[i.length>0?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:z_,children:i.map(t=>/* @__PURE__ */ (0,Y.jsx)(q_,{attachment:t.attachment,conversationId:e.conversationId},t.key))}):null,a.length>0?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:B_,children:a.map(t=>/* @__PURE__ */ (0,Y.jsx)(Y_,{attachment:t.attachment,conversationId:e.conversationId},t.key))}):null]})}function G_(e){return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:z_,children:e.images.map((e,t)=>/* @__PURE__ */ (0,Y.jsxs)(`figure`,{className:`grid min-w-0 gap-1`,children:[/* @__PURE__ */ (0,Y.jsx)(n_,{filename:e.filename,imageClassName:H_,src:O_(e),triggerClassName:U_}),/* @__PURE__ */ (0,Y.jsx)(K_,{filename:e.filename})]},`${e.filename}:${t}`))})}function K_(e){return/* @__PURE__ */ (0,Y.jsxs)(`figcaption`,{className:`flex h-6 min-w-0 items-center gap-1.5 px-0.5 font-mono text-xs`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-dashboard-text`,children:e.filename}),typeof e.bytes==`number`?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`flex-none text-dashboard-text-muted`,children:A_(e.bytes)}):null,e.download?/* @__PURE__ */ (0,Y.jsx)(`a`,{"aria-label":`Download ${e.download.filename}`,className:`grid size-6 flex-none place-items-center rounded text-dashboard-text-muted hover:bg-dashboard-fill-hover hover:text-dashboard-text focus-visible:outline-2 focus-visible:outline-dashboard-focus`,download:e.download.filename,href:e.download.href,rel:`noreferrer`,target:`_blank`,children:/* @__PURE__ */ (0,Y.jsx)(zn,{size:13})}):null]})}function q_(e){let t=(0,J.useContext)(I_),n=k_(e.conversationId,e.attachment.id),{filename:r,bytes:i}=e.attachment;if(j_(e.attachment)){let a=t.find(e=>e.some(e=>e.src===n&&e.filename===r));return/* @__PURE__ */ (0,Y.jsxs)(`figure`,{className:`grid min-w-0 gap-1`,children:[/* @__PURE__ */ (0,Y.jsx)(n_,{context:N_(e.attachment),filename:r,gallery:a,imageClassName:H_,loading:`lazy`,src:n,triggerClassName:U_}),/* @__PURE__ */ (0,Y.jsx)(K_,{bytes:i,filename:r})]})}return/* @__PURE__ */ (0,Y.jsxs)(`figure`,{className:`col-span-2 grid min-w-0 gap-1 sm:col-span-1`,children:[/* @__PURE__ */ (0,Y.jsx)(`video`,{"aria-label":r,className:`${V_} bg-dashboard-ink object-contain`,controls:!0,playsInline:!0,preload:`metadata`,src:n}),/* @__PURE__ */ (0,Y.jsx)(K_,{bytes:i,download:{filename:r,href:n},filename:r})]})}const J_=`grid w-full min-w-0 cursor-pointer grid-cols-[auto_minmax(0,1fr)] items-center gap-2 rounded-lg border border-dashboard-border bg-dashboard-fill-faint px-3 py-2 text-left font-sans no-underline transition-colors hover:border-dashboard-border-interactive hover:bg-dashboard-fill-hover focus-visible:outline-2 focus-visible:outline-dashboard-focus`;function Y_(e){let[t,n]=(0,J.useState)(!1),r=k_(e.conversationId,e.attachment.id),i=N_(e.attachment),a=C_(e.attachment),o=/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-6 place-items-center text-dashboard-text-muted`,children:/* @__PURE__ */ (0,Y.jsx)(dr,{size:13})}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`truncate font-mono text-xs text-dashboard-text`,children:/* @__PURE__ */ (0,Y.jsx)(Q,{text:e.attachment.filename})}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`truncate font-mono text-xs text-dashboard-text-muted`,children:/* @__PURE__ */ (0,Y.jsx)(Q,{text:i})})]})]});return a?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`button`,{"aria-haspopup":`dialog`,className:J_,onClick:()=>n(!0),type:`button`,children:o}),t?/* @__PURE__ */ (0,Y.jsx)(E_,{attachment:e.attachment,href:r,language:a,meta:i,onClose:()=>n(!1)}):null]}):/* @__PURE__ */ (0,Y.jsx)(`a`,{className:J_,download:e.attachment.filename,href:r,rel:`noreferrer`,target:`_blank`,children:o})}function X_(e){return e.reduce((e,t)=>e+t.data.length*3/4,0)}function Z_(e){return e.length<=3&&X_(e)<=3145728}async function Q_(e,t){if(t.length+e.length>3)throw Error(`Attach up to 3 images.`);if(X_(t)+e.reduce((e,t)=>e+t.size,0)>3145728)throw Error(`Images must total 3 MB or less.`);if(e.some(e=>!gi.some(t=>t===e.type)||!e.size))throw Error(`Use PNG, JPEG, GIF, or WebP image files.`);let n=await Promise.all(e.map(e=>new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(/* @__PURE__ */ Error(`Could not read the image. Add it again.`)),r.onload=()=>t({filename:e.name||`image.png`,contentType:e.type,data:String(r.result).split(`,`,2)[1]}),r.readAsDataURL(e)})));return[...t,...n]}async function $_(e,t){let n=(t??[]).filter(e=>gi.some(t=>t===e.contentType));return await Q_(await Promise.all(n.map(async t=>{let n=await fetch(k_(e,t.id));if(!n.ok)throw Error(`Could not read the queued image.`);return new File([await n.blob()],t.filename,{type:t.contentType})})),[])}function ev(e){return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`col-span-full flex min-w-0 flex-wrap gap-2 px-3 pt-3`,children:e.images.map((t,n)=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`relative min-w-0 rounded-lg border border-dashboard-border p-1`,children:[/* @__PURE__ */ (0,Y.jsx)(`img`,{alt:t.filename,className:`h-20 w-24 rounded-md object-contain`,src:O_(t)}),/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[/* @__PURE__ */ (0,Y.jsx)(W,{render:/* @__PURE__ */ (0,Y.jsx)(H,{"aria-label":`Remove ${t.filename}`,className:`absolute right-0 top-0 size-7 rounded-full border border-dashboard-border bg-dashboard-surface-raised text-dashboard-text data-disabled:hover:!bg-dashboard-surface-raised data-disabled:hover:!text-dashboard-text`,disabled:e.disabled,focusableWhenDisabled:!0,onClick:()=>e.onRemove(n),size:`icon`,type:`button`,children:/* @__PURE__ */ (0,Y.jsx)(Xn,{"aria-hidden":`true`,size:14})})}),/* @__PURE__ */ (0,Y.jsx)(Cr,{size:`compact`,children:`Remove image`})]})]},n))})}function tv(e){return/* @__PURE__ */ (0,Y.jsx)(`textarea`,{...e,onKeyDown:t=>{e.onKeyDown?.(t),Ud(t)}})}function nv({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(tv,{"data-slot":`textarea`,className:F(Wd,`min-h-36`,e),...t})}function rv(){return t(`junior:composer:autocorrect`,!1)}function iv(e){(0,J.useEffect)(()=>{let t,n=n=>{let r=e.current,i=n.touches[0];t=r&&i&&n.touches.length===1&&document.activeElement===r&&!r.contains(n.target)?{x:i.clientX,y:i.clientY}:void 0},r=n=>{let r=n.touches[0];if(!t||!r)return;let i=r.clientX-t.x,a=r.clientY-t.y;a<24||a<Math.abs(i)||(t=void 0,e.current?.blur())};return document.addEventListener(`touchstart`,n,{passive:!0}),document.addEventListener(`touchmove`,r,{passive:!0}),()=>{document.removeEventListener(`touchstart`,n),document.removeEventListener(`touchmove`,r)}},[e])}const av=`(pointer: coarse)`;function ov(e){let t=window.matchMedia(av);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function sv(){return window.matchMedia(av).matches}function cv(e,t,n){return t===e.lastSubmittedText&&n===e.images?e:{idempotencyKey:crypto.randomUUID(),lastSubmittedText:t,images:n}}const lv=(0,J.memo)(function(e){let t=pv(e.draftId),[n]=(0,J.useState)(()=>fv(t)),[r,i]=(0,J.useState)(!1),[a,o]=(0,J.useState)(()=>!!n.text.trim()),[s,c]=(0,J.useState)([]),l=(0,J.useRef)(s),[u,d]=(0,J.useState)(),[f,p]=(0,J.useState)(!1),m=(0,J.useRef)(!1),[h,g]=(0,J.useState)(!1),_=!e.footerStart&&!e.compact,v=(0,J.useRef)(null),y=hs(),[b]=rv(),x=!(0,J.useSyncExternalStore)(ov,sv,()=>!1),S=(0,J.useId)(),C=(0,J.useRef)(null);iv(C);let w=(0,J.useRef)(n),T=(0,J.useRef)(a),E=(0,J.useRef)(void 0),D=(0,J.useRef)({idempotencyKey:n.idempotencyKey,lastSubmittedText:n.lastSubmittedText}),O=(0,J.useRef)(!1),k=(0,J.useRef)(!1),A=(0,J.useRef)(!1),j=!!e.disabled||r;(0,J.useEffect)(()=>()=>{E.current!==void 0&&window.clearTimeout(E.current),_v(t,w.current)},[t]),(0,J.useEffect)(()=>{let e=C.current;if(!e)return;uv(e);let t=e.clientWidth,n,r=()=>{n===void 0&&(n=window.requestAnimationFrame(()=>{n=void 0,uv(e)}))},i=new ResizeObserver(()=>{e.clientWidth!==t&&(t=e.clientWidth,r())});i.observe(e);let a=_?window.matchMedia(`(min-height: 62.5rem)`):void 0;return a?.addEventListener(`change`,r),()=>{i.disconnect(),a?.removeEventListener(`change`,r),n!==void 0&&window.cancelAnimationFrame(n)}},[_]);let M=e=>{let t=!!e.trim();T.current!==t&&(T.current=t,o(t))},ee=e=>{l.current=e,c(e)},N=async e=>{if(!(!e.length||m.current||j)){m.current=!0,p(!0),d(void 0);try{let t=l.current,n=(await Q_(e,t)).slice(t.length),r=[...l.current,...n];Z_(r)?ee(r):d(`Attach up to 3 images that total 3 MB or less.`),C.current?.focus({preventScroll:!0})}catch(e){d(e instanceof Error?e.message:`Could not read images. Add them again.`)}finally{m.current=!1,p(!1)}}},P=()=>{E.current!==void 0&&window.clearTimeout(E.current),E.current=window.setTimeout(()=>{E.current=void 0,_v(t,w.current)},250)},te=()=>{C.current&&uv(C.current)},F=e=>{let t=w.current;t.text!==e&&(w.current={...t,text:e},M(e),P())},ne=e=>{w.current=e;let t=C.current;t&&(t.value=e.text),M(e.text),te()},re=()=>!!(w.current.text.trim()||l.current.length||e.sendsWithoutDraft)&&y&&!O.current&&!k.current&&!j&&!m.current,ie=async n=>{if(n?.preventDefault(),!re())return;let r=e.beforeSubmit?.({sendsMessage:!!(w.current.text.trim()||l.current.length)});if(r){k.current=!0;let e;try{e=await r}finally{k.current=!1}if(!e)return}let a=w.current.text.trim(),o=l.current;if(!a&&!o.length)return;let s=cv(D.current,a,o.length?o:void 0);D.current=s;let c=()=>e.onSubmit(a,s.idempotencyKey,o.length?o:void 0),u=()=>{let e=dv(),n={...e,text:``};ne(n),ee([]),d(void 0),_v(t,n),D.current=e};if(O.current=!0,e.onSubmitStart?.(),e.holdDraftUntilAccept){let e={...w.current,idempotencyKey:s.idempotencyKey,lastSubmittedText:s.lastSubmittedText,hasImages:o.length>0};w.current=e,_v(t,e),i(!0);try{await c()}catch{(0,ou.flushSync)(()=>i(!1)),C.current?.focus({preventScroll:!0});return}finally{O.current=!1,i(!1)}u()}else u(),C.current?.focus({preventScroll:!0}),queueMicrotask(()=>{O.current=!1}),await c().catch(()=>{})},I=e=>{let n=mv(w.current,e);ne(n),_v(t,n)},L=async()=>{if(!e.onStop||A.current)return;A.current=!0;let t;try{t=await e.onStop()}catch{return}finally{A.current=!1}t&&(I(t),C.current?.focus({preventScroll:!0}))};return(0,J.useImperativeHandle)(e.ref,()=>({appendText:e=>{let n=w.current.text.trimEnd(),r={...w.current,text:`${n&&`${n}\n\n`}${e}\n\n`};ne(r),_v(t,r);let i=C.current;i&&(i.focus({preventScroll:!0}),i.setSelectionRange(r.text.length,r.text.length),i.scrollTop=i.scrollHeight)},canRestoreImages:e=>!e.length||Z_([...e,...l.current]),focus:()=>C.current?.focus({preventScroll:!0}),restoreMessage:e=>{e.text.trim()&&I(e.text);let t=e.images??[];if(t.length){let e=[...t];for(let t of l.current)Z_([...e,t])&&e.push(t);e.length<t.length+l.current.length&&d(`Some draft images did not fit. Add them again.`),ee(e)}C.current?.focus({preventScroll:!0})}})),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-1.5`,children:[e.error||u?/* @__PURE__ */ (0,Y.jsx)(`div`,{"aria-live":`polite`,className:`min-w-0 font-sans text-xs leading-relaxed text-rose-300`,children:u??e.error}):null,/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:K(e.footerStart?`block overflow-hidden focus-within:border-dashboard-focus/45 focus-within:ring-1 focus-within:ring-dashboard-focus/25`:`grid grid-cols-[minmax(0,1fr)_auto] items-end overflow-hidden focus-within:border-dashboard-accent/35 focus-within:ring-1 focus-within:ring-dashboard-focus/35`,_&&`md:block`,aa,h&&`ring-2 ring-dashboard-focus`),onDragOver:t=>{t.dataTransfer.types.includes(`Files`)&&(t.preventDefault(),e.compact?t.dataTransfer.dropEffect=`none`:(t.dataTransfer.dropEffect=`copy`,g(!0)))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||g(!1)},onDrop:t=>{t.dataTransfer.types.includes(`Files`)&&(t.preventDefault(),!e.compact&&(g(!1),N(Array.from(t.dataTransfer.files))))},onPaste:t=>{let n=Array.from(t.clipboardData.files);!e.compact&&n.length&&(t.preventDefault(),N(n))},onSubmit:ie,children:[s.length?/* @__PURE__ */ (0,Y.jsx)(ev,{images:s,disabled:f||j,onRemove:e=>{m.current||j||(ee(l.current.filter((t,n)=>n!==e)),d(void 0))}}):null,h||f?/* @__PURE__ */ (0,Y.jsx)(`div`,{role:`status`,className:`col-span-full px-3 pt-2 text-sm text-dashboard-text-muted`,children:f?`Reading images…`:`Drop images here`}):null,/* @__PURE__ */ (0,Y.jsx)(`input`,{accept:gi.join(`,`),"aria-label":`Choose images`,className:`sr-only`,multiple:!0,onChange:e=>{N(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``},ref:v,tabIndex:-1,type:`file`}),/* @__PURE__ */ (0,Y.jsx)(`label`,{className:`sr-only`,htmlFor:S,children:e.label}),/* @__PURE__ */ (0,Y.jsx)(tv,{autoCapitalize:b?`sentences`:`off`,autoComplete:b?void 0:`off`,autoCorrect:b?`on`:`off`,className:K(`min-h-12 max-h-28 w-full resize-none overflow-y-auto border-0 bg-transparent px-3 py-3 font-sans text-base leading-relaxed text-dashboard-text outline-none placeholder:text-dashboard-text-faint`,e.compact?`md:max-h-[min(calc(8lh_+_1.5rem),30dvh)] md:text-sm`:`md:max-h-[min(calc(12lh_+_1.5rem),40dvh)] md:px-4`,_?`md:py-2 md:tall:min-h-14 md:tall:py-3`:!e.compact&&`md:min-h-14`),disabled:r,enterKeyHint:x?`send`:`enter`,id:S,inputMode:`text`,maxLength:32e3,defaultValue:n.text,onChange:e=>{F(e.target.value),te()},onFocus:e.onFocus,onKeyDown:e=>{x&&e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),ie())},placeholder:e.placeholder??`Message Junior…`,ref:C,rows:1,spellCheck:b}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:K(`flex min-w-0 items-center gap-3 px-2 py-1.5`,!e.compact&&`md:px-3`,_?`md:tall:py-2`:!e.compact&&`md:py-2`,e.footerStart?`justify-between`:`justify-end md:justify-between`),children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[e.compact?null:/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[/* @__PURE__ */ (0,Y.jsx)(W,{render:/* @__PURE__ */ (0,Y.jsx)(H,{focusableWhenDisabled:!0,"aria-label":`Attach images`,disabled:j||f,onClick:()=>v.current?.click(),size:`icon`,type:`button`,children:/* @__PURE__ */ (0,Y.jsx)(Zn,{"aria-hidden":`true`,size:16})})}),/* @__PURE__ */ (0,Y.jsx)(Cr,{size:`compact`,children:`Attach images (up to 3 MB total)`})]}),e.footerStart,e.footerStart||e.compact||!x?null:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`hidden min-w-0 font-sans text-xs leading-relaxed text-dashboard-text-muted md:block`,children:`Enter to send · Shift+Enter for a new line`})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[e.onStop?/* @__PURE__ */ (0,Y.jsxs)(H,{"aria-label":e.stopPending?`Stopping`:`Stop`,disabled:e.stopPending||!y,onClick:()=>void L(),children:[/* @__PURE__ */ (0,Y.jsx)(Rn,{"aria-hidden":`true`,fill:`currentColor`,size:12}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`hidden md:inline`,children:e.stopPending?`Stopping…`:`Stop`})]}):null,/* @__PURE__ */ (0,Y.jsxs)(H,{"aria-label":j?`Sending message`:e.submitLabel,className:K(`disabled:!border-transparent disabled:!bg-dashboard-fill-hover disabled:!text-dashboard-text-muted disabled:!opacity-100`,e.compact&&`w-9 px-0`),disabled:!a&&!s.length&&!e.sendsWithoutDraft||!y||j||f,variant:`primary`,type:`submit`,children:[/* @__PURE__ */ (0,Y.jsx)(sn,{"aria-hidden":`true`,size:14}),e.compact?null:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`hidden md:inline`,children:j?`Sending…`:e.submitLabel})]})]})]})]})]})});function uv(e){let t=e.style.height;e.style.height=`auto`;let n=`${e.scrollHeight}px`;e.style.height=t===n?t:n}function dv(){return{idempotencyKey:crypto.randomUUID(),lastSubmittedText:``,text:``}}function fv(e){if(typeof window>`u`)return dv();try{let t=window.localStorage.getItem(e);if(!t)return dv();let n=JSON.parse(t);if(typeof n==`object`&&n&&`idempotencyKey`in n&&typeof n.idempotencyKey==`string`&&`text`in n&&typeof n.text==`string`){let e=n.text.slice(0,32e3),t=`lastSubmittedText`in n&&typeof n.lastSubmittedText==`string`?n.lastSubmittedText:e.trim();return{idempotencyKey:`hasImages`in n&&n.hasImages?crypto.randomUUID():n.idempotencyKey,lastSubmittedText:t,text:e}}}catch{}return dv()}function pv(e){return`junior:dashboard:conversation-draft:${encodeURIComponent(e)}`}function mv(e,t){return{...e,text:e.text.trim()?`${t}\n${e.text}`:t}}function hv(e,t){if(!t.trim())return;let n=pv(e);_v(n,mv(fv(n),t))}function gv(e){let t=pv(e),{text:n}=fv(t);return _v(t,{...dv(),text:``}),n}function _v(e,t){if(typeof window<`u`)try{t.text?window.localStorage.setItem(e,JSON.stringify(t)):window.localStorage.removeItem(e)}catch{}}function vv(e){let t=Qf(e.menu),n=e.placement===`mobile`;return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid gap-0.5`,children:[n&&!e.menu.eventLogOpen?/* @__PURE__ */ (0,Y.jsx)(wv,{label:e.searchOpen?`Hide search`:`Search transcript`,onClick:()=>{e.close(),e.onSearchClick()},pressed:e.searchOpen,children:e.searchOpen?/* @__PURE__ */ (0,Y.jsx)(Xn,{"aria-hidden":`true`,size:16,strokeWidth:2}):/* @__PURE__ */ (0,Y.jsx)(At,{"aria-hidden":`true`,size:16,strokeWidth:2})}):null,n?/* @__PURE__ */ (0,Y.jsx)(wv,{label:`Conversation details`,onClick:()=>{e.close(),e.onDetailsClick()},pressed:e.detailsOpen,children:/* @__PURE__ */ (0,Y.jsx)(Nn,{"aria-hidden":`true`,size:16,strokeWidth:2})}):null,t.map((t,n)=>/* @__PURE__ */ (0,Y.jsxs)(J.Fragment,{children:[n>0?/* @__PURE__ */ (0,Y.jsx)(Vl,{className:`my-1 bg-dashboard-border-subtle`}):null,t.map(t=>/* @__PURE__ */ (0,Y.jsx)(yv,{close:e.close,item:t},t.key))]},n))]})}function yv(e){let{item:t}=e,n=/* @__PURE__ */ (0,Y.jsx)(t.icon,{"aria-hidden":`true`,className:`size-4 shrink-0`});return t.href?/* @__PURE__ */ (0,Y.jsxs)(tf,{className:wt({size:`menu`}),href:t.href,children:[n,t.label]}):/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(H,{"aria-label":t.label,disabled:t.disabled,focusableWhenDisabled:t.stayOpen||t.toggle,onClick:()=>{!t.stayOpen&&!t.toggle&&e.close(),t.onClick?.()},size:`menu`,children:[n,/* @__PURE__ */ (0,Y.jsx)(`span`,{children:t.label})]}),t.feedback===void 0?null:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`sr-only`,role:`status`,children:t.feedback})]})}function bv(e){return/* @__PURE__ */ (0,Y.jsxs)(ha,{"aria-label":`Transcript view`,className:`inline-flex gap-0.5 rounded-md border border-dashboard-border bg-dashboard-overlay-soft p-0.5`,onValueChange:([t])=>{t&&e.onChange(t)},value:[e.value],children:[/* @__PURE__ */ (0,Y.jsx)(xv,{label:`Conversation`,value:`rich`,children:/* @__PURE__ */ (0,Y.jsx)(br,{"aria-hidden":`true`,size:14,strokeWidth:2})}),/* @__PURE__ */ (0,Y.jsx)(xv,{label:`Event log`,value:`raw`,children:/* @__PURE__ */ (0,Y.jsx)(mr,{"aria-hidden":`true`,size:14,strokeWidth:2})})]})}function xv(e){return/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[/* @__PURE__ */ (0,Y.jsx)(W,{render:/* @__PURE__ */ (0,Y.jsx)(ua,{"aria-label":e.label,className:`size-7 min-w-0 border-0 px-0 data-pressed:border-0 data-pressed:bg-dashboard-fill-hover`,value:e.value,children:e.children})}),/* @__PURE__ */ (0,Y.jsx)(Cr,{size:`compact`,children:e.label})]})}function Sv(e){return/* @__PURE__ */ (0,Y.jsxs)(Tr,{disabled:e.tooltipDisabled,children:[/* @__PURE__ */ (0,Y.jsx)(W,{render:/* @__PURE__ */ (0,Y.jsx)(H,{ref:e.ref,"aria-controls":e.controls,"aria-expanded":e.expanded,"aria-keyshortcuts":e.keyShortcuts,"aria-label":e.label,"aria-pressed":e.pressed,className:K(`text-dashboard-text-muted`,e.pressed&&`bg-dashboard-fill-strong text-dashboard-text`),onClick:e.onClick,size:`icon`,children:e.children})}),/* @__PURE__ */ (0,Y.jsxs)(Cr,{size:`compact`,children:[e.label,e.shortcut?/* @__PURE__ */ (0,Y.jsx)(`kbd`,{className:`ml-1.5 font-sans`,children:e.shortcut}):null]})]})}function Cv(e){let t=(0,J.useRef)(null);return lh({anchorRef:t,inputRef:e.inputRef,onOpen:e.onClick,open:e.open}),/* @__PURE__ */ (0,Y.jsx)(Sv,{ref:t,keyShortcuts:e.open?void 0:`Meta+F Control+F`,label:e.open?`Hide search`:`Search transcript`,onClick:e.onClick,pressed:e.open,shortcut:e.open?void 0:Uc(`f`),children:e.open?/* @__PURE__ */ (0,Y.jsx)(Xn,{"aria-hidden":`true`,size:15,strokeWidth:2}):/* @__PURE__ */ (0,Y.jsx)(At,{"aria-hidden":`true`,size:15,strokeWidth:2})})}function wv(e){return/* @__PURE__ */ (0,Y.jsxs)(H,{"aria-label":e.label,"aria-pressed":e.pressed,className:e.pressed?`bg-dashboard-fill-strong`:void 0,disabled:e.disabled,onClick:e.onClick,size:`menu`,children:[e.children,/* @__PURE__ */ (0,Y.jsx)(`span`,{children:e.label})]})}const Tv=`thin-scrollbar px-4 pb-4 md:px-7 md:pb-6`;function Ev(e){return/* @__PURE__ */ (0,Y.jsx)(`section`,{className:`min-w-0`,children:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:K(e.full?`w-full`:`mx-auto w-full max-w-[52.5rem] pt-5 md:pt-7`,e.className),children:e.children})})}function Dv(e){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:K(`grid h-full min-h-0 min-w-0 grid-rows-[auto_minmax(0,1fr)_minmax(0,auto)]`,e.scrollMinTall&&`grid-rows-[auto_minmax(7rem,1fr)_minmax(0,auto)]`,e.className),children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`min-w-0`,children:e.header}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`@container/chat relative grid min-h-0 min-w-0 grid-rows-[minmax(0,1fr)]`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{"aria-label":e.scrollAriaLabel,className:K(`min-h-0 overflow-y-auto overscroll-contain outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-dashboard-focus`,e.scrollClassName),"data-chat-scroll":``,ref:e.scrollRef,tabIndex:e.scrollAriaLabel?0:void 0,children:e.scroll}),e.overlay]}),e.dock]})}function Ov(e,t=/* @__PURE__ */ new Map){for(let n of e)if(n.threads){for(let e of n.threads)t.set(e.id,e);Ov(n.threads,t)}return t}const kv=(0,J.createContext)(/* @__PURE__ */ new Map);function Av(e){let t=(0,J.useContext)(kv),n=e.nodes.slice(0,-1).map(e=>({conversationId:e.conversationId,label:(e.kind===`thread`?t.get(e.conversationId)?.displayTitle:void 0)??e.label}));return/* @__PURE__ */ (0,Y.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`min-w-0`,children:/* @__PURE__ */ (0,Y.jsxs)(`ol`,{className:`m-0 flex min-w-0 list-none items-center gap-1.5 p-0`,children:[n.map((e,t)=>/* @__PURE__ */ (0,Y.jsxs)(`li`,{className:`inline-flex min-w-0 shrink-[2] items-center gap-1.5`,children:[t>0?/* @__PURE__ */ (0,Y.jsx)(jv,{}):null,/* @__PURE__ */ (0,Y.jsx)(V,{className:`min-w-0 max-w-[16rem] truncate font-sans text-sm text-dashboard-text-muted no-underline underline-offset-2 hover:text-dashboard-text hover:underline`,title:e.label,to:kc(e.conversationId),children:e.label})]},e.conversationId)),e.current?/* @__PURE__ */ (0,Y.jsxs)(`li`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[/* @__PURE__ */ (0,Y.jsx)(jv,{}),e.current]}):null]})})}function jv(){return/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,className:`shrink-0 text-dashboard-text-faint`,size:14})}function Mv(e){let[t,n]=(0,J.useState)(!1),r=(0,J.useRef)(null),i=(0,J.useRef)(null),a=e.buttonRef??i;return(0,J.useEffect)(()=>{if(!t)return;function e(e){r.current?.contains(e.target)||n(!1)}function i(e){e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),n(!1),r.current?.contains(document.activeElement)&&a.current?.focus({preventScroll:!0}))}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,i,!0),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,i,!0)}},[a,t]),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`relative`,ref:r,children:[/* @__PURE__ */ (0,Y.jsx)(Sv,{ref:a,label:t?`Close conversation menu`:`Conversation menu`,onClick:()=>n(e=>!e),pressed:t,tooltipDisabled:t,children:/* @__PURE__ */ (0,Y.jsx)(tr,{"aria-hidden":`true`,size:18,strokeWidth:2})}),t?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`absolute right-0 top-[calc(100%+0.35rem)] z-40 w-56 rounded-xl border border-dashboard-border-strong bg-dashboard-surface-raised/95 p-1.5 shadow-2xl shadow-black/75 backdrop-blur-xl`,children:e.children(()=>n(!1))}):null]})}function Nv(e){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:K(`absolute top-full z-20 mt-2 flex items-center gap-2 rounded-lg border border-dashboard-border-emphasis bg-dashboard-surface-raised p-1.5 shadow-lg`,e.className),onKeyDown:t=>{t.key===`Enter`&&!t.nativeEvent.isComposing?(t.preventDefault(),e.match.step(t.shiftKey?-1:1)):t.key===`Escape`&&(t.preventDefault(),t.stopPropagation(),e.onClose())},children:[/* @__PURE__ */ (0,Y.jsx)(zm,{className:`min-w-0 flex-1`,inputRef:e.inputRef,label:`Search transcript`,onChange:e.onChange,placeholder:`Search transcript…`,size:`compact`,value:e.value}),e.value.trim()?/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-live":`polite`,className:`shrink-0 pr-1.5 text-xs tabular-nums text-dashboard-text-muted`,children:e.match.count===0?`0/0`:`${e.match.index+1}/${e.match.count}`}):null]})}function Pv(e){let t=e.detailsOpen,n=(0,J.useRef)(null),r=(0,J.useRef)(null),i=(0,J.useRef)(t),[a,o]=(0,J.useState)(!1),s=(0,J.useRef)(null),c=e.view===`rich`&&(a||e.search.length>0),l=go();(0,J.useEffect)(()=>{i.current&&!t&&document.activeElement===document.body&&(window.matchMedia(`(width < 48rem) or ((width < 64rem) and (height < 30rem))`).matches?r.current:n.current)?.focus({preventScroll:!0}),i.current=t},[t]),(0,J.useEffect)(()=>{c&&s.current?.focus()},[c]);let u=()=>{o(!1),e.search.length>0&&e.onSearchChange(``)},d=()=>{c?u():o(!0)},f=(n,r)=>/* @__PURE__ */ (0,Y.jsx)(vv,{close:r,detailsOpen:t,menu:e.menu,onDetailsClick:e.onDetailsClick,onSearchClick:d,placement:n,searchOpen:c}),p=e.view===`raw`?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`h2`,{className:`m-0 min-w-0 font-display text-base font-medium leading-6 tracking-tight`,children:/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`block max-w-full cursor-pointer truncate text-left text-dashboard-text-muted hover:text-dashboard-text hover:underline`,onClick:()=>e.onViewChange(`rich`),title:`Back to conversation`,type:`button`,children:e.title})}),/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`text-dashboard-text-faint`,children:`›`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-current":`page`,className:`shrink-0 font-display text-base font-medium leading-6 tracking-tight`,children:`Event log`})]}):/* @__PURE__ */ (0,Y.jsx)(`h2`,{className:`m-0 min-w-0 truncate font-display text-base font-medium leading-6 tracking-tight`,children:e.title}),m=c||e.errors.length>0||!!e.forks||!!e.agentTree;return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(co,{children:/* @__PURE__ */ (0,Y.jsx)(Mv,{buttonRef:r,children:t=>/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`contents`,inert:e.pending,children:f(`mobile`,t)}),l?/* @__PURE__ */ (0,Y.jsxs)(H,{className:`mt-0.5`,onClick:()=>{t(),l()},size:`menu`,children:[/* @__PURE__ */ (0,Y.jsx)(dn,{"aria-hidden":`true`,size:16,strokeWidth:2}),`App menu`]}):null]})})}),e.contextTags||e.linkedWork?/* @__PURE__ */ (0,Y.jsx)(fo,{children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex w-max items-center gap-1.5 [&>*]:shrink-0`,children:[e.contextTags,e.linkedWork?/* @__PURE__ */ (0,Y.jsx)(`div`,{"aria-label":`Linked work`,children:e.linkedWork}):null]})}):null,/* @__PURE__ */ (0,Y.jsxs)(`header`,{className:K(`relative z-10 border-b md:z-30 border-dashboard-border bg-dashboard-bg`,!m&&`hidden md:block`),children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`hidden h-13 min-w-0 items-center justify-between gap-1.5 px-1 md:flex`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.sidebarToggle?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`shrink-0`,children:e.sidebarToggle}):null,e.agentTree?/* @__PURE__ */ (0,Y.jsx)(Av,{current:p,nodes:e.agentTree}):p,e.status,e.privacy?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`shrink-0`,children:e.privacy}):null,!e.agentTree&&e.contextTags?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`flex h-6 min-w-0 max-w-[min(19rem,60%)] shrink-[2] items-center`,children:e.contextTags}):null]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,inert:e.pending,children:[e.cost?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`mr-2 text-xs tabular-nums text-dashboard-text-muted`,children:e.cost}):null,e.view===`raw`?null:/* @__PURE__ */ (0,Y.jsx)(Cv,{inputRef:s,onClick:d,open:c}),/* @__PURE__ */ (0,Y.jsx)(Mv,{children:e=>f(`desktop`,e)}),t?null:/* @__PURE__ */ (0,Y.jsx)(Sv,{ref:n,expanded:!1,label:`Conversation details`,onClick:e.onDetailsClick,children:/* @__PURE__ */ (0,Y.jsx)(Xt,{"aria-hidden":`true`,size:15,strokeWidth:2})})]})]}),e.forks?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`hidden px-7 pb-2.5 md:block`,children:e.forks}):null,e.agentTree?/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2 px-4 py-2 md:hidden`,children:[/* @__PURE__ */ (0,Y.jsx)(Av,{nodes:e.agentTree}),e.status]}):null,e.forks?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`px-4 py-2 md:hidden`,children:e.forks}):null,c?/* @__PURE__ */ (0,Y.jsx)(Nv,{className:`inset-x-3 md:left-auto md:right-4 md:w-[max(20rem,25vw)]`,inputRef:s,match:e.searchMatch,onChange:e.onSearchChange,onClose:u,value:e.search}):null,e.errors.map(e=>/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`px-4 pb-3 text-xs text-red-300 md:px-7`,children:e},e))]})]})}function Fv(e){if(!e.active&&!e.className&&!e[`aria-label`])return e.children;let t=K(e.active&&`shimmer`,e.className);return e.as===`strong`?/* @__PURE__ */ (0,Y.jsx)(`strong`,{"aria-label":e[`aria-label`],className:t,children:e.children}):/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-label":e[`aria-label`],className:t,children:e.children})}function Iv(e){return/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`grid min-w-0 self-start grid-cols-[minmax(0,1fr)_auto] content-start gap-x-3 gap-y-1.5`,children:e.lines.map((e,t)=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:e.label?`contents`:K(`col-span-2 block min-w-0 break-words text-dashboard-text`,e.valueStyle===`heading`&&`font-sans tabular-nums font-semibold text-dashboard-text`,e.valueStyle===`heading`&&t>0&&`mt-1 border-t border-dashboard-border-strong pt-2`),children:[e.label?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:K(`min-w-0 break-words font-medium text-dashboard-text-muted`,e.labelStyle===`code`&&`break-all font-mono text-xs text-dashboard-text`),children:e.label}):null,e.label?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`whitespace-nowrap text-right text-dashboard-text`,children:e.value}):/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[e.value,e.live?/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`ml-2 inline-flex items-center gap-1.5 font-sans text-xs font-normal tracking-wide text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),/* @__PURE__ */ (0,Y.jsx)(Fv,{active:!0,children:`in progress`})]}):null]})]},`${t}-${e.label??``}-${e.value}-${e.live?`live`:``}`))})}function Lv(e){let t=e.tooltip?.filter(e=>e.value.trim());return!e.tooltipCard&&!t?.length?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:e.className,children:e.children}):/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[/* @__PURE__ */ (0,Y.jsx)(W,{render:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:K(`inline-flex border-b border-dotted border-dashboard-border-interactive outline-none transition-colors hover:border-dashboard-border-heavy focus-visible:border-dashboard-border-heavy`,e.className),tabIndex:0,children:e.children})}),/* @__PURE__ */ (0,Y.jsx)(Cr,{align:e.align===`left`?`start`:e.align===`right`?`end`:`center`,className:K(`w-[calc(100vw-2rem)] max-w-80 rounded-lg bg-dashboard-bg text-left font-normal shadow-xl shadow-black/35`,e.tooltipCard?`p-3 leading-snug`:`px-3 py-2 leading-relaxed`),side:e.tooltipPlacement===`above`?`top`:`bottom`,children:e.tooltipCard?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`block max-h-[min(30rem,var(--available-height,30rem))] overflow-y-auto`,children:e.tooltipCard}):t?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`block max-h-72 overflow-y-auto`,children:/* @__PURE__ */ (0,Y.jsx)(Iv,{lines:t})}):null})]})}const Rv=`bg-dashboard-focus/80`,zv=`bg-dashboard-focus/30`;function Bv(e){return/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:K(`size-2 shrink-0 rounded-xs`,e.className)})}function Vv(e){let t=Math.min(100,Math.max(0,(e.split?.selfShare??1)*100));return/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`grid gap-3`,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:K(`grid gap-2.5`,e.sections.length>0&&`border-b border-dashboard-border pb-3`),children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`flex items-baseline justify-between gap-3`,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`min-w-0 truncate font-medium text-dashboard-text`,children:[e.title,e.note?/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`text-dashboard-text-faint`,children:[` · `,e.note]}):null]}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`whitespace-nowrap text-base font-semibold tabular-nums text-dashboard-text`,children:e.total})]}),e.split?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{"aria-hidden":`true`,className:`flex h-1.5 overflow-hidden rounded-full bg-dashboard-fill-hover`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:Rv,style:{width:`${t}%`}}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:zv,style:{width:`${100-t}%`}})]}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`flex flex-wrap justify-between gap-x-3 gap-y-1 tabular-nums`,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 whitespace-nowrap`,children:[/* @__PURE__ */ (0,Y.jsx)(Bv,{className:Rv}),`this agent`,/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-medium text-dashboard-text`,children:e.split.self})]}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 whitespace-nowrap`,children:[/* @__PURE__ */ (0,Y.jsx)(Bv,{className:zv}),e.split.count,` child conversation`,e.split.count===1?``:`s`,/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-medium text-dashboard-text`,children:e.split.subagents})]})]})]}):null]}),e.sections.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-x-3 gap-y-2`,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`col-span-2 font-sans font-medium text-dashboard-text-faint`,children:[e.title,e.total?` · ${e.total}`:null]}),e.rows.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`contents`,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:K(`flex min-w-0 items-baseline gap-2`,e.code&&`font-mono`),children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 truncate`,title:e.label,children:e.label}),e.live?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`shrink-0 font-sans text-2xs text-dashboard-text-muted`,children:/* @__PURE__ */ (0,Y.jsx)(Fv,{active:!0,children:`in progress`})}):null]}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`whitespace-nowrap text-right tabular-nums text-dashboard-text`,children:e.value})]},e.label)),e.more?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`text-dashboard-text-faint`,children:[e.more.count,` more`]}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`whitespace-nowrap text-right tabular-nums`,children:e.more.value})]}):null]},e.title))]})}function Hv(e,t){return`${Wa(t)} ${e}${t===1?``:`s`}`}function Uv(e){return!!e}function Wv(e){return[[`input`,e.inputTokens],[`output`,e.outputTokens],[`cached`,e.cachedInputTokens],[`cache write`,e.cacheCreationTokens],[`reasoning`,e.reasoningTokens]].flatMap(([e,t])=>t?[{label:e,value:Wa(t)}]:[])}function Gv(e){return{cost:(Ea(e?.cumulativeUsage)?.total??0)+(e?.auxiliaryCostUsd??0),tokens:Ca(e?.cumulativeUsage)?.totalTokens??0}}function Kv(e,t){return Math.min(Math.max(0,e),Math.max(0,t))}function qv(e,t,n,r){if(!e)return[];let i=Kv(n,t);return[{value:`By agent`,valueStyle:`heading`},{label:`this agent`,value:r(t-i)},{label:Hv(`child conversation`,e.count),value:r(i)}]}function Jv(e){return e.split(`/`).at(-1)??e}function Yv(e,t){return{live:e===t,value:Jv(e),valueStyle:`heading`}}function Xv(e,t,n){if(e.length<=t+1)return{rows:e};let r=e.slice(t);return{more:{count:r.length,value:n(r.reduce((e,t)=>e+t.amount,0))},rows:e.slice(0,t)}}function Zv(e,t,n,r,i){let a=(e??[]).flatMap(e=>{let t=n(e.usage);return t?[{amount:r(t),modelId:e.modelId}]:[]}).sort((e,t)=>t.amount-e.amount).map(e=>({amount:e.amount,code:!0,label:Jv(e.modelId),live:e.modelId===t,value:i(e.amount)}));return t&&!a.some(e=>e.live)&&a.unshift({amount:0,code:!0,label:Jv(t),live:!0,value:`…`}),a}function Qv(e,t,n,r){if(!e)return;let i=Kv(n,t);return{count:e.count,self:r(t-i),selfShare:t>0?(t-i)/t:1,subagents:r(i)}}function $v(e){return new Intl.NumberFormat(`en-US`,{currency:`USD`,maximumFractionDigits:e,minimumFractionDigits:e,style:`currency`})}function ey(e){let t=e>=10?2:e>=1?3:4,n=$v(t),r=$v(4);return e=>e>0&&e<.5*10**-t?r.format(e):n.format(e)}function ty(e,t,n,r,i){let a=Zv(t,r,Ca,e=>e.totalTokens,Wa);return{note:n?Hv(`compaction`,n):void 0,sections:a.length?[{title:`By model`,...Xv(a,4,Wa)}]:[{rows:Wv(e),title:`By type`}].filter(e=>e.rows.length),split:Qv(i,e.totalTokens,Gv(i).tokens,Wa),title:`Tokens`,total:Wa(e.totalTokens)}}function ny(e,t){return[[`input`,e.input],[`output`,e.output],[`cache read`,e.cacheRead],[`cache write`,e.cacheWrite]].flatMap(([e,n])=>n===void 0?[]:[{label:e,value:t(n)}])}function ry(e,t,n,r,i){let a=wa(e,n);if(!a)return;let o=ey(a.total),s=Zv(t,r,Ea,e=>e.total,o),c=[...n?.operations??[]].sort((e,t)=>t.costUsd-e.costUsd).map(e=>({amount:e.costUsd,label:iy(e),value:o(e.costUsd)})),l=[];if(s.length)l.push({title:`By model`,...Xv(s,4,o)});else if(e){let t=ny(e,o);t.length&&l.push({rows:t,title:`By type`})}return n&&c.length&&l.push({title:`Auxiliary`,total:o(n.costUsd),...Xv(c,3,o)}),{sections:l,split:Qv(i,a.total,Gv(i).cost,o),title:`Estimated cost`,total:o(a.total)}}function iy(e){return{"junior/cache_warmup":`Cache warmup`,"junior/compaction":`Compaction`,"junior/conversation_catch_up":`Catch-up`,"junior/conversation_title":`Conversation title`,"junior/guardian_action_reviewed":`Guardian`,"junior/image_prompt_enrichment":`Image prompt`,"junior/passive_reply_routed":`Passive reply routing`,"junior/review_item_reply_match":`Review reply matching`,"junior/run_title":`Run title`,"junior/task_title":`Task title`,"junior/turn_routed":`Thinking routing`,"junior/vision_summary":`Image summary`,"memory/memories_captured":`Memory extraction`,"memory/memories_recalled":`Memory recall`,"memory/task_model_called":`Memory extraction`,"memory/user_prompt_model_called":`Memory recall`}[`${e.namespace}/${e.name}`]??`${e.namespace} · ${e.name.replaceAll(`_`,` `)}`}function ay(e){let t=Oa(e.modelUsage)??e.summary,n=wa(t,e.auxiliaryCosts);if(!n&&!e.live)return null;let r=!!e.live,i=n?`${Ja(n)}${r?`+`:``}`:`$…`,a=ry(t,e.modelUsage,e.auxiliaryCosts,e.liveModelId,e.childAgentTotals);return/* @__PURE__ */ (0,Y.jsx)(Lv,{align:e.align,tooltipPlacement:e.tooltipPlacement??`above`,tooltip:!a&&e.liveModelId?[Yv(e.liveModelId,e.liveModelId)]:void 0,tooltipCard:a?/* @__PURE__ */ (0,Y.jsx)(Vv,{...a}):void 0,children:/* @__PURE__ */ (0,Y.jsx)(Fv,{active:r,children:i})})}function oy(e){return e.summary?/* @__PURE__ */ (0,Y.jsx)(Lv,{align:e.align,tooltipCard:/* @__PURE__ */ (0,Y.jsx)(Vv,{...ty(e.summary,e.modelUsage,e.compactionCount,e.liveModelId,e.childAgentTotals)}),children:/* @__PURE__ */ (0,Y.jsx)(Fv,{active:e.live,children:Aa(e.summary)})}):null}function sy(e){if(!e.label||e.label===`none`)return null;let t=[e.startedAt?{label:`started`,value:to(e.startedAt)}:void 0,e.endedAt?{label:`ended`,value:to(e.endedAt)}:void 0,...qv(e.childAgentTotals,e.durationMs??0,e.childAgentTotals?.cumulativeDurationMs??0,e=>Ia(e)||`0s`)].filter(Uv);return/* @__PURE__ */ (0,Y.jsx)(Lv,{align:e.align,tooltip:t,children:e.label})}function cy(e){if(!e.childAgentTotals)return null;let t=Hv(`child conversation`,e.childAgentTotals.count);return/* @__PURE__ */ (0,Y.jsx)(Lv,{tooltip:[{value:`Tokens, cost, and runtime include ${t} at any depth.`}],children:t})}function ly(e){let t=/* @__PURE__ */ new Map,n=[];for(let r of e){let e=t.get(r.label);e?e.push(r):(t.set(r.label,[r]),n.push(r.label))}return n.map(e=>({label:e,annotations:t.get(e)??[]}))}function uy(e){let t=ly(e);return{groups:t,labeledGroups:t.slice(0,2),overflowGroupCount:Math.max(0,t.length-2)}}function dy(e){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`mb-2 rounded-lg border border-dashboard-accent/20 bg-dashboard-accent/[0.07] px-3 py-2.5 font-sans text-sm text-dashboard-text`,children:[/* @__PURE__ */ (0,Y.jsx)(tf,{className:`font-medium text-dashboard-accent-text underline decoration-dashboard-accent/40 underline-offset-2 hover:text-dashboard-accent-text`,href:e.authorization.authorizationUrl,children:e.authorization.label}),/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`mb-0 mt-1 text-xs text-dashboard-text-muted`,children:e.authorization.completionText})]})}function fy(e){if(e.visibility!==`private`)return null;let t=`Private conversation. Only members of this conversation can see this transcript.`;return/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`inline-flex items-center text-dashboard-text-muted`,role:`note`,title:t,children:[/* @__PURE__ */ (0,Y.jsx)(Wt,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`sr-only`,children:t})]})}function py(e){let t=e.annotations,n=vy();if(!t?.length)return null;let r=t.map(e=>yy(e)),i=uy(t),a=n&&i.groups.length>1,o=a?i.groups.flatMap(e=>e.annotations):[];return/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[/* @__PURE__ */ (0,Y.jsx)(W,{render:/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-label":`Linked work, newest first: ${r.join(`, `)}`,className:`inline-flex min-w-0 max-w-full items-center`,children:a?/* @__PURE__ */ (0,Y.jsx)(my,{annotations:o,cutoutColor:`var(--color-dashboard-surface-panel)`}):/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[i.labeledGroups.map(e=>/* @__PURE__ */ (0,Y.jsx)(gy,{group:e},e.label)),i.overflowGroupCount>0?/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`inline-flex h-5 min-w-7 shrink-0 items-center justify-center rounded-full border border-dashboard-border-strong bg-dashboard-control px-1.5 font-sans text-2xs tabular-nums leading-none text-dashboard-text-muted`,children:[`+`,i.overflowGroupCount]}):null]})})}),/* @__PURE__ */ (0,Y.jsxs)(Cr,{align:`start`,children:[/* @__PURE__ */ (0,Y.jsx)(Sr,{children:`Linked work`}),/* @__PURE__ */ (0,Y.jsx)(`ul`,{className:`m-0 list-none space-y-1 p-0`,children:t.map((e,t)=>/* @__PURE__ */ (0,Y.jsxs)(`li`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.objectType?/* @__PURE__ */ (0,Y.jsx)(th,{...e,objectType:e.objectType,size:14}):e.icon?/* @__PURE__ */ (0,Y.jsx)(xy,{icon:e.icon}):null,/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:r[t]})]},`${e.key}:${t}`))})]})]})}function my(e){return/* @__PURE__ */ (0,Y.jsx)(`span`,{className:K(`relative isolate inline-flex h-[18px] min-w-0 items-center`,e.className),children:/* @__PURE__ */ (0,Y.jsx)(hy,{className:`-m-0.5 h-[22px] min-w-[22px] p-0.5`,icons:e.annotations.map((t,n)=>/* @__PURE__ */ (0,Y.jsx)(_y,{annotation:t,cutoutColor:e.cutoutColor,stacked:n>0,zIndex:n+1},t.key)),overflow:t=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{"aria-hidden":`true`,className:`relative -ml-0.5 box-border inline-flex h-[18px] min-w-[18px] shrink-0 items-center justify-center rounded-full border border-dashboard-border-strong bg-dashboard-control px-1 font-sans text-2xs tabular-nums leading-none text-dashboard-text-muted`,style:{boxShadow:`0 0 0 2px ${e.cutoutColor}`,zIndex:e.annotations.length+1},children:[`+`,t]})})})}function hy(e){let t=(0,J.useRef)(null),n=(0,J.useRef)(null),r=e.icons.length,[i,a]=(0,J.useState)(r);return(0,J.useLayoutEffect)(()=>{let e=t.current;if(!e)return;let i=()=>{let t=Array.from(e.children),n=t[0]?.getBoundingClientRect().bottom??0;return t.filter(e=>e.getBoundingClientRect().top<n).length},o=()=>{let e=n.current;e&&(e.style.display=`none`);let t=i();e&&(e.style.display=``),a(t===r||!e?t:i())};o();let s=new ResizeObserver(o);return s.observe(e),()=>s.disconnect()},[i,r]),/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:K(`flex flex-wrap items-center gap-y-6 overflow-hidden`,e.className),ref:t,children:e.icons}),i<r?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`contents`,ref:n,children:e.overflow(r-i)}):null]})}function gy(e){return/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`inline-flex h-5 items-center gap-1 rounded-full border border-dashboard-border-strong bg-dashboard-control px-1.5 font-sans text-2xs leading-none text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,Y.jsx)(hy,{className:`h-3.5 min-w-3.5 gap-x-1`,icons:e.group.annotations.flatMap(e=>e.objectType?/* @__PURE__ */ (0,J.createElement)(th,{...e,objectType:e.objectType,key:e.key,decorative:!0,size:14}):e.icon?/* @__PURE__ */ (0,Y.jsx)(xy,{decorative:!0,icon:e.icon,size:11},e.key):[]),overflow:e=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[`+`,e]})}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`max-w-40 shrink-0 truncate whitespace-nowrap`,children:e.group.label})]})}function _y(e){let t=e.annotation.icon?by[e.annotation.icon]:void 0;return/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:K(`relative box-border inline-flex size-[18px] shrink-0 items-center justify-center rounded-full border border-dashboard-border-strong bg-dashboard-control`,e.stacked&&`-ml-1`),style:{boxShadow:`0 0 0 2px ${e.cutoutColor}`,zIndex:e.zIndex},title:t?.label,children:e.annotation.objectType?/* @__PURE__ */ (0,Y.jsx)(th,{...e.annotation,objectType:e.annotation.objectType,decorative:!0,size:12}):e.annotation.icon?/* @__PURE__ */ (0,Y.jsx)(xy,{decorative:!0,icon:e.annotation.icon,size:11}):/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-sans text-2xs font-semibold leading-none text-dashboard-text-muted`,children:e.annotation.label.slice(0,1)})})}function vy(){return(0,J.useSyncExternalStore)(e=>{if(typeof window>`u`)return()=>{};let t=window.matchMedia(Il);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)},()=>typeof window<`u`&&window.matchMedia(`(width < 48rem) or ((width < 64rem) and (height < 30rem))`).matches,()=>!1)}function yy(e){return[e.objectType?[Rr({objectType:e.objectType}).label,e.status].filter(Boolean).join(`: `):``,e.key.includes(`/`)||e.key.includes(`#`)?e.key:e.label].filter(Boolean).join(` · `)}const by={"circle-dot":{className:`text-[#3fb950] light:text-[#1a7f37]`,Icon:Ft,label:`Open`},"circle-dashed":{className:`text-[#8c959f] light:text-[#59636e]`,Icon:Nt,label:`Draft`},"circle-x":{className:`text-[#f85149] light:text-[#cf222e]`,Icon:cn,label:`Closed`},"git-merge":{className:`text-[#a371f7] light:text-[#8250df]`,Icon:$n,label:`Merged`},"git-pull-request":{className:`text-[#3fb950] light:text-[#1a7f37]`,Icon:En,label:`Open pull request`},"triangle-alert":{className:`text-[#d29922] light:text-[#9a6700]`,Icon:kn,label:`Needs attention`}};function xy(e){let t=by[e.icon],n=e.size??11;return/* @__PURE__ */ (0,Y.jsxs)(`span`,{"aria-hidden":e.decorative?!0:void 0,className:K(`inline-flex shrink-0 items-center justify-center leading-none`,t.className),style:{width:n,height:n},title:e.decorative?void 0:t.label,children:[/* @__PURE__ */ (0,Y.jsx)(t.Icon,{"aria-hidden":`true`,className:`block`,size:n,strokeWidth:2.25}),e.decorative?null:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`sr-only`,children:t.label})]})}function Sy(e){return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`flex gap-x-4 gap-y-2 overflow-x-auto`,children:e.links.map(e=>/* @__PURE__ */ (0,Y.jsxs)(tf,{className:`inline-flex min-w-0 max-w-full shrink-0 items-center gap-2 rounded-md px-1 py-0.5 font-sans text-xs leading-snug text-dashboard-text no-underline transition-colors hover:text-dashboard-accent-text focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus`,href:e.url,title:[e.label,e.plugin,Pg(e.status),e.description].filter(Boolean).join(` · `),children:[/* @__PURE__ */ (0,Y.jsx)(th,{facts:e.facts,objectType:e.objectType,size:16,status:e.status}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]},e.key))})}function Cy(e){return e.locationUrl?/* @__PURE__ */ (0,Y.jsx)(tf,{className:ra,href:e.locationUrl,children:e.label}):e.label}function wy(e){let t=e.sourceTask.id?.trim(),n=e.sourceTask.title?.trim(),r=n?`Automation: ${n}`:`Automation`;return t?/* @__PURE__ */ (0,Y.jsx)(V,{className:ra,to:Ka(t),children:r}):/* @__PURE__ */ (0,Y.jsx)(`span`,{children:r})}function Ty(e){if(!e)return;let t=/* @__PURE__ */ new Set,n;for(let r of e.events){let e=r.data;e.type===`turn_lifecycle`?(e.state===`started`?t.add(e.turnId):t.delete(e.turnId),t.size===0&&(n=void 0)):t.size>0&&r.model&&(n=r.model.modelId)}return t.size>0?n:void 0}function Ey(e){return Ay(e).length>0}function Dy(e){let t=Ay(e);return t.length===0?null:/* @__PURE__ */ (0,Y.jsx)(`dl`,{className:`m-0 grid min-w-0 gap-2 text-xs leading-snug`,children:t.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:K(`flex min-w-0 items-baseline justify-between gap-4`,e.mobileOnly&&`md:hidden`),children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{className:`shrink-0 text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{className:`m-0 min-w-0 break-words text-right tabular-nums text-dashboard-text`,children:e.content})]},e.key))})}function Oy(e,t){if(!e)return null;let n=Ha(e,{includeId:!1});return n?/* @__PURE__ */ (0,Y.jsx)(Cy,{label:n,locationUrl:t?.locationUrl??e.locationUrl}):null}function ky(e,t,n){if(!e)return null;let r=Ea(t?.cumulativeUsage??e.cumulativeUsage),i=t?.auxiliaryCosts??e.auxiliaryCosts,a=(t?.status??e.status)===`active`;return!r&&!i&&!a?null:/* @__PURE__ */ (0,Y.jsx)(ay,{auxiliaryCosts:i,childAgentTotals:t?.childAgentTotals??e.childAgentTotals,live:a,liveModelId:Ty(t),modelUsage:t?.modelUsage,summary:r,tooltipPlacement:n})}function Ay(e){if(!e.conversation)return[];let t=e.detail?.previousCursor?void 0:e.detail,n=e.detail?.cumulativeUsage??e.conversation.cumulativeUsage,r=ba(e.detail?.modelUsage)??Ca(n),i=La(e.conversation),a=(e.detail?.status??e.conversation.status)===`active`,o=Ty(e.detail),s=e.detail?.sourceTask,c=e.detail?.childAgentTotals??e.conversation.childAgentTotals,l=e.conversation.lastSeenAt,u=Oy(e.conversation,e.detail),d=e.showUsageBreakdown?null:ky(e.conversation,e.detail);return[u?{content:u,key:`location`,label:`Location`,mobileOnly:!0}:void 0,s?{content:/* @__PURE__ */ (0,Y.jsx)(wy,{sourceTask:s}),key:`source-task`,label:`Source`}:void 0,l?{content:/* @__PURE__ */ (0,Y.jsx)(`time`,{dateTime:l,title:to(l,{dateStyle:`medium`,timeStyle:`short`}),children:no(l)}),key:`last-activity`,label:`Last activity`}:void 0,i===`none`?void 0:{content:/* @__PURE__ */ (0,Y.jsx)(sy,{childAgentTotals:c,durationMs:e.conversation.cumulativeDurationMs,endedAt:e.conversation.lastSeenAt,label:i,startedAt:e.conversation.startedAt}),key:`duration`,label:`Runtime`},r&&!e.showUsageBreakdown?{content:/* @__PURE__ */ (0,Y.jsx)(oy,{childAgentTotals:c,compactionCount:t?t.events.filter(e=>e.data.type===`compaction`).length:void 0,live:a,liveModelId:o,modelUsage:e.detail?.modelUsage,summary:r}),key:`tokens`,label:`Tokens`}:void 0,d?{content:d,key:`cost`,label:`Cost`}:void 0,c?{content:/* @__PURE__ */ (0,Y.jsx)(cy,{childAgentTotals:c}),key:`subagents`,label:`Child conversations`}:void 0].filter(e=>e!==void 0)}function jy(e){let t=Pl(e.onClose);return/* @__PURE__ */ (0,Y.jsx)(Sl,{...t.rootProps,children:/* @__PURE__ */ (0,Y.jsxs)(El,{...t.contentProps,"aria-label":e.label,side:`bottom`,className:K(`mx-auto w-full max-w-2xl gap-0 rounded-t-2xl outline-none`,e.size===`content`?`max-h-[85dvh]`:`max-h-full data-[side=bottom]:h-[85dvh]`),children:[/* @__PURE__ */ (0,Y.jsx)(Dl,{className:`border-b border-dashboard-border`,children:/* @__PURE__ */ (0,Y.jsx)(Ol,{className:`break-words`,children:e.title??e.label})}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain [scrollbar-gutter:stable]`,children:e.children})]})})}const My=`(min-width: 1280px)`;function Ny(e){let t=window.matchMedia(My);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function Py(){return window.matchMedia(My).matches}function Fy(){return(0,J.useSyncExternalStore)(Ny,Py,()=>!1)}function Iy(e){let{onClose:t,overlay:n}=e,r=`Close ${e.label.toLowerCase()}`,i=Fy(),a=(0,J.useRef)(null),o=(0,J.useRef)(i);return(0,J.useEffect)(()=>{i&&!o.current&&!document.querySelector(`[data-dashboard-modal]`)&&a.current?.focus({preventScroll:!0}),o.current=i},[i]),(0,J.useEffect)(()=>{if(!i||n)return;function e(e){e.key===`Escape`&&!e.defaultPrevented&&!document.querySelector(`[data-dashboard-modal]`)&&(e.preventDefault(),t())}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,n,t]),i?n?/* @__PURE__ */ (0,Y.jsx)(m_,{actions:e.actions,closeLabel:r,header:e.title,label:e.label,onClose:t,openKey:e.label,width:`wide`,children:e.children}):/* @__PURE__ */ (0,Y.jsxs)(`aside`,{"aria-label":e.label,className:`grid min-h-0 min-w-0 grid-rows-[auto_minmax(0,1fr)] border-l border-dashboard-border bg-dashboard-bg-elevated`,children:[/* @__PURE__ */ (0,Y.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-dashboard-border py-2 pl-5 pr-3`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:e.title}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[e.actions,/* @__PURE__ */ (0,Y.jsx)(H,{ref:a,"aria-label":r,"data-slot":`details-panel-close`,onClick:t,size:`icon`,children:/* @__PURE__ */ (0,Y.jsx)(Xn,{"aria-hidden":`true`,size:15})})]})]}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`thin-scrollbar min-h-0 overflow-y-auto overscroll-contain [scrollbar-gutter:stable]`,children:e.children})]}):/* @__PURE__ */ (0,Y.jsx)(jy,{label:e.label,title:e.sheetTitle,onClose:t,children:e.actions?/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid h-full min-h-0 grid-rows-[minmax(0,1fr)_auto]`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`min-h-0`,children:e.children}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`flex justify-end gap-1 border-t border-dashboard-border px-4 py-2`,children:e.actions})]}):e.children})}const Ly=`junior:conversation:sidebar-open`,Ry=`junior:conversation:details-open`,zy=`junior:conversation:sidebar-width`,By=`junior:conversation:details-width`,Vy={default:320,max:480,min:240},Hy={default:400,max:720,min:320};function Uy(){let[e,t]=(0,J.useState)(()=>eb(Ly)!==`false`);function n(e){t(e),tb(Ly,String(e))}return[e,n]}function Wy(){let e=eb(Ry);return e===null?void 0:e===`true`}function Gy(e){Py()&&tb(Ry,String(e))}function Ky(){return Xy(zy,Vy)}function qy(e){tb(zy,String(Math.round(e)))}function Jy(){return Xy(By,Hy)}function Yy(e){tb(By,String(Math.round(e)))}function Xy(e,t){let n=Number(eb(e));return!Number.isFinite(n)||n<=0?t.default:Math.min(t.max,Math.max(t.min,n))}function Zy(){return(0,J.useSyncExternalStore)(e=>{let t=window.matchMedia(Fl);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)},()=>window.matchMedia(Fl).matches,()=>!1)}const Qy=`(min-width: 1440px)`;function $y(){return(0,J.useSyncExternalStore)(e=>{let t=window.matchMedia(Qy);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)},()=>window.matchMedia(Qy).matches,()=>!1)}function eb(e){try{return window.localStorage.getItem(e)}catch{return null}}function tb(e,t){try{window.localStorage.setItem(e,t)}catch{}}const nb=`conversation-side-panel`;function rb(e){let t=Fy(),n=(0,J.useRef)(null),r=(0,J.useRef)(null),i=(0,J.useRef)(null),[a]=(0,J.useState)(()=>{if(typeof document>`u`)return;let e=document.createElement(`div`);return e.className=`grid min-h-0 min-w-0`,e}),o=e.side!==void 0,s=o&&t;return(0,J.useLayoutEffect)(()=>{let e=s?r.current:i.current;a&&e&&a.parentNode!==e&&e.append(a)},[a,s]),/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(Vm,{className:`min-h-0 min-w-0`,elementRef:n,onLayoutChanged:(e,t)=>{if(!t.isUserInteraction)return;let r=e[nb]??0,i=n.current?.offsetWidth??0;r>0&&Yy(r/100*i)},children:[/* @__PURE__ */ (0,Y.jsx)(Hm,{className:`grid min-h-0`,id:`conversation-transcript`,minSize:448,children:e.children}),s?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(Um,{"aria-label":`Resize details panel`,className:`w-px bg-transparent transition-colors after:w-2 focus-visible:ring-dashboard-border-interactive data-[separator=active]:bg-dashboard-border-interactive data-[separator=hover]:bg-dashboard-border-interactive`}),/* @__PURE__ */ (0,Y.jsx)(Hm,{className:`grid min-h-0`,defaultSize:Jy(),groupResizeBehavior:`preserve-pixel-size`,id:nb,maxSize:Hy.max,minSize:Hy.min,children:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`grid h-full min-h-0`,ref:r})})]}):null]}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`contents`,ref:i}),o?a?(0,ou.createPortal)(e.side,a):e.side:null]})}const ib=1.65;function ab(e){let{lines:t}=e,n=(0,J.useId)(),r=(0,J.useRef)(null),i=(0,J.useRef)(null),a=(0,J.useRef)(null),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(!1),u=o&&!c;return(0,J.useLayoutEffect)(()=>{let e=r.current,n=i.current;if(!e||!n)return;let o=()=>{let r=Number.parseFloat(getComputedStyle(e).lineHeight),i=r*t,o=n.getBoundingClientRect().height>i+.5,c=document.activeElement;o&&c&&n.contains(c)&&c.getBoundingClientRect().bottom>e.getBoundingClientRect().top+i-r*ib?l(!0):!o&&c&&c===a.current&&e.focus({preventScroll:!0}),s(o)};o();let c=new ResizeObserver(o);return c.observe(n),()=>c.disconnect()},[t]),(0,J.useLayoutEffect)(()=>{let e=a.current;!c&&e&&document.activeElement===e&&e.scrollIntoView({block:`nearest`})},[c]),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`relative min-w-0`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:K(e.className,u&&`overflow-clip`),id:n,onFocusCapture:e=>{if(!u)return;let t=e.currentTarget,n=Number.parseFloat(getComputedStyle(t).lineHeight);e.target.getBoundingClientRect().bottom>t.getBoundingClientRect().bottom-n*ib&&l(!0)},ref:r,style:u?{maskImage:`linear-gradient(black calc(100% - ${ib}lh), transparent)`,maxHeight:`${t}lh`}:void 0,tabIndex:-1,children:/* @__PURE__ */ (0,Y.jsx)(`div`,{ref:i,children:e.children})}),o?/* @__PURE__ */ (0,Y.jsx)(`button`,{"aria-controls":n,"aria-expanded":c,"aria-label":`${c?`Collapse`:`Expand`} ${e.label}`,className:K(`group flex h-6 w-8 cursor-pointer items-center justify-center rounded-full focus-visible:outline-2 focus-visible:outline-dashboard-focus`,u?`absolute bottom-0 left-1/2 -translate-x-1/2`:`mx-auto mt-1`),onClick:()=>l(e=>!e),ref:a,type:`button`,children:/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-5 place-items-center rounded-full border border-dashboard-border bg-dashboard-ink text-dashboard-text-solid transition-[filter] group-hover:brightness-95 dark:bg-dashboard-text-solid dark:text-dashboard-text-inverse`,children:/* @__PURE__ */ (0,Y.jsx)(Ut,{className:`size-4 group-aria-expanded:rotate-180`,strokeWidth:2.25})})}):null]})}function ob(e){return/* @__PURE__ */ (0,Y.jsx)(`dl`,{className:K(`grid gap-px overflow-hidden rounded-md border border-dashboard-border-subtle bg-dashboard-fill-hover`,e.className),children:e.children})}function sb(e){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`min-w-0 bg-dashboard-bg-elevated px-3 py-3`,children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{className:K(`mt-1.5 ml-0 break-words text-sm leading-relaxed text-dashboard-text`,e.valueClassName),children:e.children})]})}const cb={abandoned:`neutral`,answered:`info`,blocked:`danger`,done:`success`,in_progress:`accent`,partial:`warning`};function lb(e){let{content:t}=e.brief,n=e.brief.mentions;return e.variant===`summary`?/* @__PURE__ */ (0,Y.jsx)(ab,{className:`leading-6`,label:`Brief summary`,lines:4,children:/* @__PURE__ */ (0,Y.jsx)($,{compact:!0,mentions:n,text:t.summary})}):/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-3`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[/* @__PURE__ */ (0,Y.jsx)(gp,{tone:cb[t.outcome.status],children:pb(t.outcome.status)}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`text-xs text-dashboard-text-muted`,children:[`Brief v`,e.brief.version,` · updated`,` `,to(e.brief.updatedAt,{dateStyle:`medium`,timeStyle:`short`})]})]}),/* @__PURE__ */ (0,Y.jsx)($,{mentions:n,text:t.summary}),/* @__PURE__ */ (0,Y.jsx)(ub,{title:`Intent & outcome`,children:/* @__PURE__ */ (0,Y.jsxs)(ob,{children:[/* @__PURE__ */ (0,Y.jsx)(sb,{label:`Intent`,children:/* @__PURE__ */ (0,Y.jsx)($,{mentions:n,text:t.intent})}),/* @__PURE__ */ (0,Y.jsx)(sb,{label:`Outcome`,children:/* @__PURE__ */ (0,Y.jsx)($,{mentions:n,text:t.outcome.text})})]})}),t.decisions.length?/* @__PURE__ */ (0,Y.jsx)(ub,{title:`Decisions`,children:/* @__PURE__ */ (0,Y.jsx)(db,{decisions:t.decisions,mentions:n})}):null,t.facts.length||t.links.length||t.keywords.length?/* @__PURE__ */ (0,Y.jsx)(ub,{title:`Facts, links & keywords`,children:/* @__PURE__ */ (0,Y.jsxs)(ob,{children:[t.facts.length?/* @__PURE__ */ (0,Y.jsx)(sb,{label:`Facts`,children:/* @__PURE__ */ (0,Y.jsx)(fb,{items:t.facts,mentions:n})}):null,t.links.length?/* @__PURE__ */ (0,Y.jsx)(sb,{label:`Links`,children:/* @__PURE__ */ (0,Y.jsx)(`ul`,{className:`m-0 grid list-none gap-2 p-0`,children:t.links.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[/* @__PURE__ */ (0,Y.jsx)(tf,{className:`min-w-0 break-all font-medium text-dashboard-accent-text underline decoration-dashboard-accent/30 underline-offset-2 hover:text-dashboard-accent-text`,href:e.url,children:e.label}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,children:pb(e.kind)}),e.status?/* @__PURE__ */ (0,Y.jsx)(gp,{size:`compact`,tone:mb(e.status),children:e.status}):null]},`${e.kind}:${e.url}`))})}):null,t.keywords.length?/* @__PURE__ */ (0,Y.jsx)(sb,{label:`Keywords`,children:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.keywords.map(e=>/* @__PURE__ */ (0,Y.jsx)(gp,{size:`compact`,children:e},e))})}):null]})}):null]})}function ub(e){return/* @__PURE__ */ (0,Y.jsxs)(nh,{className:`min-w-0 border-t border-dashboard-border pt-3`,children:[/* @__PURE__ */ (0,Y.jsxs)(rh,{className:`group flex w-full cursor-pointer items-center gap-2 text-left text-sm font-medium text-dashboard-text focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus`,children:[/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,className:K(ia,`text-dashboard-text-muted`)}),e.title]}),/* @__PURE__ */ (0,Y.jsx)(ih,{hiddenUntilFound:!0,children:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`mt-3`,children:e.children})})]})}function db(e){return/* @__PURE__ */ (0,Y.jsx)(`ul`,{className:`m-0 grid list-none gap-2.5 p-0`,children:e.decisions.map((t,n)=>/* @__PURE__ */ (0,Y.jsxs)(`li`,{children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[/* @__PURE__ */ (0,Y.jsx)(gp,{size:`compact`,tone:t.kind===`assumed`?`warning`:`info`,children:t.kind}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0`,children:/* @__PURE__ */ (0,Y.jsx)($,{inline:!0,mentions:e.mentions,text:t.text})})]}),t.by?/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`mt-0.5 text-xs text-dashboard-text-muted`,children:[`by ·`,` `,/* @__PURE__ */ (0,Y.jsx)($,{inline:!0,mentions:e.mentions,text:t.by})]}):null]},`${t.text}:${n}`))})}function fb(e){return/* @__PURE__ */ (0,Y.jsx)(`ul`,{className:`my-0 grid gap-1.5 pl-4`,children:e.items.map((t,n)=>/* @__PURE__ */ (0,Y.jsx)(`li`,{children:/* @__PURE__ */ (0,Y.jsx)($,{inline:!0,mentions:e.mentions,text:t})},`${t}:${n}`))})}function pb(e){return e.replaceAll(`_`,` `)}function mb(e){return e===`merged`||e===`done`?`success`:e===`closed`||e===`blocked`?`danger`:e===`open`||e===`in_progress`?`accent`:`neutral`}const hb={accent:`bg-violet-300`,danger:`bg-rose-300`,info:`bg-cyan-300`,neutral:`bg-dashboard-text-faint`,success:`bg-emerald-300`,warning:`bg-amber-300`};function gb(e){return/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:K(`inline-flex shrink-0 items-center`,e.className),title:e.label,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:K(`size-1.5 rounded-full`,hb[e.tone??`neutral`])}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`sr-only`,children:e.label})]})}const _b={active:`info`,blocked:`warning`,completed:`success`,error:`danger`,failed:`danger`,paused:`info`,running:`info`};function vb(e){return _b[e]??`neutral`}const yb={danger:`text-rose-200/85`,warning:`text-amber-200/85`};function bb(e){return L({queryFn:({signal:t})=>G(bi,`/api/conversations/${encodeURIComponent(e)}/agents`,t),queryKey:rd(e,`agents`),retry:!1})}function xb(e){let t=(0,J.useContext)(kv),{action:n,items:r}=Cb(e.threads);return/* @__PURE__ */ (0,Y.jsx)(yg,{action:n,count:r.length,flat:!0,label:`Threads`,title:`Threads`,children:r.length>0?/* @__PURE__ */ (0,Y.jsx)(bg,{itemKey:e=>e.conversationId,items:r,renderItem:e=>/* @__PURE__ */ (0,Y.jsx)(Db,{agent:e,title:t.get(e.conversationId)?.displayTitle,to:kc(e.conversationId)})}):/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0`,children:`Every Thread is archived.`})})}function Sb(e){let{action:t,items:n}=Cb(e.tasks);return/* @__PURE__ */ (0,Y.jsx)(yg,{action:t,count:n.length,flat:!0,label:`Tasks`,title:`Tasks`,children:n.length>0?/* @__PURE__ */ (0,Y.jsx)(bg,{itemKey:e=>e.conversationId,items:n,renderItem:t=>/* @__PURE__ */ (0,Y.jsx)(Db,{agent:t,onOpen:()=>e.onOpenTask({conversationId:t.conversationId,...t.redacted?void 0:{...t.name?{agentName:t.name}:void 0,label:t.title??t.name},status:t.status})})}):/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0`,children:`Every Task is archived.`})})}function Cb(e){let[t,n]=(0,J.useState)(!1),r=e.filter(e=>e.archivedAt).length;return{action:r>0?/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`cursor-pointer rounded-md px-1.5 py-0.5 font-sans text-xs text-dashboard-text-muted transition-colors hover:bg-dashboard-surface-hover hover:text-dashboard-text focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus`,onClick:()=>n(e=>!e),type:`button`,children:t?`Hide archived`:`Show archived (${r})`}):null,items:t?e:e.filter(e=>!e.archivedAt)}}const wb={active:Ft,blocked:Gn,completed:tn,error:cn,failed:cn,paused:un},Tb={accent:`text-violet-300`,danger:`text-rose-300`,info:`text-cyan-300`,neutral:`text-dashboard-text-faint`,success:`text-emerald-300`,warning:`text-amber-300`};function Eb(e){let t=e.archived?bn:e.status===`running`?_p:wb[e.status]??_r;return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(t,{"aria-hidden":`true`,className:K(`size-3.5`,e.archived?`text-dashboard-text-faint`:Tb[vb(e.status)])}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`sr-only`,children:e.archived?`archived`:e.status})]})}function Db(e){let{agent:t}=e,n=vb(t.status),r=t.task?.trim(),i=e.title??t.title??r,a=t.kind===`thread`?`Thread`:`Task`,o=t.redacted?`Private ${a.toLowerCase()}`:t.name,s=t.childAgentTotals?.count,c=[i?o:``,eo(t.cumulativeUsage),Qa(t.cumulativeUsage,t.auxiliaryCosts),s?`+${s} nested`:``].filter(Boolean);return/* @__PURE__ */ (0,Y.jsxs)(xg,{icon:/* @__PURE__ */ (0,Y.jsx)(Eb,{archived:!!t.archivedAt,status:t.status}),meta:Ia(t.cumulativeDurationMs),onClick:e.onOpen,title:i??o??a,to:e.to,tooltip:[r&&r!==i?r:``,`Updated ${to(t.updatedAt,{dateStyle:`medium`,timeStyle:`short`})}`].filter(Boolean).join(`
|
|
15
|
-
`),children:[c.length>0||t.redacted?/* @__PURE__ */ (0,Y.jsxs)(Sg,{className:`flex items-center gap-1.5`,children:[t.redacted?/* @__PURE__ */ (0,Y.jsx)(Wt,{"aria-hidden":`true`,className:`size-3 shrink-0`}):null,/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:c.join(` · `)})]}):null,t.error?/* @__PURE__ */ (0,Y.jsx)(Sg,{className:K(`line-clamp-2 whitespace-pre-wrap break-words`,yb[n]),children:t.error}):null]})}function Ob(e,t,n){let r=e[0];return{count:e.filter(e=>e.seq>t.afterSeq&&e.seq<=t.throughSeq&&e.data.type===`message`).length,more:n.hasNewerPage||!!(n.hasPreviousPage&&r&&r.seq>t.afterSeq+1)}}function kb(e,t,n){if(n.hasNewerPage)return!0;let r=e[0];if(n.hasPreviousPage&&r&&r.seq>t.afterSeq)return!0;let i=0;for(let n of e)n.seq<=t.afterSeq||n.seq>t.throughSeq||n.data.type===`turn_lifecycle`&&n.data.state!==`started`&&(i+=1);return i>=2}function Ab(e){let{unread:t}=e,n=N({mutationFn:t=>Qi(wi,`/api/conversations/${encodeURIComponent(e.conversationId)}/catch-up`,t)}),r=!n.isIdle;if(t&&(r||e.events&&kb(e.events,t,e)))return{data:n.data,error:n.isError,pending:n.isPending,request:()=>n.mutate(t),unreadMessages:Ob(e.events??[],t,e)}}const jb=(0,J.createContext)(void 0);function Mb(){return(0,J.useContext)(jb)}const Nb=`grid gap-2.5 rounded-lg border border-dashboard-accent/20 bg-dashboard-accent/10 px-3.5 py-3 font-sans text-sm leading-relaxed text-dashboard-text`;function Pb(){let e=Mb();if(!e||e.data||e.pending)return null;let{count:t,more:n}=e.unreadMessages,r=t>99?`99+`:`${t}${n?`+`:``}`;return/* @__PURE__ */ (0,Y.jsxs)(`button`,{"aria-label":t?`Catch me up, ${r} new ${t===1&&!n?`message`:`messages`}`:void 0,className:`inline-flex h-6 shrink-0 cursor-pointer items-center gap-1 rounded-full border border-dashboard-accent/30 bg-transparent px-2.5 font-sans text-xs font-medium text-dashboard-accent-text transition-colors hover:border-dashboard-accent/60 hover:bg-dashboard-accent/10 focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-1 focus-visible:outline-dashboard-focus/55`,onClick:e.request,type:`button`,children:[/* @__PURE__ */ (0,Y.jsx)(Cn,{"aria-hidden":`true`,size:12,strokeWidth:2}),`Catch me up`,t?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`-mr-1 ml-0.5 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-dashboard-accent/15 px-1 text-2xs font-semibold leading-none tabular-nums`,children:r}):null]})}function Fb(){let e=Mb(),t=(0,J.useContext)(Vp),n=(0,J.useRef)(null),r=e?.data?`data`:e?.pending?`pending`:void 0;return(0,J.useEffect)(()=>{if(!r)return;let e=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>{(n.current?.closest(`[data-transcript-unread-marker]`))?.scrollIntoView({block:`nearest`})})});return()=>cancelAnimationFrame(e)},[r]),e?.data?/* @__PURE__ */ (0,Y.jsxs)(`div`,{"aria-label":`Catch-up`,className:Nb,ref:n,role:`group`,children:[/* @__PURE__ */ (0,Y.jsx)($,{text:e.data.summary}),e.data.needsYou?/* @__PURE__ */ (0,Y.jsxs)(`p`,{className:`m-0 border-t border-dashboard-accent/15 pt-2.5`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-semibold text-dashboard-accent-text`,children:`Needs you`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`px-1.5 text-dashboard-text-muted`,children:`·`}),e.data.needsYou]}):null,t?/* @__PURE__ */ (0,Y.jsxs)(H,{className:`-mb-1 h-7 justify-self-center gap-1.5 px-2 text-xs`,onClick:t,variant:`quiet`,children:[/* @__PURE__ */ (0,Y.jsx)(Gt,{"aria-hidden":`true`,size:14,strokeWidth:2}),`Jump to latest`]}):null]}):e?.error?/* @__PURE__ */ (0,Y.jsx)(h_,{className:`text-center text-xs`,children:`Catch-up failed. Try again.`}):e?.pending?/* @__PURE__ */ (0,Y.jsxs)(`div`,{"aria-label":`Summarizing new messages`,className:Nb,ref:n,role:`status`,children:[/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-4 w-full`}),/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-4 w-2/3`})]}):null}const Ib=`grid-cols-[1.5rem_minmax(0,1fr)] gap-2 md:grid-cols-[2rem_minmax(0,1fr)] md:gap-3`,Lb=`mt-1 size-6 md:mt-0 md:size-8`;function Rb({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{...t,className:K(`grid min-w-0 grid-cols-[minmax(0,1fr)] gap-1`,e)})}function zb(){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid gap-2 py-1`,"data-transcript-unread-marker":``,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_1fr] items-center gap-3`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-label":`New messages`,className:`h-px bg-dashboard-accent/50`,role:`separator`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`font-sans text-xs font-semibold text-dashboard-accent-text`,children:`New`}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`h-px flex-1 bg-dashboard-accent/50`}),/* @__PURE__ */ (0,Y.jsx)(Pb,{})]})]}),/* @__PURE__ */ (0,Y.jsx)(Fb,{})]})}const Bb=(0,J.createContext)(null);function Vb(e){let t=(0,J.useContext)(Bb),[n,r]=(0,J.useState)(()=>e!==void 0&&t?.get(e)||!1);return[n,n=>{r(n),e!==void 0&&t?.set(e,n)}]}function Hb(e){return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:K(`py-1.5`,e.indent&&K(`grid`,`grid-cols-[1.5rem_minmax(0,1fr)] gap-2 md:grid-cols-[2rem_minmax(0,1fr)] md:gap-3`)),"data-scroll-anchor":e.anchorKey,"data-transcript-seq":e.seq,children:e.indent?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`col-start-2 min-w-0`,children:e.children}):e.children})}const Ub=[[`running`,`running`],[`blocked`,`blocked`],[`error`,`failed`],[`aborted`,`stopped`]],Wb={aborted:`stopped`,blocked:`blocked`,completed:`completed`,error:`failed`,running:`running`};function Gb(e){return e.title??e.agentName??e.task??e.subagentKind}function Kb(e){if(e.some(e=>e.part.status===`running`))return;let t=e.flatMap(e=>typeof e.timestamp==`number`?[e.timestamp]:[]),n=e.flatMap(e=>typeof e.part.finishedTimestamp==`number`?[e.part.finishedTimestamp]:[]);if(t.length!==0&&n.length!==0)return Ga(Math.min(...t),Math.max(...n))}function qb(e){if(e.length===1)return Wb[e[0].part.status];let t=Ub.flatMap(([t,n])=>{let r=e.filter(e=>e.part.status===t).length;return r>0?[`${r} ${n}`]:[]});return t.length>0?t.join(` · `):`completed`}function Jb(e){return/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:K(`size-2 shrink-0 rounded-xs`,hb[vb(e.status)],e.status===`running`&&`animate-pulse motion-reduce:animate-none`)})}const Yb=`group/tasks flex min-w-0 max-w-full cursor-pointer items-center gap-1.5 rounded-md bg-transparent px-1.5 py-0.5 -mx-1.5 text-left font-sans text-sm leading-6 text-dashboard-text-muted transition-colors hover:bg-dashboard-surface-hover hover:text-dashboard-text focus-visible:outline-2 focus-visible:outline-dashboard-focus`;function Xb(e){let{active:t}=sh(),[n,r]=Vb(e.openKey),i=e.entries.length===1?e.entries[0]:void 0,a=!i&&(n||t),o=qb(e.entries),s=Kb(e.entries),c=/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[i?/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`Task · `,/* @__PURE__ */ (0,Y.jsx)(Q,{text:Gb(i.part)})]}):/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`shrink-0`,children:[e.entries.length,` Tasks`]}),/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`shrink-0`,children:o}),s?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`shrink-0 tabular-nums text-dashboard-text-faint`,children:s}):null,/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,className:K(`size-4 shrink-0 text-dashboard-text-faint transition-transform group-hover/tasks:text-dashboard-text`,a&&`rotate-90`)})]});return i?e.onOpenTranscript?/* @__PURE__ */ (0,Y.jsx)(`button`,{"aria-label":`Open ${Gb(i.part)} transcript`,className:Yb,onClick:()=>e.onOpenTranscript?.(i.part),type:`button`,children:c}):/* @__PURE__ */ (0,Y.jsx)(`div`,{className:K(Yb,`cursor-default`),children:c}):/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,Y.jsx)(`button`,{"aria-expanded":a,className:Yb,onClick:()=>r(!a),type:`button`,children:c}),a?/* @__PURE__ */ (0,Y.jsx)(`ul`,{className:`m-0 mt-1 grid max-w-[37.5rem] list-none gap-0.5 p-0`,children:e.entries.map(t=>/* @__PURE__ */ (0,Y.jsx)(`li`,{children:/* @__PURE__ */ (0,Y.jsx)(Zb,{entry:t,onOpenTranscript:e.onOpenTranscript})},t.key))}):null]})}function Zb(e){let{part:t}=e.entry,n=Gb(t),r=Ga(e.entry.timestamp,t.finishedTimestamp),i=/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(Jb,{status:t.status}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-dashboard-text`,children:/* @__PURE__ */ (0,Y.jsx)(Q,{text:n})}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`shrink-0 text-dashboard-text-muted`,children:Wb[t.status]}),r?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`shrink-0 tabular-nums text-dashboard-text-faint`,children:r}):null]}),a=`flex w-full min-w-0 items-center gap-2.5 rounded-md bg-transparent px-2 py-1 text-left font-sans text-sm leading-5 text-inherit`;return e.onOpenTranscript?/* @__PURE__ */ (0,Y.jsx)(`button`,{"aria-label":`Open ${n} transcript`,className:K(a,`cursor-pointer transition-colors hover:bg-dashboard-surface-hover focus-visible:outline-2 focus-visible:outline-dashboard-focus`),onClick:()=>e.onOpenTranscript?.(t),type:`button`,children:i}):/* @__PURE__ */ (0,Y.jsx)(`div`,{className:a,children:i})}function Qb(e){let t=e.part.childConversationId,n=(0,J.useContext)(kv).get(t),r=hu().has(t),i=om(t),a=n?.displayTitle??e.part.title??e.part.task??`Thread`,o=n?.lastSeenAt??(typeof e.timestamp==`number`?new Date(e.timestamp).toISOString():void 0);return/* @__PURE__ */ (0,Y.jsxs)(V,{...i,className:K(`group/thread flex w-full min-w-0 max-w-[37.5rem] items-center gap-2.5 rounded-lg border border-dashboard-border-subtle bg-dashboard-surface-panel px-3 py-2 text-inherit no-underline transition-colors`,`hover:border-dashboard-border-emphasis hover:bg-dashboard-surface-hover focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus`),to:kc(t),children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-sans text-sm font-medium text-dashboard-text`,children:/* @__PURE__ */ (0,Y.jsx)(Q,{text:a})}),n?/* @__PURE__ */ (0,Y.jsx)(Sp,{status:vp(n,r)}):null,o?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`shrink-0 font-sans text-xs tabular-nums text-dashboard-text-faint`,children:Dc(o)}):null,/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,className:`size-4 shrink-0 text-dashboard-text-faint transition-colors group-hover/thread:text-dashboard-text`})]})}function $b(e){let t=e.part.event,n=t.details?` at approximately ${Wa(t.details.estimatedInputTokens)} estimated tokens`:``,r=t.modelId?` using ${t.modelId}`:``;return/* @__PURE__ */ (0,Y.jsxs)(`article`,{className:`min-w-0 py-0.5`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[/* @__PURE__ */ (0,Y.jsx)(`strong`,{className:`font-sans text-xs font-semibold text-amber-100`,children:`Context compacted`}),typeof e.timestamp==`number`?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,children:Ba(e.timestamp)}):null]}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`mt-1 text-xs leading-relaxed text-dashboard-text-muted`,children:`Earlier context was summarized${n}${r} before execution continued.`}),t.summary?/* @__PURE__ */ (0,Y.jsxs)(nh,{className:`mt-2`,children:[/* @__PURE__ */ (0,Y.jsxs)(rh,{className:`group flex cursor-pointer select-none items-center gap-1 text-xs font-medium text-dashboard-text-muted focus-visible:outline-2 focus-visible:outline-dashboard-focus`,children:[/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,className:ia}),`Continuation summary`]}),/* @__PURE__ */ (0,Y.jsx)(ih,{hiddenUntilFound:!0,children:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`mt-1.5 whitespace-pre-wrap text-xs leading-relaxed text-dashboard-text-muted`,children:/* @__PURE__ */ (0,Y.jsx)($,{mentions:e.part.mentions,text:t.summary})})})]}):null]})}const ex=s({events:u(s({memoryIds:u(p().min(1)).min(1),seq:a().int().min(0),source:o([`captured`,`recalled`]),turnId:p().min(1).optional()}).strict()),memories:u(s({content:p().min(1),id:p().min(1),visibility:o([`private`,`public`])}).strict())}).strict();function tx(e){return L({queryFn:({signal:t})=>G(ex,`/api/plugins/memory/conversations/${encodeURIComponent(e)}/memories`,t),queryKey:rd(e,`memories`),retry:!1})}function nx(e){return`${e.source}:${e.turnId}`}function rx(e,t){let n=e?.events.find(e=>e.source===t.source&&e.turnId===t.turnId);if(!n||!e)return[];let r=new Map(e.memories.map(e=>[e.id,e]));return n.memoryIds.flatMap(e=>{let t=r.get(e);return t?[t]:[]})}function ix(e){if(!e)return[];let t=new Map(e.memories.map(e=>[e.id,e])),n=/* @__PURE__ */ new Set,r=[];for(let i of e.events)for(let e of i.memoryIds){let a=`${i.source}:${e}`,o=t.get(e);!n.has(a)&&o&&(n.add(a),r.push({memory:o,seq:i.seq,source:i.source,...i.turnId?{turnId:i.turnId}:void 0}))}return r}const ax=(0,J.createContext)(void 0);function ox(){return(0,J.useContext)(ax)}function sx(e){return e.namespace===`memory`&&e.name===`memories_captured`}const cx=(0,J.createContext)(!1);function lx(e){let t=ux(e.kind),n=e.icon??t.icon,r=(0,J.useContext)(cx);return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:K(`grid min-w-0 items-start`,r?`grid-cols-[1rem_minmax(0,1fr)] gap-2`:Ib),"data-transcript-rail-event":e.kind,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:K(`grid h-6 place-items-center`,!r&&(e.kind===`thread`||e.kind===`message_context`)&&`mt-1.5`,t.className),children:e.objectType?/* @__PURE__ */ (0,Y.jsx)(th,{objectType:e.objectType,size:14,decorative:!0}):/* @__PURE__ */ (0,Y.jsx)(n,{size:r?14:15,strokeWidth:2})}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`min-w-0`,children:e.children})]})}function ux(e){return e===`message_context`?{className:`text-dashboard-text-muted`,icon:pn}:e===`event`?{className:`text-violet-200`,icon:Bn}:e===`attachments_delivered`?{className:`text-dashboard-text-muted`,icon:Wn}:e===`structured_event`?{className:`text-violet-200`,icon:Sn}:e===`tasks`?{className:`text-cyan-200`,icon:mn}:e===`thread`?{className:`text-cyan-200`,icon:br}:{className:`text-amber-200`,icon:an}}const dx={activity:Sn,brain:xr,calendar:on,check:Yt,database:Ln,info:Nn,key:Tt,link:_n,sparkles:Cn,warning:kn};function fx(e){return e?dx[e]:Sn}function px({className:e,flush:t=!1,...n}){return/* @__PURE__ */ (0,Y.jsx)(rh,{...n,className:K(`cursor-pointer rounded-md px-2 py-1.5 text-left transition-colors hover:bg-dashboard-fill-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus disabled:cursor-default disabled:hover:bg-transparent`,t?`-mx-2 -my-1.5 w-[calc(100%+1rem)]`:`w-full`,e)})}function mx(e,t,n){return e===1?t:`${e} ${n}`}function hx(e){return e.kind===`failure`||e.kind===`attachments_delivered`||e.kind===`subagent`?!1:e.kind===`message`?_f(e.message):!(e.kind===`structured_event`&&sx(e.part))}function gx(e){let t=/* @__PURE__ */ new Set,n=[];for(let r of e){if(r.kind!==`message`)continue;let{message:e}=r;if(e.role===`user`){if(e.noReply){t.add(r.key);continue}n=e.eventType?[...n,r.key]:[]}else if(e.role===`assistant`){if(e.quiet){t.add(r.key);for(let e of n)t.add(e)}n=[]}}return t}function _x(e){return e.kind===`tool`?e.part.startedTimestamp??e.timestamp:e.kind===`message`?e.message.timestamp:e.timestamp}function vx(e){return e.kind===`tool`?e.part.resultTimestamp??e.timestamp:e.kind===`message`?e.message.timestamp:e.timestamp}function yx(e){let t,n;for(let r of e){let e=_x(r),i=vx(r);typeof e==`number`&&Number.isFinite(e)&&(t=t===void 0?e:Math.min(t,e)),typeof i==`number`&&Number.isFinite(i)&&(n=n===void 0?i:Math.max(n,i))}if(!(typeof t!=`number`||typeof n!=`number`||n<t))return n-t}function bx(e){let t=mx(e.length,`1 event`,`events`),n=yx(e);return typeof n!=`number`||n<=0?t:`${t} · ${za(n)}`}function xx(e){let t=e.filter(e=>e.kind===`tool`).length,n=e.filter(e=>e.kind===`reasoning`).length,r=e.filter(e=>e.kind===`context`&&e.part.event.type===`compaction`).length,i=e.filter(e=>e.kind===`structured_event`).length,a=e.filter(e=>e.kind===`attachments_delivered`).length,o=e.filter(e=>e.kind===`message`&&e.message.role!==`assistant`).length,s=e.filter(e=>e.kind===`message`&&e.message.role===`assistant`).length,c=[t>0?mx(t,`1 tool call`,`tool calls`):void 0,n>0?mx(n,`1 reasoning entry`,`reasoning entries`):void 0,r>0?mx(r,`context compacted`,`context compacted`):void 0,i>0?mx(i,`1 structured event`,`structured events`):void 0,a>0?mx(a,`1 file delivery`,`file deliveries`):void 0,o>0?mx(o,`1 event`,`events`):void 0,s>0?mx(s,`1 quiet reply`,`quiet replies`):void 0].filter(e=>e!==void 0);return c.length>0?c.join(` · `):bx(e)}function Sx(e){return e.some(e=>e.kind===`tool`&&e.part.status===`running`)}function Cx(e){let{active:t}=sh(),[n,r]=Vb(e.openKey),i=e.entries.map(t=>/* @__PURE__ */ (0,Y.jsx)(J.Fragment,{children:e.renderEntry(t)},t.key)),a=bx(e.entries),o=xx(e.entries),s=Sx(e.entries);return t?/* @__PURE__ */ (0,Y.jsx)(cx.Provider,{value:!0,children:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`grid min-w-0 gap-1`,children:i})}):/* @__PURE__ */ (0,Y.jsxs)(nh,{className:`min-w-0 py-0.5`,onOpenChange:r,open:n,children:[/* @__PURE__ */ (0,Y.jsx)(px,{flush:!0,className:K(`group/activity-run flex items-center gap-1 text-xs leading-tight text-dashboard-text-muted`,s&&`text-dashboard-accent-text/80`),children:/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[/* @__PURE__ */ (0,Y.jsxs)(W,{render:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`}),children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:/* @__PURE__ */ (0,Y.jsx)(Fv,{active:s,children:n?`Hide ${a}`:a})}),/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,className:`size-3 shrink-0 opacity-55 transition-transform group-aria-expanded/activity-run:rotate-90`,strokeWidth:2.2})]}),/* @__PURE__ */ (0,Y.jsx)(Cr,{children:o})]})}),/* @__PURE__ */ (0,Y.jsx)(ih,{hiddenUntilFound:!0,children:/* @__PURE__ */ (0,Y.jsx)(cx.Provider,{value:!0,children:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`mt-1.5 grid min-w-0 gap-1`,children:i})})})]})}function wx({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(ct,{"data-slot":`checkbox`,className:F(`grid size-4 shrink-0 cursor-pointer place-items-center rounded-sm border border-dashboard-border-interactive bg-dashboard-control text-dashboard-text-inverse transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus data-checked:border-dashboard-focus data-checked:bg-dashboard-focus data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...t,children:/* @__PURE__ */ (0,Y.jsx)(Xe,{"data-slot":`checkbox-indicator`,children:/* @__PURE__ */ (0,Y.jsx)(Yt,{"aria-hidden":`true`,size:12,strokeWidth:3})})})}function Tx(e){return/* @__PURE__ */ (0,Y.jsx)(st,{"data-slot":`radio-group`,...e})}function Ex({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(rt,{"data-slot":`radio-group-item`,className:F(`grid size-4 shrink-0 cursor-pointer place-items-center rounded-full border border-dashboard-border-interactive bg-dashboard-control transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus data-checked:border-dashboard-focus data-checked:bg-dashboard-focus data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...t,children:/* @__PURE__ */ (0,Y.jsx)(ut,{"data-slot":`radio-group-indicator`,className:`size-1.5 rounded-full bg-dashboard-text-inverse`})})}const Dx=`flex cursor-pointer items-start gap-3 rounded-md border border-dashboard-border bg-dashboard-surface-panel px-3 py-2.5 text-sm transition-colors hover:border-dashboard-border-emphasis hover:bg-dashboard-surface-hover has-[[data-checked]]:border-dashboard-accent/60 has-[[data-checked]]:bg-dashboard-accent/10 has-[[data-disabled]]:cursor-not-allowed has-[[data-disabled]]:opacity-60`;function Ox(e){return/* @__PURE__ */ (0,Y.jsx)(`span`,{className:K(`ml-2 text-xs font-normal text-dashboard-accent-text/80`,e.className),children:`Suggested`})}function kx(e){return e.value?/* @__PURE__ */ (0,Y.jsx)(`kbd`,{"aria-hidden":`true`,className:`grid size-5 shrink-0 place-items-center rounded border border-dashboard-border bg-dashboard-fill-soft font-sans text-2xs text-dashboard-text-muted max-md:hidden`,children:e.value}):null}function Ax(e){return/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`grid min-w-0 gap-0.5 break-words`,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`font-medium text-dashboard-text`,children:[e.label,e.recommended?/* @__PURE__ */ (0,Y.jsx)(Ox,{}):null]}),e.description?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,children:e.description}):null]})}function jx(e){let t=(0,J.useId)(),{field:n}=e,r=/* @__PURE__ */ (0,Y.jsxs)(`legend`,{className:`mb-2 p-0 text-sm font-semibold text-dashboard-text`,children:[n.label,n.kind===`multi_choice`?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`ml-2 text-xs font-normal text-dashboard-text-muted`,children:`Pick any`}):null]}),i=n.description?/* @__PURE__ */ (0,Y.jsx)(Yd,{className:`-mt-1 mb-2`,id:`${t}-help`,children:n.description}):null,a=n.description?`${t}-help`:void 0;return n.kind===`choice`?/* @__PURE__ */ (0,Y.jsxs)(`fieldset`,{className:`m-0 min-w-0 border-0 p-0`,children:[r,i,/* @__PURE__ */ (0,Y.jsx)(Tx,{"aria-describedby":a,"aria-label":n.label,className:`grid gap-2`,disabled:e.disabled,onValueChange:t=>e.onChange([String(t)]),value:e.values[0]??null,children:n.options.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`label`,{className:Dx,children:[/* @__PURE__ */ (0,Y.jsx)(Ex,{className:`mt-0.5`,value:e.label}),/* @__PURE__ */ (0,Y.jsx)(Ax,{description:e.description,label:e.label,recommended:e.recommended})]},e.label))})]}):/* @__PURE__ */ (0,Y.jsxs)(`fieldset`,{"aria-describedby":a,className:`m-0 min-w-0 border-0 p-0`,children:[r,i,/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`grid gap-2`,children:n.options.map(t=>/* @__PURE__ */ (0,Y.jsxs)(`label`,{className:Dx,children:[/* @__PURE__ */ (0,Y.jsx)(wx,{checked:e.values.includes(t.label),className:`mt-0.5`,disabled:e.disabled,onCheckedChange:n=>e.onChange(n?[...e.values,t.label]:e.values.filter(e=>e!==t.label))}),/* @__PURE__ */ (0,Y.jsx)(Ax,{description:t.description,label:t.label,recommended:t.recommended})]},t.label))})]})}function Mx(e){let t=(0,J.useId)();return/* @__PURE__ */ (0,Y.jsxs)(qd,{children:[/* @__PURE__ */ (0,Y.jsx)(Jd,{htmlFor:t,children:e.label}),e.description?/* @__PURE__ */ (0,Y.jsx)(Yd,{className:`-mt-1`,id:`${t}-help`,children:e.description}):null,/* @__PURE__ */ (0,Y.jsx)(nv,{"aria-describedby":e.description?`${t}-help`:void 0,className:K(`min-h-20 leading-relaxed`,e.className),disabled:e.disabled,id:t,onChange:t=>e.onChange(t.target.value),ref:e.ref,value:e.value})]})}function Nx(e){let[t,n]=(0,J.useState)(!1),[r,i]=(0,J.useState)(),[a,o]=(0,J.useState)(!1),s=(0,J.useId)(),[c,l]=(0,J.useState)({}),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(!1),m=f?void 0:li(e.request),h=(0,J.useRef)(null);(0,J.useEffect)(()=>{f&&h.current?.focus()},[f]);let g=(0,J.useRef)(!1);async function _(t){if(g.current)return!1;g.current=!0,n(!0),o(!1);try{return await e.onSubmit(t),!0}catch{return g.current=!1,n(!1),i(void 0),o(!0),!1}}function v(t,n){i(n),_({requestId:e.requestId,values:{[t]:[n]}})}let y={other:u,requestId:e.requestId,values:c},b=xi(e.request,y),x=Object.keys(b.values).length,S=e.request.fields.length,C=!m&&!t&&!Ti(b),w=e.onUnsentChange;(0,J.useEffect)(()=>{w?.(C)},[w,C]),(0,J.useImperativeHandle)(e.ref,()=>({sendPicks:()=>C?_(y):void 0}));function T(e){e.preventDefault(),Ti(b)||_(y)}let E=e.secondaryActions?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1 sm:ml-auto`,children:e.secondaryActions}):null,D=e.docked?null:/* @__PURE__ */ (0,Y.jsx)(H,{disabled:t,onClick:()=>p(!0),children:`Other…`}),O=t=>e.docked&&t<9?String(t+1):void 0;return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[m?.options.some(e=>e.description)?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{"aria-label":m.label,className:`mt-3 grid gap-2`,role:`group`,children:m.options.map((e,n)=>/* @__PURE__ */ (0,Y.jsxs)(`button`,{"aria-describedby":e.description?`${s}-${n}`:void 0,"aria-keyshortcuts":O(n),"aria-labelledby":`${s}-${n}-label`,className:`group flex w-full cursor-pointer items-center gap-3 rounded-md border border-dashboard-border bg-dashboard-surface-raised px-3 py-2.5 text-left font-sans text-sm transition-colors hover:border-dashboard-border-emphasis hover:bg-dashboard-surface-hover focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus disabled:cursor-not-allowed disabled:opacity-60 data-[picked]:border-dashboard-accent/60 data-[picked]:bg-dashboard-accent/10 data-[picked]:opacity-100`,"data-picked":r===e.label?``:void 0,disabled:t,onClick:()=>v(m.id,e.label),type:`button`,children:[/* @__PURE__ */ (0,Y.jsx)(kx,{value:O(n)}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-0.5 break-words`,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`font-medium text-dashboard-text`,id:`${s}-${n}-label`,children:[e.label,e.recommended?/* @__PURE__ */ (0,Y.jsx)(Ox,{}):null]}),e.description?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,id:`${s}-${n}`,children:e.description}):null]}),/* @__PURE__ */ (0,Y.jsx)(qt,{"aria-hidden":`true`,className:`shrink-0 text-dashboard-text-faint opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100 group-data-[picked]:opacity-100`,size:16})]},e.label))}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[D,E]})]}):m?/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[m.options.map((e,n)=>/* @__PURE__ */ (0,Y.jsxs)(H,{"aria-keyshortcuts":O(n),disabled:t,onClick:()=>v(m.id,e.label),children:[/* @__PURE__ */ (0,Y.jsx)(kx,{value:O(n)}),e.label,e.recommended?/* @__PURE__ */ (0,Y.jsx)(Ox,{className:`ml-0`}):null]},e.label)),D,E]}):/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:`mt-4 grid gap-5`,onSubmit:T,children:[e.request.fields.map(e=>e.kind===`text`?/* @__PURE__ */ (0,Y.jsx)(Mx,{description:e.description,disabled:t,label:e.label,onChange:t=>l(n=>({...n,[e.id]:[t]})),value:c[e.id]?.[0]??``},e.id):/* @__PURE__ */ (0,Y.jsx)(jx,{disabled:t,field:e,onChange:t=>l(n=>({...n,[e.id]:t})),values:c[e.id]??[]},e.id)),e.docked?null:/* @__PURE__ */ (0,Y.jsx)(Mx,{className:`min-h-16`,description:si.description,disabled:t,label:si.label,onChange:d,ref:h,value:u}),e.docked&&S<2&&!E?null:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.docked?null:/* @__PURE__ */ (0,Y.jsx)(H,{disabled:t,type:`submit`,variant:`primary`,children:`Send`}),S>1?/* @__PURE__ */ (0,Y.jsxs)(`span`,{"aria-live":`polite`,className:`text-xs text-dashboard-text-muted`,children:[x,` of `,S,` answered`]}):null,E]})]}),a?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`mb-0 mt-2 text-xs text-rose-300`,role:`alert`,children:`Could not send your answer. Try again.`}):null]})}function Px(e){return/* @__PURE__ */ (0,Y.jsx)(pt,{...e})}function Fx({className:e,...t}){return/* @__PURE__ */ (0,Y.jsxs)(Me,{children:[/* @__PURE__ */ (0,Y.jsx)(ze,{className:`fixed inset-0 z-50 bg-dashboard-overlay transition-opacity duration-180 motion-reduce:transition-none data-ending-style:opacity-0 data-starting-style:opacity-0`}),/* @__PURE__ */ (0,Y.jsx)(je,{"data-dashboard-modal":``,"data-slot":`alert-dialog-content`,className:F(`fixed top-1/2 left-1/2 z-50 grid grid-cols-1 max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-sm -translate-x-1/2 -translate-y-1/2 gap-4 overflow-y-auto rounded-xl border border-dashboard-border-emphasis bg-dashboard-surface-raised p-5 text-dashboard-text shadow-lg outline-none transition-[opacity,scale] duration-180 motion-reduce:transition-none data-ending-style:opacity-0 data-starting-style:opacity-0 data-ending-style:scale-95 data-starting-style:scale-95`,e),...t})]})}function Ix({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(ke,{className:F(`m-0 font-display text-lg font-medium`,e),...t})}function Lx({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(De,{className:F(`m-0 break-words text-sm leading-relaxed text-dashboard-text-muted`,e),...t})}function Rx({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:F(`flex flex-wrap justify-end gap-2`,e),...t})}function zx(e){return/* @__PURE__ */ (0,Y.jsx)(H,{"data-slot":`alert-dialog-action`,className:`min-h-11`,...e})}function Bx(e){return/* @__PURE__ */ (0,Y.jsx)(it,{render:/* @__PURE__ */ (0,Y.jsx)(H,{className:`min-h-11`}),...e})}const Vx=(0,J.createContext)(void 0);function Hx(e){let t=(0,J.useMemo)(()=>({conversationId:e.conversationId,titles:/* @__PURE__ */ new Map}),[e.conversationId]);return/* @__PURE__ */ (0,Y.jsx)(Vx.Provider,{value:t,children:e.children})}function Ux(e,t){let n=(0,J.useContext)(Vx),r=(0,J.useId)(),i=e.kind===`action`&&e.status===`open`&&e.canAct&&!e.assignedToEveryone&&e.addedByConversationId===n?.conversationId,a=e.title;(0,J.useEffect)(()=>{if(n&&i&&t)return n.titles.set(r,a),()=>{n.titles.delete(r)}},[i,n,r,a,t])}function Wx(){let e=(0,J.useContext)(Vx),[t,n]=(0,J.useState)(!1),[r,i]=(0,J.useState)([]),a=(0,J.useRef)(void 0),o=(0,J.useCallback)(()=>{let t=[...e?.titles.values()??[]];if(t.length!==0)return i(t),n(!0),new Promise(e=>{a.current=e})},[e]),s=e=>{a.current?.(e),a.current=void 0,n(!1)};return{confirmSubmit:o,dialog:/* @__PURE__ */ (0,Y.jsx)(Px,{onOpenChange:e=>{e||s(!1)},open:t,children:/* @__PURE__ */ (0,Y.jsxs)(Fx,{children:[/* @__PURE__ */ (0,Y.jsx)(Ix,{children:`Send without your answers?`}),/* @__PURE__ */ (0,Y.jsx)(Lx,{children:r.length===1?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[`Your answers to`,` `,/* @__PURE__ */ (0,Y.jsx)(`strong`,{className:`font-medium text-dashboard-text`,children:r[0]}),` `,`are not sent. This message closes that review item, and the answers are lost.`]}):`Your answers to ${r.length} review items are not sent. This message closes those items, and the answers are lost.`}),/* @__PURE__ */ (0,Y.jsxs)(Rx,{children:[/* @__PURE__ */ (0,Y.jsx)(Bx,{children:`Go back`}),/* @__PURE__ */ (0,Y.jsx)(zx,{onClick:()=>s(!0),variant:`danger`,children:`Send message`})]})]})})}}function Gx(e){return e.displayName??e.email}function Kx(e){return e instanceof ta&&e.apiError?e.apiError:`Could not save this action. Try again.`}function qx(e){let t=xi(e.request,e.answer),n=e.request.fields.flatMap(e=>{let n=t.values[e.id];return n?.length?[{label:e.label,value:n.join(`, `)}]:[]});return t.other&&n.push({label:`Other`,value:t.other}),/* @__PURE__ */ (0,Y.jsx)(`dl`,{className:`m-0 grid gap-2 rounded-md bg-dashboard-fill-soft p-3`,children:n.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid gap-0.5`,children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{className:`text-xs font-medium text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{className:`m-0 whitespace-pre-wrap break-words`,children:e.value})]},e.label))})}function Jx(e){let{item:t}=e,n=t.closedBy?Gx(t.closedBy):`An agent`,r=t.status===`dismissed`?`dismissed`:`closed`;return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[/* @__PURE__ */ (0,Y.jsxs)(`p`,{className:`m-0 text-dashboard-text-muted`,children:[n,` `,r,` this `,no(t.closedAt),`.`]}),t.closeReason?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 text-dashboard-text-muted`,children:t.closeReason}):null,t.request&&t.answer?/* @__PURE__ */ (0,Y.jsx)(qx,{answer:t.answer,request:t.request}):null]})}function Yx(e){let{item:t}=e,n=pu(),[r,i]=(0,J.useState)(),[a,o]=(0,J.useState)(!1);if(Ux(t,a),t.status!==`open`)return/* @__PURE__ */ (0,Y.jsx)(Jx,{item:t});if(!t.canAct)return/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:`Only an assignee can act on this item.`});async function s(e){i(void 0);try{await n.mutateAsync({body:e,id:t.id})}catch(e){throw i(Kx(e)),e}}let c=/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[t.canTake?/* @__PURE__ */ (0,Y.jsx)(H,{disabled:n.isPending,onClick:()=>void s({action:`take`}).catch(()=>{}),variant:`quiet`,children:`Take`}):null,/* @__PURE__ */ (0,Y.jsx)(H,{disabled:n.isPending,onClick:()=>void s({action:`dismiss`}).catch(()=>{}),variant:`quiet`,children:`Dismiss`})]});return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid gap-3`,children:[t.kind===`action`&&t.request?/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`text-sm`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`font-medium`,children:/* @__PURE__ */ (0,Y.jsx)($,{text:t.request.question})}),/* @__PURE__ */ (0,Y.jsx)(Nx,{onUnsentChange:o,onSubmit:e=>s({action:`submit`,answer:{values:e.values,...e.other?{other:e.other}:void 0}}),request:t.request,requestId:t.id,secondaryActions:c})]}):/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1 sm:ml-auto`,children:c})}),r?/* @__PURE__ */ (0,Y.jsx)(h_,{children:r}):null]})}function Xx(e){return`/review?item=${encodeURIComponent(e)}`}function Zx(e){try{let{protocol:t}=new URL(e);return t===`https:`||t===`http:`?e:void 0}catch{return}}function Qx(e){return e.status===`open`?e.kind===`action`?`Needs an answer`:`Notice`:e.status===`done`?`Done`:`Dismissed`}function $x(e){let t=e.assignees.map(e=>e.displayName??e.email);return e.assignedToEveryone&&t.unshift(`Everyone`),t.length>0?t.join(`, `):`Unassigned`}const eS=s({tool_name:p()}),tS=s({item:s({id:p().min(1)})});function nS(e){let t=e;if(typeof e==`string`)try{t=JSON.parse(e)}catch{return}return tS.safeParse(t).data?.item.id}function rS(e){if(e.status===`completed`&&(e.name===`executeTool`?eS.safeParse(e.input).data?.tool_name:e.name)===`addReviewItem`)return nS(e.output)}function iS(e){let{data:t}=e;if(t.type!==`message`||!t.reviewItemChanges)return e;if(t.events)return{...e,data:{...t,reviewItemChanges:void 0}}}function aS(e){return e.status===`open`&&e.kind===`action`&&!!e.request&&e.canAct}function oS(e,t){let n=xi(e,t),r=e.fields.flatMap(e=>{let t=n.values[e.id];return t?.length?[t.join(`, `)]:[]});return n.other&&r.push(n.other),r.join(` · `)}function sS(e,t){if(e.kind!==t.kind)return e.kind===`action`?-1:1;let n=Date.parse(e.createdAt)-Date.parse(t.createdAt);return n===0?e.id<t.id?-1:+(e.id>t.id):n}function cS(e){let t=e.filter(e=>e.status===`open`);return{fyi:t.filter(e=>e.kind===`notice`).sort(sS),needsYou:t.filter(e=>e.kind===`action`).sort(sS)}}function lS(e,t){return[...e.needsYou,...e.fyi].find(e=>sS(t,e)<0)}const uS={dismissed:`Dismissed`,submitted:`Answered`,taken:`Took`};function dS(e){let{item:t,record:n}=e,r=uS[n.kind];return/* @__PURE__ */ (0,Y.jsxs)(`section`,{"aria-label":`${r} ${t.title}`,className:`grid min-w-0 max-w-[37.5rem] gap-2 rounded-lg border border-dashboard-border bg-dashboard-surface-panel p-3 font-sans text-sm`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[/* @__PURE__ */ (0,Y.jsx)(lr,{"aria-hidden":`true`,className:`shrink-0 text-dashboard-text-muted`,size:15}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`shrink-0 text-dashboard-text-muted`,children:r}),/* @__PURE__ */ (0,Y.jsx)(V,{className:`min-w-0 flex-1 truncate font-medium text-dashboard-text no-underline hover:underline focus-visible:outline-dashboard-focus`,to:Xx(t.id),children:t.title})]}),n.kind===`submitted`&&t.request&&t.answer?/* @__PURE__ */ (0,Y.jsx)(qx,{answer:t.answer,request:t.request}):null]})}function fS(e){let{data:t,isError:n}=lu(e.record.reviewItemId);return n?e.fallback:t?/* @__PURE__ */ (0,Y.jsx)(dS,{item:t,record:e.record}):null}function pS(e){let{data:t}=lu(e.record.reviewItemId);return t?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[uS[e.record.kind],` `,/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-medium text-dashboard-text`,children:t.title})]}):e.fallback}function mS(e){return e.status===`open`?e.kind===`notice`?void 0:e.canAct?`Waiting on you`:`Waiting on ${$x(e)}`:e.status===`dismissed`?`Dismissed`:e.request&&e.answer?oS(e.request,e.answer):`Done`}function hS(e){let{data:t,isError:n}=lu(e.itemId);if(n)return e.fallback;if(!t)return null;let r=t.kind===`action`?`Asked`:`Added`,i=mS(t);return/* @__PURE__ */ (0,Y.jsxs)(`section`,{"aria-label":`${r} ${t.title}`,className:`flex min-w-0 max-w-[37.5rem] flex-wrap items-center gap-x-2 gap-y-0.5 rounded-lg border border-dashboard-border bg-dashboard-surface-panel px-3 py-2 font-sans text-sm transition-shadow duration-300 motion-reduce:transition-none data-highlighted:ring-2 data-highlighted:ring-violet-300/50`,"data-review-item-ask":t.id,children:[/* @__PURE__ */ (0,Y.jsx)(lr,{"aria-hidden":`true`,className:`shrink-0 text-dashboard-text-muted`,size:15}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`shrink-0 text-dashboard-text-muted`,children:r}),/* @__PURE__ */ (0,Y.jsx)(V,{className:`min-w-0 max-w-full truncate font-medium text-dashboard-text no-underline hover:underline focus-visible:outline-dashboard-focus`,to:Xx(t.id),children:t.title}),i?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:t.status===`open`?`min-w-0 truncate text-dashboard-accent-text`:`min-w-0 truncate text-dashboard-text-muted`,title:i,children:i}):null]})}function gS({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`span`,{"data-slot":`trace-icon`,"aria-hidden":`true`,className:F(`flex size-4 shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4`,e),...t})}function _S({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(nh,{"data-slot":`trace-collapsible`,className:F(`flex w-full min-w-0 flex-col`,e),...t})}function vS({className:e,children:t,...n}){return/* @__PURE__ */ (0,Y.jsxs)(rh,{"data-slot":`trace-collapsible-trigger`,className:F(`group/trace-collapsible-trigger flex w-fit max-w-full min-w-0 cursor-pointer items-center gap-1 rounded-md px-2 py-1.5 text-left text-dashboard-text-muted transition-colors outline-none hover:bg-dashboard-fill-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus disabled:cursor-default disabled:hover:bg-transparent`,e),...n,children:[t,/* @__PURE__ */ (0,Y.jsx)(gS,{className:`transition-transform group-aria-expanded/trace-collapsible-trigger:rotate-90 motion-reduce:transition-none`,children:/* @__PURE__ */ (0,Y.jsx)(U,{className:`size-3 text-dashboard-text-faint`})})]})}function yS({className:e,children:t,...n}){return/* @__PURE__ */ (0,Y.jsx)(ih,{"data-slot":`trace-collapsible-content`,className:`h-(--collapsible-panel-height) min-w-0 overflow-hidden transition-[height] duration-200 data-ending-style:h-0 data-starting-style:h-0 motion-reduce:transition-none`,...n,children:/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`trace-collapsible-content-inner`,className:F(`mt-1.5 ml-6 min-w-0 overflow-hidden rounded-md border border-dashboard-border-subtle bg-dashboard-surface-panel`,e),children:t})})}function bS({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`article`,{"data-slot":`message`,className:F(`group/message grid min-w-0`,e),...t})}function xS({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`message-content`,className:F(`grid min-w-0 grid-cols-[minmax(0,1fr)] gap-2`,e),...t})}function SS({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{"data-slot":`message-actions`,className:F(`flex items-center gap-0.5 [@media(hover:hover)_and_(pointer:fine)_and_(not_(any-pointer:coarse))]:opacity-0 group-hover/message:opacity-100 group-focus-within/message:opacity-100 has-[[aria-expanded=true]]:opacity-100`,e),...t})}function CS({children:e,label:t,...n}){return/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[/* @__PURE__ */ (0,Y.jsx)(W,{render:/* @__PURE__ */ (0,Y.jsx)(H,{"data-slot":`message-action`,"aria-label":t,size:`icon`,...n,children:e})}),/* @__PURE__ */ (0,Y.jsx)(Cr,{size:`compact`,children:t})]})}function wS(e){let t=e.right!==void 0&&e.right!==null&&e.right!==!1;return/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:K(`flex min-w-0 items-start justify-between gap-2 md:items-center md:gap-3`,e.className),children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:K(`flex min-w-0 items-center gap-2 overflow-hidden`,e.leftClassName),children:e.left}),t?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:K(`min-w-0 max-w-[60%] shrink text-right md:max-w-none md:shrink-0`,e.rightClassName),children:e.right}):null]})}function TS(e){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-h-6 min-w-0 flex-wrap items-baseline gap-x-2 text-sm leading-6`,children:[e.children,e.action?/* @__PURE__ */ (0,Y.jsx)(SS,{className:`h-6 shrink-0 self-center`,children:e.action}):null]})}function ES(e){return/* @__PURE__ */ (0,Y.jsx)(`span`,{className:K(`font-sans leading-none`,e.className),children:e.children})}function DS(e){let{active:t}=sh(),[n,r]=(0,J.useState)(!1),i=e.meta.join(` · `),a=e.expandable??!!e.children,o=a&&(t||n),s=e.icon,c=/* @__PURE__ */ (0,Y.jsx)(wS,{className:`flex-1`,left:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[e.signature,e.mobileSummaryMeta&&!o?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`hidden text-dashboard-text-muted max-md:inline`,children:`·`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`hidden shrink-0 whitespace-nowrap text-dashboard-text-muted max-md:inline`,children:e.mobileSummaryMeta})]}):null]}),leftClassName:K(`gap-x-1 gap-y-0.5`,a&&!o?`flex-nowrap`:`flex-wrap`),right:i?/* @__PURE__ */ (0,Y.jsx)(ES,{className:`min-w-0 break-words text-xs text-dashboard-text-muted`,children:i}):void 0,rightClassName:`ml-3 min-w-0 max-md:hidden`}),l=s?/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`grid min-w-0 flex-1 grid-cols-[1rem_minmax(0,1fr)] items-center gap-2`,children:[/* @__PURE__ */ (0,Y.jsx)(s,{"aria-hidden":`true`,className:K(`size-3.5 justify-self-center`,e.iconClassName),strokeWidth:2}),c]}):c;return a?/* @__PURE__ */ (0,Y.jsxs)(_S,{className:`max-w-full`,disabled:t,open:o,onOpenChange:r,children:[/* @__PURE__ */ (0,Y.jsx)(vS,{className:`-mx-2 w-auto font-mono text-xs leading-tight`,children:l}),/* @__PURE__ */ (0,Y.jsxs)(yS,{children:[i?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`hidden min-w-0 break-words border-b border-dashboard-border-subtle px-2.5 py-1.5 font-sans text-xs tabular-nums leading-snug text-dashboard-text-muted max-md:block`,children:i}):null,e.children]})]}):/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`flex min-w-0 max-w-full py-1.5 font-mono text-xs leading-tight text-dashboard-text-muted`,children:l})}function OS(e,t){return e===`bash`?AS(t,`command`):e===`loadSkill`?AS(t,`skill_name`):e===`webSearch`?AS(t,`query`):e===`executeTool`?FS(AS(t,`tool_name`),kS(t,`arguments`)):jS(t,120)}function kS(e,t){return IS(e)?MS(e[t]):null}function AS(e,t){if(!IS(e))return null;let n=e[t];return typeof n==`string`?PS(n,120):null}function jS(e,t){return e==null||e===``?null:IS(e)?MS(e):PS(NS(e),t)}function MS(e){if(!IS(e))return null;let t=Object.entries(e);if(t.length===0)return null;let n=t.slice(0,4).map(([e,t])=>`${e}: ${PS(NS(t),48)}`).join(`, `);return PS(t.length>4?`${n}, …`:n,120)}function NS(e){return typeof e==`string`?JSON.stringify(e):Ta(e).replace(/\s+/g,` `).trim()}function PS(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,Math.max(0,t-1)).trimEnd()}…`:n}function FS(...e){let t=e.filter(e=>!!e);return t.length>0?PS(t.join(`, `),120):null}function IS(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const LS=(0,J.memo)(function(e){let t=Ba(e.timestamp),n=Ga(e.timestamp,e.part.resultTimestamp),r=e.part.input!==void 0||e.part.output!==void 0,i=[n,(0,J.useMemo)(()=>Pa(e.part.output),[e.part.output])].filter(BS).join(` · `),a=[i,t].filter(BS),o=i,s=OS(e.part.name,e.part.input),c=/* @__PURE__ */ (0,Y.jsx)(RS,{name:e.part.name,preview:s,status:e.part.status}),l=/* @__PURE__ */ (0,Y.jsxs)(DS,{expandable:r,icon:e.part.status===`error`?kn:ir,iconClassName:e.part.status===`error`?`text-rose-300`:`text-dashboard-text-faint`,meta:a,mobileSummaryMeta:o,signature:c,children:[e.part.input===void 0?null:/* @__PURE__ */ (0,Y.jsx)(zS,{label:`arguments`,value:e.part.input}),e.part.output===void 0?null:/* @__PURE__ */ (0,Y.jsx)(zS,{label:`result`,value:e.part.output})]}),u=rS(e.part);return u?/* @__PURE__ */ (0,Y.jsx)(hS,{fallback:l,itemId:u}):/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`min-w-0`,children:l})});function RS(e){let{active:t}=sh(),n=e.status===`running`,r=e.status===`error`,i=n&&!t,a=n?`${e.name} (running)`:r?`${e.name} (failed)`:void 0;return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(Fv,{active:i,"aria-label":a,as:`strong`,className:K(`shrink-0 font-bold`,r?`!text-rose-300`:!i&&`text-dashboard-text`),children:/* @__PURE__ */ (0,Y.jsx)(Q,{text:e.name})}),e.preview&&!t?/* @__PURE__ */ (0,Y.jsxs)(`code`,{className:`min-w-0 truncate font-[inherit] text-dashboard-text-muted group-aria-expanded/trace-collapsible-trigger:hidden`,children:[`(`,/* @__PURE__ */ (0,Y.jsx)(Q,{text:e.preview}),`)`]}):null]})}function zS(e){let t=(0,J.useMemo)(()=>Ta(e.value),[e.value]);return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`min-w-0 max-w-full overflow-hidden border-dashboard-border-subtle px-3 py-2.5 [&+&]:border-t`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`pb-1.5 font-sans text-xs font-medium leading-none text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,Y.jsx)(mh,{code:t,language:`json`})]})}function BS(e){return typeof e==`string`&&e.length>0}function VS(e){let{active:t}=sh(),[n,r]=Vb(e.openKey),i=t||n,a=e.part.redacted?`Reasoning redacted`:e.part.text,o=Ba(e.timestamp);return/* @__PURE__ */ (0,Y.jsxs)(_S,{className:`text-xs leading-tight`,disabled:t,open:i,onOpenChange:r,children:[/* @__PURE__ */ (0,Y.jsx)(vS,{className:`-mx-2 w-auto`,children:/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`grid min-w-0 flex-1 grid-cols-[1rem_minmax(0,1fr)] items-center gap-2`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-label":`Reasoning`,className:`inline-flex size-4 shrink-0 items-center justify-center text-violet-200/80`,title:`Reasoning`,children:/* @__PURE__ */ (0,Y.jsx)(xn,{"aria-hidden":`true`,size:14,strokeWidth:2})}),/* @__PURE__ */ (0,Y.jsx)(wS,{left:i?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`block min-w-0 text-dashboard-text-muted`,children:`Reasoning`}):/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`block min-w-0 truncate italic text-dashboard-text-muted`,children:/* @__PURE__ */ (0,Y.jsx)($,{inline:!0,links:!1,text:a})}),right:o?/* @__PURE__ */ (0,Y.jsx)(ES,{className:`min-w-0 break-words text-xs tabular-nums text-dashboard-text-muted max-md:hidden`,children:o}):void 0,rightClassName:`min-w-0 max-md:hidden`})]})}),/* @__PURE__ */ (0,Y.jsx)(yS,{className:`px-3 py-2.5`,hiddenUntilFound:!0,children:/* @__PURE__ */ (0,Y.jsx)($,{text:a})})]})}function HS(e){let t=_a(e.role),n=t===`assistant`||t===`user`;return/* @__PURE__ */ (0,Y.jsxs)(bS,{className:K(n&&K(`grid-cols-[1.5rem_minmax(0,1fr)] gap-2 md:grid-cols-[2rem_minmax(0,1fr)] md:gap-3`,`text-dashboard-text`),t===`system`&&`rounded-xl bg-dashboard-surface-panel px-4 py-3 text-dashboard-text max-md:ml-4`,t===`tool`&&`rounded-none px-0 text-dashboard-text-muted max-md:ml-8`,t===`other`&&`bg-dashboard-surface-hover text-dashboard-text max-md:ml-8`),onCopy:e.onCopy,children:[n?/* @__PURE__ */ (0,Y.jsx)(`div`,{"aria-hidden":`true`,className:K(`flex items-center justify-center`,Lb),children:t===`assistant`?/* @__PURE__ */ (0,Y.jsx)(`img`,{alt:``,className:`size-full object-contain`,draggable:!1,src:xs}):e.fromAgent?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`grid size-full place-items-center rounded-full bg-dashboard-surface-hover text-cyan-200`,children:/* @__PURE__ */ (0,Y.jsx)(mn,{size:15,strokeWidth:2})}):/* @__PURE__ */ (0,Y.jsxs)(Hs,{className:`size-full border-0 bg-violet-300 shadow-none`,children:[/* @__PURE__ */ (0,Y.jsx)(Us,{alt:``,loading:`lazy`,referrerPolicy:`no-referrer`,src:e.avatarUrl}),/* @__PURE__ */ (0,Y.jsx)(Ws,{children:e.actor.split(/\s+/).map(e=>e[0]).slice(0,2).join(``).toUpperCase()})]})}):null,/* @__PURE__ */ (0,Y.jsx)(xS,{className:`py-1`,children:e.children})]})}const US=(0,J.createContext)(null);function WS(e){let[t,n]=(0,J.useState)(!1);return/* @__PURE__ */ (0,Y.jsx)(US.Provider,{value:{full:t,toggle:()=>n(e=>!e)},children:e.children})}function GS(e){let t=(0,J.useContext)(US),n=typeof e.value==`number`&&Number.isFinite(e.value),r=n&&Date.now()-e.value>432e5,i=t?.full?Ba(e.value,!0):r?$a(e.value):Ba(e.value),a=/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`cursor-pointer border-0 bg-transparent p-0 font-inherit text-inherit`,onClick:t?.toggle,type:`button`,children:i});if(!r||t?.full||!n)return a;let o=va(e.value);return/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[/* @__PURE__ */ (0,Y.jsx)(W,{render:a}),/* @__PURE__ */ (0,Y.jsx)(Cr,{children:/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`grid grid-cols-[auto_auto] gap-x-3`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{children:`Local`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{children:o.local}),/* @__PURE__ */ (0,Y.jsx)(`span`,{children:`UTC`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{children:o.utc})]})})]})}function KS(e){return/* @__PURE__ */ (0,Y.jsxs)(HS,{role:`assistant`,actor:pa(),children:[/* @__PURE__ */ (0,Y.jsxs)(TS,{children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`max-w-full truncate font-sans text-sm font-semibold leading-6 text-dashboard-accent-text`,children:pa()}),typeof e.timestamp==`number`?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-xs leading-6 text-dashboard-text-muted`,children:/* @__PURE__ */ (0,Y.jsx)(GS,{value:e.timestamp})}):null]}),/* @__PURE__ */ (0,Y.jsx)(W_,{attachments:e.part.attachments,conversationId:e.conversation.conversationId})]})}function qS(e){let t=sh(),n=e.part.presentation,r=Ba(e.timestamp),i=n.details??[],a=e.part.mentions??[],o=`min-w-0 font-sans text-xs`,s=e=>i.length===1&&n.title.includes(e),c=i.length>0?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`grid gap-4 pb-1 pt-2`,children:i.map((e,t)=>/* @__PURE__ */ (0,Y.jsxs)(`section`,{children:[s(e.title)?null:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`whitespace-pre-wrap break-words font-sans text-sm font-medium text-dashboard-text`,children:/* @__PURE__ */ (0,Y.jsx)(Q,{text:e.title})}),e.description?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`mt-1`,children:/* @__PURE__ */ (0,Y.jsx)($,{mentions:a,text:e.description})}):null,e.content?/* @__PURE__ */ (0,Y.jsx)(`pre`,{className:`mt-2 max-h-[32rem] overflow-auto whitespace-pre-wrap break-words rounded-md border border-dashboard-border-subtle bg-dashboard-surface-panel px-3 py-2.5 font-mono text-xs leading-normal text-dashboard-text-muted first:mt-0`,children:/* @__PURE__ */ (0,Y.jsx)(Q,{text:e.content})}):null,e.metadata?.length?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:e.metadata.map(e=>/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,children:/* @__PURE__ */ (0,Y.jsx)(Q,{text:e})},e))}):null]},`${e.title}:${t}`))}):null,l=i.length>0&&!t.active,u=/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-2 max-md:grid-cols-[minmax(0,1fr)]`,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`block text-sm font-medium leading-6 text-dashboard-text`,children:/* @__PURE__ */ (0,Y.jsx)(Q,{text:n.title})}),n.preview?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-dashboard-text-muted`,children:/* @__PURE__ */ (0,Y.jsx)($,{inline:!0,links:!l,mentions:a,text:n.preview})}):null]}),r?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-xs leading-6 tabular-nums text-dashboard-text-muted max-md:hidden`,children:r}):null]});return l?/* @__PURE__ */ (0,Y.jsxs)(nh,{className:o,children:[/* @__PURE__ */ (0,Y.jsx)(px,{flush:!0,className:`block`,children:u}),/* @__PURE__ */ (0,Y.jsx)(ih,{hiddenUntilFound:!0,children:c})]}):/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:o,children:[u,c]})}function JS(){return/* @__PURE__ */ (0,Y.jsx)(nr,{"aria-label":`Private`,role:`img`,size:13,strokeWidth:1.8})}function YS(e){return/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 pt-1 text-dashboard-text-faint`,children:[e.private?/* @__PURE__ */ (0,Y.jsx)(JS,{}):null,/* @__PURE__ */ (0,Y.jsx)(zt,{"aria-hidden":`true`,className:`transition-colors group-hover:text-dashboard-text`,size:14})]})}function XS(e){return`${e} ${e===1?`memory`:`memories`}`}function ZS(e){let{anchor:t,state:n}=e,r=n.open?.source===t.source&&n.open.turnId===t.turnId,i=r?n.open?.memoryId:void 0;return/* @__PURE__ */ (0,Y.jsxs)(Gs,{onOpenChange:e=>n.setOpen(e?t:void 0),open:r,children:[/* @__PURE__ */ (0,Y.jsx)(Ks,{"data-memory-anchor":nx(t),render:e.trigger}),/* @__PURE__ */ (0,Y.jsx)(qs,{align:`start`,"aria-label":e.label,className:`max-h-[min(28rem,var(--available-height))] w-96 p-1.5`,children:/* @__PURE__ */ (0,Y.jsx)(`ul`,{className:`m-0 grid list-none divide-y divide-dashboard-border-subtle p-0`,children:e.memories.map(e=>/* @__PURE__ */ (0,Y.jsx)(`li`,{className:`py-1 first:pt-0 last:pb-0`,children:/* @__PURE__ */ (0,Y.jsxs)(V,{className:K(`group grid grid-cols-[minmax(0,1fr)_auto] items-start gap-3 rounded-md px-2.5 py-2 no-underline transition-colors hover:bg-dashboard-fill-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus`,e.id===i&&`bg-dashboard-fill-strong`),ref:e.id===i?e=>e?.scrollIntoView({block:`nearest`}):void 0,to:Da(e.id),children:[/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 line-clamp-4 whitespace-pre-wrap break-words text-sm leading-relaxed text-dashboard-text`,children:e.content}),/* @__PURE__ */ (0,Y.jsx)(YS,{private:e.visibility===`private`})]})},e.id))})})]})}function QS(e){let t=ox(),n=[...new Set(e.message.contexts?.filter(e=>mf(e)).map(e=>e.turnId))].flatMap(e=>{let n={source:`recalled`,turnId:e},r=rx(t?.list,n);return r.length>0?[{anchor:n,memories:r}]:[]});return!t||n.length===0?null:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:K(`flex flex-wrap gap-2`,e.className),children:n.map(({anchor:e,memories:n})=>{let r=`Recalled ${XS(n.length)}`;return/* @__PURE__ */ (0,Y.jsx)(ZS,{anchor:e,label:r,memories:n,state:t,trigger:/* @__PURE__ */ (0,Y.jsxs)(`button`,{className:`inline-flex h-6 cursor-pointer items-center gap-1.5 rounded-md border border-dashboard-border-subtle bg-transparent px-2 font-sans text-xs text-dashboard-text-muted transition-colors hover:bg-dashboard-fill-hover hover:text-dashboard-text focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus aria-expanded:bg-dashboard-fill-strong aria-expanded:text-dashboard-text`,type:`button`,children:[/* @__PURE__ */ (0,Y.jsx)(xr,{"aria-hidden":`true`,size:13,strokeWidth:1.8}),r]})},e.turnId)})})}function $S(e){let t=ox(),n=e.turnId?{source:`captured`,turnId:e.turnId}:void 0,r=n?rx(t?.list,n):[];if(!t||!n||r.length===0)return e.fallback;let i=`Captured ${XS(r.length)}`,a=Ba(e.timestamp);return/* @__PURE__ */ (0,Y.jsx)(ZS,{anchor:n,label:i,memories:r,state:t,trigger:/* @__PURE__ */ (0,Y.jsxs)(`button`,{className:`-mx-2 -my-1.5 grid w-[calc(100%+1rem)] cursor-pointer grid-cols-[minmax(0,1fr)_auto] items-start gap-2 rounded-md border-0 bg-transparent px-2 py-1.5 text-left font-sans transition-colors hover:bg-dashboard-fill-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus aria-expanded:bg-dashboard-fill-hover max-md:grid-cols-[minmax(0,1fr)]`,type:`button`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-sm font-medium leading-6 text-dashboard-text`,children:i}),a?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-xs leading-6 tabular-nums text-dashboard-text-muted max-md:hidden`,children:a}):null]})})}function eC(e){let t=Ba(e.timestamp),n=e.eventId?e.sentryEventUrl?/* @__PURE__ */ (0,Y.jsx)(tf,{className:`font-mono text-rose-100/80 underline decoration-rose-100/30 underline-offset-2 transition-colors hover:text-rose-50 hover:decoration-rose-100/70`,href:e.sentryEventUrl,children:`event_id=${e.eventId}`}):/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-mono text-rose-100/80`,children:`event_id=${e.eventId}`}):null;return/* @__PURE__ */ (0,Y.jsxs)(_s,{className:`min-w-0 gap-3 rounded-lg border-0 bg-rose-300/[0.1] px-4 py-3 text-rose-100 *:[svg]:row-span-1 has-[>svg]:grid-cols-[auto_minmax(0,1fr)_auto] has-[>svg]:gap-x-3 max-md:has-[>svg]:grid-cols-[auto_minmax(0,1fr)] *:[svg]:text-rose-300`,"data-transcript-failure":e.failureCode,"data-transcript-failure-event-id":e.eventId,"data-transcript-failure-reason":e.failureReason,variant:`destructive`,children:[/* @__PURE__ */ (0,Y.jsx)(Gn,{"aria-hidden":`true`,size:16}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,Y.jsx)(vs,{className:`font-display text-base font-semibold leading-tight`,children:xf(e.failureCode,e.failureReason)}),/* @__PURE__ */ (0,Y.jsx)(ys,{className:`mt-1 leading-relaxed text-rose-100/70`,children:Sf(e.failureCode,e.failureReason)}),n?/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`mt-2 text-xs leading-relaxed text-rose-100/65`,children:[`Reference: `,n]}):null]}),t?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-mono text-xs leading-none text-rose-100/55 max-md:col-start-2`,children:t}):null]})}const tC={sent:!1},nC=(0,J.createContext)(null);function rC(){let[e]=(0,J.useState)(()=>({listeners:/* @__PURE__ */ new Set,states:/* @__PURE__ */ new Map}));return(0,J.useEffect)(()=>{let t=()=>{for(let t of e.states.values())t.sendGood?.()};return window.addEventListener(`pagehide`,t),()=>{window.removeEventListener(`pagehide`,t),t()}},[e]),e}function iC(e){let t=Go().data?.me.user,n=(0,J.useContext)(nC);if(!n)throw Error(`Reply ratings need TranscriptReplyRatings`);let r=()=>n.states.get(e.messageId)??tC,{rating:i,sent:a}=(0,J.useSyncExternalStore)((0,J.useCallback)(e=>(n.listeners.add(e),()=>n.listeners.delete(e)),[n]),r,r),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(``);if(!na())return null;let u=t=>{n.states.set(e.messageId,t);for(let e of n.listeners)e()},d=(n,i)=>{r().sent||(u({rating:n,sent:!0}),qi({...e,comment:i,rating:n,reader:t}))},f=()=>{clearTimeout(r().timer),u(tC)},p=()=>{let e=r();if(e.sent)return;if(e.rating===`good`){f();return}let t=()=>{clearTimeout(r().timer),d(`good`)};u({rating:`good`,sendGood:t,sent:!1,timer:setTimeout(t,5e3)})},m=()=>{s(!1),d(`bad`,c.trim()||void 0)};return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[!a||i===`good`?/* @__PURE__ */ (0,Y.jsx)(CS,{"aria-pressed":i===`good`,label:`Good reply`,onClick:p,children:/* @__PURE__ */ (0,Y.jsx)(jn,{"aria-hidden":`true`,fill:i===`good`?`currentColor`:`none`,size:15})}):null,!a||i===`bad`?/* @__PURE__ */ (0,Y.jsxs)(Gs,{onOpenChange:e=>{e&&r().sent||(e&&r().rating===`good`&&f(),s(e))},open:o,children:[/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[/* @__PURE__ */ (0,Y.jsx)(W,{render:/* @__PURE__ */ (0,Y.jsx)(Ks,{render:/* @__PURE__ */ (0,Y.jsx)(H,{"aria-label":`Bad reply`,"aria-pressed":i===`bad`,"data-slot":`message-action`,size:`icon`})}),children:/* @__PURE__ */ (0,Y.jsx)(Pn,{"aria-hidden":`true`,fill:i===`bad`?`currentColor`:`none`,size:15})}),/* @__PURE__ */ (0,Y.jsx)(Cr,{size:`compact`,children:`Bad reply`})]}),/* @__PURE__ */ (0,Y.jsxs)(qs,{align:`start`,className:`grid w-72 gap-2 p-3`,children:[/* @__PURE__ */ (0,Y.jsx)(Js,{children:`What went wrong?`}),/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:`grid gap-2`,onSubmit:e=>{e.preventDefault(),m()},children:[/* @__PURE__ */ (0,Y.jsx)(nv,{"aria-label":`Comment`,className:`min-h-20`,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),m())},placeholder:`Optional`,value:c}),/* @__PURE__ */ (0,Y.jsx)(H,{className:`justify-self-end`,type:`submit`,variant:`primary`,children:`Send`})]})]})]}):null]})}function aC(){return/* @__PURE__ */ (0,Y.jsx)(`code`,{className:`inline-flex w-fit font-mono text-sm leading-tight text-dashboard-text-muted`,children:`<redacted>`})}const oC=(0,J.createContext)(void 0);function sC(e){return/* @__PURE__ */ (0,Y.jsx)(oC,{value:e.panel,children:e.children})}function cC(e){let t=(0,J.useContext)(oC),[n,r]=(0,J.useState)(!1),i=(0,J.useId)(),a=e.messageId??i,o=t?t.openId===a:n;return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[/* @__PURE__ */ (0,Y.jsx)(W,{closeOnClick:!0,render:/* @__PURE__ */ (0,Y.jsx)(H,{"aria-haspopup":t?void 0:`dialog`,"aria-expanded":o,"aria-label":`View turn context`,className:K(`size-6 shrink-0`,o&&`bg-dashboard-fill-strong text-dashboard-text`),"data-turn-context-id":a,onClick:()=>{if(!t)return r(!0);t.onToggle({actor:e.actor,contexts:e.contexts,id:a,timestamp:e.timestamp})},size:`icon`,children:/* @__PURE__ */ (0,Y.jsx)(rn,{"aria-hidden":`true`,size:14,strokeWidth:1.8})})}),/* @__PURE__ */ (0,Y.jsx)(Cr,{size:`compact`,children:`View turn context`})]}),!t&&n?(0,ou.createPortal)(/* @__PURE__ */ (0,Y.jsx)(m_,{closeLabel:`Close turn context`,header:/* @__PURE__ */ (0,Y.jsx)(`h2`,{className:`m-0 text-sm font-semibold text-dashboard-text`,id:i,children:`Turn context`}),onClose:()=>r(!1),openKey:i,titleId:i,children:/* @__PURE__ */ (0,Y.jsx)(uC,{actor:e.actor,contexts:e.contexts,timestamp:e.timestamp})}),document.body):null]})}function lC(e){return/* @__PURE__ */ (0,Y.jsx)(Iy,{label:`Turn context`,onClose:e.onClose,title:/* @__PURE__ */ (0,Y.jsx)(`h2`,{className:`m-0 text-base font-semibold text-dashboard-text`,children:`Turn context`}),children:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`p-4 pb-[max(1rem,env(safe-area-inset-bottom))]`,children:/* @__PURE__ */ (0,Y.jsx)(uC,{actor:e.actor,contexts:e.contexts,timestamp:e.timestamp})})})}function uC(e){let t=[...e.contexts].sort((e,t)=>Number(!!gf(t))-Number(!!gf(e)));return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-3`,children:[e.actor?/* @__PURE__ */ (0,Y.jsx)(dC,{actor:e.actor,timestamp:e.timestamp}):null,t.map((e,t)=>/* @__PURE__ */ (0,Y.jsx)(fC,{context:e},`${e.pluginName}:${e.kind}:${e.version}:${t}`))]})}function dC(e){let t=qm(e.actor),n=e.actor.email?.trim(),r=e.actor.slackUserName?.trim(),i=[n&&n!==t?n:void 0,r&&r!==t?`@${r}`:void 0].filter(Boolean);return/* @__PURE__ */ (0,Y.jsxs)(`section`,{"aria-label":`Speaker`,className:`flex min-w-0 items-center gap-3 rounded-lg border border-dashboard-border-subtle bg-dashboard-surface-panel p-3`,children:[/* @__PURE__ */ (0,Y.jsx)(Km,{imageUrl:e.actor.avatarUrl,name:t,size:`detail`}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[n?/* @__PURE__ */ (0,Y.jsx)(V,{className:`min-w-0 truncate text-sm font-medium text-dashboard-text no-underline hover:underline`,to:Ua(n),children:t}):/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-dashboard-text`,children:t}),e.timestamp===void 0?null:/* @__PURE__ */ (0,Y.jsx)(`time`,{className:`shrink-0 text-xs tabular-nums text-dashboard-text-muted`,dateTime:new Date(e.timestamp).toISOString(),children:Ba(e.timestamp,!0)})]}),i.length?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 mt-0.5 truncate text-xs text-dashboard-text-muted`,title:e.actor.slackUserId,children:i.join(` · `)}):null]})]})}function fC(e){let t=mf(e.context);if(t)return/* @__PURE__ */ (0,Y.jsx)(yg,{count:t.memories.length,title:`Recalled memories`,children:/* @__PURE__ */ (0,Y.jsx)(pC,{memories:t.memories})});let n=gf(e.context);return n?/* @__PURE__ */ (0,Y.jsx)(yg,{title:`User customization`,children:/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 whitespace-pre-wrap text-sm leading-relaxed text-dashboard-text`,children:/* @__PURE__ */ (0,Y.jsx)(Q,{text:n.text})})}):/* @__PURE__ */ (0,Y.jsx)(yg,{title:`${e.context.pluginName} · ${e.context.kind} v${e.context.version}`,children:/* @__PURE__ */ (0,Y.jsx)(`pre`,{className:`m-0 overflow-x-auto whitespace-pre-wrap break-words font-mono text-xs leading-relaxed`,children:/* @__PURE__ */ (0,Y.jsx)(Q,{text:JSON.stringify(e.context.content,null,2)})})})}function pC(e){return/* @__PURE__ */ (0,Y.jsx)(`ul`,{className:`-mx-1.5 -mb-1.5 -mt-1 grid list-none divide-y divide-dashboard-border-subtle p-0`,children:e.memories.map(e=>/* @__PURE__ */ (0,Y.jsx)(`li`,{className:`py-1 first:pt-0 last:pb-0`,children:/* @__PURE__ */ (0,Y.jsxs)(V,{className:`group grid grid-cols-[minmax(0,1fr)_auto] items-start gap-3 rounded-md px-1.5 py-1.5 no-underline transition-colors hover:bg-dashboard-surface-hover focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus`,to:Da(e.id),children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-dashboard-text`,children:/* @__PURE__ */ (0,Y.jsx)(Q,{text:e.content})}),/* @__PURE__ */ (0,Y.jsx)(YS,{private:e.scope===`personal`})]})},e.id))})}function mC(e){let{active:t}=sh(),[n,r]=(0,J.useState)(!1),i=ro(e.conversation,e.message),a=Ba(e.message.timestamp),o=bf(e.message),s=e.redacted?/* @__PURE__ */ (0,Y.jsx)(aC,{}):/* @__PURE__ */ (0,Y.jsx)(Q,{text:o});return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(nh,{className:`min-w-0 rounded-lg border border-dashboard-border-subtle bg-dashboard-surface-panel px-3 py-2.5 md:hidden`,"data-transcript-message-context":!0,disabled:t,onOpenChange:r,open:t||n,children:[/* @__PURE__ */ (0,Y.jsxs)(px,{flush:!0,className:`group flex items-center justify-between gap-2 font-sans text-xs font-medium text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`Context from `,i]}),/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,className:ia})]}),/* @__PURE__ */ (0,Y.jsxs)(ih,{hiddenUntilFound:!0,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap pt-2 text-sm leading-relaxed text-dashboard-text-subtle`,children:s}),!e.redacted&&e.message.contexts?.length?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`mt-2`,children:/* @__PURE__ */ (0,Y.jsx)(cC,{actor:ka(e.conversation,e.message),contexts:e.message.contexts,messageId:e.message.messageId,timestamp:e.message.timestamp})}):null]})]}),/* @__PURE__ */ (0,Y.jsxs)(`article`,{className:`hidden min-w-0 rounded-lg border border-dashboard-border-subtle bg-dashboard-surface-panel px-3 py-2.5 md:block`,"data-transcript-message-context":!0,children:[/* @__PURE__ */ (0,Y.jsx)(wS,{left:/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`font-sans text-xs font-medium text-dashboard-text-muted`,children:[`Context from `,i]}),leftClassName:`min-w-0`,right:a?/* @__PURE__ */ (0,Y.jsx)(ES,{className:`text-xs tabular-nums text-dashboard-text-muted`,children:a}):void 0}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap text-sm leading-relaxed text-dashboard-text-subtle`,children:s}),!e.redacted&&e.message.contexts?.length?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`mt-2`,children:/* @__PURE__ */ (0,Y.jsx)(cC,{actor:ka(e.conversation,e.message),contexts:e.message.contexts,messageId:e.message.messageId,timestamp:e.message.timestamp})}):null]})]})}function hC(e){let[t,n]=(0,J.useState)(!1);return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(CS,{label:`Fork after this message`,onClick:()=>n(!0),children:/* @__PURE__ */ (0,Y.jsx)(sr,{size:14,"aria-hidden":`true`})}),t?/* @__PURE__ */ (0,Y.jsx)(gC,{...e,onClose:()=>n(!1)}):null]})}function gC(e){let t=(0,J.useId)(),n=`${t}-error`,r=(0,J.useRef)(null),[i]=(0,J.useState)(()=>crypto.randomUUID()),[a,o]=(0,J.useState)(``),s=ge(),c=ld(e.conversationId),l=Pl(e.onClose,r),u=()=>{a.trim()&&!c.isPending&&c.mutate({idempotencyKey:i,message:a,messageId:e.messageId},{onSuccess:t=>{e.onClose(),s(kc(t.conversationId))}})},d=c.error?c.error instanceof ta&&c.error.apiError||`Could not fork the conversation. Try again.`:void 0;return/* @__PURE__ */ (0,Y.jsx)(il,{...l.rootProps,onOpenChange:(e,t)=>{!e&&c.isPending?t.cancel():l.rootProps.onOpenChange(e,t)},children:/* @__PURE__ */ (0,Y.jsx)(ol,{...l.contentProps,children:/* @__PURE__ */ (0,Y.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),u()},children:[/* @__PURE__ */ (0,Y.jsx)(sl,{children:`Fork Conversation`}),/* @__PURE__ */ (0,Y.jsxs)(qd,{children:[/* @__PURE__ */ (0,Y.jsx)(Jd,{htmlFor:t,children:`Message`}),/* @__PURE__ */ (0,Y.jsx)(nv,{ref:r,id:t,"aria-describedby":d?n:void 0,"aria-invalid":d?!0:void 0,className:`min-h-24 leading-relaxed`,placeholder:`Message Junior…`,value:a,disabled:c.isPending,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),u())}}),/* @__PURE__ */ (0,Y.jsx)(Xd,{id:n,children:d})]}),/* @__PURE__ */ (0,Y.jsxs)(cl,{children:[/* @__PURE__ */ (0,Y.jsx)(al,{disabled:c.isPending,render:/* @__PURE__ */ (0,Y.jsx)(H,{children:`Cancel`})}),/* @__PURE__ */ (0,Y.jsx)(H,{variant:`primary`,type:`submit`,disabled:!a.trim()||c.isPending,children:c.isPending?`Forking…`:`Fork and send`})]})]})})})}function _C({card:e}){return/* @__PURE__ */ (0,Y.jsxs)(`section`,{"aria-label":e.title,className:`my-1 w-full min-w-0 max-w-[37.5rem] overflow-hidden rounded-xl border border-dashboard-border-emphasis bg-dashboard-surface-panel text-sm`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex items-center gap-3 px-4 pb-3 pt-4 md:px-5`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-lg border border-dashboard-border bg-dashboard-fill-soft text-dashboard-accent-text`,children:/* @__PURE__ */ (0,Y.jsx)(th,{objectType:`automation`,status:e.status,size:18})}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 flex-1 break-words text-base font-semibold text-dashboard-text`,children:e.title})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-3 px-4 pb-4 md:px-5`,children:[e.status&&/* @__PURE__ */ (0,Y.jsx)(gp,{size:`compact`,tone:Rr({objectType:`automation`,status:e.status}).tone,children:e.status}),/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 line-clamp-3 break-words text-sm leading-relaxed text-dashboard-text-muted`,children:/* @__PURE__ */ (0,Y.jsx)($,{inline:!0,text:e.instruction})}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex items-start gap-2 text-xs leading-relaxed text-dashboard-text`,children:[/* @__PURE__ */ (0,Y.jsx)(On,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-dashboard-text-muted`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 break-words`,children:e.trigger})]}),e.warning?/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex items-start gap-2 text-xs leading-relaxed text-dashboard-text`,children:[/* @__PURE__ */ (0,Y.jsx)(Gn,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-amber-500`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 break-words`,children:e.warning})]}):null]}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2 border-t border-dashboard-border bg-dashboard-fill-faint px-4 py-3 md:px-5`,children:/* @__PURE__ */ (0,Y.jsxs)(V,{to:Ka(e.id),className:`inline-flex shrink-0 items-center gap-2 rounded-sm text-xs font-medium text-dashboard-accent-text no-underline hover:underline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-dashboard-focus`,children:[`Open automation`,/* @__PURE__ */ (0,Y.jsx)(zt,{"aria-hidden":`true`,size:14})]})})]})}function vC({card:e}){if(e.plugin===`junior`&&e.objectType===`automation`)return/* @__PURE__ */ (0,Y.jsx)(_C,{card:{id:e.key,title:e.title,instruction:e.description??``,trigger:e.trigger??``,warning:e.warning??null,status:e.status}});let t=kr(e.facts),n=Rr(e),r=e.displayType??n.label;function i(e){return/* @__PURE__ */ (0,Y.jsx)(`dl`,{className:`grid min-w-0 grid-cols-1 gap-3 sm:grid-cols-2`,children:e.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{className:`text-xs text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{className:`m-0 mt-1 break-words text-sm text-dashboard-text`,children:e.value})]},e.key))})}return/* @__PURE__ */ (0,Y.jsxs)(`section`,{"aria-label":`${r}: ${e.title}`,className:`my-1 w-full min-w-0 max-w-[37.5rem] overflow-hidden rounded-xl border border-dashboard-border-emphasis bg-dashboard-surface-panel text-sm`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex items-start gap-3 px-4 pb-3 pt-4 md:px-5`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-lg border border-dashboard-border bg-dashboard-fill-soft text-dashboard-text-muted`,children:/* @__PURE__ */ (0,Y.jsx)(th,{...e,size:18})}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[/* @__PURE__ */ (0,Y.jsxs)(`p`,{className:`m-0 mb-1 break-words text-xs text-dashboard-text-muted`,children:[r,` · `,e.plugin,` · `,e.label]}),e.url?/* @__PURE__ */ (0,Y.jsx)(tf,{href:e.url,className:`break-words text-base font-semibold text-dashboard-text hover:underline focus-visible:outline-dashboard-focus`,children:e.title}):/* @__PURE__ */ (0,Y.jsx)(`strong`,{className:`break-words text-base text-dashboard-text`,children:e.title})]})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-4 px-4 pb-4 md:px-5`,children:[e.status&&/* @__PURE__ */ (0,Y.jsx)(gp,{size:`compact`,tone:n.tone,children:e.status}),t.length>0&&i(t),e.description&&/* @__PURE__ */ (0,Y.jsxs)(nh,{className:`min-w-0 border-t border-dashboard-border pt-3`,children:[/* @__PURE__ */ (0,Y.jsxs)(rh,{className:`group flex cursor-pointer items-center gap-1 text-xs font-medium text-dashboard-text-muted focus-visible:outline-dashboard-focus`,children:[/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,className:`size-3.5 shrink-0 transition-transform group-aria-expanded:rotate-90 motion-reduce:transition-none`}),`More details`]}),/* @__PURE__ */ (0,Y.jsx)(ih,{hiddenUntilFound:!0,children:/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`mb-0 mt-3 whitespace-pre-wrap break-words text-sm text-dashboard-text-muted`,children:e.description})})]}),e.warning&&/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 break-words text-xs text-amber-500`,children:e.warning})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-dashboard-border bg-dashboard-fill-faint px-4 py-3 text-xs md:px-5`,children:[e.url&&/* @__PURE__ */ (0,Y.jsxs)(tf,{href:e.url,className:`font-medium text-dashboard-text hover:underline focus-visible:outline-dashboard-focus`,children:[`Open `,r.toLowerCase()]}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-dashboard-text-muted`,children:`Latest saved state`})]})]})}function yC(e,t){if(!e||e.isCollapsed||e.toString().length===0)return!1;for(let n=0;n<e.rangeCount;n+=1)if(e.getRangeAt(n).intersectsNode(t))return!0;return!1}function bC(e,t,n){return e?!yC(t,n):!1}const xC={github:{label:`GitHub`,Mark:zg},slack:{label:`Slack`,Mark:Xf}};function SC(e){let{label:t,Mark:n}=xC[e.provider];return/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`inline-flex shrink-0 self-center`,title:t,children:/* @__PURE__ */ (0,Y.jsx)(n,{className:`size-3.5`})})}function CC(e){return e===`github`?`github`:void 0}function wC(e,t){if(e.postedTo)return CC(e.postedTo);if(t.surface===`slack`&&(e.role===`user`||e.role===`assistant`))return e.source===`slack`?`slack`:void 0}function TC(e){return CC(e.eventNamespace)}const EC=(0,J.memo)(function(e){let t=bf(e.message),n=_a(e.message.role),r=n===`assistant`||n===`user`,i=kC(e.message,e.conversation)?e.message.messageId:void 0,a=/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)] gap-2`,"data-quick-question-message-id":i,children:e.message.parts.map((t,n)=>t.type===`text`?/* @__PURE__ */ (0,Y.jsx)($,{chat:r,mentions:e.message.mentions,text:t.text??``},n):null)});return/* @__PURE__ */ (0,Y.jsxs)(HS,{role:e.message.role,actor:ro(e.conversation,e.message),fromAgent:!!e.message.agentInvocationId,avatarUrl:ka(e.conversation,e.message)?.avatarUrl,onCopy:e=>{let n=e.currentTarget.ownerDocument.getSelection();bC(t,n,e.currentTarget)&&(e.clipboardData.setData(`text/plain`,t),e.preventDefault())},children:[/* @__PURE__ */ (0,Y.jsx)(AC,{action:OC(e.message,e.conversation),message:e.message,conversation:e.conversation}),e.message.reviewItemChanges?.length?e.message.reviewItemChanges.map((e,t)=>/* @__PURE__ */ (0,Y.jsx)(fS,{fallback:a,record:e},t)):a,/* @__PURE__ */ (0,Y.jsx)(QS,{message:e.message}),e.message.attachments?.length?/* @__PURE__ */ (0,Y.jsx)(W_,{attachments:e.message.attachments,conversationId:e.conversation.conversationId}):null,e.message.images?.length?/* @__PURE__ */ (0,Y.jsx)(G_,{images:e.message.images}):null,e.message.cards?.map(e=>{switch(e.kind){case`object`:return/* @__PURE__ */ (0,Y.jsx)(vC,{card:e},`${e.plugin}:${e.key}`);case`automation`:return/* @__PURE__ */ (0,Y.jsx)(_C,{card:e},`${e.kind}:${e.id}`)}}),n===`assistant`&&!e.message.pending&&(t||i)?/* @__PURE__ */ (0,Y.jsxs)(SS,{className:`-mt-1.5 -mb-2.5 -ml-2 [&>button]:size-8`,children:[t?/* @__PURE__ */ (0,Y.jsx)(Yf,{getText:()=>t,label:`Copy message`}):null,i?/* @__PURE__ */ (0,Y.jsx)(hC,{conversationId:e.conversation.conversationId,messageId:i}):null,e.message.messageId?/* @__PURE__ */ (0,Y.jsx)(iC,{conversationId:e.conversation.conversationId,messageId:e.message.messageId}):null]}):null]})},(e,t)=>e.message===t.message&&e.conversation.conversationId===t.conversation.conversationId&&e.conversation.surface===t.conversation.surface&&e.conversation.canFork===t.conversation.canFork&&e.conversation.actorIdentity===t.conversation.actorIdentity&&e.conversation.authors===t.conversation.authors);function DC(e){return/* @__PURE__ */ (0,Y.jsxs)(HS,{role:e.message.role,actor:ro(e.conversation,e.message),fromAgent:!!e.message.agentInvocationId,avatarUrl:ka(e.conversation,e.message)?.avatarUrl,children:[/* @__PURE__ */ (0,Y.jsx)(AC,{message:e.message,conversation:e.conversation}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)] gap-1 font-mono text-base leading-snug text-dashboard-text-muted`,children:e.message.parts.map((e,t)=>/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`py-1`,children:/* @__PURE__ */ (0,Y.jsx)(aC,{})},t))})]})}function OC(e,t){if(e.role===`user`&&e.contexts?.length)return/* @__PURE__ */ (0,Y.jsx)(cC,{actor:ka(t,e),contexts:e.contexts,messageId:e.messageId,timestamp:e.timestamp})}function kC(e,t){return!!(t.canFork&&e.role===`assistant`&&e.messageId&&!e.pending)}function AC(e){let t=wC(e.message,e.conversation),n=Ba(e.message.timestamp),r=ro(e.conversation,e.message);return/* @__PURE__ */ (0,Y.jsxs)(TS,{action:e.action,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:jC(e.message.role),children:r}),t||n?/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`inline-flex max-w-full flex-wrap items-baseline gap-x-1.5 text-xs leading-6 text-dashboard-text-muted`,children:[t?/* @__PURE__ */ (0,Y.jsx)(SC,{provider:t}):null,t&&n?/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}):null,/* @__PURE__ */ (0,Y.jsx)(GS,{value:e.message.timestamp})]}):null]})}function jC(e){let t=_a(e);return K(`inline-block max-w-full truncate font-sans text-sm font-semibold leading-6`,t===`assistant`&&`text-dashboard-accent-text`,t===`user`&&`text-dashboard-text`,t===`system`&&`text-amber-200`,t===`tool`&&`text-dashboard-text-muted`,t===`other`&&`text-dashboard-text`)}function MC(e){return/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`break-all rounded-md border border-dashboard-border px-1.5 py-0.5 font-mono text-2xs leading-none text-dashboard-text-muted`,children:/* @__PURE__ */ (0,Y.jsx)(Q,{text:e.eventType})})}function NC(e){let t=e[0]?.label,n=t&&e.every(e=>e.label===t);return`${e.length} events${n?` · ${t}`:``}`}function PC(e){let{active:t}=sh(),[n,r]=Vb(e.openKey),i=bf(e.message),a=e.message.parts.some(e=>e.type===`text`&&e.redacted),o=e.message.events??[],s=e.message.mentions??[],c=o.length>1,l=TC(e.message),u=c?NC(o):e.message.trustedSummary??e.message.eventType??``,d=!i,f=/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`flex min-h-6 min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 break-words font-display text-sm font-semibold leading-6 text-dashboard-text`,children:/* @__PURE__ */ (0,Y.jsx)($,{inline:!0,links:d,mentions:s,text:u})}),l?/* @__PURE__ */ (0,Y.jsx)(SC,{provider:l}):null,!c&&e.message.eventType?/* @__PURE__ */ (0,Y.jsx)(MC,{eventType:e.message.eventType}):null]}),c?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`flex min-w-0 flex-col gap-1`,role:`list`,children:o.map((e,t)=>/* @__PURE__ */ (0,Y.jsxs)(`span`,{role:`listitem`,className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs leading-5 text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 break-words`,children:/* @__PURE__ */ (0,Y.jsx)($,{inline:!0,links:d,mentions:s,text:e.trustedSummary??e.eventType})}),/* @__PURE__ */ (0,Y.jsx)(MC,{eventType:e.eventType})]},t))}):null]}),p=/* @__PURE__ */ (0,Y.jsx)(Y.Fragment,{children:i?/* @__PURE__ */ (0,Y.jsxs)(nh,{className:`min-w-0`,disabled:t,onOpenChange:r,open:t||n,children:[/* @__PURE__ */ (0,Y.jsxs)(px,{flush:!0,className:`group flex items-start gap-2 text-dashboard-text-muted`,children:[f,/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,className:K(ia,`mt-1.5`),strokeWidth:2.2})]}),/* @__PURE__ */ (0,Y.jsx)(ih,{hiddenUntilFound:!0,children:/* @__PURE__ */ (0,Y.jsx)(`pre`,{className:`mt-2 max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-lg border border-dashboard-border bg-dashboard-surface-panel px-3 py-2 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:/* @__PURE__ */ (0,Y.jsx)(Q,{text:i})})})]}):/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[f,a?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`mt-2`,children:/* @__PURE__ */ (0,Y.jsx)(aC,{})}):null]})}),m=e.message.reviewItemChanges??[],h=m.length>0&&o.length===0;return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`min-w-0 py-1`,children:[h?null:p,m.length?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:K(`grid min-w-0 gap-2`,!h&&`mt-2`),children:m.map((e,t)=>/* @__PURE__ */ (0,Y.jsx)(fS,{fallback:h&&m.length===1?p:null,record:e},t))}):null]})}function FC(e,t){let n=e.sourceTask?.triggerMessageId;return!!(n&&t.role===`user`&&t.messageId===n)}function IC(e){if(e.credentialMode===`system`)return`Runs as system`;if(e.credentialMode===`creator`&&e.credentialUser)return`Runs as ${e.credentialUser}`}function LC(e){let t=bf(e.message),n=e.message.parts.some(e=>e.type===`text`&&e.redacted),[r,i]=(0,J.useState)(!1),a=e.sourceTask.id?.trim(),o=e.sourceTask.title?.trim()||`Automation`,s=[e.sourceTask.triggerLabel,e.message.timestamp?no(new Date(e.message.timestamp).toISOString()):void 0,IC(e.sourceTask)].filter(Boolean);return/* @__PURE__ */ (0,Y.jsxs)(`section`,{"aria-label":o,className:`grid w-full min-w-0 max-w-[37.5rem] gap-2 rounded-xl border border-dashboard-border-emphasis bg-dashboard-surface-panel px-4 py-3`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[/* @__PURE__ */ (0,Y.jsx)(th,{objectType:`automation`,size:16,decorative:!0}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-sans text-sm font-semibold text-dashboard-text`,children:/* @__PURE__ */ (0,Y.jsx)(Q,{text:o})}),a?/* @__PURE__ */ (0,Y.jsxs)(V,{className:K(wt(),`h-8 shrink-0 text-xs`),to:Ka(a),children:[`Open automation`,/* @__PURE__ */ (0,Y.jsx)(qt,{"aria-hidden":`true`,size:14})]}):null]}),s.length>0?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 min-w-0 break-words text-xs leading-relaxed text-dashboard-text-muted`,children:s.join(` · `)}):null,t?/* @__PURE__ */ (0,Y.jsxs)(nh,{className:`min-w-0`,onOpenChange:i,open:r,children:[/* @__PURE__ */ (0,Y.jsxs)(rh,{className:`group -mx-1 inline-flex cursor-pointer items-center gap-1 rounded-sm border-0 bg-transparent px-1 py-0.5 font-sans text-xs font-medium text-dashboard-text-muted transition-colors hover:text-dashboard-text focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus`,children:[/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,className:`size-3 transition-transform group-aria-expanded:rotate-90 motion-reduce:transition-none`,strokeWidth:2.2}),r?`Hide prompt`:`Show prompt`]}),/* @__PURE__ */ (0,Y.jsx)(ih,{children:/* @__PURE__ */ (0,Y.jsx)(`pre`,{className:`mt-2 max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-lg border border-dashboard-border-subtle bg-dashboard-bg px-3 py-2 font-mono text-xs leading-relaxed text-dashboard-text-muted`,children:/* @__PURE__ */ (0,Y.jsx)(Q,{text:t})})})]}):n?/* @__PURE__ */ (0,Y.jsx)(aC,{}):null]})}function RC(){let e=`${pa()} is thinking…`;return/* @__PURE__ */ (0,Y.jsx)(`div`,{"aria-live":`polite`,className:`flex items-center text-sm text-dashboard-text-muted`,role:`status`,children:/* @__PURE__ */ (0,Y.jsx)(Fv,{active:!0,children:e})})}const zC=`unread-marker`;function BC(e){let{entries:t,search:n}=e,r=gx(t),i=e=>hx(e)||r.has(e.key),a=e=>n===void 0||fh(e,n),o=/* @__PURE__ */ new Set,s=[],c=n===void 0?XC(t,e.unread):void 0,l=c!==void 0,u=e=>{l&&e.seq!==void 0&&e.seq>=c&&(l=!1,s.push({kind:`unread_marker`,key:zC})),s.push(e)},d=[],f=()=>{for(let t of d)a(t)&&(l&&t.seq!==void 0&&t.seq>=c&&(l=!1,s.push({kind:`unread_marker`,key:zC})),u({kind:`entry`,entry:t,key:`${e.keyPrefix}:${t.key}`,seq:WC(s)??t.seq}));d=[]};for(let n=0;n<t.length;){let r=t[n];if(HC(r))d.push(r),n+=1;else if(r.kind===`message`&&r.message.role===`user`&&!i(r)&&f(),i(r)){let r=[];for(;n<t.length;){let e=t[n];if(HC(e))d.push(e);else if(i(e))r.push(e);else break;n+=1}let s=r.filter(a);s.length>0&&u({kind:`activity`,entries:s,key:QC({claimedKeys:o,entries:r,keyPrefix:e.keyPrefix,knownKeys:e.knownActivityKeys}),seq:ZC(r)})}else if(GC(r)){let r=[];for(;n<t.length&&GC(t[n]);)r.push(t[n]),n+=1;let i=r.filter(a);i.length>0&&u({kind:`tasks`,entries:i,key:`${e.keyPrefix}:tasks:${r[0].key}`,seq:ZC(r)})}else a(r)&&u({kind:`entry`,entry:r,key:`${e.keyPrefix}:${r.key}`,seq:r.seq}),n+=1}return f(),s}function VC(e){return e.kind===`tool`?rS(e.part):void 0}function HC(e){return VC(e)!==void 0}function UC(e,t){let n=e.findIndex(e=>e.kind===`entry`&&VC(e.entry)===t);return n<0?void 0:n}function WC(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.kind!==`unread_marker`&&n.seq!==void 0)return n.seq}}function GC(e){return e.kind===`subagent`&&e.part.childKind===`task`}function KC(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1,a=e[i],o=a.kind===`unread_marker`?qC(e,i)??-1/0:a.seq;o!==void 0&&o<t?n=i+1:r=i}return n}function qC(e,t){let n=e[t-1];return n===void 0||n.kind===`unread_marker`?void 0:n.seq}function JC(e){if(e.kind!==`entry`)return e.kind;let{entry:t}=e;return t.kind===`message`?`message:${t.message.role}`:t.kind}function YC(e){return e===`unread_marker`?32:e===`activity`||e===`tasks`?36:e===`attachments_delivered`?240:e===`message:assistant`?120:e.startsWith(`message:`)?80:44}function XC(e,t){if(!t)return;let n=0,r=e.length;for(;n<r;){let i=n+r>>1,a=e[i].seq;a!==void 0&&a<=t.afterSeq?n=i+1:r=i}let i=e[n]?.seq;return i!==void 0&&i<=t.throughSeq?i:void 0}function ZC(e){for(let t=e.length-1;t>=0;--t){let n=e[t].seq;if(n!==void 0)return n}}function QC(e){let t=e.entries.map(t=>`${e.keyPrefix}:${t.key}`),n=t.map(t=>e.knownKeys.get(t)).find(t=>t!==void 0&&!e.claimedKeys.has(t))??`${e.keyPrefix}:activity:${e.entries[0].key}`;return e.claimedKeys.add(n),t.forEach(t=>e.knownKeys.set(t,n)),n}function $C(e){let{listRef:t}=e,n=(0,J.useRef)(/* @__PURE__ */ new Map),r=(0,J.useRef)(/* @__PURE__ */ new Map),i=(0,J.useRef)(/* @__PURE__ */ new Map),a=(0,J.useRef)(e);a.current=e;let o=(0,J.useCallback)(e=>{let t=a.current.getItemKey(e),r=i.current.get(t);if(r!==void 0)return r;let o=a.current.sizeClass(e),s=n.current.get(o),c=s?.count?s.total/s.count:a.current.defaultSize(o);return i.current.set(t,c),c},[]),s=(e,t,i)=>{let a=r.current.get(e);if(a){let e=n.current.get(a.sizeClass);--e.count,e.total-=a.size}r.current.set(e,{size:i,sizeClass:t});let o=n.current.get(t)??{count:0,total:0};o.count+=1,o.total+=i,n.current.set(t,o)},c=(0,J.useRef)(null),l=(0,J.useRef)(null),u=c.current?.scrollOffset;l.current&&l.current.scrollOffset===u||(i.current.clear(),l.current={getItemKey:e=>a.current.getItemKey(e),scrollOffset:u});let[d,f]=(0,J.useState)(0),p=e.keptIndexes.filter(t=>t!==void 0&&t>=0&&t<e.count).join(`,`),m=(0,J.useCallback)(e=>{let t=new Set(ee(e));if(p)for(let e of p.split(`,`))t.add(Number(e));return[...t].sort((e,t)=>e-t)},[p]),h=(0,J.useCallback)(()=>{let e=t.current,n=Up(e);if(!e||!(n instanceof Element))return;let r=e.getBoundingClientRect().top-n.getBoundingClientRect().top+n.scrollTop;f(e=>Math.abs(r-e)>=1?r:e)},[t]);(0,J.useLayoutEffect)(h,[h]);let g=ie({count:e.count,estimateSize:o,gap:e.gap,getItemKey:l.current.getItemKey,measureElement:(e,t,n)=>{let r=te(e,t,n),i=n.indexFromElement(e);return s(a.current.getItemKey(i),a.current.sizeClass(i),r),r},initialRect:typeof window>`u`?{height:1e3,width:0}:void 0,getScrollElement:()=>{let e=Up(t.current);return e instanceof Element?e:null},onChange:h,overscan:10,rangeExtractor:m,scrollMargin:d,scrollToFn:()=>{}});return g.shouldAdjustScrollPositionOnItemSizeChange=()=>!1,c.current=g,g}const ew=(0,J.createContext)(void 0);function tw(e){return/* @__PURE__ */ (0,Y.jsx)(VS,{openKey:e.key,part:e.part,timestamp:e.timestamp})}function nw(e){return/* @__PURE__ */ (0,Y.jsx)(lx,{kind:`thread`,children:/* @__PURE__ */ (0,Y.jsx)(Qb,{part:e.part,timestamp:e.timestamp})})}function rw(e,t,n){return/* @__PURE__ */ (0,Y.jsx)(lx,{kind:`tasks`,children:/* @__PURE__ */ (0,Y.jsx)(Xb,{entries:e,onOpenTranscript:n,openKey:t})})}const iw=(0,J.memo)(function(e){let{events:t,annotations:n}=e.conversation,r=(0,J.useMemo)(()=>xa(t,n,e.pendingMessages),[t,n,e.pendingMessages]);return/* @__PURE__ */ (0,Y.jsx)(WS,{children:/* @__PURE__ */ (0,Y.jsx)(L_,{conversationId:e.conversation.conversationId,messages:r,children:/* @__PURE__ */ (0,Y.jsx)(`section`,{className:`min-w-0 pt-1`,children:/* @__PURE__ */ (0,Y.jsx)(aw,{onOpenSubagentTranscript:e.onOpenSubagentTranscript,conversation:e.conversation,messages:r,responding:e.responding,revealSeq:e.revealSeq,scrollAnchorKey:e.scrollAnchorKey,unread:e.unread})})})})});function aw(e){let t={revealSeq:e.revealSeq,scrollAnchorKey:e.scrollAnchorKey};return/* @__PURE__ */ (0,Y.jsxs)(Rb,{children:[e.conversation.eventHistory.status===`expired`?/* @__PURE__ */ (0,Y.jsx)(ow,{brief:e.conversation.brief,expiredAt:e.conversation.eventHistory.expiredAt}):e.conversation.eventHistory.status===`available`?/* @__PURE__ */ (0,Y.jsx)(sw,{...t,onOpenSubagentTranscript:e.onOpenSubagentTranscript,transcript:e.messages,conversation:e.conversation,unread:e.unread}):e.conversation.eventHistory.status===`redacted`&&e.messages.length>0?/* @__PURE__ */ (0,Y.jsx)(uw,{...t,onOpenSubagentTranscript:e.onOpenSubagentTranscript,conversation:e.conversation,messages:e.messages}):e.messages.length>0?/* @__PURE__ */ (0,Y.jsx)(sw,{...t,onOpenSubagentTranscript:e.onOpenSubagentTranscript,transcript:e.messages,conversation:e.conversation}):/* @__PURE__ */ (0,Y.jsx)(xm,{children:Ma(e.conversation)}),e.responding?/* @__PURE__ */ (0,Y.jsx)(Hb,{indent:!0,children:/* @__PURE__ */ (0,Y.jsx)(RC,{})}):null]})}function ow(e){return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[e.brief?/* @__PURE__ */ (0,Y.jsxs)(ca,{as:`section`,padding:`md`,variant:`section`,children:[/* @__PURE__ */ (0,Y.jsx)(`h3`,{className:`mt-0 mb-3 font-display text-lg font-medium text-dashboard-text`,children:`Brief`}),/* @__PURE__ */ (0,Y.jsx)(lb,{brief:e.brief})]}):null,/* @__PURE__ */ (0,Y.jsxs)(_m,{className:`flex items-start gap-3 border-dashed border-dashboard-border-emphasis bg-dashboard-fill-soft`,children:[/* @__PURE__ */ (0,Y.jsx)(vm,{children:/* @__PURE__ */ (0,Y.jsx)(ar,{})}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,Y.jsx)(ym,{children:`Transcript expired`}),/* @__PURE__ */ (0,Y.jsxs)(bm,{className:`mt-1 text-sm`,children:[`The retention policy removed these events on`,` `,/* @__PURE__ */ (0,Y.jsx)(`time`,{dateTime:e.expiredAt,children:to(e.expiredAt,{dateStyle:`medium`,timeStyle:`short`})}),`.`,e.brief?` The brief above is still available.`:null]})]})]})]})}const sw=(0,J.memo)(function(e){let t=(0,J.useMemo)(()=>yf(e.transcript),[e.transcript]);return/* @__PURE__ */ (0,Y.jsx)(cw,{entries:t,keyPrefix:e.conversation.conversationId,revealSeq:e.revealSeq,scrollAnchorKey:e.scrollAnchorKey,unread:e.unread,renderContext:e=>/* @__PURE__ */ (0,Y.jsx)(lx,{kind:`compaction`,children:/* @__PURE__ */ (0,Y.jsx)($b,{part:e.part,timestamp:e.timestamp})}),renderFailure:e=>/* @__PURE__ */ (0,Y.jsx)(eC,{eventId:e.eventId,failureCode:e.failureCode,failureReason:e.failureReason,sentryEventUrl:e.sentryEventUrl,timestamp:e.timestamp}),renderMessage:t=>e.conversation.sourceTask&&FC(e.conversation,t.message)?/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[/* @__PURE__ */ (0,Y.jsx)(LC,{message:t.message,sourceTask:e.conversation.sourceTask}),/* @__PURE__ */ (0,Y.jsx)(QS,{message:t.message})]}):t.message.eventType?/* @__PURE__ */ (0,Y.jsxs)(lx,{kind:`event`,objectType:t.message.eventObjectType,children:[/* @__PURE__ */ (0,Y.jsx)(PC,{message:t.message,openKey:t.key}),/* @__PURE__ */ (0,Y.jsx)(QS,{className:`mt-1`,message:t.message})]}):t.message.context?/* @__PURE__ */ (0,Y.jsxs)(lx,{kind:`message_context`,children:[/* @__PURE__ */ (0,Y.jsx)(mC,{message:t.message,conversation:e.conversation}),/* @__PURE__ */ (0,Y.jsx)(QS,{className:`mt-2`,message:t.message})]}):/* @__PURE__ */ (0,Y.jsx)(EC,{message:t.message,conversation:e.conversation}),renderAttachmentsDelivered:t=>/* @__PURE__ */ (0,Y.jsx)(KS,{conversation:e.conversation,part:t.part,timestamp:t.timestamp}),renderStructuredEvent:e=>/* @__PURE__ */ (0,Y.jsx)(lx,{icon:fx(e.part.presentation.icon),kind:`structured_event`,children:sx(e.part)?/* @__PURE__ */ (0,Y.jsx)($S,{fallback:/* @__PURE__ */ (0,Y.jsx)(qS,{part:e.part,timestamp:e.timestamp}),timestamp:e.timestamp,turnId:e.part.turnId}):/* @__PURE__ */ (0,Y.jsx)(qS,{part:e.part,timestamp:e.timestamp})}),renderThread:nw,renderTasks:(t,n)=>rw(t,n,t=>e.onOpenSubagentTranscript?.({part:t,conversation:e.conversation})),renderReasoning:tw,renderTool:e=>/* @__PURE__ */ (0,Y.jsx)(LS,{part:e.part,timestamp:e.timestamp})},e.conversation.conversationId)});function cw(e){let t=sh(),n=(0,J.useRef)(/* @__PURE__ */ new Map),[r]=(0,J.useState)(()=>/* @__PURE__ */ new Map),i=rC(),a=(0,J.useRef)(null),o=t.active?t.normalizedQuery:void 0,s=(0,J.useMemo)(()=>BC({entries:e.entries,keyPrefix:e.keyPrefix,knownActivityKeys:n.current,search:o,unread:e.unread}),[e.entries,e.keyPrefix,e.unread,o]),c=(0,J.useMemo)(()=>new Map(s.map((e,t)=>[e.key,t])),[s]),l=o===void 0?0:s.length,{match:u,onMatches:d}=t,f=(0,J.useRef)({});(0,J.useEffect)(()=>{let e=f.current,t=e.query===o,n=l>0&&t&&e.firstKey!==void 0?c.get(e.firstKey)??0:0,r=Math.min(u+n,l-1),i=l>0?s[r]?.key:void 0;f.current={firstKey:s[0]?.key,matchKey:i,query:o},d?.(l,n),t&&i!==void 0&&i!==e.matchKey&&a.current?.querySelector(`[data-index="${r}"]`)?.scrollIntoView({block:`center`})},[c,u,l,d,s,o]);let p=(0,J.use)(ew),m=p?.itemId,h=(0,J.useMemo)(()=>m===void 0?void 0:UC(s,m),[m,s]),g=(0,J.useRef)(void 0),_=(0,J.useRef)(void 0);(0,J.useEffect)(()=>{let e=a.current;if(!e||!p||h===void 0||g.current===p.version)return;let t=()=>{let t=e.querySelector(`[data-index="${h}"]`),n=t?.querySelector(`[data-review-item-ask]`);if(!t||!n)return!1;if(g.current=p.version,!p.showRow(t,{arrived:p.arrived}))return!0;let r=_.current;return r&&(window.clearTimeout(r.timer),r.record.removeAttribute(`data-highlighted`)),n.setAttribute(`data-highlighted`,``),_.current={record:n,timer:window.setTimeout(()=>{n.removeAttribute(`data-highlighted`),_.current=void 0},1600)},!0};if(t())return;let n=new MutationObserver(()=>{t()&&n.disconnect()});return n.observe(e,{childList:!0,subtree:!0}),()=>n.disconnect()},[h,p]),(0,J.useEffect)(()=>()=>window.clearTimeout(_.current?.timer),[]);let v=e.scrollAnchorKey?.(),y=c.get(zC),b=e.revealSeq===void 0?void 0:KC(s,e.revealSeq),x=$C({count:s.length,defaultSize:YC,gap:4,getItemKey:e=>s[e].key,keptIndexes:[v===void 0?void 0:c.get(v),y,y===void 0?void 0:y+1,b,b===void 0?void 0:b-1,l===0?void 0:u,h],listRef:a,sizeClass:e=>JC(s[e])}),{renderAttachmentsDelivered:S,renderContext:C,renderFailure:w,renderMessage:T,renderReasoning:E,renderStructuredEvent:D,renderThread:O,renderTasks:k,renderTool:A}=e,j=(0,J.useCallback)(e=>e.kind===`subagent`?O(e):e.kind===`context`?C(e):e.kind===`attachments_delivered`?S(e):e.kind===`structured_event`?D(e):e.kind===`failure`?w(e):e.kind===`reasoning`?E(e):e.kind===`tool`?A(e):T(e),[S,C,w,T,E,D,O,A]);return t.active&&s.length===0?/* @__PURE__ */ (0,Y.jsx)(xm,{children:`No events match your search.`}):/* @__PURE__ */ (0,Y.jsx)(Bb,{value:r,children:/* @__PURE__ */ (0,Y.jsx)(nC,{value:i,children:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`relative min-w-0`,ref:a,style:{height:x.getTotalSize()},children:x.getVirtualItems().map(e=>/* @__PURE__ */ (0,Y.jsx)(lw,{current:l>0&&e.index===u,index:e.index,measure:x.measureElement,offset:e.start-x.options.scrollMargin,renderEntry:j,renderTasks:k,row:s[e.index]},e.key))})})})}const lw=(0,J.memo)(function(e){let{row:t}=e;return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:K(`absolute left-0 top-0 w-full rounded-lg`,e.current&&`ring-1 ring-amber-400/40`),"data-index":e.index,ref:e.measure,style:{transform:`translateY(${e.offset}px)`},children:t.kind===`unread_marker`?/* @__PURE__ */ (0,Y.jsx)(zb,{}):t.kind===`activity`?/* @__PURE__ */ (0,Y.jsx)(Hb,{anchorKey:t.key,indent:!0,seq:t.seq,children:/* @__PURE__ */ (0,Y.jsx)(Cx,{entries:t.entries,openKey:t.key,renderEntry:e.renderEntry})}):t.kind===`tasks`?/* @__PURE__ */ (0,Y.jsx)(Hb,{anchorKey:t.key,seq:t.seq,children:e.renderTasks(t.entries,t.key)}):/* @__PURE__ */ (0,Y.jsx)(Hb,{anchorKey:t.key,seq:t.seq,children:e.renderEntry(t.entry)})})});function uw(e){return/* @__PURE__ */ (0,Y.jsx)(cw,{entries:yf(e.messages),keyPrefix:`${e.conversation.conversationId}:redacted`,revealSeq:e.revealSeq,scrollAnchorKey:e.scrollAnchorKey,renderContext:e=>/* @__PURE__ */ (0,Y.jsx)(lx,{kind:`compaction`,children:/* @__PURE__ */ (0,Y.jsx)($b,{part:e.part,timestamp:e.timestamp})}),renderFailure:e=>/* @__PURE__ */ (0,Y.jsx)(eC,{eventId:e.eventId,failureCode:e.failureCode,failureReason:e.failureReason,sentryEventUrl:e.sentryEventUrl,timestamp:e.timestamp}),renderMessage:t=>e.conversation.sourceTask&&FC(e.conversation,t.message)?/* @__PURE__ */ (0,Y.jsx)(LC,{message:t.message,sourceTask:e.conversation.sourceTask}):t.message.eventType?/* @__PURE__ */ (0,Y.jsx)(lx,{kind:`event`,objectType:t.message.eventObjectType,children:/* @__PURE__ */ (0,Y.jsx)(PC,{message:t.message,openKey:t.key})}):t.message.context?/* @__PURE__ */ (0,Y.jsx)(lx,{kind:`message_context`,children:/* @__PURE__ */ (0,Y.jsx)(mC,{message:t.message,conversation:e.conversation,redacted:!0})}):/* @__PURE__ */ (0,Y.jsx)(DC,{message:t.message,conversation:e.conversation}),renderAttachmentsDelivered:t=>/* @__PURE__ */ (0,Y.jsx)(KS,{conversation:e.conversation,part:t.part,timestamp:t.timestamp}),renderStructuredEvent:e=>/* @__PURE__ */ (0,Y.jsx)(lx,{icon:fx(e.part.presentation.icon),kind:`structured_event`,children:/* @__PURE__ */ (0,Y.jsx)(qS,{part:e.part,timestamp:e.timestamp})}),renderThread:nw,renderTasks:(t,n)=>rw(t,n,t=>e.onOpenSubagentTranscript?.({part:t,conversation:e.conversation})),renderReasoning:tw,renderTool:e=>/* @__PURE__ */ (0,Y.jsx)(LS,{part:e.part,timestamp:e.timestamp})},e.conversation.conversationId)}function dw(){let[e,n]=t(`junior:event-log:time-mode`,`utc`),r=e===`local`,i=Intl.DateTimeFormat().resolvedOptions().timeZone,a=r?i:`UTC`,o=(0,J.useMemo)(()=>{let e={timeZone:a,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,fractionalSecondDigits:3,hourCycle:`h23`,numberingSystem:`latn`};return{clock:new Intl.DateTimeFormat(`en-GB`,e),timestamp:new Intl.DateTimeFormat(void 0,{...e,year:`numeric`,month:`short`,day:`numeric`,timeZoneName:`short`}),shortTimestamp:new Intl.DateTimeFormat(void 0,{...e,fractionalSecondDigits:void 0,year:`numeric`,month:`short`,day:`numeric`,timeZoneName:`short`}),zone:new Intl.DateTimeFormat(void 0,{timeZone:a,timeZoneName:`shortGeneric`})}},[a]);return{local:r,label:r?o.zone.formatToParts().find(e=>e.type===`timeZoneName`)?.value??i:`UTC`,title:r?`${i} · Switch to UTC`:`UTC · Switch to local time (${i})`,toggle(){n(r?`utc`:`local`)},formatClock(e){return o.clock.format(new Date(e))},formatTimestamp(e){return o.timestamp.format(new Date(e))},formatShortTimestamp(e){return o.shortTimestamp.format(new Date(e))}}}function fw(e){let t=e.modelCall?.usage,n=Ea(t);return[n?`${Ra(n)} call`:void 0,...[[`inputTokens`,`in`],[`outputTokens`,`out`],[`cachedInputTokens`,`cache read`],[`cacheCreationTokens`,`cache write`],[`reasoningTokens`,`reasoning`],[`totalTokens`,`total`]].map(([e,n])=>t?.[e]===void 0?void 0:`${Wa(t[e])} ${n}`)].filter(e=>e!==void 0).join(` · `)}function pw(e){switch(e.type){case`message`:return`${e.role} · ${e.redacted?`Content hidden`:e.text||`Empty message`}`;case`message_handled`:return e.messageId;case`assistant_message`:return e.parts.map(e=>e.redacted?`Content hidden`:e.text).join(` · `)||`Model call recorded`;case`tool_calls`:return e.calls.map(e=>{let t=OS(e.name,e.input);return`${e.name} · ${e.status}${t?` · ${t}`:``}`}).join(` / `);case`turn_lifecycle`:return e.state===`failed`?`${e.state} · ${e.failureCode}${e.failureReason?` · ${e.failureReason}`:``}`:`${e.state} · ${e.turnId}`;case`turn_context`:return`${e.pluginName} · ${e.kind} · v${e.version}`;case`guardian_action_reviewed`:return`${e.decision} · ${e.toolName} · ${e.riskLevel} risk`;case`structured_event`:return`${e.namespace}.${e.name} · ${e.presentation.title}`;case`attachments_delivered`:return e.attachments.map(e=>e.filename).join(`, `);case`reply_posted`:return`${e.plugin} · ${e.url??e.text}`;case`compaction`:return e.summary??`Agent history compacted`;case`subagent`:return`${e.agentName??e.subagentKind} · ${e.status} · ${e.childConversationId}`}}function mw(e){return e.type===`turn_lifecycle`&&e.state===`failed`||e.type===`tool_calls`&&e.calls.some(e=>e.status===`error`)||e.type===`subagent`&&e.status===`error`||e.type===`guardian_action_reviewed`&&e.decision===`deny`?`text-rose-300`:e.type===`guardian_action_reviewed`&&e.decision===`ask`||e.type===`turn_lifecycle`&&e.state===`blocked`||e.type===`subagent`&&(e.status===`aborted`||e.status===`blocked`)?`text-amber-200`:`text-dashboard-text-subtle`}function hw(e){return e.map(e=>({event:e,summary:pw(e.data).replace(/\s+/g,` `).slice(0,300),metadata:[e.model?.modelId,fw(e)].filter(Boolean).join(` · `)}))}function gw(e,t){return t?e.filter(({event:e,summary:n,metadata:r})=>`${n} ${r} ${JSON.stringify(e)}`.toLowerCase().includes(t)):e}function _w(e,t){let n=e.findIndex(e=>e.event.seq===t);return n===-1?{}:{previous:e[n-1]?.event.seq,next:e[n+1]?.event.seq}}const vw=I(`flex w-fit items-stretch *:focus-visible:relative *:focus-visible:z-10 has-[>[data-slot=button-group]]:gap-2`,{variants:{orientation:{horizontal:`*:data-slot:rounded-r-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-r-md! [&>[data-slot]~[data-slot]]:rounded-l-none [&>[data-slot]~[data-slot]]:border-l-0`,vertical:`flex-col *:data-slot:rounded-b-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-md! [&>[data-slot]~[data-slot]]:rounded-t-none [&>[data-slot]~[data-slot]]:border-t-0`}},defaultVariants:{orientation:`horizontal`}});function yw({className:e,orientation:t,...n}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{role:`group`,"data-slot":`button-group`,"data-orientation":t,className:F(vw({orientation:t}),e),...n})}function bw({className:e,orientation:t=`vertical`,...n}){return/* @__PURE__ */ (0,Y.jsx)(Vl,{"data-slot":`button-group-separator`,orientation:t,className:F(`relative self-stretch bg-dashboard-border data-horizontal:mx-px data-horizontal:w-auto data-vertical:my-px data-vertical:h-auto`,e),...n})}function xw({usage:e}){let t=Ea(e),n=[{label:`Input`,tokens:e?.inputTokens,cost:e?.cost?.input},{label:`Output`,tokens:e?.outputTokens,cost:e?.cost?.output},{label:`Cache read`,tokens:e?.cachedInputTokens,cost:e?.cost?.cacheRead},{label:`Cache write`,tokens:e?.cacheCreationTokens,cost:e?.cost?.cacheWrite},{label:`Reasoning`,tokens:e?.reasoningTokens},{label:`Total`,tokens:e?.totalTokens,cost:t?.total}].filter(e=>e.tokens!==void 0||e.cost!==void 0);if(n.length===0)return/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:`Token usage and cost were not recorded for this call.`});let r=n.find(e=>e.label===`Total`);return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(Oh,{"aria-label":`Model call token and cost breakdown`,className:`min-w-72 table-fixed text-xs leading-relaxed`,children:[/* @__PURE__ */ (0,Y.jsxs)(`colgroup`,{children:[/* @__PURE__ */ (0,Y.jsx)(`col`,{}),/* @__PURE__ */ (0,Y.jsx)(`col`,{className:`w-24`}),/* @__PURE__ */ (0,Y.jsx)(`col`,{className:`w-24`})]}),/* @__PURE__ */ (0,Y.jsx)(kh,{children:/* @__PURE__ */ (0,Y.jsxs)(Mh,{className:`border-dashboard-border`,children:[/* @__PURE__ */ (0,Y.jsx)(Nh,{scope:`col`,className:`px-0 py-2 leading-relaxed font-normal`,children:`Usage`}),/* @__PURE__ */ (0,Y.jsx)(Nh,{scope:`col`,className:`px-0 py-2 text-right leading-relaxed font-normal`,children:`Tokens`}),/* @__PURE__ */ (0,Y.jsx)(Nh,{scope:`col`,className:`px-0 py-2 text-right leading-relaxed font-normal`,children:`Cost (USD)`})]})}),/* @__PURE__ */ (0,Y.jsx)(Ah,{children:n.filter(e=>e!==r).map(e=>/* @__PURE__ */ (0,Y.jsx)(Sw,{...e},e.label))}),r?/* @__PURE__ */ (0,Y.jsx)(jh,{className:`font-semibold`,children:/* @__PURE__ */ (0,Y.jsx)(Sw,{...r,total:!0})}):null]}),/* @__PURE__ */ (0,Y.jsxs)(`p`,{className:`m-0 text-xs leading-relaxed text-dashboard-text-muted`,children:[`This call only · Estimated costs`,/* @__PURE__ */ (0,Y.jsx)(`br`,{}),`Input excludes cache reads and writes. Reasoning is included in output.`]})]})}function Sw(e){return/* @__PURE__ */ (0,Y.jsxs)(Mh,{children:[/* @__PURE__ */ (0,Y.jsx)(Nh,{scope:`row`,className:K(`px-0 py-2 leading-relaxed`,e.total?`font-semibold text-dashboard-text`:`font-normal text-dashboard-text-muted`),children:e.label}),/* @__PURE__ */ (0,Y.jsx)(Ph,{className:`px-0 py-2 text-right font-sans tabular-nums`,children:e.tokens===void 0?/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-label":`Not recorded`,className:`text-dashboard-text-faint`,children:`—`}):e.tokens.toLocaleString(`en-US`)}),/* @__PURE__ */ (0,Y.jsx)(Ph,{className:`px-0 py-2 text-right font-sans tabular-nums`,children:e.cost===void 0?/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-label":`Not recorded separately`,className:`text-dashboard-text-faint`,children:`—`}):/* @__PURE__ */ (0,Y.jsx)(`span`,{title:`${e.cost} USD`,children:Ra({total:e.cost})})})]})}function Cw({event:e}){let t=e.data,n=e.mentions??[],r=e.model,{usage:i,...a}=e.modelCall??{},o;switch(t.type){case`message`:{let{type:e,text:r,redacted:i,...a}=t;o=/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(Tw,{children:/* @__PURE__ */ (0,Y.jsx)(Ow,{value:a})}),/* @__PURE__ */ (0,Y.jsx)(Tw,{title:`Message`,children:i?/* @__PURE__ */ (0,Y.jsx)(aC,{}):/* @__PURE__ */ (0,Y.jsx)($,{mentions:n,text:r??``})})]});break}case`tool_calls`:o=/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[t.calls.map(e=>{let{name:t,input:n,output:r,...i}=e;return/* @__PURE__ */ (0,Y.jsxs)(Tw,{title:t,children:[/* @__PURE__ */ (0,Y.jsx)(Ow,{value:i}),n===void 0?null:/* @__PURE__ */ (0,Y.jsx)(Ew,{title:`Input`,children:/* @__PURE__ */ (0,Y.jsx)(Ow,{value:n})}),r===void 0?null:/* @__PURE__ */ (0,Y.jsx)(Ew,{title:`Output`,children:/* @__PURE__ */ (0,Y.jsx)(Ow,{value:r})})]},e.toolCallId)}),t.assistant?/* @__PURE__ */ (0,Y.jsx)(Tw,{title:`Assistant`,children:/* @__PURE__ */ (0,Y.jsx)(Ow,{value:t.assistant})}):null]});break;case`assistant_message`:o=t.parts.map((e,t)=>/* @__PURE__ */ (0,Y.jsx)(Tw,{title:`Reasoning`,children:e.redacted?/* @__PURE__ */ (0,Y.jsx)(aC,{}):/* @__PURE__ */ (0,Y.jsx)($,{mentions:n,text:e.text??``})},t));break;case`structured_event`:{let{type:e,presentation:r,...i}=t;o=/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(Tw,{children:/* @__PURE__ */ (0,Y.jsx)(Ow,{value:i})}),/* @__PURE__ */ (0,Y.jsxs)(Tw,{title:r.title,children:[r.preview?/* @__PURE__ */ (0,Y.jsx)($,{mentions:n,text:r.preview}):null,r.details?.map((e,t)=>/* @__PURE__ */ (0,Y.jsxs)(Ew,{title:e.title,children:[e.description?/* @__PURE__ */ (0,Y.jsx)($,{mentions:n,text:e.description}):null,e.content?/* @__PURE__ */ (0,Y.jsx)(Ow,{value:e.content}):null,e.metadata?/* @__PURE__ */ (0,Y.jsx)(Ow,{value:e.metadata}):null]},t))]})]});break}default:{let{type:e,...n}=t;o=/* @__PURE__ */ (0,Y.jsx)(Tw,{children:/* @__PURE__ */ (0,Y.jsx)(Ow,{value:n})})}}return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`@container grid min-w-0 gap-3`,children:[/* @__PURE__ */ (0,Y.jsx)(Tw,{title:`Configuration`,children:/* @__PURE__ */ (0,Y.jsx)(Ow,{value:{model:r?.modelId??`Not recorded`,...a}})}),e.modelCall?/* @__PURE__ */ (0,Y.jsx)(Tw,{title:`Call usage`,children:/* @__PURE__ */ (0,Y.jsx)(xw,{usage:i})}):null,o,/* @__PURE__ */ (0,Y.jsx)(ww,{event:e})]})}function ww({event:e}){let[t,n]=(0,J.useState)(!1),r=t?JSON.stringify(e,null,2):``;return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`relative min-w-0`,children:/* @__PURE__ */ (0,Y.jsxs)(nh,{onOpenChange:n,open:t,children:[/* @__PURE__ */ (0,Y.jsxs)(rh,{className:`group flex min-h-9 cursor-pointer items-center gap-1 pr-12 text-xs text-dashboard-text-muted hover:text-dashboard-text focus-visible:outline-2 focus-visible:outline-dashboard-focus`,children:[/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,className:ia}),`Raw JSON`]}),/* @__PURE__ */ (0,Y.jsxs)(ih,{children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`absolute right-0 top-0`,children:/* @__PURE__ */ (0,Y.jsx)(Yf,{getText:()=>r,label:`Copy JSON`})}),/* @__PURE__ */ (0,Y.jsx)(`div`,{"aria-label":`Raw event JSON`,className:`mt-3 max-h-80 min-w-0 overflow-auto overscroll-contain rounded-lg border border-dashboard-border bg-dashboard-surface-panel p-3 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus`,role:`region`,tabIndex:0,children:/* @__PURE__ */ (0,Y.jsx)(mh,{code:r,language:`json`})})]})]})})}function Tw(e){return/* @__PURE__ */ (0,Y.jsx)(yg,{label:e.title,title:e.title,children:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`grid min-w-0 gap-3 text-sm text-dashboard-text`,children:e.children})})}function Ew(e){return/* @__PURE__ */ (0,Y.jsxs)(`section`,{"aria-label":e.title,className:`grid min-w-0 gap-1.5 border-t border-dashboard-border-subtle pt-3`,children:[/* @__PURE__ */ (0,Y.jsx)(`h4`,{className:`m-0 font-sans text-xs font-medium text-dashboard-text-muted`,children:e.title}),e.children]})}function Dw(e){let t=e.replace(/([a-z\d])([A-Z])/g,`$1 $2`).replace(/_/g,` `).toLowerCase();return(t.charAt(0).toUpperCase()+t.slice(1)).replace(/\bid\b/gi,`ID`).replace(/\bids\b/gi,`IDs`).replace(/\busd\b/gi,`USD`).replace(/\bapi\b/gi,`API`)}function Ow({value:e}){if(Array.isArray(e))return e.length?/* @__PURE__ */ (0,Y.jsx)(`ol`,{className:`m-0 grid min-w-0 list-decimal gap-4 pl-5 text-sm text-dashboard-text-muted`,children:e.map((e,t)=>/* @__PURE__ */ (0,Y.jsx)(`li`,{children:/* @__PURE__ */ (0,Y.jsx)(Ow,{value:e})},t))}):/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-sm text-dashboard-text-muted`,children:`Empty list`});if(typeof e==`object`&&e){let t=Object.entries(e).filter(([,e])=>e!==void 0);return t.length?/* @__PURE__ */ (0,Y.jsx)(`dl`,{className:`m-0 grid min-w-0 divide-y divide-dashboard-border-subtle`,children:t.map(([e,t])=>{let n=typeof t==`object`&&!!t;return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:n?`grid min-w-0 gap-2 py-2 first:pt-0 last:pb-0`:`grid min-w-0 grid-cols-[minmax(0,7rem)_minmax(0,1fr)] items-baseline gap-x-4 py-2 first:pt-0 last:pb-0 @min-[30rem]:grid-cols-[minmax(0,10rem)_minmax(0,1fr)]`,children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{className:`break-words text-xs leading-relaxed text-dashboard-text-muted`,children:Dw(e)}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{className:`m-0 min-w-0`,children:n?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`border-l border-dashboard-border pl-3`,children:/* @__PURE__ */ (0,Y.jsx)(Ow,{value:t})}):/* @__PURE__ */ (0,Y.jsx)(Ow,{value:t})})]},e)})}):/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-sm text-dashboard-text-muted`,children:`Empty object`})}return/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`block whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-dashboard-text [overflow-wrap:anywhere]`,children:e===null?`null`:e===``?`Empty text`:String(e)})}const kw=`size-8 data-disabled:cursor-not-allowed data-disabled:opacity-50 data-disabled:hover:!bg-transparent data-disabled:hover:!text-dashboard-text-muted`;function Aw(e){let{conversation:t,event:n,onSelect:r}=e,i=dw(),a=n?/* @__PURE__ */ (0,Y.jsxs)(`p`,{className:`m-0 flex min-w-0 gap-x-1.5 whitespace-nowrap font-sans text-xs tabular-nums text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`shrink-0`,children:[`#`,n.seq]}),/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),/* @__PURE__ */ (0,Y.jsx)(`time`,{className:`min-w-0 truncate`,dateTime:n.createdAt,title:i.formatTimestamp(n.createdAt),children:i.formatShortTimestamp(n.createdAt)})]}):null,o=n?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`h2`,{className:`m-0 mb-1 break-words font-mono text-sm font-semibold text-dashboard-text`,children:n.data.type}),a]}):/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid gap-2 py-0.5`,children:[/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-3.5 w-28`}),/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-3 w-40`})]}),s=r&&n?/* @__PURE__ */ (0,Y.jsxs)(yw,{"aria-label":`Event navigation`,className:`rounded-md border border-dashboard-border`,children:[/* @__PURE__ */ (0,Y.jsx)(H,{"aria-label":`Previous event`,className:kw,disabled:e.previous===void 0,focusableWhenDisabled:!0,onClick:()=>{e.previous!==void 0&&r(e.previous)},size:`icon`,title:`Previous event`,children:/* @__PURE__ */ (0,Y.jsx)($t,{"aria-hidden":`true`,size:15})}),/* @__PURE__ */ (0,Y.jsx)(bw,{}),/* @__PURE__ */ (0,Y.jsx)(H,{"aria-label":`Next event`,className:kw,disabled:e.next===void 0,focusableWhenDisabled:!0,onClick:()=>{e.next!==void 0&&r(e.next)},size:`icon`,title:`Next event`,children:/* @__PURE__ */ (0,Y.jsx)(Ut,{"aria-hidden":`true`,size:15})})]}):void 0;return/* @__PURE__ */ (0,Y.jsx)(Iy,{actions:s,label:`Event details`,onClose:e.onClose,overlay:e.overlay,sheetTitle:n?.data.type,title:o,children:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:K(`h-full min-w-0 overflow-y-auto overscroll-contain p-4 pb-[max(1rem,env(safe-area-inset-bottom))]`,e.overlay&&`xl:p-0`),children:n&&t?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`mb-4 xl:hidden`,children:a}),t.canFork&&n.data.type===`message`&&n.data.role===`assistant`&&!n.data.redacted?/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-sm`,children:[/* @__PURE__ */ (0,Y.jsx)(hC,{conversationId:t.conversationId,messageId:n.data.messageId}),/* @__PURE__ */ (0,Y.jsx)(`span`,{children:`Fork after this reply`})]}):null,/* @__PURE__ */ (0,Y.jsx)(Cw,{event:n})]}):/* @__PURE__ */ (0,Y.jsx)(jw,{})},n?.seq??`loading`)})}function jw(){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{"aria-busy":`true`,role:`status`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`sr-only`,children:`Loading event`}),/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-3 w-40 xl:hidden`})]})}const Mw=`grid grid-cols-[12ch_minmax(0,1fr)] items-baseline gap-x-3 px-4 @min-[32rem]:grid-cols-[12ch_17ch_minmax(0,1fr)]`,Nw=(0,J.memo)(function(e){let{conversation:t}=e,n=dw(),r=sh(),[i,a]=(0,J.useState)(),o=e.onSelectedSeqChange?e.selectedSeq:i,s=e.onSelectedSeqChange??a,c=(0,J.useRef)(null),l=(0,J.useRef)(void 0),u=t.events,d=(0,J.useMemo)(()=>hw(u),[u]),f=(0,J.useMemo)(()=>gw(d,r.normalizedQuery),[d,r.normalizedQuery]),p=u.find(e=>e.seq===o),m=(0,J.useRef)(void 0),h=(0,J.useRef)(void 0),g=(0,J.useMemo)(()=>new Map(f.map((e,t)=>[e.event.seq,t])),[f]),_=e=>e===void 0?void 0:g.get(e),v=$C({count:f.length,defaultSize:e=>e===`metadata`?56:40,getItemKey:e=>f[e]?.event.seq??e,keptIndexes:[_(o),_(h.current),_(Pw(e.scrollAnchorKey?.()))],listRef:c,sizeClass:e=>f[e]?.metadata?`metadata`:`plain`}),y=v.getVirtualItems();return(0,J.useEffect)(()=>{if(o===void 0)return;let e=c.current?.querySelector(`[data-event-seq="${o}"]`);e&&(m.current===o&&(m.current=void 0,e.querySelector(`button`)?.focus({preventScroll:!0})),l.current!==o&&(l.current=o,e.scrollIntoView({block:`nearest`})))},[o,y]),t.eventHistory.status===`expired`?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`text-sm text-dashboard-text-muted`,children:`Event history expired for this conversation.`}):/* @__PURE__ */ (0,Y.jsxs)(`section`,{"aria-label":`Conversation event log`,className:`@container min-w-0`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`sticky top-0 z-10 bg-dashboard-bg`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-dashboard-border px-4 py-2`,children:[/* @__PURE__ */ (0,Y.jsx)(zm,{className:`min-w-32 flex-1 @max-[28rem]:basis-full`,label:`Search events`,onChange:e.onSearchChange,placeholder:`Search events…`,size:`compact`,value:r.query}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-3 whitespace-nowrap text-xs text-dashboard-text-muted @max-[28rem]:w-full @max-[28rem]:justify-between`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{role:`status`,children:r.active?`${f.length} of ${u.length} loaded events`:`${u.length} loaded events`}),/* @__PURE__ */ (0,Y.jsx)(da,{"aria-label":`Use local time`,onPressedChange:n.toggle,pressed:n.local,title:n.title,children:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`max-w-32 truncate`,children:n.label})})]})]}),/* @__PURE__ */ (0,Y.jsx)(Lw,{})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`font-mono text-xs`,children:[/* @__PURE__ */ (0,Y.jsx)(`ol`,{"aria-label":`Events`,className:`relative m-0 list-none p-0`,ref:c,style:{height:v.getTotalSize()},children:y.map(e=>{let{event:t,summary:r,metadata:i}=f[e.index],a=e.index;return/* @__PURE__ */ (0,Y.jsx)(`li`,{className:K(`absolute left-0 top-0 w-full scroll-mt-32 scroll-mb-2`,a>0&&`border-t border-dashboard-border-subtle`),"data-event-seq":t.seq,"data-index":a,"data-scroll-anchor":`event:${t.seq}`,onBlur:()=>{h.current===t.seq&&(h.current=void 0)},onFocus:()=>{h.current=t.seq},ref:v.measureElement,style:{transform:`translateY(${e.start-v.options.scrollMargin}px)`},children:/* @__PURE__ */ (0,Y.jsxs)(`button`,{"aria-expanded":o===t.seq,"aria-label":`Event ${t.seq}: ${t.data.type}`,className:K(Mw,`relative min-h-11 w-full cursor-pointer border-0 bg-transparent py-2 text-left leading-5 hover:bg-dashboard-fill-hover active:bg-dashboard-fill-strong focus-visible:bg-dashboard-fill-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus @min-[32rem]:min-h-9 @min-[32rem]:py-1.5`,o===t.seq&&`bg-dashboard-fill-strong before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-dashboard-accent before:content-['']`),onClick:()=>{l.current=t.seq,s(t.seq)},onKeyDown:e=>{if(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||e.key!==`ArrowUp`&&e.key!==`ArrowDown`)return;e.preventDefault();let t=f[a+(e.key===`ArrowDown`?1:-1)];if(!t)return;s(t.event.seq);let n=c.current?.querySelector(`[data-event-seq="${t.event.seq}"] button`);n?n.focus({preventScroll:!0}):m.current=t.event.seq},type:`button`,children:[/* @__PURE__ */ (0,Y.jsx)(`time`,{className:`tabular-nums text-dashboard-text-muted`,dateTime:t.createdAt,title:n.formatTimestamp(t.createdAt),children:n.formatClock(t.createdAt)}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:K(`truncate`,mw(t.data)),title:t.data.type,children:/* @__PURE__ */ (0,Y.jsx)(Q,{text:t.data.type})}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`col-span-2 row-start-2 grid min-w-0 gap-0.5 text-dashboard-text @min-[32rem]:col-span-1 @min-[32rem]:row-auto`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`truncate`,title:r,children:/* @__PURE__ */ (0,Y.jsx)(Q,{text:r})}),i?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`truncate text-dashboard-text-muted`,title:i,children:/* @__PURE__ */ (0,Y.jsx)(Q,{text:i})}):null]})]})},e.key)})}),f.length===0?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 px-3 py-6 text-sm text-dashboard-text-muted`,children:r.active?`No events match your search.`:`No events available.`}):null]}),p&&!e.onSelectedSeqChange?(0,ou.createPortal)(/* @__PURE__ */ (0,Y.jsx)(Aw,{overlay:!0,conversation:t,event:p,onClose:()=>s(void 0),onSelect:s,..._w(f,p.seq)}),document.body):null]})});function Pw(e){return e?.startsWith(`event:`)?Number(e.slice(6)):void 0}const Fw=[`w-3/5`,`w-2/5`,`w-4/5`,`w-1/2`,`w-2/3`,`w-1/3`];function Iw(){return/* @__PURE__ */ (0,Y.jsxs)(`section`,{"aria-busy":`true`,className:`@container min-w-0`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`sr-only`,role:`status`,children:`Loading events`}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`sticky top-0 z-10 bg-dashboard-bg`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-dashboard-border px-4 py-2`,children:[/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-9 min-w-32 flex-1 @max-[28rem]:basis-full`}),/* @__PURE__ */ (0,Y.jsx)(q,{className:`ml-auto h-3 w-24`})]}),/* @__PURE__ */ (0,Y.jsx)(Lw,{})]}),/* @__PURE__ */ (0,Y.jsx)(`ol`,{className:`m-0 list-none divide-y divide-dashboard-border-subtle p-0`,children:Fw.map((e,t)=>/* @__PURE__ */ (0,Y.jsxs)(`li`,{className:K(Mw,`min-h-11 items-center gap-y-2 py-2 @min-[32rem]:min-h-9 @min-[32rem]:py-1.5`),children:[/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-3 w-[10ch]`}),/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-3 w-[12ch]`}),/* @__PURE__ */ (0,Y.jsx)(q,{className:K(`col-span-2 row-start-2 h-3 @min-[32rem]:col-span-1 @min-[32rem]:row-auto`,e)})]},t))})]})}function Lw(){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{"aria-hidden":`true`,className:K(Mw,`border-b border-dashboard-border py-2 font-mono text-xs text-dashboard-text-muted`),children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{children:`Time`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{children:`Event`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`hidden @min-[32rem]:block`,children:`Summary`})]})}function Rw(e){let t=e.view??`rich`,[n,r]=(0,J.useState)(``),i=e.search??n,a=t===`raw`?`events`:`messages`,o=e.transcript?.eventHistory.status===`redacted`,s=Bp({conversationId:e.transcript?.conversationId,enabled:e.live??!1,endsAtLatest:!e.newerHistory,historyVersion:e.historyVersion??`empty`,juniorMessageVersion:jp(e.transcript),pinRequestVersion:e.pinRequestVersion,startAtLink:e.startAtLink,startAtUnread:t===`rich`&&e.startAtUnread,view:t,versions:{rich:Mp(e.transcript,`rich`),raw:Mp(e.transcript,`raw`)}}),{revealAsk:c}=e,{showRow:l}=s,u=(0,J.useMemo)(()=>c?{...c,showRow:l}:void 0,[c,l]);im({content:s.contentElement,engaged:e.readEngaged,lastReadSeq:e.lastReadSeq,onRead:e.onRead,paused:t!==`rich`||i.trim().length>0});let d=()=>e.onLoadPreviousPage?.(),f=Hp({edge:`top`,enabled:!(!e.onLoadPreviousPage||!e.hasPreviousPage||e.loadingPreviousPage||e.historyError),historyVersion:e.historyVersion??`empty`,onLoad:d}),p=e.newerHistory,m=Hp({edge:`bottom`,enabled:!(!p||p.loading||p.error),historyVersion:e.historyVersion??`empty`,onLoad:()=>p?.load()}),h=()=>{p?.showLatest(),s.jumpToBottom()};return e.transcript?/* @__PURE__ */ (0,Y.jsx)(oh,{match:e.searchMatch,onMatches:e.onSearchMatches,query:i,children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0 [overflow-anchor:none]`,ref:s.contentRef,children:[o?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`mb-2 min-w-0 break-words text-sm leading-relaxed text-dashboard-text-muted`,children:`Hidden because this conversation is not public.`}):null,e.hasPreviousPage||e.loadingPreviousPage?/* @__PURE__ */ (0,Y.jsx)(zw,{className:`mb-3`,label:`Load earlier events`,loading:e.loadingPreviousPage,onClick:d,ref:f,children:e.loadingPreviousPage?`Loading earlier ${a}…`:`Show earlier ${a}`}):null,e.historyError?/* @__PURE__ */ (0,Y.jsx)(`div`,{"aria-live":`polite`,className:`mb-2 text-center font-sans text-xs text-amber-100/65`,children:`Earlier events could not be loaded.`}):null,t===`raw`?/* @__PURE__ */ (0,Y.jsx)(Nw,{conversation:e.transcript,onSearchChange:e.onSearchChange??r,onSelectedSeqChange:e.onSelectedEventSeqChange,scrollAnchorKey:s.scrollAnchorKey,selectedSeq:e.selectedEventSeq},e.transcript.conversationId):/* @__PURE__ */ (0,Y.jsx)(sC,{panel:e.turnContextPanel,children:/* @__PURE__ */ (0,Y.jsx)(Vp,{value:h,children:/* @__PURE__ */ (0,Y.jsx)(ew,{value:u,children:/* @__PURE__ */ (0,Y.jsx)(iw,{onOpenSubagentTranscript:e.onOpenSubagentTranscript,conversation:e.transcript,pendingMessages:e.pendingMessages,responding:e.responding??e.live??!1,revealSeq:e.revealSeq,scrollAnchorKey:s.scrollAnchorKey,unread:e.unread})})})}),p?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[p.error?/* @__PURE__ */ (0,Y.jsx)(`div`,{"aria-live":`polite`,className:`mt-2 text-center font-sans text-xs text-amber-100/65`,children:`Newer events could not be loaded.`}):null,/* @__PURE__ */ (0,Y.jsx)(zw,{className:`mb-12 mt-3`,label:`Load newer events`,loading:p.loading,onClick:p.load,ref:m,children:p.loading?`Loading newer ${a}…`:`Show newer ${a}`})]}):null,/* @__PURE__ */ (0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`h-px`,ref:s.anchorRef}),/* @__PURE__ */ (0,Y.jsx)(Bw,{hasPendingUpdate:s.hasPendingUpdate,onClick:h,visible:s.showJumpToLatest})]})}):/* @__PURE__ */ (0,Y.jsx)(xm,{children:`No transcript is available for this conversation.`})}function zw(e){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:K(`flex items-center gap-3`,e.className),ref:e.ref,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`h-px min-w-4 flex-1 bg-dashboard-fill-strong`}),/* @__PURE__ */ (0,Y.jsx)(`button`,{"aria-label":e.label,className:`shrink-0 cursor-pointer border-0 bg-transparent px-1 py-0.5 font-sans text-xs font-medium text-dashboard-text-muted transition-colors hover:text-dashboard-text focus-visible:outline focus-visible:outline-1 focus-visible:outline-dashboard-focus/55 disabled:cursor-not-allowed disabled:opacity-50`,disabled:e.loading,onClick:e.onClick,title:e.label,type:`button`,children:e.children}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`h-px min-w-4 flex-1 bg-dashboard-fill-strong`})]})}function Bw(e){return e.visible?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`pointer-events-none sticky -bottom-2.5 z-20 flex h-0 justify-center md:-bottom-5`,children:/* @__PURE__ */ (0,Y.jsxs)(H,{"aria-label":e.hasPendingUpdate?`Jump to latest update`:`Jump to latest`,className:`pointer-events-auto h-8 -translate-y-full gap-1.5 rounded-full pl-3 pr-3.5 text-xs shadow-[0_4px_16px_rgba(0,0,0,0.12)]`,onClick:e.onClick,children:[/* @__PURE__ */ (0,Y.jsx)(Gt,{"aria-hidden":`true`,size:14,strokeWidth:2}),`Jump to latest`]})}):null}const Vw=()=>{},Hw=/* @__PURE__ */ (0,Y.jsx)(`h2`,{className:`m-0 flex min-w-0 items-center gap-1.5 font-sans text-sm`,children:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-semibold text-dashboard-text`,children:`Details`})}),Uw=`New conversation`,Ww={archive:Vw,continueInSlack:Vw,delivery:Vw,eventLog:Vw,pin:Vw,read:Vw,rename:Vw,subscription:Vw},Gw={archive:!1,delivery:!1,pin:!1,read:!1,subscription:!1};function Kw(e){return`pending:${e}`}function qw(e){let t=P(),{pending:n}=e,r=(0,J.useMemo)(()=>({conversationId:n.idempotencyKey,cumulativeDurationMs:0,displayTitle:Uw,eventHistory:{status:`available`},events:[],generatedAt:n.createdAt,isParticipant:!0,kind:`root`,lastProgressAt:n.createdAt,lastSeenAt:n.createdAt,startedAt:n.createdAt,status:`active`,surface:`internal`,visibility:n.visibility}),[n]),i=(0,J.useMemo)(()=>[bu({...yu({...n,actorIdentity:_u(t),inline:!0,messageId:n.idempotencyKey,now:n.createdAt}),status:`accepted`})],[n,t]),a=(0,J.useRef)(null);(0,J.useEffect)(()=>a.current?.focus(),[]);let o=$y(),s=ch(``);return oo(`Back to conversations`,void 0,Uw),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`grid h-full min-h-0 min-w-0 grid-rows-[minmax(0,1fr)]`,children:/* @__PURE__ */ (0,Y.jsx)(rb,{side:o?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`contents`,inert:!0,children:/* @__PURE__ */ (0,Y.jsx)(Iy,{label:`Conversation details`,onClose:Vw,title:Hw,children:null})}):void 0,children:/* @__PURE__ */ (0,Y.jsx)(Dv,{header:/* @__PURE__ */ (0,Y.jsx)(Pv,{detailsOpen:o,errors:[],menu:{actions:Ww,conversation:void 0,conversationId:n.idempotencyKey,detail:void 0,pending:Gw},pending:!0,onDetailsClick:Vw,onSearchChange:Vw,onViewChange:Vw,privacy:/* @__PURE__ */ (0,Y.jsx)(fy,{visibility:n.visibility}),search:``,searchMatch:s,sidebarToggle:e.sidebarToggle,title:Uw,view:`rich`}),scrollMinTall:!0,scrollAriaLabel:`Conversation transcript`,scrollClassName:Tv,scroll:/* @__PURE__ */ (0,Y.jsx)(Ev,{className:`duration-200 ease-out motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-bottom-1`,children:/* @__PURE__ */ (0,Y.jsx)(Rw,{pendingMessages:i,responding:!0,transcript:r})}),dock:/* @__PURE__ */ (0,Y.jsx)(Gm,{children:/* @__PURE__ */ (0,Y.jsx)(lv,{disabled:!0,draftId:Kw(n.idempotencyKey),label:`Continue this conversation`,ref:a,submitLabel:`Send`,onSubmit:async()=>{}})})})})})}const Jw=`junior-notification-target`,Yw=`/_junior/dashboard/notification-target`;String.raw`
|
|
16
|
-
const SCOPE_URL = new URL(self.registration.scope);
|
|
17
|
-
const TARGET_CACHE = ${JSON.stringify(Jw)};
|
|
18
|
-
const TARGET_KEY = new URL(${JSON.stringify(Yw)}, SCOPE_URL).href;
|
|
19
|
-
|
|
20
|
-
self.addEventListener("install", () => {
|
|
21
|
-
self.skipWaiting();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
self.addEventListener("activate", (event) => {
|
|
25
|
-
event.waitUntil(self.clients.claim());
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
function readPayload(event) {
|
|
29
|
-
try {
|
|
30
|
-
const data = event.data ? event.data.json() : {};
|
|
31
|
-
return data && typeof data === "object" ? data : {};
|
|
32
|
-
} catch (_error) {
|
|
33
|
-
return {};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function targetUrl(value) {
|
|
38
|
-
try {
|
|
39
|
-
const url = new URL(typeof value === "string" ? value : SCOPE_URL.href, SCOPE_URL);
|
|
40
|
-
return url.origin === SCOPE_URL.origin ? url : SCOPE_URL;
|
|
41
|
-
} catch (_error) {
|
|
42
|
-
return SCOPE_URL;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async function updateBadge() {
|
|
47
|
-
if (!self.navigator.setAppBadge) return;
|
|
48
|
-
const shown = await self.registration.getNotifications();
|
|
49
|
-
if (shown.length > 0) {
|
|
50
|
-
await self.navigator.setAppBadge(shown.length);
|
|
51
|
-
} else if (self.navigator.clearAppBadge) {
|
|
52
|
-
await self.navigator.clearAppBadge();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
self.addEventListener("push", (event) => {
|
|
57
|
-
event.waitUntil(
|
|
58
|
-
(async () => {
|
|
59
|
-
const payload = readPayload(event);
|
|
60
|
-
const url = targetUrl(payload.url);
|
|
61
|
-
const windows = await self.clients.matchAll({
|
|
62
|
-
includeUncontrolled: true,
|
|
63
|
-
type: "window",
|
|
64
|
-
});
|
|
65
|
-
const viewing = windows.some(
|
|
66
|
-
(client) =>
|
|
67
|
-
client.focused &&
|
|
68
|
-
client.visibilityState === "visible" &&
|
|
69
|
-
new URL(client.url).pathname === url.pathname,
|
|
70
|
-
);
|
|
71
|
-
await self.registration.showNotification(
|
|
72
|
-
typeof payload.title === "string" ? payload.title : "Junior",
|
|
73
|
-
{
|
|
74
|
-
body: typeof payload.body === "string" ? payload.body : "",
|
|
75
|
-
data: { url: url.href },
|
|
76
|
-
icon: "/_junior/dashboard/icon-512.png",
|
|
77
|
-
renotify: !viewing,
|
|
78
|
-
silent: viewing,
|
|
79
|
-
tag: typeof payload.tag === "string" ? payload.tag : undefined,
|
|
80
|
-
},
|
|
81
|
-
);
|
|
82
|
-
await updateBadge();
|
|
83
|
-
})(),
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
self.addEventListener("notificationclick", (event) => {
|
|
88
|
-
event.notification.close();
|
|
89
|
-
const url = targetUrl(event.notification.data && event.notification.data.url);
|
|
90
|
-
event.waitUntil(
|
|
91
|
-
(async () => {
|
|
92
|
-
// iOS can run this handler while a backgrounded Home Screen app is
|
|
93
|
-
// still suspended, for example behind the lock screen. navigate() and
|
|
94
|
-
// postMessage() can then get lost, and the app resumes on its old page.
|
|
95
|
-
// The page reads this entry when it becomes visible and opens the URL.
|
|
96
|
-
// A Cache Storage failure must not stop the navigation below.
|
|
97
|
-
try {
|
|
98
|
-
const cache = await caches.open(TARGET_CACHE);
|
|
99
|
-
await cache.put(
|
|
100
|
-
TARGET_KEY,
|
|
101
|
-
new Response(JSON.stringify({ atMs: Date.now(), url: url.href }), {
|
|
102
|
-
headers: { "content-type": "application/json" },
|
|
103
|
-
}),
|
|
104
|
-
);
|
|
105
|
-
} catch (_error) {}
|
|
106
|
-
const windows = await self.clients.matchAll({
|
|
107
|
-
includeUncontrolled: true,
|
|
108
|
-
type: "window",
|
|
109
|
-
});
|
|
110
|
-
const existing = windows.find((client) =>
|
|
111
|
-
client.url.startsWith(SCOPE_URL.href),
|
|
112
|
-
);
|
|
113
|
-
if (existing) {
|
|
114
|
-
await existing.focus();
|
|
115
|
-
if (existing.url !== url.href) {
|
|
116
|
-
// navigate() fails for a window that this worker does not control,
|
|
117
|
-
// and Safari can lack it. The page then opens the URL itself.
|
|
118
|
-
const navigated =
|
|
119
|
-
"navigate" in existing
|
|
120
|
-
? await existing.navigate(url.href).catch(() => null)
|
|
121
|
-
: null;
|
|
122
|
-
if (!navigated) {
|
|
123
|
-
existing.postMessage({ type: "junior:open", url: url.href });
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
} else {
|
|
127
|
-
await self.clients.openWindow(url.href);
|
|
128
|
-
}
|
|
129
|
-
await updateBadge();
|
|
130
|
-
})(),
|
|
131
|
-
);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
self.addEventListener("pushsubscriptionchange", (event) => {
|
|
135
|
-
const previous = event.oldSubscription;
|
|
136
|
-
const options = previous && previous.options;
|
|
137
|
-
if (!options || !options.applicationServerKey) return;
|
|
138
|
-
event.waitUntil(
|
|
139
|
-
(async () => {
|
|
140
|
-
const next = await self.registration.pushManager.subscribe({
|
|
141
|
-
applicationServerKey: options.applicationServerKey,
|
|
142
|
-
userVisibleOnly: true,
|
|
143
|
-
});
|
|
144
|
-
await fetch("/api/notifications/subscriptions", {
|
|
145
|
-
body: JSON.stringify(next.toJSON()),
|
|
146
|
-
credentials: "include",
|
|
147
|
-
headers: { "content-type": "application/json" },
|
|
148
|
-
method: "POST",
|
|
149
|
-
});
|
|
150
|
-
})(),
|
|
151
|
-
);
|
|
152
|
-
});
|
|
153
|
-
`;function Xw(){return window.__JUNIOR_DASHBOARD_BASE_PATH__??`/`}function Zw(){return window.matchMedia?.(`(display-mode: standalone)`).matches===!0||navigator.standalone===!0}function Qw(){return/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1}function $w(){return!window.isSecureContext||!(`serviceWorker`in navigator)||!(`PushManager`in window)||!(`Notification`in window)?Qw()&&!Zw()?`needs-install`:`unsupported`:`supported`}let eT;function tT(){if(`serviceWorker`in navigator&&window.isSecureContext)return eT??=navigator.serviceWorker.register(`/_junior/dashboard/sw.js`,{scope:Xw()}),eT}function nT(e){let t=`${e}${`=`.repeat((4-e.length%4)%4)}`,n=atob(t.replace(/-/g,`+`).replace(/_/g,`/`)),r=new Uint8Array(new ArrayBuffer(n.length));for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return r}function rT(e,t){let n=e.options.applicationServerKey;if(!n)return!1;let r=new Uint8Array(n);return r.length===t.length&&r.every((e,n)=>e===t[n])}async function iT(){if(`serviceWorker`in navigator&&window.isSecureContext)return await(await navigator.serviceWorker.getRegistration(Xw()))?.pushManager.getSubscription()??void 0}async function aT(e){let t=tT();if(!t)throw Error(`Service workers are not available.`);if(await Notification.requestPermission()!==`granted`)throw Error(`Notification permission was not granted.`);let{pushManager:n}=await t,r=nT(e),i=await n.getSubscription();return i&&rT(i,r)?i.toJSON():(await i?.unsubscribe(),(await n.subscribe({applicationServerKey:r,userVisibleOnly:!0})).toJSON())}async function oT(){let e=await iT();if(!e)return;let{endpoint:t}=e;return await e.unsubscribe(),t}function sT(){navigator.clearAppBadge?.().catch(()=>void 0)}function cT(e){let t=new URL(e,window.location.href);if(t.origin!==window.location.origin)return;let n=`${window.location.pathname}${window.location.search}`;`${t.pathname}${t.search}`!==n&&window.location.assign(t.href)}async function lT(){if(typeof caches>`u`)return;let e=await caches.open(Jw),t=await e.match(Yw);if(!t)return;await e.delete(Yw);let n=await t.json();typeof n!=`object`||!n||!(`url`in n)||typeof n.url!=`string`||!(`atMs`in n)||typeof n.atMs!=`number`||Date.now()-n.atMs>12e4||cT(n.url)}const uT=`/api/notifications`,dT=`push-notifications`,fT=`/settings#${dT}`,pT=[`dashboard`,`notifications`,`device`],mT=j({queryKey:[`dashboard`,`notifications`],queryFn:({signal:e})=>G(Nr,uT,e)});async function hT(e,t){let n=await aT(t),r=await Qi(Nr,`${uT}/subscriptions`,n);return e.setQueryData(mT.queryKey,r),e.invalidateQueries({queryKey:pT}),r}function gT(){return Qi(Jr,`${uT}/test`,{})}const _T=`junior:dashboard:push-notifications-tip-shown`,vT=`push-notifications-tip`,yT=12e3;function bT(){try{return window.localStorage.getItem(_T)!==null}catch{return!0}}function xT(){try{window.localStorage.setItem(_T,`1`)}catch{}}function ST(e){return/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`cursor-pointer border-0 bg-transparent p-0 font-medium text-dashboard-text underline underline-offset-2`,onClick:e.onClick,type:`button`,children:e.children})}function CT(){let e=P(),t=ge(),{add:n,close:r,update:i}=Io(),a=(0,J.useCallback)(async()=>{if(bT())return;let a=$w();if(a===`unsupported`)return;let o=(await e.fetchQuery(mT)).publicKey;if(!o)return;let s=a===`supported`&&!!await iT();if(xT(),s)return;function c(){r(vT),t(fT)}let l=/* @__PURE__ */ (0,Y.jsx)(ST,{onClick:c,children:`Settings`});function u(e){i(vT,{actionProps:void 0,description:/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[e??/* @__PURE__ */ (0,Y.jsx)(ST,{onClick:()=>void d(),children:`Send a test`}),l]}),timeout:yT,title:`Push notifications are on`,type:`success`})}async function d(){try{let{delivered:e}=await gT();u(e>0?`Test sent.`:`No device got the test.`)}catch{u(`Could not send the test.`)}}async function f(t){i(vT,{actionProps:{children:`Turning on…`,disabled:!0},type:`loading`});try{await hT(e,t),u()}catch{i(vT,{actionProps:void 0,description:l,timeout:yT,title:`Could not turn on push notifications`,type:`error`})}}a===`supported`&&tT()?.catch(()=>void 0),n({actionProps:a===`supported`?{children:`Turn on`,onClick:()=>void f(o)}:{children:`Set up`,onClick:c},description:`Get a push notification when ${pa()} replies.`,id:vT,timeout:yT,title:`Push notifications`,type:`info`})},[n,r,t,e,i]);return(0,J.useCallback)(()=>void a().catch(()=>void 0),[a])}function wT(e){let{items:t,query:n}=cu({conversationId:e}),r=n.isPlaceholderData,{fetchNextPage:i,hasNextPage:a,isFetching:o}=n,s=n.isFetchNextPageError,c=n.data?.pages.length??0;(0,J.useEffect)(()=>{r||s||!a||o||i()},[s,i,a,o,c,r]);let l=(0,J.useMemo)(()=>r?[]:t.filter(aS),[t,r]),u=!r&&(s||n.isError&&!n.data),{refetch:d}=n,f=(0,J.useCallback)(()=>void d(),[d]);return{loadFailed:u,pending:n.isPending||r||!!a||u,questions:l,retry:f}}function TT(e){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[/* @__PURE__ */ (0,Y.jsx)(h_,{className:`w-auto`,children:`Some questions did not load.`}),/* @__PURE__ */ (0,Y.jsx)(H,{className:`h-7 px-2 text-xs`,onClick:e.onRetry,variant:`quiet`,children:`Try again`})]})}function ET(e){return e instanceof ta&&e.apiError?e.apiError:`Could not save this action. Try again.`}function DT(e){return e instanceof HTMLElement&&(e.isContentEditable||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)}function OT(e){let[t,n]=(0,J.useState)(),r=(0,J.useRef)(null),i=(0,J.useRef)(/* @__PURE__ */ new Map),[a,o]=(0,J.useState)(()=>/* @__PURE__ */ new Set),s=(0,J.useCallback)((e,t)=>{o(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),c=e.questions.some(e=>a.has(e.id)),{onAnswersChange:l}=e;(0,J.useEffect)(()=>{l(c)},[c,l]);let u=(0,J.useRef)(!1),d=(0,J.useRef)(!1);(0,J.useImperativeHandle)(e.answersRef,()=>({send:async()=>{u.current=!0;let t=e.questions.flatMap(e=>{let t=i.current.get(e.id)?.sendPicks();return t?[t.then(t=>({id:e.id,sent:t}))]:[]});try{let e=(await Promise.all(t)).find(e=>!e.sent);return e&&e.id!==p?.id&&(d.current=!0,n(e.id)),!e}finally{u.current=!1}}}));let f=Math.max(0,e.questions.findIndex(e=>e.id===t)),p=e.questions[f],m=(0,J.useRef)(void 0),{onShow:h}=e;if((0,J.useEffect)(()=>{let e=m.current;if(m.current=p?.id,!p){d.current=!1;return}if(p.id===e)return;let t=d.current;d.current=!1,h?.(p,t)},[p,h]),!p)return null;let g=e.questions.length,_=t=>{d.current=!0,n(e.questions[(f+t+g)%g].id)},v=t=>{u.current||(t&&g===1?e.focusMessageBox():r.current?.focus())},y=()=>r.current?.querySelector(`[data-current-question]`);function b(t){if(t.defaultPrevented||t.metaKey||t.ctrlKey||t.altKey||DT(t.target))return;if(t.key===`Escape`){t.preventDefault(),y()?.querySelector(`[data-dismiss-question]`)?.click();return}let n=y()?.querySelector(`button[aria-keyshortcuts="${CSS.escape(t.key)}"]:not(:disabled)`);n?(t.preventDefault(),n.click()):t.key.length===1&&t.key!==` `&&e.focusMessageBox()}return/* @__PURE__ */ (0,Y.jsx)(`section`,{"aria-label":`Question: ${p.title}`,className:`mb-2 grid min-w-0 gap-2 rounded-xl border border-dashboard-accent/30 bg-dashboard-surface-panel px-3 py-2.5 font-sans text-sm text-dashboard-text outline-none focus-visible:ring-2 focus-visible:ring-dashboard-focus/50 md:max-h-[50vh] md:overflow-y-auto md:px-4 md:py-3`,onKeyDown:b,ref:t=>{r.current=t,typeof e.ref==`function`?e.ref(t):e.ref&&(e.ref.current=t)},tabIndex:-1,children:e.questions.map((e,t)=>/* @__PURE__ */ (0,Y.jsx)(`div`,{className:t===f?`grid min-w-0 gap-2`:`hidden`,"data-current-question":t===f?``:void 0,children:/* @__PURE__ */ (0,Y.jsx)(kT,{afterAction:v,formRef:t=>{t?i.current.set(e.id,t):i.current.delete(e.id)},item:e,onCloseShown:e=>{t===f&&(d.current=e)},onPicksChange:s,onShowRecord:()=>h?.(e,!0),stepper:g>1?/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5 text-xs text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,Y.jsx)(H,{"aria-label":`Previous question`,className:`size-7`,onClick:()=>_(-1),size:`icon`,variant:`quiet`,children:/* @__PURE__ */ (0,Y.jsx)(Lt,{"aria-hidden":`true`,size:15})}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[t+1,` of `,g]}),/* @__PURE__ */ (0,Y.jsx)(H,{"aria-label":`Next question`,className:`size-7`,onClick:()=>_(1),size:`icon`,variant:`quiet`,children:/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,size:15})})]}):null})},e.id))})}function kT(e){let{item:t,onPicksChange:n}=e,r=pu(),[i,a]=(0,J.useState)(),[o,s]=(0,J.useState)(!1);(0,J.useEffect)(()=>{n(t.id,o)},[t.id,n,o]);async function c(n){a(void 0);let i=n.action!==`take`;i&&e.onCloseShown(!0);try{await r.mutateAsync({body:n,id:t.id})}catch(t){throw i&&e.onCloseShown(!1),a(ET(t)),t}e.afterAction(n.action!==`take`)}return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(`header`,{className:`flex min-w-0 items-center gap-2`,children:[/* @__PURE__ */ (0,Y.jsx)(lr,{"aria-hidden":`true`,className:`shrink-0 text-dashboard-accent`,size:15}),/* @__PURE__ */ (0,Y.jsx)(`h2`,{className:`m-0 min-w-0 flex-1 truncate text-sm font-semibold`,children:/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`max-w-full cursor-pointer truncate text-left hover:underline focus-visible:rounded-sm focus-visible:outline-2 focus-visible:outline-dashboard-focus`,onClick:e.onShowRecord,type:`button`,children:t.title})}),e.stepper,/* @__PURE__ */ (0,Y.jsxs)(H,{className:`h-7 gap-1.5 px-2 text-xs`,"data-dismiss-question":``,disabled:r.isPending,onClick:()=>void c({action:`dismiss`}).catch(()=>{}),variant:`quiet`,children:[`Dismiss`,/* @__PURE__ */ (0,Y.jsx)(`kbd`,{"aria-hidden":`true`,className:`font-sans text-2xs text-dashboard-text-faint max-md:hidden`,children:`Esc`})]})]}),t.request?/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`font-medium [&_p]:my-0`,children:/* @__PURE__ */ (0,Y.jsx)($,{text:t.request.question})}),/* @__PURE__ */ (0,Y.jsx)(Nx,{docked:!0,ref:e.formRef,onSubmit:e=>c({action:`submit`,answer:{values:e.values,...e.other?{other:e.other}:void 0}}),onUnsentChange:s,request:t.request,requestId:t.id,secondaryActions:t.canTake?/* @__PURE__ */ (0,Y.jsx)(H,{disabled:r.isPending,onClick:()=>void c({action:`take`}).catch(()=>{}),variant:`quiet`,children:`Take`}):void 0})]}):null,i?/* @__PURE__ */ (0,Y.jsx)(h_,{children:i}):null]})}function AT(e,t=[]){return Xh(jT(e),t)}function jT(e){return e.replace(Lh,(e,t,n)=>n?.trim()?n.trim():t).replace(/\[([^\]]+)\]\([^\s)]+(?:\s+"[^"]*")?\)/g,`$1`).replace(/(^|\s)([*_~`]{1,3})(?=\S)/g,`$1`).replace(/([*_~`]{1,3})(?=\s|$|[.,!?;:])/g,``).replace(/^\s*(?:#{1,6}|[-+*]|\d+\.)\s+/gm,``).replace(/\s+/g,` `).trim()}const MT=cr;function NT(e){return e.clientStatus===`failed`?{icon:Gn,label:`Failed to send`,tooltip:`Failed to send`}:e.clientStatus===`sending`?{icon:_p,label:`Sending`,tooltip:`Sending`}:e.delivery===`interrupt`&&e.source!==`web`?{icon:fr,label:`Next step`,tooltip:`Junior reads it at its next step`}:e.delivery===`interrupt`?{icon:MT,label:`Steered`,tooltip:`Steered: Junior reads it at its next step`}:{icon:On,label:`Queued`,tooltip:`Queued: Junior reads it after the current reply`}}function PT(e){return/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[/* @__PURE__ */ (0,Y.jsx)(W,{render:/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-label":e.label,className:`inline-flex text-dashboard-text-muted`,children:e.children})}),/* @__PURE__ */ (0,Y.jsx)(Cr,{size:`compact`,children:e.tooltip??e.label})]})}function FT(e){let t=e.icon;return/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[/* @__PURE__ */ (0,Y.jsx)(W,{render:/* @__PURE__ */ (0,Y.jsx)(H,{"aria-label":e.label,className:`size-6`,disabled:e.disabled,focusableWhenDisabled:!0,onClick:e.onClick,size:`icon`,type:`button`,variant:e.variant,children:e.pending?/* @__PURE__ */ (0,Y.jsx)(_p,{"aria-hidden":`true`,className:`size-3.25`}):/* @__PURE__ */ (0,Y.jsx)(t,{"aria-hidden":`true`,size:14,strokeWidth:2.2})})}),/* @__PURE__ */ (0,Y.jsx)(Cr,{size:`compact`,children:e.tooltip})]})}function IT(e){let t=NT(e.message),n=t.icon;return/* @__PURE__ */ (0,Y.jsxs)(ES,{className:`flex min-w-0 items-center justify-end gap-1 text-xs leading-none text-dashboard-text-muted`,children:[e.showSlack?/* @__PURE__ */ (0,Y.jsxs)(Tr,{children:[/* @__PURE__ */ (0,Y.jsx)(W,{render:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`inline-flex text-dashboard-text-muted`,children:/* @__PURE__ */ (0,Y.jsx)(Xf,{className:`size-3.5`})})}),/* @__PURE__ */ (0,Y.jsx)(Cr,{size:`compact`,children:`From Slack`})]}):null,/* @__PURE__ */ (0,Y.jsx)(PT,{label:t.label,tooltip:t.tooltip,children:/* @__PURE__ */ (0,Y.jsx)(n,{"aria-hidden":`true`,className:`size-3.25`,strokeWidth:2.2})}),e.onSteer?/* @__PURE__ */ (0,Y.jsx)(FT,{disabled:e.actionsDisabled,icon:MT,label:`Steer queued message`,onClick:e.onSteer,pending:e.steerPending,tooltip:`Steer: Junior reads it at its next step`}):null,e.onEdit?/* @__PURE__ */ (0,Y.jsx)(FT,{disabled:e.actionsDisabled,icon:en,label:`Edit queued message`,onClick:e.onEdit,pending:e.editPending,tooltip:`Edit: move it back to the composer`}):null,e.onCancel?/* @__PURE__ */ (0,Y.jsx)(FT,{disabled:e.actionsDisabled,icon:Kn,label:e.cancelError?`Could not delete. Try again.`:`Delete queued message`,onClick:e.onCancel,pending:e.cancelPending,tooltip:e.cancelError?`Could not delete. Try again.`:`Delete from the queue`,variant:`danger`}):null]})}function LT(e){let{actorIdentityId:t}=e.message,n=(t?e.authors?.[t]:void 0)??e.message.actorIdentity;return n?/* @__PURE__ */ (0,Y.jsx)(Zm,{participant:n,size:`list`}):/* @__PURE__ */ (0,Y.jsx)(Km,{name:`?`,size:`list`})}function RT(e){let t=`size-6 rounded object-cover`,n=`block size-6 flex-none overflow-hidden rounded border border-dashboard-border bg-dashboard-fill-faint transition-colors hover:border-dashboard-border-interactive focus-visible:outline-2 focus-visible:outline-dashboard-focus`,r=e.message.images??[],i=e.message.attachments??[];return r.length===0&&i.length===0?null:/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`flex flex-none items-center gap-1`,children:[r.map((e,r)=>/* @__PURE__ */ (0,Y.jsx)(n_,{filename:e.filename,imageClassName:t,src:O_(e),triggerClassName:n},`local:${r}`)),i.map(r=>gi.some(e=>e===r.contentType)&&e.conversationId?/* @__PURE__ */ (0,Y.jsx)(n_,{filename:r.filename,imageClassName:t,loading:`lazy`,src:k_(e.conversationId,r.id),triggerClassName:n},r.id):/* @__PURE__ */ (0,Y.jsx)(PT,{label:r.filename,children:/* @__PURE__ */ (0,Y.jsx)(dr,{"aria-hidden":`true`,size:14})},r.id))]})}function zT(e){let t=e.message.text??``,n=e.message.mentions??[],r=!!e.message.redacted,i=e.message.source===`slack`;return/* @__PURE__ */ (0,Y.jsxs)(`article`,{className:K(`min-w-0 grid-cols-[minmax(0,1fr)] gap-1 px-3 py-1.5 text-dashboard-text md:px-3.5`,e.className),children:[/* @__PURE__ */ (0,Y.jsx)(wS,{className:`items-center`,left:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(LT,{authors:e.authors,message:e.message}),r?null:/* @__PURE__ */ (0,Y.jsx)(RT,{conversationId:e.conversationId,message:e.message}),r?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 font-sans text-sm leading-snug text-dashboard-text-muted`,children:`[redacted]`}):t?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 min-w-0 truncate font-sans text-sm leading-snug text-dashboard-text-subtle`,title:AT(t,n),children:e.message.reviewItemChange?/* @__PURE__ */ (0,Y.jsx)(pS,{fallback:/* @__PURE__ */ (0,Y.jsx)($,{inline:!0,mentions:n,text:t}),record:e.message.reviewItemChange}):/* @__PURE__ */ (0,Y.jsx)($,{inline:!0,mentions:n,text:t})}):null]}),leftClassName:`flex-1 text-sm leading-snug text-dashboard-text`,right:/* @__PURE__ */ (0,Y.jsx)(IT,{actionsDisabled:e.actionsDisabled,cancelError:e.cancelError,cancelPending:e.cancelPending,editPending:e.editPending,message:e.message,onCancel:e.onCancel?()=>e.onCancel?.(e.message):void 0,onEdit:e.canEdit&&e.onEdit?()=>e.onEdit?.(e.message):void 0,onSteer:e.canSteer&&e.onSteer?()=>e.onSteer?.(e.message):void 0,showSlack:i,steerPending:e.steerPending})}),e.onRetry?/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 font-sans text-xs text-red-300/80`,children:`Could not send.`}),/* @__PURE__ */ (0,Y.jsx)(`button`,{className:`cursor-pointer border-0 bg-transparent p-0 font-sans text-xs font-medium text-dashboard-accent-text/90 underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-dashboard-focus`,onClick:()=>e.onRetry?.(e.message),type:`button`,children:`Retry`})]}):null,e.cancelError?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 font-sans text-xs text-amber-100/75`,children:`Could not delete. Try again.`}):null]})}function BT(e){return/* @__PURE__ */ (0,Y.jsxs)(`button`,{"aria-controls":e.controls,"aria-expanded":e.expanded,className:K(`group flex w-full cursor-pointer items-center gap-1.5 border-0 bg-transparent px-3 py-2 text-left font-sans text-xs font-medium text-amber-100/80 transition-colors hover:text-amber-50 focus-visible:outline focus-visible:outline-1 focus-visible:outline-amber-200/55 md:px-3.5`,e.className),onClick:e.onClick,type:`button`,children:[/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,className:ia}),e.expanded?`Show fewer queued messages`:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`md:tall:hidden`,children:[e.totalCount,` queued messages`]}),e.tallHiddenCount>0?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`hidden md:tall:inline`,children:e.tallHiddenCount===1?`1 more queued message`:`${e.tallHiddenCount} more queued messages`}):null]})]})}function VT(e,t){return!!(e&&t&&e.trim().toLowerCase()===t.trim().toLowerCase())}const HT=(0,J.memo)(function(e){let[t,n]=(0,J.useState)(!1),r=(0,J.useId)(),i=(0,J.useRef)(e.onLayoutChange);i.current=e.onLayoutChange;let a=(0,J.useRef)(!1);(0,J.useLayoutEffect)(()=>{a.current?i.current?.():a.current=!0},[t]);let o=new Set(e.committedMessageIds??[]),s=e.messages.filter(e=>!o.has(e.messageId)).map(t=>{let n=!!(e.cancelError&&e.cancelTargetInboundMessageId===t.inboundMessageId),r=t.clientStatus===`failed`&&t.idempotencyKey?e.onRetry:void 0;return{cancelError:n,message:t,retry:r,needsAttention:n||!!r}});if(s.length===0)return null;let c=s.length>5,l=s.length>1&&s.some(e=>!e.needsAttention),u=c?s.slice(4).filter(e=>!e.needsAttention).length:0,d=()=>n(e=>!e),f=!!e.cancelPending||!!e.editTargetInboundMessageId||!!e.steerTargetInboundMessageId;return/* @__PURE__ */ (0,Y.jsxs)(`div`,{"aria-label":`Pending messages`,className:`mx-2 overflow-hidden rounded-t-lg bg-amber-300/[0.055] md:mx-3`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{id:r,children:s.map((n,r)=>{let{cancelError:i,message:a,needsAttention:o,retry:s}=n,u=l&&!t&&!o;if(u&&c&&r>=4)return null;let d=a.clientStatus===void 0,p=d&&a.source===`web`&&!a.redacted&&VT(a.actorIdentity?.email,e.viewerEmail);return/* @__PURE__ */ (0,Y.jsx)(zT,{actionsDisabled:f,authors:e.authors,cancelError:i,cancelPending:!!(e.cancelPending&&e.cancelTargetInboundMessageId===a.inboundMessageId),canEdit:p,canSteer:p&&a.delivery===`defer`,className:u?c?`hidden md:tall:grid`:`grid md:hidden md:tall:grid`:`grid`,conversationId:e.conversationId,editPending:e.editTargetInboundMessageId===a.inboundMessageId,message:a,onCancel:d?e.onCancelMessage:void 0,onEdit:e.onEditMessage,onRetry:s,onSteer:e.onSteerMessage,steerPending:e.steerTargetInboundMessageId===a.inboundMessageId},a.messageId)})}),l?/* @__PURE__ */ (0,Y.jsx)(BT,{className:K(!c&&`hidden md:flex`,u===0&&`md:tall:hidden`),controls:r,expanded:t,onClick:d,tallHiddenCount:u,totalCount:s.length}):null]})}),UT=(0,J.memo)(WT);function WT(e){let t=ud(e.conversationId),n=Wx(),r=md(e.conversationId),i=(0,J.useRef)(r);i.current=r;let a=dd(e.conversationId),[o,s]=(0,J.useState)(),[c,l]=(0,J.useState)(),{loadFailed:u,pending:d,questions:f,retry:p}=wT(e.conversationId),m=(0,J.useRef)(void 0);!d&&m.current?.conversationId!==e.conversationId&&(m.current={conversationId:e.conversationId,ids:new Set(f.map(e=>e.id))});let{conversationId:h,onShowQuestion:g}=e,_=(0,J.useCallback)((e,t)=>{if(t){g?.(e,!1);return}let n=m.current;n?.conversationId===h&&(n.ids.has(e.id)||g?.(e,!0))},[h,g]),v=(0,J.useRef)(null),y=(0,J.useRef)(null),[b,x]=(0,J.useState)(!1),S=(0,J.useRef)(b);S.current=b;let{confirmSubmit:C}=n,w=(0,J.useCallback)(({sendsMessage:e})=>{let t=e?C():void 0;if(t||S.current)return(async()=>t&&!await t?!1:await y.current?.send()??!0)()},[C]),T=(0,J.useRef)(t);T.current=t;let E=(0,J.useRef)(a);E.current=a;let D=(0,J.useRef)(e.onPinRequest);D.current=e.onPinRequest;let O=e.pendingMessages.map(e=>[e.inboundMessageId,e.messageId,e.clientStatus,e.delivery].join(`:`)).join(`|`),k=(0,J.useRef)(O);(0,J.useEffect)(()=>{k.current!==O&&(k.current=O,window.matchMedia(`(width < 48rem) or ((width < 64rem) and (height < 30rem))`).matches&&D.current())},[O]);let A=new Set(e.committedMessageIds),j=(0,J.useRef)(!1);j.current=e.sendsInline&&!e.pendingMessages.some(e=>!A.has(e.messageId));let M=(0,J.useCallback)(async(e,t,n)=>{await T.current.mutateAsync({idempotencyKey:t,inline:j.current,message:e,images:n})},[]),ee=(0,J.useCallback)(e=>{e.idempotencyKey&&(e.text||e.images?.length)&&T.current.mutateAsync({idempotencyKey:e.idempotencyKey,message:e.text??``,images:e.images})},[]),N=(0,J.useCallback)(()=>{E.current.isPending||E.current.reset(),i.current.isPending||i.current.reset(),l(void 0),D.current()},[]),P=e.pendingMessages.filter(e=>e.clientStatus===void 0).map(e=>e.inboundMessageId),te=(0,J.useCallback)(t=>{let n=e.pendingGeneratedAtRef.current;n&&E.current.mutate({inboundMessageIds:[t.inboundMessageId],receivedBefore:n})},[e.pendingGeneratedAtRef]),F=a.variables?.inboundMessageIds[0],ne=!!(a.error&&a.variables?.inboundMessageIds.some(e=>P.includes(e))),re=dd(e.conversationId),ie=(0,J.useRef)(re);ie.current=re;let I=(0,J.useRef)(!1),L=(0,J.useRef)(null);(0,J.useImperativeHandle)(e.ref,()=>({appendText:e=>L.current?.appendText(e)}));let{onFocusRequestDone:ae}=e,oe=e.focusRequest?.key,se=e.focusRequest?.draftFrom,ce=f.length>0;(0,J.useEffect)(()=>{if(!oe||d&&!ce)return;ae(oe);let e=se?gv(se):``;e?L.current?.restoreMessage({text:e}):se?L.current?.focus():sv()||(ce?v.current?.focus():L.current?.focus())},[se,oe,ae,ce,d]);let le=Go().data?.me.user.email,ue=(0,J.useCallback)(async t=>{let n=e.pendingGeneratedAtRef.current;if(!n||I.current)return;I.current=!0;let r=t.inboundMessageId;s(r),l(void 0);try{let i=await $_(e.conversationId,t.attachments);if(!L.current)return;if(!L.current.canRestoreImages(i)){l(`Remove some draft images to edit that message.`);return}if(!(await ie.current.mutateAsync({inboundMessageIds:[r],receivedBefore:n})).cancelledInboundMessageIds.includes(r)){l(`That message was already read or removed.`);return}let a={images:i,text:t.text??``};L.current?L.current.restoreMessage(a):hv(e.conversationId,a.text)}catch{l(`Could not edit the queued message. Try again.`)}finally{I.current=!1,s(void 0)}},[e.conversationId,e.pendingGeneratedAtRef]),R=fd(e.conversationId),de=(0,J.useRef)(R);de.current=R;let fe=(0,J.useCallback)(e=>{if(de.current.isPending)return;l(void 0);let t=e.inboundMessageId;de.current.mutate({inboundMessageIds:[t]},{onError:()=>l(`Could not send the queued message now. Try again.`),onSuccess:e=>{e.steeredInboundMessageIds.includes(t)||l(`That message was already read, steered, or removed.`)}})},[]),pe=R.isPending?R.variables?.inboundMessageIds[0]:void 0,me=(0,J.useCallback)(async()=>{let e=(await i.current.mutateAsync()).stoppedMessages.map(e=>e.text);return e.length?e.join(`
|
|
154
|
-
`):void 0},[]),he=(0,J.useCallback)(()=>{window.matchMedia(`(width < 48rem) or ((width < 64rem) and (height < 30rem))`).matches&&D.current()},[]),ge=(0,J.useCallback)(()=>L.current?.focus(),[]),_e=(0,J.useCallback)(()=>{window.matchMedia(`(width < 48rem) or ((width < 64rem) and (height < 30rem))`).matches&&D.current()},[]);return/* @__PURE__ */ (0,Y.jsx)(Gm,{above:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[e.pendingAuthorization?/* @__PURE__ */ (0,Y.jsx)(dy,{authorization:e.pendingAuthorization}):null,/* @__PURE__ */ (0,Y.jsx)(HT,{authors:e.authors,cancelError:ne,cancelPending:a.isPending,cancelTargetInboundMessageId:F,committedMessageIds:e.committedMessageIds,conversationId:e.conversationId,editTargetInboundMessageId:o,messages:e.pendingMessages,onCancelMessage:te,onEditMessage:ue,onLayoutChange:he,onRetry:ee,onSteerMessage:e.stoppable?fe:void 0,steerTargetInboundMessageId:pe,viewerEmail:le}),/* @__PURE__ */ (0,Y.jsx)(OT,{answersRef:y,focusMessageBox:ge,onAnswersChange:x,onShow:_,questions:f,ref:v}),u?/* @__PURE__ */ (0,Y.jsx)(TT,{onRetry:p}):null,n.dialog]}),children:/* @__PURE__ */ (0,Y.jsx)(lv,{beforeSubmit:w,draftId:e.conversationId,error:c??(r.error?`Could not stop Junior. Try again.`:void 0),ref:L,label:`Continue this conversation`,placeholder:ce?`Or type your answer…`:void 0,sendsWithoutDraft:b,submitLabel:`Send`,onFocus:_e,onStop:e.stoppable?me:void 0,stopPending:r.isPending,onSubmitStart:N,onSubmit:M})})}function GT(e){let{detail:t}=e,n=(0,J.useMemo)(()=>Pu(t.data?.events),[t.data?.events]),r=(0,J.useRef)(t.pendingGeneratedAt);return r.current=t.pendingGeneratedAt,t.data?/* @__PURE__ */ (0,Y.jsx)(UT,{authors:t.data.authors,conversationId:e.conversationId,committedMessageIds:n,focusRequest:e.focusRequest,onFocusRequestDone:e.onFocusRequestDone,onPinRequest:e.onPinRequest,onShowQuestion:e.onShowQuestion,pendingAuthorization:t.pendingAuthorization,pendingGeneratedAtRef:r,pendingMessages:t.pendingMessages,ref:e.ref,sendsInline:t.data.eventHistory.status===`available`&&!e.hasNewerPage&&!Xu(t.data)&&t.inlineMessages.length===0,stoppable:e.live}):null}function KT(e){let t=P();return N({mutationFn:t=>Ui(ci,`/api/conversations/${encodeURIComponent(e)}/auto-archive`,{autoArchive:t}),onSuccess:n=>{t.setQueryData(X(e),e=>e&&{...e,autoArchive:n.autoArchive,detailEtag:void 0})}})}function qT(){let e=P();return N({mutationFn:()=>Qi(ni,`/api/conversations/archive-done`,{}),onSuccess:async()=>{await e.invalidateQueries({queryKey:[`dashboard`,`conversations`]})}})}const JT=`Archive this conversation for everyone when its linked work is merged or closed and nobody replies during your wait time.`;function YT(e){let t=KT(e.conversationId),n=(0,J.useId)();return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid gap-1`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[/* @__PURE__ */ (0,Y.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2.5`,children:[/* @__PURE__ */ (0,Y.jsx)(wx,{"aria-describedby":n,checked:e.autoArchive,disabled:t.isPending,onCheckedChange:e=>t.mutate(e)}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-semibold text-dashboard-text`,children:`Auto archive`})]}),/* @__PURE__ */ (0,Y.jsxs)(Gs,{children:[/* @__PURE__ */ (0,Y.jsx)(Ks,{delay:0,openOnHover:!0,render:/* @__PURE__ */ (0,Y.jsx)(`button`,{"aria-label":`About auto archive`,className:`grid place-items-center rounded-sm text-dashboard-text-muted hover:text-dashboard-text focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus`,type:`button`,children:/* @__PURE__ */ (0,Y.jsx)(hr,{"aria-hidden":`true`,size:14,strokeWidth:2})})}),/* @__PURE__ */ (0,Y.jsx)(qs,{"aria-label":`About auto archive`,className:`w-64 px-3 py-2 text-xs`,side:`top`,children:/* @__PURE__ */ (0,Y.jsx)(Ys,{children:JT})})]}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`sr-only`,id:n,children:JT})]}),t.isError?/* @__PURE__ */ (0,Y.jsx)(h_,{children:`Could not save auto-archive. Try again.`}):null]})}function XT({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`nav`,{role:`navigation`,"aria-label":`Pagination`,"data-slot":`pagination`,className:F(`flex w-full justify-center`,e),...t})}function ZT({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`ul`,{"data-slot":`pagination-content`,className:F(`flex items-center gap-2`,e),...t})}function QT({...e}){return/* @__PURE__ */ (0,Y.jsx)(`li`,{"data-slot":`pagination-item`,...e})}function $T(e){return/* @__PURE__ */ (0,Y.jsx)(H,{"aria-label":`Previous page`,size:`icon`,...e,children:/* @__PURE__ */ (0,Y.jsx)(Lt,{"aria-hidden":`true`,size:16})})}function eE(e){return/* @__PURE__ */ (0,Y.jsx)(H,{"aria-label":`Next page`,size:`icon`,...e,children:/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,size:16})})}function tE(e){return e.hasMore?/* @__PURE__ */ (0,Y.jsx)(H,{className:K(`justify-self-center`,e.className),disabled:e.loading,onClick:e.onLoadMore,children:e.loading?`Loading…`:`Load more`}):null}function nE(e,t,n){let r=(Math.max(1,t)-1)*n;return e.slice(r,r+n)}function rE(e,t){return e<=0?1:Math.max(1,Math.ceil(e/t))}function iE(e){if(e.total<=e.pageSize||e.pageCount<=1)return null;let t=Math.min(Math.max(1,e.page),e.pageCount),n=(t-1)*e.pageSize+1,r=Math.min(e.total,t*e.pageSize);return/* @__PURE__ */ (0,Y.jsxs)(XT,{className:K(`flex-wrap items-center justify-between gap-3`,e.className),children:[/* @__PURE__ */ (0,Y.jsxs)(`p`,{className:`m-0 font-sans tabular-nums text-xs text-dashboard-text-muted`,children:[`Showing `,n.toLocaleString(`en-US`),`-`,r.toLocaleString(`en-US`),` of`,` `,e.total.toLocaleString(`en-US`)]}),/* @__PURE__ */ (0,Y.jsxs)(ZT,{children:[/* @__PURE__ */ (0,Y.jsx)(QT,{children:/* @__PURE__ */ (0,Y.jsx)($T,{disabled:t<=1,onClick:()=>e.onPageChange(t-1)})}),/* @__PURE__ */ (0,Y.jsxs)(QT,{className:`min-w-16 text-center font-sans tabular-nums text-xs text-dashboard-text-muted`,children:[t,` / `,e.pageCount]}),/* @__PURE__ */ (0,Y.jsx)(QT,{children:/* @__PURE__ */ (0,Y.jsx)(eE,{disabled:t>=e.pageCount,onClick:()=>e.onPageChange(t+1)})})]})]})}function aE(e){let{item:t}=e,n=t.status===`open`,r=t.assignees.length>0||t.assignedToEveryone;return/* @__PURE__ */ (0,Y.jsxs)(`section`,{"aria-label":`Review item: ${t.title}`,className:`my-1 w-full min-w-0 max-w-[37.5rem] overflow-hidden rounded-xl border border-dashboard-border-emphasis bg-dashboard-surface-panel font-sans text-sm text-dashboard-text`,children:[/* @__PURE__ */ (0,Y.jsxs)(`header`,{className:`flex items-start gap-3 px-4 pb-3 pt-4 md:px-5`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:K(`grid size-9 shrink-0 place-items-center rounded-lg border`,n?`border-dashboard-accent/30 bg-dashboard-accent/10 text-dashboard-accent`:`border-dashboard-border bg-dashboard-fill-soft text-dashboard-text-muted`),children:/* @__PURE__ */ (0,Y.jsx)(lr,{size:18})}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0 flex-1 gap-1`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 text-xs text-dashboard-text-muted`,children:`Review item`}),/* @__PURE__ */ (0,Y.jsx)(gp,{className:`shrink-0`,size:`compact`,tone:n?`accent`:`neutral`,children:Qx(t)})]}),/* @__PURE__ */ (0,Y.jsx)(`h3`,{className:`m-0 break-words text-base font-semibold leading-snug`,children:t.title})]})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-4 px-4 pb-4 md:px-5`,children:[/* @__PURE__ */ (0,Y.jsx)($,{text:t.body}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`border-t border-dashboard-border pt-4`,children:/* @__PURE__ */ (0,Y.jsx)(Yx,{item:t})})]}),/* @__PURE__ */ (0,Y.jsxs)(`footer`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-dashboard-border bg-dashboard-fill-faint px-4 py-3 text-xs md:px-5`,children:[/* @__PURE__ */ (0,Y.jsxs)(V,{className:`inline-flex items-center gap-2 font-medium text-dashboard-text no-underline hover:underline focus-visible:outline-dashboard-focus`,to:Xx(t.id),children:[`Open on the review desk`,/* @__PURE__ */ (0,Y.jsx)(qt,{"aria-hidden":`true`,size:14})]}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 truncate text-dashboard-text-muted`,children:r?`Assigned to ${$x(t)}`:`Unassigned`})]})]})}function oE(e){let{items:t,query:n}=cu({conversationId:e.conversationId}),r=(0,J.useRef)(null),i=t.length>0;return(0,J.useEffect)(()=>{e.highlight&&i&&r.current?.scrollIntoView({block:`nearest`})},[e.highlight,i]),i?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:K(`rounded-lg`,e.highlight&&`ring-2 ring-violet-300/50`),ref:r,children:/* @__PURE__ */ (0,Y.jsxs)(yg,{count:n.hasNextPage?void 0:t.length,label:`Needs you`,title:`Needs you`,children:[/* @__PURE__ */ (0,Y.jsx)(bg,{itemKey:e=>e.id,items:t,renderItem:t=>/* @__PURE__ */ (0,Y.jsx)(sE,{defaultExpanded:e.highlight,item:t})}),/* @__PURE__ */ (0,Y.jsx)(tE,{className:`mt-2`,hasMore:!!n.hasNextPage,loading:n.isFetchingNextPage,onLoadMore:()=>void n.fetchNextPage()})]})}):null}function sE(e){let[t,n]=(0,J.useState)(e.defaultExpanded);return(0,J.useEffect)(()=>{e.defaultExpanded&&n(!0)},[e.defaultExpanded]),/* @__PURE__ */ (0,Y.jsxs)(nh,{className:`min-w-0`,onOpenChange:n,open:t,children:[/* @__PURE__ */ (0,Y.jsx)(xg,{disclosure:!0,icon:/* @__PURE__ */ (0,Y.jsx)(lr,{"aria-hidden":`true`,className:`size-3.5`}),meta:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`grid size-5 place-items-center`,children:/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,className:ia})}),title:e.item.title}),/* @__PURE__ */ (0,Y.jsx)(ih,{className:`px-1.5 pb-1`,children:/* @__PURE__ */ (0,Y.jsx)(aE,{item:e.item})})]})}function cE(e){let t=t=>new Set(e.events.filter(e=>e.source===t).flatMap(e=>e.memoryIds)).size;return{captured:t(`captured`),recalled:t(`recalled`)}}function lE(e){let t=cE(e.list),n=[t.recalled?`${t.recalled} recalled`:void 0,t.captured?`${t.captured} captured`:void 0].filter(Boolean).join(` · `);return/* @__PURE__ */ (0,Y.jsx)(yg,{title:`Memories`,children:/* @__PURE__ */ (0,Y.jsxs)(`button`,{className:`group -mx-1.5 -my-1 flex min-h-8 w-[calc(100%+0.75rem)] items-center justify-between gap-2.5 rounded-md px-1.5 py-1.5 text-left text-sm tabular-nums text-dashboard-text transition-colors hover:bg-dashboard-surface-hover focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus`,onClick:e.onOpen,type:`button`,children:[n,/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,className:ia})]})})}function uE(e){let{entry:t}=e,{turnId:n}=t;return/* @__PURE__ */ (0,Y.jsxs)(`li`,{className:`grid overflow-hidden rounded-lg border border-dashboard-border-subtle bg-dashboard-surface-panel`,children:[/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 whitespace-pre-wrap px-3 py-2.5 text-sm leading-relaxed text-dashboard-text [overflow-wrap:anywhere]`,children:t.memory.content}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-h-8 items-center justify-between gap-2 border-t border-dashboard-border-subtle bg-dashboard-fill-faint px-3 py-1 text-xs text-dashboard-text-muted`,children:[t.memory.visibility===`private`?/* @__PURE__ */ (0,Y.jsx)(JS,{}):/* @__PURE__ */ (0,Y.jsx)(`span`,{}),n?/* @__PURE__ */ (0,Y.jsxs)(`button`,{className:`-mr-1.5 inline-flex cursor-pointer items-center gap-1 rounded-md border-0 bg-transparent px-1.5 py-1 font-sans text-xs font-medium text-dashboard-text-muted transition-colors hover:bg-dashboard-fill-hover hover:text-dashboard-text focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus`,onClick:()=>e.onSelect({...t,turnId:n}),type:`button`,children:[`Go to message`,/* @__PURE__ */ (0,Y.jsx)(qt,{"aria-hidden":`true`,size:13})]}):null]})]})}function dE(e){let t=[`recalled`,`captured`].map(t=>({entries:e.entries.filter(e=>e.source===t),source:t})).filter(e=>e.entries.length>0);return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`grid gap-5`,children:t.map(t=>/* @__PURE__ */ (0,Y.jsxs)(`section`,{className:`grid gap-2`,children:[/* @__PURE__ */ (0,Y.jsxs)(`h3`,{className:`m-0 flex items-center gap-1.5 font-sans text-xs font-semibold text-dashboard-text`,children:[t.source===`recalled`?/* @__PURE__ */ (0,Y.jsx)(xr,{"aria-hidden":`true`,size:13,strokeWidth:1.8}):/* @__PURE__ */ (0,Y.jsx)(Vt,{"aria-hidden":`true`,size:13,strokeWidth:1.8}),t.source===`recalled`?`Recalled`:`Captured`,/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-normal tabular-nums text-dashboard-text-muted`,children:t.entries.length})]}),/* @__PURE__ */ (0,Y.jsx)(`ol`,{className:`m-0 grid list-none gap-2 p-0`,children:t.entries.map(t=>/* @__PURE__ */ (0,Y.jsx)(uE,{entry:t,onSelect:e.onSelect},`${t.source}:${t.memory.id}`))})]},t.source))})}function fE(e){let t=Fy(),n=ox()?.list,[r,i]=(0,J.useState)(!1),[a,o]=(0,J.useState)(e.conversationId);a!==e.conversationId&&(o(e.conversationId),i(!1));let s=bb(e.conversationId).data?.agents,c=s?.filter(e=>e.kind===`thread`)??[],l=s?.filter(e=>e.kind===`task`)??[],u=e.agentTree?.at(-2),d=Cg(e.conversationId).data?.watches??[],f=new Set(e.links.map(e=>e.url)),p=/* @__PURE__ */ new Map,m=[];for(let e of d)e.url&&f.has(e.url)?p.set(e.url,[...p.get(e.url)??[],e]):m.push(e);return r&&n?/* @__PURE__ */ (0,Y.jsx)(Iy,{label:`Conversation details`,onClose:e.onClose,title:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`-ml-2 flex min-w-0 items-center gap-1`,children:[/* @__PURE__ */ (0,Y.jsx)(H,{"aria-label":`Back to details`,onClick:()=>i(!1),size:`icon`,children:/* @__PURE__ */ (0,Y.jsx)(rr,{"aria-hidden":`true`,size:15})}),/* @__PURE__ */ (0,Y.jsx)(`h2`,{className:`m-0 truncate font-sans text-sm font-semibold text-dashboard-text`,children:`Memories`})]}),children:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`px-4 pb-[max(1rem,env(safe-area-inset-bottom))] pt-3`,children:/* @__PURE__ */ (0,Y.jsx)(dE,{entries:ix(n),onSelect:n=>{t||e.onClose(),e.onSelectMemory(n)}})})}):/* @__PURE__ */ (0,Y.jsx)(Iy,{label:`Conversation details`,title:/* @__PURE__ */ (0,Y.jsx)(`h2`,{"aria-label":`Conversation details`,className:`m-0 flex min-w-0 items-center gap-1.5 font-sans text-sm`,children:e.brief?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-semibold text-dashboard-text`,children:`Brief`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`text-dashboard-text-faint`,children:`·`}),/* @__PURE__ */ (0,Y.jsxs)(`time`,{className:`truncate text-xs font-normal text-dashboard-text-muted`,dateTime:e.brief.updatedAt,title:to(e.brief.updatedAt,{dateStyle:`medium`,timeStyle:`short`}),children:[`Updated `,no(e.brief.updatedAt)]})]}):/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-semibold text-dashboard-text`,children:`Details`})}),onClose:e.onClose,children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0 content-start gap-2 px-4 pb-[max(1rem,env(safe-area-inset-bottom))] pt-3`,children:[u?/* @__PURE__ */ (0,Y.jsx)(yg,{flat:!0,title:`Parent`,children:/* @__PURE__ */ (0,Y.jsx)(xg,{icon:/* @__PURE__ */ (0,Y.jsx)(wn,{"aria-hidden":`true`,size:14}),title:u.label,to:kc(u.conversationId)})}):null,/* @__PURE__ */ (0,Y.jsx)(oE,{conversationId:e.conversationId,highlight:e.highlightReview}),e.brief?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`min-w-0 break-words px-1 pb-1 font-sans text-sm leading-relaxed text-dashboard-text-muted`,children:/* @__PURE__ */ (0,Y.jsx)(lb,{brief:e.brief,variant:`summary`})}):null,c.length>0?/* @__PURE__ */ (0,Y.jsx)(xb,{threads:c}):null,e.links.length>0||m.length>0?/* @__PURE__ */ (0,Y.jsxs)(yg,{count:e.links.length||m.length,flat:!0,title:e.links.length>0?`Linked work`:`Waiting on`,children:[e.links.length>0?/* @__PURE__ */ (0,Y.jsx)(Ig,{links:e.links,watchesByUrl:p}):null,e.links.length>0&&m.length>0?/* @__PURE__ */ (0,Y.jsx)(`h4`,{className:`m-0 mb-1.5 mt-3 font-sans text-xs font-semibold text-dashboard-text-muted`,children:`Also waiting on`}):null,m.length>0?/* @__PURE__ */ (0,Y.jsx)(wg,{watches:m}):null]}):null,e.autoArchive==null?null:/* @__PURE__ */ (0,Y.jsx)(yg,{children:e.autoArchive}),l.length>0?/* @__PURE__ */ (0,Y.jsx)(Sb,{onOpenTask:n=>{t||e.onClose(),e.onOpenSubagent(n)},tasks:l}):null,e.overview==null?null:/* @__PURE__ */ (0,Y.jsx)(yg,{flat:!0,children:e.overview}),e.usage,e.identity==null?null:/* @__PURE__ */ (0,Y.jsx)(yg,{flat:!0,title:`Participants`,children:e.identity}),n?.events.length?/* @__PURE__ */ (0,Y.jsx)(lE,{list:n,onOpen:()=>i(!0)}):null]})})}function pE(e,t,n){let r=[[`input`,e?.inputTokens,t?.input],[`output`,e?.outputTokens,t?.output],[`cached`,e?.cachedInputTokens,t?.cacheRead],[`cache write`,e?.cacheCreationTokens,t?.cacheWrite],[`reasoning (in output)`,e?.reasoningTokens,void 0]].flatMap(([e,t,r])=>t||r!==void 0?[{cost:r===void 0?void 0:n(r),count:t===void 0?`—`:Wa(t),label:e}]:[]);return r.length?r:void 0}const mE=`px-0 text-right align-top font-sans tabular-nums`;function hE(e){return/* @__PURE__ */ (0,Y.jsxs)(Oh,{"aria-label":e.label,className:`min-w-72 table-fixed text-xs leading-relaxed`,children:[/* @__PURE__ */ (0,Y.jsxs)(`colgroup`,{children:[/* @__PURE__ */ (0,Y.jsx)(`col`,{}),/* @__PURE__ */ (0,Y.jsx)(`col`,{className:`w-20`}),/* @__PURE__ */ (0,Y.jsx)(`col`,{className:`w-20`})]}),/* @__PURE__ */ (0,Y.jsx)(kh,{children:/* @__PURE__ */ (0,Y.jsxs)(Mh,{className:`border-dashboard-border`,children:[/* @__PURE__ */ (0,Y.jsx)(Nh,{scope:`col`,className:`px-0 py-2 leading-relaxed font-normal`,children:e.label}),/* @__PURE__ */ (0,Y.jsx)(Nh,{scope:`col`,className:`px-0 py-2 text-right leading-relaxed font-normal`,children:e.countLabel}),/* @__PURE__ */ (0,Y.jsx)(Nh,{scope:`col`,className:`px-0 py-2 text-right leading-relaxed font-normal`,children:`Cost`})]})}),e.rows.map((e,t,n)=>{let r=e.parts?`pt-2 pb-0.5`:K(t===0?`pt-2`:`pt-0`,t===n.length-1?`pb-2`:`pb-0`);return/* @__PURE__ */ (0,Y.jsxs)(Ah,{className:K(e.parts&&`border-b border-dashboard-border-subtle last-of-type:border-b-0`),children:[/* @__PURE__ */ (0,Y.jsxs)(Mh,{className:`border-0`,children:[/* @__PURE__ */ (0,Y.jsx)(Nh,{scope:`row`,className:K(`pl-0 pr-3 align-top leading-relaxed font-normal text-dashboard-text`,r),children:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`block truncate`,children:e.label})}),/* @__PURE__ */ (0,Y.jsx)(Ph,{className:K(mE,r),children:e.count}),/* @__PURE__ */ (0,Y.jsx)(Ph,{className:K(mE,r),children:e.cost})]}),e.parts?.map((e,t,n)=>{let r=t===n.length-1?`pt-0 pb-2`:`py-0`;return/* @__PURE__ */ (0,Y.jsxs)(Mh,{className:`border-0 text-2xs leading-5`,children:[/* @__PURE__ */ (0,Y.jsx)(Nh,{scope:`row`,className:K(`truncate pl-3 pr-3 align-top text-2xs leading-5 font-normal text-dashboard-text-faint`,r),children:e.label}),/* @__PURE__ */ (0,Y.jsx)(Ph,{className:K(mE,`text-dashboard-text-faint`,r),children:e.count}),/* @__PURE__ */ (0,Y.jsx)(Ph,{className:K(mE,`text-dashboard-text-faint`,r),children:e.cost})]},e.label)})]},e.key)}),e.total?/* @__PURE__ */ (0,Y.jsx)(jh,{className:`font-semibold`,children:/* @__PURE__ */ (0,Y.jsxs)(Mh,{children:[/* @__PURE__ */ (0,Y.jsx)(Nh,{scope:`row`,className:`px-0 py-2 leading-relaxed font-semibold text-dashboard-text`,children:e.total.label}),/* @__PURE__ */ (0,Y.jsx)(Ph,{className:`px-0 py-2 text-right font-sans tabular-nums`,children:e.total.count}),/* @__PURE__ */ (0,Y.jsx)(Ph,{className:`px-0 py-2 text-right font-sans tabular-nums`,children:e.total.cost})]})}):null]})}function gE(e){if(!e.conversation)return!1;let t=e.detail?.auxiliaryCosts??e.conversation.auxiliaryCosts;return!!(e.detail?.modelUsage?.length||t?.operations?.length)}function _E(e){if(!gE(e)||!e.conversation)return null;let t=e.detail?.modelUsage??[],n=e.detail?.auxiliaryCosts??e.conversation.auxiliaryCosts,r=e.detail?.cumulativeUsage??e.conversation.cumulativeUsage,i=e.detail?.childAgentTotals??e.conversation.childAgentTotals,a=ba(t),o=Ca(r),s=(a??o)?.totalTokens,c=Oa(t),l=Ea(r),u=wa(c??l,n),d=u?.total,f=[...n?.operations??[]].sort((e,t)=>t.costUsd-e.costUsd),p=ey(d??0),m=e=>e===void 0?`—`:Wa(e),h=e=>e===void 0?`—`:p(e),g=Ty(e.detail),_=(e.detail?.status??e.conversation.status)===`active`,v=pE(a?void 0:o,c?void 0:l,p),y=e.detail?.previousCursor?void 0:e.detail?.events.filter(e=>e.data.type===`compaction`).length,b=t.map(e=>({cost:Ea(e.usage),modelId:e.modelId,tokens:Ca(e.usage)})).sort((e,t)=>(t.cost?.total??0)-(e.cost?.total??0)||(t.tokens?.totalTokens??0)-(e.tokens?.totalTokens??0));g&&!b.some(e=>e.modelId===g)&&b.unshift({cost:void 0,modelId:g,tokens:void 0});let x=Gv(i),S=Kv(x.cost,d??x.cost),C=Kv(x.tokens,s??x.tokens),w=/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-4 px-1 pb-1`,children:[i?/* @__PURE__ */ (0,Y.jsx)(hE,{countLabel:`Tokens`,label:`Agent`,rows:[{cost:h(d===void 0?void 0:d-S),count:m(s===void 0?void 0:s-C),key:`self`,label:`This agent`},{cost:p(S),count:m(C),key:`subagents`,label:`${Wa(i.count)} child conversation${i.count===1?``:`s`}`}],total:{cost:h(d),count:m(s),label:`Total`}}):null,b.length?/* @__PURE__ */ (0,Y.jsx)(hE,{countLabel:`Tokens`,label:`Model`,rows:b.map(({cost:e,modelId:t,tokens:n})=>{let r=t===g;return{cost:r&&!e?`…`:h(e?.total),count:r&&!n?`…`:m(n?.totalTokens),key:t,label:/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 truncate font-mono`,title:t,children:Jv(t)}),r?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`shrink-0 text-dashboard-text-muted`,children:/* @__PURE__ */ (0,Y.jsx)(Fv,{active:!0,children:`in progress`})}):null]}),parts:pE(n,e,p)}}),total:t.length>1?{cost:h(c?.total),count:m(a?.totalTokens),label:`All models`}:void 0}):null,v?/* @__PURE__ */ (0,Y.jsx)(hE,{countLabel:`Tokens`,label:`Token type`,rows:v.map(e=>({cost:e.cost??`—`,count:e.count,key:e.label,label:e.label}))}):null,n&&f.length?/* @__PURE__ */ (0,Y.jsx)(hE,{countLabel:`Calls`,label:`Auxiliary`,rows:f.map(e=>({cost:p(e.costUsd),count:Wa(e.events),key:`${e.namespace}/${e.name}`,label:iy(e)})),total:f.length>1?{cost:p(n.costUsd),count:Wa(f.reduce((e,t)=>e+t.events,0)),label:`All auxiliary`}:void 0}):null,/* @__PURE__ */ (0,Y.jsxs)(`p`,{className:`m-0 text-xs leading-relaxed text-dashboard-text-muted`,children:[`Estimated costs.`,i?` Totals include child conversations at any depth.`:null,y?` ${Wa(y)} compaction${y===1?``:`s`}.`:null]})]}),T=[s===void 0?void 0:`${m(s)} tokens`,u?`${Ja(u)}${_?`+`:``}`:_?`$…`:void 0].filter(Boolean).join(` · `);return/* @__PURE__ */ (0,Y.jsxs)(nh,{className:`min-w-0 border-t border-dashboard-border-subtle`,children:[/* @__PURE__ */ (0,Y.jsx)(`h3`,{className:`m-0`,children:/* @__PURE__ */ (0,Y.jsxs)(rh,{className:`group flex min-h-9 w-full min-w-0 cursor-pointer items-center gap-1.5 rounded-md px-1 py-2 text-left font-sans text-xs font-semibold text-dashboard-text transition-colors hover:bg-dashboard-surface-hover focus-visible:outline-2 focus-visible:outline-dashboard-focus`,children:[/* @__PURE__ */ (0,Y.jsx)(U,{"aria-hidden":`true`,className:K(ia,`text-dashboard-text-muted`)}),`Usage`,T?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`ml-auto font-normal tabular-nums text-dashboard-text-muted`,children:/* @__PURE__ */ (0,Y.jsx)(Fv,{active:_,children:T})}):null]})}),/* @__PURE__ */ (0,Y.jsx)(ih,{hiddenUntilFound:!0,children:w})]})}function vE(e){let{conversation:t,detail:n}=e,r=Qm(t),i=gE({conversation:t,detail:n});return/* @__PURE__ */ (0,Y.jsx)(ax,{value:e.memoryState,children:/* @__PURE__ */ (0,Y.jsx)(fE,{agentTree:n?.agentTree,autoArchive:n?.autoArchive===void 0?null:/* @__PURE__ */ (0,Y.jsx)(YT,{autoArchive:n.autoArchive,conversationId:e.conversationId}),brief:n?.brief,conversationId:e.conversationId,highlightReview:e.highlightReview,identity:r.length>0?/* @__PURE__ */ (0,Y.jsx)($m,{participants:r,size:`detail`}):null,onClose:e.onClose,onOpenSubagent:e.onOpenSubagent,onSelectMemory:e.onSelectMemory,links:e.links,overview:Ey({conversation:t,detail:n,showUsageBreakdown:i})?/* @__PURE__ */ (0,Y.jsx)(Dy,{conversation:t,detail:n,showUsageBreakdown:i}):null,usage:i?/* @__PURE__ */ (0,Y.jsx)(_E,{conversation:t,detail:n}):null})})}const yE=`font-medium text-dashboard-text no-underline underline-offset-2 hover:underline`;function bE(e){return/* @__PURE__ */ (0,Y.jsxs)(`nav`,{"aria-label":`Conversation forks`,className:`flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1 text-xs leading-snug text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,Y.jsx)(sr,{"aria-hidden":`true`,size:12,className:`shrink-0`}),e.forkedFromConversationId?/* @__PURE__ */ (0,Y.jsxs)(`span`,{children:[`Forked from`,` `,/* @__PURE__ */ (0,Y.jsx)(V,{className:yE,to:kc(e.forkedFromConversationId),children:e.forkedFromTitle??`source conversation`})]}):null,e.forkedFromConversationId&&e.forks?.length?/* @__PURE__ */ (0,Y.jsx)(`span`,{children:`·`}):null,e.forks?.length?/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-1.5`,children:[`Forks:`,e.forks.map((e,t)=>/* @__PURE__ */ (0,Y.jsx)(V,{"aria-label":`Fork ${t+1}`,className:yE,to:kc(e),children:t+1},e))]}):null]})}function xE(e){let t=e.hasChildren?`Also archive its child conversations?`:`Archive for everyone?`;return/* @__PURE__ */ (0,Y.jsx)(Px,{open:!0,onOpenChange:t=>{t||e.onClose()},children:/* @__PURE__ */ (0,Y.jsxs)(Fx,{children:[/* @__PURE__ */ (0,Y.jsx)(Ix,{children:t}),/* @__PURE__ */ (0,Y.jsxs)(Lx,{children:[`This hides the conversation`,e.hasChildren?` and its child conversations`:``,` for everyone. A new message from a person restores it.`]}),/* @__PURE__ */ (0,Y.jsxs)(Rx,{children:[/* @__PURE__ */ (0,Y.jsx)(Bx,{children:`Cancel`}),/* @__PURE__ */ (0,Y.jsx)(zx,{onClick:e.onConfirm,children:`Archive`})]})]})})}const SE={base:6,active:14,max:24},CE=(0,J.createContext)(void 0);function wE(){let e=(0,J.useContext)(CE);if(!e)throw Error(`useMessageOutline must be used within MessageOutline.`);return e}function TE({activeIndex:e,children:t,className:n,itemCount:r,...i}){let a=(0,J.useRef)(null),o=(0,J.useRef)([]),s=(0,J.useRef)(void 0),[c,l]=(0,J.useState)(),u=(0,J.useMemo)(()=>({activeIndex:e,listRef:a,movePointer:t=>{let n=s.current;s.current=t;let i=[n,t].filter(e=>e!==void 0);if(i.length===0)return;let a=Math.max(0,Math.floor(Math.min(...i)-4)),c=Math.min(r-1,Math.ceil(Math.max(...i)+4));for(let n=a;n<=c;n+=1){let r=o.current[n];r&&(r.style.transform=ME(jE(n,t,n===e)))}l(t===void 0?void 0:Math.min(r-1,Math.max(0,Math.round(t))))},pointerRef:s,previewIndex:c,registerBar:(e,t)=>{o.current[e]=t}}),[e,r,c]);return/* @__PURE__ */ (0,Y.jsx)(CE.Provider,{value:u,children:/* @__PURE__ */ (0,Y.jsx)(`nav`,{"data-slot":`message-outline`,className:F(`pointer-events-none flex items-center`,n),...i,children:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`relative flex max-h-full flex-col`,children:t})})})}function EE({className:e,...t}){let{activeIndex:n,listRef:r,movePointer:i,previewIndex:a}=wE();(0,J.useEffect)(()=>{let e=r.current;if(!e||n<0||a!==void 0)return;let t=n*8;t<e.scrollTop?e.scrollTop=t:t+8>e.scrollTop+e.clientHeight&&(e.scrollTop=t+8-e.clientHeight)},[n,r,a]);let o=(0,J.useRef)(void 0),s=(e,t)=>{o.current=t;let n=t-e.getBoundingClientRect().top+e.scrollTop;i(n/8-.5)};return/* @__PURE__ */ (0,Y.jsx)(`ol`,{"data-slot":`message-outline-list`,className:F(`pointer-events-auto m-0 min-h-0 list-none overflow-y-auto overscroll-contain p-0 pr-2 [scrollbar-width:none]`,e),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||i(void 0)},onFocus:e=>{e.target.matches(`:focus-visible`)&&(o.current=void 0)},onPointerLeave:()=>{o.current=void 0,i(void 0)},onPointerMove:e=>{e.pointerType!==`touch`&&s(e.currentTarget,e.clientY)},onScroll:e=>{o.current!==void 0&&s(e.currentTarget,o.current)},ref:r,...t})}function DE({className:e,index:t,...n}){let{activeIndex:r,movePointer:i,pointerRef:a,previewIndex:o,registerBar:s}=wE(),c=t===r;return/* @__PURE__ */ (0,Y.jsx)(`li`,{"data-slot":`message-outline-item`,children:/* @__PURE__ */ (0,Y.jsx)(`button`,{"aria-current":c?`location`:void 0,"data-highlighted":!c&&t===o?``:void 0,className:F(`group/message-outline-item flex h-2 w-6 cursor-pointer items-center border-0 bg-transparent p-0 focus-visible:outline focus-visible:outline-1 focus-visible:outline-dashboard-focus/55`,e),onFocus:()=>i(t),type:`button`,...n,children:/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`message-outline-bar`,className:F(`block h-0.5 origin-left rounded-full bg-dashboard-border-emphasis transition-[transform,background-color] duration-150 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-[background-color] group-data-highlighted/message-outline-item:bg-dashboard-border-heavy`,c&&`bg-dashboard-text-faint`),ref:e=>s(t,e),style:{transform:ME(jE(t,a.current,c)),width:SE.max}})})})}function OE({className:e,...t}){let{listRef:n,previewIndex:r}=wE();if(r===void 0)return null;let i=n.current,a=r*8+4-(i?.scrollTop??0),o=i?.offsetParent,s=`calc(${a}px - 50%)`;if(o instanceof HTMLElement&&o.parentElement){let e=-o.offsetTop,t=e+o.parentElement.clientHeight;s=`clamp(${e}px, ${s}, calc(${t}px - 100%))`}return/* @__PURE__ */ (0,Y.jsx)(`div`,{"aria-hidden":`true`,"data-slot":`message-outline-preview`,className:F(`pointer-events-none absolute top-0 left-full ml-2 grid w-72 origin-left gap-1.5 rounded-xl border border-dashboard-border-emphasis bg-dashboard-surface-raised px-3.5 py-3 shadow-[0_8px_24px_rgba(0,0,0,0.12)] transition-[translate,scale,opacity] duration-150 ease-[cubic-bezier(0.22,1,0.36,1)] starting:scale-[0.97] starting:opacity-0 motion-reduce:transition-[opacity] motion-reduce:starting:scale-100`,e),style:{translate:`0 ${s}`},...t})}function kE({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`p`,{"data-slot":`message-outline-preview-title`,className:F(`m-0 truncate text-sm font-medium text-dashboard-text`,`only:min-h-[calc(var(--text-sm)*(var(--text-sm--line-height)+3*var(--leading-relaxed))+--spacing(1.5))] only:line-clamp-4 only:leading-relaxed only:whitespace-normal`,e),...t})}function AE({className:e,...t}){return/* @__PURE__ */ (0,Y.jsx)(`p`,{"data-slot":`message-outline-preview-description`,className:F(`m-0 line-clamp-3 text-sm leading-relaxed text-dashboard-text-faint`,e),...t})}function jE(e,t,n){let r=t===void 0?1/0:Math.abs(e-t),i=r<4?(1+Math.cos(Math.PI*r/4))/2:0,a=SE.base+(SE.max-SE.base)*i;return n?Math.max(SE.active,a):a}function ME(e){return`scaleX(${e/SE.max})`}function NE(e){let t=[];for(let n of e){if(n.pending)continue;let e=AT(FE(n),n.mentions);e&&(n.role===`user`&&!n.eventType&&!n.context?t.push({seq:n.sourceSeq,title:e}):n.role===`assistant`&&t.length>0&&(t.at(-1).reply=e))}return t}function PE(e,t){if(!e?.items.length)return[...t];let n=/* @__PURE__ */ new Map;for(let t of e.items){let e=AT(t.text,t.mentions);e&&n.set(t.seq,{seq:t.seq,title:e})}for(let e of t)n.set(e.seq,e);return[...n.values()].sort((e,t)=>e.seq-t.seq)}function FE(e){return e.parts.map(e=>e.type===`text`?e.text??``:``).join(`
|
|
155
|
-
`)}function IE(e,t){let n;for(let r of e){if(r.seq>t)break;n=r}return n}const LE=[];function RE(e){let{scrollRef:t}=e,n=(0,J.useDeferredValue)(e.events,LE),r=zE(e.conversationId).data,i=(0,J.useMemo)(()=>PE(r,NE(xa(n,void 0))),[n,r]),a=VE(i,t),[o,s]=(0,J.useState)();return(0,J.useEffect)(()=>{if(o===void 0)return;let e=t.current,n=e?.querySelector(`[data-transcript-seq="${o}"]`);e&&n&&(s(void 0),e.scrollTop+=n.getBoundingClientRect().top-e.getBoundingClientRect().top-12)},[n,o,t]),i.length<2?null:/* @__PURE__ */ (0,Y.jsxs)(TE,{activeIndex:i.findIndex(e=>e.seq===a),"aria-label":`Conversation outline`,className:`absolute inset-y-8 left-3 z-20 hidden @min-[62rem]/chat:flex`,itemCount:i.length,children:[/* @__PURE__ */ (0,Y.jsx)(EE,{children:i.map((t,n)=>/* @__PURE__ */ (0,Y.jsx)(DE,{"aria-label":t.title,index:n,onClick:()=>{e.onSelect(t.seq),s(t.seq)}},t.seq))}),/* @__PURE__ */ (0,Y.jsx)(BE,{items:i})]})}function zE(e){return L({gcTime:0,queryFn:({signal:t})=>G(ui,`/api/conversations/${encodeURIComponent(e)}/outline`,t),queryKey:[`conversation`,e,`outline`],retry:!1,staleTime:1/0})}function BE(e){let{previewIndex:t}=wE(),n=t===void 0?void 0:e.items[t];return n?/* @__PURE__ */ (0,Y.jsxs)(OE,{children:[/* @__PURE__ */ (0,Y.jsx)(kE,{children:n.title}),n.reply?/* @__PURE__ */ (0,Y.jsx)(AE,{children:n.reply}):null]}):null}function VE(e,t){let[n,r]=(0,J.useState)(),i=(0,J.useCallback)(()=>{let n=t.current;if(!n)return;let i=n.getBoundingClientRect().top+12,a,o=1/0;for(let e of n.querySelectorAll(`[data-transcript-seq]`)){let t=e.getBoundingClientRect();t.bottom<=i||t.top>=o||(o=t.top,a=Number(e.dataset.transcriptSeq))}r(a===void 0?void 0:IE(e,a)?.seq)},[e,t]);return(0,J.useEffect)(()=>{let e=t.current;if(!e)return;let n=0,r=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(i)};return r(),e.addEventListener(`scroll`,r,{passive:!0}),()=>{cancelAnimationFrame(n),e.removeEventListener(`scroll`,r)}},[t,i]),n}const HE=new Intl.Segmenter(void 0,{granularity:`word`});function UE(e){if(e.length<6)return!1;let t=0;for(let n of HE.segment(e))if(n.isWordLike&&(t+=1),t>=2)return!0;return!1}function WE(e){return e.split(`
|
|
156
|
-
`).map(e=>e.trim()?`> ${e.trimEnd()}`:`>`).join(`
|
|
157
|
-
`)}const GE=/* @__PURE__ */ new Set([`A`,`B`,`CODE`,`DEL`,`EM`,`I`,`OL`,`S`,`STRONG`,`TABLE`,`TBODY`,`THEAD`,`TR`,`UL`]);function KE(e){let t=e.commonAncestorContainer,n=t instanceof Element?t:t.parentElement,r=n?.closest(`pre`)??n?.closest(`[data-code-language]`)?.querySelector(`pre`);if(r)return $E(r,qE(e,r));let i=e.cloneContents();for(;n&&GE.has(n.tagName);){let e=n.cloneNode(!1);e.appendChild(i),i=e,n=n.parentElement}return JE(i).replace(/\n{3,}/g,`
|
|
158
|
-
|
|
159
|
-
`).trim()}function qE(e,t){let n=e.cloneRange();return t.contains(n.startContainer)||n.setStart(t,0),t.contains(n.endContainer)||n.setEnd(t,t.childNodes.length),n.toString()}function JE(e){if(e.nodeType===Node.TEXT_NODE)return XE(e);if(!(e instanceof Element))return YE(e);if(e.matches(`button, svg, [aria-hidden='true']`))return``;let t=e.tagName;switch(t){case`BR`:return`
|
|
160
|
-
`;case`B`:case`STRONG`:return QE(`**`,YE(e));case`EM`:case`I`:return QE(`_`,YE(e));case`DEL`:case`S`:return QE(`~~`,YE(e));case`CODE`:return QE("`",e.textContent??``);case`A`:{let t=YE(e),n=e.getAttribute(`href`)??``;return/^https?:/i.test(n)&&t.trim()!==n?`[${t}](${n})`:t}case`INPUT`:return!(e instanceof HTMLInputElement)||e.type!==`checkbox`?``:e.checked?`[x] `:`[ ] `;case`PRE`:return ZE($E(e,e.textContent??``));case`H1`:case`H2`:case`H3`:case`H4`:case`H5`:case`H6`:return ZE(`${`#`.repeat(Number(t[1]))} ${YE(e)}`);case`BLOCKQUOTE`:return ZE(WE(YE(e).trim()));case`OL`:case`UL`:return ZE(eD(e));case`TABLE`:return ZE(tD(e));case`HR`:return ZE(`---`);case`DIV`:case`LI`:case`P`:return ZE(YE(e));default:return YE(e)}}function YE(e){return Array.from(e.childNodes,JE).join(``)}function XE(e){let t=e.textContent??``;if(!t.trim()&&t.includes(`
|
|
161
|
-
`))return``;let n=t.replace(/\s+/g,` `);return e.previousSibling?.nodeName===`BR`&&(n=n.trimStart()),e.nextSibling?.nodeName===`BR`&&(n=n.trimEnd()),n}function ZE(e){return`\n\n${e.trim()}\n\n`}function QE(e,t){let[,n=``,r=``,i=``]=/^(\s*)([\s\S]*?)(\s*)$/.exec(t)??[];return r?`${n}${e}${r}${e}${i}`:t}function $E(e,t){return`\`\`\`${e.closest(`[data-code-language]`)?.dataset.codeLanguage??``}\n${t.replace(/\n$/,``)}\n\`\`\``}function eD(e){let t=Number(e.getAttribute(`start`)??1);return Array.from(e.children).filter(e=>e.tagName===`LI`).map(n=>{let r=e.tagName===`OL`?`${t++}. `:`- `;return r+YE(n).trim().replace(/\n{2,}/g,`
|
|
162
|
-
`).replace(/\n/g,`\n${` `.repeat(r.length)}`)}).join(`
|
|
163
|
-
`)}function tD(e){let t=Array.from(e.querySelectorAll(`tr`),e=>Array.from(e.children,e=>YE(e).trim().replace(/\s*\n\s*/g,` `).replace(/(\\*)\|/g,`$1$1\\|`))),n=Math.max(0,...t.map(e=>e.length));if(!n)return``;let r=e=>`| ${Array.from({length:n},(t,n)=>e[n]??``).join(` | `)} |`,i=Array.from(e.querySelector(`tr`)?.children??[]),a=Array.from({length:n},(e,t)=>{let n=i[t];return n?.classList.contains(`text-center`)?`:---:`:n?.classList.contains(`text-right`)?`---:`:`---`}),[o=[],...s]=t;return[r(o),r(a),...s.map(r)].join(`
|
|
164
|
-
`)}const nD=`quick-question`,rD=[`Explain this`,`Is this right?`,`What's the risk?`];function iD(e){typeof CSS<`u`&&`highlights`in CSS&&(e?CSS.highlights.set(nD,new Highlight(e)):CSS.highlights.delete(nD))}function aD(e){let t=window.getSelection();if(!e||!t||t.isCollapsed||!t.rangeCount)return;let n=t.toString().trim().slice(0,4e3).trim();if(!UE(n))return;let r=t.getRangeAt(0),i=r.commonAncestorContainer,a=(i instanceof Element?i:i.parentElement)?.closest(`[data-quick-question-message-id]`),o=a?.dataset.quickQuestionMessageId;if(a&&o&&e.contains(a))return{messageId:o,quote:n,range:r.cloneRange()}}function oD(e,t){return e.compareBoundaryPoints(Range.START_TO_START,t)===0&&e.compareBoundaryPoints(Range.END_TO_END,t)===0}function sD(e){let{rootRef:t,onAsk:n,onRespond:r}=e,[i,a]=(0,J.useState)(),o=(0,J.useRef)(void 0),s=(0,J.useRef)(!1),c=(0,J.useCallback)(e=>{o.current=e,a(e)},[]);(0,J.useEffect)(()=>{let e,n=!1,r=!1,i=()=>{if(s.current)return;window.clearTimeout(e);let r=aD(t.current);c(r&&{rect:r.range.getBoundingClientRect(),selection:r,touch:n})},a=()=>{s.current||(c(void 0),window.clearTimeout(e),r||(e=window.setTimeout(i,300)))},l=()=>{if(s.current)return;let n=aD(t.current);n?o.current&&oD(o.current.selection.range,n.range)||a():(window.clearTimeout(e),c(void 0))},u=e=>{n=e.pointerType!==`mouse`,r=e.pointerType===`mouse`,s.current=!1},d=()=>{r=!1};return document.addEventListener(`pointerdown`,u,!0),document.addEventListener(`pointerup`,d,!0),document.addEventListener(`pointercancel`,d,!0),document.addEventListener(`mouseup`,i),document.addEventListener(`keyup`,i),document.addEventListener(`selectionchange`,l),document.addEventListener(`scroll`,a,!0),()=>{window.clearTimeout(e),document.removeEventListener(`pointerdown`,u,!0),document.removeEventListener(`pointerup`,d,!0),document.removeEventListener(`pointercancel`,d,!0),document.removeEventListener(`mouseup`,i),document.removeEventListener(`keyup`,i),document.removeEventListener(`selectionchange`,l),document.removeEventListener(`scroll`,a,!0)}},[c,t]);let l=(0,J.useRef)(null);if((0,J.useLayoutEffect)(()=>{let e=l.current;if(!e)return;e.style.marginLeft=`0px`;let{left:t,right:n}=e.getBoundingClientRect(),r=Math.max(8-t,Math.min(0,window.innerWidth-8-n));e.style.marginLeft=`${r}px`},[i]),!i)return null;let u=e=>{s.current=!1,c(void 0),window.getSelection()?.removeAllRanges(),e(i.selection)},{rect:d}=i,f=i.touch||d.top<56;return(0,ou.createPortal)(/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:K(`fixed z-50 flex -translate-x-1/2 gap-1 rounded-lg border border-dashboard-border-emphasis bg-dashboard-surface-raised p-1 shadow-lg`,!f&&`-translate-y-full`),onMouseDown:e=>e.preventDefault(),onPointerDown:()=>{s.current=!0},ref:l,style:{left:d.left+d.width/2,top:f?Math.min(d.bottom+(i.touch?24:8),window.innerHeight-56):d.top-8},children:[/* @__PURE__ */ (0,Y.jsx)(H,{className:`h-8 text-dashboard-text`,onClick:()=>u(n),variant:`quiet`,children:`Quick question`}),r?/* @__PURE__ */ (0,Y.jsx)(H,{className:`h-8 text-dashboard-text`,onClick:()=>u(({range:e})=>r(WE(KE(e)))),variant:`quiet`,children:`Respond`}):null]}),document.body)}function cD(){let e=P();return N({mutationFn:async e=>{let t=e.forkId??(await Qi(qr,`/api/conversations/${encodeURIComponent(e.sourceConversationId)}/forks`,{idempotencyKey:e.threadKey,messageId:e.messageId,quickQuestion:{quote:e.quote}})).conversationId;return Qi(ii,`/api/conversations/${encodeURIComponent(t)}/messages`,{idempotencyKey:e.idempotencyKey,message:e.text})},onSuccess:t=>e.invalidateQueries({queryKey:X(t.conversationId)})})}function lD(){let e=P();return N({mutationFn:e=>Qi(qr,`/api/conversations/${encodeURIComponent(e)}/quick-question/keep`,{}),onSuccess:()=>e.invalidateQueries({queryKey:[`dashboard`,`conversations`]})})}function uD(e){let[t,n]=(0,J.useState)(),r=t?.conversationId===e?t:void 0,i=cD(),{mutateAsync:a,reset:o}=i,s=(0,J.useCallback)(t=>{o(),iD(t.range),n({...t,asked:[],conversationId:e,id:crypto.randomUUID()})},[e,o]),c=(0,J.useCallback)(()=>{o(),iD(void 0),n(void 0)},[o]);(0,J.useEffect)(()=>()=>{iD(void 0),n(void 0)},[e]);let l=(0,J.useCallback)(async(t,i)=>{if(!r)return;let o=await a({forkId:r.forkId,idempotencyKey:i,messageId:r.messageId,quote:r.quote,sourceConversationId:e,text:t,threadKey:r.id});n(e=>e?.id===r.id?{...e,asked:[...e.asked,t],askedAtMs:Date.now(),forkId:o.conversationId}:e)},[e,a,r]);return{close:c,error:i.error,open:s,pending:i.isPending,submit:l,thread:r}}function dD(e,t){let n=(e?.events??[]).flatMap(({data:e})=>e.type===`message`&&(e.role===`user`||e.role===`assistant`)&&e.text?[{id:e.messageId,role:e.role,text:e.text}]:[]),r=n.findIndex(e=>e.id===t);return n.slice(r+1)}function fD(e){let{thread:t}=e,n=(0,J.useRef)(null),r=(0,J.useRef)(null),i=Go().data?.me.user,a=i?.name?.trim()||i?.email||`You`,o=pa(),s=L(od(t.forkId,{fastPollUntilMs:t.askedAtMs&&t.askedAtMs+1e4})).data,c=dD(s,t.messageId),l=t.asked.slice(c.filter(e=>e.role===`user`).length).map(e=>({role:`user`,text:e})),u=[...c,...l],d=e.pending||l.length>0||s?.status===`active`&&u.at(-1)?.role===`user`;return(0,J.useEffect)(()=>{r.current?.querySelector(`textarea`)?.focus()},[t.id]),(0,J.useEffect)(()=>{let e=n.current;e&&(e.scrollTop=e.scrollHeight)},[u.length,d]),/* @__PURE__ */ (0,Y.jsx)(Iy,{label:`Quick question`,sheetTitle:`Quick question`,onClose:e.onClose,title:/* @__PURE__ */ (0,Y.jsx)(`h2`,{className:`m-0 font-sans text-sm font-semibold text-dashboard-text`,children:`Quick question`}),children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid h-full min-h-0 grid-rows-[minmax(0,1fr)_auto]`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid content-start grid-cols-[minmax(0,1fr)] gap-5 overflow-y-auto px-4 py-4`,ref:n,children:[/* @__PURE__ */ (0,Y.jsx)(`blockquote`,{className:`m-0 border-l-2 border-dashboard-accent pl-2.5 text-sm text-dashboard-text-muted`,children:/* @__PURE__ */ (0,Y.jsx)(ab,{className:`leading-relaxed break-words whitespace-pre-wrap`,label:`quote`,lines:5,children:t.quote.replace(/\n\s*\n/g,`
|
|
165
|
-
`)},t.id)}),u.length===0&&!e.pending?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:rD.map(t=>/* @__PURE__ */ (0,Y.jsx)(H,{className:`h-7 rounded-full px-2.5 text-xs`,onClick:()=>void e.onSubmit(t,crypto.randomUUID()).catch(()=>{}),children:t},t))}):u.map((e,t)=>/* @__PURE__ */ (0,Y.jsxs)(HS,{actor:e.role===`user`?a:o,avatarUrl:e.role===`user`?i?.avatarUrl:void 0,role:e.role,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:e.role===`user`?`text-sm font-semibold text-dashboard-text`:`text-sm font-semibold text-dashboard-accent-text`,children:e.role===`user`?a:o}),/* @__PURE__ */ (0,Y.jsx)($,{chat:!0,text:e.text})]},t)),d?/* @__PURE__ */ (0,Y.jsxs)(HS,{actor:o,role:`assistant`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-sm font-semibold text-dashboard-accent-text`,children:o}),/* @__PURE__ */ (0,Y.jsx)(Fv,{active:!0,className:`text-sm text-dashboard-text-muted`,children:`Thinking…`})]}):null]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid gap-1.5 px-3 pt-2 pb-2`,ref:r,children:[/* @__PURE__ */ (0,Y.jsx)(lv,{compact:!0,disabled:d,draftId:`quick-question:${e.conversationId}`,error:e.error?e.error instanceof ta&&e.error.apiError||`Could not ask. Try again.`:void 0,label:`Quick question`,onSubmit:e.onSubmit,placeholder:u.length?`Ask a follow-up…`:`Ask a quick question…`,holdDraftUntilAccept:!0,submitLabel:`Ask`},t.id),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2 pl-1 text-xs text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:`Closing discards this question.`}),/* @__PURE__ */ (0,Y.jsx)(pD,{disabled:d,forkId:t.forkId},t.id)]})]})]})})}function pD(e){let t=ge(),n=lD(),r=e.forkId;return/* @__PURE__ */ (0,Y.jsxs)(H,{className:`h-7 shrink-0 px-2 text-xs whitespace-nowrap`,disabled:!r||e.disabled||n.isPending,onClick:()=>r&&n.mutate(r,{onSuccess:()=>t(kc(r))}),variant:`quiet`,children:[/* @__PURE__ */ (0,Y.jsx)(sr,{"aria-hidden":`true`,size:13}),n.isError?`Retry keep`:`Keep as fork`]})}function mD(){return/* @__PURE__ */ (0,Y.jsxs)(Rb,{"aria-busy":`true`,"aria-live":`polite`,role:`status`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`sr-only`,children:`Loading conversation transcript`}),/* @__PURE__ */ (0,Y.jsx)(hD,{width:`w-3/4`}),/* @__PURE__ */ (0,Y.jsx)(Hb,{indent:!0,children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid gap-2 py-1`,children:[/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-3 w-36 opacity-70`}),/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-3 w-1/2`})]})}),/* @__PURE__ */ (0,Y.jsx)(hD,{width:`w-1/2`}),/* @__PURE__ */ (0,Y.jsx)(hD,{width:`w-2/3`})]})}function hD(e){return/* @__PURE__ */ (0,Y.jsx)(Hb,{children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:K(`grid`,Ib),children:[/* @__PURE__ */ (0,Y.jsx)(q,{className:K(`rounded-full`,Lb)}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid gap-2 pt-1`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`flex h-6 items-center`,children:/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-3 w-24 opacity-70`})}),/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-4 max-w-xl ${e.width}`}),/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-4 w-1/2 max-w-lg`})]})]})})}function gD(e){let{conversationId:t,detail:n,onShowLatest:r,onStartFailed:i,start:a}=e,o=a?Object.entries(a)[0]?.join(`:`):void 0,s=(0,J.useRef)([]),c=(0,J.useMemo)(()=>{let e=_D(s.current,n?.events);return s.current=e,e},[n?.events]),l=c[0]?.seq,u=(0,J.useRef)(void 0),d=O({enabled:!!a,staleTime:1/0,gcTime:0,queryKey:[`conversation`,t,`around`,o,`newer`],queryFn:({pageParam:e,signal:n})=>yD(t,e,n),initialPageParam:a??{around:``},...e.startPage&&a?{initialData:{pageParams:[a],pages:[e.startPage]}}:void 0,getNextPageParam:e=>vD(e,l)||!e.nextCursor?void 0:{after:e.nextCursor},retry:!1}),f=d.data?.pages[0],p=O({enabled:!1,queryKey:[`conversation`,t,`around`,o,`earlier`],queryFn:({pageParam:e,signal:n})=>yd(t,e,n),initialPageParam:f?.previousCursor??``,getNextPageParam:e=>e.previousCursor,retry:!1}),m=d.data?.pages,h=p.data?.pages,g=m?.at(-1),_=g?vD(g,l):!1;_&&(u.current=o);let v=g!==void 0&&!_&&(u.current===o||!g.nextCursor);(0,J.useEffect)(()=>{v&&r()},[r,v]);let y=!!(a&&d.error&&!m);(0,J.useEffect)(()=>{y&&i?.()},[i,y]);let b=(0,J.useMemo)(()=>[...h??[],...m??[]],[h,m]),x=(0,J.useMemo)(()=>n&&m?Iu(n,b,_?c:[]):void 0,[n,c,m,b,_]);if(!a||v||y)return;let S=p.data?p.hasNextPage:!!f?.previousCursor;return{data:x,hasPreviousPage:S,historyError:p.error,historyVersion:Ru(b),isLoadingPreviousPage:p.isFetchingNextPage,isPending:!m,loadPreviousPage:()=>{S&&p.fetchNextPage({cancelRefetch:!1})},..._?void 0:{newer:{error:d.error,load:()=>{d.hasNextPage&&d.fetchNextPage({cancelRefetch:!1})},loading:d.isFetchingNextPage,showLatest:r}}}}function _D(e,t){let n=t?.[0]?.seq,r=e.at(-1)?.seq;if(!t||n===void 0)return e;if(r===void 0||n>r+1)return t;let i=e.filter(e=>e.seq<n);return i.length?[...i,...t]:t}function vD(e,t){let n=e.events.at(-1)?.seq;return n===void 0||t===void 0?!e.nextCursor:n+1>=t}function yD(e,t,n){let r=new URLSearchParams(t);return G(Gr,`/api/conversations/${encodeURIComponent(e)}/events?${r}`,n).then(e=>{if(`after`in t&&e.nextCursor===t.after)throw Error(`Conversation history cursor did not advance`);return e})}function bD(e,t){let n=`event`in t?t.event:Bc(e,t.turn);if(!(n!==void 0&&e!==void 0&&n>=(e[0]?.seq??1/0)&&n<=(e.at(-1)?.seq??-1/0)))return`event`in t?{event:String(t.event)}:{turn:t.turn}}function xD(e){return e.target?/* @__PURE__ */ (0,Y.jsx)(SD,{onClose:e.onClose,target:e.target},e.target.conversationId):null}function SD(e){let t=hd(e.target.conversationId),[n,r]=(0,J.useState)(`rich`),[i,a]=(0,J.useState)(``),o=ch(i),[s,c]=(0,J.useState)(!1),l=t.data,u=e.target.label??Va(l)??(l?.kind===`thread`?`Thread`:`Task`),d=CD(e.target.status,l?.status),f=e.target.agentName&&e.target.agentName!==u?e.target.agentName:void 0,p=l?Date.parse(l.startedAt):void 0,m=n===`rich`&&(s||i.length>0),h=(0,J.useRef)(null);(0,J.useEffect)(()=>{m&&h.current?.focus()},[m]);let g=()=>{c(!1),i.length>0&&a(``)},_=`subagent-transcript-drawer-title`;return/* @__PURE__ */ (0,Y.jsx)(m_,{actions:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[n===`rich`?/* @__PURE__ */ (0,Y.jsx)(Cv,{inputRef:h,onClick:()=>{m?g():c(!0)},open:m}):null,/* @__PURE__ */ (0,Y.jsx)(bv,{onChange:r,value:n}),/* @__PURE__ */ (0,Y.jsx)(Yf,{label:`Copy as Markdown`,copyingLabel:`Preparing Markdown`,getText:l?async()=>wf(await t.loadCompleteTranscript()):void 0},e.target.conversationId)]}),closeLabel:`Close transcript`,flush:n===`raw`,header:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[/* @__PURE__ */ (0,Y.jsx)(mn,{"aria-hidden":`true`,className:`shrink-0 text-cyan-300`,size:16,strokeWidth:2}),/* @__PURE__ */ (0,Y.jsx)(`h2`,{className:`m-0 min-w-0 break-words font-display text-lg font-medium leading-tight tracking-tight text-dashboard-text`,id:_,children:u})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`mt-1.5 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs leading-5 text-dashboard-text-muted`,children:[f?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-medium text-dashboard-text`,children:f}):null,d?/* @__PURE__ */ (0,Y.jsx)(gp,{size:`compact`,tone:vb(d),children:d}):null,l&&p!==void 0?/* @__PURE__ */ (0,Y.jsxs)(`time`,{className:`tabular-nums`,dateTime:l.startedAt,title:Ba(p,!0),children:[`Started `,$a(p)]}):null,/* @__PURE__ */ (0,Y.jsxs)(V,{className:`inline-flex w-fit items-center gap-1 font-medium text-dashboard-accent-text no-underline hover:underline`,onClick:e.onClose,to:kc(e.target.conversationId),children:[`Open conversation`,/* @__PURE__ */ (0,Y.jsx)(Fn,{"aria-hidden":`true`,size:12,strokeWidth:2})]})]}),/* @__PURE__ */ (0,Y.jsx)(`code`,{className:`mt-1 block min-w-0 break-all font-mono text-xs text-dashboard-text-faint`,children:e.target.conversationId}),m?/* @__PURE__ */ (0,Y.jsx)(Nv,{className:`inset-x-4 md:left-auto md:right-5 md:w-80`,inputRef:h,match:o,onChange:a,onClose:g,value:i}):null]}),onClose:e.onClose,openKey:e.target.conversationId,titleId:_,width:`wide`,children:t.isPending?/* @__PURE__ */ (0,Y.jsx)(mD,{}):t.error&&!l?/* @__PURE__ */ (0,Y.jsxs)(_s,{className:`gap-1 px-4 py-3 has-[>svg]:gap-x-3`,variant:`destructive`,children:[/* @__PURE__ */ (0,Y.jsx)(Gn,{"aria-hidden":`true`}),/* @__PURE__ */ (0,Y.jsx)(vs,{className:`font-display text-base font-semibold leading-tight`,children:`Conversation failed to load.`}),/* @__PURE__ */ (0,Y.jsx)(ys,{className:`leading-relaxed`,children:`Junior could not get this child conversation. Use Open conversation to view it on its own page.`})]}):l?/* @__PURE__ */ (0,Y.jsx)(Rw,{hasPreviousPage:t.hasPreviousPage,historyError:t.historyError,historyVersion:t.historyVersion,loadingPreviousPage:t.isLoadingPreviousPage,onLoadPreviousPage:t.loadPreviousPage,search:i,onSearchChange:a,searchMatch:o.index,onSearchMatches:o.setMatches,transcript:l,view:n}):/* @__PURE__ */ (0,Y.jsx)(xm,{children:`Conversation unavailable.`})})}function CD(e,t){return e&&e!==`running`&&e!==`completed`?e:t??e}function wD(e){let t=$y(),n=(0,J.useRef)(null),r=(0,J.useRef)(null),i=(0,J.useRef)(null),a=(0,J.useRef)(!1),[o,s]=(0,J.useState)(),[c,l]=Ee(),u=Ic(c.get(Fc)),d=c.get(`turn`)??void 0,f=u!==void 0||d!==void 0,[p,m]=(0,J.useState)(()=>!f&&void 0),h=c.get(Lc)===Rc;(0,J.useEffect)(()=>{h&&m(!0)},[h]);let g=Fy(),[_]=(0,J.useState)(Wy),v=p??(h||(_===void 0?t:_&&g)),y=(0,J.useCallback)(()=>{m(!1),Gy(!1),l(e=>{if(!e.has(`review`))return e;let t=new URLSearchParams(e);return t.delete(Lc),t},{replace:!0})},[l]),[b,x]=(0,J.useState)(),[S,C]=(0,J.useState)(),[w,T]=(0,J.useState)(),[E,D]=(0,J.useState)(),[O,k]=(0,J.useState)(),[A,j]=(0,J.useState)(e.conversationId);A!==e.conversationId&&(j(e.conversationId),C(void 0),T(void 0),D(void 0),k(void 0));let M=uD(e.conversationId),ee=!!M.thread&&!f&&!b,N=v&&!f&&!b&&!M.thread;(0,J.useLayoutEffect)(()=>{N&&a.current&&(a.current=!1,n.current?.querySelector(`[data-slot="details-panel-close"]`)?.focus({preventScroll:!0}))},[N]);let P=be(),te=Nc(P.state),[F,ne]=(0,J.useState)(()=>f||te?`raw`:`rich`),[re,ie]=(0,J.useState)(P.key);te&&re!==P.key&&(ie(P.key),ne(`raw`));let I=f?`raw`:F,[L,ae]=(0,J.useState)(``),oe=ch(L),[se,ce]=(0,J.useState)(!1),[le,ue]=(0,J.useState)(0),R=e.conversationId,de=e.data?.conversations.conversations??[],fe=Ya(de),pe=hu().has(R),[me]=(0,J.useState)(()=>$p()===`unread`),[he,_e]=(0,J.useState)(()=>u!==void 0||d!==void 0),z=e.detail,[ve,ye]=(0,J.useState)(!1),B=me&&!ve&&!he,[V,xe]=(0,J.useState)(()=>d===void 0?u===void 0?void 0:bD(z.data?.events,{event:u}):bD(z.data?.events,{turn:d})),Se=(0,J.useCallback)(()=>{ye(!0),xe(void 0)},[]),Ce=tx(R).data,we=(0,J.useMemo)(()=>({list:Ce,open:S,setOpen:C}),[Ce,S]),Te=jd(R),[De,Oe]=(0,J.useState)(!1),ke=ge(),Ae=e=>{Te.mutate({archived:e,lastSeenAt:Qe.lastSeenAt}),e&&ke(`/`,{state:{archivedConversation:Qe}})},je=Vd(R),Me=$d(R),Ne=Qd(R),Pe=Bd(R),Fe=Hd(R),[Ie,Le]=(0,J.useState)(!1),Re=rm(R),[ze,Be]=(0,J.useState)(!1),Ve=(0,J.useCallback)(()=>Be(!0),[]),He=em(z.data,z.fetchedDetail),Ue=(0,J.useCallback)(()=>{xe(void 0),_e(!1),T(void 0),l(e=>{let t=new URLSearchParams(e);return t.delete(Fc),t.delete(zc),t},{replace:!0})},[l]),We=B?He.unreadCursor:void 0,Ge=gD({conversationId:R,detail:z.latest,onShowLatest:Se,...V?{onStartFailed:Ue,start:V}:We?{start:{around:We},...He.unreadPage?{startPage:He.unreadPage}:void 0}:void 0}),Ke=(0,J.useRef)(z.data),qe=!!(Ke.current&&(Ge?.isPending||B&&!V&&!z.fetchedAtOpen)),Je=z.isPending||!(!Ge?.isPending||Ke.current),Ye=qe?{...z,data:Ke.current,hasPreviousPage:!1,isLoadingPreviousPage:!1,loadPreviousPage:()=>{}}:Ge??z;Ye.data&&(Ke.current=Ye.data);let Xe=Ab({conversationId:R,events:Ye.data?.events,hasNewerPage:!!Ye.newer,hasPreviousPage:Ye.hasPreviousPage,unread:qe?void 0:He.unread}),Ze=fe.find(e=>e.id===R),Qe=Pd(qa(z.data)??Ze,e.pendingArchiveUpdate),$e=z.data,et=Fg($e),tt=Va(z.data)??Fa(Qe);fa(z.data||Qe?tt:void 0);let nt=I===`rich`&&(z.data?.isParticipant||z.data?.visibility===`public`)&&z.data.kind!==`task`,[rt,it]=(0,J.useState)(),at=jc(P.state),ot=at&&P.key!==rt?{draftFrom:at.draftFrom,key:P.key}:void 0,st=Ye.data,ct=!Je&&!!st;(0,J.useEffect)(()=>{ct&&Ji()},[R,ct]);let lt=st?.eventHistory.status===`available`?st.events:void 0,ut=e=>{ae(``),D(e);let t=bD(Ye.data?.events,{event:e});t&&xe(t)},dt=st?.eventHistory.status===`expired`?void 0:st?.events.find(e=>e.seq===u),ft=TD(Qe?Sa(Qe):void 0,z.data),pt=(0,J.useCallback)(e=>{ne(`raw`),l(t=>{let n=new URLSearchParams(t);return n.delete(zc),e===void 0?n.delete(Fc):n.set(Fc,String(e)),n},{replace:!0})},[l]),mt=(0,J.useCallback)(e=>{e!==`raw`&&f&&pt(void 0),x(void 0),ne(e)},[f,pt]);oo(I===`raw`?`Back to conversation`:void 0,()=>mt(`rich`));let ht=(0,J.useEffectEvent)(e=>{let t=bD(Ye.data?.events,e);return t&&xe(t),!!t}),gt=(0,J.useCallback)((e,t)=>k(n=>({arrived:t,itemId:e.id,turnId:e.addedByConversationId===R?e.addedByTurnId:void 0,version:(n?.version??0)+1})),[R]),_t=(0,J.useEffectEvent)((e,t)=>{Ye.data?.events.some(t=>t.data.type===`tool_calls`&&t.data.calls.some(t=>rS(t)===e))||ht({turn:t})});(0,J.useEffect)(()=>{O?.turnId&&!O.arrived&&_t(O.itemId,O.turnId)},[O]),(0,J.useEffect)(()=>{d===void 0?u!==void 0&&ht({event:u}):ht({turn:d})},[d,u]);let vt=d?Bc(st?.events,d):void 0;(0,J.useEffect)(()=>{vt!==void 0&&pt(vt)},[vt,pt]),(0,J.useEffect)(()=>{if(!w||!st)return;let e=n.current?.querySelector(`[data-memory-anchor="${CSS.escape(nx(w))}"]`);e?(e.scrollIntoView({block:`center`}),C(w),T(void 0)):!qe&&!ht({event:w.seq})&&T(void 0)},[qe,w,st,I]);let yt=!!dt||f&&!dt&&(Je||qe||d!==void 0),bt=st?.events,xt=L.trim().toLowerCase(),St=(0,J.useMemo)(()=>f&&bt?gw(hw(bt),xt):[],[f,bt,xt]),Ct=(0,J.useMemo)(()=>({openId:b?.id,onToggle:e=>x(t=>t?.id===e.id?void 0:e)}),[b?.id]),wt=(0,J.useCallback)(()=>{Se(),ue(e=>e+1)},[Se]),H=(0,J.useCallback)(({part:e})=>{s({...e.agentName?{agentName:e.agentName}:void 0,conversationId:e.childConversationId,label:e.title??e.agentName,status:e.status})},[]),Tt=()=>{let e=n.current?.querySelector(`[data-event-seq="${u}"] button`);pt(void 0),e?.focus({preventScroll:!0})},Et=()=>{let e=[...n.current?.querySelectorAll(`[data-turn-context-id="${CSS.escape(b?.id??``)}"]`)??[]].find(e=>e.getClientRects().length>0);x(void 0),e?.focus({preventScroll:!0})},Dt=/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[N?/* @__PURE__ */ (0,Y.jsx)(vE,{conversation:Qe,conversationId:R,detail:$e,highlightReview:h,links:et,memoryState:we,onClose:y,onOpenSubagent:s,onSelectMemory:e=>{I!==`rich`&&mt(`rich`),ae(``),D(e.seq),T({memoryId:e.memory.id,seq:e.seq,source:e.source,turnId:e.turnId})}}):null,yt?/* @__PURE__ */ (0,Y.jsx)(Aw,{conversation:st,event:dt,onClose:Tt,onSelect:pt,..._w(St,u)}):null,b?/* @__PURE__ */ (0,Y.jsx)(oh,{query:L,children:/* @__PURE__ */ (0,Y.jsx)(lC,{actor:b.actor,contexts:b.contexts,onClose:Et,timestamp:b.timestamp},b.id)}):null,ee&&M.thread?/* @__PURE__ */ (0,Y.jsx)(fD,{conversationId:R,error:M.error,onClose:M.close,onSubmit:M.submit,pending:M.pending,thread:M.thread}):null]});return/* @__PURE__ */ (0,Y.jsxs)(`div`,{ref:n,className:`grid h-full min-h-0 min-w-0 grid-rows-[minmax(0,1fr)]`,children:[/* @__PURE__ */ (0,Y.jsx)(rb,{side:N||yt||b||ee?Dt:void 0,children:/* @__PURE__ */ (0,Y.jsx)(Dv,{header:/* @__PURE__ */ (0,Y.jsx)(Pv,{agentTree:$e?.agentTree,contextTags:Kg(Qe),cost:ky(Qe,$e,`below`),detailsOpen:N,errors:[Te.error?Te.error instanceof ta&&Te.error.apiError||`Could not update archive state.`:``,je.error?`Could not update pin.`:``,Pe.error?`Could not update read state.`:``,Fe.error?`Could not rename.`:``,Me.error?`Could not update subscription.`:``,Ne.error?`Could not change Slack updates.`:``].filter(Boolean),onDetailsClick:()=>{f&&pt(void 0),x(void 0),M.close(),N?y():(a.current=!0,m(!0),Gy(!0))},forks:z.data?.forkedFromConversationId||z.data?.forks?.length?/* @__PURE__ */ (0,Y.jsx)(bE,{forkedFromConversationId:z.data.forkedFromConversationId,forkedFromTitle:z.data.forkedFromTitle,forks:z.data.forks}):null,linkedWork:et.length?/* @__PURE__ */ (0,Y.jsx)(Sy,{links:et}):null,menu:{actions:{archive:()=>{Qe?.archivedAt?Ae(!1):Qe.parentConversationId?Oe(!0):Ae(!0)},continueInSlack:()=>ce(!0),delivery:e=>Ne.mutate(e),eventLog:()=>mt(I===`raw`?`rich`:`raw`),pin:e=>je.mutate(e),read:e=>Pe.mutate(e),rename:()=>Le(!0),subscription:e=>Me.mutate(e)},conversation:Qe,conversationId:R,detail:$e,eventLogOpen:I===`raw`,getMarkdown:$e?async()=>wf(await z.loadCompleteTranscript(),Qe):void 0,pending:{archive:Te.isPending,delivery:Ne.isPending,pin:je.isPending,read:Pe.isPending,subscription:Me.isPending}},onSearchChange:ae,onViewChange:mt,privacy:/* @__PURE__ */ (0,Y.jsx)(fy,{visibility:Qe?.visibility}),search:L,searchMatch:oe,sidebarToggle:e.sidebarToggle,status:Zu($e)&&Qe?/* @__PURE__ */ (0,Y.jsx)(Sp,{status:vp(Qe,pe)}):null,title:tt,view:I}),overlay:I===`rich`&&!Je&<?/* @__PURE__ */ (0,Y.jsx)(RE,{conversationId:R,events:lt,onSelect:ut,scrollRef:i}):void 0,scrollMinTall:!0,scrollAriaLabel:`Conversation transcript`,scrollRef:i,scrollClassName:I===`raw`?`thin-scrollbar`:Tv,scroll:/* @__PURE__ */ (0,Y.jsx)(Ev,{full:I===`raw`,children:Je?I===`raw`?/* @__PURE__ */ (0,Y.jsx)(Iw,{}):/* @__PURE__ */ (0,Y.jsx)(mD,{}):z.error&&!z.data?/* @__PURE__ */ (0,Y.jsx)(ca,{className:`border-dashboard-border bg-dashboard-fill-soft p-4 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:z.error.message}):/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[z.error?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`mb-3 rounded-lg border border-amber-300/15 bg-amber-300/[0.045] px-3 py-2 font-sans text-xs text-amber-100/65`,children:`Transcript refresh failed. Showing the latest available data.`}):null,/* @__PURE__ */ (0,Y.jsx)(ax,{value:we,children:/* @__PURE__ */ (0,Y.jsx)(jb,{value:Xe,children:/* @__PURE__ */ (0,Y.jsx)(Rw,{hasPreviousPage:Ye.hasPreviousPage,historyError:Ye.historyError,historyVersion:Ye.historyVersion,lastReadSeq:z.data?.readPosition?.lastReadSeq,live:ft,loadingPreviousPage:Ye.isLoadingPreviousPage,newerHistory:Ye.newer,onLoadPreviousPage:Ye.loadPreviousPage,onRead:qe?void 0:Re,readEngaged:ze,onSelectedEventSeqChange:pt,pendingMessages:Ye.newer?void 0:z.inlineMessages,pinRequestVersion:le,revealAsk:O,revealSeq:E,responding:!z.error&&!Ye.newer&&Xu(z.data),onOpenSubagentTranscript:H,search:L,onSearchChange:ae,searchMatch:oe.index,onSearchMatches:oe.setMatches,selectedEventSeq:u,startAtLink:he,startAtUnread:me,transcript:st,turnContextPanel:Ct,unread:qe?void 0:He.unread,view:I})})})]})}),dock:nt?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`contents`,onFocusCapture:Ve,onPointerDownCapture:Ve,children:/* @__PURE__ */ (0,Y.jsx)(GT,{conversationId:R,detail:z,focusRequest:ot,hasNewerPage:!!Ye.newer,live:ft,onFocusRequestDone:it,onPinRequest:wt,onShowQuestion:gt,ref:r})}):void 0})}),De?/* @__PURE__ */ (0,Y.jsx)(xE,{hasChildren:!!z.data?.childAgentTotals?.count,onClose:()=>Oe(!1),onConfirm:()=>{Oe(!1),Ae(!0)}}):null,/* @__PURE__ */ (0,Y.jsx)(sD,{onAsk:e=>{f&&pt(void 0),x(void 0),M.open(e)},onRespond:nt?e=>r.current?.appendText(e):void 0,rootRef:n}),/* @__PURE__ */ (0,Y.jsx)(xD,{onClose:()=>s(void 0),target:o}),Ie?/* @__PURE__ */ (0,Y.jsx)(Zd,{onClose:()=>Le(!1),onSave:e=>Fe.mutate(e),title:tt}):null,se?/* @__PURE__ */ (0,Y.jsx)(nf,{conversationId:R,onClose:()=>ce(!1)}):null]})}function TD(e,t){return t?t.status===`active`:e===`active`}const ED=`conversation-list`;function DD(e){let[t,n]=(0,J.useState)(20),[r,i]=(0,J.useState)(``),[a,o]=Uy(),{showArchiveError:s,showArchived:c}=zd();Ad(c,s);let l=Zy(),u=(0,J.useRef)(null),d=(0,J.useRef)(null),f=(0,J.useId)(),p=Vc(r.trim()),m=l?``:p,h=R(),g=ge(),_=he(),v=h.conversationId,y=!v,b=Jo(m),x=Od(),S=zo(),C=cd(),w=CT(),[T,E]=(0,J.useState)();!y&&T&&E(void 0);let D=P(),O=(0,J.useRef)(null),k=(0,J.useRef)(!1),A=(0,J.useMemo)(()=>kD(Ya(b.data?.conversations??[]),x,!!m),[b.data?.conversations,x,m]),j=()=>{C.reset(),v?(k.current=!0,g(`/`)):O.current?.focus()},M=(0,J.useMemo)(()=>Ov(A),[A]),ee=hu(),N=gu(),te=(0,J.useMemo)(()=>yc(A,vc(A,N)),[A,N]),F=(0,J.useMemo)(()=>te.slice(0,t),[te,t]),ne=te.length-F.length,re=(0,J.useRef)(null);(0,J.useEffect)(()=>{n(20),re.current?.scrollTo({top:0})},[m]);let ie=Hp({edge:`bottom`,enabled:ne>0,historyVersion:String(t),onLoad:()=>n(e=>e+20)}),I=(0,J.useRef)(void 0),L=(0,J.useRef)(v);L.current=v,(0,J.useEffect)(()=>{if(!y)return;let e=new AbortController;return I.current=e.signal,()=>e.abort()},[y]);let ae=(0,J.useRef)(!1);(0,J.useEffect)(()=>{if(!y)return;let e=(ae.current||_===ye.Push)&&!k.current;ae.current=!0,k.current=!1,!(e&&sv())&&O.current?.focus()},[y,_]);let oe=/* @__PURE__ */ (0,Y.jsx)(OD,{composerRef:O,docked:!l,error:C.error?`Message failed to send. Try again.`:void 0,onSubmit:async(e,t,n,r)=>{let i=I.current,a=Kw(t);E({createdAt:(/* @__PURE__ */ new Date()).toISOString(),idempotencyKey:t,images:r,message:e,visibility:n});let o;try{o=await C.mutateAsync({idempotencyKey:t,message:e,images:r,visibility:n})}catch(e){throw(0,ou.flushSync)(()=>E(void 0)),gv(a),e}await am(D,o.conversationId);let s=i?.aborted;s&&L.current!==o.conversationId?hv(o.conversationId,gv(a)):(await g(kc(o.conversationId),{flushSync:!0,replace:s,state:{...Ac,draftFrom:a}}),w())}}),se=/* @__PURE__ */ (0,Y.jsx)(Sv,{controls:f,expanded:a,label:a?`Hide conversation list`:`Show conversation list`,onClick:()=>{let e=u.current;e&&(e.isCollapsed()?e.resize(Ky()):e.collapse())},children:/* @__PURE__ */ (0,Y.jsx)(Qt,{"aria-hidden":`true`,size:15,strokeWidth:2})}),ce=/* @__PURE__ */ (0,Y.jsxs)(`main`,{className:K(`h-full min-h-0 w-full overflow-hidden`,T?`hidden`:`grid`,l?`grid-rows-[auto_minmax(0,1fr)]`:`grid-rows-[minmax(0,1fr)_auto]`),children:[l?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`flex h-13 items-center px-1`,children:se}):/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`min-h-0 overflow-y-auto overscroll-contain px-4 pb-3 sm:px-6`,ref:re,children:/* @__PURE__ */ (0,Y.jsxs)(`section`,{"aria-label":`Conversations`,className:`grid gap-3 pt-4`,children:[/* @__PURE__ */ (0,Y.jsx)(zm,{className:`w-full sm:ml-auto sm:w-72`,label:`Search your conversations`,onChange:i,placeholder:`Search conversations…`,value:r}),/* @__PURE__ */ (0,Y.jsx)(Jg,{conversations:F,emptyLabel:b.error?.message,loading:b.isPending,onReorderPins:m||A.filter(e=>e.pinnedAt).length>t?void 0:S,timeZone:ja(),waitingConversationIds:N}),ne>0?/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`py-2 text-center font-sans text-xs text-dashboard-text-muted`,ref:ie,role:`status`,children:[`Loading `,Math.min(ne,20),` more…`]}):null]})}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:l?`grid min-h-0 place-items-center overflow-y-auto overscroll-contain px-6 pb-13`:K(Wm,`overflow-y-auto border-t border-dashboard-border-subtle sm:px-6`),children:oe})]});return/* @__PURE__ */ (0,Y.jsxs)(Vm,{className:`min-h-0 overflow-hidden bg-dashboard-bg`,elementRef:d,onLayoutChanged:e=>{let t=e[ED]??0,n=d.current?.offsetWidth??0;t>0&&qy(t/100*n)},children:[l?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(Hm,{collapsible:!0,defaultSize:a?Ky():0,groupResizeBehavior:`preserve-pixel-size`,id:ED,maxSize:Vy.max,minSize:Vy.min,onResize:e=>{let t=e.inPixels>0;t!==a&&o(t)},panelRef:u,children:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:K(`h-full min-h-0 overflow-hidden`,!a&&`hidden`),id:f,children:/* @__PURE__ */ (0,Y.jsx)(Tm,{conversations:A,error:b.error?.message,loading:b.isPending,onNewConversation:j,onReorderPins:S,selectedId:v,timeZone:ja(),waitingConversations:ee})})}),/* @__PURE__ */ (0,Y.jsx)(Um,{"aria-label":`Resize conversation list`,className:`w-px bg-transparent transition-colors after:w-2 focus-visible:ring-dashboard-border-interactive data-[separator=active]:bg-dashboard-border-interactive data-[separator=hover]:bg-dashboard-border-interactive`})]}):null,/* @__PURE__ */ (0,Y.jsxs)(Hm,{id:`selected-conversation`,children:[y?ce:null,v||T?/* @__PURE__ */ (0,Y.jsx)(`section`,{"aria-busy":y||void 0,"aria-label":`Selected conversation`,className:`grid h-full min-h-0 grid-rows-[minmax(0,1fr)] overflow-hidden bg-dashboard-bg`,children:v?/* @__PURE__ */ (0,Y.jsx)(Hx,{conversationId:v,children:/* @__PURE__ */ (0,Y.jsx)(kv,{value:M,children:/* @__PURE__ */ (0,Y.jsx)(wD,{conversationId:v,detail:e.detail,data:b.data?{conversations:b.data}:void 0,pendingArchiveUpdate:x.find(e=>e.conversationId===v),sidebarToggle:se})})},v):T?/* @__PURE__ */ (0,Y.jsx)(qw,{pending:T,sidebarToggle:se}):null}):null]})]})}function OD(e){let[t,n]=(0,J.useState)(`public`);return/* @__PURE__ */ (0,Y.jsxs)(`section`,{"aria-label":`New conversation`,className:`mx-auto grid w-full max-w-3xl gap-3`,children:[/* @__PURE__ */ (0,Y.jsx)(`h2`,{className:K(`m-0 text-center font-display text-2xl font-medium tracking-[-0.03em] text-dashboard-text md:text-3xl`,e.docked&&`sr-only`),children:`What do you need?`}),/* @__PURE__ */ (0,Y.jsx)(lv,{draftId:`new`,error:e.error,footerStart:/* @__PURE__ */ (0,Y.jsxs)(ha,{"aria-label":`Conversation visibility`,className:`inline-flex shrink-0 gap-0.5 rounded-lg border border-dashboard-border bg-dashboard-surface-panel p-0.5`,onValueChange:([e])=>{e&&n(e)},value:[t],children:[/* @__PURE__ */ (0,Y.jsxs)(ua,{className:`min-w-20 gap-1.5`,value:`public`,children:[/* @__PURE__ */ (0,Y.jsx)(Yn,{"aria-hidden":`true`,className:`size-3`}),`Public`]}),/* @__PURE__ */ (0,Y.jsxs)(ua,{className:`min-w-20 gap-1.5`,value:`private`,children:[/* @__PURE__ */ (0,Y.jsx)(Wt,{"aria-hidden":`true`,className:`size-3`}),`Private`]})]}),label:`Start a conversation`,holdDraftUntilAccept:!0,ref:e.composerRef,submitLabel:`Send`,onSubmit:(n,r,i)=>e.onSubmit(n,r,t,i)})]})}function kD(e,t,n){let r=new Map(e.filter(e=>n||!e.archivedAt).map(e=>[e.id,e]));for(let e of t){if(e.archived&&!n){r.delete(e.conversationId);continue}let t=r.get(e.conversationId)??(e.conversation?Ya([e.conversation])[0]:void 0);t&&r.set(e.conversationId,{...t,archivedAt:e.archived?t.archivedAt??t.lastSeenAt:null})}let i=[...r.values()].sort((e,t)=>t.lastSeenAt.localeCompare(e.lastSeenAt)),a=new Set(t.filter(e=>e.archived).map(e=>e.conversationId));return n||a.size===0?i:Fd(i,e=>a.has(e.id))}function AD(e){let[t]=Uy();return/* @__PURE__ */ (0,Y.jsxs)(`div`,{"aria-busy":`true`,"aria-live":`polite`,className:K(sa,`grid h-full min-h-0 grid-cols-[minmax(0,1fr)] overflow-hidden`,t&&`md:grid-cols-[var(--conversation-sidebar-width)_minmax(0,1fr)]`),role:`status`,style:{"--conversation-sidebar-width":`${Ky()}px`},children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`sr-only`,children:e.detail?`Loading conversation`:`Loading conversations`}),t?/* @__PURE__ */ (0,Y.jsx)(jD,{}):null,e.detail?/* @__PURE__ */ (0,Y.jsx)(ND,{}):/* @__PURE__ */ (0,Y.jsx)(MD,{})]})}function jD(){return/* @__PURE__ */ (0,Y.jsxs)(`aside`,{className:`hidden h-full min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden border-r border-dashboard-border bg-dashboard-surface-panel md:grid`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`px-3 pb-1.5 pt-2.5`,children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid grid-cols-[0.875rem_minmax(0,1fr)] items-center gap-2 px-3 py-2 text-sm leading-snug`,children:[/* @__PURE__ */ (0,Y.jsx)(q,{className:`size-[1.125rem] justify-self-center rounded-md`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`flex h-[1lh] items-center`,children:/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-3 w-28`})})]})}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`min-h-0 overflow-hidden px-3`,children:/* @__PURE__ */ (0,Y.jsx)(Dm,{})})]})}function MD(){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid h-full min-h-0 w-full grid-rows-[minmax(0,1fr)_auto] overflow-hidden md:grid-rows-[minmax(0,1fr)]`,children:[/* @__PURE__ */ (0,Y.jsxs)(`section`,{className:`grid min-h-0 content-start gap-3 overflow-hidden px-4 pb-3 pt-4 sm:px-6 md:hidden`,children:[/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-9 w-full rounded-lg border border-dashboard-border bg-dashboard-overlay-soft sm:ml-auto sm:w-72`}),/* @__PURE__ */ (0,Y.jsx)(Yg,{})]}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:K(Wm,`border-t border-dashboard-border-subtle sm:px-6 md:grid md:max-h-none md:place-items-center md:border-t-0 md:px-6 md:pb-13 md:pt-13`),children:/* @__PURE__ */ (0,Y.jsxs)(`section`,{className:`mx-auto grid w-full max-w-3xl gap-3`,children:[/* @__PURE__ */ (0,Y.jsx)(q,{className:`mx-auto hidden h-8 w-56 md:block`}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`w-full rounded-xl border border-dashboard-border-subtle bg-dashboard-surface-raised p-3`,children:[/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-20 w-full bg-dashboard-fill-faint`}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`mt-3 flex justify-between`,children:[/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-7 w-32`}),/* @__PURE__ */ (0,Y.jsx)(q,{className:`size-8 rounded-md`})]})]})]})})]})}function ND(){return/* @__PURE__ */ (0,Y.jsx)(`section`,{"aria-label":`Selected conversation`,className:`grid min-h-0 grid-rows-[minmax(0,1fr)] overflow-hidden bg-dashboard-fill-faint`,children:/* @__PURE__ */ (0,Y.jsx)(Dv,{scrollAriaLabel:`Conversation transcript`,scrollClassName:`thin-scrollbar px-4 pb-4 md:px-7 md:pb-6`,scroll:/* @__PURE__ */ (0,Y.jsxs)(`section`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`mb-4 grid gap-3 border-b border-dashboard-border-subtle py-4`,children:[/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-6 w-2/3 max-w-lg`}),/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-3 w-1/3 max-w-56 opacity-70`})]}),/* @__PURE__ */ (0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`mx-auto w-full max-w-[52.5rem]`,children:/* @__PURE__ */ (0,Y.jsx)(mD,{})})]})})})}const PD=[`overview`,`conversations`,`changes`];function FD(e,t=`overview`){let n=`/code/${encodeURIComponent(e)}`;return t===`overview`?n:`${n}/${t}`}const ID=`m-0 font-display text-xl font-medium tracking-[-0.02em] text-dashboard-text`;function LD(e){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:e.className,children:[e.anchor?/* @__PURE__ */ (0,Y.jsx)(vo,{anchor:e.anchor,className:ID,title:e.title}):/* @__PURE__ */ (0,Y.jsx)(`h2`,{className:ID,children:e.title}),e.description?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`mt-1.5 mb-0 max-w-2xl font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.description}):null]})}const RD=[{end:!0,label:`General`,to:`/settings`},{label:`API Tokens`,to:`/settings/api-tokens`},{label:`Identities`,to:`/settings/connections`},{label:`MCP`,to:`/settings/mcp`}];function zD(e){return/* @__PURE__ */ (0,Y.jsx)(_o,{children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid w-full max-w-3xl min-w-0 gap-8`,children:[/* @__PURE__ */ (0,Y.jsx)(ma,{documentTitle:e.title,navigation:/* @__PURE__ */ (0,Y.jsx)(xo,{ariaLabel:`Settings navigation`,items:RD}),title:`Settings`}),/* @__PURE__ */ (0,Y.jsxs)(`section`,{className:`grid min-w-0 gap-5`,children:[/* @__PURE__ */ (0,Y.jsx)(LD,{description:e.description,title:e.title}),e.children]})]})})}function BD(e){return/* @__PURE__ */ (0,Y.jsxs)(_o,{children:[/* @__PURE__ */ (0,Y.jsx)(ma,{description:e.description,title:e.title}),/* @__PURE__ */ (0,Y.jsx)(la,{label:e.label,variant:e.variant})]})}const VD=[{end:!0,label:`Overview`,to:`/system`},{label:`People`,to:`/system/people`},{label:`Locations`,to:`/system/locations`},{label:`Workspaces`,to:`/system/workspaces`},{label:`Plugins`,to:So}];function HD(e){if(z(`/system/workspaces`,e))return!0;let t=z(`/system/workspaces/:workspaceId`,e);return!!(t&&t.params.workspaceId!==`new`)}function UD(e){return/* @__PURE__ */ (0,Y.jsx)(ho,{ariaLabel:`System navigation`,className:e.className,items:VD,children:e.children})}function WD(e){return/* @__PURE__ */ (0,Y.jsx)(UD,{children:/* @__PURE__ */ (0,Y.jsx)(_o,{children:e.children})})}function GD(e){return/* @__PURE__ */ (0,Y.jsx)(UD,{children:/* @__PURE__ */ (0,Y.jsx)(BD,{...e})})}const KD=`/memories`,qD=`${KD}/library`,JD=/* @__PURE__ */ new Set([`library`]);function YD(e){if(e===qD||e.startsWith(`${qD}/`))return!0;let t=e.match(/^\/memories\/([^/]+)$/);return!(!t?.[1]||JD.has(t[1]))}function XD(e){let t=YD(be().pathname);return/* @__PURE__ */ (0,Y.jsx)(ho,{ariaLabel:`Memory navigation`,className:t?`grid h-full min-h-0 grid-rows-[auto_minmax(0,1fr)] md:grid-rows-[minmax(0,1fr)]`:void 0,items:[{end:!0,label:`Overview`,to:KD},{isActive:YD,label:`Memories`,to:qD}],children:t?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`min-h-0`,children:e.children}):/* @__PURE__ */ (0,Y.jsx)(_o,{className:`gap-6 sm:gap-8`,children:e.children})})}function ZD(e){let t=YD(be().pathname),n=/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(ma,{description:e.description??`Personal and public memories Junior can use across conversations.`,title:e.title??`Memories`}),/* @__PURE__ */ (0,Y.jsx)(la,{label:e.label,variant:t?`library`:`overview`})]});return/* @__PURE__ */ (0,Y.jsx)(XD,{children:t?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`h-full overflow-y-auto`,children:/* @__PURE__ */ (0,Y.jsx)(_o,{className:`gap-6 sm:gap-8`,children:n})}):n})}function QD(e){return!!z(`/automations/runs`,e)||!!z(`/automations/:automationId/runs`,e)}const $D=[{end:!0,label:`Automations`,to:`/automations`},{label:`Runs`,to:`/automations/runs`}];function eO(e){return/* @__PURE__ */ (0,Y.jsx)(ho,{ariaLabel:`Automations navigation`,className:e.className,items:$D,children:e.children})}function tO(e){let t=QD(be().pathname);return/* @__PURE__ */ (0,Y.jsx)(eO,{className:t?`grid h-full min-h-0 grid-rows-[auto_minmax(0,1fr)] md:grid-rows-[minmax(0,1fr)]`:void 0,children:t?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`min-h-0`,children:e.children}):/* @__PURE__ */ (0,Y.jsx)(_o,{children:e.children})})}function nO(e){let t=QD(be().pathname),n=/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(ma,{description:e.description,title:e.title}),/* @__PURE__ */ (0,Y.jsx)(la,{label:e.label,variant:`list`})]});return t?/* @__PURE__ */ (0,Y.jsx)(_o,{children:n}):n}function rO(e,t){return e===`memory`&&t===`memories`?`/memories`:`/plugins/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}const iO=[`/admin`,`/automations`,`/memories`,`/settings`,`/plugins/`,`/review`];function aO(e){return iO.some(t=>e.startsWith(t))}const oO={key:`code`,label:`Code`,to:`/code`},sO={key:`system`,label:`System`,to:`/system`};function cO(e){let t=e.loading&&aO(e.pathname),n=e.loggedIn||t,r=!e.loading&&!e.loggedIn;return[...n?[{count:e.reviewCount,key:`review`,label:`Inbox`,to:`/review`},{key:`automations`,label:`Automations`,to:`/automations`}]:[],...e.primaryUserPages.map(uO),...r?[oO,sO]:[]]}function lO(e){return[...e.map(uO),oO,sO]}function uO(e){return{key:`${e.pluginName}:${e.id}`,label:e.label,to:rO(e.pluginName,e.id)}}function dO(e){let t=``;for(let{route:n}of e)n.path&&(t=n.path.startsWith(`/`)?n.path:`${t.replace(/\/\*?$/,``)}/${n.path}`);return t||`/`}function fO(e){let t=be(),n=pe(e.children),r=we(n,t),i=Ce(n,t),a=i?dO(i):void 0;return(0,J.useLayoutEffect)(()=>{a&&Ki(a)},[t.key,a]),/* @__PURE__ */ (0,Y.jsx)(J.Suspense,{fallback:e.fallback,children:r})}const pO={accent:`bg-dashboard-accent`,closed:`border border-dashboard-text-faint`,muted:`bg-dashboard-text-faint`,warning:`bg-amber-300`};function mO(e){return/* @__PURE__ */ (0,Y.jsx)(`li`,{children:/* @__PURE__ */ (0,Y.jsx)(V,{"aria-current":e.selected?`page`:void 0,className:K(`block min-w-0 rounded-lg px-3 py-2 text-inherit no-underline transition-colors hover:bg-dashboard-fill-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus`,e.selected===`always`&&`bg-dashboard-surface-active`,e.selected===`wide`&&`md:bg-dashboard-surface-active`),to:e.to,children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[0.875rem_minmax(0,1fr)] items-start gap-x-2`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:K(`mt-[0.4rem] size-2 shrink-0 justify-self-center rounded-full`,pO[e.dot])}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:K(`truncate font-sans text-sm font-medium leading-snug`,e.dot===`closed`?`text-dashboard-text-muted`:`text-dashboard-text`),children:e.title}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`col-start-2 mt-1 truncate font-sans text-xs leading-tight text-dashboard-text-muted`,children:e.meta})]})})})}function hO(e){return e.count===0?null:/* @__PURE__ */ (0,Y.jsxs)(`section`,{"aria-label":e.label,children:[/* @__PURE__ */ (0,Y.jsx)(pp,{className:K(`px-3 pb-1`,e.first?`pt-1`:`pt-3`),collapsed:e.collapsed,count:e.count,label:e.label,onToggle:e.onToggle}),e.collapsed?null:/* @__PURE__ */ (0,Y.jsx)(`ul`,{className:`m-0 grid list-none gap-0.5 p-0`,children:e.children})]})}function gO(){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{"aria-busy":`true`,"aria-live":`polite`,className:`grid gap-0.5`,role:`status`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`sr-only`,children:`Loading review items`}),/* @__PURE__ */ (0,Y.jsx)(q,{className:`mb-1 ml-3 mt-1.5 h-2.5 w-16`}),[0,1,2,3,4].map(e=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid gap-1 rounded-lg px-3 py-2`,children:[/* @__PURE__ */ (0,Y.jsx)(q,{className:K(`h-4`,e%2?`w-3/5`:`w-4/5`)}),/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-3 w-2/5 opacity-70`})]},e))]})}function _O(e){let t=[{items:e.needsYou,key:`needs-you`,label:`Needs you`},{items:e.fyi,key:`fyi`,label:`FYI`}],n=[...t.map(e=>e.items.length),e.blocked.length],r=e=>n.slice(0,e).every(e=>e===0),i=t=>{let n=t.status===`open`,r=t.automationId?`Automation`:e.sourceTitle(t),i=[n?void 0:Qx(t),r,no(n?t.createdAt:t.closedAt)];return/* @__PURE__ */ (0,Y.jsx)(mO,{dot:n?t.kind===`action`?`accent`:`muted`:`closed`,meta:i.filter(Boolean).join(` · `),selected:t.id===e.selectedId?e.selectedShown?`always`:`wide`:void 0,title:t.title,to:bo(Xx(t.id),e.searchParams)},t.id)};return/* @__PURE__ */ (0,Y.jsxs)(`aside`,{className:`grid h-full min-h-0 grid-rows-[auto_auto_minmax(0,1fr)] overflow-hidden border-r border-dashboard-border bg-dashboard-surface-panel`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`px-5 py-3`,children:/* @__PURE__ */ (0,Y.jsx)(`h2`,{className:`m-0 font-display text-lg font-medium leading-tight text-dashboard-text`,children:`Inbox`})}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`px-4 pb-2`,children:/* @__PURE__ */ (0,Y.jsx)(zm,{label:`Search review items`,onChange:e.onSearchChange,placeholder:`Search items…`,size:`compact`,value:e.search})}),/* @__PURE__ */ (0,Y.jsx)(Sm,{children:/* @__PURE__ */ (0,Y.jsx)(`nav`,{"aria-label":`Review items`,className:`px-3 pb-[max(0.5rem,env(safe-area-inset-bottom))]`,children:e.error?/* @__PURE__ */ (0,Y.jsx)(h_,{className:`px-3 py-2`,children:`Could not load review items.`}):e.loading?/* @__PURE__ */ (0,Y.jsx)(gO,{}):e.results?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[e.results.length>0?/* @__PURE__ */ (0,Y.jsx)(`ul`,{"aria-label":`Search results`,className:`m-0 grid list-none gap-0.5 p-0 pt-1`,children:e.results.map(i)}):null,e.footer]}):/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[t.map((t,n)=>/* @__PURE__ */ (0,Y.jsx)(hO,{collapsed:e.collapsed.has(t.key),count:t.items.length,first:r(n),label:t.label,onToggle:()=>e.onToggle(t.key),children:t.items.map(i)},t.key)),/* @__PURE__ */ (0,Y.jsx)(hO,{collapsed:e.collapsed.has(`blocked`),count:e.blocked.length,first:r(2),label:`Blocked automations`,onToggle:()=>e.onToggle(`blocked`),children:e.blocked.map(e=>/* @__PURE__ */ (0,Y.jsx)(mO,{dot:`warning`,meta:e.statusReason??`Blocked`,title:e.title,to:Ka(e.id)},e.id))}),e.footer]})})})]})}function vO(e){return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{className:`text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{className:`m-0 min-w-0 break-words text-dashboard-text`,children:e.children})]})}function yO(e){let{item:t}=e,n=t.subject,r=n?.url?Zx(n.url):void 0,[i,...a]=uu([t.addedByConversationId,...t.conversationIds]),o=t.assignees.length>0||t.assignedToEveryone;return/* @__PURE__ */ (0,Y.jsx)(Iy,{label:`Review item details`,onClose:e.onClose,title:/* @__PURE__ */ (0,Y.jsx)(`h2`,{className:`m-0 text-base font-semibold text-dashboard-text`,children:`Details`}),children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-3 p-4 pb-[max(1rem,env(safe-area-inset-bottom))]`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`min-w-0 break-words px-1 pb-1 font-sans text-sm leading-relaxed text-dashboard-text-muted`,children:/* @__PURE__ */ (0,Y.jsx)($,{text:t.body})}),/* @__PURE__ */ (0,Y.jsx)(yg,{title:`Assignees`,children:o?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-sm text-dashboard-text`,children:$x(t)}):/* @__PURE__ */ (0,Y.jsx)(gp,{size:`compact`,tone:`warning`,children:`Unassigned`})}),/* @__PURE__ */ (0,Y.jsx)(yg,{children:/* @__PURE__ */ (0,Y.jsxs)(`dl`,{className:`m-0 grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1.5`,children:[/* @__PURE__ */ (0,Y.jsx)(vO,{label:`Status`,children:Qx(t)}),/* @__PURE__ */ (0,Y.jsx)(vO,{label:`Added`,children:no(t.createdAt)}),/* @__PURE__ */ (0,Y.jsxs)(vO,{label:`Added by`,children:[/* @__PURE__ */ (0,Y.jsx)(V,{className:ra,title:t.addedByConversationId,to:kc(t.addedByConversationId,{turnId:t.addedByTurnId}),children:i??`Conversation`}),t.automationId?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[` · `,/* @__PURE__ */ (0,Y.jsx)(V,{className:ra,to:Ka(t.automationId),children:`Automation`})]}):null]}),/* @__PURE__ */ (0,Y.jsx)(vO,{label:`Visibility`,children:t.visibility===`private`?`Private`:`Public`})]})}),n?/* @__PURE__ */ (0,Y.jsx)(yg,{title:`Subject`,children:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-sm`,children:r?/* @__PURE__ */ (0,Y.jsx)(tf,{className:ra,href:r,children:n.title??r}):n.title??n.id})}):null,t.conversationIds.length>0?/* @__PURE__ */ (0,Y.jsx)(yg,{count:t.conversationIds.length,title:`Linked conversations`,children:/* @__PURE__ */ (0,Y.jsx)(`ul`,{className:`m-0 grid list-none gap-1 p-0 text-sm`,children:t.conversationIds.map((e,t)=>{let n=a[t];return/* @__PURE__ */ (0,Y.jsx)(`li`,{className:n?`truncate`:`truncate font-mono text-xs`,children:/* @__PURE__ */ (0,Y.jsx)(V,{className:ra,title:e,to:kc(e),children:n??e})},e)})})}):null]})})}function bO(e,t){let n=Date.parse(t.createdAt),r=t.closedAt?Date.parse(t.closedAt):1/0,i=e.flatMap(e=>{if(e.data.type!==`message`||e.data.role===`system`)return[];let t=iS(e);return t?[t]:[]});return{after:i.filter(e=>{let t=Date.parse(e.createdAt);return t>n&&t<r}).slice(0,3),before:i.filter(e=>Date.parse(e.createdAt)<=n).slice(-3)}}function xO(e){let t=(0,J.useMemo)(()=>({...e.conversation,events:e.events}),[e.conversation,e.events]);return/* @__PURE__ */ (0,Y.jsx)(iw,{conversation:t})}function SO(e){let t=hd(e.item.addedByConversationId),n=t.data,r=n?.events,i=(0,J.useMemo)(()=>r?bO(r,e.item):void 0,[r,e.item]),a=(0,J.useRef)(t.loadPreviousPage);a.current=t.loadPreviousPage;let o=r?.[0]?.createdAt,s=n?.eventHistory.status===`available`,c=s&&o!==void 0&&Date.parse(o)>Date.parse(e.item.createdAt)&&t.hasPreviousPage,l=c&&!t.isLoadingPreviousPage&&!t.historyError;return(0,J.useEffect)(()=>{l&&a.current()},[l,o]),t.isPending||c&&!t.historyError?/* @__PURE__ */ (0,Y.jsx)(mD,{}):!n||!i||!s||c||i.before.length+i.after.length===0?e.fallback:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[i.before.length>0?/* @__PURE__ */ (0,Y.jsx)(xO,{conversation:n,events:i.before}):null,i.after.length>0?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex items-center gap-3 py-1 font-sans text-xs font-medium text-dashboard-accent-text`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`h-px flex-1 bg-dashboard-accent/30`}),`New since `,pa(),` asked`,/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`h-px flex-1 bg-dashboard-accent/30`})]}),/* @__PURE__ */ (0,Y.jsx)(xO,{conversation:n,events:i.after})]}):null]})}const CO=`inline-flex items-center gap-1.5 font-sans text-sm font-medium text-dashboard-text no-underline hover:underline focus-visible:outline-dashboard-focus`;function wO(e){let{item:t}=e,n=t.status===`open`,r=(0,J.useRef)(null),i=(0,J.useRef)(null);(0,J.useEffect)(()=>{let e=r.current,t=i.current,n=e?.closest(`[data-chat-scroll]`);if(!e||!t||!n)return;let a=new ResizeObserver(()=>{let e=t.getBoundingClientRect().top-n.getBoundingClientRect().top+n.scrollTop;n.scrollTop=Math.min(n.scrollHeight-n.clientHeight,e-24)}),o=()=>a.disconnect(),s=[`keydown`,`pointerdown`,`touchstart`,`wheel`];a.observe(e);for(let e of s)n.addEventListener(e,o,{passive:!0});return()=>{o();for(let e of s)n.removeEventListener(e,o)}},[]);let a=t.automationId?`Automation`:e.sourceTitle,o=t.kind===`notice`||!t.request,s=/* @__PURE__ */ (0,Y.jsxs)(V,{className:CO,to:kc(t.addedByConversationId,{turnId:t.addedByTurnId}),children:[`Open conversation`,/* @__PURE__ */ (0,Y.jsx)(qt,{"aria-hidden":`true`,size:14})]});return/* @__PURE__ */ (0,Y.jsx)(Dv,{header:/* @__PURE__ */ (0,Y.jsx)(`header`,{className:`border-b border-dashboard-border bg-dashboard-bg`,children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-4 px-4 py-3 md:px-7 md:py-5`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-1.5`,children:[/* @__PURE__ */ (0,Y.jsxs)(V,{className:`inline-flex items-center gap-1 font-sans text-xs text-dashboard-text-muted no-underline hover:text-dashboard-text md:hidden`,to:e.backTo,children:[/* @__PURE__ */ (0,Y.jsx)(Lt,{"aria-hidden":`true`,size:14}),`Inbox`]}),/* @__PURE__ */ (0,Y.jsx)(`h2`,{className:`m-0 min-w-0 break-words font-display text-xl font-medium leading-tight tracking-tight`,children:t.title}),/* @__PURE__ */ (0,Y.jsxs)(`p`,{className:`m-0 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,Y.jsx)(gp,{size:`compact`,tone:n?`accent`:`neutral`,children:Qx(t)}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{children:[a?`${a} · `:null,no(t.createdAt),t.visibility===`private`?` · Private`:null]})]})]}),/* @__PURE__ */ (0,Y.jsxs)(H,{"aria-label":`Review item details`,"aria-pressed":e.detailsOpen,className:`shrink-0`,onClick:e.onDetailsClick,children:[/* @__PURE__ */ (0,Y.jsx)(Xt,{"aria-hidden":`true`,size:15,strokeWidth:2}),`Details`]})]})}),scrollAriaLabel:`Review item`,scrollClassName:`px-4 pb-6 md:px-7`,scroll:/* @__PURE__ */ (0,Y.jsxs)(`article`,{"aria-label":t.title,ref:r,className:`mx-auto grid w-full min-w-0 max-w-[52.5rem] gap-5 pt-5 md:pt-7`,children:[/* @__PURE__ */ (0,Y.jsx)(SO,{fallback:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid gap-3 font-sans text-sm leading-relaxed`,children:[o?null:/* @__PURE__ */ (0,Y.jsx)($,{text:t.body}),/* @__PURE__ */ (0,Y.jsx)(`div`,{children:s})]}),item:t}),/* @__PURE__ */ (0,Y.jsxs)(`section`,{"aria-label":n?`Answer`:`Outcome`,ref:i,className:`grid min-w-0 gap-4 rounded-xl border border-dashboard-border-emphasis bg-dashboard-surface-panel p-4 font-sans text-sm md:p-5`,children:[o?/* @__PURE__ */ (0,Y.jsx)($,{text:t.body}):null,/* @__PURE__ */ (0,Y.jsx)(Yx,{item:t})]}),e.next?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`flex justify-end`,children:/* @__PURE__ */ (0,Y.jsxs)(V,{className:CO,replace:!0,to:e.next.to,children:[`Next: `,e.next.title,/* @__PURE__ */ (0,Y.jsx)(qt,{"aria-hidden":`true`,size:14})]})}):null]})})}const TO=`grid h-full min-h-0 w-full overflow-hidden bg-dashboard-bg md:grid-cols-[20rem_minmax(0,1fr)]`;function EO(e){return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:K(`grid content-center justify-items-center gap-3 px-4 py-12 text-center`,e.className),children:/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 font-display text-lg font-medium text-dashboard-text`,children:`Nothing needs you`})})}function DO(){return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:TO,children:/* @__PURE__ */ (0,Y.jsxs)(`aside`,{"aria-busy":`true`,"aria-label":`Loading review items`,className:`grid content-start gap-2 border-r border-dashboard-border bg-dashboard-surface-panel px-5 py-3`,children:[/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-5 w-16`}),/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-8 w-full`}),[0,1,2,3].map(e=>/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid gap-1 py-2`,children:[/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-4 w-4/5`}),/* @__PURE__ */ (0,Y.jsx)(q,{className:`h-3 w-2/5 opacity-70`})]},e))]})})}function OO(){fa(`Inbox`);let[e]=Ee(),[t,n,r]=yo(),{items:i,moreArchived:a,query:o}=cu({forViewer:!0,q:r}),s=!r,c=fu(s),l=s?c.data?.automations??[]:[],u=(0,J.useMemo)(()=>cS(i),[i]),d=(0,J.useMemo)(()=>r?[...i.filter(e=>e.status===`open`),...i.filter(e=>e.status!==`open`)]:void 0,[i,r]),f=[...u.needsYou,...u.fyi],[p,m]=(0,J.useState)(()=>/* @__PURE__ */ new Set),h=e=>m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),g=e.get(`item`)??void 0,_=g??f[0]?.id,v=i.find(e=>e.id===_),y=lu(v?void 0:_),b=v??y.data,x=b?lS(u,b):void 0,S=(0,J.useMemo)(()=>{let e=d??[...p.has(`needs-you`)?[]:u.needsYou,...p.has(`fyi`)?[]:u.fyi],t=b?[...e,b]:e;return[...new Set(t.filter(e=>!e.automationId).map(e=>e.addedByConversationId))]},[p,u,d,b]),C=uu(S),w=e=>C[S.indexOf(e.addedByConversationId)],T=Fy(),[E,D]=(0,J.useState)(),O=!!b&&(E??T),k=new URLSearchParams(e);k.delete(`item`);let A=!!o.data,j=A&&!r&&f.length===0&&l.length===0;return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:TO,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:K(`h-full min-h-0 overflow-hidden`,g&&`max-md:hidden`),children:/* @__PURE__ */ (0,Y.jsx)(_O,{blocked:l,collapsed:p,error:!(!o.error||o.data),footer:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(tE,{className:`mx-3 mt-2`,hasMore:!o.isPlaceholderData&&!!o.hasNextPage,loading:o.isFetchingNextPage,onLoadMore:()=>void o.fetchNextPage()}),o.isFetchNextPageError?/* @__PURE__ */ (0,Y.jsx)(h_,{className:`px-3 py-2`,children:`Could not load more items. Try again.`}):null,a?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 px-3 py-2 text-xs text-dashboard-text-muted`,children:`Narrow the search to find older archived items.`}):null,A&&r&&i.length===0?/* @__PURE__ */ (0,Y.jsxs)(`p`,{className:`m-0 px-3 py-8 text-center text-sm text-dashboard-text-muted`,children:[`No items match "`,r,`".`]}):null,j?/* @__PURE__ */ (0,Y.jsx)(EO,{className:`md:hidden`}):null]}),fyi:u.fyi,loading:!o.data&&!o.error,needsYou:u.needsYou,onSearchChange:n,onToggle:h,results:d,search:t,searchParams:k,selectedId:b?.id,selectedShown:!!g,sourceTitle:w})}),/* @__PURE__ */ (0,Y.jsx)(`section`,{"aria-label":`Selected review item`,className:K(`grid min-h-0 grid-rows-[minmax(0,1fr)] overflow-hidden`,!g&&`max-md:hidden`,O&&`xl:grid-cols-[minmax(0,1fr)_25rem]`),children:b?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(wO,{backTo:bo(`/review`,k),detailsOpen:O,item:b,next:x?{title:x.title,to:bo(Xx(x.id),k)}:void 0,onDetailsClick:()=>D(!O),sourceTitle:w(b)},b.id),O?/* @__PURE__ */ (0,Y.jsx)(yO,{item:b,onClose:()=>D(!1)}):null]}):y.error?/* @__PURE__ */ (0,Y.jsx)(h_,{className:`p-7`,children:`Review item not found.`}):j?/* @__PURE__ */ (0,Y.jsx)(EO,{}):null})]})}const kO=[`dashboard`,`versions`],AO=[`conversations`,`reviewItems`,`spend`],jO=[`focus`,`keydown`,`pointerdown`,`pointermove`,`touchstart`,`wheel`];function MO(e){return Date.now()-e>=3e5}function NO(e,t){let n=new Set(e.split(` `));return t.split(` `).filter(e=>!n.has(e)).map(e=>e.split(`:`)[0]??e)}function PO(e,t,n,r){let i=e=>t!==void 0&&t[e]!==n[e];if(Xi(AO.filter(i),t&&i(`conversations`)?NO(t.conversations,n.conversations):[]),(i(`conversations`)||i(`reviewItems`))&&e.invalidateQueries({queryKey:[`dashboard`,`conversations`]}),i(`reviewItems`)&&e.invalidateQueries({queryKey:su}),i(`spend`)&&e.invalidateQueries({queryKey:[`dashboard`,`personal-spend`]}),!r)return;let a=X(r),o=e.getQueryState(a);if(!o?.data||o.fetchStatus===`fetching`||ad(o.data))return;let s=o.data.conversationVersion;s!==void 0&&s!==n.conversation&&e.invalidateQueries({exact:!0,queryKey:a})}function FO(e,t){let n=(0,J.useRef)(Date.now()),{refetch:r}=L({enabled:t,queryKey:kO,queryFn:async({client:t,signal:n})=>{let r=t.getQueryData(kO),i=await G(Lr,e?`/api/versions?${new URLSearchParams({conversationId:e})}`:`/api/versions`,n);return PO(t,r,i,e),i},refetchInterval:()=>MO(n.current)?1e4:5e3,retry:!1,staleTime:0});(0,J.useEffect)(()=>{let e=()=>{let e=MO(n.current);n.current=Date.now(),e&&t&&r()};for(let t of jO)window.addEventListener(t,e,{capture:!0,passive:!0});return()=>{for(let t of jO)window.removeEventListener(t,e,{capture:!0})}},[t,r])}const IO=(0,J.lazy)(()=>import(`./chunks/RepositoryPage-fti2vfu4.js`).then(e=>({default:e.RepositoryPage}))),LO=(0,J.lazy)(()=>import(`./chunks/BoardPage-f0uxqg7u.js`).then(e=>({default:e.BoardPage}))),RO=(0,J.lazy)(()=>import(`./chunks/CodePage-i97ivyji.js`).then(e=>({default:e.CodePage}))),zO=(0,J.lazy)(()=>import(`./chunks/LocationDetailPage-ggd6zgzp.js`).then(e=>({default:e.LocationDetailPage}))),BO=(0,J.lazy)(()=>import(`./chunks/LocationsPage-fh6vzxa1.js`).then(e=>({default:e.LocationsPage}))),VO=(0,J.lazy)(()=>import(`./chunks/PeoplePage-odrbcmhj.js`).then(e=>({default:e.PeoplePage}))),HO=(0,J.lazy)(()=>import(`./chunks/PersonProfilePage-gynexe89.js`).then(e=>({default:e.PersonProfilePage}))),UO=(0,J.lazy)(()=>import(`./chunks/ConnectionsPage-mholegdk.js`).then(e=>({default:e.ConnectionsPage}))),WO=(0,J.lazy)(()=>import(`./chunks/McpSettingsPage-fm3fh2ux.js`).then(e=>({default:e.McpSettingsPage}))),GO=(0,J.lazy)(()=>import(`./chunks/PersonalTokensPage-4o4zj02w.js`).then(e=>({default:e.PersonalTokensPage}))),KO=(0,J.lazy)(()=>import(`./chunks/SettingsPage-kxspx37h.js`).then(e=>({default:e.SettingsPage}))),qO=(0,J.lazy)(()=>import(`./chunks/SystemPage-jurblfgy.js`).then(e=>({default:e.SystemPage}))),JO=(0,J.lazy)(()=>import(`./chunks/WorkspaceFormPage-hwvyvnuk.js`).then(e=>({default:e.WorkspaceFormPage}))),YO=(0,J.lazy)(()=>import(`./chunks/WorkspacesPage-lu9w3ugz.js`).then(e=>({default:e.WorkspacesPage}))),XO=(0,J.lazy)(()=>import(`./chunks/AutomationPage-e1l74ezg.js`).then(e=>({default:e.AutomationPage}))),ZO=(0,J.lazy)(()=>import(`./chunks/AutomationRunsPage-j50ps7nt.js`).then(e=>({default:e.AutomationRunsPage}))),QO=(0,J.lazy)(()=>import(`./chunks/AutomationsPage-cphxl4l6.js`).then(e=>({default:e.AutomationsPage}))),$O=(0,J.lazy)(()=>import(`./chunks/PluginUserPage-kwylbbpr.js`).then(e=>({default:e.MemoryPermalinkRoute}))),ek=(0,J.lazy)(()=>import(`./chunks/PluginUserPage-kwylbbpr.js`).then(e=>({default:e.PluginUserPageRoute}))),tk=(0,J.lazy)(()=>import(`./chunks/AdminPage-mn71yp2v.js`).then(e=>({default:e.AdminPage}))),nk={backgroundImage:`url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitchTiles'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.7'/%3E%3C/svg%3E")`},rk=[{loading:{description:`Manage your profile and preferences.`,label:`Loading settings`,title:`General`},path:`/settings`,render:e=>/* @__PURE__ */ (0,Y.jsx)(KO,{identity:e.me})},{loading:{description:`Create and revoke personal API tokens.`,label:`Loading API tokens`,title:`API Tokens`,variant:`list`},path:`/settings/api-tokens`,render:()=>/* @__PURE__ */ (0,Y.jsx)(GO,{})},{loading:{description:`Connect and disconnect your accounts.`,label:`Loading identities`,title:`Identities`,variant:`list`},path:`/settings/connections`,render:()=>/* @__PURE__ */ (0,Y.jsx)(UO,{})},{loading:{description:`Connect an MCP client to your conversations.`,label:`Loading MCP`,title:`MCP`},path:`/settings/mcp`,render:()=>/* @__PURE__ */ (0,Y.jsx)(WO,{})}];function ik(){let e=be(),[t,n]=(0,J.useState)(!1),[r,i]=(0,J.useState)(!1),a=()=>i(!0),o=Go(),s=qo(),c=o.data,l=Hi(c?.config.version),u=s.data??[],d=!c&&!o.error,f=!!(c?.config.authRequired&&c.me.user.email),p=cs(f),m=ks(),h=f?u.filter(e=>e.navigation===`primary`):[],g=e.pathname===`/`||e.pathname===`/conversations`||e.pathname.startsWith(`/conversations/`),_=ak(e.pathname),v=Jo(),y=hd(_,{unreadPageAtOpen:$p()===`unread`,versionsPoll:!0});FO(_,!!c);let b=(0,J.useMemo)(()=>{if(_)return Ya(v.data?.conversations??[]).find(e=>e.id===_)},[_,v.data?.conversations]),x=_?Va(y.data)??Fa(b):void 0,S=du(f),C=cO({loading:d,loggedIn:f,pathname:e.pathname,primaryUserPages:h,reviewCount:S.data?.needsViewer}),w=f?lO(u.filter(e=>e.navigation===`profile`)):[];(0,J.useEffect)(()=>{n(!1)},[e.pathname]);async function T(){let e=await fetch(`${c?.config.authPath??`/api/auth`}/sign-out`,{body:`{}`,credentials:`same-origin`,headers:{"content-type":`application/json`},method:`POST`});if(!e.ok)throw Error(`Sign-out returned ${e.status}`);window.location.assign(c?.config.basePath??`/`)}return/* @__PURE__ */ (0,Y.jsx)(po,{children:/* @__PURE__ */ (0,Y.jsxs)(Gl,{children:[/* @__PURE__ */ (0,Y.jsx)(vl,{currentConversationId:_,navItems:[...C,...w],onOpenChange:i,open:r}),m?null:/* @__PURE__ */ (0,Y.jsx)(Xl,{navItems:C,onSearch:a,profile:f?/* @__PURE__ */ (0,Y.jsx)(pc,{identity:c.me,onSignOut:T,spend:p.data,pages:w}):void 0,workspaceActive:g}),/* @__PURE__ */ (0,Y.jsxs)(au,{className:`min-w-0 flex-1 bg-dashboard-bg`,enabled:g||e.pathname===`/review`||QD(e.pathname)||HD(e.pathname)||YD(e.pathname),children:[/* @__PURE__ */ (0,Y.jsx)(uo,{desktopTopBar:m,banner:/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(ws,{serverVersion:l}),/* @__PURE__ */ (0,Y.jsx)(bs,{})]}),header:/* @__PURE__ */ (0,Y.jsx)(zl,{desktopTopBar:m,mobileBackTo:_?`/`:void 0,mobileTitle:x,mobileNavigationOpen:t,navItems:C,onMobileNavigationOpenChange:n,onSearch:a,profile:f?/* @__PURE__ */ (0,Y.jsx)(pc,{identity:c.me,onSignOut:T,spend:p.data,pages:w,variant:`top-bar`}):void 0,mobileIdentity:f?/* @__PURE__ */ (0,Y.jsx)(pc,{identity:c.me,onSignOut:T,spend:p.data,pages:w,variant:`sheet-identity`}):void 0,mobileProfile:f?/* @__PURE__ */ (0,Y.jsx)(pc,{identity:c.me,onSignOut:T,spend:p.data,pages:w,variant:`sheet-links`}):void 0,mobileSpend:f?/* @__PURE__ */ (0,Y.jsx)(pc,{identity:c.me,onSignOut:T,spend:p.data,pages:w,variant:`sheet-spend`}):void 0,version:c?.config.version,workspaceActive:g})}),/* @__PURE__ */ (0,Y.jsxs)(fO,{fallback:/* @__PURE__ */ (0,Y.jsx)(Cs,{label:`Loading page`}),children:[/* @__PURE__ */ (0,Y.jsx)(B,{element:/* @__PURE__ */ (0,Y.jsx)(ok,{}),path:`/tasks`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:/* @__PURE__ */ (0,Y.jsx)(ok,{}),path:`/tasks/*`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:/* @__PURE__ */ (0,Y.jsx)(ck,{}),path:`/automations/:automationId/executions`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:d||f?/* @__PURE__ */ (0,Y.jsx)(XO,{enabled:f,tab:`runs`}):/* @__PURE__ */ (0,Y.jsx)(de,{replace:!0,to:`/`}),path:`/automations/:automationId/runs`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:d||f?/* @__PURE__ */ (0,Y.jsx)(XO,{enabled:f,tab:`versions`}):/* @__PURE__ */ (0,Y.jsx)(de,{replace:!0,to:`/`}),path:`/automations/:automationId/versions`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:d||f?/* @__PURE__ */ (0,Y.jsx)(XO,{enabled:f,tab:`edit`}):/* @__PURE__ */ (0,Y.jsx)(de,{replace:!0,to:`/`}),path:`/automations/:automationId/edit`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:d?/* @__PURE__ */ (0,Y.jsx)(tO,{children:/* @__PURE__ */ (0,Y.jsx)(nO,{description:`Newest runs across your automations and automations in public destinations.`,label:`Loading automation runs`,title:`Runs`})}):f?/* @__PURE__ */ (0,Y.jsx)(tO,{children:/* @__PURE__ */ (0,Y.jsx)(ZO,{enabled:f})}):/* @__PURE__ */ (0,Y.jsx)(de,{replace:!0,to:`/`}),path:`/automations/runs`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:/* @__PURE__ */ (0,Y.jsx)(sk,{}),path:`/automations/list`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:d||f?/* @__PURE__ */ (0,Y.jsx)(XO,{enabled:f,tab:`overview`}):/* @__PURE__ */ (0,Y.jsx)(de,{replace:!0,to:`/`}),path:`/automations/:automationId`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:d?/* @__PURE__ */ (0,Y.jsx)(tO,{children:/* @__PURE__ */ (0,Y.jsx)(nO,{label:`Loading automations`,title:`Automations`})}):f?/* @__PURE__ */ (0,Y.jsx)(tO,{children:/* @__PURE__ */ (0,Y.jsx)(QO,{enabled:f})}):/* @__PURE__ */ (0,Y.jsx)(de,{replace:!0,to:`/`}),path:`/automations`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:/* @__PURE__ */ (0,Y.jsx)(lk,{section:`locations`}),path:`/locations`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:/* @__PURE__ */ (0,Y.jsx)(lk,{section:`locations`}),path:`/locations/:locationId`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:d?/* @__PURE__ */ (0,Y.jsx)(GD,{description:`Public destinations and their conversation activity.`,label:`Loading locations`,title:`Locations`,variant:`stats`}):/* @__PURE__ */ (0,Y.jsx)(BO,{}),path:`/system/locations`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:d?/* @__PURE__ */ (0,Y.jsx)(WD,{children:/* @__PURE__ */ (0,Y.jsx)(Cs,{label:`Loading location`})}):/* @__PURE__ */ (0,Y.jsx)(zO,{}),path:`/system/locations/:locationId`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:d?/* @__PURE__ */ (0,Y.jsx)(AD,{detail:!1}):c?/* @__PURE__ */ (0,Y.jsx)(DD,{detail:y}):/* @__PURE__ */ (0,Y.jsx)(Cs,{label:o.error?.message??`Dashboard unavailable`}),path:`/`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:d?/* @__PURE__ */ (0,Y.jsx)(DO,{}):f?/* @__PURE__ */ (0,Y.jsx)(OO,{}):/* @__PURE__ */ (0,Y.jsx)(de,{replace:!0,to:`/`}),path:`/review`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:/* @__PURE__ */ (0,Y.jsx)(LO,{}),path:`/board`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:/* @__PURE__ */ (0,Y.jsx)(RO,{}),path:`/code`}),PD.map(e=>/* @__PURE__ */ (0,Y.jsx)(B,{element:/* @__PURE__ */ (0,Y.jsx)(IO,{tab:e}),path:e===`overview`?`/code/:repositoryId`:`/code/:repositoryId/${e}`},e)),/* @__PURE__ */ (0,Y.jsx)(B,{element:/* @__PURE__ */ (0,Y.jsx)(de,{replace:!0,to:`/`}),path:`/conversations/new`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:d?/* @__PURE__ */ (0,Y.jsx)(AD,{detail:!0}):c?/* @__PURE__ */ (0,Y.jsx)(DD,{detail:y}):/* @__PURE__ */ (0,Y.jsx)(Cs,{label:o.error?.message??`Dashboard unavailable`}),path:`/conversations/:conversationId`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:/* @__PURE__ */ (0,Y.jsx)(de,{replace:!0,to:`/`}),path:`/conversations`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:/* @__PURE__ */ (0,Y.jsx)(lk,{section:`people`}),path:`/people`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:d?/* @__PURE__ */ (0,Y.jsx)(Cs,{label:`Loading profile`}):/* @__PURE__ */ (0,Y.jsx)(HO,{}),path:`/people/:email`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:d?/* @__PURE__ */ (0,Y.jsx)(GD,{description:`People, activity, and model spend.`,label:`Loading people`,title:`People`,variant:`stats`}):/* @__PURE__ */ (0,Y.jsx)(VO,{}),path:`/system/people`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:d?/* @__PURE__ */ (0,Y.jsx)(GD,{description:`Repository recipes Junior can switch into.`,label:`Loading Workspaces`,title:`Workspaces`,variant:`list`}):/* @__PURE__ */ (0,Y.jsx)(YO,{}),path:`/system/workspaces`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:d?/* @__PURE__ */ (0,Y.jsx)(WD,{children:/* @__PURE__ */ (0,Y.jsx)(Cs,{label:`Loading Workspace`})}):/* @__PURE__ */ (0,Y.jsx)(JO,{}),path:`/system/workspaces/new`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:d?/* @__PURE__ */ (0,Y.jsx)(GD,{description:`Repository recipes Junior can switch into.`,label:`Loading Workspaces`,title:`Workspaces`,variant:`list`}):/* @__PURE__ */ (0,Y.jsx)(YO,{}),path:`/system/workspaces/:workspaceId`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:d?/* @__PURE__ */ (0,Y.jsx)(WD,{children:/* @__PURE__ */ (0,Y.jsx)(Cs,{label:`Loading Workspace`})}):/* @__PURE__ */ (0,Y.jsx)(JO,{}),path:`/system/workspaces/:workspaceId/edit`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:d?/* @__PURE__ */ (0,Y.jsx)(GD,{description:`Runtime health, model usage, and loaded capabilities.`,label:`Loading system`,title:`System`,variant:`overview`}):c?/* @__PURE__ */ (0,Y.jsx)(uk,{coreData:c}):/* @__PURE__ */ (0,Y.jsx)(WD,{children:/* @__PURE__ */ (0,Y.jsx)(Cs,{label:o.error?.message??`Dashboard unavailable`})}),path:`/system/*`}),rk.map(e=>/* @__PURE__ */ (0,Y.jsx)(B,{element:d?/* @__PURE__ */ (0,Y.jsx)(zD,{description:e.loading.description,title:e.loading.title,children:/* @__PURE__ */ (0,Y.jsx)(la,{label:e.loading.label,variant:e.loading.variant})}):f?e.render(c):/* @__PURE__ */ (0,Y.jsx)(de,{replace:!0,to:`/`}),path:e.path},e.path)),/* @__PURE__ */ (0,Y.jsx)(B,{element:d||s.isPending?/* @__PURE__ */ (0,Y.jsx)(ZD,{label:`Loading memories`}):f&&s.data?/* @__PURE__ */ (0,Y.jsx)($O,{pages:s.data}):/* @__PURE__ */ (0,Y.jsx)(de,{replace:!0,to:`/`}),path:`/memories/library`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:d||s.isPending?/* @__PURE__ */ (0,Y.jsx)(ZD,{label:`Loading memory`}):f&&s.data?/* @__PURE__ */ (0,Y.jsx)($O,{pages:s.data}):/* @__PURE__ */ (0,Y.jsx)(de,{replace:!0,to:`/`}),path:`/memories/:memoryId?`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:d||s.isPending?/* @__PURE__ */ (0,Y.jsx)(Cs,{label:`Loading page`}):f&&s.data?/* @__PURE__ */ (0,Y.jsx)(ek,{pages:s.data}):/* @__PURE__ */ (0,Y.jsx)(de,{replace:!0,to:`/`}),path:`/plugins/:pluginName/:pageId/*`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:d||s.isPending?/* @__PURE__ */ (0,Y.jsx)(Cs,{label:`Loading admin`}):f&&c.me.user.isAdmin&&s.data?/* @__PURE__ */ (0,Y.jsx)(tk,{pages:s.data}):/* @__PURE__ */ (0,Y.jsx)(de,{replace:!0,to:`/`}),path:`/admin`}),/* @__PURE__ */ (0,Y.jsx)(B,{element:/* @__PURE__ */ (0,Y.jsx)(de,{replace:!0,to:`/`}),path:`*`})]}),/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none fixed inset-0 z-50 block opacity-[0.018]`,"data-dashboard-noise":``,style:nk})]})]})})}function ak(e){if(Pc(e))return;let t=e.match(/^\/conversations\/([^/]+)$/);if(t?.[1])try{return decodeURIComponent(t[1])}catch{return t[1]}}function ok(){let e=be(),t=e.pathname.slice(6);return/* @__PURE__ */ (0,Y.jsx)(de,{replace:!0,to:`/automations${t}${e.search}${e.hash}`})}function sk(){let e=be();return/* @__PURE__ */ (0,Y.jsx)(de,{replace:!0,to:`/automations${e.search}${e.hash}`})}function ck(){let e=be(),{automationId:t}=R();return/* @__PURE__ */ (0,Y.jsx)(de,{replace:!0,to:`${Ka(t??``,`runs`)}${e.search}${e.hash}`})}function lk(e){let t=be(),n=`/${e.section}`,r=t.pathname.slice(n.length);return/* @__PURE__ */ (0,Y.jsx)(de,{replace:!0,to:`/system/${e.section}${r}${t.search}${t.hash}`})}function uk(e){let t=ms(e.coreData);return!t.data&&!t.error?/* @__PURE__ */ (0,Y.jsx)(GD,{description:`Runtime health, model usage, and loaded capabilities.`,label:`Loading system`,title:`System`,variant:`overview`}):t.data?/* @__PURE__ */ (0,Y.jsx)(qO,{data:t.data}):/* @__PURE__ */ (0,Y.jsx)(WD,{children:/* @__PURE__ */ (0,Y.jsx)(Cs,{label:t.error?.message??`System unavailable`})})}var dk=class extends J.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){let n=e.stack??t.componentStack;window.__JUNIOR_DASHBOARD_SHOW_ERROR__?.(n?Error(n):e)}render(){return this.state.error?/* @__PURE__ */ (0,Y.jsx)(fk,{error:this.state.error}):this.props.children}};function fk(e){return/* @__PURE__ */ (0,Y.jsx)(`main`,{className:`grid min-h-screen place-items-center bg-dashboard-ink p-8 text-dashboard-text-solid`,children:/* @__PURE__ */ (0,Y.jsxs)(`section`,{className:`w-full max-w-5xl border border-rose-400/50 bg-dashboard-surface-raised p-5 font-sans`,children:[/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`font-mono text-xs uppercase leading-none text-dashboard-text-faint`,children:`Dashboard Error`}),/* @__PURE__ */ (0,Y.jsxs)(`h1`,{className:`mt-2 text-3xl font-bold leading-tight tracking-normal`,children:[pa(),` failed to render`]}),/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`my-4 max-w-3xl text-dashboard-text-subtle`,children:`The dashboard hit a client-side exception. The stack trace is shown here so the page does not fail blank.`}),/* @__PURE__ */ (0,Y.jsx)(`pre`,{className:`max-h-[60vh] overflow-auto whitespace-pre-wrap break-words border border-dashboard-border-strong bg-dashboard-ink p-4 font-mono text-sm leading-relaxed text-dashboard-text-solid`,children:e.error.stack??e.error.message})]})})}Gi();const pk=document.getElementById(`dashboard-root`);if(!pk)throw Error(`Junior dashboard root element was not found`);typeof Notification<`u`&&Notification.permission===`granted`&&tT()?.catch(()=>void 0),navigator.serviceWorker?.addEventListener(`message`,e=>{let t=e.data;typeof t==`object`&&t&&`type`in t&&t.type===`junior:open`&&`url`in t&&typeof t.url==`string`&&cT(t.url)});function mk(){sT(),lT().catch(()=>void 0)}mk(),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&mk()});const hk=new M({defaultOptions:{queries:{staleTime:3e4}}}),gk=xe([{path:`*`,element:/* @__PURE__ */ (0,Y.jsx)(ik,{})}],{basename:window.__JUNIOR_DASHBOARD_BASE_PATH__??`/`});(0,Co.createRoot)(pk).render(/* @__PURE__ */ (0,Y.jsx)(dk,{children:/* @__PURE__ */ (0,Y.jsx)(S,{client:hk,children:/* @__PURE__ */ (0,Y.jsx)(Fo,{children:/* @__PURE__ */ (0,Y.jsx)(wr,{children:/* @__PURE__ */ (0,Y.jsx)(Se,{router:gk})})})})}));export{Mh as $,Zo as $t,Rx as A,yc as At,jy as B,vs as Bt,tT as C,ml as Ct,Bx as D,Vc as Dt,zx as E,fl as Et,gb as F,Ks as Ft,Jg as G,es as Gt,rv as H,is as Ht,hb as I,js as It,Oh as J,rs as Jt,qg as K,ns as Kt,sb as L,Os as Lt,Tx as M,qs as Mt,Ex as N,Ys as Nt,Fx as O,kc as Ot,wx as P,Js as Pt,kh as Q,Qo as Qt,ob as R,Cs as Rt,$w as S,pl as St,Px as T,hl as Tt,nv as U,os as Ut,py as V,ss as Vt,h_ as W,as as Wt,Ph as X,Xo as Xt,Ah as Y,$o as Yt,Nh as Z,Yo as Zt,mT as _,Kd as _t,UD as a,$m as at,hT as b,Pl as bt,LD as c,xm as ct,iE as d,Yf as dt,us as en,_h as et,rE as f,tf as ft,dT as g,Jd as gt,uT as h,Xd as ht,GD as i,Io as in,th as it,Ix as j,Gs as jt,Lx as k,vc as kt,FD as l,Qp as lt,qT as m,Yd as mt,XD as n,ds as nn,ih as nt,BD as o,Km as ot,nE as p,qd as pt,$ as q,ts as qt,WD as r,ps as rn,rh as rt,zD as s,zm as st,rO as t,ls as tn,nh as tt,tE as u,gp as ut,pT as v,gu as vt,oT as w,dl as wt,iT as x,ll as xt,gT as y,Fl as yt,Iy as z,_s as zt};
|