@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.
Files changed (93) hide show
  1. package/dist/app.js +7 -5
  2. package/dist/client-manifest.json +1 -1
  3. package/dist/index.js +7 -5
  4. package/dist/public/chunks/{AdminPage-mn71yp2v.js → AdminPage-lctmhvpg.js} +1 -1
  5. package/dist/public/chunks/{AnchorHeading-cp3vx8qa.js → AnchorHeading-ixbupfij.js} +1 -1
  6. package/dist/public/chunks/{Area-h08sxa33.js → Area-d95rfkv5.js} +1 -1
  7. package/dist/public/chunks/AutomationPage-m78li1hv.js +3 -0
  8. package/dist/public/chunks/{AutomationRunDetails-jjdhbqtn.js → AutomationRunDetails-dx5lutte.js} +1 -1
  9. package/dist/public/chunks/{AutomationRunsPage-j50ps7nt.js → AutomationRunsPage-cba6nbxd.js} +1 -1
  10. package/dist/public/chunks/{AutomationStatus-czfg6ayl.js → AutomationStatus-eqq5lrad.js} +1 -1
  11. package/dist/public/chunks/AutomationsPage-cp7wtt2v.js +8 -0
  12. package/dist/public/chunks/{BarChart-e3oi6in1.js → BarChart-lbkezxbi.js} +1 -1
  13. package/dist/public/chunks/{BoardPage-f0uxqg7u.js → BoardPage-m4zqf62q.js} +1 -1
  14. package/dist/public/chunks/{CodeChangeRow-dk3gkjut.js → CodeChangeRow-d620nk75.js} +2 -2
  15. package/dist/public/chunks/CodePage-h2ayars2.js +1 -0
  16. package/dist/public/chunks/{CodeSummaryCards-o1po2jis.js → CodeSummaryCards-iotfblbp.js} +1 -1
  17. package/dist/public/chunks/{ConnectionsPage-mholegdk.js → ConnectionsPage-nm7w1i05.js} +2 -2
  18. package/dist/public/chunks/{DirectoryMetric-dgzufji4.js → DirectoryMetric-huy2ptzz.js} +1 -1
  19. package/dist/public/chunks/{DrawerContent-ovjgr16m.js → DrawerContent-n3biwp5m.js} +1 -1
  20. package/dist/public/chunks/{FilterBar-mtnh7fbi.js → FilterBar-dqnt967g.js} +1 -1
  21. package/dist/public/chunks/FormNotice-kj5pzsl7.js +1 -0
  22. package/dist/public/chunks/{LocationDetailPage-ggd6zgzp.js → LocationDetailPage-iqtx76w6.js} +2 -2
  23. package/dist/public/chunks/{LocationsPage-fh6vzxa1.js → LocationsPage-ju5jfejt.js} +2 -2
  24. package/dist/public/chunks/{McpSettingsPage-fm3fh2ux.js → McpSettingsPage-brav5c42.js} +1 -1
  25. package/dist/public/chunks/{PeoplePage-odrbcmhj.js → PeoplePage-lfq8nrto.js} +2 -2
  26. package/dist/public/chunks/{PersonProfilePage-gynexe89.js → PersonProfilePage-ep45sxr6.js} +1 -1
  27. package/dist/public/chunks/{PersonalTokensPage-4o4zj02w.js → PersonalTokensPage-jbt4q7uz.js} +1 -1
  28. package/dist/public/chunks/PluginReportRecordSet-ml18z19r.js +1 -0
  29. package/dist/public/chunks/{PluginUserPage-kwylbbpr.js → PluginUserPage-ilar25ic.js} +2 -2
  30. package/dist/public/chunks/RepositoryPage-o9m3vty4.js +1 -0
  31. package/dist/public/chunks/SettingsPage-jc9et1qq.js +1 -0
  32. package/dist/public/chunks/SystemPage-bbp8cdds.js +15 -0
  33. package/dist/public/chunks/{WorkspaceFormPage-hwvyvnuk.js → WorkspaceFormPage-kshmsdek.js} +2 -2
  34. package/dist/public/chunks/{WorkspacesPage-lu9w3ugz.js → WorkspacesPage-ohasc10u.js} +1 -1
  35. package/dist/public/chunks/alert-ifqo1uj7.js +1 -0
  36. package/dist/public/chunks/{automationFormat-hd7pnocr.js → automationFormat-kv314fzh.js} +1 -1
  37. package/dist/public/chunks/{chart-myr1oeen.js → chart-il2ahs5y.js} +1 -1
  38. package/dist/public/chunks/{circle-dollar-sign-fpl4dmok.js → circle-dollar-sign-h7k4kr7s.js} +1 -1
  39. package/dist/public/chunks/{code-highlighter-i3ux67or.js → code-highlighter-ea4j0ys1.js} +1 -1
  40. package/dist/public/chunks/{coins-bqkaxeba.js → coins-l2c8c17w.js} +1 -1
  41. package/dist/public/chunks/{format-gle1s0ri.js → format-flkutk9e.js} +2 -2
  42. package/dist/public/chunks/junior-g62bxb2t.js +4 -0
  43. package/dist/public/chunks/{native-select-jfknh8t4.js → native-select-fxs3p0bj.js} +1 -1
  44. package/dist/public/chunks/{plus-gndielka.js → plus-54e3zzys.js} +1 -1
  45. package/dist/public/chunks/vendor-icons-blmhaswc.js +698 -0
  46. package/dist/public/chunks/{workspaceQueries-m1ksz95c.js → workspaceQueries-onxawhg4.js} +1 -1
  47. package/dist/public/client-ctcthgam.js +165 -0
  48. package/dist/public/styles-4CIT7L7K.css +2 -0
  49. package/dist/tailwind.css +1 -1
  50. package/package.json +4 -4
  51. package/src/client/api.ts +16 -0
  52. package/src/client/components/MarkdownViewToggle.tsx +24 -0
  53. package/src/client/components/SkillLink.tsx +119 -0
  54. package/src/client/conversations/ConversationHomeList.tsx +87 -76
  55. package/src/client/conversations/ConversationListStatusIcon.tsx +39 -55
  56. package/src/client/conversations/ConversationSectionList.tsx +101 -0
  57. package/src/client/conversations/ConversationSidebar.tsx +159 -169
  58. package/src/client/conversations/ConversationWorkspace.tsx +5 -16
  59. package/src/client/conversations/TextAttachmentPreview.tsx +5 -14
  60. package/src/client/conversations/WaitingChip.tsx +78 -0
  61. package/src/client/conversations/conversationSections.ts +78 -55
  62. package/src/client/conversations/heldListOrder.ts +170 -0
  63. package/src/client/conversations/toolCallPreview.ts +3 -1
  64. package/src/client/conversations/transcriptSource.ts +7 -2
  65. package/src/client/conversations/useMarkConversationUnread.ts +2 -2
  66. package/src/client/format.ts +18 -2
  67. package/src/client/pages/automations/AutomationDraftChanges.tsx +2 -1
  68. package/src/client/pages/automations/AutomationOverview.tsx +3 -3
  69. package/src/client/pages/automations/AutomationSkillPicker.tsx +75 -31
  70. package/src/client/pages/automations/AutomationTaskFields.tsx +3 -13
  71. package/src/client/pages/automations/AutomationVersionsTab.tsx +2 -5
  72. package/src/client/pages/automations/skillSearch.ts +50 -0
  73. package/src/client/pages/code/RepositorySections.tsx +14 -5
  74. package/src/client/pages/code/RepositoryTabs.tsx +5 -11
  75. package/src/client/pages/system/PluginDetails.tsx +15 -8
  76. package/src/client/pages/system/SkillInventory.tsx +2 -6
  77. package/src/client/review-desk/queries.ts +30 -23
  78. package/src/client/review-desk/reviewItemFormat.ts +3 -1
  79. package/src/client/types.ts +5 -1
  80. package/src/mock-reporting/review-items.ts +6 -2
  81. package/dist/public/chunks/AutomationPage-e1l74ezg.js +0 -10
  82. package/dist/public/chunks/AutomationsPage-cphxl4l6.js +0 -8
  83. package/dist/public/chunks/CodePage-i97ivyji.js +0 -1
  84. package/dist/public/chunks/FormNotice-eyo2kdte.js +0 -1
  85. package/dist/public/chunks/PluginReportRecordSet-hm1cwp6c.js +0 -1
  86. package/dist/public/chunks/RepositoryPage-fti2vfu4.js +0 -1
  87. package/dist/public/chunks/SettingsPage-kxspx37h.js +0 -1
  88. package/dist/public/chunks/SystemPage-jurblfgy.js +0 -15
  89. package/dist/public/chunks/SystemPlugins-jr37f1cv.js +0 -1
  90. package/dist/public/chunks/junior-hdb4wc4q.js +0 -4
  91. package/dist/public/chunks/vendor-icons-mxz7yi04.js +0 -692
  92. package/dist/public/client-f7asutg5.js +0 -165
  93. package/dist/public/styles-ZJJGBKKX.css +0 -2
@@ -0,0 +1,165 @@
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 ae,ut as I,v as oe,w as se,x as ce,y as le}from"./chunks/vendor-lthmb2su.js";import{C as ue,S as de,_ as L,a as fe,b as pe,c as me,f as he,g as ge,h as _e,i as ve,l as R,m as ye,n as be,o as z,p as xe,r as B,s as Se,t as Ce,u as we,v as Te,x as Ee,y as De}from"./chunks/vendor-react-ggbyvons.js";import{A as Oe,B as ke,C as Ae,Ct as je,D as Me,E as Ne,F as Pe,H as Fe,I as Ie,It as Le,L as Re,Lt as ze,M as Be,P as Ve,Pt as He,R as Ue,S as We,St as Ge,Tt as Ke,U as qe,V as Je,W as Ye,_ as Xe,a as Ze,b as Qe,c as $e,d as et,f as tt,g as nt,h as rt,i as it,j as at,l as ot,m as st,n as ct,o as lt,p as ut,r as dt,s as ft,st as pt,t as mt,u as ht,ut as gt,v as _t,vt,w as yt,wt as bt,x as xt,y as St,yt as Ct,z as wt}from"./chunks/vendor-ui-j25lilhx.js";import{n as Tt,t as V}from"./chunks/button-ygjnb239.js";import{$ as Et,A as Dt,At as Ot,B as kt,Bt as At,C as jt,Ct as Mt,D as Nt,Dt as Pt,E as Ft,Et as It,F as Lt,Ft as Rt,G as zt,Gt as Bt,H as Vt,Ht,I as Ut,It as Wt,J as Gt,Jt as Kt,K as qt,Kt as Jt,L as Yt,Lt as Xt,M as Zt,Mt as Qt,N as $t,Nt as en,O as tn,Ot as nn,P as rn,Pt as H,Q as an,Qt as on,R as sn,Rt as cn,S as ln,St as un,T as dn,Tt as fn,U as pn,Ut as mn,V as hn,Vt as gn,W as _n,Wt as vn,X as yn,Xt as bn,Y as xn,Yt as Sn,Z as Cn,Zt as wn,_ as Tn,_t as En,a as Dn,at as On,b as kn,bt as An,c as jn,ct as Mn,d as Nn,dt as Pn,et as Fn,f as In,ft as Ln,g as Rn,gt as zn,h as Bn,ht as Vn,i as Hn,it as Un,j as Wn,jt as Gn,k as Kn,kt as qn,l as Jn,lt as Yn,m as Xn,mt as Zn,n as Qn,nt as $n,o as er,ot as tr,p as nr,pt as rr,q as ir,qt as ar,r as or,rt as sr,s as cr,st as lr,t as ur,tt as dr,u as fr,ut as pr,v as mr,vt as hr,w as gr,wt as _r,x as vr,xt as yr,y as br,yt as xr,z as Sr,zt as Cr}from"./chunks/vendor-icons-blmhaswc.js";import{a as U,i as wr,n as W,r as Tr,t as G}from"./chunks/tooltip-h1yceend.js";import{$ as Er,A as Dr,B as Or,Ct as kr,D as Ar,Dt as jr,E as Mr,Et as Nr,F as Pr,G as Fr,Gt as Ir,H as Lr,Ht as Rr,J as zr,K as Br,M as Vr,Mt as Hr,N as Ur,Ot as Wr,P as Gr,Q as Kr,St as qr,T as Jr,Tt as Yr,Ut as Xr,V as Zr,Vt as Qr,X as $r,Y as ei,Z as ti,_ as ni,a as ri,at as ii,b as ai,c as oi,d as si,dt as ci,et as li,f as ui,g as di,gt as fi,h as pi,ht as mi,i as hi,j as gi,jt as _i,k as vi,l as yi,lt as bi,m as xi,mt as Si,n as Ci,o as wi,ot as Ti,p as Ei,pt as Di,q as Oi,r as ki,rt as Ai,s as ji,t as Mi,v as Ni,vt as Pi,w as Fi,wt as Ii,y as Li,yt as Ri,z as zi}from"./chunks/junior-g62bxb2t.js";import{n as Bi,r as Vi,t as Hi}from"./chunks/schema-m4v0mjyv.js";import{_ as Ui,a as Wi,c as Gi,d as Ki,f as qi,g as Ji,h as Yi,i as K,l as Xi,m as Zi,n as Qi,o as $i,p as ea,s as ta,t as na,u as ra}from"./chunks/http-cdq677qt.js";import{n as ia,r as aa,t as oa}from"./chunks/alert-ifqo1uj7.js";import{a as sa,i as ca,n as la,o as ua,r as da,t as q}from"./chunks/styles-j0007fov.js";import{t as fa}from"./chunks/Card-hy4bfgq7.js";import{t as J}from"./chunks/skeleton-h6p83ux1.js";import{t as pa}from"./chunks/PageContentSkeleton-b7dkba0l.js";import{d as ma,f as ha,l as ga,m as _a,t as va,u as ya}from"./chunks/PageHeader-bhl3orzi.js";import{A as ba,B as xa,C as Sa,E as Ca,F as wa,G as Ta,H as Ea,I as Da,L as Oa,M as ka,N as Aa,O as ja,P as Ma,R as Na,S as Pa,T as Fa,V as Ia,W as La,_ as Ra,a as za,b as Ba,d as Va,f as Ha,g as Ua,h as Wa,i as Ga,j as Ka,k as qa,l as Ja,m as Ya,n as Xa,o as Za,p as Qa,r as $a,s as eo,t as to,u as no,v as ro,w as io,x as ao,y as oo,z as so}from"./chunks/format-flkutk9e.js";import{a as co,c as lo,d as uo,f as fo,i as po,l as mo,n as ho,o as go,r as _o,s as vo,t as yo,u as bo}from"./chunks/SecondaryNavigation-m358iuko.js";import{t as xo}from"./chunks/PageLayout-l6dhbimv.js";import{t as So}from"./chunks/AnchorHeading-ixbupfij.js";import{n as Co,t as wo}from"./chunks/searchParams-moqjgi65.js";import{t as To}from"./chunks/SegmentedNav-eik9tbzh.js";var Eo=pe(),Y=/* @__PURE__ */ e(ue(),1),X=de();function Do({...e}){return/* @__PURE__ */ (0,X.jsx)(ze,{...e})}function Oo({...e}){return/* @__PURE__ */ (0,X.jsx)(gt,{"data-slot":`toast-portal`,...e})}function ko({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(He,{"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 Ao({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(Ke,{"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 jo({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(bt,{"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 Mo({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(Ge,{"data-slot":`toast-title`,className:F(`break-words text-sm font-medium`,e),...t})}function No({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(je,{"data-slot":`toast-description`,className:F(`break-words text-sm text-dashboard-text-muted`,e),...t})}function Po({className:e,render:t=/* @__PURE__ */ (0,X.jsx)(V,{}),...n}){return/* @__PURE__ */ (0,X.jsx)(vt,{"data-slot":`toast-action`,render:t,className:F(`shrink-0`,e),...n})}function Fo({className:e,children:t,render:n=/* @__PURE__ */ (0,X.jsx)(V,{size:`icon`}),...r}){return/* @__PURE__ */ (0,X.jsx)(Ct,{"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,X.jsx)(Qn,{"aria-hidden":`true`})})}function Io({type:e}){let t=null;return e===`success`&&(t=/* @__PURE__ */ (0,X.jsx)(nn,{"aria-hidden":`true`})),e===`info`&&(t=/* @__PURE__ */ (0,X.jsx)(Fn,{"aria-hidden":`true`})),e===`warning`&&(t=/* @__PURE__ */ (0,X.jsx)(jn,{"aria-hidden":`true`})),e===`error`&&(t=/* @__PURE__ */ (0,X.jsx)(Lt,{className:`text-rose-300`,"aria-hidden":`true`})),e===`loading`&&(t=/* @__PURE__ */ (0,X.jsx)(xn,{className:`animate-spin motion-reduce:animate-none`,"aria-hidden":`true`})),t?/* @__PURE__ */ (0,X.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 Lo(){let{toasts:e}=pt();return e.map(e=>/* @__PURE__ */ (0,X.jsx)(Ao,{toast:e,children:/* @__PURE__ */ (0,X.jsxs)(jo,{children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[/* @__PURE__ */ (0,X.jsx)(Io,{type:e.type}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[/* @__PURE__ */ (0,X.jsx)(Mo,{}),/* @__PURE__ */ (0,X.jsx)(No,{})]})]}),e.actionProps?/* @__PURE__ */ (0,X.jsx)(Po,{}):null,/* @__PURE__ */ (0,X.jsx)(Fo,{})]})},e.id))}function Ro({children:e,...t}){return/* @__PURE__ */ (0,X.jsxs)(Do,{limit:3,timeout:4e3,...t,children:[e,/* @__PURE__ */ (0,X.jsx)(Oo,{children:/* @__PURE__ */ (0,X.jsx)(ko,{children:/* @__PURE__ */ (0,X.jsx)(Lo,{})})})]})}const zo=pt,Bo=[`dashboard`,`pin-order`],Vo={queryKey:[`dashboard`,`conversations`]};function Ho(){let e=P(),[,t]=(0,Y.useReducer)(e=>e+1,0),{mutate:n}=N({mutationKey:Bo,scope:{id:`pin-order`},mutationFn:({conversationIds:e})=>ta(Dr,`/api/conversations/pin-order`,{conversationIds:e}),onError:(e,t)=>t.onError(),onSettled:()=>e.isMutating({mutationKey:Bo})===1?e.invalidateQueries(Vo):void 0});return(0,Y.useCallback)(r=>{e.cancelQueries(Vo),Wo(e,r.conversationIds),t(),n(r)},[n,e])}function Uo(){return re({mutationKey:Bo})>0}function Wo(e,t){let n=new Map(t.map((e,t)=>[e,t]));e.setQueriesData(Vo,e=>e&&{...e,conversations:e.conversations.map(e=>{let t=n.get(e.conversationId);return t===void 0?e:{...e,pinPosition:t}})})}const Go=3e5;function Ko(){if(typeof window>`u`)return;let e=window.__JUNIOR_DASHBOARD_BOOTSTRAP__;delete window.__JUNIOR_DASHBOARD_BOOTSTRAP__;let t=Hi.safeParse(e);return t.success?t.data:void 0}function qo(){return j({queryKey:[`dashboard`,`core`],queryFn:async({signal:e})=>{let[t,n]=await Promise.all([K(Vi,`/api/me`,e),K(Bi,`/api/config`,e)]);return{config:n,me:t}},initialData:Ko,initialDataUpdatedAt:()=>performance.timeOrigin,retry:!1,staleTime:Go})}function Jo(){return I(qo())}function Yo(){return I({queryKey:[`dashboard`,`plugins`],queryFn:({signal:e})=>K(ti,`/api/plugins`,e),retry:!1,staleTime:Go})}function Xo(){return I({queryKey:[`dashboard`,`plugin-user-pages`],queryFn:({signal:e})=>K(Ir,`/api/user-pages`,e),retry:!1,staleTime:Go})}function Zo(e=``){let t=Uo();return I({enabled:!t,queryKey:[`dashboard`,`conversations`,`viewer`,{search:e}],queryFn:({signal:t})=>K(zr,`/api/conversations${e?`?q=${encodeURIComponent(e)}`:``}`,t),placeholderData:h,retry:!1})}function Qo(){return I({queryKey:[`dashboard`,`code`],queryFn:({signal:e})=>K(ji,`/api/code`,e),retry:!1})}function $o(){return I({queryKey:[`dashboard`,`board`],queryFn:({signal:e})=>K(wi,`/api/board`,e),retry:!1})}function es(e){return I({enabled:!!e,queryKey:[`dashboard`,`code`,`repositories`,e],queryFn:({signal:t})=>K(yi,`/api/code/repositories/${encodeURIComponent(e)}`,t),retry:!1})}function ts(e,t=``){return I({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),K(zr,`/api/conversations?${r.toString()}`,n)},placeholderData:h,retry:!1})}function ns(e,t){return I({enabled:e,queryKey:[`dashboard`,`automations`,t],queryFn:({signal:e})=>K(ii,`/api/automations${t?`?${t}`:``}`,e),placeholderData:h,retry:!1})}function rs(e,t){return I({enabled:e&&!!t,queryKey:[`dashboard`,`automations`,`detail`,t],queryFn:({signal:e})=>K(bi,`/api/automations/${encodeURIComponent(t)}`,e),retry:!1})}function is(e){return I({enabled:e,queryKey:[`dashboard`,`automations`,`runs`],queryFn:({signal:e})=>K(Ti,`/api/automations/runs`,e),retry:!1})}function as(e,t){return I({enabled:e&&!!t,queryKey:[`dashboard`,`automations`,t,`executions`],queryFn:({signal:e})=>K(Ai,`/api/automations/${encodeURIComponent(t)}/executions`,e),retry:!1})}function os(e,t){return I({enabled:e&&!!t,queryKey:[`dashboard`,`automations`,t,`versions`],queryFn:({signal:e})=>K(ci,`/api/automations/${encodeURIComponent(t)}/versions`,e),retry:!1})}function ss(){return I({queryKey:[`dashboard`,`people`],queryFn:({signal:e})=>K(Ci,`/api/people`,e),retry:!1})}function cs(e){return I({enabled:!!e,queryKey:[`dashboard`,`people`,e],queryFn:async({signal:t})=>K(ki,`/api/people/${encodeURIComponent(e)}`,t),retry:!1})}function ls(e){return I({enabled:!!e,queryKey:[`dashboard`,`people`,e,`plugin-reports`],queryFn:({signal:t})=>K($r,`/api/people/${encodeURIComponent(e)}/plugin-reports`,t),retry:!1})}function us(e){return I({enabled:!!e,queryKey:[`dashboard`,`people`,e,`code`],queryFn:({signal:t})=>K(oi,`/api/people/${encodeURIComponent(e)}/code`,t),retry:!1})}function ds(e){return I({enabled:e,queryKey:[`dashboard`,`personal-spend`],queryFn:({signal:e})=>K(Ar,`/api/people/me/spend`,e),retry:!1,staleTime:0})}function fs(){return I({queryKey:[`dashboard`,`locations`],queryFn:({signal:e})=>K(Jr,`/api/locations`,e),retry:!1})}function ps(e){return I({enabled:!!e,queryKey:[`dashboard`,`locations`,e],queryFn:async({signal:t})=>K(Fi,`/api/locations/${encodeURIComponent(e)}`,t),retry:!1})}function ms(){return I({queryKey:[`dashboard`,`skills`],queryFn:({signal:e})=>K(Er,`/api/skills`,e),retry:!1,staleTime:Go})}function hs(e){return I({queryKey:[`dashboard`,`skills`,e],queryFn:({signal:t})=>K(Kr,`/api/skills/${encodeURIComponent(e)}`,t),retry:!1,staleTime:Go})}function gs(){return I({queryKey:[`dashboard`,`plugin-reports`],queryFn:({signal:e})=>K($r,`/api/plugin-reports`,e),retry:!1})}function _s(){return I({queryKey:[`dashboard`,`stats`],queryFn:({signal:e})=>K(zi,`/api/stats`,e),retry:!1})}function vs(e){let t=Yo(),n=I({queryKey:[`dashboard`,`conversation-stats`],queryFn:({signal:e})=>K(ni,`/api/conversations/stats`,e),retry:!1}),r=I({queryKey:[`dashboard`,`reply-times`],queryFn:({signal:e})=>K(gi,`/api/reply-times`,e),retry:!1}),i=ms(),a=gs();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 ys(){return(0,Y.useSyncExternalStore)(e=>w.subscribe(e),()=>w.isOnline(),()=>!0)}function bs(){return ys()?null:/* @__PURE__ */ (0,X.jsx)(oa,{"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,X.jsx)(`div`,{className:`relative grid size-10 shrink-0 select-none place-items-center overflow-visible`,children:/* @__PURE__ */ (0,X.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,X.jsx)(`div`,{className:q(da,`grid min-h-[calc(100dvh-5rem)] place-items-center px-4 py-8 md:px-8`),children:/* @__PURE__ */ (0,X.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,X.jsx)(Ss,{}),/* @__PURE__ */ (0,X.jsxs)(`div`,{children:[/* @__PURE__ */ (0,X.jsx)(`div`,{className:`font-bold`,children:e.label}),/* @__PURE__ */ (0,X.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,X.jsxs)(oa,{"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,X.jsx)(`span`,{children:`The dashboard changed. Refresh to load the latest version.`}),/* @__PURE__ */ (0,X.jsx)(V,{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&&Mi!==`unknown`&&e!==`unknown`&&e!==Mi}const Es={automations:ur,code:xr,"memory:memories":Cr,review:dr,system:Mn};function Ds(e){return Es[e]??At}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,X.jsxs)(`div`,{className:q(`flex items-center justify-between gap-3`,e.className),children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-sans text-sm font-semibold text-dashboard-text`,children:e.label}),/* @__PURE__ */ (0,X.jsx)(ya,{"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,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(U,{render:/* @__PURE__ */ (0,X.jsx)(ma,{"aria-label":e.itemLabel(t),value:t.value,children:/* @__PURE__ */ (0,X.jsx)(t.Icon,{"aria-hidden":`true`,size:14,strokeWidth:2})})}),/* @__PURE__ */ (0,X.jsx)(W,{size:`compact`,children:t.label})]},t.value))})]})}const js=[{description:`Top bar on tall windows, sidebar on shorter ones.`,Icon:Dt,label:`Adaptive`,value:`adaptive`},{description:`Always show the top bar.`,Icon:Wn,label:`Top bar`,value:`top-bar`},{description:`Always show the sidebar.`,Icon:$t,label:`Sidebar`,value:`sidebar`}];function Ms(e){let[t,n]=Os();return/* @__PURE__ */ (0,X.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,Y.useSyncExternalStore)(Ls,Is),Rs]}const Bs=[{Icon:Yt,label:`System`,value:`system`},{Icon:Xn,label:`Light`,value:`light`},{Icon:Ut,label:`Dark`,value:`dark`}];function Vs(e){let[t,n]=zs();return/* @__PURE__ */ (0,X.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,X.jsx)(Ye,{"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,X.jsx)(qe,{"data-slot":`avatar-image`,className:F(`size-full object-cover`,e),...t})}function Ws({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(Fe,{"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,X.jsx)(Je,{...e})}function Ks(e){return/* @__PURE__ */ (0,X.jsx)(ke,{"data-slot":`popover-trigger`,...e})}function qs({className:e,align:t=`center`,side:n=`bottom`,...r}){return/* @__PURE__ */ (0,X.jsx)(wt,{children:/* @__PURE__ */ (0,X.jsx)(Ue,{align:t,side:n,sideOffset:8,className:`isolate z-50`,children:/* @__PURE__ */ (0,X.jsx)(Re,{"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,X.jsx)(Ie,{className:F(`m-0 text-sm font-medium`,e),...t})}function Ys({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(Pe,{className:F(`m-0 leading-relaxed text-dashboard-text-muted`,e),...t})}const Xs=Y.createContext(null);function Zs(){let e=Y.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]=Y.useState(e),l=t??s,u=Y.useCallback(e=>{let t=typeof e==`function`?e(l):e;n?n(t):c(t)},[n,l]),d=Y.useCallback(()=>{u(e=>!e)},[u]),f=l?`expanded`:`collapsed`,p=Y.useMemo(()=>({state:f,open:l,setOpen:u,toggleSidebar:d}),[f,l,u,d]);return/* @__PURE__ */ (0,X.jsx)(Xs.Provider,{value:p,children:/* @__PURE__ */ (0,X.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,X.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,X.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,X.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,X.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,X.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,X.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,X.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,X.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,X.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,X.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,X.jsx)(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:F(`group/menu-item relative`,e),...t})}const oc=ae(`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=Ve({defaultTagName:`button`,props:Le({className:F(oc({variant:n,size:r}),a)},o),render:i?/* @__PURE__ */ (0,X.jsx)(U,{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,X.jsxs)(G,{children:[c,/* @__PURE__ */ (0,X.jsx)(W,{side:`right`,align:`center`,hidden:s!==`collapsed`,...i})]})):c}function cc({className:e,...t}){return/* @__PURE__ */ (0,X.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,X.jsxs)(Hs,{"aria-hidden":`true`,className:q(`border-0 shadow-black/40`,e),children:[/* @__PURE__ */ (0,X.jsx)(Us,{alt:`User avatar`,src:t.avatarUrl}),/* @__PURE__ */ (0,X.jsx)(Ws,{className:`font-bold tracking-wide`,children:lc(t.name,t.email)})]})}function dc({value:e}){let[t,n]=(0,Y.useState)(e),[r,i]=(0,Y.useState)(!1),a=(0,Y.useRef)(e);return(0,Y.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,X.jsx)(`span`,{className:q(`transition-colors duration-700 motion-reduce:transition-none`,r&&`text-dashboard-accent-text`),children:t===void 0?`—`:Qa({total:t})})}const fc=Tt({size:`menu`});function pc({identity:e,onSignOut:t,spend:n,pages:r,variant:i=`popover`}){let[a,o]=(0,Y.useState)(!1),s=e.user.email,c=e.user.name?.trim()||s,l=n?Qa({total:n.sevenDaysUsd}):`—`,u=n?Qa({total:n.thirtyDaysUsd}):`—`,d=/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`border-b border-dashboard-border-strong px-2.5 py-2.5`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[/* @__PURE__ */ (0,X.jsx)(uc,{className:`size-8`,user:e.user}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 truncate text-sm font-semibold text-dashboard-text`,children:c}),c===s?null:/* @__PURE__ */ (0,X.jsx)(`p`,{className:`mt-0.5 mb-0 truncate text-xs text-dashboard-text-muted`,children:s})]})]}),/* @__PURE__ */ (0,X.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,X.jsxs)(`span`,{children:[`7d`,` `,/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-semibold text-dashboard-text`,children:/* @__PURE__ */ (0,X.jsx)(dc,{value:n?.sevenDaysUsd})})]}),/* @__PURE__ */ (0,X.jsxs)(`span`,{children:[`30d`,` `,/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-semibold text-dashboard-text`,children:/* @__PURE__ */ (0,X.jsx)(dc,{value:n?.thirtyDaysUsd})})]})]})]}),f=n=>/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsxs)(B,{className:q(fc,`mt-1`),onClick:n,to:qa(s),children:[/* @__PURE__ */ (0,X.jsx)(er,{"aria-hidden":`true`,size:16,strokeWidth:2}),`My profile`]}),/* @__PURE__ */ (0,X.jsxs)(B,{className:fc,onClick:n,to:`/settings`,children:[/* @__PURE__ */ (0,X.jsx)(vr,{"aria-hidden":`true`,size:16,strokeWidth:2}),`Settings`]}),r.map(e=>{let t=Ds(e.key);return/* @__PURE__ */ (0,X.jsxs)(B,{className:fc,onClick:n,to:e.to,children:[/* @__PURE__ */ (0,X.jsx)(t,{"aria-hidden":`true`,size:16,strokeWidth:2}),e.label]},e.key)}),e.user.isAdmin?/* @__PURE__ */ (0,X.jsxs)(B,{className:fc,onClick:n,to:`/admin`,children:[/* @__PURE__ */ (0,X.jsx)(br,{"aria-hidden":`true`,size:16,strokeWidth:2}),`Admin`]}):null,/* @__PURE__ */ (0,X.jsxs)(V,{onClick:()=>{n(),t()},size:`menu`,children:[/* @__PURE__ */ (0,X.jsx)(qt,{"aria-hidden":`true`,size:16,strokeWidth:2}),`Log out`]})]});if(i===`sheet-spend`)return/* @__PURE__ */ (0,X.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,X.jsx)(`span`,{className:`text-xs font-medium`,children:`Spend`}),/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`whitespace-nowrap`,children:[`7d`,` `,/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-semibold text-dashboard-text`,children:/* @__PURE__ */ (0,X.jsx)(dc,{value:n?.sevenDaysUsd})})]}),/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`whitespace-nowrap`,children:[`30d`,` `,/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-semibold text-dashboard-text`,children:/* @__PURE__ */ (0,X.jsx)(dc,{value:n?.thirtyDaysUsd})})]})]});if(i===`sheet-links`){let n=q(`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`,ua);return/* @__PURE__ */ (0,X.jsxs)(`nav`,{"aria-label":`Account menu for ${c}`,className:`grid gap-1`,children:[/* @__PURE__ */ (0,X.jsx)(B,{className:n,to:qa(s),children:`My profile`}),/* @__PURE__ */ (0,X.jsx)(B,{className:n,to:`/settings`,children:`Settings`}),r.map(e=>/* @__PURE__ */ (0,X.jsx)(B,{className:n,to:e.to,children:e.label},e.key)),e.user.isAdmin?/* @__PURE__ */ (0,X.jsx)(B,{className:n,to:`/admin`,children:`Admin`}):null,/* @__PURE__ */ (0,X.jsx)(`button`,{className:q(n,`w-full cursor-pointer`),"data-mobile-nav-dismiss":!0,onClick:()=>{t()},type:`button`,children:`Log out`}),/* @__PURE__ */ (0,X.jsx)(Vs,{className:`px-3 py-2`})]})}if(i===`sheet-identity`)return/* @__PURE__ */ (0,X.jsxs)(`div`,{"aria-label":`Signed in as ${c}`,className:`flex min-w-0 items-center gap-2.5 px-1`,children:[/* @__PURE__ */ (0,X.jsx)(uc,{user:e.user}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 truncate text-xs font-semibold text-dashboard-text`,children:c}),c===s?null:/* @__PURE__ */ (0,X.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,X.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,X.jsxs)(Ks,{"aria-label":`${m}. Personal model spend: 7 days ${l}, 30 days ${u}.`,className:q(`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,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`flex items-baseline gap-1 whitespace-nowrap tabular-nums`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`text-xs font-medium tracking-[0.08em] text-dashboard-text-muted`,children:`7d`}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`text-xs font-semibold text-dashboard-text`,children:/* @__PURE__ */ (0,X.jsx)(dc,{value:n?.sevenDaysUsd})})]}),/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px bg-dashboard-fill-strong`}),/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`flex items-baseline gap-1 whitespace-nowrap tabular-nums`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`text-xs font-medium tracking-[0.08em] text-dashboard-text-muted`,children:`30d`}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`text-xs font-semibold text-dashboard-text`,children:/* @__PURE__ */ (0,X.jsx)(dc,{value:n?.thirtyDaysUsd})})]})]}),/* @__PURE__ */ (0,X.jsx)(uc,{user:e.user}),/* @__PURE__ */ (0,X.jsx)(Wt,{"aria-hidden":`true`,className:q(`text-dashboard-text-muted transition-[color,transform] group-hover:text-dashboard-text`,a&&`rotate-180 text-dashboard-text`),size:14,strokeWidth:2})]}):/* @__PURE__ */ (0,X.jsx)(ac,{children:/* @__PURE__ */ (0,X.jsxs)(sc,{"aria-label":m,className:q(`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,X.jsx)(Ks,{...h}),children:[/* @__PURE__ */ (0,X.jsx)(uc,{user:e.user}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium group-data-[collapsible=icon]:hidden`,children:c}),/* @__PURE__ */ (0,X.jsx)(Ot,{"aria-hidden":`true`,className:`text-dashboard-text-muted group-data-[collapsible=icon]:hidden`,strokeWidth:2})]})}),/* @__PURE__ */ (0,X.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,X.jsxs)(`div`,{className:`grid gap-1 border-b border-dashboard-border-strong px-2.5 py-2`,children:[/* @__PURE__ */ (0,X.jsx)(Vs,{}),/* @__PURE__ */ (0,X.jsx)(Ms,{})]}),f(()=>o(!1))]})]})}const mc={key:`pinned`,label:`Pinned`,order:-2},hc={key:`needs-you`,label:`Needs you`,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.waiting)?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(yc),r.get(hc.key)?.conversations.sort(xc(t.waiting)),[...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}function vc(e,t){let n=e=>e.pinnedAt?0:_c(e,t)?1:2,r=xc(t);return[...e].sort((e,t)=>Sc(t)-Sc(e)).sort((e,t)=>{let i=n(e);return i-n(t)||(i===0?yc(e,t):i===1?r(e,t):0)})}function yc(e,t){return(e.pinPosition??-1/0)-(t.pinPosition??-1/0)||bc(t)-bc(e)||e.id.localeCompare(t.id)}function bc(e){return e.pinnedAt&&Date.parse(e.pinnedAt)||0}function xc(e){let t=t=>{let n=Date.parse(e.get(t.id)?.waitingSince??``);return Number.isFinite(n)?n:1/0};return(e,n)=>{let r=t(e),i=t(n);return r===i?0:r<i?-1:1}}function Sc(e){let t=Date.parse(e.lastMessageAt??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:Fa()})}function Oc(e,t=Date.now(),n=Fa()){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,Y.useState)(e);return(0,Y.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,X.jsx)(X.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,X.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,X.jsx)(yt,{"data-slot":`dialog`,...e})}function al(e){return/* @__PURE__ */ (0,X.jsx)(at,{"data-slot":`dialog-close`,...e})}function ol({className:e,...t}){return/* @__PURE__ */ (0,X.jsxs)(Ne,{"data-slot":`dialog-portal`,children:[/* @__PURE__ */ (0,X.jsx)(Be,{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,X.jsx)(Me,{"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,X.jsx)(Ae,{"data-slot":`dialog-title`,className:F(`m-0 font-display text-lg font-medium`,e),...t})}function cl({className:e,...t}){return/* @__PURE__ */ (0,X.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,X.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,X.jsx)(il,{...r,children:/* @__PURE__ */ (0,X.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,X.jsx)(sl,{className:`sr-only`,children:n}),e]})})}function dl({children:e,className:t,...n}){return/* @__PURE__ */ (0,X.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex items-center gap-3 border-b border-dashboard-border-subtle px-4`,children:[/* @__PURE__ */ (0,X.jsx)(jt,{"aria-hidden":`true`,className:`size-4 shrink-0 text-dashboard-text-muted`}),/* @__PURE__ */ (0,X.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,X.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,X.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,X.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,X.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,Y.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,X.jsx)(ul,{onOpenChange:t,open:n,title:_l,children:/* @__PURE__ */ (0,X.jsx)(yl,{currentConversationId:e.currentConversationId,navItems:e.navItems,onClose:()=>t(!1)})})}function yl(e){let[t,n]=(0,Y.useState)(``),r=Vc(t.trim()),i=Zo(),a=Zo(r),o=_e(),s=(0,Y.useRef)(null),c=!!r&&t.trim()===r&&!a.isPlaceholderData,l=(0,Y.useMemo)(()=>bl({currentConversationId:e.currentConversationId,feed:$a(i.data?.conversations??[]),navItems:e.navItems,query:t.trim(),searched:c?$a(a.data?.conversations??[]):[]}),[i.data?.conversations,e.currentConversationId,e.navItems,t,a.data?.conversations,c]);(0,Y.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,X.jsxs)(ll,{loop:!0,shouldFilter:!1,vimBindings:!1,children:[/* @__PURE__ */ (0,X.jsx)(dl,{"aria-label":`Conversation or page`,onValueChange:n,placeholder:`Go to a conversation or page…`,spellCheck:!1,value:t,children:/* @__PURE__ */ (0,X.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,X.jsxs)(fl,{ref:s,children:[/* @__PURE__ */ (0,X.jsx)(pl,{children:d?`Searching…`:`No matches.`}),u.map(([t,n])=>/* @__PURE__ */ (0,X.jsx)(ml,{heading:t,children:n.map(t=>{let n=t.icon;return/* @__PURE__ */ (0,X.jsxs)(hl,{onSelect:()=>{o(t.to,{state:t.state}),e.onClose()},value:t.id,children:[/* @__PURE__ */ (0,X.jsx)(n,{"aria-hidden":`true`}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:/* @__PURE__ */ (0,X.jsx)(Gc,{label:t.label,matches:t.matches})}),t.meta?/* @__PURE__ */ (0,X.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:Rn,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=za(e),i=n?Xc(r,n):void 0;return{group:t,icon:e.visibility===`private`?Gt:kt,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,X.jsx)(yt,{"data-slot":`sheet`,...e})}function Cl({...e}){return/* @__PURE__ */ (0,X.jsx)(at,{"data-slot":`sheet-close`,...e})}function wl({...e}){return/* @__PURE__ */ (0,X.jsx)(Ne,{"data-slot":`sheet-portal`,...e})}function Tl({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(Be,{"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=Y.useRef(null);return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(`div`,{ref:o,className:`contents`}),/* @__PURE__ */ (0,X.jsxs)(wl,{container:o,children:[/* @__PURE__ */ (0,X.jsx)(Tl,{}),/* @__PURE__ */ (0,X.jsxs)(Me,{"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,X.jsxs)(at,{"data-slot":`sheet-close`,render:/* @__PURE__ */ (0,X.jsx)(V,{...i,className:F(`absolute top-3 right-3`,i?.className),size:`icon`}),children:[/* @__PURE__ */ (0,X.jsx)(Qn,{"aria-hidden":`true`,size:15,strokeWidth:2.25}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})]})}function Dl({className:e,...t}){return/* @__PURE__ */ (0,X.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,X.jsx)(Ae,{"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,Y.useState)(!1),i=(0,Y.useRef)(!1),a=(0,Y.useRef)(null),o=(0,Y.useSyncExternalStore)(Nl,()=>{let e=document.querySelectorAll(`[data-dashboard-modal]`),t=e[e.length-1];return a.current?t===a.current:!t},()=>!0);return(0,Y.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,X.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,Y.useRef)(null),n=(0,Y.useRef)(e.onMobileNavigationOpenChange);n.current=e.onMobileNavigationOpenChange;let r=mo(),i=!!(e.mobileBackTo||r),a=e.mobileTitle??r?.title,o=a===void 0?`Conversation`:a.trim();fo(()=>{n.current(!0)});let s=({isActive:e})=>q(`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`:q(`hover:bg-dashboard-fill-soft`,ua)),c=({isActive:e})=>q(`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`:q(`hover:bg-dashboard-fill-soft`,ua));return(0,Y.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,X.jsxs)(`header`,{className:q(`relative bg-dashboard-bg`,!e.desktopTopBar&&`md:hidden`),children:[e.desktopTopBar?/* @__PURE__ */ (0,X.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,X.jsxs)(`div`,{className:`flex items-center gap-5 max-lg:min-w-0`,children:[/* @__PURE__ */ (0,X.jsx)(B,{"aria-label":`${_a()} home`,className:`flex items-center text-inherit no-underline`,to:`/`,children:/* @__PURE__ */ (0,X.jsx)(Ss,{})}),/* @__PURE__ */ (0,X.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,X.jsx)(B,{"aria-current":e.workspaceActive?`page`:void 0,className:s({isActive:e.workspaceActive}),to:`/`,children:`Conversations`}),e.navItems.map(e=>/* @__PURE__ */ (0,X.jsxs)(ve,{className:s,to:e.to,children:[e.label,/* @__PURE__ */ (0,X.jsx)(Rl,{count:e.count})]},e.key))]})]}),/* @__PURE__ */ (0,X.jsxs)(V,{"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,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center justify-center gap-2`,children:[/* @__PURE__ */ (0,X.jsx)(jt,{"aria-hidden":`true`,className:`size-4 shrink-0`}),/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`truncate max-lg:sr-only`,children:[_l,`…`]})]}),/* @__PURE__ */ (0,X.jsx)(`kbd`,{className:`font-sans text-xs max-xl:hidden`,children:gl})]}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`flex items-center gap-3 justify-self-end`,children:e.profile})]}):null,/* @__PURE__ */ (0,X.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,X.jsx)(`button`,{"aria-label":r.label,className:q(Ll,`cursor-pointer border-0 bg-transparent disabled:cursor-default`),disabled:!r.onClick,onClick:r.onClick,type:`button`,children:/* @__PURE__ */ (0,X.jsx)(Kt,{"aria-hidden":`true`,size:20,strokeWidth:2})}):i&&e.mobileBackTo?/* @__PURE__ */ (0,X.jsx)(B,{"aria-label":`Back to conversations`,className:Ll,to:e.mobileBackTo,children:/* @__PURE__ */ (0,X.jsx)(Kt,{"aria-hidden":`true`,size:20,strokeWidth:2})}):/* @__PURE__ */ (0,X.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,X.jsx)(pn,{"aria-hidden":`true`,size:20,strokeWidth:2})}),i?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`col-start-2 row-start-1 flex min-w-0 items-center gap-2`,children:o?/* @__PURE__ */ (0,X.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,X.jsx)(B,{"aria-label":`${_a()} home`,className:q(`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,X.jsx)(`span`,{className:`truncate font-sans text-sm font-semibold`,children:_a()})}),i?/* @__PURE__ */ (0,X.jsx)(co,{}):null,i?/* @__PURE__ */ (0,X.jsx)(vo,{}):null]}),e.mobileNavigationOpen?/* @__PURE__ */ (0,X.jsxs)(Bl,{closeRef:t,onClose:()=>n.current(!1),children:[/* @__PURE__ */ (0,X.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,X.jsx)(B,{"aria-label":`${_a()} home`,className:`min-w-0 truncate font-sans text-sm font-semibold text-inherit no-underline`,to:`/`,children:_a()}),/* @__PURE__ */ (0,X.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,X.jsx)(Qn,{"aria-hidden":`true`,size:20,strokeWidth:2})})]}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-3`,children:[e.mobileSpend?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`mb-3`,children:e.mobileSpend}):null,/* @__PURE__ */ (0,X.jsxs)(`nav`,{"aria-label":`Primary`,className:`grid gap-1`,children:[/* @__PURE__ */ (0,X.jsxs)(V,{className:q(c({isActive:!1}),`gap-2`),"data-mobile-nav-dismiss":``,onClick:e.onSearch,size:`menu`,children:[/* @__PURE__ */ (0,X.jsx)(jt,{"aria-hidden":`true`,className:`size-4`}),_l]}),/* @__PURE__ */ (0,X.jsx)(B,{"aria-current":e.workspaceActive?`page`:void 0,className:c({isActive:e.workspaceActive}),to:`/`,children:`Conversations`}),e.navItems.map(e=>/* @__PURE__ */ (0,X.jsxs)(ve,{className:c,to:e.to,children:[e.label,/* @__PURE__ */ (0,X.jsx)(Rl,{count:e.count})]},e.key))]}),/* @__PURE__ */ (0,X.jsx)(lo,{}),e.mobileProfile?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`mt-4 border-t border-dashboard-border-subtle pt-3`,children:e.mobileProfile}):null]}),e.mobileIdentity||e.version?/* @__PURE__ */ (0,X.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,X.jsx)(`div`,{className:e.version?`mb-2.5`:void 0,children:e.mobileIdentity}):null,e.version?/* @__PURE__ */ (0,X.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,X.jsx)(Sl,{...t.rootProps,children:/* @__PURE__ */ (0,X.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,X.jsx)(We,{"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,X.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,X.jsxs)(ac,{children:[/* @__PURE__ */ (0,X.jsxs)(sc,{"aria-label":n,className:Hl,isActive:e.active,render:/* @__PURE__ */ (0,X.jsx)(B,{"aria-current":e.active?`page`:void 0,to:e.to}),tooltip:{children:n,size:`compact`,sideOffset:6},children:[/* @__PURE__ */ (0,X.jsx)(t,{"aria-hidden":`true`,strokeWidth:1.9}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:Ul,children:e.label})]}),e.count?/* @__PURE__ */ (0,X.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,X.jsx)(ic,{className:`mt-3 group-data-[collapsible=icon]:items-center`,children:/* @__PURE__ */ (0,X.jsx)(ac,{children:/* @__PURE__ */ (0,X.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,X.jsx)(jt,{"aria-hidden":`true`,strokeWidth:1.9}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:Ul,children:_l})]})})})}function Jl(e){let t=ye({end:!1,path:e.item.to})!==null;return/* @__PURE__ */ (0,X.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,Y.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,X.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,X.jsx)(e?Qt:Gn,{"aria-hidden":`true`,strokeWidth:2})})}function Xl(e){return/* @__PURE__ */ (0,X.jsxs)($s,{className:`border-dashboard-border-strong pt-[env(safe-area-inset-top)]`,collapsible:`icon`,children:[/* @__PURE__ */ (0,X.jsxs)(ec,{className:`px-3 pt-3 pb-4 group-data-[collapsible=icon]:items-center group-data-[collapsible=icon]:px-2`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 group-data-[collapsible=icon]:flex-col`,children:[/* @__PURE__ */ (0,X.jsxs)(B,{"aria-label":`${_a()} home`,className:`flex min-w-0 items-center gap-2 text-inherit no-underline`,to:`/`,children:[/* @__PURE__ */ (0,X.jsx)(Ss,{}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:q(`truncate font-sans text-sm font-semibold`,Ul),children:_a()})]}),/* @__PURE__ */ (0,X.jsx)(Yl,{})]}),/* @__PURE__ */ (0,X.jsx)(ql,{onSearch:e.onSearch}),/* @__PURE__ */ (0,X.jsx)(Vl,{className:`mt-1 bg-dashboard-border-strong group-data-[collapsible=icon]:data-horizontal:w-6`})]}),/* @__PURE__ */ (0,X.jsx)(nc,{className:`group-data-[collapsible=icon]:overflow-auto`,children:/* @__PURE__ */ (0,X.jsx)(rc,{className:`px-3 py-0 group-data-[collapsible=icon]:items-center group-data-[collapsible=icon]:px-2`,children:/* @__PURE__ */ (0,X.jsx)(`nav`,{"aria-label":`Primary`,className:`w-full`,children:/* @__PURE__ */ (0,X.jsxs)(ic,{className:`gap-1 group-data-[collapsible=icon]:items-center group-data-[collapsible=icon]:gap-1.5`,children:[/* @__PURE__ */ (0,X.jsx)(Kl,{active:e.workspaceActive,icon:Sr,label:`Conversations`,to:`/`}),e.navItems.map(e=>/* @__PURE__ */ (0,X.jsx)(Jl,{item:e},e.key))]})})})}),e.profile?/* @__PURE__ */ (0,X.jsx)(tc,{className:`px-3 pb-3 group-data-[collapsible=icon]:items-center group-data-[collapsible=icon]:px-2`,children:/* @__PURE__ */ (0,X.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,Y.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,Y.useRef)(null);return ru(t,e.enabled),/* @__PURE__ */ (0,X.jsx)(`main`,{className:q(`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(Ee(),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),K(Ur,`/api/review-items?${r.toString()}`,t)},getNextPageParam:e=>e.nextCursor,placeholderData:h,retry:!1}),i=r.data?.pages;return{items:(0,Y.useMemo)(()=>(i??[]).flatMap(e=>e.items),[i]),moreArchived:!!i?.[0]?.moreArchived,query:r}}function lu(e){return I({enabled:!!e,queryKey:[...su,`detail`,e],queryFn:({signal:t})=>K(Gr,`/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})=>Ga(await K(kr,`/api/conversations/${encodeURIComponent(e)}?limit=1`,t))??null,retry:!1,staleTime:3e5}))}).map(e=>e.data??void 0)}function du(e){return I({enabled:e,queryKey:[...su,`count`],queryFn:({signal:e})=>K(Vr,`/api/review-items/count`,e),retry:!1})}function fu(e){return I({enabled:e,queryKey:[`dashboard`,`automations`,`scope=mine&state=blocked`],queryFn:({signal:e})=>K(ii,`/api/automations?scope=mine&state=blocked&pageSize=100`,e),retry:!1})}function pu(){let e=P();return N({mutationFn:e=>$i(Gr,`/api/review-items/${encodeURIComponent(e.id)}/actions`,e.body),onSettled:()=>e.invalidateQueries({queryKey:su})})}const mu=/* @__PURE__ */ new Map,hu={queryKey:[...su,`waiting-conversations`],queryFn:({signal:e})=>K(Pr,`/api/review-items/waiting-conversations`,e),retry:!1};function gu(){return!I(hu).isPending}function _u(){let e=I(hu).data?.conversations;return(0,Y.useMemo)(()=>e?new Map(e.map(({conversationId:e,items:t,waitingSince:n})=>[e,{items:t,waitingSince:n}])):mu,[e])}function vu(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 yu(e){return[`conversation`,e,`outbox`]}function bu(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 xu(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 Su(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(xu);t.length>0&&(a=[...r,...t])}return Cu(n,a)}function Cu(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(!wu(e[n],t[n]))return t;return e}function wu(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&&Eu(e.actorIdentity,t.actorIdentity)&&Tu(e.mentions,t.mentions)}function Tu(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((e,n)=>Eu(e,t[n]))}function Eu(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 Du(e){return!!e.inline&&e.status!==`failed`}function Ou(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 ku(e,t){let n=new Set(t.queued.map(e=>e.messageId)),{messageIds:r,turnInputIds:i}=Ou(t.events),a=e=>{let a=n.has(e.messageId);if(!(r.has(e.messageId)||!a&&i.has(e.messageId)))return a?Du(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 Au(e,t,n){let r=n.filter(Du);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)??xu(e)),queued:e.filter(e=>!i.has(e.messageId))}}function ju(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 Mu(e,t,n){return(e??[]).map(e=>e.idempotencyKey===t?{...e,acceptedAtMs:Date.now(),messageId:n,status:`accepted`}:e)}function Nu(e,t){return(e??[]).map(e=>e.idempotencyKey===t?{...e,status:`failed`}:e)}const Pu=[];function Fu(e){if(!e)return Pu;let t=[];for(let n of e)n.data.type===`message`&&t.push(n.data.messageId);return t}function Iu(e,t){return qu(e,t)||(t.length===0?e:{...e,events:Ku([...t.flatMap(e=>e.events),...e.events]),previousCursor:Vu(e.previousCursor,t)??(t.length?Gu(t):e.previousCursor)})}function Lu(e,t,n){return qu(e,t)||{...e,events:Ku([...t.flatMap(e=>e.events),...n]),previousCursor:Gu(t)}}async function Ru(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 Iu(e.detail,n)}function zu(e){let t=Uu(e);return t===void 0?`empty`:String(t)}function Bu(e,t){return Vu(e,t)??Gu(t)}function Vu(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=Uu(r),s=Wu(t.filter(e=>!r.has(e)));if(o!==void 0&&s!==void 0&&o<=s+1)return;a=e.previousCursor}}function Hu(e,t){return t.some(t=>t.eventHistory.status!==e.eventHistory.status)}function Uu(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 Wu(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 Gu(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 Ku(e){return[...new Map(e.map(e=>[e.seq,e])).values()].sort((e,t)=>e.seq-t.seq)}function qu(e,t){if(e.eventHistory.status!==`available`)return Ju(e);let n=t.find(e=>e.eventHistory.status!==`available`);if(n)return Ju({...e,eventHistory:n.eventHistory,events:n.events,previousCursor:n.previousCursor})}function Ju(e){let{modelUsage:t,...n}=e;return n}function Yu(e,t){if(!e)return t;let n=Xu(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 Xu(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 Zu(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 Qu(e){return!!e?.agentTree}function Z(e){return[`conversation`,e,`detail`]}function $u(e){return{id:`conversation:${e}:read`}}function ed(e){return[`conversation`,e,`unread`]}function td(e,t){let n=Z(t),r=e.getQueryState(n);if(!r?.data?.prefetchedAtMs)return;let{prefetchedAtMs:i,...a}=r.data;e.setQueryData(n,a,{updatedAt:r.dataUpdatedAt})}function nd(e){return!!(e?.prefetchedAtMs&&Date.now()-e.prefetchedAtMs<3e4)}const rd=[`agents`,`memories`,`watches`];function id(e,t){return[`conversation`,e,t]}function ad(e,t,n,r){if(n?.detailEtag&&r.detailEtag&&n.detailEtag!==r.detailEtag){for(let n of rd)e.invalidateQueries({queryKey:id(t,n)});e.invalidateQueries({queryKey:su})}}function od(e){return e?.status===`active`||!!e?.mailbox?.messages.length||!!e?.mailbox?.authorization}function sd(e,t){return j({enabled:!!e,queryKey:Z(e),queryFn:async({signal:n,client:r})=>{let i=r.getQueryData(Z(e)),a=await _d(e,n,i,{mailbox:!0,unreadPage:t?.unreadPage});return ad(r,e,i,a),a},structuralSharing:(e,t)=>!t||typeof t!=`object`||!e||typeof e!=`object`?t:cd(e,Yu(e,t)),refetchInterval:e=>t?.fastPollUntilMs&&Date.now()<t.fastPollUntilMs?500:t?.awaitingMessage||od(e.state.data)?2e3:!t?.versionsPoll&&1e4,retry:!1})}function cd(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 ld(){let e=P();return N({mutationFn:e=>$i(qr,`/api/conversations`,e),onSuccess:(t,n)=>{e.setQueryData(yu(t.conversationId),r=>ju(r,{...bu({...n,actorIdentity:vu(e),inline:!0,messageId:t.messageId}),acceptedAtMs:Date.now(),status:`accepted`})),e.invalidateQueries({queryKey:[`dashboard`,`conversations`]}),e.invalidateQueries({exact:!0,queryKey:Z(t.conversationId)})}})}function ud(e){let t=P();return N({mutationFn:async t=>{let n=await $i(Nr,`/api/conversations/${encodeURIComponent(e)}/forks`,{messageId:t.messageId,idempotencyKey:t.idempotencyKey});return $i(qr,`/api/conversations/${encodeURIComponent(n.conversationId)}/messages`,{idempotencyKey:t.idempotencyKey,message:t.message})},onSuccess:(e,n)=>{t.setQueryData(yu(e.conversationId),r=>ju(r,{...bu({idempotencyKey:n.idempotencyKey,message:n.message,actorIdentity:vu(t),inline:!0,messageId:e.messageId}),acceptedAtMs:Date.now(),status:`accepted`})),t.invalidateQueries({queryKey:[`dashboard`,`conversations`]})}})}function dd(e){let t=P(),n=yu(e);return N({mutationFn:({inline:t,...n})=>$i(qr,`/api/conversations/${encodeURIComponent(e)}/messages`,n),onMutate:async r=>{let i=await Pi({conversationId:e,idempotencyKey:r.idempotencyKey}),a=bu({...r,actorIdentity:vu(t),messageId:i});t.setQueryData(n,e=>ju(e,a))},onError:(e,r)=>{t.setQueryData(n,e=>Nu(e,r.idempotencyKey))},onSuccess:(r,i)=>{t.setQueryData(n,e=>Mu(e,i.idempotencyKey,r.messageId)),t.invalidateQueries({queryKey:[`dashboard`,`conversations`]}),t.invalidateQueries({exact:!0,queryKey:Z(e)})}})}function fd(e){let t=P();return N({mutationFn:t=>Qi(Br,`/api/conversations/${encodeURIComponent(e)}/pending-messages`,t),onMutate:async n=>{await t.cancelQueries({exact:!0,queryKey:Z(e)});let r=t.getQueryData(Z(e));return r?.mailbox&&t.setQueryData(Z(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(Z(e),e=>e&&{...e,mailbox:i.previousPending?.mailbox})},onSettled:async()=>{await Promise.all([t.invalidateQueries({queryKey:[`dashboard`,`conversations`]}),t.invalidateQueries({exact:!0,queryKey:Z(e)})])}})}function pd(e){let t=P();return N({mutationFn:t=>$i(li,`/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:Z(e)}),t.setQueryData(Z(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:Z(e)})}})}function md(e){return[`conversation`,e,`stopped-messages`]}function hd(e){let t=P();return N({mutationFn:()=>$i(Or,`/api/conversations/${encodeURIComponent(e)}/stop`,{}),onSuccess:n=>{let r=n.stoppedInboundMessageIds;r.length&&(t.setQueryData(md(e),e=>[...e??[],...r]),t.setQueryData(yu(e),e=>e?.filter(e=>!r.includes(e.messageId))))},onSettled:async()=>{await t.invalidateQueries({exact:!0,queryKey:Z(e)})}})}function gd(e,t){let n=P(),r=()=>{let t=nd(n.getQueryData(Z(e)));return{conversationId:e,fetched:t,prefetched:t}},[i,a]=(0,Y.useState)(r);i.conversationId!==e&&a(r());let o=i.conversationId===e&&i.fetched,s=i.conversationId===e&&i.prefetched,c=I({enabled:!!e,queryFn:async()=>n.getQueryData(yu(e))??[],queryKey:yu(e),initialData:[],staleTime:1/0,gcTime:1/0}),l=I({enabled:!!e,queryFn:async()=>n.getQueryData(md(e))??[],queryKey:md(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=I({...sd(e,{awaitingMessage:u.length>0,fastPollUntilMs:d?d+6e3:void 0,unreadPage:!!t?.unreadPageAtOpen&&!o,versionsPoll:t?.versionsPoll})}),p=f.refetch;(0,Y.useEffect)(()=>{if(e)return p({cancelRefetch:!1}),()=>td(n,e)},[e,n,p]),!o&&f.isFetchedAfterMount&&!f.isFetching&&a({conversationId:e,fetched:!0,prefetched:s});let m=(0,Y.useDeferredValue)(f.data),h=m&&m.conversationId===e?m:f.data,g=h?.mailbox;(0,Y.useEffect)(()=>{g&&h&&n.setQueryData(yu(e),e=>e&&ku(e,{events:h.events,mailboxReadAtMs:h.mailboxReadAtMs,queued:g.messages}))},[e,h,g,c.data,n]);let _=f.data?.displayTitle,v=f.dataUpdatedAt;(0,Y.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,Y.useMemo)(()=>[`conversation`,e,`history`,y],[e,y]),x=O({enabled:!1,queryKey:b,queryFn:async({pageParam:t,signal:n})=>({...await bd(e,t,n),requestedBefore:t}),initialPageParam:h?.previousCursor??``,getNextPageParam:(e,t)=>Bu(h?.previousCursor,t),retry:!1}),S=x.data?.pages,C=(0,Y.useMemo)(()=>h?Iu(h,S??[]):void 0,[h,S]),w=(0,Y.useRef)(void 0),T=(0,Y.useRef)(void 0),{inlineMessages:E,pendingMessages:D}=(0,Y.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=Au(Su(t,n),t,n),i=Cu(w.current,r.queued),a=Cu(T.current,r.inline);return w.current=i,T.current=a,{inlineMessages:a,pendingMessages:i}},[c.data,g?.messages,l.data]),k=xd(x.error),A=!!(h&&(Hu(h,S??[])||k)),j=k?null:x.error,M=!(!h?.previousCursor||!x.data||!Vu(h.previousCursor,x.data.pages)||A||x.error||x.isFetchingNextPage),ee=x.isFetchingNextPage||M;(0,Y.useEffect)(()=>{A&&p()},[p,A]),(0,Y.useEffect)(()=>{k&&n.resetQueries({exact:!0,queryKey:b})},[b,k,n]);let N=x.fetchNextPage;return(0,Y.useEffect)(()=>{M&&N({cancelRefetch:!1})},[N,M]),{data:C,latest:f.data,error:f.error,historyError:j,historyVersion:zu(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 Ru({detail:h,historyPages:x.data?.pages??[],readPage:t=>bd(e,t)})},loadPreviousPage:()=>{let t=x.data?x.hasNextPage:!!h?.previousCursor;e&&t&&x.fetchNextPage({cancelRefetch:!1})}}}async function _d(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 Xi(`/api/conversations/${encodeURIComponent(e)}${o}`,t,n?.detailEtag?{[Ri]:n.detailEtag}:void 0);if(c.status===304&&n)return n;if(!r?.mailbox)return yd(vd(await ea(c,kr),n),c);let u=await ea(c,l([ei,Oi]));if(!(`unchanged`in u))return{...yd(vd(u,n),c),mailboxReadAtMs:s};if(!n)throw Error(`Unchanged detail without a cached copy`);return{...n,mailbox:u.mailbox,mailboxReadAtMs:s}}function vd(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 yd(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 bd(e,t,n){let r=new URLSearchParams({before:t});return K(Ii,`/api/conversations/${encodeURIComponent(e)}/events?${r}`,n).then(e=>{if(e.previousCursor===t)throw Error(`Conversation history cursor did not advance`);return e})}function xd(e){return e instanceof na&&e.status===400}function Sd(e,t,n){return e.map(e=>e.conversationId===t?{...e,...n}:e.threads?{...e,threads:Sd(e.threads,t,n)}:e)}function Cd(e,t,n){for(let r of e){if(r.conversationId===t)return{parentConversationId:n,row:r};let e=r.threads&&Cd(r.threads,t,r.conversationId);if(e)return e}}function wd(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:wd(e.threads,t,n)}:e)}function Td({queryKey:e}){return e[0]===`conversation`&&(e[2]===`detail`||e[2]===`agents`)}function Ed(e){return[`dashboard`,`archived-conversation`,e]}function Dd(e){let t=e[e.length-1];return t===`active`||t===`archived`?t:void 0}const Od=[`dashboard`,`archive-conversation`];function kd(){return b({filters:{mutationKey:Od,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 Ad(e){let t=b({filters:{exact:!0,mutationKey:[...Od,e]},select:e=>e.state.status});return e?t.at(-1):void 0}function jd(e,t){let n=xe(),r=_e(),i=n.state?.archivedConversation,a=Ad(i?.id);(0,Y.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 Md(e,t){let n=P();return N(Nd(n,e,t))}function Nd(e,t,n){return _({mutationKey:[...Od,t],mutationFn:e=>Wi(hi,`/api/conversations/${encodeURIComponent(t)}/archive`,{...e,applyToChildren:!0}),onMutate:async n=>{let r={queryKey:[`dashboard`,`conversations`]},i=Z(t),a=Ed(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=Pd(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=!!Cd(i.conversations,t),o=Dd(r),s=!n.archived&&!a&&!!f&&o!==`archived`,c=f?.parentConversationId,l=s?c?wd(i.conversations,c,{...f.conversation,archivedAt:null}):[...i.conversations,{...f.conversation,archivedAt:null}].sort((e,t)=>t.lastSeenAt.localeCompare(e.lastSeenAt)):Sd(i.conversations,t,u);e.setQueryData(r,{...i,conversations:n.archived?Id(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(Z(t),e=>e&&{...e,archivedAt:r.archivedAt,detailEtag:void 0}),i.archived||e.removeQueries({exact:!0,queryKey:Ed(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:Td})])}})}function Pd(e,t){let n,r=[];for(let[i,a]of e){let e=a&&Cd(a.conversations,t);e&&(n??=e,r.push(JSON.stringify(i)))}return n?{conversation:n.row,feedQueryHashes:r,parentConversationId:n.parentConversationId}:void 0}function Fd(e,t){let n=e??(t?.conversation?$a([t.conversation])[0]:void 0);if(!n||!t)return n;let r=t.archived?n.archivedAt??n.lastSeenAt:null;return{...n,archivedAt:r}}function Id(e,t){return e.map(e=>{if(!e.threads)return e;let{threads:n,...r}=e,i=Id(n.filter(e=>!t(e)),t);return i.length?{...r,threads:i}:r})}const Ld=`conversation-archived`,Rd=6e3;function zd(e){return`conversation-action-error:${e}`}function Bd(){let{add:e,close:t,update:n}=zo(),r=P(),i=(0,Y.useCallback)((t,n)=>{e({description:za(t),id:zd(t.id),priority:`high`,title:n,type:`error`})},[e]),a=(0,Y.useCallback)((e,t)=>{i(e,t?`Could not archive`:`Could not restore`)},[i]),o=(0,Y.useCallback)(e=>{t(zd(e.id))},[t]),s=(0,Y.useCallback)(a=>{o(a);let s=za(a),c={"aria-label":`Undo archive for ${s}`,children:`Undo`,onClick:l};function l(){n(Ld,{actionProps:{...c,children:`Restoring…`,disabled:!0},type:`loading`}),new E(r,Nd(r,a.id)).mutate({archived:!1,lastSeenAt:a.lastSeenAt}).then(()=>t(Ld),u)}function u(){let e=!1;n(Ld,t=>t.data?.conversationId===a.id?(e=!0,{actionProps:c,timeout:Rd,title:`Could not restore`,type:`error`}):{}),e||i(a,`Could not restore`)}e({actionProps:c,data:{conversationId:a.id},description:s,id:Ld,timeout:Rd,title:`Conversation archived`,type:`success`})},[e,o,t,r,i,n]);return(0,Y.useMemo)(()=>({clearActionError:o,showActionError:i,showArchiveError:a,showArchived:s}),[o,i,a,s])}function Vd(e,t){let n=P(),r={queryKey:[`dashboard`,`conversations`]},i=Z(e);return N({mutationKey:ed(e),scope:$u(e),mutationFn:t=>Wi(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 Hd(e,t){let n=P(),r={queryKey:[`dashboard`,`conversations`]},i=Z(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=>Wi(vi,`/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 Ud(e,t){let n=P(),r={queryKey:[`dashboard`,`conversations`]},i=Z(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=>Wi(Wr,`/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 Wd(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 Gd=`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`,Kd=ae(Gd,{variants:{size:{default:``,comfortable:`min-h-11 text-base sm:min-h-10 sm:text-sm`}},defaultVariants:{size:`default`}});function qd({className:e,size:t,...n}){return/* @__PURE__ */ (0,X.jsx)(xt,{"data-slot":`input`,className:F(Kd({size:t}),e),...n,onKeyDown:e=>{n.onKeyDown?.(e),Wd(e)}})}function Jd({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(`div`,{"data-slot":`field`,className:F(`grid gap-2`,e),...t})}function Yd({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(`label`,{"data-slot":`field-label`,className:F(`text-sm font-semibold text-dashboard-text`,e),...t})}function Xd({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(`p`,{"data-slot":`field-description`,className:F(`m-0 text-xs leading-relaxed text-dashboard-text-muted sm:text-sm`,e),...t})}function Zd({className:e,...t}){return t.children?/* @__PURE__ */ (0,X.jsx)(`p`,{role:`alert`,"data-slot":`field-error`,className:F(`m-0 text-xs leading-relaxed text-rose-300`,e),...t}):null}function Qd(e){let t=(0,Y.useId)(),n=(0,Y.useRef)(null),[r,i]=(0,Y.useState)(e.title),a=Pl(e.onClose,n),o=r.trim(),s=o.length>0&&o!==e.title;return/* @__PURE__ */ (0,X.jsx)(il,{...a.rootProps,children:/* @__PURE__ */ (0,X.jsx)(ol,{...a.contentProps,children:/* @__PURE__ */ (0,X.jsxs)(`form`,{className:`grid gap-4`,onSubmit:t=>{t.preventDefault(),s&&e.onSave(o),a.rootProps.onOpenChange(!1,{cancel(){}})},children:[/* @__PURE__ */ (0,X.jsx)(sl,{children:`Rename conversation`}),/* @__PURE__ */ (0,X.jsxs)(Jd,{children:[/* @__PURE__ */ (0,X.jsx)(Yd,{htmlFor:t,children:`Title`}),/* @__PURE__ */ (0,X.jsx)(qd,{ref:n,id:t,maxLength:200,value:r,onChange:e=>i(e.target.value),onFocus:e=>e.target.select()})]}),/* @__PURE__ */ (0,X.jsxs)(cl,{children:[/* @__PURE__ */ (0,X.jsx)(al,{render:/* @__PURE__ */ (0,X.jsx)(V,{children:`Cancel`})}),/* @__PURE__ */ (0,X.jsx)(V,{variant:`primary`,type:`submit`,disabled:!s,children:`Save`})]})]})})})}function $d(e,t){let n=P(),r=Z(e);return N({onError:()=>t?.onError?.(),mutationFn:t=>Wi(pi,`/api/conversations/${encodeURIComponent(e)}/delivery`,{paused:t}),onSuccess:e=>{n.setQueryData(r,t=>t&&{...t,deliveryPaused:e.paused,detailEtag:void 0})}})}function ef(e,t){let n=P(),r=Z(e);return N({onError:()=>t?.onError?.(),mutationFn:t=>Wi(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 tf(){return/* @__PURE__ */ (0,X.jsx)(Ln,{"aria-hidden":`true`,className:`ml-1 inline size-[0.8em] shrink-0 align-[-0.05em] opacity-60`})}function nf({children:e,...t}){return/* @__PURE__ */ (0,X.jsxs)(`a`,{...t,rel:`noreferrer`,target:`_blank`,children:[e,/* @__PURE__ */ (0,X.jsx)(tf,{})]})}function rf(e){let t=(0,Y.useId)(),n=(0,Y.useRef)(null),r=Pl(e.onClose,n),i=P(),a=fs(),o=(0,Y.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,Y.useState)(``),l=(0,Y.useMemo)(()=>of(o,s.trim()),[o,s]),[u,d]=(0,Y.useState)(``),f=l.some(e=>e.channel.id===u)?u:l[0]?.channel.id??``,p=N({mutationFn:t=>$i(si,`/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:Z(e.conversationId)})])}),m=()=>{f&&!p.isPending&&p.mutate(f)},h=p.error?p.error instanceof na&&p.error.apiError||`Could not move the conversation. Try again.`:a.error?`Could not load channels. Try again.`:void 0;return/* @__PURE__ */ (0,X.jsx)(il,{...r.rootProps,onOpenChange:(e,t)=>{!e&&p.isPending?t.cancel():r.rootProps.onOpenChange(e,t)},children:/* @__PURE__ */ (0,X.jsx)(ol,{...r.contentProps,children:p.data?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(sl,{children:`Moved to Slack`}),/* @__PURE__ */ (0,X.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,X.jsxs)(cl,{children:[/* @__PURE__ */ (0,X.jsx)(al,{render:/* @__PURE__ */ (0,X.jsx)(V,{children:`Close`})}),p.data.locationUrl?/* @__PURE__ */ (0,X.jsx)(nf,{className:Tt({variant:`primary`}),href:p.data.locationUrl,children:`Open in Slack`}):null]})]}):/* @__PURE__ */ (0,X.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),m()},children:[/* @__PURE__ */ (0,X.jsx)(sl,{children:`Continue in Slack`}),/* @__PURE__ */ (0,X.jsxs)(Jd,{children:[/* @__PURE__ */ (0,X.jsx)(Yd,{children:`Channel`}),/* @__PURE__ */ (0,X.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,X.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,X.jsxs)(fl,{className:`max-h-64 sm:max-h-64`,children:[/* @__PURE__ */ (0,X.jsx)(pl,{children:a.isPending?`Loading channels…`:o.length?`No matching channels.`:`No public channels yet.`}),l.slice(0,af).map(e=>/* @__PURE__ */ (0,X.jsxs)(hl,{disabled:p.isPending,onSelect:d,value:e.channel.id,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:/* @__PURE__ */ (0,X.jsx)(Gc,{label:e.channel.label,matches:e.matches})}),e.channel.id===f?/* @__PURE__ */ (0,X.jsx)(Xt,{"aria-hidden":`true`}):null]},e.channel.id))]}),l.length>af?/* @__PURE__ */ (0,X.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,X.jsx)(Xd,{children:`Junior starts a thread there with this conversation. You can move a conversation once.`}),/* @__PURE__ */ (0,X.jsx)(Zd,{id:t,children:h})]}),/* @__PURE__ */ (0,X.jsxs)(cl,{children:[/* @__PURE__ */ (0,X.jsx)(al,{disabled:p.isPending,render:/* @__PURE__ */ (0,X.jsx)(V,{children:`Cancel`})}),/* @__PURE__ */ (0,X.jsx)(V,{variant:`primary`,type:`submit`,disabled:!f||p.isPending,children:p.isPending?`Moving…`:`Move to channel`})]})]})})})}const af=50;function of(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 sf({...e}){return/* @__PURE__ */ (0,X.jsx)(nt,{"data-slot":`context-menu`,...e})}function cf({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(rt,{"data-slot":`context-menu-trigger`,className:F(`select-none`,e),...t})}function lf({className:e,align:t=`start`,alignOffset:n=4,side:r=`right`,sideOffset:i=0,...a}){return/* @__PURE__ */ (0,X.jsx)(Xe,{children:/* @__PURE__ */ (0,X.jsx)(st,{className:`isolate z-50 outline-none`,align:t,alignOffset:n,side:r,sideOffset:i,children:/* @__PURE__ */ (0,X.jsx)(_t,{"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 uf=`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 df({className:e,inset:t,variant:n=`default`,...r}){return/* @__PURE__ */ (0,X.jsx)(Qe,{"data-slot":`context-menu-item`,"data-inset":t,"data-variant":n,className:F(uf,e),...r})}function ff({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(St,{"data-slot":`context-menu-item`,className:F(uf,e),...t})}function pf({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(We,{"data-slot":`context-menu-separator`,className:F(`-mx-1 my-1 h-px bg-border`,e),...t})}const mf=s({memories:u(s({id:p(),content:p(),observedAtMs:a(),scope:o([`personal`,`conversation`]),kind:o([`preference`,`procedure`,`knowledge`])}).strict())}).strict();function hf(e){if(e.pluginName!==`memory`||e.kind!==`recall`||e.version!==1)return;let t=mf.safeParse(e.content);return t.success?t.data:void 0}const gf=s({text:p()}).strict();function _f(e){if(e.pluginName!==`junior`||e.kind!==`user_customization`||e.version!==1)return;let t=gf.safeParse(e.content);return t.success?t.data:void 0}function vf(e){return e.role===`user`&&e.eventType!==void 0&&Fr(e.eventType)}function yf(e){return e.contexts?.some(e=>hf(e))===!0}function bf(e){let t=[];for(let n of e){if(vf(n)&&!yf(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 xf(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(jr)].filter(Boolean).join(`
8
+
9
+ `)}function Sf(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 Cf(e,t){let n=_a();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 wf(e,t,n){return[Sf(e,t),Cf(e,t),e.replaceAll(`_`,` `),...t?[t.replaceAll(`_`,` `)]:[],...n?[`event_id=${n}`,n]:[]].join(` `)}function Tf(e,t){if(e.previousCursor)throw Error(`Cannot export a partial conversation transcript`);let n=[];return n.push(`# ${Gf(Rf(e,t))}`,``),Wf(n,`Conversation ID`,Kf(e.conversationId)),Wf(n,`Generated`,e.generatedAt),Wf(n,`Actor`,zf(t,e)),Wf(n,`Location`,Bf(t,e)),Wf(n,`Usage`,[io(e.cumulativeUsage),no(e.cumulativeUsage,e.auxiliaryCosts)].filter(Boolean).join(` · `)),Wf(n,`Sentry conversation`,e.sentryConversationUrl),n.push(``,`## Transcript`),Ef(n,e),Jf(n)}function Ef(e,t){let n=La(t);t.eventHistory.status===`available`?Df(e,t,n,!1):t.eventHistory.status===`redacted`&&n.length?(e.push(``,`Transcript hidden because this conversation is not public.`),Df(e,t,n,!0)):n.length?Df(e,t,n,!1):e.push(``,Ia(t))}function Df(e,t,n,r){for(let i of bf(n))if(i.kind===`message`)i.message.eventType?jf(e,t,i.message,r):i.message.context?Mf(e,t,i.message,r):Nf(e,t,i.message,r);else if(i.kind===`failure`)kf(e,t,i.failureCode,i.failureReason,i.eventId,i.sentryEventUrl,i.timestamp);else if(i.kind===`subagent`)Ff(e,t,i.part,i.timestamp);else if(i.kind===`context`)Af(e,t,i.part,i.timestamp);else if(i.kind===`reasoning`)Of(e,t,i.part,i.timestamp);else if(i.kind===`structured_event`){e.push(``,`### ${i.part.presentation.title}`),Lf(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(``,qf(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`}`),Lf(e,t,i.timestamp);for(let t of i.part.attachments)e.push(``,`- ${t.filename} (${t.contentType}, ${t.bytes} bytes)`)}else If(e,t,i.part,i.timestamp)}function Of(e,t,n,r){e.push(``,`### Reasoning`),Lf(e,t,r),e.push(``,n.redacted?`<redacted>`:n.text)}function kf(e,t,n,r,i,a,o){e.push(``,`### ${Sf(n,r)}`),Lf(e,t,o),e.push(``,Cf(n,r)),Wf(e,`Code`,n),r&&Wf(e,`Reason`,r),i&&Wf(e,`Event id`,a?`[${i}](${a})`:i)}function Af(e,t,n,r){let i=n.event;e.push(``,`### Context compacted`),Lf(e,t,r),Wf(e,`Model`,i.modelId),i.details&&(Wf(e,`Estimated input tokens`,String(i.details.estimatedInputTokens)),i.details.replacementInputTokens!==void 0&&Wf(e,`Replacement input tokens`,String(i.details.replacementInputTokens)),Wf(e,`Compaction trigger`,String(i.details.triggerTokens)),Wf(e,`Input limit`,String(i.details.inputLimitTokens)),Wf(e,`Input messages`,String(i.details.inputMessageCount)),Wf(e,`Retained messages`,String(i.details.retainedMessageCount)),Wf(e,`Summary characters`,String(i.details.summaryChars))),i.summary&&e.push(``,`#### Continuation summary`,``,i.summary)}function jf(e,t,n,r){if(e.push(``,`### Event: ${Gf(n.eventType??``)}`),Lf(e,t,n.timestamp),r){e.push(``,`- <redacted>`);return}let i=xf(n);e.push(``,i.trim().length?i:`_No content._`)}function Mf(e,t,n,r){e.push(``,`### Context from ${Vf(n,t)}`),Lf(e,t,n.timestamp),e.push(``,r?`<redacted>`:xf(n)),r||Pf(e,n.contexts)}function Nf(e,t,n,r){if(e.push(``,`### ${Vf(n,t)}`),Lf(e,t,n.timestamp),r){e.push(``,...n.parts.map(()=>`- <redacted>`));return}let i=xf(n);e.push(``,i.trim().length?i:`_No content._`),Pf(e,n.contexts)}function Pf(e,t){for(let n of t??[]){let t=hf(n);if(e.push(``,t?`#### Recalled memories`:`#### ${Gf(n.kind)} context`),Wf(e,`Plugin`,n.pluginName),Wf(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: ${Kf(n.id)}`,` - Observed: ${new Date(n.observedAtMs).toISOString()}`,` - Scope: ${n.scope}`,` - Kind: ${n.kind}`)}}function Ff(e,t,n,r){e.push(``,`### ${n.childKind===`thread`?`Thread`:`Task`}: ${Gf(n.agentName??n.subagentKind)}`),Lf(e,t,r),Wf(e,`Status`,n.status),Wf(e,`Title`,n.title),Wf(e,`Task`,n.task)}function If(e,t,n,r){e.push(``,`### Tool: ${Gf(n.name)}`),Lf(e,t,r),Wf(e,`Status`,n.status),Wf(e,`Duration`,Ya(r,n.resultTimestamp)),n.input!==void 0&&e.push(``,`#### Arguments`,``,qf(ka(n.input),`json`)),n.output!==void 0&&e.push(``,`#### Result`,``,qf(ka(n.output),`json`))}function Lf(e,t,n){let r=[Hf(n),Uf(t,n)].filter(Yf);r.length&&e.push(``,`_${r.join(` - `)}_`)}function Rf(e,t){return e.displayTitle.trim()||(t?za(t):`Conversation`)}function zf(e,t){return to(e?.actorIdentity??t?.actorIdentity)??``}function Bf(e,t){return e?Ka(e)??``:t?Ka(t)??``:``}function Vf(e,t){return Gf(so(t,e))}function Hf(e){return typeof e!=`number`||!Number.isFinite(e)?``:new Date(e).toISOString()}function Uf(e,t){if(typeof t!=`number`||!Number.isFinite(t))return``;let n=Date.parse(e.startedAt);return!Number.isFinite(n)||t<n?``:`+${Ua(t-n)}`}function Wf(e,t,n){n&&e.push(`- ${t}: ${n}`)}function Gf(e){return e.replace(/\s+/g,` `).trim()||`Untitled`}function Kf(e){let t=e.includes("`")?"``":"`";return`${t}${e}${t}`}function qf(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 Jf(e){return`${e.join(`
10
+ `)}\n`}function Yf(e){return e.length>0}function Xf(e){let[t,n]=(0,Y.useState)(`idle`),r=t===`copied`?`Copied`:t===`copying`?e.copyingLabel??`Copying`:t===`failed`?`Copy failed`:e.label,i={copied:Xt,copying:hr,failed:qn,idle:hr}[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 Zf(e){let{copy:t,disabled:n,failed:r,icon:i,label:a}=Xf(e);return/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(U,{render:/* @__PURE__ */ (0,X.jsx)(V,{focusableWhenDisabled:!0,"aria-label":a,disabled:n,onClick:()=>void t(),size:`icon`,children:/* @__PURE__ */ (0,X.jsx)(i,{"aria-hidden":`true`,className:r?`text-rose-300`:void 0,size:15,strokeWidth:2})})}),/* @__PURE__ */ (0,X.jsx)(W,{size:`compact`,children:a})]})}function Qf(e){return/* @__PURE__ */ (0,X.jsxs)(`svg`,{"aria-label":`Slack`,className:e.className,fill:`currentColor`,role:`img`,viewBox:`0 0 127 127`,children:[/* @__PURE__ */ (0,X.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,X.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,X.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,X.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 $f(e){let t=he(kc(e)),[n,r]=(0,Y.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`?Xt:kn,label:i,share:o}}function ep(e){let t=$f(e.conversationId),n=Xf({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&&Ea(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:tp,key:`continue-in-slack`,label:`Continue in Slack`,onClick:r.continueInSlack}),a?.deliveryPaused!==void 0&&f.push({disabled:o.delivery,icon:a.deliveryPaused?Vt:cr,key:`delivery`,label:a.deliveryPaused?`Reattach to Slack`:`Detach from Slack`,onClick:()=>r.delivery(!a.deliveryPaused),toggle:!0}),f.push({icon:e.eventLogOpen?Sr:gr,key:`event-log`,label:e.eventLogOpen?`Back to conversation`:`Open event log`,onClick:r.eventLog}),a?.sentryConversationUrl&&f.push({href:a.sentryConversationUrl,icon:np,key:`sentry`,label:`Open in Sentry`});let p=[{disabled:!u||o.read||!l&&!(i&&Ca(i)),icon:l?zt:_n,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?Ft:Nt,key:`pin`,label:c?`Unpin`:`Pin`,onClick:()=>r.pin(!c),toggle:!0}),p.push({disabled:!u,icon:tn,key:`rename`,label:`Rename`,onClick:r.rename},{disabled:a?.subscribed===void 0||o.subscription,icon:a?.subscribed?vn:mn,key:`subscription`,label:a?.subscribed?`Unsubscribe`:`Subscribe`,onClick:()=>r.subscription(!a?.subscribed),toggle:!0},{disabled:!u||o.archive,icon:s?wn:bn,key:`archive`,label:o.archive?`Saving archive state`:s?`Restore`:`Archive`,onClick:r.archive}),[f,p]}function tp(e){return/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex`,children:/* @__PURE__ */ (0,X.jsx)(Qf,{className:e.className})})}function np(e){return/* @__PURE__ */ (0,X.jsx)(`svg`,{"aria-hidden":`true`,className:e.className,fill:`currentColor`,viewBox:`0 0 24 24`,children:/* @__PURE__ */ (0,X.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 rp(e){let t=I({...sd(e.conversationId),enabled:!1}).data;return ep({...e,detail:t,getMarkdown:t?async()=>Tf(await Ru({detail:t,historyPages:[],readPage:t=>bd(e.conversationId,t)}),e.conversation):void 0}).map((e,t)=>/* @__PURE__ */ (0,X.jsxs)(Y.Fragment,{children:[t>0?/* @__PURE__ */ (0,X.jsx)(pf,{}):null,e.map(e=>e.href?/* @__PURE__ */ (0,X.jsxs)(ff,{href:e.href,rel:`noreferrer`,target:`_blank`,children:[/* @__PURE__ */ (0,X.jsx)(e.icon,{"aria-hidden":`true`}),e.label]},e.key):/* @__PURE__ */ (0,X.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,X.jsxs)(df,{closeOnClick:!e.stayOpen,disabled:e.disabled,onClick:e.onClick,children:[/* @__PURE__ */ (0,X.jsx)(e.icon,{"aria-hidden":`true`}),e.label]}),e.feedback===void 0?null:/* @__PURE__ */ (0,X.jsx)(`span`,{className:`sr-only`,role:`status`,children:e.feedback})]},e.key))]},t))}const ip=(0,Y.createContext)(null);function ap(e){let{conversations:t,onError:i,reorder:a}=e,o=(0,Y.useMemo)(()=>t.map(e=>e.id),[t]),s=(0,Y.useCallback)((e,n)=>{let r=o.indexOf(e);r<0||n<0||n>=o.length||r!==n&&a?.({conversationIds:le(o,r,n),onError:()=>i(t[r])})},[t,o,i,a]),l=!a||o.length<2,u=(0,Y.useMemo)(()=>({disabled:l,move:s}),[l,s]),p=c(r(n,{activationConstraint:{distance:4}}),r(se,{activationConstraint:{delay:250,tolerance:5}})),m=(0,Y.useMemo)(()=>lp(t),[t]);return/* @__PURE__ */ (0,X.jsxs)(ce,{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,X.jsx)(oe,{items:o,children:/* @__PURE__ */ (0,X.jsx)(ip.Provider,{value:u,children:e.children})}),(0,ou.createPortal)(/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(d,{dropAnimation:null,children:/* @__PURE__ */ (0,X.jsx)(cp,{conversations:t})}),/* @__PURE__ */ (0,X.jsx)(sp,{ids:o})]}),document.body)]})}function op(e){let t=(0,Y.useContext)(ip),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 sp(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,X.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 cp(e){let{active:t}=i(),n=e.conversations.find(e=>e.id===t?.id);return n?/* @__PURE__ */ (0,X.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,X.jsx)(Nt,{"aria-hidden":`true`,className:`size-3 shrink-0 text-dashboard-text-muted`,fill:`currentColor`}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:za(n)})]}):null}function lp(e){let t=t=>{let n=e.find(e=>e.id===t);return n?za(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 up(e){let t=mp(),n=t?0:e.durationMs??180,[r,i]=(0,Y.useState)(()=>e.items.map(t=>({item:t,key:e.getKey(t),state:`present`}))),a=(0,Y.useRef)(e.items.length>0),o=r.some(e=>e.state===`exiting`),s=(0,Y.useCallback)(e=>{i(t=>t.filter(t=>t.key!==e))},[]);return(0,Y.useLayoutEffect)(()=>{i(t=>dp(t,e.items,e.getKey,a.current)),e.items.length>0&&(a.current=!0)},[e.getKey,e.items]),(0,Y.useEffect)(()=>{if(!r.some(e=>e.state===`entering`))return;if(t){i(e=>pp(e));return}let e=window.requestAnimationFrame(()=>{i(e=>pp(e))});return()=>window.cancelAnimationFrame(e)},[r,t]),/* @__PURE__ */ (0,X.jsx)(`div`,{"aria-label":r.length>0?e.ariaLabel:void 0,className:q(e.className,o&&`pointer-events-none`),role:r.length>0?e.role:void 0,children:r.length>0?r.map(t=>/* @__PURE__ */ (0,X.jsx)(fp,{animatedItem:t,durationMs:n,onExited:s,renderItem:e.renderItem},t.key)):e.empty})}function dp(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 fp(e){let{animatedItem:t,durationMs:n,onExited:r}=e;return(0,Y.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,X.jsx)(`div`,{"aria-hidden":t.state===`exiting`||void 0,className:q(`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,X.jsx)(`div`,{className:`min-h-0 min-w-0 overflow-hidden`,children:e.renderItem(t.item)})})}function pp(e){return e.map(e=>e.state===`entering`?{...e,state:`present`}:e)}function mp(){let[e,t]=(0,Y.useState)(!1);return(0,Y.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 hp(e){return/* @__PURE__ */ (0,X.jsx)(`svg`,{"aria-label":`GitHub`,className:e.className,fill:`currentColor`,role:`img`,viewBox:`0 0 24 24`,children:/* @__PURE__ */ (0,X.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 gp(e){return e===`github`?`github`:void 0}function _p(e,t){if(e.postedTo)return gp(e.postedTo);if(t.surface===`slack`&&(e.role===`user`||e.role===`assistant`))return e.source===`slack`?`slack`:void 0}function vp(e){return gp(e.eventNamespace)}function yp(e){return gp(e.plugin)===`github`?/* @__PURE__ */ (0,X.jsx)(hp,{className:`size-3 shrink-0 text-dashboard-text-muted`}):/* @__PURE__ */ (0,X.jsx)(dr,{"aria-hidden":`true`,className:`size-3 shrink-0 text-dashboard-text-muted`})}function bp(e){let[t,...n]=e.waiting.items;return t?/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(U,{render:/* @__PURE__ */ (0,X.jsxs)(B,{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.conversationId,{reviewItems:!0}),children:[/* @__PURE__ */ (0,X.jsx)(yp,{plugin:t.plugin}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:t.title}),n.length>0?/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`ml-auto shrink-0 text-dashboard-text-faint`,children:[`+`,n.length,` more`]}):null,/* @__PURE__ */ (0,X.jsx)(H,{"aria-hidden":`true`,className:q(`size-3 shrink-0 text-dashboard-text-muted`,n.length>0?void 0:`ml-auto`)})]})}),/* @__PURE__ */ (0,X.jsx)(W,{align:`start`,side:`right`,children:/* @__PURE__ */ (0,X.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.waiting.items.map((e,t)=>/* @__PURE__ */ (0,X.jsxs)(`li`,{className:`flex items-start gap-1.5 text-dashboard-text`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`mt-0.5 flex`,children:/* @__PURE__ */ (0,X.jsx)(yp,{plugin:e.plugin})}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 break-words`,children:e.title})]},t))})})]}):null}function xp(e){return e.map(e=>({ids:e.conversations.map(e=>e.id),key:e.key,label:e.label}))}function Sp(e,t){let n=t.flatMap(e=>e.conversations.map(t=>({conversation:t,section:e}))),r=new Map(n.map(e=>[e.conversation.id,e.conversation])),i=new Set(e.flatMap(e=>e.ids)),a=-1;n.forEach((e,t)=>{i.has(e.conversation.id)&&(a=t)});let o=e.map(e=>({conversations:e.ids.flatMap(e=>r.get(e)??[]),key:e.key,label:e.label}));for(let{conversation:e,section:t}of n.slice(a+1)){let n=o.find(e=>e.key===t.key);n?n.conversations.push(e):o.push({...t,conversations:[e]})}let s=/* @__PURE__ */ new Map;for(let e of o)e.conversations.forEach((t,n)=>s.set(t.id,{index:n,key:e.key}));let c=0;for(let e of t){let t=e.conversations.flatMap(t=>{let n=s.get(t.id);return n?.key===e.key?[n.index]:[]});c+=e.conversations.length-Cp(t)}return{pending:c,sections:o.filter(e=>e.conversations.length>0)}}function Cp(e){let t=[];for(let n of e){let e=0,r=t.length;for(;e<r;){let i=e+r>>1;t[i]<n?e=i+1:r=i}t[e]=n}return t.length}function wp(e,t){let[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),c=t.settled&&(i||o);c&&!n&&r({following:!1,order:xp(e)}),!c&&n&&r(null);let l=n&&!n.following?Sp(n.order,e):{pending:0,sections:e};(0,Y.useEffect)(()=>{o&&document.activeElement===document.body&&s(!1)},[o,l.pending]);let u=(0,Y.useCallback)(()=>r(t=>t&&{following:!1,order:xp(e)}),[e]),d=(0,Y.useCallback)(()=>r(e=>e&&{following:!0,order:e.order}),[]);return{applyPending:u,holdProps:{onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||s(!1)},onFocus:()=>s(!0),onPointerEnter:e=>{e.pointerType!==`touch`&&a(!0)},onPointerLeave:()=>a(!1)},pending:l.pending,releaseHold:d,sections:l.sections}}function Tp(e){let t=(0,Y.useMemo)(()=>gc(e.conversations,{nowMs:Date.now(),timeZone:e.timeZone,waiting:e.waitingConversations}),[e.conversations,e.timeZone,e.waitingConversations]),n=gu(),r=wp(t,{settled:!e.loading&&n}),{releaseHold:i}=r,{onReorderPins:a}=e,o=(0,Y.useCallback)(e=>{i(),a?.(e)},[a,i]),s=r.sections.find(e=>e.key===`pinned`)?.conversations??[];return/* @__PURE__ */ (0,X.jsxs)(`div`,{...r.holdProps,className:e.className,children:[/* @__PURE__ */ (0,X.jsx)(Ep,{count:r.pending,onApply:r.applyPending}),/* @__PURE__ */ (0,X.jsx)(ap,{conversations:s,onError:e.onReorderError,reorder:a?o:void 0,children:e.children({releaseHold:i,sections:r.sections})})]})}function Ep(e){return/* @__PURE__ */ (0,X.jsx)(`div`,{"aria-live":`polite`,className:`pointer-events-none sticky top-0 z-20 flex h-0 items-start justify-center`,children:e.count>0?/* @__PURE__ */ (0,X.jsxs)(`button`,{className:`pointer-events-auto mt-1 inline-flex cursor-pointer items-center gap-1 rounded-full border border-dashboard-border-strong bg-dashboard-surface-raised px-2.5 py-1 font-sans text-xs font-medium text-dashboard-text shadow-sm duration-150 hover:border-dashboard-border-interactive focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-dashboard-focus motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-top-1`,onClick:e.onApply,type:`button`,children:[/* @__PURE__ */ (0,X.jsx)(Bt,{"aria-hidden":`true`,className:`size-3`}),e.count,` updated`]}):null})}function Dp({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(xn,{"data-slot":`spinner`,role:`status`,"aria-label":`Loading`,className:F(`size-4 animate-spin motion-reduce:animate-none`,e),...t})}function Op(e){return e.status===`active`?/* @__PURE__ */ (0,X.jsx)(Dp,{"aria-label":`Running`,className:`size-3 text-emerald-300`}):e.unread||e.waitingOnViewer?/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-label":e.waitingOnViewer?`Waiting on you`:`Unread`,className:`size-1.5 shrink-0 rounded-full bg-dashboard-accent`,role:`img`}):null}function kp(e){return!e.isPrivate&&e.status!==`failed`&&e.status!==`stopped`?null:/* @__PURE__ */ (0,X.jsxs)(`span`,{className:q(`inline-flex shrink-0 items-center gap-1 font-sans text-xs`,e.className),children:[e.isPrivate?/* @__PURE__ */ (0,X.jsx)(Gt,{"aria-label":`Private conversation`,className:`size-3 shrink-0 text-dashboard-text-faint`,role:`img`}):null,e.status===`failed`?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`text-rose-400`,children:`Failed`}):e.status===`stopped`?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`text-dashboard-text-muted`,children:`Stopped`}):null]})}function Ap(e){return/* @__PURE__ */ (0,X.jsx)(`h3`,{className:q(`m-0 font-sans text-xs font-medium text-dashboard-text-muted`,e.className),id:e.id,children:/* @__PURE__ */ (0,X.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,X.jsx)(H,{"aria-hidden":`true`,className:q(`size-3 shrink-0 justify-self-center transition-transform motion-reduce:transition-none`,!e.collapsed&&`rotate-90`)}),/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e.label,e.collapsed?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`tabular-nums text-dashboard-text-faint`,children:e.count}):null]})]})})}const jp={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`},Mp={compact:`text-xs`,default:`text-sm`};function Np(e){return/* @__PURE__ */ (0,X.jsxs)(`span`,{className:q(`inline-flex w-fit items-center gap-1.5 font-sans font-medium normal-case leading-snug tracking-normal`,Mp[e.size??`default`],jp[e.tone??`neutral`],e.className),children:[/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 shrink-0 rounded-full bg-current`}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`block first-letter:uppercase`,children:e.children})]})}function Pp(e,t){return t?`waiting`:Ea(e)}const Fp={active:`Running`,failed:`Failed`,idle:`Idle`,stopped:`Stopped`,waiting:`Waiting on you`},Ip={active:`info`,failed:`danger`,idle:`neutral`,stopped:`neutral`,waiting:`warning`};function Lp(e){let t=Fp[e.status],n=q(`size-3.5 shrink-0`,e.className);if(e.status===`active`)return/* @__PURE__ */ (0,X.jsx)(Dp,{"aria-label":t,className:q(n,`text-dashboard-text-muted`)});let r=e.status===`waiting`?qn:e.status===`failed`?un:e.status===`stopped`?Mt:nn;return/* @__PURE__ */ (0,X.jsx)(r,{"aria-label":t,className:q(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 Rp(e){return/* @__PURE__ */ (0,X.jsx)(Np,{className:q(`shrink-0`,e.status===`active`&&`animate-pulse motion-reduce:animate-none`),size:`compact`,tone:Ip[e.status],children:Fp[e.status]})}const zp=`junior:conversation:start-position`,Bp=`data-scroll-anchor`;function Vp(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 Hp(e,t){let n=e.querySelectorAll(`[${Bp}]`),r=/* @__PURE__ */ new Map,i=e=>{let t=r.get(e);return t||(t=n[e].getBoundingClientRect(),r.set(e,t)),t},a=Vp(n.length,i,t);if(a===null)return null;let o=n[a];return{element:o,key:o.getAttribute(Bp)??``,offset:i(a).top-t.top}}function Up(e,t,n){let r=n.element.isConnected?n.element:Wp(e,n.key);return r?r.getBoundingClientRect().top-t.top-n.offset:null}function Wp(e,t){for(let n of e.querySelectorAll(`[${Bp}]`))if(n.getAttribute(Bp)===t)return n;return null}const Gp=typeof window>`u`?Y.useEffect:Y.useLayoutEffect;function Kp(e,t=96){return e.scrollHeight-e.scrollTop-e.clientHeight<=t}function qp(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 Jp(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`||Yp(i)){n=i;break}}return[e.conversationId,e.status,n?.seq??``,n?.createdAt??``,Xp(n)].join(`|`)}function Yp(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 Xp(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 Zp(e){return e.enabled&&e.following}function Qp(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 $p(e){return!e.following&&(e.endsAtLatest===!1||!!e.openedAtUnread||e.enabled&&e.hasPendingUpdate)}function em(e){return e.source===`scroll`&&e.previousScrollTop!=null&&e.snapshot.scrollTop<e.previousScrollTop-2?`pause`:e.source===`scroll`&&Kp(e.snapshot)?`follow`:`preserve`}function tm(e){return e.intent===`pause`&&!Kp(e.snapshot)?`pause`:`ignore`}function nm(e){let t=(0,Y.useRef)(null),n=(0,Y.useRef)(null),r=(0,Y.useRef)(e.enabled),i=(0,Y.useRef)(!0);i.current=e.endsAtLatest??!0;let a=(0,Y.useRef)(!1),o=(0,Y.useRef)(!1),s=(0,Y.useRef)(null),c=(0,Y.useRef)(null),l=(0,Y.useRef)(null),u=(0,Y.useRef)(null),d=(0,Y.useRef)(e.pinRequestVersion??0),f=(0,Y.useRef)(e.juniorMessageVersion),p=(0,Y.useRef)(e.enabled),m=(0,Y.useRef)(!1),h=(0,Y.useRef)(e.versions),g=(0,Y.useRef)(0),[_,v]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(null),T=(0,Y.useCallback)(e=>{n.current=e,w(e)},[]);(0,Y.useEffect)(()=>{r.current=e.enabled,e.enabled||b(!1)},[e.enabled]);let E=(0,Y.useRef)(!1),D=(0,Y.useCallback)(e=>{a.current=e,v(e),e?S(!1):E.current=!1},[]),O=(0,Y.useCallback)(()=>{let e=n.current,t=am(e);e&&t&&(u.current=Hp(e,cm(t)))},[]),k=(0,Y.useCallback)(()=>{let e=n.current,t=am(e),r=u.current;if(!e||!t)return;let i=r?Up(e,cm(t),r):null;if(i!==null&&Math.abs(i)>=1){sm(t,om(t).scrollTop+i);let e=om(t).scrollTop;c.current=e,l.current=e}O()},[O]),A=(0,Y.useCallback)(()=>{if(!a.current)return;let e=am(n.current);!e||om(e).scrollTop<=0||(g.current=0,D(!1))},[D]),j=(0,Y.useCallback)(e=>{let t=am(n.current);if(!t)return;let r=om(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=em({previousScrollTop:a,snapshot:r,source:e});if(e===`scroll`&&g.current>0)tm({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,Y.useCallback)(e=>{let t=am(n.current);if(!t)return;let i=a.current,o=i?++g.current:0;sm(t,om(t).scrollHeight,e);let s=()=>{if(i&&g.current!==o)return;i&&(g.current=0);let e=om(t);c.current=e.scrollTop,r.current&&a.current&&Kp(e)&&(D(!0),b(!1))};e===`smooth`?window.setTimeout(s,400):requestAnimationFrame(()=>{requestAnimationFrame(s)})},[D]),ee=(0,Y.useCallback)((e,t)=>{let r=am(n.current);if(!r||t.arrived&&!a.current)return!1;let i=cm(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=um();if(sm(r,Math.max(0,om(r).scrollTop+s),d),d===`smooth`)return u.current=null,!0;let f=om(r);return c.current=f.scrollTop,l.current=f.scrollTop,O(),!0},[A,O]),N=(0,Y.useCallback)(()=>{let e=n.current,t=am(e),r=e?.querySelector(`[data-transcript-unread-marker]`);if(!t||!r)return!1;E.current=!1;let a=r.getBoundingClientRect().top-cm(t).top;sm(t,Math.max(0,om(t).scrollTop+a-48));let o=om(t);c.current=o.scrollTop,l.current=o.scrollTop;let s=i.current&&Kp(o);return D(s),S(!s),O(),!0},[O,D]);Gp(()=>{if(!C||!e.conversationId)return;let t=`${e.conversationId}:${e.startAtLink?`link`:`start`}`;if(s.current===t)return;let n=am(C);n&&(s.current=t,b(!1),e.startAtLink?(c.current=om(n).scrollTop,D(!1)):e.startAtUnread&&N()||(sm(n,om(n).scrollHeight),c.current=om(n).scrollTop,D(!0),E.current=!!e.startAtUnread))},[C,e.conversationId,e.startAtLink,e.startAtUnread,N,D]);let P=(0,Y.useCallback)(()=>{E.current&&N()||(i.current?M(`auto`):(D(!1),k()))},[N,k,M,D]),te=(0,Y.useCallback)(()=>{a.current?P():(k(),j(`measure`))},[P,j,k]);Gp(()=>{te()},[e.historyVersion,te]),Gp(()=>{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=am(n.current);e&&D(Kp(om(e)))}Zp({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,Y.useEffect)(()=>{if(typeof window>`u`||!C)return;let e=am(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,Y.useEffect)(()=>{if(typeof ResizeObserver>`u`||!C)return;let e=new ResizeObserver(()=>{te()});e.observe(C);let t=am(C);return t&&!lm(t)&&e.observe(t),()=>e.disconnect()},[C,te]);let F=(0,Y.useCallback)(()=>{E.current=!1,D(!0),b(!1),M(um())},[M,D]);Gp(()=>{let t=f.current!==e.juniorMessageVersion;f.current=e.juniorMessageVersion;let n=Qp({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]),Gp(()=>{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,Y.useCallback)(()=>u.current?.key,[]);return(0,Y.useMemo)(()=>({anchorRef:t,contentElement:C,contentRef:T,hasPendingUpdate:y,jumpToBottom:F,scrollAnchorKey:ne,showRow:ee,showJumpToLatest:$p({enabled:e.enabled,endsAtLatest:e.endsAtLatest,following:_,hasPendingUpdate:y,openedAtUnread:x})}),[C,T,_,y,e.enabled,e.endsAtLatest,F,x,ne,ee])}const rm=(0,Y.createContext)(void 0);function im(e){let[t,n]=(0,Y.useState)(null),r=(0,Y.useRef)(e.onLoad);return r.current=e.onLoad,(0,Y.useEffect)(()=>{if(!e.enabled||!t||typeof IntersectionObserver>`u`)return;let n=am(t),i=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(i.disconnect(),r.current())},{root:n&&!lm(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 am(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 om(e){if(lm(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 sm(e,t,n=`auto`){lm(e)?window.scrollTo({behavior:n,top:t}):e.scrollTo({behavior:n,top:t})}function cm(e){if(lm(e))return{bottom:window.innerHeight,top:0};let t=e.getBoundingClientRect().top;return{bottom:t+e.clientHeight,top:t}}function lm(e){return e===window}function um(){return typeof window>`u`||typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}const dm=`data-transcript-seq`,fm=`[${dm}]`,pm=/* @__PURE__ */ new Set([` `,`ArrowDown`,`ArrowUp`,`End`,`Home`,`PageDown`,`PageUp`]);function mm(){return t(zp,`unread`)}function hm(){if(typeof window>`u`)return`unread`;try{let e=window.localStorage.getItem(zp);return e&&JSON.parse(e)===`latest`?`latest`:`unread`}catch{return`unread`}}function gm(e,t){let[n,r]=(0,Y.useState)(),[i,a]=(0,Y.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),{..._m(o?.lastReadSeq,s?s.throughSeq:e?.events.at(-1)?.seq),...s?.unreadCursor?{unreadCursor:s.unreadCursor,unreadPage:s.unreadPage}:void 0}}function _m(e,t){return e===void 0?{}:t===void 0||t<=e?{lastReadSeq:e}:{lastReadSeq:e,unread:{afterSeq:e,throughSeq:t}}}function vm(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 ym(e){let t=P(),{mutate:n}=N({scope:$u(e),mutationFn:t=>ta(Yr,`/api/conversations/${encodeURIComponent(e)}/read-position`,{lastReadSeq:t}),onSuccess:async({unreadReply:n,...r})=>{let i=Z(e),a={queryKey:[`dashboard`,`conversations`]},o=!n&&t.isMutating({mutationKey:ed(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&&{...vm(e,r),...o?{unread:void 0}:void 0})}});return(0,Y.useCallback)(r=>{let i=t.getQueryData(Z(e))?.readPosition?.lastReadSeq;i!==void 0&&r<=i||t.isMutating({mutationKey:ed(e)})>0||n(r)},[e,n,t])}function bm(e){let t=(0,Y.useRef)(e.onRead);t.current=e.onRead;let n=(0,Y.useRef)(e.paused);n.current=e.paused;let r=(0,Y.useRef)(e.lastReadSeq??-1),i=(0,Y.useRef)(!1),a=(0,Y.useRef)(void 0),o=(0,Y.useRef)(e.engaged);o.current=e.engaged,(0,Y.useEffect)(()=>{e.lastReadSeq!==void 0&&e.lastReadSeq<r.current&&(r.current=e.lastReadSeq)},[e.lastReadSeq]);let s=!!e.onRead;(0,Y.useEffect)(()=>{e.engaged&&a.current?.()},[e.engaged]),(0,Y.useEffect)(()=>{let c=e.content,l=am(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(fm)];return e.matches(fm)?[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:[dm],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&&pm.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 xm(e,t){e.getQueryCache().find({exact:!0,queryKey:Z(t)})?.getObserversCount()||await e.prefetchQuery({...sd(t),queryFn:async({signal:n})=>{let r=await _d(t,n,void 0,{mailbox:!0,unreadPage:hm()===`unread`});return ad(e,t,e.getQueryData(Z(t)),r),{...r,prefetchedAtMs:Date.now()}}})}function Sm(e){let t=P(),n=(0,Y.useRef)(void 0);(0,Y.useEffect)(()=>()=>clearTimeout(n.current),[]);let r=()=>{clearTimeout(n.current),n.current=setTimeout(()=>void xm(t,e),150)},i=()=>clearTimeout(n.current);return{onBlur:i,onFocus:r,onPointerEnter:e=>{e.pointerType!==`touch`&&r()},onPointerLeave:i}}const Cm=[`pl-[2.125rem]`,`pl-[3.125rem]`,`pl-[4.125rem]`],wm=(0,Y.memo)(function(e){let t=Sm(e.conversation.id);return/* @__PURE__ */ (0,X.jsxs)(B,{...t,"aria-current":e.selected?`page`:void 0,className:q(`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`,Cm[Math.min(e.depth,Cm.length-1)],e.selected&&`bg-dashboard-surface-active`),to:kc(e.conversation.id),children:[/* @__PURE__ */ (0,X.jsx)(Lp,{status:Pp(e.conversation,e.waiting)}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:q(`min-w-0 truncate font-sans text-sm leading-snug`,e.selected?`font-medium text-dashboard-text`:`text-dashboard-text-muted`),children:za(e.conversation)}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-sans text-xs tabular-nums text-dashboard-text-faint`,children:Dc(e.conversation.lastSeenAt)})]})});function Tm(e){return/* @__PURE__ */ (0,X.jsxs)(`button`,{"aria-expanded":e.expanded,className:q(`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`,Cm[0]),onClick:e.onToggle,type:`button`,children:[/* @__PURE__ */ (0,X.jsx)(H,{"aria-hidden":`true`,className:ca}),e.expanded?`Show fewer`:`Show ${e.hiddenCount} more`]})}function Em(e,t){let n=e??[],r=Om(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=Om(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 Om(e,t){return e.flatMap(e=>[{conversation:e,depth:t},...Om(e.threads??[],t+1)])}const km=`junior:conversation-collapsed-sections`;function Am(){let[e,t]=(0,Y.useState)(jm);return{collapsedKeys:e,toggle:(0,Y.useCallback)(e=>{t(t=>{let n=new Set(t);return n.delete(e)||n.add(e),Mm(n),n})},[])}}function jm(){if(typeof window>`u`)return/* @__PURE__ */ new Set;try{let e=JSON.parse(window.localStorage.getItem(km)??`[]`);return Array.isArray(e)?new Set(e.filter(e=>typeof e==`string`)):/* @__PURE__ */ new Set}catch{return/* @__PURE__ */ new Set}}function Mm(e){if(typeof window<`u`)try{window.localStorage.setItem(km,JSON.stringify([...e]))}catch{}}function Nm({className:e,...t}){return/* @__PURE__ */ (0,X.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 Pm({className:e,...t}){return/* @__PURE__ */ (0,X.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 Fm({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(`div`,{"data-slot":`empty-title`,className:F(`font-display text-base font-medium leading-tight text-dashboard-text`,e),...t})}function Im({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(`div`,{"data-slot":`empty-description`,className:F(`text-base leading-relaxed text-dashboard-text-muted`,e),...t})}function Lm(e){return/* @__PURE__ */ (0,X.jsx)(Nm,{children:/* @__PURE__ */ (0,X.jsx)(Im,{children:e.children})})}function Rm({className:e,children:t,viewportClassName:n,...r}){return/* @__PURE__ */ (0,X.jsxs)(ut,{"data-slot":`scroll-area`,className:F(`relative min-h-0`,e),...r,children:[/* @__PURE__ */ (0,X.jsx)(tt,{"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,X.jsx)(et,{"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,X.jsx)(ht,{className:`flex-1 rounded-full bg-dashboard-scrollbar-thumb/80 hover:bg-dashboard-scrollbar-thumb-hover`})})]})}const zm=`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`,Bm=e=>e.key;function Vm(e){let{clearActionError:t,showActionError:n,showArchiveError:r,showArchived:i}=Bd(),a=(0,Y.useCallback)((e,t)=>{n(e,t?`Could not pin`:`Could not unpin`)},[n]),o=(0,Y.useCallback)((e,t)=>{n(e,t?`Could not mark as unread`:`Could not mark as read`)},[n]),{collapsedKeys:s,toggle:c}=Am(),[l,u]=(0,Y.useState)(()=>/* @__PURE__ */ new Set),d=(0,Y.useCallback)(e=>{u(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},[]),f=(0,Y.useCallback)(e=>n(e,`Could not reorder`),[n]);return/* @__PURE__ */ (0,X.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,X.jsx)(`div`,{className:`px-3 pb-1.5 pt-2.5`,children:/* @__PURE__ */ (0,X.jsxs)(V,{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,X.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,X.jsx)(Rn,{className:`size-3`,strokeWidth:2.25})}),`New conversation`]})}),/* @__PURE__ */ (0,X.jsx)(Tp,{className:`relative min-h-0`,conversations:e.conversations,loading:e.loading,onReorderError:f,onReorderPins:e.onReorderPins,timeZone:e.timeZone,waitingConversations:e.waitingConversations,children:({releaseHold:u,sections:f})=>/* @__PURE__ */ (0,X.jsx)(Rm,{className:`h-full`,viewportClassName:`px-3 pb-[max(0.5rem,env(safe-area-inset-bottom))]`,children:e.error?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`p-2`,children:/* @__PURE__ */ (0,X.jsx)(Lm,{children:e.error})}):e.loading&&e.conversations.length===0?/* @__PURE__ */ (0,X.jsx)(Um,{}):/* @__PURE__ */ (0,X.jsx)(Hm,{collapsedKeys:s,expandedThreadRoots:l,loading:e.loading,sections:f,selectedId:e.selectedId,renderItem:s=>s.kind===`section`?/* @__PURE__ */ (0,X.jsx)(Ap,{className:q(`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,X.jsx)(Tm,{expanded:s.expanded,hiddenCount:s.hiddenCount,onToggle:()=>d(s.rootId)}):s.kind===`thread`?/* @__PURE__ */ (0,X.jsx)(wm,{conversation:s.conversation,depth:s.depth,selected:s.conversation.id===e.selectedId,waiting:e.waitingConversations.has(s.conversation.id)}):/* @__PURE__ */ (0,X.jsx)(qm,{conversation:s.conversation,onArchiveError:r,onArchived:i,onPinError:a,onPinned:t,onUnreadError:o,onActionError:n,onRowAction:u,selected:s.conversation.id===e.selectedId,waiting:e.waitingConversations.get(s.conversation.id)})})})})]})}function Hm(e){let{collapsedKeys:t,expandedThreadRoots:n,sections:r,selectedId:i}=e,a=(0,Y.useMemo)(()=>Gm(r,t,{expandedThreadRoots:n,selectedId:i}),[t,n,r,i]);return/* @__PURE__ */ (0,X.jsx)(up,{ariaLabel:`Your conversations`,className:`grid gap-0.5`,empty:e.loading?void 0:/* @__PURE__ */ (0,X.jsx)(`div`,{className:`p-2`,children:/* @__PURE__ */ (0,X.jsx)(Lm,{children:`No conversations match this view.`})}),getKey:Bm,items:a,renderItem:e.renderItem,role:`navigation`})}function Um(){return/* @__PURE__ */ (0,X.jsxs)(`div`,{"aria-busy":`true`,"aria-live":`polite`,role:`status`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`sr-only`,children:`Loading your conversations`}),/* @__PURE__ */ (0,X.jsx)(Wm,{})]})}function Wm(){return/* @__PURE__ */ (0,X.jsxs)(`div`,{"aria-hidden":`true`,className:`grid gap-0.5`,children:[/* @__PURE__ */ (0,X.jsx)(J,{className:`mb-1 ml-3 mt-1.5 h-2.5 w-12`}),Array.from({length:10},(e,t)=>/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg py-2 pl-[2.125rem] pr-3`,children:[/* @__PURE__ */ (0,X.jsx)(J,{className:q(`h-4`,t%3==0?`w-4/5`:`w-3/5`)}),/* @__PURE__ */ (0,X.jsx)(J,{className:`h-3 w-6 opacity-70`})]},t))]})}function Gm(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}=Em(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 qm(e){return e.conversation.pinnedAt?/* @__PURE__ */ (0,X.jsx)(Jm,{...e}):/* @__PURE__ */ (0,X.jsx)(Ym,{...e})}function Jm(e){let t=op(e.conversation.id);return/* @__PURE__ */ (0,X.jsx)(Ym,{...e,drag:t})}const Ym=(0,Y.memo)(function(e){let t=Md(e.conversation.id,{onError:()=>e.onArchiveError(e.conversation,t.variables?.archived??!0),onSuccess:t=>{t&&e.onArchived(e.conversation)}}),n=Hd(e.conversation.id,{onError:t=>e.onPinError(e.conversation,t),onSuccess:()=>e.onPinned(e.conversation)}),r=Vd(e.conversation.id,{onError:t=>e.onUnreadError(e.conversation,t)}),i=Ud(e.conversation.id,{onError:()=>e.onActionError(e.conversation,`Could not rename`)}),a=ef(e.conversation.id,{onError:()=>e.onActionError(e.conversation,`Could not update subscription`)}),o=$d(e.conversation.id,{onError:()=>e.onActionError(e.conversation,`Could not change Slack updates`)}),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),d=_e(),f=P(),p=Sm(e.conversation.id),m=!!e.conversation.pinnedAt,h=Ea(e.conversation),g=za(e.conversation),_=!!e.conversation.unread,v=_||!!e.waiting,y=e.drag,b=Ca(e.conversation),x=!!e.conversation.archivedAt,S=e.conversation.isParticipant,C=S&&!e.waiting&&(_||b),w=t=>{e.onRowAction(),n.mutate(t)},T=()=>w(!m),E=t=>{e.onRowAction(),r.mutate(t)},D=()=>{e.onRowAction(),t.mutate({archived:!x,lastSeenAt:e.conversation.lastSeenAt})};return/* @__PURE__ */ (0,X.jsxs)(sf,{onOpenChange:t=>{t&&xm(f,e.conversation.id)},children:[/* @__PURE__ */ (0,X.jsxs)(cf,{...p,...y?.listeners,className:q(`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,X.jsxs)(B,{"aria-current":e.selected?`page`:void 0,"aria-keyshortcuts":y?`Alt+ArrowUp Alt+ArrowDown`:void 0,className:q(`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,X.jsx)(`span`,{className:`grid place-items-center`,children:v?/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-label":e.waiting?`Waiting on you`:`Unread`,className:`size-1.5 shrink-0 rounded-full bg-dashboard-accent`,role:`img`}):null}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:q(`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,X.jsx)(Xm,{conversation:e.conversation,status:h})]}),C?/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(U,{render:/* @__PURE__ */ (0,X.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:()=>E(!_),type:`button`,children:/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,className:q(`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,X.jsx)(W,{size:`compact`,children:_?`Mark as read`:`Mark as unread`})]}):null,e.waiting?/* @__PURE__ */ (0,X.jsx)(bp,{conversationId:e.conversation.id,waiting:e.waiting}):null,S?/* @__PURE__ */ (0,X.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,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(U,{render:/* @__PURE__ */ (0,X.jsx)(`button`,{"aria-label":`${m?`Unpin`:`Pin`} ${g}`,"aria-pressed":m,className:q(zm,`max-sm:hidden`),disabled:n.isPending,onClick:T,type:`button`,children:/* @__PURE__ */ (0,X.jsx)(Nt,{"aria-hidden":`true`,fill:m?`currentColor`:`none`,size:14})})}),/* @__PURE__ */ (0,X.jsx)(W,{size:`compact`,children:m?`Unpin`:`Pin`})]}),/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(U,{render:/* @__PURE__ */ (0,X.jsx)(`button`,{"aria-label":`${x?`Restore`:`Archive`} ${g}`,className:zm,disabled:t.isPending,onClick:D,type:`button`,children:x?/* @__PURE__ */ (0,X.jsx)(wn,{"aria-hidden":`true`,size:14}):/* @__PURE__ */ (0,X.jsx)(bn,{"aria-hidden":`true`,size:14})})}),/* @__PURE__ */ (0,X.jsx)(W,{size:`compact`,children:x?`Restore`:`Archive`})]})]}):null]}),/* @__PURE__ */ (0,X.jsx)(lf,{children:/* @__PURE__ */ (0,X.jsx)(rp,{actions:{archive:D,continueInSlack:()=>u(!0),delivery:e=>o.mutate(e),eventLog:()=>d(kc(e.conversation.id),{replace:e.selected,state:Mc}),pin:w,read: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,X.jsx)(Qd,{onClose:()=>c(!1),onSave:e=>i.mutate(e),title:g}):null,l?/* @__PURE__ */ (0,X.jsx)(rf,{conversationId:e.conversation.id,onClose:()=>u(!1)}):null]})});function Xm(e){let t=e.conversation.visibility===`private`;return/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[/* @__PURE__ */ (0,X.jsx)(kp,{isPrivate:t,status:e.status}),e.status===`active`?/* @__PURE__ */ (0,X.jsx)(Dp,{"aria-label":`Running`,className:`size-3.5 text-dashboard-text-muted`}):e.status===`failed`||e.status===`stopped`?null:/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-sans text-xs tabular-nums text-dashboard-text-faint`,children:Dc(e.conversation.lastMessageAt??e.conversation.lastSeenAt)})]})}function Zm({className:e,...t}){return/* @__PURE__ */ (0,X.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 Qm=ae(`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 $m({className:e,align:t=`inline-start`,...n}){return/* @__PURE__ */ (0,X.jsx)(`div`,{role:`group`,"data-slot":`input-group-addon`,"data-align":t,className:F(Qm({align:t}),e),onClick:e=>{e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()},...n})}function eh({className:e,type:t=`button`,...n}){return/* @__PURE__ */ (0,X.jsx)(V,{type:t,size:`icon`,className:F(`size-6`,e),...n})}function th({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(qd,{"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 nh(e){let t=rh[e.size??`compact`];return/* @__PURE__ */ (0,X.jsxs)(Zm,{className:q(t.group,e.className),children:[/* @__PURE__ */ (0,X.jsx)(th,{"aria-label":e.label,className:q(`[&::-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,X.jsx)($m,{className:t.icon,children:/* @__PURE__ */ (0,X.jsx)(jt,{"aria-hidden":`true`,size:t.iconSize,strokeWidth:2.5})}),/* @__PURE__ */ (0,X.jsx)($m,{align:`inline-end`,className:t.clear,children:/* @__PURE__ */ (0,X.jsx)(eh,{"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,X.jsx)(Qn,{"aria-hidden":`true`,size:14,strokeWidth:2.5})})})]})}const rh={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 ih({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(T,{"data-slot":`resizable-panel-group`,className:F(`flex h-full w-full aria-[orientation=vertical]:flex-col`,e),...t})}function ah({...e}){return/* @__PURE__ */ (0,X.jsx)(m,{"data-slot":`resizable-panel`,...e})}function oh({withHandle:e,className:t,...n}){return/* @__PURE__ */ (0,X.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,X.jsx)(`div`,{className:`z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border`})})}const sh=`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 ch(e){return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:q(`flex w-full min-h-0 shrink-0 flex-col overflow-hidden`,sh,`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,X.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,X.jsx)(`div`,{className:`mx-auto w-full max-w-[52.5rem] min-w-0 shrink-0`,children:e.children})]})}function lh(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,X.jsxs)(Hs,{"aria-hidden":`true`,size:e.size===`list`?`sm`:`default`,children:[/* @__PURE__ */ (0,X.jsx)(Us,{alt:`User avatar`,loading:`lazy`,referrerPolicy:`no-referrer`,src:e.imageUrl}),/* @__PURE__ */ (0,X.jsx)(Ws,{children:n.toUpperCase()})]})}function uh(e){return e.fullName?.trim()||e.slackUserName?.trim()||e.email?.trim()||e.slackUserId?.trim()||`Unknown actor`}function dh(e){let t=uh(e),n=e.email?.trim();return n&&n!==t?`${t}, ${n}`:t}function fh(e,t){return e.email?.trim().toLowerCase()||e.slackUserId?.trim()||e.slackUserName?.trim()||`${to(e)??`actor`}:${t}`}function ph(e){let t=uh(e.participant),n=e.participant.email?.trim();return/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`grid gap-0.5 font-sans`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-semibold text-dashboard-text`,children:t}),n&&n!==t?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-sans text-dashboard-text-muted`,children:n}):null]})}function mh(e){let t=dh(e.participant);return/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(U,{render:/* @__PURE__ */ (0,X.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,X.jsx)(lh,{imageUrl:e.participant.avatarUrl,name:uh(e.participant),size:e.size})})}),/* @__PURE__ */ (0,X.jsx)(W,{children:/* @__PURE__ */ (0,X.jsx)(ph,{participant:e.participant})})]})}function hh(e){return e?.participants?.length?e.participants:e?.actorIdentity?[e.actorIdentity]:[]}function gh(e){if(e.participants.length===0)return null;let t=e.participants.slice(0,3),n=e.participants.slice(3),r=e.participants.map(dh).join(`; `);return/* @__PURE__ */ (0,X.jsxs)(`span`,{"aria-label":`Conversation participants: ${r}`,className:`inline-flex items-center`,role:`group`,children:[t.map((t,n)=>/* @__PURE__ */ (0,X.jsx)(mh,{participant:t,size:e.size},fh(t,n))),n.length>0?/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(U,{render:/* @__PURE__ */ (0,X.jsx)(Hs,{"aria-label":`${n.length} more participants: ${n.map(dh).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,X.jsxs)(Ws,{className:`tabular-nums tracking-normal text-dashboard-text-muted`,children:[`+`,n.length]})})}),/* @__PURE__ */ (0,X.jsx)(W,{children:/* @__PURE__ */ (0,X.jsx)(`span`,{className:`grid gap-1 font-sans`,children:n.map((e,t)=>/* @__PURE__ */ (0,X.jsx)(`span`,{children:dh(e)},fh(e,t)))})})]}):null]})}const _h={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 vh(e){let t=Xr(e),n=[t.label,e.status].filter(Boolean).join(`: `);return/* @__PURE__ */ (0,X.jsx)(`svg`,{"aria-hidden":e.decorative?!0:void 0,"aria-label":e.decorative?void 0:n,role:e.decorative?void 0:`img`,className:q(`inline-block shrink-0 align-middle`,_h[t.tone],e.className),width:e.size??16,height:e.size??16,viewBox:`0 0 16 16`,fill:`currentColor`,children:Rr[t.icon].map(e=>/* @__PURE__ */ (0,X.jsx)(`path`,{d:e},e))})}function yh({...e}){return/* @__PURE__ */ (0,X.jsx)(ot,{"data-slot":`collapsible`,...e})}function bh({...e}){return/* @__PURE__ */ (0,X.jsx)($e,{"data-slot":`collapsible-trigger`,...e})}function xh({...e}){return/* @__PURE__ */ (0,X.jsx)(ft,{"data-slot":`collapsible-content`,...e})}const Sh=(0,Y.createContext)({query:``,normalizedQuery:``,active:!1,match:0});function Ch({children:e,match:t=0,onMatches:n,query:r}){let i=r.trim().toLowerCase();return/* @__PURE__ */ (0,X.jsx)(Sh.Provider,{value:{query:r,normalizedQuery:i,active:i.length>0,match:t,onMatches:n},children:e})}function wh(){return(0,Y.useContext)(Sh)}function Th(e){let[t,n]=(0,Y.useState)({index:0,query:e}),[r,i]=(0,Y.useState)(0),a=t.query===e?Math.max(0,Math.min(t.index,r-1)):0;return{count:r,index:a,setMatches:(0,Y.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 Eh(e){let{anchorRef:t,inputRef:n,onOpen:r,open:i}=e;(0,Y.useEffect)(()=>{let e=e=>{if(e.defaultPrevented||!Wc(e,`f`))return;let a=n.current;(!a||document.activeElement!==a||e.repeat)&&Dh(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 Dh(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}=wh();if(!n||!e)return/* @__PURE__ */ (0,X.jsx)(X.Fragment,{children:e});let r=e.toLowerCase();if(!r.includes(t))return/* @__PURE__ */ (0,X.jsx)(X.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,X.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,X.jsx)(X.Fragment,{children:i})}function Oh(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 kh(e,t){if(!t)return!0;if(e.kind===`message`)return Ah(e.message.trustedSummary,t)||Ah(e.message.eventType,t)||Ah(xf(e.message),t);if(e.kind===`failure`)return Ah(wf(e.failureCode,e.failureReason,e.eventId),t);if(e.kind===`tool`)return[e.part.name,e.part.status,ka(e.part.input),ka(e.part.output)].some(e=>Ah(e,t));if(e.kind===`reasoning`)return Ah(e.part.redacted?`reasoning redacted`:e.part.text,t);if(e.kind===`subagent`)return Ah(e.part.agentName??e.part.subagentKind,t)||Ah(e.part.title,t)||Ah(e.part.task,t)||Ah(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=>Ah(e,t))}return e.kind===`attachments_delivered`?e.part.attachments.some(e=>Ah(e.filename,t)||Ah(e.contentType,t)):e.kind===`context`&&[`context compacted`,e.part.event.summary].some(e=>Ah(e,t))}function Ah(e,t){return e?e.toLowerCase().includes(t):!1}function jh(e){let t=wh(),n=t.active?t.normalizedQuery:void 0,r=I({queryKey:[`highlight`,e.language,e.code,n],queryFn:async()=>{let t=n?Oh(e.code,n):[],{codeToHtml:r}=await import(`./chunks/code-highlighter-ea4j0ys1.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,X.jsx)(Nh,{html:r.data}):/* @__PURE__ */ (0,X.jsx)(Mh,{children:e.code})}function Mh(e){return/* @__PURE__ */ (0,X.jsx)(`pre`,{className:q(`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,X.jsx)(`code`,{children:e.children})})}function Nh(e){return/* @__PURE__ */ (0,X.jsx)(`div`,{className:q(`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 Ph={"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`)},Fh=/^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,Ih=/^\s*(?:(?:async\s+)?def\s+\w+\s*\(.*\)\s*(?:->.*)?:|class\s+\w+(?:\([^)]*\))?\s*:|from\s+[\w.]+\s+import\s|import\s+[\w.]+\s*$)/m,Lh=/^\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)/,Rh={console:`shellscript`,htm:`html`,js:`javascript`,jsonl:`json`,md:`markdown`,ndjson:`json`,sh:`shellscript`,text:`markdown`,txt:`markdown`,xml:`xml`,yml:`yaml`};function zh(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(Bh(n));let a=i[2]?.trim().split(/\s+/)[0],o=Uh(i[3]??``,i[1]?.length??0),s=a?Vh(a):Hh(o);t.push({code:Wh(o,s),fenced:!0,language:s}),r=i.index+i[0].length}let a=e.slice(r).trim();return a&&t.push(Bh(a)),t.length>0?t:[Bh(e)]}function Bh(e){let t=eo(e);return{code:Wh(e,t),fenced:!1,language:t}}function Vh(e){let t=e.toLowerCase(),n=Rh[t]??t;return Object.hasOwn(Ph,n)?n:`markdown`}function Hh(e){return eo(e)===`json`?`json`:Fh.test(e)?`tsx`:Ih.test(e)?`python`:Lh.test(e)?`shellscript`:`markdown`}function Uh(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 Wh(e,t){return t===`json`?ba(e)??e:e}function Gh({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:/* @__PURE__ */ (0,X.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,X.jsx)(`thead`,{"data-slot":`table-header`,className:F(`[&_tr]:hover:bg-transparent`,e),...t})}function qh({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(`tbody`,{"data-slot":`table-body`,className:F(`[&_tr:last-child]:border-0`,e),...t})}function Jh({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(`tfoot`,{"data-slot":`table-footer`,className:F(`border-t border-dashboard-border font-medium [&>tr]:last:border-b-0`,e),...t})}function Yh({className:e,...t}){return/* @__PURE__ */ (0,X.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 Xh({className:e,...t}){return/* @__PURE__ */ (0,X.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 Zh({className:e,...t}){return/* @__PURE__ */ (0,X.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 Qh=`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 $h(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 eg=/<((?:https?|mailto):[^\s|<>]+)(?:\|([^<>]*))?>/g;function tg(e){return e.replace(eg,(e,t,n)=>n?.trim()?`[${n.trim()}](${t})`:e)}const ng=D,rg=/:([a-z0-9_+-]+):(?::(skin-tone-[2-6]):)?/g,ig=65039;function ag(e){return e.split(`-`).map(e=>Number.parseInt(e,16))}const og=/* @__PURE__ */ new Map;for(let[e,t]of Object.entries(ng)){let n=ag(e);for(let e of typeof t==`string`?[t]:t)og.set(e,n)}function sg(e,t){let n=og.get(e);if(!n)return``;let[r,...i]=n,a=t?og.get(t)?.[0]:void 0;if(a!==void 0){let e=i[0]===ig?i.slice(1):i;return String.fromCodePoint(r,a,...e)}return i.length===0&&r<126976?String.fromCodePoint(r,ig):String.fromCodePoint(...n)}function cg(e){return e.includes(`:`)?e.replace(rg,(e,t,n)=>sg(t,n)||e):e}const lg=/<([@#])([A-Z0-9]+)(?:\|([^<>]*))?>/g,ug=(0,Y.createContext)({links:!0,people:/* @__PURE__ */ new Map});function dg(e){return/* @__PURE__ */ (0,X.jsx)(ug.Provider,{value:{links:e.links,people:mg(e.mentions)},children:e.children})}function fg(e,t){let n=[],r=0;for(let i of gg(e))i.start>r&&n.push(/* @__PURE__ */ (0,X.jsx)(Q,{text:cg(e.slice(r,i.start))},`${t}-m-${r}`)),n.push(/* @__PURE__ */ (0,X.jsx)(_g,{mention:i},`${t}-m-${i.start}`)),r=i.end;return r<e.length&&n.push(/* @__PURE__ */ (0,X.jsx)(Q,{text:cg(e.slice(r))},`${t}-m-${r}`)),n}function pg(e,t){let n=mg(t),r=``,i=0;for(let t of gg(e))r+=cg(e.slice(i,t.start)),r+=hg(t,n),i=t.end;return r+cg(e.slice(i))}function mg(e){let t=/* @__PURE__ */ new Map;for(let n of e)n.slackUserId&&t.set(n.slackUserId,n);return t}function hg(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 gg(e){return[...e.matchAll(lg)].map(e=>({end:e.index+e[0].length,id:e[2],label:e[3]?.trim()||void 0,sigil:e[1],start:e.index}))}function _g(e){let{links:t,people:n}=(0,Y.useContext)(ug),{id:r,sigil:i}=e.mention,a=i===`@`?n.get(r):void 0,o=/* @__PURE__ */ (0,X.jsx)(Q,{text:hg(e.mention,n)});return t&&a?.email?/* @__PURE__ */ (0,X.jsx)(B,{className:q(`pointer-events-auto`,Qh),title:r,to:qa(a.email),children:o}):/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-medium text-dashboard-accent-text`,title:r,children:o})}function vg(e){if(!e.text.trim())return null;let t=e.document?e.text:yg(tg(e.text));return e.inline?/* @__PURE__ */ (0,X.jsx)(y,{components:Ag,remarkPlugins:[g],urlTransform:$h,children:t}):/* @__PURE__ */ (0,X.jsx)(`div`,{className:q(`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,X.jsx)(`div`,{className:q(`grid min-w-0`,e.chat?`gap-3`:`gap-2`),children:/* @__PURE__ */ (0,X.jsx)(y,{components:Tg,remarkPlugins:e.document?[g]:[g,ne,bg,Sg],urlTransform:$h,children:t})})})}function yg(e){return e.replace(/^([ \t]*)[•◦](?=[ \t])/gm,`$1-`)}function bg(){return(e,t)=>{xg(e,String(t.value))}}function xg(e,t){e.children=e.children?.flatMap(e=>{xg(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 Sg(){return e=>{e.children=e.children?.flatMap(Cg)}}function Cg(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 wg=`m-0 min-w-0 font-semibold tracking-[-0.01em] text-dashboard-text [&:not(:first-child)]:mt-1 [&+*]:-mt-1`,Tg={a:({children:e,href:t})=>/* @__PURE__ */ (0,X.jsx)(Mg,{href:t,children:e}),blockquote:({children:e})=>/* @__PURE__ */ (0,X.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,X.jsx)(`code`,{className:`rounded-[0.25rem] bg-dashboard-fill-strong px-1 py-0.5 font-mono text-[0.9em] text-dashboard-text`,children:Y.Children.map(e,e=>typeof e==`string`?/* @__PURE__ */ (0,X.jsx)(Q,{text:e}):e)}),del:({children:e})=>/* @__PURE__ */ (0,X.jsx)(`del`,{className:`text-dashboard-text-muted`,children:Eg(e)}),em:({children:e})=>/* @__PURE__ */ (0,X.jsx)(`em`,{className:`italic text-dashboard-text`,children:Eg(e)}),h1:({children:e})=>/* @__PURE__ */ (0,X.jsx)(`h1`,{className:q(wg,`text-[1.05em]`),children:Eg(e)}),h2:({children:e})=>/* @__PURE__ */ (0,X.jsx)(`h2`,{className:q(wg,`text-[1.05em]`),children:Eg(e)}),h3:({children:e})=>/* @__PURE__ */ (0,X.jsx)(`h3`,{className:q(wg,`text-[1em]`),children:Eg(e)}),h4:({children:e})=>/* @__PURE__ */ (0,X.jsx)(`h4`,{className:q(wg,`text-[1em]`),children:Eg(e)}),h5:({children:e})=>/* @__PURE__ */ (0,X.jsx)(`h5`,{className:q(wg,`text-[1em]`),children:Eg(e)}),h6:({children:e})=>/* @__PURE__ */ (0,X.jsx)(`h6`,{className:q(wg,`text-[1em]`),children:Eg(e)}),hr:()=>/* @__PURE__ */ (0,X.jsx)(`hr`,{className:`m-0 w-full border-dashboard-border`}),img:({alt:e,src:t})=>/* @__PURE__ */ (0,X.jsx)(Mg,{href:typeof t==`string`?t:void 0,children:e||t}),li:({children:e,className:t})=>/* @__PURE__ */ (0,X.jsx)(`li`,{className:q(`min-w-0 pl-1 [&>*+*]:mt-1.5`,t?.includes(`task-list-item`)&&`-ml-5 list-none`),children:Eg(e)}),ol:({children:e,start:t})=>/* @__PURE__ */ (0,X.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,X.jsx)(`p`,{className:`m-0 min-w-0 whitespace-normal`,children:Eg(e)}),pre:({children:e})=>/* @__PURE__ */ (0,X.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,X.jsx)(`strong`,{className:`font-semibold text-dashboard-text`,children:Eg(e)}),table:({children:e})=>/* @__PURE__ */ (0,X.jsx)(`div`,{className:`min-w-0 max-w-full overflow-hidden rounded-md border border-dashboard-border bg-dashboard-fill-faint`,children:/* @__PURE__ */ (0,X.jsx)(Gh,{className:`w-max min-w-full`,children:e})}),tbody:({children:e})=>/* @__PURE__ */ (0,X.jsx)(qh,{children:e}),td:({children:e,style:t})=>/* @__PURE__ */ (0,X.jsx)(Zh,{className:q(`px-2.5 py-1.5 align-top`,jg(t?.textAlign)),children:Eg(e)}),th:({children:e,style:t})=>/* @__PURE__ */ (0,X.jsx)(Xh,{className:q(`px-2.5 py-1.5`,jg(t?.textAlign)),scope:`col`,children:Eg(e)}),thead:({children:e})=>/* @__PURE__ */ (0,X.jsx)(Kh,{className:`bg-dashboard-overlay-soft`,children:e}),tr:({children:e})=>/* @__PURE__ */ (0,X.jsx)(Yh,{className:`[thead_&]:border-dashboard-border`,children:e}),ul:({children:e})=>/* @__PURE__ */ (0,X.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 Eg(e){return Y.Children.map(e,(e,t)=>typeof e==`string`?fg(e,`t-${t}`):e)}function Dg(e){return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[Eg(e.children),`
13
+ `]})}function Og(e){return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[Eg(e.children),` `]})}function kg(e){return/* @__PURE__ */ (0,X.jsx)(X.Fragment,{children:e.children})}const Ag={a:({children:e})=>/* @__PURE__ */ (0,X.jsx)(X.Fragment,{children:Eg(e)}),blockquote:kg,code:Tg.code,del:Tg.del,em:Tg.em,h1:Dg,h2:Dg,h3:Dg,h4:Dg,h5:Dg,h6:Dg,hr:()=>`
14
+ `,img:({alt:e})=>e??null,li:Dg,ol:kg,p:Dg,pre:kg,strong:Tg.strong,table:kg,tbody:kg,td:Og,th:Og,thead:kg,tr:Dg,ul:kg};function jg(e){if(e===`center`)return`text-center`;if(e===`right`)return`text-right`}function Mg(e){if(!e.href)return/* @__PURE__ */ (0,X.jsx)(X.Fragment,{children:Eg(e.children)});let t=typeof e.children==`string`?/* @__PURE__ */ (0,X.jsx)(Ng,{href:e.href,label:e.children}):e.children;return/^https?:/i.test(e.href)?/* @__PURE__ */ (0,X.jsx)(nf,{className:Qh,href:e.href,children:t}):/* @__PURE__ */ (0,X.jsx)(`a`,{className:Qh,href:e.href,children:t})}function Ng(e){let t=wh(),n=t.active&&e.href.toLowerCase().includes(t.normalizedQuery),r=e.label.toLowerCase().includes(t.normalizedQuery);return n&&!r?/* @__PURE__ */ (0,X.jsx)(`mark`,{className:`rounded-[2px] bg-amber-400/20 text-inherit not-italic`,title:`Matched URL: ${e.href}`,children:e.label}):/* @__PURE__ */ (0,X.jsx)(Q,{text:e.label})}const Pg=[],$=(0,Y.memo)(function(e){return/* @__PURE__ */ (0,X.jsx)(dg,{links:e.links??!0,mentions:e.mentions??Pg,children:e.inline?/* @__PURE__ */ (0,X.jsx)(vg,{inline:!0,text:e.text}):e.document?/* @__PURE__ */ (0,X.jsx)(vg,{document:!0,text:e.text}):/* @__PURE__ */ (0,X.jsx)(Fg,{chat:e.chat,compact:e.compact,text:e.text})})});function Fg(e){return/* @__PURE__ */ (0,X.jsx)(`div`,{className:`grid min-w-0 gap-2`,children:zh(e.text).map((t,n)=>t.language===`markdown`&&!t.fenced?/* @__PURE__ */ (0,X.jsx)(vg,{chat:e.chat,compact:e.compact,text:t.code},n):/* @__PURE__ */ (0,X.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,X.jsx)(jh,{code:t.code,language:t.language}),/* @__PURE__ */ (0,X.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,X.jsx)(Zf,{getText:()=>t.code,label:`Copy code`})})]},n))})}function Ig(e){return/* @__PURE__ */ (0,X.jsxs)(`section`,{"aria-label":e.label,className:q(`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,X.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[/* @__PURE__ */ (0,X.jsxs)(`h3`,{className:q(`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,X.jsx)(`span`,{className:`font-normal tabular-nums text-dashboard-text-faint`,children:e.count.toLocaleString(`en-US`)}):null]}),e.action]}):null,/* @__PURE__ */ (0,X.jsx)(`div`,{className:`min-w-0 break-words font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.children})]})}function Lg(e){let[t,n]=(0,Y.useState)(!1),r=e.items.length-3,i=t||r<=0?e.items:e.items.slice(0,3);return/* @__PURE__ */ (0,X.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,X.jsx)(`li`,{children:e.renderItem(t)},e.itemKey(t))),r>0?/* @__PURE__ */ (0,X.jsx)(`li`,{children:/* @__PURE__ */ (0,X.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,X.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center`,children:/* @__PURE__ */ (0,X.jsx)(H,{"aria-hidden":`true`,className:ca})}),t?`Show fewer`:`Show ${r} more`]})}):null]})}function Rg(e){let t=e.href!==void 0||e.to!==void 0||e.onClick!==void 0||e.disclosure===!0,n=q(`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,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center text-dashboard-text-muted`,children:e.icon}),/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`flex min-w-0 items-center text-sm font-medium leading-5 text-dashboard-text`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`truncate`,children:e.title}),e.href?/* @__PURE__ */ (0,X.jsx)(tf,{}):null]}),/* @__PURE__ */ (0,X.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,X.jsx)(`a`,{className:n,href:e.href,rel:`noreferrer`,target:`_blank`,title:e.tooltip,children:r}):e.to?/* @__PURE__ */ (0,X.jsx)(B,{className:n,title:e.tooltip,to:e.to,children:r}):e.onClick?/* @__PURE__ */ (0,X.jsx)(`button`,{className:q(n,`cursor-pointer`),onClick:e.onClick,title:e.tooltip,type:`button`,children:r}):e.disclosure?/* @__PURE__ */ (0,X.jsx)(bh,{className:n,title:e.tooltip,children:r}):/* @__PURE__ */ (0,X.jsx)(`div`,{className:n,title:e.tooltip,children:r})}function zg(e){return/* @__PURE__ */ (0,X.jsx)(`div`,{className:q(`col-start-2 col-end-4 min-w-0 text-xs leading-4 text-dashboard-text-muted`,e.className),children:e.children})}function Bg(e){return I({queryFn:({signal:t})=>K(ai,`/api/conversations/${encodeURIComponent(e)}/watches`,t),queryKey:id(e,`watches`),retry:!1})}function Vg(e){return/* @__PURE__ */ (0,X.jsx)(Lg,{itemKey:e=>e.id,items:e.watches,renderItem:e=>/* @__PURE__ */ (0,X.jsx)(Ug,{watch:e})})}const Hg={channel:Un,deployment:dn,deployment_source:dn,issue:It,pull_request:On,release_source:nr,repository:Yn,team:Dn,timer:fr,workspace_snapshot:rn};function Ug(e){let{watch:t}=e,n=t.redacted?Gt:Hg[t.resourceType]??Pn,r=`${t.namespace} ${t.resourceType.replaceAll(`_`,` `)}`,i=/* @__PURE__ */ (0,X.jsx)(n,{"aria-hidden":`true`,className:`size-3.5`}),a=t.label??`Private ${r}`;return/* @__PURE__ */ (0,X.jsxs)(yh,{className:`min-w-0`,children:[t.url?/* @__PURE__ */ (0,X.jsx)(Wg,{label:a,children:/* @__PURE__ */ (0,X.jsx)(Rg,{href:t.url,icon:i,title:a})}):/* @__PURE__ */ (0,X.jsx)(Rg,{disclosure:!0,icon:i,meta:/* @__PURE__ */ (0,X.jsx)(Gg,{}),title:a}),/* @__PURE__ */ (0,X.jsx)(Kg,{watches:[t]})]})}function Wg(e){return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-0.5`,children:[/* @__PURE__ */ (0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:e.children}),/* @__PURE__ */ (0,X.jsx)(bh,{"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,X.jsx)(Gg,{})})]})}function Gg(){return/* @__PURE__ */ (0,X.jsx)(`span`,{className:`grid size-5 place-items-center`,children:/* @__PURE__ */ (0,X.jsx)(H,{"aria-hidden":`true`,className:ca})})}function Kg(e){return/* @__PURE__ */ (0,X.jsx)(xh,{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,X.jsx)(qg,{watch:e},e.id))})}function qg(e){let{watch:t}=e,n=t.firesAt?[]:t.events,r=Object.entries(t.match??{});return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0 gap-1.5`,children:[t.intent?/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 break-words`,children:/* @__PURE__ */ (0,X.jsx)($,{inline:!0,text:t.intent})}):null,t.firesAt?/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`m-0`,children:[`Fires`,` `,/* @__PURE__ */ (0,X.jsx)(`time`,{dateTime:t.firesAt,children:ao(t.firesAt,{dateStyle:`medium`,timeStyle:`short`})})]}):null,n.length>0||r.length>0?/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[n.map(e=>/* @__PURE__ */ (0,X.jsx)(Jg,{children:Yg(e,t.resourceType)},e)),r.map(([e,t])=>/* @__PURE__ */ (0,X.jsxs)(Jg,{filter:!0,children:[e.replaceAll(`_`,` `),`: `,[t].flat().join(`, `)]},`match:${e}`))]}):null,t.childAgent?/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`m-0 flex min-w-0 items-center gap-1`,children:[/* @__PURE__ */ (0,X.jsx)(gn,{"aria-hidden":`true`,className:`size-3 shrink-0`}),/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`truncate`,children:[`via `,t.childAgent.name??`child conversation`]})]}):null]})}function Jg(e){return/* @__PURE__ */ (0,X.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 Yg(e,t){let n=e.split(`.`);return(n[0]===t&&n.length>1?n.slice(1):n).join(` `).replaceAll(`_`,` `)}const Xg={closed:`Closed`,draft:`Draft`,merged:`Merged`,open:`Open`,warning:`Needs attention`};function Zg(e){return e?Xg[e]??e.charAt(0).toUpperCase()+e.slice(1):``}function Qg(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 $g(e){return/* @__PURE__ */ (0,X.jsx)(Lg,{itemKey:e=>e.key,items:e.links,renderItem:t=>{let n=/* @__PURE__ */ (0,X.jsx)(t_,{link:t}),r=e.watchesByUrl.get(t.url);return r?/* @__PURE__ */ (0,X.jsxs)(yh,{className:`min-w-0`,children:[/* @__PURE__ */ (0,X.jsx)(Wg,{label:t.label,children:n}),/* @__PURE__ */ (0,X.jsx)(Kg,{watches:r})]}):e.watchesByUrl.size>0?/* @__PURE__ */ (0,X.jsx)(e_,{children:n}):n}})}function e_(e){return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-0.5`,children:[/* @__PURE__ */ (0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:e.children}),/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,className:`size-8 shrink-0`})]})}function t_(e){let{link:t}=e,n=Zg(t.status),r=/* @__PURE__ */ (0,X.jsx)(vh,{decorative:!0,facts:t.facts,objectType:t.objectType,size:14,status:t.status});return/* @__PURE__ */ (0,X.jsx)(Rg,{href:t.url,icon:n?/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(U,{render:/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-label":n,className:`inline-flex`,role:`img`,children:r})}),/* @__PURE__ */ (0,X.jsx)(W,{size:`compact`,children:n})]}):r,title:t.label,tooltip:[t.label,t.plugin,n,t.description].filter(Boolean).join(` · `),children:t.description?/* @__PURE__ */ (0,X.jsx)(zg,{className:`line-clamp-2 break-words`,children:t.description}):null})}function n_(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 r_(e){let t;for(let n of e??[]){if(n.plugin!==`github`||!n.url)continue;let e=n_(n.url);if(e){if(t&&t.href.toLowerCase()!==e.href.toLowerCase())return;t??=e}}return t}function i_(e){let t=q(`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,X.jsxs)(X.Fragment,{children:[e.icon,/* @__PURE__ */ (0,X.jsx)(`span`,{className:e.detail?`shrink-0`:`truncate`,children:e.label}),e.detail?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`truncate font-normal text-dashboard-text`,children:e.detail}):null]});return e.href?/* @__PURE__ */ (0,X.jsx)(nf,{className:q(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,X.jsx)(`span`,{className:t,title:e.label,children:n})}function a_(e){let t=Ka(e.conversation,{includeId:!1});return t?/* @__PURE__ */ (0,X.jsx)(i_,{className:e.className,href:e.conversation.locationUrl,icon:/* @__PURE__ */ (0,X.jsx)(Qf,{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 o_(e,t){let n=Ka(e,{includeId:!1}),r=!!n&&n!==t,i=Qg(e);return!r&&i.length===0?null:/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[r?/* @__PURE__ */ (0,X.jsx)(a_,{className:`max-w-40 shrink-0`,conversation:e}):null,i.slice(0,2).map((e,t)=>/* @__PURE__ */ (0,X.jsx)(i_,{className:q(`max-w-96`,t>0&&`max-sm:hidden`),detail:e.description,href:e.url,icon:/* @__PURE__ */ (0,X.jsx)(vh,{decorative:!0,facts:e.facts,objectType:e.objectType,size:12,status:e.status}),label:e.description&&e.shortLabel||e.label,title:[e.label,Zg(e.status),e.description].filter(Boolean).join(` · `)},e.key)),/* @__PURE__ */ (0,X.jsx)(s_,{className:`sm:hidden`,count:i.length-1}),/* @__PURE__ */ (0,X.jsx)(s_,{className:`max-sm:hidden`,count:i.length-2})]})}function s_(e){return e.count<=0?null:/* @__PURE__ */ (0,X.jsxs)(`span`,{className:q(`shrink-0 font-sans text-2xs tabular-nums text-dashboard-text-muted`,e.className),children:[`+`,e.count]})}function c_(e){let t=e&&Ka(e,{includeId:!1}),n=r_(e?.annotations);return!t&&!n?null:/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[t&&e?/* @__PURE__ */ (0,X.jsx)(a_,{conversation:e}):null,n?/* @__PURE__ */ (0,X.jsx)(i_,{...n,icon:/* @__PURE__ */ (0,X.jsx)(hp,{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 l_(e){let{collapsedKeys:t,toggle:n}=Am(),{showActionError:r,showArchiveError:i,showArchived:a}=Bd(),o=(0,Y.useCallback)(e=>r(e,`Could not reorder`),[r]);return/* @__PURE__ */ (0,X.jsx)(Tp,{conversations:e.conversations,loading:e.loading??!1,onReorderError:o,onReorderPins:e.onReorderPins,timeZone:e.timeZone,waitingConversations:e.waitingConversations,children:({releaseHold:r,sections:o})=>e.loading&&e.conversations.length===0?/* @__PURE__ */ (0,X.jsx)(u_,{label:`Loading conversations`}):e.conversations.length===0?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`rounded-lg border border-dashboard-border-subtle bg-dashboard-fill-faint p-4`,children:/* @__PURE__ */ (0,X.jsx)(Lm,{children:e.emptyLabel??`No conversations match this view.`})}):/* @__PURE__ */ (0,X.jsx)(`div`,{"aria-label":`Your conversations`,className:`grid gap-5`,role:`list`,children:o.map(o=>/* @__PURE__ */ (0,X.jsx)(f_,{collapsed:t.has(o.key),onArchiveError:i,onArchived:a,onRowAction:r,onToggle:()=>n(o.key),waitingConversations:e.waitingConversations,section:o},o.key))})})}function u_(e){return/* @__PURE__ */ (0,X.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,X.jsx)(`span`,{className:`sr-only`,children:e.label}):null,[3,2].map((e,t)=>/* @__PURE__ */ (0,X.jsxs)(`div`,{children:[/* @__PURE__ */ (0,X.jsx)(J,{className:q(`mb-2 ml-1 h-3`,t===0?`w-16`:`w-12`)}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`grid gap-2`,children:Array.from({length:e},(e,n)=>/* @__PURE__ */ (0,X.jsx)(d_,{index:n+t*3},n))})]},e))]})}function d_(e){return/* @__PURE__ */ (0,X.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,X.jsx)(J,{className:`mt-0.5 size-8 rounded-md`}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[/* @__PURE__ */ (0,X.jsx)(`div`,{className:`flex h-6 min-w-0 flex-1 items-center`,children:/* @__PURE__ */ (0,X.jsx)(J,{className:q(`h-3.5`,e.index%2==0?`w-56 max-w-4/5`:`w-44 max-w-3/5`)})}),/* @__PURE__ */ (0,X.jsx)(J,{className:`h-3 w-14 opacity-70`}),/* @__PURE__ */ (0,X.jsx)(J,{className:`size-4`})]}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`flex h-5 min-w-0 items-center`,children:/* @__PURE__ */ (0,X.jsx)(J,{className:q(`h-3 opacity-70`,e.index%2==0?`w-full max-w-xl`:`w-1/2 max-w-md`)})}),/* @__PURE__ */ (0,X.jsx)(J,{className:`mt-1 h-6 w-28 rounded-md opacity-70`})]})]})}function f_(e){return/* @__PURE__ */ (0,X.jsxs)(`section`,{"aria-labelledby":`conversation-section-${e.section.key}`,children:[/* @__PURE__ */ (0,X.jsx)(Ap,{className:q(`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,X.jsx)(`div`,{className:`grid gap-2`,children:e.section.conversations.map(t=>{let n={conversation:t,onArchiveError:e.onArchiveError,onArchived:e.onArchived,onRowAction:e.onRowAction,waitingOnViewer:e.waitingConversations.has(t.id)};return t.pinnedAt?/* @__PURE__ */ (0,Y.createElement)(p_,{...n,key:t.id}):/* @__PURE__ */ (0,Y.createElement)(m_,{...n,key:t.id})})})]})}function p_(e){let t=op(e.conversation.id);return/* @__PURE__ */ (0,X.jsx)(m_,{...e,drag:t})}function m_(e){let t=e.conversation,n=e.drag,r=Md(t.id,{onError:()=>e.onArchiveError(t,r.variables?.archived??!0),onSuccess:n=>{n&&e.onArchived(t)}}),i=Ea(t),a=za(t),o=hh(t),s=t.visibility===`private`,c=o_(t,a),l=Sm(t.id),u=s?Gt:kt,d=!!t.unread,f=e.waitingOnViewer||d,p=f&&i!==`active`,m=t.lastMessageAt??t.lastSeenAt;return/* @__PURE__ */ (0,X.jsxs)(`article`,{...l,...n?.listeners,className:q(`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,X.jsx)(B,{"aria-keyshortcuts":n?`Alt+ArrowUp Alt+ArrowDown`:void 0,"aria-label":`Open ${a}`,className:q(`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,X.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,X.jsx)(u,{"aria-label":s?`Private conversation`:`Public conversation`,role:`img`,size:15}),p?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`absolute -bottom-1 -right-1 grid size-3.5 place-items-center rounded-full bg-dashboard-surface-panel`,children:/* @__PURE__ */ (0,X.jsx)(Op,{status:i,unread:d,waitingOnViewer:e.waitingOnViewer})}):null]}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[/* @__PURE__ */ (0,X.jsx)(`h4`,{className:q(`pointer-events-none relative z-[1] m-0 min-w-0 flex-1 truncate font-display text-sm leading-6 text-dashboard-text`,f?`font-semibold`:`font-medium`),children:a}),o.length>0?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`pointer-events-none relative z-[1] hidden sm:inline-flex`,children:/* @__PURE__ */ (0,X.jsx)(gh,{participants:o,size:`list`})}):null,i===`active`?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`pointer-events-none relative z-[1] flex min-w-14 justify-end`,children:/* @__PURE__ */ (0,X.jsx)(Dp,{"aria-label":`Running`,className:`size-3.5 text-dashboard-text-muted`})}):/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(kp,{className:`pointer-events-none relative z-[1]`,isPrivate:!1,status:i}),/* @__PURE__ */ (0,X.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:m,title:ao(m,{dateStyle:`medium`,timeStyle:`short`}),children:Oc(m)})]}),/* @__PURE__ */ (0,X.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:()=>{e.onRowAction(),r.mutate({archived:!t.archivedAt,lastSeenAt:t.lastSeenAt})},type:`button`,children:t.archivedAt?/* @__PURE__ */ (0,X.jsx)(wn,{"aria-hidden":`true`,size:15}):/* @__PURE__ */ (0,X.jsx)(bn,{"aria-hidden":`true`,size:15})})]}),t.activityPreview||i===`active`?/* @__PURE__ */ (0,X.jsx)(`p`,{className:q(`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,X.jsx)($,{inline:!0,mentions:t.activityPreview.mentions,text:t.activityPreview.text}):`Working…`}):null,c?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`pointer-events-none relative z-[1] mt-1 min-w-0 overflow-hidden [&_a]:pointer-events-auto`,children:c}):null]})]})}function h_(e){return!e.defaultPrevented&&e.button===0&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey}function g_(e,t){return e.src===t.src&&e.filename===t.filename}function __(e){let[t,n]=(0,Y.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=>g_(e,u))??-1;return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(`a`,{className:c,href:s,onClick:e=>{h_(e)&&(e.preventDefault(),n(!0))},rel:`noreferrer`,target:`_blank`,children:/* @__PURE__ */ (0,X.jsx)(`img`,{...l,alt:i,className:o,src:s})}),t?/* @__PURE__ */ (0,X.jsx)(y_,{images:a&&d>=0?a:[u],initialIndex:Math.max(d,0),onClose:()=>n(!1)}):null]})}const v_=`h-10 w-10 border-0 bg-transparent p-0 text-dashboard-text-muted hover:bg-dashboard-fill-hover hover:text-dashboard-text`;function y_(e){let t=Pl(e.onClose),n=(0,Y.useRef)(null),[r,i]=(0,Y.useState)(e.images[e.initialIndex]),a=e.images.length,o=Math.max(e.images.findIndex(e=>g_(e,r)),0),s=e.images[o],c=t=>i(e.images[(t+a)%a]);return/* @__PURE__ */ (0,X.jsx)(il,{...t.rootProps,actionsRef:n,children:/* @__PURE__ */ (0,X.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,X.jsxs)(`div`,{className:`grid h-full min-h-0 grid-rows-[auto_minmax(0,1fr)] bg-dashboard-bg-elevated`,children:[/* @__PURE__ */ (0,X.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,X.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,X.jsx)(sl,{className:`truncate font-mono text-xs leading-normal font-normal`,children:s.filename}),s.context?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`truncate font-mono text-2xs text-dashboard-text-muted`,children:s.context}):null]}),a>1?/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[/* @__PURE__ */ (0,X.jsx)(V,{"aria-label":`Previous image`,className:v_,onClick:()=>c(o-1),children:/* @__PURE__ */ (0,X.jsx)(Rt,{"aria-hidden":`true`,size:16})}),/* @__PURE__ */ (0,X.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,X.jsx)(V,{"aria-label":`Next image`,className:v_,onClick:()=>c(o+1),children:/* @__PURE__ */ (0,X.jsx)(H,{"aria-hidden":`true`,size:16})})]}):/* @__PURE__ */ (0,X.jsx)(`span`,{}),/* @__PURE__ */ (0,X.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,X.jsx)(Ln,{"aria-hidden":`true`,size:14}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`max-sm:sr-only`,children:`Open raw file`})]}),/* @__PURE__ */ (0,X.jsxs)(al,{render:/* @__PURE__ */ (0,X.jsx)(V,{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,X.jsx)(Qn,{"aria-hidden":`true`,size:16}),/* @__PURE__ */ (0,X.jsx)(`span`,{children:`Close`})]})]}),/* @__PURE__ */ (0,X.jsx)(x_,{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 b_={scale:1,x:0,y:0};function x_(e){let[t,n]=(0,Y.useState)(b_),[r,i]=(0,Y.useState)(),a=(0,Y.useRef)(null),o=(0,Y.useRef)(/* @__PURE__ */ new Map),s=(0,Y.useRef)(void 0),c=(0,Y.useRef)(void 0),l=(0,Y.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:E_(n),start:T_(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?b_:w_(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*E_(u)/r.distance:r.zoom.scale;n(w_(r,T_(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?b_:t;c!==t&&n(c),o.current.size>0?u(c):s.current=void 0};return/* @__PURE__ */ (0,X.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,X.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 w_(e,t,n,r){let i=D_(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:D_(o,-c,c),y:D_(s,-l,l)}}function T_(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 E_(e){let[t,n]=e;return!t||!n?0:Math.hypot(n.x-t.x,n.y-t.y)}function D_(e,t,n){return Math.min(Math.max(e,t),n)}const O_=(0,Y.lazy)(()=>import(`./chunks/DrawerContent-n3biwp5m.js`).then(e=>({default:e.DrawerContent})));function k_(e){return/* @__PURE__ */ (0,X.jsx)(Y.Suspense,{fallback:null,children:/* @__PURE__ */ (0,X.jsx)(O_,{...e},e.openKey)})}function A_(e){return/* @__PURE__ */ (0,X.jsx)(oa,{className:q(`block rounded-none border-0 bg-transparent p-0 text-rose-300`,e.className),variant:`destructive`,children:e.children})}function j_(e){return/* @__PURE__ */ (0,X.jsxs)(ya,{"aria-label":`Markdown view`,onValueChange:t=>{let n=t[0];n&&e.onChange(n)},value:[e.value],children:[/* @__PURE__ */ (0,X.jsx)(ma,{value:`formatted`,children:`Formatted`}),/* @__PURE__ */ (0,X.jsx)(ma,{value:`raw`,children:`Raw`})]})}const M_=524288,N_={htm:`html`,md:`markdown`,ndjson:`jsonl`},P_=/* @__PURE__ */ new Set([`conf`,`diff`,`env`,`go`,`ini`,`log`,`patch`,`rb`,`rs`,`text`,`toml`,`txt`]),F_={"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`},I_={"text/css":`css`,"text/csv":`csv`,"text/html":`html`,"text/javascript":`javascript`,"text/markdown":`markdown`,"text/xml":`xml`,"text/yaml":`yaml`};function L_(e){let t=e.lastIndexOf(`.`);if(t<0)return;let n=e.slice(t+1).toLowerCase();if(P_.has(n))return`plain`;let r=N_[n]??n;return Object.hasOwn(Ph,r)?r:void 0}function R_(e){let t=e.split(`;`,1)[0]?.trim().toLowerCase()??``;if(t in F_)return F_[t];if(t.startsWith(`text/`))return I_[t]??`plain`}function z_(e){return L_(e.filename)??R_(e.contentType)}function B_(e,t){if(!e.includes(0))return new TextDecoder().decode(e,{stream:t})}const V_=[`w-3/4`,`w-full`,`w-5/6`,`w-2/3`,`w-full`];function H_(e){let t=(0,Y.useId)(),{bytes:n,filename:r}=e.attachment,i=n>M_,a=e.language===`markdown`,[o,s]=(0,Y.useState)(`formatted`),c=I({queryKey:[`attachment-text`,e.href,n,i],queryFn:async({signal:t})=>n===0?``:B_(await Gi(e.href,524288,t),i)??null,staleTime:1/0});return(0,ou.createPortal)(/* @__PURE__ */ (0,X.jsx)(k_,{actions:/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[a?/* @__PURE__ */ (0,X.jsx)(j_,{onChange:s,value:o}):null,/* @__PURE__ */ (0,X.jsx)(`a`,{"aria-label":`Download ${r}`,className:Tt({size:`icon`}),download:r,href:e.href,rel:`noreferrer`,target:`_blank`,children:/* @__PURE__ */ (0,X.jsx)(Vn,{"aria-hidden":`true`,size:15})})]}),closeLabel:`Close ${r}`,header:/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:[/* @__PURE__ */ (0,X.jsx)(`h2`,{className:`m-0 font-mono text-sm font-semibold text-dashboard-text`,id:t,children:r}),/* @__PURE__ */ (0,X.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,X.jsx)(`div`,{"aria-label":`Loading file`,className:`grid gap-2`,role:`status`,children:V_.map((e,t)=>/* @__PURE__ */ (0,X.jsx)(J,{className:`h-4 ${e}`},t))}):c.isError?/* @__PURE__ */ (0,X.jsx)(A_,{children:`Could not load this file.`}):c.data===null?/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:`This file is not text. Download it to open it.`}):/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0 gap-3`,children:[i?/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`m-0 text-xs text-dashboard-text-muted`,children:[`Showing the first `,M_/1024,` KB. Download the file to see all of it.`]}):null,/* @__PURE__ */ (0,X.jsx)(U_,{language:e.language,text:c.data,view:o})]})}),document.body)}function U_(e){return e.text?e.language===`markdown`&&e.view===`formatted`?/* @__PURE__ */ (0,X.jsx)($,{document:!0,text:e.text}):e.language===`plain`?/* @__PURE__ */ (0,X.jsx)(Mh,{children:e.text}):/* @__PURE__ */ (0,X.jsx)(jh,{code:e.text,language:e.language}):/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:`Empty file.`})}function W_(e){return`data:${e.contentType};base64,${e.data}`}function G_(e,t){return`/api/conversations/${encodeURIComponent(e)}/attachments/${encodeURIComponent(t)}`}function K_(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function q_(e){return Hr.some(t=>t===e.contentType)}function J_(e){return _i.some(t=>t===e.contentType)}function Y_(e){return[e.contentType,K_(e.bytes)].join(` · `)}function X_(e,t){return t.filter(q_).map(t=>({context:Y_(t),filename:t.filename,src:G_(e,t.id)}))}function Z_(e,t){let n=[],r;for(let i of t){if(i.role===`user`){let t=X_(e,i.attachments??[]);t.length>0&&n.push(t),i.context||(r=void 0);continue}let t=X_(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 Q_=(0,Y.createContext)([]);function $_(e){let t=(0,Y.useMemo)(()=>Z_(e.conversationId,e.messages),[e.conversationId,e.messages]);return/* @__PURE__ */ (0,X.jsx)(Q_.Provider,{value:t,children:e.children})}const ev=`sm:grid-cols-[repeat(auto-fill,15rem)]`,tv=`grid min-w-0 grid-cols-2 gap-2 ${ev}`,nv=`grid min-w-0 grid-cols-1 gap-2 ${ev}`,rv=`block aspect-[4/3] w-full overflow-hidden rounded-lg border border-dashboard-border bg-dashboard-fill-faint`,iv=`size-full object-cover`,av=`${rv} transition-colors hover:border-dashboard-border-interactive focus-visible:outline-2 focus-visible:outline-dashboard-focus`;function ov(e){let t=wh();if(e.attachments.length===0)return null;let n=e=>!t.active&&(q_(e)||J_(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,X.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[i.length>0?/* @__PURE__ */ (0,X.jsx)(`div`,{className:tv,children:i.map(t=>/* @__PURE__ */ (0,X.jsx)(lv,{attachment:t.attachment,conversationId:e.conversationId},t.key))}):null,a.length>0?/* @__PURE__ */ (0,X.jsx)(`div`,{className:nv,children:a.map(t=>/* @__PURE__ */ (0,X.jsx)(dv,{attachment:t.attachment,conversationId:e.conversationId},t.key))}):null]})}function sv(e){return/* @__PURE__ */ (0,X.jsx)(`div`,{className:tv,children:e.images.map((e,t)=>/* @__PURE__ */ (0,X.jsxs)(`figure`,{className:`grid min-w-0 gap-1`,children:[/* @__PURE__ */ (0,X.jsx)(__,{filename:e.filename,imageClassName:iv,src:W_(e),triggerClassName:av}),/* @__PURE__ */ (0,X.jsx)(cv,{filename:e.filename})]},`${e.filename}:${t}`))})}function cv(e){return/* @__PURE__ */ (0,X.jsxs)(`figcaption`,{className:`flex h-6 min-w-0 items-center gap-1.5 px-0.5 font-mono text-xs`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-dashboard-text`,children:e.filename}),typeof e.bytes==`number`?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`flex-none text-dashboard-text-muted`,children:K_(e.bytes)}):null,e.download?/* @__PURE__ */ (0,X.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,X.jsx)(Vn,{size:13})}):null]})}function lv(e){let t=(0,Y.useContext)(Q_),n=G_(e.conversationId,e.attachment.id),{filename:r,bytes:i}=e.attachment;if(q_(e.attachment)){let a=t.find(e=>e.some(e=>e.src===n&&e.filename===r));return/* @__PURE__ */ (0,X.jsxs)(`figure`,{className:`grid min-w-0 gap-1`,children:[/* @__PURE__ */ (0,X.jsx)(__,{context:Y_(e.attachment),filename:r,gallery:a,imageClassName:iv,loading:`lazy`,src:n,triggerClassName:av}),/* @__PURE__ */ (0,X.jsx)(cv,{bytes:i,filename:r})]})}return/* @__PURE__ */ (0,X.jsxs)(`figure`,{className:`col-span-2 grid min-w-0 gap-1 sm:col-span-1`,children:[/* @__PURE__ */ (0,X.jsx)(`video`,{"aria-label":r,className:`${rv} bg-dashboard-ink object-contain`,controls:!0,playsInline:!0,preload:`metadata`,src:n}),/* @__PURE__ */ (0,X.jsx)(cv,{bytes:i,download:{filename:r,href:n},filename:r})]})}const uv=`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 dv(e){let[t,n]=(0,Y.useState)(!1),r=G_(e.conversationId,e.attachment.id),i=Y_(e.attachment),a=z_(e.attachment),o=/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-6 place-items-center text-dashboard-text-muted`,children:/* @__PURE__ */ (0,X.jsx)(pr,{size:13})}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,X.jsx)(`div`,{className:`truncate font-mono text-xs text-dashboard-text`,children:/* @__PURE__ */ (0,X.jsx)(Q,{text:e.attachment.filename})}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`truncate font-mono text-xs text-dashboard-text-muted`,children:/* @__PURE__ */ (0,X.jsx)(Q,{text:i})})]})]});return a?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(`button`,{"aria-haspopup":`dialog`,className:uv,onClick:()=>n(!0),type:`button`,children:o}),t?/* @__PURE__ */ (0,X.jsx)(H_,{attachment:e.attachment,href:r,language:a,meta:i,onClose:()=>n(!1)}):null]}):/* @__PURE__ */ (0,X.jsx)(`a`,{className:uv,download:e.attachment.filename,href:r,rel:`noreferrer`,target:`_blank`,children:o})}function fv(e){return e.reduce((e,t)=>e+t.data.length*3/4,0)}function pv(e){return e.length<=3&&fv(e)<=3145728}async function mv(e,t){if(t.length+e.length>3)throw Error(`Attach up to 3 images.`);if(fv(t)+e.reduce((e,t)=>e+t.size,0)>3145728)throw Error(`Images must total 3 MB or less.`);if(e.some(e=>!Hr.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 hv(e,t){let n=(t??[]).filter(e=>Hr.some(t=>t===e.contentType));return await mv(await Promise.all(n.map(async t=>{let n=await fetch(G_(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 gv(e){return/* @__PURE__ */ (0,X.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,X.jsxs)(`div`,{className:`relative min-w-0 rounded-lg border border-dashboard-border p-1`,children:[/* @__PURE__ */ (0,X.jsx)(`img`,{alt:t.filename,className:`h-20 w-24 rounded-md object-contain`,src:W_(t)}),/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(U,{render:/* @__PURE__ */ (0,X.jsx)(V,{"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,X.jsx)(Qn,{"aria-hidden":`true`,size:14})})}),/* @__PURE__ */ (0,X.jsx)(W,{size:`compact`,children:`Remove image`})]})]},n))})}function _v(e){return/* @__PURE__ */ (0,X.jsx)(`textarea`,{...e,onKeyDown:t=>{e.onKeyDown?.(t),Wd(t)}})}function vv({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(_v,{"data-slot":`textarea`,className:F(Gd,`min-h-36`,e),...t})}function yv(){return t(`junior:composer:autocorrect`,!1)}function bv(e){(0,Y.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 xv=`(pointer: coarse)`;function Sv(e){let t=window.matchMedia(xv);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function Cv(){return window.matchMedia(xv).matches}function wv(e,t,n){return t===e.lastSubmittedText&&n===e.images?e:{idempotencyKey:crypto.randomUUID(),lastSubmittedText:t,images:n}}const Tv=(0,Y.memo)(function(e){let t=kv(e.draftId),[n]=(0,Y.useState)(()=>Ov(t)),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(()=>!!n.text.trim()),[s,c]=(0,Y.useState)([]),l=(0,Y.useRef)(s),[u,d]=(0,Y.useState)(),[f,p]=(0,Y.useState)(!1),m=(0,Y.useRef)(!1),[h,g]=(0,Y.useState)(!1),_=!e.footerStart&&!e.compact,v=(0,Y.useRef)(null),y=ys(),[b]=yv(),x=!(0,Y.useSyncExternalStore)(Sv,Cv,()=>!1),S=(0,Y.useId)(),C=(0,Y.useRef)(null);bv(C);let w=(0,Y.useRef)(n),T=(0,Y.useRef)(a),E=(0,Y.useRef)(void 0),D=(0,Y.useRef)({idempotencyKey:n.idempotencyKey,lastSubmittedText:n.lastSubmittedText}),O=(0,Y.useRef)(!1),k=(0,Y.useRef)(!1),A=(0,Y.useRef)(!1),j=!!e.disabled||r;(0,Y.useEffect)(()=>()=>{E.current!==void 0&&window.clearTimeout(E.current),Nv(t,w.current)},[t]),(0,Y.useEffect)(()=>{let e=C.current;if(!e)return;Ev(e);let t=e.clientWidth,n,r=()=>{n===void 0&&(n=window.requestAnimationFrame(()=>{n=void 0,Ev(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 mv(e,t)).slice(t.length),r=[...l.current,...n];pv(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,Nv(t,w.current)},250)},te=()=>{C.current&&Ev(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=wv(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),Nv(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,Nv(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(()=>{})},ae=e=>{let n=Av(w.current,e);ne(n),Nv(t,n)},I=async()=>{if(!e.onStop||A.current)return;A.current=!0;let t;try{t=await e.onStop()}catch{return}finally{A.current=!1}t&&(ae(t),C.current?.focus({preventScroll:!0}))};return(0,Y.useImperativeHandle)(e.ref,()=>({appendText:e=>{let n=w.current.text.trimEnd(),r={...w.current,text:`${n&&`${n}\n\n`}${e}\n\n`};ne(r),Nv(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||pv([...e,...l.current]),focus:()=>C.current?.focus({preventScroll:!0}),restoreMessage:e=>{e.text.trim()&&ae(e.text);let t=e.images??[];if(t.length){let e=[...t];for(let t of l.current)pv([...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,X.jsxs)(`div`,{className:`grid min-w-0 gap-1.5`,children:[e.error||u?/* @__PURE__ */ (0,X.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,X.jsxs)(`form`,{className:q(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`,la,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,X.jsx)(gv,{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,X.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,X.jsx)(`input`,{accept:Hr.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,X.jsx)(`label`,{className:`sr-only`,htmlFor:S,children:e.label}),/* @__PURE__ */ (0,X.jsx)(_v,{autoCapitalize:b?`sentences`:`off`,autoComplete:b?void 0:`off`,autoCorrect:b?`on`:`off`,className:q(`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,X.jsxs)(`div`,{className:q(`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,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[e.compact?null:/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(U,{render:/* @__PURE__ */ (0,X.jsx)(V,{focusableWhenDisabled:!0,"aria-label":`Attach images`,disabled:j||f,onClick:()=>v.current?.click(),size:`icon`,type:`button`,children:/* @__PURE__ */ (0,X.jsx)($n,{"aria-hidden":`true`,size:16})})}),/* @__PURE__ */ (0,X.jsx)(W,{size:`compact`,children:`Attach images (up to 3 MB total)`})]}),e.footerStart,e.footerStart||e.compact||!x?null:/* @__PURE__ */ (0,X.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,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[e.onStop?/* @__PURE__ */ (0,X.jsxs)(V,{"aria-label":e.stopPending?`Stopping`:`Stop`,disabled:e.stopPending||!y,onClick:()=>void I(),children:[/* @__PURE__ */ (0,X.jsx)(Bn,{"aria-hidden":`true`,fill:`currentColor`,size:12}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`hidden md:inline`,children:e.stopPending?`Stopping…`:`Stop`})]}):null,/* @__PURE__ */ (0,X.jsxs)(V,{"aria-label":j?`Sending message`:e.submitLabel,className:q(`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,X.jsx)(ln,{"aria-hidden":`true`,size:14}),e.compact?null:/* @__PURE__ */ (0,X.jsx)(`span`,{className:`hidden md:inline`,children:j?`Sending…`:e.submitLabel})]})]})]})]})]})});function Ev(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 Ov(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 kv(e){return`junior:dashboard:conversation-draft:${encodeURIComponent(e)}`}function Av(e,t){return{...e,text:e.text.trim()?`${t}\n${e.text}`:t}}function jv(e,t){if(!t.trim())return;let n=kv(e);Nv(n,Av(Ov(n),t))}function Mv(e){let t=kv(e),{text:n}=Ov(t);return Nv(t,{...Dv(),text:``}),n}function Nv(e,t){if(typeof window<`u`)try{t.text?window.localStorage.setItem(e,JSON.stringify(t)):window.localStorage.removeItem(e)}catch{}}function Pv(e){let t=ep(e.menu),n=e.placement===`mobile`;return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid gap-0.5`,children:[n&&!e.menu.eventLogOpen?/* @__PURE__ */ (0,X.jsx)(Bv,{label:e.searchOpen?`Hide search`:`Search transcript`,onClick:()=>{e.close(),e.onSearchClick()},pressed:e.searchOpen,children:e.searchOpen?/* @__PURE__ */ (0,X.jsx)(Qn,{"aria-hidden":`true`,size:16,strokeWidth:2}):/* @__PURE__ */ (0,X.jsx)(jt,{"aria-hidden":`true`,size:16,strokeWidth:2})}):null,n?/* @__PURE__ */ (0,X.jsx)(Bv,{label:`Conversation details`,onClick:()=>{e.close(),e.onDetailsClick()},pressed:e.detailsOpen,children:/* @__PURE__ */ (0,X.jsx)(Fn,{"aria-hidden":`true`,size:16,strokeWidth:2})}):null,t.map((t,n)=>/* @__PURE__ */ (0,X.jsxs)(Y.Fragment,{children:[n>0?/* @__PURE__ */ (0,X.jsx)(Vl,{className:`my-1 bg-dashboard-border-subtle`}):null,t.map(t=>/* @__PURE__ */ (0,X.jsx)(Fv,{close:e.close,item:t},t.key))]},n))]})}function Fv(e){let{item:t}=e,n=/* @__PURE__ */ (0,X.jsx)(t.icon,{"aria-hidden":`true`,className:`size-4 shrink-0`});return t.href?/* @__PURE__ */ (0,X.jsxs)(nf,{className:Tt({size:`menu`}),href:t.href,children:[n,t.label]}):/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsxs)(V,{"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,X.jsx)(`span`,{children:t.label})]}),t.feedback===void 0?null:/* @__PURE__ */ (0,X.jsx)(`span`,{className:`sr-only`,role:`status`,children:t.feedback})]})}function Iv(e){return/* @__PURE__ */ (0,X.jsxs)(ya,{"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,X.jsx)(Lv,{label:`Conversation`,value:`rich`,children:/* @__PURE__ */ (0,X.jsx)(Sr,{"aria-hidden":`true`,size:14,strokeWidth:2})}),/* @__PURE__ */ (0,X.jsx)(Lv,{label:`Event log`,value:`raw`,children:/* @__PURE__ */ (0,X.jsx)(gr,{"aria-hidden":`true`,size:14,strokeWidth:2})})]})}function Lv(e){return/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(U,{render:/* @__PURE__ */ (0,X.jsx)(ma,{"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,X.jsx)(W,{size:`compact`,children:e.label})]})}function Rv(e){return/* @__PURE__ */ (0,X.jsxs)(G,{disabled:e.tooltipDisabled,children:[/* @__PURE__ */ (0,X.jsx)(U,{render:/* @__PURE__ */ (0,X.jsx)(V,{ref:e.ref,"aria-controls":e.controls,"aria-expanded":e.expanded,"aria-keyshortcuts":e.keyShortcuts,"aria-label":e.label,"aria-pressed":e.pressed,className:q(`text-dashboard-text-muted`,e.pressed&&`bg-dashboard-fill-strong text-dashboard-text`),onClick:e.onClick,size:`icon`,children:e.children})}),/* @__PURE__ */ (0,X.jsxs)(W,{size:`compact`,children:[e.label,e.shortcut?/* @__PURE__ */ (0,X.jsx)(`kbd`,{className:`ml-1.5 font-sans`,children:e.shortcut}):null]})]})}function zv(e){let t=(0,Y.useRef)(null);return Eh({anchorRef:t,inputRef:e.inputRef,onOpen:e.onClick,open:e.open}),/* @__PURE__ */ (0,X.jsx)(Rv,{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,X.jsx)(Qn,{"aria-hidden":`true`,size:15,strokeWidth:2}):/* @__PURE__ */ (0,X.jsx)(jt,{"aria-hidden":`true`,size:15,strokeWidth:2})})}function Bv(e){return/* @__PURE__ */ (0,X.jsxs)(V,{"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,X.jsx)(`span`,{children:e.label})]})}const Vv=`thin-scrollbar px-4 pb-4 md:px-7 md:pb-6`;function Hv(e){return/* @__PURE__ */ (0,X.jsx)(`section`,{className:`min-w-0`,children:/* @__PURE__ */ (0,X.jsx)(`div`,{className:q(e.full?`w-full`:`mx-auto w-full max-w-[52.5rem] pt-5 md:pt-7`,e.className),children:e.children})})}function Uv(e){return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:q(`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,X.jsx)(`div`,{className:`min-w-0`,children:e.header}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`@container/chat relative grid min-h-0 min-w-0 grid-rows-[minmax(0,1fr)]`,children:[/* @__PURE__ */ (0,X.jsx)(`div`,{"aria-label":e.scrollAriaLabel,className:q(`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 Wv(e,t=/* @__PURE__ */ new Map){for(let n of e)if(n.threads){for(let e of n.threads)t.set(e.id,e);Wv(n.threads,t)}return t}const Gv=(0,Y.createContext)(/* @__PURE__ */ new Map);function Kv(e){let t=(0,Y.useContext)(Gv),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,X.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`min-w-0`,children:/* @__PURE__ */ (0,X.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,X.jsxs)(`li`,{className:`inline-flex min-w-0 shrink-[2] items-center gap-1.5`,children:[t>0?/* @__PURE__ */ (0,X.jsx)(qv,{}):null,/* @__PURE__ */ (0,X.jsx)(B,{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,X.jsxs)(`li`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[/* @__PURE__ */ (0,X.jsx)(qv,{}),e.current]}):null]})})}function qv(){return/* @__PURE__ */ (0,X.jsx)(H,{"aria-hidden":`true`,className:`shrink-0 text-dashboard-text-faint`,size:14})}function Jv(e){let[t,n]=(0,Y.useState)(!1),r=(0,Y.useRef)(null),i=(0,Y.useRef)(null),a=e.buttonRef??i;return(0,Y.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,X.jsxs)(`div`,{className:`relative`,ref:r,children:[/* @__PURE__ */ (0,X.jsx)(Rv,{ref:a,label:t?`Close conversation menu`:`Conversation menu`,onClick:()=>n(e=>!e),pressed:t,tooltipDisabled:t,children:/* @__PURE__ */ (0,X.jsx)(rr,{"aria-hidden":`true`,size:18,strokeWidth:2})}),t?/* @__PURE__ */ (0,X.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 Yv(e){return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:q(`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,X.jsx)(nh,{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,X.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 Xv(e){let t=e.detailsOpen,n=(0,Y.useRef)(null),r=(0,Y.useRef)(null),i=(0,Y.useRef)(t),[a,o]=(0,Y.useState)(!1),s=(0,Y.useRef)(null),c=e.view===`rich`&&(a||e.search.length>0),l=bo();(0,Y.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,Y.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,X.jsx)(Pv,{close:r,detailsOpen:t,menu:e.menu,onDetailsClick:e.onDetailsClick,onSearchClick:d,placement:n,searchOpen:c}),p=e.view===`raw`?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(`h2`,{className:`m-0 min-w-0 font-display text-base font-medium leading-6 tracking-tight`,children:/* @__PURE__ */ (0,X.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,X.jsx)(`span`,{"aria-hidden":`true`,className:`text-dashboard-text-faint`,children:`›`}),/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-current":`page`,className:`shrink-0 font-display text-base font-medium leading-6 tracking-tight`,children:`Event log`})]}):/* @__PURE__ */ (0,X.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,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(po,{children:/* @__PURE__ */ (0,X.jsx)(Jv,{buttonRef:r,children:t=>/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(`div`,{className:`contents`,inert:e.pending,children:f(`mobile`,t)}),l?/* @__PURE__ */ (0,X.jsxs)(V,{className:`mt-0.5`,onClick:()=>{t(),l()},size:`menu`,children:[/* @__PURE__ */ (0,X.jsx)(pn,{"aria-hidden":`true`,size:16,strokeWidth:2}),`App menu`]}):null]})})}),e.contextTags||e.linkedWork?/* @__PURE__ */ (0,X.jsx)(go,{children:/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex w-max items-center gap-1.5 [&>*]:shrink-0`,children:[e.contextTags,e.linkedWork?/* @__PURE__ */ (0,X.jsx)(`div`,{"aria-label":`Linked work`,children:e.linkedWork}):null]})}):null,/* @__PURE__ */ (0,X.jsxs)(`header`,{className:q(`relative z-10 border-b md:z-30 border-dashboard-border bg-dashboard-bg`,!m&&`hidden md:block`),children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`hidden h-13 min-w-0 items-center justify-between gap-1.5 px-1 md:flex`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.sidebarToggle?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`shrink-0`,children:e.sidebarToggle}):null,e.agentTree?/* @__PURE__ */ (0,X.jsx)(Kv,{current:p,nodes:e.agentTree}):p,e.status,e.privacy?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`shrink-0`,children:e.privacy}):null,!e.agentTree&&e.contextTags?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`flex h-6 min-w-0 max-w-[min(19rem,60%)] shrink-[2] items-center`,children:e.contextTags}):null]}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,inert:e.pending,children:[e.cost?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`mr-2 text-xs tabular-nums text-dashboard-text-muted`,children:e.cost}):null,e.view===`raw`?null:/* @__PURE__ */ (0,X.jsx)(zv,{inputRef:s,onClick:d,open:c}),/* @__PURE__ */ (0,X.jsx)(Jv,{children:e=>f(`desktop`,e)}),t?null:/* @__PURE__ */ (0,X.jsx)(Rv,{ref:n,expanded:!1,label:`Conversation details`,onClick:e.onDetailsClick,children:/* @__PURE__ */ (0,X.jsx)(Zt,{"aria-hidden":`true`,size:15,strokeWidth:2})})]})]}),e.forks?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`hidden px-7 pb-2.5 md:block`,children:e.forks}):null,e.agentTree?/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2 px-4 py-2 md:hidden`,children:[/* @__PURE__ */ (0,X.jsx)(Kv,{nodes:e.agentTree}),e.status]}):null,e.forks?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`px-4 py-2 md:hidden`,children:e.forks}):null,c?/* @__PURE__ */ (0,X.jsx)(Yv,{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,X.jsx)(`div`,{className:`px-4 pb-3 text-xs text-red-300 md:px-7`,children:e},e))]})]})}function Zv(e){if(!e.active&&!e.className&&!e[`aria-label`])return e.children;let t=q(e.active&&`shimmer`,e.className);return e.as===`strong`?/* @__PURE__ */ (0,X.jsx)(`strong`,{"aria-label":e[`aria-label`],className:t,children:e.children}):/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-label":e[`aria-label`],className:t,children:e.children})}function Qv(e){return/* @__PURE__ */ (0,X.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,X.jsxs)(`span`,{className:e.label?`contents`:q(`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,X.jsx)(`span`,{className:q(`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,X.jsx)(`span`,{className:`whitespace-nowrap text-right text-dashboard-text`,children:e.value}):/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[e.value,e.live?/* @__PURE__ */ (0,X.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,X.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),/* @__PURE__ */ (0,X.jsx)(Zv,{active:!0,children:`in progress`})]}):null]})]},`${t}-${e.label??``}-${e.value}-${e.live?`live`:``}`))})}function $v(e){let t=e.tooltip?.filter(e=>e.value.trim());return!e.tooltipCard&&!t?.length?/* @__PURE__ */ (0,X.jsx)(`span`,{className:e.className,children:e.children}):/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(U,{render:/* @__PURE__ */ (0,X.jsx)(`span`,{className:q(`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,X.jsx)(W,{align:e.align===`left`?`start`:e.align===`right`?`end`:`center`,className:q(`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,X.jsx)(`span`,{className:`block max-h-[min(30rem,var(--available-height,30rem))] overflow-y-auto`,children:e.tooltipCard}):t?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`block max-h-72 overflow-y-auto`,children:/* @__PURE__ */ (0,X.jsx)(Qv,{lines:t})}):null})]})}const ey=`bg-dashboard-focus/80`,ty=`bg-dashboard-focus/30`;function ny(e){return/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,className:q(`size-2 shrink-0 rounded-xs`,e.className)})}function ry(e){let t=Math.min(100,Math.max(0,(e.split?.selfShare??1)*100));return/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`grid gap-3`,children:[/* @__PURE__ */ (0,X.jsxs)(`span`,{className:q(`grid gap-2.5`,e.sections.length>0&&`border-b border-dashboard-border pb-3`),children:[/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`flex items-baseline justify-between gap-3`,children:[/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`min-w-0 truncate font-medium text-dashboard-text`,children:[e.title,e.note?/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`text-dashboard-text-faint`,children:[` · `,e.note]}):null]}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`whitespace-nowrap text-base font-semibold tabular-nums text-dashboard-text`,children:e.total})]}),e.split?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsxs)(`span`,{"aria-hidden":`true`,className:`flex h-1.5 overflow-hidden rounded-full bg-dashboard-fill-hover`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:ey,style:{width:`${t}%`}}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:ty,style:{width:`${100-t}%`}})]}),/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`flex flex-wrap justify-between gap-x-3 gap-y-1 tabular-nums`,children:[/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 whitespace-nowrap`,children:[/* @__PURE__ */ (0,X.jsx)(ny,{className:ey}),`this agent`,/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-medium text-dashboard-text`,children:e.split.self})]}),/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 whitespace-nowrap`,children:[/* @__PURE__ */ (0,X.jsx)(ny,{className:ty}),e.split.count,` child conversation`,e.split.count===1?``:`s`,/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-medium text-dashboard-text`,children:e.split.subagents})]})]})]}):null]}),e.sections.map(e=>/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-x-3 gap-y-2`,children:[/* @__PURE__ */ (0,X.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,X.jsxs)(`span`,{className:`contents`,children:[/* @__PURE__ */ (0,X.jsxs)(`span`,{className:q(`flex min-w-0 items-baseline gap-2`,e.code&&`font-mono`),children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 truncate`,title:e.label,children:e.label}),e.live?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`shrink-0 font-sans text-2xs text-dashboard-text-muted`,children:/* @__PURE__ */ (0,X.jsx)(Zv,{active:!0,children:`in progress`})}):null]}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`whitespace-nowrap text-right tabular-nums text-dashboard-text`,children:e.value})]},e.label)),e.more?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`text-dashboard-text-faint`,children:[e.more.count,` more`]}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`whitespace-nowrap text-right tabular-nums`,children:e.more.value})]}):null]},e.title))]})}function iy(e,t){return`${Ja(t)} ${e}${t===1?``:`s`}`}function ay(e){return!!e}function oy(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:Ja(t)}]:[])}function sy(e){return{cost:(Aa(e?.cumulativeUsage)?.total??0)+(e?.auxiliaryCostUsd??0),tokens:Da(e?.cumulativeUsage)?.totalTokens??0}}function cy(e,t){return Math.min(Math.max(0,e),Math.max(0,t))}function ly(e,t,n,r){if(!e)return[];let i=cy(n,t);return[{value:`By agent`,valueStyle:`heading`},{label:`this agent`,value:r(t-i)},{label:iy(`child conversation`,e.count),value:r(i)}]}function uy(e){return e.split(`/`).at(-1)??e}function dy(e,t){return{live:e===t,value:uy(e),valueStyle:`heading`}}function fy(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 py(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:uy(e.modelId),live:e.modelId===t,value:i(e.amount)}));return t&&!a.some(e=>e.live)&&a.unshift({amount:0,code:!0,label:uy(t),live:!0,value:`…`}),a}function my(e,t,n,r){if(!e)return;let i=cy(n,t);return{count:e.count,self:r(t-i),selfShare:t>0?(t-i)/t:1,subagents:r(i)}}function hy(e){return new Intl.NumberFormat(`en-US`,{currency:`USD`,maximumFractionDigits:e,minimumFractionDigits:e,style:`currency`})}function gy(e){let t=e>=10?2:e>=1?3:4,n=hy(t),r=hy(4);return e=>e>0&&e<.5*10**-t?r.format(e):n.format(e)}function _y(e,t,n,r,i){let a=py(t,r,Da,e=>e.totalTokens,Ja);return{note:n?iy(`compaction`,n):void 0,sections:a.length?[{title:`By model`,...fy(a,4,Ja)}]:[{rows:oy(e),title:`By type`}].filter(e=>e.rows.length),split:my(i,e.totalTokens,sy(i).tokens,Ja),title:`Tokens`,total:Ja(e.totalTokens)}}function vy(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 yy(e,t,n,r,i){let a=Oa(e,n);if(!a)return;let o=gy(a.total),s=py(t,r,Aa,e=>e.total,o),c=[...n?.operations??[]].sort((e,t)=>t.costUsd-e.costUsd).map(e=>({amount:e.costUsd,label:by(e),value:o(e.costUsd)})),l=[];if(s.length)l.push({title:`By model`,...fy(s,4,o)});else if(e){let t=vy(e,o);t.length&&l.push({rows:t,title:`By type`})}return n&&c.length&&l.push({title:`Auxiliary`,total:o(n.costUsd),...fy(c,3,o)}),{sections:l,split:my(i,a.total,sy(i).cost,o),title:`Estimated cost`,total:o(a.total)}}function by(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 xy(e){let t=Ma(e.modelUsage)??e.summary,n=Oa(t,e.auxiliaryCosts);if(!n&&!e.live)return null;let r=!!e.live,i=n?`${Qa(n)}${r?`+`:``}`:`$…`,a=yy(t,e.modelUsage,e.auxiliaryCosts,e.liveModelId,e.childAgentTotals);return/* @__PURE__ */ (0,X.jsx)($v,{align:e.align,tooltipPlacement:e.tooltipPlacement??`above`,tooltip:!a&&e.liveModelId?[dy(e.liveModelId,e.liveModelId)]:void 0,tooltipCard:a?/* @__PURE__ */ (0,X.jsx)(ry,{...a}):void 0,children:/* @__PURE__ */ (0,X.jsx)(Zv,{active:r,children:i})})}function Sy(e){return e.summary?/* @__PURE__ */ (0,X.jsx)($v,{align:e.align,tooltipCard:/* @__PURE__ */ (0,X.jsx)(ry,{..._y(e.summary,e.modelUsage,e.compactionCount,e.liveModelId,e.childAgentTotals)}),children:/* @__PURE__ */ (0,X.jsx)(Zv,{active:e.live,children:Pa(e.summary)})}):null}function Cy(e){if(!e.label||e.label===`none`)return null;let t=[e.startedAt?{label:`started`,value:ao(e.startedAt)}:void 0,e.endedAt?{label:`ended`,value:ao(e.endedAt)}:void 0,...ly(e.childAgentTotals,e.durationMs??0,e.childAgentTotals?.cumulativeDurationMs??0,e=>Ba(e)||`0s`)].filter(ay);return/* @__PURE__ */ (0,X.jsx)($v,{align:e.align,tooltip:t,children:e.label})}function wy(e){if(!e.childAgentTotals)return null;let t=iy(`child conversation`,e.childAgentTotals.count);return/* @__PURE__ */ (0,X.jsx)($v,{tooltip:[{value:`Tokens, cost, and runtime include ${t} at any depth.`}],children:t})}function Ty(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 Ey(e){let t=Ty(e);return{groups:t,labeledGroups:t.slice(0,2),overflowGroupCount:Math.max(0,t.length-2)}}function Dy(e){return/* @__PURE__ */ (0,X.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,X.jsx)(nf,{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,X.jsx)(`p`,{className:`mb-0 mt-1 text-xs text-dashboard-text-muted`,children:e.authorization.completionText})]})}function Oy(e){if(e.visibility!==`private`)return null;let t=`Private conversation. Only members of this conversation can see this transcript.`;return/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`inline-flex items-center text-dashboard-text-muted`,role:`note`,title:t,children:[/* @__PURE__ */ (0,X.jsx)(Gt,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`sr-only`,children:t})]})}function ky(e){let t=e.annotations,n=Py();if(!t?.length)return null;let r=t.map(e=>Fy(e)),i=Ey(t),a=n&&i.groups.length>1,o=a?i.groups.flatMap(e=>e.annotations):[];return/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(U,{render:/* @__PURE__ */ (0,X.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,X.jsx)(Ay,{annotations:o,cutoutColor:`var(--color-dashboard-surface-panel)`}):/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[i.labeledGroups.map(e=>/* @__PURE__ */ (0,X.jsx)(My,{group:e},e.label)),i.overflowGroupCount>0?/* @__PURE__ */ (0,X.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,X.jsxs)(W,{align:`start`,children:[/* @__PURE__ */ (0,X.jsx)(wr,{children:`Linked work`}),/* @__PURE__ */ (0,X.jsx)(`ul`,{className:`m-0 list-none space-y-1 p-0`,children:t.map((e,t)=>/* @__PURE__ */ (0,X.jsxs)(`li`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.objectType?/* @__PURE__ */ (0,X.jsx)(vh,{...e,objectType:e.objectType,size:14}):e.icon?/* @__PURE__ */ (0,X.jsx)(Ly,{icon:e.icon}):null,/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:r[t]})]},`${e.key}:${t}`))})]})]})}function Ay(e){return/* @__PURE__ */ (0,X.jsx)(`span`,{className:q(`relative isolate inline-flex h-[18px] min-w-0 items-center`,e.className),children:/* @__PURE__ */ (0,X.jsx)(jy,{className:`-m-0.5 h-[22px] min-w-[22px] p-0.5`,icons:e.annotations.map((t,n)=>/* @__PURE__ */ (0,X.jsx)(Ny,{annotation:t,cutoutColor:e.cutoutColor,stacked:n>0,zIndex:n+1},t.key)),overflow:t=>/* @__PURE__ */ (0,X.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 jy(e){let t=(0,Y.useRef)(null),n=(0,Y.useRef)(null),r=e.icons.length,[i,a]=(0,Y.useState)(r);return(0,Y.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,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:q(`flex flex-wrap items-center gap-y-6 overflow-hidden`,e.className),ref:t,children:e.icons}),i<r?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`contents`,ref:n,children:e.overflow(r-i)}):null]})}function My(e){return/* @__PURE__ */ (0,X.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,X.jsx)(jy,{className:`h-3.5 min-w-3.5 gap-x-1`,icons:e.group.annotations.flatMap(e=>e.objectType?/* @__PURE__ */ (0,Y.createElement)(vh,{...e,objectType:e.objectType,key:e.key,decorative:!0,size:14}):e.icon?/* @__PURE__ */ (0,X.jsx)(Ly,{decorative:!0,icon:e.icon,size:11},e.key):[]),overflow:e=>/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[`+`,e]})}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`max-w-40 shrink-0 truncate whitespace-nowrap`,children:e.group.label})]})}function Ny(e){let t=e.annotation.icon?Iy[e.annotation.icon]:void 0;return/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,className:q(`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,X.jsx)(vh,{...e.annotation,objectType:e.annotation.objectType,decorative:!0,size:12}):e.annotation.icon?/* @__PURE__ */ (0,X.jsx)(Ly,{decorative:!0,icon:e.annotation.icon,size:11}):/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-sans text-2xs font-semibold leading-none text-dashboard-text-muted`,children:e.annotation.label.slice(0,1)})})}function Py(){return(0,Y.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 Fy(e){return[e.objectType?[Xr({objectType:e.objectType}).label,e.status].filter(Boolean).join(`: `):``,e.key.includes(`/`)||e.key.includes(`#`)?e.key:e.label].filter(Boolean).join(` · `)}const Iy={"circle-dot":{className:`text-[#3fb950] light:text-[#1a7f37]`,Icon:It,label:`Open`},"circle-dashed":{className:`text-[#8c959f] light:text-[#59636e]`,Icon:Pt,label:`Draft`},"circle-x":{className:`text-[#f85149] light:text-[#cf222e]`,Icon:un,label:`Closed`},"git-merge":{className:`text-[#a371f7] light:text-[#8250df]`,Icon:tr,label:`Merged`},"git-pull-request":{className:`text-[#3fb950] light:text-[#1a7f37]`,Icon:On,label:`Open pull request`},"triangle-alert":{className:`text-[#d29922] light:text-[#9a6700]`,Icon:jn,label:`Needs attention`}};function Ly(e){let t=Iy[e.icon],n=e.size??11;return/* @__PURE__ */ (0,X.jsxs)(`span`,{"aria-hidden":e.decorative?!0:void 0,className:q(`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,X.jsx)(t.Icon,{"aria-hidden":`true`,className:`block`,size:n,strokeWidth:2.25}),e.decorative?null:/* @__PURE__ */ (0,X.jsx)(`span`,{className:`sr-only`,children:t.label})]})}function Ry(e){return/* @__PURE__ */ (0,X.jsx)(`div`,{className:`flex gap-x-4 gap-y-2 overflow-x-auto`,children:e.links.map(e=>/* @__PURE__ */ (0,X.jsxs)(nf,{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,Zg(e.status),e.description].filter(Boolean).join(` · `),children:[/* @__PURE__ */ (0,X.jsx)(vh,{facts:e.facts,objectType:e.objectType,size:16,status:e.status}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]},e.key))})}function zy(e){return e.locationUrl?/* @__PURE__ */ (0,X.jsx)(nf,{className:sa,href:e.locationUrl,children:e.label}):e.label}function By(e){let t=e.sourceTask.id?.trim(),n=e.sourceTask.title?.trim(),r=n?`Automation: ${n}`:`Automation`;return t?/* @__PURE__ */ (0,X.jsx)(B,{className:sa,to:Xa(t),children:r}):/* @__PURE__ */ (0,X.jsx)(`span`,{children:r})}function Vy(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 Hy(e){return Ky(e).length>0}function Uy(e){let t=Ky(e);return t.length===0?null:/* @__PURE__ */ (0,X.jsx)(`dl`,{className:`m-0 grid min-w-0 gap-2 text-xs leading-snug`,children:t.map(e=>/* @__PURE__ */ (0,X.jsxs)(`div`,{className:q(`flex min-w-0 items-baseline justify-between gap-4`,e.mobileOnly&&`md:hidden`),children:[/* @__PURE__ */ (0,X.jsx)(`dt`,{className:`shrink-0 text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,X.jsx)(`dd`,{className:`m-0 min-w-0 break-words text-right tabular-nums text-dashboard-text`,children:e.content})]},e.key))})}function Wy(e,t){if(!e)return null;let n=Ka(e,{includeId:!1});return n?/* @__PURE__ */ (0,X.jsx)(zy,{label:n,locationUrl:t?.locationUrl??e.locationUrl}):null}function Gy(e,t,n){if(!e)return null;let r=Aa(t?.cumulativeUsage??e.cumulativeUsage),i=t?.auxiliaryCosts??e.auxiliaryCosts,a=(t?.status??e.status)===`active`;return!r&&!i&&!a?null:/* @__PURE__ */ (0,X.jsx)(xy,{auxiliaryCosts:i,childAgentTotals:t?.childAgentTotals??e.childAgentTotals,live:a,liveModelId:Vy(t),modelUsage:t?.modelUsage,summary:r,tooltipPlacement:n})}function Ky(e){if(!e.conversation)return[];let t=e.detail?.previousCursor?void 0:e.detail,n=e.detail?.cumulativeUsage??e.conversation.cumulativeUsage,r=wa(e.detail?.modelUsage)??Da(n),i=Va(e.conversation),a=(e.detail?.status??e.conversation.status)===`active`,o=Vy(e.detail),s=e.detail?.sourceTask,c=e.detail?.childAgentTotals??e.conversation.childAgentTotals,l=e.conversation.lastSeenAt,u=Wy(e.conversation,e.detail),d=e.showUsageBreakdown?null:Gy(e.conversation,e.detail);return[u?{content:u,key:`location`,label:`Location`,mobileOnly:!0}:void 0,s?{content:/* @__PURE__ */ (0,X.jsx)(By,{sourceTask:s}),key:`source-task`,label:`Source`}:void 0,l?{content:/* @__PURE__ */ (0,X.jsx)(`time`,{dateTime:l,title:ao(l,{dateStyle:`medium`,timeStyle:`short`}),children:oo(l)}),key:`last-activity`,label:`Last activity`}:void 0,i===`none`?void 0:{content:/* @__PURE__ */ (0,X.jsx)(Cy,{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,X.jsx)(Sy,{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,X.jsx)(wy,{childAgentTotals:c}),key:`subagents`,label:`Child conversations`}:void 0].filter(e=>e!==void 0)}function qy(e){let t=Pl(e.onClose);return/* @__PURE__ */ (0,X.jsx)(Sl,{...t.rootProps,children:/* @__PURE__ */ (0,X.jsxs)(El,{...t.contentProps,"aria-label":e.label,side:`bottom`,className:q(`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,X.jsx)(Dl,{className:`border-b border-dashboard-border`,children:/* @__PURE__ */ (0,X.jsx)(Ol,{className:`break-words`,children:e.title??e.label})}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain [scrollbar-gutter:stable]`,children:e.children})]})})}const Jy=`(min-width: 1280px)`;function Yy(e){let t=window.matchMedia(Jy);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function Xy(){return window.matchMedia(Jy).matches}function Zy(){return(0,Y.useSyncExternalStore)(Yy,Xy,()=>!1)}function Qy(e){let{onClose:t,overlay:n}=e,r=`Close ${e.label.toLowerCase()}`,i=Zy(),a=(0,Y.useRef)(null),o=(0,Y.useRef)(i);return(0,Y.useEffect)(()=>{i&&!o.current&&!document.querySelector(`[data-dashboard-modal]`)&&a.current?.focus({preventScroll:!0}),o.current=i},[i]),(0,Y.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,X.jsx)(k_,{actions:e.actions,closeLabel:r,header:e.title,label:e.label,onClose:t,openKey:e.label,width:`wide`,children:e.children}):/* @__PURE__ */ (0,X.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,X.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-dashboard-border py-2 pl-5 pr-3`,children:[/* @__PURE__ */ (0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:e.title}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[e.actions,/* @__PURE__ */ (0,X.jsx)(V,{ref:a,"aria-label":r,"data-slot":`details-panel-close`,onClick:t,size:`icon`,children:/* @__PURE__ */ (0,X.jsx)(Qn,{"aria-hidden":`true`,size:15})})]})]}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`thin-scrollbar min-h-0 overflow-y-auto overscroll-contain [scrollbar-gutter:stable]`,children:e.children})]}):/* @__PURE__ */ (0,X.jsx)(qy,{label:e.label,title:e.sheetTitle,onClose:t,children:e.actions?/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid h-full min-h-0 grid-rows-[minmax(0,1fr)_auto]`,children:[/* @__PURE__ */ (0,X.jsx)(`div`,{className:`min-h-0`,children:e.children}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`flex justify-end gap-1 border-t border-dashboard-border px-4 py-2`,children:e.actions})]}):e.children})}const $y=`junior:conversation:sidebar-open`,eb=`junior:conversation:details-open`,tb=`junior:conversation:sidebar-width`,nb=`junior:conversation:details-width`,rb={default:320,max:480,min:240},ib={default:400,max:720,min:320};function ab(){let[e,t]=(0,Y.useState)(()=>gb($y)!==`false`);function n(e){t(e),_b($y,String(e))}return[e,n]}function ob(){let e=gb(eb);return e===null?void 0:e===`true`}function sb(e){Xy()&&_b(eb,String(e))}function cb(){return fb(tb,rb)}function lb(e){_b(tb,String(Math.round(e)))}function ub(){return fb(nb,ib)}function db(e){_b(nb,String(Math.round(e)))}function fb(e,t){let n=Number(gb(e));return!Number.isFinite(n)||n<=0?t.default:Math.min(t.max,Math.max(t.min,n))}function pb(){return(0,Y.useSyncExternalStore)(e=>{let t=window.matchMedia(Fl);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)},()=>window.matchMedia(Fl).matches,()=>!1)}const mb=`(min-width: 1440px)`;function hb(){return(0,Y.useSyncExternalStore)(e=>{let t=window.matchMedia(mb);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)},()=>window.matchMedia(mb).matches,()=>!1)}function gb(e){try{return window.localStorage.getItem(e)}catch{return null}}function _b(e,t){try{window.localStorage.setItem(e,t)}catch{}}const vb=`conversation-side-panel`;function yb(e){let t=Zy(),n=(0,Y.useRef)(null),r=(0,Y.useRef)(null),i=(0,Y.useRef)(null),[a]=(0,Y.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,Y.useLayoutEffect)(()=>{let e=s?r.current:i.current;a&&e&&a.parentNode!==e&&e.append(a)},[a,s]),/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsxs)(ih,{className:`min-h-0 min-w-0`,elementRef:n,onLayoutChanged:(e,t)=>{if(!t.isUserInteraction)return;let r=e[vb]??0,i=n.current?.offsetWidth??0;r>0&&db(r/100*i)},children:[/* @__PURE__ */ (0,X.jsx)(ah,{className:`grid min-h-0`,id:`conversation-transcript`,minSize:448,children:e.children}),s?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(oh,{"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,X.jsx)(ah,{className:`grid min-h-0`,defaultSize:ub(),groupResizeBehavior:`preserve-pixel-size`,id:vb,maxSize:ib.max,minSize:ib.min,children:/* @__PURE__ */ (0,X.jsx)(`div`,{className:`grid h-full min-h-0`,ref:r})})]}):null]}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`contents`,ref:i}),o?a?(0,ou.createPortal)(e.side,a):e.side:null]})}const bb=1.65;function xb(e){let{lines:t}=e,n=(0,Y.useId)(),r=(0,Y.useRef)(null),i=(0,Y.useRef)(null),a=(0,Y.useRef)(null),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),u=o&&!c;return(0,Y.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*bb?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,Y.useLayoutEffect)(()=>{let e=a.current;!c&&e&&document.activeElement===e&&e.scrollIntoView({block:`nearest`})},[c]),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`relative min-w-0`,children:[/* @__PURE__ */ (0,X.jsx)(`div`,{className:q(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*bb&&l(!0)},ref:r,style:u?{maskImage:`linear-gradient(black calc(100% - ${bb}lh), transparent)`,maxHeight:`${t}lh`}:void 0,tabIndex:-1,children:/* @__PURE__ */ (0,X.jsx)(`div`,{ref:i,children:e.children})}),o?/* @__PURE__ */ (0,X.jsx)(`button`,{"aria-controls":n,"aria-expanded":c,"aria-label":`${c?`Collapse`:`Expand`} ${e.label}`,className:q(`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,X.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,X.jsx)(Wt,{className:`size-4 group-aria-expanded:rotate-180`,strokeWidth:2.25})})}):null]})}function Sb(e){return/* @__PURE__ */ (0,X.jsx)(`dl`,{className:q(`grid gap-px overflow-hidden rounded-md border border-dashboard-border-subtle bg-dashboard-fill-hover`,e.className),children:e.children})}function Cb(e){return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`min-w-0 bg-dashboard-bg-elevated px-3 py-3`,children:[/* @__PURE__ */ (0,X.jsx)(`dt`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,X.jsx)(`dd`,{className:q(`mt-1.5 ml-0 break-words text-sm leading-relaxed text-dashboard-text`,e.valueClassName),children:e.children})]})}const wb={abandoned:`neutral`,answered:`info`,blocked:`danger`,done:`success`,in_progress:`accent`,partial:`warning`};function Tb(e){let{content:t}=e.brief,n=e.brief.mentions;return e.variant===`summary`?/* @__PURE__ */ (0,X.jsx)(xb,{className:`leading-6`,label:`Brief summary`,lines:4,children:/* @__PURE__ */ (0,X.jsx)($,{compact:!0,mentions:n,text:t.summary})}):/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0 gap-3`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[/* @__PURE__ */ (0,X.jsx)(Np,{tone:wb[t.outcome.status],children:kb(t.outcome.status)}),/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`text-xs text-dashboard-text-muted`,children:[`Brief v`,e.brief.version,` · updated`,` `,ao(e.brief.updatedAt,{dateStyle:`medium`,timeStyle:`short`})]})]}),/* @__PURE__ */ (0,X.jsx)($,{mentions:n,text:t.summary}),/* @__PURE__ */ (0,X.jsx)(Eb,{title:`Intent & outcome`,children:/* @__PURE__ */ (0,X.jsxs)(Sb,{children:[/* @__PURE__ */ (0,X.jsx)(Cb,{label:`Intent`,children:/* @__PURE__ */ (0,X.jsx)($,{mentions:n,text:t.intent})}),/* @__PURE__ */ (0,X.jsx)(Cb,{label:`Outcome`,children:/* @__PURE__ */ (0,X.jsx)($,{mentions:n,text:t.outcome.text})})]})}),t.decisions.length?/* @__PURE__ */ (0,X.jsx)(Eb,{title:`Decisions`,children:/* @__PURE__ */ (0,X.jsx)(Db,{decisions:t.decisions,mentions:n})}):null,t.facts.length||t.links.length||t.keywords.length?/* @__PURE__ */ (0,X.jsx)(Eb,{title:`Facts, links & keywords`,children:/* @__PURE__ */ (0,X.jsxs)(Sb,{children:[t.facts.length?/* @__PURE__ */ (0,X.jsx)(Cb,{label:`Facts`,children:/* @__PURE__ */ (0,X.jsx)(Ob,{items:t.facts,mentions:n})}):null,t.links.length?/* @__PURE__ */ (0,X.jsx)(Cb,{label:`Links`,children:/* @__PURE__ */ (0,X.jsx)(`ul`,{className:`m-0 grid list-none gap-2 p-0`,children:t.links.map(e=>/* @__PURE__ */ (0,X.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[/* @__PURE__ */ (0,X.jsx)(nf,{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,X.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,children:kb(e.kind)}),e.status?/* @__PURE__ */ (0,X.jsx)(Np,{size:`compact`,tone:Ab(e.status),children:e.status}):null]},`${e.kind}:${e.url}`))})}):null,t.keywords.length?/* @__PURE__ */ (0,X.jsx)(Cb,{label:`Keywords`,children:/* @__PURE__ */ (0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.keywords.map(e=>/* @__PURE__ */ (0,X.jsx)(Np,{size:`compact`,children:e},e))})}):null]})}):null]})}function Eb(e){return/* @__PURE__ */ (0,X.jsxs)(yh,{className:`min-w-0 border-t border-dashboard-border pt-3`,children:[/* @__PURE__ */ (0,X.jsxs)(bh,{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,X.jsx)(H,{"aria-hidden":`true`,className:q(ca,`text-dashboard-text-muted`)}),e.title]}),/* @__PURE__ */ (0,X.jsx)(xh,{hiddenUntilFound:!0,children:/* @__PURE__ */ (0,X.jsx)(`div`,{className:`mt-3`,children:e.children})})]})}function Db(e){return/* @__PURE__ */ (0,X.jsx)(`ul`,{className:`m-0 grid list-none gap-2.5 p-0`,children:e.decisions.map((t,n)=>/* @__PURE__ */ (0,X.jsxs)(`li`,{children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[/* @__PURE__ */ (0,X.jsx)(Np,{size:`compact`,tone:t.kind===`assumed`?`warning`:`info`,children:t.kind}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0`,children:/* @__PURE__ */ (0,X.jsx)($,{inline:!0,mentions:e.mentions,text:t.text})})]}),t.by?/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`mt-0.5 text-xs text-dashboard-text-muted`,children:[`by ·`,` `,/* @__PURE__ */ (0,X.jsx)($,{inline:!0,mentions:e.mentions,text:t.by})]}):null]},`${t.text}:${n}`))})}function Ob(e){return/* @__PURE__ */ (0,X.jsx)(`ul`,{className:`my-0 grid gap-1.5 pl-4`,children:e.items.map((t,n)=>/* @__PURE__ */ (0,X.jsx)(`li`,{children:/* @__PURE__ */ (0,X.jsx)($,{inline:!0,mentions:e.mentions,text:t})},`${t}:${n}`))})}function kb(e){return e.replaceAll(`_`,` `)}function Ab(e){return e===`merged`||e===`done`?`success`:e===`closed`||e===`blocked`?`danger`:e===`open`||e===`in_progress`?`accent`:`neutral`}const jb={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 Mb(e){return/* @__PURE__ */ (0,X.jsxs)(`span`,{className:q(`inline-flex shrink-0 items-center`,e.className),title:e.label,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,className:q(`size-1.5 rounded-full`,jb[e.tone??`neutral`])}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`sr-only`,children:e.label})]})}const Nb={active:`info`,blocked:`warning`,completed:`success`,error:`danger`,failed:`danger`,paused:`info`,running:`info`};function Pb(e){return Nb[e]??`neutral`}const Fb={danger:`text-rose-200/85`,warning:`text-amber-200/85`};function Ib(e){return I({queryFn:({signal:t})=>K(xi,`/api/conversations/${encodeURIComponent(e)}/agents`,t),queryKey:id(e,`agents`),retry:!1})}function Lb(e){let t=(0,Y.useContext)(Gv),{action:n,items:r}=zb(e.threads);return/* @__PURE__ */ (0,X.jsx)(Ig,{action:n,count:r.length,flat:!0,label:`Threads`,title:`Threads`,children:r.length>0?/* @__PURE__ */ (0,X.jsx)(Lg,{itemKey:e=>e.conversationId,items:r,renderItem:e=>/* @__PURE__ */ (0,X.jsx)(Ub,{agent:e,title:t.get(e.conversationId)?.displayTitle,to:kc(e.conversationId)})}):/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0`,children:`Every Thread is archived.`})})}function Rb(e){let{action:t,items:n}=zb(e.tasks);return/* @__PURE__ */ (0,X.jsx)(Ig,{action:t,count:n.length,flat:!0,label:`Tasks`,title:`Tasks`,children:n.length>0?/* @__PURE__ */ (0,X.jsx)(Lg,{itemKey:e=>e.conversationId,items:n,renderItem:t=>/* @__PURE__ */ (0,X.jsx)(Ub,{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,X.jsx)(`p`,{className:`m-0`,children:`Every Task is archived.`})})}function zb(e){let[t,n]=(0,Y.useState)(!1),r=e.filter(e=>e.archivedAt).length;return{action:r>0?/* @__PURE__ */ (0,X.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 Bb={active:It,blocked:qn,completed:nn,error:un,failed:un,paused:fn},Vb={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 Hb(e){let t=e.archived?bn:e.status===`running`?Dp:Bb[e.status]??yr;return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(t,{"aria-hidden":`true`,className:q(`size-3.5`,e.archived?`text-dashboard-text-faint`:Vb[Pb(e.status)])}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`sr-only`,children:e.archived?`archived`:e.status})]})}function Ub(e){let{agent:t}=e,n=Pb(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:``,io(t.cumulativeUsage),no(t.cumulativeUsage,t.auxiliaryCosts),s?`+${s} nested`:``].filter(Boolean);return/* @__PURE__ */ (0,X.jsxs)(Rg,{icon:/* @__PURE__ */ (0,X.jsx)(Hb,{archived:!!t.archivedAt,status:t.status}),meta:Ba(t.cumulativeDurationMs),onClick:e.onOpen,title:i??o??a,to:e.to,tooltip:[r&&r!==i?r:``,`Updated ${ao(t.updatedAt,{dateStyle:`medium`,timeStyle:`short`})}`].filter(Boolean).join(`
15
+ `),children:[c.length>0||t.redacted?/* @__PURE__ */ (0,X.jsxs)(zg,{className:`flex items-center gap-1.5`,children:[t.redacted?/* @__PURE__ */ (0,X.jsx)(Gt,{"aria-hidden":`true`,className:`size-3 shrink-0`}):null,/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:c.join(` · `)})]}):null,t.error?/* @__PURE__ */ (0,X.jsx)(zg,{className:q(`line-clamp-2 whitespace-pre-wrap break-words`,Fb[n]),children:t.error}):null]})}function Wb(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 Gb(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 Kb(e){let{unread:t}=e,n=N({mutationFn:t=>$i(Ei,`/api/conversations/${encodeURIComponent(e.conversationId)}/catch-up`,t)}),r=!n.isIdle;if(t&&(r||e.events&&Gb(e.events,t,e)))return{data:n.data,error:n.isError,pending:n.isPending,request:()=>n.mutate(t),unreadMessages:Wb(e.events??[],t,e)}}const qb=(0,Y.createContext)(void 0);function Jb(){return(0,Y.useContext)(qb)}const Yb=`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 Xb(){let e=Jb();if(!e||e.data||e.pending)return null;let{count:t,more:n}=e.unreadMessages,r=t>99?`99+`:`${t}${n?`+`:``}`;return/* @__PURE__ */ (0,X.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,X.jsx)(Tn,{"aria-hidden":`true`,size:12,strokeWidth:2}),`Catch me up`,t?/* @__PURE__ */ (0,X.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 Zb(){let e=Jb(),t=(0,Y.useContext)(rm),n=(0,Y.useRef)(null),r=e?.data?`data`:e?.pending?`pending`:void 0;return(0,Y.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,X.jsxs)(`div`,{"aria-label":`Catch-up`,className:Yb,ref:n,role:`group`,children:[/* @__PURE__ */ (0,X.jsx)($,{text:e.data.summary}),e.data.needsYou?/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`m-0 border-t border-dashboard-accent/15 pt-2.5`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-semibold text-dashboard-accent-text`,children:`Needs you`}),/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,className:`px-1.5 text-dashboard-text-muted`,children:`·`}),e.data.needsYou]}):null,t?/* @__PURE__ */ (0,X.jsxs)(V,{className:`-mb-1 h-7 justify-self-center gap-1.5 px-2 text-xs`,onClick:t,variant:`quiet`,children:[/* @__PURE__ */ (0,X.jsx)(Sn,{"aria-hidden":`true`,size:14,strokeWidth:2}),`Jump to latest`]}):null]}):e?.error?/* @__PURE__ */ (0,X.jsx)(A_,{className:`text-center text-xs`,children:`Catch-up failed. Try again.`}):e?.pending?/* @__PURE__ */ (0,X.jsxs)(`div`,{"aria-label":`Summarizing new messages`,className:Yb,ref:n,role:`status`,children:[/* @__PURE__ */ (0,X.jsx)(J,{className:`h-4 w-full`}),/* @__PURE__ */ (0,X.jsx)(J,{className:`h-4 w-2/3`})]}):null}const Qb=`grid-cols-[1.5rem_minmax(0,1fr)] gap-2 md:grid-cols-[2rem_minmax(0,1fr)] md:gap-3`,$b=`mt-1 size-6 md:mt-0 md:size-8`;function ex({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(`div`,{...t,className:q(`grid min-w-0 grid-cols-[minmax(0,1fr)] gap-1`,e)})}function tx(){return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid gap-2 py-1`,"data-transcript-unread-marker":``,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_1fr] items-center gap-3`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-label":`New messages`,className:`h-px bg-dashboard-accent/50`,role:`separator`}),/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,className:`font-sans text-xs font-semibold text-dashboard-accent-text`,children:`New`}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`h-px flex-1 bg-dashboard-accent/50`}),/* @__PURE__ */ (0,X.jsx)(Xb,{})]})]}),/* @__PURE__ */ (0,X.jsx)(Zb,{})]})}const nx=(0,Y.createContext)(null);function rx(e){let t=(0,Y.useContext)(nx),[n,r]=(0,Y.useState)(()=>e!==void 0&&t?.get(e)||!1);return[n,n=>{r(n),e!==void 0&&t?.set(e,n)}]}function ix(e){return/* @__PURE__ */ (0,X.jsx)(`div`,{className:q(`py-1.5`,e.indent&&q(`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,X.jsx)(`div`,{className:`col-start-2 min-w-0`,children:e.children}):e.children})}const ax=[[`running`,`running`],[`blocked`,`blocked`],[`error`,`failed`],[`aborted`,`stopped`]],ox={aborted:`stopped`,blocked:`blocked`,completed:`completed`,error:`failed`,running:`running`};function sx(e){return e.title??e.agentName??e.task??e.subagentKind}function cx(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 Ya(Math.min(...t),Math.max(...n))}function lx(e){if(e.length===1)return ox[e[0].part.status];let t=ax.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 ux(e){return/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,className:q(`size-2 shrink-0 rounded-xs`,jb[Pb(e.status)],e.status===`running`&&`animate-pulse motion-reduce:animate-none`)})}const dx=`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 fx(e){let{active:t}=wh(),[n,r]=rx(e.openKey),i=e.entries.length===1?e.entries[0]:void 0,a=!i&&(n||t),o=lx(e.entries),s=cx(e.entries),c=/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[i?/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`Task · `,/* @__PURE__ */ (0,X.jsx)(Q,{text:sx(i.part)})]}):/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`shrink-0`,children:[e.entries.length,` Tasks`]}),/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`shrink-0`,children:o}),s?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`shrink-0 tabular-nums text-dashboard-text-faint`,children:s}):null,/* @__PURE__ */ (0,X.jsx)(H,{"aria-hidden":`true`,className:q(`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,X.jsx)(`button`,{"aria-label":`Open ${sx(i.part)} transcript`,className:dx,onClick:()=>e.onOpenTranscript?.(i.part),type:`button`,children:c}):/* @__PURE__ */ (0,X.jsx)(`div`,{className:q(dx,`cursor-default`),children:c}):/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,X.jsx)(`button`,{"aria-expanded":a,className:dx,onClick:()=>r(!a),type:`button`,children:c}),a?/* @__PURE__ */ (0,X.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,X.jsx)(`li`,{children:/* @__PURE__ */ (0,X.jsx)(px,{entry:t,onOpenTranscript:e.onOpenTranscript})},t.key))}):null]})}function px(e){let{part:t}=e.entry,n=sx(t),r=Ya(e.entry.timestamp,t.finishedTimestamp),i=/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(ux,{status:t.status}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-dashboard-text`,children:/* @__PURE__ */ (0,X.jsx)(Q,{text:n})}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`shrink-0 text-dashboard-text-muted`,children:ox[t.status]}),r?/* @__PURE__ */ (0,X.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,X.jsx)(`button`,{"aria-label":`Open ${n} transcript`,className:q(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,X.jsx)(`div`,{className:a,children:i})}function mx(e){let t=e.part.childConversationId,n=(0,Y.useContext)(Gv).get(t),r=_u().has(t),i=Sm(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,X.jsxs)(B,{...i,className:q(`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,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-sans text-sm font-medium text-dashboard-text`,children:/* @__PURE__ */ (0,X.jsx)(Q,{text:a})}),n?/* @__PURE__ */ (0,X.jsx)(Rp,{status:Pp(n,r)}):null,o?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`shrink-0 font-sans text-xs tabular-nums text-dashboard-text-faint`,children:Dc(o)}):null,/* @__PURE__ */ (0,X.jsx)(H,{"aria-hidden":`true`,className:`size-4 shrink-0 text-dashboard-text-faint transition-colors group-hover/thread:text-dashboard-text`})]})}function hx(e){let t=e.part.event,n=t.details?` at approximately ${Ja(t.details.estimatedInputTokens)} estimated tokens`:``,r=t.modelId?` using ${t.modelId}`:``;return/* @__PURE__ */ (0,X.jsxs)(`article`,{className:`min-w-0 py-0.5`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[/* @__PURE__ */ (0,X.jsx)(`strong`,{className:`font-sans text-xs font-semibold text-amber-100`,children:`Context compacted`}),typeof e.timestamp==`number`?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,children:Wa(e.timestamp)}):null]}),/* @__PURE__ */ (0,X.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,X.jsxs)(yh,{className:`mt-2`,children:[/* @__PURE__ */ (0,X.jsxs)(bh,{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,X.jsx)(H,{"aria-hidden":`true`,className:ca}),`Continuation summary`]}),/* @__PURE__ */ (0,X.jsx)(xh,{hiddenUntilFound:!0,children:/* @__PURE__ */ (0,X.jsx)(`div`,{className:`mt-1.5 whitespace-pre-wrap text-xs leading-relaxed text-dashboard-text-muted`,children:/* @__PURE__ */ (0,X.jsx)($,{mentions:e.part.mentions,text:t.summary})})})]}):null]})}const gx=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 _x(e){return I({queryFn:({signal:t})=>K(gx,`/api/plugins/memory/conversations/${encodeURIComponent(e)}/memories`,t),queryKey:id(e,`memories`),retry:!1})}function vx(e){return`${e.source}:${e.turnId}`}function yx(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 bx(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 xx=(0,Y.createContext)(void 0);function Sx(){return(0,Y.useContext)(xx)}function Cx(e){return e.namespace===`memory`&&e.name===`memories_captured`}const wx=(0,Y.createContext)(!1);function Tx(e){let t=Ex(e.kind),n=e.icon??t.icon,r=(0,Y.useContext)(wx);return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:q(`grid min-w-0 items-start`,r?`grid-cols-[1rem_minmax(0,1fr)] gap-2`:Qb),"data-transcript-rail-event":e.kind,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,className:q(`grid h-6 place-items-center`,!r&&(e.kind===`thread`||e.kind===`message_context`)&&`mt-1.5`,t.className),children:e.objectType?/* @__PURE__ */ (0,X.jsx)(vh,{objectType:e.objectType,size:14,decorative:!0}):/* @__PURE__ */ (0,X.jsx)(n,{size:r?14:15,strokeWidth:2})}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`min-w-0`,children:e.children})]})}function Ex(e){return e===`message_context`?{className:`text-dashboard-text-muted`,icon:hn}:e===`event`?{className:`text-violet-200`,icon:Hn}:e===`attachments_delivered`?{className:`text-dashboard-text-muted`,icon:Kn}:e===`structured_event`?{className:`text-violet-200`,icon:on}:e===`tasks`?{className:`text-cyan-200`,icon:gn}:e===`thread`?{className:`text-cyan-200`,icon:Sr}:{className:`text-amber-200`,icon:sn}}const Dx={activity:on,brain:Cr,calendar:cn,check:Xt,database:zn,info:Fn,key:Et,link:yn,sparkles:Tn,warning:jn};function Ox(e){return e?Dx[e]:on}function kx({className:e,flush:t=!1,...n}){return/* @__PURE__ */ (0,X.jsx)(bh,{...n,className:q(`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 Ax(e,t,n){return e===1?t:`${e} ${n}`}function jx(e){return e.kind===`failure`||e.kind===`attachments_delivered`||e.kind===`subagent`?!1:e.kind===`message`?vf(e.message):!(e.kind===`structured_event`&&Cx(e.part))}function Mx(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 Nx(e){return e.kind===`tool`?e.part.startedTimestamp??e.timestamp:e.kind===`message`?e.message.timestamp:e.timestamp}function Px(e){return e.kind===`tool`?e.part.resultTimestamp??e.timestamp:e.kind===`message`?e.message.timestamp:e.timestamp}function Fx(e){let t,n;for(let r of e){let e=Nx(r),i=Px(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 Ix(e){let t=Ax(e.length,`1 event`,`events`),n=Fx(e);return typeof n!=`number`||n<=0?t:`${t} · ${Ua(n)}`}function Lx(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?Ax(t,`1 tool call`,`tool calls`):void 0,n>0?Ax(n,`1 reasoning entry`,`reasoning entries`):void 0,r>0?Ax(r,`context compacted`,`context compacted`):void 0,i>0?Ax(i,`1 structured event`,`structured events`):void 0,a>0?Ax(a,`1 file delivery`,`file deliveries`):void 0,o>0?Ax(o,`1 event`,`events`):void 0,s>0?Ax(s,`1 quiet reply`,`quiet replies`):void 0].filter(e=>e!==void 0);return c.length>0?c.join(` · `):Ix(e)}function Rx(e){return e.some(e=>e.kind===`tool`&&e.part.status===`running`)}function zx(e){let{active:t}=wh(),[n,r]=rx(e.openKey),i=e.entries.map(t=>/* @__PURE__ */ (0,X.jsx)(Y.Fragment,{children:e.renderEntry(t)},t.key)),a=Ix(e.entries),o=Lx(e.entries),s=Rx(e.entries);return t?/* @__PURE__ */ (0,X.jsx)(wx.Provider,{value:!0,children:/* @__PURE__ */ (0,X.jsx)(`div`,{className:`grid min-w-0 gap-1`,children:i})}):/* @__PURE__ */ (0,X.jsxs)(yh,{className:`min-w-0 py-0.5`,onOpenChange:r,open:n,children:[/* @__PURE__ */ (0,X.jsx)(kx,{flush:!0,className:q(`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,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsxs)(U,{render:/* @__PURE__ */ (0,X.jsx)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`}),children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:/* @__PURE__ */ (0,X.jsx)(Zv,{active:s,children:n?`Hide ${a}`:a})}),/* @__PURE__ */ (0,X.jsx)(H,{"aria-hidden":`true`,className:`size-3 shrink-0 opacity-55 transition-transform group-aria-expanded/activity-run:rotate-90`,strokeWidth:2.2})]}),/* @__PURE__ */ (0,X.jsx)(W,{children:o})]})}),/* @__PURE__ */ (0,X.jsx)(xh,{hiddenUntilFound:!0,children:/* @__PURE__ */ (0,X.jsx)(wx.Provider,{value:!0,children:/* @__PURE__ */ (0,X.jsx)(`div`,{className:`mt-1.5 grid min-w-0 gap-1`,children:i})})})]})}function Bx({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(lt,{"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,X.jsx)(Ze,{"data-slot":`checkbox-indicator`,children:/* @__PURE__ */ (0,X.jsx)(Xt,{"aria-hidden":`true`,size:12,strokeWidth:3})})})}function Vx(e){return/* @__PURE__ */ (0,X.jsx)(ct,{"data-slot":`radio-group`,...e})}function Hx({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(it,{"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,X.jsx)(dt,{"data-slot":`radio-group-indicator`,className:`size-1.5 rounded-full bg-dashboard-text-inverse`})})}const Ux=`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 Wx(e){return/* @__PURE__ */ (0,X.jsx)(`span`,{className:q(`ml-2 text-xs font-normal text-dashboard-accent-text/80`,e.className),children:`Suggested`})}function Gx(e){return e.value?/* @__PURE__ */ (0,X.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 Kx(e){return/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`grid min-w-0 gap-0.5 break-words`,children:[/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`font-medium text-dashboard-text`,children:[e.label,e.recommended?/* @__PURE__ */ (0,X.jsx)(Wx,{}):null]}),e.description?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,children:e.description}):null]})}function qx(e){let t=(0,Y.useId)(),{field:n}=e,r=/* @__PURE__ */ (0,X.jsxs)(`legend`,{className:`mb-2 p-0 text-sm font-semibold text-dashboard-text`,children:[n.label,n.kind===`multi_choice`?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`ml-2 text-xs font-normal text-dashboard-text-muted`,children:`Pick any`}):null]}),i=n.description?/* @__PURE__ */ (0,X.jsx)(Xd,{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,X.jsxs)(`fieldset`,{className:`m-0 min-w-0 border-0 p-0`,children:[r,i,/* @__PURE__ */ (0,X.jsx)(Vx,{"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,X.jsxs)(`label`,{className:Ux,children:[/* @__PURE__ */ (0,X.jsx)(Hx,{className:`mt-0.5`,value:e.label}),/* @__PURE__ */ (0,X.jsx)(Kx,{description:e.description,label:e.label,recommended:e.recommended})]},e.label))})]}):/* @__PURE__ */ (0,X.jsxs)(`fieldset`,{"aria-describedby":a,className:`m-0 min-w-0 border-0 p-0`,children:[r,i,/* @__PURE__ */ (0,X.jsx)(`div`,{className:`grid gap-2`,children:n.options.map(t=>/* @__PURE__ */ (0,X.jsxs)(`label`,{className:Ux,children:[/* @__PURE__ */ (0,X.jsx)(Bx,{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,X.jsx)(Kx,{description:t.description,label:t.label,recommended:t.recommended})]},t.label))})]})}function Jx(e){let t=(0,Y.useId)();return/* @__PURE__ */ (0,X.jsxs)(Jd,{children:[/* @__PURE__ */ (0,X.jsx)(Yd,{htmlFor:t,children:e.label}),e.description?/* @__PURE__ */ (0,X.jsx)(Xd,{className:`-mt-1`,id:`${t}-help`,children:e.description}):null,/* @__PURE__ */ (0,X.jsx)(vv,{"aria-describedby":e.description?`${t}-help`:void 0,className:q(`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 Yx(e){let[t,n]=(0,Y.useState)(!1),[r,i]=(0,Y.useState)(),[a,o]=(0,Y.useState)(!1),s=(0,Y.useId)(),[c,l]=(0,Y.useState)({}),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(!1),m=f?void 0:Si(e.request),h=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{f&&h.current?.focus()},[f]);let g=(0,Y.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=fi(e.request,y),x=Object.keys(b.values).length,S=e.request.fields.length,C=!m&&!t&&!mi(b),w=e.onUnsentChange;(0,Y.useEffect)(()=>{w?.(C)},[w,C]),(0,Y.useImperativeHandle)(e.ref,()=>({sendPicks:()=>C?_(y):void 0}));function T(e){e.preventDefault(),mi(b)||_(y)}let E=e.secondaryActions?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`flex flex-wrap gap-1 sm:ml-auto`,children:e.secondaryActions}):null,D=e.docked?null:/* @__PURE__ */ (0,X.jsx)(V,{disabled:t,onClick:()=>p(!0),children:`Other…`}),O=t=>e.docked&&t<9?String(t+1):void 0;return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[m?.options.some(e=>e.description)?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(`div`,{"aria-label":m.label,className:`mt-3 grid gap-2`,role:`group`,children:m.options.map((e,n)=>/* @__PURE__ */ (0,X.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,X.jsx)(Gx,{value:O(n)}),/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-0.5 break-words`,children:[/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`font-medium text-dashboard-text`,id:`${s}-${n}-label`,children:[e.label,e.recommended?/* @__PURE__ */ (0,X.jsx)(Wx,{}):null]}),e.description?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,id:`${s}-${n}`,children:e.description}):null]}),/* @__PURE__ */ (0,X.jsx)(ar,{"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,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[D,E]})]}):m?/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[m.options.map((e,n)=>/* @__PURE__ */ (0,X.jsxs)(V,{"aria-keyshortcuts":O(n),disabled:t,onClick:()=>v(m.id,e.label),children:[/* @__PURE__ */ (0,X.jsx)(Gx,{value:O(n)}),e.label,e.recommended?/* @__PURE__ */ (0,X.jsx)(Wx,{className:`ml-0`}):null]},e.label)),D,E]}):/* @__PURE__ */ (0,X.jsxs)(`form`,{className:`mt-4 grid gap-5`,onSubmit:T,children:[e.request.fields.map(e=>e.kind===`text`?/* @__PURE__ */ (0,X.jsx)(Jx,{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,X.jsx)(qx,{disabled:t,field:e,onChange:t=>l(n=>({...n,[e.id]:t})),values:c[e.id]??[]},e.id)),e.docked?null:/* @__PURE__ */ (0,X.jsx)(Jx,{className:`min-h-16`,description:Di.description,disabled:t,label:Di.label,onChange:d,ref:h,value:u}),e.docked&&S<2&&!E?null:/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.docked?null:/* @__PURE__ */ (0,X.jsx)(V,{disabled:t,type:`submit`,variant:`primary`,children:`Send`}),S>1?/* @__PURE__ */ (0,X.jsxs)(`span`,{"aria-live":`polite`,className:`text-xs text-dashboard-text-muted`,children:[x,` of `,S,` answered`]}):null,E]})]}),a?/* @__PURE__ */ (0,X.jsx)(`p`,{className:`mb-0 mt-2 text-xs text-rose-300`,role:`alert`,children:`Could not send your answer. Try again.`}):null]})}function Xx(e){return/* @__PURE__ */ (0,X.jsx)(mt,{...e})}function Zx({className:e,...t}){return/* @__PURE__ */ (0,X.jsxs)(Ne,{children:[/* @__PURE__ */ (0,X.jsx)(Be,{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,X.jsx)(Me,{"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 Qx({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(Ae,{className:F(`m-0 font-display text-lg font-medium`,e),...t})}function $x({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(Oe,{className:F(`m-0 break-words text-sm leading-relaxed text-dashboard-text-muted`,e),...t})}function eS({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(`div`,{className:F(`flex flex-wrap justify-end gap-2`,e),...t})}function tS(e){return/* @__PURE__ */ (0,X.jsx)(V,{"data-slot":`alert-dialog-action`,className:`min-h-11`,...e})}function nS(e){return/* @__PURE__ */ (0,X.jsx)(at,{render:/* @__PURE__ */ (0,X.jsx)(V,{className:`min-h-11`}),...e})}const rS=(0,Y.createContext)(void 0);function iS(e){let t=(0,Y.useMemo)(()=>({conversationId:e.conversationId,titles:/* @__PURE__ */ new Map}),[e.conversationId]);return/* @__PURE__ */ (0,X.jsx)(rS.Provider,{value:t,children:e.children})}function aS(e,t){let n=(0,Y.useContext)(rS),r=(0,Y.useId)(),i=e.kind===`action`&&e.status===`open`&&e.canAct&&!e.assignedToEveryone&&e.addedByConversationId===n?.conversationId,a=e.title;(0,Y.useEffect)(()=>{if(n&&i&&t)return n.titles.set(r,a),()=>{n.titles.delete(r)}},[i,n,r,a,t])}function oS(){let e=(0,Y.useContext)(rS),[t,n]=(0,Y.useState)(!1),[r,i]=(0,Y.useState)([]),a=(0,Y.useRef)(void 0),o=(0,Y.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,X.jsx)(Xx,{onOpenChange:e=>{e||s(!1)},open:t,children:/* @__PURE__ */ (0,X.jsxs)(Zx,{children:[/* @__PURE__ */ (0,X.jsx)(Qx,{children:`Send without your answers?`}),/* @__PURE__ */ (0,X.jsx)($x,{children:r.length===1?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[`Your answers to`,` `,/* @__PURE__ */ (0,X.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,X.jsxs)(eS,{children:[/* @__PURE__ */ (0,X.jsx)(nS,{children:`Go back`}),/* @__PURE__ */ (0,X.jsx)(tS,{onClick:()=>s(!0),variant:`danger`,children:`Send message`})]})]})})}}function sS(e){return e.displayName??e.email}function cS(e){return e instanceof na&&e.apiError?e.apiError:`Could not save this action. Try again.`}function lS(e){let t=fi(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,X.jsx)(`dl`,{className:`m-0 grid gap-2 rounded-md bg-dashboard-fill-soft p-3`,children:n.map(e=>/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid gap-0.5`,children:[/* @__PURE__ */ (0,X.jsx)(`dt`,{className:`text-xs font-medium text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,X.jsx)(`dd`,{className:`m-0 whitespace-pre-wrap break-words`,children:e.value})]},e.label))})}function uS(e){let{item:t}=e,n=t.closedBy?sS(t.closedBy):`An agent`,r=t.status===`dismissed`?`dismissed`:`closed`;return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`m-0 text-dashboard-text-muted`,children:[n,` `,r,` this `,oo(t.closedAt),`.`]}),t.closeReason?/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 text-dashboard-text-muted`,children:t.closeReason}):null,t.request&&t.answer?/* @__PURE__ */ (0,X.jsx)(lS,{answer:t.answer,request:t.request}):null]})}function dS(e){let{item:t}=e,n=pu(),[r,i]=(0,Y.useState)(),[a,o]=(0,Y.useState)(!1);if(aS(t,a),t.status!==`open`)return/* @__PURE__ */ (0,X.jsx)(uS,{item:t});if(!t.canAct)return/* @__PURE__ */ (0,X.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(cS(e)),e}}let c=/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[t.canTake?/* @__PURE__ */ (0,X.jsx)(V,{disabled:n.isPending,onClick:()=>void s({action:`take`}).catch(()=>{}),variant:`quiet`,children:`Take`}):null,/* @__PURE__ */ (0,X.jsx)(V,{disabled:n.isPending,onClick:()=>void s({action:`dismiss`}).catch(()=>{}),variant:`quiet`,children:`Dismiss`})]});return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid gap-3`,children:[t.kind===`action`&&t.request?/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`text-sm`,children:[/* @__PURE__ */ (0,X.jsx)(`div`,{className:`font-medium`,children:/* @__PURE__ */ (0,X.jsx)($,{text:t.request.question})}),/* @__PURE__ */ (0,X.jsx)(Yx,{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,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:/* @__PURE__ */ (0,X.jsx)(`div`,{className:`flex flex-wrap gap-1 sm:ml-auto`,children:c})}),r?/* @__PURE__ */ (0,X.jsx)(A_,{children:r}):null]})}function fS(e){return`/review?item=${encodeURIComponent(e)}`}function pS(e){try{let{protocol:t}=new URL(e);return t===`https:`||t===`http:`?e:void 0}catch{return}}function mS(e){return e.status===`open`?e.kind===`notice`?`Notice`:e.request?`Needs an answer`:`Waiting on you`:e.status===`done`?`Done`:`Dismissed`}function hS(e){let t=e.assignees.map(e=>e.displayName??e.email);return e.assignedToEveryone&&t.unshift(`Everyone`),t.length>0?t.join(`, `):`Unassigned`}const gS=s({tool_name:p()}),_S=s({item:s({id:p().min(1)})});function vS(e){let t=e;if(typeof e==`string`)try{t=JSON.parse(e)}catch{return}return _S.safeParse(t).data?.item.id}function yS(e){if(e.status===`completed`&&(e.name===`executeTool`?gS.safeParse(e.input).data?.tool_name:e.name)===`addReviewItem`)return vS(e.output)}function bS(e){let{data:t}=e;if(t.type!==`message`||!t.reviewItemChanges)return e;if(t.events)return{...e,data:{...t,reviewItemChanges:void 0}}}function xS(e){return e.status===`open`&&e.kind===`action`&&!!e.request&&e.canAct}function SS(e,t){let n=fi(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 CS(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 wS(e){let t=e.filter(e=>e.status===`open`);return{fyi:t.filter(e=>e.kind===`notice`).sort(CS),needsYou:t.filter(e=>e.kind===`action`).sort(CS)}}function TS(e,t){return[...e.needsYou,...e.fyi].find(e=>CS(t,e)<0)}const ES={dismissed:`Dismissed`,submitted:`Answered`,taken:`Took`};function DS(e){let{item:t,record:n}=e,r=ES[n.kind];return/* @__PURE__ */ (0,X.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,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[/* @__PURE__ */ (0,X.jsx)(dr,{"aria-hidden":`true`,className:`shrink-0 text-dashboard-text-muted`,size:15}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`shrink-0 text-dashboard-text-muted`,children:r}),/* @__PURE__ */ (0,X.jsx)(B,{className:`min-w-0 flex-1 truncate font-medium text-dashboard-text no-underline hover:underline focus-visible:outline-dashboard-focus`,to:fS(t.id),children:t.title})]}),n.kind===`submitted`&&t.request&&t.answer?/* @__PURE__ */ (0,X.jsx)(lS,{answer:t.answer,request:t.request}):null]})}function OS(e){let{data:t,isError:n}=lu(e.record.reviewItemId);return n?e.fallback:t?/* @__PURE__ */ (0,X.jsx)(DS,{item:t,record:e.record}):null}function kS(e){let{data:t}=lu(e.record.reviewItemId);return t?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[ES[e.record.kind],` `,/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-medium text-dashboard-text`,children:t.title})]}):e.fallback}function AS(e){return e.status===`open`?e.kind===`notice`?void 0:e.canAct?`Waiting on you`:`Waiting on ${hS(e)}`:e.status===`dismissed`?`Dismissed`:e.request&&e.answer?SS(e.request,e.answer):`Done`}function jS(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=AS(t);return/* @__PURE__ */ (0,X.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,X.jsx)(dr,{"aria-hidden":`true`,className:`shrink-0 text-dashboard-text-muted`,size:15}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`shrink-0 text-dashboard-text-muted`,children:r}),/* @__PURE__ */ (0,X.jsx)(B,{className:`min-w-0 max-w-full truncate font-medium text-dashboard-text no-underline hover:underline focus-visible:outline-dashboard-focus`,to:fS(t.id),children:t.title}),i?/* @__PURE__ */ (0,X.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 MS({className:e,...t}){return/* @__PURE__ */ (0,X.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 NS({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(yh,{"data-slot":`trace-collapsible`,className:F(`flex w-full min-w-0 flex-col`,e),...t})}function PS({className:e,children:t,...n}){return/* @__PURE__ */ (0,X.jsxs)(bh,{"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,X.jsx)(MS,{className:`transition-transform group-aria-expanded/trace-collapsible-trigger:rotate-90 motion-reduce:transition-none`,children:/* @__PURE__ */ (0,X.jsx)(H,{className:`size-3 text-dashboard-text-faint`})})]})}function FS({className:e,children:t,...n}){return/* @__PURE__ */ (0,X.jsx)(xh,{"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,X.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 IS({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(`article`,{"data-slot":`message`,className:F(`group/message grid min-w-0`,e),...t})}function LS({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(`div`,{"data-slot":`message-content`,className:F(`grid min-w-0 grid-cols-[minmax(0,1fr)] gap-2`,e),...t})}function RS({className:e,...t}){return/* @__PURE__ */ (0,X.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 zS({children:e,label:t,...n}){return/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(U,{render:/* @__PURE__ */ (0,X.jsx)(V,{"data-slot":`message-action`,"aria-label":t,size:`icon`,...n,children:e})}),/* @__PURE__ */ (0,X.jsx)(W,{size:`compact`,children:t})]})}function BS(e){let t=e.right!==void 0&&e.right!==null&&e.right!==!1;return/* @__PURE__ */ (0,X.jsxs)(`span`,{className:q(`flex min-w-0 items-start justify-between gap-2 md:items-center md:gap-3`,e.className),children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:q(`flex min-w-0 items-center gap-2 overflow-hidden`,e.leftClassName),children:e.left}),t?/* @__PURE__ */ (0,X.jsx)(`span`,{className:q(`min-w-0 max-w-[60%] shrink text-right md:max-w-none md:shrink-0`,e.rightClassName),children:e.right}):null]})}function VS(e){return/* @__PURE__ */ (0,X.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,X.jsx)(RS,{className:`h-6 shrink-0 self-center`,children:e.action}):null]})}function HS(e){return/* @__PURE__ */ (0,X.jsx)(`span`,{className:q(`font-sans leading-none`,e.className),children:e.children})}function US(e){let{active:t}=wh(),[n,r]=(0,Y.useState)(!1),i=e.meta.join(` · `),a=e.expandable??!!e.children,o=a&&(t||n),s=e.icon,c=/* @__PURE__ */ (0,X.jsx)(BS,{className:`flex-1`,left:/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[e.signature,e.mobileSummaryMeta&&!o?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`hidden text-dashboard-text-muted max-md:inline`,children:`·`}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`hidden shrink-0 whitespace-nowrap text-dashboard-text-muted max-md:inline`,children:e.mobileSummaryMeta})]}):null]}),leftClassName:q(`gap-x-1 gap-y-0.5`,a&&!o?`flex-nowrap`:`flex-wrap`),right:i?/* @__PURE__ */ (0,X.jsx)(HS,{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,X.jsxs)(`span`,{className:`grid min-w-0 flex-1 grid-cols-[1rem_minmax(0,1fr)] items-center gap-2`,children:[/* @__PURE__ */ (0,X.jsx)(s,{"aria-hidden":`true`,className:q(`size-3.5 justify-self-center`,e.iconClassName),strokeWidth:2}),c]}):c;return a?/* @__PURE__ */ (0,X.jsxs)(NS,{className:`max-w-full`,disabled:t,open:o,onOpenChange:r,children:[/* @__PURE__ */ (0,X.jsx)(PS,{className:`-mx-2 w-auto font-mono text-xs leading-tight`,children:l}),/* @__PURE__ */ (0,X.jsxs)(FS,{children:[i?/* @__PURE__ */ (0,X.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,X.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})}const WS=[`w-3/4`,`w-full`,`w-5/6`,`w-2/3`,`w-full`];function GS(e){return`$${e}`}function KS(e){let[t,n]=(0,Y.useState)(!1);return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(`button`,{className:q(`cursor-pointer text-dashboard-accent-text focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus`,e.chip?`rounded-md border border-dashboard-border bg-dashboard-overlay-soft px-2.5 py-1.5 text-xs hover:border-dashboard-border-heavy`:`border-0 bg-transparent p-0 hover:underline`,e.children?`font-sans`:`font-mono`),onClick:()=>n(!0),type:`button`,children:e.children??GS(e.name)}),t?/* @__PURE__ */ (0,X.jsx)(qS,{name:e.name,onClose:()=>n(!1)}):null]})}function qS(e){let t=(0,Y.useId)(),[n,r]=(0,Y.useState)(`formatted`),i=hs(e.name),a=i.error instanceof na&&i.error.status===404;return/* @__PURE__ */ (0,X.jsx)(k_,{actions:i.data?/* @__PURE__ */ (0,X.jsx)(j_,{onChange:r,value:n}):null,closeLabel:`Close ${GS(e.name)}`,header:/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:[/* @__PURE__ */ (0,X.jsx)(`h2`,{className:`m-0 font-mono text-sm font-semibold text-dashboard-text`,id:t,children:GS(e.name)}),i.data?/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`font-sans text-xs text-dashboard-text-muted`,children:[i.data.pluginProvider?`From the ${i.data.pluginProvider} plugin`:`App or local skill`,i.data.disableModelInvocation?` · Manual only`:``]}):null]}),onClose:e.onClose,openKey:t,titleId:t,width:`wide`,children:i.isPending?/* @__PURE__ */ (0,X.jsx)(`div`,{"aria-label":`Loading skill`,className:`grid gap-2`,role:`status`,children:WS.map((e,t)=>/* @__PURE__ */ (0,X.jsx)(J,{className:`h-4 ${e}`},t))}):i.isError?/* @__PURE__ */ (0,X.jsx)(A_,{children:a?`This skill is no longer installed.`:`Could not load this skill.`}):/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0 gap-4`,children:[/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:i.data.description}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`border-t border-dashboard-border-subtle pt-4`,children:n===`formatted`?/* @__PURE__ */ (0,X.jsx)($,{document:!0,text:i.data.body}):/* @__PURE__ */ (0,X.jsx)(jh,{code:i.data.body,language:`markdown`})})]})})}function JS(e,t){if(e===`bash`)return XS(t,`command`);if(e===`loadSkill`){let e=XS(t,`skill_name`);return e?GS(e):null}return e===`webSearch`?XS(t,`query`):e===`executeTool`?tC(XS(t,`tool_name`),YS(t,`arguments`)):ZS(t,120)}function YS(e,t){return nC(e)?QS(e[t]):null}function XS(e,t){if(!nC(e))return null;let n=e[t];return typeof n==`string`?eC(n,120):null}function ZS(e,t){return e==null||e===``?null:nC(e)?QS(e):eC($S(e),t)}function QS(e){if(!nC(e))return null;let t=Object.entries(e);if(t.length===0)return null;let n=t.slice(0,4).map(([e,t])=>`${e}: ${eC($S(t),48)}`).join(`, `);return eC(t.length>4?`${n}, …`:n,120)}function $S(e){return typeof e==`string`?JSON.stringify(e):ka(e).replace(/\s+/g,` `).trim()}function eC(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,Math.max(0,t-1)).trimEnd()}…`:n}function tC(...e){let t=e.filter(e=>!!e);return t.length>0?eC(t.join(`, `),120):null}function nC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const rC=(0,Y.memo)(function(e){let t=Wa(e.timestamp),n=Ya(e.timestamp,e.part.resultTimestamp),r=e.part.input!==void 0||e.part.output!==void 0,i=[n,(0,Y.useMemo)(()=>Ra(e.part.output),[e.part.output])].filter(oC).join(` · `),a=[i,t].filter(oC),o=i,s=JS(e.part.name,e.part.input),c=/* @__PURE__ */ (0,X.jsx)(iC,{name:e.part.name,preview:s,status:e.part.status}),l=/* @__PURE__ */ (0,X.jsxs)(US,{expandable:r,icon:e.part.status===`error`?jn:or,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,X.jsx)(aC,{label:`arguments`,value:e.part.input}),e.part.output===void 0?null:/* @__PURE__ */ (0,X.jsx)(aC,{label:`result`,value:e.part.output})]}),u=yS(e.part);return u?/* @__PURE__ */ (0,X.jsx)(jS,{fallback:l,itemId:u}):/* @__PURE__ */ (0,X.jsx)(`div`,{className:`min-w-0`,children:l})});function iC(e){let{active:t}=wh(),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,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(Zv,{active:i,"aria-label":a,as:`strong`,className:q(`shrink-0 font-bold`,r?`!text-rose-300`:!i&&`text-dashboard-text`),children:/* @__PURE__ */ (0,X.jsx)(Q,{text:e.name})}),e.preview&&!t?/* @__PURE__ */ (0,X.jsxs)(`code`,{className:`min-w-0 truncate font-[inherit] text-dashboard-text-muted group-aria-expanded/trace-collapsible-trigger:hidden`,children:[`(`,/* @__PURE__ */ (0,X.jsx)(Q,{text:e.preview}),`)`]}):null]})}function aC(e){let t=(0,Y.useMemo)(()=>ka(e.value),[e.value]);return/* @__PURE__ */ (0,X.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,X.jsx)(`div`,{className:`pb-1.5 font-sans text-xs font-medium leading-none text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,X.jsx)(jh,{code:t,language:`json`})]})}function oC(e){return typeof e==`string`&&e.length>0}function sC(e){let{active:t}=wh(),[n,r]=rx(e.openKey),i=t||n,a=e.part.redacted?`Reasoning redacted`:e.part.text,o=Wa(e.timestamp);return/* @__PURE__ */ (0,X.jsxs)(NS,{className:`text-xs leading-tight`,disabled:t,open:i,onOpenChange:r,children:[/* @__PURE__ */ (0,X.jsx)(PS,{className:`-mx-2 w-auto`,children:/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`grid min-w-0 flex-1 grid-cols-[1rem_minmax(0,1fr)] items-center gap-2`,children:[/* @__PURE__ */ (0,X.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,X.jsx)(Cn,{"aria-hidden":`true`,size:14,strokeWidth:2})}),/* @__PURE__ */ (0,X.jsx)(BS,{left:i?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`block min-w-0 text-dashboard-text-muted`,children:`Reasoning`}):/* @__PURE__ */ (0,X.jsx)(`span`,{className:`block min-w-0 truncate italic text-dashboard-text-muted`,children:/* @__PURE__ */ (0,X.jsx)($,{inline:!0,links:!1,text:a})}),right:o?/* @__PURE__ */ (0,X.jsx)(HS,{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,X.jsx)(FS,{className:`px-3 py-2.5`,hiddenUntilFound:!0,children:/* @__PURE__ */ (0,X.jsx)($,{text:a})})]})}function cC(e){let t=xa(e.role),n=t===`assistant`||t===`user`;return/* @__PURE__ */ (0,X.jsxs)(IS,{className:q(n&&q(`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,X.jsx)(`div`,{"aria-hidden":`true`,className:q(`flex items-center justify-center`,$b),children:t===`assistant`?/* @__PURE__ */ (0,X.jsx)(`img`,{alt:``,className:`size-full object-contain`,draggable:!1,src:xs}):e.fromAgent?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`grid size-full place-items-center rounded-full bg-dashboard-surface-hover text-cyan-200`,children:/* @__PURE__ */ (0,X.jsx)(gn,{size:15,strokeWidth:2})}):/* @__PURE__ */ (0,X.jsxs)(Hs,{className:`size-full border-0 bg-violet-300 shadow-none`,children:[/* @__PURE__ */ (0,X.jsx)(Us,{alt:``,loading:`lazy`,referrerPolicy:`no-referrer`,src:e.avatarUrl}),/* @__PURE__ */ (0,X.jsx)(Ws,{children:e.actor.split(/\s+/).map(e=>e[0]).slice(0,2).join(``).toUpperCase()})]})}):null,/* @__PURE__ */ (0,X.jsx)(LS,{className:`py-1`,children:e.children})]})}const lC=(0,Y.createContext)(null);function uC(e){let[t,n]=(0,Y.useState)(!1);return/* @__PURE__ */ (0,X.jsx)(lC.Provider,{value:{full:t,toggle:()=>n(e=>!e)},children:e.children})}function dC(e){let t=(0,Y.useContext)(lC),n=typeof e.value==`number`&&Number.isFinite(e.value),r=n&&Date.now()-e.value>432e5,i=t?.full?Wa(e.value,!0):r?ro(e.value):Wa(e.value),a=/* @__PURE__ */ (0,X.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=Sa(e.value);return/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(U,{render:a}),/* @__PURE__ */ (0,X.jsx)(W,{children:/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`grid grid-cols-[auto_auto] gap-x-3`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{children:`Local`}),/* @__PURE__ */ (0,X.jsx)(`span`,{children:o.local}),/* @__PURE__ */ (0,X.jsx)(`span`,{children:`UTC`}),/* @__PURE__ */ (0,X.jsx)(`span`,{children:o.utc})]})})]})}function fC(e){return/* @__PURE__ */ (0,X.jsxs)(cC,{role:`assistant`,actor:_a(),children:[/* @__PURE__ */ (0,X.jsxs)(VS,{children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`max-w-full truncate font-sans text-sm font-semibold leading-6 text-dashboard-accent-text`,children:_a()}),typeof e.timestamp==`number`?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`text-xs leading-6 text-dashboard-text-muted`,children:/* @__PURE__ */ (0,X.jsx)(dC,{value:e.timestamp})}):null]}),/* @__PURE__ */ (0,X.jsx)(ov,{attachments:e.part.attachments,conversationId:e.conversation.conversationId})]})}function pC(e){let t=wh(),n=e.part.presentation,r=Wa(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,X.jsx)(`div`,{className:`grid gap-4 pb-1 pt-2`,children:i.map((e,t)=>/* @__PURE__ */ (0,X.jsxs)(`section`,{children:[s(e.title)?null:/* @__PURE__ */ (0,X.jsx)(`div`,{className:`whitespace-pre-wrap break-words font-sans text-sm font-medium text-dashboard-text`,children:/* @__PURE__ */ (0,X.jsx)(Q,{text:e.title})}),e.description?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`mt-1`,children:/* @__PURE__ */ (0,X.jsx)($,{mentions:a,text:e.description})}):null,e.content?/* @__PURE__ */ (0,X.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,X.jsx)(Q,{text:e.content})}):null,e.metadata?.length?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:e.metadata.map(e=>/* @__PURE__ */ (0,X.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,children:/* @__PURE__ */ (0,X.jsx)(Q,{text:e})},e))}):null]},`${e.title}:${t}`))}):null,l=i.length>0&&!t.active,u=/* @__PURE__ */ (0,X.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,X.jsxs)(`span`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`block text-sm font-medium leading-6 text-dashboard-text`,children:/* @__PURE__ */ (0,X.jsx)(Q,{text:n.title})}),n.preview?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-dashboard-text-muted`,children:/* @__PURE__ */ (0,X.jsx)($,{inline:!0,links:!l,mentions:a,text:n.preview})}):null]}),r?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`text-xs leading-6 tabular-nums text-dashboard-text-muted max-md:hidden`,children:r}):null]});return l?/* @__PURE__ */ (0,X.jsxs)(yh,{className:o,children:[/* @__PURE__ */ (0,X.jsx)(kx,{flush:!0,className:`block`,children:u}),/* @__PURE__ */ (0,X.jsx)(xh,{hiddenUntilFound:!0,children:c})]}):/* @__PURE__ */ (0,X.jsxs)(`div`,{className:o,children:[u,c]})}function mC(){return/* @__PURE__ */ (0,X.jsx)(ir,{"aria-label":`Private`,role:`img`,size:13,strokeWidth:1.8})}function hC(e){return/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`flex items-center gap-1.5 pt-1 text-dashboard-text-faint`,children:[e.private?/* @__PURE__ */ (0,X.jsx)(mC,{}):null,/* @__PURE__ */ (0,X.jsx)(Jt,{"aria-hidden":`true`,className:`transition-colors group-hover:text-dashboard-text`,size:14})]})}function gC(e){return`${e} ${e===1?`memory`:`memories`}`}function _C(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,X.jsxs)(Gs,{onOpenChange:e=>n.setOpen(e?t:void 0),open:r,children:[/* @__PURE__ */ (0,X.jsx)(Ks,{"data-memory-anchor":vx(t),render:e.trigger}),/* @__PURE__ */ (0,X.jsx)(qs,{align:`start`,"aria-label":e.label,className:`max-h-[min(28rem,var(--available-height))] w-96 p-1.5`,children:/* @__PURE__ */ (0,X.jsx)(`ul`,{className:`m-0 grid list-none divide-y divide-dashboard-border-subtle p-0`,children:e.memories.map(e=>/* @__PURE__ */ (0,X.jsx)(`li`,{className:`py-1 first:pt-0 last:pb-0`,children:/* @__PURE__ */ (0,X.jsxs)(B,{className:q(`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:ja(e.id),children:[/* @__PURE__ */ (0,X.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,X.jsx)(hC,{private:e.visibility===`private`})]})},e.id))})})]})}function vC(e){let t=Sx(),n=[...new Set(e.message.contexts?.filter(e=>hf(e)).map(e=>e.turnId))].flatMap(e=>{let n={source:`recalled`,turnId:e},r=yx(t?.list,n);return r.length>0?[{anchor:n,memories:r}]:[]});return!t||n.length===0?null:/* @__PURE__ */ (0,X.jsx)(`div`,{className:q(`flex flex-wrap gap-2`,e.className),children:n.map(({anchor:e,memories:n})=>{let r=`Recalled ${gC(n.length)}`;return/* @__PURE__ */ (0,X.jsx)(_C,{anchor:e,label:r,memories:n,state:t,trigger:/* @__PURE__ */ (0,X.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,X.jsx)(Cr,{"aria-hidden":`true`,size:13,strokeWidth:1.8}),r]})},e.turnId)})})}function yC(e){let t=Sx(),n=e.turnId?{source:`captured`,turnId:e.turnId}:void 0,r=n?yx(t?.list,n):[];if(!t||!n||r.length===0)return e.fallback;let i=`Captured ${gC(r.length)}`,a=Wa(e.timestamp);return/* @__PURE__ */ (0,X.jsx)(_C,{anchor:n,label:i,memories:r,state:t,trigger:/* @__PURE__ */ (0,X.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,X.jsx)(`span`,{className:`text-sm font-medium leading-6 text-dashboard-text`,children:i}),a?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`text-xs leading-6 tabular-nums text-dashboard-text-muted max-md:hidden`,children:a}):null]})})}function bC(e){let t=Wa(e.timestamp),n=e.eventId?e.sentryEventUrl?/* @__PURE__ */ (0,X.jsx)(nf,{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,X.jsx)(`span`,{className:`font-mono text-rose-100/80`,children:`event_id=${e.eventId}`}):null;return/* @__PURE__ */ (0,X.jsxs)(oa,{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,X.jsx)(qn,{"aria-hidden":`true`,size:16}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,X.jsx)(aa,{className:`font-display text-base font-semibold leading-tight`,children:Sf(e.failureCode,e.failureReason)}),/* @__PURE__ */ (0,X.jsx)(ia,{className:`mt-1 leading-relaxed text-rose-100/70`,children:Cf(e.failureCode,e.failureReason)}),n?/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`mt-2 text-xs leading-relaxed text-rose-100/65`,children:[`Reference: `,n]}):null]}),t?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-mono text-xs leading-none text-rose-100/55 max-md:col-start-2`,children:t}):null]})}const xC={sent:!1},SC=(0,Y.createContext)(null);function CC(){let[e]=(0,Y.useState)(()=>({listeners:/* @__PURE__ */ new Set,states:/* @__PURE__ */ new Map}));return(0,Y.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 wC(e){let t=Jo().data?.me.user,n=(0,Y.useContext)(SC);if(!n)throw Error(`Reply ratings need TranscriptReplyRatings`);let r=()=>n.states.get(e.messageId)??xC,{rating:i,sent:a}=(0,Y.useSyncExternalStore)((0,Y.useCallback)(e=>(n.listeners.add(e),()=>n.listeners.delete(e)),[n]),r,r),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(``);if(!ra())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}),Ji({...e,comment:i,rating:n,reader:t}))},f=()=>{clearTimeout(r().timer),u(xC)},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,X.jsxs)(X.Fragment,{children:[!a||i===`good`?/* @__PURE__ */ (0,X.jsx)(zS,{"aria-pressed":i===`good`,label:`Good reply`,onClick:p,children:/* @__PURE__ */ (0,X.jsx)(Nn,{"aria-hidden":`true`,fill:i===`good`?`currentColor`:`none`,size:15})}):null,!a||i===`bad`?/* @__PURE__ */ (0,X.jsxs)(Gs,{onOpenChange:e=>{e&&r().sent||(e&&r().rating===`good`&&f(),s(e))},open:o,children:[/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(U,{render:/* @__PURE__ */ (0,X.jsx)(Ks,{render:/* @__PURE__ */ (0,X.jsx)(V,{"aria-label":`Bad reply`,"aria-pressed":i===`bad`,"data-slot":`message-action`,size:`icon`})}),children:/* @__PURE__ */ (0,X.jsx)(In,{"aria-hidden":`true`,fill:i===`bad`?`currentColor`:`none`,size:15})}),/* @__PURE__ */ (0,X.jsx)(W,{size:`compact`,children:`Bad reply`})]}),/* @__PURE__ */ (0,X.jsxs)(qs,{align:`start`,className:`grid w-72 gap-2 p-3`,children:[/* @__PURE__ */ (0,X.jsx)(Js,{children:`What went wrong?`}),/* @__PURE__ */ (0,X.jsxs)(`form`,{className:`grid gap-2`,onSubmit:e=>{e.preventDefault(),m()},children:[/* @__PURE__ */ (0,X.jsx)(vv,{"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,X.jsx)(V,{className:`justify-self-end`,type:`submit`,variant:`primary`,children:`Send`})]})]})]}):null]})}function TC(){return/* @__PURE__ */ (0,X.jsx)(`code`,{className:`inline-flex w-fit font-mono text-sm leading-tight text-dashboard-text-muted`,children:`<redacted>`})}const EC=(0,Y.createContext)(void 0);function DC(e){return/* @__PURE__ */ (0,X.jsx)(EC,{value:e.panel,children:e.children})}function OC(e){let t=(0,Y.useContext)(EC),[n,r]=(0,Y.useState)(!1),i=(0,Y.useId)(),a=e.messageId??i,o=t?t.openId===a:n;return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(U,{closeOnClick:!0,render:/* @__PURE__ */ (0,X.jsx)(V,{"aria-haspopup":t?void 0:`dialog`,"aria-expanded":o,"aria-label":`View turn context`,className:q(`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,X.jsx)(an,{"aria-hidden":`true`,size:14,strokeWidth:1.8})})}),/* @__PURE__ */ (0,X.jsx)(W,{size:`compact`,children:`View turn context`})]}),!t&&n?(0,ou.createPortal)(/* @__PURE__ */ (0,X.jsx)(k_,{closeLabel:`Close turn context`,header:/* @__PURE__ */ (0,X.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,X.jsx)(AC,{actor:e.actor,contexts:e.contexts,timestamp:e.timestamp})}),document.body):null]})}function kC(e){return/* @__PURE__ */ (0,X.jsx)(Qy,{label:`Turn context`,onClose:e.onClose,title:/* @__PURE__ */ (0,X.jsx)(`h2`,{className:`m-0 text-base font-semibold text-dashboard-text`,children:`Turn context`}),children:/* @__PURE__ */ (0,X.jsx)(`div`,{className:`p-4 pb-[max(1rem,env(safe-area-inset-bottom))]`,children:/* @__PURE__ */ (0,X.jsx)(AC,{actor:e.actor,contexts:e.contexts,timestamp:e.timestamp})})})}function AC(e){let t=[...e.contexts].sort((e,t)=>Number(!!_f(t))-Number(!!_f(e)));return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0 gap-3`,children:[e.actor?/* @__PURE__ */ (0,X.jsx)(jC,{actor:e.actor,timestamp:e.timestamp}):null,t.map((e,t)=>/* @__PURE__ */ (0,X.jsx)(MC,{context:e},`${e.pluginName}:${e.kind}:${e.version}:${t}`))]})}function jC(e){let t=uh(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,X.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,X.jsx)(lh,{imageUrl:e.actor.avatarUrl,name:t,size:`detail`}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[n?/* @__PURE__ */ (0,X.jsx)(B,{className:`min-w-0 truncate text-sm font-medium text-dashboard-text no-underline hover:underline`,to:qa(n),children:t}):/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-dashboard-text`,children:t}),e.timestamp===void 0?null:/* @__PURE__ */ (0,X.jsx)(`time`,{className:`shrink-0 text-xs tabular-nums text-dashboard-text-muted`,dateTime:new Date(e.timestamp).toISOString(),children:Wa(e.timestamp,!0)})]}),i.length?/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 mt-0.5 truncate text-xs text-dashboard-text-muted`,title:e.actor.slackUserId,children:i.join(` · `)}):null]})]})}function MC(e){let t=hf(e.context);if(t)return/* @__PURE__ */ (0,X.jsx)(Ig,{count:t.memories.length,title:`Recalled memories`,children:/* @__PURE__ */ (0,X.jsx)(NC,{memories:t.memories})});let n=_f(e.context);return n?/* @__PURE__ */ (0,X.jsx)(Ig,{title:`User customization`,children:/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 whitespace-pre-wrap text-sm leading-relaxed text-dashboard-text`,children:/* @__PURE__ */ (0,X.jsx)(Q,{text:n.text})})}):/* @__PURE__ */ (0,X.jsx)(Ig,{title:`${e.context.pluginName} · ${e.context.kind} v${e.context.version}`,children:/* @__PURE__ */ (0,X.jsx)(`pre`,{className:`m-0 overflow-x-auto whitespace-pre-wrap break-words font-mono text-xs leading-relaxed`,children:/* @__PURE__ */ (0,X.jsx)(Q,{text:JSON.stringify(e.context.content,null,2)})})})}function NC(e){return/* @__PURE__ */ (0,X.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,X.jsx)(`li`,{className:`py-1 first:pt-0 last:pb-0`,children:/* @__PURE__ */ (0,X.jsxs)(B,{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:ja(e.id),children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-dashboard-text`,children:/* @__PURE__ */ (0,X.jsx)(Q,{text:e.content})}),/* @__PURE__ */ (0,X.jsx)(hC,{private:e.scope===`personal`})]})},e.id))})}function PC(e){let{active:t}=wh(),[n,r]=(0,Y.useState)(!1),i=so(e.conversation,e.message),a=Wa(e.message.timestamp),o=xf(e.message),s=e.redacted?/* @__PURE__ */ (0,X.jsx)(TC,{}):/* @__PURE__ */ (0,X.jsx)(Q,{text:o});return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsxs)(yh,{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,X.jsxs)(kx,{flush:!0,className:`group flex items-center justify-between gap-2 font-sans text-xs font-medium text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`Context from `,i]}),/* @__PURE__ */ (0,X.jsx)(H,{"aria-hidden":`true`,className:ca})]}),/* @__PURE__ */ (0,X.jsxs)(xh,{hiddenUntilFound:!0,children:[/* @__PURE__ */ (0,X.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,X.jsx)(`div`,{className:`mt-2`,children:/* @__PURE__ */ (0,X.jsx)(OC,{actor:Na(e.conversation,e.message),contexts:e.message.contexts,messageId:e.message.messageId,timestamp:e.message.timestamp})}):null]})]}),/* @__PURE__ */ (0,X.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,X.jsx)(BS,{left:/* @__PURE__ */ (0,X.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,X.jsx)(HS,{className:`text-xs tabular-nums text-dashboard-text-muted`,children:a}):void 0}),/* @__PURE__ */ (0,X.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,X.jsx)(`div`,{className:`mt-2`,children:/* @__PURE__ */ (0,X.jsx)(OC,{actor:Na(e.conversation,e.message),contexts:e.message.contexts,messageId:e.message.messageId,timestamp:e.message.timestamp})}):null]})]})}function FC(e){let[t,n]=(0,Y.useState)(!1);return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(zS,{label:`Fork after this message`,onClick:()=>n(!0),children:/* @__PURE__ */ (0,X.jsx)(lr,{size:14,"aria-hidden":`true`})}),t?/* @__PURE__ */ (0,X.jsx)(IC,{...e,onClose:()=>n(!1)}):null]})}function IC(e){let t=(0,Y.useId)(),n=`${t}-error`,r=(0,Y.useRef)(null),[i]=(0,Y.useState)(()=>crypto.randomUUID()),[a,o]=(0,Y.useState)(``),s=_e(),c=ud(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 na&&c.error.apiError||`Could not fork the conversation. Try again.`:void 0;return/* @__PURE__ */ (0,X.jsx)(il,{...l.rootProps,onOpenChange:(e,t)=>{!e&&c.isPending?t.cancel():l.rootProps.onOpenChange(e,t)},children:/* @__PURE__ */ (0,X.jsx)(ol,{...l.contentProps,children:/* @__PURE__ */ (0,X.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),u()},children:[/* @__PURE__ */ (0,X.jsx)(sl,{children:`Fork Conversation`}),/* @__PURE__ */ (0,X.jsxs)(Jd,{children:[/* @__PURE__ */ (0,X.jsx)(Yd,{htmlFor:t,children:`Message`}),/* @__PURE__ */ (0,X.jsx)(vv,{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,X.jsx)(Zd,{id:n,children:d})]}),/* @__PURE__ */ (0,X.jsxs)(cl,{children:[/* @__PURE__ */ (0,X.jsx)(al,{disabled:c.isPending,render:/* @__PURE__ */ (0,X.jsx)(V,{children:`Cancel`})}),/* @__PURE__ */ (0,X.jsx)(V,{variant:`primary`,type:`submit`,disabled:!a.trim()||c.isPending,children:c.isPending?`Forking…`:`Fork and send`})]})]})})})}function LC({card:e}){return/* @__PURE__ */ (0,X.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,X.jsxs)(`div`,{className:`flex items-center gap-3 px-4 pb-3 pt-4 md:px-5`,children:[/* @__PURE__ */ (0,X.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,X.jsx)(vh,{objectType:`automation`,status:e.status,size:18})}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 flex-1 break-words text-base font-semibold text-dashboard-text`,children:e.title})]}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0 gap-3 px-4 pb-4 md:px-5`,children:[e.status&&/* @__PURE__ */ (0,X.jsx)(Np,{size:`compact`,tone:Xr({objectType:`automation`,status:e.status}).tone,children:e.status}),/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 line-clamp-3 break-words text-sm leading-relaxed text-dashboard-text-muted`,children:/* @__PURE__ */ (0,X.jsx)($,{inline:!0,text:e.instruction})}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex items-start gap-2 text-xs leading-relaxed text-dashboard-text`,children:[/* @__PURE__ */ (0,X.jsx)(An,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-dashboard-text-muted`}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 break-words`,children:e.trigger})]}),e.warning?/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex items-start gap-2 text-xs leading-relaxed text-dashboard-text`,children:[/* @__PURE__ */ (0,X.jsx)(qn,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-amber-500`}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 break-words`,children:e.warning})]}):null]}),/* @__PURE__ */ (0,X.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,X.jsxs)(B,{to:Xa(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,X.jsx)(Jt,{"aria-hidden":`true`,size:14})]})})]})}function RC({card:e}){if(e.plugin===`junior`&&e.objectType===`automation`)return/* @__PURE__ */ (0,X.jsx)(LC,{card:{id:e.key,title:e.title,instruction:e.description??``,trigger:e.trigger??``,warning:e.warning??null,status:e.status}});let t=Qr(e.facts),n=Xr(e),r=e.displayType??n.label;function i(e){return/* @__PURE__ */ (0,X.jsx)(`dl`,{className:`grid min-w-0 grid-cols-1 gap-3 sm:grid-cols-2`,children:e.map(e=>/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,X.jsx)(`dt`,{className:`text-xs text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,X.jsx)(`dd`,{className:`m-0 mt-1 break-words text-sm text-dashboard-text`,children:e.value})]},e.key))})}return/* @__PURE__ */ (0,X.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,X.jsxs)(`div`,{className:`flex items-start gap-3 px-4 pb-3 pt-4 md:px-5`,children:[/* @__PURE__ */ (0,X.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,X.jsx)(vh,{...e,size:18})}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[/* @__PURE__ */ (0,X.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,X.jsx)(nf,{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,X.jsx)(`strong`,{className:`break-words text-base text-dashboard-text`,children:e.title})]})]}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0 gap-4 px-4 pb-4 md:px-5`,children:[e.status&&/* @__PURE__ */ (0,X.jsx)(Np,{size:`compact`,tone:n.tone,children:e.status}),t.length>0&&i(t),e.description&&/* @__PURE__ */ (0,X.jsxs)(yh,{className:`min-w-0 border-t border-dashboard-border pt-3`,children:[/* @__PURE__ */ (0,X.jsxs)(bh,{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,X.jsx)(H,{"aria-hidden":`true`,className:`size-3.5 shrink-0 transition-transform group-aria-expanded:rotate-90 motion-reduce:transition-none`}),`More details`]}),/* @__PURE__ */ (0,X.jsx)(xh,{hiddenUntilFound:!0,children:/* @__PURE__ */ (0,X.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,X.jsx)(`p`,{className:`m-0 break-words text-xs text-amber-500`,children:e.warning})]}),/* @__PURE__ */ (0,X.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,X.jsxs)(nf,{href:e.url,className:`font-medium text-dashboard-text hover:underline focus-visible:outline-dashboard-focus`,children:[`Open `,r.toLowerCase()]}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`text-dashboard-text-muted`,children:`Latest saved state`})]})]})}function zC(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?!zC(t,n):!1}const VC={github:{label:`GitHub`,Mark:hp},slack:{label:`Slack`,Mark:Qf}};function HC(e){let{label:t,Mark:n}=VC[e.provider];return/* @__PURE__ */ (0,X.jsx)(`span`,{className:`inline-flex shrink-0 self-center`,title:t,children:/* @__PURE__ */ (0,X.jsx)(n,{className:`size-3.5`})})}const UC=(0,Y.memo)(function(e){let t=xf(e.message),n=xa(e.message.role),r=n===`assistant`||n===`user`,i=KC(e.message,e.conversation)?e.message.messageId:void 0,a=/* @__PURE__ */ (0,X.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,X.jsx)($,{chat:r,mentions:e.message.mentions,text:t.text??``},n):null)});return/* @__PURE__ */ (0,X.jsxs)(cC,{role:e.message.role,actor:so(e.conversation,e.message),fromAgent:!!e.message.agentInvocationId,avatarUrl:Na(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,X.jsx)(qC,{action:GC(e.message,e.conversation),message:e.message,conversation:e.conversation}),e.message.reviewItemChanges?.length?e.message.reviewItemChanges.map((e,t)=>/* @__PURE__ */ (0,X.jsx)(OS,{fallback:a,record:e},t)):a,/* @__PURE__ */ (0,X.jsx)(vC,{message:e.message}),e.message.attachments?.length?/* @__PURE__ */ (0,X.jsx)(ov,{attachments:e.message.attachments,conversationId:e.conversation.conversationId}):null,e.message.images?.length?/* @__PURE__ */ (0,X.jsx)(sv,{images:e.message.images}):null,e.message.cards?.map(e=>{switch(e.kind){case`object`:return/* @__PURE__ */ (0,X.jsx)(RC,{card:e},`${e.plugin}:${e.key}`);case`automation`:return/* @__PURE__ */ (0,X.jsx)(LC,{card:e},`${e.kind}:${e.id}`)}}),n===`assistant`&&!e.message.pending&&(t||i)?/* @__PURE__ */ (0,X.jsxs)(RS,{className:`-mt-1.5 -mb-2.5 -ml-2 [&>button]:size-8`,children:[t?/* @__PURE__ */ (0,X.jsx)(Zf,{getText:()=>t,label:`Copy message`}):null,i?/* @__PURE__ */ (0,X.jsx)(FC,{conversationId:e.conversation.conversationId,messageId:i}):null,e.message.messageId?/* @__PURE__ */ (0,X.jsx)(wC,{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 WC(e){return/* @__PURE__ */ (0,X.jsxs)(cC,{role:e.message.role,actor:so(e.conversation,e.message),fromAgent:!!e.message.agentInvocationId,avatarUrl:Na(e.conversation,e.message)?.avatarUrl,children:[/* @__PURE__ */ (0,X.jsx)(qC,{message:e.message,conversation:e.conversation}),/* @__PURE__ */ (0,X.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,X.jsx)(`div`,{className:`py-1`,children:/* @__PURE__ */ (0,X.jsx)(TC,{})},t))})]})}function GC(e,t){if(e.role===`user`&&e.contexts?.length)return/* @__PURE__ */ (0,X.jsx)(OC,{actor:Na(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 qC(e){let t=_p(e.message,e.conversation),n=Wa(e.message.timestamp),r=so(e.conversation,e.message);return/* @__PURE__ */ (0,X.jsxs)(VS,{action:e.action,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:JC(e.message.role),children:r}),t||n?/* @__PURE__ */ (0,X.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,X.jsx)(HC,{provider:t}):null,t&&n?/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,children:`·`}):null,/* @__PURE__ */ (0,X.jsx)(dC,{value:e.message.timestamp})]}):null]})}function JC(e){let t=xa(e);return q(`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 YC(e){return/* @__PURE__ */ (0,X.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,X.jsx)(Q,{text:e.eventType})})}function XC(e){let t=e[0]?.label,n=t&&e.every(e=>e.label===t);return`${e.length} events${n?` · ${t}`:``}`}function ZC(e){let{active:t}=wh(),[n,r]=rx(e.openKey),i=xf(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=vp(e.message),u=c?XC(o):e.message.trustedSummary??e.message.eventType??``,d=!i,f=/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:[/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`flex min-h-6 min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 break-words font-display text-sm font-semibold leading-6 text-dashboard-text`,children:/* @__PURE__ */ (0,X.jsx)($,{inline:!0,links:d,mentions:s,text:u})}),l?/* @__PURE__ */ (0,X.jsx)(HC,{provider:l}):null,!c&&e.message.eventType?/* @__PURE__ */ (0,X.jsx)(YC,{eventType:e.message.eventType}):null]}),c?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`flex min-w-0 flex-col gap-1`,role:`list`,children:o.map((e,t)=>/* @__PURE__ */ (0,X.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,X.jsx)(`span`,{className:`min-w-0 break-words`,children:/* @__PURE__ */ (0,X.jsx)($,{inline:!0,links:d,mentions:s,text:e.trustedSummary??e.eventType})}),/* @__PURE__ */ (0,X.jsx)(YC,{eventType:e.eventType})]},t))}):null]}),p=/* @__PURE__ */ (0,X.jsx)(X.Fragment,{children:i?/* @__PURE__ */ (0,X.jsxs)(yh,{className:`min-w-0`,disabled:t,onOpenChange:r,open:t||n,children:[/* @__PURE__ */ (0,X.jsxs)(kx,{flush:!0,className:`group flex items-start gap-2 text-dashboard-text-muted`,children:[f,/* @__PURE__ */ (0,X.jsx)(H,{"aria-hidden":`true`,className:q(ca,`mt-1.5`),strokeWidth:2.2})]}),/* @__PURE__ */ (0,X.jsx)(xh,{hiddenUntilFound:!0,children:/* @__PURE__ */ (0,X.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,X.jsx)(Q,{text:i})})})]}):/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[f,a?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`mt-2`,children:/* @__PURE__ */ (0,X.jsx)(TC,{})}):null]})}),m=e.message.reviewItemChanges??[],h=m.length>0&&o.length===0;return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`min-w-0 py-1`,children:[h?null:p,m.length?/* @__PURE__ */ (0,X.jsx)(`div`,{className:q(`grid min-w-0 gap-2`,!h&&`mt-2`),children:m.map((e,t)=>/* @__PURE__ */ (0,X.jsx)(OS,{fallback:h&&m.length===1?p:null,record:e},t))}):null]})}function QC(e,t){let n=e.sourceTask?.triggerMessageId;return!!(n&&t.role===`user`&&t.messageId===n)}function $C(e){if(e.credentialMode===`system`)return`Runs as system`;if(e.credentialMode===`creator`&&e.credentialUser)return`Runs as ${e.credentialUser}`}function ew(e){let t=xf(e.message),n=e.message.parts.some(e=>e.type===`text`&&e.redacted),[r,i]=(0,Y.useState)(!1),a=e.sourceTask.id?.trim(),o=e.sourceTask.title?.trim()||`Automation`,s=[e.sourceTask.triggerLabel,e.message.timestamp?oo(new Date(e.message.timestamp).toISOString()):void 0,$C(e.sourceTask)].filter(Boolean);return/* @__PURE__ */ (0,X.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,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[/* @__PURE__ */ (0,X.jsx)(vh,{objectType:`automation`,size:16,decorative:!0}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-sans text-sm font-semibold text-dashboard-text`,children:/* @__PURE__ */ (0,X.jsx)(Q,{text:o})}),a?/* @__PURE__ */ (0,X.jsxs)(B,{className:q(Tt(),`h-8 shrink-0 text-xs`),to:Xa(a),children:[`Open automation`,/* @__PURE__ */ (0,X.jsx)(ar,{"aria-hidden":`true`,size:14})]}):null]}),s.length>0?/* @__PURE__ */ (0,X.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,X.jsxs)(yh,{className:`min-w-0`,onOpenChange:i,open:r,children:[/* @__PURE__ */ (0,X.jsxs)(bh,{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,X.jsx)(H,{"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,X.jsx)(xh,{children:/* @__PURE__ */ (0,X.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,X.jsx)(Q,{text:t})})})]}):n?/* @__PURE__ */ (0,X.jsx)(TC,{}):null]})}function tw(){let e=`${_a()} is thinking…`;return/* @__PURE__ */ (0,X.jsx)(`div`,{"aria-live":`polite`,className:`flex items-center text-sm text-dashboard-text-muted`,role:`status`,children:/* @__PURE__ */ (0,X.jsx)(Zv,{active:!0,children:e})})}const nw=`unread-marker`;function rw(e){let{entries:t,search:n}=e,r=Mx(t),i=e=>jx(e)||r.has(e.key),a=e=>n===void 0||kh(e,n),o=/* @__PURE__ */ new Set,s=[],c=n===void 0?pw(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:nw})),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:nw})),u({kind:`entry`,entry:t,key:`${e.keyPrefix}:${t.key}`,seq:sw(s)??t.seq}));d=[]};for(let n=0;n<t.length;){let r=t[n];if(aw(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(aw(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:hw({claimedKeys:o,entries:r,keyPrefix:e.keyPrefix,knownKeys:e.knownActivityKeys}),seq:mw(r)})}else if(cw(r)){let r=[];for(;n<t.length&&cw(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:mw(r)})}else a(r)&&u({kind:`entry`,entry:r,key:`${e.keyPrefix}:${r.key}`,seq:r.seq}),n+=1}return f(),s}function iw(e){return e.kind===`tool`?yS(e.part):void 0}function aw(e){return iw(e)!==void 0}function ow(e,t){let n=e.findIndex(e=>e.kind===`entry`&&iw(e.entry)===t);return n<0?void 0:n}function sw(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 cw(e){return e.kind===`subagent`&&e.part.childKind===`task`}function lw(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1,a=e[i],o=a.kind===`unread_marker`?uw(e,i)??-1/0:a.seq;o!==void 0&&o<t?n=i+1:r=i}return n}function uw(e,t){let n=e[t-1];return n===void 0||n.kind===`unread_marker`?void 0:n.seq}function dw(e){if(e.kind!==`entry`)return e.kind;let{entry:t}=e;return t.kind===`message`?`message:${t.message.role}`:t.kind}function fw(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 pw(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 mw(e){for(let t=e.length-1;t>=0;--t){let n=e[t].seq;if(n!==void 0)return n}}function hw(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 gw(e){let{listRef:t}=e,n=(0,Y.useRef)(/* @__PURE__ */ new Map),r=(0,Y.useRef)(/* @__PURE__ */ new Map),i=(0,Y.useRef)(/* @__PURE__ */ new Map),a=(0,Y.useRef)(e);a.current=e;let o=(0,Y.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,Y.useRef)(null),l=(0,Y.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,Y.useState)(0),p=e.keptIndexes.filter(t=>t!==void 0&&t>=0&&t<e.count).join(`,`),m=(0,Y.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,Y.useCallback)(()=>{let e=t.current,n=am(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,Y.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=am(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 _w=(0,Y.createContext)(void 0);function vw(e){return/* @__PURE__ */ (0,X.jsx)(sC,{openKey:e.key,part:e.part,timestamp:e.timestamp})}function yw(e){return/* @__PURE__ */ (0,X.jsx)(Tx,{kind:`thread`,children:/* @__PURE__ */ (0,X.jsx)(mx,{part:e.part,timestamp:e.timestamp})})}function bw(e,t,n){return/* @__PURE__ */ (0,X.jsx)(Tx,{kind:`tasks`,children:/* @__PURE__ */ (0,X.jsx)(fx,{entries:e,onOpenTranscript:n,openKey:t})})}const xw=(0,Y.memo)(function(e){let{events:t,annotations:n}=e.conversation,r=(0,Y.useMemo)(()=>Ta(t,n,e.pendingMessages),[t,n,e.pendingMessages]);return/* @__PURE__ */ (0,X.jsx)(uC,{children:/* @__PURE__ */ (0,X.jsx)($_,{conversationId:e.conversation.conversationId,messages:r,children:/* @__PURE__ */ (0,X.jsx)(`section`,{className:`min-w-0 pt-1`,children:/* @__PURE__ */ (0,X.jsx)(Sw,{onOpenSubagentTranscript:e.onOpenSubagentTranscript,conversation:e.conversation,messages:r,responding:e.responding,revealSeq:e.revealSeq,scrollAnchorKey:e.scrollAnchorKey,unread:e.unread})})})})});function Sw(e){let t={revealSeq:e.revealSeq,scrollAnchorKey:e.scrollAnchorKey};return/* @__PURE__ */ (0,X.jsxs)(ex,{children:[e.conversation.eventHistory.status===`expired`?/* @__PURE__ */ (0,X.jsx)(Cw,{brief:e.conversation.brief,expiredAt:e.conversation.eventHistory.expiredAt}):e.conversation.eventHistory.status===`available`?/* @__PURE__ */ (0,X.jsx)(ww,{...t,onOpenSubagentTranscript:e.onOpenSubagentTranscript,transcript:e.messages,conversation:e.conversation,unread:e.unread}):e.conversation.eventHistory.status===`redacted`&&e.messages.length>0?/* @__PURE__ */ (0,X.jsx)(Dw,{...t,onOpenSubagentTranscript:e.onOpenSubagentTranscript,conversation:e.conversation,messages:e.messages}):e.messages.length>0?/* @__PURE__ */ (0,X.jsx)(ww,{...t,onOpenSubagentTranscript:e.onOpenSubagentTranscript,transcript:e.messages,conversation:e.conversation}):/* @__PURE__ */ (0,X.jsx)(Lm,{children:Ia(e.conversation)}),e.responding?/* @__PURE__ */ (0,X.jsx)(ix,{indent:!0,children:/* @__PURE__ */ (0,X.jsx)(tw,{})}):null]})}function Cw(e){return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[e.brief?/* @__PURE__ */ (0,X.jsxs)(fa,{as:`section`,padding:`md`,variant:`section`,children:[/* @__PURE__ */ (0,X.jsx)(`h3`,{className:`mt-0 mb-3 font-display text-lg font-medium text-dashboard-text`,children:`Brief`}),/* @__PURE__ */ (0,X.jsx)(Tb,{brief:e.brief})]}):null,/* @__PURE__ */ (0,X.jsxs)(Nm,{className:`flex items-start gap-3 border-dashed border-dashboard-border-emphasis bg-dashboard-fill-soft`,children:[/* @__PURE__ */ (0,X.jsx)(Pm,{children:/* @__PURE__ */ (0,X.jsx)(sr,{})}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,X.jsx)(Fm,{children:`Transcript expired`}),/* @__PURE__ */ (0,X.jsxs)(Im,{className:`mt-1 text-sm`,children:[`The retention policy removed these events on`,` `,/* @__PURE__ */ (0,X.jsx)(`time`,{dateTime:e.expiredAt,children:ao(e.expiredAt,{dateStyle:`medium`,timeStyle:`short`})}),`.`,e.brief?` The brief above is still available.`:null]})]})]})]})}const ww=(0,Y.memo)(function(e){let t=(0,Y.useMemo)(()=>bf(e.transcript),[e.transcript]);return/* @__PURE__ */ (0,X.jsx)(Tw,{entries:t,keyPrefix:e.conversation.conversationId,revealSeq:e.revealSeq,scrollAnchorKey:e.scrollAnchorKey,unread:e.unread,renderContext:e=>/* @__PURE__ */ (0,X.jsx)(Tx,{kind:`compaction`,children:/* @__PURE__ */ (0,X.jsx)(hx,{part:e.part,timestamp:e.timestamp})}),renderFailure:e=>/* @__PURE__ */ (0,X.jsx)(bC,{eventId:e.eventId,failureCode:e.failureCode,failureReason:e.failureReason,sentryEventUrl:e.sentryEventUrl,timestamp:e.timestamp}),renderMessage:t=>e.conversation.sourceTask&&QC(e.conversation,t.message)?/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[/* @__PURE__ */ (0,X.jsx)(ew,{message:t.message,sourceTask:e.conversation.sourceTask}),/* @__PURE__ */ (0,X.jsx)(vC,{message:t.message})]}):t.message.eventType?/* @__PURE__ */ (0,X.jsxs)(Tx,{kind:`event`,objectType:t.message.eventObjectType,children:[/* @__PURE__ */ (0,X.jsx)(ZC,{message:t.message,openKey:t.key}),/* @__PURE__ */ (0,X.jsx)(vC,{className:`mt-1`,message:t.message})]}):t.message.context?/* @__PURE__ */ (0,X.jsxs)(Tx,{kind:`message_context`,children:[/* @__PURE__ */ (0,X.jsx)(PC,{message:t.message,conversation:e.conversation}),/* @__PURE__ */ (0,X.jsx)(vC,{className:`mt-2`,message:t.message})]}):/* @__PURE__ */ (0,X.jsx)(UC,{message:t.message,conversation:e.conversation}),renderAttachmentsDelivered:t=>/* @__PURE__ */ (0,X.jsx)(fC,{conversation:e.conversation,part:t.part,timestamp:t.timestamp}),renderStructuredEvent:e=>/* @__PURE__ */ (0,X.jsx)(Tx,{icon:Ox(e.part.presentation.icon),kind:`structured_event`,children:Cx(e.part)?/* @__PURE__ */ (0,X.jsx)(yC,{fallback:/* @__PURE__ */ (0,X.jsx)(pC,{part:e.part,timestamp:e.timestamp}),timestamp:e.timestamp,turnId:e.part.turnId}):/* @__PURE__ */ (0,X.jsx)(pC,{part:e.part,timestamp:e.timestamp})}),renderThread:yw,renderTasks:(t,n)=>bw(t,n,t=>e.onOpenSubagentTranscript?.({part:t,conversation:e.conversation})),renderReasoning:vw,renderTool:e=>/* @__PURE__ */ (0,X.jsx)(rC,{part:e.part,timestamp:e.timestamp})},e.conversation.conversationId)});function Tw(e){let t=wh(),n=(0,Y.useRef)(/* @__PURE__ */ new Map),[r]=(0,Y.useState)(()=>/* @__PURE__ */ new Map),i=CC(),a=(0,Y.useRef)(null),o=t.active?t.normalizedQuery:void 0,s=(0,Y.useMemo)(()=>rw({entries:e.entries,keyPrefix:e.keyPrefix,knownActivityKeys:n.current,search:o,unread:e.unread}),[e.entries,e.keyPrefix,e.unread,o]),c=(0,Y.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,Y.useRef)({});(0,Y.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,Y.use)(_w),m=p?.itemId,h=(0,Y.useMemo)(()=>m===void 0?void 0:ow(s,m),[m,s]),g=(0,Y.useRef)(void 0),_=(0,Y.useRef)(void 0);(0,Y.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,Y.useEffect)(()=>()=>window.clearTimeout(_.current?.timer),[]);let v=e.scrollAnchorKey?.(),y=c.get(nw),b=e.revealSeq===void 0?void 0:lw(s,e.revealSeq),x=gw({count:s.length,defaultSize:fw,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=>dw(s[e])}),{renderAttachmentsDelivered:S,renderContext:C,renderFailure:w,renderMessage:T,renderReasoning:E,renderStructuredEvent:D,renderThread:O,renderTasks:k,renderTool:A}=e,j=(0,Y.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,X.jsx)(Lm,{children:`No events match your search.`}):/* @__PURE__ */ (0,X.jsx)(nx,{value:r,children:/* @__PURE__ */ (0,X.jsx)(SC,{value:i,children:/* @__PURE__ */ (0,X.jsx)(`div`,{className:`relative min-w-0`,ref:a,style:{height:x.getTotalSize()},children:x.getVirtualItems().map(e=>/* @__PURE__ */ (0,X.jsx)(Ew,{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 Ew=(0,Y.memo)(function(e){let{row:t}=e;return/* @__PURE__ */ (0,X.jsx)(`div`,{className:q(`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,X.jsx)(tx,{}):t.kind===`activity`?/* @__PURE__ */ (0,X.jsx)(ix,{anchorKey:t.key,indent:!0,seq:t.seq,children:/* @__PURE__ */ (0,X.jsx)(zx,{entries:t.entries,openKey:t.key,renderEntry:e.renderEntry})}):t.kind===`tasks`?/* @__PURE__ */ (0,X.jsx)(ix,{anchorKey:t.key,seq:t.seq,children:e.renderTasks(t.entries,t.key)}):/* @__PURE__ */ (0,X.jsx)(ix,{anchorKey:t.key,seq:t.seq,children:e.renderEntry(t.entry)})})});function Dw(e){return/* @__PURE__ */ (0,X.jsx)(Tw,{entries:bf(e.messages),keyPrefix:`${e.conversation.conversationId}:redacted`,revealSeq:e.revealSeq,scrollAnchorKey:e.scrollAnchorKey,renderContext:e=>/* @__PURE__ */ (0,X.jsx)(Tx,{kind:`compaction`,children:/* @__PURE__ */ (0,X.jsx)(hx,{part:e.part,timestamp:e.timestamp})}),renderFailure:e=>/* @__PURE__ */ (0,X.jsx)(bC,{eventId:e.eventId,failureCode:e.failureCode,failureReason:e.failureReason,sentryEventUrl:e.sentryEventUrl,timestamp:e.timestamp}),renderMessage:t=>e.conversation.sourceTask&&QC(e.conversation,t.message)?/* @__PURE__ */ (0,X.jsx)(ew,{message:t.message,sourceTask:e.conversation.sourceTask}):t.message.eventType?/* @__PURE__ */ (0,X.jsx)(Tx,{kind:`event`,objectType:t.message.eventObjectType,children:/* @__PURE__ */ (0,X.jsx)(ZC,{message:t.message,openKey:t.key})}):t.message.context?/* @__PURE__ */ (0,X.jsx)(Tx,{kind:`message_context`,children:/* @__PURE__ */ (0,X.jsx)(PC,{message:t.message,conversation:e.conversation,redacted:!0})}):/* @__PURE__ */ (0,X.jsx)(WC,{message:t.message,conversation:e.conversation}),renderAttachmentsDelivered:t=>/* @__PURE__ */ (0,X.jsx)(fC,{conversation:e.conversation,part:t.part,timestamp:t.timestamp}),renderStructuredEvent:e=>/* @__PURE__ */ (0,X.jsx)(Tx,{icon:Ox(e.part.presentation.icon),kind:`structured_event`,children:/* @__PURE__ */ (0,X.jsx)(pC,{part:e.part,timestamp:e.timestamp})}),renderThread:yw,renderTasks:(t,n)=>bw(t,n,t=>e.onOpenSubagentTranscript?.({part:t,conversation:e.conversation})),renderReasoning:vw,renderTool:e=>/* @__PURE__ */ (0,X.jsx)(rC,{part:e.part,timestamp:e.timestamp})},e.conversation.conversationId)}function Ow(){let[e,n]=t(`junior:event-log:time-mode`,`utc`),r=e===`local`,i=Intl.DateTimeFormat().resolvedOptions().timeZone,a=r?i:`UTC`,o=(0,Y.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 kw(e){let t=e.modelCall?.usage,n=Aa(t);return[n?`${Ha(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:`${Ja(t[e])} ${n}`)].filter(e=>e!==void 0).join(` · `)}function Aw(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=JS(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 jw(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 Mw(e){return e.map(e=>({event:e,summary:Aw(e.data).replace(/\s+/g,` `).slice(0,300),metadata:[e.model?.modelId,kw(e)].filter(Boolean).join(` · `)}))}function Nw(e,t){return t?e.filter(({event:e,summary:n,metadata:r})=>`${n} ${r} ${JSON.stringify(e)}`.toLowerCase().includes(t)):e}function Pw(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 Fw=ae(`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 Iw({className:e,orientation:t,...n}){return/* @__PURE__ */ (0,X.jsx)(`div`,{role:`group`,"data-slot":`button-group`,"data-orientation":t,className:F(Fw({orientation:t}),e),...n})}function Lw({className:e,orientation:t=`vertical`,...n}){return/* @__PURE__ */ (0,X.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 Rw({usage:e}){let t=Aa(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,X.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,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsxs)(Gh,{"aria-label":`Model call token and cost breakdown`,className:`min-w-72 table-fixed text-xs leading-relaxed`,children:[/* @__PURE__ */ (0,X.jsxs)(`colgroup`,{children:[/* @__PURE__ */ (0,X.jsx)(`col`,{}),/* @__PURE__ */ (0,X.jsx)(`col`,{className:`w-24`}),/* @__PURE__ */ (0,X.jsx)(`col`,{className:`w-24`})]}),/* @__PURE__ */ (0,X.jsx)(Kh,{children:/* @__PURE__ */ (0,X.jsxs)(Yh,{className:`border-dashboard-border`,children:[/* @__PURE__ */ (0,X.jsx)(Xh,{scope:`col`,className:`px-0 py-2 leading-relaxed font-normal`,children:`Usage`}),/* @__PURE__ */ (0,X.jsx)(Xh,{scope:`col`,className:`px-0 py-2 text-right leading-relaxed font-normal`,children:`Tokens`}),/* @__PURE__ */ (0,X.jsx)(Xh,{scope:`col`,className:`px-0 py-2 text-right leading-relaxed font-normal`,children:`Cost (USD)`})]})}),/* @__PURE__ */ (0,X.jsx)(qh,{children:n.filter(e=>e!==r).map(e=>/* @__PURE__ */ (0,X.jsx)(zw,{...e},e.label))}),r?/* @__PURE__ */ (0,X.jsx)(Jh,{className:`font-semibold`,children:/* @__PURE__ */ (0,X.jsx)(zw,{...r,total:!0})}):null]}),/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`m-0 text-xs leading-relaxed text-dashboard-text-muted`,children:[`This call only · Estimated costs`,/* @__PURE__ */ (0,X.jsx)(`br`,{}),`Input excludes cache reads and writes. Reasoning is included in output.`]})]})}function zw(e){return/* @__PURE__ */ (0,X.jsxs)(Yh,{children:[/* @__PURE__ */ (0,X.jsx)(Xh,{scope:`row`,className:q(`px-0 py-2 leading-relaxed`,e.total?`font-semibold text-dashboard-text`:`font-normal text-dashboard-text-muted`),children:e.label}),/* @__PURE__ */ (0,X.jsx)(Zh,{className:`px-0 py-2 text-right font-sans tabular-nums`,children:e.tokens===void 0?/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-label":`Not recorded`,className:`text-dashboard-text-faint`,children:`—`}):e.tokens.toLocaleString(`en-US`)}),/* @__PURE__ */ (0,X.jsx)(Zh,{className:`px-0 py-2 text-right font-sans tabular-nums`,children:e.cost===void 0?/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-label":`Not recorded separately`,className:`text-dashboard-text-faint`,children:`—`}):/* @__PURE__ */ (0,X.jsx)(`span`,{title:`${e.cost} USD`,children:Ha({total:e.cost})})})]})}function Bw({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,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(Hw,{children:/* @__PURE__ */ (0,X.jsx)(Gw,{value:a})}),/* @__PURE__ */ (0,X.jsx)(Hw,{title:`Message`,children:i?/* @__PURE__ */ (0,X.jsx)(TC,{}):/* @__PURE__ */ (0,X.jsx)($,{mentions:n,text:r??``})})]});break}case`tool_calls`:o=/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[t.calls.map(e=>{let{name:t,input:n,output:r,...i}=e;return/* @__PURE__ */ (0,X.jsxs)(Hw,{title:t,children:[/* @__PURE__ */ (0,X.jsx)(Gw,{value:i}),n===void 0?null:/* @__PURE__ */ (0,X.jsx)(Uw,{title:`Input`,children:/* @__PURE__ */ (0,X.jsx)(Gw,{value:n})}),r===void 0?null:/* @__PURE__ */ (0,X.jsx)(Uw,{title:`Output`,children:/* @__PURE__ */ (0,X.jsx)(Gw,{value:r})})]},e.toolCallId)}),t.assistant?/* @__PURE__ */ (0,X.jsx)(Hw,{title:`Assistant`,children:/* @__PURE__ */ (0,X.jsx)(Gw,{value:t.assistant})}):null]});break;case`assistant_message`:o=t.parts.map((e,t)=>/* @__PURE__ */ (0,X.jsx)(Hw,{title:`Reasoning`,children:e.redacted?/* @__PURE__ */ (0,X.jsx)(TC,{}):/* @__PURE__ */ (0,X.jsx)($,{mentions:n,text:e.text??``})},t));break;case`structured_event`:{let{type:e,presentation:r,...i}=t;o=/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(Hw,{children:/* @__PURE__ */ (0,X.jsx)(Gw,{value:i})}),/* @__PURE__ */ (0,X.jsxs)(Hw,{title:r.title,children:[r.preview?/* @__PURE__ */ (0,X.jsx)($,{mentions:n,text:r.preview}):null,r.details?.map((e,t)=>/* @__PURE__ */ (0,X.jsxs)(Uw,{title:e.title,children:[e.description?/* @__PURE__ */ (0,X.jsx)($,{mentions:n,text:e.description}):null,e.content?/* @__PURE__ */ (0,X.jsx)(Gw,{value:e.content}):null,e.metadata?/* @__PURE__ */ (0,X.jsx)(Gw,{value:e.metadata}):null]},t))]})]});break}default:{let{type:e,...n}=t;o=/* @__PURE__ */ (0,X.jsx)(Hw,{children:/* @__PURE__ */ (0,X.jsx)(Gw,{value:n})})}}return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`@container grid min-w-0 gap-3`,children:[/* @__PURE__ */ (0,X.jsx)(Hw,{title:`Configuration`,children:/* @__PURE__ */ (0,X.jsx)(Gw,{value:{model:r?.modelId??`Not recorded`,...a}})}),e.modelCall?/* @__PURE__ */ (0,X.jsx)(Hw,{title:`Call usage`,children:/* @__PURE__ */ (0,X.jsx)(Rw,{usage:i})}):null,o,/* @__PURE__ */ (0,X.jsx)(Vw,{event:e})]})}function Vw({event:e}){let[t,n]=(0,Y.useState)(!1),r=t?JSON.stringify(e,null,2):``;return/* @__PURE__ */ (0,X.jsx)(`div`,{className:`relative min-w-0`,children:/* @__PURE__ */ (0,X.jsxs)(yh,{onOpenChange:n,open:t,children:[/* @__PURE__ */ (0,X.jsxs)(bh,{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,X.jsx)(H,{"aria-hidden":`true`,className:ca}),`Raw JSON`]}),/* @__PURE__ */ (0,X.jsxs)(xh,{children:[/* @__PURE__ */ (0,X.jsx)(`div`,{className:`absolute right-0 top-0`,children:/* @__PURE__ */ (0,X.jsx)(Zf,{getText:()=>r,label:`Copy JSON`})}),/* @__PURE__ */ (0,X.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,X.jsx)(jh,{code:r,language:`json`})})]})]})})}function Hw(e){return/* @__PURE__ */ (0,X.jsx)(Ig,{label:e.title,title:e.title,children:/* @__PURE__ */ (0,X.jsx)(`div`,{className:`grid min-w-0 gap-3 text-sm text-dashboard-text`,children:e.children})})}function Uw(e){return/* @__PURE__ */ (0,X.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,X.jsx)(`h4`,{className:`m-0 font-sans text-xs font-medium text-dashboard-text-muted`,children:e.title}),e.children]})}function Ww(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 Gw({value:e}){if(Array.isArray(e))return e.length?/* @__PURE__ */ (0,X.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,X.jsx)(`li`,{children:/* @__PURE__ */ (0,X.jsx)(Gw,{value:e})},t))}):/* @__PURE__ */ (0,X.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,X.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,X.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,X.jsx)(`dt`,{className:`break-words text-xs leading-relaxed text-dashboard-text-muted`,children:Ww(e)}),/* @__PURE__ */ (0,X.jsx)(`dd`,{className:`m-0 min-w-0`,children:n?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`border-l border-dashboard-border pl-3`,children:/* @__PURE__ */ (0,X.jsx)(Gw,{value:t})}):/* @__PURE__ */ (0,X.jsx)(Gw,{value:t})})]},e)})}):/* @__PURE__ */ (0,X.jsx)(`span`,{className:`text-sm text-dashboard-text-muted`,children:`Empty object`})}return/* @__PURE__ */ (0,X.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 qw(e){let{conversation:t,event:n,onSelect:r}=e,i=Ow(),a=n?/* @__PURE__ */ (0,X.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,X.jsxs)(`span`,{className:`shrink-0`,children:[`#`,n.seq]}),/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),/* @__PURE__ */ (0,X.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,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.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,X.jsxs)(`div`,{className:`grid gap-2 py-0.5`,children:[/* @__PURE__ */ (0,X.jsx)(J,{className:`h-3.5 w-28`}),/* @__PURE__ */ (0,X.jsx)(J,{className:`h-3 w-40`})]}),s=r&&n?/* @__PURE__ */ (0,X.jsxs)(Iw,{"aria-label":`Event navigation`,className:`rounded-md border border-dashboard-border`,children:[/* @__PURE__ */ (0,X.jsx)(V,{"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,X.jsx)(en,{"aria-hidden":`true`,size:15})}),/* @__PURE__ */ (0,X.jsx)(Lw,{}),/* @__PURE__ */ (0,X.jsx)(V,{"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,X.jsx)(Wt,{"aria-hidden":`true`,size:15})})]}):void 0;return/* @__PURE__ */ (0,X.jsx)(Qy,{actions:s,label:`Event details`,onClose:e.onClose,overlay:e.overlay,sheetTitle:n?.data.type,title:o,children:/* @__PURE__ */ (0,X.jsx)(`div`,{className:q(`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,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(`div`,{className:`mb-4 xl:hidden`,children:a}),t.canFork&&n.data.type===`message`&&n.data.role===`assistant`&&!n.data.redacted?/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-sm`,children:[/* @__PURE__ */ (0,X.jsx)(FC,{conversationId:t.conversationId,messageId:n.data.messageId}),/* @__PURE__ */ (0,X.jsx)(`span`,{children:`Fork after this reply`})]}):null,/* @__PURE__ */ (0,X.jsx)(Bw,{event:n})]}):/* @__PURE__ */ (0,X.jsx)(Jw,{})},n?.seq??`loading`)})}function Jw(){return/* @__PURE__ */ (0,X.jsxs)(`div`,{"aria-busy":`true`,role:`status`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`sr-only`,children:`Loading event`}),/* @__PURE__ */ (0,X.jsx)(J,{className:`h-3 w-40 xl:hidden`})]})}const Yw=`grid grid-cols-[12ch_minmax(0,1fr)] items-baseline gap-x-3 px-4 @min-[32rem]:grid-cols-[12ch_17ch_minmax(0,1fr)]`,Xw=(0,Y.memo)(function(e){let{conversation:t}=e,n=Ow(),r=wh(),[i,a]=(0,Y.useState)(),o=e.onSelectedSeqChange?e.selectedSeq:i,s=e.onSelectedSeqChange??a,c=(0,Y.useRef)(null),l=(0,Y.useRef)(void 0),u=t.events,d=(0,Y.useMemo)(()=>Mw(u),[u]),f=(0,Y.useMemo)(()=>Nw(d,r.normalizedQuery),[d,r.normalizedQuery]),p=u.find(e=>e.seq===o),m=(0,Y.useRef)(void 0),h=(0,Y.useRef)(void 0),g=(0,Y.useMemo)(()=>new Map(f.map((e,t)=>[e.event.seq,t])),[f]),_=e=>e===void 0?void 0:g.get(e),v=gw({count:f.length,defaultSize:e=>e===`metadata`?56:40,getItemKey:e=>f[e]?.event.seq??e,keptIndexes:[_(o),_(h.current),_(Zw(e.scrollAnchorKey?.()))],listRef:c,sizeClass:e=>f[e]?.metadata?`metadata`:`plain`}),y=v.getVirtualItems();return(0,Y.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,X.jsx)(`p`,{className:`text-sm text-dashboard-text-muted`,children:`Event history expired for this conversation.`}):/* @__PURE__ */ (0,X.jsxs)(`section`,{"aria-label":`Conversation event log`,className:`@container min-w-0`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`sticky top-0 z-10 bg-dashboard-bg`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-dashboard-border px-4 py-2`,children:[/* @__PURE__ */ (0,X.jsx)(nh,{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,X.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,X.jsx)(`span`,{role:`status`,children:r.active?`${f.length} of ${u.length} loaded events`:`${u.length} loaded events`}),/* @__PURE__ */ (0,X.jsx)(ha,{"aria-label":`Use local time`,onPressedChange:n.toggle,pressed:n.local,title:n.title,children:/* @__PURE__ */ (0,X.jsx)(`span`,{className:`max-w-32 truncate`,children:n.label})})]})]}),/* @__PURE__ */ (0,X.jsx)(eT,{})]}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`font-mono text-xs`,children:[/* @__PURE__ */ (0,X.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,X.jsx)(`li`,{className:q(`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,X.jsxs)(`button`,{"aria-expanded":o===t.seq,"aria-label":`Event ${t.seq}: ${t.data.type}`,className:q(Yw,`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,X.jsx)(`time`,{className:`tabular-nums text-dashboard-text-muted`,dateTime:t.createdAt,title:n.formatTimestamp(t.createdAt),children:n.formatClock(t.createdAt)}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:q(`truncate`,jw(t.data)),title:t.data.type,children:/* @__PURE__ */ (0,X.jsx)(Q,{text:t.data.type})}),/* @__PURE__ */ (0,X.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,X.jsx)(`span`,{className:`truncate`,title:r,children:/* @__PURE__ */ (0,X.jsx)(Q,{text:r})}),i?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`truncate text-dashboard-text-muted`,title:i,children:/* @__PURE__ */ (0,X.jsx)(Q,{text:i})}):null]})]})},e.key)})}),f.length===0?/* @__PURE__ */ (0,X.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,X.jsx)(qw,{overlay:!0,conversation:t,event:p,onClose:()=>s(void 0),onSelect:s,...Pw(f,p.seq)}),document.body):null]})});function Zw(e){return e?.startsWith(`event:`)?Number(e.slice(6)):void 0}const Qw=[`w-3/5`,`w-2/5`,`w-4/5`,`w-1/2`,`w-2/3`,`w-1/3`];function $w(){return/* @__PURE__ */ (0,X.jsxs)(`section`,{"aria-busy":`true`,className:`@container min-w-0`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`sr-only`,role:`status`,children:`Loading events`}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`sticky top-0 z-10 bg-dashboard-bg`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-dashboard-border px-4 py-2`,children:[/* @__PURE__ */ (0,X.jsx)(J,{className:`h-9 min-w-32 flex-1 @max-[28rem]:basis-full`}),/* @__PURE__ */ (0,X.jsx)(J,{className:`ml-auto h-3 w-24`})]}),/* @__PURE__ */ (0,X.jsx)(eT,{})]}),/* @__PURE__ */ (0,X.jsx)(`ol`,{className:`m-0 list-none divide-y divide-dashboard-border-subtle p-0`,children:Qw.map((e,t)=>/* @__PURE__ */ (0,X.jsxs)(`li`,{className:q(Yw,`min-h-11 items-center gap-y-2 py-2 @min-[32rem]:min-h-9 @min-[32rem]:py-1.5`),children:[/* @__PURE__ */ (0,X.jsx)(J,{className:`h-3 w-[10ch]`}),/* @__PURE__ */ (0,X.jsx)(J,{className:`h-3 w-[12ch]`}),/* @__PURE__ */ (0,X.jsx)(J,{className:q(`col-span-2 row-start-2 h-3 @min-[32rem]:col-span-1 @min-[32rem]:row-auto`,e)})]},t))})]})}function eT(){return/* @__PURE__ */ (0,X.jsxs)(`div`,{"aria-hidden":`true`,className:q(Yw,`border-b border-dashboard-border py-2 font-mono text-xs text-dashboard-text-muted`),children:[/* @__PURE__ */ (0,X.jsx)(`span`,{children:`Time`}),/* @__PURE__ */ (0,X.jsx)(`span`,{children:`Event`}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`hidden @min-[32rem]:block`,children:`Summary`})]})}function tT(e){let t=e.view??`rich`,[n,r]=(0,Y.useState)(``),i=e.search??n,a=t===`raw`?`events`:`messages`,o=e.transcript?.eventHistory.status===`redacted`,s=nm({conversationId:e.transcript?.conversationId,enabled:e.live??!1,endsAtLatest:!e.newerHistory,historyVersion:e.historyVersion??`empty`,juniorMessageVersion:qp(e.transcript),pinRequestVersion:e.pinRequestVersion,startAtLink:e.startAtLink,startAtUnread:t===`rich`&&e.startAtUnread,view:t,versions:{rich:Jp(e.transcript,`rich`),raw:Jp(e.transcript,`raw`)}}),{revealAsk:c}=e,{showRow:l}=s,u=(0,Y.useMemo)(()=>c?{...c,showRow:l}:void 0,[c,l]);bm({content:s.contentElement,engaged:e.readEngaged,lastReadSeq:e.lastReadSeq,onRead:e.onRead,paused:t!==`rich`||i.trim().length>0});let d=()=>e.onLoadPreviousPage?.(),f=im({edge:`top`,enabled:!(!e.onLoadPreviousPage||!e.hasPreviousPage||e.loadingPreviousPage||e.historyError),historyVersion:e.historyVersion??`empty`,onLoad:d}),p=e.newerHistory,m=im({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,X.jsx)(Ch,{match:e.searchMatch,onMatches:e.onSearchMatches,query:i,children:/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0 [overflow-anchor:none]`,ref:s.contentRef,children:[o?/* @__PURE__ */ (0,X.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,X.jsx)(nT,{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,X.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,X.jsx)(Xw,{conversation:e.transcript,onSearchChange:e.onSearchChange??r,onSelectedSeqChange:e.onSelectedEventSeqChange,scrollAnchorKey:s.scrollAnchorKey,selectedSeq:e.selectedEventSeq},e.transcript.conversationId):/* @__PURE__ */ (0,X.jsx)(DC,{panel:e.turnContextPanel,children:/* @__PURE__ */ (0,X.jsx)(rm,{value:h,children:/* @__PURE__ */ (0,X.jsx)(_w,{value:u,children:/* @__PURE__ */ (0,X.jsx)(xw,{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,X.jsxs)(X.Fragment,{children:[p.error?/* @__PURE__ */ (0,X.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,X.jsx)(nT,{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,X.jsx)(`div`,{"aria-hidden":`true`,className:`h-px`,ref:s.anchorRef}),/* @__PURE__ */ (0,X.jsx)(rT,{hasPendingUpdate:s.hasPendingUpdate,onClick:h,visible:s.showJumpToLatest})]})}):/* @__PURE__ */ (0,X.jsx)(Lm,{children:`No transcript is available for this conversation.`})}function nT(e){return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:q(`flex items-center gap-3`,e.className),ref:e.ref,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`h-px min-w-4 flex-1 bg-dashboard-fill-strong`}),/* @__PURE__ */ (0,X.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,X.jsx)(`span`,{className:`h-px min-w-4 flex-1 bg-dashboard-fill-strong`})]})}function rT(e){return e.visible?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`pointer-events-none sticky -bottom-2.5 z-20 flex h-0 justify-center md:-bottom-5`,children:/* @__PURE__ */ (0,X.jsxs)(V,{"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,X.jsx)(Sn,{"aria-hidden":`true`,size:14,strokeWidth:2}),`Jump to latest`]})}):null}const iT=()=>{},aT=/* @__PURE__ */ (0,X.jsx)(`h2`,{className:`m-0 flex min-w-0 items-center gap-1.5 font-sans text-sm`,children:/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-semibold text-dashboard-text`,children:`Details`})}),oT=`New conversation`,sT={archive:iT,continueInSlack:iT,delivery:iT,eventLog:iT,pin:iT,read:iT,rename:iT,subscription:iT},cT={archive:!1,delivery:!1,pin:!1,read:!1,subscription:!1};function lT(e){return`pending:${e}`}function uT(e){let t=P(),{pending:n}=e,r=(0,Y.useMemo)(()=>({conversationId:n.idempotencyKey,cumulativeDurationMs:0,displayTitle:oT,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,Y.useMemo)(()=>[xu({...bu({...n,actorIdentity:vu(t),inline:!0,messageId:n.idempotencyKey,now:n.createdAt}),status:`accepted`})],[n,t]),a=(0,Y.useRef)(null);(0,Y.useEffect)(()=>a.current?.focus(),[]);let o=hb(),s=Th(``);return uo(`Back to conversations`,void 0,oT),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`grid h-full min-h-0 min-w-0 grid-rows-[minmax(0,1fr)]`,children:/* @__PURE__ */ (0,X.jsx)(yb,{side:o?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`contents`,inert:!0,children:/* @__PURE__ */ (0,X.jsx)(Qy,{label:`Conversation details`,onClose:iT,title:aT,children:null})}):void 0,children:/* @__PURE__ */ (0,X.jsx)(Uv,{header:/* @__PURE__ */ (0,X.jsx)(Xv,{detailsOpen:o,errors:[],menu:{actions:sT,conversation:void 0,conversationId:n.idempotencyKey,detail:void 0,pending:cT},pending:!0,onDetailsClick:iT,onSearchChange:iT,onViewChange:iT,privacy:/* @__PURE__ */ (0,X.jsx)(Oy,{visibility:n.visibility}),search:``,searchMatch:s,sidebarToggle:e.sidebarToggle,title:oT,view:`rich`}),scrollMinTall:!0,scrollAriaLabel:`Conversation transcript`,scrollClassName:Vv,scroll:/* @__PURE__ */ (0,X.jsx)(Hv,{className:`duration-200 ease-out motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-bottom-1`,children:/* @__PURE__ */ (0,X.jsx)(tT,{pendingMessages:i,responding:!0,transcript:r})}),dock:/* @__PURE__ */ (0,X.jsx)(ch,{children:/* @__PURE__ */ (0,X.jsx)(Tv,{disabled:!0,draftId:lT(n.idempotencyKey),label:`Continue this conversation`,ref:a,submitLabel:`Send`,onSubmit:async()=>{}})})})})})}const dT=`junior-notification-target`,fT=`/_junior/dashboard/notification-target`;String.raw`
16
+ const SCOPE_URL = new URL(self.registration.scope);
17
+ const TARGET_CACHE = ${JSON.stringify(dT)};
18
+ const TARGET_KEY = new URL(${JSON.stringify(fT)}, 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 pT(){return window.__JUNIOR_DASHBOARD_BASE_PATH__??`/`}function mT(){return window.matchMedia?.(`(display-mode: standalone)`).matches===!0||navigator.standalone===!0}function hT(){return/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1}function gT(){return!window.isSecureContext||!(`serviceWorker`in navigator)||!(`PushManager`in window)||!(`Notification`in window)?hT()&&!mT()?`needs-install`:`unsupported`:`supported`}let _T;function vT(){if(`serviceWorker`in navigator&&window.isSecureContext)return _T??=navigator.serviceWorker.register(`/_junior/dashboard/sw.js`,{scope:pT()}),_T}function yT(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 bT(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 xT(){if(`serviceWorker`in navigator&&window.isSecureContext)return await(await navigator.serviceWorker.getRegistration(pT()))?.pushManager.getSubscription()??void 0}async function ST(e){let t=vT();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=yT(e),i=await n.getSubscription();return i&&bT(i,r)?i.toJSON():(await i?.unsubscribe(),(await n.subscribe({applicationServerKey:r,userVisibleOnly:!0})).toJSON())}async function CT(){let e=await xT();if(!e)return;let{endpoint:t}=e;return await e.unsubscribe(),t}function wT(){navigator.clearAppBadge?.().catch(()=>void 0)}function TT(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 ET(){if(typeof caches>`u`)return;let e=await caches.open(dT),t=await e.match(fT);if(!t)return;await e.delete(fT);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||TT(n.url)}const DT=`/api/notifications`,OT=`push-notifications`,kT=`/settings#${OT}`,AT=[`dashboard`,`notifications`,`device`],jT=j({queryKey:[`dashboard`,`notifications`],queryFn:({signal:e})=>K(Mr,DT,e)});async function MT(e,t){let n=await ST(t),r=await $i(Mr,`${DT}/subscriptions`,n);return e.setQueryData(jT.queryKey,r),e.invalidateQueries({queryKey:AT}),r}function NT(){return $i(Zr,`${DT}/test`,{})}const PT=`junior:dashboard:push-notifications-tip-shown`,FT=`push-notifications-tip`,IT=12e3;function LT(){try{return window.localStorage.getItem(PT)!==null}catch{return!0}}function RT(){try{window.localStorage.setItem(PT,`1`)}catch{}}function zT(e){return/* @__PURE__ */ (0,X.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 BT(){let e=P(),t=_e(),{add:n,close:r,update:i}=zo(),a=(0,Y.useCallback)(async()=>{if(LT())return;let a=gT();if(a===`unsupported`)return;let o=(await e.fetchQuery(jT)).publicKey;if(!o)return;let s=a===`supported`&&!!await xT();if(RT(),s)return;function c(){r(FT),t(kT)}let l=/* @__PURE__ */ (0,X.jsx)(zT,{onClick:c,children:`Settings`});function u(e){i(FT,{actionProps:void 0,description:/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[e??/* @__PURE__ */ (0,X.jsx)(zT,{onClick:()=>void d(),children:`Send a test`}),l]}),timeout:IT,title:`Push notifications are on`,type:`success`})}async function d(){try{let{delivered:e}=await NT();u(e>0?`Test sent.`:`No device got the test.`)}catch{u(`Could not send the test.`)}}async function f(t){i(FT,{actionProps:{children:`Turning on…`,disabled:!0},type:`loading`});try{await MT(e,t),u()}catch{i(FT,{actionProps:void 0,description:l,timeout:IT,title:`Could not turn on push notifications`,type:`error`})}}a===`supported`&&vT()?.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 ${_a()} replies.`,id:FT,timeout:IT,title:`Push notifications`,type:`info`})},[n,r,t,e,i]);return(0,Y.useCallback)(()=>void a().catch(()=>void 0),[a])}function VT(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,Y.useEffect)(()=>{r||s||!a||o||i()},[s,i,a,o,c,r]);let l=(0,Y.useMemo)(()=>r?[]:t.filter(xS),[t,r]),u=!r&&(s||n.isError&&!n.data),{refetch:d}=n,f=(0,Y.useCallback)(()=>void d(),[d]);return{loadFailed:u,pending:n.isPending||r||!!a||u,questions:l,retry:f}}function HT(e){return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[/* @__PURE__ */ (0,X.jsx)(A_,{className:`w-auto`,children:`Some questions did not load.`}),/* @__PURE__ */ (0,X.jsx)(V,{className:`h-7 px-2 text-xs`,onClick:e.onRetry,variant:`quiet`,children:`Try again`})]})}function UT(e){return e instanceof na&&e.apiError?e.apiError:`Could not save this action. Try again.`}function WT(e){return e instanceof HTMLElement&&(e.isContentEditable||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)}function GT(e){let[t,n]=(0,Y.useState)(),r=(0,Y.useRef)(null),i=(0,Y.useRef)(/* @__PURE__ */ new Map),[a,o]=(0,Y.useState)(()=>/* @__PURE__ */ new Set),s=(0,Y.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,Y.useEffect)(()=>{l(c)},[c,l]);let u=(0,Y.useRef)(!1),d=(0,Y.useRef)(!1);(0,Y.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,Y.useRef)(void 0),{onShow:h}=e;if((0,Y.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||WT(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,X.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,X.jsx)(`div`,{className:t===f?`grid min-w-0 gap-2`:`hidden`,"data-current-question":t===f?``:void 0,children:/* @__PURE__ */ (0,X.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,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5 text-xs text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,X.jsx)(V,{"aria-label":`Previous question`,className:`size-7`,onClick:()=>_(-1),size:`icon`,variant:`quiet`,children:/* @__PURE__ */ (0,X.jsx)(Rt,{"aria-hidden":`true`,size:15})}),/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`tabular-nums`,children:[t+1,` of `,g]}),/* @__PURE__ */ (0,X.jsx)(V,{"aria-label":`Next question`,className:`size-7`,onClick:()=>_(1),size:`icon`,variant:`quiet`,children:/* @__PURE__ */ (0,X.jsx)(H,{"aria-hidden":`true`,size:15})})]}):null})},e.id))})}function KT(e){let{item:t,onPicksChange:n}=e,r=pu(),[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(!1);(0,Y.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(UT(t)),t}e.afterAction(n.action!==`take`)}return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsxs)(`header`,{className:`flex min-w-0 items-center gap-2`,children:[/* @__PURE__ */ (0,X.jsx)(dr,{"aria-hidden":`true`,className:`shrink-0 text-dashboard-accent`,size:15}),/* @__PURE__ */ (0,X.jsx)(`h2`,{className:`m-0 min-w-0 flex-1 truncate text-sm font-semibold`,children:/* @__PURE__ */ (0,X.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,X.jsxs)(V,{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,X.jsx)(`kbd`,{"aria-hidden":`true`,className:`font-sans text-2xs text-dashboard-text-faint max-md:hidden`,children:`Esc`})]})]}),t.request?/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,X.jsx)(`div`,{className:`font-medium [&_p]:my-0`,children:/* @__PURE__ */ (0,X.jsx)($,{text:t.request.question})}),/* @__PURE__ */ (0,X.jsx)(Yx,{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,X.jsx)(V,{disabled:r.isPending,onClick:()=>void c({action:`take`}).catch(()=>{}),variant:`quiet`,children:`Take`}):void 0})]}):null,i?/* @__PURE__ */ (0,X.jsx)(A_,{children:i}):null]})}function qT(e,t=[]){return pg(JT(e),t)}function JT(e){return e.replace(eg,(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 YT=ur;function XT(e){return e.clientStatus===`failed`?{icon:qn,label:`Failed to send`,tooltip:`Failed to send`}:e.clientStatus===`sending`?{icon:Dp,label:`Sending`,tooltip:`Sending`}:e.delivery===`interrupt`&&e.source!==`web`?{icon:mr,label:`Next step`,tooltip:`Junior reads it at its next step`}:e.delivery===`interrupt`?{icon:YT,label:`Steered`,tooltip:`Steered: Junior reads it at its next step`}:{icon:An,label:`Queued`,tooltip:`Queued: Junior reads it after the current reply`}}function ZT(e){return/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(U,{render:/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-label":e.label,className:`inline-flex text-dashboard-text-muted`,children:e.children})}),/* @__PURE__ */ (0,X.jsx)(W,{size:`compact`,children:e.tooltip??e.label})]})}function QT(e){let t=e.icon;return/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(U,{render:/* @__PURE__ */ (0,X.jsx)(V,{"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,X.jsx)(Dp,{"aria-hidden":`true`,className:`size-3.25`}):/* @__PURE__ */ (0,X.jsx)(t,{"aria-hidden":`true`,size:14,strokeWidth:2.2})})}),/* @__PURE__ */ (0,X.jsx)(W,{size:`compact`,children:e.tooltip})]})}function $T(e){let t=XT(e.message),n=t.icon;return/* @__PURE__ */ (0,X.jsxs)(HS,{className:`flex min-w-0 items-center justify-end gap-1 text-xs leading-none text-dashboard-text-muted`,children:[e.showSlack?/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(U,{render:/* @__PURE__ */ (0,X.jsx)(`span`,{className:`inline-flex text-dashboard-text-muted`,children:/* @__PURE__ */ (0,X.jsx)(Qf,{className:`size-3.5`})})}),/* @__PURE__ */ (0,X.jsx)(W,{size:`compact`,children:`From Slack`})]}):null,/* @__PURE__ */ (0,X.jsx)(ZT,{label:t.label,tooltip:t.tooltip,children:/* @__PURE__ */ (0,X.jsx)(n,{"aria-hidden":`true`,className:`size-3.25`,strokeWidth:2.2})}),e.onSteer?/* @__PURE__ */ (0,X.jsx)(QT,{disabled:e.actionsDisabled,icon:YT,label:`Steer queued message`,onClick:e.onSteer,pending:e.steerPending,tooltip:`Steer: Junior reads it at its next step`}):null,e.onEdit?/* @__PURE__ */ (0,X.jsx)(QT,{disabled:e.actionsDisabled,icon:tn,label:`Edit queued message`,onClick:e.onEdit,pending:e.editPending,tooltip:`Edit: move it back to the composer`}):null,e.onCancel?/* @__PURE__ */ (0,X.jsx)(QT,{disabled:e.actionsDisabled,icon:Jn,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 eE(e){let{actorIdentityId:t}=e.message,n=(t?e.authors?.[t]:void 0)??e.message.actorIdentity;return n?/* @__PURE__ */ (0,X.jsx)(mh,{participant:n,size:`list`}):/* @__PURE__ */ (0,X.jsx)(lh,{name:`?`,size:`list`})}function tE(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,X.jsxs)(`span`,{className:`flex flex-none items-center gap-1`,children:[r.map((e,r)=>/* @__PURE__ */ (0,X.jsx)(__,{filename:e.filename,imageClassName:t,src:W_(e),triggerClassName:n},`local:${r}`)),i.map(r=>Hr.some(e=>e===r.contentType)&&e.conversationId?/* @__PURE__ */ (0,X.jsx)(__,{filename:r.filename,imageClassName:t,loading:`lazy`,src:G_(e.conversationId,r.id),triggerClassName:n},r.id):/* @__PURE__ */ (0,X.jsx)(ZT,{label:r.filename,children:/* @__PURE__ */ (0,X.jsx)(pr,{"aria-hidden":`true`,size:14})},r.id))]})}function nE(e){let t=e.message.text??``,n=e.message.mentions??[],r=!!e.message.redacted,i=e.message.source===`slack`;return/* @__PURE__ */ (0,X.jsxs)(`article`,{className:q(`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,X.jsx)(BS,{className:`items-center`,left:/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(eE,{authors:e.authors,message:e.message}),r?null:/* @__PURE__ */ (0,X.jsx)(tE,{conversationId:e.conversationId,message:e.message}),r?/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 font-sans text-sm leading-snug text-dashboard-text-muted`,children:`[redacted]`}):t?/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 min-w-0 truncate font-sans text-sm leading-snug text-dashboard-text-subtle`,title:qT(t,n),children:e.message.reviewItemChange?/* @__PURE__ */ (0,X.jsx)(kS,{fallback:/* @__PURE__ */ (0,X.jsx)($,{inline:!0,mentions:n,text:t}),record:e.message.reviewItemChange}):/* @__PURE__ */ (0,X.jsx)($,{inline:!0,mentions:n,text:t})}):null]}),leftClassName:`flex-1 text-sm leading-snug text-dashboard-text`,right:/* @__PURE__ */ (0,X.jsx)($T,{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,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 font-sans text-xs text-red-300/80`,children:`Could not send.`}),/* @__PURE__ */ (0,X.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,X.jsx)(`p`,{className:`m-0 font-sans text-xs text-amber-100/75`,children:`Could not delete. Try again.`}):null]})}function rE(e){return/* @__PURE__ */ (0,X.jsxs)(`button`,{"aria-controls":e.controls,"aria-expanded":e.expanded,className:q(`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,X.jsx)(H,{"aria-hidden":`true`,className:ca}),e.expanded?`Show fewer queued messages`:/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`md:tall:hidden`,children:[e.totalCount,` queued messages`]}),e.tallHiddenCount>0?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`hidden md:tall:inline`,children:e.tallHiddenCount===1?`1 more queued message`:`${e.tallHiddenCount} more queued messages`}):null]})]})}function iE(e,t){return!!(e&&t&&e.trim().toLowerCase()===t.trim().toLowerCase())}const aE=(0,Y.memo)(function(e){let[t,n]=(0,Y.useState)(!1),r=(0,Y.useId)(),i=(0,Y.useRef)(e.onLayoutChange);i.current=e.onLayoutChange;let a=(0,Y.useRef)(!1);(0,Y.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,X.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,X.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&&iE(a.actorIdentity?.email,e.viewerEmail);return/* @__PURE__ */ (0,X.jsx)(nE,{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,X.jsx)(rE,{className:q(!c&&`hidden md:flex`,u===0&&`md:tall:hidden`),controls:r,expanded:t,onClick:d,tallHiddenCount:u,totalCount:s.length}):null]})}),oE=(0,Y.memo)(sE);function sE(e){let t=dd(e.conversationId),n=oS(),r=hd(e.conversationId),i=(0,Y.useRef)(r);i.current=r;let a=fd(e.conversationId),[o,s]=(0,Y.useState)(),[c,l]=(0,Y.useState)(),{loadFailed:u,pending:d,questions:f,retry:p}=VT(e.conversationId),m=(0,Y.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,Y.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,Y.useRef)(null),y=(0,Y.useRef)(null),[b,x]=(0,Y.useState)(!1),S=(0,Y.useRef)(b);S.current=b;let{confirmSubmit:C}=n,w=(0,Y.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,Y.useRef)(t);T.current=t;let E=(0,Y.useRef)(a);E.current=a;let D=(0,Y.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,Y.useRef)(O);(0,Y.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,Y.useRef)(!1);j.current=e.sendsInline&&!e.pendingMessages.some(e=>!A.has(e.messageId));let M=(0,Y.useCallback)(async(e,t,n)=>{await T.current.mutateAsync({idempotencyKey:t,inline:j.current,message:e,images:n})},[]),ee=(0,Y.useCallback)(e=>{e.idempotencyKey&&(e.text||e.images?.length)&&T.current.mutateAsync({idempotencyKey:e.idempotencyKey,message:e.text??``,images:e.images})},[]),N=(0,Y.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,Y.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=fd(e.conversationId),ie=(0,Y.useRef)(re);ie.current=re;let ae=(0,Y.useRef)(!1),I=(0,Y.useRef)(null);(0,Y.useImperativeHandle)(e.ref,()=>({appendText:e=>I.current?.appendText(e)}));let{onFocusRequestDone:oe}=e,se=e.focusRequest?.key,ce=e.focusRequest?.draftFrom,le=f.length>0;(0,Y.useEffect)(()=>{if(!se||d&&!le)return;oe(se);let e=ce?Mv(ce):``;e?I.current?.restoreMessage({text:e}):ce?I.current?.focus():Cv()||(le?v.current?.focus():I.current?.focus())},[ce,se,oe,le,d]);let ue=Jo().data?.me.user.email,de=(0,Y.useCallback)(async t=>{let n=e.pendingGeneratedAtRef.current;if(!n||ae.current)return;ae.current=!0;let r=t.inboundMessageId;s(r),l(void 0);try{let i=await hv(e.conversationId,t.attachments);if(!I.current)return;if(!I.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??``};I.current?I.current.restoreMessage(a):jv(e.conversationId,a.text)}catch{l(`Could not edit the queued message. Try again.`)}finally{ae.current=!1,s(void 0)}},[e.conversationId,e.pendingGeneratedAtRef]),L=pd(e.conversationId),fe=(0,Y.useRef)(L);fe.current=L;let pe=(0,Y.useCallback)(e=>{if(fe.current.isPending)return;l(void 0);let t=e.inboundMessageId;fe.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.`)}})},[]),me=L.isPending?L.variables?.inboundMessageIds[0]:void 0,he=(0,Y.useCallback)(async()=>{let e=(await i.current.mutateAsync()).stoppedMessages.map(e=>e.text);return e.length?e.join(`
154
+ `):void 0},[]),ge=(0,Y.useCallback)(()=>{window.matchMedia(`(width < 48rem) or ((width < 64rem) and (height < 30rem))`).matches&&D.current()},[]),_e=(0,Y.useCallback)(()=>I.current?.focus(),[]),ve=(0,Y.useCallback)(()=>{window.matchMedia(`(width < 48rem) or ((width < 64rem) and (height < 30rem))`).matches&&D.current()},[]);return/* @__PURE__ */ (0,X.jsx)(ch,{above:/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[e.pendingAuthorization?/* @__PURE__ */ (0,X.jsx)(Dy,{authorization:e.pendingAuthorization}):null,/* @__PURE__ */ (0,X.jsx)(aE,{authors:e.authors,cancelError:ne,cancelPending:a.isPending,cancelTargetInboundMessageId:F,committedMessageIds:e.committedMessageIds,conversationId:e.conversationId,editTargetInboundMessageId:o,messages:e.pendingMessages,onCancelMessage:te,onEditMessage:de,onLayoutChange:ge,onRetry:ee,onSteerMessage:e.stoppable?pe:void 0,steerTargetInboundMessageId:me,viewerEmail:ue}),/* @__PURE__ */ (0,X.jsx)(GT,{answersRef:y,focusMessageBox:_e,onAnswersChange:x,onShow:_,questions:f,ref:v}),u?/* @__PURE__ */ (0,X.jsx)(HT,{onRetry:p}):null,n.dialog]}),children:/* @__PURE__ */ (0,X.jsx)(Tv,{beforeSubmit:w,draftId:e.conversationId,error:c??(r.error?`Could not stop Junior. Try again.`:void 0),ref:I,label:`Continue this conversation`,placeholder:le?`Or type your answer…`:void 0,sendsWithoutDraft:b,submitLabel:`Send`,onFocus:ve,onStop:e.stoppable?he:void 0,stopPending:r.isPending,onSubmitStart:N,onSubmit:M})})}function cE(e){let{detail:t}=e,n=(0,Y.useMemo)(()=>Fu(t.data?.events),[t.data?.events]),r=(0,Y.useRef)(t.pendingGeneratedAt);return r.current=t.pendingGeneratedAt,t.data?/* @__PURE__ */ (0,X.jsx)(oE,{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&&!Zu(t.data)&&t.inlineMessages.length===0,stoppable:e.live}):null}function lE(e){let t=P();return N({mutationFn:t=>Wi(ui,`/api/conversations/${encodeURIComponent(e)}/auto-archive`,{autoArchive:t}),onSuccess:n=>{t.setQueryData(Z(e),e=>e&&{...e,autoArchive:n.autoArchive,detailEtag:void 0})}})}function uE(){let e=P();return N({mutationFn:()=>$i(ri,`/api/conversations/archive-done`,{}),onSuccess:async()=>{await e.invalidateQueries({queryKey:[`dashboard`,`conversations`]})}})}const dE=`Archive this conversation for everyone when its linked work is merged or closed and nobody replies during your wait time.`;function fE(e){let t=lE(e.conversationId),n=(0,Y.useId)();return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid gap-1`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[/* @__PURE__ */ (0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2.5`,children:[/* @__PURE__ */ (0,X.jsx)(Bx,{"aria-describedby":n,checked:e.autoArchive,disabled:t.isPending,onCheckedChange:e=>t.mutate(e)}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-semibold text-dashboard-text`,children:`Auto archive`})]}),/* @__PURE__ */ (0,X.jsxs)(Gs,{children:[/* @__PURE__ */ (0,X.jsx)(Ks,{delay:0,openOnHover:!0,render:/* @__PURE__ */ (0,X.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,X.jsx)(_r,{"aria-hidden":`true`,size:14,strokeWidth:2})})}),/* @__PURE__ */ (0,X.jsx)(qs,{"aria-label":`About auto archive`,className:`w-64 px-3 py-2 text-xs`,side:`top`,children:/* @__PURE__ */ (0,X.jsx)(Ys,{children:dE})})]}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`sr-only`,id:n,children:dE})]}),t.isError?/* @__PURE__ */ (0,X.jsx)(A_,{children:`Could not save auto-archive. Try again.`}):null]})}function pE({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(`nav`,{role:`navigation`,"aria-label":`Pagination`,"data-slot":`pagination`,className:F(`flex w-full justify-center`,e),...t})}function mE({className:e,...t}){return/* @__PURE__ */ (0,X.jsx)(`ul`,{"data-slot":`pagination-content`,className:F(`flex items-center gap-2`,e),...t})}function hE({...e}){return/* @__PURE__ */ (0,X.jsx)(`li`,{"data-slot":`pagination-item`,...e})}function gE(e){return/* @__PURE__ */ (0,X.jsx)(V,{"aria-label":`Previous page`,size:`icon`,...e,children:/* @__PURE__ */ (0,X.jsx)(Rt,{"aria-hidden":`true`,size:16})})}function _E(e){return/* @__PURE__ */ (0,X.jsx)(V,{"aria-label":`Next page`,size:`icon`,...e,children:/* @__PURE__ */ (0,X.jsx)(H,{"aria-hidden":`true`,size:16})})}function vE(e){return e.hasMore?/* @__PURE__ */ (0,X.jsx)(V,{className:q(`justify-self-center`,e.className),disabled:e.loading,onClick:e.onLoadMore,children:e.loading?`Loading…`:`Load more`}):null}function yE(e,t,n){let r=(Math.max(1,t)-1)*n;return e.slice(r,r+n)}function bE(e,t){return e<=0?1:Math.max(1,Math.ceil(e/t))}function xE(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,X.jsxs)(pE,{className:q(`flex-wrap items-center justify-between gap-3`,e.className),children:[/* @__PURE__ */ (0,X.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,X.jsxs)(mE,{children:[/* @__PURE__ */ (0,X.jsx)(hE,{children:/* @__PURE__ */ (0,X.jsx)(gE,{disabled:t<=1,onClick:()=>e.onPageChange(t-1)})}),/* @__PURE__ */ (0,X.jsxs)(hE,{className:`min-w-16 text-center font-sans tabular-nums text-xs text-dashboard-text-muted`,children:[t,` / `,e.pageCount]}),/* @__PURE__ */ (0,X.jsx)(hE,{children:/* @__PURE__ */ (0,X.jsx)(_E,{disabled:t>=e.pageCount,onClick:()=>e.onPageChange(t+1)})})]})]})}function SE(e){let{item:t}=e,n=t.status===`open`,r=t.assignees.length>0||t.assignedToEveryone;return/* @__PURE__ */ (0,X.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,X.jsxs)(`header`,{className:`flex items-start gap-3 px-4 pb-3 pt-4 md:px-5`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,className:q(`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,X.jsx)(dr,{size:18})}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0 flex-1 gap-1`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 text-xs text-dashboard-text-muted`,children:`Review item`}),/* @__PURE__ */ (0,X.jsx)(Np,{className:`shrink-0`,size:`compact`,tone:n?`accent`:`neutral`,children:mS(t)})]}),/* @__PURE__ */ (0,X.jsx)(`h3`,{className:`m-0 break-words text-base font-semibold leading-snug`,children:t.title})]})]}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0 gap-4 px-4 pb-4 md:px-5`,children:[/* @__PURE__ */ (0,X.jsx)($,{text:t.body}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`border-t border-dashboard-border pt-4`,children:/* @__PURE__ */ (0,X.jsx)(dS,{item:t})})]}),/* @__PURE__ */ (0,X.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,X.jsxs)(B,{className:`inline-flex items-center gap-2 font-medium text-dashboard-text no-underline hover:underline focus-visible:outline-dashboard-focus`,to:fS(t.id),children:[`Open on the review desk`,/* @__PURE__ */ (0,X.jsx)(ar,{"aria-hidden":`true`,size:14})]}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 truncate text-dashboard-text-muted`,children:r?`Assigned to ${hS(t)}`:`Unassigned`})]})]})}function CE(e){let{items:t,query:n}=cu({conversationId:e.conversationId}),r=(0,Y.useRef)(null),i=t.length>0;return(0,Y.useEffect)(()=>{e.highlight&&i&&r.current?.scrollIntoView({block:`nearest`})},[e.highlight,i]),i?/* @__PURE__ */ (0,X.jsx)(`div`,{className:q(`rounded-lg`,e.highlight&&`ring-2 ring-violet-300/50`),ref:r,children:/* @__PURE__ */ (0,X.jsxs)(Ig,{count:n.hasNextPage?void 0:t.length,label:`Needs you`,title:`Needs you`,children:[/* @__PURE__ */ (0,X.jsx)(Lg,{itemKey:e=>e.id,items:t,renderItem:t=>/* @__PURE__ */ (0,X.jsx)(wE,{defaultExpanded:e.highlight,item:t})}),/* @__PURE__ */ (0,X.jsx)(vE,{className:`mt-2`,hasMore:!!n.hasNextPage,loading:n.isFetchingNextPage,onLoadMore:()=>void n.fetchNextPage()})]})}):null}function wE(e){let[t,n]=(0,Y.useState)(e.defaultExpanded);return(0,Y.useEffect)(()=>{e.defaultExpanded&&n(!0)},[e.defaultExpanded]),/* @__PURE__ */ (0,X.jsxs)(yh,{className:`min-w-0`,onOpenChange:n,open:t,children:[/* @__PURE__ */ (0,X.jsx)(Rg,{disclosure:!0,icon:/* @__PURE__ */ (0,X.jsx)(dr,{"aria-hidden":`true`,className:`size-3.5`}),meta:/* @__PURE__ */ (0,X.jsx)(`span`,{className:`grid size-5 place-items-center`,children:/* @__PURE__ */ (0,X.jsx)(H,{"aria-hidden":`true`,className:ca})}),title:e.item.title}),/* @__PURE__ */ (0,X.jsx)(xh,{className:`px-1.5 pb-1`,children:/* @__PURE__ */ (0,X.jsx)(SE,{item:e.item})})]})}function TE(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 EE(e){let t=TE(e.list),n=[t.recalled?`${t.recalled} recalled`:void 0,t.captured?`${t.captured} captured`:void 0].filter(Boolean).join(` · `);return/* @__PURE__ */ (0,X.jsx)(Ig,{title:`Memories`,children:/* @__PURE__ */ (0,X.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,X.jsx)(H,{"aria-hidden":`true`,className:ca})]})})}function DE(e){let{entry:t}=e,{turnId:n}=t;return/* @__PURE__ */ (0,X.jsxs)(`li`,{className:`grid overflow-hidden rounded-lg border border-dashboard-border-subtle bg-dashboard-surface-panel`,children:[/* @__PURE__ */ (0,X.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,X.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,X.jsx)(mC,{}):/* @__PURE__ */ (0,X.jsx)(`span`,{}),n?/* @__PURE__ */ (0,X.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,X.jsx)(ar,{"aria-hidden":`true`,size:13})]}):null]})]})}function OE(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,X.jsx)(`div`,{className:`grid gap-5`,children:t.map(t=>/* @__PURE__ */ (0,X.jsxs)(`section`,{className:`grid gap-2`,children:[/* @__PURE__ */ (0,X.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,X.jsx)(Cr,{"aria-hidden":`true`,size:13,strokeWidth:1.8}):/* @__PURE__ */ (0,X.jsx)(Ht,{"aria-hidden":`true`,size:13,strokeWidth:1.8}),t.source===`recalled`?`Recalled`:`Captured`,/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-normal tabular-nums text-dashboard-text-muted`,children:t.entries.length})]}),/* @__PURE__ */ (0,X.jsx)(`ol`,{className:`m-0 grid list-none gap-2 p-0`,children:t.entries.map(t=>/* @__PURE__ */ (0,X.jsx)(DE,{entry:t,onSelect:e.onSelect},`${t.source}:${t.memory.id}`))})]},t.source))})}function kE(e){let t=Zy(),n=Sx()?.list,[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(e.conversationId);a!==e.conversationId&&(o(e.conversationId),i(!1));let s=Ib(e.conversationId).data?.agents,c=s?.filter(e=>e.kind===`thread`)??[],l=s?.filter(e=>e.kind===`task`)??[],u=e.agentTree?.at(-2),d=Bg(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,X.jsx)(Qy,{label:`Conversation details`,onClose:e.onClose,title:/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`-ml-2 flex min-w-0 items-center gap-1`,children:[/* @__PURE__ */ (0,X.jsx)(V,{"aria-label":`Back to details`,onClick:()=>i(!1),size:`icon`,children:/* @__PURE__ */ (0,X.jsx)(Kt,{"aria-hidden":`true`,size:15})}),/* @__PURE__ */ (0,X.jsx)(`h2`,{className:`m-0 truncate font-sans text-sm font-semibold text-dashboard-text`,children:`Memories`})]}),children:/* @__PURE__ */ (0,X.jsx)(`div`,{className:`px-4 pb-[max(1rem,env(safe-area-inset-bottom))] pt-3`,children:/* @__PURE__ */ (0,X.jsx)(OE,{entries:bx(n),onSelect:n=>{t||e.onClose(),e.onSelectMemory(n)}})})}):/* @__PURE__ */ (0,X.jsx)(Qy,{label:`Conversation details`,title:/* @__PURE__ */ (0,X.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,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-semibold text-dashboard-text`,children:`Brief`}),/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,className:`text-dashboard-text-faint`,children:`·`}),/* @__PURE__ */ (0,X.jsxs)(`time`,{className:`truncate text-xs font-normal text-dashboard-text-muted`,dateTime:e.brief.updatedAt,title:ao(e.brief.updatedAt,{dateStyle:`medium`,timeStyle:`short`}),children:[`Updated `,oo(e.brief.updatedAt)]})]}):/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-semibold text-dashboard-text`,children:`Details`})}),onClose:e.onClose,children:/* @__PURE__ */ (0,X.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,X.jsx)(Ig,{flat:!0,title:`Parent`,children:/* @__PURE__ */ (0,X.jsx)(Rg,{icon:/* @__PURE__ */ (0,X.jsx)(En,{"aria-hidden":`true`,size:14}),title:u.label,to:kc(u.conversationId)})}):null,/* @__PURE__ */ (0,X.jsx)(CE,{conversationId:e.conversationId,highlight:e.highlightReview}),e.brief?/* @__PURE__ */ (0,X.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,X.jsx)(Tb,{brief:e.brief,variant:`summary`})}):null,c.length>0?/* @__PURE__ */ (0,X.jsx)(Lb,{threads:c}):null,e.links.length>0||m.length>0?/* @__PURE__ */ (0,X.jsxs)(Ig,{count:e.links.length||m.length,flat:!0,title:e.links.length>0?`Linked work`:`Waiting on`,children:[e.links.length>0?/* @__PURE__ */ (0,X.jsx)($g,{links:e.links,watchesByUrl:p}):null,e.links.length>0&&m.length>0?/* @__PURE__ */ (0,X.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,X.jsx)(Vg,{watches:m}):null]}):null,e.autoArchive==null?null:/* @__PURE__ */ (0,X.jsx)(Ig,{children:e.autoArchive}),l.length>0?/* @__PURE__ */ (0,X.jsx)(Rb,{onOpenTask:n=>{t||e.onClose(),e.onOpenSubagent(n)},tasks:l}):null,e.overview==null?null:/* @__PURE__ */ (0,X.jsx)(Ig,{flat:!0,children:e.overview}),e.usage,e.identity==null?null:/* @__PURE__ */ (0,X.jsx)(Ig,{flat:!0,title:`Participants`,children:e.identity}),n?.events.length?/* @__PURE__ */ (0,X.jsx)(EE,{list:n,onOpen:()=>i(!0)}):null]})})}function AE(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?`—`:Ja(t),label:e}]:[]);return r.length?r:void 0}const jE=`px-0 text-right align-top font-sans tabular-nums`;function ME(e){return/* @__PURE__ */ (0,X.jsxs)(Gh,{"aria-label":e.label,className:`min-w-72 table-fixed text-xs leading-relaxed`,children:[/* @__PURE__ */ (0,X.jsxs)(`colgroup`,{children:[/* @__PURE__ */ (0,X.jsx)(`col`,{}),/* @__PURE__ */ (0,X.jsx)(`col`,{className:`w-20`}),/* @__PURE__ */ (0,X.jsx)(`col`,{className:`w-20`})]}),/* @__PURE__ */ (0,X.jsx)(Kh,{children:/* @__PURE__ */ (0,X.jsxs)(Yh,{className:`border-dashboard-border`,children:[/* @__PURE__ */ (0,X.jsx)(Xh,{scope:`col`,className:`px-0 py-2 leading-relaxed font-normal`,children:e.label}),/* @__PURE__ */ (0,X.jsx)(Xh,{scope:`col`,className:`px-0 py-2 text-right leading-relaxed font-normal`,children:e.countLabel}),/* @__PURE__ */ (0,X.jsx)(Xh,{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`:q(t===0?`pt-2`:`pt-0`,t===n.length-1?`pb-2`:`pb-0`);return/* @__PURE__ */ (0,X.jsxs)(qh,{className:q(e.parts&&`border-b border-dashboard-border-subtle last-of-type:border-b-0`),children:[/* @__PURE__ */ (0,X.jsxs)(Yh,{className:`border-0`,children:[/* @__PURE__ */ (0,X.jsx)(Xh,{scope:`row`,className:q(`pl-0 pr-3 align-top leading-relaxed font-normal text-dashboard-text`,r),children:/* @__PURE__ */ (0,X.jsx)(`span`,{className:`block truncate`,children:e.label})}),/* @__PURE__ */ (0,X.jsx)(Zh,{className:q(jE,r),children:e.count}),/* @__PURE__ */ (0,X.jsx)(Zh,{className:q(jE,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,X.jsxs)(Yh,{className:`border-0 text-2xs leading-5`,children:[/* @__PURE__ */ (0,X.jsx)(Xh,{scope:`row`,className:q(`truncate pl-3 pr-3 align-top text-2xs leading-5 font-normal text-dashboard-text-faint`,r),children:e.label}),/* @__PURE__ */ (0,X.jsx)(Zh,{className:q(jE,`text-dashboard-text-faint`,r),children:e.count}),/* @__PURE__ */ (0,X.jsx)(Zh,{className:q(jE,`text-dashboard-text-faint`,r),children:e.cost})]},e.label)})]},e.key)}),e.total?/* @__PURE__ */ (0,X.jsx)(Jh,{className:`font-semibold`,children:/* @__PURE__ */ (0,X.jsxs)(Yh,{children:[/* @__PURE__ */ (0,X.jsx)(Xh,{scope:`row`,className:`px-0 py-2 leading-relaxed font-semibold text-dashboard-text`,children:e.total.label}),/* @__PURE__ */ (0,X.jsx)(Zh,{className:`px-0 py-2 text-right font-sans tabular-nums`,children:e.total.count}),/* @__PURE__ */ (0,X.jsx)(Zh,{className:`px-0 py-2 text-right font-sans tabular-nums`,children:e.total.cost})]})}):null]})}function NE(e){if(!e.conversation)return!1;let t=e.detail?.auxiliaryCosts??e.conversation.auxiliaryCosts;return!!(e.detail?.modelUsage?.length||t?.operations?.length)}function PE(e){if(!NE(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=wa(t),o=Da(r),s=(a??o)?.totalTokens,c=Ma(t),l=Aa(r),u=Oa(c??l,n),d=u?.total,f=[...n?.operations??[]].sort((e,t)=>t.costUsd-e.costUsd),p=gy(d??0),m=e=>e===void 0?`—`:Ja(e),h=e=>e===void 0?`—`:p(e),g=Vy(e.detail),_=(e.detail?.status??e.conversation.status)===`active`,v=AE(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:Aa(e.usage),modelId:e.modelId,tokens:Da(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=sy(i),S=cy(x.cost,d??x.cost),C=cy(x.tokens,s??x.tokens),w=/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0 gap-4 px-1 pb-1`,children:[i?/* @__PURE__ */ (0,X.jsx)(ME,{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:`${Ja(i.count)} child conversation${i.count===1?``:`s`}`}],total:{cost:h(d),count:m(s),label:`Total`}}):null,b.length?/* @__PURE__ */ (0,X.jsx)(ME,{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,X.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono`,title:t,children:uy(t)}),r?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`shrink-0 text-dashboard-text-muted`,children:/* @__PURE__ */ (0,X.jsx)(Zv,{active:!0,children:`in progress`})}):null]}),parts:AE(n,e,p)}}),total:t.length>1?{cost:h(c?.total),count:m(a?.totalTokens),label:`All models`}:void 0}):null,v?/* @__PURE__ */ (0,X.jsx)(ME,{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,X.jsx)(ME,{countLabel:`Calls`,label:`Auxiliary`,rows:f.map(e=>({cost:p(e.costUsd),count:Ja(e.events),key:`${e.namespace}/${e.name}`,label:by(e)})),total:f.length>1?{cost:p(n.costUsd),count:Ja(f.reduce((e,t)=>e+t.events,0)),label:`All auxiliary`}:void 0}):null,/* @__PURE__ */ (0,X.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?` ${Ja(y)} compaction${y===1?``:`s`}.`:null]})]}),T=[s===void 0?void 0:`${m(s)} tokens`,u?`${Qa(u)}${_?`+`:``}`:_?`$…`:void 0].filter(Boolean).join(` · `);return/* @__PURE__ */ (0,X.jsxs)(yh,{className:`min-w-0 border-t border-dashboard-border-subtle`,children:[/* @__PURE__ */ (0,X.jsx)(`h3`,{className:`m-0`,children:/* @__PURE__ */ (0,X.jsxs)(bh,{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,X.jsx)(H,{"aria-hidden":`true`,className:q(ca,`text-dashboard-text-muted`)}),`Usage`,T?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`ml-auto font-normal tabular-nums text-dashboard-text-muted`,children:/* @__PURE__ */ (0,X.jsx)(Zv,{active:_,children:T})}):null]})}),/* @__PURE__ */ (0,X.jsx)(xh,{hiddenUntilFound:!0,children:w})]})}function FE(e){let{conversation:t,detail:n}=e,r=hh(t),i=NE({conversation:t,detail:n});return/* @__PURE__ */ (0,X.jsx)(xx,{value:e.memoryState,children:/* @__PURE__ */ (0,X.jsx)(kE,{agentTree:n?.agentTree,autoArchive:n?.autoArchive===void 0?null:/* @__PURE__ */ (0,X.jsx)(fE,{autoArchive:n.autoArchive,conversationId:e.conversationId}),brief:n?.brief,conversationId:e.conversationId,highlightReview:e.highlightReview,identity:r.length>0?/* @__PURE__ */ (0,X.jsx)(gh,{participants:r,size:`detail`}):null,onClose:e.onClose,onOpenSubagent:e.onOpenSubagent,onSelectMemory:e.onSelectMemory,links:e.links,overview:Hy({conversation:t,detail:n,showUsageBreakdown:i})?/* @__PURE__ */ (0,X.jsx)(Uy,{conversation:t,detail:n,showUsageBreakdown:i}):null,usage:i?/* @__PURE__ */ (0,X.jsx)(PE,{conversation:t,detail:n}):null})})}const IE=`font-medium text-dashboard-text no-underline underline-offset-2 hover:underline`;function LE(e){return/* @__PURE__ */ (0,X.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,X.jsx)(lr,{"aria-hidden":`true`,size:12,className:`shrink-0`}),e.forkedFromConversationId?/* @__PURE__ */ (0,X.jsxs)(`span`,{children:[`Forked from`,` `,/* @__PURE__ */ (0,X.jsx)(B,{className:IE,to:kc(e.forkedFromConversationId),children:e.forkedFromTitle??`source conversation`})]}):null,e.forkedFromConversationId&&e.forks?.length?/* @__PURE__ */ (0,X.jsx)(`span`,{children:`·`}):null,e.forks?.length?/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-1.5`,children:[`Forks:`,e.forks.map((e,t)=>/* @__PURE__ */ (0,X.jsx)(B,{"aria-label":`Fork ${t+1}`,className:IE,to:kc(e),children:t+1},e))]}):null]})}function RE(e){let t=e.hasChildren?`Also archive its child conversations?`:`Archive for everyone?`;return/* @__PURE__ */ (0,X.jsx)(Xx,{open:!0,onOpenChange:t=>{t||e.onClose()},children:/* @__PURE__ */ (0,X.jsxs)(Zx,{children:[/* @__PURE__ */ (0,X.jsx)(Qx,{children:t}),/* @__PURE__ */ (0,X.jsxs)($x,{children:[`This hides the conversation`,e.hasChildren?` and its child conversations`:``,` for everyone. A new message from a person restores it.`]}),/* @__PURE__ */ (0,X.jsxs)(eS,{children:[/* @__PURE__ */ (0,X.jsx)(nS,{children:`Cancel`}),/* @__PURE__ */ (0,X.jsx)(tS,{onClick:e.onConfirm,children:`Archive`})]})]})})}const zE={base:6,active:14,max:24},BE=(0,Y.createContext)(void 0);function VE(){let e=(0,Y.useContext)(BE);if(!e)throw Error(`useMessageOutline must be used within MessageOutline.`);return e}function HE({activeIndex:e,children:t,className:n,itemCount:r,...i}){let a=(0,Y.useRef)(null),o=(0,Y.useRef)([]),s=(0,Y.useRef)(void 0),[c,l]=(0,Y.useState)(),u=(0,Y.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=YE(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,X.jsx)(BE.Provider,{value:u,children:/* @__PURE__ */ (0,X.jsx)(`nav`,{"data-slot":`message-outline`,className:F(`pointer-events-none flex items-center`,n),...i,children:/* @__PURE__ */ (0,X.jsx)(`div`,{className:`relative flex max-h-full flex-col`,children:t})})})}function UE({className:e,...t}){let{activeIndex:n,listRef:r,movePointer:i,previewIndex:a}=VE();(0,Y.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,Y.useRef)(void 0),s=(e,t)=>{o.current=t;let n=t-e.getBoundingClientRect().top+e.scrollTop;i(n/8-.5)};return/* @__PURE__ */ (0,X.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 WE({className:e,index:t,...n}){let{activeIndex:r,movePointer:i,pointerRef:a,previewIndex:o,registerBar:s}=VE(),c=t===r;return/* @__PURE__ */ (0,X.jsx)(`li`,{"data-slot":`message-outline-item`,children:/* @__PURE__ */ (0,X.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,X.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:YE(JE(t,a.current,c)),width:zE.max}})})})}function GE({className:e,...t}){let{listRef:n,previewIndex:r}=VE();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,X.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,X.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 qE({className:e,...t}){return/* @__PURE__ */ (0,X.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=zE.base+(zE.max-zE.base)*i;return n?Math.max(zE.active,a):a}function YE(e){return`scaleX(${e/zE.max})`}function XE(e){let t=[];for(let n of e){if(n.pending)continue;let e=qT(QE(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 ZE(e,t){if(!e?.items.length)return[...t];let n=/* @__PURE__ */ new Map;for(let t of e.items){let e=qT(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 QE(e){return e.parts.map(e=>e.type===`text`?e.text??``:``).join(`
155
+ `)}function $E(e,t){let n;for(let r of e){if(r.seq>t)break;n=r}return n}const eD=[];function tD(e){let{scrollRef:t}=e,n=(0,Y.useDeferredValue)(e.events,eD),r=nD(e.conversationId).data,i=(0,Y.useMemo)(()=>ZE(r,XE(Ta(n,void 0))),[n,r]),a=iD(i,t),[o,s]=(0,Y.useState)();return(0,Y.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,X.jsxs)(HE,{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,X.jsx)(UE,{children:i.map((t,n)=>/* @__PURE__ */ (0,X.jsx)(WE,{"aria-label":t.title,index:n,onClick:()=>{e.onSelect(t.seq),s(t.seq)}},t.seq))}),/* @__PURE__ */ (0,X.jsx)(rD,{items:i})]})}function nD(e){return I({gcTime:0,queryFn:({signal:t})=>K(di,`/api/conversations/${encodeURIComponent(e)}/outline`,t),queryKey:[`conversation`,e,`outline`],retry:!1,staleTime:1/0})}function rD(e){let{previewIndex:t}=VE(),n=t===void 0?void 0:e.items[t];return n?/* @__PURE__ */ (0,X.jsxs)(GE,{children:[/* @__PURE__ */ (0,X.jsx)(KE,{children:n.title}),n.reply?/* @__PURE__ */ (0,X.jsx)(qE,{children:n.reply}):null]}):null}function iD(e,t){let[n,r]=(0,Y.useState)(),i=(0,Y.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:$E(e,a)?.seq)},[e,t]);return(0,Y.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 aD=new Intl.Segmenter(void 0,{granularity:`word`});function oD(e){if(e.length<6)return!1;let t=0;for(let n of aD.segment(e))if(n.isWordLike&&(t+=1),t>=2)return!0;return!1}function sD(e){return e.split(`
156
+ `).map(e=>e.trim()?`> ${e.trimEnd()}`:`>`).join(`
157
+ `)}const cD=/* @__PURE__ */ new Set([`A`,`B`,`CODE`,`DEL`,`EM`,`I`,`OL`,`S`,`STRONG`,`TABLE`,`TBODY`,`THEAD`,`TR`,`UL`]);function lD(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 gD(r,uD(e,r));let i=e.cloneContents();for(;n&&cD.has(n.tagName);){let e=n.cloneNode(!1);e.appendChild(i),i=e,n=n.parentElement}return dD(i).replace(/\n{3,}/g,`
158
+
159
+ `).trim()}function uD(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 dD(e){if(e.nodeType===Node.TEXT_NODE)return pD(e);if(!(e instanceof Element))return fD(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 hD(`**`,fD(e));case`EM`:case`I`:return hD(`_`,fD(e));case`DEL`:case`S`:return hD(`~~`,fD(e));case`CODE`:return hD("`",e.textContent??``);case`A`:{let t=fD(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 mD(gD(e,e.textContent??``));case`H1`:case`H2`:case`H3`:case`H4`:case`H5`:case`H6`:return mD(`${`#`.repeat(Number(t[1]))} ${fD(e)}`);case`BLOCKQUOTE`:return mD(sD(fD(e).trim()));case`OL`:case`UL`:return mD(_D(e));case`TABLE`:return mD(vD(e));case`HR`:return mD(`---`);case`DIV`:case`LI`:case`P`:return mD(fD(e));default:return fD(e)}}function fD(e){return Array.from(e.childNodes,dD).join(``)}function pD(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 mD(e){return`\n\n${e.trim()}\n\n`}function hD(e,t){let[,n=``,r=``,i=``]=/^(\s*)([\s\S]*?)(\s*)$/.exec(t)??[];return r?`${n}${e}${r}${e}${i}`:t}function gD(e,t){return`\`\`\`${e.closest(`[data-code-language]`)?.dataset.codeLanguage??``}\n${t.replace(/\n$/,``)}\n\`\`\``}function _D(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+fD(n).trim().replace(/\n{2,}/g,`
162
+ `).replace(/\n/g,`\n${` `.repeat(r.length)}`)}).join(`
163
+ `)}function vD(e){let t=Array.from(e.querySelectorAll(`tr`),e=>Array.from(e.children,e=>fD(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 yD=`quick-question`,bD=[`Explain this`,`Is this right?`,`What's the risk?`];function xD(e){typeof CSS<`u`&&`highlights`in CSS&&(e?CSS.highlights.set(yD,new Highlight(e)):CSS.highlights.delete(yD))}function SD(e){let t=window.getSelection();if(!e||!t||t.isCollapsed||!t.rangeCount)return;let n=t.toString().trim().slice(0,4e3).trim();if(!oD(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 CD(e,t){return e.compareBoundaryPoints(Range.START_TO_START,t)===0&&e.compareBoundaryPoints(Range.END_TO_END,t)===0}function wD(e){let{rootRef:t,onAsk:n,onRespond:r}=e,[i,a]=(0,Y.useState)(),o=(0,Y.useRef)(void 0),s=(0,Y.useRef)(!1),c=(0,Y.useCallback)(e=>{o.current=e,a(e)},[]);(0,Y.useEffect)(()=>{let e,n=!1,r=!1,i=()=>{if(s.current)return;window.clearTimeout(e);let r=SD(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=SD(t.current);n?o.current&&CD(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,Y.useRef)(null);if((0,Y.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,X.jsxs)(`div`,{className:q(`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,X.jsx)(V,{className:`h-8 text-dashboard-text`,onClick:()=>u(n),variant:`quiet`,children:`Quick question`}),r?/* @__PURE__ */ (0,X.jsx)(V,{className:`h-8 text-dashboard-text`,onClick:()=>u(({range:e})=>r(sD(lD(e)))),variant:`quiet`,children:`Respond`}):null]}),document.body)}function TD(){let e=P();return N({mutationFn:async e=>{let t=e.forkId??(await $i(Nr,`/api/conversations/${encodeURIComponent(e.sourceConversationId)}/forks`,{idempotencyKey:e.threadKey,messageId:e.messageId,quickQuestion:{quote:e.quote}})).conversationId;return $i(qr,`/api/conversations/${encodeURIComponent(t)}/messages`,{idempotencyKey:e.idempotencyKey,message:e.text})},onSuccess:t=>e.invalidateQueries({queryKey:Z(t.conversationId)})})}function ED(){let e=P();return N({mutationFn:e=>$i(Nr,`/api/conversations/${encodeURIComponent(e)}/quick-question/keep`,{}),onSuccess:()=>e.invalidateQueries({queryKey:[`dashboard`,`conversations`]})})}function DD(e){let[t,n]=(0,Y.useState)(),r=t?.conversationId===e?t:void 0,i=TD(),{mutateAsync:a,reset:o}=i,s=(0,Y.useCallback)(t=>{o(),xD(t.range),n({...t,asked:[],conversationId:e,id:crypto.randomUUID()})},[e,o]),c=(0,Y.useCallback)(()=>{o(),xD(void 0),n(void 0)},[o]);(0,Y.useEffect)(()=>()=>{xD(void 0),n(void 0)},[e]);let l=(0,Y.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 OD(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 kD(e){let{thread:t}=e,n=(0,Y.useRef)(null),r=(0,Y.useRef)(null),i=Jo().data?.me.user,a=i?.name?.trim()||i?.email||`You`,o=_a(),s=I(sd(t.forkId,{fastPollUntilMs:t.askedAtMs&&t.askedAtMs+1e4})).data,c=OD(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,Y.useEffect)(()=>{r.current?.querySelector(`textarea`)?.focus()},[t.id]),(0,Y.useEffect)(()=>{let e=n.current;e&&(e.scrollTop=e.scrollHeight)},[u.length,d]),/* @__PURE__ */ (0,X.jsx)(Qy,{label:`Quick question`,sheetTitle:`Quick question`,onClose:e.onClose,title:/* @__PURE__ */ (0,X.jsx)(`h2`,{className:`m-0 font-sans text-sm font-semibold text-dashboard-text`,children:`Quick question`}),children:/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid h-full min-h-0 grid-rows-[minmax(0,1fr)_auto]`,children:[/* @__PURE__ */ (0,X.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,X.jsx)(`blockquote`,{className:`m-0 border-l-2 border-dashboard-accent pl-2.5 text-sm text-dashboard-text-muted`,children:/* @__PURE__ */ (0,X.jsx)(xb,{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,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:bD.map(t=>/* @__PURE__ */ (0,X.jsx)(V,{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,X.jsxs)(cC,{actor:e.role===`user`?a:o,avatarUrl:e.role===`user`?i?.avatarUrl:void 0,role:e.role,children:[/* @__PURE__ */ (0,X.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,X.jsx)($,{chat:!0,text:e.text})]},t)),d?/* @__PURE__ */ (0,X.jsxs)(cC,{actor:o,role:`assistant`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`text-sm font-semibold text-dashboard-accent-text`,children:o}),/* @__PURE__ */ (0,X.jsx)(Zv,{active:!0,className:`text-sm text-dashboard-text-muted`,children:`Thinking…`})]}):null]}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid gap-1.5 px-3 pt-2 pb-2`,ref:r,children:[/* @__PURE__ */ (0,X.jsx)(Tv,{compact:!0,disabled:d,draftId:`quick-question:${e.conversationId}`,error:e.error?e.error instanceof na&&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,X.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2 pl-1 text-xs text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:`Closing discards this question.`}),/* @__PURE__ */ (0,X.jsx)(AD,{disabled:d,forkId:t.forkId},t.id)]})]})]})})}function AD(e){let t=_e(),n=ED(),r=e.forkId;return/* @__PURE__ */ (0,X.jsxs)(V,{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,X.jsx)(lr,{"aria-hidden":`true`,size:13}),n.isError?`Retry keep`:`Keep as fork`]})}function jD(){return/* @__PURE__ */ (0,X.jsxs)(ex,{"aria-busy":`true`,"aria-live":`polite`,role:`status`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`sr-only`,children:`Loading conversation transcript`}),/* @__PURE__ */ (0,X.jsx)(MD,{width:`w-3/4`}),/* @__PURE__ */ (0,X.jsx)(ix,{indent:!0,children:/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid gap-2 py-1`,children:[/* @__PURE__ */ (0,X.jsx)(J,{className:`h-3 w-36 opacity-70`}),/* @__PURE__ */ (0,X.jsx)(J,{className:`h-3 w-1/2`})]})}),/* @__PURE__ */ (0,X.jsx)(MD,{width:`w-1/2`}),/* @__PURE__ */ (0,X.jsx)(MD,{width:`w-2/3`})]})}function MD(e){return/* @__PURE__ */ (0,X.jsx)(ix,{children:/* @__PURE__ */ (0,X.jsxs)(`div`,{className:q(`grid`,Qb),children:[/* @__PURE__ */ (0,X.jsx)(J,{className:q(`rounded-full`,$b)}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid gap-2 pt-1`,children:[/* @__PURE__ */ (0,X.jsx)(`div`,{className:`flex h-6 items-center`,children:/* @__PURE__ */ (0,X.jsx)(J,{className:`h-3 w-24 opacity-70`})}),/* @__PURE__ */ (0,X.jsx)(J,{className:`h-4 max-w-xl ${e.width}`}),/* @__PURE__ */ (0,X.jsx)(J,{className:`h-4 w-1/2 max-w-lg`})]})]})})}function ND(e){let{conversationId:t,detail:n,onShowLatest:r,onStartFailed:i,start:a}=e,o=a?Object.entries(a)[0]?.join(`:`):void 0,s=(0,Y.useRef)([]),c=(0,Y.useMemo)(()=>{let e=PD(s.current,n?.events);return s.current=e,e},[n?.events]),l=c[0]?.seq,u=(0,Y.useRef)(void 0),d=O({enabled:!!a,staleTime:1/0,gcTime:0,queryKey:[`conversation`,t,`around`,o,`newer`],queryFn:({pageParam:e,signal:n})=>ID(t,e,n),initialPageParam:a??{around:``},...e.startPage&&a?{initialData:{pageParams:[a],pages:[e.startPage]}}:void 0,getNextPageParam:e=>FD(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})=>bd(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?FD(g,l):!1;_&&(u.current=o);let v=g!==void 0&&!_&&(u.current===o||!g.nextCursor);(0,Y.useEffect)(()=>{v&&r()},[r,v]);let y=!!(a&&d.error&&!m);(0,Y.useEffect)(()=>{y&&i?.()},[i,y]);let b=(0,Y.useMemo)(()=>[...h??[],...m??[]],[h,m]),x=(0,Y.useMemo)(()=>n&&m?Lu(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:zu(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 PD(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 FD(e,t){let n=e.events.at(-1)?.seq;return n===void 0||t===void 0?!e.nextCursor:n+1>=t}function ID(e,t,n){let r=new URLSearchParams(t);return K(Ii,`/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 LD(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 RD(e){return e.target?/* @__PURE__ */ (0,X.jsx)(zD,{onClose:e.onClose,target:e.target},e.target.conversationId):null}function zD(e){let t=gd(e.target.conversationId),[n,r]=(0,Y.useState)(`rich`),[i,a]=(0,Y.useState)(``),o=Th(i),[s,c]=(0,Y.useState)(!1),l=t.data,u=e.target.label??Ga(l)??(l?.kind===`thread`?`Thread`:`Task`),d=BD(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,Y.useRef)(null);(0,Y.useEffect)(()=>{m&&h.current?.focus()},[m]);let g=()=>{c(!1),i.length>0&&a(``)},_=`subagent-transcript-drawer-title`;return/* @__PURE__ */ (0,X.jsx)(k_,{actions:/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[n===`rich`?/* @__PURE__ */ (0,X.jsx)(zv,{inputRef:h,onClick:()=>{m?g():c(!0)},open:m}):null,/* @__PURE__ */ (0,X.jsx)(Iv,{onChange:r,value:n}),/* @__PURE__ */ (0,X.jsx)(Zf,{label:`Copy as Markdown`,copyingLabel:`Preparing Markdown`,getText:l?async()=>Tf(await t.loadCompleteTranscript()):void 0},e.target.conversationId)]}),closeLabel:`Close transcript`,flush:n===`raw`,header:/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[/* @__PURE__ */ (0,X.jsx)(gn,{"aria-hidden":`true`,className:`shrink-0 text-cyan-300`,size:16,strokeWidth:2}),/* @__PURE__ */ (0,X.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,X.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,X.jsx)(`span`,{className:`font-medium text-dashboard-text`,children:f}):null,d?/* @__PURE__ */ (0,X.jsx)(Np,{size:`compact`,tone:Pb(d),children:d}):null,l&&p!==void 0?/* @__PURE__ */ (0,X.jsxs)(`time`,{className:`tabular-nums`,dateTime:l.startedAt,title:Wa(p,!0),children:[`Started `,ro(p)]}):null,/* @__PURE__ */ (0,X.jsxs)(B,{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,X.jsx)(Ln,{"aria-hidden":`true`,size:12,strokeWidth:2})]})]}),/* @__PURE__ */ (0,X.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,X.jsx)(Yv,{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,X.jsx)(jD,{}):t.error&&!l?/* @__PURE__ */ (0,X.jsxs)(oa,{className:`gap-1 px-4 py-3 has-[>svg]:gap-x-3`,variant:`destructive`,children:[/* @__PURE__ */ (0,X.jsx)(qn,{"aria-hidden":`true`}),/* @__PURE__ */ (0,X.jsx)(aa,{className:`font-display text-base font-semibold leading-tight`,children:`Conversation failed to load.`}),/* @__PURE__ */ (0,X.jsx)(ia,{className:`leading-relaxed`,children:`Junior could not get this child conversation. Use Open conversation to view it on its own page.`})]}):l?/* @__PURE__ */ (0,X.jsx)(tT,{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,X.jsx)(Lm,{children:`Conversation unavailable.`})})}function BD(e,t){return e&&e!==`running`&&e!==`completed`?e:t??e}function VD(e){let t=hb(),n=(0,Y.useRef)(null),r=(0,Y.useRef)(null),i=(0,Y.useRef)(null),a=(0,Y.useRef)(!1),[o,s]=(0,Y.useState)(),[c,l]=De(),u=Ic(c.get(Fc)),d=c.get(`turn`)??void 0,f=u!==void 0||d!==void 0,[p,m]=(0,Y.useState)(()=>!f&&void 0),h=c.get(Lc)===Rc;(0,Y.useEffect)(()=>{h&&m(!0)},[h]);let g=Zy(),[_]=(0,Y.useState)(ob),v=p??(h||(_===void 0?t:_&&g)),y=(0,Y.useCallback)(()=>{m(!1),sb(!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,Y.useState)(),[S,C]=(0,Y.useState)(),[w,T]=(0,Y.useState)(),[E,D]=(0,Y.useState)(),[O,k]=(0,Y.useState)(),[A,j]=(0,Y.useState)(e.conversationId);A!==e.conversationId&&(j(e.conversationId),C(void 0),T(void 0),D(void 0),k(void 0));let M=DD(e.conversationId),ee=!!M.thread&&!f&&!b,N=v&&!f&&!b&&!M.thread;(0,Y.useLayoutEffect)(()=>{N&&a.current&&(a.current=!1,n.current?.querySelector(`[data-slot="details-panel-close"]`)?.focus({preventScroll:!0}))},[N]);let P=xe(),te=Nc(P.state),[F,ne]=(0,Y.useState)(()=>f||te?`raw`:`rich`),[re,ie]=(0,Y.useState)(P.key);te&&re!==P.key&&(ie(P.key),ne(`raw`));let ae=f?`raw`:F,[I,oe]=(0,Y.useState)(``),se=Th(I),[ce,le]=(0,Y.useState)(!1),[ue,de]=(0,Y.useState)(0),L=e.conversationId,fe=e.data?.conversations.conversations??[],pe=$a(fe),me=_u().has(L),[he]=(0,Y.useState)(()=>hm()===`unread`),[ge,ve]=(0,Y.useState)(()=>u!==void 0||d!==void 0),R=e.detail,[ye,be]=(0,Y.useState)(!1),z=he&&!ye&&!ge,[B,Se]=(0,Y.useState)(()=>d===void 0?u===void 0?void 0:LD(R.data?.events,{event:u}):LD(R.data?.events,{turn:d})),Ce=(0,Y.useCallback)(()=>{be(!0),Se(void 0)},[]),we=_x(L).data,Te=(0,Y.useMemo)(()=>({list:we,open:S,setOpen:C}),[we,S]),Ee=Md(L),[Oe,ke]=(0,Y.useState)(!1),Ae=_e(),je=e=>{Ee.mutate({archived:e,lastSeenAt:$e.lastSeenAt}),e&&Ae(`/`,{state:{archivedConversation:$e}})},Me=Hd(L),Ne=ef(L),Pe=$d(L),Fe=Vd(L),Ie=Ud(L),[Le,Re]=(0,Y.useState)(!1),ze=ym(L),[Be,Ve]=(0,Y.useState)(!1),He=(0,Y.useCallback)(()=>Ve(!0),[]),Ue=gm(R.data,R.fetchedDetail),We=(0,Y.useCallback)(()=>{Se(void 0),ve(!1),T(void 0),l(e=>{let t=new URLSearchParams(e);return t.delete(Fc),t.delete(zc),t},{replace:!0})},[l]),Ge=z?Ue.unreadCursor:void 0,Ke=ND({conversationId:L,detail:R.latest,onShowLatest:Ce,...B?{onStartFailed:We,start:B}:Ge?{start:{around:Ge},...Ue.unreadPage?{startPage:Ue.unreadPage}:void 0}:void 0}),qe=(0,Y.useRef)(R.data),Je=!!(qe.current&&(Ke?.isPending||z&&!B&&!R.fetchedAtOpen)),Ye=R.isPending||!(!Ke?.isPending||qe.current),Xe=Je?{...R,data:qe.current,hasPreviousPage:!1,isLoadingPreviousPage:!1,loadPreviousPage:()=>{}}:Ke??R;Xe.data&&(qe.current=Xe.data);let Ze=Kb({conversationId:L,events:Xe.data?.events,hasNewerPage:!!Xe.newer,hasPreviousPage:Xe.hasPreviousPage,unread:Je?void 0:Ue.unread}),Qe=pe.find(e=>e.id===L),$e=Fd(Za(R.data)??Qe,e.pendingArchiveUpdate),et=R.data,tt=Qg(et),nt=Ga(R.data)??za($e);ga(R.data||$e?nt:void 0);let rt=ae===`rich`&&(R.data?.isParticipant||R.data?.visibility===`public`)&&R.data.kind!==`task`,[it,at]=(0,Y.useState)(),ot=jc(P.state),st=ot&&P.key!==it?{draftFrom:ot.draftFrom,key:P.key}:void 0,ct=Xe.data,lt=!Ye&&!!ct;(0,Y.useEffect)(()=>{lt&&Yi()},[L,lt]);let ut=ct?.eventHistory.status===`available`?ct.events:void 0,dt=e=>{oe(``),D(e);let t=LD(Xe.data?.events,{event:e});t&&Se(t)},ft=ct?.eventHistory.status===`expired`?void 0:ct?.events.find(e=>e.seq===u),pt=HD($e?Ea($e):void 0,R.data),mt=(0,Y.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]),ht=(0,Y.useCallback)(e=>{e!==`raw`&&f&&mt(void 0),x(void 0),ne(e)},[f,mt]);uo(ae===`raw`?`Back to conversation`:void 0,()=>ht(`rich`));let gt=(0,Y.useEffectEvent)(e=>{let t=LD(Xe.data?.events,e);return t&&Se(t),!!t}),_t=(0,Y.useCallback)((e,t)=>k(n=>({arrived:t,itemId:e.id,turnId:e.addedByConversationId===L?e.addedByTurnId:void 0,version:(n?.version??0)+1})),[L]),vt=(0,Y.useEffectEvent)((e,t)=>{Xe.data?.events.some(t=>t.data.type===`tool_calls`&&t.data.calls.some(t=>yS(t)===e))||gt({turn:t})});(0,Y.useEffect)(()=>{O?.turnId&&!O.arrived&&vt(O.itemId,O.turnId)},[O]),(0,Y.useEffect)(()=>{d===void 0?u!==void 0&&gt({event:u}):gt({turn:d})},[d,u]);let yt=d?Bc(ct?.events,d):void 0;(0,Y.useEffect)(()=>{yt!==void 0&&mt(yt)},[yt,mt]),(0,Y.useEffect)(()=>{if(!w||!ct)return;let e=n.current?.querySelector(`[data-memory-anchor="${CSS.escape(vx(w))}"]`);e?(e.scrollIntoView({block:`center`}),C(w),T(void 0)):!Je&&!gt({event:w.seq})&&T(void 0)},[Je,w,ct,ae]);let bt=!!ft||f&&!ft&&(Ye||Je||d!==void 0),xt=ct?.events,St=I.trim().toLowerCase(),Ct=(0,Y.useMemo)(()=>f&&xt?Nw(Mw(xt),St):[],[f,xt,St]),wt=(0,Y.useMemo)(()=>({openId:b?.id,onToggle:e=>x(t=>t?.id===e.id?void 0:e)}),[b?.id]),Tt=(0,Y.useCallback)(()=>{Ce(),de(e=>e+1)},[Ce]),V=(0,Y.useCallback)(({part:e})=>{s({...e.agentName?{agentName:e.agentName}:void 0,conversationId:e.childConversationId,label:e.title??e.agentName,status:e.status})},[]),Et=()=>{let e=n.current?.querySelector(`[data-event-seq="${u}"] button`);mt(void 0),e?.focus({preventScroll:!0})},Dt=()=>{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})},Ot=/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[N?/* @__PURE__ */ (0,X.jsx)(FE,{conversation:$e,conversationId:L,detail:et,highlightReview:h,links:tt,memoryState:Te,onClose:y,onOpenSubagent:s,onSelectMemory:e=>{ae!==`rich`&&ht(`rich`),oe(``),D(e.seq),T({memoryId:e.memory.id,seq:e.seq,source:e.source,turnId:e.turnId})}}):null,bt?/* @__PURE__ */ (0,X.jsx)(qw,{conversation:ct,event:ft,onClose:Et,onSelect:mt,...Pw(Ct,u)}):null,b?/* @__PURE__ */ (0,X.jsx)(Ch,{query:I,children:/* @__PURE__ */ (0,X.jsx)(kC,{actor:b.actor,contexts:b.contexts,onClose:Dt,timestamp:b.timestamp},b.id)}):null,ee&&M.thread?/* @__PURE__ */ (0,X.jsx)(kD,{conversationId:L,error:M.error,onClose:M.close,onSubmit:M.submit,pending:M.pending,thread:M.thread}):null]});return/* @__PURE__ */ (0,X.jsxs)(`div`,{ref:n,className:`grid h-full min-h-0 min-w-0 grid-rows-[minmax(0,1fr)]`,children:[/* @__PURE__ */ (0,X.jsx)(yb,{side:N||bt||b||ee?Ot:void 0,children:/* @__PURE__ */ (0,X.jsx)(Uv,{header:/* @__PURE__ */ (0,X.jsx)(Xv,{agentTree:et?.agentTree,contextTags:c_($e),cost:Gy($e,et,`below`),detailsOpen:N,errors:[Ee.error?Ee.error instanceof na&&Ee.error.apiError||`Could not update archive state.`:``,Me.error?`Could not update pin.`:``,Fe.error?`Could not update read state.`:``,Ie.error?`Could not rename.`:``,Ne.error?`Could not update subscription.`:``,Pe.error?`Could not change Slack updates.`:``].filter(Boolean),onDetailsClick:()=>{f&&mt(void 0),x(void 0),M.close(),N?y():(a.current=!0,m(!0),sb(!0))},forks:R.data?.forkedFromConversationId||R.data?.forks?.length?/* @__PURE__ */ (0,X.jsx)(LE,{forkedFromConversationId:R.data.forkedFromConversationId,forkedFromTitle:R.data.forkedFromTitle,forks:R.data.forks}):null,linkedWork:tt.length?/* @__PURE__ */ (0,X.jsx)(Ry,{links:tt}):null,menu:{actions:{archive:()=>{$e?.archivedAt?je(!1):$e.parentConversationId?ke(!0):je(!0)},continueInSlack:()=>le(!0),delivery:e=>Pe.mutate(e),eventLog:()=>ht(ae===`raw`?`rich`:`raw`),pin:e=>Me.mutate(e),read:e=>Fe.mutate(e),rename:()=>Re(!0),subscription:e=>Ne.mutate(e)},conversation:$e,conversationId:L,detail:et,eventLogOpen:ae===`raw`,getMarkdown:et?async()=>Tf(await R.loadCompleteTranscript(),$e):void 0,pending:{archive:Ee.isPending,delivery:Pe.isPending,pin:Me.isPending,read:Fe.isPending,subscription:Ne.isPending}},onSearchChange:oe,onViewChange:ht,privacy:/* @__PURE__ */ (0,X.jsx)(Oy,{visibility:$e?.visibility}),search:I,searchMatch:se,sidebarToggle:e.sidebarToggle,status:Qu(et)&&$e?/* @__PURE__ */ (0,X.jsx)(Rp,{status:Pp($e,me)}):null,title:nt,view:ae}),overlay:ae===`rich`&&!Ye&&ut?/* @__PURE__ */ (0,X.jsx)(tD,{conversationId:L,events:ut,onSelect:dt,scrollRef:i}):void 0,scrollMinTall:!0,scrollAriaLabel:`Conversation transcript`,scrollRef:i,scrollClassName:ae===`raw`?`thin-scrollbar`:Vv,scroll:/* @__PURE__ */ (0,X.jsx)(Hv,{full:ae===`raw`,children:Ye?ae===`raw`?/* @__PURE__ */ (0,X.jsx)($w,{}):/* @__PURE__ */ (0,X.jsx)(jD,{}):R.error&&!R.data?/* @__PURE__ */ (0,X.jsx)(fa,{className:`border-dashboard-border bg-dashboard-fill-soft p-4 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:R.error.message}):/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[R.error?/* @__PURE__ */ (0,X.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,X.jsx)(xx,{value:Te,children:/* @__PURE__ */ (0,X.jsx)(qb,{value:Ze,children:/* @__PURE__ */ (0,X.jsx)(tT,{hasPreviousPage:Xe.hasPreviousPage,historyError:Xe.historyError,historyVersion:Xe.historyVersion,lastReadSeq:R.data?.readPosition?.lastReadSeq,live:pt,loadingPreviousPage:Xe.isLoadingPreviousPage,newerHistory:Xe.newer,onLoadPreviousPage:Xe.loadPreviousPage,onRead:Je?void 0:ze,readEngaged:Be,onSelectedEventSeqChange:mt,pendingMessages:Xe.newer?void 0:R.inlineMessages,pinRequestVersion:ue,revealAsk:O,revealSeq:E,responding:!R.error&&!Xe.newer&&Zu(R.data),onOpenSubagentTranscript:V,search:I,onSearchChange:oe,searchMatch:se.index,onSearchMatches:se.setMatches,selectedEventSeq:u,startAtLink:ge,startAtUnread:he,transcript:ct,turnContextPanel:wt,unread:Je?void 0:Ue.unread,view:ae})})})]})}),dock:rt?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`contents`,onFocusCapture:He,onPointerDownCapture:He,children:/* @__PURE__ */ (0,X.jsx)(cE,{conversationId:L,detail:R,focusRequest:st,hasNewerPage:!!Xe.newer,live:pt,onFocusRequestDone:at,onPinRequest:Tt,onShowQuestion:_t,ref:r})}):void 0})}),Oe?/* @__PURE__ */ (0,X.jsx)(RE,{hasChildren:!!R.data?.childAgentTotals?.count,onClose:()=>ke(!1),onConfirm:()=>{ke(!1),je(!0)}}):null,/* @__PURE__ */ (0,X.jsx)(wD,{onAsk:e=>{f&&mt(void 0),x(void 0),M.open(e)},onRespond:rt?e=>r.current?.appendText(e):void 0,rootRef:n}),/* @__PURE__ */ (0,X.jsx)(RD,{onClose:()=>s(void 0),target:o}),Le?/* @__PURE__ */ (0,X.jsx)(Qd,{onClose:()=>Re(!1),onSave:e=>Ie.mutate(e),title:nt}):null,ce?/* @__PURE__ */ (0,X.jsx)(rf,{conversationId:L,onClose:()=>le(!1)}):null]})}function HD(e,t){return t?t.status===`active`:e===`active`}const UD=`conversation-list`;function WD(e){let[t,n]=(0,Y.useState)(20),[r,i]=(0,Y.useState)(``),[a,o]=ab(),{showArchiveError:s,showArchived:c}=Bd();jd(c,s);let l=pb(),u=(0,Y.useRef)(null),d=(0,Y.useRef)(null),f=(0,Y.useId)(),p=Vc(r.trim()),m=l?``:p,h=L(),g=_e(),_=ge(),v=h.conversationId,y=!v,b=Zo(m),x=kd(),S=Ho(),C=ld(),w=BT(),[T,E]=(0,Y.useState)();!y&&T&&E(void 0);let D=P(),O=(0,Y.useRef)(null),k=(0,Y.useRef)(!1),A=(0,Y.useMemo)(()=>KD($a(b.data?.conversations??[]),x,!!m),[b.data?.conversations,x,m]),j=()=>{C.reset(),v?(k.current=!0,g(`/`)):O.current?.focus()},M=(0,Y.useMemo)(()=>Wv(A),[A]),ee=_u(),N=(0,Y.useMemo)(()=>vc(A,ee),[A,ee]),te=(0,Y.useMemo)(()=>N.slice(0,t),[N,t]),F=N.length-te.length,ne=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{n(20),ne.current?.scrollTo({top:0})},[m]);let re=im({edge:`bottom`,enabled:F>0,historyVersion:String(t),onLoad:()=>n(e=>e+20)}),ie=(0,Y.useRef)(void 0),ae=(0,Y.useRef)(v);ae.current=v,(0,Y.useEffect)(()=>{if(!y)return;let e=new AbortController;return ie.current=e.signal,()=>e.abort()},[y]);let I=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{if(!y)return;let e=(I.current||_===be.Push)&&!k.current;I.current=!0,k.current=!1,!(e&&Cv())&&O.current?.focus()},[y,_]);let oe=/* @__PURE__ */ (0,X.jsx)(GD,{composerRef:O,docked:!l,error:C.error?`Message failed to send. Try again.`:void 0,onSubmit:async(e,t,n,r)=>{let i=ie.current,a=lT(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)),Mv(a),e}await xm(D,o.conversationId);let s=i?.aborted;s&&ae.current!==o.conversationId?jv(o.conversationId,Mv(a)):(await g(kc(o.conversationId),{flushSync:!0,replace:s,state:{...Ac,draftFrom:a}}),w())}}),se=/* @__PURE__ */ (0,X.jsx)(Rv,{controls:f,expanded:a,label:a?`Hide conversation list`:`Show conversation list`,onClick:()=>{let e=u.current;e&&(e.isCollapsed()?e.resize(cb()):e.collapse())},children:/* @__PURE__ */ (0,X.jsx)($t,{"aria-hidden":`true`,size:15,strokeWidth:2})}),ce=/* @__PURE__ */ (0,X.jsxs)(`main`,{className:q(`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,X.jsx)(`div`,{className:`flex h-13 items-center px-1`,children:se}):/* @__PURE__ */ (0,X.jsx)(`div`,{className:`min-h-0 overflow-y-auto overscroll-contain px-4 pb-3 sm:px-6`,ref:ne,children:/* @__PURE__ */ (0,X.jsxs)(`section`,{"aria-label":`Conversations`,className:`grid gap-3 pt-4`,children:[/* @__PURE__ */ (0,X.jsx)(nh,{className:`w-full sm:ml-auto sm:w-72`,label:`Search your conversations`,onChange:i,placeholder:`Search conversations…`,value:r}),/* @__PURE__ */ (0,X.jsx)(l_,{conversations:te,emptyLabel:b.error?.message,loading:b.isPending,onReorderPins:m||A.filter(e=>e.pinnedAt).length>t?void 0:S,timeZone:Fa(),waitingConversations:ee}),F>0?/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`py-2 text-center font-sans text-xs text-dashboard-text-muted`,ref:re,role:`status`,children:[`Loading `,Math.min(F,20),` more…`]}):null]})}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:l?`grid min-h-0 place-items-center overflow-y-auto overscroll-contain px-6 pb-13`:q(sh,`overflow-y-auto border-t border-dashboard-border-subtle sm:px-6`),children:oe})]});return/* @__PURE__ */ (0,X.jsxs)(ih,{className:`min-h-0 overflow-hidden bg-dashboard-bg`,elementRef:d,onLayoutChanged:e=>{let t=e[UD]??0,n=d.current?.offsetWidth??0;t>0&&lb(t/100*n)},children:[l?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(ah,{collapsible:!0,defaultSize:a?cb():0,groupResizeBehavior:`preserve-pixel-size`,id:UD,maxSize:rb.max,minSize:rb.min,onResize:e=>{let t=e.inPixels>0;t!==a&&o(t)},panelRef:u,children:/* @__PURE__ */ (0,X.jsx)(`div`,{className:q(`h-full min-h-0 overflow-hidden`,!a&&`hidden`),id:f,children:/* @__PURE__ */ (0,X.jsx)(Vm,{conversations:A,error:b.error?.message,loading:b.isPending,onNewConversation:j,onReorderPins:S,selectedId:v,timeZone:Fa(),waitingConversations:ee})})}),/* @__PURE__ */ (0,X.jsx)(oh,{"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,X.jsxs)(ah,{id:`selected-conversation`,children:[y?ce:null,v||T?/* @__PURE__ */ (0,X.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,X.jsx)(iS,{conversationId:v,children:/* @__PURE__ */ (0,X.jsx)(Gv,{value:M,children:/* @__PURE__ */ (0,X.jsx)(VD,{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,X.jsx)(uT,{pending:T,sidebarToggle:se}):null}):null]})]})}function GD(e){let[t,n]=(0,Y.useState)(`public`);return/* @__PURE__ */ (0,X.jsxs)(`section`,{"aria-label":`New conversation`,className:`mx-auto grid w-full max-w-3xl gap-3`,children:[/* @__PURE__ */ (0,X.jsx)(`h2`,{className:q(`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,X.jsx)(Tv,{draftId:`new`,error:e.error,footerStart:/* @__PURE__ */ (0,X.jsxs)(ya,{"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,X.jsxs)(ma,{className:`min-w-20 gap-1.5`,value:`public`,children:[/* @__PURE__ */ (0,X.jsx)(Zn,{"aria-hidden":`true`,className:`size-3`}),`Public`]}),/* @__PURE__ */ (0,X.jsxs)(ma,{className:`min-w-20 gap-1.5`,value:`private`,children:[/* @__PURE__ */ (0,X.jsx)(Gt,{"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?$a([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:Id(i,e=>a.has(e.id))}function qD(e){let[t]=ab();return/* @__PURE__ */ (0,X.jsxs)(`div`,{"aria-busy":`true`,"aria-live":`polite`,className:q(da,`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":`${cb()}px`},children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`sr-only`,children:e.detail?`Loading conversation`:`Loading conversations`}),t?/* @__PURE__ */ (0,X.jsx)(JD,{}):null,e.detail?/* @__PURE__ */ (0,X.jsx)(XD,{}):/* @__PURE__ */ (0,X.jsx)(YD,{})]})}function JD(){return/* @__PURE__ */ (0,X.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,X.jsx)(`div`,{className:`px-3 pb-1.5 pt-2.5`,children:/* @__PURE__ */ (0,X.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,X.jsx)(J,{className:`size-[1.125rem] justify-self-center rounded-md`}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`flex h-[1lh] items-center`,children:/* @__PURE__ */ (0,X.jsx)(J,{className:`h-3 w-28`})})]})}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`min-h-0 overflow-hidden px-3`,children:/* @__PURE__ */ (0,X.jsx)(Wm,{})})]})}function YD(){return/* @__PURE__ */ (0,X.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,X.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,X.jsx)(J,{className:`h-9 w-full rounded-lg border border-dashboard-border bg-dashboard-overlay-soft sm:ml-auto sm:w-72`}),/* @__PURE__ */ (0,X.jsx)(u_,{})]}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:q(sh,`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,X.jsxs)(`section`,{className:`mx-auto grid w-full max-w-3xl gap-3`,children:[/* @__PURE__ */ (0,X.jsx)(J,{className:`mx-auto hidden h-8 w-56 md:block`}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`w-full rounded-xl border border-dashboard-border-subtle bg-dashboard-surface-raised p-3`,children:[/* @__PURE__ */ (0,X.jsx)(J,{className:`h-20 w-full bg-dashboard-fill-faint`}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`mt-3 flex justify-between`,children:[/* @__PURE__ */ (0,X.jsx)(J,{className:`h-7 w-32`}),/* @__PURE__ */ (0,X.jsx)(J,{className:`size-8 rounded-md`})]})]})]})})]})}function XD(){return/* @__PURE__ */ (0,X.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,X.jsx)(Uv,{scrollAriaLabel:`Conversation transcript`,scrollClassName:`thin-scrollbar px-4 pb-4 md:px-7 md:pb-6`,scroll:/* @__PURE__ */ (0,X.jsxs)(`section`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`mb-4 grid gap-3 border-b border-dashboard-border-subtle py-4`,children:[/* @__PURE__ */ (0,X.jsx)(J,{className:`h-6 w-2/3 max-w-lg`}),/* @__PURE__ */ (0,X.jsx)(J,{className:`h-3 w-1/3 max-w-56 opacity-70`})]}),/* @__PURE__ */ (0,X.jsx)(`div`,{"aria-hidden":`true`,className:`mx-auto w-full max-w-[52.5rem]`,children:/* @__PURE__ */ (0,X.jsx)(jD,{})})]})})})}const ZD=[`overview`,`conversations`,`changes`];function QD(e,t=`overview`){let n=`/code/${encodeURIComponent(e)}`;return t===`overview`?n:`${n}/${t}`}const $D=`m-0 font-display text-xl font-medium tracking-[-0.02em] text-dashboard-text`;function eO(e){return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:e.className,children:[e.anchor?/* @__PURE__ */ (0,X.jsx)(So,{anchor:e.anchor,className:$D,title:e.title}):/* @__PURE__ */ (0,X.jsx)(`h2`,{className:$D,children:e.title}),e.description?/* @__PURE__ */ (0,X.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 tO=[{end:!0,label:`General`,to:`/settings`},{label:`API Tokens`,to:`/settings/api-tokens`},{label:`Identities`,to:`/settings/connections`},{label:`MCP`,to:`/settings/mcp`}];function nO(e){return/* @__PURE__ */ (0,X.jsx)(xo,{children:/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid w-full max-w-3xl min-w-0 gap-8`,children:[/* @__PURE__ */ (0,X.jsx)(va,{documentTitle:e.title,navigation:/* @__PURE__ */ (0,X.jsx)(To,{ariaLabel:`Settings navigation`,items:tO}),title:`Settings`}),/* @__PURE__ */ (0,X.jsxs)(`section`,{className:`grid min-w-0 gap-5`,children:[/* @__PURE__ */ (0,X.jsx)(eO,{description:e.description,title:e.title}),e.children]})]})})}function rO(e){return/* @__PURE__ */ (0,X.jsxs)(xo,{children:[/* @__PURE__ */ (0,X.jsx)(va,{description:e.description,title:e.title}),/* @__PURE__ */ (0,X.jsx)(pa,{label:e.label,variant:e.variant})]})}const iO=`/system/plugins`;function aO(e){let t=new Map(e.plugins.map(e=>[e.name,{...e,reports:[],skills:[]}]));for(let n of e.skills){let e=n.pluginProvider?t.get(n.pluginProvider):void 0;e&&e.skills.push(n)}for(let n of e.reports){let e=t.get(n.pluginName);e||(e={configKeys:[],description:`Core operational report.`,displayName:n.title?.trim()||n.pluginName,name:n.pluginName,reports:[],skills:[]},t.set(n.pluginName,e)),e.reports.push(n)}return[...t.values()].map(e=>({...e,reports:[...e.reports],skills:[...e.skills].sort((e,t)=>e.name.localeCompare(t.name))})).sort((e,t)=>e.displayName.localeCompare(t.displayName))}function oO(e){return`${iO}/${encodeURIComponent(e)}`}function sO(e){return e.replace(/\/+$/,``)||`/`}const cO=[{end:!0,label:`Overview`,to:`/system`},{label:`People`,to:`/system/people`},{label:`Locations`,to:`/system/locations`},{label:`Workspaces`,to:`/system/workspaces`},{label:`Plugins`,to:iO}];function lO(e){if(R(`/system/workspaces`,e))return!0;let t=R(`/system/workspaces/:workspaceId`,e);return!!(t&&t.params.workspaceId!==`new`)}function uO(e){return/* @__PURE__ */ (0,X.jsx)(yo,{ariaLabel:`System navigation`,className:e.className,items:cO,children:e.children})}function dO(e){return/* @__PURE__ */ (0,X.jsx)(uO,{children:/* @__PURE__ */ (0,X.jsx)(xo,{children:e.children})})}function fO(e){return/* @__PURE__ */ (0,X.jsx)(uO,{children:/* @__PURE__ */ (0,X.jsx)(rO,{...e})})}const pO=`/memories`,mO=`${pO}/library`,hO=/* @__PURE__ */ new Set([`library`]);function gO(e){if(e===mO||e.startsWith(`${mO}/`))return!0;let t=e.match(/^\/memories\/([^/]+)$/);return!(!t?.[1]||hO.has(t[1]))}function _O(e){let t=gO(xe().pathname);return/* @__PURE__ */ (0,X.jsx)(yo,{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:pO},{isActive:gO,label:`Memories`,to:mO}],children:t?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`min-h-0`,children:e.children}):/* @__PURE__ */ (0,X.jsx)(xo,{className:`gap-6 sm:gap-8`,children:e.children})})}function vO(e){let t=gO(xe().pathname),n=/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(va,{description:e.description??`Personal and public memories Junior can use across conversations.`,title:e.title??`Memories`}),/* @__PURE__ */ (0,X.jsx)(pa,{label:e.label,variant:t?`library`:`overview`})]});return/* @__PURE__ */ (0,X.jsx)(_O,{children:t?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`h-full overflow-y-auto`,children:/* @__PURE__ */ (0,X.jsx)(xo,{className:`gap-6 sm:gap-8`,children:n})}):n})}function yO(e){return!!R(`/automations/runs`,e)||!!R(`/automations/:automationId/runs`,e)}const bO=[{end:!0,label:`Automations`,to:`/automations`},{label:`Runs`,to:`/automations/runs`}];function xO(e){return/* @__PURE__ */ (0,X.jsx)(yo,{ariaLabel:`Automations navigation`,className:e.className,items:bO,children:e.children})}function SO(e){let t=yO(xe().pathname);return/* @__PURE__ */ (0,X.jsx)(xO,{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,X.jsx)(`div`,{className:`min-h-0`,children:e.children}):/* @__PURE__ */ (0,X.jsx)(xo,{children:e.children})})}function CO(e){let t=yO(xe().pathname),n=/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(va,{description:e.description,title:e.title}),/* @__PURE__ */ (0,X.jsx)(pa,{label:e.label,variant:`list`})]});return t?/* @__PURE__ */ (0,X.jsx)(xo,{children:n}):n}function wO(e,t){return e===`memory`&&t===`memories`?`/memories`:`/plugins/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}const TO=[`/admin`,`/automations`,`/memories`,`/settings`,`/plugins/`,`/review`];function EO(e){return TO.some(t=>e.startsWith(t))}const DO={key:`code`,label:`Code`,to:`/code`},OO={key:`system`,label:`System`,to:`/system`};function kO(e){let t=e.loading&&EO(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(jO),...r?[DO,OO]:[]]}function AO(e){return[...e.map(jO),DO,OO]}function jO(e){return{key:`${e.pluginName}:${e.id}`,label:e.label,to:wO(e.pluginName,e.id)}}function MO(e){let t=``;for(let{route:n}of e)n.path&&(t=n.path.startsWith(`/`)?n.path:`${t.replace(/\/\*?$/,``)}/${n.path}`);return t||`/`}function NO(e){let t=xe(),n=me(e.children),r=Te(n,t),i=we(n,t),a=i?MO(i):void 0;return(0,Y.useLayoutEffect)(()=>{a&&qi(a)},[t.key,a]),/* @__PURE__ */ (0,X.jsx)(Y.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 FO(e){return/* @__PURE__ */ (0,X.jsx)(`li`,{children:/* @__PURE__ */ (0,X.jsx)(B,{"aria-current":e.selected?`page`:void 0,className:q(`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,X.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[0.875rem_minmax(0,1fr)] items-start gap-x-2`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,className:q(`mt-[0.4rem] size-2 shrink-0 justify-self-center rounded-full`,PO[e.dot])}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:q(`truncate font-sans text-sm font-medium leading-snug`,e.dot===`closed`?`text-dashboard-text-muted`:`text-dashboard-text`),children:e.title}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`col-start-2 mt-1 truncate font-sans text-xs leading-tight text-dashboard-text-muted`,children:e.meta})]})})})}function IO(e){return e.count===0?null:/* @__PURE__ */ (0,X.jsxs)(`section`,{"aria-label":e.label,children:[/* @__PURE__ */ (0,X.jsx)(Ap,{className:q(`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,X.jsx)(`ul`,{className:`m-0 grid list-none gap-0.5 p-0`,children:e.children})]})}function LO(){return/* @__PURE__ */ (0,X.jsxs)(`div`,{"aria-busy":`true`,"aria-live":`polite`,className:`grid gap-0.5`,role:`status`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`sr-only`,children:`Loading review items`}),/* @__PURE__ */ (0,X.jsx)(J,{className:`mb-1 ml-3 mt-1.5 h-2.5 w-16`}),[0,1,2,3,4].map(e=>/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid gap-1 rounded-lg px-3 py-2`,children:[/* @__PURE__ */ (0,X.jsx)(J,{className:q(`h-4`,e%2?`w-3/5`:`w-4/5`)}),/* @__PURE__ */ (0,X.jsx)(J,{className:`h-3 w-2/5 opacity-70`})]},e))]})}function RO(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:mS(t),r,oo(n?t.createdAt:t.closedAt)];return/* @__PURE__ */ (0,X.jsx)(FO,{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:wo(fS(t.id),e.searchParams)},t.id)};return/* @__PURE__ */ (0,X.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,X.jsx)(`div`,{className:`px-5 py-3`,children:/* @__PURE__ */ (0,X.jsx)(`h2`,{className:`m-0 font-display text-lg font-medium leading-tight text-dashboard-text`,children:`Inbox`})}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`px-4 pb-2`,children:/* @__PURE__ */ (0,X.jsx)(nh,{label:`Search review items`,onChange:e.onSearchChange,placeholder:`Search items…`,size:`compact`,value:e.search})}),/* @__PURE__ */ (0,X.jsx)(Rm,{children:/* @__PURE__ */ (0,X.jsx)(`nav`,{"aria-label":`Review items`,className:`px-3 pb-[max(0.5rem,env(safe-area-inset-bottom))]`,children:e.error?/* @__PURE__ */ (0,X.jsx)(A_,{className:`px-3 py-2`,children:`Could not load review items.`}):e.loading?/* @__PURE__ */ (0,X.jsx)(LO,{}):e.results?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[e.results.length>0?/* @__PURE__ */ (0,X.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,X.jsxs)(X.Fragment,{children:[t.map((t,n)=>/* @__PURE__ */ (0,X.jsx)(IO,{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,X.jsx)(IO,{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,X.jsx)(FO,{dot:`warning`,meta:e.statusReason??`Blocked`,title:e.title,to:Xa(e.id)},e.id))}),e.footer]})})})]})}function zO(e){return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(`dt`,{className:`text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,X.jsx)(`dd`,{className:`m-0 min-w-0 break-words text-dashboard-text`,children:e.children})]})}function BO(e){let{item:t}=e,n=t.subject,r=n?.url?pS(n.url):void 0,[i,...a]=uu([t.addedByConversationId,...t.conversationIds]),o=t.assignees.length>0||t.assignedToEveryone;return/* @__PURE__ */ (0,X.jsx)(Qy,{label:`Review item details`,onClose:e.onClose,title:/* @__PURE__ */ (0,X.jsx)(`h2`,{className:`m-0 text-base font-semibold text-dashboard-text`,children:`Details`}),children:/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0 gap-3 p-4 pb-[max(1rem,env(safe-area-inset-bottom))]`,children:[/* @__PURE__ */ (0,X.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,X.jsx)($,{text:t.body})}),/* @__PURE__ */ (0,X.jsx)(Ig,{title:`Assignees`,children:o?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`text-sm text-dashboard-text`,children:hS(t)}):/* @__PURE__ */ (0,X.jsx)(Np,{size:`compact`,tone:`warning`,children:`Unassigned`})}),/* @__PURE__ */ (0,X.jsx)(Ig,{children:/* @__PURE__ */ (0,X.jsxs)(`dl`,{className:`m-0 grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1.5`,children:[/* @__PURE__ */ (0,X.jsx)(zO,{label:`Status`,children:mS(t)}),/* @__PURE__ */ (0,X.jsx)(zO,{label:`Added`,children:oo(t.createdAt)}),/* @__PURE__ */ (0,X.jsxs)(zO,{label:`Added by`,children:[/* @__PURE__ */ (0,X.jsx)(B,{className:sa,title:t.addedByConversationId,to:kc(t.addedByConversationId,{turnId:t.addedByTurnId}),children:i??`Conversation`}),t.automationId?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[` · `,/* @__PURE__ */ (0,X.jsx)(B,{className:sa,to:Xa(t.automationId),children:`Automation`})]}):null]}),/* @__PURE__ */ (0,X.jsx)(zO,{label:`Visibility`,children:t.visibility===`private`?`Private`:`Public`})]})}),n?/* @__PURE__ */ (0,X.jsx)(Ig,{title:`Subject`,children:/* @__PURE__ */ (0,X.jsx)(`span`,{className:`text-sm`,children:r?/* @__PURE__ */ (0,X.jsx)(nf,{className:sa,href:r,children:n.title??r}):n.title??n.id})}):null,t.conversationIds.length>0?/* @__PURE__ */ (0,X.jsx)(Ig,{count:t.conversationIds.length,title:`Linked conversations`,children:/* @__PURE__ */ (0,X.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,X.jsx)(`li`,{className:n?`truncate`:`truncate font-mono text-xs`,children:/* @__PURE__ */ (0,X.jsx)(B,{className:sa,title:e,to:kc(e),children:n??e})},e)})})}):null]})})}function VO(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=bS(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 HO(e){let t=(0,Y.useMemo)(()=>({...e.conversation,events:e.events}),[e.conversation,e.events]);return/* @__PURE__ */ (0,X.jsx)(xw,{conversation:t})}function UO(e){let t=gd(e.item.addedByConversationId),n=t.data,r=n?.events,i=(0,Y.useMemo)(()=>r?VO(r,e.item):void 0,[r,e.item]),a=(0,Y.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,Y.useEffect)(()=>{l&&a.current()},[l,o]),t.isPending||c&&!t.historyError?/* @__PURE__ */ (0,X.jsx)(jD,{}):!n||!i||!s||c||i.before.length+i.after.length===0?e.fallback:/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[i.before.length>0?/* @__PURE__ */ (0,X.jsx)(HO,{conversation:n,events:i.before}):null,i.after.length>0?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex items-center gap-3 py-1 font-sans text-xs font-medium text-dashboard-accent-text`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`h-px flex-1 bg-dashboard-accent/30`}),`New since `,_a(),` asked`,/* @__PURE__ */ (0,X.jsx)(`span`,{className:`h-px flex-1 bg-dashboard-accent/30`})]}),/* @__PURE__ */ (0,X.jsx)(HO,{conversation:n,events:i.after})]}):null]})}const WO=`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 GO(e){let{item:t}=e,n=t.status===`open`,r=(0,Y.useRef)(null),i=(0,Y.useRef)(null);(0,Y.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,X.jsxs)(B,{className:WO,to:kc(t.addedByConversationId,{turnId:t.addedByTurnId}),children:[`Open conversation`,/* @__PURE__ */ (0,X.jsx)(ar,{"aria-hidden":`true`,size:14})]});return/* @__PURE__ */ (0,X.jsx)(Uv,{header:/* @__PURE__ */ (0,X.jsx)(`header`,{className:`border-b border-dashboard-border bg-dashboard-bg`,children:/* @__PURE__ */ (0,X.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,X.jsxs)(`div`,{className:`grid min-w-0 gap-1.5`,children:[/* @__PURE__ */ (0,X.jsxs)(B,{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,X.jsx)(Rt,{"aria-hidden":`true`,size:14}),`Inbox`]}),/* @__PURE__ */ (0,X.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,X.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,X.jsx)(Np,{size:`compact`,tone:n?`accent`:`neutral`,children:mS(t)}),/* @__PURE__ */ (0,X.jsxs)(`span`,{children:[a?`${a} · `:null,oo(t.createdAt),t.visibility===`private`?` · Private`:null]})]})]}),/* @__PURE__ */ (0,X.jsxs)(V,{"aria-label":`Review item details`,"aria-pressed":e.detailsOpen,className:`shrink-0`,onClick:e.onDetailsClick,children:[/* @__PURE__ */ (0,X.jsx)(Zt,{"aria-hidden":`true`,size:15,strokeWidth:2}),`Details`]})]})}),scrollAriaLabel:`Review item`,scrollClassName:`px-4 pb-6 md:px-7`,scroll:/* @__PURE__ */ (0,X.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,X.jsx)(UO,{fallback:/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid gap-3 font-sans text-sm leading-relaxed`,children:[o?null:/* @__PURE__ */ (0,X.jsx)($,{text:t.body}),/* @__PURE__ */ (0,X.jsx)(`div`,{children:s})]}),item:t}),/* @__PURE__ */ (0,X.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,X.jsx)($,{text:t.body}):null,/* @__PURE__ */ (0,X.jsx)(dS,{item:t})]}),e.next?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`flex justify-end`,children:/* @__PURE__ */ (0,X.jsxs)(B,{className:WO,replace:!0,to:e.next.to,children:[`Next: `,e.next.title,/* @__PURE__ */ (0,X.jsx)(ar,{"aria-hidden":`true`,size:14})]})}):null]})})}const KO=`grid h-full min-h-0 w-full overflow-hidden bg-dashboard-bg md:grid-cols-[20rem_minmax(0,1fr)]`;function qO(e){return/* @__PURE__ */ (0,X.jsx)(`div`,{className:q(`grid content-center justify-items-center gap-3 px-4 py-12 text-center`,e.className),children:/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 font-display text-lg font-medium text-dashboard-text`,children:`Nothing needs you`})})}function JO(){return/* @__PURE__ */ (0,X.jsx)(`div`,{className:KO,children:/* @__PURE__ */ (0,X.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,X.jsx)(J,{className:`h-5 w-16`}),/* @__PURE__ */ (0,X.jsx)(J,{className:`h-8 w-full`}),[0,1,2,3].map(e=>/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid gap-1 py-2`,children:[/* @__PURE__ */ (0,X.jsx)(J,{className:`h-4 w-4/5`}),/* @__PURE__ */ (0,X.jsx)(J,{className:`h-3 w-2/5 opacity-70`})]},e))]})})}function YO(){ga(`Inbox`);let[e]=De(),[t,n,r]=Co(),{items:i,moreArchived:a,query:o}=cu({forViewer:!0,q:r}),s=!r,c=fu(s),l=s?c.data?.automations??[]:[],u=(0,Y.useMemo)(()=>wS(i),[i]),d=(0,Y.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,Y.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?TS(u,b):void 0,S=(0,Y.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=Zy(),[E,D]=(0,Y.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,X.jsxs)(`div`,{className:KO,children:[/* @__PURE__ */ (0,X.jsx)(`div`,{className:q(`h-full min-h-0 overflow-hidden`,g&&`max-md:hidden`),children:/* @__PURE__ */ (0,X.jsx)(RO,{blocked:l,collapsed:p,error:!(!o.error||o.data),footer:/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(vE,{className:`mx-3 mt-2`,hasMore:!o.isPlaceholderData&&!!o.hasNextPage,loading:o.isFetchingNextPage,onLoadMore:()=>void o.fetchNextPage()}),o.isFetchNextPageError?/* @__PURE__ */ (0,X.jsx)(A_,{className:`px-3 py-2`,children:`Could not load more items. Try again.`}):null,a?/* @__PURE__ */ (0,X.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,X.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,X.jsx)(qO,{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,X.jsx)(`section`,{"aria-label":`Selected review item`,className:q(`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,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(GO,{backTo:wo(`/review`,k),detailsOpen:O,item:b,next:x?{title:x.title,to:wo(fS(x.id),k)}:void 0,onDetailsClick:()=>D(!O),sourceTitle:w(b)},b.id),O?/* @__PURE__ */ (0,X.jsx)(BO,{item:b,onClose:()=>D(!1)}):null]}):y.error?/* @__PURE__ */ (0,X.jsx)(A_,{className:`p-7`,children:`Review item not found.`}):j?/* @__PURE__ */ (0,X.jsx)(qO,{}):null})]})}const XO=[`dashboard`,`versions`],ZO=[`conversations`,`reviewItems`,`spend`],QO=[`focus`,`keydown`,`pointerdown`,`pointermove`,`touchstart`,`wheel`];function $O(e){return Date.now()-e>=3e5}function ek(e,t){let n=new Set(e.split(` `));return t.split(` `).filter(e=>!n.has(e)).map(e=>e.split(`:`)[0]??e)}function tk(e,t,n,r){let i=e=>t!==void 0&&t[e]!==n[e];if(Zi(ZO.filter(i),t&&i(`conversations`)?ek(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=Z(r),o=e.getQueryState(a);if(!o?.data||o.fetchStatus===`fetching`||od(o.data))return;let s=o.data.conversationVersion;s!==void 0&&s!==n.conversation&&e.invalidateQueries({exact:!0,queryKey:a})}function nk(e,t){let n=(0,Y.useRef)(Date.now()),{refetch:r}=I({enabled:t,queryKey:XO,queryFn:async({client:t,signal:n})=>{let r=t.getQueryData(XO),i=await K(Lr,e?`/api/versions?${new URLSearchParams({conversationId:e})}`:`/api/versions`,n);return tk(t,r,i,e),i},refetchInterval:()=>$O(n.current)?1e4:5e3,retry:!1,staleTime:0});(0,Y.useEffect)(()=>{let e=()=>{let e=$O(n.current);n.current=Date.now(),e&&t&&r()};for(let t of QO)window.addEventListener(t,e,{capture:!0,passive:!0});return()=>{for(let t of QO)window.removeEventListener(t,e,{capture:!0})}},[t,r])}const rk=(0,Y.lazy)(()=>import(`./chunks/RepositoryPage-o9m3vty4.js`).then(e=>({default:e.RepositoryPage}))),ik=(0,Y.lazy)(()=>import(`./chunks/BoardPage-m4zqf62q.js`).then(e=>({default:e.BoardPage}))),ak=(0,Y.lazy)(()=>import(`./chunks/CodePage-h2ayars2.js`).then(e=>({default:e.CodePage}))),ok=(0,Y.lazy)(()=>import(`./chunks/LocationDetailPage-iqtx76w6.js`).then(e=>({default:e.LocationDetailPage}))),sk=(0,Y.lazy)(()=>import(`./chunks/LocationsPage-ju5jfejt.js`).then(e=>({default:e.LocationsPage}))),ck=(0,Y.lazy)(()=>import(`./chunks/PeoplePage-lfq8nrto.js`).then(e=>({default:e.PeoplePage}))),lk=(0,Y.lazy)(()=>import(`./chunks/PersonProfilePage-ep45sxr6.js`).then(e=>({default:e.PersonProfilePage}))),uk=(0,Y.lazy)(()=>import(`./chunks/ConnectionsPage-nm7w1i05.js`).then(e=>({default:e.ConnectionsPage}))),dk=(0,Y.lazy)(()=>import(`./chunks/McpSettingsPage-brav5c42.js`).then(e=>({default:e.McpSettingsPage}))),fk=(0,Y.lazy)(()=>import(`./chunks/PersonalTokensPage-jbt4q7uz.js`).then(e=>({default:e.PersonalTokensPage}))),pk=(0,Y.lazy)(()=>import(`./chunks/SettingsPage-jc9et1qq.js`).then(e=>({default:e.SettingsPage}))),mk=(0,Y.lazy)(()=>import(`./chunks/SystemPage-bbp8cdds.js`).then(e=>({default:e.SystemPage}))),hk=(0,Y.lazy)(()=>import(`./chunks/WorkspaceFormPage-kshmsdek.js`).then(e=>({default:e.WorkspaceFormPage}))),gk=(0,Y.lazy)(()=>import(`./chunks/WorkspacesPage-ohasc10u.js`).then(e=>({default:e.WorkspacesPage}))),_k=(0,Y.lazy)(()=>import(`./chunks/AutomationPage-m78li1hv.js`).then(e=>({default:e.AutomationPage}))),vk=(0,Y.lazy)(()=>import(`./chunks/AutomationRunsPage-cba6nbxd.js`).then(e=>({default:e.AutomationRunsPage}))),yk=(0,Y.lazy)(()=>import(`./chunks/AutomationsPage-cp7wtt2v.js`).then(e=>({default:e.AutomationsPage}))),bk=(0,Y.lazy)(()=>import(`./chunks/PluginUserPage-ilar25ic.js`).then(e=>({default:e.MemoryPermalinkRoute}))),xk=(0,Y.lazy)(()=>import(`./chunks/PluginUserPage-ilar25ic.js`).then(e=>({default:e.PluginUserPageRoute}))),Sk=(0,Y.lazy)(()=>import(`./chunks/AdminPage-lctmhvpg.js`).then(e=>({default:e.AdminPage}))),Ck={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")`},wk=[{loading:{description:`Manage your profile and preferences.`,label:`Loading settings`,title:`General`},path:`/settings`,render:e=>/* @__PURE__ */ (0,X.jsx)(pk,{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,X.jsx)(fk,{})},{loading:{description:`Connect and disconnect your accounts.`,label:`Loading identities`,title:`Identities`,variant:`list`},path:`/settings/connections`,render:()=>/* @__PURE__ */ (0,X.jsx)(uk,{})},{loading:{description:`Connect an MCP client to your conversations.`,label:`Loading MCP`,title:`MCP`},path:`/settings/mcp`,render:()=>/* @__PURE__ */ (0,X.jsx)(dk,{})}];function Tk(){let e=xe(),[t,n]=(0,Y.useState)(!1),[r,i]=(0,Y.useState)(!1),a=()=>i(!0),o=Jo(),s=Xo(),c=o.data,l=Ui(c?.config.version),u=s.data??[],d=!c&&!o.error,f=!!(c?.config.authRequired&&c.me.user.email),p=ds(f),m=ks(),h=f?u.filter(e=>e.navigation===`primary`):[],g=e.pathname===`/`||e.pathname===`/conversations`||e.pathname.startsWith(`/conversations/`),_=Ek(e.pathname),v=Zo(),y=gd(_,{unreadPageAtOpen:hm()===`unread`,versionsPoll:!0});nk(_,!!c);let b=(0,Y.useMemo)(()=>{if(_)return $a(v.data?.conversations??[]).find(e=>e.id===_)},[_,v.data?.conversations]),x=_?Ga(y.data)??za(b):void 0,S=du(f),C=kO({loading:d,loggedIn:f,pathname:e.pathname,primaryUserPages:h,reviewCount:S.data?.needsViewer}),w=f?AO(u.filter(e=>e.navigation===`profile`)):[];(0,Y.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,X.jsx)(_o,{children:/* @__PURE__ */ (0,X.jsxs)(Gl,{children:[/* @__PURE__ */ (0,X.jsx)(vl,{currentConversationId:_,navItems:[...C,...w],onOpenChange:i,open:r}),m?null:/* @__PURE__ */ (0,X.jsx)(Xl,{navItems:C,onSearch:a,profile:f?/* @__PURE__ */ (0,X.jsx)(pc,{identity:c.me,onSignOut:T,spend:p.data,pages:w}):void 0,workspaceActive:g}),/* @__PURE__ */ (0,X.jsxs)(au,{className:`min-w-0 flex-1 bg-dashboard-bg`,enabled:g||e.pathname===`/review`||yO(e.pathname)||lO(e.pathname)||gO(e.pathname),children:[/* @__PURE__ */ (0,X.jsx)(ho,{desktopTopBar:m,banner:/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(ws,{serverVersion:l}),/* @__PURE__ */ (0,X.jsx)(bs,{})]}),header:/* @__PURE__ */ (0,X.jsx)(zl,{desktopTopBar:m,mobileBackTo:_?`/`:void 0,mobileTitle:x,mobileNavigationOpen:t,navItems:C,onMobileNavigationOpenChange:n,onSearch:a,profile:f?/* @__PURE__ */ (0,X.jsx)(pc,{identity:c.me,onSignOut:T,spend:p.data,pages:w,variant:`top-bar`}):void 0,mobileIdentity:f?/* @__PURE__ */ (0,X.jsx)(pc,{identity:c.me,onSignOut:T,spend:p.data,pages:w,variant:`sheet-identity`}):void 0,mobileProfile:f?/* @__PURE__ */ (0,X.jsx)(pc,{identity:c.me,onSignOut:T,spend:p.data,pages:w,variant:`sheet-links`}):void 0,mobileSpend:f?/* @__PURE__ */ (0,X.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,X.jsxs)(NO,{fallback:/* @__PURE__ */ (0,X.jsx)(Cs,{label:`Loading page`}),children:[/* @__PURE__ */ (0,X.jsx)(z,{element:/* @__PURE__ */ (0,X.jsx)(Dk,{}),path:`/tasks`}),/* @__PURE__ */ (0,X.jsx)(z,{element:/* @__PURE__ */ (0,X.jsx)(Dk,{}),path:`/tasks/*`}),/* @__PURE__ */ (0,X.jsx)(z,{element:/* @__PURE__ */ (0,X.jsx)(kk,{}),path:`/automations/:automationId/executions`}),/* @__PURE__ */ (0,X.jsx)(z,{element:d||f?/* @__PURE__ */ (0,X.jsx)(_k,{enabled:f,tab:`runs`}):/* @__PURE__ */ (0,X.jsx)(fe,{replace:!0,to:`/`}),path:`/automations/:automationId/runs`}),/* @__PURE__ */ (0,X.jsx)(z,{element:d||f?/* @__PURE__ */ (0,X.jsx)(_k,{enabled:f,tab:`versions`}):/* @__PURE__ */ (0,X.jsx)(fe,{replace:!0,to:`/`}),path:`/automations/:automationId/versions`}),/* @__PURE__ */ (0,X.jsx)(z,{element:d||f?/* @__PURE__ */ (0,X.jsx)(_k,{enabled:f,tab:`edit`}):/* @__PURE__ */ (0,X.jsx)(fe,{replace:!0,to:`/`}),path:`/automations/:automationId/edit`}),/* @__PURE__ */ (0,X.jsx)(z,{element:d?/* @__PURE__ */ (0,X.jsx)(SO,{children:/* @__PURE__ */ (0,X.jsx)(CO,{description:`Newest runs across your automations and automations in public destinations.`,label:`Loading automation runs`,title:`Runs`})}):f?/* @__PURE__ */ (0,X.jsx)(SO,{children:/* @__PURE__ */ (0,X.jsx)(vk,{enabled:f})}):/* @__PURE__ */ (0,X.jsx)(fe,{replace:!0,to:`/`}),path:`/automations/runs`}),/* @__PURE__ */ (0,X.jsx)(z,{element:/* @__PURE__ */ (0,X.jsx)(Ok,{}),path:`/automations/list`}),/* @__PURE__ */ (0,X.jsx)(z,{element:d||f?/* @__PURE__ */ (0,X.jsx)(_k,{enabled:f,tab:`overview`}):/* @__PURE__ */ (0,X.jsx)(fe,{replace:!0,to:`/`}),path:`/automations/:automationId`}),/* @__PURE__ */ (0,X.jsx)(z,{element:d?/* @__PURE__ */ (0,X.jsx)(SO,{children:/* @__PURE__ */ (0,X.jsx)(CO,{label:`Loading automations`,title:`Automations`})}):f?/* @__PURE__ */ (0,X.jsx)(SO,{children:/* @__PURE__ */ (0,X.jsx)(yk,{enabled:f})}):/* @__PURE__ */ (0,X.jsx)(fe,{replace:!0,to:`/`}),path:`/automations`}),/* @__PURE__ */ (0,X.jsx)(z,{element:/* @__PURE__ */ (0,X.jsx)(Ak,{section:`locations`}),path:`/locations`}),/* @__PURE__ */ (0,X.jsx)(z,{element:/* @__PURE__ */ (0,X.jsx)(Ak,{section:`locations`}),path:`/locations/:locationId`}),/* @__PURE__ */ (0,X.jsx)(z,{element:d?/* @__PURE__ */ (0,X.jsx)(fO,{description:`Public destinations and their conversation activity.`,label:`Loading locations`,title:`Locations`,variant:`stats`}):/* @__PURE__ */ (0,X.jsx)(sk,{}),path:`/system/locations`}),/* @__PURE__ */ (0,X.jsx)(z,{element:d?/* @__PURE__ */ (0,X.jsx)(dO,{children:/* @__PURE__ */ (0,X.jsx)(Cs,{label:`Loading location`})}):/* @__PURE__ */ (0,X.jsx)(ok,{}),path:`/system/locations/:locationId`}),/* @__PURE__ */ (0,X.jsx)(z,{element:d?/* @__PURE__ */ (0,X.jsx)(qD,{detail:!1}):c?/* @__PURE__ */ (0,X.jsx)(WD,{detail:y}):/* @__PURE__ */ (0,X.jsx)(Cs,{label:o.error?.message??`Dashboard unavailable`}),path:`/`}),/* @__PURE__ */ (0,X.jsx)(z,{element:d?/* @__PURE__ */ (0,X.jsx)(JO,{}):f?/* @__PURE__ */ (0,X.jsx)(YO,{}):/* @__PURE__ */ (0,X.jsx)(fe,{replace:!0,to:`/`}),path:`/review`}),/* @__PURE__ */ (0,X.jsx)(z,{element:/* @__PURE__ */ (0,X.jsx)(ik,{}),path:`/board`}),/* @__PURE__ */ (0,X.jsx)(z,{element:/* @__PURE__ */ (0,X.jsx)(ak,{}),path:`/code`}),ZD.map(e=>/* @__PURE__ */ (0,X.jsx)(z,{element:/* @__PURE__ */ (0,X.jsx)(rk,{tab:e}),path:e===`overview`?`/code/:repositoryId`:`/code/:repositoryId/${e}`},e)),/* @__PURE__ */ (0,X.jsx)(z,{element:/* @__PURE__ */ (0,X.jsx)(fe,{replace:!0,to:`/`}),path:`/conversations/new`}),/* @__PURE__ */ (0,X.jsx)(z,{element:d?/* @__PURE__ */ (0,X.jsx)(qD,{detail:!0}):c?/* @__PURE__ */ (0,X.jsx)(WD,{detail:y}):/* @__PURE__ */ (0,X.jsx)(Cs,{label:o.error?.message??`Dashboard unavailable`}),path:`/conversations/:conversationId`}),/* @__PURE__ */ (0,X.jsx)(z,{element:/* @__PURE__ */ (0,X.jsx)(fe,{replace:!0,to:`/`}),path:`/conversations`}),/* @__PURE__ */ (0,X.jsx)(z,{element:/* @__PURE__ */ (0,X.jsx)(Ak,{section:`people`}),path:`/people`}),/* @__PURE__ */ (0,X.jsx)(z,{element:d?/* @__PURE__ */ (0,X.jsx)(Cs,{label:`Loading profile`}):/* @__PURE__ */ (0,X.jsx)(lk,{}),path:`/people/:email`}),/* @__PURE__ */ (0,X.jsx)(z,{element:d?/* @__PURE__ */ (0,X.jsx)(fO,{description:`People, activity, and model spend.`,label:`Loading people`,title:`People`,variant:`stats`}):/* @__PURE__ */ (0,X.jsx)(ck,{}),path:`/system/people`}),/* @__PURE__ */ (0,X.jsx)(z,{element:d?/* @__PURE__ */ (0,X.jsx)(fO,{description:`Repository recipes Junior can switch into.`,label:`Loading Workspaces`,title:`Workspaces`,variant:`list`}):/* @__PURE__ */ (0,X.jsx)(gk,{}),path:`/system/workspaces`}),/* @__PURE__ */ (0,X.jsx)(z,{element:d?/* @__PURE__ */ (0,X.jsx)(dO,{children:/* @__PURE__ */ (0,X.jsx)(Cs,{label:`Loading Workspace`})}):/* @__PURE__ */ (0,X.jsx)(hk,{}),path:`/system/workspaces/new`}),/* @__PURE__ */ (0,X.jsx)(z,{element:d?/* @__PURE__ */ (0,X.jsx)(fO,{description:`Repository recipes Junior can switch into.`,label:`Loading Workspaces`,title:`Workspaces`,variant:`list`}):/* @__PURE__ */ (0,X.jsx)(gk,{}),path:`/system/workspaces/:workspaceId`}),/* @__PURE__ */ (0,X.jsx)(z,{element:d?/* @__PURE__ */ (0,X.jsx)(dO,{children:/* @__PURE__ */ (0,X.jsx)(Cs,{label:`Loading Workspace`})}):/* @__PURE__ */ (0,X.jsx)(hk,{}),path:`/system/workspaces/:workspaceId/edit`}),/* @__PURE__ */ (0,X.jsx)(z,{element:d?/* @__PURE__ */ (0,X.jsx)(fO,{description:`Runtime health, model usage, and loaded capabilities.`,label:`Loading system`,title:`System`,variant:`overview`}):c?/* @__PURE__ */ (0,X.jsx)(jk,{coreData:c}):/* @__PURE__ */ (0,X.jsx)(dO,{children:/* @__PURE__ */ (0,X.jsx)(Cs,{label:o.error?.message??`Dashboard unavailable`})}),path:`/system/*`}),wk.map(e=>/* @__PURE__ */ (0,X.jsx)(z,{element:d?/* @__PURE__ */ (0,X.jsx)(nO,{description:e.loading.description,title:e.loading.title,children:/* @__PURE__ */ (0,X.jsx)(pa,{label:e.loading.label,variant:e.loading.variant})}):f?e.render(c):/* @__PURE__ */ (0,X.jsx)(fe,{replace:!0,to:`/`}),path:e.path},e.path)),/* @__PURE__ */ (0,X.jsx)(z,{element:d||s.isPending?/* @__PURE__ */ (0,X.jsx)(vO,{label:`Loading memories`}):f&&s.data?/* @__PURE__ */ (0,X.jsx)(bk,{pages:s.data}):/* @__PURE__ */ (0,X.jsx)(fe,{replace:!0,to:`/`}),path:`/memories/library`}),/* @__PURE__ */ (0,X.jsx)(z,{element:d||s.isPending?/* @__PURE__ */ (0,X.jsx)(vO,{label:`Loading memory`}):f&&s.data?/* @__PURE__ */ (0,X.jsx)(bk,{pages:s.data}):/* @__PURE__ */ (0,X.jsx)(fe,{replace:!0,to:`/`}),path:`/memories/:memoryId?`}),/* @__PURE__ */ (0,X.jsx)(z,{element:d||s.isPending?/* @__PURE__ */ (0,X.jsx)(Cs,{label:`Loading page`}):f&&s.data?/* @__PURE__ */ (0,X.jsx)(xk,{pages:s.data}):/* @__PURE__ */ (0,X.jsx)(fe,{replace:!0,to:`/`}),path:`/plugins/:pluginName/:pageId/*`}),/* @__PURE__ */ (0,X.jsx)(z,{element:d||s.isPending?/* @__PURE__ */ (0,X.jsx)(Cs,{label:`Loading admin`}):f&&c.me.user.isAdmin&&s.data?/* @__PURE__ */ (0,X.jsx)(Sk,{pages:s.data}):/* @__PURE__ */ (0,X.jsx)(fe,{replace:!0,to:`/`}),path:`/admin`}),/* @__PURE__ */ (0,X.jsx)(z,{element:/* @__PURE__ */ (0,X.jsx)(fe,{replace:!0,to:`/`}),path:`*`})]}),/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none fixed inset-0 z-50 block opacity-[0.018]`,"data-dashboard-noise":``,style:Ck})]})]})})}function Ek(e){if(Pc(e))return;let t=e.match(/^\/conversations\/([^/]+)$/);if(t?.[1])try{return decodeURIComponent(t[1])}catch{return t[1]}}function Dk(){let e=xe(),t=e.pathname.slice(6);return/* @__PURE__ */ (0,X.jsx)(fe,{replace:!0,to:`/automations${t}${e.search}${e.hash}`})}function Ok(){let e=xe();return/* @__PURE__ */ (0,X.jsx)(fe,{replace:!0,to:`/automations${e.search}${e.hash}`})}function kk(){let e=xe(),{automationId:t}=L();return/* @__PURE__ */ (0,X.jsx)(fe,{replace:!0,to:`${Xa(t??``,`runs`)}${e.search}${e.hash}`})}function Ak(e){let t=xe(),n=`/${e.section}`,r=t.pathname.slice(n.length);return/* @__PURE__ */ (0,X.jsx)(fe,{replace:!0,to:`/system/${e.section}${r}${t.search}${t.hash}`})}function jk(e){let t=vs(e.coreData);return!t.data&&!t.error?/* @__PURE__ */ (0,X.jsx)(fO,{description:`Runtime health, model usage, and loaded capabilities.`,label:`Loading system`,title:`System`,variant:`overview`}):t.data?/* @__PURE__ */ (0,X.jsx)(mk,{data:t.data}):/* @__PURE__ */ (0,X.jsx)(dO,{children:/* @__PURE__ */ (0,X.jsx)(Cs,{label:t.error?.message??`System unavailable`})})}var Mk=class extends Y.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,X.jsx)(Nk,{error:this.state.error}):this.props.children}};function Nk(e){return/* @__PURE__ */ (0,X.jsx)(`main`,{className:`grid min-h-screen place-items-center bg-dashboard-ink p-8 text-dashboard-text-solid`,children:/* @__PURE__ */ (0,X.jsxs)(`section`,{className:`w-full max-w-5xl border border-rose-400/50 bg-dashboard-surface-raised p-5 font-sans`,children:[/* @__PURE__ */ (0,X.jsx)(`div`,{className:`font-mono text-xs uppercase leading-none text-dashboard-text-faint`,children:`Dashboard Error`}),/* @__PURE__ */ (0,X.jsxs)(`h1`,{className:`mt-2 text-3xl font-bold leading-tight tracking-normal`,children:[_a(),` failed to render`]}),/* @__PURE__ */ (0,X.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,X.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})]})})}Ki();const Pk=document.getElementById(`dashboard-root`);if(!Pk)throw Error(`Junior dashboard root element was not found`);typeof Notification<`u`&&Notification.permission===`granted`&&vT()?.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`&&TT(t.url)});function Fk(){wT(),ET().catch(()=>void 0)}Fk(),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&Fk()});const Ik=new M({defaultOptions:{queries:{staleTime:3e4}}}),Lk=Se([{path:`*`,element:/* @__PURE__ */ (0,X.jsx)(Tk,{})}],{basename:window.__JUNIOR_DASHBOARD_BASE_PATH__??`/`});(0,Eo.createRoot)(Pk).render(/* @__PURE__ */ (0,X.jsx)(Mk,{children:/* @__PURE__ */ (0,X.jsx)(S,{client:Ik,children:/* @__PURE__ */ (0,X.jsx)(Ro,{children:/* @__PURE__ */ (0,X.jsx)(Tr,{children:/* @__PURE__ */ (0,X.jsx)(Ce,{router:Lk})})})})}));export{Gh as $,is as $t,GS as A,ml as At,Bx as B,qs as Bt,NT as C,Yd as Ct,vT as D,Pl as Dt,gT as E,Fl as Et,$x as F,Gc as Ft,Qy as G,Os as Gt,jb as H,Js as Ht,eS as I,Vc as It,yv as J,ss as Jt,qy as K,Cs as Kt,Qx as L,kc as Lt,tS as M,hl as Mt,nS as N,fl as Nt,CT as O,ll as Ot,Zx as P,Xc as Pt,$ as Q,as as Qt,Vx as R,vc as Rt,AT as S,Zd as St,xT as T,_u as Tt,Cb as U,Ks as Ut,Mb as V,Ys as Vt,Sb as W,js as Wt,A_ as X,cs as Xt,vv as Y,ls as Yt,l_ as Z,rs as Zt,yE as _,kp as _t,uO as a,es as an,Ph as at,OT as b,Jd as bt,oO as c,ms as cn,bh as ct,nO as d,lh as dt,os as en,qh as et,eO as f,nh as ft,bE as g,Op as gt,xE as h,Np as ht,fO as i,ts as in,Yh as it,Xx as j,dl as jt,KS as k,pl as kt,iO as l,_s as ln,vh as lt,vE as m,mm as mt,_O as n,$o as nn,Xh as nt,aO as o,ps as on,yh as ot,QD as p,Lm as pt,ky as q,us as qt,dO as r,Qo as rn,Kh as rt,sO as s,fs as sn,xh as st,wO as t,ns as tn,Zh as tt,rO as u,zo as un,gh as ut,uE as v,Zf as vt,MT as w,qd as wt,jT as x,Xd as xt,DT as y,nf as yt,Hx as z,Gs as zt};