@sentry/junior-dashboard 0.294.0 → 0.295.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/app.js +7 -5
  2. package/dist/client-manifest.json +1 -1
  3. package/dist/index.js +7 -5
  4. package/dist/public/chunks/{AdminPage-mn71yp2v.js → AdminPage-lctmhvpg.js} +1 -1
  5. package/dist/public/chunks/{AnchorHeading-cp3vx8qa.js → AnchorHeading-ixbupfij.js} +1 -1
  6. package/dist/public/chunks/{Area-h08sxa33.js → Area-d95rfkv5.js} +1 -1
  7. package/dist/public/chunks/AutomationPage-m78li1hv.js +3 -0
  8. package/dist/public/chunks/{AutomationRunDetails-jjdhbqtn.js → AutomationRunDetails-dx5lutte.js} +1 -1
  9. package/dist/public/chunks/{AutomationRunsPage-j50ps7nt.js → AutomationRunsPage-cba6nbxd.js} +1 -1
  10. package/dist/public/chunks/{AutomationStatus-czfg6ayl.js → AutomationStatus-eqq5lrad.js} +1 -1
  11. package/dist/public/chunks/AutomationsPage-cp7wtt2v.js +8 -0
  12. package/dist/public/chunks/{BarChart-e3oi6in1.js → BarChart-lbkezxbi.js} +1 -1
  13. package/dist/public/chunks/{BoardPage-f0uxqg7u.js → BoardPage-m4zqf62q.js} +1 -1
  14. package/dist/public/chunks/{CodeChangeRow-dk3gkjut.js → CodeChangeRow-d620nk75.js} +2 -2
  15. package/dist/public/chunks/CodePage-h2ayars2.js +1 -0
  16. package/dist/public/chunks/{CodeSummaryCards-o1po2jis.js → CodeSummaryCards-iotfblbp.js} +1 -1
  17. package/dist/public/chunks/{ConnectionsPage-mholegdk.js → ConnectionsPage-nm7w1i05.js} +2 -2
  18. package/dist/public/chunks/{DirectoryMetric-dgzufji4.js → DirectoryMetric-huy2ptzz.js} +1 -1
  19. package/dist/public/chunks/{DrawerContent-ovjgr16m.js → DrawerContent-n3biwp5m.js} +1 -1
  20. package/dist/public/chunks/{FilterBar-mtnh7fbi.js → FilterBar-dqnt967g.js} +1 -1
  21. package/dist/public/chunks/FormNotice-kj5pzsl7.js +1 -0
  22. package/dist/public/chunks/{LocationDetailPage-ggd6zgzp.js → LocationDetailPage-iqtx76w6.js} +2 -2
  23. package/dist/public/chunks/{LocationsPage-fh6vzxa1.js → LocationsPage-ju5jfejt.js} +2 -2
  24. package/dist/public/chunks/{McpSettingsPage-fm3fh2ux.js → McpSettingsPage-brav5c42.js} +1 -1
  25. package/dist/public/chunks/{PeoplePage-odrbcmhj.js → PeoplePage-lfq8nrto.js} +2 -2
  26. package/dist/public/chunks/{PersonProfilePage-gynexe89.js → PersonProfilePage-ep45sxr6.js} +1 -1
  27. package/dist/public/chunks/{PersonalTokensPage-4o4zj02w.js → PersonalTokensPage-jbt4q7uz.js} +1 -1
  28. package/dist/public/chunks/PluginReportRecordSet-ml18z19r.js +1 -0
  29. package/dist/public/chunks/{PluginUserPage-kwylbbpr.js → PluginUserPage-ilar25ic.js} +2 -2
  30. package/dist/public/chunks/RepositoryPage-o9m3vty4.js +1 -0
  31. package/dist/public/chunks/SettingsPage-jc9et1qq.js +1 -0
  32. package/dist/public/chunks/SystemPage-bbp8cdds.js +15 -0
  33. package/dist/public/chunks/{WorkspaceFormPage-hwvyvnuk.js → WorkspaceFormPage-kshmsdek.js} +2 -2
  34. package/dist/public/chunks/{WorkspacesPage-lu9w3ugz.js → WorkspacesPage-ohasc10u.js} +1 -1
  35. package/dist/public/chunks/alert-ifqo1uj7.js +1 -0
  36. package/dist/public/chunks/{automationFormat-hd7pnocr.js → automationFormat-kv314fzh.js} +1 -1
  37. package/dist/public/chunks/{chart-myr1oeen.js → chart-il2ahs5y.js} +1 -1
  38. package/dist/public/chunks/{circle-dollar-sign-fpl4dmok.js → circle-dollar-sign-h7k4kr7s.js} +1 -1
  39. package/dist/public/chunks/{code-highlighter-i3ux67or.js → code-highlighter-ea4j0ys1.js} +1 -1
  40. package/dist/public/chunks/{coins-bqkaxeba.js → coins-l2c8c17w.js} +1 -1
  41. package/dist/public/chunks/{format-gle1s0ri.js → format-flkutk9e.js} +2 -2
  42. package/dist/public/chunks/junior-g62bxb2t.js +4 -0
  43. package/dist/public/chunks/{native-select-jfknh8t4.js → native-select-fxs3p0bj.js} +1 -1
  44. package/dist/public/chunks/{plus-gndielka.js → plus-54e3zzys.js} +1 -1
  45. package/dist/public/chunks/vendor-icons-blmhaswc.js +698 -0
  46. package/dist/public/chunks/{workspaceQueries-m1ksz95c.js → workspaceQueries-onxawhg4.js} +1 -1
  47. package/dist/public/client-ctcthgam.js +165 -0
  48. package/dist/public/styles-4CIT7L7K.css +2 -0
  49. package/dist/tailwind.css +1 -1
  50. package/package.json +4 -4
  51. package/src/client/api.ts +16 -0
  52. package/src/client/components/MarkdownViewToggle.tsx +24 -0
  53. package/src/client/components/SkillLink.tsx +119 -0
  54. package/src/client/conversations/ConversationHomeList.tsx +87 -76
  55. package/src/client/conversations/ConversationListStatusIcon.tsx +39 -55
  56. package/src/client/conversations/ConversationSectionList.tsx +101 -0
  57. package/src/client/conversations/ConversationSidebar.tsx +159 -169
  58. package/src/client/conversations/ConversationWorkspace.tsx +5 -16
  59. package/src/client/conversations/TextAttachmentPreview.tsx +5 -14
  60. package/src/client/conversations/WaitingChip.tsx +78 -0
  61. package/src/client/conversations/conversationSections.ts +78 -55
  62. package/src/client/conversations/heldListOrder.ts +170 -0
  63. package/src/client/conversations/toolCallPreview.ts +3 -1
  64. package/src/client/conversations/transcriptSource.ts +7 -2
  65. package/src/client/conversations/useMarkConversationUnread.ts +2 -2
  66. package/src/client/format.ts +18 -2
  67. package/src/client/pages/automations/AutomationDraftChanges.tsx +2 -1
  68. package/src/client/pages/automations/AutomationOverview.tsx +3 -3
  69. package/src/client/pages/automations/AutomationSkillPicker.tsx +75 -31
  70. package/src/client/pages/automations/AutomationTaskFields.tsx +3 -13
  71. package/src/client/pages/automations/AutomationVersionsTab.tsx +2 -5
  72. package/src/client/pages/automations/skillSearch.ts +50 -0
  73. package/src/client/pages/code/RepositorySections.tsx +14 -5
  74. package/src/client/pages/code/RepositoryTabs.tsx +5 -11
  75. package/src/client/pages/system/PluginDetails.tsx +15 -8
  76. package/src/client/pages/system/SkillInventory.tsx +2 -6
  77. package/src/client/review-desk/queries.ts +30 -23
  78. package/src/client/review-desk/reviewItemFormat.ts +3 -1
  79. package/src/client/types.ts +5 -1
  80. package/src/mock-reporting/review-items.ts +6 -2
  81. package/dist/public/chunks/AutomationPage-e1l74ezg.js +0 -10
  82. package/dist/public/chunks/AutomationsPage-cphxl4l6.js +0 -8
  83. package/dist/public/chunks/CodePage-i97ivyji.js +0 -1
  84. package/dist/public/chunks/FormNotice-eyo2kdte.js +0 -1
  85. package/dist/public/chunks/PluginReportRecordSet-hm1cwp6c.js +0 -1
  86. package/dist/public/chunks/RepositoryPage-fti2vfu4.js +0 -1
  87. package/dist/public/chunks/SettingsPage-kxspx37h.js +0 -1
  88. package/dist/public/chunks/SystemPage-jurblfgy.js +0 -15
  89. package/dist/public/chunks/SystemPlugins-jr37f1cv.js +0 -1
  90. package/dist/public/chunks/junior-hdb4wc4q.js +0 -4
  91. package/dist/public/chunks/vendor-icons-mxz7yi04.js +0 -692
  92. package/dist/public/client-f7asutg5.js +0 -165
  93. package/dist/public/styles-ZJJGBKKX.css +0 -2
