@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
@@ -1,8 +1,8 @@
1
- import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n}from"./vendor-react-ggbyvons.js";import{Qt as r,Zt as i,a,o}from"./vendor-icons-mxz7yi04.js";import{t as s}from"./circle-dollar-sign-fpl4dmok.js";import{t as c}from"./styles-j0007fov.js";import{t as l}from"./Card-hy4bfgq7.js";import{a as u,c as d,m as f,o as p,r as m,s as h,t as ee}from"./PageHeader-bhl3orzi.js";import{c as g,k as _,l as v,p as y,q as b}from"./format-gle1s0ri.js";import{n as te,r as ne}from"./searchParams-moqjgi65.js";import{Ht as x,ct as S,i as C,r as re,st as w}from"../client-f7asutg5.js";import{C as T,P as E,_ as D,a as O,d as k,n as A,o as ie,r as ae,s as j,t as M,u as N}from"./chart-myr1oeen.js";import{t as P}from"./Area-h08sxa33.js";import{t as F}from"./ChartLegend-c3e9l1vl.js";import{t as I}from"./StatCard-i2klkqqp.js";import{t as L}from"./CardHeader-b2skz2x6.js";import{a as R,i as z,n as B,o as V,r as H,t as U}from"./DirectoryMetric-dgzufji4.js"
1
+ import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n}from"./vendor-react-ggbyvons.js";import{$t as r,Qt as i,a,o}from"./vendor-icons-blmhaswc.js";import{t as s}from"./circle-dollar-sign-h7k4kr7s.js";import{t as c}from"./styles-j0007fov.js";import{t as l}from"./Card-hy4bfgq7.js";import{a as u,c as d,m as f,o as p,r as m,s as h,t as ee}from"./PageHeader-bhl3orzi.js";import{c as g,k as _,l as v,p as y,q as b}from"./format-flkutk9e.js";import{n as te,r as ne}from"./searchParams-moqjgi65.js";import{Jt as x,ft as S,i as C,pt as w,r as re}from"../client-ctcthgam.js";import{C as T,P as E,_ as D,a as O,d as k,n as A,o as ie,r as ae,s as j,t as M,u as N}from"./chart-il2ahs5y.js";import{t as P}from"./Area-d95rfkv5.js";import{t as F}from"./ChartLegend-c3e9l1vl.js";import{t as I}from"./StatCard-i2klkqqp.js";import{t as L}from"./CardHeader-b2skz2x6.js";import{a as R,i as z,n as B,o as V,r as H,t as U}from"./DirectoryMetric-huy2ptzz.js"
2
2
  /**
3
3
  * @license lucide-react v1.17.0 - ISC
4
4
  *
5
5
  * This source code is licensed under the ISC license.
6
6
  * See the LICENSE file in the root directory of this source tree.
7
7
  */
