@sentry/junior-dashboard 0.279.0 → 0.281.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +105 -43
- package/dist/client-manifest.json +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +105 -43
- package/dist/public/chunks/AdminPage-M5RBVZFN.js +1 -0
- package/dist/public/chunks/AutomationPage-WALCREDT.js +3 -0
- package/dist/public/chunks/AutomationRunsPage-CV47E4UX.js +1 -0
- package/dist/public/chunks/AutomationsPage-57L3AQVJ.js +1 -0
- package/dist/public/chunks/CodePage-XJUYMFJH.js +1 -0
- package/dist/public/chunks/ConnectionsPage-3QQAGYWF.js +1 -0
- package/dist/public/chunks/DrawerContent-RYYS57ZH.js +1 -0
- package/dist/public/chunks/LocationDetailPage-4IL5HQML.js +1 -0
- package/dist/public/chunks/LocationsPage-D2DUQAHJ.js +1 -0
- package/dist/public/chunks/McpSettingsPage-3RT7JPEK.js +1 -0
- package/dist/public/chunks/PeoplePage-6F5GPQ7C.js +1 -0
- package/dist/public/chunks/PersonProfilePage-SPAYQPTD.js +1 -0
- package/dist/public/chunks/PersonalTokensPage-SHAUJ74M.js +1 -0
- package/dist/public/chunks/PluginUserPage-64FIWD7M.js +1 -0
- package/dist/public/chunks/RepositoryPage-L7IHOXSN.js +1 -0
- package/dist/public/chunks/SettingsPage-U7WG4FHE.js +1 -0
- package/dist/public/chunks/SystemPage-ZBC43OJH.js +1 -0
- package/dist/public/chunks/WorkspaceFormPage-3NVIIZ4P.js +2 -0
- package/dist/public/chunks/WorkspacesPage-G73HPBDD.js +1 -0
- package/dist/public/chunks/chunk-2BCS5AQL.js +1 -0
- package/dist/public/chunks/chunk-2J3LGF5Q.js +1 -0
- package/dist/public/chunks/chunk-2NNKHSZE.js +1 -0
- package/dist/public/chunks/chunk-3Y3ICT6K.js +1 -0
- package/dist/public/chunks/chunk-4AKUZW6R.js +1 -0
- package/dist/public/chunks/chunk-4TQSTCIN.js +13 -0
- package/dist/public/chunks/chunk-4UGZNVJM.js +1 -0
- package/dist/public/chunks/chunk-564V7YHG.js +1 -0
- package/dist/public/chunks/chunk-5ISD3QSC.js +1 -0
- package/dist/public/chunks/chunk-5LNGNJ3P.js +1 -0
- package/dist/public/chunks/chunk-5ZA674OU.js +1 -0
- package/dist/public/chunks/chunk-64GPEGGE.js +1 -0
- package/dist/public/chunks/chunk-6FHY65EQ.js +1 -0
- package/dist/public/chunks/chunk-6FSJ3W2W.js +1 -0
- package/dist/public/chunks/chunk-6PHJZPWD.js +19 -0
- package/dist/public/chunks/chunk-B5ZN3SWQ.js +14 -0
- package/dist/public/chunks/chunk-BKOACADP.js +1 -0
- package/dist/public/chunks/chunk-CQY6BYUB.js +1 -0
- package/dist/public/chunks/chunk-CR2ICLSH.js +1 -0
- package/dist/public/chunks/chunk-DEEO4D4N.js +1 -0
- package/dist/public/chunks/chunk-DZB4LPI6.js +1 -0
- package/dist/public/chunks/chunk-FE522UEA.js +1 -0
- package/dist/public/chunks/chunk-FSGVY7HB.js +1 -0
- package/dist/public/chunks/chunk-FVX42XAD.js +1 -0
- package/dist/public/chunks/chunk-G5NWYJTV.js +1 -0
- package/dist/public/chunks/chunk-GMZIELFU.js +1 -0
- package/dist/public/chunks/chunk-GOTQ4D6W.js +1 -0
- package/dist/public/chunks/chunk-GYRM5ZIV.js +1 -0
- package/dist/public/chunks/chunk-GZBMHYYU.js +1 -0
- package/dist/public/chunks/chunk-H2ZU34CP.js +1 -0
- package/dist/public/chunks/chunk-H76B43OQ.js +1 -0
- package/dist/public/chunks/chunk-HCLRG2EC.js +1 -0
- package/dist/public/chunks/chunk-II4NXLSQ.js +2 -0
- package/dist/public/chunks/chunk-ILH47V7O.js +1 -0
- package/dist/public/chunks/chunk-IZWTFLCC.js +1 -0
- package/dist/public/chunks/chunk-J37MXUED.js +1 -0
- package/dist/public/chunks/chunk-JAZABOBA.js +0 -0
- package/dist/public/chunks/chunk-JPL2NRWK.js +1 -0
- package/dist/public/chunks/chunk-JVJ5UWIK.js +1 -0
- package/dist/public/chunks/chunk-K4TYMAA3.js +63 -0
- package/dist/public/chunks/chunk-KDUTK357.js +1 -0
- package/dist/public/chunks/chunk-L2H3ZWZN.js +1 -0
- package/dist/public/chunks/chunk-LBELRO5P.js +1 -0
- package/dist/public/chunks/chunk-LKW7MULF.js +1 -0
- package/dist/public/chunks/chunk-LZYAHJVQ.js +1 -0
- package/dist/public/chunks/chunk-MEHLQZDG.js +3 -0
- package/dist/public/chunks/chunk-MKKFXRYO.js +1 -0
- package/dist/public/chunks/chunk-MTBUV2GJ.js +1 -0
- package/dist/public/chunks/chunk-NGQRNS3C.js +1 -0
- package/dist/public/chunks/chunk-ONDKE72P.js +1 -0
- package/dist/public/chunks/chunk-PG7M7L24.js +1 -0
- package/dist/public/chunks/chunk-PQPAPPEI.js +1 -0
- package/dist/public/chunks/chunk-PXHLJIOT.js +1 -0
- package/dist/public/chunks/chunk-QOX5RMLM.js +1 -0
- package/dist/public/chunks/chunk-QPBLZSNX.js +1 -0
- package/dist/public/chunks/chunk-QQUFROWT.js +1 -0
- package/dist/public/chunks/chunk-RB5FBDEY.js +1 -0
- package/dist/public/chunks/chunk-RGXXD4DM.js +41 -0
- package/dist/public/chunks/chunk-RHMZNAJX.js +1 -0
- package/dist/public/chunks/chunk-SIOW7OOW.js +1 -0
- package/dist/public/chunks/chunk-SUX4QBVF.js +1 -0
- package/dist/public/chunks/chunk-T4M53QQT.js +1 -0
- package/dist/public/chunks/chunk-TC7TU4GK.js +1 -0
- package/dist/public/chunks/chunk-TFJOEF3Q.js +1 -0
- package/dist/public/chunks/chunk-UJD3MBMB.js +1 -0
- package/dist/public/chunks/chunk-UK2V4UBT.js +1 -0
- package/dist/public/chunks/chunk-UT6HZPGL.js +1 -0
- package/dist/public/chunks/chunk-UZ44J2LH.js +1 -0
- package/dist/public/chunks/chunk-VC6IS564.js +1 -0
- package/dist/public/chunks/chunk-WLIOZO3W.js +1 -0
- package/dist/public/chunks/chunk-WRXMQB7X.js +25 -0
- package/dist/public/chunks/chunk-XDUSY26N.js +55 -0
- package/dist/public/chunks/chunk-XNR4RZEC.js +1 -0
- package/dist/public/chunks/chunk-YPMUHXYT.js +147 -0
- package/dist/public/chunks/chunk-ZIJ6SJDN.js +1 -0
- package/dist/public/chunks/code-highlighter-Q7WC7AEF.js +12 -0
- package/dist/public/client-4OAAOHF4.js +68 -0
- package/dist/tailwind.css +1 -1
- package/package.json +5 -4
- package/src/api/schema.ts +1 -1
- package/src/assets.ts +4 -1
- package/src/client/App.tsx +100 -23
- package/src/client/TracedRoutes.tsx +8 -4
- package/src/client/code-highlighter.ts +26 -0
- package/src/client/code.tsx +2 -22
- package/src/client/components/BottomSheet.tsx +1 -1
- package/src/client/components/DetailsPanel.tsx +2 -1
- package/src/client/components/Drawer.tsx +12 -71
- package/src/client/components/DrawerContent.tsx +76 -0
- package/src/client/components/ProfileMenu.tsx +12 -3
- package/src/client/components/UserInputForm.tsx +28 -5
- package/src/client/conversations/ConversationBrief.tsx +129 -65
- package/src/client/conversations/ConversationCatchUp.tsx +107 -0
- package/src/client/conversations/ConversationContextTags.tsx +110 -0
- package/src/client/conversations/ConversationDetails.tsx +13 -14
- package/src/client/conversations/ConversationEventLog.tsx +135 -70
- package/src/client/conversations/ConversationHeader.tsx +74 -65
- package/src/client/conversations/ConversationHeaderActions.tsx +36 -38
- package/src/client/conversations/ConversationHomeList.tsx +41 -3
- package/src/client/conversations/ConversationLinkedWork.tsx +30 -10
- package/src/client/conversations/ConversationMeta.tsx +21 -27
- package/src/client/conversations/ConversationOverflowMenu.tsx +15 -4
- package/src/client/conversations/ConversationPage.tsx +219 -157
- package/src/client/conversations/ConversationTranscript.tsx +234 -186
- package/src/client/conversations/ConversationUsageBreakdown.tsx +142 -64
- package/src/client/conversations/DetailsList.tsx +7 -1
- package/src/client/conversations/PendingMailboxStack.tsx +88 -44
- package/src/client/conversations/ShareConversationButton.tsx +5 -50
- package/src/client/conversations/SlackMark.tsx +16 -4
- package/src/client/conversations/TranscriptActivityGroup.tsx +7 -14
- package/src/client/conversations/TranscriptEventView.tsx +7 -3
- package/src/client/conversations/TranscriptReasoningView.tsx +4 -2
- package/src/client/conversations/TranscriptRows.tsx +61 -16
- package/src/client/conversations/TranscriptView.tsx +25 -13
- package/src/client/conversations/conversationArchive.ts +22 -0
- package/src/client/conversations/conversationCatchUpState.ts +96 -0
- package/src/client/conversations/conversationMemory.ts +8 -1
- package/src/client/conversations/queries.ts +85 -46
- package/src/client/conversations/{transcriptUnreadHistory.ts → transcriptAroundHistory.ts} +48 -42
- package/src/client/conversations/transcriptBottomPinning.ts +40 -8
- package/src/client/conversations/transcriptListRows.ts +215 -0
- package/src/client/conversations/transcriptReadPosition.ts +24 -2
- package/src/client/conversations/turnContext.ts +1 -1
- package/src/client/conversations/virtualRows.ts +168 -0
- package/src/client/http.ts +6 -5
- package/src/client/pages/admin/AdminPage.tsx +1 -1
- package/src/client/pages/admin/ServiceAccountsSection.tsx +1 -1
- package/src/client/pages/memory/memoryDashboard.ts +1 -1
- package/src/client/pages/memory/memoryRecord.ts +1 -1
- package/src/client/pages/settings/ConnectionsPage.tsx +1 -1
- package/src/client/pages/user/PluginUserPage.tsx +0 -6
- package/src/client/pages/user/pluginUserPageRoutes.ts +5 -0
- package/src/client/primaryNav.ts +1 -1
- package/src/client/review-desk/reviewItemFormat.ts +1 -1
- package/src/client/sentry.ts +53 -3
- package/src/conversation-cache.ts +8 -10
- package/src/mock-reporting/fixtures.ts +43 -8
- package/src/mock-reporting/routes.ts +40 -3
- package/src/public-assets.ts +28 -20
- package/src/shell.ts +12 -2
- package/dist/public/client-ZCZXZBTL.js +0 -460
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as T}from"./chunk-UK2V4UBT.js";import{a as B}from"./chunk-XNR4RZEC.js";import{a as g}from"./chunk-2BCS5AQL.js";import{g as I}from"./chunk-II4NXLSQ.js";import"./chunk-MTBUV2GJ.js";import{d as x,g as N,i as h,r as R,u as z,v as E}from"./chunk-4TQSTCIN.js";import{Aa as P,Ba as k,Ca as $,Ka as c}from"./chunk-XDUSY26N.js";import{M as D,o as S,s as L}from"./chunk-6PHJZPWD.js";import{b as v}from"./chunk-CR2ICLSH.js";import{Pb as w,Sc as Q,b as l,cb as A,kb as C}from"./chunk-YPMUHXYT.js";import{c as m}from"./chunk-7SZRL6FY.js";var n=m(l(),1),O=["dashboard","service-accounts"];function F(i){return`/api/service-accounts/${encodeURIComponent(i)}`}function U(){return N({queryKey:O,queryFn:({signal:i})=>E(P,"/api/service-accounts",i),refetchOnWindowFocus:!0,retry:!1})}function K(i){let o=i.userOAuth?`People who have not connected their own ${i.displayName} account use this account.`:`Everyone uses this account. People cannot connect their own ${i.displayName} account.`;return i.connected?`Connected by ${i.connectedBy??"the CLI"} ${I(i.connectedAt)}. ${o}`:`Not connected.${i.userOAuth?"":` ${i.displayName} is not available until you connect it.`} ${o} Sign in as the shared account, not as yourself.`}function q(i){let{accountsQuery:o}=i,d=x(),r=h({mutationFn:e=>R(k,F(e.provider),{}),onSuccess:({authorizationUrl:e},{popup:a})=>{if(!a){window.location.assign(e);return}a.closed||(a.opener=null,a.location.href=e)},onError:(e,{popup:a})=>{a?.close()}}),s=h({mutationFn:e=>z($,F(e.provider)),onSuccess:()=>d.invalidateQueries({queryKey:O})}),f=o.data?.serviceAccounts??[];if(o.isSuccess&&f.length===0)return null;let y=r.isPending||s.isPending,u=r.isPending?r.variables?.provider:s.isPending?s.variables?.provider:void 0,p=!o.data&&o.isError,b=r.isError?"Could not start the sign-in. Try again.":s.isError?"Could not disconnect the account. Try again.":p?"Could not load service accounts. Try again.":void 0;return(0,n.jsxs)(c,{as:"section",padding:"md",children:[(0,n.jsx)("h2",{className:"m-0 font-display text-base font-medium text-dashboard-text",children:"Service accounts"}),(0,n.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"," ",L()," can use it, so give it only access that all of them may have."]}),b?(0,n.jsx)(B,{className:p?void 0:"mb-4",children:b}):null,p?null:o.isPending?(0,n.jsx)("p",{className:"m-0 text-sm text-dashboard-text-muted",children:"Loading service accounts\u2026"}):(0,n.jsx)("div",{className:"space-y-2",children:f.map(e=>(0,n.jsxs)("div",{className:"flex items-center gap-3 rounded-md border border-dashboard-border-strong p-3",children:[(0,n.jsx)(w,{"aria-hidden":"true",className:"shrink-0 text-dashboard-accent",size:16}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsx)("p",{className:"m-0 truncate text-sm font-semibold",children:e.displayName}),(0,n.jsx)(g,{size:"compact",tone:e.connected?"success":e.userOAuth?"neutral":"warning",children:e.connected?"connected":"not connected"}),e.userOAuth?null:(0,n.jsx)(g,{size:"compact",tone:"neutral",children:"shared only"})]}),(0,n.jsx)("p",{className:"mt-1 mb-0 break-words text-xs text-dashboard-text-muted",children:K(e)}),(0,n.jsx)("p",{className:"mt-1 mb-0 break-words font-mono text-xs text-dashboard-text-faint",children:e.tools.join(", ")})]}),e.connected?(0,n.jsx)(v,{"aria-busy":s.isPending&&u===e.provider,"aria-label":`Disconnect the ${e.displayName} service account`,disabled:y,onClick:()=>{r.reset(),s.mutate(e)},variant:"danger",children:"Disconnect"}):null,(0,n.jsx)(v,{"aria-busy":r.isPending&&u===e.provider,"aria-label":`${e.connected?"Reconnect":"Connect"} the ${e.displayName} service account`,disabled:y,onClick:()=>{s.reset();let a=window.open("about:blank","_blank");r.mutate({provider:e.provider,popup:a})},children:r.isPending&&u===e.provider?"Connecting\u2026":e.connected?"Reconnect":"Connect"})]},e.provider))})]})}var t=m(l(),1);function ae(i){let o=i.pages.filter(s=>s.navigation==="admin"),d=U(),r=o.length===0&&d.data?.serviceAccounts.length===0;return(0,t.jsx)("div",{className:`${Q} px-4 py-8 md:px-8`,children:(0,t.jsxs)("section",{className:"mx-auto grid w-full max-w-3xl gap-6",children:[(0,t.jsx)(D,{description:(0,t.jsxs)(t.Fragment,{children:["Setup that only Junior admins can see. Change who is an admin with"," ",(0,t.jsx)("code",{children:"junior admin grant <email>"})," and"," ",(0,t.jsx)("code",{children:"junior admin revoke <email>"}),"."]}),title:"Admin"}),(0,t.jsx)(q,{accountsQuery:d}),r?(0,t.jsx)(c,{padding:"md",children:(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[(0,t.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:(0,t.jsx)(A,{"aria-hidden":"true",size:17})}),(0,t.jsx)("p",{className:"m-0 text-sm text-dashboard-text-muted",children:"No plugin has admin setup."})]})}):o.length===0?null:(0,t.jsx)("div",{className:"grid gap-3",children:o.map(s=>(0,t.jsx)(S,{className:"no-underline",to:T(s.pluginName,s.id),children:(0,t.jsx)(c,{padding:"md",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("div",{className:"font-sans font-medium text-xs text-dashboard-text-muted",children:s.pluginDisplayName}),(0,t.jsx)("h2",{className:"mt-1 mb-0 font-display text-base font-medium text-dashboard-text",children:s.label}),(0,t.jsx)("p",{className:"mt-1 mb-0 text-sm text-dashboard-text-muted",children:s.description})]}),(0,t.jsx)(C,{"aria-hidden":"true",className:"shrink-0 text-dashboard-text-muted",size:16})]})})},`${s.pluginName}:${s.id}`))})]})})}export{ae as AdminPage};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as B}from"./chunk-BKOACADP.js";import{a as ca,b as ua,c as ga,d as fa,e as pa,f as Lt}from"./chunk-RB5FBDEY.js";import{a as da,b as X,c as la,d as ma}from"./chunk-FSGVY7HB.js";import{a as sa}from"./chunk-SIOW7OOW.js";import{a as he}from"./chunk-4UGZNVJM.js";import{c as ra}from"./chunk-2J3LGF5Q.js";import{a as aa}from"./chunk-SUX4QBVF.js";import{a as Go,c as Qo,f as Zo,o as Xo,p as ea,q as ta,t as oa,w as na,x as ia}from"./chunk-K4TYMAA3.js";import{a as Ho,b as pt,c as ht}from"./chunk-HCLRG2EC.js";import{a as q,b as j,c as Je,d as tt,e as Wo}from"./chunk-PQPAPPEI.js";import{b as Le}from"./chunk-GYRM5ZIV.js";import{a as Oo,b as $o,c as Vo,e as Bo}from"./chunk-ZIJ6SJDN.js";import{a as Be,b as _e,c as Ue,d as ze,e as qe,f as je,g as He}from"./chunk-MKKFXRYO.js";import"./chunk-WLIOZO3W.js";import"./chunk-JVJ5UWIK.js";import{a as We}from"./chunk-XNR4RZEC.js";import"./chunk-FE522UEA.js";import"./chunk-G5NWYJTV.js";import{a as ut}from"./chunk-5ZA674OU.js";import{l as ft}from"./chunk-RGXXD4DM.js";import{j as Yo}from"./chunk-TFJOEF3Q.js";import{a as et,b as $e}from"./chunk-KDUTK357.js";import{a as _o,b as Uo,c as gt,d as zo,e as qo,f as jo}from"./chunk-6FSJ3W2W.js";import{a as Ce}from"./chunk-2BCS5AQL.js";import"./chunk-QOX5RMLM.js";import"./chunk-H76B43OQ.js";import{h as To,j as Oe,k as mt}from"./chunk-64GPEGGE.js";import"./chunk-ILH47V7O.js";import{K as Eo,O as se,g as we,k as ct,r as Do,z as Ve}from"./chunk-II4NXLSQ.js";import"./chunk-PXHLJIOT.js";import{i as co,j as uo,l as go}from"./chunk-GMZIELFU.js";import{l as Z}from"./chunk-MEHLQZDG.js";import"./chunk-MTBUV2GJ.js";import{d as pe,g as Fe,i as ge,p as oe,q as So,r as Me,t as Ro,v as ce}from"./chunk-4TQSTCIN.js";import{Ka as Q,U as re,V as No,W as wo,X as Co,Y as ko,l as fo,m as po,n as ho,o as vo,p as bo,q as xo,r as yo,s as Ao}from"./chunk-XDUSY26N.js";import"./chunk-QPBLZSNX.js";import{a as ke,c as bt}from"./chunk-RHMZNAJX.js";import{a as It}from"./chunk-GOTQ4D6W.js";import{C as Lo,D as Mo,G as Jo,K as vt,L as Ko,M as Pt,b as nt,d as Pe,f as it,g as Yt,i as Gt,k as Et,o as W,q as Qt,u as Po,x as Io}from"./chunk-6PHJZPWD.js";import"./chunk-T4M53QQT.js";import"./chunk-IZWTFLCC.js";import"./chunk-JAZABOBA.js";import"./chunk-WRXMQB7X.js";import"./chunk-CQY6BYUB.js";import"./chunk-VC6IS564.js";import"./chunk-B5ZN3SWQ.js";import{a as Ie,b as T}from"./chunk-CR2ICLSH.js";import{Ga as eo,Hc as lt,Ia as me,N as Xt,Na as to,Qa as Ze,Qc as Ft,Rc as V,Tc as Xe,Xa as oo,Xc as Fo,_a as ao,a as Y,b as k,d as Zt,fb as no,g as rt,h as st,ib as io,j as dt,lb as ro,lc as lo,pc as mo,sb as so}from"./chunk-YPMUHXYT.js";import{b as ln,c as v}from"./chunk-7SZRL6FY.js";var Dt=v(Y(),1);var M=v(k(),1);function ha({automation:e,editPath:t,editVariant:o,onDelete:a}){let n=Le(),i=pe(),r=e.status==="completed",s=e.status==="paused",f=e.status==="blocked",w=!r,D=s||f?"resume":"pause",u=ge({mutationFn:async()=>{let p=`/api/automations/${encodeURIComponent(e.id)}`,R=await ce(re,`${p}/edit`);if(R.status!==e.status)throw new Error("The Automation changed. Reload the page before trying again.");return Me(re,`${p}/lifecycle`,{action:D,revision:R.revision})},onSuccess:async p=>{await i.invalidateQueries({queryKey:["dashboard","automations"]}),n.add({title:p.status==="blocked"?"Automation is still blocked":D==="pause"?"Automation paused":"Automation resumed",description:p.status==="blocked"?"Fix the reported requirement before resuming again.":D==="pause"?"Work already queued or running may finish.":"Future triggers are enabled.",type:p.status==="blocked"?"warning":"success"})}});return(0,M.jsxs)("div",{className:"grid min-w-0 justify-items-stretch gap-3 md:justify-items-end",children:[(0,M.jsxs)("div",{"aria-label":"Automation actions",className:"flex flex-wrap items-center gap-2",role:"group",children:[r?null:(0,M.jsxs)(W,{className:Ie({variant:o}),to:t,children:[(0,M.jsx)(lo,{"aria-hidden":"true",size:14}),"Edit automation"]}),w?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(T,{disabled:u.isPending,onClick:()=>u.mutate(),children:u.isPending?"Updating\u2026":D==="pause"?"Pause":"Resume"}),(0,M.jsxs)(Oo,{children:[(0,M.jsx)($o,{render:(0,M.jsx)(T,{"aria-label":"About pausing",size:"icon"}),children:(0,M.jsx)(so,{"aria-hidden":"true",size:16})}),(0,M.jsx)(Vo,{side:"bottom",align:"end","aria-label":"About pausing",children:(0,M.jsxs)(Bo,{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.",s&&e.statusReason?" Removing the pause keeps the block until you fix it and resume again.":""]})})]})]}):null,(0,M.jsxs)(co,{children:[(0,M.jsx)(uo,{render:(0,M.jsx)(T,{focusableWhenDisabled:!0,"aria-label":"Delete automation",size:"icon",variant:"danger",onClick:p=>a(p.currentTarget),disabled:u.isPending,children:(0,M.jsx)(lt,{"aria-hidden":"true",size:16})})}),(0,M.jsx)(go,{size:"compact",children:"Delete automation"})]})]}),u.error?(0,M.jsx)("div",{className:"max-w-sm",children:(0,M.jsx)(B,{tone:"error",title:"Could not update this automation.",children:u.error instanceof oe?u.error.apiError??"Try again.":u.error.message})}):null]})}var va=v(Y(),1);var de=v(k(),1);function ba(e){let[t,o]=(0,va.useState)(!0),a=pe(),n=Le(),i=ge({mutationFn:()=>Ro(`/api/automations/${encodeURIComponent(e.automation.id)}`),onSuccess:async()=>{await a.invalidateQueries({queryKey:["dashboard","automations"]}),e.onDeleted(),n.add({title:"Automation deleted",description:e.automation.title,type:"success"}),o(!1)}});return(0,de.jsx)(Be,{open:t,onOpenChange:(r,s)=>{i.isPending?s.cancel():o(r)},onOpenChangeComplete:r=>{r||e.onClose()},children:(0,de.jsxs)(_e,{finalFocus:e.returnFocus,children:[(0,de.jsx)(Ue,{children:"Delete automation?"}),(0,de.jsxs)(ze,{children:["Delete"," ",(0,de.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."]}),i.error?(0,de.jsx)(B,{tone:"error",title:"The automation could not be deleted. Try again."}):null,(0,de.jsxs)(qe,{children:[(0,de.jsx)(He,{disabled:i.isPending,children:"Cancel"}),(0,de.jsx)(je,{variant:"danger",disabled:i.isPending,onClick:()=>i.mutate(),children:i.isPending?"Deleting\u2026":"Delete automation"})]})]})})}var ee=v(Y(),1);function Se(e,t){return typeof e.destination=="string"?e.destination==="task_creator"?"Creator \xB7 Direct message":`${t.label} \xB7 ${t.visibility}`:e.destination.channelId===t.channelId&&e.destination.teamId===t.teamId?`${t.label} \xB7 ${t.visibility}`:`Saved destination \xB7 ${e.destination.channelId}`}var xt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function Re(e){return{title:e.title??"",instruction:e.instruction,credentialMode:e.credentialMode,outcomes:e.outcomes,trigger:e.kind==="event"?e.trigger:void 0}}function Ke(e){let t=e.schedule.recurrence;if(e.schedule.kind==="recurring"&&t){let{time:o,weekdays:a,...n}=t;return{kind:"recurring",...n,timezone:e.schedule.timezone,time:`${String(o.hour).padStart(2,"0")}:${String(o.minute).padStart(2,"0")}`,weekdays:a?.flatMap(i=>xt[i]??[])}}if(e.nextRunAtMs){let o=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),a=n=>o.find(i=>i.type===n)?.value??"";return{kind:"one_off",timezone:e.schedule.timezone,timing:{type:"at",date:`${a("year")}-${a("month")}-${a("day")}`,time:`${a("hour")}:${a("minute")}`}}}return{kind:"recurring",frequency:"daily",time:"09:00",timezone:e.schedule.timezone}}function xa(e,t){let o={};return t.title!==(e.title??"")&&(o.title=t.title),t.instruction!==e.instruction&&(o.instruction=t.instruction),t.credentialMode!==e.credentialMode&&(o.credentialMode=t.credentialMode),JSON.stringify(t.outcomes)!==JSON.stringify(e.outcomes)&&(o.outcomes=t.outcomes),e.kind==="scheduled"&&t.schedule&&(o.schedule=t.schedule),e.kind==="event"&&JSON.stringify(t.trigger)!==JSON.stringify(e.trigger)&&(o.trigger=t.trigger),o}var J=v(k(),1),Mt={title:"Title",instruction:"Instruction",schedule:"Schedule",trigger:"Trigger",outcomes:"Where results go",credentialMode:"Credentials"};function ya(e){let t=Object.keys(Mt).filter(n=>e.changes[n]!==void 0),o=mn(e.original),a=(n,i)=>cn(n,i,e.summary);return(0,J.jsx)("aside",{"aria-label":"Your changes",className:V("min-w-0 lg:sticky lg:top-4 lg:self-start",t.length===0&&"max-lg:hidden"),children:(0,J.jsxs)(Q,{padding:"sm",children:[(0,J.jsx)("h2",{className:"m-0 mb-3 font-sans text-xs font-medium text-dashboard-text-muted",children:"Your changes"}),t.length===0?(0,J.jsx)("p",{className:"m-0 text-sm text-dashboard-text-muted",children:"No changes yet. Edit a section to see it here."}):(0,J.jsx)("ul",{className:"m-0 grid list-none gap-3 p-0",children:t.map(n=>(0,J.jsxs)("li",{className:"grid min-w-0 gap-1 text-sm",children:[(0,J.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,J.jsx)("span",{className:"font-medium",children:Mt[n]}),(0,J.jsx)(T,{"aria-label":`Undo ${Mt[n].toLowerCase()} change`,disabled:e.disabled,onClick:()=>e.onUndo(n),children:"Undo"})]}),(0,J.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:[(0,J.jsx)("span",{className:"sr-only",children:"Saved: "}),a(o,n)]}),(0,J.jsxs)("p",{className:"m-0 line-clamp-3 break-words whitespace-pre-wrap text-xs",children:[(0,J.jsx)("span",{className:"sr-only",children:"New: "}),a(e.changes,n)]})]},n))}),(0,J.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 mn(e){let t=Re(e);return e.kind==="scheduled"?{...t,schedule:Ke(e)}:t}function cn(e,t,o){switch(t){case"title":return e.title||"First line of the instruction";case"instruction":return e.instruction||"Empty";case"credentialMode":return e.credentialMode==="creator"?o.ownedByViewer?"Your connected accounts":`${o.createdBy}'s connected accounts`:"System credentials only";case"outcomes":return e.outcomes?.length?e.outcomes.map(a=>Se(a,o.destination)).join(", "):"No success message";case"schedule":return e.schedule?gn(e.schedule):"Not set";case"trigger":{let a=e.trigger;if(!a)return"Not set";let n=a.identifier?`${a.label} \xB7 ${a.identifier}`:`Any ${a.label}`,i=Object.keys(a.match??{}).length;return[n,a.events.join(", "),i?`${i} ${i===1?"filter":"filters"}`:""].filter(Boolean).join(" \xB7 ")}}}var un={daily:"day",weekly:"week",monthly:"month",yearly:"year"};function gn(e){if(e.kind==="one_off")return`Once on ${e.timing.date} at ${e.timing.time} (${e.timezone})`;let t=e.interval??1,o=un[e.frequency],a=t===1?o:`${t} ${o}s`,n=e.frequency==="weekly"&&e.weekdays?.length?` on ${e.weekdays.map(i=>i.slice(0,1).toUpperCase()+i.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")}`:"";return`Every ${a}${n} at ${e.time} (${e.timezone})`}var ve=v(k(),1);function ae(e){return(0,ve.jsxs)("section",{className:V("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:[(0,ve.jsxs)("div",{children:[(0,ve.jsx)("h2",{className:"m-0 font-display text-lg font-medium",children:e.title}),e.changed?(0,ve.jsx)("p",{className:"mt-1 mb-0 text-xs text-dashboard-accent-text",children:"Unsaved changes"}):null,e.detail?(0,ve.jsx)("p",{className:"mt-2 mb-0 text-sm leading-relaxed text-dashboard-text-muted",children:e.detail}):null]}),(0,ve.jsx)("div",{className:"grid min-w-0 content-start gap-5",children:e.children})]})}var yt=v(Y(),1);var g=v(k(),1);function Aa(e){let t=e.value??Ke(e.automation),[o,a]=(0,yt.useState)(e.value);(0,yt.useEffect)(()=>{let u=setTimeout(()=>a(e.value),300);return()=>clearTimeout(u)},[e.value]);let n=Co.safeParse(o),i=Fe({queryKey:["dashboard","automation-schedule-preview",e.automation.id,o],enabled:!!o&&n.success,retry:!1,queryFn:()=>Me(ko,`/api/automations/${encodeURIComponent(e.automation.id)}/preview`,o)}),r=t.kind==="recurring"?t.frequency:"once",s=t.kind==="recurring"?t.time:t.timing.time,f=e.value?i.data?.nextRunAtMs:e.automation.nextRunAtMs,w=e.value!==o||i.isFetching,D=i.error instanceof oe?i.error.apiError:i.error?"Schedule preview could not be loaded. Try again.":e.value&&!n.success&&!w?n.error.issues[0]?.message:void 0;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"grid grid-cols-1 items-start gap-4 sm:grid-cols-2",children:[(0,g.jsxs)(q,{children:[(0,g.jsx)(j,{htmlFor:"schedule-frequency",children:"Repeat"}),(0,g.jsxs)(he,{id:"schedule-frequency",value:r,onChange:u=>{let p=u.target.value;p!=="once"&&p!=="daily"&&p!=="weekly"&&p!=="monthly"&&p!=="yearly"||e.onChange(p==="once"?{kind:"one_off",timezone:t.timezone??e.automation.schedule.timezone,timing:{type:"at",date:"",time:s}}:{kind:"recurring",timezone:t.timezone,time:s,frequency:p,interval:1,weekdays:p==="weekly"?["monday"]:void 0,dayOfMonth:["monthly","yearly"].includes(p)?1:void 0,month:p==="yearly"?1:void 0})},children:[(0,g.jsx)("option",{value:"once",children:"Once"}),(0,g.jsx)("option",{value:"daily",children:"Every day"}),(0,g.jsx)("option",{value:"weekly",children:"Every week"}),(0,g.jsx)("option",{value:"monthly",children:"Every month"}),(0,g.jsx)("option",{value:"yearly",children:"Every year"})]})]}),(0,g.jsxs)(q,{children:[(0,g.jsx)(j,{htmlFor:"schedule-time",children:"Time"}),(0,g.jsx)(Z,{size:"comfortable",id:"schedule-time",type:"time",value:s,onChange:u=>e.onChange(t.kind==="recurring"?{...t,time:u.target.value}:{...t,timing:{type:"at",date:t.timing.date,time:u.target.value}})})]})]}),t.kind==="recurring"?(0,g.jsxs)(g.Fragment,{children:[t.frequency==="weekly"?(0,g.jsxs)("fieldset",{children:[(0,g.jsx)("legend",{className:"mb-2 text-sm font-semibold",children:"On"}),(0,g.jsx)(Lo,{className:"grid grid-cols-7 gap-1.5",multiple:!0,onValueChange:u=>e.onChange({...t,weekdays:u}),value:t.weekdays??[],children:[...xt.slice(1),xt[0]].map(u=>(0,g.jsx)(Mo,{"aria-label":u,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:u,children:u.slice(0,3)},u))})]}):null,(0,g.jsxs)("div",{className:"grid grid-cols-1 items-start gap-4 sm:grid-cols-2",children:[(0,g.jsxs)(q,{children:[(0,g.jsx)(j,{htmlFor:"schedule-interval",children:"Interval"}),(0,g.jsx)(Z,{size:"comfortable",id:"schedule-interval",type:"number",min:1,max:365,value:t.interval??1,onChange:u=>e.onChange({...t,interval:u.target.valueAsNumber})}),(0,g.jsx)(Je,{id:"schedule-interval-help",children:"Number of calendar periods between runs."})]}),(0,g.jsxs)(q,{children:[(0,g.jsx)(j,{htmlFor:"schedule-start",children:"Start date"}),(0,g.jsx)(Z,{size:"comfortable",id:"schedule-start",type:"date",value:t.startDate??"",onChange:u=>e.onChange({...t,startDate:u.target.value||void 0})})]})]}),t.frequency==="monthly"||t.frequency==="yearly"?(0,g.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[(0,g.jsxs)(q,{children:[(0,g.jsx)(j,{htmlFor:"schedule-day",children:"Day of month"}),(0,g.jsx)(Z,{size:"comfortable",id:"schedule-day",type:"number",min:1,max:31,value:t.dayOfMonth??1,onChange:u=>e.onChange({...t,dayOfMonth:u.target.valueAsNumber})})]}),t.frequency==="yearly"?(0,g.jsxs)(q,{children:[(0,g.jsx)(j,{htmlFor:"schedule-month",children:"Month"}),(0,g.jsx)(he,{id:"schedule-month",value:t.month??1,onChange:u=>e.onChange({...t,month:Number(u.target.value)}),children:Array.from({length:12},(u,p)=>(0,g.jsx)("option",{value:p+1,children:new Intl.DateTimeFormat("en",{month:"long",timeZone:"UTC"}).format(new Date(Date.UTC(2026,p,1)))},p))})]}):null]}):null]}):(0,g.jsxs)(q,{children:[(0,g.jsx)(j,{htmlFor:"schedule-date",children:"Date"}),(0,g.jsx)(Z,{size:"comfortable",id:"schedule-date",type:"date",value:t.timing.date,onChange:u=>e.onChange({...t,timing:{type:"at",time:s,date:u.target.value}})})]}),(0,g.jsxs)(q,{children:[(0,g.jsx)(j,{htmlFor:"schedule-timezone",children:"Timezone"}),(0,g.jsx)(Z,{size:"comfortable",id:"schedule-timezone",list:"automation-timezones",value:t.timezone??"",onChange:u=>e.onChange({...t,timezone:u.target.value})}),(0,g.jsx)("datalist",{id:"automation-timezones",children:["UTC",...Intl.supportedValuesOf("timeZone")].map(u=>(0,g.jsx)("option",{children:u},u))}),(0,g.jsx)(Je,{id:"schedule-timezone-help",children:"Use an IANA timezone. The schedule follows local time, including daylight saving time."})]}),(0,g.jsxs)("div",{role:"status",className:"flex gap-3 rounded-md bg-dashboard-fill-soft p-3 text-sm leading-relaxed",children:[(0,g.jsx)(no,{"aria-hidden":!0,size:17,className:"mt-0.5 shrink-0 text-dashboard-text-muted"}),(0,g.jsx)("div",{children:w?"Checking schedule\u2026":D?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("span",{className:"text-rose-300",children:D}),i.error?(0,g.jsx)(T,{onClick:()=>{i.refetch()},children:"Try again"}):null]}):f?(0,g.jsxs)(g.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?i.data?.schedule.timezone??"UTC":e.automation.schedule.timezone}).format(f)]}):"No next run."})]}),e.value?(0,g.jsx)(T,{className:"w-fit",onClick:()=>e.onChange(void 0),children:"Keep saved schedule"}):null]})}var wa=v(Y(),1);var Te=v(k(),1);function Ye(e){return e.filters.length===0?(0,Te.jsx)("p",{className:"m-0 mt-1 text-xs text-dashboard-text-muted",children:"No filters. Runs on every selected event."}):(0,Te.jsxs)("div",{className:"mt-1 text-xs text-dashboard-text-muted",children:[(0,Te.jsx)("p",{className:"m-0",children:"Every filter must match:"}),(0,Te.jsx)("ul",{className:"m-0 list-disc pl-5",children:e.filters.map(t=>(0,Te.jsx)("li",{className:"break-words",children:t},t))})]})}var c=v(k(),1),At="*",fn={resourceTypes:[],events:{},anyResourceFields:{}};function Na(e,t){let o=e.events[t]?.reach;if(typeof o!="object")return;let a=o.anyOf.map(n=>e.anyResourceFields[n]?.description??n);return a.length===1?`needs a filter: ${a[0]}`:`needs one of these filters: ${a.join("; or ")}`}function Ca(e){let[t,o]=(0,wa.useState)(),a=Fe({queryKey:["dashboard","automation-event-catalog"],queryFn:({signal:m})=>ce(wo,"/api/automations/event-catalog",m),retry:!1}),n=a.data?.find(m=>m.namespace===e.value.namespace),i=n??fn,r=n?.displayName??e.value.namespace,s=e.value.resourceType===void 0,f=ho(i,e.value),w=a.data?vo(i,e.value):[],D=!f||w.some(m=>m.reason!=="field_not_set"&&m.reason!=="filter_required"),u=a.data?.filter(m=>fo(m).length>0)??[],p=Object.entries(f?.fields??{}),R=p.filter(([m,b])=>e.value.match?.[m]!==void 0||po(b,e.value.events).length===0),z=(m,b)=>{let C={...e.value.match};b===void 0?delete C[m]:C[m]=b,e.onChange({...e.value,match:C})};return(0,c.jsxs)(c.Fragment,{children:[a.error?(0,c.jsxs)(B,{title:"Event choices could not be loaded.",children:["Saved values are kept."," ",(0,c.jsx)(T,{onClick:()=>{a.refetch()},children:"Try again"})]}):a.isPending?(0,c.jsx)("p",{role:"status",children:"Loading event choices\u2026"}):null,D&&a.data?(0,c.jsxs)(B,{title:"Saved trigger \xB7 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.",(0,c.jsx)(pn,{displayName:r,source:i,trigger:e.value})]}):null,(0,c.jsxs)(q,{children:[(0,c.jsx)(j,{htmlFor:"trigger-resource",children:D?"Replace trigger":"Resource type"}),(0,c.jsxs)(he,{id:"trigger-resource",value:D?"":`${e.value.namespace}:${e.value.resourceType??At}`,onChange:m=>{let[b,C]=m.target.value.split(":");if(C===At&&b){o({namespace:b,label:"",events:[]});return}let E=a.data?.find(x=>x.namespace===b)?.resourceTypes.find(x=>x.type===C);!b||!E||o({namespace:b,resourceType:E.type,identifier:"",label:"",events:[]})},children:[(0,c.jsx)("option",{value:"",disabled:!0,children:"Keep saved trigger"}),u.map(m=>(0,c.jsxs)("option",{value:`${m.namespace}:${At}`,children:[m.displayName," \xB7 any resource"]},`${m.namespace}:${At}`)),a.data?.flatMap(m=>m.resourceTypes.map(b=>(0,c.jsxs)("option",{value:`${m.namespace}:${b.type}`,children:[m.displayName," \xB7 ",b.type.replaceAll("_"," ")]},`${m.namespace}:${b.type}`)))]})]}),(0,c.jsx)(Be,{onOpenChange:m=>{m||o(void 0)},open:t!==void 0,children:(0,c.jsxs)(_e,{children:[(0,c.jsx)(Ue,{children:"Replace the saved trigger?"}),(0,c.jsx)(ze,{children:"Its resource, events, and filters will be cleared."}),(0,c.jsxs)(qe,{children:[(0,c.jsx)(He,{children:"Cancel"}),(0,c.jsx)(je,{onClick:()=>{t&&e.onChange(t),o(void 0)},variant:"primary",children:"Replace trigger"})]})]})}),!D&&f?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(q,{children:[(0,c.jsx)(j,{htmlFor:"trigger-label",children:s?"Trigger name":"Resource name"}),(0,c.jsx)(Z,{size:"comfortable",id:"trigger-label",value:e.value.label,onChange:m=>e.onChange({...e.value,label:m.target.value})})]}),s?(0,c.jsx)("p",{className:"m-0 text-xs leading-relaxed text-dashboard-text-muted",children:"Runs for every resource that the filters match."}):(0,c.jsxs)(q,{children:[(0,c.jsx)(j,{htmlFor:"trigger-identifier",children:"Resource identifier"}),(0,c.jsx)(Z,{size:"comfortable",id:"trigger-identifier",value:e.value.identifier??"",onChange:m=>e.onChange({...e.value,identifier:m.target.value})}),(0,c.jsx)(Je,{id:"trigger-identifier-help",children:"Use the exact provider resource identifier, not its display name."})]}),(0,c.jsxs)("fieldset",{children:[(0,c.jsx)("legend",{className:"mb-2 text-sm font-semibold",children:"Run on these events"}),(0,c.jsx)("div",{className:"divide-y divide-dashboard-border-subtle rounded-md border border-dashboard-border-emphasis",children:f.events.map(m=>(0,c.jsxs)("label",{className:"flex min-h-11 cursor-pointer items-start gap-3 px-3 py-3 text-sm",children:[(0,c.jsx)(Ho,{className:"mt-0.5",checked:e.value.events.includes(m),disabled:e.disabled,onCheckedChange:()=>e.onChange({...e.value,events:e.value.events.includes(m)?e.value.events.filter(b=>b!==m):[...e.value.events,m]})}),(0,c.jsxs)("span",{className:"min-w-0 break-words",children:[bo(m),s&&Na(i,m)?(0,c.jsxs)("span",{className:"text-dashboard-text-muted",children:[" ","\xB7 ",Na(i,m)]}):null]})]},m))})]}),p.length?(0,c.jsxs)("fieldset",{className:"grid gap-4",children:[(0,c.jsx)("legend",{className:"mb-3 text-sm font-semibold",children:"Filters"}),(0,c.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.",R.length<p.length?" Filters that a selected event does not set are hidden.":null]}),R.map(([m,b])=>{let C=e.value.match?.[m],E=w.find(x=>x.field===m);return(0,c.jsxs)(q,{children:[(0,c.jsx)(j,{htmlFor:`match-${m}`,children:m}),Array.isArray(C)?(0,c.jsxs)("div",{className:"text-sm",children:[(0,c.jsx)("span",{className:"break-all",children:xo(m,b,C)})," ",(0,c.jsx)(T,{onClick:()=>z(m,void 0),children:"Remove filter"})]}):b.kind==="boolean"||b.enum?(0,c.jsxs)(he,{id:`match-${m}`,value:C===void 0?"":String(C),onChange:x=>z(m,x.target.value===""?void 0:b.kind==="boolean"?x.target.value==="true":x.target.value),children:[(0,c.jsx)("option",{value:"",children:"Any value"}),(b.enum??["true","false"]).map(x=>(0,c.jsx)("option",{children:x},x))]}):(0,c.jsx)(Z,{size:"comfortable",id:`match-${m}`,type:b.kind==="number"?"number":"text",step:"any",value:C===void 0?"":String(C),onChange:x=>z(m,x.target.value===""?void 0:b.kind==="number"?x.target.valueAsNumber:x.target.value)}),b.description?(0,c.jsx)(Je,{id:`match-${m}-help`,children:b.description}):null,E?(0,c.jsx)(tt,{children:E.message}):null]},m)})]}):null]}):null,JSON.stringify(e.value)!==JSON.stringify(e.original)?(0,c.jsx)(T,{className:"w-fit",onClick:()=>e.onChange(e.original),children:"Keep saved trigger"}):null]})}function pn(e){let t=yo(e.source,e.trigger);return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("ul",{className:"my-2 list-disc pl-5",children:t.problems.map(o=>(0,c.jsx)("li",{children:o},o))}),(0,c.jsxs)("div",{className:"text-xs",children:[(0,c.jsxs)("p",{className:"m-0 break-words",children:[e.displayName," \xB7"," ",e.trigger.resourceType?.replaceAll("_"," ")??"any resource",e.trigger.identifier?` \xB7 ${e.trigger.identifier}`:null]}),(0,c.jsx)("p",{className:"m-0 mt-1 break-words text-dashboard-text-muted",children:t.events.join(", ")}),(0,c.jsx)(Ye,{filters:t.filters})]})]})}var F=v(k(),1);function ka(e){return e.outcomes.length?(0,F.jsx)("ol",{className:"m-0 grid list-decimal gap-2 pl-5 text-sm",children:e.outcomes.map((t,o)=>(0,F.jsx)("li",{children:Se(t,e.destination)},o))}):(0,F.jsx)("p",{className:"m-0 text-sm",children:"No success message"})}function Sa(e){let t=e.original.length?e.original:[{action:"send_message",destination:"current_conversation"}],o=[...e.original.flatMap((a,n)=>typeof a.destination=="string"?[]:[{value:`saved:${n}`,label:Se(a,e.destination),outcome:a}]),{value:"current_conversation",label:`${e.destination.label} \xB7 ${e.destination.visibility}`,outcome:{action:"send_message",destination:"current_conversation"}},{value:"task_creator",label:"Creator \xB7 Direct message",outcome:{action:"send_message",destination:"task_creator"}}];return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(pt,{"aria-label":"Success messages",disabled:e.disabled,className:"flex flex-wrap gap-x-6 gap-y-3",onValueChange:a=>e.onChange(a?t:[]),value:e.value.length>0,children:[!0,!1].map(a=>(0,F.jsxs)("label",{className:"inline-flex min-h-8 cursor-pointer items-center gap-2 text-sm",children:[(0,F.jsx)(ht,{value:a}),a?"Send a message":"No success message"]},String(a)))}),e.value.length?(0,F.jsxs)("div",{className:"grid gap-4 sm:gap-2",children:[e.value.map((a,n)=>{let i=e.original.findIndex(r=>JSON.stringify(r)===JSON.stringify(a));return(0,F.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,F.jsxs)("span",{className:"w-4 text-xs text-dashboard-text-muted",children:[n+1,"."]}),(0,F.jsx)("div",{className:V("min-w-0 flex-1",e.value.length>1&&"order-last basis-full sm:order-none sm:basis-auto"),children:(0,F.jsx)(he,{"aria-label":`Message ${n+1} destination`,value:typeof a.destination=="string"?a.destination:`saved:${i}`,onChange:r=>{let s=o.find(f=>f.value===r.target.value);s&&e.onChange(e.value.map((f,w)=>w===n?s.outcome:f))},children:o.map(r=>(0,F.jsx)("option",{value:r.value,children:r.label},r.value))})}),e.value.length>1?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(T,{size:"icon",className:"ml-auto sm:ml-0","aria-label":`Move message ${n+1} up`,disabled:n===0,onClick:()=>{let r=[...e.value],s=r[n-1];s&&(r[n-1]=a,r[n]=s,e.onChange(r))},children:(0,F.jsx)(ao,{size:16})}),(0,F.jsx)(T,{size:"icon","aria-label":`Remove message ${n+1}`,onClick:()=>e.onChange(e.value.filter((r,s)=>s!==n)),children:(0,F.jsx)(lt,{size:16})})]}):null]},n)}),e.value.length<5?(0,F.jsxs)(T,{className:"w-fit",onClick:()=>e.onChange([...e.value,{action:"send_message",destination:"task_creator"}]),children:[(0,F.jsx)(mo,{size:15}),"Add message"]}):null]}):(0,F.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."}),(0,F.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."]})]})}var d=v(k(),1);function Ta(e){let t=Le(),[o,a]=(0,ee.useState)(e.automation),[n,i]=(0,ee.useState)(()=>Re(e.automation)),[r,s]=(0,ee.useState)({}),[f,w]=(0,ee.useState)(),[D,u]=(0,ee.useState)(0),p=(0,ee.useRef)(null),R=(0,ee.useRef)(!1),z=it(),m=pe(),b=xa(o,n),C=Object.keys(b).length>0,E={kind:o.kind,revision:o.revision,...b},x=Gt(()=>C&&!R.current),I=(0,ee.useRef)(null);(0,ee.useEffect)(()=>{x.state==="blocked"&&I.current?.focus()},[x.state]);let O=`/api/automations/${encodeURIComponent(o.id)}`;(0,ee.useEffect)(()=>{let y=U=>{C&&!R.current&&(U.preventDefault(),U.returnValue="")};return window.addEventListener("beforeunload",y),()=>window.removeEventListener("beforeunload",y)},[C]);let ne=()=>requestAnimationFrame(()=>(p.current?.querySelector('[aria-invalid="true"]')??p.current?.querySelector("[data-save-error]"))?.focus()),L=ge({mutationFn:()=>So(re,O,E),onSuccess:async()=>{R.current=!0,await m.invalidateQueries({queryKey:["dashboard","automations"]}),t.add({title:"Automation saved",description:"Changes apply to future work.",type:"success"}),z(e.returnPath)},onError:y=>{s(y instanceof oe?y.fields??{}:{}),ne()}});function $(y){f&&(i(y?{...Re(f),...b}:Re(f)),a(f),w(void 0),L.reset(),s({}))}let ie=ge({mutationFn:()=>ce(re,`${O}/edit`),onSuccess:w}),K=L.error instanceof oe&&L.error.code==="conflict",_=y=>i(U=>({...U,...y})),Ne=y=>{_({[y]:Re(o)[y]}),u(U=>U+1)},G=y=>Object.entries(r).filter(([U])=>U===y||U.startsWith(`${y}.`)).flatMap(([,U])=>U).join(" ")||void 0,le=o.kind==="scheduled"?"schedule":"trigger",te=o.ownedByViewer,fe=e.summary.createdBy,De=!te&&o.credentialMode==="creator"&&(b.instruction!==void 0||b[le]!==void 0||b.outcomes!==void 0),Ee=G(le),ot=y=>({"aria-invalid":!!G(y)||void 0,"aria-describedby":G(y)?`${y}-error`:void 0});return(0,d.jsxs)("form",{ref:p,noValidate:!0,onSubmit:y=>{if(y.preventDefault(),L.isPending||K||!C)return;let U=No.safeParse(E);if(!U.success){let at={};for(let Kt of U.error.issues)(at[Kt.path.join(".")]??=[]).push(Kt.message);s(at),ne();return}s({}),L.mutate()},children:[x.state==="blocked"?(0,d.jsx)("div",{tabIndex:-1,ref:I,className:"mb-6 outline-none",children:(0,d.jsxs)(B,{title:"Discard unsaved changes?",children:[(0,d.jsx)("p",{children:"Your changes have not been saved."}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(T,{onClick:()=>x.reset(),children:"Keep editing"}),(0,d.jsx)(T,{onClick:()=>x.proceed(),children:"Discard changes"})]})]})}):null,L.error||Object.keys(r).length?(0,d.jsx)("div",{tabIndex:-1,"data-save-error":!0,className:"mb-6 outline-none",children:(0,d.jsxs)(B,{tone:K?"warning":"error",title:K?"This automation changed while you were editing.":"Changes could not be saved.",children:[(0,d.jsxs)("p",{className:"mt-1",children:["Your edits are still here."," ",K?"Review the latest version before saving again.":L.error instanceof oe?L.error.apiError:"Check the fields below, or try again."]}),K?(0,d.jsx)(T,{disabled:ie.isPending,onClick:()=>ie.mutate(),children:ie.isPending?"Loading\u2026":"Review latest version"}):null,ie.error?(0,d.jsx)("p",{role:"alert",children:"The latest version could not be loaded. Try again."}):null]})}):null,f?(0,d.jsx)("div",{className:"mb-6",children:(0,d.jsxs)(B,{title:"Compare your edits with the latest saved version",children:[(0,d.jsx)("p",{children:"Only the fields you changed are shown. Keeping your edits will replace these fields. Other saved fields stay unchanged."}),Object.entries(b).map(([y,U])=>(0,d.jsxs)("section",{className:"my-4",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold capitalize",children:y==="credentialMode"?"Credentials":y}),(0,d.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{children:"Latest saved"}),(0,d.jsx)("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm",children:Ra(y==="schedule"&&f.kind==="scheduled"?Ke(f):f[y])})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{children:"Your edit"}),(0,d.jsx)("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm",children:Ra(U)})]})]})]},y)),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsx)(T,{onClick:()=>$(!0),children:"Keep my changed fields"}),(0,d.jsx)(T,{onClick:()=>$(!1),children:"Use latest saved version"})]})]})}):null,te?null:(0,d.jsxs)("p",{className:"mt-0 mb-6 max-w-2xl text-sm leading-relaxed text-dashboard-text-muted",children:[fe," created this automation. You can edit it because it is in a public channel. Only ",fe," can turn on their connected accounts. Version history keeps every saved change."]}),(0,d.jsxs)("div",{className:"grid min-w-0 gap-6 lg:grid-cols-[minmax(0,1fr)_18rem] lg:gap-10",children:[(0,d.jsxs)("fieldset",{disabled:L.isPending,className:"min-w-0 [&>section:first-of-type]:border-t-0 [&>section:first-of-type]:pt-0",children:[(0,d.jsxs)(ae,{changed:b.title!==void 0||b.instruction!==void 0,title:"What to do",detail:"Give Junior a clear instruction and a name you can find later.",children:[(0,d.jsxs)(q,{children:[(0,d.jsx)(j,{htmlFor:"title",children:"Title"}),(0,d.jsx)(Z,{size:"comfortable",id:"title",value:n.title,placeholder:e.summary.title,onChange:y=>_({title:y.target.value}),...ot("title")}),(0,d.jsx)(tt,{id:"title-error",children:G("title")})]}),(0,d.jsxs)(q,{children:[(0,d.jsx)(j,{htmlFor:"instruction",children:"Instruction"}),(0,d.jsx)(Wo,{id:"instruction",rows:8,value:n.instruction,onChange:y=>_({instruction:y.target.value}),...ot("instruction"),className:"resize-y text-base leading-relaxed sm:text-sm"}),(0,d.jsxs)("p",{className:"m-0 text-right text-xs text-dashboard-text-muted",children:[n.instruction.length.toLocaleString()," / 4,000"]}),(0,d.jsx)(tt,{id:"instruction-error",children:G("instruction")})]})]}),(0,d.jsx)(ae,{changed:b[le]!==void 0,title:"When to run",detail:o.kind==="scheduled"?"Choose a schedule in a specific timezone.":"Run when a matching event occurs.",children:(0,d.jsxs)("div",{id:`${le}-error`,tabIndex:-1,"aria-invalid":!!Ee||void 0,className:"grid min-w-0 gap-5 outline-none",children:[Ee?(0,d.jsx)("p",{role:"alert",className:"m-0 text-sm text-rose-300",children:Ee}):null,o.kind==="scheduled"?(0,d.jsx)(Aa,{automation:o,value:n.schedule,onChange:y=>_({schedule:y})}):(0,d.jsx)(Ca,{value:n.trigger??o.trigger,original:o.trigger,disabled:L.isPending,onChange:y=>_({trigger:y})})]})}),(0,d.jsxs)(ae,{changed:b.outcomes!==void 0,title:"Where results go",detail:"Choose who gets a message after successful work.",children:[G("outcomes")?(0,d.jsx)("p",{role:"alert",className:"m-0 text-sm text-rose-300",children:G("outcomes")}):null,(0,d.jsx)(Sa,{value:n.outcomes,original:o.outcomes,destination:e.summary.destination,disabled:L.isPending,onChange:y=>_({outcomes:y})})]}),(0,d.jsxs)(ae,{changed:b.credentialMode!==void 0,title:"Credentials",detail:"Choose which connected accounts Junior can use.",children:[(0,d.jsx)(pt,{"aria-label":"Credential mode",disabled:L.isPending,className:"divide-y divide-dashboard-border-subtle rounded-md border border-dashboard-border-emphasis",onValueChange:y=>_({credentialMode:y}),value:De?"system":n.credentialMode,children:[["creator",te?"Your connected accounts":`${fe}\u2019s connected accounts`,te?"Uses accounts connected by you, the creator.":`Uses accounts connected by ${fe}. Only ${fe} can turn this on.`],["system","System credentials only",te?"Does not use your connected accounts. Some work may not be possible.":"Does not use anyone\u2019s connected accounts. Some work may not be possible."]].map(([y,U,at])=>(0,d.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:[(0,d.jsx)(ht,{className:"mt-0.5",value:y,disabled:y==="creator"&&!te&&(o.credentialMode!=="creator"||De)}),(0,d.jsxs)("span",{children:[(0,d.jsx)("span",{className:"block text-sm font-medium",children:U}),(0,d.jsx)("span",{className:"mt-1 block text-xs leading-relaxed text-dashboard-text-muted",children:at})]})]},y))}),De?(0,d.jsxs)(B,{title:"Saving switches this automation to system credentials.",children:["Only ",fe," can let a changed instruction,",o.kind==="event"?" trigger,":" schedule,"," or result destination use their connected accounts."]}):null,G("credentialMode")?(0,d.jsx)("p",{role:"alert",children:G("credentialMode")}):null]})]},D),(0,d.jsx)(ya,{changes:b,disabled:L.isPending,onUndo:Ne,original:o,summary:e.summary})]}),(0,d.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."}),(0,d.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:(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,d.jsxs)("div",{className:"min-w-0 flex-1",role:"status",children:[(0,d.jsx)("p",{className:"m-0 text-xs font-medium sm:text-sm",children:L.isPending?"Saving\u2026":C?"Unsaved changes":"Unchanged"}),(0,d.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."})]}),(0,d.jsxs)("div",{className:"flex shrink-0 gap-2",children:[(0,d.jsx)(W,{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"}),(0,d.jsx)(T,{type:"submit",variant:"primary",className:"min-h-11 sm:min-h-9",disabled:!C||L.isPending||K,children:"Save changes"})]})]})})]})}function Ra(e){return e==null?"Not set":typeof e=="string"?e:JSON.stringify(e,null,2)}var Ge=v(k(),1);function Da(){return(0,Ge.jsx)("div",{role:"status","aria-label":"Loading automation editor",children:["What to do","When to run","Where results go","Credentials"].map((e,t)=>(0,Ge.jsxs)(ae,{title:e,children:[(0,Ge.jsx)(et,{className:"h-4 w-24"}),(0,Ge.jsx)(et,{className:t===0?"h-48 w-full":"h-20 w-full"})]},e))})}var P=v(k(),1);function Ea({automation:e}){let t=Oe(!0,e.id),o=t.data?.executions.slice(0,3)??[];return(0,P.jsxs)("section",{"aria-label":"Recent runs",className:"grid min-w-0 gap-2.5",children:[(0,P.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,P.jsx)("h3",{className:"m-0 text-xs font-medium text-dashboard-text-muted",children:"Recent runs"}),e.totalRuns>0||o.length>0?(0,P.jsx)(W,{className:`${Xe} text-xs`,to:se(e.id,"runs"),children:"View all runs"}):null]}),t.isPending?(0,P.jsxs)("div",{"aria-busy":"true",role:"status",className:"grid gap-2",children:[(0,P.jsx)("span",{className:"sr-only",children:"Loading recent runs"}),Array.from({length:3},(a,n)=>(0,P.jsx)(et,{className:"h-14 rounded-md"},n))]}):null,t.error?(0,P.jsxs)(We,{children:["Recent runs could not be loaded."," ",(0,P.jsx)(T,{onClick:()=>{t.refetch()},children:"Try again"})]}):null,t.data&&o.length===0?(0,P.jsx)("p",{className:"m-0 text-sm text-dashboard-text-muted",children:e.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,o.length>0?(0,P.jsx)("ol",{className:"m-0 list-none divide-y divide-dashboard-border-subtle p-0",children:o.map(a=>{let n=[a.durationMs!==void 0?ct(a.durationMs):void 0,a.costUsd!==void 0?Ve({total:a.costUsd}):void 0].filter(Boolean).join(" \xB7 "),i=a.title!==e.title?a.title:void 0,r=(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1",children:[(0,P.jsx)(Ce,{size:"compact",tone:a.status==="completed"?"success":a.status==="failed"?"danger":"warning",children:a.status}),(0,P.jsx)("time",{className:"text-xs text-dashboard-text-muted",dateTime:a.executedAt,title:X(a.executedAt),children:we(a.executedAt)})]}),i||n?(0,P.jsxs)("div",{className:"flex min-w-0 items-baseline justify-between gap-3 text-xs text-dashboard-text-muted",children:[i?(0,P.jsx)("p",{className:"m-0 min-w-0 truncate text-dashboard-text",title:i,children:i}):null,n?(0,P.jsx)("p",{className:"m-0 shrink-0 tabular-nums",children:n}):null]}):null,a.conversationId?null:(0,P.jsx)("p",{className:"m-0 text-xs text-dashboard-text-muted",children:"No Conversation recorded"})]}),s="grid min-w-0 gap-1 rounded-md px-2 py-2.5";return(0,P.jsx)("li",{children:a.conversationId?(0,P.jsx)(W,{"aria-label":`Open ${a.status} run from ${X(a.executedAt)}`,className:`${s} text-inherit no-underline transition-colors hover:bg-dashboard-fill-hover focus-visible:outline-2 focus-visible:outline-dashboard-focus`,to:ut(a.conversationId),children:r}):(0,P.jsx)("div",{className:s,children:r})},a.executionId)})}):null]})}var Ae={};ln(Ae,{Header:()=>Oa,Item:()=>La,Panel:()=>za,Root:()=>Fa,Trigger:()=>Va});var be=v(Y(),1);var Nt=v(Y(),1),Ot=Nt.createContext(void 0);function wt(){let e=Nt.useContext(Ot);if(e===void 0)throw new Error(st(10));return e}var $t=v(k(),1),hn={value:()=>null},Fa=be.forwardRef(function(t,o){let{render:a,className:n,disabled:i=!1,hiddenUntilFound:r,keepMounted:s,loopFocus:f,onValueChange:w,multiple:D=!1,orientation:u="vertical",value:p,defaultValue:R,style:z,...m}=t,b=R??Zt,C=be.useRef([]),[E,x]=Fo({controlled:p,default:b,name:"Accordion",state:"value"}),I=dt(($,ie,K)=>{let _;D?ie?_=[...E,$]:_=E.filter(Ne=>Ne!==$):_=E[0]===$?[]:[$],w?.(_,K),!K.isCanceled&&x(_)}),O=be.useMemo(()=>({value:E,disabled:i,orientation:u}),[E,i,u]),ne=be.useMemo(()=>({disabled:i,handleValueChange:I,hiddenUntilFound:r??!1,keepMounted:s??!1,state:O,value:E}),[i,I,r,s,O,E]),L=me("div",t,{state:O,ref:o,props:m,stateAttributesMapping:hn});return(0,$t.jsx)(Ot.Provider,{value:ne,children:(0,$t.jsx)(Io,{elementsRef:C,children:L})})});var ye=v(Y(),1);var Ct=v(Y(),1),Vt=Ct.createContext(void 0);function Qe(){let e=Ct.useContext(Vt);if(e===void 0)throw new Error(st(9));return e}var Pa="data-index";var xe={...qo,index:e=>({[Pa]:String(e)}),...Xt,value:()=>null};var Bt=v(k(),1),La=ye.forwardRef(function(t,o){let{className:a,disabled:n=!1,onOpenChange:i,render:r,value:s,style:f,...w}=t,{ref:D,index:u}=Po(),{disabled:p,handleValueChange:R,state:z,value:m}=wt(),b=Ft(),C=s??b,E=n||p,x=m.includes(C),I=dt((le,te)=>{i?.(le,te),!te.isCanceled&&R(C,le,te)}),O=_o({open:x,onOpenChange:I,disabled:E}),ne=ye.useMemo(()=>({...O,onOpenChange:I,state:{open:O.open,disabled:O.disabled,transitionStatus:O.transitionStatus}}),[O,I]),L=ye.useMemo(()=>({...z,hidden:!x&&!O.mounted,index:u,disabled:E,open:x}),[O.mounted,E,u,x,z]),$=Ft(),[ie,K]=ye.useState(),_=ie===null?void 0:ie??$,Ne=ye.useMemo(()=>({defaultTriggerId:$,open:x,state:L,setTriggerId:K,triggerId:_}),[$,x,L,K,_]),G=me("div",t,{state:L,ref:[o,D],props:w,stateAttributesMapping:xe});return(0,Bt.jsx)(Uo.Provider,{value:ne,children:(0,Bt.jsx)(Vt.Provider,{value:Ne,children:G})})});var Ma=v(Y(),1);var Oa=Ma.forwardRef(function(t,o){let{render:a,className:n,style:i,...r}=t,{state:s}=Qe();return me("h3",t,{state:s,ref:o,props:r,stateAttributesMapping:xe})});var $a=v(Y(),1);var vn={...xe,...zo},Va=$a.forwardRef(function(t,o){let{disabled:a,className:n,id:i,render:r,nativeButton:s=!0,style:f,...w}=t,{panelId:D,open:u,handleTrigger:p,disabled:R}=gt(),z=a||R,{getButtonProps:m,buttonRef:b}=to({disabled:z,native:s}),{defaultTriggerId:C,state:E,setTriggerId:x}=Qe(),I=i||void 0,O=I??C;return rt(()=>(x($=>I??($===null?void 0:$)),()=>{x($=>$===I?null:$)}),[I,x]),me("button",t,{state:E,ref:[o,b],props:[{"aria-controls":u?D:void 0,"aria-expanded":u,id:O,onClick:p},w,m],stateAttributesMapping:vn})});var _t=v(Y(),1);var Ba="--accordion-panel-height",_a="--accordion-panel-width";var za=_t.forwardRef(function(t,o){let{className:a,hiddenUntilFound:n,keepMounted:i,id:r,render:s,style:f,...w}=t,{hiddenUntilFound:D,keepMounted:u}=wt(),{defaultPanelId:p,mounted:R,onOpenChange:z,open:m,setMounted:b,setOpen:C,setPanelIdState:E,transitionStatus:x}=gt(),I=n??D,O=i??u,ne=r||void 0,L=r??p;rt(()=>(E(y=>ne??(y===null?void 0:y)),()=>{E(y=>y===ne?null:y)}),[ne,E]);let{height:$,props:ie,ref:K,shouldPreventOpenAnimation:_,shouldRender:Ne,transitionStatus:G,width:le}=jo({externalRef:o,hiddenUntilFound:I,id:L,keepMounted:O,mounted:R,onOpenChange:z,open:m,setMounted:b,setOpen:C,transitionStatus:x}),{state:te,triggerId:fe}=Qe(),De={...te,transitionStatus:G},Ee=eo(f,De),ot=me("div",{...t,style:void 0},{state:De,ref:K,props:[ie,{"aria-labelledby":fe,role:"region",style:{[Ba]:$===void 0?"auto":`${$}px`,[_a]:le===void 0?"auto":`${le}px`}},w,Ee?{style:Ee}:void 0,_?{style:{animationName:"none"}}:void 0],stateAttributesMapping:xe});return Ne?ot:null});var ue=v(k(),1);function qa({className:e,...t}){return(0,ue.jsx)(Ae.Root,{"data-slot":"accordion",className:Ze("flex w-full flex-col",e),...t})}function ja({className:e,...t}){return(0,ue.jsx)(Ae.Item,{"data-slot":"accordion-item",className:Ze("not-last:border-b not-last:border-dashboard-border-subtle",e),...t})}function Ha({className:e,children:t,...o}){return(0,ue.jsx)(Ae.Header,{className:"flex",children:(0,ue.jsxs)(Ae.Trigger,{"data-slot":"accordion-trigger",className:Ze("group/accordion-trigger relative flex min-w-0 flex-1 cursor-pointer items-center justify-between gap-3 rounded-sm py-2.5 text-left font-sans text-sm font-medium text-dashboard-text transition-colors hover:text-dashboard-text-solid outline-none focus-visible:outline-2 focus-visible:outline-dashboard-focus aria-disabled:pointer-events-none aria-disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ml-auto **:data-[slot=accordion-trigger-icon]:size-4 **:data-[slot=accordion-trigger-icon]:text-dashboard-text-muted",e),...o,children:[t,(0,ue.jsx)(io,{"data-slot":"accordion-trigger-icon",className:"pointer-events-none shrink-0 group-aria-expanded/accordion-trigger:hidden"}),(0,ue.jsx)(ro,{"data-slot":"accordion-trigger-icon",className:"pointer-events-none hidden shrink-0 group-aria-expanded/accordion-trigger:inline"})]})})}function Wa({className:e,children:t,...o}){return(0,ue.jsx)(Ae.Panel,{"data-slot":"accordion-content",className:"h-(--accordion-panel-height) overflow-hidden text-sm transition-[height] duration-180 ease-out data-ending-style:h-0 data-starting-style:h-0 motion-reduce:transition-none",...o,children:(0,ue.jsx)("div",{className:Ze("pt-0 pb-2.5",e),children:t})})}var S=v(k(),1);function Ja({automation:e}){let t=e.kind==="event"&&e.trigger.problems.length>0;return(0,S.jsx)("span",{"aria-label":"Automation state","aria-live":"polite",role:"status",children:(0,S.jsx)(Ce,{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 Ka({automation:e}){let t=e.lastRunStatus?`Last run ${e.lastRunStatus}`:"Last run";return(0,S.jsxs)("div",{className:"grid gap-1.5",children:[(0,S.jsx)(bn,{automation:e}),(0,S.jsx)("p",{className:"m-0 text-xs text-dashboard-text-muted",children:e.lastRunAt?(0,S.jsxs)(S.Fragment,{children:[t," \xB7"," ",(0,S.jsx)("time",{dateTime:e.lastRunAt,title:X(e.lastRunAt),children:we(e.lastRunAt)})]}):e.lastRunStatus?`${t} \xB7 time not recorded`:e.totalRuns===0?"No runs yet":"Last run time not recorded"})]})}function Ya(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 Ga(e){return Ya(e)!==void 0}function Qa({automation:e,editPath:t}){let o=Ya(e);if(!o)return null;let a=e.status==="paused",n=e.kind==="event"?e.trigger.problems:[],i=o==="fix",r=n.length>0,s=o==="last_run";return(0,S.jsxs)(B,{title:i?"Fix this before resuming":r?"Trigger unavailable":"Check the last run",children:[i?(0,S.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,r?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("ul",{className:"my-1 list-disc pl-5",children:n.map(f=>(0,S.jsx)("li",{className:"break-words",children:f},f))}),(0,S.jsx)("p",{className:"m-0",children:"Edit the trigger, or enable its plugin again."})]}):null,s&&!i&&!r?(0,S.jsx)("p",{className:"m-0",children:e.status==="active"?"Future runs are still on.":a?"Review the last result before resuming.":"Review the last result for details."}):null,r?(0,S.jsx)(W,{className:V(Ie({variant:"primary"}),"mt-3"),to:t,children:"Change trigger"}):e.lastConversationId?(0,S.jsx)(W,{className:V(Ie({variant:"primary"}),"mt-3"),to:ut(e.lastConversationId),children:"Open last run"}):e.totalRuns>0?(0,S.jsx)(W,{className:V(Ie({variant:"primary"}),"mt-3"),to:se(e.id,"runs"),children:"View run history"}):null]})}function bn({automation:e}){let t;if(e.status==="completed")t="No future runs";else if(e.status==="paused")t="No new runs while paused";else if(e.status==="blocked")t="New runs are blocked until this is fixed";else if(e.kind==="event")t=e.trigger.problems.length===0?"Waiting for a matching event":"Waiting for a trigger fix";else if(e.nextRunAt){let o=Intl.DateTimeFormat().resolvedOptions().timeZone,a=X(e.nextRunAt,e.timezone),n=X(e.nextRunAt,o),i=Date.parse(e.nextRunAt)<=Date.now()?"Run was due":"Next run";return(0,S.jsx)(qa,{children:(0,S.jsxs)(ja,{value:"next-run",children:[(0,S.jsx)(Ha,{className:"py-1 text-sm font-normal",children:(0,S.jsxs)("span",{children:[i," ",(0,S.jsx)("time",{dateTime:e.nextRunAt,children:we(e.nextRunAt)})]})}),(0,S.jsx)(Wa,{children:(0,S.jsxs)("dl",{className:"m-0 mt-1 grid gap-1 border-l border-dashboard-border pl-3 text-xs leading-relaxed",children:[(0,S.jsx)("dt",{className:"text-dashboard-text-muted",children:"Schedule time"}),(0,S.jsx)("dd",{className:"m-0",children:(0,S.jsx)("time",{dateTime:e.nextRunAt,children:a})}),n!==a?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("dt",{className:"mt-1 text-dashboard-text-muted",children:"Your time"}),(0,S.jsx)("dd",{className:"m-0",children:(0,S.jsx)("time",{dateTime:e.nextRunAt,children:n})})]}):null]})})]})})}else t="Next run not scheduled";return(0,S.jsx)("p",{className:"m-0 text-sm text-dashboard-text",children:t})}var h=v(k(),1);function Xa(e){let{automation:t}=e;return(0,h.jsxs)("div",{className:"grid min-w-0 gap-6 lg:grid-cols-[minmax(0,1fr)_18rem] lg:gap-10",children:[(0,h.jsxs)("div",{className:"grid min-w-0 content-start gap-6",children:[(0,h.jsx)(Qa,{automation:t,editPath:e.editPath}),(0,h.jsx)(xn,{automation:t}),(0,h.jsx)(Q,{padding:"sm",children:(0,h.jsx)(Ea,{automation:t})}),(0,h.jsx)("div",{className:"lg:hidden",children:(0,h.jsx)(Za,{automation:t})})]}),(0,h.jsxs)("aside",{"aria-label":"Automation status",className:"grid min-w-0 content-start gap-3 max-lg:row-start-1",children:[(0,h.jsx)(Ut,{title:"Status",children:(0,h.jsx)(Ka,{automation:t})}),(0,h.jsx)(yn,{automation:t,range:e.range}),(0,h.jsx)("div",{className:"max-lg:hidden",children:(0,h.jsx)(Za,{automation:t})})]})]})}function xn(e){let{automation:t}=e,o=t.ownedByViewer?"you":t.createdBy;return(0,h.jsxs)("div",{className:"min-w-0 [&>section:first-child]:border-t-0 [&>section:first-child]:pt-0",children:[(0,h.jsx)(ae,{title:"What to do",children:(0,h.jsx)("div",{className:"text-base leading-relaxed [overflow-wrap:anywhere]",children:(0,h.jsx)(ft,{mentions:t.mentions??[],text:t.instruction})})}),(0,h.jsx)(ae,{title:"When to run",children:t.kind==="scheduled"?(0,h.jsx)("p",{className:"m-0 text-sm",children:da(t)}):(0,h.jsxs)("div",{className:"grid gap-1 text-sm",children:[(0,h.jsx)("p",{className:"m-0 break-words",children:t.resource}),(0,h.jsx)("p",{className:"m-0 break-words text-dashboard-text-muted",children:t.trigger.events.join(", ")}),(0,h.jsx)(Ye,{filters:t.trigger.filters})]})}),(0,h.jsx)(ae,{title:"Where results go",children:(0,h.jsx)(ka,{outcomes:t.outcomes,destination:t.destination})}),(0,h.jsx)(ae,{title:"Credentials",children:(0,h.jsx)("p",{className:"m-0 text-sm",children:t.credentialMode==="creator"?`Uses accounts connected by ${o}.`:"System credentials only. Junior does not use anyone\u2019s connected accounts."})})]})}function yn(e){let{automation:t,range:o}=e,a=Oe(!0,t.id),n=a.data?vt({days:a.data.executionDays,hours:a.data.executionHours,sixHours:a.data.executionSixHours,range:o}).reduce((i,r)=>({blocked:i.blocked+r.blocked,failed:i.failed+r.failed}),{blocked:0,failed:0}):void 0;return(0,h.jsx)(Ut,{title:o===1?"Last 24 hours":`Last ${o} days`,children:(0,h.jsxs)("dl",{className:"m-0 grid grid-cols-2 gap-x-4 gap-y-3",children:[(0,h.jsx)(kt,{label:"Runs",value:t.runs[o]}),(0,h.jsx)(kt,{label:"Spend",value:Ve({total:t.costUsd[o]})}),(0,h.jsx)(kt,{label:"Failed",value:n?.failed??"\u2014"}),(0,h.jsx)(kt,{label:"Blocked",value:n?.blocked??"\u2014"})]})})}function Za(e){let{automation:t}=e,o=Pe(),n=mt(!0,t.id).data?.activeVersion;return(0,h.jsxs)(Ut,{title:"About",children:[(0,h.jsxs)("dl",{className:"m-0 grid gap-3 text-sm",children:[(0,h.jsx)(St,{label:"Created by",children:t.createdByEmail?(0,h.jsx)(W,{className:Xe,to:Eo(t.createdByEmail),children:t.ownedByViewer?"You":t.createdBy}):t.ownedByViewer?"You":t.createdBy}),(0,h.jsx)(St,{label:"Created",children:X(t.createdAt)}),(0,h.jsxs)(St,{label:"Destination",children:[t.destination.label," \xB7"," ",t.destination.visibility==="private"?"private":"public"]}),(0,h.jsx)(St,{label:"Version",children:(0,h.jsx)(W,{className:Xe,to:ke(se(t.id,"versions"),o.search),children:n?`Version ${n}`:"Version history"})})]}),t.ownedByViewer?null:(0,h.jsxs)("p",{className:"mt-3 mb-0 text-xs leading-relaxed text-dashboard-text-muted",children:[t.destination.visibility==="private"?null:"You can edit, pause, or delete it because it is in a public channel. ","Only ",t.createdBy," can turn on their connected accounts, or resume or run it while it uses them."]})]})}function Ut(e){return(0,h.jsxs)(Q,{as:"section",padding:"sm",children:[(0,h.jsx)("h2",{className:"m-0 mb-3 font-sans text-xs font-medium text-dashboard-text-muted",children:e.title}),e.children]})}function kt(e){return(0,h.jsxs)("div",{className:"min-w-0",children:[(0,h.jsx)("dt",{className:"text-xs text-dashboard-text-muted",children:e.label}),(0,h.jsx)("dd",{className:"m-0 mt-0.5 font-display text-xl font-light tabular-nums text-dashboard-text",children:e.value})]})}function St(e){return(0,h.jsxs)("div",{className:"grid min-w-0 gap-0.5",children:[(0,h.jsx)("dt",{className:"text-xs text-dashboard-text-muted",children:e.label}),(0,h.jsx)("dd",{className:"m-0 min-w-0 break-words",children:e.children})]})}var Rt=v(Y(),1);var H=v(k(),1),zt=[{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"}],An=Object.fromEntries(zt.map(e=>[e.key,{color:e.color,label:e.label}]));function en(e){let t=e.bucketUnit??"day",o=e.days,a=o.map(r=>r.completed+r.failed+r.blocked),n=Math.max(1,...a),i=a.some(r=>r>0);return(0,H.jsxs)(Q,{className:"min-h-[15rem] p-4 sm:p-5",children:[(0,H.jsxs)("div",{children:[(0,H.jsx)("h2",{className:"m-0 font-display text-xl font-medium text-dashboard-text",children:"Runs over time"}),(0,H.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."})]}),(0,H.jsx)(aa,{ariaLabel:"Automation execution status legend",items:zt}),(0,H.jsxs)("div",{className:"relative mt-3 overflow-hidden",children:[(0,H.jsx)(na,{className:"aspect-auto h-55 w-full",config:An,children:(0,H.jsxs)(Zo,{"aria-label":`Automation executions during the last ${e.range===1?"24 hours":`${e.range} days`}`,data:o,margin:Xo,role:"img",children:[(0,H.jsx)(Go,{strokeDasharray:"3 5",vertical:!1}),(0,H.jsx)(ta,{maximum:n}),(0,H.jsx)(ea,{keys:o.map(r=>r.date)}),(0,H.jsx)(ia,{content:(0,H.jsx)(oa,{rows:r=>[["completed",r.completed],["failed",r.failed],["blocked",r.blocked],["total",r.completed+r.failed+r.blocked]]})}),zt.map(r=>(0,H.jsx)(Qo,{dataKey:r.key,fill:`var(--color-${r.key})`,fillOpacity:.82,isAnimationActive:!1,maxBarSize:13,stackId:"status"},r.key))]})}),i?null:(0,H.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."})]})]})}var A=v(k(),1),jt="result",Nn=["","completed","failed","blocked"],tn="grid-cols-[minmax(0,1fr)_5.5rem_5.5rem_5.5rem_auto_2rem]";function on(e){let{automation:t}=e,o=Oe(!0,t.id),[a,n]=bt(jt,"",Nn),i=(0,Rt.useMemo)(()=>(o.data?.executions??[]).filter(f=>!a||f.status===a),[o.data,a]),r=(0,Rt.useMemo)(()=>(o.data?.executions??[]).map(f=>({...f,automationId:t.id,automationTitle:t.title,kind:t.kind})),[t,o.data]),s=ua(i.map(f=>f.executionId));return(0,A.jsxs)(ga,{details:s.runId?(0,A.jsx)(pa,{loading:!o.data&&!o.error,onClose:s.close,run:r.find(f=>f.executionId===s.runId),showAutomation:!1},s.runId):null,label:"Runs list",listRef:s.listRef,children:[e.header,o.data?(0,A.jsx)(wn,{data:o.data,executions:i,onResultChange:n,onRowsKeyDown:s.onRowsKeyDown,onSelect:s.toggle,range:e.range,result:a,selectedRunId:s.runId}):o.error?(0,A.jsxs)(We,{children:["Runs could not be loaded."," ",(0,A.jsx)(T,{onClick:()=>{o.refetch()},children:"Try again"})]}):(0,A.jsx)($e,{label:"Loading runs",variant:"list"})]})}function wn(e){let{data:t,range:o}=e,a=(0,Rt.useMemo)(()=>kn(t.executions),[t.executions]);return(0,A.jsxs)(A.Fragment,{children:[t.executionDays.length>0?(0,A.jsx)(en,{bucketUnit:Jo(o),days:vt({days:t.executionDays,hours:t.executionHours,sixHours:t.executionSixHours,range:o,emptySixHour:n=>({blocked:0,completed:0,date:n,failed:0})}),range:o}):null,(0,A.jsxs)("div",{className:"flex flex-wrap items-end justify-between gap-x-5 gap-y-3",children:[(0,A.jsx)(ra,{ariaLabel:"Run result",items:[{count:t.executions.length,label:"All",value:""},{count:a.completed,label:"Completed",value:"completed"},{count:a.failed,label:"Failed",value:"failed"},{count:a.blocked,label:"Blocked",value:"blocked"}],onChange:n=>e.onResultChange(n),value:e.result}),(0,A.jsxs)("p",{className:"m-0 text-xs text-dashboard-text-muted",children:[t.automation.totalRuns," total \xB7 newest first"]})]}),e.executions.length===0?(0,A.jsx)(Q,{padding:"md",children:(0,A.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.`})}):(0,A.jsx)(Q,{children:(0,A.jsx)("div",{className:"min-w-0 overflow-x-auto",children:(0,A.jsxs)("div",{className:"min-w-[36rem]",children:[(0,A.jsxs)("div",{"aria-hidden":"true",className:V("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",tn),children:[(0,A.jsx)("div",{children:"Run"}),(0,A.jsx)("div",{children:"Duration"}),(0,A.jsx)("div",{children:"Tokens"}),(0,A.jsx)("div",{children:"Cost"})]}),(0,A.jsx)("div",{className:"min-w-0",onKeyDown:e.onRowsKeyDown,role:"list",children:e.executions.map(n=>(0,A.jsx)(Cn,{execution:n,fallbackTitle:t.automation.title,onSelect:()=>e.onSelect(n.executionId),selected:e.selectedRunId===n.executionId},n.executionId))})]})})}),t.truncated?(0,A.jsx)("p",{className:"m-0 text-center text-xs text-dashboard-text-muted",children:"Showing the 100 most recent runs."}):null]})}function Cn(e){let{execution:t}=e,o=Ve(t.costUsd===void 0?void 0:{total:t.costUsd})||"\u2014",a=ct(t.durationMs)||"\u2014",n=t.totalTokens===void 0?"\u2014":Do(t.totalTokens),i=la(t.status);return(0,A.jsx)("div",{className:"border-b border-dashboard-border-subtle last:border-b-0","data-run-id":t.executionId,role:"listitem",children:(0,A.jsxs)(sa,{className:V("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",tn),onSelect:e.onSelect,selected:e.selected,children:[(0,A.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:[(0,A.jsxs)("span",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[(0,A.jsx)(Lt,{className:"md:hidden",label:t.status,tone:i}),(0,A.jsx)("span",{className:"min-w-0 truncate text-sm font-medium leading-snug text-dashboard-text",children:ma(t,e.fallbackTitle)})]}),(0,A.jsxs)("span",{className:"mt-1 block truncate text-xs leading-relaxed text-dashboard-text-muted",children:[X(t.executedAt),t.automationVersion?` \xB7 Version ${t.automationVersion}`:null]}),t.error?(0,A.jsx)("span",{className:"mt-1 block truncate text-xs leading-relaxed text-rose-300",title:t.error,children:t.error}):null]}),(0,A.jsx)(qt,{label:"Duration",value:a}),(0,A.jsx)(qt,{label:"Tokens",value:n}),(0,A.jsx)(qt,{label:"Cost",value:o}),(0,A.jsx)("div",{className:"hidden justify-self-center md:block",children:(0,A.jsx)(Lt,{label:t.status,tone:i})}),(0,A.jsx)("div",{className:"max-md:hidden",children:(0,A.jsx)(fa,{conversationId:t.conversationId})})]})})}function qt(e){return(0,A.jsxs)("div",{className:"min-w-0 max-md:flex max-md:items-center max-md:gap-2",children:[(0,A.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}),(0,A.jsxs)("div",{className:"truncate whitespace-nowrap font-mono text-xs text-dashboard-text-muted md:text-sm md:text-dashboard-text",children:[(0,A.jsxs)("span",{className:"sr-only",children:[e.label,": "]}),e.value]})]})}function kn(e){return e.reduce((t,o)=>(t[o.status]+=1,t),{blocked:0,completed:0,failed:0})}var Wt=v(Y(),1);var l=v(k(),1),Tt="version";function an(e){let t=mt(!0,e.automation.id);return t.error?(0,l.jsxs)(We,{children:["Version history could not be loaded."," ",(0,l.jsx)(T,{onClick:()=>{t.refetch()},children:"Try again"})]}):t.data?(0,l.jsx)(Sn,{automation:e.automation,data:t.data}):(0,l.jsx)($e,{label:"Loading version history",variant:"list"})}function Sn(e){let{automation:t,data:o}=e,[a,n]=Qt(),i=pe(),[r,s]=(0,Wt.useState)(),[f,w]=(0,Wt.useState)(!1),D=t.status!=="completed",u=Number(a.get(Tt)),p=Math.max(0,o.versions.findIndex(x=>x.version===u)),R=o.versions[p],z=o.versions[p+1],m=x=>n(I=>{let O=new URLSearchParams(I);return O.set(Tt,String(x)),O},{replace:!0}),b=`/api/automations/${encodeURIComponent(t.id)}`,C=ge({mutationFn:async x=>{let I=await ce(re,`${b}/edit`);return Me(re,`${b}/versions/${x}/activate`,{revision:I.revision})},onMutate:()=>s(void 0),onSuccess:async(x,I)=>{s(I),await i.invalidateQueries({queryKey:["dashboard","automations"]})}});if(!R)return(0,l.jsx)(Q,{padding:"md",children:(0,l.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 E=R.version===o.activeVersion;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"m-0 max-w-2xl text-sm leading-relaxed text-dashboard-text-muted",children:D?"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."}),r!==void 0?(0,l.jsxs)("p",{role:"status",className:"m-0 text-sm text-emerald-300",children:["Version ",r," is active again. It was saved as a new version."]}):null,(0,l.jsxs)("div",{className:"grid min-w-0 gap-4 lg:grid-cols-[17rem_minmax(0,1fr)] lg:gap-6",children:[(0,l.jsxs)("nav",{"aria-label":"Versions",className:"min-w-0",children:[(0,l.jsx)("ol",{className:"m-0 grid list-none gap-1 p-0 max-lg:max-h-64 max-lg:overflow-y-auto",children:o.versions.map((x,I)=>(0,l.jsx)("li",{children:(0,l.jsx)(Rn,{active:x.version===o.activeVersion,changes:Fn(x,o.versions[I+1],o.truncated),onSelect:()=>m(x.version),selected:x.version===R.version,version:x})},x.version))}),o.truncated?(0,l.jsx)("p",{className:"m-0 mt-2 px-3 text-xs text-dashboard-text-muted",children:"Showing the 100 most recent versions."}):null]}),(0,l.jsxs)(Q,{as:"section",className:"min-w-0",padding:"none",variant:"default",children:[(0,l.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:[(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,l.jsxs)("h2",{className:"m-0 font-display text-lg font-medium",children:["Version ",R.version]}),E?(0,l.jsx)(Ce,{size:"compact",tone:"success",children:"Active"}):null]}),(0,l.jsxs)("p",{className:"mt-1 mb-0 text-xs text-dashboard-text-muted",children:[nn(R)," \xB7"," ",X(R.createdAt),z?` \xB7 Compared with version ${z.version}`:""]})]}),D&&!E?(0,l.jsx)(T,{"aria-label":`Make version ${R.version} active`,disabled:C.isPending,onClick:()=>w(!0),children:C.isPending&&C.variables===R.version?"Saving\u2026":"Make active"}):null]}),C.error&&C.variables===R.version?(0,l.jsx)("div",{className:"px-4 pt-4 sm:px-5",children:(0,l.jsx)(B,{tone:"error",title:"This version could not be made active.",children:C.error instanceof oe?C.error.code==="conflict"?"The automation changed. Try again.":C.error.apiError??"Try again.":"Try again."})}):null,(0,l.jsx)(Tn,{automation:t,previous:z,version:R})]})]}),(0,l.jsx)(Be,{onOpenChange:w,open:f,children:(0,l.jsxs)(_e,{children:[(0,l.jsxs)(Ue,{children:["Make version ",R.version," active?"]}),(0,l.jsxs)(ze,{children:["Junior saves these settings as a new version. Future runs use them.",t.ownedByViewer?null:` Only ${t.createdBy} can turn on their connected accounts.`]}),(0,l.jsxs)(qe,{children:[(0,l.jsx)(He,{children:"Cancel"}),(0,l.jsx)(je,{onClick:()=>{C.mutate(R.version),w(!1)},variant:"primary",children:"Make active"})]})]})})]})}function Rn(e){let{version:t}=e;return(0,l.jsxs)("button",{"aria-current":e.selected?"true":void 0,className:V("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:[(0,l.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium",children:["Version ",t.version,e.active?(0,l.jsx)(Ce,{size:"compact",tone:"success",children:"Active"}):null]}),(0,l.jsxs)("span",{className:"truncate text-xs text-dashboard-text-muted",children:[nn(t)," \xB7"," ",(0,l.jsx)("time",{dateTime:t.createdAt,children:we(t.createdAt)})]}),e.changes?(0,l.jsx)("span",{className:"truncate text-xs text-dashboard-text-muted",children:e.changes}):null]})}var Jt=[{key:"title",label:"Title"},{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 Tn(e){let{automation:t,previous:o,version:a}=e,n=o?rn(o,a):[];return(0,l.jsx)("dl",{className:"m-0 divide-y divide-dashboard-border-subtle",children:Jt.map(({key:i,label:r})=>{let s=n.includes(i);return(0,l.jsxs)("div",{className:V("grid min-w-0 gap-2 px-4 py-4 sm:grid-cols-[9rem_minmax(0,1fr)] sm:gap-6 sm:px-5",s&&"shadow-[inset_2px_0_0_var(--color-dashboard-accent)]"),children:[(0,l.jsxs)("dt",{className:"text-xs font-medium text-dashboard-text-muted",children:[r,s?(0,l.jsx)("span",{className:"mt-1 block font-normal text-dashboard-accent-text",children:"Changed"}):null]}),(0,l.jsx)("dd",{className:"m-0 min-w-0 text-sm leading-relaxed break-words",children:s&&o&&i==="instruction"?(0,l.jsx)(Dn,{after:a.definition.instruction,before:o.definition.instruction}):s&&o?(0,l.jsxs)("div",{className:"grid gap-2",children:[(0,l.jsxs)("div",{className:"text-dashboard-text-muted line-through decoration-dashboard-text-muted/50",children:[(0,l.jsx)("span",{className:"sr-only",children:"Before: "}),Ht(i,t,o)]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("span",{className:"sr-only",children:"After: "}),Ht(i,t,a)]})]}):Ht(i,t,a)})]},i)})})}function Ht(e,t,o){let{definition:a}=o;switch(e){case"title":return a.title??"First line of the instruction";case"instruction":return(0,l.jsx)(ft,{mentions:t.mentions,text:a.instruction});case"when":if(o.kind==="scheduled"){let{description:n,timezone:i}=o.definition.schedule;return n.includes(i)?n:`${n} (${i})`}return(0,l.jsxs)(l.Fragment,{children:[o.definition.trigger.label,o.definition.trigger.identifier?` \xB7 ${o.definition.trigger.identifier}`:null,(0,l.jsx)("br",{}),o.trigger.events.join(", "),(0,l.jsx)(Ye,{filters:o.trigger.filters})]});case"destination":return a.destination.channelId===t.destination.channelId&&a.destination.teamId===t.destination.teamId?t.destination.label:`Another destination \xB7 ${a.destination.channelId}`;case"outcomes":return a.outcomes.length?(0,l.jsx)("ol",{className:"m-0 grid list-decimal gap-1 pl-5",children:a.outcomes.map((n,i)=>(0,l.jsx)("li",{children:Se(n,t.destination)},i))}):"No message on success";case"credentialMode":return a.credentialMode==="creator"?`Uses accounts connected by ${t.ownedByViewer?"you":t.createdBy}.`:"System credentials only"}}function Dn(e){return(0,l.jsx)("div",{className:"grid overflow-hidden rounded-md border border-dashboard-border-subtle font-mono text-xs leading-relaxed",children:En(e.before,e.after).map((t,o)=>(0,l.jsxs)("div",{className:V("grid grid-cols-[1.5rem_minmax(0,1fr)] whitespace-pre-wrap px-2 py-0.5",t.kind==="added"&&"bg-emerald-500/10 text-emerald-200",t.kind==="removed"&&"bg-rose-500/10 text-rose-200"),children:[(0,l.jsx)("span",{"aria-hidden":"true",className:"select-none opacity-60",children:t.kind==="added"?"+":t.kind==="removed"?"\u2212":""}),(0,l.jsxs)("span",{children:[t.kind==="same"?null:(0,l.jsx)("span",{className:"sr-only",children:t.kind==="added"?"Added: ":"Removed: "}),t.value||" "]})]},o))})}function En(e,t){let o=e.split(`
|
|
2
|
+
`),a=t.split(`
|
|
3
|
+
`),n=Array.from({length:o.length+1},()=>Array.from({length:a.length+1},()=>0));for(let f=o.length-1;f>=0;f--)for(let w=a.length-1;w>=0;w--)n[f][w]=o[f]===a[w]?n[f+1][w+1]+1:Math.max(n[f+1][w],n[f][w+1]);let i=[],r=0,s=0;for(;r<o.length&&s<a.length;)o[r]===a[s]?(i.push({kind:"same",value:o[r]}),r++,s++):n[r+1][s]>=n[r][s+1]?i.push({kind:"removed",value:o[r++]}):i.push({kind:"added",value:a[s++]});for(;r<o.length;)i.push({kind:"removed",value:o[r++]});for(;s<a.length;)i.push({kind:"added",value:a[s++]});return i}function nn(e){return e.editedBy?e.editedBy.fullName??e.editedBy.userName??e.editedBy.slackUserId:"Editor unknown"}function Fn(e,t,o){if(!t)return e.version===1||!o?"First saved version":void 0;let a=rn(t,e);return a.length===0?"No setting changes":`Changed ${Jt.filter(({key:i})=>a.includes(i)).map(({label:i})=>i.toLowerCase()).join(", ")}`}function rn(e,t){let o=e.definition,a=t.definition,n=i=>JSON.stringify(o[i])!==JSON.stringify(a[i]);return Jt.flatMap(({key:i})=>(i==="when"?n("schedule")||n("trigger"):n(i))?[i]:[])}var N=v(k(),1),Pn=["1","7","30","90"],In=[jt,ca,Tt],sn={edit:"Edit",overview:"Overview",runs:"Runs",versions:"Versions"};function ll(e){let{automationId:t}=Yt(),o=Pe(),a=To(e.enabled,t),[n,i]=bt("range","30",Pn),r=Number(n);if(!t)return(0,N.jsx)(Et,{replace:!0,to:"/automations/list"});let s=new URLSearchParams(o.search);for(let p of In)s.delete(p);let f=ke("/automations/list",s),w=a.data,D=["overview","runs","versions"].map(p=>({label:sn[p],to:se(t,p),isActive:R=>p==="overview"?!!(nt("/automations/:automationId",R)||nt("/automations/:automationId/edit",R)):!!nt(`/automations/:automationId/${p}`,R)})),u=e.tab==="runs"&&!!w;return(0,N.jsx)(Yo,{ariaLabel:"Automation navigation",className:u?"grid h-full min-h-0 grid-rows-[auto_minmax(0,1fr)] md:grid-rows-[minmax(0,1fr)]":void 0,items:D,children:w?(0,N.jsx)(Ln,{automation:w,listPath:f,onRangeChange:p=>i(String(p)),range:r,tab:e.tab}):(0,N.jsxs)(It,{children:[(0,N.jsx)(dn,{to:f}),(0,N.jsx)(Pt,{description:"Settings, runs, and versions for one automation.",title:"Automation"}),a.error?(0,N.jsxs)(B,{tone:"error",title:"Automation could not be loaded.",children:[a.error instanceof oe&&a.error.status===404?"This automation was not found or is not visible to you.":"Try again."," ",(0,N.jsx)(T,{onClick:()=>{a.refetch()},children:"Try again"})]}):(0,N.jsx)($e,{label:"Loading automation",variant:"list"})]})})}function Ln(e){let{automation:t,tab:o}=e,a=Pe(),n=it(),[i,r]=(0,Dt.useState)(!1),s=(0,Dt.useRef)(null),f=t.status==="completed";if(o==="edit"&&f)return(0,N.jsx)(Et,{replace:!0,to:ke(se(t.id),a.search)});let w=ke(se(t.id,"edit"),a.search),D=(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(dn,{to:e.listPath}),(0,N.jsx)(Pt,{actions:o==="edit"?void 0:(0,N.jsxs)("div",{className:"flex flex-wrap items-start gap-2 md:justify-end",children:[o==="overview"||o==="runs"?(0,N.jsx)(Ko,{onChange:e.onRangeChange,value:e.range}):null,(0,N.jsx)(ha,{automation:t,editPath:w,editVariant:o==="overview"&&Ga(t)?"default":"primary",onDelete:p=>{s.current=p,r(!0)}})]}),description:(0,N.jsx)(On,{automation:t}),documentTitle:o==="overview"?t.title:`${t.title} \xB7 ${sn[o]}`,title:t.title})]}),u=i?(0,N.jsx)(ba,{automation:t,onClose:()=>r(!1),onDeleted:()=>{s.current=null,n(e.listPath)},returnFocus:()=>s.current?.isConnected?s.current:!1}):null;return o==="runs"?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(on,{automation:t,header:D,range:e.range}),u]}):(0,N.jsxs)(It,{children:[D,o==="overview"?(0,N.jsx)(Xa,{automation:t,editPath:w,range:e.range}):null,o==="edit"?(0,N.jsx)(Mn,{automation:t}):null,o==="versions"?(0,N.jsx)(an,{automation:t}):null,u]})}function Mn(e){let{automation:t}=e,o=Pe(),a=Fe({queryKey:["dashboard","automations","edit",t.id],retry:!1,queryFn:({signal:n})=>ce(re,`/api/automations/${encodeURIComponent(t.id)}/edit`,n)});return a.error&&!a.data?(0,N.jsxs)(B,{tone:"error",title:"Automation could not be loaded.",children:["It may no longer be available, or you may not have access."," ",(0,N.jsx)(T,{onClick:()=>{a.refetch()},children:"Try again"})]}):a.data?(0,N.jsx)(Ta,{automation:a.data,summary:t,returnPath:ke(se(t.id),o.search)},t.id):(0,N.jsx)(Da,{})}function On(e){let{automation:t}=e,a=[t.kind==="scheduled"?t.schedule:Ao(t.resource,t.trigger),t.destination.label,`Created by ${t.ownedByViewer?"you":t.createdBy}`];return(0,N.jsx)("span",{className:"block min-w-0 overflow-hidden",children:(0,N.jsxs)("span",{className:"-ml-4 flex min-w-0 flex-wrap items-center gap-y-1",children:[(0,N.jsxs)("span",{className:"flex items-center",children:[(0,N.jsx)("span",{"aria-hidden":"true",className:"inline-block w-4"}),(0,N.jsx)(Ja,{automation:t})]}),a.map((n,i)=>(0,N.jsxs)("span",{className:"min-w-0 break-words",children:[(0,N.jsx)("span",{"aria-hidden":"true",className:V("inline-block w-4 text-center opacity-45",i===0&&"invisible"),children:"\xB7"}),n]},i))]})})}function dn(e){return(0,N.jsxs)(W,{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:[(0,N.jsx)(oo,{"aria-hidden":"true",size:15,strokeWidth:1.8}),"All automations"]})}export{ll as AutomationPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as q,c as H,d as Q,e as W,f as Y}from"./chunk-RB5FBDEY.js";import{b as V,c as Z,d as $}from"./chunk-FSGVY7HB.js";import{a as B}from"./chunk-SIOW7OOW.js";import{a as j,b as N}from"./chunk-2J3LGF5Q.js";import"./chunk-WLIOZO3W.js";import"./chunk-JVJ5UWIK.js";import{a as L}from"./chunk-XNR4RZEC.js";import"./chunk-G5NWYJTV.js";import"./chunk-5ZA674OU.js";import{b as U,c as E,d as K}from"./chunk-3Y3ICT6K.js";import{b as P}from"./chunk-KDUTK357.js";import"./chunk-2BCS5AQL.js";import"./chunk-H76B43OQ.js";import{i as _}from"./chunk-64GPEGGE.js";import"./chunk-ILH47V7O.js";import{k as D,r as F,z as G}from"./chunk-II4NXLSQ.js";import"./chunk-GMZIELFU.js";import"./chunk-MEHLQZDG.js";import"./chunk-MTBUV2GJ.js";import"./chunk-4TQSTCIN.js";import{Ka as c}from"./chunk-XDUSY26N.js";import{b as M,c as R}from"./chunk-RHMZNAJX.js";import"./chunk-GOTQ4D6W.js";import{C as h,D as v,M as z}from"./chunk-6PHJZPWD.js";import"./chunk-IZWTFLCC.js";import"./chunk-JAZABOBA.js";import"./chunk-WRXMQB7X.js";import"./chunk-CQY6BYUB.js";import"./chunk-VC6IS564.js";import"./chunk-B5ZN3SWQ.js";import"./chunk-CR2ICLSH.js";import{Pc as A,Rc as g,a as ne,b as T,fb as C}from"./chunk-YPMUHXYT.js";import{c as x}from"./chunk-7SZRL6FY.js";var r=x(ne(),1);var e=x(T(),1),k=25,J=["all","scheduled","event"],O=["all","completed","failed","blocked"],se=[],X="grid-cols-[minmax(0,1.4fr)_minmax(0,1.2fr)_5.5rem_5.5rem_5.5rem_2rem]";function Ie(o){let a=_(o.enabled),[n,b]=R("type","all",J),[i,ee]=R("status","all",O),[te,ae,S]=M(),[l,p]=(0,r.useState)(1),m=S.toLowerCase(),f=a.data?.runs??se,d=(0,r.useMemo)(()=>f.filter(t=>n!=="all"&&t.kind!==n||i!=="all"&&t.status!==i?!1:m?[t.kind,t.status,t.automationTitle,t.title,t.conversationId].filter(Boolean).join(" ").toLowerCase().includes(m):!0),[n,f,m,i]),u=E(d.length,k),w=(0,r.useMemo)(()=>U(d,l,k),[l,d]);(0,r.useEffect)(()=>{p(1)},[n,S,i]),(0,r.useEffect)(()=>{l>u&&p(u)},[l,u]);let I=!a.data&&!a.error,s=q(w.map(t=>t.executionId)),oe=s.runId?f.find(t=>t.executionId===s.runId):void 0;return(0,e.jsxs)(H,{details:s.runId?(0,e.jsx)(W,{loading:I,onClose:s.close,run:oe,showAutomation:!0},s.runId):null,label:"Runs list",listRef:s.listRef,children:[(0,e.jsx)(z,{description:"Newest runs across your automations and automations in public destinations.",title:"Runs"}),I?(0,e.jsx)(P,{label:"Loading automation runs",variant:"list"}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(j,{search:{label:"Search runs",onChange:ae,placeholder:"Automation, conversation, or status",value:te},children:[(0,e.jsx)(N,{label:"Type",children:(0,e.jsx)(h,{className:"flex-wrap gap-2",onValueChange:([t])=>{t&&b(t)},value:[n],children:J.map(t=>(0,e.jsx)(v,{value:t,variant:"pill",children:t},t))})}),(0,e.jsx)(N,{label:"Status",children:(0,e.jsx)(h,{className:"flex-wrap gap-2",onValueChange:([t])=>{t&&ee(t)},value:[i],children:O.map(t=>(0,e.jsx)(v,{value:t,variant:"pill",children:t},t))})})]}),(0,e.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:(0,e.jsxs)("p",{className:"m-0 text-sm text-dashboard-text-muted",children:[d.length," ",d.length===1?"run":"runs",(0,e.jsxs)("span",{className:"text-dashboard-text-muted/70",children:[" ","\xB7 newest first"]})]})}),a.error?(0,e.jsx)(c,{padding:"md",children:(0,e.jsx)(L,{children:"Automation runs could not be loaded. Try again."})}):d.length===0?(0,e.jsx)(c,{padding:"md",children:(0,e.jsx)("p",{className:"m-0 text-sm text-dashboard-text-muted",children:ie({kind:n,search:m,status:i})})}):(0,e.jsx)(c,{children:(0,e.jsx)("div",{className:"min-w-0 overflow-x-auto",children:(0,e.jsxs)("div",{className:"min-w-[44rem]",children:[(0,e.jsxs)("div",{"aria-hidden":"true",className:g("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",X),children:[(0,e.jsx)("div",{children:"Run"}),(0,e.jsx)("div",{children:"Automation"}),(0,e.jsx)("div",{children:"Duration"}),(0,e.jsx)("div",{children:"Tokens"}),(0,e.jsx)("div",{children:"Cost"})]}),(0,e.jsx)("div",{className:"min-w-0",onKeyDown:s.onRowsKeyDown,role:"list",children:w.map(t=>(0,e.jsx)(re,{onSelect:()=>s.toggle(t.executionId),run:t,selected:s.runId===t.executionId},`${t.kind}:${t.executionId}`))})]})})}),(0,e.jsx)(K,{onPageChange:p,page:l,pageCount:u,pageSize:k,total:d.length}),a.data?.truncated?(0,e.jsx)("p",{className:"m-0 text-center text-xs text-dashboard-text-muted",children:"Showing the 100 most recent runs."}):null]})]})}function ie(o){return o.search||o.kind!=="all"||o.status!=="all"?"No runs matched these filters.":"No visible automations have run yet."}function re(o){let{run:a}=o,n=G(a.costUsd===void 0?void 0:{total:a.costUsd})||"\u2014",b=D(a.durationMs)||"\u2014",i=a.totalTokens===void 0?"\u2014":F(a.totalTokens);return(0,e.jsx)("div",{className:"border-b border-dashboard-border-subtle last:border-b-0","data-run-id":a.executionId,role:"listitem",children:(0,e.jsxs)(B,{className:g("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",X),onSelect:o.onSelect,selected:o.selected,children:[(0,e.jsxs)("button",{"aria-expanded":o.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:o.onSelect,type:"button",children:[(0,e.jsx)("span",{className:"block truncate text-sm font-medium leading-snug text-dashboard-text",children:$(a,a.automationTitle)}),(0,e.jsx)("span",{className:"mt-1 block truncate text-xs text-dashboard-text-muted",children:V(a.executedAt)})]}),(0,e.jsxs)("div",{className:"min-w-0 overflow-hidden",children:[(0,e.jsx)("div",{className:"truncate text-sm text-dashboard-text",children:a.automationTitle}),(0,e.jsxs)("div",{className:"mt-1 flex min-w-0 items-center gap-1.5 overflow-hidden text-dashboard-text-muted",children:[(0,e.jsx)(de,{kind:a.kind}),(0,e.jsx)(Y,{label:a.status,tone:Z(a.status)}),(0,e.jsx)("span",{className:"truncate text-xs text-dashboard-text-muted",children:a.status})]})]}),(0,e.jsx)(y,{label:"Duration",value:b}),(0,e.jsx)(y,{label:"Tokens",value:i}),(0,e.jsx)(y,{label:"Cost",value:n}),(0,e.jsx)("div",{className:"max-md:hidden",children:(0,e.jsx)(Q,{conversationId:a.conversationId})})]})})}function y(o){return(0,e.jsxs)("div",{className:"min-w-0 max-md:flex max-md:items-center max-md:gap-2",children:[(0,e.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:o.label}),(0,e.jsxs)("div",{className:"truncate whitespace-nowrap font-mono text-xs text-dashboard-text-muted md:text-sm md:text-dashboard-text",children:[(0,e.jsxs)("span",{className:"sr-only",children:[o.label,": "]}),o.value]})]})}function de(o){let a=o.kind==="scheduled"?C:A,n=o.kind==="scheduled"?"Scheduled automation":"Event automation";return(0,e.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:(0,e.jsx)(a,{"aria-hidden":"true",className:"size-3.5",strokeWidth:1.8})})}export{Ie as AutomationRunsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Ie,b as Z}from"./chunk-FSGVY7HB.js";import{a as $e}from"./chunk-SIOW7OOW.js";import{a as Oe}from"./chunk-5ISD3QSC.js";import{a as Fe}from"./chunk-4UGZNVJM.js";import{b as X}from"./chunk-2J3LGF5Q.js";import{a as w}from"./chunk-PG7M7L24.js";import{a as B,c as D,f as E,o as F,p as O,q as $,r as I,s as M,t as z,w as G,x as H}from"./chunk-K4TYMAA3.js";import{a as be,b as ye,c as xe,d as Ae}from"./chunk-ZIJ6SJDN.js";import{g as Te}from"./chunk-JVJ5UWIK.js";import{a as we}from"./chunk-XNR4RZEC.js";import"./chunk-G5NWYJTV.js";import{d as ke}from"./chunk-FVX42XAD.js";import{c as Se,d as Ne}from"./chunk-3Y3ICT6K.js";import{b as ve}from"./chunk-KDUTK357.js";import{a as Re}from"./chunk-2BCS5AQL.js";import{a as Ce}from"./chunk-H76B43OQ.js";import{g as ge}from"./chunk-64GPEGGE.js";import"./chunk-ILH47V7O.js";import{K as fe,O as L,g as P,s as he,z as Y}from"./chunk-II4NXLSQ.js";import"./chunk-GMZIELFU.js";import"./chunk-MEHLQZDG.js";import"./chunk-MTBUV2GJ.js";import"./chunk-4TQSTCIN.js";import{Ka as S,P as Q,s as pe}from"./chunk-XDUSY26N.js";import{a as Be,b as De,c as Ee}from"./chunk-RHMZNAJX.js";import{C as j,D as q,E as Pe,G as V,H as U,K as Le,M as Ue,d as ie,f as ne,o as T,q as oe}from"./chunk-6PHJZPWD.js";import"./chunk-IZWTFLCC.js";import"./chunk-JAZABOBA.js";import"./chunk-WRXMQB7X.js";import"./chunk-CQY6BYUB.js";import"./chunk-VC6IS564.js";import"./chunk-B5ZN3SWQ.js";import{b as k}from"./chunk-CR2ICLSH.js";import{Ab as se,Ac as me,Kc as ce,Oc as ue,Pc as de,Tb as le,Wb as R,a as ae,b as x,fb as re}from"./chunk-YPMUHXYT.js";import{c as f}from"./chunk-7SZRL6FY.js";var je=f(ae(),1);var _=f(ae(),1);var i=f(x(),1),Me="(min-width: 768px)",ze=[{value:"active",label:"Active"},{value:"blocked",label:"Blocked"},{value:"paused",label:"Paused"},{value:"unavailable",label:"Trigger unavailable"},{value:"completed",label:"Completed"}];function nt(e){let t=window.matchMedia(Me);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function ot(){return window.matchMedia(Me).matches}function Ge(e){let{filters:t,data:r,onChange:a}=e,[b,g]=(0,_.useState)(!1),A=(0,_.useSyncExternalStore)(nt,ot,()=>!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:r?.creators.find(m=>m.value===t.creator)?.label??t.creator},{key:"destination",label:"Destination",value:t.destination,valueLabel:r?.destinations.find(m=>m.value===t.destination)?.label??t.destination},{key:"state",label:"State",value:t.state==="all"?"":t.state,valueLabel:ze.find(m=>m.value===t.state)?.label}].filter(m=>m.value),u=(0,i.jsxs)(k,{className:"h-11 shrink-0","aria-expanded":b,"aria-haspopup":"dialog",onClick:A?void 0:()=>g(!0),children:[(0,i.jsx)(me,{"aria-hidden":"true",size:14})," Filters",c.length?` (${c.length})`:""]}),C=(0,i.jsx)(rt,{filters:t,data:r,onChange:a});return(0,i.jsxs)("div",{className:"grid gap-3",children:[(0,i.jsxs)("div",{className:"grid gap-2 lg:grid-cols-[auto_minmax(16rem,1fr)] lg:items-center lg:gap-4",children:[(0,i.jsx)(j,{"aria-label":"Scope",className:"flex-wrap gap-2",onValueChange:([m])=>{m&&a("scope",m)},value:[t.scope],children:[["all","All"],["mine","Mine"],["public","Public"],["attention","Needs attention"]].map(([m,y])=>(0,i.jsxs)(q,{className:"min-h-11 lg:min-h-9",value:m,variant:"pill",children:[y,r&&m!=="attention"?(0,i.jsx)("span",{className:"ml-1.5 opacity-65",children:r.counts[m]}):null]},m))}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(Ce,{className:"flex-1",size:"default",label:"Search automations",placeholder:"Search automations",value:e.searchText,onChange:e.onSearch}),A?(0,i.jsxs)(be,{open:b,onOpenChange:g,children:[(0,i.jsx)(ye,{render:u}),(0,i.jsxs)(xe,{align:"end",className:"w-80",children:[(0,i.jsx)(Ae,{children:"Filters"}),(0,i.jsx)("div",{className:"mt-4",children:C})]})]}):u]})]}),c.length>0?(0,i.jsx)("div",{"aria-label":"Active filters",role:"group",className:"flex min-w-0 flex-wrap gap-2",children:c.map(m=>(0,i.jsxs)(k,{"aria-label":`Remove ${m.key} filter`,className:"min-h-9 max-w-full text-xs",title:`${m.label}: ${m.valueLabel}`,onClick:()=>a(m.key,""),children:[(0,i.jsxs)("span",{className:"truncate",children:[m.label,": ",m.valueLabel]}),(0,i.jsx)(ue,{"aria-hidden":"true",className:"shrink-0",size:12})]},m.key))}):null,!A&&b?(0,i.jsx)(Te,{label:"Filters",size:"content",onClose:()=>g(!1),children:(0,i.jsx)("div",{className:"p-4 pb-[max(1rem,env(safe-area-inset-bottom))]",children:C})}):null]})}function rt({filters:e,data:t,onChange:r}){return(0,i.jsxs)("div",{className:"grid gap-4",children:[(0,i.jsx)(X,{label:"Type",children:(0,i.jsx)(j,{className:"flex-wrap gap-2",onValueChange:([a])=>{a&&r("type",a)},value:[e.type],children:["all","scheduled","event"].map(a=>(0,i.jsx)(q,{className:"min-h-9",value:a,variant:"pill",children:a},a))})}),(0,i.jsx)(W,{label:"Creator",emptyLabel:"All",value:e.creator??"",options:t?.creators??[],onChange:a=>r("creator",a)}),(0,i.jsx)(W,{label:"Destination",emptyLabel:"All",value:e.destination??"",options:t?.destinations??[],onChange:a=>r("destination",a)}),(0,i.jsx)(W,{label:"State",emptyLabel:"All",value:e.state==="all"?"":e.state,options:ze,onChange:a=>r("state",a)})]})}function He(e){return(0,i.jsx)(Oe,{ariaLabel:"Sort automations",onChange:e.onChange,options:[{value:"newest",label:"Recently created"},{value:"oldest",label:"Oldest created"},{value:"title",label:"Title A\u2013Z"}],value:e.value})}function W(e){return(0,i.jsx)(X,{label:e.label,children:(0,i.jsxs)(Fe,{"aria-label":e.ariaLabel??`Filter by ${e.label.toLowerCase()}`,variant:"filter",value:e.value,onChange:t=>e.onChange(t.currentTarget.value),children:[e.emptyLabel?(0,i.jsx)("option",{value:"",children:e.emptyLabel}):null,e.value&&!e.options.some(t=>t.value===e.value)?(0,i.jsx)("option",{value:e.value,children:e.value}):null,e.options.map(t=>(0,i.jsx)("option",{value:t.value,children:t.label},t.value))]})})}var n=f(x(),1);function Ke(e){let{automation:t}=e,r=st(t),a=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ke,{imageUrl:t.createdByAvatarUrl,name:t.createdBy,size:"list"}),(0,n.jsx)("span",{className:"truncate",children:t.createdBy})]});return(0,n.jsx)("article",{className:"min-w-0 rounded-lg border border-dashboard-border-subtle bg-dashboard-fill-faint","data-automation-id":t.id,role:"listitem",children:(0,n.jsx)($e,{className:"flex items-start gap-3 rounded-lg px-4 py-3.5",onSelect:e.onSelect,selected:!1,children:(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)(T,{"aria-label":`Open automation: ${t.title}`,className:"block w-full min-w-0 rounded-md text-left no-underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus",to:e.to,children:[(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)("span",{className:"truncate font-display text-base font-medium text-dashboard-text",title:t.title,children:t.title}),r?(0,n.jsx)(Re,{className:"shrink-0",size:"compact",tone:r==="completed"||r==="paused"?"neutral":"warning",children:r}):null]}),(0,n.jsx)(lt,{automation:t})]}),(0,n.jsxs)("div",{className:"mt-2.5 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-dashboard-text-muted",children:[t.createdByEmail?(0,n.jsx)(T,{className:"inline-flex min-w-0 max-w-full items-center gap-2 rounded-md text-dashboard-text no-underline hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus",title:t.createdBy,to:fe(t.createdByEmail),children:a}):(0,n.jsx)("span",{className:"inline-flex min-w-0 max-w-full items-center gap-2 text-dashboard-text",title:t.createdBy,children:a}),(0,n.jsx)(mt,{automation:t})]})]})})})}function st(e){return e.kind==="scheduled"?e.status==="active"?void 0:e.status:e.status!=="active"?e.status:e.trigger.problems.length===0?void 0:"Trigger unavailable"}function lt({automation:e}){let t=e.kind==="scheduled",r=t?re:de,a=e.kind==="scheduled"?e.schedule:pe(e.resource,e.trigger),b=e.kind==="scheduled"?Ie(e):a;return(0,n.jsxs)("span",{className:"mt-1 flex min-w-0 items-center gap-1.5 text-xs text-dashboard-text-muted",children:[(0,n.jsx)(r,{"aria-label":t?"Scheduled automation":`${e.source} event automation`,className:"shrink-0",role:"img",size:13}),(0,n.jsx)("span",{className:"min-w-0 truncate",title:b,children:a}),(0,n.jsx)("span",{"aria-hidden":"true",className:"shrink-0 opacity-45",children:"\xB7"}),e.destination.visibility==="private"?(0,n.jsx)(R,{"aria-label":"Private destination",className:"shrink-0",role:"img",size:12}):null,(0,n.jsx)("span",{className:"min-w-0 max-w-[45%] truncate",title:e.destination.label,children:e.destination.label})]})}function mt({automation:e}){let t=e.kind==="scheduled"&&e.status==="active"?e.nextRunAt:void 0,r=e.lastRunAt?Z(e.lastRunAt):void 0,a=e.lastRunStatus==="failed"||e.lastRunStatus==="blocked";return(0,n.jsxs)(n.Fragment,{children:[t?(0,n.jsxs)(_e,{title:Z(t),children:["Next run ",P(t)]}):null,(0,n.jsx)(_e,{title:r,children:a?(0,n.jsxs)(T,{className:"text-amber-300 underline",to:L(e.id,"runs"),children:["Last run ",e.lastRunStatus,e.lastRunAt?` ${P(e.lastRunAt)}`:null]}):e.lastRunAt?`Last run ${P(e.lastRunAt)}`:"Never run"})]})}function _e(e){return(0,n.jsxs)("span",{className:"whitespace-nowrap",title:e.title,children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"mr-2 opacity-45",children:"\xB7"}),e.children]})}var d=f(x(),1),ct={costUsd:{color:"var(--color-cyan-300)",label:"Spend"}};function J(e){return Y({total:e})}function Qe(e){let t=e.bucketUnit??"day",r=e.days,a=r.map(u=>u.costUsd),b=a.reduce((u,C)=>u+C,0),g=Math.max(.01,...a),A=I(a),c=a.some(u=>u>0);return(0,d.jsxs)(S,{className:"min-h-[17rem] p-4 sm:p-5",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h2",{className:"m-0 font-display text-xl font-medium text-dashboard-text",children:Y({total:b})||"$0.00"}),(0,d.jsx)("p",{className:"mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted",children:"Spend from conversations linked to completed automation executions."})]}),(0,d.jsxs)("div",{className:"relative mt-5 overflow-hidden",children:[(0,d.jsx)(G,{className:"aspect-auto h-50 w-full",config:ct,children:(0,d.jsxs)(E,{"aria-label":`Automation execution spend during the last ${e.range===1?"24 hours":`${e.range} days`}`,data:r,margin:F,role:"img",children:[(0,d.jsx)(B,{strokeDasharray:"3 5",vertical:!1}),(0,d.jsx)($,{format:J,maximum:g}),(0,d.jsx)(O,{keys:r.map(u=>u.date)}),(0,d.jsx)(H,{content:(0,d.jsx)(z,{rows:u=>[["spend",J(u.costUsd)]]})}),(0,d.jsx)(D,{dataKey:"costUsd",fill:"var(--color-costUsd)",fillOpacity:.82,isAnimationActive:!1,maxBarSize:13,radius:1}),(0,d.jsx)(M,{unit:U(t),average:A,format:J,stroke:"var(--color-slate-200)"})]})}),c?null:(0,d.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 linked spend in this period."})]})]})}var p=f(x(),1),ut={total:{color:"var(--color-amber-400)",label:"Executions"}};function Ye(e){let t=e.bucketUnit??"day",r=e.days.map(c=>({date:c.date,total:c.scheduled+c.event})),a=r.map(c=>c.total),b=Math.max(1,...a),g=I(a),A=a.some(c=>c>0);return(0,p.jsxs)(S,{className:"min-h-[17rem] p-4 sm:p-5",children:[(0,p.jsxs)("div",{children:[(0,p.jsxs)("h2",{className:"m-0 font-display text-xl font-medium text-dashboard-text",children:[a.reduce((c,u)=>c+u,0).toLocaleString()," runs"]}),(0,p.jsx)("p",{className:"mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted",children:"Completed automation executions over time."})]}),(0,p.jsxs)("div",{className:"relative mt-5 overflow-hidden",children:[(0,p.jsx)(G,{className:"aspect-auto h-50 w-full",config:ut,children:(0,p.jsxs)(E,{"aria-label":`Automation executions during the last ${e.range===1?"24 hours":`${e.range} days`}`,data:r,margin:F,role:"img",children:[(0,p.jsx)(B,{strokeDasharray:"3 5",vertical:!1}),(0,p.jsx)($,{maximum:b}),(0,p.jsx)(O,{keys:r.map(c=>c.date)}),(0,p.jsx)(H,{content:(0,p.jsx)(z,{rows:c=>[["executions",c.total]]})}),(0,p.jsx)(D,{dataKey:"total",fill:"var(--color-total)",fillOpacity:.82,isAnimationActive:!1,maxBarSize:13,radius:1}),(0,p.jsx)(M,{unit:U(t),average:g,format:he,stroke:"var(--color-slate-200)"})]})}),A?null:(0,p.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."})]})]})}var o=f(x(),1),dt=["1","7","30","90"];function pt(e){let t=Number(e);return t===1||t===7||t===30||t===90?t:30}var gt=[];function pa(e){let t=ne(),r=ie(),[a,b]=Ee("range","30",dt),g=pt(a),A=l=>b(String(l)),[c,u]=oe(),[C,m]=De("q",{resetPage:!0}),y=Q.parse(Object.fromEntries(Object.entries(Q.shape).flatMap(([l,v])=>{let h=v.safeParse(c.get(l)??void 0);return h.success&&h.data!==void 0?[[l,h.data]]:[]}))),qe=new URLSearchParams(Object.entries(y).map(([l,v])=>[l,String(v)])),s=ge(e.enabled,e.view==="list"?qe.toString():""),ee=(l,v)=>{let h=new URLSearchParams(window.location.search);h.delete("page"),v?h.set(l,v):h.delete(l),u(h,{replace:!0})},Ve=l=>u(v=>{let h=new URLSearchParams(v);return l===1?h.delete("page"):h.set("page",String(l)),h}),te=l=>Be(L(l),r.search),Xe=s.data?.automations??gt,Ze=s.data?.counts.mine??0,We=s.data?.counts.public??0,Je=s.data?.counts.private??0,N=s.data?.total??0,et=Se(N,y.pageSize),tt=s.data?.page??y.page;Pe(e.view==="list"?"All automations":void 0),(0,je.useEffect)(()=>{e.view!=="list"||!s.data||s.isPlaceholderData||s.isFetching||s.data.page===y.page||u(l=>{let v=new URLSearchParams(l);return v.set("page",String(s.data.page)),v},{replace:!0})},[y.page,e.view,s.data,s.isFetching,s.isPlaceholderData,u]);let at=!s.data&&!s.error,K=s.data?.executionDays?.length?Le({days:s.data.executionDays,hours:s.data.executionHours,sixHours:s.data.executionSixHours,range:g,emptySixHour:l=>({costUsd:0,date:l,event:0,scheduled:0})}):[],it=K.length>0;return(0,o.jsxs)(o.Fragment,{children:[e.view==="overview"?(0,o.jsx)(Ue,{description:"Scheduled and event-driven work created by users.",onRangeChange:A,range:g,title:"Automations"}):(0,o.jsx)("h2",{className:"m-0 font-display text-2xl font-light tracking-tight text-dashboard-text sm:text-3xl",children:"All automations"}),e.view==="list"?(0,o.jsx)(Ge,{filters:y,data:s.data,onChange:ee,searchText:C,onSearch:m}):null,at?(0,o.jsx)(ve,{label:"Loading automations",variant:e.view==="overview"?"stats":"list"}):null,s.error?(0,o.jsxs)(we,{children:["Automations could not be loaded."," ",(0,o.jsx)(k,{onClick:()=>{s.refetch()},children:"Try again"})]}):null,s.data&&e.view==="overview"?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[(0,o.jsx)(w,{detail:"All automations you can access",icon:le,label:"Total automations",value:s.data?.counts.all??0}),(0,o.jsx)(w,{detail:"Created by you",icon:ce,label:"Your automations",value:Ze}),(0,o.jsx)(w,{detail:"In shared destinations",icon:se,label:"Public automations",value:We}),(0,o.jsx)(w,{detail:"Visible only to you",icon:R,label:"Private automations",value:Je})]}),it?(0,o.jsxs)("section",{className:"grid gap-4 xl:grid-cols-2",children:[(0,o.jsx)(Ye,{bucketUnit:V(g),days:K,range:g}),(0,o.jsx)(Qe,{bucketUnit:V(g),days:K,range:g})]}):null]}):null,s.data&&e.view==="list"?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-x-5 gap-y-2",children:[(0,o.jsxs)("p",{className:"m-0 text-xs text-dashboard-text-muted",children:[N," ",N===1?"automation":"automations",s.isFetching?(0,o.jsx)("span",{className:"ml-3",role:"status",children:"Updating results\u2026"}):null]}),(0,o.jsx)(He,{value:y.sort,onChange:l=>ee("sort",l)})]}),!s.error&&N===0?(0,o.jsx)(S,{padding:"md",children:(0,o.jsx)("p",{className:"m-0 text-sm text-dashboard-text-muted",children:"No automations matched these filters."})}):(0,o.jsx)("div",{className:"grid grid-cols-[minmax(0,1fr)] gap-2",role:"list",children:Xe.map(l=>{let v=`${l.kind}:${l.id}`;return(0,o.jsx)(Ke,{onSelect:()=>t(te(l.id)),automation:l,to:te(l.id)},v)})}),(0,o.jsx)(Ne,{onPageChange:Ve,page:tt,pageCount:et,pageSize:y.pageSize,total:N})]}):null]})}export{pa as AutomationsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as N,b as w,c as H}from"./chunk-QQUFROWT.js";import{a as T,b as R}from"./chunk-ONDKE72P.js";import"./chunk-PG7M7L24.js";import"./chunk-SUX4QBVF.js";import"./chunk-K4TYMAA3.js";import{b as u}from"./chunk-5LNGNJ3P.js";import{a as C}from"./chunk-DEEO4D4N.js";import"./chunk-KDUTK357.js";import"./chunk-2BCS5AQL.js";import{a as p,b as g,c as y,e as m,f as o,g as s}from"./chunk-QOX5RMLM.js";import{e as l}from"./chunk-564V7YHG.js";import{d as b}from"./chunk-64GPEGGE.js";import"./chunk-ILH47V7O.js";import"./chunk-II4NXLSQ.js";import"./chunk-GMZIELFU.js";import"./chunk-4TQSTCIN.js";import{Ka as d}from"./chunk-XDUSY26N.js";import{a as f}from"./chunk-GOTQ4D6W.js";import{G as x,K as h,M as v,o as c}from"./chunk-6PHJZPWD.js";import"./chunk-WRXMQB7X.js";import"./chunk-CQY6BYUB.js";import"./chunk-B5ZN3SWQ.js";import{a as L,b as n}from"./chunk-YPMUHXYT.js";import{c as i}from"./chunk-7SZRL6FY.js";var k=i(L(),1);var e=i(n(),1);function G(){let[r,t]=(0,k.useState)(30),a=b();return!a.data&&!a.error?(0,e.jsx)(C,{description:"Repositories and code changes created by Junior.",label:"Loading code activity",title:"Code",variant:"stats"}):(0,e.jsxs)(f,{children:[(0,e.jsx)(v,{description:"Repositories and code changes created by Junior.",onRangeChange:t,range:r,title:"Code"}),a.error?(0,e.jsx)(l,{children:"Code activity is unavailable. Try refreshing the dashboard."}):null,a.data?(0,e.jsx)(P,{data:a.data,range:r}):null]})}function P(r){let t=r.data;return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(H,{summary:t.summary}),(0,e.jsx)(T,{bucketUnit:x(r.range),days:h({days:t.activityDays,hours:t.activityHours,sixHours:t.activitySixHours,range:r.range,emptySixHour:a=>({closed:0,created:0,date:a,merged:0})}),range:r.range}),(0,e.jsxs)(d,{as:"section",children:[(0,e.jsx)("div",{className:"border-b border-dashboard-border-subtle px-4 py-3 font-display text-lg text-dashboard-text",children:"Repositories"}),t.repositories.length===0?(0,e.jsx)("div",{className:"p-4",children:(0,e.jsx)(l,{children:"No code activity has been recorded yet."})}):(0,e.jsxs)(p,{className:"min-w-[36rem] table-fixed",children:[(0,e.jsxs)("colgroup",{children:[(0,e.jsx)("col",{}),(0,e.jsx)("col",{className:"w-28"}),(0,e.jsx)("col",{className:"w-28"}),(0,e.jsx)("col",{className:"w-28"})]}),(0,e.jsx)(g,{children:(0,e.jsxs)(m,{children:[(0,e.jsx)(o,{className:"px-4",children:"Repository"}),(0,e.jsx)(o,{className:"px-4 text-right",children:"Created"}),(0,e.jsx)(o,{className:"px-4 text-right",children:"Merge rate"}),(0,e.jsx)(o,{className:"px-4 text-right",children:"Median cost"})]})}),(0,e.jsx)(y,{children:t.repositories.map(a=>(0,e.jsxs)(m,{children:[(0,e.jsxs)(s,{className:"min-w-0 px-4 py-3",children:[(0,e.jsx)("div",{className:"truncate font-display text-sm text-dashboard-text",children:(0,e.jsx)(c,{className:"text-inherit no-underline hover:text-dashboard-accent-text",to:u(a.id),children:a.name})}),(0,e.jsx)("div",{className:"mt-1 truncate font-mono text-xs text-dashboard-text-muted",children:a.provider})]}),(0,e.jsx)(s,{className:"px-4 py-3 text-right font-sans tabular-nums",children:a.created}),(0,e.jsx)(s,{className:"px-4 py-3 text-right font-sans tabular-nums",children:N(a.mergeRate)}),(0,e.jsx)(s,{className:"px-4 py-3 text-right font-sans tabular-nums",children:w(a.medianCostUsd)})]},a.id))})]})]}),t.changes.length>0?(0,e.jsxs)(d,{as:"section",children:[(0,e.jsx)("div",{className:"border-b border-dashboard-border-subtle px-4 py-3 font-display text-lg text-dashboard-text",children:"Recent changes"}),(0,e.jsx)("div",{children:t.changes.map(a=>(0,e.jsx)(R,{change:a},a.id))})]}):null]})}export{G as CodePage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as F}from"./chunk-XNR4RZEC.js";import{a as Q}from"./chunk-DZB4LPI6.js";import"./chunk-L2H3ZWZN.js";import"./chunk-MTBUV2GJ.js";import{d as v,g as h,i as c,r as S,u as k,v as w}from"./chunk-4TQSTCIN.js";import{Ka as E,qa as x,ra as N,sa as P}from"./chunk-XDUSY26N.js";import"./chunk-QPBLZSNX.js";import"./chunk-RHMZNAJX.js";import"./chunk-GOTQ4D6W.js";import{s as D}from"./chunk-6PHJZPWD.js";import{b as l}from"./chunk-CR2ICLSH.js";import{b as f,oc as C}from"./chunk-YPMUHXYT.js";import{c as g}from"./chunk-7SZRL6FY.js";var n=g(f(),1),I=["dashboard","connections"];function L(d){return`/api/connections/${encodeURIComponent(d)}`}function W(){let d=v(),s=h({queryKey:I,queryFn:({signal:e})=>w(x,"/api/connections",e),refetchOnWindowFocus:!0,retry:!1}),o=c({mutationFn:e=>S(N,L(e.provider),{}),onSuccess:({authorizationUrl:e},{popup:t})=>{if(!t){window.location.assign(e);return}t.closed||(t.opener=null,t.location.href=e)},onError:(e,{popup:t})=>{t?.close()}}),r=c({mutationFn:e=>k(P,L(e.provider)),onSuccess:(e,t)=>{d.setQueryData(I,b=>b&&{connections:b.connections.map(a=>a.provider===t.provider?{provider:a.provider,displayName:a.displayName,description:a.description,connected:!1}:a)})}}),p=s.data?.connections??[],u=o.isPending||r.isPending,i=o.isPending?o.variables?.provider:r.isPending?r.variables?.provider:void 0,m=!s.data&&s.isError,y=o.isError?"Could not start the connection. Try again.":r.isError?"Could not disconnect the account. Try again.":m?"Could not load identities. Try again.":void 0;return(0,n.jsxs)(Q,{description:(0,n.jsxs)(n.Fragment,{children:["Connect an account so ",D()," can act as you in conversations you start here."]}),title:"Identities",children:[y?(0,n.jsx)(F,{children:y}):null,m?null:(0,n.jsx)(E,{className:"mb-0",variant:"raised",children:s.isPending?(0,n.jsx)("p",{className:"m-0 p-5 text-sm text-dashboard-text-muted",children:"Loading identities\u2026"}):p.length===0?(0,n.jsx)("p",{className:"m-0 p-5 text-sm text-dashboard-text-muted",children:"No installed plugins support account connections."}):(0,n.jsx)("ul",{className:"m-0 list-none divide-y divide-dashboard-border-subtle p-0",children:p.map(e=>(0,n.jsxs)("li",{className:"flex items-center gap-3 px-5 py-4",children:[(0,n.jsx)(C,{className:"shrink-0 text-dashboard-accent",size:16}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("p",{className:"m-0 truncate text-sm font-semibold",children:e.displayName}),(0,n.jsx)("p",{className:"mt-1 mb-0 line-clamp-2 break-words text-xs text-dashboard-text-muted",children:e.connected?e.account?(0,n.jsxs)(n.Fragment,{children:["Connected as"," ",e.account.url?(0,n.jsx)("a",{className:"text-dashboard-text",href:e.account.url,rel:"noreferrer",target:"_blank",children:e.account.label}):e.account.label]}):"Connected":e.description})]}),e.connected?(0,n.jsx)(l,{"aria-busy":i===e.provider,"aria-label":`Disconnect ${e.displayName}`,disabled:u,onClick:()=>{o.reset(),r.mutate(e)},variant:"danger",children:i===e.provider?"Disconnecting\u2026":"Disconnect"}):(0,n.jsx)(l,{"aria-busy":i===e.provider,"aria-label":`Connect ${e.displayName}`,disabled:u,onClick:()=>{r.reset();let t=window.open("about:blank","_blank");o.mutate({provider:e.provider,popup:t})},children:i===e.provider?"Connecting\u2026":"Connect"})]},e.provider))})})]})}export{W as ConnectionsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as we,b as dt,c as st,d as Ne,e as Ot}from"./chunk-FE522UEA.js";import{d as ge,e as Ir,f as _r,g as Hr,i as Br,j as Fr,k as Lr,l as Kr,m as Yr,n as Wr,p as Xr,s as zr}from"./chunk-G5NWYJTV.js";import{a as Er}from"./chunk-IZWTFLCC.js";import"./chunk-JAZABOBA.js";import{B as Cr,G as Tr,K as Ar,g as Ee,n as Gt,o as qt}from"./chunk-WRXMQB7X.js";import"./chunk-CQY6BYUB.js";import"./chunk-VC6IS564.js";import{a as fn,d as At,f as Sr,i as yr}from"./chunk-B5ZN3SWQ.js";import{b as Nr}from"./chunk-CR2ICLSH.js";import{A as Pr,D as Te,F as xr,G as Ze,H as be,Ha as Rr,I as Qe,Ia as Ae,J as lt,M as jt,O as et,Oa as Oe,Oc as Or,Pa as ke,Qa as Jt,Qc as Vr,Rc as Zt,S as Nt,Xc as kr,Y as vr,a as pe,b as Ge,c as Pt,ca as br,cd as Mr,e as wr,f as gr,g as Z,h as hr,j as k,l as Ye,o as ut,p as St,y as Dr}from"./chunk-YPMUHXYT.js";import{b as dn,c as X}from"./chunk-7SZRL6FY.js";var an=X(pe(),1);var gt=X(pe(),1);var ze={};dn(ze,{Backdrop:()=>Gr,Close:()=>qr,Content:()=>Zr,Description:()=>Qr,Handle:()=>Rt,Indent:()=>eo,IndentBackground:()=>ro,Popup:()=>lo,Portal:()=>fo,Provider:()=>wo,Root:()=>Po,SwipeArea:()=>Co,Title:()=>To,Trigger:()=>Ao,Viewport:()=>Yo,VirtualKeyboardProvider:()=>Qo,createHandle:()=>tn});var jr=X(pe(),1);var Ur="--nested-drawers",Re="--drawer-height",$r="--drawer-frontmost-height",tt="--drawer-swipe-movement-x",Me="--drawer-swipe-movement-y",Qt="--drawer-snap-point-offset",xt="--drawer-swipe-strength";var ne="--drawer-swipe-progress";var Gr=jr.forwardRef(function(t,r){let{render:a,className:i,style:R,forceRender:S=!1,...z}=t,c=ge(),s=c.useState("open"),y=c.useState("nested"),p=c.useState("mounted"),x=c.useState("transitionStatus");return Ae("div",t,{state:{open:s,transitionStatus:x},ref:[c.context.backdropRef,r],stateAttributesMapping:Nt,props:[{role:"presentation",hidden:!p,style:{pointerEvents:s?void 0:"none",userSelect:"none",WebkitUserSelect:"none",[ne]:"0",[xt]:"1"}},z],enabled:S||!y})});var qr=Ir;var Jr=X(pe(),1);var Vt="data-drawer-content";var Zr=Jr.forwardRef(function(t,r){let{render:a,className:i,style:R,...S}=t;return ge(),Ae("div",t,{ref:r,props:[{[Vt]:""},S]})});var Qr=_r;var Mt=X(pe(),1);var kt=X(pe(),1),er=kt.createContext(void 0);function We(){return kt.useContext(er)}var mn={active(e){return e?{"data-active":""}:{"data-inactive":""}}},eo=Mt.forwardRef(function(t,r){let{render:a,className:i,style:R,...S}=t,z=We(),c=z?.active??!1,s=z?.visualStateStore,y=Mt.useRef(null);return Z(()=>{let x=y.current;if(!x||!s)return;let D=()=>{let{swipeProgress:B,frontmostHeight:N}=s.getSnapshot();B<=0?x.style.setProperty(ne,"0"):x.style.setProperty(ne,`${B}`),N<=0?x.style.removeProperty(Re):x.style.setProperty(Re,`${N}px`)};D();let v=s.subscribe(D);return()=>{v(),x.style.setProperty(ne,"0"),x.style.removeProperty(Re)}},[s]),Ae("div",t,{ref:[r,y],state:{active:c},props:[{style:{[ne]:"0"}},S],stateAttributesMapping:mn})});var to=X(pe(),1);var wn={active(e){return e?{"data-active":""}:{"data-inactive":""}}},ro=to.forwardRef(function(t,r){let{render:a,className:i,style:R,...S}=t,s={active:We()?.active??!1};return Ae("div",t,{ref:r,state:s,props:S,stateAttributesMapping:wn})});var at=X(pe(),1);var Ts=et.open,As=et.closed,Ns=et.startingStyle,Os=et.endingStyle,oo="data-expanded",no="data-nested-drawer-open",so="data-nested-drawer-swiping",tr="data-swipe-dismiss",ao="data-swipe-direction",qe="data-swiping";var _t=X(pe(),1),rr=_t.createContext(void 0);function Xe(e){let t=_t.useContext(rr);if(e!==!0&&t===void 0)throw new Error(hr(90));return t}var wt=X(pe(),1);function Ht(e,t){let r=e+t;return r>=0?t:-Math.sqrt(-r)-e}function io(e,t,r){if(!Number.isFinite(t)||t<=0)return null;if(typeof e=="number")return Number.isFinite(e)?e<=1?we(e,0,1)*t:e:null;let a=e.trim();if(a.endsWith("px")){let i=Number.parseFloat(a);return Number.isFinite(i)?i:null}if(a.endsWith("rem")){let i=Number.parseFloat(a);return Number.isFinite(i)?i*r:null}return null}function vt(e,t){let r=-1,a=1/0;for(let i=0;i<e.length;i+=1){let R=Math.abs(e[i]-t);R<a&&(a=R,r=i)}return r}function Bt(){let e=ge(),{snapPoints:t,activeSnapPoint:r,setActiveSnapPoint:a,popupHeight:i}=Xe(),R=e.useState("viewportElement"),[S,z]=wt.useState(0),[c,s]=wt.useState(16),y=k(()=>{let v=Te(R).documentElement;z(R?R.offsetHeight:v.clientHeight);let B=parseFloat(getComputedStyle(v).fontSize);Number.isFinite(B)&&s(B)});Z(()=>{if(y(),!R||typeof ResizeObserver!="function")return;let D=new ResizeObserver(y);return D.observe(R),()=>{D.disconnect()}},[y,R]);let p=wt.useMemo(()=>{if(!t||t.length===0||S<=0||i<=0)return[];let D=Math.min(i,S),v=t.map(O=>{let w=io(O,S,c);if(w===null)return null;let U=we(w,0,D);return{value:O,height:U,offset:Math.max(0,i-U)}}).filter(O=>!!O);if(v.length<=1)return v;let B=[],N=[];for(let O=v.length-1;O>=0;O-=1){let w=v[O];N.some(de=>Math.abs(de-w.height)<=1)||(N.push(w.height),B.push(w))}return B.reverse(),B},[i,c,t,S]),x=wt.useMemo(()=>{if(r===null)return;let D=p.find(O=>Object.is(O.value,r));if(D)return D;let v=Math.min(i,S),B=io(r,S,c);if(B===null)return;let N=we(B,0,v);return p[vt(p.map(O=>O.height),N)]},[r,i,p,c,S]);return{snapPoints:t,activeSnapPoint:r,setActiveSnapPoint:a,popupHeight:i,viewportHeight:S,resolvedSnapPoints:p,activeSnapPointOffset:x?.offset??null}}var Ft=X(pe(),1),or=Ft.createContext(null);function co(){return Ft.useContext(or)}var uo=X(Ge(),1),po=!1;function gn(){po||(typeof CSS<"u"&&"registerProperty"in CSS&&([tt,Me,Qt].forEach(e=>{try{CSS.registerProperty({name:e,syntax:"<length>",inherits:!1,initialValue:"0px"})}catch{}}),[{name:ne,initialValue:"0"},{name:xt,initialValue:"1"}].forEach(({name:e,initialValue:t})=>{try{CSS.registerProperty({name:e,syntax:"<number>",inherits:!1,initialValue:t})}catch{}})),po=!0)}var hn={...Nt,expanded(e){return e?{[oo]:""}:null},nestedDrawerOpen(e){return e?{[no]:""}:null},nestedDrawerSwiping(e){return e?{[so]:""}:null},swipeDirection(e){return{[ao]:e}},swiping(e){return e?{[qe]:""}:null}},lo=at.forwardRef(function(t,r){let{render:a,className:i,style:R,finalFocus:S,initialFocus:z,...c}=t,s=ge(),y=s.context.popupRef,{swipeDirection:p,frontmostHeight:x,hasNestedDrawer:D,nestedSwiping:v,nestedSwipeProgressStore:B,onPopupHeightChange:N,notifyParentFrontmostHeight:O,notifyParentHasNestedDrawer:w}=Xe(),U=s.useState("descriptionElementId"),de=s.useState("disablePointerDismissal"),L=s.useState("floatingRootContext"),fe=s.useState("popupProps"),q=s.useState("modal"),K=s.useState("mounted"),se=s.useState("nested"),l=s.useState("nestedOpenDrawerCount"),b=s.useState("transitionStatus"),A=s.useState("open"),T=s.useState("openMethod"),I=s.useState("titleElementId"),_=s.useState("role"),Y=L.useState("floatingId"),$=c.id??Y,H=co();Hr();let{snapPoints:me,activeSnapPoint:xe,activeSnapPointOffset:Q}=Bt(),he=l>0,ye=H?.swiping??!1,re=H?.swipeStrength??null,[ae,De]=at.useState(0),G=at.useRef(0),ee=k(()=>{let W=y.current;if(!W)return;let m=W.offsetHeight;if(G.current>0&&x>G.current&&m>G.current)return;if(G.current>0&&D){let oe=G.current;De(oe),N(oe);return}let E=m;E!==G.current&&(G.current=E,De(E),N(E))});Z(()=>{if(!K){G.current=0,De(0),N(0);return}let W=y.current;if(!W||(gn(),ee(),typeof ResizeObserver!="function"))return;let m=new ResizeObserver(ee);return m.observe(W),()=>{m.disconnect()}},[ee,K,he,N,y]),Z(()=>{let W=()=>{let E=y.current;if(!E)return;let oe=B.getSnapshot();oe>0?E.style.setProperty(ne,`${oe}`):E.style.setProperty(ne,"0")};W();let m=B.subscribe(W),f=y.current;return()=>{m(),f&&f.style.setProperty(ne,"0")}},[B,y]),Z(()=>{if(A)return O?.(x),()=>{O?.(0)}},[x,A,O]),Z(()=>w?(w(A||b==="ending"),()=>{w(!1)}):void 0,[w,A,b]),yr({open:A,ref:y,onComplete(){A&&s.context.onOpenChangeComplete?.(!0)}});let Pe=z===void 0?y:z,ce=s.useStateSetter("popupElement"),J={open:A,nested:se,transitionStatus:b,expanded:xe===1,nestedDrawerOpen:he,nestedDrawerSwiping:v,swipeDirection:p,swiping:ye},ve;ae&&!(!D&&b!=="ending")&&(ve=`${ae}px`);let n=me&&me.length>0&&(p==="down"||p==="up"),u=null;n&&Q!==null&&(u=p==="up"?-Q:Q);let V=H?H.getDragStyles():wr;if(n&&p==="down"){let W=Q??0,m=Number.parseFloat(String(V[Me]));ye&&Number.isFinite(m)?V={...V,transform:void 0,[Me]:`${Ht(W,m)}px`}:V={...V,transform:void 0}}let Se=Ae("div",t,{state:J,props:[fe,{id:$,"aria-labelledby":I,"aria-describedby":U,role:_,...Tr,hidden:!K,onKeyDown(W){Mr.has(W.key)&&W.stopPropagation()},style:{...V,[ne]:"0",[Ur]:l,[Re]:ve,[Qt]:typeof u=="number"?`${u}px`:"0px",[$r]:x?`${x}px`:void 0,[xt]:typeof re=="number"&&Number.isFinite(re)&&re>0?`${re}`:"1"}},c],ref:[r,y,ce],stateAttributesMapping:hn});return(0,uo.jsx)(Cr,{context:L,openInteractionType:T,disabled:!K,closeOnFocusOut:!de,initialFocus:Pe,returnFocus:S,modal:q!==!1,restoreFocus:"popup",children:Se})});var fo=Br;var bt=X(pe(),1);var mo=X(Ge(),1);function wo(e){let{children:t}=e,r=gr(()=>new Set),[a,i]=bt.useState(!1),[R]=bt.useState(Dn),S=k((s,y)=>{let p=r.current;if(p.has(s)===y)return;let x=p.size>0;y?p.add(s):p.delete(s);let D=p.size>0;D!==x&&i(D)}),z=k(s=>{S(s,!1)}),c=bt.useMemo(()=>({setDrawerOpen:S,removeDrawer:z,active:a,visualStateStore:R}),[a,z,S,R]);return(0,mo.jsx)(er.Provider,{value:c,children:t})}function Dn(){let e={swipeProgress:0,frontmostHeight:0},t=new Set;return{getSnapshot:()=>e,set(r){let a=e.swipeProgress;r.swipeProgress!==void 0&&(a=Number.isFinite(r.swipeProgress)?r.swipeProgress:0);let i=e.frontmostHeight;r.frontmostHeight!==void 0&&(i=Number.isFinite(r.frontmostHeight)?r.frontmostHeight:0),!(a===e.swipeProgress&&i===e.frontmostHeight)&&(e={swipeProgress:a,frontmostHeight:i},t.forEach(R=>{R()}))},subscribe(r){return t.add(r),()=>{t.delete(r)}}}}var ue=X(pe(),1);var it=X(Ge(),1),go,ho;function Po(e){let{children:t,open:r,defaultOpen:a=!1,onOpenChange:i,onOpenChangeComplete:R,disablePointerDismissal:S=!1,modal:z=!0,actionsRef:c,handle:s,triggerId:y,defaultTriggerId:p=null,swipeDirection:x="down",snapToSequentialPoints:D=!1,snapPoints:v,snapPoint:B,defaultSnapPoint:N,onSnapPointChange:O}=e,w=Xe(!0),U=w?.onNestedSwipeProgressChange,de=w?.onNestedFrontmostHeightChange,L=w?.onNestedSwipingChange,fe=w?.onNestedDrawerPresenceChange,[q,K]=ue.useState(0),[se,l]=ue.useState(0),[b,A]=ue.useState(!1),[T,I]=ue.useState(!1),[_]=ue.useState(Pn),Y=N!==void 0?N:v?.[0]??null,$=B!==void 0,[H,me]=kr({controlled:B,default:Y,name:"Drawer",state:"snapPoint"}),xe=ue.useRef(!1),Q=ue.useRef(!1),he=k((M,n)=>{let u=n??Oe(ke.none);O?.(M,u),!u.isCanceled&&me(M)}),ye=ue.useMemo(()=>$||!v||v.length===0?H:H===null||!v.some(M=>Object.is(M,H))?Y:H,[H,$,Y,v]),re=k(M=>{K(M),!xe.current&&M>0&&l(M)}),ae=k(M=>{if(M>0){xe.current=!0,l(M);return}xe.current=!1,q>0&&l(q)}),De=k(M=>{A(M)}),G=k(M=>{_.set(M),U?.(M)}),ee=k(M=>{I(M),L?.(M)}),Pe=k((M,n)=>{i?.(M,n),!n.isCanceled&&!M&&v&&v.length>0&&he(Y,Oe(n.reason,n.event,n.trigger))}),ce=ue.useMemo(()=>({swipeDirection:x,swipeAreaActiveRef:Q,snapToSequentialPoints:D,snapPoints:v,activeSnapPoint:ye,setActiveSnapPoint:he,frontmostHeight:se,popupHeight:q,hasNestedDrawer:b,nestedSwiping:T,nestedSwipeProgressStore:_,onNestedDrawerPresenceChange:De,onPopupHeightChange:re,onNestedFrontmostHeightChange:ae,onNestedSwipingChange:ee,onNestedSwipeProgressChange:G,notifyParentFrontmostHeight:de,notifyParentSwipingChange:L,notifyParentSwipeProgressChange:U,notifyParentHasNestedDrawer:fe}),[ye,se,b,T,_,fe,U,L,de,De,ae,G,ee,re,q,he,v,D,Q,x]),J=typeof t=="function"?M=>(0,it.jsxs)(ue.Fragment,{children:[go||(go=(0,it.jsx)(Do,{})),t(M)]}):(0,it.jsxs)(ue.Fragment,{children:[ho||(ho=(0,it.jsx)(Do,{})),t]}),ve=Fr("drawer",{open:r,defaultOpen:a,onOpenChange:Pe,onOpenChangeComplete:R,disablePointerDismissal:S,modal:z,actionsRef:c,handle:s,triggerId:y,defaultTriggerId:p,children:J});return(0,it.jsx)(rr.Provider,{value:ce,children:ve})}function Pn(){let e=0,t=new Set;return{getSnapshot:()=>e,set(r){let a=Number.isFinite(r)?r:0;a!==e&&(e=a,t.forEach(i=>{i()}))},subscribe(r){return t.add(r),()=>{t.delete(r)}}}}function Do(){let e=We(),t=ge(!1),r=e?.setDrawerOpen,a=e?.removeDrawer,i=t.useState("open"),R=t.useState("nestedOpenDialogCount"),S=t.useState("popupElement"),z=R===0;return Z(()=>{if(a)return()=>{a(t)}},[a,t]),Z(()=>{r?.(t,i)},[i,r,t]),ue.useEffect(()=>{if(!i||!z||!xr.os.android)return;let s=Ye(S).CloseWatcher;if(!s)return;function y(D){if(!t.select("open"))return;let v=Oe(ke.closeWatcher,D);D.cancelable||(v.cancel=Pt),t.setOpen(!1,v),v.isCanceled&&D.preventDefault()}let p=new s,x=Ee(p,"cancel",y);return()=>{x(),p.destroy()}},[t,z,i,S]),null}var le=X(pe(),1);var So=et.open,xo=et.closed,vo="data-disabled",bo="data-swipe-direction",Ro="data-swiping";var Sn=.5,xn=1,vn=.1,bn=40,Rn={[So]:""},yn={[xo]:""},En={[Ro]:""},Cn={[vo]:""},Tn={open(e){return e?Rn:yn},swiping(e){return e?En:null},swipeDirection(e){return{[bo]:e}},disabled(e){return e?Cn:null}},Eo={up:"down",down:"up",left:"right",right:"left"};function An(e){return e==="left"||e==="right"?"pan-y":"pan-x"}var Co=le.forwardRef(function(t,r){let{render:a,className:i,style:R,disabled:S=!1,swipeDirection:z,...c}=t,s=ge(),{swipeDirection:y,frontmostHeight:p,swipeAreaActiveRef:x}=Xe(),D=We(),[v,B]=le.useState(!1),N=le.useRef(null),O=le.useRef(null),w=le.useRef(!1),U=le.useRef({x:0,y:0}),de=le.useRef(null),L=le.useRef(!1),fe=le.useRef(null),q=le.useRef(null),K=le.useRef(null),se=le.useRef(Pt),l=Vr(t.id),b=Ar(l,s);Z(()=>(b(N.current),()=>b(null)),[b,l,s]);let A=s.useState("open"),T=k(()=>{U.current.x=0,U.current.y=0}),I=z??Eo[y],_=Eo[I],Y=!S&&(!A||v);function $(){se.current(),s.context.outsidePressEnabledRef.current=!1}let H=k(()=>{se.current();let n=Te(N.current);function u(V){V?.type==="click"&&V.detail!==0&&!br(V)||(se.current=Pt,n.removeEventListener("pointerdown",u,!0),n.removeEventListener("click",u,!0),s.context.outsidePressEnabledRef.current=!0)}se.current=u,n.addEventListener("pointerdown",u,!0),n.addEventListener("click",u,!0)});function me(n){let V=_==="left"||_==="right"?n.offsetWidth:n.offsetHeight;return V<=0?null:V}function xe(){let n=s.context.popupRef.current;return n?me(n):null}function Q(n){let u=me(n);if(u==null)return null;let V=_==="left"||_==="right",Se=Er(n),W=V?Se.x:Se.y;return Number.isFinite(W)&&Math.abs(W)>.5?Math.min(u,Math.abs(W)):u}function he(){let n=xe();return n==null?bn:n*Sn}function ye(){let n=s.context.popupRef.current;if(!n||!s.select("open")||!s.select("mounted"))return;de.current==null&&(de.current=Q(n));let u=de.current;if(u===null)return;let{x:V,y:Se}=U.current,W=Ne(I,V,Se),m=Math.max(0,W),f=m>u?u+Math.sqrt(m-u):m,He=(u-f)*(_==="left"||_==="up"?-1:1),Be=_==="left"||_==="right",rt=Be?He:0,Ue=Be?0:He,Fe=Math.max(0,Math.min(1,m/u)),ot=Math.max(0,Math.min(1,1-Fe));n.style.setProperty(tt,`${rt}px`),n.style.setProperty(Me,`${Ue}px`),n.setAttribute(qe,""),fe.current=n,K.current===null&&(K.current=n.style.transition),n.style.transition="none";let o=s.context.backdropRef.current;o&&(o.setAttribute(qe,""),q.current=o,o.style.setProperty(ne,`${ot}`),Fe>0&&p>0?o.style.setProperty(Re,`${p}px`):o.style.removeProperty(Re)),D?.visualStateStore.set({swipeProgress:Fe,frontmostHeight:Fe>0?p:0}),L.current=!0,x.current=!0}let re=k(()=>{let n=fe.current;n&&(n.style.removeProperty(tt),n.style.removeProperty(Me),n.removeAttribute(qe)),n&&K.current!==null&&(n.style.transition=K.current,K.current=null);let u=q.current;u&&(u.removeAttribute(qe),u.style.setProperty(ne,"0"),u.style.removeProperty(Re)),D?.visualStateStore.set({swipeProgress:0,frontmostHeight:0}),L.current=!1,fe.current=null,q.current=null,x.current=!1});function ae(n){w.current=!0,s.setOpen(!0,Oe(ke.swipe,n,N.current))}function De(n){s.setOpen(!1,Oe(ke.swipe,n,N.current))}function G(){O.current=null,w.current=!1,de.current=null,B(!1)}function ee(){G(),H(),T(),re()}let Pe=Ot({enabled:Y,directions:[I],elementRef:N,trackDrag:!1,movementCssVars:{x:tt,y:Me},onSwipeStart(n){$(),O.current=n,w.current=!1,B(!0),T()},onProgress(n,u){if(!u||!O.current||(U.current.x=u.deltaX,U.current.y=u.deltaY,u.direction!==I))return;let V=Ne(I,u.deltaX,u.deltaY);!w.current&&V<xn||(!w.current&&!s.select("open")&&ae(O.current),ye())},onRelease({event:n,direction:u,deltaX:V,deltaY:Se,releaseVelocityX:W,releaseVelocityY:m}){let f=Ne(I,V,Se),E=Ne(I,W,m),oe=he(),He=f>=oe,Be=E>=vn;return u===I&&(He||Be)&&!S?s.select("open")||ae(n):w.current&&s.select("open")&&De(n),ee(),!1},onCancel:ee}),ce=Pe.getPointerProps(),J=Pe.getTouchProps(),ve=Pe.reset;Z(()=>{v&&L.current&&ye()}),Z(()=>{Y||(v&&H(),ve(),T(),re(),G())},[re,H,Y,T,ve,v]),le.useEffect(()=>()=>{se.current(),s.context.outsidePressEnabledRef.current=!0},[s]);let M={open:A,swiping:Pe.swiping,swipeDirection:I,disabled:S};return Ae("div",t,{state:M,ref:[r,N,b],stateAttributesMapping:Tn,props:[{role:"presentation","aria-hidden":!0,style:{pointerEvents:Y?void 0:"none",touchAction:An(I)},onPointerDown(n){n.pointerType!=="touch"&&(ce.onPointerDown?.(n),n.cancelable&&n.preventDefault())},onPointerMove(n){n.pointerType!=="touch"&&ce.onPointerMove?.(n)},onPointerUp(n){n.pointerType!=="touch"&&ce.onPointerUp?.(n)},onPointerCancel(n){n.pointerType!=="touch"&&ce.onPointerCancel?.(n)}},J,l?{id:l}:void 0,c]})});var To=Kr;var Ao=Yr;var te=X(pe(),1),Ko=X(fn(),1);var Lt=X(pe(),1),nr=Lt.createContext(void 0);function No(){return Lt.useContext(nr)}var ir=X(Ge(),1),cr=10,Oo=.5,Vo=.5,Nn=300,ko=4,Mo=.2,On=4,sr=80,Io=360,_o=.1,Vn=1,Ho=6,kn=2,Mn=`[${Vt}]`,Bo={horizontal:`[${Gt}="x"]`,vertical:`[${Gt}="y"]`},Yo=te.forwardRef(function(t,r){let{render:a,className:i,style:R,children:S,...z}=t,c=ge(),s=c.context.popupRef,y=c.context.backdropRef,{swipeDirection:p,notifyParentSwipingChange:x,notifyParentSwipeProgressChange:D,frontmostHeight:v,snapToSequentialPoints:B,swipeAreaActiveRef:N}=Xe(),O=We(),{snapPoints:w,resolvedSnapPoints:U,activeSnapPoint:de,activeSnapPointOffset:L,setActiveSnapPoint:fe,popupHeight:q}=Bt(),K=c.useState("open"),se=c.useState("mounted"),l=c.useState("nested"),b=c.useState("nestedOpenDrawerCount"),A=c.useState("viewportElement"),T=c.useState("popupElement"),I=O?.visualStateStore,_=b>0,Y=p==="left"||p==="right"?"horizontal":"vertical",$=Y==="vertical",H=$?"horizontal":"vertical",[me,xe]=te.useState(null),Q=te.useRef(void 0),he=te.useRef(null),ye=At(),re=te.useRef(!1),ae=te.useRef(!1),De=te.useRef(""),G=te.useRef(!1),ee=te.useRef(!1),Pe=te.useRef(null),ce=No(),J=te.useMemo(()=>{if(!w||w.length<2||U.length<2||p!=="down"&&p!=="up")return null;let o=U.map(C=>C.offset).sort((C,g)=>C-g),d=o[0],P=o[1]-d;return{minOffset:d,range:P}},[U,w,p]),ve=te.useMemo(()=>!J||L===null?null:we((L-J.minOffset)/J.range,0,1),[L,J]),M=te.useMemo(()=>w&&w.length>0&&(p==="down"||p==="up")?p==="down"?["down","up"]:["up","down"]:[p],[w,p]),n=k(o=>{s.current?.toggleAttribute(tr,o),y.current?.toggleAttribute(tr,o)}),u=k(()=>{n(!1),s.current?.removeAttribute(jt.endingStyle),xe(null)}),V=k(()=>{ae.current&&(ae.current=!1,x?.(!1))}),Se=k((o,d,h)=>{let P=K&&!l&&d,C=P?o:0,g=K&&d?o:0;h&&D&&(D(g),g<=0&&V()),I?.set({swipeProgress:C,frontmostHeight:C>0?v:0});let F=y.current;if(!F)return;let j=P&&C>0;F.style.setProperty(ne,j?`${C}`:"0"),j&&v>0?F.style.setProperty(Re,`${v}px`):F.style.removeProperty(Re)});function W(o,d,h,P,C,g,F,j){let Le=Wo(o,d);if(Le<=0)return null;let Ce=((d==="down"||d==="up")&&w&&w.length>0?L??0:0)+Ne(d,h,P),je=Math.max(0,Le-Ce);if(je<=0)return null;let Ke=Ne(d,F,j),yt=Math.abs(Ke)>0?Ke:Ne(d,C,g);if(yt<=Mo)return null;let Xt=we(yt,Mo,On),Et=(we(je/Xt,sr,Io)-sr)/(Io-sr);return _o+Et*(Vn-_o)}function m(o){if(ae.current||!o)return;let d=o.direction??p,h=Ne(d,o.deltaX,o.deltaY);Math.abs(h)<cr||(ae.current=!0,x?.(!0))}let f=Ot({enabled:se&&!_,directions:M,elementRef:c.context.popupRef,ignoreSelectorWhenTouch:!1,ignoreScrollableAncestors:!0,movementCssVars:{x:tt,y:Me},onSwipeStart(o){if("touches"in o||o.pointerType==="touch")return;let d=s.current,P=Te(d).getSelection?.();if(!P||P.isCollapsed)return;let C=ut(P.anchorNode)?P.anchorNode:P.anchorNode?.parentElement,g=ut(P.focusNode)?P.focusNode:P.focusNode?.parentElement;!be(d,C)&&!be(d,g)||P.removeAllRanges()},onSwipingChange(o){re.current=o,ar(c.context.backdropRef.current,o),!o&&!D&&V()},swipeThreshold({element:o,direction:d}){return Fo(o,d)},canStart(o,d){let h=c.context.popupRef.current;if(!h)return!1;let P=d.nativeEvent,C="touches"in P||P.pointerType==="touch",g=C?Pe.current:null,F=h.ownerDocument,j=st(h.getRootNode(),o.x,o.y);return!(!g?.startedInPopup&&!be(h,j)||C&&Lo(F,h)||g?.hasCrossAxisGestureTarget&&!g.drawerAxisAttributed&&g.allowSwipe!==!0)},onProgress(o,d){let h=re.current;h&&m(d);let P=!!(w&&w.length>0);if(h&&p==="down"&&P&&d){let g=c.context.popupRef.current;g&&(g.style.removeProperty("transform"),g.style.setProperty(Me,`${Ht(L??0,d.deltaY)}px`))}let C=o;if(J&&q>0){let g=L??J.minOffset,F=j=>we((j-J.minOffset)/J.range,0,1);h&&d&&Number.isFinite(d.deltaY)?C=F(we(g+d.deltaY,0,q)):ve!==null&&(C=ve)}h||(D?.(0),V()),Se(C,!0,h)},onRelease({event:o,deltaX:d,deltaY:h,direction:P,velocityX:C,velocityY:g,releaseVelocityX:F,releaseVelocityY:j}){let Le=c.context.popupRef.current;if(!Le){u();return}let $e=Le;function Ce(ie){V(),n(!0),$e.style.removeProperty("transition"),$e.setAttribute(jt.endingStyle,""),Ko.flushSync(()=>{xe(W($e,ie,d,h,C,g,F,j))})}if(!w||w.length===0){if(!P){u();return}let ie=Ne(P,d,h);if(ie<=0)return u(),!1;if(Ne(P,C,g)>=Oo)return Ce(P),!0;let ht=ie>Fo($e,P);return ht?Ce(P):u(),ht}if(p!=="down"&&p!=="up"){u();return}if(!q)return u(),!1;if(U.length===0){u();return}let je=p==="down"?h:-h,Ke=Math.sign(je),yt=p==="down"?j:-j,Xt=p==="down"?g:-g,Je=yt;if(Ke!==0&&Math.abs(je)>=cr){let ie=Math.sign(Je);ie!==0&&ie!==Ke&&(Je=Xt)}let Et=L??0,lr=we(Et+je,0,q),cn=Math.abs(Je)>=Vo?we(Je,-ko,ko)*Nn:0,nt=B?lr:we(lr+cn,0,q),zt=Oe(ke.swipe,o),dr=()=>(Se(0,!0,!0),u(),!1),Ut=ie=>(fe(ie.value,zt),dr()),Ct=ie=>P?(fe(null,zt),zt.isCanceled?dr():(Q.current=de,Ce(p),!0)):Ut(ie);if(B){let ie=[...U].sort((ct,pt)=>ct.offset-pt.offset),ht=ie.map(ct=>ct.offset),fr=vt(ht,Et),Dt=ie[vt(ht,nt)],mr=Math.sign(Je),pn=Ke!==0&&mr!==0&&mr===Ke&&Math.abs(Je)>=Vo,$t=nt;if(pn){let ct=we(fr+Ke,0,ie.length-1);if(ct!==fr){let pt=ie[ct];(Ke>0?nt<pt.offset:nt>pt.offset)&&(Dt=pt,$t=pt.offset)}else if(Ke>0)return Ct(Dt)}let un=Math.abs($t-q),ln=Math.abs($t-Dt.offset);return un<ln?Ct(Dt):Ut(Dt)}let Tt=U[vt(U.map(ie=>ie.offset),nt)];return Je>=Oo&&je>0||Math.abs(nt-q)<Math.abs(nt-Tt.offset)?Ct(Tt):Ut(Tt)},onDismiss(o){I?.set({swipeProgress:0,frontmostHeight:0});let d=c.context.backdropRef.current;d&&(d.style.setProperty(ne,"0"),d.style.removeProperty(Re));let h=Oe(ke.swipe,o);if(c.setOpen(!1,h),h.isCanceled){let P=Q.current;P!==void 0&&fe(P,Oe(ke.swipe,o)),Q.current=void 0,he.current?.(),u();return}if(c.select("open")){let P=o;ye.request(()=>{if(c.select("open")){let C=Q.current;C!==void 0&&fe(C,Oe(ke.swipe,P)),Q.current=void 0,u(),he.current?.()}else Q.current=void 0});return}Q.current=void 0,n(!0)}}),E=f.getPointerProps(),oe=f.getTouchProps(),{moveNative:He,reset:Be}=f;he.current=Be,te.useEffect(()=>{let o=A??T;if(!o||!K||!se)return;let d=o,h=Te(d);function P(g,F,j){let Le=$?j.clientY-F.lastY:j.clientX-F.lastX;if(g.touches.length===2||Lo(h,d)||_||Wn(F,g,j,$))return;let Ce=F.scrollTarget;if(!Ce||Ce===h.documentElement||Ce===h.body){g.cancelable&&g.preventDefault(),g.stopPropagation(),He(g,d);return}if(!Xn(Ce,Y)){g.cancelable&&g.preventDefault(),g.stopPropagation();return}if(Le!==0){let je=zn(Ce,Y,p,Le);F.allowSwipe?g.cancelable&&g.preventDefault():g.cancelable&&je?(F.allowSwipe=!0,g.preventDefault()):F.allowSwipe=!1}F.allowSwipe===!0&&(g.stopPropagation(),He(g,d))}function C(g){if(ce?.onTouchMove(g),ee.current)return;let F=Pe.current,j=g.touches[0];!j||!F||(P(g,F,j),Yn(F,j))}return Ee(h,"touchmove",C,{passive:!1,capture:!0})},[se,_,K,T,$,Y,p,He,A,ce]),Z(()=>{!J||f.swiping||Se(!K||l?0:ve??0,!0,!1)},[Se,v,l,D,K,ve,J,f.swiping,c,I]),Z(()=>{if(D)return K||D(0),()=>{D(0)}},[D,K]),Z(()=>{K&&(N.current||Be(),u())},[u,K,Be,N]),Z(()=>{let o=y.current;return()=>{I?.set({swipeProgress:0,frontmostHeight:0}),ar(o,!1);let d=y.current;d!==o&&ar(d,!1),V()}},[y,V,I]);let rt=te.useMemo(()=>({swiping:f.swiping,getDragStyles:f.getDragStyles,swipeStrength:me??null,setSwipeDismissed:n}),[n,f.getDragStyles,f.swiping,me]);function Ue(o){ee.current=o,Pe.current=null}function Fe(){Ue(!1),De.current="",G.current=!1}function ot(o){return De.current="",o.pointerType!=="touch"}return(0,ir.jsx)(Lr,{ref:r,className:i,style:R,render:a,...Rr(z,{onPointerDown(o){if(De.current=o.pointerType,G.current=o.pointerType==="pen",!K||!se||_)return;let d=st(o.currentTarget.getRootNode(),o.clientX,o.clientY);In(d)||_n(d)||o.pointerType!=="touch"&&E.onPointerDown?.(o)},onPointerMove(o){o.pointerType!=="touch"&&E.onPointerMove?.(o)},onPointerUp(o){ot(o)&&E.onPointerUp?.(o)},onPointerCancel(o){ot(o)&&E.onPointerCancel?.(o)},onTouchStart(o){if(De.current==="pen"&&G.current){G.current=!1,Ue(!1);return}if(!K||!se||_){Ue(!1);return}let h=o.touches[0];if(!h)return;if(Kn(o)){Ue(!1);return}let P=o.currentTarget,C=st(P.getRootNode(),h.clientX,h.clientY),g=lt(o.nativeEvent),F=ut(g)?g:P;if(!be(P,F)){Ue(!0);return}if(ce?.onTouchStart(o),Qe(C,`${qt}:not(${Bo[H]})`)){Ue(!0);return}ee.current=!1;let j=dt(F,P,Y),Le=dt(F,P,H)!=null||Qe(C,Bo[H])!=null,$e=null;j&&($e=zo(j,Y,p)?null:!1),Pe.current={startX:h.clientX,startY:h.clientY,lastX:h.clientX,lastY:h.clientY,startedInPopup:be(s.current,C),scrollTarget:j,hasCrossAxisGestureTarget:Le,allowSwipe:$e,preserveNativeCrossAxisScroll:!1,drawerAxisAttributed:!1},oe.onTouchStart?.(o)},onTouchEnd(o){ce?.onTouchEnd(o),Fe(),oe.onTouchEnd?.(o)},onTouchCancel(o){ce?.onTouchCancel(),Fe(),oe.onTouchCancel?.(o)},[Xr]:void 0}),children:(0,ir.jsx)(or.Provider,{value:rt,children:S})})});function ar(e,t){e?.toggleAttribute(qe,t)}function In(e){return!!Qe(e,qt)}function _n(e){return!!Qe(e,Mn)}function Wo(e,t){return t==="left"||t==="right"?e.offsetWidth:e.offsetHeight}function Fo(e,t){return Math.max(Wo(e,t)*.5,cr)}function Hn(e,t){return e instanceof t.HTMLInputElement&&e.type==="range"}function Bn(e){return e.tagName==="INPUT"||e.tagName==="TEXTAREA"}function Fn(e,t){let r=ut(e.anchorNode)?e.anchorNode:e.anchorNode?.parentElement,a=ut(e.focusNode)?e.focusNode:e.focusNode?.parentElement;return e.containsNode(t,!0)||be(t,r)||be(t,a)}function Lo(e,t){let r=Ze(e);if(r&&be(t,r)&&Bn(r)){let{selectionStart:i,selectionEnd:R}=r;if(i!=null&&R!=null&&i<R)return!0}let a=e.getSelection?.();return!a||a.isCollapsed?!1:Fn(a,t)}function Ln(e,t){return e.composedPath().some(r=>Hn(r,t))}function Kn(e){return Ln(e.nativeEvent,Ye(e.currentTarget))}function Yn(e,t){e.lastX=t.clientX,e.lastY=t.clientY}function Wn(e,t,r,a){if(e.preserveNativeCrossAxisScroll)return!0;if(e.drawerAxisAttributed||e.allowSwipe===!0||!e.hasCrossAxisGestureTarget)return!1;if(!t.cancelable)return e.preserveNativeCrossAxisScroll=!0,!0;let i=a?r.clientY-e.startY:r.clientX-e.startX,R=a?r.clientX-e.startX:r.clientY-e.startY,S=Math.abs(i),z=Math.abs(R);return z>=Ho&&z>S+kn?(e.preserveNativeCrossAxisScroll=!0,!0):S>=Ho?(e.drawerAxisAttributed=!0,!1):!0}function Xn(e,t){return Xo(e,t).max>0}function Xo(e,t){if(t==="vertical"){let a=Math.max(0,e.scrollHeight-e.clientHeight);return{offset:e.scrollTop,max:a}}let r=Math.max(0,e.scrollWidth-e.clientWidth);return{offset:e.scrollLeft,max:r}}function zo(e,t,r){let a=Uo(r,t),{offset:i,max:R}=Xo(e,t);return a?i<=0:i>=R}function zn(e,t,r,a){return(Uo(r,t)?a>0:a<0)?zo(e,t,r):!1}function Uo(e,t){return t==="vertical"?e==="down":e==="right"}var Ie=X(pe(),1);var pr="--drawer-keyboard-inset";var Jo=X(Ge(),1),ur=60,Kt=16,jo=150,Un=4,$n=60,Go=10,Yt=16,jn=new Set(["email","number","password","search","tel","text","url"]),Zo=Symbol("KeyboardTapBlocked");function Qo(e){let{children:t}=e,r=ge(),a=r.useState("open"),i=r.useState("mounted"),R=r.useState("modal"),S=r.useState("nestedOpenDialogCount"),c=r.useState("viewportElement"),s=S>0,y=Ie.useRef(!1),p=Ie.useRef(null),x=Ie.useRef(null),D=Ie.useRef(null),v=Ie.useRef(!1),B=Ie.useRef(null),N=At(),O=Sr(),w=k(()=>{let l=D.current;l&&(l.element.style.overflowAnchor=l.overflowAnchor,l.element.style.paddingBottom=l.paddingBottom,l.element.style.scrollPaddingBottom=l.scrollPaddingBottom,D.current=null)}),U=k((l,b)=>{let A=Math.max(0,Math.ceil(b)),T=D.current;if(T&&!T.element.isConnected&&(w(),T=null),A===0){w();return}if(T&&T.element!==l&&(w(),T=null),!T){let I=Dr(l);T={element:l,overflowAnchor:l.style.overflowAnchor,paddingBottom:l.style.paddingBottom,scrollPaddingBottom:l.style.scrollPaddingBottom,computedPaddingBottom:Number.parseFloat(I.paddingBottom)||0,computedScrollPaddingBottom:Number.parseFloat(I.scrollPaddingBottom)||0},D.current=T}l.style.overflowAnchor="none",l.style.paddingBottom=`${A+Math.max(T.computedPaddingBottom,Kt)}px`,l.style.scrollPaddingBottom=`${T.computedScrollPaddingBottom+Kt}px`}),de=k((l,b)=>{let T=Ye(l).matchMedia?.("(prefers-reduced-motion: reduce)")?.matches?"auto":"smooth";l.scrollTo({top:b,behavior:T})}),L=k(()=>{y.current=!1,p.current=null});Ie.useEffect(()=>{if(!i||!a){x.current=null,w(),N.cancel();return}if(!c){w();return}let l=Te(c),b=Ye(c),A=b.visualViewport,T=null,I=0,_=0,Y=-1,$=-1,H=null,me=()=>{if(!A||A.scale!==1)return null;let m=b.innerHeight,f=A.height;if(m-f>ur)$=f;else if(Math.abs(f-$)>ur)return $=-1,null;H||(H=l.createElement("div"),H.style.cssText="position:fixed;top:0;height:100svh;visibility:hidden",l.body.appendChild(H));let E=H.offsetHeight-f<=ur,oe=Math.max(0,A.offsetTop);return{top:oe,bottom:E?m:Math.min(m,oe+f),resizing:E&&Math.abs(m-f)>=1}};B.current=me;let xe=m=>{c.style.setProperty(pr,`${Math.max(0,Math.ceil(m))}px`)},Q=b.scrollX,he=b.scrollY,ye=()=>R!==!0||s||!x.current||b.scrollX===Q&&b.scrollY===he||me()==null?!1:(b.scrollTo({left:Q,top:he,behavior:"instant"}),!0),re=null,ae=()=>{re?.(),re=null},De=(m,f)=>{ae();let E=m.getBoundingClientRect();re=en(m,(f.top+f.bottom-E.top-E.bottom)/2)},G=()=>{ae();let m=x.current;if(s||!m||!be(c,m)){xe(0),w();return}ye();let f=me();if(!f){xe(0),w();return}xe(Math.max(0,b.innerHeight-f.bottom));let E=es(m,c);if(!E){w();return}let oe=E.getBoundingClientRect(),He=Math.min(oe.bottom,f.bottom),Be=Math.max(0,oe.bottom-f.bottom);U(E,Be);let rt=Math.max(0,E.scrollHeight-E.clientHeight);if(rt<=0)return;let Fe=Math.max(oe.top,f.top)+Kt,ot=He-Kt;if(ot<=Fe)return;let o=m.getBoundingClientRect(),d=E.scrollTop+(o.top+o.bottom-Fe-ot)/2,h=Math.round(we(d,0,rt));if(T===E&&!f.resizing&&Math.abs(I-h)<=1){if(Y>=0){let C=E.scrollTop;if(Math.abs(C-h)<=1)return;if(C!==Y){Y=C;return}}}else{let C=T===E?_+1:1;if(T=E,I=h,_=C,Y=-1,C<=$n){N.request(G);return}}T=E,I=h,_=0,Y=E.scrollTop,de(E,h)},ee=()=>{N.request(G)},Pe=()=>{let m=Un,f=()=>{G(),m-=1,m>0&&O.start(jo,f)};O.start(jo,f)},ce=()=>{x.current=null,$=-1,O.clear(),ee()},J=m=>{if(s)return!1;let f=Wt(m);return!f||!be(c,f)?!1:(x.current!==f&&(T=null),x.current=f,!0)},ve=m=>{let f=x.current;re&&f&&f===lt(m)&&f.focus({preventScroll:!0})},M=m=>{if(v.current=!1,ae(),!J(lt(m))){ce();return}me()!=null&&Pe(),ee()},n=m=>{if(!v.current){if(J(m.relatedTarget)){let f=x.current,E=me();f&&E&&De(f,E),ee();return}ce()}},u=()=>{(x.current||J(Ze(l)))&&ee()},V=[];A&&V.push(Ee(A,"resize",u),Ee(A,"scroll",u),Ee(b,"resize",u));let Se=()=>{ye()&&ee()},W=()=>{x.current&&N.cancel(),O.clear(),T=null};return V.push(Ee(l,"focus",ve,!0),Ee(l,"focusin",M,!0),Ee(l,"focusout",n,!0),Ee(b,"scroll",Se),Ee(l,"pointerdown",W,!0)),J(Ze(l))&&ee(),()=>{V.forEach(m=>m()),ae(),x.current=null,w(),N.cancel(),O.clear(),B.current=null,H?.remove(),c.style.removeProperty(pr)}},[de,N,O,R,i,s,a,w,c,U]);let fe=k(l=>{let b=l.touches[0];y.current=!1,p.current={x:b.clientX,y:b.clientY}}),q=k(l=>{let b=l.touches[0],A=p.current;!b||!A||y.current||(Math.abs(b.clientX-A.x)>Go||Math.abs(b.clientY-A.y)>Go)&&(y.current=!0)}),K=k(l=>{if(!a||!i||s||!c||!p.current||y.current){L();return}let b=l.changedTouches[0]??l.touches[0],A=c.getRootNode(),T=lt(l.nativeEvent),I=b?Jn(A,b.clientX,b.clientY):null;if(I===Zo){L();return}let _=b&&(I??Gn(T));if(_&&(!be(c,_.focusTarget)||!be(c,_.clickTarget))){L();return}if(_){let{clickTarget:Y,focusTarget:$}=_,H=Ye($);if(H.visualViewport&&H.visualViewport.scale!==1){L();return}if(Ze(Te($))===$&&(!H.visualViewport||B.current?.()!=null)){L();return}l.preventDefault(),v.current=!0;try{Qn($)}finally{v.current=!1}Zn(Y,b),Y!==$&&Ze(Te($))===$&&$.focus({preventScroll:!0}),L();return}L()}),se=Ie.useMemo(()=>({onTouchStart:fe,onTouchMove:q,onTouchEnd:K,onTouchCancel:L}),[K,q,fe,L]);return(0,Jo.jsx)(nr.Provider,{value:se,children:t})}function qo(e){if(e.isContentEditable)return!0;let t=Ye(e);return e instanceof t.HTMLTextAreaElement||e instanceof t.HTMLInputElement&&jn.has(e.type)?!e.matches(":disabled"):!1}function Wt(e){if(!St(e))return null;if(qo(e))return e.isContentEditable?qn(e):e;let r=Qe(e,"label")?.control??null;return St(r)&&qo(r)?r:null}function Gn(e){if(!St(e))return null;let t=Wt(e);return t?{focusTarget:t,clickTarget:e}:null}function qn(e){let t=e;for(;t.parentElement?.isContentEditable;)t=t.parentElement;return t}function Jn(e,t,r){let a=st(e,t,r);if(St(a)){let i=Wt(a);if(i)return{focusTarget:i,clickTarget:a}}if(vr(a)||Qe(a,"label")!=null)return Zo;for(let[i,R]of[[0,Yt],[0,-Yt],[Yt,0],[-Yt,0]]){let S=Wt(st(e,t+i,r+R));if(S)return{focusTarget:S,clickTarget:S}}return null}function Zn(e,t){let r=Ye(e),a=r.PointerEvent??r.MouseEvent;e.dispatchEvent(new a("click",{bubbles:!0,cancelable:!0,clientX:t.clientX,clientY:t.clientY,detail:1,view:r}))}function Qn(e){let t=Ze(Te(e))===e,r=en(e,-2e3);try{t&&e.blur(),e.focus({preventScroll:!0})}finally{r()}}function en(e,t){let r=e.style.opacity,a=e.style.transform,i=e.style.transition;return e.style.transition="none",e.style.opacity="0",e.style.transform=`translateY(${t}px)`,()=>{e.style.opacity=r,e.style.transform=a,e.style.transition=i}}function es(e,t){let r=Pr(e);return dt(r,t,"vertical")??dt(r,t,"vertical",!0)}var Rt=class extends Wr{};function tn(){return new Rt}var Ve=X(Ge(),1),rn=gt.createContext(null);function ts(){let e=gt.useContext(rn);if(!e)throw new Error("useDrawer must be used within a Drawer.");return e}function on({modal:e=!0,swipeDirection:t="down",...r}){let a=gt.useMemo(()=>({modal:e,swipeDirection:t}),[e,t]);return(0,Ve.jsx)(rn.Provider,{value:a,children:(0,Ve.jsx)(ze.Root,{"data-slot":"drawer",modal:e,swipeDirection:t,...r})})}function rs({...e}){return(0,Ve.jsx)(ze.Portal,{"data-slot":"drawer-portal",...e})}function nn({...e}){return(0,Ve.jsx)(ze.Close,{"data-slot":"drawer-close",...e})}function os({className:e,...t}){return(0,Ve.jsx)(ze.Backdrop,{"data-slot":"drawer-overlay",className:Jt("fixed inset-0 z-50 min-h-dvh bg-dashboard-overlay opacity-[calc(1-var(--drawer-swipe-progress))] transition-opacity duration-450 ease-[cubic-bezier(0.32,0.72,0,1)] select-none motion-reduce:transition-none data-ending-style:pointer-events-none data-ending-style:opacity-0 data-ending-style:duration-[calc(var(--drawer-swipe-strength)*400ms)] data-starting-style:opacity-0 data-swiping:duration-0 supports-[-webkit-touch-callout:none]:absolute",e),...t})}function sn({className:e,children:t,...r}){let{modal:a,swipeDirection:i}=ts(),R=i==="down"||i==="up"?"y":"x";return(0,Ve.jsxs)(rs,{children:[(0,Ve.jsx)(os,{}),(0,Ve.jsx)(ze.Viewport,{"data-slot":"drawer-viewport","data-modal":a,className:"pointer-events-none fixed inset-0 z-50 select-none data-[modal=true]:pointer-events-auto",children:(0,Ve.jsx)(ze.Popup,{"data-slot":"drawer-popup","data-swipe-axis":R,className:Jt("group/drawer-popup pointer-events-auto fixed z-50 m-(--drawer-inset,0px) flex h-(--drawer-content-height) max-h-(--drawer-content-max-height,none) min-h-0 w-(--drawer-content-width,auto) transform-[translate3d(var(--translate-x,0px),var(--translate-y,0px),0)_scale(var(--stack-scale))] flex-col border-dashboard-border-strong bg-popover text-sm text-popover-foreground transition-[transform,height,opacity,filter] duration-450 ease-[cubic-bezier(0.22,1,0.36,1)] will-change-transform outline-none motion-reduce:transition-none select-none [interpolate-size:allow-keywords] data-[swipe-direction=down]:rounded-t-xl data-[swipe-direction=down]:border-t data-[swipe-direction=left]:rounded-r-xl data-[swipe-direction=left]:border-r data-[swipe-direction=right]:rounded-l-xl data-[swipe-direction=right]:border-l data-[swipe-direction=up]:rounded-b-xl data-[swipe-direction=up]:border-b","data-nested-drawer-open:overflow-hidden data-nested-drawer-open:brightness-95","after:pointer-events-none after:absolute after:bg-(--drawer-bleed-background,var(--color-popover)) data-[swipe-axis=x]:after:inset-y-0 data-[swipe-axis=x]:after:w-(--bleed) data-[swipe-axis=y]:after:inset-x-0 data-[swipe-axis=y]:after:h-(--bleed) data-[swipe-direction=down]:after:top-full data-[swipe-direction=left]:after:right-full data-[swipe-direction=right]:after:left-full data-[swipe-direction=up]:after:bottom-full","[--drawer-content-height:var(--drawer-height,auto)] data-[swipe-axis=x]:[--drawer-content-width:75%] data-[swipe-axis=y]:[--drawer-content-max-height:calc(100dvh-6rem)] data-[swipe-axis=y]:data-snap-points:[--drawer-content-height:100dvh] data-[swipe-axis=x]:sm:[--drawer-content-width:24rem]","[--bleed:3rem] [--peek:1rem] [--stack-height:var(--drawer-frontmost-height,var(--drawer-height,0px))] [--stack-peek-offset:max(0px,calc((var(--nested-drawers)-var(--stack-progress))*var(--peek)))] [--stack-progress:clamp(0,var(--drawer-swipe-progress),1)] [--stack-scale-base:max(0,calc(1-(var(--nested-drawers)*var(--stack-step))))] [--stack-scale:clamp(0,calc(var(--stack-scale-base)+(var(--stack-step)*var(--stack-progress))),1)] [--stack-shrink:calc(1-var(--stack-scale))] [--stack-step:0.05]","data-ending-style:transform-(--closed-transform) data-ending-style:opacity-[0.9999] data-ending-style:duration-[calc(var(--drawer-swipe-strength)*400ms)] data-nested-drawer-swiping:duration-0 data-ending-style:data-nested-drawer-swiping:duration-[calc(var(--drawer-swipe-strength)*400ms)] data-starting-style:transform-(--closed-transform) data-swiping:duration-0 data-ending-style:data-swiping:duration-[calc(var(--drawer-swipe-strength)*400ms)]","data-[swipe-axis=y]:inset-x-0 data-[swipe-axis=y]:data-nested-drawer-open:h-(--stack-height)","data-[swipe-axis=x]:inset-y-0 data-[swipe-axis=x]:flex-row","data-[swipe-direction=down]:bottom-0 data-[swipe-direction=down]:origin-bottom data-[swipe-direction=down]:[--closed-transform:translate3d(0,calc(100%+var(--drawer-inset,0px)+2px),0)] data-[swipe-direction=down]:[--translate-y:calc(var(--drawer-snap-point-offset,0px)+var(--drawer-swipe-movement-y)-var(--stack-peek-offset)-(var(--stack-shrink)*var(--stack-height)))]","data-[swipe-direction=up]:top-0 data-[swipe-direction=up]:origin-top data-[swipe-direction=up]:[--closed-transform:translate3d(0,calc(-100%-var(--drawer-inset,0px)-2px),0)] data-[swipe-direction=up]:[--translate-y:calc(var(--drawer-snap-point-offset,0px)+var(--drawer-swipe-movement-y)+var(--stack-peek-offset)+(var(--stack-shrink)*var(--stack-height)))]","data-[swipe-direction=left]:left-0 data-[swipe-direction=left]:origin-left data-[swipe-direction=left]:[--closed-transform:translate3d(calc(-100%-var(--drawer-inset,0px)-2px),0,0)] data-[swipe-direction=left]:[--translate-x:calc(var(--drawer-swipe-movement-x)+var(--stack-peek-offset)+(var(--stack-shrink)*100%))]","data-[swipe-direction=right]:right-0 data-[swipe-direction=right]:origin-right data-[swipe-direction=right]:[--closed-transform:translate3d(calc(100%+var(--drawer-inset,0px)+2px),0,0)] data-[swipe-direction=right]:[--translate-x:calc(var(--drawer-swipe-movement-x)-var(--stack-peek-offset)-(var(--stack-shrink)*100%))]",e),...r,children:(0,Ve.jsx)(ze.Content,{"data-slot":"drawer-content",className:"flex min-h-0 flex-1 flex-col overflow-hidden overscroll-contain rounded-[inherit] transition-opacity duration-300 ease-[cubic-bezier(0.45,1.005,0,1.005)] select-text motion-reduce:transition-none group-data-nested-drawer-open/drawer-popup:opacity-0 group-data-nested-drawer-swiping/drawer-popup:opacity-100 group-data-swiping/drawer-popup:select-none",children:t})})})]})}var _e=X(Ge(),1);function ic(e){let t=(0,an.useRef)(null),r=zr(e.onClose,t);return(0,_e.jsx)(on,{...r.rootProps,swipeDirection:"right",children:(0,_e.jsxs)(sn,{...r.contentProps,"aria-label":e.label,"aria-labelledby":e.titleId,"data-dashboard-modal":"",className:Zt("data-[swipe-axis=x]:[--drawer-content-width:100%] data-[swipe-axis=x]:sm:[--drawer-content-width:100%]",e.width==="wide"?"data-[swipe-axis=x]:md:[--drawer-content-width:min(760px,94vw)]":e.width==="narrow"?"data-[swipe-axis=x]:md:[--drawer-content-width:min(440px,94vw)]":"data-[swipe-axis=x]:md:[--drawer-content-width:min(560px,94vw)]"),children:[(0,_e.jsxs)("header",{className:"flex shrink-0 items-start gap-3 border-b border-dashboard-border bg-dashboard-bg-elevated px-4 py-3 pt-[max(0.75rem,env(safe-area-inset-top))] md:px-5",children:[(0,_e.jsx)("div",{className:"min-w-0 flex-1",children:e.header}),(0,_e.jsxs)("div",{className:"flex shrink-0 items-start gap-1.5",children:[e.actions,(0,_e.jsx)(nn,{render:(0,_e.jsx)(Nr,{ref:t,"aria-label":e.closeLabel,size:"icon"}),children:(0,_e.jsx)(Or,{"aria-hidden":"true",size:15,strokeWidth:2.25})})]})]}),(0,_e.jsx)("div",{className:Zt("min-h-0 flex-1 overflow-auto",e.flush?"pb-[env(safe-area-inset-bottom)]":"px-4 py-4 pb-[max(1rem,env(safe-area-inset-bottom))] md:px-5"),children:e.children})]})})}export{ic as DrawerContent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as O}from"./chunk-UZ44J2LH.js";import{a as l}from"./chunk-PG7M7L24.js";import{a as V}from"./chunk-SUX4QBVF.js";import{a as R,c as B,f as w,o as M,p as $,q as z,r as E,s as G,t as I,w as q,x as H}from"./chunk-K4TYMAA3.js";import{a as u}from"./chunk-TC7TU4GK.js";import"./chunk-UT6HZPGL.js";import{b as N}from"./chunk-J37MXUED.js";import"./chunk-TFJOEF3Q.js";import"./chunk-DEEO4D4N.js";import"./chunk-KDUTK357.js";import{e as f}from"./chunk-564V7YHG.js";import{r as A}from"./chunk-64GPEGGE.js";import"./chunk-ILH47V7O.js";import{K as S,b as p,g as D,r as s,s as P}from"./chunk-II4NXLSQ.js";import"./chunk-GMZIELFU.js";import"./chunk-4TQSTCIN.js";import{Ka as n}from"./chunk-XDUSY26N.js";import"./chunk-QPBLZSNX.js";import"./chunk-RHMZNAJX.js";import"./chunk-GOTQ4D6W.js";import{H as T,M as U,g as b,o as h}from"./chunk-6PHJZPWD.js";import"./chunk-WRXMQB7X.js";import"./chunk-CQY6BYUB.js";import"./chunk-B5ZN3SWQ.js";import{Lc as L,Zb as x,b as m,bc as k,vb as g,xb as C}from"./chunk-YPMUHXYT.js";import{c}from"./chunk-7SZRL6FY.js";var t=c(m(),1);function j(o){let e=o.bucketUnit??"day",r=o.days.map(i=>i.conversations),v=Math.max(1,...r),d=E(r);return(0,t.jsxs)(n,{children:[(0,t.jsx)(O,{description:"Daily persisted conversations for this location.",title:"Conversation activity",trailing:(0,t.jsx)(V,{ariaLabel:"Conversation activity period",inline:!0,items:[{color:"var(--color-cyan-400)",key:"period",label:"90 days"}]})}),(0,t.jsx)("div",{className:"px-2 py-3 sm:px-4 sm:py-4",children:(0,t.jsx)(q,{className:"aspect-auto h-60 w-full",config:{},children:(0,t.jsxs)(w,{"aria-label":"Daily conversations for this location",data:o.days,margin:M,role:"img",children:[(0,t.jsx)("defs",{children:(0,t.jsxs)("linearGradient",{id:"location-bars",x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,t.jsx)("stop",{offset:"0%",stopColor:"var(--color-cyan-400)"}),(0,t.jsx)("stop",{offset:"100%",stopColor:"var(--color-amber-500)",stopOpacity:"0.65"})]})}),(0,t.jsx)(R,{strokeDasharray:"3 5",vertical:!1}),(0,t.jsx)(z,{maximum:v}),(0,t.jsx)($,{keys:o.days.map(i=>i.date)}),(0,t.jsx)(H,{content:(0,t.jsx)(I,{rows:i=>[["conversations",i.conversations],["active",i.active],["failed",i.failed]]})}),(0,t.jsx)(B,{dataKey:"conversations",fill:"url(#location-bars)",fillOpacity:.9,isAnimationActive:!1,maxBarSize:20,minPointSize:i=>i?2:0,radius:2}),(0,t.jsx)(G,{unit:T(e),average:d,format:P,stroke:"var(--color-cyan-400)"})]})})})]})}var a=c(m(),1);function fa(){let o=b(),e=A(o.locationId);return(0,a.jsx)(K,{data:e.data,error:e.error})}function K(o){return!o.data&&!o.error?(0,a.jsx)(u,{children:(0,a.jsx)(N,{label:"Loading location"})}):(0,a.jsxs)(u,{children:[o.error?(0,a.jsx)(n,{padding:"sm",children:(0,a.jsx)(f,{children:o.data?"Location telemetry refresh failed. Showing cached data.":"Location failed to load."})}):null,o.data?(0,a.jsx)(X,{detail:o.data}):null]})}function X(o){let e=o.detail;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(U,{description:`${e.provider} public ${e.kind} / ${e.providerDestinationId} / last active ${D(e.lastSeenAt)}`,title:e.label}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[(0,a.jsx)(l,{detail:"Persisted conversations",icon:k,label:"Conversations",value:s(e.conversations)}),(0,a.jsx)(l,{detail:"Verified people seen here",icon:L,label:"People",value:s(e.actors.length)}),(0,a.jsx)(l,{detail:"Persisted model usage",icon:C,label:"Tokens",value:s(e.tokens??0)}),(0,a.jsx)(l,{detail:"Cumulative conversation runtime",icon:g,label:"Runtime",value:(0,a.jsx)(p,{value:e.durationMs})})]}),(0,a.jsx)(j,{days:e.activityDays}),(0,a.jsxs)(n,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 border-b border-dashboard-border-subtle px-4 py-4",children:[(0,a.jsx)("span",{className:"grid size-9 place-items-center rounded-md border border-dashboard-accent/15 bg-dashboard-accent/[0.06] text-dashboard-accent",children:(0,a.jsx)(x,{"aria-hidden":"true",size:16})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"m-0 font-sans text-xs font-medium text-dashboard-text-muted",children:"People seen here"}),(0,a.jsx)("p",{className:"mt-1 mb-0 font-mono text-xs text-dashboard-text-muted",children:"Verified contributors across persisted conversations."})]})]}),e.actors.length?(0,a.jsx)("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3",children:e.actors.slice(0,9).map((r,v)=>{let d=[r.actor.email,r.actor.slackUserId,r.actor.slackUserName,r.actor.fullName,v].join(":"),i=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"truncate font-display text-base font-medium text-dashboard-text",children:r.label}),(0,a.jsxs)("div",{className:"mt-1 font-mono text-xs text-dashboard-text-muted",children:[s(r.conversations)," conversations /"," ",(0,a.jsx)(p,{value:r.durationMs})]})]}),y="min-w-0 border-b border-r border-dashboard-border-subtle px-4 py-3.5 transition-colors hover:bg-dashboard-fill-soft";return r.actor.email?(0,a.jsx)(h,{className:`${y} text-inherit no-underline`,to:S(r.actor.email),children:i},d):(0,a.jsx)("div",{className:y,children:i},d)})}):(0,a.jsx)("div",{className:"p-4",children:(0,a.jsx)(f,{children:"No verified people have been recorded here."})})]})]})}export{fa as LocationDetailPage,K as LocationDetailPageContent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as tt,b as et,c as at,d as ot,e as L}from"./chunk-UJD3MBMB.js";import{a as Z}from"./chunk-5ISD3QSC.js";import{a as C}from"./chunk-UZ44J2LH.js";import"./chunk-4UGZNVJM.js";import{a as f}from"./chunk-PG7M7L24.js";import{a as Y}from"./chunk-SUX4QBVF.js";import{a as _,c as Q,f as j,o as G,p as V,q as W,t as X,w as F,x as J}from"./chunk-K4TYMAA3.js";import{a as I,b as O}from"./chunk-TC7TU4GK.js";import"./chunk-UT6HZPGL.js";import"./chunk-TFJOEF3Q.js";import"./chunk-DEEO4D4N.js";import"./chunk-KDUTK357.js";import{a as B}from"./chunk-H76B43OQ.js";import{e as g}from"./chunk-564V7YHG.js";import{q as N}from"./chunk-64GPEGGE.js";import"./chunk-ILH47V7O.js";import{M,b as h,g as w,r as l}from"./chunk-II4NXLSQ.js";import"./chunk-GMZIELFU.js";import"./chunk-MEHLQZDG.js";import"./chunk-4TQSTCIN.js";import{Ka as y}from"./chunk-XDUSY26N.js";import"./chunk-QPBLZSNX.js";import{b as E,c as q}from"./chunk-RHMZNAJX.js";import"./chunk-GOTQ4D6W.js";import{G as H,I as U,J as K,K as $,M as z,s as P}from"./chunk-6PHJZPWD.js";import"./chunk-WRXMQB7X.js";import"./chunk-CQY6BYUB.js";import"./chunk-VC6IS564.js";import"./chunk-B5ZN3SWQ.js";import"./chunk-CR2ICLSH.js";import{Kb as R,Wb as p,_b as A,a as vt,b as u,bc as T,vb as D}from"./chunk-YPMUHXYT.js";import{c}from"./chunk-7SZRL6FY.js";var x=c(vt(),1);var r=c(u(),1),S=[{color:"var(--color-cyan-400)",dataKey:"publicConversations",key:"public",label:"public"},{color:"var(--color-amber-400)",dataKey:"privateConversations",key:"private",label:"private"}],bt=Object.fromEntries(S.map(t=>[t.key,{color:t.color,label:t.label}]));function it(t){let o=t.bucketUnit??"day",m=`Conversations per ${U(o)}`,d=Math.max(1,...t.days.flatMap(n=>[n.privateConversations,n.publicConversations]));return(0,r.jsxs)(y,{children:[(0,r.jsx)(C,{description:`${K(o)} public volume compared with private activity in aggregate.`,title:m,trailing:(0,r.jsx)(Y,{ariaLabel:"Conversation visibility legend",inline:!0,items:S})}),(0,r.jsx)("div",{className:"px-2 py-3 sm:px-4 sm:py-4",children:(0,r.jsx)(F,{className:"aspect-auto h-65 w-full",config:bt,children:(0,r.jsxs)(j,{"aria-label":`Public and private ${m.toLowerCase()}`,barGap:2,data:t.days,margin:G,role:"img",children:[(0,r.jsx)(_,{strokeDasharray:"3 5",vertical:!1}),(0,r.jsx)(W,{maximum:d}),(0,r.jsx)(V,{keys:t.days.map(n=>n.date)}),(0,r.jsx)(J,{content:(0,r.jsx)(X,{rows:n=>S.map(i=>[i.label,n[i.dataKey]])})}),S.map(n=>(0,r.jsx)(Q,{dataKey:n.dataKey,fill:`var(--color-${n.key})`,fillOpacity:.85,isAnimationActive:!1,maxBarSize:8,minPointSize:i=>i?2:0,radius:1.5},n.key))]})})})]})}var a=c(u(),1);function rt(t){return(0,a.jsxs)(y,{children:[(0,a.jsx)(C,{description:`${t.locations.length} of ${t.totalLocations} public locations`,title:"Public directory"}),(0,a.jsxs)(tt,{columnsClassName:"md:grid-cols-[minmax(14rem,1fr)_minmax(11rem,15rem)]",children:[(0,a.jsx)(B,{label:"Search locations",placeholder:"Search channel name...",value:t.query,onChange:t.onQueryChange}),(0,a.jsx)(Z,{ariaLabel:"Sort locations",onChange:o=>t.onSortChange(o),options:[{label:"Most conversations",value:"conversations"},{label:"Recently active",value:"recent"},{label:"Most tokens",value:"tokens"},{label:"Most runtime",value:"runtime"}],value:t.sort})]}),(0,a.jsx)(et,{ariaLabel:"Public location directory results",empty:t.locations.length===0?(0,a.jsx)(g,{children:"No public locations match this search."}):void 0,headers:["Location","Conversations","Tokens","Runtime"],loading:t.loading,children:t.locations.map(o=>(0,a.jsxs)(at,{to:M(o.id),children:[(0,a.jsx)(ot,{description:(0,a.jsxs)(a.Fragment,{children:["Last active ",w(o.lastSeenAt)]}),icon:(0,a.jsx)(R,{"aria-hidden":"true",size:16,strokeWidth:1.8}),iconClassName:"bg-dashboard-accent/[0.06] text-dashboard-accent group-hover:border-dashboard-accent/25",title:o.label}),(0,a.jsx)(L,{label:"Conversations",value:l(o.conversations)}),(0,a.jsx)(L,{label:"Tokens",value:l(o.tokens??0)}),(0,a.jsx)(L,{label:"Runtime",value:(0,a.jsx)(h,{value:o.durationMs})})]},o.id))})]})}var s=c(u(),1);function nt(t){return(0,s.jsx)(y,{className:"opacity-80",padding:"sm",children:(0,s.jsxs)("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-3 max-sm:grid-cols-[auto_minmax(0,1fr)]",children:[(0,s.jsx)("span",{className:"grid size-9 shrink-0 place-items-center rounded-md border border-dashboard-border bg-dashboard-fill-soft text-dashboard-text-muted",children:(0,s.jsx)(p,{"aria-hidden":"true",size:15})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("div",{className:"font-display text-base font-medium text-dashboard-text",children:"Private activity"}),(0,s.jsx)("div",{className:"mt-1 font-sans text-xs leading-relaxed text-dashboard-text-muted",children:"DMs, private channels, and unknown visibility stay combined and unlinked."})]}),(0,s.jsxs)("div",{className:"text-right max-sm:col-start-2 max-sm:text-left",children:[(0,s.jsx)("div",{className:"font-display text-2xl font-light text-dashboard-text",children:l(t.item.conversations)}),(0,s.jsx)("div",{className:"font-sans font-medium text-xs text-dashboard-text-muted",children:"conversations"})]})]})})}var e=c(u(),1),ft=["conversations","recent","runtime","tokens"];function oe(){let t=N();return(0,e.jsx)(pt,{data:t.data,error:t.error})}function pt(t){let[o,m]=(0,x.useState)(90),[d,n]=q("sort","conversations",ft),i=(0,x.useDeferredValue)(d),[v,st,ct]=E();if(!t.data&&!t.error)return(0,e.jsx)(O,{description:"Public destinations and their conversation activity.",label:"Loading locations",title:"Locations",variant:"stats"});let lt=ht(t.data?.locations??[],ct,i),mt=t.data?$({days:t.data.activityDays,hours:t.data.activityHours,sixHours:t.data.activitySixHours,range:o,emptySixHour:b=>({date:b,privateConversations:0,publicConversations:0})}):[],dt=H(o),ut=t.data?.locations.reduce((b,k)=>b+k.conversations,0)??0,yt=t.data?.locations.reduce((b,k)=>b+k.durationMs,0)??0;return(0,e.jsxs)(I,{children:[(0,e.jsx)(z,{description:t.error&&!t.data?"Locations failed to load.":`See the public channels where ${P()} has been working and how busy they've been.`,onRangeChange:m,range:o,title:"Locations"}),t.error?(0,e.jsx)(y,{padding:"sm",children:(0,e.jsx)(g,{children:t.data?"Location telemetry refresh failed. Showing cached data.":"Location telemetry is unavailable. Try refreshing the dashboard."})}):null,t.data?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[(0,e.jsx)(f,{detail:"Named public destinations",icon:A,label:"Public locations",value:l(t.data.locations.length)}),(0,e.jsx)(f,{detail:"Across public destinations",icon:T,label:"Conversations",value:l(ut)}),(0,e.jsx)(f,{detail:"Cumulative public runtime",icon:D,label:"Runtime",value:(0,e.jsx)(h,{value:yt})}),(0,e.jsx)(f,{detail:"Combined to preserve privacy",icon:p,label:"Private conversations",value:l(t.data.privateActivity.conversations)})]}),(0,e.jsx)(it,{bucketUnit:dt,days:mt}),(0,e.jsx)(rt,{loading:d!==i,locations:lt,onQueryChange:st,onSortChange:n,query:v,sort:d,totalLocations:t.data.locations.length}),t.data.privateActivity.conversations>0?(0,e.jsx)(nt,{item:t.data.privateActivity}):null]}):null]})}function ht(t,o,m){let d=o.trim().toLowerCase();return[...d?t.filter(i=>i.label.toLowerCase().includes(d)):t].sort((i,v)=>m==="conversations"?v.conversations-i.conversations:m==="runtime"?v.durationMs-i.durationMs:m==="tokens"?(v.tokens??0)-(i.tokens??0):Date.parse(v.lastSeenAt)-Date.parse(i.lastSeenAt))}export{oe as LocationsPage,pt as LocationsPageContent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as d}from"./chunk-DZB4LPI6.js";import"./chunk-L2H3ZWZN.js";import{a as l}from"./chunk-PXHLJIOT.js";import"./chunk-GMZIELFU.js";import"./chunk-QPBLZSNX.js";import"./chunk-RHMZNAJX.js";import"./chunk-GOTQ4D6W.js";import{s as a}from"./chunk-6PHJZPWD.js";import"./chunk-WRXMQB7X.js";import"./chunk-CQY6BYUB.js";import"./chunk-B5ZN3SWQ.js";import"./chunk-CR2ICLSH.js";import{Tc as i,b as s}from"./chunk-YPMUHXYT.js";import{c as n}from"./chunk-7SZRL6FY.js";var e=n(s(),1),c="https://junior.sentry.dev/operate/mcp-server/";function p(){return a().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"junior"}function r(t){return(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)("h2",{className:"m-0 text-sm font-semibold",children:t.label}),(0,e.jsx)(l,{getText:()=>t.value,label:`Copy ${t.label}`})]}),(0,e.jsx)("pre",{className:"mt-2 mb-0 whitespace-pre-wrap break-words rounded-md border border-dashboard-border-emphasis bg-dashboard-ink p-3 font-mono text-xs text-dashboard-text",children:t.value})]})}function v(){let t=new URL("/api/mcp",window.location.origin).toString(),o=p(),m=JSON.stringify({mcpServers:{[o]:{type:"http",url:t}}},null,2);return(0,e.jsxs)(d,{description:(0,e.jsxs)(e.Fragment,{children:["Connect Claude Code or another MCP client to list your"," ",a()," conversations. The client signs in through this dashboard. Personal API tokens do not work here."]}),title:"MCP",children:[(0,e.jsxs)("div",{className:"grid gap-5",children:[(0,e.jsx)(r,{label:"Server URL",value:t}),(0,e.jsx)(r,{label:"Claude Code",value:`claude mcp add --transport http ${o} ${t}`}),(0,e.jsx)(r,{label:"JSON config",value:m})]}),(0,e.jsxs)("p",{className:"m-0 text-sm text-dashboard-text-muted",children:["The client must support OAuth with Client ID Metadata Documents."," ",(0,e.jsx)("a",{className:i,href:c,rel:"noreferrer",target:"_blank",children:"Read the MCP server docs"}),"."]})]})}export{v as McpSettingsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as ye,b as fe,c as ge,d as ve,e as U}from"./chunk-UJD3MBMB.js";import{a as ue}from"./chunk-5ISD3QSC.js";import{a as R}from"./chunk-UZ44J2LH.js";import"./chunk-4UGZNVJM.js";import{a as C}from"./chunk-PG7M7L24.js";import{a as me}from"./chunk-SUX4QBVF.js";import{a as te,b as oe,g as re,o as ae,p as ie,q as ne,r as se,s as le,t as ce,w as pe,x as de}from"./chunk-K4TYMAA3.js";import{a as Z,b as ee}from"./chunk-TC7TU4GK.js";import"./chunk-UT6HZPGL.js";import"./chunk-TFJOEF3Q.js";import"./chunk-DEEO4D4N.js";import"./chunk-KDUTK357.js";import{a as _}from"./chunk-H76B43OQ.js";import{e as b}from"./chunk-564V7YHG.js";import{l as O}from"./chunk-64GPEGGE.js";import"./chunk-ILH47V7O.js";import{K as z,a as I,r as A,s as Q,z as h}from"./chunk-II4NXLSQ.js";import"./chunk-GMZIELFU.js";import"./chunk-MEHLQZDG.js";import"./chunk-4TQSTCIN.js";import{Ka as f}from"./chunk-XDUSY26N.js";import"./chunk-QPBLZSNX.js";import{b as F,c as J}from"./chunk-RHMZNAJX.js";import"./chunk-GOTQ4D6W.js";import{F as D,G as j,H as K,I as V,K as X,M as Y,s as q}from"./chunk-6PHJZPWD.js";import"./chunk-WRXMQB7X.js";import"./chunk-CQY6BYUB.js";import"./chunk-VC6IS564.js";import"./chunk-B5ZN3SWQ.js";import"./chunk-CR2ICLSH.js";import{Ic as W,Kc as H,Lc as B,Rc as G,Ta as $,a as ke,b as v,pb as E}from"./chunk-YPMUHXYT.js";import{c as y}from"./chunk-7SZRL6FY.js";var x=y(ke(),1);var o=y(v(),1);function he(e){let a=e.bucketUnit??"day",s=`Active people per ${V(a)}`,p=e.days.map(c=>c.activePeople),t=Math.max(1,...p),P=se(p),l=e.days.length>30;return(0,o.jsxs)(f,{children:[(0,o.jsx)(R,{description:"Distinct verified actors grouped by recorded conversation activity.",title:s,trailing:(0,o.jsx)(me,{ariaLabel:"People activity legend",inline:!0,items:[{color:"var(--color-amber-400)",key:"people",label:"people"}]})}),(0,o.jsx)("div",{className:"px-2 py-3 sm:px-4 sm:py-4",children:(0,o.jsx)(pe,{className:"aspect-auto h-65 w-full",config:{},children:(0,o.jsxs)(re,{"aria-label":s,data:e.days,margin:ae,role:"img",children:[(0,o.jsxs)("defs",{children:[(0,o.jsxs)("linearGradient",{id:"people-area",x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,o.jsx)("stop",{offset:"0%",stopColor:"var(--color-amber-500)",stopOpacity:"0.3"}),(0,o.jsx)("stop",{offset:"100%",stopColor:"var(--color-amber-500)",stopOpacity:"0"})]}),(0,o.jsxs)("linearGradient",{id:"people-line",x1:"0",x2:"1",y1:"0",y2:"0",children:[(0,o.jsx)("stop",{offset:"0%",stopColor:"var(--color-amber-500)"}),(0,o.jsx)("stop",{offset:"55%",stopColor:"var(--color-amber-400)"}),(0,o.jsx)("stop",{offset:"100%",stopColor:"var(--color-cyan-400)"})]})]}),(0,o.jsx)(te,{strokeDasharray:"3 5",vertical:!1}),(0,o.jsx)(ne,{maximum:t}),(0,o.jsx)(ie,{keys:e.days.map(c=>c.date)}),(0,o.jsx)(de,{content:(0,o.jsx)(ce,{rows:c=>[["active people",c.activePeople],["conversations",c.conversations]]})}),(0,o.jsx)(oe,{activeDot:{fill:"var(--color-amber-400)",r:5},dataKey:"activePeople",dot:{fill:"var(--color-amber-400)",fillOpacity:l?.35:.75,r:l?3:4,stroke:"none"},fill:"url(#people-area)",fillOpacity:1,isAnimationActive:!1,stroke:"url(#people-line)",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,type:"linear"}),(0,o.jsx)(le,{unit:K(a),average:P,format:Q,stroke:"var(--color-amber-400)"})]})})})]})}var n=y(v(),1);function be(e){return e.actor.fullName??e.actor.slackUserName??e.actor.email}function Te(e){return be(e)===e.actor.email?void 0:e.actor.email}function Ne(e,a){return e<=0&&a>0?"unknown":I(e)}function N(e,a){return e.windows[a]}function S(e){return e.costUsd-e.priorCostUsd}function L(e){if(Math.abs(e)<.005)return"$0.00";let a=h({total:Math.abs(e)});return`${e>0?"+":"\u2212"}${a}`}function Ce(e,a,s,p){let t=a.trim().toLowerCase();return[...t?e.filter(l=>[l.actor.email,l.actor.fullName,l.actor.slackUserName].some(c=>c?.toLowerCase().includes(t))):e].sort((l,c)=>{let d=N(l,p),r=N(c,p);return s==="spend"?r.costUsd-d.costUsd||S(r)-S(d)||l.actor.email.localeCompare(c.actor.email):s==="spendDelta"?S(r)-S(d)||r.costUsd-d.costUsd||l.actor.email.localeCompare(c.actor.email):s==="conversations"?r.conversations-d.conversations||r.costUsd-d.costUsd:s==="runtime"?r.durationMs-d.durationMs||r.costUsd-d.costUsd:Date.parse(c.lastSeenAt)-Date.parse(l.lastSeenAt)})}function Se(e){return(0,n.jsxs)(f,{children:[(0,n.jsx)(R,{description:`${e.people.length} of ${e.totalPeople} people`,title:"People directory"}),(0,n.jsxs)(ye,{columnsClassName:"md:grid-cols-[minmax(14rem,1fr)_minmax(10rem,14rem)]",children:[(0,n.jsx)(_,{label:"Search people",placeholder:"Search name, email, Slack handle...",value:e.query,onChange:e.onQueryChange}),(0,n.jsx)(ue,{ariaLabel:"Sort people",onChange:a=>e.onSortChange(a),options:[{label:"Most spend",value:"spend"},{label:"Biggest spend increase",value:"spendDelta"},{label:"Most conversations",value:"conversations"},{label:"Recently active",value:"recent"},{label:"Most runtime",value:"runtime"}],value:e.sort})]}),(0,n.jsx)(fe,{ariaLabel:"People directory results",empty:e.people.length===0?(0,n.jsx)(b,{children:"No people match this search."}):void 0,headers:["Person","Conversations","Spend","Runtime"],loading:e.loading,children:e.people.map(a=>{let s=N(a,e.range),p=S(s);return(0,n.jsxs)(ge,{to:z(a.actor.email),children:[(0,n.jsx)(ve,{description:Te(a),icon:(0,n.jsx)(H,{"aria-hidden":"true",size:16,strokeWidth:1.8}),iconClassName:"bg-amber-500/[0.07] text-amber-300 group-hover:border-amber-500/25",title:be(a)}),(0,n.jsx)(U,{label:"Conversations",value:A(s.conversations)}),(0,n.jsx)(U,{label:"Spend",value:(0,n.jsxs)("span",{className:"inline-flex flex-col items-end gap-1",children:[(0,n.jsx)("span",{className:"whitespace-nowrap",children:h({total:s.costUsd})||"$0.00"}),(0,n.jsx)("span",{className:G("whitespace-nowrap font-mono text-2xs leading-none",Math.abs(p)<.005?"text-dashboard-text-muted":p>0?"text-amber-300/80":"text-cyan-300/75"),children:L(p)})]})}),(0,n.jsx)(U,{label:"Runtime",value:(0,n.jsx)("span",{className:"whitespace-nowrap",children:Ne(s.durationMs,s.conversations)})})]},a.actor.email)})})]})}var i=y(v(),1),Le=["spend","spendDelta","conversations","recent","runtime"];function Pe(e){return e.actor.fullName??e.actor.slackUserName??e.actor.email}function yt(){let e=O();return(0,i.jsx)(Me,{data:e.data,error:e.error})}function Me(e){let[a,s,p]=F(),[t,P]=(0,x.useState)(7),[l,c]=J("sort","spend",Le),d=(0,x.useDeferredValue)(l);if(!e.data&&!e.error)return(0,i.jsx)(ee,{description:"People, activity, and model spend.",label:"Loading people",title:"People",variant:"stats"});let r=e.data,we=r?X({days:r.activityDays,hours:r.activityHours,sixHours:r.activitySixHours,range:t,emptySixHour:m=>({activePeople:0,conversations:0,date:m})}):[],Ae=j(t),De=r?Ce(r.people,p,d,t):[],Re=r?.people.filter(m=>m.windows[t].conversations>0).length??0,Ue=r?.people.reduce((m,u)=>m+u.windows[t].costUsd,0)??0,w=r?.people.reduce((m,u)=>m?u.windows[t].costUsd>m.windows[t].costUsd?u:m:u,void 0),g=r?.people.reduce((m,u)=>{let M=u.windows[t].costUsd-u.windows[t].priorCostUsd;if(!m)return M>0?u:void 0;let xe=m.windows[t].costUsd-m.windows[t].priorCostUsd;return M>xe?u:m},void 0),k=w?.windows[t].costUsd??0,T=g?g.windows[t].costUsd-g.windows[t].priorCostUsd:0;return(0,i.jsxs)(Z,{children:[(0,i.jsx)(Y,{description:e.error?"People failed to load.":`Who used ${q()} in the ${D(t)}, and how spend changed from the prior period.`,onRangeChange:P,range:t,title:"People"}),e.error?(0,i.jsx)(f,{padding:"md",children:(0,i.jsx)(b,{children:"People telemetry is unavailable. Try refreshing the dashboard."})}):r?.people.length?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[(0,i.jsx)(C,{detail:`People with activity in the ${D(t)}`,icon:B,label:"Active people",value:A(Re)}),(0,i.jsx)(C,{detail:`Estimated model cost in the ${D(t)}`,icon:E,label:"Model spend",value:h({total:Ue})||"$0.00"}),(0,i.jsx)(C,{detail:w&&k>0?Pe(w):"No spend in this range",icon:$,label:"Highest spend",value:w&&k>0?h({total:k})||"$0.00":"\u2014"}),(0,i.jsx)(C,{detail:g&&T>0?`${Pe(g)} vs prior period`:"No spend increases in this range",icon:W,label:"Biggest increase",value:g&&T>0?L(T):"\u2014"})]}),(0,i.jsx)(he,{bucketUnit:Ae,days:we}),(0,i.jsx)(Se,{loading:l!==d,onQueryChange:s,onSortChange:c,people:De,query:a,range:t,sort:l,totalPeople:r.people.length})]}):(0,i.jsx)(f,{padding:"md",children:(0,i.jsx)(b,{children:"No actor telemetry with trusted email."})})]})}export{yt as PeoplePage,Me as PeoplePageContent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as oe,b as ie,c as ne}from"./chunk-NGQRNS3C.js";import"./chunk-H2ZU34CP.js";import{a as L}from"./chunk-4UGZNVJM.js";import{a as k,b as A}from"./chunk-LBELRO5P.js";import{b as $}from"./chunk-2J3LGF5Q.js";import{a as re,b as ae}from"./chunk-ONDKE72P.js";import{a as h}from"./chunk-PG7M7L24.js";import"./chunk-SUX4QBVF.js";import{u as te}from"./chunk-K4TYMAA3.js";import{b as j}from"./chunk-J37MXUED.js";import{a as N}from"./chunk-L2H3ZWZN.js";import"./chunk-LKW7MULF.js";import"./chunk-6FSJ3W2W.js";import"./chunk-2BCS5AQL.js";import"./chunk-QOX5RMLM.js";import"./chunk-H76B43OQ.js";import{e as P}from"./chunk-564V7YHG.js";import{m as W,n as V,o as Y}from"./chunk-64GPEGGE.js";import"./chunk-ILH47V7O.js";import{a as C,b as K,r as f,z as R}from"./chunk-II4NXLSQ.js";import{i as Z,j as z,l as q,m as Q}from"./chunk-GMZIELFU.js";import"./chunk-MEHLQZDG.js";import"./chunk-4TQSTCIN.js";import{Ka as y}from"./chunk-XDUSY26N.js";import{a as ee}from"./chunk-GOTQ4D6W.js";import{G as w,K as D,M as X,g as U,o as E,s as J}from"./chunk-6PHJZPWD.js";import"./chunk-IZWTFLCC.js";import"./chunk-JAZABOBA.js";import"./chunk-WRXMQB7X.js";import"./chunk-CQY6BYUB.js";import"./chunk-VC6IS564.js";import"./chunk-B5ZN3SWQ.js";import"./chunk-CR2ICLSH.js";import{Gc as F,Jb as I,Rb as B,Rc as x,Xa as O,a as _,b as v,bc as G,vb as H,xb as T}from"./chunk-YPMUHXYT.js";import{c as p}from"./chunk-7SZRL6FY.js";var ge=p(_(),1);var l=p(v(),1);function le(e){let r=Math.max(1,...e.days.map(i=>i.conversations)),a=[],o=e.days[0]?new Date(`${e.days[0].date}T00:00:00Z`).getUTCDay():0,m=[...Array.from({length:o},()=>null),...e.days];for(;m.length>0&&m.length%7!==0;)m.push(null);for(let i=0;i<m.length;i+=7){let u=m.slice(i,i+7);for(;u.length<7;)u.push(null);a.push(u)}a.length===0&&a.push([null,null,null,null,null,null,null]);let d=a.map((i,u)=>{let s=i.find(Boolean);if(!s)return"";let n=u>0?a[u-1]:void 0,S=n?[...n].reverse().find(Boolean):void 0;return S&&S.date.slice(0,7)===s.date.slice(0,7)?"":new Date(`${s.date}T00:00:00Z`).toLocaleString(void 0,{month:"short",timeZone:"UTC"})});return(0,l.jsx)("div",{className:"overflow-x-auto px-4 py-4",children:(0,l.jsxs)("div",{className:"min-w-[36rem]",children:[(0,l.jsx)("div",{"aria-hidden":"true",className:"mb-1 grid gap-1 text-xs font-semibold leading-none text-dashboard-text-muted",style:{gridTemplateColumns:`repeat(${a.length}, minmax(0.75rem, 1fr))`},children:d.map((i,u)=>(0,l.jsx)("div",{className:"h-3 overflow-visible",children:i},`${i}-${u}`))}),(0,l.jsx)("div",{"aria-label":`Daily ${J()} conversation activity`,className:"grid w-full grid-flow-col grid-rows-7 gap-1",role:"list",style:{gridTemplateColumns:`repeat(${a.length}, minmax(0.75rem, 1fr))`},children:a.flatMap((i,u)=>i.map((s,n)=>s?(0,l.jsxs)(Z,{children:[(0,l.jsx)(z,{render:(0,l.jsx)("span",{"aria-label":`${s.date}: ${s.conversations} conversations, ${se(s)}, ${R({total:s.costUsd??0})} spend, ${f(s.tokens??0)} tokens`,className:x("size-3 border border-dashboard-overlay outline-none focus-visible:ring-2 focus-visible:ring-dashboard-focus",pe(s.conversations,r)),role:"listitem",tabIndex:0})}),(0,l.jsxs)(q,{children:[(0,l.jsx)(Q,{children:ue(s.date)}),(0,l.jsx)(te,{rows:[["conversations",s.conversations],["runtime",se(s)],["spend",R({total:s.costUsd??0})],["tokens",f(s.tokens??0)]]})]})]},s.date):(0,l.jsx)("span",{"aria-hidden":"true",className:"size-3 border border-dashboard-overlay bg-dashboard-surface-raised"},`empty-${u}-${n}`)))}),(0,l.jsxs)("div",{className:"mt-3 flex items-center gap-1 text-xs font-semibold leading-none text-dashboard-text-muted",children:[(0,l.jsx)("span",{children:"Less"}),[0,1,2,3,4].map(i=>(0,l.jsx)("span",{"aria-hidden":"true",className:x("size-3 border border-dashboard-overlay",i===0&&"bg-dashboard-surface-hover",i===1&&"bg-[#133225] light:bg-[#9be9a8]",i===2&&"bg-[#176a4a] light:bg-[#40c463]",i===3&&"bg-[#22a06b] light:bg-[#30a14e]",i===4&&"bg-[#8bdc97] light:bg-[#216e39]")},i)),(0,l.jsx)("span",{children:"More"})]})]})})}function ue(e){return new Date(`${e}T00:00:00Z`).toLocaleDateString(void 0,{day:"numeric",month:"short",timeZone:"UTC",year:"numeric"})}function se(e){return e.durationMs<=0&&e.conversations>0?"unknown":C(e.durationMs)}function pe(e,r){if(e<=0)return"bg-dashboard-surface-hover";let a=e/r;return a>=.75?"bg-[#8bdc97] light:bg-[#216e39]":a>=.45?"bg-[#22a06b] light:bg-[#30a14e]":a>=.2?"bg-[#176a4a] light:bg-[#40c463]":"bg-[#133225] light:bg-[#9be9a8]"}var M=p(_(),1);var c=p(v(),1),fe=1440*60*1e3,be=[{label:"Open",value:"open"},{label:"Merged",value:"merged"},{label:"Closed",value:"closed"},{label:"All",value:""}],ve=[{label:"Any time",value:""},{label:"Last 24 hours",value:"1"},{label:"Last 7 days",value:"7"},{label:"Last 30 days",value:"30"},{label:"Last 90 days",value:"90"}];function de(e){let[r,a]=(0,M.useState)("open"),[o,m]=(0,M.useState)(""),d=o?Date.parse(e.generatedAt)-Number(o)*fe:void 0,i=e.changes.filter(n=>d===void 0||Date.parse(n.openedAt)>=d),u=i.filter(n=>!r||n.state===r),s=n=>n?i.filter(S=>S.state===n).length:i.length;return(0,c.jsxs)(y,{as:"section",children:[(0,c.jsxs)("div",{className:"flex flex-wrap items-end justify-between gap-4 border-b border-dashboard-border-subtle px-4 py-3",children:[(0,c.jsx)("div",{className:"font-display text-lg text-dashboard-text",children:"Recent changes"}),(0,c.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,c.jsx)($,{className:"w-36",label:"State",children:(0,c.jsx)(L,{"aria-label":"Filter changes by state",onChange:n=>a(n.currentTarget.value),value:r,children:be.map(n=>(0,c.jsxs)("option",{value:n.value,children:[n.label," (",s(n.value),")"]},n.value))})}),(0,c.jsx)($,{className:"w-36",label:"Opened",children:(0,c.jsx)(L,{"aria-label":"Filter changes by opened date",onChange:n=>m(n.currentTarget.value),value:o,children:ve.map(n=>(0,c.jsx)("option",{value:n.value,children:n.label},n.value))})})]})]}),u.length>0?(0,c.jsx)("div",{children:u.map(n=>(0,c.jsx)(ae,{change:n},n.id))}):(0,c.jsx)("div",{className:"p-4",children:(0,c.jsx)(P,{children:r&&i.length>0?`No ${r} changes. Set State to All to see ${i.length} more.`:"No changes match these filters."})})]})}var b=p(v(),1);function he(e){return e===void 0?"\u2014":`${Math.round(e*100)}%`}function ye(e){return C(e)||"\u2014"}function xe(e){return R(e===void 0?void 0:{total:e})||"\u2014"}function Ce(e){let r=e.summary;return e.changes.length>0||r.created+r.merged+r.closed>0||(r.costUsd??0)>0||e.activityDays.some(a=>a.created+a.merged+a.closed>0)}function me(e){if(!Ce(e.report))return null;let r=e.report.summary;return(0,b.jsxs)("section",{"aria-labelledby":"profile-code-title",className:"grid gap-4",children:[(0,b.jsx)(N,{id:"profile-code-title",title:"Code"}),(0,b.jsxs)("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[(0,b.jsx)(h,{detail:"In the last 30 days",icon:I,label:"Created",value:f(r.created)}),(0,b.jsx)(h,{detail:"Share of completed changes that merged",icon:B,label:"Merge rate",value:he(r.mergeRate)}),(0,b.jsx)(h,{detail:"Median time from open to merge in the last 30 days",icon:F,label:"Median merge time",value:ye(r.medianMergeTimeMs)}),(0,b.jsx)(h,{detail:"Conversation cost for changes opened in the last 30 days",icon:T,label:"Cost",value:xe(r.costUsd)})]}),(0,b.jsx)(re,{bucketUnit:w(e.range),days:D({days:e.report.activityDays,hours:e.report.activityHours,sixHours:e.report.activitySixHours,range:e.range,emptySixHour:a=>({closed:0,created:0,date:a,merged:0})}),range:e.range}),e.report.changes.length>0?(0,b.jsx)(de,{changes:e.report.changes,generatedAt:e.report.generatedAt}):null]})}var g=p(v(),1);function ce(e){return e.reports.length===0?null:(0,g.jsx)(g.Fragment,{children:e.reports.map(r=>(0,g.jsx)(Ne,{range:e.range,report:r},r.pluginName))})}function Ne(e){let r=e.report.title&&e.report.title!==e.report.pluginName?e.report.title:e.report.pluginName,a=e.report.metrics??[],o=e.report.widgets??[],m=e.report.recordSets??[];return!a.length&&!o.length&&!m.length?null:(0,g.jsxs)("section",{"aria-labelledby":`profile-plugin-${e.report.pluginName}-title`,className:"grid gap-4",children:[(0,g.jsx)(N,{id:`profile-plugin-${e.report.pluginName}-title`,title:r}),a.length?(0,g.jsx)("div",{className:x("grid gap-px overflow-hidden rounded-md border border-dashboard-border bg-dashboard-fill-hover",a.length===1?"grid-cols-1":"grid-cols-2",a.length===3?"lg:grid-cols-3":a.length===5?"lg:grid-cols-5":a.length>=4?"lg:grid-cols-4":void 0),children:a.map(d=>(0,g.jsxs)("div",{className:x("min-w-0 bg-dashboard-surface-panel px-4 py-4",a.length>1&&a.length%2===1&&"last:col-span-2 lg:last:col-span-1",Re(d.tone)),children:[(0,g.jsx)("div",{className:"truncate font-display text-2xl font-light leading-none text-dashboard-text",children:d.value}),(0,g.jsx)("div",{className:"mt-2 font-sans font-medium text-xs text-dashboard-text-muted",children:d.label})]},d.label))}):null,o.length?(0,g.jsx)("div",{className:x("grid gap-3",o.length>1?"lg:grid-cols-2":void 0),children:o.map(d=>(0,g.jsx)(ie,{range:e.range,widget:d},d.id))}):null,m.map(d=>(0,g.jsx)(ne,{recordSet:d},`${e.report.pluginName}:${d.title}`))]})}function Re(e){if(e==="danger")return"shadow-[inset_0_2px_0_rgba(251,113,133,0.65)]";if(e==="warning")return"shadow-[inset_0_2px_0_rgba(251,191,36,0.65)]";if(e==="good")return"shadow-[inset_0_2px_0_rgba(110,231,183,0.55)]"}var t=p(v(),1);function Se(e,r){return e<=0&&r>0?"unknown":C(e)}function yt(){let e=U(),r=e.email?decodeURIComponent(e.email):void 0,a=W(r),o=V(r),m=Y(r);return!a.data&&!a.error?(0,t.jsx)(j,{label:"Loading profile"}):(0,t.jsx)(ee,{children:a.data?(0,t.jsx)(Te,{code:m.data,codeError:!!m.error,codeLoading:m.isPending,pluginReports:o.data?.reports??[],pluginReportsError:!!o.error,pluginReportsLoading:o.isPending,profile:a.data}):(0,t.jsx)(y,{padding:"md",children:(0,t.jsx)(P,{children:"Profile failed to load."})})})}function Te(e){let[r,a]=(0,ge.useState)(30),o=e.profile,m=e.pluginReports??[],d=o.actor.fullName??o.actor.slackUserName??o.actor.email;return(0,t.jsxs)("div",{className:"grid min-w-0 gap-5",children:[(0,t.jsxs)(E,{className:"flex w-fit items-center gap-2 font-display text-sm font-medium text-dashboard-text-muted no-underline transition-colors hover:text-dashboard-text",to:"/system/people",children:[(0,t.jsx)(O,{"aria-hidden":"true",size:15,strokeWidth:1.8}),"Back to people"]}),(0,t.jsx)(X,{description:(0,t.jsxs)(t.Fragment,{children:[o.actor.email,o.actor.slackUserName?` / @${o.actor.slackUserName}`:""]}),onRangeChange:a,range:r,title:d}),(0,t.jsxs)("section",{className:"grid gap-4","aria-labelledby":"profile-metrics-title",children:[(0,t.jsx)(N,{id:"profile-metrics-title",title:"Usage over time"}),(0,t.jsx)(oe,{bucketUnit:w(r),days:D({days:o.activityDays,hours:o.activityHours,sixHours:o.activitySixHours,range:r,emptySixHour:i=>({active:0,conversations:0,date:i,durationMs:0,failed:0})})})]}),e.codeError?(0,t.jsx)(y,{className:"border-amber-300/10 bg-amber-300/[0.025]",padding:"sm",children:(0,t.jsx)("div",{className:"font-display text-sm font-medium text-dashboard-text-muted",children:"Code activity failed to load."})}):null,!e.codeLoading&&e.code?(0,t.jsx)(me,{range:r,report:e.code}):null,e.pluginReportsError?(0,t.jsx)(y,{className:"border-amber-300/10 bg-amber-300/[0.025]",padding:"sm",children:(0,t.jsx)("div",{className:"font-display text-sm font-medium text-dashboard-text-muted",children:"Plugin activity failed to load."})}):null,e.pluginReportsLoading?null:(0,t.jsx)(ce,{range:r,reports:m}),(0,t.jsxs)("div",{className:"grid min-w-0 gap-5 lg:grid-cols-[minmax(0,1fr)_19rem] lg:items-start",children:[(0,t.jsx)("aside",{className:"grid min-w-0 gap-4 lg:order-2",children:(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3 lg:grid-cols-1",children:[(0,t.jsx)(h,{detail:"Across the complete conversation index",icon:G,label:"Conversations",value:f(o.totals.conversations)}),(0,t.jsx)(h,{detail:"Cumulative persisted conversation runtime",icon:H,label:"Runtime",value:(0,t.jsx)(K,{value:o.totals.durationMs})}),(0,t.jsx)(h,{detail:"Persisted model token usage",icon:T,label:"Tokens",value:f(o.totals.tokens??0)})]})}),(0,t.jsxs)("div",{className:"grid min-w-0 gap-5 lg:order-1",children:[(0,t.jsxs)(y,{as:"section",className:"mb-0",variant:"section",children:[(0,t.jsx)(k,{actions:(0,t.jsx)("div",{className:"font-sans font-medium text-xs text-dashboard-text-muted",children:"52 weeks"}),children:(0,t.jsx)(A,{children:"Activity"})}),(0,t.jsx)(le,{days:o.activityDays})]}),(0,t.jsx)(Pe,{items:o.surfaces,title:"Surfaces"})]})]})]})}function Pe(e){return e.items.length<=1?null:(0,t.jsxs)(y,{as:"section",className:"mb-0",variant:"section",children:[(0,t.jsx)(k,{children:(0,t.jsx)(A,{children:e.title})}),(0,t.jsx)("ol",{className:"m-0 list-none p-0",children:e.items.slice(0,6).map((r,a)=>(0,t.jsxs)("li",{className:"grid min-w-0 grid-cols-[2rem_minmax(0,1fr)_auto] items-center gap-3 border-b border-dashboard-border-subtle px-4 py-3 last:border-b-0",children:[(0,t.jsx)("div",{className:"font-mono text-xs leading-none text-dashboard-text-muted",children:a+1}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"truncate font-display text-base font-medium leading-tight text-dashboard-text",children:r.label}),(0,t.jsxs)("div",{className:"mt-1 truncate font-mono text-xs leading-tight text-dashboard-text-muted",children:[Se(r.durationMs,r.conversations),r.tokens?` / ${f(r.tokens)} tokens`:"",r.failed?` / ${f(r.failed)} errors`:""]})]}),(0,t.jsx)("div",{className:"font-display text-xl font-light leading-none text-dashboard-text",children:f(r.conversations)})]},r.label))})]})}export{yt as PersonProfilePage,Te as Profile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as q}from"./chunk-XNR4RZEC.js";import{a as B}from"./chunk-DZB4LPI6.js";import"./chunk-L2H3ZWZN.js";import{l as R}from"./chunk-MEHLQZDG.js";import"./chunk-MTBUV2GJ.js";import{d as v,g as C,i as g,r as E,t as L,v as M}from"./chunk-4TQSTCIN.js";import{Ka as D,ya as w,za as A}from"./chunk-XDUSY26N.js";import"./chunk-QPBLZSNX.js";import"./chunk-RHMZNAJX.js";import"./chunk-GOTQ4D6W.js";import{s as Q}from"./chunk-6PHJZPWD.js";import"./chunk-VC6IS564.js";import"./chunk-B5ZN3SWQ.js";import{b as i}from"./chunk-CR2ICLSH.js";import{Hc as S,Pb as I,a as z,b as N}from"./chunk-YPMUHXYT.js";import{c as f}from"./chunk-7SZRL6FY.js";var l=f(z(),1);var e=f(N(),1),d=["dashboard","personal-tokens"];function X(){let m=v(),c=(0,l.useRef)(!1),[u,y]=(0,l.useState)("Local agent"),o=()=>m.cancelQueries({exact:!0,queryKey:d}),n=C({queryKey:d,queryFn:({signal:t})=>M(w,"/api/personal-tokens",t),retry:!1}),a=g({gcTime:0,mutationFn:t=>E(A,"/api/personal-tokens",{name:t}),onMutate:()=>o(),onSuccess:async t=>{let{token:p,...r}=t;await o(),m.setQueryData(d,k=>({tokens:[r,...(k?.tokens??[]).filter(K=>K.id!==r.id)]}))},onSettled:()=>{c.current=!1}}),s=g({mutationFn:t=>L(`/api/personal-tokens/${encodeURIComponent(t.id)}`),onMutate:()=>o(),onSuccess:async(t,p)=>{await o(),m.setQueryData(d,r=>({tokens:(r?.tokens??[]).filter(k=>k.id!==p.id)})),a.data?.id===p.id&&a.reset()}}),b=a.data,x=n.data?.tokens??[],h=n.isPending,T=a.isPending||s.isPending,P=(a.isError?"Could not create the API token. Try again.":s.isError?"Could not revoke the API token. Try again.":void 0)??(!n.data&&n.isError?"Could not load API tokens. Try again.":void 0);return(0,e.jsxs)(B,{description:(0,e.jsxs)(e.Fragment,{children:["Use a token to read ",Q()," APIs from a local agent or script. Tokens expire after 90 days."]}),title:"API Tokens",children:[b?(0,e.jsxs)("div",{className:"rounded-md border border-emerald-400/40 bg-emerald-400/5 p-3",children:[(0,e.jsx)("p",{className:"mt-0 mb-2 text-sm font-semibold",children:"Copy this token now. It won't be shown again."}),(0,e.jsx)("code",{className:"block overflow-x-auto rounded-md bg-dashboard-ink p-2 text-xs text-emerald-300",children:b.token}),(0,e.jsx)(i,{className:"mt-3",onClick:()=>{a.reset(),y("Local agent")},children:"Create another token"})]}):(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)(R,{"aria-label":"Token name",className:"min-w-0 flex-1",maxLength:80,onChange:t=>y(t.target.value),value:u}),(0,e.jsx)(i,{disabled:h||T||!u.trim(),onClick:()=>{c.current||(s.reset(),c.current=!0,a.mutate(u))},children:"Create token"})]}),P?(0,e.jsx)(q,{children:P}):null,(0,e.jsx)(D,{className:"mb-0",variant:"raised",children:h?(0,e.jsx)("p",{className:"m-0 p-5 text-sm text-dashboard-text-muted",children:"Loading API tokens\u2026"}):x.length===0?(0,e.jsx)("p",{className:"m-0 p-5 text-sm text-dashboard-text-muted",children:"No active API tokens."}):(0,e.jsx)("ul",{className:"m-0 list-none divide-y divide-dashboard-border-subtle p-0",children:x.map(t=>(0,e.jsxs)("li",{className:"flex items-center gap-3 px-5 py-4",children:[(0,e.jsx)(I,{className:"text-dashboard-accent",size:16}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsx)("p",{className:"m-0 truncate text-sm font-semibold",children:t.name}),(0,e.jsxs)("p",{className:"mt-1 mb-0 text-xs text-dashboard-text-muted",children:["Ends in ",t.tokenSuffix," \xB7 Expires"," ",new Date(t.expiresAt).toLocaleDateString()]})]}),(0,e.jsx)(i,{"aria-label":`Revoke ${t.name}`,disabled:T,onClick:()=>{a.isError&&a.reset(),s.mutate(t)},size:"icon",variant:"danger",type:"button",children:(0,e.jsx)(S,{size:16})})]},t.id))})})]})}export{X as PersonalTokensPage};
|