@@ -1 +1 @@
1
- import{ot as e,pt as t,ut as n}from"./vendor-lthmb2su.js";import{S as r,r as i}from"./vendor-react-ggbyvons.js";import{t as a}from"./button-ygjnb239.js";import{$ as o,Bt as s,Pt as c}from"./vendor-icons-mxz7yi04.js";import{C as l,I as u,R as d}from"./junior-hdb4wc4q.js";import{i as f,n as p,o as m}from"./http-cdq677qt.js";import{r as h}from"./styles-j0007fov.js";import{t as g}from"./Card-hy4bfgq7.js";import{m as _,t as v}from"./PageHeader-bhl3orzi.js";import{y}from"./format-gle1s0ri.js";import{t as b}from"./AnchorHeading-cp3vx8qa.js";import{W as x,t as S,ut as C}from"../client-f7asutg5.js";var w=r();const T=[`dashboard`,`service-accounts`];function E(e){return`/api/service-accounts/${encodeURIComponent(e)}`}function D(){return n({queryKey:T,queryFn:({signal:e})=>f(u,`/api/service-accounts`,e),refetchOnWindowFocus:!0,retry:!1})}function O(e){let t=e.userOAuth?`People who have not connected their own ${e.displayName} account use this account.`:`Everyone uses this account. People cannot connect their own ${e.displayName} account.`;return e.connected?`Connected by ${e.connectedBy??`the CLI`} ${y(e.connectedAt)}. ${t}`:`Not connected.${e.userOAuth?``:` ${e.displayName} is not available until you connect it.`} ${t} Sign in as the shared account, not as yourself.`}function k(n){let{accountsQuery:r}=n,i=t(),s=e({mutationFn:e=>m(d,E(e.provider),{}),onSuccess:({authorizationUrl:e},{popup:t})=>{t?t.closed||(t.opener=null,t.location.href=e):window.location.assign(e)},onError:(e,{popup:t})=>{t?.close()}}),c=e({mutationFn:e=>p(l,E(e.provider)),onSuccess:()=>i.invalidateQueries({queryKey:T})}),u=r.data?.serviceAccounts??[];if(r.isSuccess&&u.length===0)return null;let f=s.isPending||c.isPending,h=s.isPending?s.variables?.provider:c.isPending?c.variables?.provider:void 0,v=!r.data&&r.isError,y=s.isError?`Could not start the sign-in. Try again.`:c.isError?`Could not disconnect the account. Try again.`:v?`Could not load service accounts. Try again.`:void 0;return/* @__PURE__ */ (0,w.jsxs)(g,{as:`section`,padding:`md`,children:[/* @__PURE__ */ (0,w.jsx)(b,{anchor:`service-accounts`,className:`m-0 font-display text-base font-medium text-dashboard-text`,title:`Service accounts`}),/* @__PURE__ */ (0,w.jsxs)(`p`,{className:`mt-1 mb-4 text-sm text-dashboard-text-muted`,children:[`A shared account that Junior uses for a plugin. It can do only what its plugin allows, usually read. Everyone who can talk to`,` `,_(),` can use it, so give it only access that all of them may have.`]}),y?/* @__PURE__ */ (0,w.jsx)(x,{className:v?void 0:`mb-4`,children:y}):null,v?null:r.isPending?/* @__PURE__ */ (0,w.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:`Loading service accounts…`}):/* @__PURE__ */ (0,w.jsx)(`div`,{className:`space-y-2`,children:u.map(e=>/* @__PURE__ */ (0,w.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-dashboard-border-strong p-3`,children:[/* @__PURE__ */ (0,w.jsx)(o,{"aria-hidden":`true`,className:`shrink-0 text-dashboard-accent`,size:16}),/* @__PURE__ */ (0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[/* @__PURE__ */ (0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[/* @__PURE__ */ (0,w.jsx)(`p`,{className:`m-0 truncate text-sm font-semibold`,children:e.displayName}),/* @__PURE__ */ (0,w.jsx)(C,{size:`compact`,tone:e.connected?`success`:e.userOAuth?`neutral`:`warning`,children:e.connected?`connected`:`not connected`}),e.userOAuth?null:/* @__PURE__ */ (0,w.jsx)(C,{size:`compact`,tone:`neutral`,children:`shared only`})]}),/* @__PURE__ */ (0,w.jsx)(`p`,{className:`mt-1 mb-0 break-words text-xs text-dashboard-text-muted`,children:O(e)}),/* @__PURE__ */ (0,w.jsx)(`p`,{className:`mt-1 mb-0 break-words font-mono text-xs text-dashboard-text-faint`,children:e.tools.join(`, `)})]}),e.connected?/* @__PURE__ */ (0,w.jsx)(a,{"aria-busy":c.isPending&&h===e.provider,"aria-label":`Disconnect the ${e.displayName} service account`,disabled:f,onClick:()=>{s.reset(),c.mutate(e)},variant:`danger`,children:`Disconnect`}):null,/* @__PURE__ */ (0,w.jsx)(a,{"aria-busy":s.isPending&&h===e.provider,"aria-label":`${e.connected?`Reconnect`:`Connect`} the ${e.displayName} service account`,disabled:f,onClick:()=>{c.reset();let t=window.open(`about:blank`,`_blank`);s.mutate({provider:e.provider,popup:t})},children:s.isPending&&h===e.provider?`Connecting…`:e.connected?`Reconnect`:`Connect`})]},e.provider))})]})}function A(e){let t=e.pages.filter(e=>e.navigation===`admin`),n=D(),r=t.length===0&&n.data?.serviceAccounts.length===0;return/* @__PURE__ */ (0,w.jsx)(`div`,{className:`${h} px-4 py-8 md:px-8`,children:/* @__PURE__ */ (0,w.jsxs)(`section`,{className:`mx-auto grid w-full max-w-3xl gap-6`,children:[/* @__PURE__ */ (0,w.jsx)(v,{description:/* @__PURE__ */ (0,w.jsxs)(w.Fragment,{children:[`Setup that only Junior admins can see. Change who is an admin with`,` `,/* @__PURE__ */ (0,w.jsx)(`code`,{children:`junior admin grant <email>`}),` and`,` `,/* @__PURE__ */ (0,w.jsx)(`code`,{children:`junior admin revoke <email>`}),`.`]}),title:`Admin`}),/* @__PURE__ */ (0,w.jsx)(k,{accountsQuery:n}),r?/* @__PURE__ */ (0,w.jsx)(g,{padding:`md`,children:/* @__PURE__ */ (0,w.jsxs)(`div`,{className:`flex items-center gap-4`,children:[/* @__PURE__ */ (0,w.jsx)(`div`,{className:`grid size-10 shrink-0 place-items-center rounded-md border border-dashboard-border bg-dashboard-fill-soft text-dashboard-text-muted`,children:/* @__PURE__ */ (0,w.jsx)(s,{"aria-hidden":`true`,size:17})}),/* @__PURE__ */ (0,w.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:`No plugin has admin setup.`})]})}):t.length===0?null:/* @__PURE__ */ (0,w.jsx)(`div`,{className:`grid gap-3`,children:t.map(e=>/* @__PURE__ */ (0,w.jsx)(i,{className:`no-underline`,to:S(e.pluginName,e.id),children:/* @__PURE__ */ (0,w.jsx)(g,{padding:`md`,children:/* @__PURE__ */ (0,w.jsxs)(`div`,{className:`flex items-center gap-3`,children:[/* @__PURE__ */ (0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[/* @__PURE__ */ (0,w.jsx)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:e.pluginDisplayName}),/* @__PURE__ */ (0,w.jsx)(`h2`,{className:`mt-1 mb-0 font-display text-base font-medium text-dashboard-text`,children:e.label}),/* @__PURE__ */ (0,w.jsx)(`p`,{className:`mt-1 mb-0 text-sm text-dashboard-text-muted`,children:e.description})]}),/* @__PURE__ */ (0,w.jsx)(c,{"aria-hidden":`true`,className:`shrink-0 text-dashboard-text-muted`,size:16})]})})},`${e.pluginName}:${e.id}`))})]})})}export{A as AdminPage};
1
+ import{ot as e,pt as t,ut as n}from"./vendor-lthmb2su.js";import{S as r,r as i}from"./vendor-react-ggbyvons.js";import{t as a}from"./button-ygjnb239.js";import{$ as o,Bt as s,Pt as c}from"./vendor-icons-blmhaswc.js";import{C as l,I as u,R as d}from"./junior-g62bxb2t.js";import{i as f,n as p,o as m}from"./http-cdq677qt.js";import{r as h}from"./styles-j0007fov.js";import{t as g}from"./Card-hy4bfgq7.js";import{m as _,t as v}from"./PageHeader-bhl3orzi.js";import{y}from"./format-flkutk9e.js";import{t as b}from"./AnchorHeading-ixbupfij.js";import{X as x,ht as S,t as C}from"../client-ctcthgam.js";var w=r();const T=[`dashboard`,`service-accounts`];function E(e){return`/api/service-accounts/${encodeURIComponent(e)}`}function D(){return n({queryKey:T,queryFn:({signal:e})=>f(u,`/api/service-accounts`,e),refetchOnWindowFocus:!0,retry:!1})}function O(e){let t=e.userOAuth?`People who have not connected their own ${e.displayName} account use this account.`:`Everyone uses this account. People cannot connect their own ${e.displayName} account.`;return e.connected?`Connected by ${e.connectedBy??`the CLI`} ${y(e.connectedAt)}. ${t}`:`Not connected.${e.userOAuth?``:` ${e.displayName} is not available until you connect it.`} ${t} Sign in as the shared account, not as yourself.`}function k(n){let{accountsQuery:r}=n,i=t(),s=e({mutationFn:e=>m(d,E(e.provider),{}),onSuccess:({authorizationUrl:e},{popup:t})=>{t?t.closed||(t.opener=null,t.location.href=e):window.location.assign(e)},onError:(e,{popup:t})=>{t?.close()}}),c=e({mutationFn:e=>p(l,E(e.provider)),onSuccess:()=>i.invalidateQueries({queryKey:T})}),u=r.data?.serviceAccounts??[];if(r.isSuccess&&u.length===0)return null;let f=s.isPending||c.isPending,h=s.isPending?s.variables?.provider:c.isPending?c.variables?.provider:void 0,v=!r.data&&r.isError,y=s.isError?`Could not start the sign-in. Try again.`:c.isError?`Could not disconnect the account. Try again.`:v?`Could not load service accounts. Try again.`:void 0;return/* @__PURE__ */ (0,w.jsxs)(g,{as:`section`,padding:`md`,children:[/* @__PURE__ */ (0,w.jsx)(b,{anchor:`service-accounts`,className:`m-0 font-display text-base font-medium text-dashboard-text`,title:`Service accounts`}),/* @__PURE__ */ (0,w.jsxs)(`p`,{className:`mt-1 mb-4 text-sm text-dashboard-text-muted`,children:[`A shared account that Junior uses for a plugin. It can do only what its plugin allows, usually read. Everyone who can talk to`,` `,_(),` can use it, so give it only access that all of them may have.`]}),y?/* @__PURE__ */ (0,w.jsx)(x,{className:v?void 0:`mb-4`,children:y}):null,v?null:r.isPending?/* @__PURE__ */ (0,w.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:`Loading service accounts…`}):/* @__PURE__ */ (0,w.jsx)(`div`,{className:`space-y-2`,children:u.map(e=>/* @__PURE__ */ (0,w.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-dashboard-border-strong p-3`,children:[/* @__PURE__ */ (0,w.jsx)(o,{"aria-hidden":`true`,className:`shrink-0 text-dashboard-accent`,size:16}),/* @__PURE__ */ (0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[/* @__PURE__ */ (0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[/* @__PURE__ */ (0,w.jsx)(`p`,{className:`m-0 truncate text-sm font-semibold`,children:e.displayName}),/* @__PURE__ */ (0,w.jsx)(S,{size:`compact`,tone:e.connected?`success`:e.userOAuth?`neutral`:`warning`,children:e.connected?`connected`:`not connected`}),e.userOAuth?null:/* @__PURE__ */ (0,w.jsx)(S,{size:`compact`,tone:`neutral`,children:`shared only`})]}),/* @__PURE__ */ (0,w.jsx)(`p`,{className:`mt-1 mb-0 break-words text-xs text-dashboard-text-muted`,children:O(e)}),/* @__PURE__ */ (0,w.jsx)(`p`,{className:`mt-1 mb-0 break-words font-mono text-xs text-dashboard-text-faint`,children:e.tools.join(`, `)})]}),e.connected?/* @__PURE__ */ (0,w.jsx)(a,{"aria-busy":c.isPending&&h===e.provider,"aria-label":`Disconnect the ${e.displayName} service account`,disabled:f,onClick:()=>{s.reset(),c.mutate(e)},variant:`danger`,children:`Disconnect`}):null,/* @__PURE__ */ (0,w.jsx)(a,{"aria-busy":s.isPending&&h===e.provider,"aria-label":`${e.connected?`Reconnect`:`Connect`} the ${e.displayName} service account`,disabled:f,onClick:()=>{c.reset();let t=window.open(`about:blank`,`_blank`);s.mutate({provider:e.provider,popup:t})},children:s.isPending&&h===e.provider?`Connecting…`:e.connected?`Reconnect`:`Connect`})]},e.provider))})]})}function A(e){let t=e.pages.filter(e=>e.navigation===`admin`),n=D(),r=t.length===0&&n.data?.serviceAccounts.length===0;return/* @__PURE__ */ (0,w.jsx)(`div`,{className:`${h} px-4 py-8 md:px-8`,children:/* @__PURE__ */ (0,w.jsxs)(`section`,{className:`mx-auto grid w-full max-w-3xl gap-6`,children:[/* @__PURE__ */ (0,w.jsx)(v,{description:/* @__PURE__ */ (0,w.jsxs)(w.Fragment,{children:[`Setup that only Junior admins can see. Change who is an admin with`,` `,/* @__PURE__ */ (0,w.jsx)(`code`,{children:`junior admin grant <email>`}),` and`,` `,/* @__PURE__ */ (0,w.jsx)(`code`,{children:`junior admin revoke <email>`}),`.`]}),title:`Admin`}),/* @__PURE__ */ (0,w.jsx)(k,{accountsQuery:n}),r?/* @__PURE__ */ (0,w.jsx)(g,{padding:`md`,children:/* @__PURE__ */ (0,w.jsxs)(`div`,{className:`flex items-center gap-4`,children:[/* @__PURE__ */ (0,w.jsx)(`div`,{className:`grid size-10 shrink-0 place-items-center rounded-md border border-dashboard-border bg-dashboard-fill-soft text-dashboard-text-muted`,children:/* @__PURE__ */ (0,w.jsx)(s,{"aria-hidden":`true`,size:17})}),/* @__PURE__ */ (0,w.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:`No plugin has admin setup.`})]})}):t.length===0?null:/* @__PURE__ */ (0,w.jsx)(`div`,{className:`grid gap-3`,children:t.map(e=>/* @__PURE__ */ (0,w.jsx)(i,{className:`no-underline`,to:C(e.pluginName,e.id),children:/* @__PURE__ */ (0,w.jsx)(g,{padding:`md`,children:/* @__PURE__ */ (0,w.jsxs)(`div`,{className:`flex items-center gap-3`,children:[/* @__PURE__ */ (0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[/* @__PURE__ */ (0,w.jsx)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:e.pluginDisplayName}),/* @__PURE__ */ (0,w.jsx)(`h2`,{className:`mt-1 mb-0 font-display text-base font-medium text-dashboard-text`,children:e.label}),/* @__PURE__ */ (0,w.jsx)(`p`,{className:`mt-1 mb-0 text-sm text-dashboard-text-muted`,children:e.description})]}),/* @__PURE__ */ (0,w.jsx)(c,{"aria-hidden":`true`,className:`shrink-0 text-dashboard-text-muted`,size:16})]})})},`${e.pluginName}:${e.id}`))})]})})}export{A as AdminPage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n,p as r,r as i}from"./vendor-react-ggbyvons.js";import{X as a}from"./vendor-icons-mxz7yi04.js";import{t as o}from"./styles-j0007fov.js";var s=/* @__PURE__ */ e(t(),1),c=n();function l(e){return`${e}-title`}function u(e){let{hash:t,key:n,search:u}=r();(0,s.useEffect)(()=>{if(t!==`#${e.anchor}`)return;let n=document.getElementById(e.anchor);if(!n)return;let r=document.querySelector(`[data-dashboard-chrome]`)?.getBoundingClientRect().height??0;n.style.scrollMarginTop=`${r+40}px`,n.scrollIntoView()},[t,n,e.anchor]);let d=l(e.anchor);return/* @__PURE__ */ (0,c.jsxs)(`h2`,{"aria-labelledby":d,className:o(`group/anchor`,e.className),id:e.anchor,children:[/* @__PURE__ */ (0,c.jsx)(`span`,{id:d,children:e.title}),/* @__PURE__ */ (0,c.jsx)(i,{"aria-label":`Link to ${e.label??e.title}`,className:`ml-2 inline-flex rounded-sm align-middle text-dashboard-text-muted opacity-0 transition-opacity group-hover/anchor:opacity-100 hover:text-dashboard-text focus-visible:opacity-100 pointer-coarse:opacity-100 motion-reduce:transition-none`,to:{hash:e.anchor,search:u},children:/* @__PURE__ */ (0,c.jsx)(a,{"aria-hidden":`true`,size:14})})]})}export{l as n,u as t};
1
+ import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n,p as r,r as i}from"./vendor-react-ggbyvons.js";import{X as a}from"./vendor-icons-blmhaswc.js";import{t as o}from"./styles-j0007fov.js";var s=/* @__PURE__ */ e(t(),1),c=n();function l(e){return`${e}-title`}function u(e){let{hash:t,key:n,search:u}=r();(0,s.useEffect)(()=>{if(t!==`#${e.anchor}`)return;let n=document.getElementById(e.anchor);if(!n)return;let r=document.querySelector(`[data-dashboard-chrome]`)?.getBoundingClientRect().height??0;n.style.scrollMarginTop=`${r+40}px`,n.scrollIntoView()},[t,n,e.anchor]);let d=l(e.anchor);return/* @__PURE__ */ (0,c.jsxs)(`h2`,{"aria-labelledby":d,className:o(`group/anchor`,e.className),id:e.anchor,children:[/* @__PURE__ */ (0,c.jsx)(`span`,{id:d,children:e.title}),/* @__PURE__ */ (0,c.jsx)(i,{"aria-label":`Link to ${e.label??e.title}`,className:`ml-2 inline-flex rounded-sm align-middle text-dashboard-text-muted opacity-0 transition-opacity group-hover/anchor:opacity-100 hover:text-dashboard-text focus-visible:opacity-100 pointer-coarse:opacity-100 motion-reduce:transition-none`,to:{hash:e.anchor,search:u},children:/* @__PURE__ */ (0,c.jsx)(a,{"aria-hidden":`true`,size:14})})]})}export{l as n,u as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{nt as t}from"./vendor-lthmb2su.js";import{C as n}from"./vendor-react-ggbyvons.js";import{$t as r,At as i,Bt as a,Ct as o,D as s,Dt as c,E as l,Et as u,F as d,G as f,Ht as p,I as m,K as h,M as g,Mt as _,N as v,Nt as y,O as b,Pt as x,Qt as S,R as C,S as ee,T as w,Tt as T,U as E,Vt as D,Wt as O,X as k,Xt as A,Yt as j,Z as M,Zt as te,b as N,bt as P,ct as ne,dt as re,et as ie,ft as F,gt as I,j as ae,k as oe,kt as L,mt as se,pt as ce,q as le,rt as ue,st as de,ut as R,w as fe,wt as pe,x as me,y as z,zt as B}from"./chart-myr1oeen.js";var V=/* @__PURE__ */ e(n());function H(){return H=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},H.apply(null,arguments)}var U=e=>{var{cx:n,cy:r,r:i,className:a}=e,o=t(`recharts-dot`,a);return p(n)&&p(r)&&p(i)?/*#__PURE__*/ V.createElement(`circle`,H({},S(e),x(e),{className:o,cx:n,cy:r,r:i})):null},he=[`points`];function W(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 G(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?W(Object(n),!0).forEach(function(t){ge(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):W(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ge(e,t,n){return(t=_e(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _e(e){var t=ve(e,`string`);return typeof t==`symbol`?t:t+``}function ve(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)}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 ye(e,t){if(e==null)return{};var n,r,i=be(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 be(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 xe(e){var{option:n,dotProps:r,className:i}=e;if(/*#__PURE__*/ (0,V.isValidElement)(n))return/*#__PURE__*/ (0,V.cloneElement)(n,r);if(typeof n==`function`)return n(r);var a=t(i,typeof n==`boolean`?``:n.className),o=r??{},{points:s}=o,c=ye(o,he);return/*#__PURE__*/ V.createElement(U,K({},c,{className:a}))}function Se(e,t){return e==null?!1:t?!0:e.length===1}function Ce(e){var{points:t,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:s,clipPathId:c,zIndex:l=M.scatter}=e;if(!Se(t,n))return null;var u=ae(n),f=te(n),p=t.map((e,r)=>{var s=G(G(G({r:3},o),f),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:a,value:e.value,payload:e.payload,points:t});return/*#__PURE__*/ V.createElement(xe,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),m={};return s&&c!=null&&(m.clipPath=`url(#clipPath-${u?``:`dots-`}${c})`),/*#__PURE__*/ V.createElement(d,{zIndex:l},/*#__PURE__*/ V.createElement(j,K({className:r},m),p))}function q(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 J(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?q(Object(n),!0).forEach(function(t){we(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):q(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function we(e,t,n){return(t=Te(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Te(e){var t=Ee(e,`string`);return typeof t==`symbol`?t:t+``}function Ee(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 De=e=>{var{point:t,childIndex:n,mainColor:i,activeDot:a,dataKey:o,clipPath:s}=e;if(a===!1||t.x==null||t.y==null)return null;var c=J(J(J({},{index:n,dataKey:o,cx:t.x,cy:t.y,r:4,fill:i??`none`,strokeWidth:2,stroke:`#fff`,payload:t.payload,value:t.value}),r(a)),x(a)),l=/*#__PURE__*/ (0,V.isValidElement)(a)?/*#__PURE__*/ (0,V.cloneElement)(a,c):typeof a==`function`?a(c):/*#__PURE__*/ V.createElement(U,c);return/*#__PURE__*/ V.createElement(j,{className:`recharts-active-dot`,clipPath:s},l)};function Y(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=M.activeDot}=e,s=_(C),c=fe();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return D(l)?null:/*#__PURE__*/ V.createElement(d,{zIndex:o},/*#__PURE__*/ V.createElement(De,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}function Oe(e){var t=r(e),n=3,i=2;if(t!=null){var{r:a,strokeWidth:o}=t,s=Number(a),c=Number(o);return(Number.isNaN(s)||s<0)&&(s=n),(Number.isNaN(c)||c<0)&&(c=i),{r:s,strokeWidth:c}}return{r:n,strokeWidth:i}}var ke=(e,t,n)=>E(e,`xAxis`,z(e,t),n),Ae=(e,t,n)=>h(e,`xAxis`,z(e,t),n),je=(e,t,n)=>E(e,`yAxis`,N(e,t),n),Me=(e,t,n)=>h(e,`yAxis`,N(e,t),n),Ne=i([F,ke,je,Ae,Me],(e,t,n,r,i)=>c(e,`xAxis`)?P(t,r,!1):P(n,i,!1)),Pe=i([le,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),Fe=e=>{var t=F(e);return c(t,`xAxis`)?`yAxis`:`xAxis`},Ie=(e,t)=>Fe(e)===`yAxis`?N(e,t):z(e,t),Le=i([Pe,(e,t,n)=>f(e,Fe(e),Ie(e,t),n)],(e,t)=>{if(e!=null&&t!=null){var{stackId:n}=e,r=k(e);if(n!=null&&r!=null){var i=(t[n]?.stackedData)?.find(e=>e.key===r);if(i!=null)return i.map(e=>[e[0],e[1]])}}}),Re=i([F,ke,je,Ae,Me,Le,ue,Ne,Pe,ie],(e,t,n,r,i,a,o,s,c,l)=>{var{chartData:u,dataStartIndex:d,dataEndIndex:f}=o;if(!(c==null||e!==`horizontal`&&e!==`vertical`||t==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null)){var{data:p}=c,m=p&&p.length>0?p:u?.slice(d,f+1);if(m!=null)return st({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:d,areaSettings:c,stackedData:a,displayedData:m,chartBaseValue:l,bandSize:s})}}),ze=[`id`],Be=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function X(){return X=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},X.apply(null,arguments)}function Ve(e,t){if(e==null)return{};var n,r,i=He(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 He(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 Ue(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 Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ue(Object(n),!0).forEach(function(t){We(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ue(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function We(e,t,n){return(t=Ge(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ge(e){var t=Ke(e,`string`);return typeof t==`symbol`?t:t+``}function Ke(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)}function Q(e,t){return e&&e!==`none`?e:t}var qe=e=>{var{dataKey:t,name:n,stroke:r,fill:i,legendType:a,hide:o}=e;return[{inactive:o,dataKey:t,type:a,color:Q(r,i),value:T(n,t),payload:e}]},Je=/*#__PURE__*/ V.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:n,getPosition:O,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:T(o,t),hide:s,type:l,color:Q(r,a),unit:c,graphicalItemId:u}};return/*#__PURE__*/ V.createElement(oe,{tooltipEntrySettings:d})});function Ye(e){var{clipPathId:t,points:n,props:r}=e,{needClip:i,dot:a,dataKey:o}=r,s=S(r);return/*#__PURE__*/ V.createElement(Ce,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function Xe(e){var{showLabels:t,children:n,points:r}=e,i=r.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return/*#__PURE__*/ V.createElement(g,{value:t?i:void 0},n)}function Ze(e){var{points:t,baseLine:n,needClip:r,clipPathId:i,props:a}=e,{layout:o,type:s,stroke:c,connectNulls:l,isRange:u}=a,{id:d}=a,f=Ve(a,ze),p=S(f),m=A(f);return/*#__PURE__*/ V.createElement(V.Fragment,null,t?.length>1&&/*#__PURE__*/ V.createElement(j,{clipPath:r?`url(#clipPath-${i})`:void 0},/*#__PURE__*/ V.createElement(R,X({},m,{id:d,points:t,connectNulls:l,type:s,baseLine:n,layout:o,stroke:`none`,className:`recharts-area-area`})),c!==`none`&&/*#__PURE__*/ V.createElement(R,X({},p,{className:`recharts-area-curve`,layout:o,type:s,connectNulls:l,fill:`none`,points:t})),c!==`none`&&u&&Array.isArray(n)&&/*#__PURE__*/ V.createElement(R,X({},p,{className:`recharts-area-curve`,layout:o,type:s,connectNulls:l,fill:`none`,points:n}))),/*#__PURE__*/ V.createElement(Ye,{points:t,props:f,clipPathId:i}))}function Qe(e){var{alpha:t,baseLine:n,points:r,strokeWidth:i}=e,a=r[0]?.y,o=r[r.length-1]?.y;if(!L(a)||!L(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.x||0));return p(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.x||0),c)),p(c)?/*#__PURE__*/ V.createElement(`rect`,{x:0,y:a<o?a:a-s,width:c+(i?parseInt(`${i}`,10):1),height:Math.floor(s)}):null}function $e(e){var{alpha:t,baseLine:n,points:r,strokeWidth:i}=e,a=r[0]?.x,o=r[r.length-1]?.x;if(!L(a)||!L(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.y||0));return p(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.y||0),c)),p(c)?/*#__PURE__*/ V.createElement(`rect`,{x:a<o?a:a-s,y:0,width:s,height:Math.floor(c+(i?parseInt(`${i}`,10):1))}):null}function et(e){var{alpha:t,layout:n,points:r,baseLine:i,strokeWidth:a}=e;return n===`vertical`?/*#__PURE__*/ V.createElement(Qe,{alpha:t,points:r,baseLine:i,strokeWidth:a}):/*#__PURE__*/ V.createElement($e,{alpha:t,points:r,baseLine:i,strokeWidth:a})}function tt(e){var{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:o}=e,{points:s,baseLine:c,isAnimationActive:l,animationBegin:u,animationDuration:d,animationEasing:f,onAnimationStart:m,onAnimationEnd:h}=r,g=(0,V.useMemo)(()=>({points:s,baseLine:c}),[s,c]),_=de(g,`recharts-area-`),y=ce(),[b,x]=(0,V.useState)(!1),S=!b,C=(0,V.useCallback)(()=>{typeof h==`function`&&h(),x(!1)},[h]),ee=(0,V.useCallback)(()=>{typeof m==`function`&&m(),x(!0)},[m]);if(y==null)return null;var w=i.current,T=o.current;return/*#__PURE__*/ V.createElement(Xe,{showLabels:S,points:s},r.children,/*#__PURE__*/ V.createElement(ne,{animationId:_,begin:u,duration:d,isActive:l,easing:f,onAnimationEnd:C,onAnimationStart:ee,key:_},e=>{if(w){var u=w.length/s.length,d=e===1?s:s.map((t,n)=>{var r=Math.floor(n*u);if(w[r]){var i=w[r];return Z(Z({},t),{},{x:B(i.x,t.x,e),y:B(i.y,t.y,e)})}return t}),f=p(c)?B(T,c,e):D(c)||a(c)?B(T,0,e):c.map((t,n)=>{var r=Math.floor(n*u);if(Array.isArray(T)&&T[r]){var i=T[r];return Z(Z({},t),{},{x:B(i.x,t.x,e),y:B(i.y,t.y,e)})}return t});return e>0&&(i.current=d,o.current=f),/*#__PURE__*/ V.createElement(Ze,{points:d,baseLine:f,needClip:t,clipPathId:n,props:r})}return e>0&&(i.current=s,o.current=c),/*#__PURE__*/ V.createElement(j,null,l&&/*#__PURE__*/ V.createElement(`defs`,null,/*#__PURE__*/ V.createElement(`clipPath`,{id:`animationClipPath-${n}`},/*#__PURE__*/ V.createElement(et,{alpha:e,points:s,baseLine:c,layout:y,strokeWidth:r.strokeWidth}))),/*#__PURE__*/ V.createElement(j,{clipPath:`url(#animationClipPath-${n})`},/*#__PURE__*/ V.createElement(Ze,{points:s,baseLine:c,needClip:t,clipPathId:n,props:r})))}),/*#__PURE__*/ V.createElement(v,{label:r.label}))}function nt(e){var{needClip:t,clipPathId:n,props:r}=e,i=(0,V.useRef)(null),a=(0,V.useRef)();return/*#__PURE__*/ V.createElement(tt,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var rt=class extends V.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:a,left:o,needClip:s,xAxisId:c,yAxisId:l,width:u,height:f,id:p,baseLine:m,zIndex:h}=this.props;if(e)return null;var g=t(`recharts-area`,i),_=p,{r:v,strokeWidth:y}=Oe(n),b=ae(n),x=v*2+y,S=s?`url(#clipPath-${b?``:`dots-`}${_})`:void 0;return/*#__PURE__*/ V.createElement(d,{zIndex:h},/*#__PURE__*/ V.createElement(j,{className:g},s&&/*#__PURE__*/ V.createElement(`defs`,null,/*#__PURE__*/ V.createElement(me,{clipPathId:_,xAxisId:c,yAxisId:l}),!b&&/*#__PURE__*/ V.createElement(`clipPath`,{id:`clipPath-dots-${_}`},/*#__PURE__*/ V.createElement(`rect`,{x:o-x/2,y:a-x/2,width:u+x,height:f+x}))),/*#__PURE__*/ V.createElement(nt,{needClip:s,clipPathId:_,props:this.props})),/*#__PURE__*/ V.createElement(Y,{points:r,mainColor:Q(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:S}),this.props.isRange&&Array.isArray(m)&&/*#__PURE__*/ V.createElement(Y,{points:m,mainColor:Q(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:S}))}},it={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!1,fill:`#3182bd`,fillOpacity:.6,hide:!1,isAnimationActive:`auto`,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,type:`linear`,label:!1,xAxisId:0,yAxisId:0,zIndex:M.area};function at(e){var{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,connectNulls:a,dot:o,fill:s,fillOpacity:c,hide:l,isAnimationActive:u,legendType:d,stroke:f,xAxisId:p,yAxisId:h}=e,g=Ve(e,Be),v=se(),y=m(),{needClip:b}=ee(p,h),x=I(),{points:S,isRange:C,baseLine:T}=_(t=>Re(t,e.id,x))??{},E=w();if(v!==`horizontal`&&v!==`vertical`||E==null||y!==`AreaChart`&&y!==`ComposedChart`)return null;var{height:D,width:O,x:k,y:A}=E;return!S||!S.length?null:/*#__PURE__*/ V.createElement(rt,X({},g,{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,baseLine:T,connectNulls:a,dot:o,fill:s,fillOpacity:c,height:D,hide:l,layout:v,isAnimationActive:u,isRange:C,legendType:d,needClip:b,points:S,stroke:f,width:O,left:k,top:A,xAxisId:p,yAxisId:h}))}var ot=(e,t,n,r,i)=>{var a=n??t;if(p(a))return a;var o=e===`horizontal`?i:r,s=o.scale.domain();if(o.type===`number`){var c=Math.max(s[0],s[1]),l=Math.min(s[0],s[1]);return a===`dataMin`?l:a===`dataMax`||c<0?c:Math.max(Math.min(s[0],s[1]),0)}return a===`dataMin`?s[0]:a===`dataMax`?s[1]:s[0]};function st(e){var{areaSettings:{connectNulls:t,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:s,xAxis:c,yAxis:l,displayedData:d,dataStartIndex:f,xAxisTicks:p,yAxisTicks:m,bandSize:h}=e,g=i&&i.length,_=ot(a,s,n,c,l),v=a===`horizontal`,y=!1,b=d.map((e,n)=>{var a;if(g)a=i[f+n];else{var s=u(e,r);Array.isArray(s)?(a=s,y=!0):a=[_,s]}var d=a?.[1]??null,b=d==null||g&&!t&&u(e,r)==null;return v?{x:o({axis:c,ticks:p,bandSize:h,entry:e,index:n}),y:b?null:l.scale.map(d)??null,value:a,payload:e}:{x:b?null:c.scale.map(d)??null,y:o({axis:l,ticks:m,bandSize:h,entry:e,index:n}),value:a,payload:e}});return{points:b,baseLine:(g||y?b.map(e=>{var t=Array.isArray(e.value)?e.value[0]:null;return v?{x:e.x,y:t!=null&&e.y!=null?l.scale.map(t)??null:null,payload:e.payload}:{x:t==null?null:c.scale.map(t)??null,y:e.y,payload:e.payload}}):v?l.scale.map(_):c.scale.map(_))??0,isRange:y}}function ct(e){var t=y(e,it),n=I();return/*#__PURE__*/ V.createElement(s,{id:t.id,type:`area`},e=>/*#__PURE__*/ V.createElement(V.Fragment,null,/*#__PURE__*/ V.createElement(b,{legendPayload:qe(t)}),/*#__PURE__*/ V.createElement(Je,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),/*#__PURE__*/ V.createElement(l,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:pe(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),/*#__PURE__*/ V.createElement(at,X({},t,{id:e}))))}var $=/*#__PURE__*/ V.memo(ct,re);$.displayName=`Area`;export{$ as t};
1
+ import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{nt as t}from"./vendor-lthmb2su.js";import{C as n}from"./vendor-react-ggbyvons.js";import{$t as r,At as i,Bt as a,Ct as o,D as s,Dt as c,E as l,Et as u,F as d,G as f,Ht as p,I as m,K as h,M as g,Mt as _,N as v,Nt as y,O as b,Pt as x,Qt as S,R as C,S as ee,T as w,Tt as T,U as E,Vt as D,Wt as O,X as k,Xt as A,Yt as j,Z as M,Zt as te,b as N,bt as P,ct as ne,dt as re,et as ie,ft as F,gt as I,j as ae,k as oe,kt as L,mt as se,pt as ce,q as le,rt as ue,st as de,ut as R,w as fe,wt as pe,x as me,y as z,zt as B}from"./chart-il2ahs5y.js";var V=/* @__PURE__ */ e(n());function H(){return H=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},H.apply(null,arguments)}var U=e=>{var{cx:n,cy:r,r:i,className:a}=e,o=t(`recharts-dot`,a);return p(n)&&p(r)&&p(i)?/*#__PURE__*/ V.createElement(`circle`,H({},S(e),x(e),{className:o,cx:n,cy:r,r:i})):null},he=[`points`];function W(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 G(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?W(Object(n),!0).forEach(function(t){ge(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):W(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ge(e,t,n){return(t=_e(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _e(e){var t=ve(e,`string`);return typeof t==`symbol`?t:t+``}function ve(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)}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 ye(e,t){if(e==null)return{};var n,r,i=be(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 be(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 xe(e){var{option:n,dotProps:r,className:i}=e;if(/*#__PURE__*/ (0,V.isValidElement)(n))return/*#__PURE__*/ (0,V.cloneElement)(n,r);if(typeof n==`function`)return n(r);var a=t(i,typeof n==`boolean`?``:n.className),o=r??{},{points:s}=o,c=ye(o,he);return/*#__PURE__*/ V.createElement(U,K({},c,{className:a}))}function Se(e,t){return e==null?!1:t?!0:e.length===1}function Ce(e){var{points:t,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:s,clipPathId:c,zIndex:l=M.scatter}=e;if(!Se(t,n))return null;var u=ae(n),f=te(n),p=t.map((e,r)=>{var s=G(G(G({r:3},o),f),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:a,value:e.value,payload:e.payload,points:t});return/*#__PURE__*/ V.createElement(xe,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),m={};return s&&c!=null&&(m.clipPath=`url(#clipPath-${u?``:`dots-`}${c})`),/*#__PURE__*/ V.createElement(d,{zIndex:l},/*#__PURE__*/ V.createElement(j,K({className:r},m),p))}function q(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 J(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?q(Object(n),!0).forEach(function(t){we(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):q(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function we(e,t,n){return(t=Te(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Te(e){var t=Ee(e,`string`);return typeof t==`symbol`?t:t+``}function Ee(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 De=e=>{var{point:t,childIndex:n,mainColor:i,activeDot:a,dataKey:o,clipPath:s}=e;if(a===!1||t.x==null||t.y==null)return null;var c=J(J(J({},{index:n,dataKey:o,cx:t.x,cy:t.y,r:4,fill:i??`none`,strokeWidth:2,stroke:`#fff`,payload:t.payload,value:t.value}),r(a)),x(a)),l=/*#__PURE__*/ (0,V.isValidElement)(a)?/*#__PURE__*/ (0,V.cloneElement)(a,c):typeof a==`function`?a(c):/*#__PURE__*/ V.createElement(U,c);return/*#__PURE__*/ V.createElement(j,{className:`recharts-active-dot`,clipPath:s},l)};function Y(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=M.activeDot}=e,s=_(C),c=fe();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return D(l)?null:/*#__PURE__*/ V.createElement(d,{zIndex:o},/*#__PURE__*/ V.createElement(De,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}function Oe(e){var t=r(e),n=3,i=2;if(t!=null){var{r:a,strokeWidth:o}=t,s=Number(a),c=Number(o);return(Number.isNaN(s)||s<0)&&(s=n),(Number.isNaN(c)||c<0)&&(c=i),{r:s,strokeWidth:c}}return{r:n,strokeWidth:i}}var ke=(e,t,n)=>E(e,`xAxis`,z(e,t),n),Ae=(e,t,n)=>h(e,`xAxis`,z(e,t),n),je=(e,t,n)=>E(e,`yAxis`,N(e,t),n),Me=(e,t,n)=>h(e,`yAxis`,N(e,t),n),Ne=i([F,ke,je,Ae,Me],(e,t,n,r,i)=>c(e,`xAxis`)?P(t,r,!1):P(n,i,!1)),Pe=i([le,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),Fe=e=>{var t=F(e);return c(t,`xAxis`)?`yAxis`:`xAxis`},Ie=(e,t)=>Fe(e)===`yAxis`?N(e,t):z(e,t),Le=i([Pe,(e,t,n)=>f(e,Fe(e),Ie(e,t),n)],(e,t)=>{if(e!=null&&t!=null){var{stackId:n}=e,r=k(e);if(n!=null&&r!=null){var i=(t[n]?.stackedData)?.find(e=>e.key===r);if(i!=null)return i.map(e=>[e[0],e[1]])}}}),Re=i([F,ke,je,Ae,Me,Le,ue,Ne,Pe,ie],(e,t,n,r,i,a,o,s,c,l)=>{var{chartData:u,dataStartIndex:d,dataEndIndex:f}=o;if(!(c==null||e!==`horizontal`&&e!==`vertical`||t==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null)){var{data:p}=c,m=p&&p.length>0?p:u?.slice(d,f+1);if(m!=null)return st({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:d,areaSettings:c,stackedData:a,displayedData:m,chartBaseValue:l,bandSize:s})}}),ze=[`id`],Be=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function X(){return X=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},X.apply(null,arguments)}function Ve(e,t){if(e==null)return{};var n,r,i=He(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 He(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 Ue(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 Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ue(Object(n),!0).forEach(function(t){We(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ue(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function We(e,t,n){return(t=Ge(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ge(e){var t=Ke(e,`string`);return typeof t==`symbol`?t:t+``}function Ke(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)}function Q(e,t){return e&&e!==`none`?e:t}var qe=e=>{var{dataKey:t,name:n,stroke:r,fill:i,legendType:a,hide:o}=e;return[{inactive:o,dataKey:t,type:a,color:Q(r,i),value:T(n,t),payload:e}]},Je=/*#__PURE__*/ V.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:n,getPosition:O,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:T(o,t),hide:s,type:l,color:Q(r,a),unit:c,graphicalItemId:u}};return/*#__PURE__*/ V.createElement(oe,{tooltipEntrySettings:d})});function Ye(e){var{clipPathId:t,points:n,props:r}=e,{needClip:i,dot:a,dataKey:o}=r,s=S(r);return/*#__PURE__*/ V.createElement(Ce,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function Xe(e){var{showLabels:t,children:n,points:r}=e,i=r.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return/*#__PURE__*/ V.createElement(g,{value:t?i:void 0},n)}function Ze(e){var{points:t,baseLine:n,needClip:r,clipPathId:i,props:a}=e,{layout:o,type:s,stroke:c,connectNulls:l,isRange:u}=a,{id:d}=a,f=Ve(a,ze),p=S(f),m=A(f);return/*#__PURE__*/ V.createElement(V.Fragment,null,t?.length>1&&/*#__PURE__*/ V.createElement(j,{clipPath:r?`url(#clipPath-${i})`:void 0},/*#__PURE__*/ V.createElement(R,X({},m,{id:d,points:t,connectNulls:l,type:s,baseLine:n,layout:o,stroke:`none`,className:`recharts-area-area`})),c!==`none`&&/*#__PURE__*/ V.createElement(R,X({},p,{className:`recharts-area-curve`,layout:o,type:s,connectNulls:l,fill:`none`,points:t})),c!==`none`&&u&&Array.isArray(n)&&/*#__PURE__*/ V.createElement(R,X({},p,{className:`recharts-area-curve`,layout:o,type:s,connectNulls:l,fill:`none`,points:n}))),/*#__PURE__*/ V.createElement(Ye,{points:t,props:f,clipPathId:i}))}function Qe(e){var{alpha:t,baseLine:n,points:r,strokeWidth:i}=e,a=r[0]?.y,o=r[r.length-1]?.y;if(!L(a)||!L(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.x||0));return p(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.x||0),c)),p(c)?/*#__PURE__*/ V.createElement(`rect`,{x:0,y:a<o?a:a-s,width:c+(i?parseInt(`${i}`,10):1),height:Math.floor(s)}):null}function $e(e){var{alpha:t,baseLine:n,points:r,strokeWidth:i}=e,a=r[0]?.x,o=r[r.length-1]?.x;if(!L(a)||!L(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.y||0));return p(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.y||0),c)),p(c)?/*#__PURE__*/ V.createElement(`rect`,{x:a<o?a:a-s,y:0,width:s,height:Math.floor(c+(i?parseInt(`${i}`,10):1))}):null}function et(e){var{alpha:t,layout:n,points:r,baseLine:i,strokeWidth:a}=e;return n===`vertical`?/*#__PURE__*/ V.createElement(Qe,{alpha:t,points:r,baseLine:i,strokeWidth:a}):/*#__PURE__*/ V.createElement($e,{alpha:t,points:r,baseLine:i,strokeWidth:a})}function tt(e){var{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:o}=e,{points:s,baseLine:c,isAnimationActive:l,animationBegin:u,animationDuration:d,animationEasing:f,onAnimationStart:m,onAnimationEnd:h}=r,g=(0,V.useMemo)(()=>({points:s,baseLine:c}),[s,c]),_=de(g,`recharts-area-`),y=ce(),[b,x]=(0,V.useState)(!1),S=!b,C=(0,V.useCallback)(()=>{typeof h==`function`&&h(),x(!1)},[h]),ee=(0,V.useCallback)(()=>{typeof m==`function`&&m(),x(!0)},[m]);if(y==null)return null;var w=i.current,T=o.current;return/*#__PURE__*/ V.createElement(Xe,{showLabels:S,points:s},r.children,/*#__PURE__*/ V.createElement(ne,{animationId:_,begin:u,duration:d,isActive:l,easing:f,onAnimationEnd:C,onAnimationStart:ee,key:_},e=>{if(w){var u=w.length/s.length,d=e===1?s:s.map((t,n)=>{var r=Math.floor(n*u);if(w[r]){var i=w[r];return Z(Z({},t),{},{x:B(i.x,t.x,e),y:B(i.y,t.y,e)})}return t}),f=p(c)?B(T,c,e):D(c)||a(c)?B(T,0,e):c.map((t,n)=>{var r=Math.floor(n*u);if(Array.isArray(T)&&T[r]){var i=T[r];return Z(Z({},t),{},{x:B(i.x,t.x,e),y:B(i.y,t.y,e)})}return t});return e>0&&(i.current=d,o.current=f),/*#__PURE__*/ V.createElement(Ze,{points:d,baseLine:f,needClip:t,clipPathId:n,props:r})}return e>0&&(i.current=s,o.current=c),/*#__PURE__*/ V.createElement(j,null,l&&/*#__PURE__*/ V.createElement(`defs`,null,/*#__PURE__*/ V.createElement(`clipPath`,{id:`animationClipPath-${n}`},/*#__PURE__*/ V.createElement(et,{alpha:e,points:s,baseLine:c,layout:y,strokeWidth:r.strokeWidth}))),/*#__PURE__*/ V.createElement(j,{clipPath:`url(#animationClipPath-${n})`},/*#__PURE__*/ V.createElement(Ze,{points:s,baseLine:c,needClip:t,clipPathId:n,props:r})))}),/*#__PURE__*/ V.createElement(v,{label:r.label}))}function nt(e){var{needClip:t,clipPathId:n,props:r}=e,i=(0,V.useRef)(null),a=(0,V.useRef)();return/*#__PURE__*/ V.createElement(tt,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var rt=class extends V.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:a,left:o,needClip:s,xAxisId:c,yAxisId:l,width:u,height:f,id:p,baseLine:m,zIndex:h}=this.props;if(e)return null;var g=t(`recharts-area`,i),_=p,{r:v,strokeWidth:y}=Oe(n),b=ae(n),x=v*2+y,S=s?`url(#clipPath-${b?``:`dots-`}${_})`:void 0;return/*#__PURE__*/ V.createElement(d,{zIndex:h},/*#__PURE__*/ V.createElement(j,{className:g},s&&/*#__PURE__*/ V.createElement(`defs`,null,/*#__PURE__*/ V.createElement(me,{clipPathId:_,xAxisId:c,yAxisId:l}),!b&&/*#__PURE__*/ V.createElement(`clipPath`,{id:`clipPath-dots-${_}`},/*#__PURE__*/ V.createElement(`rect`,{x:o-x/2,y:a-x/2,width:u+x,height:f+x}))),/*#__PURE__*/ V.createElement(nt,{needClip:s,clipPathId:_,props:this.props})),/*#__PURE__*/ V.createElement(Y,{points:r,mainColor:Q(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:S}),this.props.isRange&&Array.isArray(m)&&/*#__PURE__*/ V.createElement(Y,{points:m,mainColor:Q(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:S}))}},it={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!1,fill:`#3182bd`,fillOpacity:.6,hide:!1,isAnimationActive:`auto`,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,type:`linear`,label:!1,xAxisId:0,yAxisId:0,zIndex:M.area};function at(e){var{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,connectNulls:a,dot:o,fill:s,fillOpacity:c,hide:l,isAnimationActive:u,legendType:d,stroke:f,xAxisId:p,yAxisId:h}=e,g=Ve(e,Be),v=se(),y=m(),{needClip:b}=ee(p,h),x=I(),{points:S,isRange:C,baseLine:T}=_(t=>Re(t,e.id,x))??{},E=w();if(v!==`horizontal`&&v!==`vertical`||E==null||y!==`AreaChart`&&y!==`ComposedChart`)return null;var{height:D,width:O,x:k,y:A}=E;return!S||!S.length?null:/*#__PURE__*/ V.createElement(rt,X({},g,{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,baseLine:T,connectNulls:a,dot:o,fill:s,fillOpacity:c,height:D,hide:l,layout:v,isAnimationActive:u,isRange:C,legendType:d,needClip:b,points:S,stroke:f,width:O,left:k,top:A,xAxisId:p,yAxisId:h}))}var ot=(e,t,n,r,i)=>{var a=n??t;if(p(a))return a;var o=e===`horizontal`?i:r,s=o.scale.domain();if(o.type===`number`){var c=Math.max(s[0],s[1]),l=Math.min(s[0],s[1]);return a===`dataMin`?l:a===`dataMax`||c<0?c:Math.max(Math.min(s[0],s[1]),0)}return a===`dataMin`?s[0]:a===`dataMax`?s[1]:s[0]};function st(e){var{areaSettings:{connectNulls:t,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:s,xAxis:c,yAxis:l,displayedData:d,dataStartIndex:f,xAxisTicks:p,yAxisTicks:m,bandSize:h}=e,g=i&&i.length,_=ot(a,s,n,c,l),v=a===`horizontal`,y=!1,b=d.map((e,n)=>{var a;if(g)a=i[f+n];else{var s=u(e,r);Array.isArray(s)?(a=s,y=!0):a=[_,s]}var d=a?.[1]??null,b=d==null||g&&!t&&u(e,r)==null;return v?{x:o({axis:c,ticks:p,bandSize:h,entry:e,index:n}),y:b?null:l.scale.map(d)??null,value:a,payload:e}:{x:b?null:c.scale.map(d)??null,y:o({axis:l,ticks:m,bandSize:h,entry:e,index:n}),value:a,payload:e}});return{points:b,baseLine:(g||y?b.map(e=>{var t=Array.isArray(e.value)?e.value[0]:null;return v?{x:e.x,y:t!=null&&e.y!=null?l.scale.map(t)??null:null,payload:e.payload}:{x:t==null?null:c.scale.map(t)??null,y:e.y,payload:e.payload}}):v?l.scale.map(_):c.scale.map(_))??0,isRange:y}}function ct(e){var t=y(e,it),n=I();return/*#__PURE__*/ V.createElement(s,{id:t.id,type:`area`},e=>/*#__PURE__*/ V.createElement(V.Fragment,null,/*#__PURE__*/ V.createElement(b,{legendPayload:qe(t)}),/*#__PURE__*/ V.createElement(Je,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),/*#__PURE__*/ V.createElement(l,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:pe(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),/*#__PURE__*/ V.createElement(at,X({},t,{id:e}))))}var $=/*#__PURE__*/ V.memo(ct,re);$.displayName=`Area`;export{$ as t};
@@ -0,0 +1,3 @@
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 _,Gt as v,Jt as y,O as ee,V as b,_ as x,l as S,wt as te}from"./vendor-icons-blmhaswc.js";import{a as C,i as w,n as ne,r as re,t as T}from"./automationFormat-kv314fzh.js";import{t as ie}from"./plus-54e3zzys.js";import{a as E,n as D,t as O}from"./tooltip-h1yceend.js";import{Bt as ae,Ft as k,It as A,Lt as j,Nt as M,Pt as N,Rt as oe,ct as se,nt as ce,st as le,tt as P,ut as ue,zt as de}from"./junior-g62bxb2t.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-flkutk9e.js";import{t as ke}from"./SecondaryNavigation-m358iuko.js";import{t as Ae}from"./PageLayout-l6dhbimv.js";import{t as je}from"./AnchorHeading-ixbupfij.js";import{r as Me,t as B}from"./searchParams-moqjgi65.js";import{A as Ne,At as Pe,B as Fe,Bt as Ie,Ct as V,F as Le,Ft as Re,I as ze,L as Be,Lt as Ve,M as He,Mt as Ue,N as We,Nt as Ge,Ot as Ke,P as qe,Pt as Je,Q as Ye,Qt as Xe,R as Ze,St as H,Ut as Qe,V as $e,Vt as et,X as tt,Y as nt,Zt as rt,bt as U,cn as it,dt as at,en as ot,ht as st,j as ct,jt as lt,k as ut,kt as dt,un as ft,wt as W,xt as G,z as pt,zt as mt}from"../client-ctcthgam.js";import{t as K}from"./FormNotice-kj5pzsl7.js";import{t as q}from"./native-select-fxs3p0bj.js";import{a as J,i as ht,n as gt,o as _t,r as vt,s as yt,t as bt}from"./AutomationRunDetails-dx5lutte.js";import{a as xt,n as St,r as Ct,t as wt}from"./AutomationStatus-eqq5lrad.js";import{r as Tt}from"./FilterBar-dqnt967g.js";import{t as Et}from"./SelectableRow-j8fwjsjz.js";import{C as Dt,a as Ot,d as kt,n as At,o as jt,s as Mt,t as Nt}from"./chart-il2ahs5y.js";import{n as Pt,t as Ft}from"./BarChart-lbkezxbi.js";import{t as It}from"./ChartLegend-c3e9l1vl.js";var Y=/* @__PURE__ */ e(i(),1),X=a();function Lt({automation:e,editPath:r,editVariant:i,onDelete:a}){let o=ft(),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(P,`${t}/edit`);if(n.status!==e.status)throw Error(`The Automation changed. Reload the page before trying again.`);return pe(P,`${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)(ee,{"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)(mt,{children:[/* @__PURE__ */ (0,X.jsx)(Qe,{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)(Ie,{side:`bottom`,align:`end`,"aria-label":`About pausing`,children:/* @__PURE__ */ (0,X.jsxs)(et,{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)(O,{children:[/* @__PURE__ */ (0,X.jsx)(E,{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)(S,{"aria-hidden":`true`,size:16})})}),/* @__PURE__ */ (0,X.jsx)(D,{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 Rt(e){let[r,i]=(0,Y.useState)(!0),a=n(),o=ft(),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)(ct,{open:r,onOpenChange:(e,t)=>{s.isPending?t.cancel():i(e)},onOpenChangeComplete:t=>{t||e.onClose()},children:/* @__PURE__ */ (0,X.jsxs)(qe,{finalFocus:e.returnFocus,children:[/* @__PURE__ */ (0,X.jsx)(Be,{children:`Delete automation?`}),/* @__PURE__ */ (0,X.jsxs)(Le,{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)(ze,{children:[/* @__PURE__ */ (0,X.jsx)(We,{disabled:s.isPending,children:`Cancel`}),/* @__PURE__ */ (0,X.jsx)(He,{variant:`danger`,disabled:s.isPending,onClick:()=>s.mutate(),children:s.isPending?`Deleting…`:`Delete automation`})]})]})})}function zt(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 Bt=[`sunday`,`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`];function Z(e){return{title:e.title??``,task:Vt(e.task),credentialMode:e.credentialMode,outcomes:e.outcomes,trigger:e.kind===`event`?e.trigger:void 0}}function Vt(e){return e.kind===`instruction`?e:{kind:`skill`,skill:e.skill,context:e.context??``}}function Ht(e){return e.kind===`instruction`?e:{kind:`skill`,skill:e.skill,...e.context.trim()?{context:e.context}:void 0}}function Ut(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=>Bt[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 Wt(e,t){let n={};t.title!==(e.title??``)&&(n.title=t.title);let r=Ht(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 Gt={title:`Title`,task:`Instruction`,schedule:`Schedule`,trigger:`Trigger`,outcomes:`Where results go`,credentialMode:`Credentials`};function Kt(e){let t=Object.keys(Gt).filter(t=>e.changes[t]!==void 0),n=qt(e.original),r=e.changes.task??n.task,i=t=>t===`task`&&e.changes.task?Jt(n.task,e.changes.task):Gt[t],a=(t,n)=>Xt(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 qt(e){let t={...Z(e),task:e.task};return e.kind===`scheduled`?{...t,schedule:Ut(e)}:t}function Jt(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 Yt(e){if(e.kind===`instruction`)return e.instruction||`Empty`;let t=e.skill?Ne(e.skill):`No skill chosen`;return e.context?`${t} · ${e.context}`:t}function Xt(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?Yt(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=>zt(e,n.destination)).join(`, `):`No success message`;case`schedule`:return e.schedule?Qt(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 Zt={daily:`day`,weekly:`week`,monthly:`month`,yearly:`year`};function Qt(e){if(e.kind===`one_off`)return`Once on ${e.timing.date} at ${e.timing.time} (${e.timezone})`;let t=e.interval??1,n=Zt[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 $t(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:$t(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 en(e){let t=e.value??Ut(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=le.safeParse(n),o=r({queryKey:[`dashboard`,`automation-schedule-preview`,e.automation.id,n],enabled:!!n&&a.success,retry:!1,queryFn:()=>pe(se,`/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)(U,{children:[/* @__PURE__ */ (0,X.jsx)(V,{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)(U,{children:[/* @__PURE__ */ (0,X.jsx)(V,{htmlFor:`schedule-time`,children:`Time`}),/* @__PURE__ */ (0,X.jsx)(W,{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:[...Bt.slice(1),Bt[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)(U,{children:[/* @__PURE__ */ (0,X.jsx)(V,{htmlFor:`schedule-interval`,children:`Interval`}),/* @__PURE__ */ (0,X.jsx)(W,{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)(G,{id:`schedule-interval-help`,children:`Number of calendar periods between runs.`})]}),/* @__PURE__ */ (0,X.jsxs)(U,{children:[/* @__PURE__ */ (0,X.jsx)(V,{htmlFor:`schedule-start`,children:`Start date`}),/* @__PURE__ */ (0,X.jsx)(W,{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)(U,{children:[/* @__PURE__ */ (0,X.jsx)(V,{htmlFor:`schedule-day`,children:`Day of month`}),/* @__PURE__ */ (0,X.jsx)(W,{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)(U,{children:[/* @__PURE__ */ (0,X.jsx)(V,{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)(U,{children:[/* @__PURE__ */ (0,X.jsx)(V,{htmlFor:`schedule-date`,children:`Date`}),/* @__PURE__ */ (0,X.jsx)(W,{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)(U,{children:[/* @__PURE__ */ (0,X.jsx)(V,{htmlFor:`schedule-timezone`,children:`Timezone`}),/* @__PURE__ */ (0,X.jsx)(W,{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)(G,{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 tn(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 nn={resourceTypes:[],events:{},anyResourceFields:{}};function rn(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 an(e){let[t,n]=(0,Y.useState)(),i=r({queryKey:[`dashboard`,`automation-event-catalog`],queryFn:({signal:e})=>F(ce,`/api/automations/event-catalog`,e),retry:!1}),a=i.data?.find(t=>t.namespace===e.value.namespace),o=a??nn,s=a?.displayName??e.value.namespace,c=e.value.resourceType===void 0,l=A(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=>M(e).length>0)??[],p=Object.entries(l?.fields??{}),m=p.filter(([t,n])=>e.value.match?.[t]!==void 0||ae(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)(on,{displayName:s,source:o,trigger:e.value})]}):null,/* @__PURE__ */ (0,X.jsxs)(U,{children:[/* @__PURE__ */ (0,X.jsx)(V,{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)(ct,{onOpenChange:e=>{e||n(void 0)},open:t!==void 0,children:/* @__PURE__ */ (0,X.jsxs)(qe,{children:[/* @__PURE__ */ (0,X.jsx)(Be,{children:`Replace the saved trigger?`}),/* @__PURE__ */ (0,X.jsx)(Le,{children:`Its resource, events, and filters will be cleared.`}),/* @__PURE__ */ (0,X.jsxs)(ze,{children:[/* @__PURE__ */ (0,X.jsx)(We,{children:`Cancel`}),/* @__PURE__ */ (0,X.jsx)(He,{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)(U,{children:[/* @__PURE__ */ (0,X.jsx)(V,{htmlFor:`trigger-label`,children:c?`Trigger name`:`Resource name`}),/* @__PURE__ */ (0,X.jsx)(W,{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)(U,{children:[/* @__PURE__ */ (0,X.jsx)(V,{htmlFor:`trigger-identifier`,children:`Resource identifier`}),/* @__PURE__ */ (0,X.jsx)(W,{size:`comfortable`,id:`trigger-identifier`,value:e.value.identifier??``,onChange:t=>e.onChange({...e.value,identifier:t.target.value})}),/* @__PURE__ */ (0,X.jsx)(G,{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)(Fe,{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:[de(t),c&&rn(o,t)?/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`text-dashboard-text-muted`,children:[` `,`· `,rn(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)(U,{children:[/* @__PURE__ */ (0,X.jsx)(V,{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:k(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)(W,{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)(G,{id:`match-${t}-help`,children:n.description}):null,i?/* @__PURE__ */ (0,X.jsx)(H,{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 on(e){let t=N(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)(tn,{filters:t.filters})]})]})}function sn(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:zt(t,e.destination)},n))}):/* @__PURE__ */ (0,X.jsx)(`p`,{className:`m-0 text-sm`,children:`No success message`})}function cn(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:zt(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)(Ze,{"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)(pt,{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)(v,{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)(S,{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)(ie,{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 ln(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean),r=[],i=[];for(let a of e){let e=Je(a.name,t);if(e){r.push({row:{skill:a,nameMatches:e.indices},score:e.score});continue}let o=a.description.toLowerCase();if(!n.every(e=>o.includes(e)))continue;let s=Je(a.description,t);s&&i.push({row:{skill:a,descriptionMatches:s.indices},score:s.score})}let a=(e,t)=>t.score-e.score;return[...r.sort(a),...i.sort(a)].map(e=>e.row)}function un(e){let[t,n]=(0,Y.useState)(!1),[r,i]=(0,Y.useState)(``),a=e.skills.find(t=>t.name===e.value),o=!!e.value&&!a,s=[{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),c=r.trim().replace(/^\$/,``),l=t=>{e.onChange(t),n(!1)};return/* @__PURE__ */ (0,X.jsxs)(mt,{open:t,onOpenChange:e=>{n(e),e||i(``)},children:[/* @__PURE__ */ (0,X.jsxs)(Qe,{id:e.id,"aria-invalid":e.invalid||o||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)(fn,{plugin:!!a?.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`,o&&`text-dashboard-text-muted line-through decoration-dashboard-text-muted/60`),children:Ne(e.value)}),o?/* @__PURE__ */ (0,X.jsx)(pn,{tone:`danger`,children:`Not found`}):a?.disableModelInvocation?/* @__PURE__ */ (0,X.jsx)(pn,{children:`Manual only`}):null]}),a?.description?/* @__PURE__ */ (0,X.jsx)(`span`,{className:`truncate text-xs text-dashboard-text-muted`,children:a.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)(Ie,{align:`start`,className:`w-(--anchor-width) max-w-[calc(100vw-2rem)] min-w-80 overflow-hidden p-0`,children:/* @__PURE__ */ (0,X.jsxs)(Ke,{label:`Skills`,shouldFilter:!1,children:[/* @__PURE__ */ (0,X.jsx)(lt,{placeholder:`Search by name or description`,value:r,onValueChange:i}),/* @__PURE__ */ (0,X.jsxs)(Ge,{children:[/* @__PURE__ */ (0,X.jsx)(dt,{children:`No skills match.`}),c?ln(e.skills,c).map(e=>/* @__PURE__ */ (0,X.jsx)(dn,{row:e,onSelect:l},e.skill.name)):s.map(e=>/* @__PURE__ */ (0,X.jsx)(Pe,{heading:e.heading,children:e.skills.map(e=>/* @__PURE__ */ (0,X.jsx)(dn,{row:{skill:e},onSelect:l},e.name))},e.heading))]})]})})]})}function dn(e){let{skill:t}=e.row;return/* @__PURE__ */ (0,X.jsx)(Ue,{value:t.name,onSelect:()=>e.onSelect(t.name),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.jsxs)(`span`,{className:`truncate font-mono`,children:[`$`,/* @__PURE__ */ (0,X.jsx)(Re,{label:t.name,matches:e.row.nameMatches})]}),t.disableModelInvocation?/* @__PURE__ */ (0,X.jsx)(pn,{children:`Manual only`}):null]}),/* @__PURE__ */ (0,X.jsx)(`span`,{className:`truncate text-xs text-dashboard-text-muted`,children:/* @__PURE__ */ (0,X.jsx)(Re,{label:t.description,matches:e.row.descriptionMatches})})]})})}function fn(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)(x,{"aria-hidden":`true`,size:15,strokeWidth:1.8})})}function pn(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 mn(e){let{task:t,original:n}=e,[r,i]=(0,Y.useState)(t.kind===`skill`&&t.context!==``),a=it().data;return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[/* @__PURE__ */ (0,X.jsxs)(U,{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?Vt(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)(hn,{...e,task:t,skills:a,contextOpen:r||t.context!==``,onContextOpen:i}):/* @__PURE__ */ (0,X.jsxs)(U,{children:[/* @__PURE__ */ (0,X.jsx)(V,{htmlFor:`task.instruction`,children:`Instruction`}),/* @__PURE__ */ (0,X.jsx)(nt,{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)(H,{id:`task.instruction-error`,children:e.fieldError(`task.instruction`)})]})]})}function hn(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?`${Ne(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)(U,{children:[/* @__PURE__ */ (0,X.jsx)(V,{htmlFor:`task.skill`,children:`Skill`}),/* @__PURE__ */ (0,X.jsx)(un,{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)(H,{id:`task.skill-error`,children:i}),/* @__PURE__ */ (0,X.jsxs)(G,{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)(ut,{name:n.name,children:`View skill`}):null]})]}),e.contextOpen?/* @__PURE__ */ (0,X.jsxs)(U,{children:[/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[/* @__PURE__ */ (0,X.jsx)(V,{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)(nt,{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)(G,{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)(H,{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)(ie,{"aria-hidden":`true`,className:`size-4`}),`Add context`]})]})}function gn(e){let r=ft(),[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=Wt(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(P,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 ie(e){p&&(s(e?{...Z(p),...x,task:x.task?o.task:Vt(p.task)}:Z(p)),a(p),m(void 0),T.reset(),d({}))}let E=t({mutationFn:()=>F(P,`${ne}/edit`),onSuccess:m}),D=T.error instanceof I&&T.error.code===`conflict`,O=e=>s(t=>({...t,...e})),ae=e=>{O({[e]:Z(i)[e]}),_(e=>e+1)},k=e=>Object.entries(u).filter(([t])=>t===e||t.startsWith(`${e}.`)).flatMap(([,e])=>e).join(` `)||void 0,A=i.kind===`scheduled`?`schedule`:`trigger`,j=i.ownedByViewer,M=e.summary.createdBy,N=!j&&i.credentialMode===`creator`&&(x.task!==void 0||x[A]!==void 0||x.outcomes!==void 0),oe=k(A),se=e=>({"aria-invalid":!!k(e)||void 0,"aria-describedby":k(e)?`${e}-error`:void 0});return/* @__PURE__ */ (0,X.jsxs)(`form`,{ref:v,noValidate:!0,onSubmit:e=>{if(e.preventDefault(),T.isPending||D||!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=ue.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:D?`warning`:`error`,title:D?`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.`,` `,D?`Review the latest version before saving again.`:T.error instanceof I?T.error.apiError:`Check the fields below, or try again.`]}),D?/* @__PURE__ */ (0,X.jsx)(h,{disabled:E.isPending,onClick:()=>E.mutate(),children:E.isPending?`Loading…`:`Review latest version`}):null,E.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:_n(e===`schedule`&&p.kind===`scheduled`?Ut(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:_n(t)})]})]})]},e)),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[/* @__PURE__ */ (0,X.jsx)(h,{onClick:()=>ie(!0),children:`Keep my changed fields`}),/* @__PURE__ */ (0,X.jsx)(h,{onClick:()=>ie(!1),children:`Use latest saved version`})]})]})}):null,j?null:/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`mt-0 mb-6 max-w-2xl text-sm leading-relaxed text-dashboard-text-muted`,children:[M,` created this automation. You can edit it because it is in a public channel. Only `,M,` 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)(U,{children:[/* @__PURE__ */ (0,X.jsx)(V,{htmlFor:`title`,children:`Title`}),/* @__PURE__ */ (0,X.jsx)(W,{size:`comfortable`,id:`title`,value:o.title,placeholder:e.summary.title,onChange:e=>O({title:e.target.value}),...se(`title`)}),/* @__PURE__ */ (0,X.jsx)(H,{id:`title-error`,children:k(`title`)})]}),/* @__PURE__ */ (0,X.jsx)(mn,{task:o.task,original:i,disabled:T.isPending,fieldError:k,inputState:se,onChange:e=>O({task:e})})]}),/* @__PURE__ */ (0,X.jsx)(Q,{changed:x[A]!==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:`${A}-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)(en,{automation:i,value:o.schedule,onChange:e=>O({schedule:e})}):/* @__PURE__ */ (0,X.jsx)(an,{value:o.trigger??i.trigger,original:i.trigger,disabled:T.isPending,onChange:e=>O({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:[k(`outcomes`)?/* @__PURE__ */ (0,X.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-rose-300`,children:k(`outcomes`)}):null,/* @__PURE__ */ (0,X.jsx)(cn,{value:o.outcomes,original:i.outcomes,destination:e.summary.destination,disabled:T.isPending,onChange:e=>O({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)(Ze,{"aria-label":`Credential mode`,disabled:T.isPending,className:`divide-y divide-dashboard-border-subtle rounded-md border border-dashboard-border-emphasis`,onValueChange:e=>O({credentialMode:e}),value:N?`system`:o.credentialMode,children:[[`creator`,j?`Your connected accounts`:`${M}’s connected accounts`,j?`Uses accounts connected by you, the creator.`:`Uses accounts connected by ${M}. Only ${M} can turn this on.`],[`system`,`System credentials only`,j?`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)(pt,{className:`mt-0.5`,value:e,disabled:e===`creator`&&!j&&(i.credentialMode!==`creator`||N)}),/* @__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))}),N?/* @__PURE__ */ (0,X.jsxs)(K,{title:`Saving switches this automation to system credentials.`,children:[`Only `,M,` can let a changed instruction,`,i.kind===`event`?` trigger,`:` schedule,`,` or result destination use their connected accounts.`]}):null,k(`credentialMode`)?/* @__PURE__ */ (0,X.jsx)(`p`,{role:`alert`,children:k(`credentialMode`)}):null]})]},g),/* @__PURE__ */ (0,X.jsx)(Kt,{changes:x,disabled:T.isPending,onUndo:ae,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||D,children:`Save changes`})]})]})})]})}function _n(e){return e==null?`Not set`:typeof e==`string`?e:JSON.stringify(e,null,2)}function vn(){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 yn=new Intl.DateTimeFormat(void 0,{day:`numeric`,month:`short`,timeZone:`UTC`});function bn(e){let{automation:t}=e,n=t.costUsd[30],r=t.runs[30],i=e=>De({total:e});return/* @__PURE__ */ (0,X.jsxs)(yt,{title:`Cost`,children:[e.days?/* @__PURE__ */ (0,X.jsx)(xn,{days:e.days.slice(-30)}):null,/* @__PURE__ */ (0,X.jsxs)(_t,{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 xn(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:`${yn.format(/* @__PURE__ */ new Date(`${e.date}T00:00:00.000Z`))} · ${De({total:e.costUsd})}`},e.date))})}function Sn(e){let{automation:t}=e,n=Xe(!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)(wt,{automation:t,editPath:e.editPath,lastRunError:r&&r.status!==`completed`?r.error:void 0}),/* @__PURE__ */ (0,X.jsx)(Cn,{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)(En,{automation:t}),/* @__PURE__ */ (0,X.jsx)(bn,{automation:t,days:n.data?.executionDays}),/* @__PURE__ */ (0,X.jsx)(Dn,{automation:t})]})]})}function Cn(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)(xt,{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)(Tn,{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)(wn,{automation:t,run:e,to:i(e)},e.executionId))}):null]})})}function wn(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)($e,{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:Ve(t.conversationId),children:/* @__PURE__ */ (0,X.jsx)(b,{"aria-hidden":`true`,size:15})}):/* @__PURE__ */ (0,X.jsx)(`span`,{})]})}function Tn({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 En(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)(yt,{title:`Definition`,children:[r.kind===`skill`?/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:[`Runs `,/* @__PURE__ */ (0,X.jsx)(ut,{name:r.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)(Ye,{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)(_t,{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)(sn,{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 Dn({automation:e}){let t=d(),n=ot(!0,e.id).data?.activeVersion,r=/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[/* @__PURE__ */ (0,X.jsx)(at,{imageUrl:e.createdByAvatarUrl,name:e.createdBy,size:`list`}),e.ownedByViewer?`You`:e.createdBy]});return/* @__PURE__ */ (0,X.jsxs)(yt,{title:`About`,children:[/* @__PURE__ */ (0,X.jsxs)(_t,{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 On=[{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`}],kn=Object.fromEntries(On.map(e=>[e.key,{color:e.color,label:e.label}]));function An(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)(It,{ariaLabel:`Automation execution status legend`,items:On}),/* @__PURE__ */ (0,X.jsxs)(`div`,{className:`relative mt-3 overflow-hidden`,children:[/* @__PURE__ */ (0,X.jsx)(Nt,{className:`aspect-auto h-55 w-full`,config:kn,children:/* @__PURE__ */ (0,X.jsxs)(Ft,{"aria-label":`Automation executions during the last ${e.range===1?`24 hours`:`${e.range} days`}`,data:n,margin:kt,role:`img`,children:[/* @__PURE__ */ (0,X.jsx)(Dt,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,X.jsx)(Mt,{maximum:i}),/* @__PURE__ */ (0,X.jsx)(jt,{keys:n.map(e=>e.date)}),/* @__PURE__ */ (0,X.jsx)(At,{content:/* @__PURE__ */ (0,X.jsx)(Ot,{rows:e=>[[`completed`,e.completed],[`failed`,e.failed],[`blocked`,e.blocked],[`total`,e.completed+e.failed+e.blocked]]})}),On.map(e=>/* @__PURE__ */ (0,X.jsx)(Pt,{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 jn=`result`,Mn=[``,`completed`,`failed`,`blocked`],Nn=`grid-cols-[minmax(0,1fr)_5.5rem_5.5rem_5.5rem_auto_2rem]`;function Pn(e){let{automation:t}=e,n=Xe(!0,t.id),[r,i]=Me(jn,``,Mn),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=ht(a.map(e=>e.executionId));return/* @__PURE__ */ (0,X.jsxs)(gt,{details:s.runId?/* @__PURE__ */ (0,X.jsx)(bt,{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)(Fn,{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 Fn(e){let{data:t,range:n}=e,r=(0,Y.useMemo)(()=>Rn(t.executions),[t.executions]);return/* @__PURE__ */ (0,X.jsxs)(X.Fragment,{children:[t.executionDays.length>0?/* @__PURE__ */ (0,X.jsx)(An,{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)(Tt,{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`,Nn),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)(In,{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 In(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)(Et,{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`,Nn),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)($e,{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)(Ln,{label:`Duration`,value:r}),/* @__PURE__ */ (0,X.jsx)(Ln,{label:`Tokens`,value:i}),/* @__PURE__ */ (0,X.jsx)(Ln,{label:`Cost`,value:n}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`hidden justify-self-center md:block`,children:/* @__PURE__ */ (0,X.jsx)($e,{label:t.status,tone:a})}),/* @__PURE__ */ (0,X.jsx)(`div`,{className:`max-md:hidden`,children:/* @__PURE__ */ (0,X.jsx)(vt,{conversationId:t.conversationId})})]})})}function Ln(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 Rn(e){return e.reduce((e,t)=>(e[t.status]+=1,e),{blocked:0,completed:0,failed:0})}const zn=`version`;function Bn(e){let t=ot(!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)(Vn,{automation:e.automation,data:t.data}):/* @__PURE__ */ (0,X.jsx)(_e,{label:`Loading version history`,variant:`list`})}function Vn(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(zn)),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(zn,String(e)),n},{replace:!0}),ee=`/api/automations/${encodeURIComponent(r.id)}`,b=t({mutationFn:async e=>{let t=await F(P,`${ee}/edit`);return pe(P,`${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)(Hn,{active:e.version===i.activeVersion,changes:Yn(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)(st,{size:`compact`,tone:`success`,children:`Active`}):null]}),/* @__PURE__ */ (0,X.jsxs)(`p`,{className:`mt-1 mb-0 text-xs text-dashboard-text-muted`,children:[Jn(_),` ·`,` `,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)(Wn,{automation:r,previous:v,version:_})]})]}),/* @__PURE__ */ (0,X.jsx)(ct,{onOpenChange:d,open:u,children:/* @__PURE__ */ (0,X.jsxs)(qe,{children:[/* @__PURE__ */ (0,X.jsxs)(Be,{children:[`Make version `,_.version,` active?`]}),/* @__PURE__ */ (0,X.jsxs)(Le,{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)(ze,{children:[/* @__PURE__ */ (0,X.jsx)(We,{children:`Cancel`}),/* @__PURE__ */ (0,X.jsx)(He,{onClick:()=>{b.mutate(_.version),d(!1)},variant:`primary`,children:`Make active`})]})]})})]})}function Hn(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)(st,{size:`compact`,tone:`success`,children:`Active`}):null]}),/* @__PURE__ */ (0,X.jsxs)(`span`,{className:`truncate text-xs text-dashboard-text-muted`,children:[Jn(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 Un=[{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 Wn(e){let{automation:t,previous:n,version:r}=e,i=n?Xn(n,r):[];return/* @__PURE__ */ (0,X.jsx)(`dl`,{className:`m-0 divide-y divide-dashboard-border-subtle`,children:Un.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)(Kn,{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: `}),Gn(e,t,n)]}),/* @__PURE__ */ (0,X.jsxs)(`div`,{children:[/* @__PURE__ */ (0,X.jsx)(`span`,{className:`sr-only`,children:`After: `}),Gn(e,t,r)]})]}):Gn(e,t,r)})]},e)})})}function Gn(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)(ut,{name:i.skill}):`No skill`;case`instruction`:return i.instruction?/* @__PURE__ */ (0,X.jsx)(Ye,{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)(tn,{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:zt(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 Kn(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:qn(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 qn(e,t){let n=e.split(`
2
+ `),r=t.split(`
3
+ `),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 Jn(e){return e.editedBy?e.editedBy.fullName??e.editedBy.userName??e.editedBy.slackUserId:`Editor unknown`}function Yn(e,t,n){if(!t)return e.version===1||!n?`First saved version`:void 0;let r=Xn(t,e);return r.length===0?`No setting changes`:`Changed ${Un.filter(({key:e})=>r.includes(e)).map(({label:e})=>e.toLowerCase()).join(`, `)}`}function Xn(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 Un.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 Zn=[`1`,`7`,`30`,`90`],Qn=[jn,`run`,zn],$n={edit:`Edit`,overview:`Overview`,runs:`Runs`,versions:`Versions`};function er(e){let{automationId:t}=o(),n=d(),r=rt(e.enabled,t),[i,a]=Me(`range`,`30`,Zn),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 Qn)l.delete(e);let f=B(`/automations`,l),p=r.data,m=[`overview`,`runs`,`versions`].map(e=>({label:$n[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)(tr,{automation:p,listPath:f,onRangeChange:e=>a(String(e)),range:c,tab:e.tab}):/* @__PURE__ */ (0,X.jsxs)(Ae,{children:[/* @__PURE__ */ (0,X.jsx)(ir,{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 tr(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)(ir,{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)(Lt,{automation:t,editPath:f,editVariant:n===`overview`&&Ct(t)?`default`:`primary`,onDelete:e=>{c.current=e,o(!0)}})]}),description:/* @__PURE__ */ (0,X.jsx)(rr,{automation:t}),documentTitle:n===`overview`?t.title:`${t.title} · ${$n[n]}`,title:t.title})]}),m=a?/* @__PURE__ */ (0,X.jsx)(Rt,{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)(Pn,{automation:t,header:p,range:e.range}),m]}):/* @__PURE__ */ (0,X.jsxs)(Ae,{children:[p,n===`overview`?/* @__PURE__ */ (0,X.jsx)(Sn,{automation:t,editPath:f}):null,n===`edit`?/* @__PURE__ */ (0,X.jsx)(nr,{automation:t}):null,n===`versions`?/* @__PURE__ */ (0,X.jsx)(Bn,{automation:t}):null,m]})}function nr(e){let{automation:t}=e,n=d(),i=r({queryKey:[`dashboard`,`automations`,`edit`,t.id],retry:!1,queryFn:({signal:e})=>F(P,`/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)(gn,{automation:i.data,summary:t,returnPath:B(z(t.id),n.search)},t.id):/* @__PURE__ */ (0,X.jsx)(vn,{})}function rr(e){let{automation:t}=e,n=[t.kind===`scheduled`?t.schedule:oe(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)(St,{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 ir(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)(y,{"aria-hidden":`true`,size:15,strokeWidth:1.8}),`Automations`]})}export{er as AutomationPage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n,r,y as i}from"./vendor-react-ggbyvons.js";import{n as a}from"./button-ygjnb239.js";import{V as o}from"./vendor-icons-mxz7yi04.js";import{i as s,n as c,t as l}from"./automationFormat-hd7pnocr.js";import{a as u,n as d,t as f}from"./tooltip-h1yceend.js";import{a as p,t as m}from"./styles-j0007fov.js";import{t as h}from"./PageContentSkeleton-b7dkba0l.js";import{b as g,l as _,n as v,p as y,y as b}from"./format-gle1s0ri.js";import{t as x}from"./PageLayout-l6dhbimv.js";import{Ot as S,ut as C,z as w}from"../client-f7asutg5.js";var T=/* @__PURE__ */ e(t(),1),E=n();function D(e){return/* @__PURE__ */ (0,E.jsxs)(`section`,{"aria-label":e.title,className:`grid min-w-0 gap-2.5 rounded-lg border border-dashboard-border-subtle bg-dashboard-surface-panel p-3`,children:[/* @__PURE__ */ (0,E.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[/* @__PURE__ */ (0,E.jsx)(`h3`,{className:`m-0 font-sans text-xs font-medium text-dashboard-text-muted`,children:e.title}),e.action?/* @__PURE__ */ (0,E.jsx)(`div`,{className:`shrink-0 text-xs`,children:e.action}):null]}),e.children]})}function O(e){return/* @__PURE__ */ (0,E.jsx)(`dl`,{className:`m-0 grid min-w-0 gap-2 text-xs leading-snug`,children:e.children})}function k(e){return/* @__PURE__ */ (0,E.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-4`,children:[/* @__PURE__ */ (0,E.jsx)(`dt`,{className:`shrink-0 text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,E.jsx)(`dd`,{className:`m-0 min-w-0 break-words text-right tabular-nums text-dashboard-text`,children:e.children})]})}function A(e){let[t,n]=i(),r=(0,T.useRef)(null),a=t.get(`run`)??void 0,o=e=>n(t=>{let n=new URLSearchParams(t);return e?n.set(`run`,e):n.delete(`run`),n},{replace:!0}),s=e=>r.current?.querySelector(`[data-run-id="${CSS.escape(e)}"] button`);return{close:()=>{let e=a?s(a):void 0;o(void 0),(e??r.current)?.focus({preventScroll:!0})},listRef:r,onRowsKeyDown:t=>{if(!a||t.key!==`ArrowDown`&&t.key!==`ArrowUp`)return;let n=t.target.closest(`[data-run-id]`)?.getAttribute(`data-run-id`),r=n?e.indexOf(n):-1,i=e[r+(t.key===`ArrowDown`?1:-1)];r!==-1&&i&&(t.preventDefault(),o(i),s(i)?.focus())},runId:a,toggle:e=>o(e===a?void 0:e)}}function j(e){return/* @__PURE__ */ (0,E.jsxs)(`div`,{className:m(`grid h-full min-h-0 min-w-0`,e.details?`xl:grid-cols-[minmax(0,1fr)_25rem]`:void 0),children:[/* @__PURE__ */ (0,E.jsx)(`div`,{"aria-label":e.label,className:`min-h-0 overflow-y-auto overscroll-contain outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus`,ref:e.listRef,role:`region`,tabIndex:0,children:/* @__PURE__ */ (0,E.jsx)(x,{children:e.children})}),e.details]})}function M(e){return e.conversationId?/* @__PURE__ */ (0,E.jsxs)(f,{children:[/* @__PURE__ */ (0,E.jsx)(u,{render:/* @__PURE__ */ (0,E.jsx)(r,{"aria-label":`Open conversation`,className:m(a({size:`icon`}),`size-8`),to:S(e.conversationId),children:/* @__PURE__ */ (0,E.jsx)(o,{"aria-hidden":`true`,size:15})})}),/* @__PURE__ */ (0,E.jsx)(d,{size:`compact`,children:`Open conversation`})]}):/* @__PURE__ */ (0,E.jsx)(`span`,{"aria-hidden":`true`})}function N(e){let{run:t}=e,n=t?c(t,t.automationTitle):`Run`;return/* @__PURE__ */ (0,E.jsx)(w,{actions:t?.conversationId?/* @__PURE__ */ (0,E.jsx)(r,{className:m(a(),`shrink-0 whitespace-nowrap`),to:S(t.conversationId),children:`Open conversation`}):void 0,label:`Run details`,onClose:e.onClose,sheetTitle:n,title:/* @__PURE__ */ (0,E.jsx)(`h2`,{className:`m-0 line-clamp-2 break-words font-display text-base font-medium text-dashboard-text`,children:n}),children:/* @__PURE__ */ (0,E.jsx)(`div`,{className:`p-4 [overflow-wrap:anywhere]`,children:t?/* @__PURE__ */ (0,E.jsx)(P,{run:t,showAutomation:e.showAutomation}):e.loading?/* @__PURE__ */ (0,E.jsx)(h,{label:`Loading run details`,variant:`panel`}):/* @__PURE__ */ (0,E.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:`This run is not in the loaded runs.`})})})}function P(e){let{run:t}=e;return/* @__PURE__ */ (0,E.jsxs)(`div`,{className:`grid min-w-0 gap-3`,children:[/* @__PURE__ */ (0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 px-1`,children:[/* @__PURE__ */ (0,E.jsx)(C,{tone:l(t.status),children:t.status}),/* @__PURE__ */ (0,E.jsx)(`time`,{className:`text-xs text-dashboard-text-muted`,dateTime:t.executedAt,title:s(t.executedAt),children:b(t.executedAt)})]}),t.error?/* @__PURE__ */ (0,E.jsx)(D,{title:`Error`,children:/* @__PURE__ */ (0,E.jsx)(`p`,{className:`m-0 whitespace-pre-wrap font-mono text-xs leading-relaxed text-rose-300`,children:t.error})}):null,/* @__PURE__ */ (0,E.jsx)(D,{title:`Run`,children:/* @__PURE__ */ (0,E.jsxs)(O,{children:[/* @__PURE__ */ (0,E.jsx)(k,{label:`Trigger`,children:t.kind===`scheduled`?`Schedule`:`Event`}),t.scheduledFor?/* @__PURE__ */ (0,E.jsx)(k,{label:`Scheduled for`,children:s(t.scheduledFor)}):null,t.startedAt?/* @__PURE__ */ (0,E.jsx)(k,{label:`Started`,children:s(t.startedAt)}):null,/* @__PURE__ */ (0,E.jsx)(k,{label:`Finished`,children:s(t.executedAt)}),/* @__PURE__ */ (0,E.jsx)(k,{label:`Duration`,children:g(t.durationMs)||`—`}),/* @__PURE__ */ (0,E.jsx)(k,{label:`Tokens`,children:t.totalTokens===void 0?`—`:_(t.totalTokens)}),/* @__PURE__ */ (0,E.jsx)(k,{label:`Cost`,children:t.costUsd===void 0?`—`:y({total:t.costUsd})})]})}),/* @__PURE__ */ (0,E.jsx)(D,{title:`Setup`,children:/* @__PURE__ */ (0,E.jsxs)(O,{children:[e.showAutomation?/* @__PURE__ */ (0,E.jsx)(k,{label:`Automation`,children:/* @__PURE__ */ (0,E.jsx)(r,{className:p,to:v(t.automationId),children:t.automationTitle})}):null,t.automationVersion?/* @__PURE__ */ (0,E.jsx)(k,{label:`Version`,children:/* @__PURE__ */ (0,E.jsxs)(r,{className:p,to:`${v(t.automationId,`versions`)}?version=${t.automationVersion}`,children:[`Version `,t.automationVersion]})}):null,t.credentialMode?/* @__PURE__ */ (0,E.jsx)(k,{label:`Accounts`,children:t.credentialMode===`creator`?`Creator’s connected accounts`:`Junior’s accounts only`}):null,/* @__PURE__ */ (0,E.jsx)(k,{label:`Run ID`,children:/* @__PURE__ */ (0,E.jsx)(`span`,{className:`font-mono`,children:t.executionId})})]})}),t.conversationId?null:/* @__PURE__ */ (0,E.jsx)(`p`,{className:`m-0 px-1 text-xs text-dashboard-text-muted`,children:`No Conversation was recorded for this run.`})]})}export{k as a,A as i,j as n,O as o,M as r,D as s,N as t};
1
+ import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n,r,y as i}from"./vendor-react-ggbyvons.js";import{n as a}from"./button-ygjnb239.js";import{V as o}from"./vendor-icons-blmhaswc.js";import{i as s,n as c,t as l}from"./automationFormat-kv314fzh.js";import{a as u,n as d,t as f}from"./tooltip-h1yceend.js";import{a as p,t as m}from"./styles-j0007fov.js";import{t as h}from"./PageContentSkeleton-b7dkba0l.js";import{b as g,l as _,n as v,p as y,y as b}from"./format-flkutk9e.js";import{t as x}from"./PageLayout-l6dhbimv.js";import{G as S,Lt as C,ht as w}from"../client-ctcthgam.js";var T=/* @__PURE__ */ e(t(),1),E=n();function D(e){return/* @__PURE__ */ (0,E.jsxs)(`section`,{"aria-label":e.title,className:`grid min-w-0 gap-2.5 rounded-lg border border-dashboard-border-subtle bg-dashboard-surface-panel p-3`,children:[/* @__PURE__ */ (0,E.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[/* @__PURE__ */ (0,E.jsx)(`h3`,{className:`m-0 font-sans text-xs font-medium text-dashboard-text-muted`,children:e.title}),e.action?/* @__PURE__ */ (0,E.jsx)(`div`,{className:`shrink-0 text-xs`,children:e.action}):null]}),e.children]})}function O(e){return/* @__PURE__ */ (0,E.jsx)(`dl`,{className:`m-0 grid min-w-0 gap-2 text-xs leading-snug`,children:e.children})}function k(e){return/* @__PURE__ */ (0,E.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-4`,children:[/* @__PURE__ */ (0,E.jsx)(`dt`,{className:`shrink-0 text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,E.jsx)(`dd`,{className:`m-0 min-w-0 break-words text-right tabular-nums text-dashboard-text`,children:e.children})]})}function A(e){let[t,n]=i(),r=(0,T.useRef)(null),a=t.get(`run`)??void 0,o=e=>n(t=>{let n=new URLSearchParams(t);return e?n.set(`run`,e):n.delete(`run`),n},{replace:!0}),s=e=>r.current?.querySelector(`[data-run-id="${CSS.escape(e)}"] button`);return{close:()=>{let e=a?s(a):void 0;o(void 0),(e??r.current)?.focus({preventScroll:!0})},listRef:r,onRowsKeyDown:t=>{if(!a||t.key!==`ArrowDown`&&t.key!==`ArrowUp`)return;let n=t.target.closest(`[data-run-id]`)?.getAttribute(`data-run-id`),r=n?e.indexOf(n):-1,i=e[r+(t.key===`ArrowDown`?1:-1)];r!==-1&&i&&(t.preventDefault(),o(i),s(i)?.focus())},runId:a,toggle:e=>o(e===a?void 0:e)}}function j(e){return/* @__PURE__ */ (0,E.jsxs)(`div`,{className:m(`grid h-full min-h-0 min-w-0`,e.details?`xl:grid-cols-[minmax(0,1fr)_25rem]`:void 0),children:[/* @__PURE__ */ (0,E.jsx)(`div`,{"aria-label":e.label,className:`min-h-0 overflow-y-auto overscroll-contain outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus`,ref:e.listRef,role:`region`,tabIndex:0,children:/* @__PURE__ */ (0,E.jsx)(x,{children:e.children})}),e.details]})}function M(e){return e.conversationId?/* @__PURE__ */ (0,E.jsxs)(f,{children:[/* @__PURE__ */ (0,E.jsx)(u,{render:/* @__PURE__ */ (0,E.jsx)(r,{"aria-label":`Open conversation`,className:m(a({size:`icon`}),`size-8`),to:C(e.conversationId),children:/* @__PURE__ */ (0,E.jsx)(o,{"aria-hidden":`true`,size:15})})}),/* @__PURE__ */ (0,E.jsx)(d,{size:`compact`,children:`Open conversation`})]}):/* @__PURE__ */ (0,E.jsx)(`span`,{"aria-hidden":`true`})}function N(e){let{run:t}=e,n=t?c(t,t.automationTitle):`Run`;return/* @__PURE__ */ (0,E.jsx)(S,{actions:t?.conversationId?/* @__PURE__ */ (0,E.jsx)(r,{className:m(a(),`shrink-0 whitespace-nowrap`),to:C(t.conversationId),children:`Open conversation`}):void 0,label:`Run details`,onClose:e.onClose,sheetTitle:n,title:/* @__PURE__ */ (0,E.jsx)(`h2`,{className:`m-0 line-clamp-2 break-words font-display text-base font-medium text-dashboard-text`,children:n}),children:/* @__PURE__ */ (0,E.jsx)(`div`,{className:`p-4 [overflow-wrap:anywhere]`,children:t?/* @__PURE__ */ (0,E.jsx)(P,{run:t,showAutomation:e.showAutomation}):e.loading?/* @__PURE__ */ (0,E.jsx)(h,{label:`Loading run details`,variant:`panel`}):/* @__PURE__ */ (0,E.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:`This run is not in the loaded runs.`})})})}function P(e){let{run:t}=e;return/* @__PURE__ */ (0,E.jsxs)(`div`,{className:`grid min-w-0 gap-3`,children:[/* @__PURE__ */ (0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 px-1`,children:[/* @__PURE__ */ (0,E.jsx)(w,{tone:l(t.status),children:t.status}),/* @__PURE__ */ (0,E.jsx)(`time`,{className:`text-xs text-dashboard-text-muted`,dateTime:t.executedAt,title:s(t.executedAt),children:b(t.executedAt)})]}),t.error?/* @__PURE__ */ (0,E.jsx)(D,{title:`Error`,children:/* @__PURE__ */ (0,E.jsx)(`p`,{className:`m-0 whitespace-pre-wrap font-mono text-xs leading-relaxed text-rose-300`,children:t.error})}):null,/* @__PURE__ */ (0,E.jsx)(D,{title:`Run`,children:/* @__PURE__ */ (0,E.jsxs)(O,{children:[/* @__PURE__ */ (0,E.jsx)(k,{label:`Trigger`,children:t.kind===`scheduled`?`Schedule`:`Event`}),t.scheduledFor?/* @__PURE__ */ (0,E.jsx)(k,{label:`Scheduled for`,children:s(t.scheduledFor)}):null,t.startedAt?/* @__PURE__ */ (0,E.jsx)(k,{label:`Started`,children:s(t.startedAt)}):null,/* @__PURE__ */ (0,E.jsx)(k,{label:`Finished`,children:s(t.executedAt)}),/* @__PURE__ */ (0,E.jsx)(k,{label:`Duration`,children:g(t.durationMs)||`—`}),/* @__PURE__ */ (0,E.jsx)(k,{label:`Tokens`,children:t.totalTokens===void 0?`—`:_(t.totalTokens)}),/* @__PURE__ */ (0,E.jsx)(k,{label:`Cost`,children:t.costUsd===void 0?`—`:y({total:t.costUsd})})]})}),/* @__PURE__ */ (0,E.jsx)(D,{title:`Setup`,children:/* @__PURE__ */ (0,E.jsxs)(O,{children:[e.showAutomation?/* @__PURE__ */ (0,E.jsx)(k,{label:`Automation`,children:/* @__PURE__ */ (0,E.jsx)(r,{className:p,to:v(t.automationId),children:t.automationTitle})}):null,t.automationVersion?/* @__PURE__ */ (0,E.jsx)(k,{label:`Version`,children:/* @__PURE__ */ (0,E.jsxs)(r,{className:p,to:`${v(t.automationId,`versions`)}?version=${t.automationVersion}`,children:[`Version `,t.automationVersion]})}):null,t.credentialMode?/* @__PURE__ */ (0,E.jsx)(k,{label:`Accounts`,children:t.credentialMode===`creator`?`Creator’s connected accounts`:`Junior’s accounts only`}):null,/* @__PURE__ */ (0,E.jsx)(k,{label:`Run ID`,children:/* @__PURE__ */ (0,E.jsx)(`span`,{className:`font-mono`,children:t.executionId})})]})}),t.conversationId?null:/* @__PURE__ */ (0,E.jsx)(`p`,{className:`m-0 px-1 text-xs text-dashboard-text-muted`,children:`No Conversation was recorded for this run.`})]})}export{k as a,A as i,j as n,O as o,M as r,D as s,N as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n}from"./vendor-react-ggbyvons.js";import{t as r}from"./vendor-icons-mxz7yi04.js";import{a as i,i as a,n as o,t as s}from"./automationFormat-hd7pnocr.js";import{t as c}from"./styles-j0007fov.js";import{t as l}from"./Card-hy4bfgq7.js";import{t as u}from"./PageContentSkeleton-b7dkba0l.js";import{d,t as f,u as p}from"./PageHeader-bhl3orzi.js";import{b as m,l as h,p as g}from"./format-gle1s0ri.js";import{n as _,r as v}from"./searchParams-moqjgi65.js";import{F as y,W as b,d as x,f as S,p as C,qt as w}from"../client-f7asutg5.js";import{i as T,n as E,r as D,t as O}from"./AutomationRunDetails-jjdhbqtn.js";import{n as k,t as A}from"./FilterBar-mtnh7fbi.js";import{t as j}from"./SelectableRow-j8fwjsjz.js";var M=/* @__PURE__ */ e(t(),1),N=n();const P=[`all`,`scheduled`,`event`],F=[`all`,`completed`,`failed`,`blocked`],I=[],L=`grid-cols-[minmax(0,1.4fr)_minmax(0,1.2fr)_5.5rem_5.5rem_5.5rem_2rem]`;function R(e){let t=w(e.enabled),[n,r]=v(`type`,`all`,P),[i,a]=v(`status`,`all`,F),[o,s,m]=_(),[h,g]=(0,M.useState)(1),y=m.toLowerCase(),D=t.data?.runs??I,j=(0,M.useMemo)(()=>D.filter(e=>n!==`all`&&e.kind!==n||i!==`all`&&e.status!==i?!1:!y||[e.kind,e.status,e.automationTitle,e.title,e.conversationId].filter(Boolean).join(` `).toLowerCase().includes(y)),[n,D,y,i]),R=S(j.length,25),V=(0,M.useMemo)(()=>C(j,h,25),[h,j]);(0,M.useEffect)(()=>{g(1)},[n,m,i]),(0,M.useEffect)(()=>{h>R&&g(R)},[h,R]);let H=!t.data&&!t.error,U=T(V.map(e=>e.executionId)),W=U.runId?D.find(e=>e.executionId===U.runId):void 0;return/* @__PURE__ */ (0,N.jsxs)(E,{details:U.runId?/* @__PURE__ */ (0,N.jsx)(O,{loading:H,onClose:U.close,run:W,showAutomation:!0},U.runId):null,label:`Runs list`,listRef:U.listRef,children:[/* @__PURE__ */ (0,N.jsx)(f,{description:`Newest runs across your automations and automations in public destinations.`,title:`Runs`}),H?/* @__PURE__ */ (0,N.jsx)(u,{label:`Loading automation runs`,variant:`list`}):/* @__PURE__ */ (0,N.jsxs)(N.Fragment,{children:[/* @__PURE__ */ (0,N.jsxs)(A,{search:{label:`Search runs`,onChange:s,placeholder:`Automation, conversation, or status`,value:o},children:[/* @__PURE__ */ (0,N.jsx)(k,{label:`Type`,children:/* @__PURE__ */ (0,N.jsx)(p,{className:`flex-wrap gap-2`,onValueChange:([e])=>{e&&r(e)},value:[n],children:P.map(e=>/* @__PURE__ */ (0,N.jsx)(d,{value:e,variant:`pill`,children:e},e))})}),/* @__PURE__ */ (0,N.jsx)(k,{label:`Status`,children:/* @__PURE__ */ (0,N.jsx)(p,{className:`flex-wrap gap-2`,onValueChange:([e])=>{e&&a(e)},value:[i],children:F.map(e=>/* @__PURE__ */ (0,N.jsx)(d,{value:e,variant:`pill`,children:e},e))})})]}),/* @__PURE__ */ (0,N.jsx)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-5 gap-y-1 border-b border-dashboard-border-subtle pb-3`,children:/* @__PURE__ */ (0,N.jsxs)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:[j.length,` `,j.length===1?`run`:`runs`,/* @__PURE__ */ (0,N.jsxs)(`span`,{className:`text-dashboard-text-muted/70`,children:[` `,`· newest first`]})]})}),t.error?/* @__PURE__ */ (0,N.jsx)(l,{padding:`md`,children:/* @__PURE__ */ (0,N.jsx)(b,{children:`Automation runs could not be loaded. Try again.`})}):j.length===0?/* @__PURE__ */ (0,N.jsx)(l,{padding:`md`,children:/* @__PURE__ */ (0,N.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:z({kind:n,search:y,status:i})})}):/* @__PURE__ */ (0,N.jsx)(l,{children:/* @__PURE__ */ (0,N.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:/* @__PURE__ */ (0,N.jsxs)(`div`,{className:`min-w-[44rem]`,children:[/* @__PURE__ */ (0,N.jsxs)(`div`,{"aria-hidden":`true`,className:c(`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`,L),children:[/* @__PURE__ */ (0,N.jsx)(`div`,{children:`Run`}),/* @__PURE__ */ (0,N.jsx)(`div`,{children:`Automation`}),/* @__PURE__ */ (0,N.jsx)(`div`,{children:`Duration`}),/* @__PURE__ */ (0,N.jsx)(`div`,{children:`Tokens`}),/* @__PURE__ */ (0,N.jsx)(`div`,{children:`Cost`})]}),/* @__PURE__ */ (0,N.jsx)(`div`,{className:`min-w-0`,onKeyDown:U.onRowsKeyDown,role:`list`,children:V.map(e=>/* @__PURE__ */ (0,N.jsx)(B,{onSelect:()=>U.toggle(e.executionId),run:e,selected:U.runId===e.executionId},`${e.kind}:${e.executionId}`))})]})})}),/* @__PURE__ */ (0,N.jsx)(x,{onPageChange:g,page:h,pageCount:R,pageSize:25,total:j.length}),t.data?.truncated?/* @__PURE__ */ (0,N.jsx)(`p`,{className:`m-0 text-center text-xs text-dashboard-text-muted`,children:`Showing the 100 most recent runs.`}):null]})]})}function z(e){return e.search||e.kind!==`all`||e.status!==`all`?`No runs matched these filters.`:`No visible automations have run yet.`}function B(e){let{run:t}=e,n=g(t.costUsd===void 0?void 0:{total:t.costUsd})||`—`,r=m(t.durationMs)||`—`,i=t.totalTokens===void 0?`—`:h(t.totalTokens);return/* @__PURE__ */ (0,N.jsx)(`div`,{className:`border-b border-dashboard-border-subtle last:border-b-0`,"data-run-id":t.executionId,role:`listitem`,children:/* @__PURE__ */ (0,N.jsxs)(j,{className:c(`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`,L),onSelect:e.onSelect,selected:e.selected,children:[/* @__PURE__ */ (0,N.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,N.jsx)(`span`,{className:`block truncate text-sm font-medium leading-snug text-dashboard-text`,children:o(t,t.automationTitle)}),/* @__PURE__ */ (0,N.jsx)(`span`,{className:`mt-1 block truncate text-xs text-dashboard-text-muted`,children:a(t.executedAt)})]}),/* @__PURE__ */ (0,N.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[/* @__PURE__ */ (0,N.jsx)(`div`,{className:`truncate text-sm text-dashboard-text`,children:t.automationTitle}),/* @__PURE__ */ (0,N.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center gap-1.5 overflow-hidden text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,N.jsx)(H,{kind:t.kind}),/* @__PURE__ */ (0,N.jsx)(y,{label:t.status,tone:s(t.status)}),/* @__PURE__ */ (0,N.jsx)(`span`,{className:`truncate text-xs text-dashboard-text-muted`,children:t.status})]})]}),/* @__PURE__ */ (0,N.jsx)(V,{label:`Duration`,value:r}),/* @__PURE__ */ (0,N.jsx)(V,{label:`Tokens`,value:i}),/* @__PURE__ */ (0,N.jsx)(V,{label:`Cost`,value:n}),/* @__PURE__ */ (0,N.jsx)(`div`,{className:`max-md:hidden`,children:/* @__PURE__ */ (0,N.jsx)(D,{conversationId:t.conversationId})})]})})}function V(e){return/* @__PURE__ */ (0,N.jsxs)(`div`,{className:`min-w-0 max-md:flex max-md:items-center max-md:gap-2`,children:[/* @__PURE__ */ (0,N.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,N.jsxs)(`div`,{className:`truncate whitespace-nowrap font-mono text-xs text-dashboard-text-muted md:text-sm md:text-dashboard-text`,children:[/* @__PURE__ */ (0,N.jsxs)(`span`,{className:`sr-only`,children:[e.label,`: `]}),e.value]})]})}function H(e){let t=e.kind===`scheduled`?i:r,n=e.kind===`scheduled`?`Scheduled automation`:`Event automation`;return/* @__PURE__ */ (0,N.jsx)(`span`,{"aria-label":n,className:`inline-flex size-3.5 shrink-0 items-center justify-center text-dashboard-accent/80`,role:`img`,title:n,children:/* @__PURE__ */ (0,N.jsx)(t,{"aria-hidden":`true`,className:`size-3.5`,strokeWidth:1.8})})}export{R as AutomationRunsPage};
1
+ import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n}from"./vendor-react-ggbyvons.js";import{t as r}from"./vendor-icons-blmhaswc.js";import{a as i,i as a,n as o,t as s}from"./automationFormat-kv314fzh.js";import{t as c}from"./styles-j0007fov.js";import{t as l}from"./Card-hy4bfgq7.js";import{t as u}from"./PageContentSkeleton-b7dkba0l.js";import{d,t as f,u as p}from"./PageHeader-bhl3orzi.js";import{b as m,l as h,p as g}from"./format-flkutk9e.js";import{n as _,r as v}from"./searchParams-moqjgi65.js";import{$t as y,V as b,X as x,_ as S,g as C,h as w}from"../client-ctcthgam.js";import{i as T,n as E,r as D,t as O}from"./AutomationRunDetails-dx5lutte.js";import{n as k,t as A}from"./FilterBar-dqnt967g.js";import{t as j}from"./SelectableRow-j8fwjsjz.js";var M=/* @__PURE__ */ e(t(),1),N=n();const P=[`all`,`scheduled`,`event`],F=[`all`,`completed`,`failed`,`blocked`],I=[],L=`grid-cols-[minmax(0,1.4fr)_minmax(0,1.2fr)_5.5rem_5.5rem_5.5rem_2rem]`;function R(e){let t=y(e.enabled),[n,r]=v(`type`,`all`,P),[i,a]=v(`status`,`all`,F),[o,s,m]=_(),[h,g]=(0,M.useState)(1),b=m.toLowerCase(),D=t.data?.runs??I,j=(0,M.useMemo)(()=>D.filter(e=>n!==`all`&&e.kind!==n||i!==`all`&&e.status!==i?!1:!b||[e.kind,e.status,e.automationTitle,e.title,e.conversationId].filter(Boolean).join(` `).toLowerCase().includes(b)),[n,D,b,i]),R=C(j.length,25),V=(0,M.useMemo)(()=>S(j,h,25),[h,j]);(0,M.useEffect)(()=>{g(1)},[n,m,i]),(0,M.useEffect)(()=>{h>R&&g(R)},[h,R]);let H=!t.data&&!t.error,U=T(V.map(e=>e.executionId)),W=U.runId?D.find(e=>e.executionId===U.runId):void 0;return/* @__PURE__ */ (0,N.jsxs)(E,{details:U.runId?/* @__PURE__ */ (0,N.jsx)(O,{loading:H,onClose:U.close,run:W,showAutomation:!0},U.runId):null,label:`Runs list`,listRef:U.listRef,children:[/* @__PURE__ */ (0,N.jsx)(f,{description:`Newest runs across your automations and automations in public destinations.`,title:`Runs`}),H?/* @__PURE__ */ (0,N.jsx)(u,{label:`Loading automation runs`,variant:`list`}):/* @__PURE__ */ (0,N.jsxs)(N.Fragment,{children:[/* @__PURE__ */ (0,N.jsxs)(A,{search:{label:`Search runs`,onChange:s,placeholder:`Automation, conversation, or status`,value:o},children:[/* @__PURE__ */ (0,N.jsx)(k,{label:`Type`,children:/* @__PURE__ */ (0,N.jsx)(p,{className:`flex-wrap gap-2`,onValueChange:([e])=>{e&&r(e)},value:[n],children:P.map(e=>/* @__PURE__ */ (0,N.jsx)(d,{value:e,variant:`pill`,children:e},e))})}),/* @__PURE__ */ (0,N.jsx)(k,{label:`Status`,children:/* @__PURE__ */ (0,N.jsx)(p,{className:`flex-wrap gap-2`,onValueChange:([e])=>{e&&a(e)},value:[i],children:F.map(e=>/* @__PURE__ */ (0,N.jsx)(d,{value:e,variant:`pill`,children:e},e))})})]}),/* @__PURE__ */ (0,N.jsx)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-5 gap-y-1 border-b border-dashboard-border-subtle pb-3`,children:/* @__PURE__ */ (0,N.jsxs)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:[j.length,` `,j.length===1?`run`:`runs`,/* @__PURE__ */ (0,N.jsxs)(`span`,{className:`text-dashboard-text-muted/70`,children:[` `,`· newest first`]})]})}),t.error?/* @__PURE__ */ (0,N.jsx)(l,{padding:`md`,children:/* @__PURE__ */ (0,N.jsx)(x,{children:`Automation runs could not be loaded. Try again.`})}):j.length===0?/* @__PURE__ */ (0,N.jsx)(l,{padding:`md`,children:/* @__PURE__ */ (0,N.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:z({kind:n,search:b,status:i})})}):/* @__PURE__ */ (0,N.jsx)(l,{children:/* @__PURE__ */ (0,N.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:/* @__PURE__ */ (0,N.jsxs)(`div`,{className:`min-w-[44rem]`,children:[/* @__PURE__ */ (0,N.jsxs)(`div`,{"aria-hidden":`true`,className:c(`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`,L),children:[/* @__PURE__ */ (0,N.jsx)(`div`,{children:`Run`}),/* @__PURE__ */ (0,N.jsx)(`div`,{children:`Automation`}),/* @__PURE__ */ (0,N.jsx)(`div`,{children:`Duration`}),/* @__PURE__ */ (0,N.jsx)(`div`,{children:`Tokens`}),/* @__PURE__ */ (0,N.jsx)(`div`,{children:`Cost`})]}),/* @__PURE__ */ (0,N.jsx)(`div`,{className:`min-w-0`,onKeyDown:U.onRowsKeyDown,role:`list`,children:V.map(e=>/* @__PURE__ */ (0,N.jsx)(B,{onSelect:()=>U.toggle(e.executionId),run:e,selected:U.runId===e.executionId},`${e.kind}:${e.executionId}`))})]})})}),/* @__PURE__ */ (0,N.jsx)(w,{onPageChange:g,page:h,pageCount:R,pageSize:25,total:j.length}),t.data?.truncated?/* @__PURE__ */ (0,N.jsx)(`p`,{className:`m-0 text-center text-xs text-dashboard-text-muted`,children:`Showing the 100 most recent runs.`}):null]})]})}function z(e){return e.search||e.kind!==`all`||e.status!==`all`?`No runs matched these filters.`:`No visible automations have run yet.`}function B(e){let{run:t}=e,n=g(t.costUsd===void 0?void 0:{total:t.costUsd})||`—`,r=m(t.durationMs)||`—`,i=t.totalTokens===void 0?`—`:h(t.totalTokens);return/* @__PURE__ */ (0,N.jsx)(`div`,{className:`border-b border-dashboard-border-subtle last:border-b-0`,"data-run-id":t.executionId,role:`listitem`,children:/* @__PURE__ */ (0,N.jsxs)(j,{className:c(`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`,L),onSelect:e.onSelect,selected:e.selected,children:[/* @__PURE__ */ (0,N.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,N.jsx)(`span`,{className:`block truncate text-sm font-medium leading-snug text-dashboard-text`,children:o(t,t.automationTitle)}),/* @__PURE__ */ (0,N.jsx)(`span`,{className:`mt-1 block truncate text-xs text-dashboard-text-muted`,children:a(t.executedAt)})]}),/* @__PURE__ */ (0,N.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[/* @__PURE__ */ (0,N.jsx)(`div`,{className:`truncate text-sm text-dashboard-text`,children:t.automationTitle}),/* @__PURE__ */ (0,N.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center gap-1.5 overflow-hidden text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,N.jsx)(H,{kind:t.kind}),/* @__PURE__ */ (0,N.jsx)(b,{label:t.status,tone:s(t.status)}),/* @__PURE__ */ (0,N.jsx)(`span`,{className:`truncate text-xs text-dashboard-text-muted`,children:t.status})]})]}),/* @__PURE__ */ (0,N.jsx)(V,{label:`Duration`,value:r}),/* @__PURE__ */ (0,N.jsx)(V,{label:`Tokens`,value:i}),/* @__PURE__ */ (0,N.jsx)(V,{label:`Cost`,value:n}),/* @__PURE__ */ (0,N.jsx)(`div`,{className:`max-md:hidden`,children:/* @__PURE__ */ (0,N.jsx)(D,{conversationId:t.conversationId})})]})})}function V(e){return/* @__PURE__ */ (0,N.jsxs)(`div`,{className:`min-w-0 max-md:flex max-md:items-center max-md:gap-2`,children:[/* @__PURE__ */ (0,N.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,N.jsxs)(`div`,{className:`truncate whitespace-nowrap font-mono text-xs text-dashboard-text-muted md:text-sm md:text-dashboard-text`,children:[/* @__PURE__ */ (0,N.jsxs)(`span`,{className:`sr-only`,children:[e.label,`: `]}),e.value]})]})}function H(e){let t=e.kind===`scheduled`?i:r,n=e.kind===`scheduled`?`Scheduled automation`:`Event automation`;return/* @__PURE__ */ (0,N.jsx)(`span`,{"aria-label":n,className:`inline-flex size-3.5 shrink-0 items-center justify-center text-dashboard-accent/80`,role:`img`,title:n,children:/* @__PURE__ */ (0,N.jsx)(t,{"aria-hidden":`true`,className:`size-3.5`,strokeWidth:1.8})})}export{R as AutomationRunsPage};
@@ -1 +1 @@
1
- import{S as e,r as t}from"./vendor-react-ggbyvons.js";import{n}from"./button-ygjnb239.js";import{i as r,t as i}from"./automationFormat-hd7pnocr.js";import{t as a}from"./styles-j0007fov.js";import{n as o,y as s}from"./format-gle1s0ri.js";import{I as c,Ot as l,ut as u}from"../client-f7asutg5.js";import{t as d}from"./FormNotice-eyo2kdte.js";var f=e();function p(e){let n=e.runs.slice(-e.slots),o=Math.max(0,...n.map(e=>e.status===`completed`?e.durationMs??0:0)),s=e.slots-n.length,l=e.size!=="default";return/* @__PURE__ */ (0,f.jsxs)(`div`,{"aria-label":e.label,className:a(`flex min-w-0 items-end justify-end overflow-hidden [&>*]:shrink-0`,l?`h-5 gap-0.5`:`h-16 gap-1`),role:`img`,children:[Array.from({length:s},(e,t)=>/* @__PURE__ */ (0,f.jsx)(`span`,{"aria-hidden":`true`,className:a(`h-0.5 rounded-full bg-dashboard-fill-strong`,l?`w-1`:`w-2`)},`empty-${t}`)),n.map(e=>{let n=e.status!==`completed`||!o||e.durationMs===void 0?100:Math.max(30,Math.round(e.durationMs/o*100)),s=`${e.status} · ${r(e.executedAt)}`,u=a(`block rounded-[1px] opacity-80 transition-opacity hover:opacity-100`,l?`w-1`:`w-2`,c[i(e.status)]);return e.to?/* @__PURE__ */ (0,f.jsx)(t,{"aria-label":`Open ${s}`,className:a(u,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus`),style:{height:`${n}%`},title:s,to:e.to},e.key):/* @__PURE__ */ (0,f.jsx)(`span`,{"aria-hidden":`true`,className:u,style:{height:`${n}%`},title:s},e.key)})]})}function m({automation:e}){let t=e.kind===`event`&&e.trigger.problems.length>0;return/* @__PURE__ */ (0,f.jsx)(`span`,{"aria-label":`Automation state`,"aria-live":`polite`,role:`status`,children:/* @__PURE__ */ (0,f.jsx)(u,{size:`compact`,tone:e.status===`paused`||e.status===`completed`?`neutral`:e.status===`blocked`||t?`warning`:`success`,children:e.status===`active`&&t?`Trigger unavailable`:e.status})})}function h(e){if(e.status===`blocked`||e.status===`paused`&&e.statusReason)return`fix`;if(e.kind===`event`&&e.trigger.problems.length>0)return`trigger`;if(e.lastRunStatus===`failed`||e.lastRunStatus===`blocked`)return`last_run`}function g(e){let t=h(e);if(!t)return;let n={label:`Open runs`,to:o(e.id,`runs`)},r=e.kind===`event`?e.trigger.problems[0]:void 0,i=r?{label:`Change trigger`,to:o(e.id,`edit`)}:e.lastConversationId?{label:`Open last run`,to:l(e.lastConversationId)}:n;return t===`trigger`?{action:i,message:r??`Trigger unavailable`,tone:`warning`}:t===`fix`?{action:i,message:e.statusReason??`${e.status} until fixed`,tone:`warning`}:{action:i,message:`Last run ${e.lastRunStatus}${e.lastRunAt?` ${s(e.lastRunAt)}`:``}`,tone:e.lastRunStatus===`failed`?`danger`:`warning`}}function _(e){return h(e)!==void 0}function v({automation:e,editPath:r,lastRunError:i}){let s=h(e);if(!s)return null;let c=e.status===`paused`,u=e.kind===`event`?e.trigger.problems:[],p=s===`fix`,m=u.length>0,g=s===`last_run`;return/* @__PURE__ */ (0,f.jsxs)(d,{title:p?`Fix this before resuming`:m?`Trigger unavailable`:`Last run ${e.lastRunStatus??`needs a look`}`,children:[p?/* @__PURE__ */ (0,f.jsxs)(`p`,{className:`m-0 break-words`,children:[e.statusReason??`Check the last run to see what needs fixing.`,` `,!e.ownedByViewer&&e.credentialMode===`creator`?`It uses accounts connected by ${e.createdBy}. Ask them to resume it, or switch it to Junior's credentials first.`:null]}):null,m?/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`ul`,{className:`my-1 list-disc pl-5`,children:u.map(e=>/* @__PURE__ */ (0,f.jsx)(`li`,{className:`break-words`,children:e},e))}),/* @__PURE__ */ (0,f.jsx)(`p`,{className:`m-0`,children:`Edit the trigger, or enable its plugin again.`})]}):null,g&&!p&&!m&&i?/* @__PURE__ */ (0,f.jsx)(`p`,{className:`m-0 mb-1 whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-rose-300`,children:i}):null,g&&!p&&!m?/* @__PURE__ */ (0,f.jsx)(`p`,{className:`m-0`,children:e.status===`active`?`Future runs are still on.`:c?`Review the last result before resuming.`:`Review the last result for details.`}):null,m?/* @__PURE__ */ (0,f.jsx)(t,{className:a(n({variant:`primary`}),`mt-3`),to:r,children:`Change trigger`}):e.lastConversationId?/* @__PURE__ */ (0,f.jsx)(t,{className:a(n({variant:`primary`}),`mt-3`),to:l(e.lastConversationId),children:`Open last run`}):e.totalRuns>0?/* @__PURE__ */ (0,f.jsx)(t,{className:a(n({variant:`primary`}),`mt-3`),to:o(e.id,`runs`),children:`View run history`}):null]})}export{p as a,g as i,m as n,_ as r,v as t};
1
+ import{S as e,r as t}from"./vendor-react-ggbyvons.js";import{n}from"./button-ygjnb239.js";import{i as r,t as i}from"./automationFormat-kv314fzh.js";import{t as a}from"./styles-j0007fov.js";import{n as o,y as s}from"./format-flkutk9e.js";import{H as c,Lt as l,ht as u}from"../client-ctcthgam.js";import{t as d}from"./FormNotice-kj5pzsl7.js";var f=e();function p(e){let n=e.runs.slice(-e.slots),o=Math.max(0,...n.map(e=>e.status===`completed`?e.durationMs??0:0)),s=e.slots-n.length,l=e.size!=="default";return/* @__PURE__ */ (0,f.jsxs)(`div`,{"aria-label":e.label,className:a(`flex min-w-0 items-end justify-end overflow-hidden [&>*]:shrink-0`,l?`h-5 gap-0.5`:`h-16 gap-1`),role:`img`,children:[Array.from({length:s},(e,t)=>/* @__PURE__ */ (0,f.jsx)(`span`,{"aria-hidden":`true`,className:a(`h-0.5 rounded-full bg-dashboard-fill-strong`,l?`w-1`:`w-2`)},`empty-${t}`)),n.map(e=>{let n=e.status!==`completed`||!o||e.durationMs===void 0?100:Math.max(30,Math.round(e.durationMs/o*100)),s=`${e.status} · ${r(e.executedAt)}`,u=a(`block rounded-[1px] opacity-80 transition-opacity hover:opacity-100`,l?`w-1`:`w-2`,c[i(e.status)]);return e.to?/* @__PURE__ */ (0,f.jsx)(t,{"aria-label":`Open ${s}`,className:a(u,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus`),style:{height:`${n}%`},title:s,to:e.to},e.key):/* @__PURE__ */ (0,f.jsx)(`span`,{"aria-hidden":`true`,className:u,style:{height:`${n}%`},title:s},e.key)})]})}function m({automation:e}){let t=e.kind===`event`&&e.trigger.problems.length>0;return/* @__PURE__ */ (0,f.jsx)(`span`,{"aria-label":`Automation state`,"aria-live":`polite`,role:`status`,children:/* @__PURE__ */ (0,f.jsx)(u,{size:`compact`,tone:e.status===`paused`||e.status===`completed`?`neutral`:e.status===`blocked`||t?`warning`:`success`,children:e.status===`active`&&t?`Trigger unavailable`:e.status})})}function h(e){if(e.status===`blocked`||e.status===`paused`&&e.statusReason)return`fix`;if(e.kind===`event`&&e.trigger.problems.length>0)return`trigger`;if(e.lastRunStatus===`failed`||e.lastRunStatus===`blocked`)return`last_run`}function g(e){let t=h(e);if(!t)return;let n={label:`Open runs`,to:o(e.id,`runs`)},r=e.kind===`event`?e.trigger.problems[0]:void 0,i=r?{label:`Change trigger`,to:o(e.id,`edit`)}:e.lastConversationId?{label:`Open last run`,to:l(e.lastConversationId)}:n;return t===`trigger`?{action:i,message:r??`Trigger unavailable`,tone:`warning`}:t===`fix`?{action:i,message:e.statusReason??`${e.status} until fixed`,tone:`warning`}:{action:i,message:`Last run ${e.lastRunStatus}${e.lastRunAt?` ${s(e.lastRunAt)}`:``}`,tone:e.lastRunStatus===`failed`?`danger`:`warning`}}function _(e){return h(e)!==void 0}function v({automation:e,editPath:r,lastRunError:i}){let s=h(e);if(!s)return null;let c=e.status===`paused`,u=e.kind===`event`?e.trigger.problems:[],p=s===`fix`,m=u.length>0,g=s===`last_run`;return/* @__PURE__ */ (0,f.jsxs)(d,{title:p?`Fix this before resuming`:m?`Trigger unavailable`:`Last run ${e.lastRunStatus??`needs a look`}`,children:[p?/* @__PURE__ */ (0,f.jsxs)(`p`,{className:`m-0 break-words`,children:[e.statusReason??`Check the last run to see what needs fixing.`,` `,!e.ownedByViewer&&e.credentialMode===`creator`?`It uses accounts connected by ${e.createdBy}. Ask them to resume it, or switch it to Junior's credentials first.`:null]}):null,m?/* @__PURE__ */ (0,f.jsxs)(f.Fragment,{children:[/* @__PURE__ */ (0,f.jsx)(`ul`,{className:`my-1 list-disc pl-5`,children:u.map(e=>/* @__PURE__ */ (0,f.jsx)(`li`,{className:`break-words`,children:e},e))}),/* @__PURE__ */ (0,f.jsx)(`p`,{className:`m-0`,children:`Edit the trigger, or enable its plugin again.`})]}):null,g&&!p&&!m&&i?/* @__PURE__ */ (0,f.jsx)(`p`,{className:`m-0 mb-1 whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-rose-300`,children:i}):null,g&&!p&&!m?/* @__PURE__ */ (0,f.jsx)(`p`,{className:`m-0`,children:e.status===`active`?`Future runs are still on.`:c?`Review the last result before resuming.`:`Review the last result for details.`}):null,m?/* @__PURE__ */ (0,f.jsx)(t,{className:a(n({variant:`primary`}),`mt-3`),to:r,children:`Change trigger`}):e.lastConversationId?/* @__PURE__ */ (0,f.jsx)(t,{className:a(n({variant:`primary`}),`mt-3`),to:l(e.lastConversationId),children:`Open last run`}):e.totalRuns>0?/* @__PURE__ */ (0,f.jsx)(t,{className:a(n({variant:`primary`}),`mt-3`),to:o(e.id,`runs`),children:`View run history`}):null]})}export{p as a,g as i,m as n,_ as r,v as t};
@@ -0,0 +1,8 @@
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{$t as c,J as l,Pt as u,n as d,t as f}from"./vendor-icons-blmhaswc.js";import{a as p,i as m,r as h}from"./automationFormat-kv314fzh.js";import{Rt as g,it as _}from"./junior-g62bxb2t.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 ee,u as S}from"./PageHeader-bhl3orzi.js";import{n as C,y as w}from"./format-flkutk9e.js";import{n as T,t as te}from"./searchParams-moqjgi65.js";import{Bt as ne,Et as E,Ht as D,K as O,Ut as k,X as A,ct as j,dt as M,ft as N,ot as P,st as F,tn as I,zt as L}from"../client-ctcthgam.js";import{t as R}from"./native-select-fxs3p0bj.js";import{a as z,i as B,r as V}from"./AutomationStatus-eqq5lrad.js";import{n as H}from"./FilterBar-dqnt967g.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=c(`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(E);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function J(){return window.matchMedia(E).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)(N,{className:`flex-1`,size:`default`,label:`Search automations`,placeholder:`Search automations`,value:e.searchText,onChange:e.onSearch}),o?/* @__PURE__ */ (0,G.jsxs)(L,{open:i,onOpenChange:a,children:[/* @__PURE__ */ (0,G.jsx)(k,{render:l}),/* @__PURE__ */ (0,G.jsxs)(ne,{align:`end`,className:`w-80`,children:[/* @__PURE__ */ (0,G.jsx)(D,{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)(O,{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)(S,{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)(M,{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)(l,{"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 ${w(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 ${w(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]=T(`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=I(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=>te(C(e),n.search);return/* @__PURE__ */ (0,G.jsxs)(G.Fragment,{children:[/* @__PURE__ */ (0,G.jsx)(ee,{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)(A,{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)(P,{"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)(j,{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)(u,{"aria-hidden":`true`,className:v(`transition-transform`,n&&`rotate-90`),size:14}),a]})}),/* @__PURE__ */ (0,G.jsx)(F,{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};