8
- ;const W=r(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]);var G=/* @__PURE__ */ e(t()),K=[`axis`],q=/*#__PURE__*/ (0,G.forwardRef)((e,t)=>/*#__PURE__*/ G.createElement(D,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:K,tooltipPayloadSearcher:E,categoricalChartProps:e,ref:t})),J=n();function oe(e){let t=e.bucketUnit??`day`,n=`Active people per ${p(t)}`,r=e.days.map(e=>e.activePeople),i=Math.max(1,...r),a=N(r),o=e.days.length>30;return/* @__PURE__ */ (0,J.jsxs)(l,{children:[/* @__PURE__ */ (0,J.jsx)(L,{description:`Distinct verified actors grouped by recorded conversation activity.`,title:n,trailing:/* @__PURE__ */ (0,J.jsx)(F,{ariaLabel:`People activity legend`,inline:!0,items:[{color:`var(--color-amber-400)`,key:`people`,label:`people`}]})}),/* @__PURE__ */ (0,J.jsx)(`div`,{className:`px-2 py-3 sm:px-4 sm:py-4`,children:/* @__PURE__ */ (0,J.jsx)(M,{className:`aspect-auto h-65 w-full`,config:{},children:/* @__PURE__ */ (0,J.jsxs)(q,{"aria-label":n,data:e.days,margin:k,role:`img`,children:[/* @__PURE__ */ (0,J.jsxs)(`defs`,{children:[/* @__PURE__ */ (0,J.jsxs)(`linearGradient`,{id:`people-area`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[/* @__PURE__ */ (0,J.jsx)(`stop`,{offset:`0%`,stopColor:`var(--color-amber-500)`,stopOpacity:`0.3`}),/* @__PURE__ */ (0,J.jsx)(`stop`,{offset:`100%`,stopColor:`var(--color-amber-500)`,stopOpacity:`0`})]}),/* @__PURE__ */ (0,J.jsxs)(`linearGradient`,{id:`people-line`,x1:`0`,x2:`1`,y1:`0`,y2:`0`,children:[/* @__PURE__ */ (0,J.jsx)(`stop`,{offset:`0%`,stopColor:`var(--color-amber-500)`}),/* @__PURE__ */ (0,J.jsx)(`stop`,{offset:`55%`,stopColor:`var(--color-amber-400)`}),/* @__PURE__ */ (0,J.jsx)(`stop`,{offset:`100%`,stopColor:`var(--color-cyan-400)`})]})]}),/* @__PURE__ */ (0,J.jsx)(T,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,J.jsx)(j,{maximum:i}),/* @__PURE__ */ (0,J.jsx)(ie,{keys:e.days.map(e=>e.date)}),/* @__PURE__ */ (0,J.jsx)(A,{content:/* @__PURE__ */ (0,J.jsx)(O,{rows:e=>[[`active people`,e.activePeople],[`conversations`,e.conversations]]})}),/* @__PURE__ */ (0,J.jsx)(P,{activeDot:{fill:`var(--color-amber-400)`,r:5},dataKey:`activePeople`,dot:{fill:`var(--color-amber-400)`,fillOpacity:o?.35:.75,r:o?3:4,stroke:`none`},fill:`url(#people-area)`,fillOpacity:1,isAnimationActive:!1,stroke:`url(#people-line)`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2.5,type:`linear`}),/* @__PURE__ */ (0,J.jsx)(ae,{unit:u(t),average:a,format:g,stroke:`var(--color-amber-400)`})]})})})]})}function Y(e){return e.actor.fullName??e.actor.slackUserName??e.actor.email}function se(e){return Y(e)===e.actor.email?void 0:e.actor.email}function ce(e,t){return e<=0&&t>0?`unknown`:b(e)}function X(e,t){return e.windows[t]}function Z(e){return e.costUsd-e.priorCostUsd}function Q(e){if(Math.abs(e)<.005)return`$0.00`;let t=y({total:Math.abs(e)});return`${e>0?`+`:`−`}${t}`}function le(e,t,n,r){let i=t.trim().toLowerCase();return[...i?e.filter(e=>[e.actor.email,e.actor.fullName,e.actor.slackUserName].some(e=>e?.toLowerCase().includes(i))):e].sort((e,t)=>{let i=X(e,r),a=X(t,r);return n===`spend`?a.costUsd-i.costUsd||Z(a)-Z(i)||e.actor.email.localeCompare(t.actor.email):n===`spendDelta`?Z(a)-Z(i)||a.costUsd-i.costUsd||e.actor.email.localeCompare(t.actor.email):n===`conversations`?a.conversations-i.conversations||a.costUsd-i.costUsd:n===`runtime`?a.durationMs-i.durationMs||a.costUsd-i.costUsd:Date.parse(t.lastSeenAt)-Date.parse(e.lastSeenAt)})}function ue(e){return/* @__PURE__ */ (0,J.jsxs)(l,{children:[/* @__PURE__ */ (0,J.jsx)(L,{description:`${e.people.length} of ${e.totalPeople} people`,title:`People directory`}),/* @__PURE__ */ (0,J.jsxs)(R,{columnsClassName:`md:grid-cols-[minmax(14rem,1fr)_minmax(10rem,14rem)]`,children:[/* @__PURE__ */ (0,J.jsx)(w,{label:`Search people`,placeholder:`Search name, email, Slack handle...`,value:e.query,onChange:e.onQueryChange}),/* @__PURE__ */ (0,J.jsx)(V,{ariaLabel:`Sort people`,onChange:t=>e.onSortChange(t),options:[{label:`Most spend`,value:`spend`},{label:`Biggest spend increase`,value:`spendDelta`},{label:`Most conversations`,value:`conversations`},{label:`Recently active`,value:`recent`},{label:`Most runtime`,value:`runtime`}],value:e.sort})]}),/* @__PURE__ */ (0,J.jsx)(z,{ariaLabel:`People directory results`,empty:e.people.length===0?/* @__PURE__ */ (0,J.jsx)(S,{children:`No people match this search.`}):void 0,headers:[`Person`,`Conversations`,`Spend`,`Runtime`],loading:e.loading,children:e.people.map(t=>{let n=X(t,e.range),r=Z(n);return/* @__PURE__ */ (0,J.jsxs)(H,{to:_(t.actor.email),children:[/* @__PURE__ */ (0,J.jsx)(B,{description:se(t),icon:/* @__PURE__ */ (0,J.jsx)(o,{"aria-hidden":`true`,size:16,strokeWidth:1.8}),iconClassName:`bg-amber-500/[0.07] text-amber-300 group-hover:border-amber-500/25`,title:Y(t)}),/* @__PURE__ */ (0,J.jsx)(U,{label:`Conversations`,value:v(n.conversations)}),/* @__PURE__ */ (0,J.jsx)(U,{label:`Spend`,value:/* @__PURE__ */ (0,J.jsxs)(`span`,{className:`inline-flex flex-col items-end gap-1`,children:[/* @__PURE__ */ (0,J.jsx)(`span`,{className:`whitespace-nowrap`,children:y({total:n.costUsd})||`$0.00`}),/* @__PURE__ */ (0,J.jsx)(`span`,{className:c(`whitespace-nowrap font-mono text-2xs leading-none`,Math.abs(r)<.005?`text-dashboard-text-muted`:r>0?`text-amber-300/80`:`text-cyan-300/75`),children:Q(r)})]})}),/* @__PURE__ */ (0,J.jsx)(U,{label:`Runtime`,value:/* @__PURE__ */ (0,J.jsx)(`span`,{className:`whitespace-nowrap`,children:ce(n.durationMs,n.conversations)})})]},t.actor.email)})})]})}const de=[`spend`,`spendDelta`,`conversations`,`recent`,`runtime`];function $(e){return e.actor.fullName??e.actor.slackUserName??e.actor.email}function fe(){let e=x();return/* @__PURE__ */ (0,J.jsx)(pe,{data:e.data,error:e.error})}function pe(e){let[t,n,r]=te(),[o,c]=(0,G.useState)(7),[u,p]=ne(`sort`,`spend`,de),g=(0,G.useDeferredValue)(u);if(!e.data&&!e.error)return/* @__PURE__ */ (0,J.jsx)(C,{description:`People, activity, and model spend.`,label:`Loading people`,title:`People`,variant:`stats`});let _=e.data,b=_?m({days:_.activityDays,hours:_.activityHours,sixHours:_.activitySixHours,range:o,emptySixHour:e=>({activePeople:0,conversations:0,date:e})}):[],x=h(o),w=_?le(_.people,r,g,o):[],T=_?.people.filter(e=>e.windows[o].conversations>0).length??0,E=_?.people.reduce((e,t)=>e+t.windows[o].costUsd,0)??0,D=_?.people.reduce((e,t)=>e?t.windows[o].costUsd>e.windows[o].costUsd?t:e:t,void 0),O=_?.people.reduce((e,t)=>{let n=t.windows[o].costUsd-t.windows[o].priorCostUsd;return e?n>e.windows[o].costUsd-e.windows[o].priorCostUsd?t:e:n>0?t:void 0},void 0),k=D?.windows[o].costUsd??0,A=O?O.windows[o].costUsd-O.windows[o].priorCostUsd:0;return/* @__PURE__ */ (0,J.jsxs)(re,{children:[/* @__PURE__ */ (0,J.jsx)(ee,{description:e.error?`People failed to load.`:`Who used ${f()} in the ${d(o)}, and how spend changed from the prior period.`,onRangeChange:c,range:o,title:`People`}),e.error?/* @__PURE__ */ (0,J.jsx)(l,{padding:`md`,children:/* @__PURE__ */ (0,J.jsx)(S,{children:`People telemetry is unavailable. Try refreshing the dashboard.`})}):_?.people.length?/* @__PURE__ */ (0,J.jsxs)(J.Fragment,{children:[/* @__PURE__ */ (0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[/* @__PURE__ */ (0,J.jsx)(I,{detail:`People with activity in the ${d(o)}`,icon:a,label:`Active people`,value:v(T)}),/* @__PURE__ */ (0,J.jsx)(I,{detail:`Estimated model cost in the ${d(o)}`,icon:s,label:`Model spend`,value:y({total:E})||`$0.00`}),/* @__PURE__ */ (0,J.jsx)(I,{detail:D&&k>0?$(D):`No spend in this range`,icon:i,label:`Highest spend`,value:D&&k>0?y({total:k})||`$0.00`:`—`}),/* @__PURE__ */ (0,J.jsx)(I,{detail:O&&A>0?`${$(O)} vs prior period`:`No spend increases in this range`,icon:W,label:`Biggest increase`,value:O&&A>0?Q(A):`—`})]}),/* @__PURE__ */ (0,J.jsx)(oe,{bucketUnit:x,days:b}),/* @__PURE__ */ (0,J.jsx)(ue,{loading:u!==g,onQueryChange:n,onSortChange:p,people:w,query:t,range:o,sort:u,totalPeople:_.people.length})]}):/* @__PURE__ */ (0,J.jsx)(l,{padding:`md`,children:/* @__PURE__ */ (0,J.jsx)(S,{children:`No actor telemetry with trusted email.`})})]})}export{fe as PeoplePage};
8
+ ;const W=r(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]);var G=/* @__PURE__ */ e(t()),K=[`axis`],q=/*#__PURE__*/ (0,G.forwardRef)((e,t)=>/*#__PURE__*/ G.createElement(D,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:K,tooltipPayloadSearcher:E,categoricalChartProps:e,ref:t})),J=n();function oe(e){let t=e.bucketUnit??`day`,n=`Active people per ${p(t)}`,r=e.days.map(e=>e.activePeople),i=Math.max(1,...r),a=N(r),o=e.days.length>30;return/* @__PURE__ */ (0,J.jsxs)(l,{children:[/* @__PURE__ */ (0,J.jsx)(L,{description:`Distinct verified actors grouped by recorded conversation activity.`,title:n,trailing:/* @__PURE__ */ (0,J.jsx)(F,{ariaLabel:`People activity legend`,inline:!0,items:[{color:`var(--color-amber-400)`,key:`people`,label:`people`}]})}),/* @__PURE__ */ (0,J.jsx)(`div`,{className:`px-2 py-3 sm:px-4 sm:py-4`,children:/* @__PURE__ */ (0,J.jsx)(M,{className:`aspect-auto h-65 w-full`,config:{},children:/* @__PURE__ */ (0,J.jsxs)(q,{"aria-label":n,data:e.days,margin:k,role:`img`,children:[/* @__PURE__ */ (0,J.jsxs)(`defs`,{children:[/* @__PURE__ */ (0,J.jsxs)(`linearGradient`,{id:`people-area`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[/* @__PURE__ */ (0,J.jsx)(`stop`,{offset:`0%`,stopColor:`var(--color-amber-500)`,stopOpacity:`0.3`}),/* @__PURE__ */ (0,J.jsx)(`stop`,{offset:`100%`,stopColor:`var(--color-amber-500)`,stopOpacity:`0`})]}),/* @__PURE__ */ (0,J.jsxs)(`linearGradient`,{id:`people-line`,x1:`0`,x2:`1`,y1:`0`,y2:`0`,children:[/* @__PURE__ */ (0,J.jsx)(`stop`,{offset:`0%`,stopColor:`var(--color-amber-500)`}),/* @__PURE__ */ (0,J.jsx)(`stop`,{offset:`55%`,stopColor:`var(--color-amber-400)`}),/* @__PURE__ */ (0,J.jsx)(`stop`,{offset:`100%`,stopColor:`var(--color-cyan-400)`})]})]}),/* @__PURE__ */ (0,J.jsx)(T,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,J.jsx)(j,{maximum:i}),/* @__PURE__ */ (0,J.jsx)(ie,{keys:e.days.map(e=>e.date)}),/* @__PURE__ */ (0,J.jsx)(A,{content:/* @__PURE__ */ (0,J.jsx)(O,{rows:e=>[[`active people`,e.activePeople],[`conversations`,e.conversations]]})}),/* @__PURE__ */ (0,J.jsx)(P,{activeDot:{fill:`var(--color-amber-400)`,r:5},dataKey:`activePeople`,dot:{fill:`var(--color-amber-400)`,fillOpacity:o?.35:.75,r:o?3:4,stroke:`none`},fill:`url(#people-area)`,fillOpacity:1,isAnimationActive:!1,stroke:`url(#people-line)`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2.5,type:`linear`}),/* @__PURE__ */ (0,J.jsx)(ae,{unit:u(t),average:a,format:g,stroke:`var(--color-amber-400)`})]})})})]})}function Y(e){return e.actor.fullName??e.actor.slackUserName??e.actor.email}function se(e){return Y(e)===e.actor.email?void 0:e.actor.email}function ce(e,t){return e<=0&&t>0?`unknown`:b(e)}function X(e,t){return e.windows[t]}function Z(e){return e.costUsd-e.priorCostUsd}function Q(e){if(Math.abs(e)<.005)return`$0.00`;let t=y({total:Math.abs(e)});return`${e>0?`+`:`−`}${t}`}function le(e,t,n,r){let i=t.trim().toLowerCase();return[...i?e.filter(e=>[e.actor.email,e.actor.fullName,e.actor.slackUserName].some(e=>e?.toLowerCase().includes(i))):e].sort((e,t)=>{let i=X(e,r),a=X(t,r);return n===`spend`?a.costUsd-i.costUsd||Z(a)-Z(i)||e.actor.email.localeCompare(t.actor.email):n===`spendDelta`?Z(a)-Z(i)||a.costUsd-i.costUsd||e.actor.email.localeCompare(t.actor.email):n===`conversations`?a.conversations-i.conversations||a.costUsd-i.costUsd:n===`runtime`?a.durationMs-i.durationMs||a.costUsd-i.costUsd:Date.parse(t.lastSeenAt)-Date.parse(e.lastSeenAt)})}function ue(e){return/* @__PURE__ */ (0,J.jsxs)(l,{children:[/* @__PURE__ */ (0,J.jsx)(L,{description:`${e.people.length} of ${e.totalPeople} people`,title:`People directory`}),/* @__PURE__ */ (0,J.jsxs)(R,{columnsClassName:`md:grid-cols-[minmax(14rem,1fr)_minmax(10rem,14rem)]`,children:[/* @__PURE__ */ (0,J.jsx)(S,{label:`Search people`,placeholder:`Search name, email, Slack handle...`,value:e.query,onChange:e.onQueryChange}),/* @__PURE__ */ (0,J.jsx)(V,{ariaLabel:`Sort people`,onChange:t=>e.onSortChange(t),options:[{label:`Most spend`,value:`spend`},{label:`Biggest spend increase`,value:`spendDelta`},{label:`Most conversations`,value:`conversations`},{label:`Recently active`,value:`recent`},{label:`Most runtime`,value:`runtime`}],value:e.sort})]}),/* @__PURE__ */ (0,J.jsx)(z,{ariaLabel:`People directory results`,empty:e.people.length===0?/* @__PURE__ */ (0,J.jsx)(w,{children:`No people match this search.`}):void 0,headers:[`Person`,`Conversations`,`Spend`,`Runtime`],loading:e.loading,children:e.people.map(t=>{let n=X(t,e.range),r=Z(n);return/* @__PURE__ */ (0,J.jsxs)(H,{to:_(t.actor.email),children:[/* @__PURE__ */ (0,J.jsx)(B,{description:se(t),icon:/* @__PURE__ */ (0,J.jsx)(o,{"aria-hidden":`true`,size:16,strokeWidth:1.8}),iconClassName:`bg-amber-500/[0.07] text-amber-300 group-hover:border-amber-500/25`,title:Y(t)}),/* @__PURE__ */ (0,J.jsx)(U,{label:`Conversations`,value:v(n.conversations)}),/* @__PURE__ */ (0,J.jsx)(U,{label:`Spend`,value:/* @__PURE__ */ (0,J.jsxs)(`span`,{className:`inline-flex flex-col items-end gap-1`,children:[/* @__PURE__ */ (0,J.jsx)(`span`,{className:`whitespace-nowrap`,children:y({total:n.costUsd})||`$0.00`}),/* @__PURE__ */ (0,J.jsx)(`span`,{className:c(`whitespace-nowrap font-mono text-2xs leading-none`,Math.abs(r)<.005?`text-dashboard-text-muted`:r>0?`text-amber-300/80`:`text-cyan-300/75`),children:Q(r)})]})}),/* @__PURE__ */ (0,J.jsx)(U,{label:`Runtime`,value:/* @__PURE__ */ (0,J.jsx)(`span`,{className:`whitespace-nowrap`,children:ce(n.durationMs,n.conversations)})})]},t.actor.email)})})]})}const de=[`spend`,`spendDelta`,`conversations`,`recent`,`runtime`];function $(e){return e.actor.fullName??e.actor.slackUserName??e.actor.email}function fe(){let e=x();return/* @__PURE__ */ (0,J.jsx)(pe,{data:e.data,error:e.error})}function pe(e){let[t,n,r]=te(),[o,c]=(0,G.useState)(7),[u,p]=ne(`sort`,`spend`,de),g=(0,G.useDeferredValue)(u);if(!e.data&&!e.error)return/* @__PURE__ */ (0,J.jsx)(C,{description:`People, activity, and model spend.`,label:`Loading people`,title:`People`,variant:`stats`});let _=e.data,b=_?m({days:_.activityDays,hours:_.activityHours,sixHours:_.activitySixHours,range:o,emptySixHour:e=>({activePeople:0,conversations:0,date:e})}):[],x=h(o),S=_?le(_.people,r,g,o):[],T=_?.people.filter(e=>e.windows[o].conversations>0).length??0,E=_?.people.reduce((e,t)=>e+t.windows[o].costUsd,0)??0,D=_?.people.reduce((e,t)=>e?t.windows[o].costUsd>e.windows[o].costUsd?t:e:t,void 0),O=_?.people.reduce((e,t)=>{let n=t.windows[o].costUsd-t.windows[o].priorCostUsd;return e?n>e.windows[o].costUsd-e.windows[o].priorCostUsd?t:e:n>0?t:void 0},void 0),k=D?.windows[o].costUsd??0,A=O?O.windows[o].costUsd-O.windows[o].priorCostUsd:0;return/* @__PURE__ */ (0,J.jsxs)(re,{children:[/* @__PURE__ */ (0,J.jsx)(ee,{description:e.error?`People failed to load.`:`Who used ${f()} in the ${d(o)}, and how spend changed from the prior period.`,onRangeChange:c,range:o,title:`People`}),e.error?/* @__PURE__ */ (0,J.jsx)(l,{padding:`md`,children:/* @__PURE__ */ (0,J.jsx)(w,{children:`People telemetry is unavailable. Try refreshing the dashboard.`})}):_?.people.length?/* @__PURE__ */ (0,J.jsxs)(J.Fragment,{children:[/* @__PURE__ */ (0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[/* @__PURE__ */ (0,J.jsx)(I,{detail:`People with activity in the ${d(o)}`,icon:a,label:`Active people`,value:v(T)}),/* @__PURE__ */ (0,J.jsx)(I,{detail:`Estimated model cost in the ${d(o)}`,icon:s,label:`Model spend`,value:y({total:E})||`$0.00`}),/* @__PURE__ */ (0,J.jsx)(I,{detail:D&&k>0?$(D):`No spend in this range`,icon:i,label:`Highest spend`,value:D&&k>0?y({total:k})||`$0.00`:`—`}),/* @__PURE__ */ (0,J.jsx)(I,{detail:O&&A>0?`${$(O)} vs prior period`:`No spend increases in this range`,icon:W,label:`Biggest increase`,value:O&&A>0?Q(A):`—`})]}),/* @__PURE__ */ (0,J.jsx)(oe,{bucketUnit:x,days:b}),/* @__PURE__ */ (0,J.jsx)(ue,{loading:u!==g,onQueryChange:n,onSortChange:p,people:S,query:t,range:o,sort:u,totalPeople:_.people.length})]}):/* @__PURE__ */ (0,J.jsx)(l,{padding:`md`,children:/* @__PURE__ */ (0,J.jsx)(w,{children:`No actor telemetry with trusted email.`})})]})}export{fe as PeoplePage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n,_ as r,r as i}from"./vendor-react-ggbyvons.js";import{B as a,at as o,bt as s,qt as c,u as l}from"./vendor-icons-mxz7yi04.js";import{t as u}from"./coins-bqkaxeba.js";import{n as ee,r as d,t as f}from"./CodeChangeRow-dk3gkjut.js";import{a as p,i as m,n as h,t as te}from"./tooltip-h1yceend.js";import{t as g}from"./styles-j0007fov.js";import{t as _}from"./Card-hy4bfgq7.js";import{m as v,r as y,s as b,t as x}from"./PageHeader-bhl3orzi.js";import{K as S,l as C,p as w,q as T}from"./format-gle1s0ri.js";import{t as E}from"./PageLayout-l6dhbimv.js";import{n as D}from"./AnchorHeading-cp3vx8qa.js";import{Rt as O,Ut as k,Vt as A,Wt as j,c as M,ct as N}from"../client-f7asutg5.js";import{t as P}from"./native-select-jfknh8t4.js";import{n as F}from"./FilterBar-mtnh7fbi.js";import{c as I}from"./chart-myr1oeen.js";import{n as L,r as R,t as z}from"./PluginReportRecordSet-hm1cwp6c.js";import{t as B}from"./StatCard-i2klkqqp.js";import{n as V,t as H}from"./SectionTitle-drw3mqtl.js";var U=/* @__PURE__ */ e(t(),1),W=n();function G(e){let t=Math.max(1,...e.days.map(e=>e.conversations)),n=[],r=e.days[0]?(/* @__PURE__ */ new Date(`${e.days[0].date}T00:00:00Z`)).getUTCDay():0,i=[...Array.from({length:r},()=>null),...e.days];for(;i.length>0&&i.length%7!=0;)i.push(null);for(let e=0;e<i.length;e+=7){let t=i.slice(e,e+7);for(;t.length<7;)t.push(null);n.push(t)}n.length===0&&n.push([null,null,null,null,null,null,null]);let a=n.map((e,t)=>{let r=e.find(Boolean);if(!r)return``;let i=t>0?n[t-1]:void 0,a=i?[...i].reverse().find(Boolean):void 0;return a&&a.date.slice(0,7)===r.date.slice(0,7)?``:(/* @__PURE__ */ new Date(`${r.date}T00:00:00Z`)).toLocaleString(void 0,{month:`short`,timeZone:`UTC`})});return/* @__PURE__ */ (0,W.jsx)(`div`,{className:`overflow-x-auto px-4 py-4`,children:/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`min-w-[36rem]`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{"aria-hidden":`true`,className:`mb-1 grid gap-1 text-xs font-semibold leading-none text-dashboard-text-muted`,style:{gridTemplateColumns:`repeat(${n.length}, minmax(0.75rem, 1fr))`},children:a.map((e,t)=>/* @__PURE__ */ (0,W.jsx)(`div`,{className:`h-3 overflow-visible`,children:e},`${e}-${t}`))}),/* @__PURE__ */ (0,W.jsx)(`div`,{"aria-label":`Daily ${v()} conversation activity`,className:`grid w-full grid-flow-col grid-rows-7 gap-1`,role:`list`,style:{gridTemplateColumns:`repeat(${n.length}, minmax(0.75rem, 1fr))`},children:n.flatMap((e,n)=>e.map((e,r)=>e?/* @__PURE__ */ (0,W.jsxs)(te,{children:[/* @__PURE__ */ (0,W.jsx)(p,{render:/* @__PURE__ */ (0,W.jsx)(`span`,{"aria-label":`${e.date}: ${e.conversations} conversations, ${q(e)}, ${w({total:e.costUsd??0})} spend, ${C(e.tokens??0)} tokens`,className:g(`size-3 border border-dashboard-overlay outline-none focus-visible:ring-2 focus-visible:ring-dashboard-focus`,J(e.conversations,t)),role:`listitem`,tabIndex:0})}),/* @__PURE__ */ (0,W.jsxs)(h,{children:[/* @__PURE__ */ (0,W.jsx)(m,{children:K(e.date)}),/* @__PURE__ */ (0,W.jsx)(I,{rows:[[`conversations`,e.conversations],[`runtime`,q(e)],[`spend`,w({total:e.costUsd??0})],[`tokens`,C(e.tokens??0)]]})]})]},e.date):/* @__PURE__ */ (0,W.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 border border-dashboard-overlay bg-dashboard-surface-raised`},`empty-${n}-${r}`)))}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-3 flex items-center gap-1 text-xs font-semibold leading-none text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,W.jsx)(`span`,{children:`Less`}),[0,1,2,3,4].map(e=>/* @__PURE__ */ (0,W.jsx)(`span`,{"aria-hidden":`true`,className:g(`size-3 border border-dashboard-overlay`,e===0&&`bg-dashboard-surface-hover`,e===1&&`bg-[#133225] light:bg-[#9be9a8]`,e===2&&`bg-[#176a4a] light:bg-[#40c463]`,e===3&&`bg-[#22a06b] light:bg-[#30a14e]`,e===4&&`bg-[#8bdc97] light:bg-[#216e39]`)},e)),/* @__PURE__ */ (0,W.jsx)(`span`,{children:`More`})]})]})})}function K(e){return(/* @__PURE__ */ new Date(`${e}T00:00:00Z`)).toLocaleDateString(void 0,{day:`numeric`,month:`short`,timeZone:`UTC`,year:`numeric`})}function q(e){return e.durationMs<=0&&e.conversations>0?`unknown`:T(e.durationMs)}function J(e,t){if(e<=0)return`bg-dashboard-surface-hover`;let n=e/t;return n>=.75?`bg-[#8bdc97] light:bg-[#216e39]`:n>=.45?`bg-[#22a06b] light:bg-[#30a14e]`:n>=.2?`bg-[#176a4a] light:bg-[#40c463]`:`bg-[#133225] light:bg-[#9be9a8]`}const Y=[{label:`Open`,value:`open`},{label:`Merged`,value:`merged`},{label:`Closed`,value:`closed`},{label:`All`,value:``}],X=[{label:`Any time`,value:``},{label:`Last 24 hours`,value:`1`},{label:`Last 7 days`,value:`7`},{label:`Last 30 days`,value:`30`},{label:`Last 90 days`,value:`90`}];function Z(e){let[t,n]=(0,U.useState)(`open`),[r,i]=(0,U.useState)(``),a=r?Date.parse(e.generatedAt)-Number(r)*864e5:void 0,o=e.changes.filter(e=>a===void 0||Date.parse(e.openedAt)>=a),s=o.filter(e=>!t||e.state===t),c=e=>e?o.filter(t=>t.state===e).length:o.length;return/* @__PURE__ */ (0,W.jsxs)(_,{as:`section`,children:[/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-4 border-b border-dashboard-border-subtle px-4 py-3`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-display text-lg text-dashboard-text`,children:`Recent changes`}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(F,{className:`w-36`,label:`State`,children:/* @__PURE__ */ (0,W.jsx)(P,{"aria-label":`Filter changes by state`,onChange:e=>n(e.currentTarget.value),value:t,children:Y.map(e=>/* @__PURE__ */ (0,W.jsxs)(`option`,{value:e.value,children:[e.label,` (`,c(e.value),`)`]},e.value))})}),/* @__PURE__ */ (0,W.jsx)(F,{className:`w-36`,label:`Opened`,children:/* @__PURE__ */ (0,W.jsx)(P,{"aria-label":`Filter changes by opened date`,onChange:e=>i(e.currentTarget.value),value:r,children:X.map(e=>/* @__PURE__ */ (0,W.jsx)(`option`,{value:e.value,children:e.label},e.value))})})]})]}),s.length>0?/* @__PURE__ */ (0,W.jsx)(`div`,{children:s.map(e=>/* @__PURE__ */ (0,W.jsx)(f,{change:e},e.id))}):/* @__PURE__ */ (0,W.jsx)(`div`,{className:`p-4`,children:/* @__PURE__ */ (0,W.jsx)(N,{children:t&&o.length>0?`No ${t} changes. Set State to All to see ${o.length} more.`:`No changes match these filters.`})})]})}function Q(e){return e===void 0?`—`:`${Math.round(e*100)}%`}function ne(e){return T(e)||`—`}function re(e){return w(e===void 0?void 0:{total:e})||`—`}function ie(e){let t=e.summary;return e.changes.length>0||t.created+t.merged+t.closed>0||(t.costUsd??0)>0||e.activityDays.some(e=>e.created+e.merged+e.closed>0)}function ae(e){if(!ie(e.report))return null;let t=e.report.summary;return/* @__PURE__ */ (0,W.jsxs)(`section`,{"aria-labelledby":D(`code`),className:`grid gap-4`,children:[/* @__PURE__ */ (0,W.jsx)(M,{anchor:`code`,title:`Code`}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[/* @__PURE__ */ (0,W.jsx)(B,{detail:`In the last 30 days`,icon:o,label:`Created`,value:C(t.created)}),/* @__PURE__ */ (0,W.jsx)(B,{detail:`Share of completed changes that merged`,icon:d,label:`Merge rate`,value:Q(t.mergeRate)}),/* @__PURE__ */ (0,W.jsx)(B,{detail:`Median time from open to merge in the last 30 days`,icon:l,label:`Median merge time`,value:ne(t.medianMergeTimeMs)}),/* @__PURE__ */ (0,W.jsx)(B,{detail:`Conversation cost for changes opened in the last 30 days`,icon:u,label:`Cost`,value:re(t.costUsd)})]}),/* @__PURE__ */ (0,W.jsx)(ee,{bucketUnit:b(e.range),days:y({days:e.report.activityDays,hours:e.report.activityHours,sixHours:e.report.activitySixHours,range:e.range,emptySixHour:e=>({closed:0,created:0,date:e,merged:0})}),range:e.range}),e.report.changes.length>0?/* @__PURE__ */ (0,W.jsx)(Z,{changes:e.report.changes,generatedAt:e.report.generatedAt}):null]})}function oe(e){return e.reports.length===0?null:/* @__PURE__ */ (0,W.jsx)(W.Fragment,{children:e.reports.map(t=>/* @__PURE__ */ (0,W.jsx)($,{range:e.range,report:t},t.pluginName))})}function $(e){let t=e.report.title&&e.report.title!==e.report.pluginName?e.report.title:e.report.pluginName,n=e.report.metrics??[],r=e.report.widgets??[],i=e.report.recordSets??[];if(!n.length&&!r.length&&!i.length)return null;let a=`plugin-${e.report.pluginName}`;return/* @__PURE__ */ (0,W.jsxs)(`section`,{"aria-labelledby":D(a),className:`grid gap-4`,children:[/* @__PURE__ */ (0,W.jsx)(M,{anchor:a,title:t}),n.length?/* @__PURE__ */ (0,W.jsx)(`div`,{className:g(`grid gap-px overflow-hidden rounded-md border border-dashboard-border bg-dashboard-fill-hover`,n.length===1?`grid-cols-1`:`grid-cols-2`,n.length===3?`lg:grid-cols-3`:n.length===5?`lg:grid-cols-5`:n.length>=4?`lg:grid-cols-4`:void 0),children:n.map(e=>/* @__PURE__ */ (0,W.jsxs)(`div`,{className:g(`min-w-0 bg-dashboard-surface-panel px-4 py-4`,n.length>1&&n.length%2==1&&`last:col-span-2 lg:last:col-span-1`,se(e.tone)),children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`truncate font-display text-2xl font-light leading-none text-dashboard-text`,children:e.value}),/* @__PURE__ */ (0,W.jsx)(`div`,{className:`mt-2 font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label})]},e.label))}):null,r.length?/* @__PURE__ */ (0,W.jsx)(`div`,{className:g(`grid gap-3`,r.length>1?`lg:grid-cols-2`:void 0),children:r.map(t=>/* @__PURE__ */ (0,W.jsx)(L,{range:e.range,widget:t},t.id))}):null,i.map(t=>/* @__PURE__ */ (0,W.jsx)(z,{recordSet:t},`${e.report.pluginName}:${t.title}`))]})}function se(e){if(e===`danger`)return`shadow-[inset_0_2px_0_rgba(251,113,133,0.65)]`;if(e===`warning`)return`shadow-[inset_0_2px_0_rgba(251,191,36,0.65)]`;if(e===`good`)return`shadow-[inset_0_2px_0_rgba(110,231,183,0.55)]`}function ce(e,t){return e<=0&&t>0?`unknown`:T(e)}function le(){let e=r(),t=e.email?decodeURIComponent(e.email):void 0,n=j(t),i=k(t),a=A(t);return!n.data&&!n.error?/* @__PURE__ */ (0,W.jsx)(O,{label:`Loading profile`}):/* @__PURE__ */ (0,W.jsx)(E,{children:n.data?/* @__PURE__ */ (0,W.jsx)(ue,{code:a.data,codeError:!!a.error,codeLoading:a.isPending,pluginReports:i.data?.reports??[],pluginReportsError:!!i.error,pluginReportsLoading:i.isPending,profile:n.data}):/* @__PURE__ */ (0,W.jsx)(_,{padding:`md`,children:/* @__PURE__ */ (0,W.jsx)(N,{children:`Profile failed to load.`})})})}function ue(e){let[t,n]=(0,U.useState)(30),r=e.profile,o=e.pluginReports??[],l=r.actor.fullName??r.actor.slackUserName??r.actor.email;return/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[/* @__PURE__ */ (0,W.jsxs)(i,{className:`flex w-fit items-center gap-2 font-display text-sm font-medium text-dashboard-text-muted no-underline transition-colors hover:text-dashboard-text`,to:`/system/people`,children:[/* @__PURE__ */ (0,W.jsx)(c,{"aria-hidden":`true`,size:15,strokeWidth:1.8}),`Back to people`]}),/* @__PURE__ */ (0,W.jsx)(x,{description:/* @__PURE__ */ (0,W.jsxs)(W.Fragment,{children:[r.actor.email,r.actor.slackUserName?` / @${r.actor.slackUserName}`:``]}),onRangeChange:n,range:t,title:l}),/* @__PURE__ */ (0,W.jsxs)(`section`,{className:`grid gap-4`,"aria-labelledby":D(`usage`),children:[/* @__PURE__ */ (0,W.jsx)(M,{anchor:`usage`,title:`Usage over time`}),/* @__PURE__ */ (0,W.jsx)(R,{bucketUnit:b(t),days:y({days:r.activityDays,hours:r.activityHours,sixHours:r.activitySixHours,range:t,emptySixHour:e=>({active:0,conversations:0,date:e,durationMs:0,failed:0})})})]}),e.codeError?/* @__PURE__ */ (0,W.jsx)(_,{className:`border-amber-300/10 bg-amber-300/[0.025]`,padding:`sm`,children:/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-display text-sm font-medium text-dashboard-text-muted`,children:`Code activity failed to load.`})}):null,!e.codeLoading&&e.code?/* @__PURE__ */ (0,W.jsx)(ae,{range:t,report:e.code}):null,e.pluginReportsError?/* @__PURE__ */ (0,W.jsx)(_,{className:`border-amber-300/10 bg-amber-300/[0.025]`,padding:`sm`,children:/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-display text-sm font-medium text-dashboard-text-muted`,children:`Plugin activity failed to load.`})}):null,e.pluginReportsLoading?null:/* @__PURE__ */ (0,W.jsx)(oe,{range:t,reports:o}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid min-w-0 gap-5 lg:grid-cols-[minmax(0,1fr)_19rem] lg:items-start`,children:[/* @__PURE__ */ (0,W.jsx)(`aside`,{className:`grid min-w-0 gap-4 lg:order-2`,children:/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3 lg:grid-cols-1`,children:[/* @__PURE__ */ (0,W.jsx)(B,{detail:`Across the complete conversation index`,icon:a,label:`Conversations`,value:C(r.totals.conversations)}),/* @__PURE__ */ (0,W.jsx)(B,{detail:`Cumulative persisted conversation runtime`,icon:s,label:`Runtime`,value:/* @__PURE__ */ (0,W.jsx)(S,{value:r.totals.durationMs})}),/* @__PURE__ */ (0,W.jsx)(B,{detail:`Persisted model token usage`,icon:u,label:`Tokens`,value:C(r.totals.tokens??0)})]})}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid min-w-0 gap-5 lg:order-1`,children:[/* @__PURE__ */ (0,W.jsxs)(_,{as:`section`,className:`mb-0`,variant:`section`,children:[/* @__PURE__ */ (0,W.jsx)(V,{actions:/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:`52 weeks`}),children:/* @__PURE__ */ (0,W.jsx)(H,{children:`Activity`})}),/* @__PURE__ */ (0,W.jsx)(G,{days:r.activityDays})]}),/* @__PURE__ */ (0,W.jsx)(de,{items:r.surfaces,title:`Surfaces`})]})]})]})}function de(e){return e.items.length<=1?null:/* @__PURE__ */ (0,W.jsxs)(_,{as:`section`,className:`mb-0`,variant:`section`,children:[/* @__PURE__ */ (0,W.jsx)(V,{children:/* @__PURE__ */ (0,W.jsx)(H,{children:e.title})}),/* @__PURE__ */ (0,W.jsx)(`ol`,{className:`m-0 list-none p-0`,children:e.items.slice(0,6).map((e,t)=>/* @__PURE__ */ (0,W.jsxs)(`li`,{className:`grid min-w-0 grid-cols-[2rem_minmax(0,1fr)_auto] items-center gap-3 border-b border-dashboard-border-subtle px-4 py-3 last:border-b-0`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-mono text-xs leading-none text-dashboard-text-muted`,children:t+1}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`truncate font-display text-base font-medium leading-tight text-dashboard-text`,children:e.label}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-1 truncate font-mono text-xs leading-tight text-dashboard-text-muted`,children:[ce(e.durationMs,e.conversations),e.tokens?` / ${C(e.tokens)} tokens`:``,e.failed?` / ${C(e.failed)} errors`:``]})]}),/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-display text-xl font-light leading-none text-dashboard-text`,children:C(e.conversations)})]},e.label))})]})}export{le as PersonProfilePage};
1
+ import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n,_ as r,r as i}from"./vendor-react-ggbyvons.js";import{B as a,Jt as o,at as s,bt as c,u as l}from"./vendor-icons-blmhaswc.js";import{t as u}from"./coins-l2c8c17w.js";import{n as ee,r as d,t as f}from"./CodeChangeRow-d620nk75.js";import{a as p,i as m,n as h,t as te}from"./tooltip-h1yceend.js";import{t as g}from"./styles-j0007fov.js";import{t as _}from"./Card-hy4bfgq7.js";import{m as v,r as y,s as b,t as x}from"./PageHeader-bhl3orzi.js";import{K as S,l as C,p as w,q as T}from"./format-flkutk9e.js";import{t as E}from"./PageLayout-l6dhbimv.js";import{n as D}from"./AnchorHeading-ixbupfij.js";import{Kt as O,Xt as k,Yt as A,f as j,pt as M,qt as N}from"../client-ctcthgam.js";import{t as P}from"./native-select-fxs3p0bj.js";import{n as F}from"./FilterBar-dqnt967g.js";import{c as I}from"./chart-il2ahs5y.js";import{n as L,r as R,t as z}from"./PluginReportRecordSet-ml18z19r.js";import{t as B}from"./StatCard-i2klkqqp.js";import{n as V,t as H}from"./SectionTitle-drw3mqtl.js";var U=/* @__PURE__ */ e(t(),1),W=n();function G(e){let t=Math.max(1,...e.days.map(e=>e.conversations)),n=[],r=e.days[0]?(/* @__PURE__ */ new Date(`${e.days[0].date}T00:00:00Z`)).getUTCDay():0,i=[...Array.from({length:r},()=>null),...e.days];for(;i.length>0&&i.length%7!=0;)i.push(null);for(let e=0;e<i.length;e+=7){let t=i.slice(e,e+7);for(;t.length<7;)t.push(null);n.push(t)}n.length===0&&n.push([null,null,null,null,null,null,null]);let a=n.map((e,t)=>{let r=e.find(Boolean);if(!r)return``;let i=t>0?n[t-1]:void 0,a=i?[...i].reverse().find(Boolean):void 0;return a&&a.date.slice(0,7)===r.date.slice(0,7)?``:(/* @__PURE__ */ new Date(`${r.date}T00:00:00Z`)).toLocaleString(void 0,{month:`short`,timeZone:`UTC`})});return/* @__PURE__ */ (0,W.jsx)(`div`,{className:`overflow-x-auto px-4 py-4`,children:/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`min-w-[36rem]`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{"aria-hidden":`true`,className:`mb-1 grid gap-1 text-xs font-semibold leading-none text-dashboard-text-muted`,style:{gridTemplateColumns:`repeat(${n.length}, minmax(0.75rem, 1fr))`},children:a.map((e,t)=>/* @__PURE__ */ (0,W.jsx)(`div`,{className:`h-3 overflow-visible`,children:e},`${e}-${t}`))}),/* @__PURE__ */ (0,W.jsx)(`div`,{"aria-label":`Daily ${v()} conversation activity`,className:`grid w-full grid-flow-col grid-rows-7 gap-1`,role:`list`,style:{gridTemplateColumns:`repeat(${n.length}, minmax(0.75rem, 1fr))`},children:n.flatMap((e,n)=>e.map((e,r)=>e?/* @__PURE__ */ (0,W.jsxs)(te,{children:[/* @__PURE__ */ (0,W.jsx)(p,{render:/* @__PURE__ */ (0,W.jsx)(`span`,{"aria-label":`${e.date}: ${e.conversations} conversations, ${q(e)}, ${w({total:e.costUsd??0})} spend, ${C(e.tokens??0)} tokens`,className:g(`size-3 border border-dashboard-overlay outline-none focus-visible:ring-2 focus-visible:ring-dashboard-focus`,J(e.conversations,t)),role:`listitem`,tabIndex:0})}),/* @__PURE__ */ (0,W.jsxs)(h,{children:[/* @__PURE__ */ (0,W.jsx)(m,{children:K(e.date)}),/* @__PURE__ */ (0,W.jsx)(I,{rows:[[`conversations`,e.conversations],[`runtime`,q(e)],[`spend`,w({total:e.costUsd??0})],[`tokens`,C(e.tokens??0)]]})]})]},e.date):/* @__PURE__ */ (0,W.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 border border-dashboard-overlay bg-dashboard-surface-raised`},`empty-${n}-${r}`)))}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-3 flex items-center gap-1 text-xs font-semibold leading-none text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,W.jsx)(`span`,{children:`Less`}),[0,1,2,3,4].map(e=>/* @__PURE__ */ (0,W.jsx)(`span`,{"aria-hidden":`true`,className:g(`size-3 border border-dashboard-overlay`,e===0&&`bg-dashboard-surface-hover`,e===1&&`bg-[#133225] light:bg-[#9be9a8]`,e===2&&`bg-[#176a4a] light:bg-[#40c463]`,e===3&&`bg-[#22a06b] light:bg-[#30a14e]`,e===4&&`bg-[#8bdc97] light:bg-[#216e39]`)},e)),/* @__PURE__ */ (0,W.jsx)(`span`,{children:`More`})]})]})})}function K(e){return(/* @__PURE__ */ new Date(`${e}T00:00:00Z`)).toLocaleDateString(void 0,{day:`numeric`,month:`short`,timeZone:`UTC`,year:`numeric`})}function q(e){return e.durationMs<=0&&e.conversations>0?`unknown`:T(e.durationMs)}function J(e,t){if(e<=0)return`bg-dashboard-surface-hover`;let n=e/t;return n>=.75?`bg-[#8bdc97] light:bg-[#216e39]`:n>=.45?`bg-[#22a06b] light:bg-[#30a14e]`:n>=.2?`bg-[#176a4a] light:bg-[#40c463]`:`bg-[#133225] light:bg-[#9be9a8]`}const Y=[{label:`Open`,value:`open`},{label:`Merged`,value:`merged`},{label:`Closed`,value:`closed`},{label:`All`,value:``}],X=[{label:`Any time`,value:``},{label:`Last 24 hours`,value:`1`},{label:`Last 7 days`,value:`7`},{label:`Last 30 days`,value:`30`},{label:`Last 90 days`,value:`90`}];function Z(e){let[t,n]=(0,U.useState)(`open`),[r,i]=(0,U.useState)(``),a=r?Date.parse(e.generatedAt)-Number(r)*864e5:void 0,o=e.changes.filter(e=>a===void 0||Date.parse(e.openedAt)>=a),s=o.filter(e=>!t||e.state===t),c=e=>e?o.filter(t=>t.state===e).length:o.length;return/* @__PURE__ */ (0,W.jsxs)(_,{as:`section`,children:[/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-4 border-b border-dashboard-border-subtle px-4 py-3`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-display text-lg text-dashboard-text`,children:`Recent changes`}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(F,{className:`w-36`,label:`State`,children:/* @__PURE__ */ (0,W.jsx)(P,{"aria-label":`Filter changes by state`,onChange:e=>n(e.currentTarget.value),value:t,children:Y.map(e=>/* @__PURE__ */ (0,W.jsxs)(`option`,{value:e.value,children:[e.label,` (`,c(e.value),`)`]},e.value))})}),/* @__PURE__ */ (0,W.jsx)(F,{className:`w-36`,label:`Opened`,children:/* @__PURE__ */ (0,W.jsx)(P,{"aria-label":`Filter changes by opened date`,onChange:e=>i(e.currentTarget.value),value:r,children:X.map(e=>/* @__PURE__ */ (0,W.jsx)(`option`,{value:e.value,children:e.label},e.value))})})]})]}),s.length>0?/* @__PURE__ */ (0,W.jsx)(`div`,{children:s.map(e=>/* @__PURE__ */ (0,W.jsx)(f,{change:e},e.id))}):/* @__PURE__ */ (0,W.jsx)(`div`,{className:`p-4`,children:/* @__PURE__ */ (0,W.jsx)(M,{children:t&&o.length>0?`No ${t} changes. Set State to All to see ${o.length} more.`:`No changes match these filters.`})})]})}function Q(e){return e===void 0?`—`:`${Math.round(e*100)}%`}function ne(e){return T(e)||`—`}function re(e){return w(e===void 0?void 0:{total:e})||`—`}function ie(e){let t=e.summary;return e.changes.length>0||t.created+t.merged+t.closed>0||(t.costUsd??0)>0||e.activityDays.some(e=>e.created+e.merged+e.closed>0)}function ae(e){if(!ie(e.report))return null;let t=e.report.summary;return/* @__PURE__ */ (0,W.jsxs)(`section`,{"aria-labelledby":D(`code`),className:`grid gap-4`,children:[/* @__PURE__ */ (0,W.jsx)(j,{anchor:`code`,title:`Code`}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[/* @__PURE__ */ (0,W.jsx)(B,{detail:`In the last 30 days`,icon:s,label:`Created`,value:C(t.created)}),/* @__PURE__ */ (0,W.jsx)(B,{detail:`Share of completed changes that merged`,icon:d,label:`Merge rate`,value:Q(t.mergeRate)}),/* @__PURE__ */ (0,W.jsx)(B,{detail:`Median time from open to merge in the last 30 days`,icon:l,label:`Median merge time`,value:ne(t.medianMergeTimeMs)}),/* @__PURE__ */ (0,W.jsx)(B,{detail:`Conversation cost for changes opened in the last 30 days`,icon:u,label:`Cost`,value:re(t.costUsd)})]}),/* @__PURE__ */ (0,W.jsx)(ee,{bucketUnit:b(e.range),days:y({days:e.report.activityDays,hours:e.report.activityHours,sixHours:e.report.activitySixHours,range:e.range,emptySixHour:e=>({closed:0,created:0,date:e,merged:0})}),range:e.range}),e.report.changes.length>0?/* @__PURE__ */ (0,W.jsx)(Z,{changes:e.report.changes,generatedAt:e.report.generatedAt}):null]})}function oe(e){return e.reports.length===0?null:/* @__PURE__ */ (0,W.jsx)(W.Fragment,{children:e.reports.map(t=>/* @__PURE__ */ (0,W.jsx)($,{range:e.range,report:t},t.pluginName))})}function $(e){let t=e.report.title&&e.report.title!==e.report.pluginName?e.report.title:e.report.pluginName,n=e.report.metrics??[],r=e.report.widgets??[],i=e.report.recordSets??[];if(!n.length&&!r.length&&!i.length)return null;let a=`plugin-${e.report.pluginName}`;return/* @__PURE__ */ (0,W.jsxs)(`section`,{"aria-labelledby":D(a),className:`grid gap-4`,children:[/* @__PURE__ */ (0,W.jsx)(j,{anchor:a,title:t}),n.length?/* @__PURE__ */ (0,W.jsx)(`div`,{className:g(`grid gap-px overflow-hidden rounded-md border border-dashboard-border bg-dashboard-fill-hover`,n.length===1?`grid-cols-1`:`grid-cols-2`,n.length===3?`lg:grid-cols-3`:n.length===5?`lg:grid-cols-5`:n.length>=4?`lg:grid-cols-4`:void 0),children:n.map(e=>/* @__PURE__ */ (0,W.jsxs)(`div`,{className:g(`min-w-0 bg-dashboard-surface-panel px-4 py-4`,n.length>1&&n.length%2==1&&`last:col-span-2 lg:last:col-span-1`,se(e.tone)),children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`truncate font-display text-2xl font-light leading-none text-dashboard-text`,children:e.value}),/* @__PURE__ */ (0,W.jsx)(`div`,{className:`mt-2 font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label})]},e.label))}):null,r.length?/* @__PURE__ */ (0,W.jsx)(`div`,{className:g(`grid gap-3`,r.length>1?`lg:grid-cols-2`:void 0),children:r.map(t=>/* @__PURE__ */ (0,W.jsx)(L,{range:e.range,widget:t},t.id))}):null,i.map(t=>/* @__PURE__ */ (0,W.jsx)(z,{recordSet:t},`${e.report.pluginName}:${t.title}`))]})}function se(e){if(e===`danger`)return`shadow-[inset_0_2px_0_rgba(251,113,133,0.65)]`;if(e===`warning`)return`shadow-[inset_0_2px_0_rgba(251,191,36,0.65)]`;if(e===`good`)return`shadow-[inset_0_2px_0_rgba(110,231,183,0.55)]`}function ce(e,t){return e<=0&&t>0?`unknown`:T(e)}function le(){let e=r(),t=e.email?decodeURIComponent(e.email):void 0,n=k(t),i=A(t),a=N(t);return!n.data&&!n.error?/* @__PURE__ */ (0,W.jsx)(O,{label:`Loading profile`}):/* @__PURE__ */ (0,W.jsx)(E,{children:n.data?/* @__PURE__ */ (0,W.jsx)(ue,{code:a.data,codeError:!!a.error,codeLoading:a.isPending,pluginReports:i.data?.reports??[],pluginReportsError:!!i.error,pluginReportsLoading:i.isPending,profile:n.data}):/* @__PURE__ */ (0,W.jsx)(_,{padding:`md`,children:/* @__PURE__ */ (0,W.jsx)(M,{children:`Profile failed to load.`})})})}function ue(e){let[t,n]=(0,U.useState)(30),r=e.profile,s=e.pluginReports??[],l=r.actor.fullName??r.actor.slackUserName??r.actor.email;return/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[/* @__PURE__ */ (0,W.jsxs)(i,{className:`flex w-fit items-center gap-2 font-display text-sm font-medium text-dashboard-text-muted no-underline transition-colors hover:text-dashboard-text`,to:`/system/people`,children:[/* @__PURE__ */ (0,W.jsx)(o,{"aria-hidden":`true`,size:15,strokeWidth:1.8}),`Back to people`]}),/* @__PURE__ */ (0,W.jsx)(x,{description:/* @__PURE__ */ (0,W.jsxs)(W.Fragment,{children:[r.actor.email,r.actor.slackUserName?` / @${r.actor.slackUserName}`:``]}),onRangeChange:n,range:t,title:l}),/* @__PURE__ */ (0,W.jsxs)(`section`,{className:`grid gap-4`,"aria-labelledby":D(`usage`),children:[/* @__PURE__ */ (0,W.jsx)(j,{anchor:`usage`,title:`Usage over time`}),/* @__PURE__ */ (0,W.jsx)(R,{bucketUnit:b(t),days:y({days:r.activityDays,hours:r.activityHours,sixHours:r.activitySixHours,range:t,emptySixHour:e=>({active:0,conversations:0,date:e,durationMs:0,failed:0})})})]}),e.codeError?/* @__PURE__ */ (0,W.jsx)(_,{className:`border-amber-300/10 bg-amber-300/[0.025]`,padding:`sm`,children:/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-display text-sm font-medium text-dashboard-text-muted`,children:`Code activity failed to load.`})}):null,!e.codeLoading&&e.code?/* @__PURE__ */ (0,W.jsx)(ae,{range:t,report:e.code}):null,e.pluginReportsError?/* @__PURE__ */ (0,W.jsx)(_,{className:`border-amber-300/10 bg-amber-300/[0.025]`,padding:`sm`,children:/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-display text-sm font-medium text-dashboard-text-muted`,children:`Plugin activity failed to load.`})}):null,e.pluginReportsLoading?null:/* @__PURE__ */ (0,W.jsx)(oe,{range:t,reports:s}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid min-w-0 gap-5 lg:grid-cols-[minmax(0,1fr)_19rem] lg:items-start`,children:[/* @__PURE__ */ (0,W.jsx)(`aside`,{className:`grid min-w-0 gap-4 lg:order-2`,children:/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3 lg:grid-cols-1`,children:[/* @__PURE__ */ (0,W.jsx)(B,{detail:`Across the complete conversation index`,icon:a,label:`Conversations`,value:C(r.totals.conversations)}),/* @__PURE__ */ (0,W.jsx)(B,{detail:`Cumulative persisted conversation runtime`,icon:c,label:`Runtime`,value:/* @__PURE__ */ (0,W.jsx)(S,{value:r.totals.durationMs})}),/* @__PURE__ */ (0,W.jsx)(B,{detail:`Persisted model token usage`,icon:u,label:`Tokens`,value:C(r.totals.tokens??0)})]})}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid min-w-0 gap-5 lg:order-1`,children:[/* @__PURE__ */ (0,W.jsxs)(_,{as:`section`,className:`mb-0`,variant:`section`,children:[/* @__PURE__ */ (0,W.jsx)(V,{actions:/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:`52 weeks`}),children:/* @__PURE__ */ (0,W.jsx)(H,{children:`Activity`})}),/* @__PURE__ */ (0,W.jsx)(G,{days:r.activityDays})]}),/* @__PURE__ */ (0,W.jsx)(de,{items:r.surfaces,title:`Surfaces`})]})]})]})}function de(e){return e.items.length<=1?null:/* @__PURE__ */ (0,W.jsxs)(_,{as:`section`,className:`mb-0`,variant:`section`,children:[/* @__PURE__ */ (0,W.jsx)(V,{children:/* @__PURE__ */ (0,W.jsx)(H,{children:e.title})}),/* @__PURE__ */ (0,W.jsx)(`ol`,{className:`m-0 list-none p-0`,children:e.items.slice(0,6).map((e,t)=>/* @__PURE__ */ (0,W.jsxs)(`li`,{className:`grid min-w-0 grid-cols-[2rem_minmax(0,1fr)_auto] items-center gap-3 border-b border-dashboard-border-subtle px-4 py-3 last:border-b-0`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-mono text-xs leading-none text-dashboard-text-muted`,children:t+1}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`truncate font-display text-base font-medium leading-tight text-dashboard-text`,children:e.label}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-1 truncate font-mono text-xs leading-tight text-dashboard-text-muted`,children:[ce(e.durationMs,e.conversations),e.tokens?` / ${C(e.tokens)} tokens`:``,e.failed?` / ${C(e.failed)} errors`:``]})]}),/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-display text-xl font-light leading-none text-dashboard-text`,children:C(e.conversations)})]},e.label))})]})}export{le as PersonProfilePage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{ot as t,pt as n,ut as r}from"./vendor-lthmb2su.js";import{C as i,S as a}from"./vendor-react-ggbyvons.js";import{t as o}from"./button-ygjnb239.js";import{$ as s,l as c}from"./vendor-icons-mxz7yi04.js";import{O as l,x as u}from"./junior-hdb4wc4q.js";import{i as d,o as f,r as p}from"./http-cdq677qt.js";import{t as m}from"./Card-hy4bfgq7.js";import{m as h}from"./PageHeader-bhl3orzi.js";import{W as g,_t as _,s as v}from"../client-f7asutg5.js";var y=/* @__PURE__ */ e(i(),1),b=a();const x=[`dashboard`,`personal-tokens`];function S(){let e=n(),i=(0,y.useRef)(!1),[a,S]=(0,y.useState)(`Local agent`),C=()=>e.cancelQueries({exact:!0,queryKey:x}),w=r({queryKey:x,queryFn:({signal:e})=>d(l,`/api/personal-tokens`,e),retry:!1}),T=t({gcTime:0,mutationFn:e=>f(u,`/api/personal-tokens`,{name:e}),onMutate:()=>C(),onSuccess:async t=>{let{token:n,...r}=t;await C(),e.setQueryData(x,e=>({tokens:[r,...(e?.tokens??[]).filter(e=>e.id!==r.id)]}))},onSettled:()=>{i.current=!1}}),E=t({mutationFn:e=>p(`/api/personal-tokens/${encodeURIComponent(e.id)}`),onMutate:()=>C(),onSuccess:async(t,n)=>{await C(),e.setQueryData(x,e=>({tokens:(e?.tokens??[]).filter(e=>e.id!==n.id)})),T.data?.id===n.id&&T.reset()}}),D=T.data,O=w.data?.tokens??[],k=w.isPending,A=T.isPending||E.isPending,j=!k&&!A&&!!a.trim(),M=(T.isError?`Could not create the API token. Try again.`:E.isError?`Could not revoke the API token. Try again.`:void 0)??(!w.data&&w.isError?`Could not load API tokens. Try again.`:void 0);return/* @__PURE__ */ (0,b.jsxs)(v,{description:/* @__PURE__ */ (0,b.jsxs)(b.Fragment,{children:[`Use a token to read `,h(),` APIs from a local agent or script. Tokens expire after 90 days.`]}),title:`API Tokens`,children:[D?/* @__PURE__ */ (0,b.jsxs)(`div`,{className:`rounded-md border border-emerald-400/40 bg-emerald-400/5 p-3`,children:[/* @__PURE__ */ (0,b.jsx)(`p`,{className:`mt-0 mb-2 text-sm font-semibold`,children:`Copy this token now. It won't be shown again.`}),/* @__PURE__ */ (0,b.jsx)(`code`,{className:`block overflow-x-auto rounded-md bg-dashboard-ink p-2 text-xs text-emerald-300`,children:D.token}),/* @__PURE__ */ (0,b.jsx)(o,{className:`mt-3`,onClick:()=>{T.reset(),S(`Local agent`)},children:`Create another token`})]}):/* @__PURE__ */ (0,b.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),j&&!i.current&&(E.reset(),i.current=!0,T.mutate(a))},children:[/* @__PURE__ */ (0,b.jsx)(_,{"aria-label":`Token name`,className:`min-w-0 flex-1`,maxLength:80,onChange:e=>S(e.target.value),value:a}),/* @__PURE__ */ (0,b.jsx)(o,{disabled:!j,type:`submit`,children:`Create token`})]}),M?/* @__PURE__ */ (0,b.jsx)(g,{children:M}):null,/* @__PURE__ */ (0,b.jsx)(m,{className:`mb-0`,variant:`raised`,children:k?/* @__PURE__ */ (0,b.jsx)(`p`,{className:`m-0 p-5 text-sm text-dashboard-text-muted`,children:`Loading API tokens…`}):O.length===0?/* @__PURE__ */ (0,b.jsx)(`p`,{className:`m-0 p-5 text-sm text-dashboard-text-muted`,children:`No active API tokens.`}):/* @__PURE__ */ (0,b.jsx)(`ul`,{className:`m-0 list-none divide-y divide-dashboard-border-subtle p-0`,children:O.map(e=>/* @__PURE__ */ (0,b.jsxs)(`li`,{className:`flex items-center gap-3 px-5 py-4`,children:[/* @__PURE__ */ (0,b.jsx)(s,{className:`text-dashboard-accent`,size:16}),/* @__PURE__ */ (0,b.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[/* @__PURE__ */ (0,b.jsx)(`p`,{className:`m-0 truncate text-sm font-semibold`,children:e.name}),/* @__PURE__ */ (0,b.jsxs)(`p`,{className:`mt-1 mb-0 text-xs text-dashboard-text-muted`,children:[`Ends in `,e.tokenSuffix,` · Expires`,` `,new Date(e.expiresAt).toLocaleDateString()]})]}),/* @__PURE__ */ (0,b.jsx)(o,{"aria-label":`Revoke ${e.name}`,disabled:A,onClick:()=>{T.isError&&T.reset(),E.mutate(e)},size:`icon`,variant:`danger`,type:`button`,children:/* @__PURE__ */ (0,b.jsx)(c,{size:16})})]},e.id))})})]})}export{S as PersonalTokensPage};
1
+ import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{ot as t,pt as n,ut as r}from"./vendor-lthmb2su.js";import{C as i,S as a}from"./vendor-react-ggbyvons.js";import{t as o}from"./button-ygjnb239.js";import{$ as s,l as c}from"./vendor-icons-blmhaswc.js";import{O as l,x as u}from"./junior-g62bxb2t.js";import{i as d,o as f,r as p}from"./http-cdq677qt.js";import{t as m}from"./Card-hy4bfgq7.js";import{m as h}from"./PageHeader-bhl3orzi.js";import{X as g,d as _,wt as v}from"../client-ctcthgam.js";var y=/* @__PURE__ */ e(i(),1),b=a();const x=[`dashboard`,`personal-tokens`];function S(){let e=n(),i=(0,y.useRef)(!1),[a,S]=(0,y.useState)(`Local agent`),C=()=>e.cancelQueries({exact:!0,queryKey:x}),w=r({queryKey:x,queryFn:({signal:e})=>d(l,`/api/personal-tokens`,e),retry:!1}),T=t({gcTime:0,mutationFn:e=>f(u,`/api/personal-tokens`,{name:e}),onMutate:()=>C(),onSuccess:async t=>{let{token:n,...r}=t;await C(),e.setQueryData(x,e=>({tokens:[r,...(e?.tokens??[]).filter(e=>e.id!==r.id)]}))},onSettled:()=>{i.current=!1}}),E=t({mutationFn:e=>p(`/api/personal-tokens/${encodeURIComponent(e.id)}`),onMutate:()=>C(),onSuccess:async(t,n)=>{await C(),e.setQueryData(x,e=>({tokens:(e?.tokens??[]).filter(e=>e.id!==n.id)})),T.data?.id===n.id&&T.reset()}}),D=T.data,O=w.data?.tokens??[],k=w.isPending,A=T.isPending||E.isPending,j=!k&&!A&&!!a.trim(),M=(T.isError?`Could not create the API token. Try again.`:E.isError?`Could not revoke the API token. Try again.`:void 0)??(!w.data&&w.isError?`Could not load API tokens. Try again.`:void 0);return/* @__PURE__ */ (0,b.jsxs)(_,{description:/* @__PURE__ */ (0,b.jsxs)(b.Fragment,{children:[`Use a token to read `,h(),` APIs from a local agent or script. Tokens expire after 90 days.`]}),title:`API Tokens`,children:[D?/* @__PURE__ */ (0,b.jsxs)(`div`,{className:`rounded-md border border-emerald-400/40 bg-emerald-400/5 p-3`,children:[/* @__PURE__ */ (0,b.jsx)(`p`,{className:`mt-0 mb-2 text-sm font-semibold`,children:`Copy this token now. It won't be shown again.`}),/* @__PURE__ */ (0,b.jsx)(`code`,{className:`block overflow-x-auto rounded-md bg-dashboard-ink p-2 text-xs text-emerald-300`,children:D.token}),/* @__PURE__ */ (0,b.jsx)(o,{className:`mt-3`,onClick:()=>{T.reset(),S(`Local agent`)},children:`Create another token`})]}):/* @__PURE__ */ (0,b.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),j&&!i.current&&(E.reset(),i.current=!0,T.mutate(a))},children:[/* @__PURE__ */ (0,b.jsx)(v,{"aria-label":`Token name`,className:`min-w-0 flex-1`,maxLength:80,onChange:e=>S(e.target.value),value:a}),/* @__PURE__ */ (0,b.jsx)(o,{disabled:!j,type:`submit`,children:`Create token`})]}),M?/* @__PURE__ */ (0,b.jsx)(g,{children:M}):null,/* @__PURE__ */ (0,b.jsx)(m,{className:`mb-0`,variant:`raised`,children:k?/* @__PURE__ */ (0,b.jsx)(`p`,{className:`m-0 p-5 text-sm text-dashboard-text-muted`,children:`Loading API tokens…`}):O.length===0?/* @__PURE__ */ (0,b.jsx)(`p`,{className:`m-0 p-5 text-sm text-dashboard-text-muted`,children:`No active API tokens.`}):/* @__PURE__ */ (0,b.jsx)(`ul`,{className:`m-0 list-none divide-y divide-dashboard-border-subtle p-0`,children:O.map(e=>/* @__PURE__ */ (0,b.jsxs)(`li`,{className:`flex items-center gap-3 px-5 py-4`,children:[/* @__PURE__ */ (0,b.jsx)(s,{className:`text-dashboard-accent`,size:16}),/* @__PURE__ */ (0,b.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[/* @__PURE__ */ (0,b.jsx)(`p`,{className:`m-0 truncate text-sm font-semibold`,children:e.name}),/* @__PURE__ */ (0,b.jsxs)(`p`,{className:`mt-1 mb-0 text-xs text-dashboard-text-muted`,children:[`Ends in `,e.tokenSuffix,` · Expires`,` `,new Date(e.expiresAt).toLocaleDateString()]})]}),/* @__PURE__ */ (0,b.jsx)(o,{"aria-label":`Revoke ${e.name}`,disabled:A,onClick:()=>{T.isError&&T.reset(),E.mutate(e)},size:`icon`,variant:`danger`,type:`button`,children:/* @__PURE__ */ (0,b.jsx)(c,{size:16})})]},e.id))})})]})}export{S as PersonalTokensPage};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{nt as t}from"./vendor-lthmb2su.js";import{C as n,S as r}from"./vendor-react-ggbyvons.js";import{Pt as i}from"./vendor-icons-blmhaswc.js";import{i as a,t as o}from"./styles-j0007fov.js";import{t as s}from"./Card-hy4bfgq7.js";import{a as c,d as l,o as u,u as d}from"./PageHeader-bhl3orzi.js";import{c as f,l as p,p as m,q as h}from"./format-flkutk9e.js";import{$ as g,ct as _,et as v,it as y,nt as b,ot as x,rt as S,st as C,tt as w}from"../client-ctcthgam.js";import{$t as ee,A as te,At as T,C as E,Ct as D,D as ne,E as re,Et as O,F as ie,Ft as ae,H as oe,It as se,J as ce,K as le,Lt as ue,M as de,Mt as fe,N as pe,Nt as me,O as he,P as ge,Qt as _e,R as ve,S as ye,Tt as k,U as A,Vt as j,Yt as M,Z as N,_ as be,a as P,ct as xe,d as F,dt as Se,f as Ce,g as we,gt as Te,h as Ee,ht as De,it as Oe,k as ke,n as I,o as L,p as Ae,q as je,r as Me,s as R,st as Ne,t as z,u as Pe,ut as Fe,v as Ie,x as Le,yt as Re,zt as B}from"./chart-il2ahs5y.js";import{a as ze,c as Be,i as Ve,l as He,n as V,o as Ue,r as We,s as Ge,t as H}from"./BarChart-lbkezxbi.js";import{t as Ke}from"./Area-d95rfkv5.js";import{t as qe}from"./ChartLegend-c3e9l1vl.js";import{t as Je}from"./ChartHeader-c1zg4xt5.js";var U=/* @__PURE__ */ e(n()),Ye=[`option`,`isActive`];function W(){return W=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},W.apply(null,arguments)}function Xe(e,t){if(e==null)return{};var n,r,i=Ze(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Ze(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Qe(e){var{option:t,isActive:n}=e,r=Xe(e,Ye);return typeof t==`string`?/*#__PURE__*/ U.createElement(Ge,W({option:/*#__PURE__*/ U.createElement(He,W({type:t},r)),isActive:n,shapeType:`symbols`},r)):/*#__PURE__*/ U.createElement(Ge,W({option:t,isActive:n,shapeType:`symbols`},r))}var $e=(e,t,n,r,i,a,o)=>A(e,`xAxis`,t,o),et=(e,t,n,r,i,a,o)=>le(e,`xAxis`,t,o),tt=(e,t,n,r,i,a,o)=>A(e,`yAxis`,n,o),nt=(e,t,n,r,i,a,o)=>le(e,`yAxis`,n,o),rt=(e,t,n,r)=>ce(e,`zAxis`,r,!1),it=(e,t,n,r,i)=>i,at=(e,t,n,r,i,a)=>a,ot=(e,t,n,r,i,a,o)=>Oe(e,void 0,void 0,o),st=T([je,it],(e,t)=>e.filter(e=>e.type===`scatter`).find(e=>e.id===t)),ct=T([ot,$e,et,tt,nt,rt,st,at],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=e;if(o!=null){var d=o?.data!=null&&o.data.length>0?o.data:c?.slice(l,u+1);if(d!=null&&t!=null&&r!=null&&n!=null&&i!=null&&n?.length!==0&&i?.length!==0)return Ct({displayedData:d,xAxis:t,yAxis:r,zAxis:a,scatterSettings:o,xAxisTicks:n,yAxisTicks:i,cells:s})}}),lt=[`id`],ut=[`onMouseEnter`,`onClick`,`onMouseLeave`],dt=[`animationBegin`,`animationDuration`,`animationEasing`,`hide`,`isAnimationActive`,`legendType`,`lineJointType`,`lineType`,`shape`,`xAxisId`,`yAxisId`,`zAxisId`];function G(e,t){if(e==null)return{};var n,r,i=ft(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function ft(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function K(){return K=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},K.apply(null,arguments)}function pt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?pt(Object(n),!0).forEach(function(t){mt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function mt(e,t,n){return(t=ht(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ht(e){var t=gt(e,`string`);return typeof t==`symbol`?t:t+``}function gt(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var _t=e=>{var{dataKey:t,name:n,fill:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:k(n,t),payload:e}]},vt=/*#__PURE__*/ U.memo(e=>{var{dataKey:t,points:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,tooltipType:c,id:l}=e,u={dataDefinedOnItem:n?.map(e=>e.tooltipPayload),getPosition:e=>{var t;return n==null||(t=n[Number(e)])==null?void 0:t.tooltipPosition},settings:{stroke:r,strokeWidth:i,fill:a,nameKey:void 0,dataKey:t,name:k(o,t),hide:s,type:c,color:a,unit:``,graphicalItemId:l}};return/*#__PURE__*/ U.createElement(ke,{tooltipEntrySettings:u})});function yt(e){var{points:t,props:n}=e,{line:r,lineType:i,lineJointType:a}=n;if(!r)return null;var o=_e(n),s=ee(r),c,l;if(i===`joint`)c=t.map(e=>({x:e.cx??null,y:e.cy??null}));else if(i===`fitting`){var{xmin:u,xmax:d,a:f,b:p}=ue(t),m=e=>f*e+p;c=[{x:u,y:m(u)},{x:d,y:m(d)}]}var h=q(q(q({},o),{},{fill:`none`,stroke:o&&o.fill},s),{},{points:c});return l=/*#__PURE__*/ U.isValidElement(r)?/*#__PURE__*/ U.cloneElement(r,h):typeof r==`function`?r(h):/*#__PURE__*/ U.createElement(Fe,K({},h,{type:a})),/*#__PURE__*/ U.createElement(M,{className:`recharts-scatter-line`,key:`recharts-scatter-line`},l)}function bt(e){var{showLabels:t,points:n,children:r}=e,i=De(),a=(0,U.useMemo)(()=>n?.map(e=>{var t={x:e.x??0,y:e.y??0,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width};return q(q({},t),{},{value:void 0,payload:e.payload,viewBox:t,parentViewBox:i,fill:void 0})}),[i,n]);return/*#__PURE__*/ U.createElement(de,{value:t?a:void 0},r)}function xt(e){var{points:t,allOtherScatterProps:n}=e,{shape:r,activeShape:i,dataKey:a}=n,{id:o}=n,s=G(n,lt),c=fe(ve),{onMouseEnter:l,onClick:u,onMouseLeave:d}=n,f=G(n,ut),p=ze(l,a,o),m=Ue(d),h=Ve(u,a,o);if(!se(t))return null;var g=_e(s);return/*#__PURE__*/ U.createElement(U.Fragment,null,/*#__PURE__*/ U.createElement(yt,{points:t,props:s}),t.map((e,t)=>{var n=i!=null&&i!==!1,a=n&&c===String(t),s=n&&a?i:r,l=q(q(q({},g),e),{},{index:t,[Re]:String(o)});return/*#__PURE__*/ U.createElement(ie,{key:`symbol-${e?.cx}-${e?.cy}-${e?.size}-${t}`,zIndex:a?N.activeDot:void 0},/*#__PURE__*/ U.createElement(M,K({className:`recharts-scatter-symbol`},ae(f,e,t),{onMouseEnter:p(e,t),onMouseLeave:m(e,t),onClick:h(e,t)}),/*#__PURE__*/ U.createElement(Qe,K({option:s,isActive:a},l))))}))}function St(e){var{previousPointsRef:t,props:n}=e,{points:r,isAnimationActive:i,animationBegin:a,animationDuration:o,animationEasing:s}=n,c=t.current,l=Ne(n,`recharts-scatter-`),[u,d]=(0,U.useState)(!1),f=(0,U.useCallback)(()=>{d(!1)},[]),p=(0,U.useCallback)(()=>{d(!0)},[]),m=!u;return/*#__PURE__*/ U.createElement(bt,{showLabels:m,points:r},n.children,/*#__PURE__*/ U.createElement(xe,{animationId:l,begin:a,duration:o,isActive:i,easing:s,onAnimationEnd:f,onAnimationStart:p,key:l},e=>{var i=e===1?r:r?.map((t,n)=>{var r=c&&c[n];return r?q(q({},t),{},{cx:t.cx==null?void 0:B(r.cx,t.cx,e),cy:t.cy==null?void 0:B(r.cy,t.cy,e),size:B(r.size,t.size,e)}):q(q({},t),{},{size:B(0,t.size,e)})});return e>0&&(t.current=i),/*#__PURE__*/ U.createElement(M,null,/*#__PURE__*/ U.createElement(xt,{points:i,allOtherScatterProps:n,showLabels:m}))}),/*#__PURE__*/ U.createElement(pe,{label:n.label}))}function Ct(e){var{displayedData:t,xAxis:n,yAxis:r,zAxis:i,scatterSettings:a,xAxisTicks:o,yAxisTicks:s,cells:c}=e,l=j(n.dataKey)?a.dataKey:n.dataKey,u=j(r.dataKey)?a.dataKey:r.dataKey,d=i&&i.dataKey,f=i?i.range:oe.range,p=f&&f[0],m=n.scale.bandwidth?n.scale.bandwidth():0,h=r.scale.bandwidth?r.scale.bandwidth():0;return t.map((e,t)=>{var f=O(e,l),g=O(e,u),_=!j(d)&&O(e,d)||`-`,v=[{name:j(n.dataKey)?a.name:n.name||String(n.dataKey),unit:n.unit||``,value:f,payload:e,dataKey:l,type:a.tooltipType,graphicalItemId:a.id},{name:j(r.dataKey)?a.name:r.name||String(r.dataKey),unit:r.unit||``,value:g,payload:e,dataKey:u,type:a.tooltipType,graphicalItemId:a.id}];_!==`-`&&i!=null&&v.push({name:i.name||i.dataKey,unit:i.unit||``,value:_,payload:e,dataKey:d,type:a.tooltipType,graphicalItemId:a.id});var y=D({axis:n,ticks:o,bandSize:m,entry:e,index:t,dataKey:l}),b=D({axis:r,ticks:s,bandSize:h,entry:e,index:t,dataKey:u}),x=_!==`-`&&i!=null?i.scale.map(_):p,S=x==null?0:Math.sqrt(Math.max(x,0)/Math.PI);return q(q({},e),{},{cx:y,cy:b,x:y==null?void 0:y-S,y:b==null?void 0:b-S,width:2*S,height:2*S,size:x,node:{x:f,y:g,z:_},tooltipPayload:v,tooltipPosition:{x:y,y:b},payload:e},c&&c[t]&&c[t].props)})}var wt=(e,t,n)=>({x:e.cx,y:e.cy,value:Number(n===`x`?e.node.x:e.node.y),errorVal:O(e,t)});function Tt(e){var{hide:n,points:r,className:i,needClip:a,xAxisId:o,yAxisId:s,id:c}=e,l=(0,U.useRef)(null);if(n)return null;var u=t(`recharts-scatter`,i),d=c;return/*#__PURE__*/ U.createElement(ie,{zIndex:e.zIndex},/*#__PURE__*/ U.createElement(M,{className:u,clipPath:a?`url(#clipPath-${d})`:void 0,id:c},a&&/*#__PURE__*/ U.createElement(`defs`,null,/*#__PURE__*/ U.createElement(Le,{clipPathId:d,xAxisId:o,yAxisId:s})),/*#__PURE__*/ U.createElement(We,{xAxisId:o,yAxisId:s,data:r,dataPointFormatter:wt,errorBarOffset:0},/*#__PURE__*/ U.createElement(M,{key:`recharts-scatter-symbols`},/*#__PURE__*/ U.createElement(St,{props:e,previousPointsRef:l})))))}var Et={xAxisId:0,yAxisId:0,zAxisId:0,label:!1,line:!1,legendType:`circle`,lineType:`joint`,lineJointType:`linear`,shape:`circle`,hide:!1,isAnimationActive:`auto`,animationBegin:0,animationDuration:400,animationEasing:`linear`,zIndex:N.scatter};function Dt(e){var t=me(e,Et),{animationBegin:n,animationDuration:r,animationEasing:i,hide:a,isAnimationActive:o,legendType:s,lineJointType:c,lineType:l,shape:u,xAxisId:d,yAxisId:f,zAxisId:p}=t,m=G(t,dt),{needClip:h}=ye(d,f),g=(0,U.useMemo)(()=>te(e.children,Be),[e.children]),_=Te(),v=fe(t=>ct(t,d,f,p,e.id,g,_));return h==null||v==null?null:/*#__PURE__*/ U.createElement(U.Fragment,null,/*#__PURE__*/ U.createElement(vt,{dataKey:e.dataKey,points:v,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:e.id}),/*#__PURE__*/ U.createElement(Tt,K({},m,{xAxisId:d,yAxisId:f,zAxisId:p,lineType:l,lineJointType:c,legendType:s,shape:u,hide:a,isAnimationActive:o,animationBegin:n,animationDuration:r,animationEasing:i,points:v,needClip:h})))}function Ot(e){var t=me(e,Et),n=Te();return/*#__PURE__*/ U.createElement(ne,{id:t.id,type:`scatter`},e=>/*#__PURE__*/ U.createElement(U.Fragment,null,/*#__PURE__*/ U.createElement(he,{legendPayload:_t(t)}),/*#__PURE__*/ U.createElement(re,{type:`scatter`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:t.zAxisId,dataKey:t.dataKey,hide:t.hide,name:t.name,tooltipType:t.tooltipType,isPanorama:n}),/*#__PURE__*/ U.createElement(Dt,K({},t,{id:e}))))}var kt=/*#__PURE__*/ U.memo(Ot,Se);kt.displayName=`Scatter`;var At=[`axis`],jt=/*#__PURE__*/ (0,U.forwardRef)((e,t)=>/*#__PURE__*/ U.createElement(be,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:At,tooltipPayloadSearcher:ge,categoricalChartProps:e,ref:t}));const J=[{key:`cachedInputTokens`,label:`From cache`,color:`var(--color-cyan-400)`},{key:`cacheCreationTokens`,label:`Written to cache`,color:`var(--color-amber-400)`},{key:`inputTokens`,label:`Uncached`,color:`var(--color-violet-400)`}];function Y(e){if(!J.some(({key:t})=>e[t]===void 0))return J.reduce((t,{key:n})=>t+e[n],0)}function X(e,t){if(e===void 0||t===void 0||t===0)return`—`;let n=e/t*100;return n<100&&n>=99.95?`<100%`:n>0&&n<.05?`<0.1%`:`${n.toFixed(1)}%`}function Mt(e){return J.some(({key:t})=>e[t]!==void 0)||(e.tokens??0)>0||e.durationMs>0||e.conversations>0}function Nt(e){let t=e.filter(Mt),n={};for(let{key:e}of J)t.length&&t.every(t=>t[e]!==void 0)&&(n[e]=t.reduce((t,n)=>t+n[e],0));return{input:n,total:Y(n),activePeriods:t.length,incompletePeriods:t.filter(e=>Y(e)===void 0).length}}var Z=r();function Pt(e){let t=e.days.filter(e=>(e.cacheCreationTokens??0)>0).sort((e,t)=>t.cacheCreationTokens-e.cacheCreationTokens||t.date.localeCompare(e.date)).slice(0,3);if(!t.length)return null;let n=e.bucketUnit===`6hour`?`6 hours`:e.bucketUnit;return/* @__PURE__ */ (0,Z.jsxs)(x,{className:`border-t border-dashboard-border-subtle px-4 py-3 sm:px-5`,children:[/* @__PURE__ */ (0,Z.jsxs)(_,{className:`group flex cursor-pointer items-center gap-1 font-sans tabular-nums text-xs text-dashboard-text focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus`,children:[/* @__PURE__ */ (0,Z.jsx)(i,{"aria-hidden":`true`,className:a}),`Largest cache writes`]}),/* @__PURE__ */ (0,Z.jsxs)(C,{hiddenUntilFound:!0,children:[/* @__PURE__ */ (0,Z.jsxs)(`p`,{className:`mb-2 mt-3 font-sans tabular-nums text-xs leading-relaxed text-dashboard-text-muted`,children:[`Top three by tokens written per `,n,`, within the selected time window. Large writes alone do not mean a cache problem.`]}),/* @__PURE__ */ (0,Z.jsxs)(g,{"aria-label":`Largest cache writes`,className:`min-w-80 table-fixed font-sans text-xs tabular-nums`,children:[/* @__PURE__ */ (0,Z.jsx)(S,{children:/* @__PURE__ */ (0,Z.jsxs)(y,{children:[/* @__PURE__ */ (0,Z.jsx)(b,{scope:`col`,className:`px-0 py-2 font-normal`,children:e.bucketUnit===`day`?`Day`:`Starting at`}),/* @__PURE__ */ (0,Z.jsx)(b,{scope:`col`,className:`w-24 px-0 py-2 text-right font-normal`,children:`Written`}),/* @__PURE__ */ (0,Z.jsx)(b,{scope:`col`,className:`w-24 px-0 py-2 text-right font-normal`,children:`From cache`})]})}),/* @__PURE__ */ (0,Z.jsx)(v,{children:t.map(e=>/* @__PURE__ */ (0,Z.jsxs)(y,{children:[/* @__PURE__ */ (0,Z.jsx)(b,{scope:`row`,className:`px-0 py-2 font-normal whitespace-normal`,children:Ee(e.date)}),/* @__PURE__ */ (0,Z.jsx)(w,{className:`px-0 py-2 text-right whitespace-normal`,children:p(e.cacheCreationTokens)}),/* @__PURE__ */ (0,Z.jsx)(w,{className:`px-0 py-2 text-right whitespace-normal`,children:X(e.cachedInputTokens,Y(e))})]},e.date))})]})]})]})}const Ft={...Object.fromEntries(J.map(({color:e,key:t,label:n})=>[t,{color:e,label:n}])),missing:{color:`var(--color-slate-400)`,label:`Missing data`}};function It(e){let[t,n]=(0,U.useState)(`share`),r=Nt(e.days),o=e.days.map(e=>{let n=Y(e);return{...Object.fromEntries(J.map(({key:r})=>{let i=e[r]??0;return[r,t===`share`?n?i/n*100:0:i]})),date:e.date,day:e,missing:n===void 0&&Mt(e)?0:void 0}}),c=t===`share`?100:Math.max(1,...e.days.map(e=>J.reduce((t,{key:n})=>t+(e[n]??0),0)));return/* @__PURE__ */ (0,Z.jsxs)(s,{children:[/* @__PURE__ */ (0,Z.jsx)(Je,{title:`Input cache`,trailing:/* @__PURE__ */ (0,Z.jsxs)(d,{"aria-label":`Cache chart display`,onValueChange:([e])=>{e&&n(e)},value:[t],children:[/* @__PURE__ */ (0,Z.jsx)(l,{value:`share`,children:`Percent`}),/* @__PURE__ */ (0,Z.jsx)(l,{value:`tokens`,children:`Tokens`})]})}),/* @__PURE__ */ (0,Z.jsx)(`dl`,{className:`m-0 flex flex-wrap gap-x-5 gap-y-2 px-4 py-3 font-sans tabular-nums text-xs sm:px-5`,children:J.map(({key:e,label:t,color:n})=>/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[/* @__PURE__ */ (0,Z.jsxs)(`dt`,{className:`flex items-center gap-1.5 text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 rounded-full`,style:{backgroundColor:n}}),t]}),/* @__PURE__ */ (0,Z.jsx)(`dd`,{className:`m-0 tabular-nums text-dashboard-text`,children:X(r.input[e],r.total)})]},e))}),r.activePeriods===0?/* @__PURE__ */ (0,Z.jsx)(`p`,{className:`m-0 px-4 pb-2 font-sans tabular-nums text-xs text-dashboard-text-muted sm:px-5`,children:`No input data in this time window.`}):r.incompletePeriods>0?/* @__PURE__ */ (0,Z.jsxs)(`p`,{className:`m-0 px-4 pb-2 font-sans tabular-nums text-xs text-dashboard-text-muted sm:px-5`,children:[`Missing data in `,r.incompletePeriods,` of `,r.activePeriods,` `,`active time intervals. Percentages are unavailable; Tokens shows the reported values.`]}):null,/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`px-2 pb-2`,children:/* @__PURE__ */ (0,Z.jsx)(z,{className:`aspect-auto h-40 w-full`,config:Ft,children:/* @__PURE__ */ (0,Z.jsxs)(H,{"aria-label":`Input cache ${t} per ${u(e.bucketUnit)}`,data:o,margin:F,role:`img`,children:[/* @__PURE__ */ (0,Z.jsx)(E,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,Z.jsx)(R,{format:t===`share`?e=>`${e}%`:p,maximum:c}),/* @__PURE__ */ (0,Z.jsx)(L,{keys:o.map(e=>e.date)}),/* @__PURE__ */ (0,Z.jsx)(Ie,{dataKey:`date`,hide:!0,xAxisId:`missing`}),/* @__PURE__ */ (0,Z.jsx)(I,{content:/* @__PURE__ */ (0,Z.jsx)(P,{rows:({day:e})=>{let t=Y(e);return J.map(({key:n,label:r})=>[r,e[n]===void 0?`Not reported`:`${p(e[n])} · ${X(e[n],t)}`])}})}),J.map(({key:e})=>/* @__PURE__ */ (0,Z.jsx)(V,{dataKey:e,fill:`var(--color-${e})`,fillOpacity:.85,isAnimationActive:!1,maxBarSize:32,stackId:`input`},e)),/* @__PURE__ */ (0,Z.jsx)(V,{dataKey:`missing`,fill:`var(--color-missing)`,isAnimationActive:!1,maxBarSize:32,minPointSize:3,xAxisId:`missing`})]})})}),/* @__PURE__ */ (0,Z.jsx)(Pt,{days:e.days,bucketUnit:e.bucketUnit}),/* @__PURE__ */ (0,Z.jsxs)(x,{className:`border-t border-dashboard-border-subtle px-4 py-3 font-sans tabular-nums text-xs text-dashboard-text-muted sm:px-5`,children:[/* @__PURE__ */ (0,Z.jsxs)(_,{className:`group flex cursor-pointer items-center gap-1 text-dashboard-text focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus`,children:[/* @__PURE__ */ (0,Z.jsx)(i,{"aria-hidden":`true`,className:a}),`How to read this`]}),/* @__PURE__ */ (0,Z.jsx)(C,{hiddenUntilFound:!0,children:/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 leading-relaxed`,children:[/* @__PURE__ */ (0,Z.jsx)(`p`,{className:`m-0`,children:`From cache is input reused. Written to cache is input saved for reuse. Uncached is the remaining input.`}),/* @__PURE__ */ (0,Z.jsx)(`p`,{className:`m-0`,children:`Percentages use total input tokens, not call counts. Gray marks and — mean missing data; zero means a reported zero. The latest interval may be incomplete.`}),/* @__PURE__ */ (0,Z.jsx)(`p`,{className:`m-0`,children:`These totals can show when reuse changes, but not why. They do not show individual calls or prove that every call reported cache use.`})]})})]})]})}function Lt(e){return e<1?`$${e.toFixed(2)}`:`$${p(e)}`}function Rt(e){let t=e/36e5;return t>=24?`${p(t/24)}d`:t>=1?`${p(t)}h`:h(e)}function zt(){return{axisFormat:p,color:`var(--color-cyan-400)`,format:p,metric:`tokens`,title:`Token usage`,type:`bar`}}function Bt(){return[{axisFormat:Lt,color:`var(--color-amber-400)`,format:e=>m({total:e}),metric:`costUsd`,title:`Model spend`,type:`area`},{axisFormat:Rt,color:`var(--color-violet-400)`,format:h,metric:`durationMs`,title:`Runtime`,type:`scatter`}]}function Vt(e,t){return e[t]??0}function Ht(e){let t=e.bucketUnit??`day`,n=e.cacheBreakdown?Bt():[zt(),...Bt()];return/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[e.cacheBreakdown?/* @__PURE__ */ (0,Z.jsx)(It,{bucketUnit:t,days:e.days}):null,/* @__PURE__ */ (0,Z.jsx)(`div`,{className:e.cacheBreakdown?`grid gap-4 lg:grid-cols-2`:`grid gap-4 lg:grid-cols-3`,children:n.map(n=>/* @__PURE__ */ (0,Z.jsx)(Ut,{bucketUnit:t,chart:n,days:e.days},n.metric))})]})}function Ut(e){let{chart:t,days:n}=e,r=n.map(e=>Vt(e,t.metric)),i=n.map((e,t)=>({date:e.date,value:r[t]})),a=Math.max(2**-52,...r),o=r.reduce((e,t)=>e+t,0),l=Pe(r),u={dataKey:`value`,fill:`var(--color-value)`,isAnimationActive:!1};return/* @__PURE__ */ (0,Z.jsxs)(s,{children:[/* @__PURE__ */ (0,Z.jsx)(Je,{title:t.title,total:t.format(o)}),/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`px-2 py-2`,children:/* @__PURE__ */ (0,Z.jsx)(z,{className:`aspect-auto h-38 w-full`,config:{value:{color:t.color,label:t.title}},children:/* @__PURE__ */ (0,Z.jsxs)(jt,{"aria-label":`${t.title} per ${e.bucketUnit===`6hour`?`6 hours`:e.bucketUnit}`,data:i,margin:F,role:`img`,children:[/* @__PURE__ */ (0,Z.jsx)(E,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,Z.jsx)(R,{format:t.axisFormat,maximum:a}),/* @__PURE__ */ (0,Z.jsx)(L,{keys:i.map(e=>e.date)}),/* @__PURE__ */ (0,Z.jsx)(I,{content:/* @__PURE__ */ (0,Z.jsx)(P,{rows:e=>[[t.title,t.format(e.value)]]})}),t.type===`bar`?/* @__PURE__ */ (0,Z.jsx)(V,{...u,fillOpacity:.8,maxBarSize:8,minPointSize:e=>e?2:0,radius:1.5}):t.type===`area`?/* @__PURE__ */ (0,Z.jsx)(Ke,{...u,dot:{fillOpacity:.45,r:2.5,stroke:`none`},fillOpacity:.08,stroke:`var(--color-value)`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,type:`linear`}):/* @__PURE__ */ (0,Z.jsx)(kt,{...u,fillOpacity:.75}),/* @__PURE__ */ (0,Z.jsx)(Me,{average:l,format:t.metric===`tokens`?f:t.format,stroke:t.color,unit:c(e.bucketUnit)})]})})})]})}const Q=[`var(--color-cyan-300)`,`var(--color-emerald-300)`,`var(--color-amber-400)`,`var(--color-rose-400)`,`var(--color-violet-400)`],Wt={danger:`var(--color-rose-400)`,good:`var(--color-emerald-300)`,neutral:`var(--color-cyan-300)`,warning:`var(--color-amber-400)`};function Gt(e,t){return e.tone?Wt[e.tone]:Q[t%Q.length]??Q[0]}function Kt(e,t){let n=e.timeRangeDays?e.categories.slice(-Jt(e,t)):e.categories,r=n.flatMap(t=>e.series.map(e=>t.values[e.key]??0)),i=Math.min(0,...r),a=Math.max(0,...r);return{categories:n,maximum:a===i?i+1:a,minimum:i}}function qt(e){let{widget:t}=e,{categories:n,maximum:r,minimum:i}=Kt(t,e.range),a=Xt(t),o=n.map(e=>({category:e,id:e.id,...Object.fromEntries(t.series.map((t,n)=>[`series-${n}`,e.values[t.key]??0]))})),s=new Map(n.map(e=>[e.id,e.label])),c=Object.fromEntries(t.series.map((e,t)=>[`series-${t}`,{color:Gt(e,t),label:e.label}]));return/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-md border border-dashboard-border bg-dashboard-surface-panel`,children:[/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:`border-b border-dashboard-border-subtle px-4 py-3`,children:[/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:/* @__PURE__ */ (0,Z.jsx)(`h4`,{className:`m-0 font-sans text-xs font-medium text-dashboard-text-muted`,children:t.title})}),t.description?/* @__PURE__ */ (0,Z.jsx)(`p`,{className:`mt-1 mb-0 font-mono text-xs text-dashboard-text-muted`,children:t.description}):null,t.series.length>1?/* @__PURE__ */ (0,Z.jsx)(qe,{ariaLabel:`Chart legend`,items:t.series.map((e,t)=>({color:Gt(e,t),key:e.key,label:e.label}))}):null]}),n.length===0?/* @__PURE__ */ (0,Z.jsx)(`p`,{className:`m-0 p-4 font-sans text-xs text-dashboard-text-muted`,children:t.emptyText??`No chart data.`}):/* @__PURE__ */ (0,Z.jsx)(z,{className:`aspect-auto h-60 w-full`,config:c,children:/* @__PURE__ */ (0,Z.jsxs)(H,{"aria-label":t.title,data:o,margin:F,role:`img`,children:[/* @__PURE__ */ (0,Z.jsx)(E,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,Z.jsx)(R,{format:e=>Zt(e,a),maximum:r,minimum:i}),/* @__PURE__ */ (0,Z.jsx)(L,{centered:!0,dataKey:`id`,formatLabel:e=>Ce(s.get(e)??e),keys:n.map(e=>e.id)}),/* @__PURE__ */ (0,Z.jsx)(I,{content:/* @__PURE__ */ (0,Z.jsx)(P,{formatLabel:e=>Ae(s.get(e)??e),rows:({category:e})=>t.series.map(t=>[t.label,Zt(e.values[t.key]??0,t.format)])})}),t.series.map((e,n)=>/* @__PURE__ */ (0,Z.jsx)(V,{dataKey:`series-${n}`,fill:`var(--color-series-${n})`,fillOpacity:.82,isAnimationActive:!1,maxBarSize:54/t.series.length,minPointSize:e=>e?2:0,radius:1.5},e.key))]})})]})}function Jt(e,t){let n=e.timeRangeDays??[],r=e.categories[0],i=r?.id||r?.label||``,a=we(i);return t===1?a&&n.includes(1)?24:n.includes(7)?7:n.includes(30)?30:n[0]??30:t&&n.includes(t)?t:n.includes(30)?30:n[0]??30}function Yt(e){return String(Number(e.toPrecision(12)))}function Xt(e){return new Set(e.series.map(e=>e.format)).size===1?e.series[0]?.format:void 0}function Zt(e,t){return t===`usd`?m({total:e}):Yt(e)}function Qt(e){let t=e.recordSet.fields??[],n=e.recordSet.records??[],r=e.embedded===!0;return/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:o(r?`border-t border-dashboard-border-subtle`:`overflow-hidden rounded-md border border-dashboard-border bg-dashboard-surface-panel`),children:[/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-5 py-3`,children:[/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:e.recordSet.title}),/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:`hidden font-mono text-xs text-dashboard-text-muted sm:block`,children:[n.length,` records`]})]}),n.length===0?/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`px-5 pb-5 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.recordSet.emptyText??`No records.`}):t.length===0?/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`px-5 pb-5 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:`Report records are unavailable because no fields were declared.`}):/* @__PURE__ */ (0,Z.jsxs)(Z.Fragment,{children:[/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`grid gap-2 border-t border-dashboard-border-subtle p-3 sm:hidden`,children:n.map(e=>/* @__PURE__ */ (0,Z.jsx)(`div`,{className:o(`grid gap-3 rounded-md border border-dashboard-border-subtle bg-dashboard-overlay-soft p-3`,$(e.tone)),children:t.map(t=>/* @__PURE__ */ (0,Z.jsxs)(`div`,{children:[/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:t.label}),/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`mt-1 break-words font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.values[t.key]??``})]},t.key))},e.id))}),/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`hidden border-t border-dashboard-border-subtle sm:block`,children:/* @__PURE__ */ (0,Z.jsxs)(g,{className:`min-w-[36rem]`,children:[/* @__PURE__ */ (0,Z.jsx)(S,{className:`bg-dashboard-overlay-soft`,children:/* @__PURE__ */ (0,Z.jsx)(y,{children:t.map(e=>/* @__PURE__ */ (0,Z.jsx)(b,{className:`px-5`,scope:`col`,children:e.label},e.key))})}),/* @__PURE__ */ (0,Z.jsx)(v,{children:n.map(e=>/* @__PURE__ */ (0,Z.jsx)(y,{className:$(e.tone),children:t.map(t=>/* @__PURE__ */ (0,Z.jsx)(w,{className:`max-w-72 truncate px-5 py-3 font-mono text-xs text-dashboard-text-muted`,children:e.values[t.key]??``},t.key))},e.id))})]})})]})]})}function $(e){return e===`danger`?`bg-rose-500/[0.07]`:e===`warning`?`bg-amber-300/[0.045]`:e===`good`?`bg-emerald-400/[0.055]`:``}export{qt as n,Ht as r,Qt as t};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{G as t,I as n,K as r,P as i,R as a,X as o,it as s,ot as c,pt as l,ut as u}from"./vendor-lthmb2su.js";import{C as d,S as f,_ as p,a as m,h as ee,p as h,y as g}from"./vendor-react-ggbyvons.js";import{t as _}from"./button-ygjnb239.js";import{Bt as te,Qt as v,_ as ne,gt as re,kt as ie,l as ae,o as oe}from"./vendor-icons-mxz7yi04.js";import{a as se,n as ce,t as le}from"./tooltip-h1yceend.js";import{Ut as ue}from"./junior-hdb4wc4q.js";import{i as y,r as de}from"./http-cdq677qt.js";import{r as fe,t as b}from"./styles-j0007fov.js";import{t as x}from"./Card-hy4bfgq7.js";import{t as S}from"./PageContentSkeleton-b7dkba0l.js";import{a as pe,r as C,s as me,t as w}from"./PageHeader-bhl3orzi.js";import{p as T}from"./format-gle1s0ri.js";import{t as he}from"./PageLayout-l6dhbimv.js";import{t as E}from"./AnchorHeading-cp3vx8qa.js";import{n as ge,t as D}from"./searchParams-moqjgi65.js";import{A as O,D as k,E as A,O as j,Rt as _e,T as M,W as N,j as P,k as F,n as ve,q as I,st as L,u as R,z as ye}from"../client-f7asutg5.js";import{t as be}from"./SelectableRow-j8fwjsjz.js";import{C as z,a as B,d as V,n as xe,o as Se,r as Ce,s as we,t as Te,u as Ee}from"./chart-myr1oeen.js";import{n as H,t as De}from"./BarChart-e3oi6in1.js";import{t as Oe}from"./ChartLegend-c3e9l1vl.js"
1
+ import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{G as t,I as n,K as r,P as i,R as a,X as o,it as s,ot as c,pt as l,ut as u}from"./vendor-lthmb2su.js";import{C as d,S as f,_ as p,a as m,h as ee,p as h,y as g}from"./vendor-react-ggbyvons.js";import{t as _}from"./button-ygjnb239.js";import{$t as v,Bt as te,_ as ne,gt as re,kt as ie,l as ae,o as oe}from"./vendor-icons-blmhaswc.js";import{a as se,n as ce,t as le}from"./tooltip-h1yceend.js";import{Wt as ue}from"./junior-g62bxb2t.js";import{i as y,r as de}from"./http-cdq677qt.js";import{r as fe,t as b}from"./styles-j0007fov.js";import{t as x}from"./Card-hy4bfgq7.js";import{t as S}from"./PageContentSkeleton-b7dkba0l.js";import{a as pe,r as C,s as me,t as w}from"./PageHeader-bhl3orzi.js";import{p as T}from"./format-flkutk9e.js";import{t as he}from"./PageLayout-l6dhbimv.js";import{t as E}from"./AnchorHeading-ixbupfij.js";import{n as ge,t as D}from"./searchParams-moqjgi65.js";import{F as O,G as _e,I as k,Kt as ve,L as A,M as j,N as M,P as N,Q as P,X as F,ft as I,j as L,m as R,n as ye}from"../client-ctcthgam.js";import{t as be}from"./SelectableRow-j8fwjsjz.js";import{C as z,a as B,d as V,n as xe,o as Se,r as Ce,s as we,t as Te,u as Ee}from"./chart-il2ahs5y.js";import{n as H,t as De}from"./BarChart-lbkezxbi.js";import{t as Oe}from"./ChartLegend-c3e9l1vl.js"
2
2
  /**
3
3
  * @license lucide-react v1.17.0 - ISC
4
4
  *
@@ -12,4 +12,4 @@ import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{G as t,I as n,K as r,P
12
12
  * This source code is licensed under the ISC license.
13
13
  * See the LICENSE file in the root directory of this source tree.
14
14
  */
