@sentry/junior-dashboard 0.294.0 → 0.295.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +7 -5
- package/dist/client-manifest.json +1 -1
- package/dist/index.js +7 -5
- package/dist/public/chunks/{AdminPage-mn71yp2v.js → AdminPage-lctmhvpg.js} +1 -1
- package/dist/public/chunks/{AnchorHeading-cp3vx8qa.js → AnchorHeading-ixbupfij.js} +1 -1
- package/dist/public/chunks/{Area-h08sxa33.js → Area-d95rfkv5.js} +1 -1
- package/dist/public/chunks/AutomationPage-m78li1hv.js +3 -0
- package/dist/public/chunks/{AutomationRunDetails-jjdhbqtn.js → AutomationRunDetails-dx5lutte.js} +1 -1
- package/dist/public/chunks/{AutomationRunsPage-j50ps7nt.js → AutomationRunsPage-cba6nbxd.js} +1 -1
- package/dist/public/chunks/{AutomationStatus-czfg6ayl.js → AutomationStatus-eqq5lrad.js} +1 -1
- package/dist/public/chunks/AutomationsPage-cp7wtt2v.js +8 -0
- package/dist/public/chunks/{BarChart-e3oi6in1.js → BarChart-lbkezxbi.js} +1 -1
- package/dist/public/chunks/{BoardPage-f0uxqg7u.js → BoardPage-m4zqf62q.js} +1 -1
- package/dist/public/chunks/{CodeChangeRow-dk3gkjut.js → CodeChangeRow-d620nk75.js} +2 -2
- package/dist/public/chunks/CodePage-h2ayars2.js +1 -0
- package/dist/public/chunks/{CodeSummaryCards-o1po2jis.js → CodeSummaryCards-iotfblbp.js} +1 -1
- package/dist/public/chunks/{ConnectionsPage-mholegdk.js → ConnectionsPage-nm7w1i05.js} +2 -2
- package/dist/public/chunks/{DirectoryMetric-dgzufji4.js → DirectoryMetric-huy2ptzz.js} +1 -1
- package/dist/public/chunks/{DrawerContent-ovjgr16m.js → DrawerContent-n3biwp5m.js} +1 -1
- package/dist/public/chunks/{FilterBar-mtnh7fbi.js → FilterBar-dqnt967g.js} +1 -1
- package/dist/public/chunks/FormNotice-kj5pzsl7.js +1 -0
- package/dist/public/chunks/{LocationDetailPage-ggd6zgzp.js → LocationDetailPage-iqtx76w6.js} +2 -2
- package/dist/public/chunks/{LocationsPage-fh6vzxa1.js → LocationsPage-ju5jfejt.js} +2 -2
- package/dist/public/chunks/{McpSettingsPage-fm3fh2ux.js → McpSettingsPage-brav5c42.js} +1 -1
- package/dist/public/chunks/{PeoplePage-odrbcmhj.js → PeoplePage-lfq8nrto.js} +2 -2
- package/dist/public/chunks/{PersonProfilePage-gynexe89.js → PersonProfilePage-ep45sxr6.js} +1 -1
- package/dist/public/chunks/{PersonalTokensPage-4o4zj02w.js → PersonalTokensPage-jbt4q7uz.js} +1 -1
- package/dist/public/chunks/PluginReportRecordSet-ml18z19r.js +1 -0
- package/dist/public/chunks/{PluginUserPage-kwylbbpr.js → PluginUserPage-ilar25ic.js} +2 -2
- package/dist/public/chunks/RepositoryPage-o9m3vty4.js +1 -0
- package/dist/public/chunks/SettingsPage-jc9et1qq.js +1 -0
- package/dist/public/chunks/SystemPage-bbp8cdds.js +15 -0
- package/dist/public/chunks/{WorkspaceFormPage-hwvyvnuk.js → WorkspaceFormPage-kshmsdek.js} +2 -2
- package/dist/public/chunks/{WorkspacesPage-lu9w3ugz.js → WorkspacesPage-ohasc10u.js} +1 -1
- package/dist/public/chunks/alert-ifqo1uj7.js +1 -0
- package/dist/public/chunks/{automationFormat-hd7pnocr.js → automationFormat-kv314fzh.js} +1 -1
- package/dist/public/chunks/{chart-myr1oeen.js → chart-il2ahs5y.js} +1 -1
- package/dist/public/chunks/{circle-dollar-sign-fpl4dmok.js → circle-dollar-sign-h7k4kr7s.js} +1 -1
- package/dist/public/chunks/{code-highlighter-i3ux67or.js → code-highlighter-ea4j0ys1.js} +1 -1
- package/dist/public/chunks/{coins-bqkaxeba.js → coins-l2c8c17w.js} +1 -1
- package/dist/public/chunks/{format-gle1s0ri.js → format-flkutk9e.js} +2 -2
- package/dist/public/chunks/junior-g62bxb2t.js +4 -0
- package/dist/public/chunks/{native-select-jfknh8t4.js → native-select-fxs3p0bj.js} +1 -1
- package/dist/public/chunks/{plus-gndielka.js → plus-54e3zzys.js} +1 -1
- package/dist/public/chunks/vendor-icons-blmhaswc.js +698 -0
- package/dist/public/chunks/{workspaceQueries-m1ksz95c.js → workspaceQueries-onxawhg4.js} +1 -1
- package/dist/public/client-ctcthgam.js +165 -0
- package/dist/public/styles-4CIT7L7K.css +2 -0
- package/dist/tailwind.css +1 -1
- package/package.json +4 -4
- package/src/client/api.ts +16 -0
- package/src/client/components/MarkdownViewToggle.tsx +24 -0
- package/src/client/components/SkillLink.tsx +119 -0
- package/src/client/conversations/ConversationHomeList.tsx +87 -76
- package/src/client/conversations/ConversationListStatusIcon.tsx +39 -55
- package/src/client/conversations/ConversationSectionList.tsx +101 -0
- package/src/client/conversations/ConversationSidebar.tsx +159 -169
- package/src/client/conversations/ConversationWorkspace.tsx +5 -16
- package/src/client/conversations/TextAttachmentPreview.tsx +5 -14
- package/src/client/conversations/WaitingChip.tsx +78 -0
- package/src/client/conversations/conversationSections.ts +78 -55
- package/src/client/conversations/heldListOrder.ts +170 -0
- package/src/client/conversations/toolCallPreview.ts +3 -1
- package/src/client/conversations/transcriptSource.ts +7 -2
- package/src/client/conversations/useMarkConversationUnread.ts +2 -2
- package/src/client/format.ts +18 -2
- package/src/client/pages/automations/AutomationDraftChanges.tsx +2 -1
- package/src/client/pages/automations/AutomationOverview.tsx +3 -3
- package/src/client/pages/automations/AutomationSkillPicker.tsx +75 -31
- package/src/client/pages/automations/AutomationTaskFields.tsx +3 -13
- package/src/client/pages/automations/AutomationVersionsTab.tsx +2 -5
- package/src/client/pages/automations/skillSearch.ts +50 -0
- package/src/client/pages/code/RepositorySections.tsx +14 -5
- package/src/client/pages/code/RepositoryTabs.tsx +5 -11
- package/src/client/pages/system/PluginDetails.tsx +15 -8
- package/src/client/pages/system/SkillInventory.tsx +2 -6
- package/src/client/review-desk/queries.ts +30 -23
- package/src/client/review-desk/reviewItemFormat.ts +3 -1
- package/src/client/types.ts +5 -1
- package/src/mock-reporting/review-items.ts +6 -2
- package/dist/public/chunks/AutomationPage-e1l74ezg.js +0 -10
- package/dist/public/chunks/AutomationsPage-cphxl4l6.js +0 -8
- package/dist/public/chunks/CodePage-i97ivyji.js +0 -1
- package/dist/public/chunks/FormNotice-eyo2kdte.js +0 -1
- package/dist/public/chunks/PluginReportRecordSet-hm1cwp6c.js +0 -1
- package/dist/public/chunks/RepositoryPage-fti2vfu4.js +0 -1
- package/dist/public/chunks/SettingsPage-kxspx37h.js +0 -1
- package/dist/public/chunks/SystemPage-jurblfgy.js +0 -15
- package/dist/public/chunks/SystemPlugins-jr37f1cv.js +0 -1
- package/dist/public/chunks/junior-hdb4wc4q.js +0 -4
- package/dist/public/chunks/vendor-icons-mxz7yi04.js +0 -692
- package/dist/public/client-f7asutg5.js +0 -165
- package/dist/public/styles-ZJJGBKKX.css +0 -2
|
@@ -1,10 +0,0 @@
|
|
|
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,_ as o,a as s,d as c,h as l,l as u,p as d,r as f,y as p}from"./vendor-react-ggbyvons.js";import{n as m,t as h}from"./button-ygjnb239.js";import{At as g,Bt as _,O as v,Qt as y,V as ee,_ as b,l as x,qt as S,wt as te}from"./vendor-icons-mxz7yi04.js";import{a as C,i as w,n as ne,r as re,t as T}from"./automationFormat-hd7pnocr.js";import{t as E}from"./plus-gndielka.js";import{a as D,n as O,t as k}from"./tooltip-h1yceend.js";import{$ as A,Ft as ie,It as j,Lt as M,Mt as N,Nt as P,Pt as ae,Rt as oe,at as se,ct as ce,et as le,ot as ue,zt as de}from"./junior-hdb4wc4q.js";import{a as fe,i as F,o as pe,r as me,t as I}from"./http-cdq677qt.js";import{a as he,t as L}from"./styles-j0007fov.js";import{t as R}from"./Card-hy4bfgq7.js";import{t as ge}from"./skeleton-h6p83ux1.js";import{t as _e}from"./PageContentSkeleton-b7dkba0l.js";import{d as ve,n as ye,r as be,s as xe,t as Se,u as Ce}from"./PageHeader-bhl3orzi.js";import{b as we,k as Te,l as Ee,n as z,p as De,y as Oe}from"./format-gle1s0ri.js";import{t as ke}from"./SecondaryNavigation-m358iuko.js";import{t as Ae}from"./PageLayout-l6dhbimv.js";import{t as je}from"./AnchorHeading-cp3vx8qa.js";import{r as Me,t as B}from"./searchParams-moqjgi65.js";import{r as Ne}from"./SystemPlugins-jr37f1cv.js";import{A as Pe,Ct as Fe,D as Ie,E as Le,Et as Re,F as ze,Ft as Be,Gt as Ve,Jt as He,Kt as Ue,M as We,Mt as Ge,N as Ke,Nt as qe,O as Je,Ot as Ye,P as Xe,St as Ze,T as Qe,Tt as $e,U as et,W as tt,_t as V,gt as H,ht as U,in as nt,j as rt,jt as it,k as at,mt as W,nn as ot,ot as st,pt as G,q as ct,ut as lt,wt as ut,xt as dt}from"../client-f7asutg5.js";import{t as K}from"./FormNotice-eyo2kdte.js";import{t as q}from"./native-select-jfknh8t4.js";import{a as J,i as ft,n as pt,o as mt,r as ht,s as gt,t as _t}from"./AutomationRunDetails-jjdhbqtn.js";import{a as vt,n as yt,r as bt,t as xt}from"./AutomationStatus-czfg6ayl.js";import{r as St}from"./FilterBar-mtnh7fbi.js";import{t as Ct}from"./SelectableRow-j8fwjsjz.js";import{C as wt,a as Tt,d as Et,n as Dt,o as Ot,s as kt,t as At}from"./chart-myr1oeen.js";import{n as jt,t as Mt}from"./BarChart-e3oi6in1.js";import{t as Nt}from"./ChartLegend-c3e9l1vl.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 Pt=y(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]);var Y=/* @__PURE__ */ e(i(),1),X=a();function Ft({automation:e,editPath:r,editVariant:i,onDelete:a}){let o=nt(),s=n(),c=e.status===`completed`,l=e.status===`paused`,u=e.status===`blocked`,d=!c,p=l||u?`resume`:`pause`,g=t({mutationFn:async()=>{let t=`/api/automations/${encodeURIComponent(e.id)}`,n=await F(A,`${t}/edit`);if(n.status!==e.status)throw Error(`The Automation changed. Reload the page before trying again.`);return pe(A,`${t}/lifecycle`,{action:p,revision:n.revision})},onSuccess:async e=>{await s.invalidateQueries({queryKey:[`dashboard`,`automations`]}),o.add({title:e.status===`blocked`?`Automation is still blocked`:p===`pause`?`Automation paused`:`Automation resumed`,description:e.status===`blocked`?`Fix the reported requirement before resuming again.`:p===`pause`?`Work already queued or running may finish.`:`Future triggers are enabled.`,type:e.status===`blocked`?`warning`:`success`})}});return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0 justify-items-stretch gap-3 md:justify-items-end`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{"aria-label":`Automation actions`,className:`flex flex-wrap items-center gap-2`,role:`group`,children:[c?null:/* @__PURE__ */ (0,X.jsxs)(f,{className:m({variant:i}),to:r,children:[/* @__PURE__ */ (0,X.jsx)(v,{"aria-hidden":`true`,size:14}),`Edit automation`]}),d?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(h,{disabled:g.isPending,onClick:()=>g.mutate(),children:g.isPending?`Updating…`:p===`pause`?`Pause`:`Resume`}),/* @__PURE__ */ (0,X.jsxs)(it,{children:[/* @__PURE__ */ (0,X.jsx)(Be,{render:/* @__PURE__ */ (0,X.jsx)(h,{"aria-label":`About pausing`,size:`icon`}),children:/* @__PURE__ */ (0,X.jsx)(te,{"aria-hidden":`true`,size:16})}),/* @__PURE__ */ (0,X.jsx)(Ge,{side:`bottom`,align:`end`,"aria-label":`About pausing`,children:/* @__PURE__ */ (0,X.jsxs)(qe,{children:[`Pausing stops new runs. Work already queued or running may finish. Resuming skips missed runs and waits for the next scheduled time or new event.`,l&&e.statusReason?` Removing the pause keeps the block until you fix it and resume again.`:``]})})]})]}):null,/* @__PURE__ */ (0,X.jsxs)(k,{children:[/* @__PURE__ */ (0,X.jsx)(D,{render:/* @__PURE__ */ (0,X.jsx)(h,{focusableWhenDisabled:!0,"aria-label":`Delete automation`,size:`icon`,variant:`danger`,onClick:e=>a(e.currentTarget),disabled:g.isPending,children:/* @__PURE__ */ (0,X.jsx)(x,{"aria-hidden":`true`,size:16})})}),/* @__PURE__ */ (0,X.jsx)(O,{size:`compact`,children:`Delete automation`})]})]}),g.error?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`max-w-sm`,children:/* @__PURE__ */ (0,X.jsx)(K,{tone:`error`,title:`Could not update this automation.`,children:g.error instanceof I?g.error.apiError??`Try again.`:g.error.message})}):null]})}function It(e){let[r,i]=(0,Y.useState)(!0),a=n(),o=nt(),s=t({mutationFn:()=>me(`/api/automations/${encodeURIComponent(e.automation.id)}`),onSuccess:async()=>{await a.invalidateQueries({queryKey:[`dashboard`,`automations`]}),e.onDeleted(),o.add({title:`Automation deleted`,description:e.automation.title,type:`success`}),i(!1)}});return/* @__PURE__ */ (0,X.jsx)(Qe,{open:r,onOpenChange:(e,t)=>{s.isPending?t.cancel():i(e)},onOpenChangeComplete:t=>{t||e.onClose()},children:/* @__PURE__ */ (0,X.jsxs)(Je,{finalFocus:e.returnFocus,children:[/* @__PURE__ */ (0,X.jsx)(rt,{children:`Delete automation?`}),/* @__PURE__ */ (0,X.jsxs)(at,{children:[`Delete`,` `,/* @__PURE__ */ (0,X.jsx)(`strong`,{className:`font-medium text-dashboard-text`,children:e.automation.title}),`? This removes the Automation and stops future triggers. Work already queued or running may finish.`]}),s.error?/* @__PURE__ */ (0,X.jsx)(K,{tone:`error`,title:`The automation could not be deleted. Try again.`}):null,/* @__PURE__ */ (0,X.jsxs)(Pe,{children:[/* @__PURE__ */ (0,X.jsx)(Ie,{disabled:s.isPending,children:`Cancel`}),/* @__PURE__ */ (0,X.jsx)(Le,{variant:`danger`,disabled:s.isPending,onClick:()=>s.mutate(),children:s.isPending?`Deleting…`:`Delete automation`})]})]})})}function Lt(e,t){return typeof e.destination==`string`?e.destination===`task_creator`?`Creator · Direct message`:`${t.label} · ${t.visibility}`:e.destination.channelId===t.channelId&&e.destination.teamId===t.teamId?`${t.label} · ${t.visibility}`:`Saved destination · ${e.destination.channelId}`}const Rt=[`sunday`,`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`];function Z(e){return{title:e.title??``,task:zt(e.task),credentialMode:e.credentialMode,outcomes:e.outcomes,trigger:e.kind===`event`?e.trigger:void 0}}function zt(e){return e.kind===`instruction`?e:{kind:`skill`,skill:e.skill,context:e.context??``}}function Bt(e){return e.kind===`instruction`?e:{kind:`skill`,skill:e.skill,...e.context.trim()?{context:e.context}:void 0}}function Vt(e){let t=e.schedule.recurrence;if(e.schedule.kind===`recurring`&&t){let{time:n,weekdays:r,...i}=t;return{kind:`recurring`,...i,timezone:e.schedule.timezone,time:`${String(n.hour).padStart(2,`0`)}:${String(n.minute).padStart(2,`0`)}`,weekdays:r?.flatMap(e=>Rt[e]??[])}}if(e.nextRunAtMs){let t=new Intl.DateTimeFormat(`en-CA`,{timeZone:e.schedule.timezone,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}).formatToParts(e.nextRunAtMs),n=e=>t.find(t=>t.type===e)?.value??``;return{kind:`one_off`,timezone:e.schedule.timezone,timing:{type:`at`,date:`${n(`year`)}-${n(`month`)}-${n(`day`)}`,time:`${n(`hour`)}:${n(`minute`)}`}}}return{kind:`recurring`,frequency:`daily`,time:`09:00`,timezone:e.schedule.timezone}}function Ht(e,t){let n={};t.title!==(e.title??``)&&(n.title=t.title);let r=Bt(t.task);return JSON.stringify(r)!==JSON.stringify(e.task)&&(n.task=r),t.credentialMode!==e.credentialMode&&(n.credentialMode=t.credentialMode),JSON.stringify(t.outcomes)!==JSON.stringify(e.outcomes)&&(n.outcomes=t.outcomes),e.kind===`scheduled`&&t.schedule&&(n.schedule=t.schedule),e.kind===`event`&&JSON.stringify(t.trigger)!==JSON.stringify(e.trigger)&&(n.trigger=t.trigger),n}const Ut={title:`Title`,task:`Instruction`,schedule:`Schedule`,trigger:`Trigger`,outcomes:`Where results go`,credentialMode:`Credentials`};function Wt(e){let t=Object.keys(Ut).filter(t=>e.changes[t]!==void 0),n=Gt(e.original),r=e.changes.task??n.task,i=t=>t===`task`&&e.changes.task?Kt(n.task,e.changes.task):Ut[t],a=(t,n)=>Jt(t,n,e.summary,r.kind===`skill`);return/* @__PURE__ */ (0,X.jsx)(`aside`,{"aria-label":`Your changes`,className:L(`min-w-0 lg:sticky lg:top-4 lg:self-start`,t.length===0&&`max-lg:hidden`),children:/* @__PURE__ */ (0,X.jsxs)(R,{padding:`sm`,children:[/* @__PURE__ */ (0,X.jsx)(`h2`,{className:`m-0 mb-3 font-sans text-xs font-medium text-dashboard-text-muted`,children:`Your changes`}),t.length===0?/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:`No changes yet. Edit a section to see it here.`}):/* @__PURE__ */ (0,X.jsx)(`ul`,{className:`m-0 grid list-none gap-3 p-0`,children:t.map(t=>/* @__PURE__ */ (0,X.jsxs)(`li`,{className:`grid min-w-0 gap-1 text-sm`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-medium`,children:i(t)}),/* @__PURE__ */ (0,X.jsx)(h,{"aria-label":`Undo ${i(t).toLowerCase()} change`,disabled:e.disabled,onClick:()=>e.onUndo(t),children:`Undo`})]}),/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`m-0 line-clamp-3 break-words whitespace-pre-wrap text-xs text-dashboard-text-muted line-through decoration-dashboard-text-muted/50`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`sr-only`,children:`Saved: `}),a(n,t)]}),/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`m-0 line-clamp-3 break-words whitespace-pre-wrap text-xs`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`sr-only`,children:`New: `}),a(e.changes,t)]})]},t))}),/* @__PURE__ */ (0,X.jsx)(`p`,{className:`mt-3 mb-0 text-xs leading-relaxed text-dashboard-text-muted`,children:`Saving creates a new version. It does not run this automation.`})]})})}function Gt(e){let t={...Z(e),task:e.task};return e.kind===`scheduled`?{...t,schedule:Vt(e)}:t}function Kt(e,t){return e.kind===t.kind?e.kind===`instruction`||t.kind===`instruction`?`Instruction`:e.skill===t.skill?`Additional context`:e.context===t.context?`Skill`:`Skill and context`:`What to run`}function qt(e){if(e.kind===`instruction`)return e.instruction||`Empty`;let t=e.skill||`No skill chosen`;return e.context?`${t} · ${e.context}`:t}function Jt(e,t,n,r){switch(t){case`title`:return e.title||(r?`Named after the skill`:`First line of the instruction`);case`task`:return e.task?qt(e.task):`Not set`;case`credentialMode`:return e.credentialMode===`creator`?n.ownedByViewer?`Your connected accounts`:`${n.createdBy}'s connected accounts`:`System credentials only`;case`outcomes`:return e.outcomes?.length?e.outcomes.map(e=>Lt(e,n.destination)).join(`, `):`No success message`;case`schedule`:return e.schedule?Xt(e.schedule):`Not set`;case`trigger`:{let t=e.trigger;if(!t)return`Not set`;let n=t.identifier?`${t.label} · ${t.identifier}`:`Any ${t.label}`,r=Object.keys(t.match??{}).length;return[n,t.events.join(`, `),r?`${r} ${r===1?`filter`:`filters`}`:``].filter(Boolean).join(` · `)}}}const Yt={daily:`day`,weekly:`week`,monthly:`month`,yearly:`year`};function Xt(e){if(e.kind===`one_off`)return`Once on ${e.timing.date} at ${e.timing.time} (${e.timezone})`;let t=e.interval??1,n=Yt[e.frequency];return`Every ${t===1?n:`${t} ${n}s`}${e.frequency===`weekly`&&e.weekdays?.length?` on ${e.weekdays.map(e=>e.slice(0,1).toUpperCase()+e.slice(1,3)).join(`, `)}`:e.frequency===`monthly`&&e.dayOfMonth?` on day ${e.dayOfMonth}`:e.frequency===`yearly`&&e.month&&e.dayOfMonth?` on ${String(e.month).padStart(2,`0`)}-${String(e.dayOfMonth).padStart(2,`0`)}`:``} at ${e.time} (${e.timezone})`}function Zt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function Q(e){return/* @__PURE__ */ (0,X.jsxs)(`section`,{className:L(`grid min-w-0 gap-5 border-t border-dashboard-border-emphasis py-8 md:grid-cols-[12rem_minmax(0,1fr)] md:gap-10`,e.changed&&`-ml-4 pl-4 shadow-[inset_2px_0_0_var(--color-dashboard-accent)] sm:-ml-5 sm:pl-5`),children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{children:[/* @__PURE__ */ (0,X.jsx)(je,{anchor:Zt(e.title),className:`m-0 font-display text-lg font-medium`,title:e.title}),e.changed?/* @__PURE__ */ (0,X.jsx)(`p`,{className:`mt-1 mb-0 text-xs text-dashboard-accent-text`,children:`Unsaved changes`}):null,e.detail?/* @__PURE__ */ (0,X.jsx)(`p`,{className:`mt-2 mb-0 text-sm leading-relaxed text-dashboard-text-muted`,children:e.detail}):null]}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`grid min-w-0 content-start gap-5`,children:e.children})]})}function Qt(e){let t=e.value??Vt(e.automation),[n,i]=(0,Y.useState)(e.value);(0,Y.useEffect)(()=>{let t=setTimeout(()=>i(e.value),300);return()=>clearTimeout(t)},[e.value]);let a=se.safeParse(n),o=r({queryKey:[`dashboard`,`automation-schedule-preview`,e.automation.id,n],enabled:!!n&&a.success,retry:!1,queryFn:()=>pe(ue,`/api/automations/${encodeURIComponent(e.automation.id)}/preview`,n)}),s=t.kind===`recurring`?t.frequency:`once`,c=t.kind===`recurring`?t.time:t.timing.time,l=e.value?o.data?.nextRunAtMs:e.automation.nextRunAtMs,u=e.value!==n||o.isFetching,d=o.error instanceof I?o.error.apiError:o.error?`Schedule preview could not be loaded. Try again.`:e.value&&!a.success&&!u?a.error.issues[0]?.message:void 0;return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid grid-cols-1 items-start gap-4 sm:grid-cols-2`,children:[/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(H,{htmlFor:`schedule-frequency`,children:`Repeat`}),/* @__PURE__ */ (0,X.jsxs)(q,{id:`schedule-frequency`,value:s,onChange:n=>{let r=n.target.value;(r===`once`||r===`daily`||r===`weekly`||r===`monthly`||r===`yearly`)&&e.onChange(r===`once`?{kind:`one_off`,timezone:t.timezone??e.automation.schedule.timezone,timing:{type:`at`,date:``,time:c}}:{kind:`recurring`,timezone:t.timezone,time:c,frequency:r,interval:1,weekdays:r===`weekly`?[`monday`]:void 0,dayOfMonth:[`monthly`,`yearly`].includes(r)?1:void 0,month:r===`yearly`?1:void 0})},children:[/* @__PURE__ */ (0,X.jsx)(`option`,{value:`once`,children:`Once`}),/* @__PURE__ */ (0,X.jsx)(`option`,{value:`daily`,children:`Every day`}),/* @__PURE__ */ (0,X.jsx)(`option`,{value:`weekly`,children:`Every week`}),/* @__PURE__ */ (0,X.jsx)(`option`,{value:`monthly`,children:`Every month`}),/* @__PURE__ */ (0,X.jsx)(`option`,{value:`yearly`,children:`Every year`})]})]}),/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(H,{htmlFor:`schedule-time`,children:`Time`}),/* @__PURE__ */ (0,X.jsx)(V,{size:`comfortable`,id:`schedule-time`,type:`time`,value:c,onChange:n=>e.onChange(t.kind===`recurring`?{...t,time:n.target.value}:{...t,timing:{type:`at`,date:t.timing.date,time:n.target.value}})})]})]}),t.kind===`recurring`?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[t.frequency===`weekly`?/* @__PURE__ */ (0,X.jsxs)(`fieldset`,{children:[/* @__PURE__ */ (0,X.jsx)(`legend`,{className:`mb-2 text-sm font-semibold`,children:`On`}),/* @__PURE__ */ (0,X.jsx)(Ce,{className:`grid grid-cols-7 gap-1.5`,multiple:!0,onValueChange:n=>e.onChange({...t,weekdays:n}),value:t.weekdays??[],children:[...Rt.slice(1),Rt[0]].map(e=>/* @__PURE__ */ (0,X.jsx)(ve,{"aria-label":e,className:`h-auto min-h-11 min-w-0 border-dashboard-border-emphasis px-1 capitalize data-pressed:border-dashboard-focus/50 data-pressed:bg-dashboard-focus/10 data-pressed:text-dashboard-focus sm:min-h-10 sm:text-sm`,value:e,children:e.slice(0,3)},e))})]}):null,/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid grid-cols-1 items-start gap-4 sm:grid-cols-2`,children:[/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(H,{htmlFor:`schedule-interval`,children:`Interval`}),/* @__PURE__ */ (0,X.jsx)(V,{size:`comfortable`,id:`schedule-interval`,type:`number`,min:1,max:365,value:t.interval??1,onChange:n=>e.onChange({...t,interval:n.target.valueAsNumber})}),/* @__PURE__ */ (0,X.jsx)(W,{id:`schedule-interval-help`,children:`Number of calendar periods between runs.`})]}),/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(H,{htmlFor:`schedule-start`,children:`Start date`}),/* @__PURE__ */ (0,X.jsx)(V,{size:`comfortable`,id:`schedule-start`,type:`date`,value:t.startDate??``,onChange:n=>e.onChange({...t,startDate:n.target.value||void 0})})]})]}),t.frequency===`monthly`||t.frequency===`yearly`?/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(H,{htmlFor:`schedule-day`,children:`Day of month`}),/* @__PURE__ */ (0,X.jsx)(V,{size:`comfortable`,id:`schedule-day`,type:`number`,min:1,max:31,value:t.dayOfMonth??1,onChange:n=>e.onChange({...t,dayOfMonth:n.target.valueAsNumber})})]}),t.frequency===`yearly`?/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(H,{htmlFor:`schedule-month`,children:`Month`}),/* @__PURE__ */ (0,X.jsx)(q,{id:`schedule-month`,value:t.month??1,onChange:n=>e.onChange({...t,month:Number(n.target.value)}),children:Array.from({length:12},(e,t)=>/* @__PURE__ */ (0,X.jsx)(`option`,{value:t+1,children:new Intl.DateTimeFormat(`en`,{month:`long`,timeZone:`UTC`}).format(new Date(Date.UTC(2026,t,1)))},t))})]}):null]}):null]}):/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(H,{htmlFor:`schedule-date`,children:`Date`}),/* @__PURE__ */ (0,X.jsx)(V,{size:`comfortable`,id:`schedule-date`,type:`date`,value:t.timing.date,onChange:n=>e.onChange({...t,timing:{type:`at`,time:c,date:n.target.value}})})]}),/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(H,{htmlFor:`schedule-timezone`,children:`Timezone`}),/* @__PURE__ */ (0,X.jsx)(V,{size:`comfortable`,id:`schedule-timezone`,list:`automation-timezones`,value:t.timezone??``,onChange:n=>e.onChange({...t,timezone:n.target.value})}),/* @__PURE__ */ (0,X.jsx)(`datalist`,{id:`automation-timezones`,children:[`UTC`,...Intl.supportedValuesOf(`timeZone`)].map(e=>/* @__PURE__ */ (0,X.jsx)(`option`,{children:e},e))}),/* @__PURE__ */ (0,X.jsx)(W,{id:`schedule-timezone-help`,children:`Use an IANA timezone. The schedule follows local time, including daylight saving time.`})]}),/* @__PURE__ */ (0,X.jsxs)(`div`,{role:`status`,className:`flex gap-3 rounded-md bg-dashboard-fill-soft p-3 text-sm leading-relaxed`,children:[/* @__PURE__ */ (0,X.jsx)(C,{"aria-hidden":!0,size:17,className:`mt-0.5 shrink-0 text-dashboard-text-muted`}),/* @__PURE__ */ (0,X.jsx)(`div`,{children:u?`Checking schedule…`:d?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`text-rose-300`,children:d}),o.error?/* @__PURE__ */ (0,X.jsx)(h,{onClick:()=>void o.refetch(),children:`Try again`}):null]}):l?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[`Next run`,` `,new Intl.DateTimeFormat(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,timeZoneName:`short`,timeZone:e.value?o.data?.schedule.timezone??`UTC`:e.automation.schedule.timezone}).format(l)]}):`No next run.`})]}),e.value?/* @__PURE__ */ (0,X.jsx)(h,{className:`w-fit`,onClick:()=>e.onChange(void 0),children:`Keep saved schedule`}):null]})}function $t(e){return e.filters.length===0?/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 mt-1 text-xs text-dashboard-text-muted`,children:`No filters. Runs on every selected event.`}):/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`mt-1 text-xs text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0`,children:`Every filter must match:`}),/* @__PURE__ */ (0,X.jsx)(`ul`,{className:`m-0 list-disc pl-5`,children:e.filters.map(e=>/* @__PURE__ */ (0,X.jsx)(`li`,{className:`break-words`,children:e},e))})]})}const en={resourceTypes:[],events:{},anyResourceFields:{}};function tn(e,t){let n=e.events[t]?.reach;if(typeof n!=`object`)return;let r=n.anyOf.map(t=>e.anyResourceFields[t]?.description??t);return r.length===1?`needs a filter: ${r[0]}`:`needs one of these filters: ${r.join(`; or `)}`}function nn(e){let[t,n]=(0,Y.useState)(),i=r({queryKey:[`dashboard`,`automation-event-catalog`],queryFn:({signal:e})=>F(le,`/api/automations/event-catalog`,e),retry:!1}),a=i.data?.find(t=>t.namespace===e.value.namespace),o=a??en,s=a?.displayName??e.value.namespace,c=e.value.resourceType===void 0,l=ie(o,e.value),u=i.data?j(o,e.value):[],d=!l||u.some(e=>e.reason!==`field_not_set`&&e.reason!==`filter_required`),f=i.data?.filter(e=>N(e).length>0)??[],p=Object.entries(l?.fields??{}),m=p.filter(([t,n])=>e.value.match?.[t]!==void 0||de(n,e.value.events).length===0),g=(t,n)=>{let r={...e.value.match};n===void 0?delete r[t]:r[t]=n,e.onChange({...e.value,match:r})};return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[i.error?/* @__PURE__ */ (0,X.jsxs)(K,{title:`Event choices could not be loaded.`,children:[`Saved values are kept.`,` `,/* @__PURE__ */ (0,X.jsx)(h,{onClick:()=>void i.refetch(),children:`Try again`})]}):i.isPending?/* @__PURE__ */ (0,X.jsx)(`p`,{role:`status`,children:`Loading event choices…`}):null,d&&i.data?/* @__PURE__ */ (0,X.jsxs)(K,{title:`Saved trigger · Kept unchanged`,children:[`Some saved values are not in the current catalog. You can edit other fields, or select a new resource type to replace the trigger.`,/* @__PURE__ */ (0,X.jsx)(rn,{displayName:s,source:o,trigger:e.value})]}):null,/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(H,{htmlFor:`trigger-resource`,children:d?`Replace trigger`:`Resource type`}),/* @__PURE__ */ (0,X.jsxs)(q,{id:`trigger-resource`,value:d?``:`${e.value.namespace}:${e.value.resourceType??`*`}`,onChange:e=>{let[t,r]=e.target.value.split(`:`);if(r===`*`&&t){n({namespace:t,label:``,events:[]});return}let a=i.data?.find(e=>e.namespace===t)?.resourceTypes.find(e=>e.type===r);t&&a&&n({namespace:t,resourceType:a.type,identifier:``,label:``,events:[]})},children:[/* @__PURE__ */ (0,X.jsx)(`option`,{value:``,disabled:!0,children:`Keep saved trigger`}),f.map(e=>/* @__PURE__ */ (0,X.jsxs)(`option`,{value:`${e.namespace}:*`,children:[e.displayName,` · any resource`]},`${e.namespace}:*`)),i.data?.flatMap(e=>e.resourceTypes.map(t=>/* @__PURE__ */ (0,X.jsxs)(`option`,{value:`${e.namespace}:${t.type}`,children:[e.displayName,` · `,t.type.replaceAll(`_`,` `)]},`${e.namespace}:${t.type}`)))]})]}),/* @__PURE__ */ (0,X.jsx)(Qe,{onOpenChange:e=>{e||n(void 0)},open:t!==void 0,children:/* @__PURE__ */ (0,X.jsxs)(Je,{children:[/* @__PURE__ */ (0,X.jsx)(rt,{children:`Replace the saved trigger?`}),/* @__PURE__ */ (0,X.jsx)(at,{children:`Its resource, events, and filters will be cleared.`}),/* @__PURE__ */ (0,X.jsxs)(Pe,{children:[/* @__PURE__ */ (0,X.jsx)(Ie,{children:`Cancel`}),/* @__PURE__ */ (0,X.jsx)(Le,{onClick:()=>{t&&e.onChange(t),n(void 0)},variant:`primary`,children:`Replace trigger`})]})]})}),!d&&l?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(H,{htmlFor:`trigger-label`,children:c?`Trigger name`:`Resource name`}),/* @__PURE__ */ (0,X.jsx)(V,{size:`comfortable`,id:`trigger-label`,value:e.value.label,onChange:t=>e.onChange({...e.value,label:t.target.value})})]}),c?/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 text-xs leading-relaxed text-dashboard-text-muted`,children:`Runs for every resource that the filters match.`}):/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(H,{htmlFor:`trigger-identifier`,children:`Resource identifier`}),/* @__PURE__ */ (0,X.jsx)(V,{size:`comfortable`,id:`trigger-identifier`,value:e.value.identifier??``,onChange:t=>e.onChange({...e.value,identifier:t.target.value})}),/* @__PURE__ */ (0,X.jsx)(W,{id:`trigger-identifier-help`,children:`Use the exact provider resource identifier, not its display name.`})]}),/* @__PURE__ */ (0,X.jsxs)(`fieldset`,{children:[/* @__PURE__ */ (0,X.jsx)(`legend`,{className:`mb-2 text-sm font-semibold`,children:`Run on these events`}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`divide-y divide-dashboard-border-subtle rounded-md border border-dashboard-border-emphasis`,children:l.events.map(t=>/* @__PURE__ */ (0,X.jsxs)(`label`,{className:`flex min-h-11 cursor-pointer items-start gap-3 px-3 py-3 text-sm`,children:[/* @__PURE__ */ (0,X.jsx)(Xe,{className:`mt-0.5`,checked:e.value.events.includes(t),disabled:e.disabled,onCheckedChange:()=>e.onChange({...e.value,events:e.value.events.includes(t)?e.value.events.filter(e=>e!==t):[...e.value.events,t]})}),/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`min-w-0 break-words`,children:[oe(t),c&&tn(o,t)?/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`text-dashboard-text-muted`,children:[` `,`· `,tn(o,t)]}):null]})]},t))})]}),p.length?/* @__PURE__ */ (0,X.jsxs)(`fieldset`,{className:`grid gap-4`,children:[/* @__PURE__ */ (0,X.jsx)(`legend`,{className:`mb-3 text-sm font-semibold`,children:`Filters`}),/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`m-0 text-xs leading-relaxed text-dashboard-text-muted`,children:[`Every filter must match. Leave a filter blank to match any value.`,m.length<p.length?` Filters that a selected event does not set are hidden.`:null]}),m.map(([t,n])=>{let r=e.value.match?.[t],i=u.find(e=>e.field===t);return/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(H,{htmlFor:`match-${t}`,children:t}),Array.isArray(r)?/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`text-sm`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`break-all`,children:ae(t,n,r)}),` `,/* @__PURE__ */ (0,X.jsx)(h,{onClick:()=>g(t,void 0),children:`Remove filter`})]}):n.kind===`boolean`||n.enum?/* @__PURE__ */ (0,X.jsxs)(q,{id:`match-${t}`,value:r===void 0?``:String(r),onChange:e=>g(t,e.target.value===``?void 0:n.kind===`boolean`?e.target.value===`true`:e.target.value),children:[/* @__PURE__ */ (0,X.jsx)(`option`,{value:``,children:`Any value`}),(n.enum??[`true`,`false`]).map(e=>/* @__PURE__ */ (0,X.jsx)(`option`,{children:e},e))]}):/* @__PURE__ */ (0,X.jsx)(V,{size:`comfortable`,id:`match-${t}`,type:n.kind===`number`?`number`:`text`,step:`any`,value:r===void 0?``:String(r),onChange:e=>g(t,e.target.value===``?void 0:n.kind===`number`?e.target.valueAsNumber:e.target.value)}),n.description?/* @__PURE__ */ (0,X.jsx)(W,{id:`match-${t}-help`,children:n.description}):null,i?/* @__PURE__ */ (0,X.jsx)(U,{children:i.message}):null]},t)})]}):null]}):null,JSON.stringify(e.value)===JSON.stringify(e.original)?null:/* @__PURE__ */ (0,X.jsx)(h,{className:`w-fit`,onClick:()=>e.onChange(e.original),children:`Keep saved trigger`})]})}function rn(e){let t=P(e.source,e.trigger);return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(`ul`,{className:`my-2 list-disc pl-5`,children:t.problems.map(e=>/* @__PURE__ */ (0,X.jsx)(`li`,{children:e},e))}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`text-xs`,children:[/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`m-0 break-words`,children:[e.displayName,` ·`,` `,e.trigger.resourceType?.replaceAll(`_`,` `)??`any resource`,e.trigger.identifier?` · ${e.trigger.identifier}`:null]}),/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 mt-1 break-words text-dashboard-text-muted`,children:t.events.join(`, `)}),/* @__PURE__ */ (0,X.jsx)($t,{filters:t.filters})]})]})}function an(e){return e.outcomes.length?/* @__PURE__ */ (0,X.jsx)(`ol`,{className:`m-0 grid list-decimal gap-2 pl-5 text-sm`,children:e.outcomes.map((t,n)=>/* @__PURE__ */ (0,X.jsx)(`li`,{children:Lt(t,e.destination)},n))}):/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 text-sm`,children:`No success message`})}function on(e){let t=e.original.length?e.original:[{action:`send_message`,destination:`current_conversation`}],n=[...e.original.flatMap((t,n)=>typeof t.destination==`string`?[]:[{value:`saved:${n}`,label:Lt(t,e.destination),outcome:t}]),{value:`current_conversation`,label:`${e.destination.label} · ${e.destination.visibility}`,outcome:{action:`send_message`,destination:`current_conversation`}},{value:`task_creator`,label:`Creator · Direct message`,outcome:{action:`send_message`,destination:`task_creator`}}];return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(We,{"aria-label":`Success messages`,disabled:e.disabled,className:`flex flex-wrap gap-x-6 gap-y-3`,onValueChange:n=>e.onChange(n?t:[]),value:e.value.length>0,children:[!0,!1].map(e=>/* @__PURE__ */ (0,X.jsxs)(`label`,{className:`inline-flex min-h-8 cursor-pointer items-center gap-2 text-sm`,children:[/* @__PURE__ */ (0,X.jsx)(Ke,{value:e}),e?`Send a message`:`No success message`]},String(e)))}),e.value.length?/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid gap-4 sm:gap-2`,children:[e.value.map((t,r)=>{let i=e.original.findIndex(e=>JSON.stringify(e)===JSON.stringify(t));return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`w-4 text-xs text-dashboard-text-muted`,children:[r+1,`.`]}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:L(`min-w-0 flex-1`,e.value.length>1&&`order-last basis-full sm:order-none sm:basis-auto`),children:/* @__PURE__ */ (0,X.jsx)(q,{"aria-label":`Message ${r+1} destination`,value:typeof t.destination==`string`?t.destination:`saved:${i}`,onChange:t=>{let i=n.find(e=>e.value===t.target.value);i&&e.onChange(e.value.map((e,t)=>t===r?i.outcome:e))},children:n.map(e=>/* @__PURE__ */ (0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))})}),e.value.length>1?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(h,{size:`icon`,className:`ml-auto sm:ml-0`,"aria-label":`Move message ${r+1} up`,disabled:r===0,onClick:()=>{let n=[...e.value],i=n[r-1];i&&(n[r-1]=t,n[r]=i,e.onChange(n))},children:/* @__PURE__ */ (0,X.jsx)(Pt,{size:16})}),/* @__PURE__ */ (0,X.jsx)(h,{size:`icon`,"aria-label":`Remove message ${r+1}`,onClick:()=>e.onChange(e.value.filter((e,t)=>t!==r)),children:/* @__PURE__ */ (0,X.jsx)(x,{size:16})})]}):null]},r)}),e.value.length<5?/* @__PURE__ */ (0,X.jsxs)(h,{className:`w-fit`,onClick:()=>e.onChange([...e.value,{action:`send_message`,destination:`task_creator`}]),children:[/* @__PURE__ */ (0,X.jsx)(E,{size:15}),`Add message`]}):null]}):/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 text-sm leading-relaxed text-dashboard-text-muted`,children:`Junior still does the work. No message is sent after success.`}),/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`m-0 text-xs leading-relaxed text-dashboard-text-muted`,children:[e.value.length?`Messages are sent in this order. `:``,`This does not limit actions in the instruction.`]})]})}function sn(e){let[t,n]=(0,Y.useState)(!1),r=e.skills.find(t=>t.name===e.value),i=!!e.value&&!r,a=[{heading:`App and local skills`,skills:e.skills.filter(e=>!e.pluginProvider)},{heading:`Plugin skills`,skills:e.skills.filter(e=>e.pluginProvider)}].filter(e=>e.skills.length>0);return/* @__PURE__ */ (0,X.jsxs)(it,{open:t,onOpenChange:n,children:[/* @__PURE__ */ (0,X.jsxs)(Be,{id:e.id,"aria-invalid":e.invalid||i||void 0,"aria-describedby":e.describedBy,className:`flex min-h-14 w-full cursor-pointer items-center gap-3 rounded-md border border-dashboard-border-emphasis bg-dashboard-ink px-3 py-2 text-left font-sans text-sm text-dashboard-text hover:border-dashboard-border-heavy focus-visible:border-dashboard-focus focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-dashboard-focus/25 aria-invalid:border-rose-300 disabled:cursor-not-allowed disabled:opacity-50`,children:[e.value?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(cn,{plugin:!!r?.pluginProvider}),/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:L(`truncate font-mono text-sm`,i&&`text-dashboard-text-muted line-through decoration-dashboard-text-muted/60`),children:e.value}),i?/* @__PURE__ */ (0,X.jsx)(ln,{tone:`danger`,children:`Not found`}):r?.disableModelInvocation?/* @__PURE__ */ (0,X.jsx)(ln,{children:`Manual only`}):null]}),r?.description?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`truncate text-xs text-dashboard-text-muted`,children:r.description}):null]})]}):/* @__PURE__ */ (0,X.jsx)(`span`,{className:`flex-1 text-dashboard-text-muted`,children:`Choose a skill`}),/* @__PURE__ */ (0,X.jsx)(g,{"aria-hidden":`true`,className:`size-4 shrink-0 text-dashboard-text-muted`})]}),/* @__PURE__ */ (0,X.jsx)(Ge,{align:`start`,className:`w-(--anchor-width) max-w-[calc(100vw-2rem)] min-w-80 overflow-hidden p-0`,children:/* @__PURE__ */ (0,X.jsxs)(dt,{label:`Skills`,children:[/* @__PURE__ */ (0,X.jsx)(ut,{placeholder:`Search by name or description`}),/* @__PURE__ */ (0,X.jsxs)(Re,{children:[/* @__PURE__ */ (0,X.jsx)(Ze,{children:`No skills match.`}),a.map(t=>/* @__PURE__ */ (0,X.jsx)(Fe,{heading:t.heading,children:t.skills.map(t=>/* @__PURE__ */ (0,X.jsx)($e,{value:t.name,keywords:[t.description],onSelect:()=>{e.onChange(t.name),n(!1)},className:`items-start`,children:/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`truncate font-mono`,children:t.name}),t.disableModelInvocation?/* @__PURE__ */ (0,X.jsx)(ln,{children:`Manual only`}):null]}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`truncate text-xs text-dashboard-text-muted`,children:t.description})]})},t.name))},t.heading))]})]})})]})}function cn(e){return/* @__PURE__ */ (0,X.jsx)(`span`,{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.plugin?/* @__PURE__ */ (0,X.jsx)(_,{"aria-hidden":`true`,size:15,strokeWidth:1.8}):/* @__PURE__ */ (0,X.jsx)(b,{"aria-hidden":`true`,size:15,strokeWidth:1.8})})}function ln(e){return/* @__PURE__ */ (0,X.jsx)(`span`,{className:L(`shrink-0 rounded-sm border px-1.5 py-0.5 font-sans text-xs leading-none font-medium`,e.tone===`danger`?`border-rose-300/40 text-rose-300`:`border-dashboard-accent/25 bg-dashboard-accent/[0.075] text-dashboard-accent-text`),children:e.children})}function un(e){let{task:t,original:n}=e,[r,i]=(0,Y.useState)(t.kind===`skill`&&t.context!==``),a=ot().data;return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(`span`,{id:`run-label`,className:`text-sm font-semibold`,children:`Run`}),/* @__PURE__ */ (0,X.jsxs)(Ce,{"aria-labelledby":`run-label`,disabled:e.disabled,value:[t.kind],onValueChange:([r])=>{if(r!==`instruction`&&r!==`skill`||r===t.kind)return;let a=r===n.task.kind?zt(n.task):r===`skill`?{kind:`skill`,skill:``,context:``}:{kind:`instruction`,instruction:``};i(a.kind===`skill`&&a.context!==``),e.onChange(a)},className:`w-fit rounded-md border border-dashboard-border-emphasis p-0.5`,children:[/* @__PURE__ */ (0,X.jsx)(ve,{value:`instruction`,children:`Instruction`}),/* @__PURE__ */ (0,X.jsx)(ve,{value:`skill`,children:`Skill`})]})]}),t.kind===`skill`?/* @__PURE__ */ (0,X.jsx)(dn,{...e,task:t,skills:a,contextOpen:r||t.context!==``,onContextOpen:i}):/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(H,{htmlFor:`task.instruction`,children:`Instruction`}),/* @__PURE__ */ (0,X.jsx)(et,{id:`task.instruction`,rows:8,value:t.instruction,onChange:n=>e.onChange({...t,instruction:n.target.value}),...e.inputState(`task.instruction`),className:`resize-y text-base leading-relaxed sm:text-sm`}),/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`m-0 text-right text-xs text-dashboard-text-muted`,children:[t.instruction.length.toLocaleString(),` / 4,000`]}),/* @__PURE__ */ (0,X.jsx)(U,{id:`task.instruction-error`,children:e.fieldError(`task.instruction`)})]})]})}function dn(e){let{task:t}=e,n=e.skills?.find(e=>e.name===t.skill),r=!!(t.skill&&e.skills&&!n),i=e.fieldError(`task.skill`)??(r?`The skill ${t.skill} is no longer installed. This automation is blocked until you choose another skill or switch to an instruction.`:void 0);return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(H,{htmlFor:`task.skill`,children:`Skill`}),/* @__PURE__ */ (0,X.jsx)(sn,{id:`task.skill`,value:t.skill,skills:e.skills??[],invalid:!!i,describedBy:i?`task.skill-error`:`skill-hint`,onChange:n=>e.onChange({...t,skill:n})}),/* @__PURE__ */ (0,X.jsx)(U,{id:`task.skill-error`,children:i}),/* @__PURE__ */ (0,X.jsxs)(W,{id:`skill-hint`,className:`flex flex-wrap items-center justify-between gap-2`,children:[`Junior loads this skill at the start of each run.`,n?/* @__PURE__ */ (0,X.jsx)(f,{to:n.pluginProvider?Ne(n.pluginProvider):`/system#skills`,className:`text-dashboard-accent-text`,children:`View skill`}):null]})]}),e.contextOpen?/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[/* @__PURE__ */ (0,X.jsx)(H,{htmlFor:`task.context`,children:`Additional context`}),/* @__PURE__ */ (0,X.jsx)(h,{variant:`quiet`,onClick:()=>{e.onChange({...t,context:``}),e.onContextOpen(!1)},children:`Remove`})]}),/* @__PURE__ */ (0,X.jsx)(et,{id:`task.context`,rows:4,autoFocus:t.context===``,value:t.context,placeholder:`What this automation needs beyond the skill, such as a repo, a threshold, or who to tag.`,onChange:n=>e.onChange({...t,context:n.target.value}),...e.inputState(`task.context`),className:`resize-y text-base leading-relaxed sm:text-sm`}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[/* @__PURE__ */ (0,X.jsx)(W,{children:`Junior gets this with the skill on every run.`}),/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`m-0 shrink-0 text-xs text-dashboard-text-muted`,children:[t.context.length.toLocaleString(),` / 4,000`]})]}),/* @__PURE__ */ (0,X.jsx)(U,{id:`task.context-error`,children:e.fieldError(`task.context`)})]}):/* @__PURE__ */ (0,X.jsxs)(h,{variant:`quiet`,className:`w-fit`,onClick:()=>e.onContextOpen(!0),children:[/* @__PURE__ */ (0,X.jsx)(E,{"aria-hidden":`true`,className:`size-4`}),`Add context`]})]})}function fn(e){let r=nt(),[i,a]=(0,Y.useState)(e.automation),[o,s]=(0,Y.useState)(()=>Z(e.automation)),[u,d]=(0,Y.useState)({}),[p,m]=(0,Y.useState)(),[g,_]=(0,Y.useState)(0),v=(0,Y.useRef)(null),y=(0,Y.useRef)(!1),ee=l(),b=n(),x=Ht(i,o),S=Object.keys(x).length>0,te={kind:i.kind,revision:i.revision,...x},C=c(()=>S&&!y.current),w=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{C.state===`blocked`&&w.current?.focus()},[C.state]);let ne=`/api/automations/${encodeURIComponent(i.id)}`;(0,Y.useEffect)(()=>{let e=e=>{S&&!y.current&&(e.preventDefault(),e.returnValue=``)};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[S]);let re=()=>requestAnimationFrame(()=>(v.current?.querySelector(`[aria-invalid="true"]`)??v.current?.querySelector(`[data-save-error]`))?.focus()),T=t({mutationFn:()=>fe(A,ne,te),onSuccess:async()=>{y.current=!0,await b.invalidateQueries({queryKey:[`dashboard`,`automations`]}),r.add({title:`Automation saved`,description:`Changes apply to future work.`,type:`success`}),ee(e.returnPath)},onError:e=>{d(e instanceof I?e.fields??{}:{}),re()}});function E(e){p&&(s(e?{...Z(p),...x,task:x.task?o.task:zt(p.task)}:Z(p)),a(p),m(void 0),T.reset(),d({}))}let D=t({mutationFn:()=>F(A,`${ne}/edit`),onSuccess:m}),O=T.error instanceof I&&T.error.code===`conflict`,k=e=>s(t=>({...t,...e})),ie=e=>{k({[e]:Z(i)[e]}),_(e=>e+1)},j=e=>Object.entries(u).filter(([t])=>t===e||t.startsWith(`${e}.`)).flatMap(([,e])=>e).join(` `)||void 0,M=i.kind===`scheduled`?`schedule`:`trigger`,N=i.ownedByViewer,P=e.summary.createdBy,ae=!N&&i.credentialMode===`creator`&&(x.task!==void 0||x[M]!==void 0||x.outcomes!==void 0),oe=j(M),se=e=>({"aria-invalid":!!j(e)||void 0,"aria-describedby":j(e)?`${e}-error`:void 0});return/* @__PURE__ */ (0,X.jsxs)(`form`,{ref:v,noValidate:!0,onSubmit:e=>{if(e.preventDefault(),T.isPending||O||!S)return;let t=o.task.kind===`skill`?o.task.skill?void 0:{"task.skill":[`Choose a skill.`]}:o.task.instruction.trim()?void 0:{"task.instruction":[`Write an instruction or choose a skill.`]};if(t){d(t),re();return}let n=ce.safeParse(te);if(n.success)d({}),T.mutate();else{let e={};for(let t of n.error.issues)(e[t.path.join(`.`)]??=[]).push(t.message);d(e),re()}},children:[C.state===`blocked`?/* @__PURE__ */ (0,X.jsx)(`div`,{tabIndex:-1,ref:w,className:`mb-6 outline-none`,children:/* @__PURE__ */ (0,X.jsxs)(K,{title:`Discard unsaved changes?`,children:[/* @__PURE__ */ (0,X.jsx)(`p`,{children:`Your changes have not been saved.`}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex gap-2`,children:[/* @__PURE__ */ (0,X.jsx)(h,{onClick:()=>C.reset(),children:`Keep editing`}),/* @__PURE__ */ (0,X.jsx)(h,{onClick:()=>C.proceed(),children:`Discard changes`})]})]})}):null,T.error||Object.keys(u).length?/* @__PURE__ */ (0,X.jsx)(`div`,{tabIndex:-1,"data-save-error":!0,className:`mb-6 outline-none`,children:/* @__PURE__ */ (0,X.jsxs)(K,{tone:O?`warning`:`error`,title:O?`This automation changed while you were editing.`:`Changes could not be saved.`,children:[/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`mt-1`,children:[`Your edits are still here.`,` `,O?`Review the latest version before saving again.`:T.error instanceof I?T.error.apiError:`Check the fields below, or try again.`]}),O?/* @__PURE__ */ (0,X.jsx)(h,{disabled:D.isPending,onClick:()=>D.mutate(),children:D.isPending?`Loading…`:`Review latest version`}):null,D.error?/* @__PURE__ */ (0,X.jsx)(`p`,{role:`alert`,children:`The latest version could not be loaded. Try again.`}):null]})}):null,p?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`mb-6`,children:/* @__PURE__ */ (0,X.jsxs)(K,{title:`Compare your edits with the latest saved version`,children:[/* @__PURE__ */ (0,X.jsx)(`p`,{children:`Only the fields you changed are shown. Keeping your edits will replace these fields. Other saved fields stay unchanged.`}),Object.entries(x).map(([e,t])=>/* @__PURE__ */ (0,X.jsxs)(`section`,{className:`my-4`,children:[/* @__PURE__ */ (0,X.jsx)(`h3`,{className:`text-sm font-semibold capitalize`,children:e===`credentialMode`?`Credentials`:e}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{children:[/* @__PURE__ */ (0,X.jsx)(`p`,{children:`Latest saved`}),/* @__PURE__ */ (0,X.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-sans text-sm`,children:pn(e===`schedule`&&p.kind===`scheduled`?Vt(p):p[e])})]}),/* @__PURE__ */ (0,X.jsxs)(`div`,{children:[/* @__PURE__ */ (0,X.jsx)(`p`,{children:`Your edit`}),/* @__PURE__ */ (0,X.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-sans text-sm`,children:pn(t)})]})]})]},e)),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[/* @__PURE__ */ (0,X.jsx)(h,{onClick:()=>E(!0),children:`Keep my changed fields`}),/* @__PURE__ */ (0,X.jsx)(h,{onClick:()=>E(!1),children:`Use latest saved version`})]})]})}):null,N?null:/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`mt-0 mb-6 max-w-2xl text-sm leading-relaxed text-dashboard-text-muted`,children:[P,` created this automation. You can edit it because it is in a public channel. Only `,P,` can turn on their connected accounts. Version history keeps every saved change.`]}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0 gap-6 lg:grid-cols-[minmax(0,1fr)_18rem] lg:gap-10`,children:[/* @__PURE__ */ (0,X.jsxs)(`fieldset`,{disabled:T.isPending,className:`min-w-0 [&>section:first-of-type]:border-t-0 [&>section:first-of-type]:pt-0`,children:[/* @__PURE__ */ (0,X.jsxs)(Q,{changed:x.title!==void 0||x.task!==void 0,title:`What to do`,detail:o.task.kind===`instruction`?`Give Junior a clear instruction and a name you can find later.`:`Pick a skill for Junior to run. Add context only when this automation needs more than the skill does.`,children:[/* @__PURE__ */ (0,X.jsxs)(G,{children:[/* @__PURE__ */ (0,X.jsx)(H,{htmlFor:`title`,children:`Title`}),/* @__PURE__ */ (0,X.jsx)(V,{size:`comfortable`,id:`title`,value:o.title,placeholder:e.summary.title,onChange:e=>k({title:e.target.value}),...se(`title`)}),/* @__PURE__ */ (0,X.jsx)(U,{id:`title-error`,children:j(`title`)})]}),/* @__PURE__ */ (0,X.jsx)(un,{task:o.task,original:i,disabled:T.isPending,fieldError:j,inputState:se,onChange:e=>k({task:e})})]}),/* @__PURE__ */ (0,X.jsx)(Q,{changed:x[M]!==void 0,title:`When to run`,detail:i.kind===`scheduled`?`Choose a schedule in a specific timezone.`:`Run when a matching event occurs.`,children:/* @__PURE__ */ (0,X.jsxs)(`div`,{id:`${M}-error`,tabIndex:-1,"aria-invalid":!!oe||void 0,className:`grid min-w-0 gap-5 outline-none`,children:[oe?/* @__PURE__ */ (0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-rose-300`,children:oe}):null,i.kind===`scheduled`?/* @__PURE__ */ (0,X.jsx)(Qt,{automation:i,value:o.schedule,onChange:e=>k({schedule:e})}):/* @__PURE__ */ (0,X.jsx)(nn,{value:o.trigger??i.trigger,original:i.trigger,disabled:T.isPending,onChange:e=>k({trigger:e})})]})}),/* @__PURE__ */ (0,X.jsxs)(Q,{changed:x.outcomes!==void 0,title:`Where results go`,detail:`Choose who gets a message after successful work.`,children:[j(`outcomes`)?/* @__PURE__ */ (0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-rose-300`,children:j(`outcomes`)}):null,/* @__PURE__ */ (0,X.jsx)(on,{value:o.outcomes,original:i.outcomes,destination:e.summary.destination,disabled:T.isPending,onChange:e=>k({outcomes:e})})]}),/* @__PURE__ */ (0,X.jsxs)(Q,{changed:x.credentialMode!==void 0,title:`Credentials`,detail:`Choose which connected accounts Junior can use.`,children:[/* @__PURE__ */ (0,X.jsx)(We,{"aria-label":`Credential mode`,disabled:T.isPending,className:`divide-y divide-dashboard-border-subtle rounded-md border border-dashboard-border-emphasis`,onValueChange:e=>k({credentialMode:e}),value:ae?`system`:o.credentialMode,children:[[`creator`,N?`Your connected accounts`:`${P}’s connected accounts`,N?`Uses accounts connected by you, the creator.`:`Uses accounts connected by ${P}. Only ${P} can turn this on.`],[`system`,`System credentials only`,N?`Does not use your connected accounts. Some work may not be possible.`:`Does not use anyone’s connected accounts. Some work may not be possible.`]].map(([e,t,n])=>/* @__PURE__ */ (0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 px-4 py-4 has-data-checked:bg-dashboard-fill-soft has-data-disabled:cursor-not-allowed has-data-disabled:opacity-60`,children:[/* @__PURE__ */ (0,X.jsx)(Ke,{className:`mt-0.5`,value:e,disabled:e===`creator`&&!N&&(i.credentialMode!==`creator`||ae)}),/* @__PURE__ */ (0,X.jsxs)(`span`,{children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`block text-sm font-medium`,children:t}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-dashboard-text-muted`,children:n})]})]},e))}),ae?/* @__PURE__ */ (0,X.jsxs)(K,{title:`Saving switches this automation to system credentials.`,children:[`Only `,P,` can let a changed instruction,`,i.kind===`event`?` trigger,`:` schedule,`,` or result destination use their connected accounts.`]}):null,j(`credentialMode`)?/* @__PURE__ */ (0,X.jsx)(`p`,{role:`alert`,children:j(`credentialMode`)}):null]})]},g),/* @__PURE__ */ (0,X.jsx)(Wt,{changes:x,disabled:T.isPending,onUndo:ie,original:i,summary:e.summary})]}),/* @__PURE__ */ (0,X.jsx)(`p`,{className:`mb-5 text-xs leading-relaxed text-dashboard-text-muted sm:hidden`,children:`Changes apply to future work. Saving does not run this automation.`}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`sticky bottom-0 z-20 -mx-4 border-t border-dashboard-border-emphasis bg-dashboard-bg px-4 py-4 sm:-mx-8 sm:px-8`,children:/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,role:`status`,children:[/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 text-xs font-medium sm:text-sm`,children:T.isPending?`Saving…`:S?`Unsaved changes`:`Unchanged`}),/* @__PURE__ */ (0,X.jsx)(`p`,{className:`mt-1 mb-0 hidden text-xs text-dashboard-text-muted sm:block`,children:`Changes apply to future work. Saving does not run it.`})]}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[/* @__PURE__ */ (0,X.jsx)(f,{to:e.returnPath,className:`inline-flex min-h-11 items-center rounded-md border border-dashboard-border-emphasis px-3 text-sm text-dashboard-text no-underline sm:min-h-9`,children:`Cancel`}),/* @__PURE__ */ (0,X.jsx)(h,{type:`submit`,variant:`primary`,className:`min-h-11 sm:min-h-9`,disabled:!S||T.isPending||O,children:`Save changes`})]})]})})]})}function pn(e){return e==null?`Not set`:typeof e==`string`?e:JSON.stringify(e,null,2)}function mn(){return/* @__PURE__ */ (0,X.jsx)(`div`,{role:`status`,"aria-label":`Loading automation editor`,children:[`What to do`,`When to run`,`Where results go`,`Credentials`].map((e,t)=>/* @__PURE__ */ (0,X.jsxs)(Q,{title:e,children:[/* @__PURE__ */ (0,X.jsx)(ge,{className:`h-4 w-24`}),/* @__PURE__ */ (0,X.jsx)(ge,{className:t===0?`h-48 w-full`:`h-20 w-full`})]},e))})}const hn=new Intl.DateTimeFormat(void 0,{day:`numeric`,month:`short`,timeZone:`UTC`});function gn(e){let{automation:t}=e,n=t.costUsd[30],r=t.runs[30],i=e=>De({total:e});return/* @__PURE__ */ (0,X.jsxs)(gt,{title:`Cost`,children:[e.days?/* @__PURE__ */ (0,X.jsx)(_n,{days:e.days.slice(-30)}):null,/* @__PURE__ */ (0,X.jsxs)(mt,{children:[/* @__PURE__ */ (0,X.jsxs)(J,{label:`Total`,children:[i(t.totalCostUsd),/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`text-dashboard-text-muted`,children:[` `,`· `,t.totalRuns,` `,t.totalRuns===1?`run`:`runs`]})]}),/* @__PURE__ */ (0,X.jsx)(J,{label:`Last 30 days`,children:i(n)}),/* @__PURE__ */ (0,X.jsx)(J,{label:`Average per day`,children:i(n/30)}),/* @__PURE__ */ (0,X.jsx)(J,{label:`Average per run`,children:r>0?i(n/r):`—`})]})]})}function _n(e){let t=Math.max(0,...e.days.map(e=>e.costUsd));return/* @__PURE__ */ (0,X.jsx)(`div`,{"aria-label":`Daily cost, last ${e.days.length} days`,className:`flex h-10 items-end gap-0.5`,role:`img`,children:e.days.map(e=>/* @__PURE__ */ (0,X.jsx)(`span`,{className:e.costUsd>0?`block flex-1 rounded-[1px] bg-chart-1 opacity-80 hover:opacity-100`:`block h-0.5 flex-1 rounded-full bg-dashboard-fill-strong`,style:e.costUsd>0&&t>0?{height:`${Math.max(8,Math.round(e.costUsd/t*100))}%`}:void 0,title:`${hn.format(/* @__PURE__ */ new Date(`${e.date}T00:00:00.000Z`))} · ${De({total:e.costUsd})}`},e.date))})}function vn(e){let{automation:t}=e,n=Ue(!0,t.id),r=n.data?.executions[0];return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0 gap-6 lg:grid-cols-[minmax(0,1fr)_22rem] lg:gap-8`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0 content-start gap-4`,children:[/* @__PURE__ */ (0,X.jsx)(xt,{automation:t,editPath:e.editPath,lastRunError:r&&r.status!==`completed`?r.error:void 0}),/* @__PURE__ */ (0,X.jsx)(yn,{automation:t,query:n})]}),/* @__PURE__ */ (0,X.jsxs)(`aside`,{"aria-label":`Automation details`,className:`grid min-w-0 content-start gap-3`,children:[/* @__PURE__ */ (0,X.jsx)(Sn,{automation:t}),/* @__PURE__ */ (0,X.jsx)(gn,{automation:t,days:n.data?.executionDays}),/* @__PURE__ */ (0,X.jsx)(Cn,{automation:t})]})]})}function yn(e){let{automation:t,query:n}=e,r=d(),i=e=>{let n=new URLSearchParams(r.search);return n.set(`run`,e.executionId),B(z(t.id,`runs`),n)},a=n.data?.executions??[];return/* @__PURE__ */ (0,X.jsx)(`section`,{"aria-label":`Recent runs`,className:`min-w-0`,children:/* @__PURE__ */ (0,X.jsxs)(R,{children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 px-4 pt-4`,children:[/* @__PURE__ */ (0,X.jsx)(`h3`,{className:`m-0 text-xs font-medium text-dashboard-text-muted`,children:`Recent runs`}),a.length>0||t.totalRuns>0?/* @__PURE__ */ (0,X.jsx)(f,{className:`${he} text-xs`,to:B(z(t.id,`runs`),r.search),children:`View all runs`}):null]}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 px-4 pt-3 pb-4 sm:flex-row sm:items-end sm:justify-between sm:gap-6`,children:[n.isPending?/* @__PURE__ */ (0,X.jsx)(ge,{className:`h-16 w-full max-w-md rounded-md`}):/* @__PURE__ */ (0,X.jsx)(vt,{label:`Last ${Math.min(a.length,48)} runs`,runs:a.slice(0,48).reverse().map(e=>({...e,key:e.executionId,to:i(e)})),size:`default`,slots:48}),/* @__PURE__ */ (0,X.jsx)(xn,{automation:t})]}),n.error?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`px-4 pb-4`,children:/* @__PURE__ */ (0,X.jsxs)(tt,{children:[`Recent runs could not be loaded.`,` `,/* @__PURE__ */ (0,X.jsx)(h,{onClick:()=>void n.refetch(),children:`Try again`})]})}):null,n.data&&a.length===0?/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 border-t border-dashboard-border-subtle px-4 py-4 text-sm text-dashboard-text-muted`,children:t.totalRuns===0?`No runs yet. Results will appear here after the first run.`:`No recent runs are available. Older run details may have expired.`}):null,a.length>0?/* @__PURE__ */ (0,X.jsx)(`ol`,{className:`m-0 list-none border-t border-dashboard-border-subtle p-0`,children:a.slice(0,6).map(e=>/* @__PURE__ */ (0,X.jsx)(bn,{automation:t,run:e,to:i(e)},e.executionId))}):null]})})}function bn(e){let{run:t}=e,n=[t.durationMs===void 0?void 0:we(t.durationMs),t.costUsd===void 0?void 0:De({total:t.costUsd})].filter(Boolean).join(` · `),r=t.title&&t.title!==e.automation.title?t.title:void 0;return/* @__PURE__ */ (0,X.jsxs)(`li`,{className:`grid grid-cols-[minmax(0,1fr)_auto_2.25rem] items-center gap-x-4 border-t border-dashboard-border-subtle pl-4 first:border-t-0`,children:[/* @__PURE__ */ (0,X.jsxs)(f,{"aria-label":`Open ${t.status} run from ${w(t.executedAt)}`,className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-baseline gap-x-3 gap-y-1 py-2.5 text-xs text-inherit no-underline focus-visible:outline-2 focus-visible:outline-dashboard-focus sm:grid-cols-[auto_8rem_minmax(0,1fr)]`,to:e.to,children:[/* @__PURE__ */ (0,X.jsx)(ze,{className:`self-center`,label:t.status,tone:T(t.status)}),/* @__PURE__ */ (0,X.jsx)(`time`,{className:`truncate text-dashboard-text`,dateTime:t.executedAt,title:w(t.executedAt),children:Oe(t.executedAt)}),t.error?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`col-start-2 line-clamp-2 text-rose-300 sm:col-start-auto sm:truncate`,title:t.error,children:t.error}):t.status===`blocked`?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`col-start-2 truncate text-amber-300 sm:col-start-auto`,children:`Blocked`}):/* @__PURE__ */ (0,X.jsx)(`span`,{className:`col-start-2 truncate text-dashboard-text-muted sm:col-start-auto`,children:r})]}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`text-right text-xs tabular-nums text-dashboard-text-muted`,children:n}),t.conversationId?/* @__PURE__ */ (0,X.jsx)(f,{"aria-label":`Open conversation`,className:`grid size-9 place-items-center rounded-md text-dashboard-text-muted hover:bg-dashboard-fill-strong hover:text-dashboard-text focus-visible:outline-2 focus-visible:outline-dashboard-focus`,title:`Open conversation`,to:Ye(t.conversationId),children:/* @__PURE__ */ (0,X.jsx)(ee,{"aria-hidden":`true`,size:15})}):/* @__PURE__ */ (0,X.jsx)(`span`,{})]})}function xn({automation:e}){let t,n;return e.status===`paused`?(t=`Paused`,n=`No runs until resumed`):e.status===`completed`?(t=`Completed`,n=`No future runs`):e.status===`blocked`?(t=`Blocked`,n=`New runs wait for a fix`):e.kind===`scheduled`?(t=e.nextRunAt?`Next ${Oe(e.nextRunAt)}`:`No next run`,n=e.nextRunAt?w(e.nextRunAt,e.timezone):void 0):e.trigger.problems.length>0?(t=`Not listening`,n=`Trigger unavailable`):(t=`Listening`,n=e.trigger.events.join(`, `)),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0 shrink-0 gap-1 sm:justify-items-end sm:text-right`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`text-sm text-dashboard-text`,children:t}),n?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`max-w-56 truncate text-xs text-dashboard-text-muted`,children:n}):null]})}function Sn(e){let{automation:t}=e,n=t.ownedByViewer?`you`:t.createdBy,{task:r}=t,i=r.kind===`skill`?r.context:r.instruction;return/* @__PURE__ */ (0,X.jsxs)(gt,{title:`Definition`,children:[r.kind===`skill`?/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:[`Runs the`,` `,/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-mono text-dashboard-text`,children:r.skill}),` `,`skill`,r.context?` with this context:`:`.`]}):null,i?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`text-sm leading-relaxed text-dashboard-text [overflow-wrap:anywhere]`,children:/* @__PURE__ */ (0,X.jsx)(ct,{mentions:t.mentions??[],text:i})}):null,/* @__PURE__ */ (0,X.jsx)(`div`,{className:`border-t border-dashboard-border-subtle pt-2.5`,children:/* @__PURE__ */ (0,X.jsxs)(mt,{children:[t.kind===`scheduled`?/* @__PURE__ */ (0,X.jsx)(J,{label:`When`,children:re(t)}):/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(J,{label:`When`,children:t.trigger.events.join(`, `)}),/* @__PURE__ */ (0,X.jsx)(J,{label:`Resource`,children:t.resource}),t.trigger.filters.map(e=>/* @__PURE__ */ (0,X.jsx)(J,{label:`Filter`,children:e},e))]}),/* @__PURE__ */ (0,X.jsx)(J,{label:`Posts to`,children:t.outcomes.length?/* @__PURE__ */ (0,X.jsx)(an,{destination:t.destination,outcomes:t.outcomes}):t.destination.label}),/* @__PURE__ */ (0,X.jsx)(J,{label:`Accounts`,children:t.credentialMode===`creator`?`Connected by ${n}`:`Junior’s only`})]})})]})}function Cn({automation:e}){let t=d(),n=He(!0,e.id).data?.activeVersion,r=/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[/* @__PURE__ */ (0,X.jsx)(st,{imageUrl:e.createdByAvatarUrl,name:e.createdBy,size:`list`}),e.ownedByViewer?`You`:e.createdBy]});return/* @__PURE__ */ (0,X.jsxs)(gt,{title:`About`,children:[/* @__PURE__ */ (0,X.jsxs)(mt,{children:[/* @__PURE__ */ (0,X.jsx)(J,{label:`Created by`,children:e.createdByEmail?/* @__PURE__ */ (0,X.jsx)(f,{className:`text-inherit no-underline hover:underline`,to:Te(e.createdByEmail),children:r}):r}),/* @__PURE__ */ (0,X.jsx)(J,{label:`Created`,children:w(e.createdAt)}),/* @__PURE__ */ (0,X.jsx)(J,{label:`Version`,children:/* @__PURE__ */ (0,X.jsx)(f,{className:he,to:B(z(e.id,`versions`),t.search),children:n?`Version ${n}`:`History`})})]}),e.ownedByViewer?null:/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`m-0 text-xs leading-relaxed text-dashboard-text-muted`,children:[e.destination.visibility===`private`?null:`You can edit, pause, or delete it because it is in a public channel. `,`Only `,e.createdBy,` can turn on their connected accounts, or resume or run it while it uses them.`]})]})}const wn=[{color:`var(--color-emerald-300)`,key:`completed`,label:`Completed`},{color:`var(--color-rose-300)`,key:`failed`,label:`Failed`},{color:`var(--color-amber-300)`,key:`blocked`,label:`Blocked`}],Tn=Object.fromEntries(wn.map(e=>[e.key,{color:e.color,label:e.label}]));function En(e){let t=e.bucketUnit??`day`,n=e.days,r=n.map(e=>e.completed+e.failed+e.blocked),i=Math.max(1,...r),a=r.some(e=>e>0);return/* @__PURE__ */ (0,X.jsxs)(R,{className:`min-h-[15rem] p-4 sm:p-5`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{children:[/* @__PURE__ */ (0,X.jsx)(`h2`,{className:`m-0 font-display text-xl font-medium text-dashboard-text`,children:`Runs over time`}),/* @__PURE__ */ (0,X.jsx)(`p`,{className:`mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:t===`hour`?`Terminal runs for this automation each hour.`:t===`6hour`?`Terminal runs for this automation each 6 hours.`:`Terminal runs for this automation each day.`})]}),/* @__PURE__ */ (0,X.jsx)(Nt,{ariaLabel:`Automation execution status legend`,items:wn}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`relative mt-3 overflow-hidden`,children:[/* @__PURE__ */ (0,X.jsx)(At,{className:`aspect-auto h-55 w-full`,config:Tn,children:/* @__PURE__ */ (0,X.jsxs)(Mt,{"aria-label":`Automation executions during the last ${e.range===1?`24 hours`:`${e.range} days`}`,data:n,margin:Et,role:`img`,children:[/* @__PURE__ */ (0,X.jsx)(wt,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,X.jsx)(kt,{maximum:i}),/* @__PURE__ */ (0,X.jsx)(Ot,{keys:n.map(e=>e.date)}),/* @__PURE__ */ (0,X.jsx)(Dt,{content:/* @__PURE__ */ (0,X.jsx)(Tt,{rows:e=>[[`completed`,e.completed],[`failed`,e.failed],[`blocked`,e.blocked],[`total`,e.completed+e.failed+e.blocked]]})}),wn.map(e=>/* @__PURE__ */ (0,X.jsx)(jt,{dataKey:e.key,fill:`var(--color-${e.key})`,fillOpacity:.82,isAnimationActive:!1,maxBarSize:13,stackId:`status`},e.key))]})}),a?null:/* @__PURE__ */ (0,X.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 automation executions in this period.`})]})]})}const Dn=`result`,On=[``,`completed`,`failed`,`blocked`],kn=`grid-cols-[minmax(0,1fr)_5.5rem_5.5rem_5.5rem_auto_2rem]`;function An(e){let{automation:t}=e,n=Ue(!0,t.id),[r,i]=Me(Dn,``,On),a=(0,Y.useMemo)(()=>(n.data?.executions??[]).filter(e=>!r||e.status===r),[n.data,r]),o=(0,Y.useMemo)(()=>(n.data?.executions??[]).map(e=>({...e,automationId:t.id,automationTitle:t.title,kind:t.kind})),[t,n.data]),s=ft(a.map(e=>e.executionId));return/* @__PURE__ */ (0,X.jsxs)(pt,{details:s.runId?/* @__PURE__ */ (0,X.jsx)(_t,{loading:!n.data&&!n.error,onClose:s.close,run:o.find(e=>e.executionId===s.runId),showAutomation:!1},s.runId):null,label:`Runs list`,listRef:s.listRef,children:[e.header,n.data?/* @__PURE__ */ (0,X.jsx)(jn,{data:n.data,executions:a,onResultChange:i,onRowsKeyDown:s.onRowsKeyDown,onSelect:s.toggle,range:e.range,result:r,selectedRunId:s.runId}):n.error?/* @__PURE__ */ (0,X.jsxs)(tt,{children:[`Runs could not be loaded.`,` `,/* @__PURE__ */ (0,X.jsx)(h,{onClick:()=>void n.refetch(),children:`Try again`})]}):/* @__PURE__ */ (0,X.jsx)(_e,{label:`Loading runs`,variant:`list`})]})}function jn(e){let{data:t,range:n}=e,r=(0,Y.useMemo)(()=>Pn(t.executions),[t.executions]);return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[t.executionDays.length>0?/* @__PURE__ */ (0,X.jsx)(En,{bucketUnit:xe(n),days:be({days:t.executionDays,hours:t.executionHours,sixHours:t.executionSixHours,range:n,emptySixHour:e=>({blocked:0,completed:0,costUsd:0,date:e,failed:0})}),range:n}):null,/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-x-5 gap-y-3`,children:[/* @__PURE__ */ (0,X.jsx)(St,{ariaLabel:`Run result`,items:[{count:t.executions.length,label:`All`,value:``},{count:r.completed,label:`Completed`,value:`completed`},{count:r.failed,label:`Failed`,value:`failed`},{count:r.blocked,label:`Blocked`,value:`blocked`}],onChange:t=>e.onResultChange(t),value:e.result}),/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`m-0 text-xs text-dashboard-text-muted`,children:[t.automation.totalRuns,` total · newest first`]})]}),e.executions.length===0?/* @__PURE__ */ (0,X.jsx)(R,{padding:`md`,children:/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:t.executions.length===0?`This automation has not run yet.`:`No ${e.result} runs in the loaded history.`})}):/* @__PURE__ */ (0,X.jsx)(R,{children:/* @__PURE__ */ (0,X.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`min-w-[36rem]`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{"aria-hidden":`true`,className:L(`sticky top-0 z-[1] hidden items-center gap-4 border-b border-dashboard-border-subtle bg-dashboard-overlay-soft px-4 py-2.5 font-sans font-medium text-xs text-dashboard-text-muted md:grid`,kn),children:[/* @__PURE__ */ (0,X.jsx)(`div`,{children:`Run`}),/* @__PURE__ */ (0,X.jsx)(`div`,{children:`Duration`}),/* @__PURE__ */ (0,X.jsx)(`div`,{children:`Tokens`}),/* @__PURE__ */ (0,X.jsx)(`div`,{children:`Cost`})]}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`min-w-0`,onKeyDown:e.onRowsKeyDown,role:`list`,children:e.executions.map(n=>/* @__PURE__ */ (0,X.jsx)(Mn,{execution:n,fallbackTitle:t.automation.title,onSelect:()=>e.onSelect(n.executionId),selected:e.selectedRunId===n.executionId},n.executionId))})]})})}),t.truncated?/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 text-center text-xs text-dashboard-text-muted`,children:`Showing the 100 most recent runs.`}):null]})}function Mn(e){let{execution:t}=e,n=De(t.costUsd===void 0?void 0:{total:t.costUsd})||`—`,r=we(t.durationMs)||`—`,i=t.totalTokens===void 0?`—`:Ee(t.totalTokens),a=T(t.status);return/* @__PURE__ */ (0,X.jsx)(`div`,{className:`border-b border-dashboard-border-subtle last:border-b-0`,"data-run-id":t.executionId,role:`listitem`,children:/* @__PURE__ */ (0,X.jsxs)(Ct,{className:L(`grid min-w-0 items-center gap-4 overflow-hidden px-4 py-3 max-md:grid-cols-1 max-md:gap-y-2 max-md:py-3.5`,kn),onSelect:e.onSelect,selected:e.selected,children:[/* @__PURE__ */ (0,X.jsxs)(`button`,{"aria-expanded":e.selected,className:`block min-w-0 cursor-pointer rounded-md border-0 bg-transparent p-0 text-left focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus`,onClick:e.onSelect,type:`button`,children:[/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 overflow-hidden`,children:[/* @__PURE__ */ (0,X.jsx)(ze,{className:`md:hidden`,label:t.status,tone:a}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium leading-snug text-dashboard-text`,children:ne(t,e.fallbackTitle)})]}),/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`mt-1 block truncate text-xs leading-relaxed text-dashboard-text-muted`,children:[w(t.executedAt),t.automationVersion?` · Version ${t.automationVersion}`:null]}),t.error?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`mt-1 block truncate text-xs leading-relaxed text-rose-300`,title:t.error,children:t.error}):null]}),/* @__PURE__ */ (0,X.jsx)(Nn,{label:`Duration`,value:r}),/* @__PURE__ */ (0,X.jsx)(Nn,{label:`Tokens`,value:i}),/* @__PURE__ */ (0,X.jsx)(Nn,{label:`Cost`,value:n}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`hidden justify-self-center md:block`,children:/* @__PURE__ */ (0,X.jsx)(ze,{label:t.status,tone:a})}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`max-md:hidden`,children:/* @__PURE__ */ (0,X.jsx)(ht,{conversationId:t.conversationId})})]})})}function Nn(e){return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`min-w-0 max-md:flex max-md:items-center max-md:gap-2`,children:[/* @__PURE__ */ (0,X.jsx)(`div`,{"aria-hidden":`true`,className:`mb-1 hidden font-sans font-medium text-2xs text-dashboard-text-muted max-md:mb-0 max-md:block`,children:e.label}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`truncate whitespace-nowrap font-mono text-xs text-dashboard-text-muted md:text-sm md:text-dashboard-text`,children:[/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`sr-only`,children:[e.label,`: `]}),e.value]})]})}function Pn(e){return e.reduce((e,t)=>(e[t.status]+=1,e),{blocked:0,completed:0,failed:0})}const Fn=`version`;function In(e){let t=He(!0,e.automation.id);return t.error?/* @__PURE__ */ (0,X.jsxs)(tt,{children:[`Version history could not be loaded.`,` `,/* @__PURE__ */ (0,X.jsx)(h,{onClick:()=>void t.refetch(),children:`Try again`})]}):t.data?/* @__PURE__ */ (0,X.jsx)(Ln,{automation:e.automation,data:t.data}):/* @__PURE__ */ (0,X.jsx)(_e,{label:`Loading version history`,variant:`list`})}function Ln(e){let{automation:r,data:i}=e,[a,o]=p(),s=n(),[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(!1),f=r.status!==`completed`,m=Number(a.get(Fn)),g=Math.max(0,i.versions.findIndex(e=>e.version===m)),_=i.versions[g],v=i.versions[g+1],y=e=>o(t=>{let n=new URLSearchParams(t);return n.set(Fn,String(e)),n},{replace:!0}),ee=`/api/automations/${encodeURIComponent(r.id)}`,b=t({mutationFn:async e=>{let t=await F(A,`${ee}/edit`);return pe(A,`${ee}/versions/${e}/activate`,{revision:t.revision})},onMutate:()=>l(void 0),onSuccess:async(e,t)=>{l(t),await s.invalidateQueries({queryKey:[`dashboard`,`automations`]})}});if(!_)return/* @__PURE__ */ (0,X.jsx)(R,{padding:`md`,children:/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:`No versions are saved yet. Junior saves a version each time the settings change.`})});let x=_.version===i.activeVersion;return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 max-w-2xl text-sm leading-relaxed text-dashboard-text-muted`,children:f?`Each save creates a version. Making a version active saves its settings as a new version. It does not run the automation.`:`This automation has completed. Its versions are read-only.`}),c===void 0?null:/* @__PURE__ */ (0,X.jsxs)(`p`,{role:`status`,className:`m-0 text-sm text-emerald-300`,children:[`Version `,c,` is active again. It was saved as a new version.`]}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid min-w-0 gap-4 lg:grid-cols-[17rem_minmax(0,1fr)] lg:gap-6`,children:[/* @__PURE__ */ (0,X.jsxs)(`nav`,{"aria-label":`Versions`,className:`min-w-0`,children:[/* @__PURE__ */ (0,X.jsx)(`ol`,{className:`m-0 grid list-none gap-1 p-0 max-lg:max-h-64 max-lg:overflow-y-auto`,children:i.versions.map((e,t)=>/* @__PURE__ */ (0,X.jsx)(`li`,{children:/* @__PURE__ */ (0,X.jsx)(Rn,{active:e.version===i.activeVersion,changes:Gn(e,i.versions[t+1],i.truncated),onSelect:()=>y(e.version),selected:e.version===_.version,version:e})},e.version))}),i.truncated?/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 mt-2 px-3 text-xs text-dashboard-text-muted`,children:`Showing the 100 most recent versions.`}):null]}),/* @__PURE__ */ (0,X.jsxs)(R,{as:`section`,className:`min-w-0`,padding:`none`,variant:`default`,children:[/* @__PURE__ */ (0,X.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-dashboard-border-subtle px-4 py-4 sm:px-5`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[/* @__PURE__ */ (0,X.jsxs)(`h2`,{className:`m-0 font-display text-lg font-medium`,children:[`Version `,_.version]}),x?/* @__PURE__ */ (0,X.jsx)(lt,{size:`compact`,tone:`success`,children:`Active`}):null]}),/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`mt-1 mb-0 text-xs text-dashboard-text-muted`,children:[Wn(_),` ·`,` `,w(_.createdAt),v?` · Compared with version ${v.version}`:``]})]}),f&&!x?/* @__PURE__ */ (0,X.jsx)(h,{"aria-label":`Make version ${_.version} active`,disabled:b.isPending,onClick:()=>d(!0),children:b.isPending&&b.variables===_.version?`Saving…`:`Make active`}):null]}),b.error&&b.variables===_.version?/* @__PURE__ */ (0,X.jsx)(`div`,{className:`px-4 pt-4 sm:px-5`,children:/* @__PURE__ */ (0,X.jsx)(K,{tone:`error`,title:`This version could not be made active.`,children:b.error instanceof I?b.error.code===`conflict`?`The automation changed. Try again.`:b.error.apiError??`Try again.`:`Try again.`})}):null,/* @__PURE__ */ (0,X.jsx)(Bn,{automation:r,previous:v,version:_})]})]}),/* @__PURE__ */ (0,X.jsx)(Qe,{onOpenChange:d,open:u,children:/* @__PURE__ */ (0,X.jsxs)(Je,{children:[/* @__PURE__ */ (0,X.jsxs)(rt,{children:[`Make version `,_.version,` active?`]}),/* @__PURE__ */ (0,X.jsxs)(at,{children:[`Junior saves these settings as a new version. Future runs use them.`,r.ownedByViewer?null:` Only ${r.createdBy} can turn on their connected accounts.`]}),/* @__PURE__ */ (0,X.jsxs)(Pe,{children:[/* @__PURE__ */ (0,X.jsx)(Ie,{children:`Cancel`}),/* @__PURE__ */ (0,X.jsx)(Le,{onClick:()=>{b.mutate(_.version),d(!1)},variant:`primary`,children:`Make active`})]})]})})]})}function Rn(e){let{version:t}=e;return/* @__PURE__ */ (0,X.jsxs)(`button`,{"aria-current":e.selected?`true`:void 0,className:L(`grid w-full min-w-0 cursor-pointer gap-0.5 rounded-md border-0 px-3 py-2.5 text-left transition-colors focus-visible:outline-2 focus-visible:outline-dashboard-focus`,e.selected?`bg-dashboard-accent/[0.08] text-dashboard-text`:`bg-transparent text-dashboard-text hover:bg-dashboard-fill-soft`),onClick:e.onSelect,type:`button`,children:[/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium`,children:[`Version `,t.version,e.active?/* @__PURE__ */ (0,X.jsx)(lt,{size:`compact`,tone:`success`,children:`Active`}):null]}),/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`truncate text-xs text-dashboard-text-muted`,children:[Wn(t),` ·`,` `,/* @__PURE__ */ (0,X.jsx)(`time`,{dateTime:t.createdAt,children:Oe(t.createdAt)})]}),e.changes?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`truncate text-xs text-dashboard-text-muted`,children:e.changes}):null]})}const zn=[{key:`title`,label:`Title`},{key:`skill`,label:`Skill`},{key:`instruction`,label:`What to do`},{key:`when`,label:`When to run`},{key:`destination`,label:`Destination`},{key:`outcomes`,label:`Where results go`},{key:`credentialMode`,label:`Credentials`}];function Bn(e){let{automation:t,previous:n,version:r}=e,i=n?Kn(n,r):[];return/* @__PURE__ */ (0,X.jsx)(`dl`,{className:`m-0 divide-y divide-dashboard-border-subtle`,children:zn.map(({key:e,label:a})=>{let o=i.includes(e);return/* @__PURE__ */ (0,X.jsxs)(`div`,{className:L(`grid min-w-0 gap-2 px-4 py-4 sm:grid-cols-[9rem_minmax(0,1fr)] sm:gap-6 sm:px-5`,o&&`shadow-[inset_2px_0_0_var(--color-dashboard-accent)]`),children:[/* @__PURE__ */ (0,X.jsxs)(`dt`,{className:`text-xs font-medium text-dashboard-text-muted`,children:[a,o?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`mt-1 block font-normal text-dashboard-accent-text`,children:`Changed`}):null]}),/* @__PURE__ */ (0,X.jsx)(`dd`,{className:`m-0 min-w-0 text-sm leading-relaxed break-words`,children:o&&n&&e===`instruction`?/* @__PURE__ */ (0,X.jsx)(Hn,{after:$(r.definition.task).instruction,before:$(n.definition.task).instruction}):o&&n?/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`grid gap-2`,children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`text-dashboard-text-muted line-through decoration-dashboard-text-muted/50`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`sr-only`,children:`Before: `}),Vn(e,t,n)]}),/* @__PURE__ */ (0,X.jsxs)(`div`,{children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`sr-only`,children:`After: `}),Vn(e,t,r)]})]}):Vn(e,t,r)})]},e)})})}function Vn(e,t,n){let{definition:r}=n,i=$(r.task);switch(e){case`title`:return r.title??`First line of the instruction`;case`skill`:return i.skill?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`font-mono`,children:i.skill}):`No skill`;case`instruction`:return i.instruction?/* @__PURE__ */ (0,X.jsx)(ct,{mentions:t.mentions,text:i.instruction}):`No context`;case`when`:if(n.kind===`scheduled`){let{description:e,timezone:t}=n.definition.schedule;return e.includes(t)?e:`${e} (${t})`}return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[n.definition.trigger.label,n.definition.trigger.identifier?` · ${n.definition.trigger.identifier}`:null,/* @__PURE__ */ (0,X.jsx)(`br`,{}),n.trigger.events.join(`, `),/* @__PURE__ */ (0,X.jsx)($t,{filters:n.trigger.filters})]});case`destination`:return r.destination.channelId===t.destination.channelId&&r.destination.teamId===t.destination.teamId?t.destination.label:`Another destination · ${r.destination.channelId}`;case`outcomes`:return r.outcomes.length?/* @__PURE__ */ (0,X.jsx)(`ol`,{className:`m-0 grid list-decimal gap-1 pl-5`,children:r.outcomes.map((e,n)=>/* @__PURE__ */ (0,X.jsx)(`li`,{children:Lt(e,t.destination)},n))}):`No message on success`;case`credentialMode`:return r.credentialMode===`creator`?`Uses accounts connected by ${t.ownedByViewer?`you`:t.createdBy}.`:`System credentials only`}}function Hn(e){return/* @__PURE__ */ (0,X.jsx)(`div`,{className:`grid overflow-hidden rounded-md border border-dashboard-border-subtle font-mono text-xs leading-relaxed`,children:Un(e.before,e.after).map((e,t)=>/* @__PURE__ */ (0,X.jsxs)(`div`,{className:L(`grid grid-cols-[1.5rem_minmax(0,1fr)] whitespace-pre-wrap px-2 py-0.5`,e.kind===`added`&&`bg-emerald-500/10 text-emerald-200`,e.kind===`removed`&&`bg-rose-500/10 text-rose-200`),children:[/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,className:`select-none opacity-60`,children:e.kind===`added`?`+`:e.kind===`removed`?`−`:``}),/* @__PURE__ */ (0,X.jsxs)(`span`,{children:[e.kind===`same`?null:/* @__PURE__ */ (0,X.jsx)(`span`,{className:`sr-only`,children:e.kind===`added`?`Added: `:`Removed: `}),e.value||` `]})]},t))})}function Un(e,t){let n=e.split(`
|
|
9
|
-
`),r=t.split(`
|
|
10
|
-
`),i=Array.from({length:n.length+1},()=>Array.from({length:r.length+1},()=>0));for(let e=n.length-1;e>=0;e--)for(let t=r.length-1;t>=0;t--)i[e][t]=n[e]===r[t]?i[e+1][t+1]+1:Math.max(i[e+1][t],i[e][t+1]);let a=[],o=0,s=0;for(;o<n.length&&s<r.length;)n[o]===r[s]?(a.push({kind:`same`,value:n[o]}),o++,s++):i[o+1][s]>=i[o][s+1]?a.push({kind:`removed`,value:n[o++]}):a.push({kind:`added`,value:r[s++]});for(;o<n.length;)a.push({kind:`removed`,value:n[o++]});for(;s<r.length;)a.push({kind:`added`,value:r[s++]});return a}function Wn(e){return e.editedBy?e.editedBy.fullName??e.editedBy.userName??e.editedBy.slackUserId:`Editor unknown`}function Gn(e,t,n){if(!t)return e.version===1||!n?`First saved version`:void 0;let r=Kn(t,e);return r.length===0?`No setting changes`:`Changed ${zn.filter(({key:e})=>r.includes(e)).map(({label:e})=>e.toLowerCase()).join(`, `)}`}function Kn(e,t){let n={...e.definition,...$(e.definition.task)},r={...t.definition,...$(t.definition.task)},i=e=>JSON.stringify(n[e])!==JSON.stringify(r[e]);return zn.flatMap(({key:e})=>(e===`when`?i(`schedule`)||i(`trigger`):i(e))?[e]:[])}function $(e){return e.kind===`skill`?{skill:e.skill,instruction:e.context??``}:{instruction:e.instruction}}const qn=[`1`,`7`,`30`,`90`],Jn=[Dn,`run`,Fn],Yn={edit:`Edit`,overview:`Overview`,runs:`Runs`,versions:`Versions`};function Xn(e){let{automationId:t}=o(),n=d(),r=Ve(e.enabled,t),[i,a]=Me(`range`,`30`,qn),c=Number(i);if(!t)return/* @__PURE__ */ (0,X.jsx)(s,{replace:!0,to:`/automations`});let l=new URLSearchParams(n.search);for(let e of Jn)l.delete(e);let f=B(`/automations`,l),p=r.data,m=[`overview`,`runs`,`versions`].map(e=>({label:Yn[e],to:z(t,e),isActive:t=>e===`overview`?!!(u(`/automations/:automationId`,t)||u(`/automations/:automationId/edit`,t)):!!u(`/automations/:automationId/${e}`,t)})),g=e.tab===`runs`&&!!p;return/* @__PURE__ */ (0,X.jsx)(ke,{ariaLabel:`Automation navigation`,className:g?`grid h-full min-h-0 grid-rows-[auto_minmax(0,1fr)] md:grid-rows-[minmax(0,1fr)]`:void 0,items:m,children:p?/* @__PURE__ */ (0,X.jsx)(Zn,{automation:p,listPath:f,onRangeChange:e=>a(String(e)),range:c,tab:e.tab}):/* @__PURE__ */ (0,X.jsxs)(Ae,{children:[/* @__PURE__ */ (0,X.jsx)(er,{to:f}),/* @__PURE__ */ (0,X.jsx)(Se,{description:`Settings, runs, and versions for one automation.`,title:`Automation`}),r.error?/* @__PURE__ */ (0,X.jsxs)(K,{tone:`error`,title:`Automation could not be loaded.`,children:[r.error instanceof I&&r.error.status===404?`This automation was not found or is not visible to you.`:`Try again.`,` `,/* @__PURE__ */ (0,X.jsx)(h,{onClick:()=>void r.refetch(),children:`Try again`})]}):/* @__PURE__ */ (0,X.jsx)(_e,{label:`Loading automation`,variant:`list`})]})})}function Zn(e){let{automation:t,tab:n}=e,r=d(),i=l(),[a,o]=(0,Y.useState)(!1),c=(0,Y.useRef)(null),u=t.status===`completed`;if(n===`edit`&&u)return/* @__PURE__ */ (0,X.jsx)(s,{replace:!0,to:B(z(t.id),r.search)});let f=B(z(t.id,`edit`),r.search),p=/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(er,{to:e.listPath}),/* @__PURE__ */ (0,X.jsx)(Se,{actions:n===`edit`?void 0:/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2 md:justify-end`,children:[n===`runs`?/* @__PURE__ */ (0,X.jsx)(ye,{onChange:e.onRangeChange,value:e.range}):null,/* @__PURE__ */ (0,X.jsx)(Ft,{automation:t,editPath:f,editVariant:n===`overview`&&bt(t)?`default`:`primary`,onDelete:e=>{c.current=e,o(!0)}})]}),description:/* @__PURE__ */ (0,X.jsx)($n,{automation:t}),documentTitle:n===`overview`?t.title:`${t.title} · ${Yn[n]}`,title:t.title})]}),m=a?/* @__PURE__ */ (0,X.jsx)(It,{automation:t,onClose:()=>o(!1),onDeleted:()=>{c.current=null,i(e.listPath)},returnFocus:()=>c.current?.isConnected?c.current:!1}):null;return n===`runs`?/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsx)(An,{automation:t,header:p,range:e.range}),m]}):/* @__PURE__ */ (0,X.jsxs)(Ae,{children:[p,n===`overview`?/* @__PURE__ */ (0,X.jsx)(vn,{automation:t,editPath:f}):null,n===`edit`?/* @__PURE__ */ (0,X.jsx)(Qn,{automation:t}):null,n===`versions`?/* @__PURE__ */ (0,X.jsx)(In,{automation:t}):null,m]})}function Qn(e){let{automation:t}=e,n=d(),i=r({queryKey:[`dashboard`,`automations`,`edit`,t.id],retry:!1,queryFn:({signal:e})=>F(A,`/api/automations/${encodeURIComponent(t.id)}/edit`,e)});return i.error&&!i.data?/* @__PURE__ */ (0,X.jsxs)(K,{tone:`error`,title:`Automation could not be loaded.`,children:[`It may no longer be available, or you may not have access.`,` `,/* @__PURE__ */ (0,X.jsx)(h,{onClick:()=>void i.refetch(),children:`Try again`})]}):i.data?/* @__PURE__ */ (0,X.jsx)(fn,{automation:i.data,summary:t,returnPath:B(z(t.id),n.search)},t.id):/* @__PURE__ */ (0,X.jsx)(mn,{})}function $n(e){let{automation:t}=e,n=[t.kind===`scheduled`?t.schedule:M(t.resource,t.trigger),t.destination.label,`Created by ${t.ownedByViewer?`you`:t.createdBy}`];return/* @__PURE__ */ (0,X.jsx)(`span`,{className:`block min-w-0 overflow-hidden`,children:/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`-ml-4 flex min-w-0 flex-wrap items-center gap-y-1`,children:[/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`flex items-center`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block w-4`}),/* @__PURE__ */ (0,X.jsx)(yt,{automation:t})]}),n.map((e,t)=>/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`min-w-0 break-words`,children:[/* @__PURE__ */ (0,X.jsx)(`span`,{"aria-hidden":`true`,className:L(`inline-block w-4 text-center opacity-45`,t===0&&`invisible`),children:`·`}),e]},t))]})})}function er(e){return/* @__PURE__ */ (0,X.jsxs)(f,{"aria-label":`Back to automations`,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:e.to,children:[/* @__PURE__ */ (0,X.jsx)(S,{"aria-hidden":`true`,size:15,strokeWidth:1.8}),`Automations`]})}export{Xn as AutomationPage};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n,h as r,p as i,r as a,y as o}from"./vendor-react-ggbyvons.js";import{t as s}from"./button-ygjnb239.js";import{J as c,Pt as l,Qt as u,n as d,t as f}from"./vendor-icons-mxz7yi04.js";import{a as p,i as m,r as h}from"./automationFormat-hd7pnocr.js";import{Lt as g,nt as _}from"./junior-hdb4wc4q.js";import{t as v}from"./styles-j0007fov.js";import{t as y}from"./Card-hy4bfgq7.js";import{t as b}from"./PageContentSkeleton-b7dkba0l.js";import{d as x,t as S,u as C}from"./PageHeader-bhl3orzi.js";import{n as w,y as T}from"./format-gle1s0ri.js";import{n as E,t as ee}from"./searchParams-moqjgi65.js";import{B as te,Ft as ne,Mt as D,Pt as O,W as k,Yt as A,jt as j,nt as M,ot as N,rt as P,st as F,tt as I,yt as L}from"../client-f7asutg5.js";import{t as R}from"./native-select-jfknh8t4.js";import{a as z,i as B,r as V}from"./AutomationStatus-czfg6ayl.js";import{n as H}from"./FilterBar-mtnh7fbi.js";import{t as re}from"./SelectableRow-j8fwjsjz.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 U=u(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]);var W=/* @__PURE__ */ e(t(),1),G=n();const K=[{value:`active`,label:`Active`},{value:`blocked`,label:`Blocked`},{value:`paused`,label:`Paused`},{value:`unavailable`,label:`Trigger unavailable`},{value:`completed`,label:`Completed`}];function q(e){let t=window.matchMedia(L);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function J(){return window.matchMedia(L).matches}function Y(e){let{filters:t,data:n,onChange:r}=e,[i,a]=(0,W.useState)(!1),o=(0,W.useSyncExternalStore)(q,J,()=>!1),c=[{key:`type`,label:`Type`,value:t.type===`all`?``:t.type,valueLabel:t.type===`scheduled`?`Scheduled`:`Event`},{key:`creator`,label:`Creator`,value:t.creator,valueLabel:n?.creators.find(e=>e.value===t.creator)?.label??t.creator},{key:`destination`,label:`Destination`,value:t.destination,valueLabel:n?.destinations.find(e=>e.value===t.destination)?.label??t.destination},{key:`state`,label:`State`,value:t.state===`all`?``:t.state,valueLabel:K.find(e=>e.value===t.state)?.label}].filter(e=>e.value),l=/* @__PURE__ */ (0,G.jsxs)(s,{className:`h-11 shrink-0`,"aria-expanded":i,"aria-haspopup":`dialog`,onClick:o?void 0:()=>a(!0),children:[/* @__PURE__ */ (0,G.jsx)(U,{"aria-hidden":`true`,size:14}),` Filters`,c.length?` (${c.length})`:``]}),u=/* @__PURE__ */ (0,G.jsx)(X,{filters:t,data:n,onChange:r});return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid gap-3`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[/* @__PURE__ */ (0,G.jsx)(F,{className:`flex-1`,size:`default`,label:`Search automations`,placeholder:`Search automations`,value:e.searchText,onChange:e.onSearch}),o?/* @__PURE__ */ (0,G.jsxs)(j,{open:i,onOpenChange:a,children:[/* @__PURE__ */ (0,G.jsx)(ne,{render:l}),/* @__PURE__ */ (0,G.jsxs)(D,{align:`end`,className:`w-80`,children:[/* @__PURE__ */ (0,G.jsx)(O,{children:`Filters`}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-4`,children:u})]})]}):l]}),c.length>0?/* @__PURE__ */ (0,G.jsx)(`div`,{"aria-label":`Active filters`,role:`group`,className:`flex min-w-0 flex-wrap gap-2`,children:c.map(e=>/* @__PURE__ */ (0,G.jsxs)(s,{"aria-label":`Remove ${e.key} filter`,className:`min-h-9 max-w-full text-xs`,title:`${e.label}: ${e.valueLabel}`,onClick:()=>r(e.key,``),children:[/* @__PURE__ */ (0,G.jsxs)(`span`,{className:`truncate`,children:[e.label,`: `,e.valueLabel]}),/* @__PURE__ */ (0,G.jsx)(d,{"aria-hidden":`true`,className:`shrink-0`,size:12})]},e.key))}):null,!o&&i?/* @__PURE__ */ (0,G.jsx)(te,{label:`Filters`,size:`content`,onClose:()=>a(!1),children:/* @__PURE__ */ (0,G.jsx)(`div`,{className:`p-4 pb-[max(1rem,env(safe-area-inset-bottom))]`,children:u})}):null]})}function X({filters:e,data:t,onChange:n}){return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid gap-4`,children:[/* @__PURE__ */ (0,G.jsx)(H,{label:`Type`,children:/* @__PURE__ */ (0,G.jsx)(C,{className:`flex-wrap gap-2`,onValueChange:([e])=>{e&&n(`type`,e)},value:[e.type],children:[`all`,`scheduled`,`event`].map(e=>/* @__PURE__ */ (0,G.jsx)(x,{className:`min-h-9`,value:e,variant:`pill`,children:e},e))})}),/* @__PURE__ */ (0,G.jsx)(Z,{label:`Creator`,emptyLabel:`All`,value:e.creator??``,options:t?.creators??[],onChange:e=>n(`creator`,e)}),/* @__PURE__ */ (0,G.jsx)(Z,{label:`Destination`,emptyLabel:`All`,value:e.destination??``,options:t?.destinations??[],onChange:e=>n(`destination`,e)}),/* @__PURE__ */ (0,G.jsx)(Z,{label:`State`,emptyLabel:`All`,value:e.state===`all`?``:e.state,options:K,onChange:e=>n(`state`,e)})]})}function Z(e){return/* @__PURE__ */ (0,G.jsx)(H,{label:e.label,children:/* @__PURE__ */ (0,G.jsxs)(R,{"aria-label":e.ariaLabel??`Filter by ${e.label.toLowerCase()}`,variant:`filter`,value:e.value,onChange:t=>e.onChange(t.currentTarget.value),children:[e.emptyLabel?/* @__PURE__ */ (0,G.jsx)(`option`,{value:``,children:e.emptyLabel}):null,e.value&&!e.options.some(t=>t.value===e.value)?/* @__PURE__ */ (0,G.jsx)(`option`,{value:e.value,children:e.value}):null,e.options.map(e=>/* @__PURE__ */ (0,G.jsx)(`option`,{value:e.value,children:e.label},e.value))]})})}function ie(e){let{automation:t}=e,n=B(t),r=t.status===`paused`||t.status===`completed`;return/* @__PURE__ */ (0,G.jsx)(`div`,{className:`border-t border-dashboard-border-subtle first:border-t-0`,"data-automation-id":t.id,role:`listitem`,children:/* @__PURE__ */ (0,G.jsxs)(re,{className:v(`grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-6 md:grid-cols-[minmax(0,1fr)_9rem_6rem_8.5rem]`,`px-4 py-3`),onSelect:e.onSelect,selected:!1,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:v(`min-w-0`,r&&`opacity-60`),children:[/* @__PURE__ */ (0,G.jsx)(a,{"aria-label":`Open automation: ${t.title}`,className:`block min-w-0 truncate rounded-md font-display text-base font-medium text-dashboard-text no-underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus`,title:t.title,to:e.to,children:t.title}),/* @__PURE__ */ (0,G.jsx)(ae,{automation:t}),n?/* @__PURE__ */ (0,G.jsxs)(`p`,{className:v(`m-0 mt-1.5 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs md:flex-nowrap`,n.tone===`danger`?`text-rose-300`:`text-amber-300`),children:[/* @__PURE__ */ (0,G.jsx)(`span`,{className:`min-w-0 md:truncate`,title:n.message,children:/* @__PURE__ */ (0,G.jsx)(`span`,{className:`first-letter:uppercase`,children:n.message})}),/* @__PURE__ */ (0,G.jsx)(a,{className:`shrink-0 font-medium text-dashboard-text underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-dashboard-focus`,to:n.action.to,children:n.action.label})]}):null]}),/* @__PURE__ */ (0,G.jsxs)(`span`,{className:`hidden min-w-0 items-center gap-2 text-xs text-dashboard-text-muted md:flex`,title:t.createdBy,children:[/* @__PURE__ */ (0,G.jsx)(N,{imageUrl:t.createdByAvatarUrl,name:t.createdBy,size:`list`}),/* @__PURE__ */ (0,G.jsx)(`span`,{className:`truncate`,children:t.ownedByViewer?`You`:t.createdBy})]}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`hidden md:block`,children:/* @__PURE__ */ (0,G.jsx)(z,{label:`Recent runs of ${t.title}`,runs:(t.recentRuns??[]).map((e,t)=>({...e,key:`${e.executedAt}:${t}`})),slots:20})}),/* @__PURE__ */ (0,G.jsx)(oe,{automation:t})]})})}function ae({automation:e}){let t=e.kind===`scheduled`,n=t?p:f,r=e.kind===`scheduled`?e.schedule:g(e.resource,e.trigger);return/* @__PURE__ */ (0,G.jsxs)(`span`,{className:`mt-1 flex min-w-0 items-center gap-1.5 text-xs text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,G.jsx)(n,{"aria-label":t?`Scheduled automation`:`${e.source} event automation`,className:`shrink-0`,role:`img`,size:13}),/* @__PURE__ */ (0,G.jsx)(`span`,{className:`min-w-0 truncate`,title:e.kind===`scheduled`?h(e):r,children:r}),/* @__PURE__ */ (0,G.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-45`,children:`·`}),e.destination.visibility===`private`?/* @__PURE__ */ (0,G.jsx)(c,{"aria-label":`Private destination`,className:`shrink-0`,role:`img`,size:12}):null,/* @__PURE__ */ (0,G.jsx)(`span`,{className:`min-w-0 max-w-[45%] shrink-0 truncate`,title:e.destination.label,children:e.destination.label})]})}function oe({automation:e}){let t=e.status===`paused`?{label:`Paused`}:e.status===`completed`?{label:`No future runs`}:e.status===`blocked`?{label:`Blocked`}:e.kind===`scheduled`?e.nextRunAt?{label:`Next ${T(e.nextRunAt)}`,title:m(e.nextRunAt,e.timezone)}:{label:`No next run`}:e.trigger.problems.length>0?{label:`Not listening`}:{label:`Listening`};return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid min-w-0 justify-items-end gap-1 text-right text-xs`,children:[/* @__PURE__ */ (0,G.jsx)(`span`,{className:`text-dashboard-text`,title:t.title,children:t.label}),/* @__PURE__ */ (0,G.jsx)(`span`,{className:`text-dashboard-text-muted`,title:e.lastRunAt?m(e.lastRunAt):void 0,children:e.lastRunAt?`Ran ${T(e.lastRunAt)}`:`Never run`})]})}const se=[],Q=[`q`,`type`,`state`,`creator`,`destination`];function ce(e){let t=r(),n=i(),[a,c]=o(),[l,u]=E(`q`),d=_.parse(Object.fromEntries(Q.flatMap(e=>{let t=_.shape[e].safeParse(a.get(e)??void 0);return t.success&&t.data!==void 0?[[e,t.data]]:[]}))),f=new URLSearchParams(Object.entries({...d,pageSize:`100`}).map(([e,t])=>[e,String(t)])),p=A(e.enabled,f.toString()),m=(e,t)=>{let n=new URLSearchParams(window.location.search);t?n.set(e,t):n.delete(e),c(n,{replace:!0})},h=p.data?.automations??se,g=le(h),v=!p.data&&!p.error,x=e=>ee(w(e),n.search);return/* @__PURE__ */ (0,G.jsxs)(G.Fragment,{children:[/* @__PURE__ */ (0,G.jsx)(S,{title:`Automations`}),/* @__PURE__ */ (0,G.jsx)(Y,{data:p.data,filters:d,onChange:m,onSearch:u,searchText:l}),v?/* @__PURE__ */ (0,G.jsx)(b,{label:`Loading automations`,variant:`list`}):null,p.error?/* @__PURE__ */ (0,G.jsxs)(k,{children:[`Automations could not be loaded.`,` `,/* @__PURE__ */ (0,G.jsx)(s,{onClick:()=>void p.refetch(),children:`Try again`})]}):null,p.data&&h.length===0?/* @__PURE__ */ (0,G.jsx)(y,{padding:`md`,children:/* @__PURE__ */ (0,G.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:Q.some(e=>a.has(e))?`No automations matched these filters.`:`No automations yet. Ask Junior in Slack to do something on a schedule or when something happens.`})}):null,p.isFetching&&p.data?/* @__PURE__ */ (0,G.jsx)(`span`,{className:`sr-only`,role:`status`,children:`Updating results…`}):null,g.map(e=>/* @__PURE__ */ (0,G.jsx)(ue,{group:e,onSelect:e=>t(x(e)),pagePath:x},e.key)),p.data&&p.data.total>h.length?/* @__PURE__ */ (0,G.jsxs)(`p`,{className:`m-0 text-xs text-dashboard-text-muted`,children:[`Showing `,h.length,` of `,p.data.total,`. Search or filter to find the rest.`]}):null]})}function le(e){let t=e.filter(e=>e.status!==`completed`&&V(e)),n=e.filter(e=>!t.includes(e));return[{automations:t,key:`attention`,label:`Needs attention`},{automations:n.filter(e=>e.status===`active`).sort($),key:`active`,label:`Active`},{automations:n.filter(e=>e.status===`paused`),collapsed:!0,key:`paused`,label:`Paused`},{automations:n.filter(e=>e.status===`completed`),collapsed:!0,key:`completed`,label:`Completed`}].filter(e=>e.automations.length>0)}function $(e,t){let n=e=>e.kind===`scheduled`&&e.nextRunAt?Date.parse(e.nextRunAt):1/0;return n(e)-n(t)||(t.lastRunAt??``).localeCompare(e.lastRunAt??``)||e.title.localeCompare(t.title)}function ue(e){let{group:t}=e,[n,r]=(0,W.useState)(!t.collapsed),i=/* @__PURE__ */ (0,G.jsx)(y,{children:/* @__PURE__ */ (0,G.jsx)(`div`,{role:`list`,children:t.automations.map(t=>/* @__PURE__ */ (0,G.jsx)(ie,{automation:t,onSelect:()=>e.onSelect(t.id),to:e.pagePath(t.id)},`${t.kind}:${t.id}`))})}),a=/* @__PURE__ */ (0,G.jsxs)(G.Fragment,{children:[t.label,/* @__PURE__ */ (0,G.jsx)(`span`,{className:`ml-2 tabular-nums text-dashboard-text-faint`,children:t.automations.length})]});return t.collapsed?/* @__PURE__ */ (0,G.jsxs)(I,{"aria-label":t.label,className:`grid gap-2.5`,onOpenChange:r,open:n,render:/* @__PURE__ */ (0,G.jsx)(`section`,{}),children:[/* @__PURE__ */ (0,G.jsx)(`h3`,{className:`m-0`,children:/* @__PURE__ */ (0,G.jsxs)(P,{className:`flex cursor-pointer items-center gap-1 rounded-md border-0 bg-transparent p-0 text-xs font-medium text-dashboard-text-muted hover:text-dashboard-text focus-visible:outline-2 focus-visible:outline-dashboard-focus`,children:[/* @__PURE__ */ (0,G.jsx)(l,{"aria-hidden":`true`,className:v(`transition-transform`,n&&`rotate-90`),size:14}),a]})}),/* @__PURE__ */ (0,G.jsx)(M,{children:i})]}):/* @__PURE__ */ (0,G.jsxs)(`section`,{"aria-label":t.label,className:`grid gap-2.5`,children:[/* @__PURE__ */ (0,G.jsx)(`h3`,{className:`m-0 text-xs font-medium text-dashboard-text-muted`,children:a}),i]})}export{ce as AutomationsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n,r}from"./vendor-react-ggbyvons.js";import{n as i,t as a}from"./CodeChangeRow-dk3gkjut.js";import{t as o}from"./Card-hy4bfgq7.js";import{r as s,s as c,t as l}from"./PageHeader-bhl3orzi.js";import{t as u}from"./PageLayout-l6dhbimv.js";import{$ as d,J as f,Q as p,X as m,Y as h,Z as g,Zt as _,ct as v,l as y,o as b}from"../client-f7asutg5.js";import{n as x,r as S,t as C}from"./CodeSummaryCards-o1po2jis.js";var w=/* @__PURE__ */ e(t(),1),T=n();function E(){let[e,t]=(0,w.useState)(30),n=_();return!n.data&&!n.error?/* @__PURE__ */ (0,T.jsx)(b,{description:`Repositories and code changes created by Junior.`,label:`Loading code activity`,title:`Code`,variant:`stats`}):/* @__PURE__ */ (0,T.jsxs)(u,{children:[/* @__PURE__ */ (0,T.jsx)(l,{description:`Repositories and code changes created by Junior.`,onRangeChange:t,range:e,title:`Code`}),n.error?/* @__PURE__ */ (0,T.jsx)(v,{children:`Code activity is unavailable. Try refreshing the dashboard.`}):null,n.data?/* @__PURE__ */ (0,T.jsx)(D,{data:n.data,range:e}):null]})}function D(e){let t=e.data;return/* @__PURE__ */ (0,T.jsxs)(T.Fragment,{children:[/* @__PURE__ */ (0,T.jsx)(C,{summary:t.summary}),/* @__PURE__ */ (0,T.jsx)(i,{bucketUnit:c(e.range),days:s({days:t.activityDays,hours:t.activityHours,sixHours:t.activitySixHours,range:e.range,emptySixHour:e=>({closed:0,created:0,date:e,merged:0})}),range:e.range}),/* @__PURE__ */ (0,T.jsxs)(o,{as:`section`,children:[/* @__PURE__ */ (0,T.jsx)(`div`,{className:`border-b border-dashboard-border-subtle px-4 py-3 font-display text-lg text-dashboard-text`,children:`Repositories`}),t.repositories.length===0?/* @__PURE__ */ (0,T.jsx)(`div`,{className:`p-4`,children:/* @__PURE__ */ (0,T.jsx)(v,{children:`No code activity has been recorded yet.`})}):/* @__PURE__ */ (0,T.jsxs)(f,{className:`min-w-[36rem] table-fixed`,children:[/* @__PURE__ */ (0,T.jsxs)(`colgroup`,{children:[/* @__PURE__ */ (0,T.jsx)(`col`,{}),/* @__PURE__ */ (0,T.jsx)(`col`,{className:`w-28`}),/* @__PURE__ */ (0,T.jsx)(`col`,{className:`w-28`}),/* @__PURE__ */ (0,T.jsx)(`col`,{className:`w-28`})]}),/* @__PURE__ */ (0,T.jsx)(p,{children:/* @__PURE__ */ (0,T.jsxs)(d,{children:[/* @__PURE__ */ (0,T.jsx)(g,{className:`px-4`,children:`Repository`}),/* @__PURE__ */ (0,T.jsx)(g,{className:`px-4 text-right`,children:`Created`}),/* @__PURE__ */ (0,T.jsx)(g,{className:`px-4 text-right`,children:`Merge rate`}),/* @__PURE__ */ (0,T.jsx)(g,{className:`px-4 text-right`,children:`Median cost`})]})}),/* @__PURE__ */ (0,T.jsx)(h,{children:t.repositories.map(e=>/* @__PURE__ */ (0,T.jsxs)(d,{children:[/* @__PURE__ */ (0,T.jsxs)(m,{className:`min-w-0 px-4 py-3`,children:[/* @__PURE__ */ (0,T.jsx)(`div`,{className:`truncate font-display text-sm text-dashboard-text`,children:/* @__PURE__ */ (0,T.jsx)(r,{className:`text-inherit no-underline hover:text-dashboard-accent-text`,to:y(e.id),children:e.name})}),/* @__PURE__ */ (0,T.jsx)(`div`,{className:`mt-1 truncate font-mono text-xs text-dashboard-text-muted`,children:e.provider})]}),/* @__PURE__ */ (0,T.jsx)(m,{className:`px-4 py-3 text-right font-sans tabular-nums`,children:e.created}),/* @__PURE__ */ (0,T.jsx)(m,{className:`px-4 py-3 text-right font-sans tabular-nums`,children:S(e.mergeRate)}),/* @__PURE__ */ (0,T.jsx)(m,{className:`px-4 py-3 text-right font-sans tabular-nums`,children:x(e.medianCostUsd)})]},e.id))})]})]}),t.changes.length>0?/* @__PURE__ */ (0,T.jsxs)(o,{as:`section`,children:[/* @__PURE__ */ (0,T.jsx)(`div`,{className:`border-b border-dashboard-border-subtle px-4 py-3 font-display text-lg text-dashboard-text`,children:`Recent changes`}),/* @__PURE__ */ (0,T.jsx)(`div`,{children:t.changes.map(e=>/* @__PURE__ */ (0,T.jsx)(a,{change:e},e.id))})]}):null]})}export{E as CodePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e}from"./vendor-react-ggbyvons.js";import{c as t}from"./vendor-icons-mxz7yi04.js";import{t as n}from"./styles-j0007fov.js";import{Bt as r,zt as i}from"../client-f7asutg5.js";var a=e();function o(e){let o=e.tone===`error`;return/* @__PURE__ */ (0,a.jsxs)(i,{role:o?`alert`:`status`,className:n(`flex min-w-0 rounded-md p-4 has-[>svg]:gap-x-3`,o?`border-rose-300/25 bg-rose-300/5 *:[svg]:text-rose-300`:`border-amber-300/25 bg-amber-300/5 *:[svg]:text-amber-300`),children:[/* @__PURE__ */ (0,a.jsx)(t,{"aria-hidden":!0,className:`size-4.5 shrink-0`}),/* @__PURE__ */ (0,a.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,a.jsx)(r,{children:e.title}),e.children?/* @__PURE__ */ (0,a.jsx)(`div`,{className:`mt-1 text-sm leading-relaxed text-dashboard-text-muted`,children:e.children}):null]})]})}export{o as t};
|
|
@@ -1 +0,0 @@
|
|
|
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-mxz7yi04.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-gle1s0ri.js";import{$ as g,J as _,Q as v,X as y,Y as b,Z as x,nt as S,rt as C,tt as ee}from"../client-f7asutg5.js";import{$t as te,A as ne,At as w,C as T,Ct as E,D as re,E as ie,Et as D,F as ae,Ft as oe,H as se,It as ce,J as le,K as ue,Lt as de,M as fe,Mt as pe,N as me,Nt as he,O as ge,P as _e,Qt as ve,R as ye,S as be,Tt as O,U as k,Vt as A,Yt as j,Z as M,_ as xe,a as N,ct as Se,d as P,dt as Ce,f as we,g as Te,gt as F,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-myr1oeen.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-e3oi6in1.js";import{t as Ke}from"./Area-h08sxa33.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)=>k(e,`xAxis`,t,o),et=(e,t,n,r,i,a,o)=>ue(e,`xAxis`,t,o),tt=(e,t,n,r,i,a,o)=>k(e,`yAxis`,n,o),nt=(e,t,n,r,i,a,o)=>ue(e,`yAxis`,n,o),rt=(e,t,n,r)=>le(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=w([je,it],(e,t)=>e.filter(e=>e.type===`scatter`).find(e=>e.id===t)),ct=w([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:O(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:O(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=ve(n),s=te(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}=de(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(j,{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(fe,{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=pe(ye),{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(!ce(t))return null;var g=ve(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(ae,{key:`symbol-${e?.cx}-${e?.cy}-${e?.size}-${t}`,zIndex:a?M.activeDot:void 0},/*#__PURE__*/ U.createElement(j,K({className:`recharts-scatter-symbol`},oe(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(Se,{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(j,null,/*#__PURE__*/ U.createElement(xt,{points:i,allOtherScatterProps:n,showLabels:m}))}),/*#__PURE__*/ U.createElement(me,{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=A(n.dataKey)?a.dataKey:n.dataKey,u=A(r.dataKey)?a.dataKey:r.dataKey,d=i&&i.dataKey,f=i?i.range:se.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=D(e,l),g=D(e,u),_=!A(d)&&D(e,d)||`-`,v=[{name:A(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:A(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=E({axis:n,ticks:o,bandSize:m,entry:e,index:t,dataKey:l}),b=E({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:D(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(ae,{zIndex:e.zIndex},/*#__PURE__*/ U.createElement(j,{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(j,{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:M.scatter};function Dt(e){var t=he(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}=be(d,f),g=(0,U.useMemo)(()=>ne(e.children,Be),[e.children]),_=F(),v=pe(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=he(e,Et),n=F();return/*#__PURE__*/ U.createElement(re,{id:t.id,type:`scatter`},e=>/*#__PURE__*/ U.createElement(U.Fragment,null,/*#__PURE__*/ U.createElement(ge,{legendPayload:_t(t)}),/*#__PURE__*/ U.createElement(ie,{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,Ce);kt.displayName=`Scatter`;var At=[`axis`],jt=/*#__PURE__*/ (0,U.forwardRef)((e,t)=>/*#__PURE__*/ U.createElement(xe,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:At,tooltipPayloadSearcher:_e,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)(ee,{className:`border-t border-dashboard-border-subtle px-4 py-3 sm:px-5`,children:[/* @__PURE__ */ (0,Z.jsxs)(C,{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)(S,{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)(_,{"aria-label":`Largest cache writes`,className:`min-w-80 table-fixed font-sans text-xs tabular-nums`,children:[/* @__PURE__ */ (0,Z.jsx)(v,{children:/* @__PURE__ */ (0,Z.jsxs)(g,{children:[/* @__PURE__ */ (0,Z.jsx)(x,{scope:`col`,className:`px-0 py-2 font-normal`,children:e.bucketUnit===`day`?`Day`:`Starting at`}),/* @__PURE__ */ (0,Z.jsx)(x,{scope:`col`,className:`w-24 px-0 py-2 text-right font-normal`,children:`Written`}),/* @__PURE__ */ (0,Z.jsx)(x,{scope:`col`,className:`w-24 px-0 py-2 text-right font-normal`,children:`From cache`})]})}),/* @__PURE__ */ (0,Z.jsx)(b,{children:t.map(e=>/* @__PURE__ */ (0,Z.jsxs)(g,{children:[/* @__PURE__ */ (0,Z.jsx)(x,{scope:`row`,className:`px-0 py-2 font-normal whitespace-normal`,children:Ee(e.date)}),/* @__PURE__ */ (0,Z.jsx)(y,{className:`px-0 py-2 text-right whitespace-normal`,children:p(e.cacheCreationTokens)}),/* @__PURE__ */ (0,Z.jsx)(y,{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:P,role:`img`,children:[/* @__PURE__ */ (0,Z.jsx)(T,{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)(N,{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)(ee,{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)(C,{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)(S,{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:P,role:`img`,children:[/* @__PURE__ */ (0,Z.jsx)(T,{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)(N,{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:P,role:`img`,children:[/* @__PURE__ */ (0,Z.jsx)(T,{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=>we(s.get(e)??e),keys:n.map(e=>e.id)}),/* @__PURE__ */ (0,Z.jsx)(I,{content:/* @__PURE__ */ (0,Z.jsx)(N,{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=Te(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)(_,{className:`min-w-[36rem]`,children:[/* @__PURE__ */ (0,Z.jsx)(v,{className:`bg-dashboard-overlay-soft`,children:/* @__PURE__ */ (0,Z.jsx)(g,{children:t.map(e=>/* @__PURE__ */ (0,Z.jsx)(x,{className:`px-5`,scope:`col`,children:e.label},e.key))})}),/* @__PURE__ */ (0,Z.jsx)(b,{children:n.map(e=>/* @__PURE__ */ (0,Z.jsx)(g,{className:$(e.tone),children:t.map(t=>/* @__PURE__ */ (0,Z.jsx)(y,{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 +0,0 @@
|
|
|
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{qt as o}from"./vendor-icons-mxz7yi04.js";import{n as s,t as c}from"./CodeChangeRow-dk3gkjut.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 ee,a as v,j as y,r as b,y as x}from"./format-gle1s0ri.js";import{t as te}from"./SecondaryNavigation-m358iuko.js";import{t as S}from"./PageLayout-l6dhbimv.js";import{$t as C,At as w,Dt as T,G as E,K as D,Ot as O,Qt as k,V as A,ct as j,d as M,f as N,ft as P,kt as F,l as I,o as L,p as R,st as z,vt as B}from"../client-f7asutg5.js";import{r as V}from"./FilterBar-mtnh7fbi.js";import{t as H}from"./CodeSummaryCards-o1po2jis.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=v(t),r=y(t,{includeId:!1}),a=!!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 ${n}`,className:`absolute inset-0 z-0 focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-dashboard-focus`,to:O(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)(D,{unread:!1,isPrivate:t.visibility===`private`,status:g(t),waitingOnViewer:!1})}),/* @__PURE__ */ (0,K.jsx)(`div`,{className:`min-w-0 truncate font-display text-sm text-dashboard-text`,children:n}),/* @__PURE__ */ (0,K.jsx)(`span`,{className:`whitespace-nowrap font-mono text-xs text-dashboard-text-muted`,children:x(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:a?/* @__PURE__ */ (0,K.jsx)(A,{annotations:t.sidebarAnnotations}):r?/* @__PURE__ */ (0,K.jsx)(`span`,{className:`truncate`,children:r}):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=T(t.trim()),o=k(e.repositoryId,a),s=b(o.data?.conversations??[]),c=B();return(0,G.useEffect)(()=>{i(1)},[a]),/* @__PURE__ */ (0,K.jsxs)(`section`,{"aria-label":`Conversations`,className:`grid gap-3`,children:[/* @__PURE__ */ (0,K.jsx)(z,{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)(j,{children:`Conversations are unavailable. Try refreshing the dashboard.`}):/* @__PURE__ */ (0,K.jsx)(E,{conversations:R(w(s,F(s,c)),r,25),emptyLabel:a?`No conversations match this search.`:`No conversations are linked to this repository yet.`,loading:!o.data,timeZone:_(),waitingConversationIds:c}),/* @__PURE__ */ (0,K.jsx)(M,{className:`pt-1`,onPageChange:i,page:r,pageCount:N(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)(z,{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)(j,{children:`No changes match these filters.`})}):R(f,a,25).map(e=>/* @__PURE__ */ (0,K.jsx)(c,{change:e},e.id))}),/* @__PURE__ */ (0,K.jsx)(M,{onPageChange:o,page:a,pageCount:N(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=C(t);if(!o.data&&!o.error)return/* @__PURE__ */ (0,K.jsx)(L,{description:Q,label:`Loading repository`,title:`Repository`,variant:`stats`});let s=o.data;if(!s)return/* @__PURE__ */ (0,K.jsxs)(S,{children:[/* @__PURE__ */ (0,K.jsx)($,{}),/* @__PURE__ */ (0,K.jsx)(j,{children:`This repository is unavailable. It may not have any code changes from Junior.`})]});let c=s.repository;return/* @__PURE__ */ (0,K.jsx)(te,{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)(S,{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)(P,{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:ee(e.id),children:e.name})]},e.id))]})}function ae(e){let t=e.data,n=k(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)(j,{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)(j,{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};
|
|
@@ -1 +0,0 @@
|
|
|
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{E as s,ht as c,kt as l,ut as u}from"./junior-hdb4wc4q.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-cp3vx8qa.js";import{C as S,H as C,It as w,Lt as ee,M as T,N as E,P as D,S as O,U as te,W as k,_ as A,_t as j,b as ne,g as M,gt as N,h as P,lt as F,m as re,mt as I,pt as L,s as R,v as z,w as B,x as V,y as H}from"../client-f7asutg5.js";import{t as U}from"./native-select-jfknh8t4.js";var W=/* @__PURE__ */ e(i(),1),G=a();const K=A.queryKey,q=[[1,`Mon`],[2,`Tue`],[3,`Wed`],[4,`Thu`],[5,`Fri`],[6,`Sat`],[0,`Sun`]],J={default:`Junior default`,saved:`from your profile`,slack:`from Slack`};function Y(){try{return Intl.supportedValuesOf(`timeZone`)}catch{return[]}}function X(){let e=r(A);return/* @__PURE__ */ (0,G.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,G.jsx)(x,{anchor:M,className:`m-0 text-lg font-bold`,title:`Push notifications`}),/* @__PURE__ */ (0,G.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,G.jsx)(ie,{}):e.isError?/* @__PURE__ */ (0,G.jsx)(k,{className:`mt-5`,children:`Could not load notification settings. Reload the page to try again.`}):/* @__PURE__ */ (0,G.jsxs)(G.Fragment,{children:[/* @__PURE__ */ (0,G.jsx)(ae,{settings:e.data}),/* @__PURE__ */ (0,G.jsx)(oe,{settings:e.data})]})]})}function ie(){return/* @__PURE__ */ (0,G.jsxs)(`div`,{"aria-label":`Loading notification settings`,className:`mt-5 grid gap-3`,role:`status`,children:[/* @__PURE__ */ (0,G.jsx)(v,{className:`h-10 w-48`}),/* @__PURE__ */ (0,G.jsx)(v,{className:`h-24 w-full`})]})}function ae({settings:e}){let i=n(),a=(0,W.useMemo)(()=>O(),[]),c=r({enabled:a===`supported`,queryKey:z,queryFn:async()=>(await V())?.endpoint??null}),l=a===`supported`&&!!e.publicKey;(0,W.useEffect)(()=>{l&&S()?.catch(()=>void 0)},[l]);let u=e=>i.setQueryData(K,e),d=t({mutationFn:e=>ne(i,e)}),f=t({mutationFn:async()=>{let e=await B();return e?await m(s,`${P}/subscriptions`,{endpoint:e}):void 0},onSuccess:e=>{e&&u(e),i.invalidateQueries({queryKey:z})}}),p=t({mutationFn:H});if(!e.publicKey)return/* @__PURE__ */ (0,G.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,G.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,G.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=!!c.data,_=e.publicKey;return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`mt-5`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-3`,children:g?/* @__PURE__ */ (0,G.jsxs)(G.Fragment,{children:[/* @__PURE__ */ (0,G.jsx)(o,{disabled:f.isPending,onClick:()=>f.mutate(),type:`button`,children:f.isPending?`Turning off…`:`Turn off on this device`}),/* @__PURE__ */ (0,G.jsx)(o,{disabled:p.isPending,onClick:()=>p.mutate(),type:`button`,children:p.isPending?`Sending…`:`Send a test`})]}):/* @__PURE__ */ (0,G.jsx)(o,{disabled:d.isPending||c.isPending||h,onClick:()=>d.mutate(_),type:`button`,variant:`primary`,children:d.isPending?`Turning on…`:`Turn on for this device`})}),/* @__PURE__ */ (0,G.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,G.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,G.jsx)(k,{className:`mt-2`,children:`Could not change notifications on this device. Try again.`}):null]})}function oe({settings:e}){let r=n(),[i,a]=(0,W.useState)(e.schedule);(0,W.useEffect)(()=>a(e.schedule),[e.schedule]);let c=(0,W.useMemo)(()=>Y(),[]),u=t({mutationFn:e=>h(s,`${P}/schedule`,e),onSuccess:e=>r.setQueryData(K,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:l(i,m,Date.now());function v(e){e.preventDefault(),f&&p&&u.mutate(i)}return/* @__PURE__ */ (0,G.jsxs)(`form`,{className:`mt-6 border-t border-dashboard-border pt-5`,onSubmit:v,children:[/* @__PURE__ */ (0,G.jsx)(`h3`,{className:`m-0 text-base font-bold`,children:`Working hours`}),/* @__PURE__ */ (0,G.jsxs)(`label`,{className:`mt-4 flex items-center gap-3 text-sm`,children:[/* @__PURE__ */ (0,G.jsx)(D,{checked:g,onCheckedChange:e=>d({followSlack:e===!0})}),`Follow my Slack notification schedule`]}),g?/* @__PURE__ */ (0,G.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,G.jsxs)(`label`,{className:`mt-4 flex items-center gap-3 text-sm`,children:[/* @__PURE__ */ (0,G.jsx)(D,{checked:i.workingHoursOnly,onCheckedChange:e=>d({workingHoursOnly:e===!0})}),`Only notify me during working hours`]}),/* @__PURE__ */ (0,G.jsxs)(`fieldset`,{className:`m-0 mt-4 border-0 p-0 disabled:opacity-60`,disabled:!i.workingHoursOnly,children:[/* @__PURE__ */ (0,G.jsx)(`legend`,{className:`mb-2 p-0 text-sm font-medium`,children:`Days`}),/* @__PURE__ */ (0,G.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:q.map(([e,t])=>/* @__PURE__ */ (0,G.jsx)(y,{className:`min-h-11 min-w-12 lg:min-h-9`,value:String(e),variant:`pill`,children:t},e))}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-3 sm:max-w-sm`,children:[/* @__PURE__ */ (0,G.jsxs)(L,{children:[/* @__PURE__ */ (0,G.jsx)(N,{htmlFor:`notification-start`,children:`Start`}),/* @__PURE__ */ (0,G.jsx)(j,{id:`notification-start`,onChange:e=>d({start:e.target.value}),required:!0,step:900,type:`time`,value:i.start})]}),/* @__PURE__ */ (0,G.jsxs)(L,{children:[/* @__PURE__ */ (0,G.jsx)(N,{htmlFor:`notification-end`,children:`End`}),/* @__PURE__ */ (0,G.jsx)(j,{id:`notification-end`,onChange:e=>d({end:e.target.value}),required:!0,step:900,type:`time`,value:i.end})]})]})]}),/* @__PURE__ */ (0,G.jsxs)(L,{className:`mt-4 sm:max-w-sm`,children:[/* @__PURE__ */ (0,G.jsx)(N,{htmlFor:`notification-timezone`,children:`Timezone`}),/* @__PURE__ */ (0,G.jsxs)(U,{id:`notification-timezone`,onChange:e=>d({timezone:e.target.value||void 0}),value:i.timezone??``,children:[/* @__PURE__ */ (0,G.jsx)(`option`,{value:``,children:e.timezoneSource===`manual`?`Automatic`:`Automatic: ${e.timezone} (${J[e.timezoneSource]})`}),c.map(e=>/* @__PURE__ */ (0,G.jsx)(`option`,{value:e,children:e},e))]}),/* @__PURE__ */ (0,G.jsx)(I,{children:`Automatic uses your Slack timezone when Junior can read it.`})]}),/* @__PURE__ */ (0,G.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,G.jsxs)(`div`,{className:`mt-5 flex items-center gap-3`,children:[/* @__PURE__ */ (0,G.jsx)(o,{disabled:!f||!p||u.isPending,type:`submit`,children:u.isPending?`Saving…`:`Save hours`}),u.isSuccess?/* @__PURE__ */ (0,G.jsx)(`p`,{className:`m-0 text-sm text-emerald-300`,children:`Hours saved.`}):null,u.isError?/* @__PURE__ */ (0,G.jsx)(k,{children:`Could not save your hours. Try again.`}):null]})]})}const se=[`dashboard`,`core`],Z=[1,6,24,72,168];function ce(e){return e===0?`No done conversations to archive.`:e===1?`Archived 1 conversation.`:`Archived ${e} conversations.`}function le(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 ue({identity:e}){let r=n(),i=t({mutationFn:e=>f(d,`/api/me`,e),onSuccess:e=>{r.setQueryData(se,t=>t&&{...t,me:e})}}),a=re(),s=e.autoArchiveDefault??!1,c=e.autoArchiveGraceHours??24,l=Z.includes(c)?Z:[...Z,c].sort((e,t)=>e-t);return/* @__PURE__ */ (0,G.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,G.jsx)(x,{anchor:`conversations`,className:`m-0 text-lg font-bold`,title:`Conversations`}),/* @__PURE__ */ (0,G.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-3`,children:[/* @__PURE__ */ (0,G.jsx)(D,{checked:s,className:`mt-0.5`,disabled:i.isPending,onCheckedChange:e=>i.mutate({autoArchiveDefault:e})}),/* @__PURE__ */ (0,G.jsxs)(`span`,{className:`grid gap-0.5`,children:[/* @__PURE__ */ (0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`Auto-archive conversations when done`}),/* @__PURE__ */ (0,G.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,G.jsxs)(L,{className:`mt-5 max-w-xs`,children:[/* @__PURE__ */ (0,G.jsx)(N,{htmlFor:`auto-archive-grace`,children:`Wait time`}),/* @__PURE__ */ (0,G.jsx)(U,{"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,G.jsx)(`option`,{value:e,children:le(e)},e))}),/* @__PURE__ */ (0,G.jsx)(I,{id:`auto-archive-grace-help`,children:`How long finished work and the conversation stay quiet before archive.`})]}),i.isError?/* @__PURE__ */ (0,G.jsx)(k,{className:`mt-3`,children:`Could not save this setting. Try again.`}):null,/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`mt-5 grid gap-1.5`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[/* @__PURE__ */ (0,G.jsx)(o,{disabled:a.isPending,onClick:()=>a.mutate(),type:`button`,children:a.isPending?`Archiving…`:`Archive done now`}),a.isSuccess?/* @__PURE__ */ (0,G.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,role:`status`,children:ce(a.data.archived)}):null,a.isError?/* @__PURE__ */ (0,G.jsx)(k,{children:`Could not archive conversations. Try again.`}):null]}),/* @__PURE__ */ (0,G.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 de=[`dashboard`,`core`],Q=[`dashboard`,`user-customization`],$=`/api/user-customization`;function fe({identity:e}){let r=n(),[i,a]=(0,W.useState)(e.user.name??``);(0,W.useEffect)(()=>{a(e.user.name??``)},[e.user.name]);let s=t({mutationFn:e=>f(d,`/api/me`,{displayName:e}),onSuccess:e=>{r.setQueryData(de,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,G.jsxs)(R,{description:`Manage your profile and preferences.`,title:`General`,children:[/* @__PURE__ */ (0,G.jsx)(`form`,{onSubmit:p,children:/* @__PURE__ */ (0,G.jsxs)(_,{className:`mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,G.jsx)(x,{anchor:`profile`,className:`m-0 text-lg font-bold`,title:`Profile`}),/* @__PURE__ */ (0,G.jsxs)(L,{className:`mt-5`,children:[/* @__PURE__ */ (0,G.jsx)(N,{htmlFor:`display-name`,children:`Display name`}),/* @__PURE__ */ (0,G.jsx)(j,{autoComplete:`name`,id:`display-name`,maxLength:80,onChange:e=>{a(e.target.value),(s.isError||s.isSuccess)&&s.reset()},value:i}),/* @__PURE__ */ (0,G.jsx)(I,{id:`display-name-help`,children:`Your display name is shown with your conversations and activity.`})]}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`mt-5 flex items-center gap-3`,children:[/* @__PURE__ */ (0,G.jsx)(o,{disabled:!u,type:`submit`,children:s.isPending?`Saving…`:`Save changes`}),s.isSuccess?/* @__PURE__ */ (0,G.jsx)(`p`,{className:`m-0 text-sm text-emerald-300`,children:`Changes saved.`}):null,s.isError?/* @__PURE__ */ (0,G.jsx)(k,{children:`Could not save your display name. Try again.`}):null]})]})}),/* @__PURE__ */ (0,G.jsx)(pe,{}),/* @__PURE__ */ (0,G.jsx)(he,{}),/* @__PURE__ */ (0,G.jsx)(ge,{}),/* @__PURE__ */ (0,G.jsx)(ue,{identity:e}),/* @__PURE__ */ (0,G.jsx)(X,{}),/* @__PURE__ */ (0,G.jsx)(_e,{})]})}function pe(){let[e,t]=ee();return/* @__PURE__ */ (0,G.jsxs)(_,{className:`mt-6 mb-0 hidden md:block`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,G.jsx)(x,{anchor:`navigation`,className:`m-0 text-lg font-bold`,title:`Navigation`}),/* @__PURE__ */ (0,G.jsx)(`p`,{className:`mt-1 mb-4 text-sm text-dashboard-text-muted`,children:`This choice applies to this browser.`}),/* @__PURE__ */ (0,G.jsx)(T,{"aria-label":`Navigation`,className:`grid gap-3`,onValueChange:t,value:e,children:w.map(e=>/* @__PURE__ */ (0,G.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3`,children:[/* @__PURE__ */ (0,G.jsx)(E,{className:`mt-0.5`,value:e.value}),/* @__PURE__ */ (0,G.jsxs)(`span`,{className:`grid gap-0.5`,children:[/* @__PURE__ */ (0,G.jsx)(`span`,{className:`text-sm font-medium`,children:e.label}),/* @__PURE__ */ (0,G.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]=F();return/* @__PURE__ */ (0,G.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,G.jsx)(x,{anchor:`open-conversations-at`,className:`m-0 text-lg font-bold`,title:`Open conversations at`}),/* @__PURE__ */ (0,G.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,G.jsx)(T,{"aria-label":`Open conversations at`,className:`grid gap-3`,onValueChange:t,value:e,children:me.map(e=>/* @__PURE__ */ (0,G.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3`,children:[/* @__PURE__ */ (0,G.jsx)(E,{className:`mt-0.5`,value:e.value}),/* @__PURE__ */ (0,G.jsxs)(`span`,{className:`grid gap-0.5`,children:[/* @__PURE__ */ (0,G.jsx)(`span`,{className:`text-sm font-medium`,children:e.label}),/* @__PURE__ */ (0,G.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,children:e.description})]})]},e.value))})]})}function ge(){let[e,t]=C();return/* @__PURE__ */ (0,G.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,G.jsx)(x,{anchor:`message-box`,className:`m-0 text-lg font-bold`,title:`Message box`}),/* @__PURE__ */ (0,G.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-3`,children:[/* @__PURE__ */ (0,G.jsx)(D,{checked:e,className:`mt-0.5`,onCheckedChange:t}),/* @__PURE__ */ (0,G.jsxs)(`span`,{className:`grid gap-0.5`,children:[/* @__PURE__ */ (0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`Autocorrect`}),/* @__PURE__ */ (0,G.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,W.useState)(``),s=r({queryKey:Q,queryFn:({signal:e})=>p(c,$,e),retry:!1}),l=s.data?.customization;(0,W.useEffect)(()=>{l!==void 0&&a(l)},[l]);let d=t({mutationFn:e=>h(c,$,{customization:e}),onSuccess:t=>{e.setQueryData(Q,t)}});if(s.error instanceof g&&s.error.status===404)return null;if(l===void 0)return s.isError?/* @__PURE__ */ (0,G.jsx)(k,{children:`Could not load your customization.`}):null;let f=i.trim()!==l&&i.trim().length<=1e3&&!d.isPending;function m(e){e.preventDefault(),f&&d.mutate(i.trim())}return/* @__PURE__ */ (0,G.jsx)(`form`,{onSubmit:m,children:/* @__PURE__ */ (0,G.jsxs)(_,{className:`mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,G.jsx)(x,{anchor:`customization`,className:`m-0 text-lg font-bold`,title:`Customization`}),/* @__PURE__ */ (0,G.jsxs)(L,{className:`mt-5`,children:[/* @__PURE__ */ (0,G.jsx)(N,{htmlFor:`user-customization`,children:`How should replies to you change?`}),/* @__PURE__ */ (0,G.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,G.jsxs)(I,{children:[`Added to each message you send. Do not put secrets here. (`,i.trim().length,`/`,u,`)`]})]}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`mt-5 flex items-center gap-3`,children:[/* @__PURE__ */ (0,G.jsx)(o,{disabled:!f,type:`submit`,children:d.isPending?`Saving…`:`Save customization`}),d.isSuccess?/* @__PURE__ */ (0,G.jsx)(`p`,{className:`m-0 text-sm text-emerald-300`,children:`Changes saved.`}):null,d.isError?/* @__PURE__ */ (0,G.jsx)(k,{children:`Could not save your customization. Try again.`}):null]})]})})}export{fe as SettingsPage};
|
|
@@ -1,15 +0,0 @@
|
|
|
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,B as s,Bt as c,Kt as l,Qt as u,_ as d,c as ee}from"./vendor-icons-mxz7yi04.js";import{t as te}from"./circle-dollar-sign-fpl4dmok.js";import{t as f}from"./styles-j0007fov.js";import{t as p}from"./Card-hy4bfgq7.js";import{a as m,c as ne,d as re,i as h,m as g,p as _,r as v,s as ie,t as y,u as ae}from"./PageHeader-bhl3orzi.js";import{c as oe,l as b,p as x,q as S,x as se}from"./format-gle1s0ri.js";import{n as ce}from"./AnchorHeading-cp3vx8qa.js";import{i as C,n as le,r as w,t as ue}from"./SystemPlugins-jr37f1cv.js";import{$ as T,J as de,Q as fe,X as E,Y as D,Z as O,c as k,ct as A,i as pe,r as me,ut as he}from"../client-f7asutg5.js";import{C as j,a as M,d as N,i as ge,l as P,m as F,n as I,o as L,r as _e,s as R,t as z,u as ve}from"./chart-myr1oeen.js";import{n as B,t as V}from"./BarChart-e3oi6in1.js";import{n as ye,r as be,t as xe}from"./PluginReportRecordSet-hm1cwp6c.js";import{t as H}from"./StatCard-i2klkqqp.js";import{t as U}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 Se=u(`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`}]]),Ce=u(`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 W=/* @__PURE__ */ e(t(),1),G=n();function we(e){return/* @__PURE__ */ (0,G.jsxs)(`section`,{"aria-labelledby":ce(`details`),className:`grid gap-3`,children:[/* @__PURE__ */ (0,G.jsx)(k,{className:`px-1`,anchor:`details`,title:`Details`}),/* @__PURE__ */ (0,G.jsxs)(p,{children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-px bg-dashboard-fill-hover sm:grid-cols-3`,children:[/* @__PURE__ */ (0,G.jsx)(K,{icon:c,label:`Identifier`,value:e.plugin.name}),/* @__PURE__ */ (0,G.jsx)(K,{icon:d,label:`Skills`,value:String(e.plugin.skills.length)}),/* @__PURE__ */ (0,G.jsx)(K,{icon:o,label:`Configuration`,value:String(e.plugin.configKeys.length)})]}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid gap-5 border-t border-dashboard-border-subtle p-4 sm:p-5 lg:grid-cols-2`,children:[/* @__PURE__ */ (0,G.jsx)(q,{emptyText:`No plugin-provided skills were discovered.`,items:e.plugin.skills.map(e=>e.name),title:`Skills`}),e.plugin.configKeys.length?/* @__PURE__ */ (0,G.jsx)(`div`,{className:`lg:col-span-2`,children:/* @__PURE__ */ (0,G.jsx)(q,{emptyText:``,items:e.plugin.configKeys,title:`Configuration keys`})}):null]})]})]})}function K(e){let t=e.icon;return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex items-center gap-3 bg-dashboard-surface-panel px-4 py-3.5`,children:[/* @__PURE__ */ (0,G.jsx)(t,{"aria-hidden":`true`,className:`text-dashboard-accent-text/60`,size:15}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`truncate font-display text-base font-medium text-dashboard-text`,children:e.value}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-0.5 font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label})]})]})}function q(e){return/* @__PURE__ */ (0,G.jsxs)(`div`,{children:[/* @__PURE__ */ (0,G.jsx)(`h3`,{className:`m-0 font-sans text-xs font-medium text-dashboard-text-muted`,children:e.title}),e.items.length?/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-2.5 flex flex-wrap gap-2`,children:e.items.map(e=>/* @__PURE__ */ (0,G.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:e},e))}):/* @__PURE__ */ (0,G.jsx)(`p`,{className:`mt-2 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.emptyText})]})}function Te(e){return/* @__PURE__ */ (0,G.jsx)(`section`,{"aria-label":`Plugins`,className:`grid gap-3`,children:e.plugins.length?/* @__PURE__ */ (0,G.jsx)(`div`,{className:`grid gap-3`,children:e.plugins.map(e=>/* @__PURE__ */ (0,G.jsx)(Ee,{plugin:e},e.name))}):/* @__PURE__ */ (0,G.jsx)(p,{padding:`md`,children:/* @__PURE__ */ (0,G.jsx)(`div`,{className:`font-mono text-xs text-dashboard-text-muted`,children:`No plugin inventory has been reported yet.`})})})}function Ee(e){let t=e.plugin.reports.flatMap(e=>e.metrics??[]);return/* @__PURE__ */ (0,G.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:w(e.plugin.name),children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-4`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[/* @__PURE__ */ (0,G.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,G.jsx)(c,{"aria-hidden":`true`,size:16,strokeWidth:1.8})}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,G.jsx)(`h3`,{className:`m-0 truncate font-display text-lg font-medium text-dashboard-text`,children:e.plugin.displayName}),/* @__PURE__ */ (0,G.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,G.jsx)(l,{"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,G.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,G.jsxs)(`div`,{className:`min-w-0 bg-dashboard-surface-panel px-3 py-2.5`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`truncate font-display text-lg font-light text-dashboard-text`,children:e.value}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-1 truncate font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label})]},e.label))}):null,/* @__PURE__ */ (0,G.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,G.jsx)(De,{icon:d,label:`${e.plugin.skills.length} skills`})})]})}function De(e){let t=e.icon;return/* @__PURE__ */ (0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-sans font-medium text-xs text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,G.jsx)(t,{"aria-hidden":`true`,size:11}),e.label]})}function Oe(e){return e.reports.length===0&&!e.emptyText?null:e.reports.length===0?/* @__PURE__ */ (0,G.jsx)(p,{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)(Se,{"aria-hidden":`true`,size:17})}),/* @__PURE__ */ (0,G.jsxs)(`div`,{children:[/* @__PURE__ */ (0,G.jsx)(`h2`,{className:`m-0 font-display text-base font-medium text-dashboard-text-muted`,children:`Operational reports`}),/* @__PURE__ */ (0,G.jsx)(`p`,{className:`mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.emptyText})]})]})}):/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid gap-3`,children:[/* @__PURE__ */ (0,G.jsx)(k,{anchor:`reports`,className:`px-1`,title:`Operational reports`}),e.reports.map(t=>/* @__PURE__ */ (0,G.jsx)(ke,{fallbackTitle:e.fallbackTitle,range:e.range,report:t},t.pluginName))]})}function ke(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,G.jsxs)(p,{children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-dashboard-border-subtle px-5 py-4`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,G.jsx)(`h3`,{className:`m-0 truncate font-display text-lg font-medium text-dashboard-text`,children:t}),/* @__PURE__ */ (0,G.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,G.jsxs)(`div`,{className:`hidden shrink-0 font-mono text-xs text-dashboard-text-muted sm:block`,children:[`updated `,se(e.report.generatedAt)]}):null]}),n.length?/* @__PURE__ */ (0,G.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,G.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`,Ae(e.tone)),children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`truncate font-display text-2xl font-light leading-none text-dashboard-text`,children:e.value}),/* @__PURE__ */ (0,G.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,G.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,G.jsx)(ye,{range:e.range,widget:t},t.id))}):null,e.report.recordSets?.map(t=>/* @__PURE__ */ (0,G.jsx)(xe,{embedded:!0,recordSet:t},`${e.report.pluginName}:${t.title}`))]})}function Ae(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 je={share:{color:`var(--color-cyan-400)`,label:`Replies`}};function J(e){return`${S(e.startMs)||`0s`} to ${S(e.endMs)}`}function Y(e){return`${Math.round(e)}%`}function Me(e){let t=e.total-e.noReply,n=0,r=e.bins.find(e=>(n+=e.count,n*2>=t));return{median:t&&r?J(r):void 0,noReplyShare:e.total?Y(e.noReply/e.total*100):void 0,replies:t}}function Ne(e){let t=e.histogram.total-e.histogram.noReply,n=e.histogram.bins.map(e=>({count:e.count,id:String(e.endMs),label:J(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,G.jsx)(z,{className:f(`aspect-auto h-48 w-full`,e.className),config:je,children:/* @__PURE__ */ (0,G.jsxs)(V,{"aria-label":`Reply times of ${t} replies`,data:n,margin:N,role:`img`,children:[/* @__PURE__ */ (0,G.jsx)(j,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,G.jsx)(R,{format:Y,maximum:Math.ceil(i/10)*10}),/* @__PURE__ */ (0,G.jsx)(L,{centered:!0,dataKey:`id`,formatLabel:e=>S(Number(e)),keys:n.map(e=>e.id)}),/* @__PURE__ */ (0,G.jsx)(I,{content:/* @__PURE__ */ (0,G.jsx)(M,{formatLabel:e=>r.get(e)??e,rows:e=>[[`Replies`,e.count],[`Share`,Y(e.share)]]})}),/* @__PURE__ */ (0,G.jsx)(B,{dataKey:`share`,fill:`var(--color-share)`,fillOpacity:.85,isAnimationActive:!1,maxBarSize:32,radius:1.5})]})})}const Pe=[{label:`People`,value:`user`},{label:`System`,value:`system`},{label:`Archived`,value:`archived`}];function X(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 Fe(e){let t=X(e);return t.group===`archived`||t.work!==`none`}function Ie(e){let{noReply:t,total:n}=e.histogram;return n?`${Math.round((n-t)/n*100)}%`:`—`}function Le(e){return e.reduce((e,t)=>!e||t.histogram.total>e.histogram.total?t:e,void 0)?.segment}function Re(e){let[t,n]=(0,W.useState)(`user`),[r,i]=(0,W.useState)(),a=e.report?.minSamples??0,o=(e.report?.segments??[]).filter(e=>X(e.segment).group===t),s=o.find(e=>e.segment===r)??o.find(e=>e.segment===Le(o)),c=s&&Me(s.histogram);return/* @__PURE__ */ (0,G.jsxs)(p,{children:[/* @__PURE__ */ (0,G.jsx)(U,{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,G.jsx)(ae,{"aria-label":`Segment group`,onValueChange:([e])=>{e&&n(e)},value:[t],children:Pe.map(e=>/* @__PURE__ */ (0,G.jsx)(re,{value:e.value,children:e.label},e.value))})}),e.report?/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid lg:grid-cols-[minmax(0,22rem)_minmax(0,1fr)]`,children:[/* @__PURE__ */ (0,G.jsxs)(de,{className:`table-fixed`,children:[/* @__PURE__ */ (0,G.jsx)(fe,{className:`bg-dashboard-overlay-soft`,children:/* @__PURE__ */ (0,G.jsxs)(T,{children:[/* @__PURE__ */ (0,G.jsx)(O,{className:`pl-4 sm:pl-5`,scope:`col`,children:`Turns`}),/* @__PURE__ */ (0,G.jsx)(O,{scope:`col`,children:`Work`}),/* @__PURE__ */ (0,G.jsx)(O,{className:`text-right`,scope:`col`,children:`Samples`}),/* @__PURE__ */ (0,G.jsx)(O,{className:`pr-4 text-right sm:pr-5`,scope:`col`,children:`Replied`})]})}),/* @__PURE__ */ (0,G.jsx)(D,{children:o.map(e=>{let t=X(e.segment),n=e.segment===s?.segment,r=e.histogram.total>=a;return/* @__PURE__ */ (0,G.jsxs)(T,{className:`cursor-pointer`,"data-state":n?`selected`:void 0,onClick:()=>i(e.segment),children:[/* @__PURE__ */ (0,G.jsx)(E,{className:`pl-4 text-xs sm:pl-5`,children:/* @__PURE__ */ (0,G.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,G.jsx)(E,{className:`text-xs capitalize`,children:t.work}),/* @__PURE__ */ (0,G.jsx)(E,{className:`text-right font-sans text-xs tabular-nums`,children:r?b(e.histogram.total):/* @__PURE__ */ (0,G.jsxs)(he,{className:`ml-auto`,size:`compact`,tone:`warning`,children:[e.histogram.total,` of `,a]})}),/* @__PURE__ */ (0,G.jsx)(E,{className:f(`pr-4 text-right font-sans text-xs tabular-nums sm:pr-5`,!r&&`text-dashboard-text-muted`),children:Ie(e)})]},e.segment)})})]}),/* @__PURE__ */ (0,G.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,G.jsxs)(G.Fragment,{children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 px-2 font-sans text-xs text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,G.jsx)(`span`,{className:`font-mono text-dashboard-text`,children:s.segment}),/* @__PURE__ */ (0,G.jsx)(`span`,{children:s.histogram.total<a?Fe(s.segment)?`Uses its "none" segment until ${a} samples`:`Too few samples to warm`:c?.median?`Typical reply ${c.median}`:`No replies`})]}),/* @__PURE__ */ (0,G.jsx)(Ne,{className:`min-h-48 flex-1`,histogram:s.histogram})]}):null})]}):/* @__PURE__ */ (0,G.jsx)(A,{children:e.error?`Reply times failed to load.`:`Loading reply times.`})]})}function ze(e){let t=Ve(e.skills),n=e.skills.filter(e=>e.pluginProvider).length;return/* @__PURE__ */ (0,G.jsxs)(p,{children:[/* @__PURE__ */ (0,G.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,G.jsx)(k,{description:/* @__PURE__ */ (0,G.jsxs)(G.Fragment,{children:[`The task-specific instructions `,g(),` `,`discovered, grouped by their plugin provider when one is registered.`]}),anchor:`skills`,title:`Skills`}),/* @__PURE__ */ (0,G.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,G.jsx)(Z,{label:`discovered`,value:e.skills.length}),/* @__PURE__ */ (0,G.jsx)(Z,{label:`from plugins`,value:n})]})]}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`grid gap-3 p-3 sm:p-4`,children:t.length?t.map(e=>/* @__PURE__ */ (0,G.jsx)(Be,{group:e},e.pluginProvider??`standalone`)):/* @__PURE__ */ (0,G.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 Be(e){let t=e.group.pluginProvider??`Standalone`;return/* @__PURE__ */ (0,G.jsxs)(`article`,{className:`rounded-lg border border-dashboard-border-subtle bg-dashboard-fill-soft p-4`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[/* @__PURE__ */ (0,G.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,G.jsx)(c,{"aria-hidden":`true`,size:15,strokeWidth:1.8}):/* @__PURE__ */ (0,G.jsx)(d,{"aria-hidden":`true`,size:15,strokeWidth:1.8})}),/* @__PURE__ */ (0,G.jsxs)(`div`,{children:[/* @__PURE__ */ (0,G.jsx)(`h3`,{className:`m-0 truncate font-display text-base font-medium text-dashboard-text`,children:t}),/* @__PURE__ */ (0,G.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,G.jsxs)(`span`,{className:`font-mono text-xs text-dashboard-text-muted`,children:[b(e.group.skills.length),` skill`,e.group.skills.length===1?``:`s`]})]}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.group.skills.map(e=>/* @__PURE__ */ (0,G.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:e.name},e.name))})]})}function Z(e){return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`border-r border-dashboard-border-subtle px-3 py-2.5 text-center last:border-r-0`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`font-display text-xl font-light leading-none text-dashboard-text`,children:b(e.value)}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-1.5 font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label})]})}function Ve(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 He={conversations:{color:`var(--color-cyan-400)`,label:`Conversations`}};function Ue(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=ve(r);return/* @__PURE__ */ (0,G.jsxs)(p,{children:[/* @__PURE__ */ (0,G.jsx)(U,{description:`Root conversations with recorded activity, per ${t===`6hour`?`6 hours`:t}.`,title:`Conversation activity`,total:b(i)}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`px-2 py-2`,children:/* @__PURE__ */ (0,G.jsx)(z,{className:`aspect-auto h-38 w-full`,config:He,children:/* @__PURE__ */ (0,G.jsxs)(V,{"aria-label":`Conversations per ${t===`6hour`?`6 hours`:t}`,data:e.days,margin:N,role:`img`,children:[/* @__PURE__ */ (0,G.jsx)(j,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,G.jsx)(R,{maximum:n}),/* @__PURE__ */ (0,G.jsx)(L,{keys:e.days.map(e=>e.date)}),/* @__PURE__ */ (0,G.jsx)(I,{content:/* @__PURE__ */ (0,G.jsx)(M,{rows:e=>[[`conversations`,e.conversations]]})}),/* @__PURE__ */ (0,G.jsx)(B,{dataKey:`conversations`,fill:`var(--color-conversations)`,fillOpacity:.78,isAnimationActive:!1,maxBarSize:24,minPointSize:e=>e?2:0,radius:2}),/* @__PURE__ */ (0,G.jsx)(_e,{average:a,format:oe,stroke:`var(--color-cyan-400)`,unit:m(t)})]})})})]})}function We(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,G.jsxs)(`div`,{className:`rounded-md border border-dashboard-border-subtle bg-dashboard-overlay-soft px-3 py-3`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`font-display text-xl font-light text-dashboard-text`,children:/* @__PURE__ */ (0,G.jsx)(`span`,{className:e.valueClassName,children:e.value})}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-1 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.label})]})}function Ge(e){let t=e.bucketUnit??`day`,n=We(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,G.jsxs)(p,{children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`border-b border-dashboard-border-subtle px-4 py-4`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{children:[/* @__PURE__ */ (0,G.jsx)(`h3`,{className:`m-0 font-sans text-xs font-medium text-dashboard-text-muted`,children:`Guardian reviews`}),/* @__PURE__ */ (0,G.jsxs)(`p`,{className:`mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:[h(t),` decisions before reviewed actions execute.`]})]}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,G.jsx)(`span`,{className:`mr-3 text-emerald-200/75`,children:`Allow`}),/* @__PURE__ */ (0,G.jsx)(`span`,{className:`mr-3 text-amber-200/75`,children:`Ask`}),/* @__PURE__ */ (0,G.jsx)(`span`,{className:`text-rose-200/75`,children:`Deny`})]})]}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-2 sm:grid-cols-5`,children:[/* @__PURE__ */ (0,G.jsx)(Q,{label:`Requests`,value:b(n.requests)}),/* @__PURE__ */ (0,G.jsx)(Q,{label:`Allowed`,value:b(n.allow),valueClassName:`text-emerald-100`}),/* @__PURE__ */ (0,G.jsx)(Q,{label:`Asked`,value:b(n.ask),valueClassName:`text-amber-100`}),/* @__PURE__ */ (0,G.jsx)(Q,{label:`Denied`,value:b(n.deny),valueClassName:`text-rose-100`}),/* @__PURE__ */ (0,G.jsx)(Q,{label:`Estimated cost`,value:x({total:n.costUsd})})]})]}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`px-4 pt-5 pb-3`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{"aria-label":`${h(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,G.jsx)(ge,{content:/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid grid-cols-[auto_auto] gap-x-4`,children:[/* @__PURE__ */ (0,G.jsx)(`span`,{children:`Allow`}),/* @__PURE__ */ (0,G.jsx)(`span`,{className:`text-right`,children:e.allow}),/* @__PURE__ */ (0,G.jsx)(`span`,{children:`Ask`}),/* @__PURE__ */ (0,G.jsx)(`span`,{className:`text-right`,children:e.ask}),/* @__PURE__ */ (0,G.jsx)(`span`,{children:`Deny`}),/* @__PURE__ */ (0,G.jsx)(`span`,{className:`text-right`,children:e.deny}),/* @__PURE__ */ (0,G.jsx)(`span`,{children:`Cost`}),/* @__PURE__ */ (0,G.jsx)(`span`,{className:`text-right`,children:x({total:e.costUsd??0})})]}),date:e.date,summary:`${e.allow} allowed, ${e.ask} asked, ${e.deny} denied, ${x({total:e.costUsd??0})}`,children:/* @__PURE__ */ (0,G.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,G.jsx)(`span`,{className:`block w-full bg-rose-400/75`,style:{flex:e.deny}}):null,e.ask?/* @__PURE__ */ (0,G.jsx)(`span`,{className:`block w-full bg-amber-300/75`,style:{flex:e.ask}}):null,e.allow?/* @__PURE__ */ (0,G.jsx)(`span`,{className:`block w-full bg-emerald-300/70`,style:{flex:e.allow}}):null]})},e.date)})}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`relative mt-2 h-4`,children:i.map(t=>{let n=e.days[t];return n?/* @__PURE__ */ (0,G.jsx)(P,{className:`absolute -translate-x-1/2`,style:{left:`${(t+.5)/e.days.length*100}%`},children:F(n.date)},n.date):null})})]})]})}function Ke(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 qe(e){if(!e.stats)return/* @__PURE__ */ (0,G.jsx)(p,{padding:`sm`,children:/* @__PURE__ */ (0,G.jsx)(A,{children:e.error?`Conversation metrics failed to load.`:e.loading?`Loading conversation metrics.`:`No conversation metrics have been reported yet.`})});let t=v({days:e.stats.metricDays,hours:e.stats.metricHours,sixHours:e.stats.metricSixHours,range:e.range,emptySixHour:e=>({conversations:0,date:e,durationMs:0})}),n=v({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=Ke(t),i=ie(e.range);return/* @__PURE__ */ (0,G.jsxs)(`section`,{"aria-label":`Runtime telemetry`,className:`grid gap-4`,children:[e.error?/* @__PURE__ */ (0,G.jsx)(`p`,{className:`m-0 font-sans text-xs text-rose-200/65`,children:`Metrics refresh failed. Showing cached data.`}):null,/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:[/* @__PURE__ */ (0,G.jsx)(H,{detail:`Root conversations in the ${ne(e.range)}`,icon:s,label:`Conversations`,value:b(r.conversations)}),/* @__PURE__ */ (0,G.jsx)(H,{detail:`All recorded model tokens`,icon:Ce,label:`Tokens`,value:b(r.tokens)}),/* @__PURE__ */ (0,G.jsx)(H,{detail:`Estimated model cost`,icon:te,label:`Model spend`,value:x({total:r.costUsd})})]}),/* @__PURE__ */ (0,G.jsx)(be,{bucketUnit:i,cacheBreakdown:!0,days:t}),/* @__PURE__ */ (0,G.jsx)(Ue,{bucketUnit:i,days:t}),/* @__PURE__ */ (0,G.jsx)(Ge,{bucketUnit:i,days:n})]})}function Je(e){let[t,n]=(0,W.useState)(30),a=i(),o=e.data.pluginReports?.reports??[],s=ue({plugins:e.data.plugins,reports:o,skills:e.data.skills}),c=le(a.pathname),l=c===C,u=s.find(e=>w(e.name)===c),d=c.startsWith(`${C}/`);return d&&!u&&e.data.pluginReportsLoading?/* @__PURE__ */ (0,G.jsx)(pe,{description:`Loading plugin details and operational reports.`,label:`Loading plugin`,title:`Plugin`}):d&&!u?/* @__PURE__ */ (0,G.jsx)(r,{replace:!0,to:C}):c!==`/system`&&!l&&!u?/* @__PURE__ */ (0,G.jsx)(r,{replace:!0,to:`/system`}):/* @__PURE__ */ (0,G.jsx)(me,{children:u?/* @__PURE__ */ (0,G.jsx)(Ze,{data:e.data,onRangeChange:n,plugin:u,range:t}):l?/* @__PURE__ */ (0,G.jsx)(Xe,{data:e.data,plugins:s}):/* @__PURE__ */ (0,G.jsx)(Ye,{data:e.data,range:t,onRangeChange:n})})}function Ye(e){return/* @__PURE__ */ (0,G.jsxs)(G.Fragment,{children:[/* @__PURE__ */ (0,G.jsx)(y,{description:`A live read on ${_()} runtime and model usage.`,onRangeChange:e.onRangeChange,range:e.range,title:`System`}),/* @__PURE__ */ (0,G.jsx)(qe,{error:e.data.conversationStatsError,range:e.range,loading:e.data.conversationStatsLoading,stats:e.data.conversationStats}),/* @__PURE__ */ (0,G.jsx)(Re,{error:e.data.replyTimesError,report:e.data.replyTimes})]})}function Xe(e){return/* @__PURE__ */ (0,G.jsxs)(G.Fragment,{children:[/* @__PURE__ */ (0,G.jsx)(y,{description:`Loaded capabilities and operational reports for ${g()}.`,title:`Plugins`}),e.data.pluginReportsError?/* @__PURE__ */ (0,G.jsx)($,{showingReports:e.plugins.some(e=>e.reports.length)}):null,/* @__PURE__ */ (0,G.jsx)(Te,{plugins:e.plugins}),e.data.skills.length?/* @__PURE__ */ (0,G.jsx)(ze,{skills:e.data.skills}):null]})}function Ze(e){let t=e.plugin.reports,n=t.some(e=>e.widgets?.some(e=>e.timeRangeDays?.length));return/* @__PURE__ */ (0,G.jsxs)(G.Fragment,{children:[/* @__PURE__ */ (0,G.jsx)(y,{description:e.plugin.description,...n?{onRangeChange:e.onRangeChange,range:e.range}:{},title:e.plugin.displayName}),e.data.pluginReportsError?/* @__PURE__ */ (0,G.jsx)($,{showingReports:!!t.length}):null,/* @__PURE__ */ (0,G.jsx)(we,{plugin:e.plugin}),/* @__PURE__ */ (0,G.jsx)(Oe,{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,G.jsx)(p,{className:`border-amber-300/10 bg-amber-300/[0.025]`,padding:`sm`,children:/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[/* @__PURE__ */ (0,G.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,G.jsx)(ee,{"aria-hidden":`true`,size:15})}),/* @__PURE__ */ (0,G.jsxs)(`div`,{children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`font-display text-sm font-medium text-dashboard-text-muted`,children:`Plugin stats failed to load.`}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-1 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.showingReports?`Showing the last operational reports ${g()} received.`:`Plugin details and capabilities are still available.`})]})]})})}export{Je as SystemPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=`/system/plugins`;function t(e){let t=new Map(e.plugins.map(e=>[e.name,{...e,reports:[],skills:[]}]));for(let n of e.skills){let e=n.pluginProvider?t.get(n.pluginProvider):void 0;e&&e.skills.push(n)}for(let n of e.reports){let e=t.get(n.pluginName);e||(e={configKeys:[],description:`Core operational report.`,displayName:n.title?.trim()||n.pluginName,name:n.pluginName,reports:[],skills:[]},t.set(n.pluginName,e)),e.reports.push(n)}return[...t.values()].map(e=>({...e,reports:[...e.reports],skills:[...e.skills].sort((e,t)=>e.name.localeCompare(t.name))})).sort((e,t)=>e.displayName.localeCompare(t.displayName))}function n(t){return`${e}/${encodeURIComponent(t)}`}function r(e){return e.replace(/\/+$/,``)||`/`}export{e as i,r as n,n as r,t};
|