15
- ;var U=/* @__PURE__ */ e(d(),1);function je(e){let[t,n]=g(),r=l(),i=(0,U.useRef)(!1),a=t.get(`filter`)?.trim()??``,[o,u,d]=ge(),f=s({initialPageParam:void 0,queryKey:[`dashboard`,`plugin-user-page`,e.pluginName,e.id,a,d],queryFn:({pageParam:t,signal:n})=>{let r=new URLSearchParams;a&&r.set(`filter`,a),d&&r.set(`q`,d),t&&r.set(`cursor`,t);let i=r.toString();return y(ue,`/api/user-pages/${encodeURIComponent(e.pluginName)}/${encodeURIComponent(e.id)}${i?`?${i}`:``}`,n)},getNextPageParam:e=>e.nextCursor,placeholderData:e=>e,retry:!1}),p=(0,U.useMemo)(()=>[...new Map((f.data?.pages??[]).flatMap(e=>e.records).map(e=>[e.id,e])).values()],[f.data?.pages]),m=c({mutationFn:e=>de(e.href),onMutate:()=>({pluginName:e.pluginName}),onSuccess:async(e,t,n)=>{r.removeQueries({queryKey:[`dashboard`,`plugin-user-page`,n.pluginName,`record`]}),await r.invalidateQueries({queryKey:[`dashboard`,`plugin-user-page`,n.pluginName]})},onSettled:()=>{i.current=!1}});function ee(e){i.current||(i.current=!0,m.mutate(e))}function h(e){let r=new URLSearchParams(t);e?r.set(`filter`,e):r.delete(`filter`),n(r,{replace:!0})}return{action:m,content:f.data?.pages[0],filter:a,query:f,records:p,runAction:ee,searchQuery:d,searchText:o,setFilter:h,setSearchText:u}}const Me=o().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),Ne=r({count:t().int().min(0),date:Me}).strict(),W=r({costUsd:t().finite().min(0),date:Me,events:t().int().min(0)}).strict(),Pe=r({days:a(Ne).length(90),extractionDays:a(W).length(90),extractionHours:a(W).min(24).optional(),generatedAt:i(),hours:a(Ne).min(24).optional(),recallDays:a(W).length(90),recallHours:a(W).min(24).optional(),stats:r({active:t().int().min(0),automatic:t().int().min(0),createdThirtyDays:t().int().min(0),embedded:t().int().min(0),explicit:t().int().min(0),knowledge:t().int().min(0),preference:t().int().min(0),procedure:t().int().min(0)}).strict()}).strict();function Fe(){return u({queryFn:({signal:e})=>y(Pe,`/api/plugins/memory/dashboard`,e),queryKey:[`dashboard`,`plugin-user-page`,`memory`,`summary`],retry:!1})}var G=f();const Ie=/* @__PURE__ */ new Set([`Learned`,`Memory ID`,`Source`,`Type`]);function Le(e){let{record:t}=e,[n,r]=(0,U.useState)(!1),i=t?Be(t):`Memory details`,a=t?.actions?.find(e=>e.tone===`danger`);return/* @__PURE__ */ (0,G.jsxs)(ye,{label:`Memory details`,onClose:e.onClose,sheetTitle:i,title:/* @__PURE__ */ (0,G.jsx)(`h2`,{className:`m-0 flex items-center gap-2 font-display text-base font-medium text-dashboard-text`,children:/* @__PURE__ */ (0,G.jsx)(`span`,{className:`truncate`,children:i})}),children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid h-full min-h-0 grid-rows-[minmax(0,1fr)_auto]`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{"aria-label":`Memory content`,role:`region`,tabIndex:0,className:`grid min-h-0 min-w-0 content-start gap-4 overflow-y-auto overscroll-contain p-4 outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus [overflow-wrap:anywhere]`,children:t?/* @__PURE__ */ (0,G.jsxs)(G.Fragment,{children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid gap-3 text-sm leading-relaxed`,children:[/* @__PURE__ */ (0,G.jsx)(I,{text:t.title}),t.description?/* @__PURE__ */ (0,G.jsx)(I,{text:t.description}):null]}),/* @__PURE__ */ (0,G.jsx)(Re,{record:t})]}):/* @__PURE__ */ (0,G.jsx)(S,{label:`Loading memory`,variant:`panel`})}),t&&a?/* @__PURE__ */ (0,G.jsx)(`footer`,{"aria-label":`Memory actions`,className:`flex items-center gap-2 border-t border-dashboard-border bg-dashboard-bg-elevated p-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:/* @__PURE__ */ (0,G.jsxs)(le,{children:[/* @__PURE__ */ (0,G.jsx)(se,{render:/* @__PURE__ */ (0,G.jsx)(_,{"aria-label":`Forget this memory`,className:`min-h-11 min-w-11`,disabled:e.forgetPending,onClick:()=>{a.confirmation?r(!0):e.onForget(a)},size:`icon`,variant:`danger`,children:/* @__PURE__ */ (0,G.jsx)(ae,{"aria-hidden":`true`,size:16})})}),/* @__PURE__ */ (0,G.jsx)(ce,{size:`compact`,children:`Forget this memory`})]})}):null]}),a?.confirmation&&t?/* @__PURE__ */ (0,G.jsx)(M,{onOpenChange:r,open:n,children:/* @__PURE__ */ (0,G.jsxs)(j,{children:[/* @__PURE__ */ (0,G.jsx)(P,{children:a.confirmation}),/* @__PURE__ */ (0,G.jsx)(F,{children:t.title}),/* @__PURE__ */ (0,G.jsxs)(O,{children:[/* @__PURE__ */ (0,G.jsx)(k,{children:`Cancel`}),/* @__PURE__ */ (0,G.jsx)(A,{onClick:()=>{r(!1),e.onForget(a)},variant:`danger`,children:a.label})]})]})}):null]})}function Re(e){let{record:t}=e,n=K(t,`Learned`),r=K(t,`Source`),i=n===`Automatic`?`From a ${r??`past`} conversation`:n===`Explicit`?`Someone asked Junior`:n?`Before origin tracking`:void 0,a=K(t,`Remembered`),o=(t.metadata??[]).filter(e=>!Ie.has(e.label)&&(e.label!==`Observed`||e.value!==a));return/* @__PURE__ */ (0,G.jsxs)(`dl`,{className:`m-0 grid min-w-0 gap-2 rounded-lg border border-dashboard-border-subtle bg-dashboard-surface-panel p-3 text-xs leading-snug`,children:[i?/* @__PURE__ */ (0,G.jsx)(ze,{label:`Learned`,children:i}):null,o.map(e=>/* @__PURE__ */ (0,G.jsx)(ze,{label:e.label,children:e.value},e.label))]})}function ze(e){return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-4`,children:[/* @__PURE__ */ (0,G.jsx)(`dt`,{className:`shrink-0 text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,G.jsx)(`dd`,{className:`m-0 min-w-0 break-words text-right tabular-nums text-dashboard-text`,children:e.children})]})}function Be(e){return K(e,`Type`)??`Memory`}function K(e,t){return e.metadata?.find(e=>e.label===t)?.value}function Ve(e){return[...new Set(e.toLowerCase().split(/[^a-z0-9_'-]+/).filter(e=>e.length>=2))]}function He(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Ue(e){let t=Ve(e.query);if(t.length===0)return/* @__PURE__ */ (0,G.jsx)(G.Fragment,{children:e.text});let n=RegExp(`(${t.sort((e,t)=>t.length-e.length).map(He).join(`|`)})`,`gi`);return/* @__PURE__ */ (0,G.jsx)(G.Fragment,{children:e.text.split(n).map((e,t)=>t%2==1?/* @__PURE__ */ (0,G.jsx)(`mark`,{className:`rounded-sm bg-amber-300/25 text-dashboard-text`,children:e},t):e)})}const We={count:{color:`var(--color-emerald-300)`,label:`Memories`}};function Ge(e){let t=e.bucketUnit??`day`,n=e.days,r=n.map(e=>e.count),i=Math.max(1,...r),a=r.some(e=>e>0);return/* @__PURE__ */ (0,G.jsxs)(x,{className:`min-h-[17rem] p-4 sm:p-5`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{children:[/* @__PURE__ */ (0,G.jsx)(E,{anchor:`activity`,className:`m-0 font-display text-xl font-medium text-dashboard-text`,title:`Activity over time`}),/* @__PURE__ */ (0,G.jsx)(`p`,{className:`mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:t===`hour`?`Memories created each hour.`:t===`6hour`?`Memories created each 6 hours.`:`Memories created each day.`})]}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`relative mt-3 overflow-hidden`,children:[/* @__PURE__ */ (0,G.jsx)(Te,{className:`aspect-auto h-50 w-full`,config:We,children:/* @__PURE__ */ (0,G.jsxs)(De,{"aria-label":`Memories learned during the last ${e.range===1?`24 hours`:`${e.range} days`}`,data:n,margin:V,role:`img`,children:[/* @__PURE__ */ (0,G.jsx)(z,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,G.jsx)(we,{maximum:i}),/* @__PURE__ */ (0,G.jsx)(Se,{keys:n.map(e=>e.date)}),/* @__PURE__ */ (0,G.jsx)(xe,{content:/* @__PURE__ */ (0,G.jsx)(B,{rows:e=>[[`memories`,e.count]]})}),/* @__PURE__ */ (0,G.jsx)(H,{dataKey:`count`,fill:`var(--color-count)`,fillOpacity:.82,isAnimationActive:!1,maxBarSize:13})]})}),a?null:/* @__PURE__ */ (0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-0 grid place-items-center pt-12 font-sans text-xs text-dashboard-text-muted`,children:`No memories were learned in this period.`})]})]})}const Ke={extraction:{color:`var(--color-cyan-300)`,label:`Extraction`},recall:{color:`var(--color-fuchsia-400)`,label:`Recall`}};function q(e){return T({total:e})}function qe(e){let t=e.bucketUnit??`day`,n=new Map(e.recallDays.map(e=>[e.date,e])),r=e.extractionDays.map(e=>{let t=n.get(e.date)??{costUsd:0,date:e.date,events:0};return{date:e.date,extraction:e,extractionCost:e.costUsd,recall:t,recallCost:t.costUsd}}),i=r.reduce((e,t)=>e+t.extraction.costUsd,0),a=r.reduce((e,t)=>e+t.recall.costUsd,0),o=i+a,s=r.reduce((e,t)=>e+t.extraction.events+t.recall.events,0),c=r.map(e=>e.extraction.costUsd+e.recall.costUsd),l=Math.max(.01,...c),u=Ee(c);return/* @__PURE__ */ (0,G.jsxs)(x,{className:`min-h-[17rem] p-4 sm:p-5`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{children:[/* @__PURE__ */ (0,G.jsx)(E,{anchor:`cost`,label:`cost`,className:`m-0 font-display text-xl font-medium text-dashboard-text`,title:T({total:o})}),/* @__PURE__ */ (0,G.jsxs)(`p`,{className:`mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:[`System-wide estimate across `,J(s),` spanning extraction and recall.`]}),/* @__PURE__ */ (0,G.jsx)(Oe,{ariaLabel:`Memory cost legend`,items:[{color:`var(--color-cyan-300)`,key:`extraction`,label:`Extraction`,value:T({total:i})},{color:`var(--color-fuchsia-400)`,key:`recall`,label:`Recall`,value:T({total:a})}]})]}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`relative mt-4 overflow-hidden`,children:[/* @__PURE__ */ (0,G.jsx)(Te,{className:`aspect-auto h-50 w-full`,config:Ke,children:/* @__PURE__ */ (0,G.jsxs)(De,{"aria-label":`Memory extraction and recall cost during the last ${e.range===1?`24 hours`:`${e.range} days`}`,data:r,margin:V,role:`img`,children:[/* @__PURE__ */ (0,G.jsx)(z,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,G.jsx)(we,{format:q,maximum:l}),/* @__PURE__ */ (0,G.jsx)(Se,{keys:r.map(e=>e.date)}),/* @__PURE__ */ (0,G.jsx)(xe,{content:/* @__PURE__ */ (0,G.jsx)(B,{rows:e=>[[`extraction`,`${q(e.extractionCost)} · ${J(e.extraction.events)}`],[`recall`,`${q(e.recallCost)} · ${J(e.recall.events)}`],[`total`,q(e.extractionCost+e.recallCost)]]})}),/* @__PURE__ */ (0,G.jsx)(H,{dataKey:`extractionCost`,fill:`var(--color-extraction)`,fillOpacity:.82,isAnimationActive:!1,maxBarSize:13,stackId:`cost`}),/* @__PURE__ */ (0,G.jsx)(H,{dataKey:`recallCost`,fill:`var(--color-recall)`,fillOpacity:.82,isAnimationActive:!1,maxBarSize:13,stackId:`cost`}),/* @__PURE__ */ (0,G.jsx)(Ce,{unit:pe(t),average:u,format:q,stroke:`var(--color-slate-200)`})]})}),s===0?/* @__PURE__ */ (0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-0 grid place-items-center pt-12 font-sans text-xs text-dashboard-text-muted`,children:`No memory extraction or recall ran in this period.`}):null]})]})}function J(e){return`${e.toLocaleString()} ${e===1?`run`:`runs`}`}const Je=r({content:o().min(1),createdAt:i(),expiresAt:i().optional(),id:o().min(1),kind:n([`preference`,`procedure`,`knowledge`]),observedAt:i(),origin:n([`automatic`,`explicit`,`other`]),sourcePlatform:n([`local`,`slack`,`web`])}).strict();function Y(e){return e.charAt(0).toUpperCase()+e.slice(1)}function X(e){return new Intl.DateTimeFormat(`en-US`,{dateStyle:`medium`,timeStyle:`short`,timeZone:`UTC`}).format(new Date(e))}function Ye(e){let t=e.origin===`automatic`?`Automatic`:e.origin===`explicit`?`Explicit`:`Other`;return{actions:[{confirmation:`Forget this memory for everyone?`,href:`/api/plugins/memory/memories/${encodeURIComponent(e.id)}`,label:`Forget`,method:`DELETE`,tone:`danger`}],id:e.id,metadata:[{label:`Type`,value:Y(e.kind)},{label:`Learned`,value:t},{label:`Source`,value:Y(e.sourcePlatform)},{label:`Remembered`,value:X(e.createdAt)},{label:`Observed`,value:X(e.observedAt)},{label:`Expires`,value:e.expiresAt?X(e.expiresAt):`Never`}],title:e.content}}function Xe(e){return u({enabled:!!e,queryFn:async({signal:t})=>Ye(await y(Je,`/api/plugins/memory/memories/${encodeURIComponent(e)}`,t)),queryKey:[`dashboard`,`plugin-user-page`,`memory`,`record`,e],retry:!1})}const Ze=`grid-cols-1 sm:grid-cols-[minmax(0,1fr)_7rem_9rem]`;function Qe(e){let[t,n]=(0,U.useState)(30),r=h(),{memoryId:i}=p(),a=`/memories`,o=`${a}/library`,s=r.pathname===a,c=r.pathname===o||!!i;return!s&&!c?/* @__PURE__ */ (0,G.jsx)(m,{replace:!0,to:a}):/* @__PURE__ */ (0,G.jsx)(ve,{children:s?/* @__PURE__ */ (0,G.jsxs)(G.Fragment,{children:[/* @__PURE__ */ (0,G.jsx)(w,{description:e.page.description,onRangeChange:n,range:t,title:e.page.label}),/* @__PURE__ */ (0,G.jsx)($e,{range:t})]}):/* @__PURE__ */ (0,G.jsx)(et,{libraryPath:o,page:e.page})})}function $e(e){let t=Fe();return t.error?/* @__PURE__ */ (0,G.jsxs)(x,{className:`flex items-center gap-3 border-rose-300/20 p-5 text-sm text-rose-200`,children:[/* @__PURE__ */ (0,G.jsx)(ie,{"aria-hidden":`true`,size:18}),`Memory history is temporarily unavailable.`]}):t.data?/* @__PURE__ */ (0,G.jsxs)(G.Fragment,{children:[/* @__PURE__ */ (0,G.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-2`,children:[/* @__PURE__ */ (0,G.jsx)(Ge,{bucketUnit:me(e.range),days:C({days:t.data.days,hours:t.data.hours,range:e.range,emptySixHour:e=>({count:0,date:e})}),range:e.range}),/* @__PURE__ */ (0,G.jsx)(qe,{bucketUnit:me(e.range),extractionDays:C({days:t.data.extractionDays,hours:t.data.extractionHours,range:e.range,emptySixHour:e=>({costUsd:0,date:e,events:0})}),range:e.range,recallDays:C({days:t.data.recallDays,hours:t.data.recallHours,range:e.range,emptySixHour:e=>({costUsd:0,date:e,events:0})})})]}),/* @__PURE__ */ (0,G.jsx)(nt,{data:t.data}),/* @__PURE__ */ (0,G.jsxs)(`section`,{className:`grid gap-4 md:grid-cols-2`,children:[/* @__PURE__ */ (0,G.jsx)(rt,{data:t.data}),/* @__PURE__ */ (0,G.jsx)(it,{data:t.data})]})]}):/* @__PURE__ */ (0,G.jsx)(S,{className:`gap-6 sm:gap-8`,label:`Loading memory history`,variant:`overview`})}function et(e){let{action:t,content:n,query:r,records:i,runAction:a,searchQuery:o,searchText:s,setSearchText:c}=je(e.page),l=ee(),u=h(),{memoryId:d}=p(),f=(0,U.useRef)(null),m=Xe(d),g=m.data??i.find(e=>e.id===d),_=e=>D(e,u.search),te=()=>{let t=d?f.current?.querySelector(`button[data-memory-id="${CSS.escape(d)}"]`):void 0;l(_(e.libraryPath)),(t??f.current)?.focus()},v=t=>{l(_(e.libraryPath)),f.current?.focus(),a(t)};(0,U.useEffect)(()=>{d&&t.reset()},[d]),(0,U.useEffect)(()=>{!d||g||m.isFetching||m.isPending||(m.isError||m.isFetched)&&l(D(e.libraryPath,u.search),{replace:!0})},[u.search,d,m.isError,m.isFetched,m.isFetching,m.isPending,l,e.libraryPath,g]);let ne=!r.data&&!r.error;return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:b(`grid h-full min-h-0 min-w-0`,d&&`xl:grid-cols-[minmax(0,1fr)_25rem]`),children:[/* @__PURE__ */ (0,G.jsx)(`div`,{"aria-label":`Memories list`,className:`min-h-0 overflow-y-auto overscroll-contain outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus`,ref:f,role:`region`,tabIndex:0,children:/* @__PURE__ */ (0,G.jsxs)(he,{className:`gap-6 sm:gap-8`,children:[/* @__PURE__ */ (0,G.jsx)(w,{description:e.page.description,title:e.page.label}),/* @__PURE__ */ (0,G.jsxs)(`section`,{className:`grid gap-4`,"aria-labelledby":`memory-library-title`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-4`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{children:/* @__PURE__ */ (0,G.jsx)(`h2`,{className:`m-0 font-display text-xl font-medium tracking-[-0.02em] text-dashboard-text`,id:`memory-library-title`,children:o?`Search results`:`What Junior remembers`})}),n?.searchPlaceholder?/* @__PURE__ */ (0,G.jsx)(L,{className:`w-full max-w-md sm:w-auto`,label:n.searchPlaceholder,onChange:c,placeholder:n.searchPlaceholder,size:`default`,value:s}):null]}),ne?/* @__PURE__ */ (0,G.jsx)(S,{label:`Loading memories`,variant:`panel`}):r.error?/* @__PURE__ */ (0,G.jsxs)(x,{className:`flex items-center gap-3 border-rose-300/20 p-5 text-sm text-rose-200`,children:[/* @__PURE__ */ (0,G.jsx)(ie,{"aria-hidden":`true`,size:18}),r.error.message]}):i.length===0?/* @__PURE__ */ (0,G.jsx)(x,{className:`grid min-h-56 place-items-center p-8 text-center`,children:/* @__PURE__ */ (0,G.jsxs)(`div`,{children:[/* @__PURE__ */ (0,G.jsx)(re,{"aria-hidden":`true`,className:`mx-auto text-dashboard-text-muted`,size:26}),/* @__PURE__ */ (0,G.jsx)(`p`,{className:`mt-4 mb-0 text-sm text-dashboard-text-muted`,children:n?.emptyText??`No memories yet.`})]})}):/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid gap-3`,children:[/* @__PURE__ */ (0,G.jsxs)(x,{padding:`none`,children:[/* @__PURE__ */ (0,G.jsx)(tt,{}),i.map((t,n)=>/* @__PURE__ */ (0,G.jsx)(at,{first:n===0,onSelect:()=>l(_(d===t.id?e.libraryPath:`/memories/${encodeURIComponent(t.id)}`)),record:t,searchQuery:o,selected:t.id===d},t.id))]}),/* @__PURE__ */ (0,G.jsx)(R,{className:`mt-2`,hasMore:!r.isPlaceholderData&&!!r.hasNextPage,loading:r.isFetchingNextPage,onLoadMore:()=>void r.fetchNextPage()}),t.error?/* @__PURE__ */ (0,G.jsx)(N,{className:`text-center`,children:`Could not complete this action. Try again.`}):null]})]})]})}),d?/* @__PURE__ */ (0,G.jsx)(Le,{forgetPending:t.isPending,onClose:te,onForget:v,record:g},d):null]})}function tt(){return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:b(`hidden items-center gap-3 border-b border-dashboard-border px-4 py-2.5 text-left font-sans font-medium text-xs text-dashboard-text-muted sm:grid`,Ze),role:`row`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{children:`Memory`}),/* @__PURE__ */ (0,G.jsx)(`div`,{children:`Type`}),/* @__PURE__ */ (0,G.jsx)(`div`,{children:`Learned`})]})}function nt(e){let{stats:t}=e.data,n=[{detail:`shared across the workspace`,label:`Total active`,tone:`text-dashboard-accent-text`,value:t.active.toLocaleString(`en-US`)},{detail:`in the last 30 days`,label:`Added · 30d`,value:`+${t.createdThirtyDays.toLocaleString(`en-US`)}`}];return/* @__PURE__ */ (0,G.jsx)(`section`,{"aria-label":`Memory summary`,className:`grid grid-cols-2 gap-px border-y border-dashboard-border-subtle bg-dashboard-fill-hover`,children:n.map(e=>/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`bg-dashboard-bg px-4 py-4 sm:px-5`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:b(`mt-2 font-display text-3xl font-light tracking-[-0.04em] text-dashboard-text`,e.tone),children:e.value}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-1 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.detail})]},e.label))})}function rt(e){let{stats:t}=e.data;return/* @__PURE__ */ (0,G.jsxs)(x,{className:`p-5 sm:p-6`,children:[/* @__PURE__ */ (0,G.jsx)(E,{anchor:`memory-types`,className:`m-0 font-display text-xl font-medium text-dashboard-text`,title:`What Junior remembers`}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`mt-5 grid gap-px overflow-hidden rounded-md border border-dashboard-border-subtle bg-dashboard-fill-hover`,children:[/* @__PURE__ */ (0,G.jsx)(Z,{detail:`How people like to work`,icon:oe,label:`Preferences`,value:t.preference}),/* @__PURE__ */ (0,G.jsx)(Z,{detail:`How work should get done`,icon:re,label:`Procedures`,value:t.procedure}),/* @__PURE__ */ (0,G.jsx)(Z,{detail:`Facts and durable context`,icon:Ae,label:`Knowledge`,value:t.knowledge})]})]})}function it(e){let{stats:t}=e.data,n=Math.max(0,t.active-t.automatic-t.explicit);return/* @__PURE__ */ (0,G.jsxs)(x,{className:`p-5 sm:p-6`,children:[/* @__PURE__ */ (0,G.jsx)(E,{anchor:`memory-sources`,className:`m-0 font-display text-xl font-medium text-dashboard-text`,title:`How they got here`}),/* @__PURE__ */ (0,G.jsx)(`p`,{className:`mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:`Same totals, split by how they were written.`}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`mt-5 grid gap-px overflow-hidden rounded-md border border-dashboard-border-subtle bg-dashboard-fill-hover`,children:[/* @__PURE__ */ (0,G.jsx)(Z,{detail:`Passive extraction after runs`,icon:ne,label:`Learned by Junior`,value:t.automatic}),/* @__PURE__ */ (0,G.jsx)(Z,{detail:`Someone asked to remember it`,icon:ke,label:`Saved explicitly`,value:t.explicit}),/* @__PURE__ */ (0,G.jsx)(Z,{detail:`Before origin tracking`,icon:Ae,label:`Older records`,value:n})]})]})}function Z(e){let t=e.icon;return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex items-center gap-3 bg-dashboard-bg-elevated px-3 py-3`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`grid size-9 shrink-0 place-items-center rounded-md border border-dashboard-border bg-dashboard-fill-soft text-dashboard-text-muted`,children:/* @__PURE__ */ (0,G.jsx)(t,{"aria-hidden":`true`,size:15})}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`font-display text-base font-medium text-dashboard-text`,children:e.label}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-0.5 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.detail})]}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`font-display text-2xl font-light text-dashboard-text`,children:e.value.toLocaleString(`en-US`)})]})}function at(e){let t=Q(e.record,`Type`),n=Q(e.record,`Remembered`),r=Q(e.record,`Source`);return/* @__PURE__ */ (0,G.jsx)(be,{className:b(`flex items-stretch`,!e.first&&`border-t border-dashboard-border-subtle`),onSelect:e.onSelect,selected:e.selected,children:/* @__PURE__ */ (0,G.jsxs)(`button`,{"aria-expanded":e.selected,"aria-label":`View memory details: ${e.record.title}`,"data-memory-id":e.record.id,className:b(`grid min-w-0 flex-1 cursor-pointer items-center gap-3 border-0 bg-transparent px-4 py-3 text-left`,Ze),onClick:e.onSelect,type:`button`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`flex min-w-0 items-center gap-2 overflow-hidden`,children:/* @__PURE__ */ (0,G.jsx)(`h3`,{className:`m-0 truncate font-display text-base font-medium leading-snug text-dashboard-text`,children:/* @__PURE__ */ (0,G.jsx)(Ue,{query:e.searchQuery,text:e.record.title})})}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`mt-1.5 truncate font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:[`Source: `,r,/* @__PURE__ */ (0,G.jsxs)(`span`,{className:`sm:hidden`,children:[` `,`· `,t,` · `,$(n)]})]})]}),/* @__PURE__ */ (0,G.jsx)(`span`,{className:`hidden truncate font-mono text-xs text-dashboard-text-muted sm:block`,children:t}),/* @__PURE__ */ (0,G.jsx)(`span`,{className:`hidden truncate font-mono text-xs text-dashboard-text sm:block`,children:$(n)})]})})}function Q(e,t){return e.metadata?.find(e=>e.label===t)?.value??`—`}function $(e){return e.split(`,`).slice(0,2).join(`,`)}function ot(e){let t=e.pages.find(e=>e.pluginName===`memory`&&e.id===`memories`);return t?/* @__PURE__ */ (0,G.jsx)(Qe,{page:t}):/* @__PURE__ */ (0,G.jsx)(m,{replace:!0,to:`/`})}function st(e){let t=h(),{"*":n,pageId:r,pluginName:i}=p(),a=e.pages.find(e=>e.pluginName===i&&e.id===r);if(!a)return/* @__PURE__ */ (0,G.jsx)(m,{replace:!0,to:`/`});if(a.pluginName===`memory`&&a.id===`memories`){let e=n?`/${n}`:``;return/* @__PURE__ */ (0,G.jsx)(m,{replace:!0,to:D(`/memories${e}`,t.search)})}return/* @__PURE__ */ (0,G.jsx)(ct,{page:a})}function ct(e){let{action:t,content:n,query:r,records:i,runAction:a,searchText:o,setSearchText:s}=je(e.page),[c,l]=(0,U.useState)(),[u,d]=(0,U.useState)(!1);return!r.data&&!r.error?/* @__PURE__ */ (0,G.jsx)(_e,{label:`Loading ${e.page.label}`}):/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`${fe} px-4 py-8 md:px-8`,children:[/* @__PURE__ */ (0,G.jsxs)(`section`,{className:`mx-auto grid w-full max-w-3xl gap-6`,children:[/* @__PURE__ */ (0,G.jsx)(w,{description:e.page.description,title:e.page.label}),n?.metrics?.length?/* @__PURE__ */ (0,G.jsx)(`section`,{"aria-label":`${e.page.label} overview`,className:`grid gap-3 sm:grid-cols-2`,children:n.metrics.map(e=>/* @__PURE__ */ (0,G.jsxs)(x,{className:`p-4`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-3 font-display text-2xl font-light text-dashboard-text`,children:e.value}),e.detail?/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-1 font-mono text-xs text-dashboard-text-muted`,children:e.detail}):null]},e.label))}):null,n?.searchPlaceholder?/* @__PURE__ */ (0,G.jsx)(L,{className:`w-full`,label:n.searchPlaceholder,onChange:s,placeholder:n.searchPlaceholder,size:`default`,value:o}):null,r.error?/* @__PURE__ */ (0,G.jsx)(x,{padding:`md`,children:/* @__PURE__ */ (0,G.jsxs)(N,{children:[`Could not load `,e.page.label.toLowerCase(),`. Try again.`]})}):i.length===0?/* @__PURE__ */ (0,G.jsx)(x,{padding:`md`,children:/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`grid size-10 shrink-0 place-items-center rounded-md border border-dashboard-border bg-dashboard-fill-soft text-dashboard-text-muted`,children:/* @__PURE__ */ (0,G.jsx)(te,{"aria-hidden":`true`,size:17})}),/* @__PURE__ */ (0,G.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:n?.emptyText??`No ${e.page.label.toLowerCase()}.`})]})}):/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid gap-3`,children:[i.map(e=>/* @__PURE__ */ (0,G.jsxs)(x,{padding:`md`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[/* @__PURE__ */ (0,G.jsx)(`h2`,{className:`m-0 min-w-0 flex-1 font-display text-base font-medium text-dashboard-text`,children:e.title}),e.actions?.map(n=>n.method===`GET`?/* @__PURE__ */ (0,G.jsx)(`a`,{className:`shrink-0 rounded-md border border-dashboard-border-strong px-3 py-1.5 text-sm font-semibold text-dashboard-text no-underline transition-colors hover:bg-dashboard-fill-strong`,href:n.href,children:n.label},`${n.method}:${n.href}`):/* @__PURE__ */ (0,G.jsx)(`button`,{"aria-label":`${n.label}: ${e.title}`,className:`cursor-pointer border-0 bg-transparent p-1 text-dashboard-text-muted transition-colors ${n.tone===`danger`?`hover:text-rose-300`:`hover:text-dashboard-text`}`,disabled:t.isPending,onClick:()=>{n.confirmation?(l({action:n,record:e}),d(!0)):a(n)},title:n.label,type:`button`,children:n.tone===`danger`?/* @__PURE__ */ (0,G.jsx)(ae,{"aria-hidden":`true`,size:16}):n.label},`${n.method}:${n.href}`))]}),e.description?/* @__PURE__ */ (0,G.jsx)(`p`,{className:`mt-2 mb-0 text-sm text-dashboard-text-muted`,children:e.description}):null,e.metadata?.length?/* @__PURE__ */ (0,G.jsx)(`dl`,{className:`mt-4 flex flex-wrap gap-x-6 gap-y-2`,children:e.metadata.map(e=>/* @__PURE__ */ (0,G.jsxs)(`div`,{children:[/* @__PURE__ */ (0,G.jsx)(`dt`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,G.jsx)(`dd`,{className:`mt-1 ml-0 font-mono text-xs text-dashboard-text-muted`,children:e.value})]},e.label))}):null]},e.id)),/* @__PURE__ */ (0,G.jsx)(R,{hasMore:!r.isPlaceholderData&&!!r.hasNextPage,loading:r.isFetchingNextPage,onLoadMore:()=>void r.fetchNextPage()}),t.error?/* @__PURE__ */ (0,G.jsx)(N,{className:`text-center`,children:`Could not complete this action. Try again.`}):null]})]}),/* @__PURE__ */ (0,G.jsx)(M,{onOpenChange:d,open:u,children:/* @__PURE__ */ (0,G.jsxs)(j,{children:[/* @__PURE__ */ (0,G.jsx)(P,{children:c?.action.confirmation}),/* @__PURE__ */ (0,G.jsx)(F,{children:c?.record.title}),/* @__PURE__ */ (0,G.jsxs)(O,{children:[/* @__PURE__ */ (0,G.jsx)(k,{children:`Cancel`}),/* @__PURE__ */ (0,G.jsx)(A,{onClick:()=>{c&&a(c.action),d(!1)},variant:c?.action.tone===`danger`?`danger`:`primary`,children:c?.action.label})]})]})})]})}export{ot as MemoryPermalinkRoute,st as PluginUserPageRoute};
15
+ ;var U=/* @__PURE__ */ e(d(),1);function je(e){let[t,n]=g(),r=l(),i=(0,U.useRef)(!1),a=t.get(`filter`)?.trim()??``,[o,u,d]=ge(),f=s({initialPageParam:void 0,queryKey:[`dashboard`,`plugin-user-page`,e.pluginName,e.id,a,d],queryFn:({pageParam:t,signal:n})=>{let r=new URLSearchParams;a&&r.set(`filter`,a),d&&r.set(`q`,d),t&&r.set(`cursor`,t);let i=r.toString();return y(ue,`/api/user-pages/${encodeURIComponent(e.pluginName)}/${encodeURIComponent(e.id)}${i?`?${i}`:``}`,n)},getNextPageParam:e=>e.nextCursor,placeholderData:e=>e,retry:!1}),p=(0,U.useMemo)(()=>[...new Map((f.data?.pages??[]).flatMap(e=>e.records).map(e=>[e.id,e])).values()],[f.data?.pages]),m=c({mutationFn:e=>de(e.href),onMutate:()=>({pluginName:e.pluginName}),onSuccess:async(e,t,n)=>{r.removeQueries({queryKey:[`dashboard`,`plugin-user-page`,n.pluginName,`record`]}),await r.invalidateQueries({queryKey:[`dashboard`,`plugin-user-page`,n.pluginName]})},onSettled:()=>{i.current=!1}});function ee(e){i.current||(i.current=!0,m.mutate(e))}function h(e){let r=new URLSearchParams(t);e?r.set(`filter`,e):r.delete(`filter`),n(r,{replace:!0})}return{action:m,content:f.data?.pages[0],filter:a,query:f,records:p,runAction:ee,searchQuery:d,searchText:o,setFilter:h,setSearchText:u}}const Me=o().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),Ne=r({count:t().int().min(0),date:Me}).strict(),W=r({costUsd:t().finite().min(0),date:Me,events:t().int().min(0)}).strict(),Pe=r({days:a(Ne).length(90),extractionDays:a(W).length(90),extractionHours:a(W).min(24).optional(),generatedAt:i(),hours:a(Ne).min(24).optional(),recallDays:a(W).length(90),recallHours:a(W).min(24).optional(),stats:r({active:t().int().min(0),automatic:t().int().min(0),createdThirtyDays:t().int().min(0),embedded:t().int().min(0),explicit:t().int().min(0),knowledge:t().int().min(0),preference:t().int().min(0),procedure:t().int().min(0)}).strict()}).strict();function Fe(){return u({queryFn:({signal:e})=>y(Pe,`/api/plugins/memory/dashboard`,e),queryKey:[`dashboard`,`plugin-user-page`,`memory`,`summary`],retry:!1})}var G=f();const Ie=/* @__PURE__ */ new Set([`Learned`,`Memory ID`,`Source`,`Type`]);function Le(e){let{record:t}=e,[n,r]=(0,U.useState)(!1),i=t?Be(t):`Memory details`,a=t?.actions?.find(e=>e.tone===`danger`);return/* @__PURE__ */ (0,G.jsxs)(_e,{label:`Memory details`,onClose:e.onClose,sheetTitle:i,title:/* @__PURE__ */ (0,G.jsx)(`h2`,{className:`m-0 flex items-center gap-2 font-display text-base font-medium text-dashboard-text`,children:/* @__PURE__ */ (0,G.jsx)(`span`,{className:`truncate`,children:i})}),children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid h-full min-h-0 grid-rows-[minmax(0,1fr)_auto]`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{"aria-label":`Memory content`,role:`region`,tabIndex:0,className:`grid min-h-0 min-w-0 content-start gap-4 overflow-y-auto overscroll-contain p-4 outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus [overflow-wrap:anywhere]`,children:t?/* @__PURE__ */ (0,G.jsxs)(G.Fragment,{children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid gap-3 text-sm leading-relaxed`,children:[/* @__PURE__ */ (0,G.jsx)(P,{text:t.title}),t.description?/* @__PURE__ */ (0,G.jsx)(P,{text:t.description}):null]}),/* @__PURE__ */ (0,G.jsx)(Re,{record:t})]}):/* @__PURE__ */ (0,G.jsx)(S,{label:`Loading memory`,variant:`panel`})}),t&&a?/* @__PURE__ */ (0,G.jsx)(`footer`,{"aria-label":`Memory actions`,className:`flex items-center gap-2 border-t border-dashboard-border bg-dashboard-bg-elevated p-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:/* @__PURE__ */ (0,G.jsxs)(le,{children:[/* @__PURE__ */ (0,G.jsx)(se,{render:/* @__PURE__ */ (0,G.jsx)(_,{"aria-label":`Forget this memory`,className:`min-h-11 min-w-11`,disabled:e.forgetPending,onClick:()=>{a.confirmation?r(!0):e.onForget(a)},size:`icon`,variant:`danger`,children:/* @__PURE__ */ (0,G.jsx)(ae,{"aria-hidden":`true`,size:16})})}),/* @__PURE__ */ (0,G.jsx)(ce,{size:`compact`,children:`Forget this memory`})]})}):null]}),a?.confirmation&&t?/* @__PURE__ */ (0,G.jsx)(L,{onOpenChange:r,open:n,children:/* @__PURE__ */ (0,G.jsxs)(N,{children:[/* @__PURE__ */ (0,G.jsx)(A,{children:a.confirmation}),/* @__PURE__ */ (0,G.jsx)(O,{children:t.title}),/* @__PURE__ */ (0,G.jsxs)(k,{children:[/* @__PURE__ */ (0,G.jsx)(M,{children:`Cancel`}),/* @__PURE__ */ (0,G.jsx)(j,{onClick:()=>{r(!1),e.onForget(a)},variant:`danger`,children:a.label})]})]})}):null]})}function Re(e){let{record:t}=e,n=K(t,`Learned`),r=K(t,`Source`),i=n===`Automatic`?`From a ${r??`past`} conversation`:n===`Explicit`?`Someone asked Junior`:n?`Before origin tracking`:void 0,a=K(t,`Remembered`),o=(t.metadata??[]).filter(e=>!Ie.has(e.label)&&(e.label!==`Observed`||e.value!==a));return/* @__PURE__ */ (0,G.jsxs)(`dl`,{className:`m-0 grid min-w-0 gap-2 rounded-lg border border-dashboard-border-subtle bg-dashboard-surface-panel p-3 text-xs leading-snug`,children:[i?/* @__PURE__ */ (0,G.jsx)(ze,{label:`Learned`,children:i}):null,o.map(e=>/* @__PURE__ */ (0,G.jsx)(ze,{label:e.label,children:e.value},e.label))]})}function ze(e){return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-4`,children:[/* @__PURE__ */ (0,G.jsx)(`dt`,{className:`shrink-0 text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,G.jsx)(`dd`,{className:`m-0 min-w-0 break-words text-right tabular-nums text-dashboard-text`,children:e.children})]})}function Be(e){return K(e,`Type`)??`Memory`}function K(e,t){return e.metadata?.find(e=>e.label===t)?.value}function Ve(e){return[...new Set(e.toLowerCase().split(/[^a-z0-9_'-]+/).filter(e=>e.length>=2))]}function He(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Ue(e){let t=Ve(e.query);if(t.length===0)return/* @__PURE__ */ (0,G.jsx)(G.Fragment,{children:e.text});let n=RegExp(`(${t.sort((e,t)=>t.length-e.length).map(He).join(`|`)})`,`gi`);return/* @__PURE__ */ (0,G.jsx)(G.Fragment,{children:e.text.split(n).map((e,t)=>t%2==1?/* @__PURE__ */ (0,G.jsx)(`mark`,{className:`rounded-sm bg-amber-300/25 text-dashboard-text`,children:e},t):e)})}const We={count:{color:`var(--color-emerald-300)`,label:`Memories`}};function Ge(e){let t=e.bucketUnit??`day`,n=e.days,r=n.map(e=>e.count),i=Math.max(1,...r),a=r.some(e=>e>0);return/* @__PURE__ */ (0,G.jsxs)(x,{className:`min-h-[17rem] p-4 sm:p-5`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{children:[/* @__PURE__ */ (0,G.jsx)(E,{anchor:`activity`,className:`m-0 font-display text-xl font-medium text-dashboard-text`,title:`Activity over time`}),/* @__PURE__ */ (0,G.jsx)(`p`,{className:`mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:t===`hour`?`Memories created each hour.`:t===`6hour`?`Memories created each 6 hours.`:`Memories created each day.`})]}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`relative mt-3 overflow-hidden`,children:[/* @__PURE__ */ (0,G.jsx)(Te,{className:`aspect-auto h-50 w-full`,config:We,children:/* @__PURE__ */ (0,G.jsxs)(De,{"aria-label":`Memories learned during the last ${e.range===1?`24 hours`:`${e.range} days`}`,data:n,margin:V,role:`img`,children:[/* @__PURE__ */ (0,G.jsx)(z,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,G.jsx)(we,{maximum:i}),/* @__PURE__ */ (0,G.jsx)(Se,{keys:n.map(e=>e.date)}),/* @__PURE__ */ (0,G.jsx)(xe,{content:/* @__PURE__ */ (0,G.jsx)(B,{rows:e=>[[`memories`,e.count]]})}),/* @__PURE__ */ (0,G.jsx)(H,{dataKey:`count`,fill:`var(--color-count)`,fillOpacity:.82,isAnimationActive:!1,maxBarSize:13})]})}),a?null:/* @__PURE__ */ (0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-0 grid place-items-center pt-12 font-sans text-xs text-dashboard-text-muted`,children:`No memories were learned in this period.`})]})]})}const Ke={extraction:{color:`var(--color-cyan-300)`,label:`Extraction`},recall:{color:`var(--color-fuchsia-400)`,label:`Recall`}};function q(e){return T({total:e})}function qe(e){let t=e.bucketUnit??`day`,n=new Map(e.recallDays.map(e=>[e.date,e])),r=e.extractionDays.map(e=>{let t=n.get(e.date)??{costUsd:0,date:e.date,events:0};return{date:e.date,extraction:e,extractionCost:e.costUsd,recall:t,recallCost:t.costUsd}}),i=r.reduce((e,t)=>e+t.extraction.costUsd,0),a=r.reduce((e,t)=>e+t.recall.costUsd,0),o=i+a,s=r.reduce((e,t)=>e+t.extraction.events+t.recall.events,0),c=r.map(e=>e.extraction.costUsd+e.recall.costUsd),l=Math.max(.01,...c),u=Ee(c);return/* @__PURE__ */ (0,G.jsxs)(x,{className:`min-h-[17rem] p-4 sm:p-5`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{children:[/* @__PURE__ */ (0,G.jsx)(E,{anchor:`cost`,label:`cost`,className:`m-0 font-display text-xl font-medium text-dashboard-text`,title:T({total:o})}),/* @__PURE__ */ (0,G.jsxs)(`p`,{className:`mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:[`System-wide estimate across `,J(s),` spanning extraction and recall.`]}),/* @__PURE__ */ (0,G.jsx)(Oe,{ariaLabel:`Memory cost legend`,items:[{color:`var(--color-cyan-300)`,key:`extraction`,label:`Extraction`,value:T({total:i})},{color:`var(--color-fuchsia-400)`,key:`recall`,label:`Recall`,value:T({total:a})}]})]}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`relative mt-4 overflow-hidden`,children:[/* @__PURE__ */ (0,G.jsx)(Te,{className:`aspect-auto h-50 w-full`,config:Ke,children:/* @__PURE__ */ (0,G.jsxs)(De,{"aria-label":`Memory extraction and recall cost during the last ${e.range===1?`24 hours`:`${e.range} days`}`,data:r,margin:V,role:`img`,children:[/* @__PURE__ */ (0,G.jsx)(z,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,G.jsx)(we,{format:q,maximum:l}),/* @__PURE__ */ (0,G.jsx)(Se,{keys:r.map(e=>e.date)}),/* @__PURE__ */ (0,G.jsx)(xe,{content:/* @__PURE__ */ (0,G.jsx)(B,{rows:e=>[[`extraction`,`${q(e.extractionCost)} · ${J(e.extraction.events)}`],[`recall`,`${q(e.recallCost)} · ${J(e.recall.events)}`],[`total`,q(e.extractionCost+e.recallCost)]]})}),/* @__PURE__ */ (0,G.jsx)(H,{dataKey:`extractionCost`,fill:`var(--color-extraction)`,fillOpacity:.82,isAnimationActive:!1,maxBarSize:13,stackId:`cost`}),/* @__PURE__ */ (0,G.jsx)(H,{dataKey:`recallCost`,fill:`var(--color-recall)`,fillOpacity:.82,isAnimationActive:!1,maxBarSize:13,stackId:`cost`}),/* @__PURE__ */ (0,G.jsx)(Ce,{unit:pe(t),average:u,format:q,stroke:`var(--color-slate-200)`})]})}),s===0?/* @__PURE__ */ (0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-0 grid place-items-center pt-12 font-sans text-xs text-dashboard-text-muted`,children:`No memory extraction or recall ran in this period.`}):null]})]})}function J(e){return`${e.toLocaleString()} ${e===1?`run`:`runs`}`}const Je=r({content:o().min(1),createdAt:i(),expiresAt:i().optional(),id:o().min(1),kind:n([`preference`,`procedure`,`knowledge`]),observedAt:i(),origin:n([`automatic`,`explicit`,`other`]),sourcePlatform:n([`local`,`slack`,`web`])}).strict();function Y(e){return e.charAt(0).toUpperCase()+e.slice(1)}function X(e){return new Intl.DateTimeFormat(`en-US`,{dateStyle:`medium`,timeStyle:`short`,timeZone:`UTC`}).format(new Date(e))}function Ye(e){let t=e.origin===`automatic`?`Automatic`:e.origin===`explicit`?`Explicit`:`Other`;return{actions:[{confirmation:`Forget this memory for everyone?`,href:`/api/plugins/memory/memories/${encodeURIComponent(e.id)}`,label:`Forget`,method:`DELETE`,tone:`danger`}],id:e.id,metadata:[{label:`Type`,value:Y(e.kind)},{label:`Learned`,value:t},{label:`Source`,value:Y(e.sourcePlatform)},{label:`Remembered`,value:X(e.createdAt)},{label:`Observed`,value:X(e.observedAt)},{label:`Expires`,value:e.expiresAt?X(e.expiresAt):`Never`}],title:e.content}}function Xe(e){return u({enabled:!!e,queryFn:async({signal:t})=>Ye(await y(Je,`/api/plugins/memory/memories/${encodeURIComponent(e)}`,t)),queryKey:[`dashboard`,`plugin-user-page`,`memory`,`record`,e],retry:!1})}const Ze=`grid-cols-1 sm:grid-cols-[minmax(0,1fr)_7rem_9rem]`;function Qe(e){let[t,n]=(0,U.useState)(30),r=h(),{memoryId:i}=p(),a=`/memories`,o=`${a}/library`,s=r.pathname===a,c=r.pathname===o||!!i;return!s&&!c?/* @__PURE__ */ (0,G.jsx)(m,{replace:!0,to:a}):/* @__PURE__ */ (0,G.jsx)(ye,{children:s?/* @__PURE__ */ (0,G.jsxs)(G.Fragment,{children:[/* @__PURE__ */ (0,G.jsx)(w,{description:e.page.description,onRangeChange:n,range:t,title:e.page.label}),/* @__PURE__ */ (0,G.jsx)($e,{range:t})]}):/* @__PURE__ */ (0,G.jsx)(et,{libraryPath:o,page:e.page})})}function $e(e){let t=Fe();return t.error?/* @__PURE__ */ (0,G.jsxs)(x,{className:`flex items-center gap-3 border-rose-300/20 p-5 text-sm text-rose-200`,children:[/* @__PURE__ */ (0,G.jsx)(ie,{"aria-hidden":`true`,size:18}),`Memory history is temporarily unavailable.`]}):t.data?/* @__PURE__ */ (0,G.jsxs)(G.Fragment,{children:[/* @__PURE__ */ (0,G.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-2`,children:[/* @__PURE__ */ (0,G.jsx)(Ge,{bucketUnit:me(e.range),days:C({days:t.data.days,hours:t.data.hours,range:e.range,emptySixHour:e=>({count:0,date:e})}),range:e.range}),/* @__PURE__ */ (0,G.jsx)(qe,{bucketUnit:me(e.range),extractionDays:C({days:t.data.extractionDays,hours:t.data.extractionHours,range:e.range,emptySixHour:e=>({costUsd:0,date:e,events:0})}),range:e.range,recallDays:C({days:t.data.recallDays,hours:t.data.recallHours,range:e.range,emptySixHour:e=>({costUsd:0,date:e,events:0})})})]}),/* @__PURE__ */ (0,G.jsx)(nt,{data:t.data}),/* @__PURE__ */ (0,G.jsxs)(`section`,{className:`grid gap-4 md:grid-cols-2`,children:[/* @__PURE__ */ (0,G.jsx)(rt,{data:t.data}),/* @__PURE__ */ (0,G.jsx)(it,{data:t.data})]})]}):/* @__PURE__ */ (0,G.jsx)(S,{className:`gap-6 sm:gap-8`,label:`Loading memory history`,variant:`overview`})}function et(e){let{action:t,content:n,query:r,records:i,runAction:a,searchQuery:o,searchText:s,setSearchText:c}=je(e.page),l=ee(),u=h(),{memoryId:d}=p(),f=(0,U.useRef)(null),m=Xe(d),g=m.data??i.find(e=>e.id===d),_=e=>D(e,u.search),v=()=>{let t=d?f.current?.querySelector(`button[data-memory-id="${CSS.escape(d)}"]`):void 0;l(_(e.libraryPath)),(t??f.current)?.focus()},te=t=>{l(_(e.libraryPath)),f.current?.focus(),a(t)};(0,U.useEffect)(()=>{d&&t.reset()},[d]),(0,U.useEffect)(()=>{!d||g||m.isFetching||m.isPending||(m.isError||m.isFetched)&&l(D(e.libraryPath,u.search),{replace:!0})},[u.search,d,m.isError,m.isFetched,m.isFetching,m.isPending,l,e.libraryPath,g]);let ne=!r.data&&!r.error;return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:b(`grid h-full min-h-0 min-w-0`,d&&`xl:grid-cols-[minmax(0,1fr)_25rem]`),children:[/* @__PURE__ */ (0,G.jsx)(`div`,{"aria-label":`Memories list`,className:`min-h-0 overflow-y-auto overscroll-contain outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus`,ref:f,role:`region`,tabIndex:0,children:/* @__PURE__ */ (0,G.jsxs)(he,{className:`gap-6 sm:gap-8`,children:[/* @__PURE__ */ (0,G.jsx)(w,{description:e.page.description,title:e.page.label}),/* @__PURE__ */ (0,G.jsxs)(`section`,{className:`grid gap-4`,"aria-labelledby":`memory-library-title`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-4`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{children:/* @__PURE__ */ (0,G.jsx)(`h2`,{className:`m-0 font-display text-xl font-medium tracking-[-0.02em] text-dashboard-text`,id:`memory-library-title`,children:o?`Search results`:`What Junior remembers`})}),n?.searchPlaceholder?/* @__PURE__ */ (0,G.jsx)(I,{className:`w-full max-w-md sm:w-auto`,label:n.searchPlaceholder,onChange:c,placeholder:n.searchPlaceholder,size:`default`,value:s}):null]}),ne?/* @__PURE__ */ (0,G.jsx)(S,{label:`Loading memories`,variant:`panel`}):r.error?/* @__PURE__ */ (0,G.jsxs)(x,{className:`flex items-center gap-3 border-rose-300/20 p-5 text-sm text-rose-200`,children:[/* @__PURE__ */ (0,G.jsx)(ie,{"aria-hidden":`true`,size:18}),r.error.message]}):i.length===0?/* @__PURE__ */ (0,G.jsx)(x,{className:`grid min-h-56 place-items-center p-8 text-center`,children:/* @__PURE__ */ (0,G.jsxs)(`div`,{children:[/* @__PURE__ */ (0,G.jsx)(re,{"aria-hidden":`true`,className:`mx-auto text-dashboard-text-muted`,size:26}),/* @__PURE__ */ (0,G.jsx)(`p`,{className:`mt-4 mb-0 text-sm text-dashboard-text-muted`,children:n?.emptyText??`No memories yet.`})]})}):/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid gap-3`,children:[/* @__PURE__ */ (0,G.jsxs)(x,{padding:`none`,children:[/* @__PURE__ */ (0,G.jsx)(tt,{}),i.map((t,n)=>/* @__PURE__ */ (0,G.jsx)(at,{first:n===0,onSelect:()=>l(_(d===t.id?e.libraryPath:`/memories/${encodeURIComponent(t.id)}`)),record:t,searchQuery:o,selected:t.id===d},t.id))]}),/* @__PURE__ */ (0,G.jsx)(R,{className:`mt-2`,hasMore:!r.isPlaceholderData&&!!r.hasNextPage,loading:r.isFetchingNextPage,onLoadMore:()=>void r.fetchNextPage()}),t.error?/* @__PURE__ */ (0,G.jsx)(F,{className:`text-center`,children:`Could not complete this action. Try again.`}):null]})]})]})}),d?/* @__PURE__ */ (0,G.jsx)(Le,{forgetPending:t.isPending,onClose:v,onForget:te,record:g},d):null]})}function tt(){return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:b(`hidden items-center gap-3 border-b border-dashboard-border px-4 py-2.5 text-left font-sans font-medium text-xs text-dashboard-text-muted sm:grid`,Ze),role:`row`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{children:`Memory`}),/* @__PURE__ */ (0,G.jsx)(`div`,{children:`Type`}),/* @__PURE__ */ (0,G.jsx)(`div`,{children:`Learned`})]})}function nt(e){let{stats:t}=e.data,n=[{detail:`shared across the workspace`,label:`Total active`,tone:`text-dashboard-accent-text`,value:t.active.toLocaleString(`en-US`)},{detail:`in the last 30 days`,label:`Added · 30d`,value:`+${t.createdThirtyDays.toLocaleString(`en-US`)}`}];return/* @__PURE__ */ (0,G.jsx)(`section`,{"aria-label":`Memory summary`,className:`grid grid-cols-2 gap-px border-y border-dashboard-border-subtle bg-dashboard-fill-hover`,children:n.map(e=>/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`bg-dashboard-bg px-4 py-4 sm:px-5`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:b(`mt-2 font-display text-3xl font-light tracking-[-0.04em] text-dashboard-text`,e.tone),children:e.value}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-1 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.detail})]},e.label))})}function rt(e){let{stats:t}=e.data;return/* @__PURE__ */ (0,G.jsxs)(x,{className:`p-5 sm:p-6`,children:[/* @__PURE__ */ (0,G.jsx)(E,{anchor:`memory-types`,className:`m-0 font-display text-xl font-medium text-dashboard-text`,title:`What Junior remembers`}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`mt-5 grid gap-px overflow-hidden rounded-md border border-dashboard-border-subtle bg-dashboard-fill-hover`,children:[/* @__PURE__ */ (0,G.jsx)(Z,{detail:`How people like to work`,icon:oe,label:`Preferences`,value:t.preference}),/* @__PURE__ */ (0,G.jsx)(Z,{detail:`How work should get done`,icon:re,label:`Procedures`,value:t.procedure}),/* @__PURE__ */ (0,G.jsx)(Z,{detail:`Facts and durable context`,icon:Ae,label:`Knowledge`,value:t.knowledge})]})]})}function it(e){let{stats:t}=e.data,n=Math.max(0,t.active-t.automatic-t.explicit);return/* @__PURE__ */ (0,G.jsxs)(x,{className:`p-5 sm:p-6`,children:[/* @__PURE__ */ (0,G.jsx)(E,{anchor:`memory-sources`,className:`m-0 font-display text-xl font-medium text-dashboard-text`,title:`How they got here`}),/* @__PURE__ */ (0,G.jsx)(`p`,{className:`mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:`Same totals, split by how they were written.`}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`mt-5 grid gap-px overflow-hidden rounded-md border border-dashboard-border-subtle bg-dashboard-fill-hover`,children:[/* @__PURE__ */ (0,G.jsx)(Z,{detail:`Passive extraction after runs`,icon:ne,label:`Learned by Junior`,value:t.automatic}),/* @__PURE__ */ (0,G.jsx)(Z,{detail:`Someone asked to remember it`,icon:ke,label:`Saved explicitly`,value:t.explicit}),/* @__PURE__ */ (0,G.jsx)(Z,{detail:`Before origin tracking`,icon:Ae,label:`Older records`,value:n})]})]})}function Z(e){let t=e.icon;return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex items-center gap-3 bg-dashboard-bg-elevated px-3 py-3`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`grid size-9 shrink-0 place-items-center rounded-md border border-dashboard-border bg-dashboard-fill-soft text-dashboard-text-muted`,children:/* @__PURE__ */ (0,G.jsx)(t,{"aria-hidden":`true`,size:15})}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`font-display text-base font-medium text-dashboard-text`,children:e.label}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-0.5 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.detail})]}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`font-display text-2xl font-light text-dashboard-text`,children:e.value.toLocaleString(`en-US`)})]})}function at(e){let t=Q(e.record,`Type`),n=Q(e.record,`Remembered`),r=Q(e.record,`Source`);return/* @__PURE__ */ (0,G.jsx)(be,{className:b(`flex items-stretch`,!e.first&&`border-t border-dashboard-border-subtle`),onSelect:e.onSelect,selected:e.selected,children:/* @__PURE__ */ (0,G.jsxs)(`button`,{"aria-expanded":e.selected,"aria-label":`View memory details: ${e.record.title}`,"data-memory-id":e.record.id,className:b(`grid min-w-0 flex-1 cursor-pointer items-center gap-3 border-0 bg-transparent px-4 py-3 text-left`,Ze),onClick:e.onSelect,type:`button`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`flex min-w-0 items-center gap-2 overflow-hidden`,children:/* @__PURE__ */ (0,G.jsx)(`h3`,{className:`m-0 truncate font-display text-base font-medium leading-snug text-dashboard-text`,children:/* @__PURE__ */ (0,G.jsx)(Ue,{query:e.searchQuery,text:e.record.title})})}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`mt-1.5 truncate font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:[`Source: `,r,/* @__PURE__ */ (0,G.jsxs)(`span`,{className:`sm:hidden`,children:[` `,`· `,t,` · `,$(n)]})]})]}),/* @__PURE__ */ (0,G.jsx)(`span`,{className:`hidden truncate font-mono text-xs text-dashboard-text-muted sm:block`,children:t}),/* @__PURE__ */ (0,G.jsx)(`span`,{className:`hidden truncate font-mono text-xs text-dashboard-text sm:block`,children:$(n)})]})})}function Q(e,t){return e.metadata?.find(e=>e.label===t)?.value??`—`}function $(e){return e.split(`,`).slice(0,2).join(`,`)}function ot(e){let t=e.pages.find(e=>e.pluginName===`memory`&&e.id===`memories`);return t?/* @__PURE__ */ (0,G.jsx)(Qe,{page:t}):/* @__PURE__ */ (0,G.jsx)(m,{replace:!0,to:`/`})}function st(e){let t=h(),{"*":n,pageId:r,pluginName:i}=p(),a=e.pages.find(e=>e.pluginName===i&&e.id===r);if(!a)return/* @__PURE__ */ (0,G.jsx)(m,{replace:!0,to:`/`});if(a.pluginName===`memory`&&a.id===`memories`){let e=n?`/${n}`:``;return/* @__PURE__ */ (0,G.jsx)(m,{replace:!0,to:D(`/memories${e}`,t.search)})}return/* @__PURE__ */ (0,G.jsx)(ct,{page:a})}function ct(e){let{action:t,content:n,query:r,records:i,runAction:a,searchText:o,setSearchText:s}=je(e.page),[c,l]=(0,U.useState)(),[u,d]=(0,U.useState)(!1);return!r.data&&!r.error?/* @__PURE__ */ (0,G.jsx)(ve,{label:`Loading ${e.page.label}`}):/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`${fe} px-4 py-8 md:px-8`,children:[/* @__PURE__ */ (0,G.jsxs)(`section`,{className:`mx-auto grid w-full max-w-3xl gap-6`,children:[/* @__PURE__ */ (0,G.jsx)(w,{description:e.page.description,title:e.page.label}),n?.metrics?.length?/* @__PURE__ */ (0,G.jsx)(`section`,{"aria-label":`${e.page.label} overview`,className:`grid gap-3 sm:grid-cols-2`,children:n.metrics.map(e=>/* @__PURE__ */ (0,G.jsxs)(x,{className:`p-4`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-3 font-display text-2xl font-light text-dashboard-text`,children:e.value}),e.detail?/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-1 font-mono text-xs text-dashboard-text-muted`,children:e.detail}):null]},e.label))}):null,n?.searchPlaceholder?/* @__PURE__ */ (0,G.jsx)(I,{className:`w-full`,label:n.searchPlaceholder,onChange:s,placeholder:n.searchPlaceholder,size:`default`,value:o}):null,r.error?/* @__PURE__ */ (0,G.jsx)(x,{padding:`md`,children:/* @__PURE__ */ (0,G.jsxs)(F,{children:[`Could not load `,e.page.label.toLowerCase(),`. Try again.`]})}):i.length===0?/* @__PURE__ */ (0,G.jsx)(x,{padding:`md`,children:/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`grid size-10 shrink-0 place-items-center rounded-md border border-dashboard-border bg-dashboard-fill-soft text-dashboard-text-muted`,children:/* @__PURE__ */ (0,G.jsx)(te,{"aria-hidden":`true`,size:17})}),/* @__PURE__ */ (0,G.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:n?.emptyText??`No ${e.page.label.toLowerCase()}.`})]})}):/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid gap-3`,children:[i.map(e=>/* @__PURE__ */ (0,G.jsxs)(x,{padding:`md`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[/* @__PURE__ */ (0,G.jsx)(`h2`,{className:`m-0 min-w-0 flex-1 font-display text-base font-medium text-dashboard-text`,children:e.title}),e.actions?.map(n=>n.method===`GET`?/* @__PURE__ */ (0,G.jsx)(`a`,{className:`shrink-0 rounded-md border border-dashboard-border-strong px-3 py-1.5 text-sm font-semibold text-dashboard-text no-underline transition-colors hover:bg-dashboard-fill-strong`,href:n.href,children:n.label},`${n.method}:${n.href}`):/* @__PURE__ */ (0,G.jsx)(`button`,{"aria-label":`${n.label}: ${e.title}`,className:`cursor-pointer border-0 bg-transparent p-1 text-dashboard-text-muted transition-colors ${n.tone===`danger`?`hover:text-rose-300`:`hover:text-dashboard-text`}`,disabled:t.isPending,onClick:()=>{n.confirmation?(l({action:n,record:e}),d(!0)):a(n)},title:n.label,type:`button`,children:n.tone===`danger`?/* @__PURE__ */ (0,G.jsx)(ae,{"aria-hidden":`true`,size:16}):n.label},`${n.method}:${n.href}`))]}),e.description?/* @__PURE__ */ (0,G.jsx)(`p`,{className:`mt-2 mb-0 text-sm text-dashboard-text-muted`,children:e.description}):null,e.metadata?.length?/* @__PURE__ */ (0,G.jsx)(`dl`,{className:`mt-4 flex flex-wrap gap-x-6 gap-y-2`,children:e.metadata.map(e=>/* @__PURE__ */ (0,G.jsxs)(`div`,{children:[/* @__PURE__ */ (0,G.jsx)(`dt`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,G.jsx)(`dd`,{className:`mt-1 ml-0 font-mono text-xs text-dashboard-text-muted`,children:e.value})]},e.label))}):null]},e.id)),/* @__PURE__ */ (0,G.jsx)(R,{hasMore:!r.isPlaceholderData&&!!r.hasNextPage,loading:r.isFetchingNextPage,onLoadMore:()=>void r.fetchNextPage()}),t.error?/* @__PURE__ */ (0,G.jsx)(F,{className:`text-center`,children:`Could not complete this action. Try again.`}):null]})]}),/* @__PURE__ */ (0,G.jsx)(L,{onOpenChange:d,open:u,children:/* @__PURE__ */ (0,G.jsxs)(N,{children:[/* @__PURE__ */ (0,G.jsx)(A,{children:c?.action.confirmation}),/* @__PURE__ */ (0,G.jsx)(O,{children:c?.record.title}),/* @__PURE__ */ (0,G.jsxs)(k,{children:[/* @__PURE__ */ (0,G.jsx)(M,{children:`Cancel`}),/* @__PURE__ */ (0,G.jsx)(j,{onClick:()=>{c&&a(c.action),d(!1)},variant:c?.action.tone===`danger`?`danger`:`primary`,children:c?.action.label})]})]})})]})}export{ot as MemoryPermalinkRoute,st as PluginUserPageRoute};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n,_ as r,r as i}from"./vendor-react-ggbyvons.js";import{n as a}from"./button-ygjnb239.js";import{Jt as o}from"./vendor-icons-blmhaswc.js";import{n as s,t as c}from"./CodeChangeRow-d620nk75.js";import{a as l,t as u}from"./styles-j0007fov.js";import{t as d}from"./Card-hy4bfgq7.js";import{n as f,r as p,s as m,t as h}from"./PageHeader-bhl3orzi.js";import{H as g,T as _,U as v,a as ee,j as y,r as b,y as x}from"./format-flkutk9e.js";import{t as S}from"./SecondaryNavigation-m358iuko.js";import{t as C}from"./PageLayout-l6dhbimv.js";import{It as w,Lt as T,Rt as E,Tt as D,Z as O,_ as k,_t as te,an as A,ft as j,g as M,gt as N,h as P,in as F,p as I,pt as L,q as R,u as z,yt as B}from"../client-ctcthgam.js";import{r as V}from"./FilterBar-dqnt967g.js";import{t as H}from"./CodeSummaryCards-iotfblbp.js";import{n as U,t as W}from"./SectionTitle-drw3mqtl.js";var G=/* @__PURE__ */ e(t(),1),K=n();function q(e){return/* @__PURE__ */ (0,K.jsxs)(d,{as:`section`,className:`mb-0`,variant:`section`,children:[/* @__PURE__ */ (0,K.jsx)(U,{actions:e.viewAllTo?/* @__PURE__ */ (0,K.jsx)(i,{className:`text-sm text-dashboard-text underline underline-offset-2`,to:e.viewAllTo,children:`View all`}):void 0,children:/* @__PURE__ */ (0,K.jsx)(W,{children:e.title})}),e.children]})}function J(e){let t=e.conversation,n=g(t),r=ee(t),a=y(t,{includeId:!1}),o=!!t.sidebarAnnotations?.length;return/* @__PURE__ */ (0,K.jsxs)(`div`,{className:`relative min-w-0 border-b border-dashboard-border-subtle px-4 py-3 transition-colors last:border-b-0 hover:bg-dashboard-fill-soft`,children:[/* @__PURE__ */ (0,K.jsx)(i,{"aria-label":`Open ${r}`,className:`absolute inset-0 z-0 focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-dashboard-focus`,to:T(t.id)}),/* @__PURE__ */ (0,K.jsxs)(`div`,{className:`pointer-events-none relative z-[1] grid min-w-0 grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-x-2`,children:[/* @__PURE__ */ (0,K.jsx)(`span`,{className:`mt-1.5 grid size-3 shrink-0 place-items-center`,children:/* @__PURE__ */ (0,K.jsx)(N,{unread:!1,status:n,waitingOnViewer:!1})}),/* @__PURE__ */ (0,K.jsx)(`div`,{className:`min-w-0 truncate font-display text-sm text-dashboard-text`,children:r}),/* @__PURE__ */ (0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 whitespace-nowrap font-mono text-xs text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,K.jsx)(te,{isPrivate:t.visibility===`private`,status:n}),x(t.lastMessageAt??t.lastSeenAt)]}),/* @__PURE__ */ (0,K.jsx)(`div`,{className:`col-start-2 col-end-4 mt-1 flex h-4 min-w-0 items-center gap-1.5 font-mono text-xs text-dashboard-text-muted`,children:o?/* @__PURE__ */ (0,K.jsx)(R,{annotations:t.sidebarAnnotations}):a?/* @__PURE__ */ (0,K.jsx)(`span`,{className:`truncate`,children:a}):null})]})]})}function Y(e,t){return p({days:e.activityDays,hours:e.activityHours,sixHours:e.activitySixHours,range:t,emptySixHour:e=>({closed:0,created:0,date:e,merged:0})})}function X(e){let[t,n]=(0,G.useState)(``),[r,i]=(0,G.useState)(1),a=w(t.trim()),o=F(e.repositoryId,a),s=b(o.data?.conversations??[]),c=D();return(0,G.useEffect)(()=>{i(1)},[a]),/* @__PURE__ */ (0,K.jsxs)(`section`,{"aria-label":`Conversations`,className:`grid gap-3`,children:[/* @__PURE__ */ (0,K.jsx)(j,{className:`w-full sm:ml-auto sm:w-72`,label:`Search conversations in this repository`,onChange:n,placeholder:`Search conversations…`,value:t}),o.error?/* @__PURE__ */ (0,K.jsx)(L,{children:`Conversations are unavailable. Try refreshing the dashboard.`}):/* @__PURE__ */ (0,K.jsx)(O,{conversations:k(E(s,c),r,25),emptyLabel:a?`No conversations match this search.`:`No conversations are linked to this repository yet.`,loading:!o.data,timeZone:_(),waitingConversations:c}),/* @__PURE__ */ (0,K.jsx)(P,{className:`pt-1`,onPageChange:i,page:r,pageCount:M(s.length,25),pageSize:25,total:s.length})]})}function Z(e){let[t,n]=(0,G.useState)(``),[r,i]=(0,G.useState)(``),[a,o]=(0,G.useState)(1),l=e.data.changes,u=r.trim().toLowerCase(),f=l.filter(e=>(!t||e.state===t)&&(!u||e.title?.toLowerCase().includes(u)||`#${e.number}`.includes(u))),p=e=>l.filter(t=>t.state===e).length;return(0,G.useEffect)(()=>{o(1)},[t,u]),/* @__PURE__ */ (0,K.jsxs)(K.Fragment,{children:[/* @__PURE__ */ (0,K.jsx)(s,{bucketUnit:m(e.range),days:Y(e.data,e.range),range:e.range}),/* @__PURE__ */ (0,K.jsxs)(`section`,{"aria-label":`Changes`,className:`grid gap-4`,children:[/* @__PURE__ */ (0,K.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-4`,children:[/* @__PURE__ */ (0,K.jsx)(V,{ariaLabel:`Change state`,items:[{count:l.length,label:`All`,value:``},{count:p(`open`),label:`Open`,value:`open`},{count:p(`merged`),label:`Merged`,value:`merged`},{count:p(`closed`),label:`Closed`,value:`closed`}],onChange:n,value:t}),/* @__PURE__ */ (0,K.jsx)(j,{className:`w-full max-w-md sm:w-auto`,label:`Search changes`,onChange:i,placeholder:`Title or number`,value:r})]}),/* @__PURE__ */ (0,K.jsx)(d,{children:f.length===0?/* @__PURE__ */ (0,K.jsx)(`div`,{className:`p-4`,children:/* @__PURE__ */ (0,K.jsx)(L,{children:`No changes match these filters.`})}):k(f,a,25).map(e=>/* @__PURE__ */ (0,K.jsx)(c,{change:e},e.id))}),/* @__PURE__ */ (0,K.jsx)(P,{onPageChange:o,page:a,pageCount:M(f.length,25),pageSize:25,total:f.length})]})]})}const Q=`Conversations and code changes from Junior.`,ne=u(`font-semibold`,l);function re(e){let t=r().repositoryId,[n,i]=(0,G.useState)(30),o=A(t);if(!o.data&&!o.error)return/* @__PURE__ */ (0,K.jsx)(z,{description:Q,label:`Loading repository`,title:`Repository`,variant:`stats`});let s=o.data;if(!s)return/* @__PURE__ */ (0,K.jsxs)(C,{children:[/* @__PURE__ */ (0,K.jsx)($,{}),/* @__PURE__ */ (0,K.jsx)(L,{children:`This repository is unavailable. It may not have any code changes from Junior.`})]});let c=s.repository;return/* @__PURE__ */ (0,K.jsx)(S,{ariaLabel:`Repository navigation`,items:[{end:!0,label:`Overview`,to:I(c.id)},{label:`Conversations`,to:I(c.id,`conversations`)},{label:`Changes`,to:I(c.id,`changes`)}],children:/* @__PURE__ */ (0,K.jsxs)(C,{children:[/* @__PURE__ */ (0,K.jsx)($,{}),/* @__PURE__ */ (0,K.jsx)(h,{actions:/* @__PURE__ */ (0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[/* @__PURE__ */ (0,K.jsx)(f,{onChange:i,value:n}),c.url?/* @__PURE__ */ (0,K.jsx)(B,{className:a(),href:c.url,children:`Open repository`}):null]}),description:/* @__PURE__ */ (0,K.jsx)(ie,{data:s}),documentTitle:e.tab===`overview`?c.name:`${c.name} · ${e.tab===`changes`?`Changes`:`Conversations`}`,title:c.name}),e.tab===`overview`?/* @__PURE__ */ (0,K.jsx)(ae,{data:s,range:n}):null,e.tab===`conversations`?/* @__PURE__ */ (0,K.jsx)(X,{repositoryId:c.id}):null,e.tab===`changes`?/* @__PURE__ */ (0,K.jsx)(Z,{data:s,range:n}):null]})})}function $(){return/* @__PURE__ */ (0,K.jsxs)(i,{className:`flex w-fit items-center gap-2 font-display text-sm font-medium text-dashboard-text-muted no-underline transition-colors hover:text-dashboard-text`,to:`/code`,children:[/* @__PURE__ */ (0,K.jsx)(o,{"aria-hidden":`true`,size:15,strokeWidth:1.8}),`Back to code`]})}function ie(e){let t=e.data.workspaces;return t.length===0?Q:/* @__PURE__ */ (0,K.jsxs)(K.Fragment,{children:[Q,` / Workspaces`,` `,t.map((e,t)=>/* @__PURE__ */ (0,K.jsxs)(`span`,{children:[t>0?`, `:null,/* @__PURE__ */ (0,K.jsx)(i,{className:ne,to:v(e.id),children:e.name})]},e.id))]})}function ae(e){let t=e.data,n=F(t.repository.id),r=b(n.data?.conversations??[]).slice(0,5),i=t.changes.slice(0,5);return/* @__PURE__ */ (0,K.jsxs)(K.Fragment,{children:[/* @__PURE__ */ (0,K.jsx)(H,{summary:t.summary}),/* @__PURE__ */ (0,K.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[/* @__PURE__ */ (0,K.jsx)(q,{title:`Recent conversations`,viewAllTo:I(t.repository.id,`conversations`),children:r.length>0?r.map(e=>/* @__PURE__ */ (0,K.jsx)(J,{conversation:e},e.id)):/* @__PURE__ */ (0,K.jsx)(`div`,{className:`p-4`,children:/* @__PURE__ */ (0,K.jsx)(L,{children:n.error?`Conversations are unavailable. Try refreshing the dashboard.`:n.data?`No conversations are linked to this repository yet.`:`Loading conversations…`})})}),/* @__PURE__ */ (0,K.jsx)(q,{title:`Recent changes`,viewAllTo:I(t.repository.id,`changes`),children:i.length>0?i.map(e=>/* @__PURE__ */ (0,K.jsx)(c,{change:e},e.id)):/* @__PURE__ */ (0,K.jsx)(`div`,{className:`p-4`,children:/* @__PURE__ */ (0,K.jsx)(L,{children:`No code changes are recorded yet.`})})})]}),/* @__PURE__ */ (0,K.jsx)(s,{bucketUnit:m(e.range),days:Y(t,e.range),range:e.range})]})}export{re as RepositoryPage};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{ot as t,pt as n,ut as r}from"./vendor-lthmb2su.js";import{C as i,S as a}from"./vendor-react-ggbyvons.js";import{t as o}from"./button-ygjnb239.js";import{At as s,E as c,_t as l,ft as u}from"./junior-g62bxb2t.js";import{r as d}from"./schema-m4v0mjyv.js";import{a as f,i as p,n as m,s as h,t as g}from"./http-cdq677qt.js";import{t as _}from"./Card-hy4bfgq7.js";import{t as v}from"./skeleton-h6p83ux1.js";import{d as y,u as b}from"./PageHeader-bhl3orzi.js";import{t as x}from"./AnchorHeading-ixbupfij.js";import{B as S,C,Ct as w,D as ee,E as T,Gt as E,J as D,O,R as k,S as A,T as j,Wt as M,X as N,Y as te,b as ne,bt as P,d as re,mt as ie,v as F,w as I,wt as L,x as R,xt as z,y as B,z as V}from"../client-ctcthgam.js";import{t as H}from"./native-select-fxs3p0bj.js";var U=/* @__PURE__ */ e(i(),1),W=a();const G=R.queryKey,K=[[1,`Mon`],[2,`Tue`],[3,`Wed`],[4,`Thu`],[5,`Fri`],[6,`Sat`],[0,`Sun`]],q={default:`Junior default`,saved:`from your profile`,slack:`from Slack`};function J(){try{return Intl.supportedValuesOf(`timeZone`)}catch{return[]}}function Y(){let e=r(R);return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{anchor:ne,className:`m-0 text-lg font-bold`,title:`Push notifications`}),/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-2 mb-0 text-sm text-dashboard-text-muted`,children:`Get a notification when Junior replies to a conversation you started here. Slack threads keep using Slack notifications.`}),e.isPending?/* @__PURE__ */ (0,W.jsx)(ae,{}):e.isError?/* @__PURE__ */ (0,W.jsx)(N,{className:`mt-5`,children:`Could not load notification settings. Reload the page to try again.`}):/* @__PURE__ */ (0,W.jsxs)(W.Fragment,{children:[/* @__PURE__ */ (0,W.jsx)(oe,{settings:e.data}),/* @__PURE__ */ (0,W.jsx)(se,{settings:e.data})]})]})}function ae(){return/* @__PURE__ */ (0,W.jsxs)(`div`,{"aria-label":`Loading notification settings`,className:`mt-5 grid gap-3`,role:`status`,children:[/* @__PURE__ */ (0,W.jsx)(v,{className:`h-10 w-48`}),/* @__PURE__ */ (0,W.jsx)(v,{className:`h-24 w-full`})]})}function oe({settings:e}){let i=n(),a=(0,U.useMemo)(()=>T(),[]),s=r({enabled:a===`supported`,queryKey:A,queryFn:async()=>(await j())?.endpoint??null}),l=a===`supported`&&!!e.publicKey;(0,U.useEffect)(()=>{l&&ee()?.catch(()=>void 0)},[l]);let u=e=>i.setQueryData(G,e),d=t({mutationFn:e=>I(i,e)}),f=t({mutationFn:async()=>{let e=await O();return e?await m(c,`${B}/subscriptions`,{endpoint:e}):void 0},onSuccess:e=>{e&&u(e),i.invalidateQueries({queryKey:A})}}),p=t({mutationFn:C});if(!e.publicKey)return/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-5 mb-0 text-sm text-dashboard-text-muted`,children:`Push notifications are not set up for this Junior install. Ask a Junior admin to add Web Push keys.`});if(a===`needs-install`)return/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-5 mb-0 text-sm text-dashboard-text-muted`,children:`On iPhone and iPad, add Junior to your Home Screen first. Tap Share, then Add to Home Screen. Open Junior from the Home Screen and come back to this page.`});if(a===`unsupported`)return/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-5 mb-0 text-sm text-dashboard-text-muted`,children:`This browser cannot receive notifications.`});let h=typeof Notification<`u`&&Notification.permission===`denied`,g=!!s.data,_=e.publicKey;return/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-5`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`flex flex-wrap items-center gap-3`,children:g?/* @__PURE__ */ (0,W.jsxs)(W.Fragment,{children:[/* @__PURE__ */ (0,W.jsx)(o,{disabled:f.isPending,onClick:()=>f.mutate(),type:`button`,children:f.isPending?`Turning off…`:`Turn off on this device`}),/* @__PURE__ */ (0,W.jsx)(o,{disabled:p.isPending,onClick:()=>p.mutate(),type:`button`,children:p.isPending?`Sending…`:`Send a test`})]}):/* @__PURE__ */ (0,W.jsx)(o,{disabled:d.isPending||s.isPending||h,onClick:()=>d.mutate(_),type:`button`,variant:`primary`,children:d.isPending?`Turning on…`:`Turn on for this device`})}),/* @__PURE__ */ (0,W.jsxs)(`p`,{className:`mt-3 mb-0 text-sm text-dashboard-text-muted`,children:[e.deviceCount===1?`1 device gets your notifications.`:`${e.deviceCount} devices get your notifications.`,h?` This browser blocks notifications from Junior. Allow them in the browser settings.`:``]}),p.isSuccess?/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-2 mb-0 text-sm text-emerald-300`,children:p.data.delivered>0?`Test sent.`:`No device got the test. Turn notifications off and on again.`}):null,d.isError||f.isError||p.isError?/* @__PURE__ */ (0,W.jsx)(N,{className:`mt-2`,children:`Could not change notifications on this device. Try again.`}):null]})}function se({settings:e}){let r=n(),[i,a]=(0,U.useState)(e.schedule);(0,U.useEffect)(()=>a(e.schedule),[e.schedule]);let l=(0,U.useMemo)(()=>J(),[]),u=t({mutationFn:e=>h(c,`${B}/schedule`,e),onSuccess:e=>r.setQueryData(G,e)}),d=e=>{a(t=>({...t,...e})),(u.isSuccess||u.isError)&&u.reset()},f=JSON.stringify(i)!==JSON.stringify(e.schedule),p=i.start!==i.end&&(!i.workingHoursOnly||i.days.length>0),m=i.timezone??e.timezone,g=i.followSlack!==!1,_=g&&e.slackPausedNow!==void 0?!e.slackPausedNow:s(i,m,Date.now());function v(e){e.preventDefault(),f&&p&&u.mutate(i)}return/* @__PURE__ */ (0,W.jsxs)(`form`,{className:`mt-6 border-t border-dashboard-border pt-5`,onSubmit:v,children:[/* @__PURE__ */ (0,W.jsx)(`h3`,{className:`m-0 text-base font-bold`,children:`Working hours`}),/* @__PURE__ */ (0,W.jsxs)(`label`,{className:`mt-4 flex items-center gap-3 text-sm`,children:[/* @__PURE__ */ (0,W.jsx)(S,{checked:g,onCheckedChange:e=>d({followSlack:e===!0})}),`Follow my Slack notification schedule`]}),g?/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-2 mb-0 text-sm text-dashboard-text-muted`,children:e.slackPausedNow===void 0?`Junior cannot read your Slack notification schedule, so it uses the hours below.`:`Junior pauses notifications when Slack does. It uses the hours below only when it cannot read Slack.`}):null,/* @__PURE__ */ (0,W.jsxs)(`label`,{className:`mt-4 flex items-center gap-3 text-sm`,children:[/* @__PURE__ */ (0,W.jsx)(S,{checked:i.workingHoursOnly,onCheckedChange:e=>d({workingHoursOnly:e===!0})}),`Only notify me during working hours`]}),/* @__PURE__ */ (0,W.jsxs)(`fieldset`,{className:`m-0 mt-4 border-0 p-0 disabled:opacity-60`,disabled:!i.workingHoursOnly,children:[/* @__PURE__ */ (0,W.jsx)(`legend`,{className:`mb-2 p-0 text-sm font-medium`,children:`Days`}),/* @__PURE__ */ (0,W.jsx)(b,{"aria-label":`Working days`,className:`flex-wrap gap-2`,multiple:!0,onValueChange:e=>d({days:e.map(Number).sort((e,t)=>e-t)}),value:i.days.map(String),children:K.map(([e,t])=>/* @__PURE__ */ (0,W.jsx)(y,{className:`min-h-11 min-w-12 lg:min-h-9`,value:String(e),variant:`pill`,children:t},e))}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-3 sm:max-w-sm`,children:[/* @__PURE__ */ (0,W.jsxs)(P,{children:[/* @__PURE__ */ (0,W.jsx)(w,{htmlFor:`notification-start`,children:`Start`}),/* @__PURE__ */ (0,W.jsx)(L,{id:`notification-start`,onChange:e=>d({start:e.target.value}),required:!0,step:900,type:`time`,value:i.start})]}),/* @__PURE__ */ (0,W.jsxs)(P,{children:[/* @__PURE__ */ (0,W.jsx)(w,{htmlFor:`notification-end`,children:`End`}),/* @__PURE__ */ (0,W.jsx)(L,{id:`notification-end`,onChange:e=>d({end:e.target.value}),required:!0,step:900,type:`time`,value:i.end})]})]})]}),/* @__PURE__ */ (0,W.jsxs)(P,{className:`mt-4 sm:max-w-sm`,children:[/* @__PURE__ */ (0,W.jsx)(w,{htmlFor:`notification-timezone`,children:`Timezone`}),/* @__PURE__ */ (0,W.jsxs)(H,{id:`notification-timezone`,onChange:e=>d({timezone:e.target.value||void 0}),value:i.timezone??``,children:[/* @__PURE__ */ (0,W.jsx)(`option`,{value:``,children:e.timezoneSource===`manual`?`Automatic`:`Automatic: ${e.timezone} (${q[e.timezoneSource]})`}),l.map(e=>/* @__PURE__ */ (0,W.jsx)(`option`,{value:e,children:e},e))]}),/* @__PURE__ */ (0,W.jsx)(z,{children:`Automatic uses your Slack timezone when Junior can read it.`})]}),/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-4 mb-0 text-sm text-dashboard-text-muted`,children:_?`Notifications are on right now.`:`Notifications are paused right now. Replies still show here.`}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-5 flex items-center gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(o,{disabled:!f||!p||u.isPending,type:`submit`,children:u.isPending?`Saving…`:`Save hours`}),u.isSuccess?/* @__PURE__ */ (0,W.jsx)(`p`,{className:`m-0 text-sm text-emerald-300`,children:`Hours saved.`}):null,u.isError?/* @__PURE__ */ (0,W.jsx)(N,{children:`Could not save your hours. Try again.`}):null]})]})}const ce=[`dashboard`,`core`],X=[1,6,24,72,168];function le(e){return e===0?`No done conversations to archive.`:e===1?`Archived 1 conversation.`:`Archived ${e} conversations.`}function ue(e){if(e%24!=0)return e===1?`1 hour`:`${e} hours`;let t=e/24;return t===7?`1 week`:t===1?`1 day`:`${t} days`}function de({identity:e}){let r=n(),i=t({mutationFn:e=>f(d,`/api/me`,e),onSuccess:e=>{r.setQueryData(ce,t=>t&&{...t,me:e})}}),a=F(),s=e.autoArchiveDefault??!1,c=e.autoArchiveGraceHours??24,l=X.includes(c)?X:[...X,c].sort((e,t)=>e-t);return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{anchor:`conversations`,className:`m-0 text-lg font-bold`,title:`Conversations`}),/* @__PURE__ */ (0,W.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(S,{checked:s,className:`mt-0.5`,disabled:i.isPending,onCheckedChange:e=>i.mutate({autoArchiveDefault:e})}),/* @__PURE__ */ (0,W.jsxs)(`span`,{className:`grid gap-0.5`,children:[/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-sm font-medium`,children:`Auto-archive conversations when done`}),/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,children:`Archive a conversation for everyone when all of its linked work, such as pull requests, is merged or closed and nobody replies during the wait time. You can change this for each conversation in its details.`})]})]}),/* @__PURE__ */ (0,W.jsxs)(P,{className:`mt-5 max-w-xs`,children:[/* @__PURE__ */ (0,W.jsx)(w,{htmlFor:`auto-archive-grace`,children:`Wait time`}),/* @__PURE__ */ (0,W.jsx)(H,{"aria-describedby":`auto-archive-grace-help`,disabled:i.isPending,id:`auto-archive-grace`,onChange:e=>i.mutate({autoArchiveGraceHours:Number(e.target.value)}),value:c,children:l.map(e=>/* @__PURE__ */ (0,W.jsx)(`option`,{value:e,children:ue(e)},e))}),/* @__PURE__ */ (0,W.jsx)(z,{id:`auto-archive-grace-help`,children:`How long finished work and the conversation stay quiet before archive.`})]}),i.isError?/* @__PURE__ */ (0,W.jsx)(N,{className:`mt-3`,children:`Could not save this setting. Try again.`}):null,/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-5 grid gap-1.5`,children:[/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(o,{disabled:a.isPending,onClick:()=>a.mutate(),type:`button`,children:a.isPending?`Archiving…`:`Archive done now`}),a.isSuccess?/* @__PURE__ */ (0,W.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,role:`status`,children:le(a.data.archived)}):null,a.isError?/* @__PURE__ */ (0,W.jsx)(N,{children:`Could not archive conversations. Try again.`}):null]}),/* @__PURE__ */ (0,W.jsx)(`p`,{className:`m-0 text-xs text-dashboard-text-muted`,children:`Archive every done conversation once, after the same wait time. Skips conversations where you turned auto-archive off.`})]})]})}const fe=[`dashboard`,`core`],Z=[`dashboard`,`user-customization`],Q=`/api/user-customization`;function pe({identity:e}){let r=n(),[i,a]=(0,U.useState)(e.user.name??``);(0,U.useEffect)(()=>{a(e.user.name??``)},[e.user.name]);let s=t({mutationFn:e=>f(d,`/api/me`,{displayName:e}),onSuccess:e=>{r.setQueryData(fe,t=>t&&{...t,me:e}),a(e.user.name??``)}}),c=e.user.name?.trim()??``,l=i.trim(),u=l.length>0&&l.length<=80&&l!==c&&!s.isPending;function p(e){e.preventDefault(),u&&s.mutate(l)}return/* @__PURE__ */ (0,W.jsxs)(re,{description:`Manage your profile and preferences.`,title:`General`,children:[/* @__PURE__ */ (0,W.jsx)(`form`,{onSubmit:p,children:/* @__PURE__ */ (0,W.jsxs)(_,{className:`mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{anchor:`profile`,className:`m-0 text-lg font-bold`,title:`Profile`}),/* @__PURE__ */ (0,W.jsxs)(P,{className:`mt-5`,children:[/* @__PURE__ */ (0,W.jsx)(w,{htmlFor:`display-name`,children:`Display name`}),/* @__PURE__ */ (0,W.jsx)(L,{autoComplete:`name`,id:`display-name`,maxLength:80,onChange:e=>{a(e.target.value),(s.isError||s.isSuccess)&&s.reset()},value:i}),/* @__PURE__ */ (0,W.jsx)(z,{id:`display-name-help`,children:`Your display name is shown with your conversations and activity.`})]}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-5 flex items-center gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(o,{disabled:!u,type:`submit`,children:s.isPending?`Saving…`:`Save changes`}),s.isSuccess?/* @__PURE__ */ (0,W.jsx)(`p`,{className:`m-0 text-sm text-emerald-300`,children:`Changes saved.`}):null,s.isError?/* @__PURE__ */ (0,W.jsx)(N,{children:`Could not save your display name. Try again.`}):null]})]})}),/* @__PURE__ */ (0,W.jsx)($,{}),/* @__PURE__ */ (0,W.jsx)(he,{}),/* @__PURE__ */ (0,W.jsx)(ge,{}),/* @__PURE__ */ (0,W.jsx)(de,{identity:e}),/* @__PURE__ */ (0,W.jsx)(Y,{}),/* @__PURE__ */ (0,W.jsx)(_e,{})]})}function $(){let[e,t]=E();return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0 hidden md:block`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{anchor:`navigation`,className:`m-0 text-lg font-bold`,title:`Navigation`}),/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-1 mb-4 text-sm text-dashboard-text-muted`,children:`This choice applies to this browser.`}),/* @__PURE__ */ (0,W.jsx)(k,{"aria-label":`Navigation`,className:`grid gap-3`,onValueChange:t,value:e,children:M.map(e=>/* @__PURE__ */ (0,W.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(V,{className:`mt-0.5`,value:e.value}),/* @__PURE__ */ (0,W.jsxs)(`span`,{className:`grid gap-0.5`,children:[/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-sm font-medium`,children:e.label}),/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,children:e.description})]})]},e.value))})]})}const me=[{description:`Open at the first new message, below a “New” line.`,label:`Where I left off`,value:`unread`},{description:`Always open at the newest message.`,label:`Latest message`,value:`latest`}];function he(){let[e,t]=ie();return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{anchor:`open-conversations-at`,className:`m-0 text-lg font-bold`,title:`Open conversations at`}),/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-1 mb-4 text-sm text-dashboard-text-muted`,children:`Junior keeps your place in each conversation on all your devices. This choice applies to this browser.`}),/* @__PURE__ */ (0,W.jsx)(k,{"aria-label":`Open conversations at`,className:`grid gap-3`,onValueChange:t,value:e,children:me.map(e=>/* @__PURE__ */ (0,W.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(V,{className:`mt-0.5`,value:e.value}),/* @__PURE__ */ (0,W.jsxs)(`span`,{className:`grid gap-0.5`,children:[/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-sm font-medium`,children:e.label}),/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,children:e.description})]})]},e.value))})]})}function ge(){let[e,t]=D();return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{anchor:`message-box`,className:`m-0 text-lg font-bold`,title:`Message box`}),/* @__PURE__ */ (0,W.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(S,{checked:e,className:`mt-0.5`,onCheckedChange:t}),/* @__PURE__ */ (0,W.jsxs)(`span`,{className:`grid gap-0.5`,children:[/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-sm font-medium`,children:`Autocorrect`}),/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,children:`Let your keyboard correct spelling and capitalize sentences as you type. This can change ids, paths, and code. This choice applies to this browser.`})]})]})]})}function _e(){let e=n(),[i,a]=(0,U.useState)(``),s=r({queryKey:Z,queryFn:({signal:e})=>p(l,Q,e),retry:!1}),c=s.data?.customization;(0,U.useEffect)(()=>{c!==void 0&&a(c)},[c]);let d=t({mutationFn:e=>h(l,Q,{customization:e}),onSuccess:t=>{e.setQueryData(Z,t)}});if(s.error instanceof g&&s.error.status===404)return null;if(c===void 0)return s.isError?/* @__PURE__ */ (0,W.jsx)(N,{children:`Could not load your customization.`}):null;let f=i.trim()!==c&&i.trim().length<=1e3&&!d.isPending;function m(e){e.preventDefault(),f&&d.mutate(i.trim())}return/* @__PURE__ */ (0,W.jsx)(`form`,{onSubmit:m,children:/* @__PURE__ */ (0,W.jsxs)(_,{className:`mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{anchor:`customization`,className:`m-0 text-lg font-bold`,title:`Customization`}),/* @__PURE__ */ (0,W.jsxs)(P,{className:`mt-5`,children:[/* @__PURE__ */ (0,W.jsx)(w,{htmlFor:`user-customization`,children:`How should replies to you change?`}),/* @__PURE__ */ (0,W.jsx)(te,{id:`user-customization`,maxLength:u,onChange:e=>{a(e.target.value),(d.isError||d.isSuccess)&&d.reset()},placeholder:`Keep replies short and simple.`,value:i}),/* @__PURE__ */ (0,W.jsxs)(z,{children:[`Added to each message you send. Do not put secrets here. (`,i.trim().length,`/`,u,`)`]})]}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-5 flex items-center gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(o,{disabled:!f,type:`submit`,children:d.isPending?`Saving…`:`Save customization`}),d.isSuccess?/* @__PURE__ */ (0,W.jsx)(`p`,{className:`m-0 text-sm text-emerald-300`,children:`Changes saved.`}):null,d.isError?/* @__PURE__ */ (0,W.jsx)(N,{children:`Could not save your customization. Try again.`}):null]})]})})}export{pe as SettingsPage};
@@ -0,0 +1,15 @@
1
+ import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n,a as r,p as i,r as a}from"./vendor-react-ggbyvons.js";import{$ as o,$t as s,B as c,Bt as l,_ as u,c as d,qt as ee}from"./vendor-icons-blmhaswc.js";import{t as te}from"./circle-dollar-sign-h7k4kr7s.js";import{t as f}from"./styles-j0007fov.js";import{t as p}from"./Card-hy4bfgq7.js";import{a as ne,c as re,d as ie,i as m,m as h,p as ae,r as g,s as oe,t as _,u as se}from"./PageHeader-bhl3orzi.js";import{c as ce,l as v,p as y,q as b,x as le}from"./format-flkutk9e.js";import{n as ue}from"./AnchorHeading-ixbupfij.js";import{$ as x,c as S,et as de,f as C,ht as fe,i as pe,it as w,k as T,l as E,nt as D,o as me,pt as O,r as he,rt as ge,s as _e,tt as k}from"../client-ctcthgam.js";import{C as A,a as j,d as M,i as ve,l as N,m as P,n as F,o as I,r as ye,s as L,t as R,u as be}from"./chart-il2ahs5y.js";import{n as z,t as B}from"./BarChart-lbkezxbi.js";import{n as xe,r as Se,t as Ce}from"./PluginReportRecordSet-ml18z19r.js";import{t as V}from"./StatCard-i2klkqqp.js";import{t as H}from"./ChartHeader-c1zg4xt5.js"
2
+ /**
3
+ * @license lucide-react v1.17.0 - ISC
4
+ *
5
+ * This source code is licensed under the ISC license.
6
+ * See the LICENSE file in the root directory of this source tree.
7
+ */
8
+ ;const we=s(`radio-tower`,[[`path`,{d:`M4.9 16.1C1 12.2 1 5.8 4.9 1.9`,key:`s0qx1y`}],[`path`,{d:`M7.8 4.7a6.14 6.14 0 0 0-.8 7.5`,key:`1idnkw`}],[`circle`,{cx:`12`,cy:`9`,r:`2`,key:`1092wv`}],[`path`,{d:`M16.2 4.8c2 2 2.26 5.11.8 7.47`,key:`ojru2q`}],[`path`,{d:`M19.1 1.9a9.96 9.96 0 0 1 0 14.1`,key:`rhi7fg`}],[`path`,{d:`M9.5 18h5`,key:`mfy3pd`}],[`path`,{d:`m8 22 4-11 4 11`,key:`25yftu`}]]),Te=s(`sigma`,[[`path`,{d:`M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2`,key:`wuwx1p`}]])
9
+ /**
10
+ * @license lucide-react v1.17.0 - ISC
11
+ *
12
+ * This source code is licensed under the ISC license.
13
+ * See the LICENSE file in the root directory of this source tree.
14
+ */
15
+ ;var U=/* @__PURE__ */ e(t(),1),W=n();function Ee(e){return/* @__PURE__ */ (0,W.jsxs)(`section`,{"aria-labelledby":ue(`details`),className:`grid gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(C,{className:`px-1`,anchor:`details`,title:`Details`}),/* @__PURE__ */ (0,W.jsxs)(p,{children:[/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-px bg-dashboard-fill-hover sm:grid-cols-3`,children:[/* @__PURE__ */ (0,W.jsx)(G,{icon:l,label:`Identifier`,value:e.plugin.name}),/* @__PURE__ */ (0,W.jsx)(G,{icon:u,label:`Skills`,value:String(e.plugin.skills.length)}),/* @__PURE__ */ (0,W.jsx)(G,{icon:o,label:`Configuration`,value:String(e.plugin.configKeys.length)})]}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid gap-5 border-t border-dashboard-border-subtle p-4 sm:p-5 lg:grid-cols-2`,children:[/* @__PURE__ */ (0,W.jsx)(K,{emptyText:`No plugin-provided skills were discovered.`,items:e.plugin.skills.map(e=>e.name),renderItem:e=>/* @__PURE__ */ (0,W.jsx)(T,{chip:!0,name:e},e),title:`Skills`}),e.plugin.configKeys.length?/* @__PURE__ */ (0,W.jsx)(`div`,{className:`lg:col-span-2`,children:/* @__PURE__ */ (0,W.jsx)(K,{emptyText:``,items:e.plugin.configKeys,title:`Configuration keys`})}):null]})]})]})}function G(e){let t=e.icon;return/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`flex items-center gap-3 bg-dashboard-surface-panel px-4 py-3.5`,children:[/* @__PURE__ */ (0,W.jsx)(t,{"aria-hidden":`true`,className:`text-dashboard-accent-text/60`,size:15}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`truncate font-display text-base font-medium text-dashboard-text`,children:e.value}),/* @__PURE__ */ (0,W.jsx)(`div`,{className:`mt-0.5 font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label})]})]})}function K(e){return/* @__PURE__ */ (0,W.jsxs)(`div`,{children:[/* @__PURE__ */ (0,W.jsx)(`h3`,{className:`m-0 font-sans text-xs font-medium text-dashboard-text-muted`,children:e.title}),e.items.length?/* @__PURE__ */ (0,W.jsx)(`div`,{className:`mt-2.5 flex flex-wrap gap-2`,children:e.items.map(t=>e.renderItem?.(t)??/* @__PURE__ */ (0,W.jsx)(`span`,{className:`rounded-md border border-dashboard-border bg-dashboard-overlay-soft px-2.5 py-1.5 font-mono text-xs text-dashboard-text-muted`,children:t},t))}):/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-2 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.emptyText})]})}function De(e){return/* @__PURE__ */ (0,W.jsx)(`section`,{"aria-label":`Plugins`,className:`grid gap-3`,children:e.plugins.length?/* @__PURE__ */ (0,W.jsx)(`div`,{className:`grid gap-3`,children:e.plugins.map(e=>/* @__PURE__ */ (0,W.jsx)(Oe,{plugin:e},e.name))}):/* @__PURE__ */ (0,W.jsx)(p,{padding:`md`,children:/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-mono text-xs text-dashboard-text-muted`,children:`No plugin inventory has been reported yet.`})})})}function Oe(e){let t=e.plugin.reports.flatMap(e=>e.metrics??[]);return/* @__PURE__ */ (0,W.jsxs)(a,{className:`group grid min-w-0 gap-4 rounded-lg border border-dashboard-border bg-dashboard-surface-panel/85 p-4 no-underline transition-colors hover:border-dashboard-accent/20 hover:bg-dashboard-accent/[0.025] sm:p-5`,to:S(e.plugin.name),children:[/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-4`,children:[/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`grid size-9 shrink-0 place-items-center rounded-md border border-dashboard-accent/15 bg-dashboard-accent/[0.075] text-dashboard-accent-text`,children:/* @__PURE__ */ (0,W.jsx)(l,{"aria-hidden":`true`,size:16,strokeWidth:1.8})}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,W.jsx)(`h3`,{className:`m-0 truncate font-display text-lg font-medium text-dashboard-text`,children:e.plugin.displayName}),/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-1 mb-0 line-clamp-2 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.plugin.description})]})]}),/* @__PURE__ */ (0,W.jsx)(ee,{"aria-hidden":`true`,className:`mt-1 shrink-0 text-dashboard-text-muted transition-transform group-hover:translate-x-0.5 group-hover:text-dashboard-accent-text/70`,size:16})]}),t.length?/* @__PURE__ */ (0,W.jsx)(`div`,{className:`grid ${t.length===1?`grid-cols-1`:`grid-cols-2`} gap-px overflow-hidden rounded-md border border-dashboard-border-subtle bg-dashboard-fill-hover`,children:t.slice(0,2).map(e=>/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`min-w-0 bg-dashboard-surface-panel px-3 py-2.5`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`truncate font-display text-lg font-light text-dashboard-text`,children:e.value}),/* @__PURE__ */ (0,W.jsx)(`div`,{className:`mt-1 truncate font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label})]},e.label))}):null,/* @__PURE__ */ (0,W.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 border-t border-dashboard-border-subtle pt-3`,children:/* @__PURE__ */ (0,W.jsx)(ke,{icon:u,label:`${e.plugin.skills.length} skills`})})]})}function ke(e){let t=e.icon;return/* @__PURE__ */ (0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-sans font-medium text-xs text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,W.jsx)(t,{"aria-hidden":`true`,size:11}),e.label]})}function Ae(e){return e.reports.length===0&&!e.emptyText?null:e.reports.length===0?/* @__PURE__ */ (0,W.jsx)(p,{padding:`md`,children:/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`flex items-center gap-4`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`grid size-10 shrink-0 place-items-center rounded-md border border-dashboard-border bg-dashboard-fill-soft text-dashboard-text-muted`,children:/* @__PURE__ */ (0,W.jsx)(we,{"aria-hidden":`true`,size:17})}),/* @__PURE__ */ (0,W.jsxs)(`div`,{children:[/* @__PURE__ */ (0,W.jsx)(`h2`,{className:`m-0 font-display text-base font-medium text-dashboard-text-muted`,children:`Operational reports`}),/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.emptyText})]})]})}):/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(C,{anchor:`reports`,className:`px-1`,title:`Operational reports`}),e.reports.map(t=>/* @__PURE__ */ (0,W.jsx)(je,{fallbackTitle:e.fallbackTitle,range:e.range,report:t},t.pluginName))]})}function je(e){let t=(e.report.title===e.report.pluginName?void 0:e.report.title)??e.fallbackTitle??e.report.pluginName,n=e.report.metrics??[];return/* @__PURE__ */ (0,W.jsxs)(p,{children:[/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-dashboard-border-subtle px-5 py-4`,children:[/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,W.jsx)(`h3`,{className:`m-0 truncate font-display text-lg font-medium text-dashboard-text`,children:t}),/* @__PURE__ */ (0,W.jsx)(`div`,{className:`mt-1 hidden font-mono text-xs text-dashboard-text-muted sm:block`,children:e.report.pluginName})]}),e.report.generatedAt?/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`hidden shrink-0 font-mono text-xs text-dashboard-text-muted sm:block`,children:[`updated `,le(e.report.generatedAt)]}):null]}),n.length?/* @__PURE__ */ (0,W.jsx)(`div`,{className:f(`grid gap-px bg-dashboard-fill-hover`,n.length===1?`grid-cols-1`:`grid-cols-2`,n.length===3?`lg:grid-cols-3`:n.length===5?`lg:grid-cols-5`:n.length>=4?`lg:grid-cols-4`:void 0),children:n.map(e=>/* @__PURE__ */ (0,W.jsxs)(`div`,{className:f(`min-w-0 bg-dashboard-surface-panel px-4 py-4`,n.length>1&&n.length%2==1&&`last:col-span-2 lg:last:col-span-1`,Me(e.tone)),children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`truncate font-display text-2xl font-light leading-none text-dashboard-text`,children:e.value}),/* @__PURE__ */ (0,W.jsx)(`div`,{className:`mt-2 font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label})]},e.label))}):null,e.report.widgets?.length?/* @__PURE__ */ (0,W.jsx)(`div`,{className:`grid gap-3 border-t border-dashboard-border-subtle bg-dashboard-overlay-soft p-3 lg:grid-cols-2`,children:e.report.widgets.map(t=>/* @__PURE__ */ (0,W.jsx)(xe,{range:e.range,widget:t},t.id))}):null,e.report.recordSets?.map(t=>/* @__PURE__ */ (0,W.jsx)(Ce,{embedded:!0,recordSet:t},`${e.report.pluginName}:${t.title}`))]})}function Me(e){return e===`danger`?`shadow-[inset_0_2px_0_rgba(251,113,133,0.65)]`:e===`warning`?`shadow-[inset_0_2px_0_rgba(251,191,36,0.65)]`:e===`good`?`shadow-[inset_0_2px_0_rgba(110,231,183,0.55)]`:``}const Ne={share:{color:`var(--color-cyan-400)`,label:`Replies`}};function q(e){return`${b(e.startMs)||`0s`} to ${b(e.endMs)}`}function J(e){return`${Math.round(e)}%`}function Pe(e){let t=e.total-e.noReply,n=0,r=e.bins.find(e=>(n+=e.count,n*2>=t));return{median:t&&r?q(r):void 0,noReplyShare:e.total?J(e.noReply/e.total*100):void 0,replies:t}}function Fe(e){let t=e.histogram.total-e.histogram.noReply,n=e.histogram.bins.map(e=>({count:e.count,id:String(e.endMs),label:q(e),share:t?e.count/t*100:0})),r=new Map(n.map(e=>[e.id,e.label])),i=Math.max(1,...n.map(e=>e.share));return/* @__PURE__ */ (0,W.jsx)(R,{className:f(`aspect-auto h-48 w-full`,e.className),config:Ne,children:/* @__PURE__ */ (0,W.jsxs)(B,{"aria-label":`Reply times of ${t} replies`,data:n,margin:M,role:`img`,children:[/* @__PURE__ */ (0,W.jsx)(A,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,W.jsx)(L,{format:J,maximum:Math.ceil(i/10)*10}),/* @__PURE__ */ (0,W.jsx)(I,{centered:!0,dataKey:`id`,formatLabel:e=>b(Number(e)),keys:n.map(e=>e.id)}),/* @__PURE__ */ (0,W.jsx)(F,{content:/* @__PURE__ */ (0,W.jsx)(j,{formatLabel:e=>r.get(e)??e,rows:e=>[[`Replies`,e.count],[`Share`,J(e.share)]]})}),/* @__PURE__ */ (0,W.jsx)(z,{dataKey:`share`,fill:`var(--color-share)`,fillOpacity:.85,isAnimationActive:!1,maxBarSize:32,radius:1.5})]})})}const Ie=[{label:`People`,value:`user`},{label:`System`,value:`system`},{label:`Archived`,value:`archived`}];function Y(e){let t=e.split(`:`);return t[0]===`archived`?{group:t[0],turns:`Any`,work:t[1]??``}:{group:t[0],turns:t[1]??``,work:t[2]??``}}function Le(e){let t=Y(e);return t.group===`archived`||t.work!==`none`}function Re(e){let{noReply:t,total:n}=e.histogram;return n?`${Math.round((n-t)/n*100)}%`:`—`}function ze(e){return e.reduce((e,t)=>!e||t.histogram.total>e.histogram.total?t:e,void 0)?.segment}function Be(e){let[t,n]=(0,U.useState)(`user`),[r,i]=(0,U.useState)(),a=e.report?.minSamples??0,o=(e.report?.segments??[]).filter(e=>Y(e.segment).group===t),s=o.find(e=>e.segment===r)??o.find(e=>e.segment===ze(o)),c=s&&Pe(s.histogram);return/* @__PURE__ */ (0,W.jsxs)(p,{children:[/* @__PURE__ */ (0,W.jsx)(H,{description:e.report?`Time until the next message after a Turn ends, by cache warming segment. A segment with fewer than ${a} samples uses the samples of its "none" segment.`:void 0,title:`Reply times`,trailing:/* @__PURE__ */ (0,W.jsx)(se,{"aria-label":`Segment group`,onValueChange:([e])=>{e&&n(e)},value:[t],children:Ie.map(e=>/* @__PURE__ */ (0,W.jsx)(ie,{value:e.value,children:e.label},e.value))})}),e.report?/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid lg:grid-cols-[minmax(0,22rem)_minmax(0,1fr)]`,children:[/* @__PURE__ */ (0,W.jsxs)(x,{className:`table-fixed`,children:[/* @__PURE__ */ (0,W.jsx)(ge,{className:`bg-dashboard-overlay-soft`,children:/* @__PURE__ */ (0,W.jsxs)(w,{children:[/* @__PURE__ */ (0,W.jsx)(D,{className:`pl-4 sm:pl-5`,scope:`col`,children:`Turns`}),/* @__PURE__ */ (0,W.jsx)(D,{scope:`col`,children:`Work`}),/* @__PURE__ */ (0,W.jsx)(D,{className:`text-right`,scope:`col`,children:`Samples`}),/* @__PURE__ */ (0,W.jsx)(D,{className:`pr-4 text-right sm:pr-5`,scope:`col`,children:`Replied`})]})}),/* @__PURE__ */ (0,W.jsx)(de,{children:o.map(e=>{let t=Y(e.segment),n=e.segment===s?.segment,r=e.histogram.total>=a;return/* @__PURE__ */ (0,W.jsxs)(w,{className:`cursor-pointer`,"data-state":n?`selected`:void 0,onClick:()=>i(e.segment),children:[/* @__PURE__ */ (0,W.jsx)(k,{className:`pl-4 text-xs sm:pl-5`,children:/* @__PURE__ */ (0,W.jsx)(`button`,{"aria-label":`Show ${e.segment}`,"aria-pressed":n,className:`cursor-pointer font-sans tabular-nums text-dashboard-text focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus`,type:`button`,children:t.turns})}),/* @__PURE__ */ (0,W.jsx)(k,{className:`text-xs capitalize`,children:t.work}),/* @__PURE__ */ (0,W.jsx)(k,{className:`text-right font-sans text-xs tabular-nums`,children:r?v(e.histogram.total):/* @__PURE__ */ (0,W.jsxs)(fe,{className:`ml-auto`,size:`compact`,tone:`warning`,children:[e.histogram.total,` of `,a]})}),/* @__PURE__ */ (0,W.jsx)(k,{className:f(`pr-4 text-right font-sans text-xs tabular-nums sm:pr-5`,!r&&`text-dashboard-text-muted`),children:Re(e)})]},e.segment)})})]}),/* @__PURE__ */ (0,W.jsx)(`div`,{className:`flex flex-col gap-2 border-dashboard-border-subtle px-2 py-3 max-lg:border-t lg:border-l`,children:s?/* @__PURE__ */ (0,W.jsxs)(W.Fragment,{children:[/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 px-2 font-sans text-xs text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,W.jsx)(`span`,{className:`font-mono text-dashboard-text`,children:s.segment}),/* @__PURE__ */ (0,W.jsx)(`span`,{children:s.histogram.total<a?Le(s.segment)?`Uses its "none" segment until ${a} samples`:`Too few samples to warm`:c?.median?`Typical reply ${c.median}`:`No replies`})]}),/* @__PURE__ */ (0,W.jsx)(Fe,{className:`min-h-48 flex-1`,histogram:s.histogram})]}):null})]}):/* @__PURE__ */ (0,W.jsx)(O,{children:e.error?`Reply times failed to load.`:`Loading reply times.`})]})}function Ve(e){let t=Ue(e.skills),n=e.skills.filter(e=>e.pluginProvider).length;return/* @__PURE__ */ (0,W.jsxs)(p,{children:[/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-dashboard-border-subtle px-5 py-4 max-sm:flex-col`,children:[/* @__PURE__ */ (0,W.jsx)(C,{description:/* @__PURE__ */ (0,W.jsxs)(W.Fragment,{children:[`The task-specific instructions `,h(),` `,`discovered, grouped by their plugin provider when one is registered.`]}),anchor:`skills`,title:`Skills`}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid min-w-[12rem] grid-cols-2 overflow-hidden rounded-lg border border-dashboard-border bg-dashboard-overlay-soft max-sm:w-full max-sm:min-w-0`,children:[/* @__PURE__ */ (0,W.jsx)(X,{label:`discovered`,value:e.skills.length}),/* @__PURE__ */ (0,W.jsx)(X,{label:`from plugins`,value:n})]})]}),/* @__PURE__ */ (0,W.jsx)(`div`,{className:`grid gap-3 p-3 sm:p-4`,children:t.length?t.map(e=>/* @__PURE__ */ (0,W.jsx)(He,{group:e},e.pluginProvider??`standalone`)):/* @__PURE__ */ (0,W.jsx)(`div`,{className:`rounded-lg border border-dashed border-dashboard-border px-4 py-8 text-center font-sans text-xs text-dashboard-text-muted`,children:`No skills have been discovered yet.`})})]})}function He(e){let t=e.group.pluginProvider??`Standalone`;return/* @__PURE__ */ (0,W.jsxs)(`article`,{className:`rounded-lg border border-dashboard-border-subtle bg-dashboard-fill-soft p-4`,children:[/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-md border border-dashboard-accent/15 bg-dashboard-accent/[0.075] text-dashboard-accent-text`,children:e.group.pluginProvider?/* @__PURE__ */ (0,W.jsx)(l,{"aria-hidden":`true`,size:15,strokeWidth:1.8}):/* @__PURE__ */ (0,W.jsx)(u,{"aria-hidden":`true`,size:15,strokeWidth:1.8})}),/* @__PURE__ */ (0,W.jsxs)(`div`,{children:[/* @__PURE__ */ (0,W.jsx)(`h3`,{className:`m-0 truncate font-display text-base font-medium text-dashboard-text`,children:t}),/* @__PURE__ */ (0,W.jsx)(`div`,{className:`mt-0.5 font-sans font-medium text-xs text-dashboard-text-muted`,children:e.group.pluginProvider?`plugin provider`:`core or local`})]})]}),/* @__PURE__ */ (0,W.jsxs)(`span`,{className:`font-mono text-xs text-dashboard-text-muted`,children:[v(e.group.skills.length),` skill`,e.group.skills.length===1?``:`s`]})]}),/* @__PURE__ */ (0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.group.skills.map(e=>/* @__PURE__ */ (0,W.jsx)(T,{chip:!0,name:e.name},e.name))})]})}function X(e){return/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`border-r border-dashboard-border-subtle px-3 py-2.5 text-center last:border-r-0`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-display text-xl font-light leading-none text-dashboard-text`,children:v(e.value)}),/* @__PURE__ */ (0,W.jsx)(`div`,{className:`mt-1.5 font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label})]})}function Ue(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=t.get(n.pluginProvider)??[];e.push(n),t.set(n.pluginProvider,e)}return[...t.entries()].map(([e,t])=>({pluginProvider:e,skills:[...t].sort((e,t)=>e.name.localeCompare(t.name))})).sort((e,t)=>e.pluginProvider?t.pluginProvider?e.pluginProvider.localeCompare(t.pluginProvider):-1:1)}const Z={conversations:{color:`var(--color-cyan-400)`,label:`Conversations`}};function We(e){let t=e.bucketUnit??`day`,n=Math.max(1,...e.days.map(e=>e.conversations)),r=e.days.map(e=>e.conversations),i=r.reduce((e,t)=>e+t,0),a=be(r);return/* @__PURE__ */ (0,W.jsxs)(p,{children:[/* @__PURE__ */ (0,W.jsx)(H,{description:`Root conversations with recorded activity, per ${t===`6hour`?`6 hours`:t}.`,title:`Conversation activity`,total:v(i)}),/* @__PURE__ */ (0,W.jsx)(`div`,{className:`px-2 py-2`,children:/* @__PURE__ */ (0,W.jsx)(R,{className:`aspect-auto h-38 w-full`,config:Z,children:/* @__PURE__ */ (0,W.jsxs)(B,{"aria-label":`Conversations per ${t===`6hour`?`6 hours`:t}`,data:e.days,margin:M,role:`img`,children:[/* @__PURE__ */ (0,W.jsx)(A,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,W.jsx)(L,{maximum:n}),/* @__PURE__ */ (0,W.jsx)(I,{keys:e.days.map(e=>e.date)}),/* @__PURE__ */ (0,W.jsx)(F,{content:/* @__PURE__ */ (0,W.jsx)(j,{rows:e=>[[`conversations`,e.conversations]]})}),/* @__PURE__ */ (0,W.jsx)(z,{dataKey:`conversations`,fill:`var(--color-conversations)`,fillOpacity:.78,isAnimationActive:!1,maxBarSize:24,minPointSize:e=>e?2:0,radius:2}),/* @__PURE__ */ (0,W.jsx)(ye,{average:a,format:ce,stroke:`var(--color-cyan-400)`,unit:ne(t)})]})})})]})}function Ge(e){return e.reduce((e,t)=>({allow:e.allow+t.allow,ask:e.ask+t.ask,costUsd:e.costUsd+(t.costUsd??0),deny:e.deny+t.deny,requests:e.requests+t.requests}),{allow:0,ask:0,costUsd:0,deny:0,requests:0})}function Q(e){return/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`rounded-md border border-dashboard-border-subtle bg-dashboard-overlay-soft px-3 py-3`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-display text-xl font-light text-dashboard-text`,children:/* @__PURE__ */ (0,W.jsx)(`span`,{className:e.valueClassName,children:e.value})}),/* @__PURE__ */ (0,W.jsx)(`div`,{className:`mt-1 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.label})]})}function Ke(e){let t=e.bucketUnit??`day`,n=Ge(e.days),r=Math.max(1,...e.days.map(e=>e.requests)),i=[0,Math.floor((e.days.length-1)/2),e.days.length-1].filter((e,t,n)=>e>=0&&n.indexOf(e)===t);return/* @__PURE__ */ (0,W.jsxs)(p,{children:[/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`border-b border-dashboard-border-subtle px-4 py-4`,children:[/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[/* @__PURE__ */ (0,W.jsxs)(`div`,{children:[/* @__PURE__ */ (0,W.jsx)(`h3`,{className:`m-0 font-sans text-xs font-medium text-dashboard-text-muted`,children:`Guardian reviews`}),/* @__PURE__ */ (0,W.jsxs)(`p`,{className:`mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:[m(t),` decisions before reviewed actions execute.`]})]}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,W.jsx)(`span`,{className:`mr-3 text-emerald-200/75`,children:`Allow`}),/* @__PURE__ */ (0,W.jsx)(`span`,{className:`mr-3 text-amber-200/75`,children:`Ask`}),/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-rose-200/75`,children:`Deny`})]})]}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-2 sm:grid-cols-5`,children:[/* @__PURE__ */ (0,W.jsx)(Q,{label:`Requests`,value:v(n.requests)}),/* @__PURE__ */ (0,W.jsx)(Q,{label:`Allowed`,value:v(n.allow),valueClassName:`text-emerald-100`}),/* @__PURE__ */ (0,W.jsx)(Q,{label:`Asked`,value:v(n.ask),valueClassName:`text-amber-100`}),/* @__PURE__ */ (0,W.jsx)(Q,{label:`Denied`,value:v(n.deny),valueClassName:`text-rose-100`}),/* @__PURE__ */ (0,W.jsx)(Q,{label:`Estimated cost`,value:y({total:n.costUsd})})]})]}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`px-4 pt-5 pb-3`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{"aria-label":`${m(t)} Guardian review results`,className:`flex h-36 items-end gap-px`,role:`img`,children:e.days.map(e=>{let t=Math.max(2,e.requests/r*100);return/* @__PURE__ */ (0,W.jsx)(ve,{content:/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid grid-cols-[auto_auto] gap-x-4`,children:[/* @__PURE__ */ (0,W.jsx)(`span`,{children:`Allow`}),/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-right`,children:e.allow}),/* @__PURE__ */ (0,W.jsx)(`span`,{children:`Ask`}),/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-right`,children:e.ask}),/* @__PURE__ */ (0,W.jsx)(`span`,{children:`Deny`}),/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-right`,children:e.deny}),/* @__PURE__ */ (0,W.jsx)(`span`,{children:`Cost`}),/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-right`,children:y({total:e.costUsd??0})})]}),date:e.date,summary:`${e.allow} allowed, ${e.ask} asked, ${e.deny} denied, ${y({total:e.costUsd??0})}`,children:/* @__PURE__ */ (0,W.jsxs)(`button`,{className:`flex min-w-0 flex-1 flex-col justify-end overflow-hidden rounded-t-sm bg-dashboard-fill-soft focus-visible:outline-1 focus-visible:outline-dashboard-focus`,style:{height:`${t}%`},type:`button`,children:[e.deny?/* @__PURE__ */ (0,W.jsx)(`span`,{className:`block w-full bg-rose-400/75`,style:{flex:e.deny}}):null,e.ask?/* @__PURE__ */ (0,W.jsx)(`span`,{className:`block w-full bg-amber-300/75`,style:{flex:e.ask}}):null,e.allow?/* @__PURE__ */ (0,W.jsx)(`span`,{className:`block w-full bg-emerald-300/70`,style:{flex:e.allow}}):null]})},e.date)})}),/* @__PURE__ */ (0,W.jsx)(`div`,{className:`relative mt-2 h-4`,children:i.map(t=>{let n=e.days[t];return n?/* @__PURE__ */ (0,W.jsx)(N,{className:`absolute -translate-x-1/2`,style:{left:`${(t+.5)/e.days.length*100}%`},children:P(n.date)},n.date):null})})]})]})}function qe(e){return e.reduce((e,t)=>({conversations:e.conversations+t.conversations,costUsd:e.costUsd+(t.costUsd??0),tokens:e.tokens+(t.tokens??0)}),{conversations:0,costUsd:0,tokens:0})}function Je(e){if(!e.stats)return/* @__PURE__ */ (0,W.jsx)(p,{padding:`sm`,children:/* @__PURE__ */ (0,W.jsx)(O,{children:e.error?`Conversation metrics failed to load.`:e.loading?`Loading conversation metrics.`:`No conversation metrics have been reported yet.`})});let t=g({days:e.stats.metricDays,hours:e.stats.metricHours,sixHours:e.stats.metricSixHours,range:e.range,emptySixHour:e=>({conversations:0,date:e,durationMs:0})}),n=g({days:e.stats.guardian.metricDays,hours:e.stats.guardian.metricHours,sixHours:e.stats.guardian.metricSixHours,range:e.range,emptySixHour:e=>({allow:0,ask:0,date:e,deny:0,requests:0})}),r=qe(t),i=oe(e.range);return/* @__PURE__ */ (0,W.jsxs)(`section`,{"aria-label":`Runtime telemetry`,className:`grid gap-4`,children:[e.error?/* @__PURE__ */ (0,W.jsx)(`p`,{className:`m-0 font-sans text-xs text-rose-200/65`,children:`Metrics refresh failed. Showing cached data.`}):null,/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:[/* @__PURE__ */ (0,W.jsx)(V,{detail:`Root conversations in the ${re(e.range)}`,icon:c,label:`Conversations`,value:v(r.conversations)}),/* @__PURE__ */ (0,W.jsx)(V,{detail:`All recorded model tokens`,icon:Te,label:`Tokens`,value:v(r.tokens)}),/* @__PURE__ */ (0,W.jsx)(V,{detail:`Estimated model cost`,icon:te,label:`Model spend`,value:y({total:r.costUsd})})]}),/* @__PURE__ */ (0,W.jsx)(Se,{bucketUnit:i,cacheBreakdown:!0,days:t}),/* @__PURE__ */ (0,W.jsx)(We,{bucketUnit:i,days:t}),/* @__PURE__ */ (0,W.jsx)(Ke,{bucketUnit:i,days:n})]})}function Ye(e){let[t,n]=(0,U.useState)(30),a=i(),o=e.data.pluginReports?.reports??[],s=me({plugins:e.data.plugins,reports:o,skills:e.data.skills}),c=_e(a.pathname),l=c===E,u=s.find(e=>S(e.name)===c),d=c.startsWith(`${E}/`);return d&&!u&&e.data.pluginReportsLoading?/* @__PURE__ */ (0,W.jsx)(pe,{description:`Loading plugin details and operational reports.`,label:`Loading plugin`,title:`Plugin`}):d&&!u?/* @__PURE__ */ (0,W.jsx)(r,{replace:!0,to:E}):c!==`/system`&&!l&&!u?/* @__PURE__ */ (0,W.jsx)(r,{replace:!0,to:`/system`}):/* @__PURE__ */ (0,W.jsx)(he,{children:u?/* @__PURE__ */ (0,W.jsx)(Qe,{data:e.data,onRangeChange:n,plugin:u,range:t}):l?/* @__PURE__ */ (0,W.jsx)(Ze,{data:e.data,plugins:s}):/* @__PURE__ */ (0,W.jsx)(Xe,{data:e.data,range:t,onRangeChange:n})})}function Xe(e){return/* @__PURE__ */ (0,W.jsxs)(W.Fragment,{children:[/* @__PURE__ */ (0,W.jsx)(_,{description:`A live read on ${ae()} runtime and model usage.`,onRangeChange:e.onRangeChange,range:e.range,title:`System`}),/* @__PURE__ */ (0,W.jsx)(Je,{error:e.data.conversationStatsError,range:e.range,loading:e.data.conversationStatsLoading,stats:e.data.conversationStats}),/* @__PURE__ */ (0,W.jsx)(Be,{error:e.data.replyTimesError,report:e.data.replyTimes})]})}function Ze(e){return/* @__PURE__ */ (0,W.jsxs)(W.Fragment,{children:[/* @__PURE__ */ (0,W.jsx)(_,{description:`Loaded capabilities and operational reports for ${h()}.`,title:`Plugins`}),e.data.pluginReportsError?/* @__PURE__ */ (0,W.jsx)($,{showingReports:e.plugins.some(e=>e.reports.length)}):null,/* @__PURE__ */ (0,W.jsx)(De,{plugins:e.plugins}),e.data.skills.length?/* @__PURE__ */ (0,W.jsx)(Ve,{skills:e.data.skills}):null]})}function Qe(e){let t=e.plugin.reports,n=t.some(e=>e.widgets?.some(e=>e.timeRangeDays?.length));return/* @__PURE__ */ (0,W.jsxs)(W.Fragment,{children:[/* @__PURE__ */ (0,W.jsx)(_,{description:e.plugin.description,...n?{onRangeChange:e.onRangeChange,range:e.range}:{},title:e.plugin.displayName}),e.data.pluginReportsError?/* @__PURE__ */ (0,W.jsx)($,{showingReports:!!t.length}):null,/* @__PURE__ */ (0,W.jsx)(Ee,{plugin:e.plugin}),/* @__PURE__ */ (0,W.jsx)(Ae,{fallbackTitle:e.plugin.displayName,...!e.data.pluginReportsLoading&&!e.data.pluginReportsError?{emptyText:`This plugin does not expose operational activity yet.`}:{},range:e.range,reports:t})]})}function $(e){return/* @__PURE__ */ (0,W.jsx)(p,{className:`border-amber-300/10 bg-amber-300/[0.025]`,padding:`sm`,children:/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`grid size-9 shrink-0 place-items-center rounded-md border border-amber-300/15 bg-amber-300/[0.055] text-amber-200/70`,children:/* @__PURE__ */ (0,W.jsx)(d,{"aria-hidden":`true`,size:15})}),/* @__PURE__ */ (0,W.jsxs)(`div`,{children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-display text-sm font-medium text-dashboard-text-muted`,children:`Plugin stats failed to load.`}),/* @__PURE__ */ (0,W.jsx)(`div`,{className:`mt-1 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.showingReports?`Showing the last operational reports ${h()} received.`:`Plugin details and capabilities are still available.`})]})]})})}export{Ye as SystemPage};