import{j as e,L as D,y as E}from"./vendor-tanstack-BpuysabX.js";import{q as R,I as i,y,H as C,B as T,g as w,h as x,bD as I,bQ as L,bS as S,aD as B,aE as M,aF as p,aG as h,bV as O,C as V,o as F,dR as d,dS as k}from"./index-CREafGO4.js";import"./automation-schema-DnZvg-v_.js";import"./form-DC8L1tSC.js";import"./radio-group-B1MsDBBw.js";import{f as z}from"./event-to-trigger-BEzU9b5I.js";import{D as P,a as A,b as J,d as j}from"./dropdown-menu-DZExFL3b.js";import{f as Q,J as _}from"./utilities-jhOD1qvX.js";import{E as G,p as H,a as U,b as q,R as Y}from"./event-resource-display-OGxgrdzt.js";import{f as Z}from"./vendor-date-C1t37jsh.js";import"./vendor-radix-DIu41Ss_.js";import"./vendor-recharts-C2XeLr4O.js";import"./vendor-forms-Buh7U8Ay.js";function K({event:s}){const r=()=>{navigator.clipboard.writeText(s.id),y.success("ID copied")};return e.jsxs(P,{children:[e.jsx(A,{asChild:!0,children:e.jsxs(R,{variant:"outline",className:"size-8 p-0","aria-label":"Event actions",children:[e.jsx("span",{className:"sr-only",children:"Open menu"}),e.jsx(i,{id:"MoreVertical",className:"size-4"})]})}),e.jsxs(J,{align:"end",children:[e.jsx(D,{to:"/automations/create",search:{eventId:s.id,eventDate:z(s.occurred)},children:e.jsxs(j,{children:[e.jsx(i,{id:"Zap",className:"mr-2 size-4"}),"Automate"]})}),e.jsxs(j,{onClick:r,children:[e.jsx(i,{id:"Copy",className:"mr-2 size-4"}),"Copy ID"]})]})]})}const u=({children:s})=>e.jsx("dt",{className:"text-sm font-medium",children:s}),f=({children:s})=>e.jsx("dd",{className:"text-sm",children:s});function g(s){return s["prefect.resource.role"]||null}function v(s){return s["prefect.resource.id"]||""}function W(s){return s["prefect.resource.name"]||s["prefect.name"]||s["prefect-cloud.name"]||null}function X({event:s}){const r=Z(new Date(s.occurred),"yyyy/MM/dd hh:mm:ss a"),n=(s.related??[]).filter(a=>g(a)!=="tag"),c=(s.related??[]).filter(a=>g(a)==="tag");return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("dl",{children:[e.jsx(u,{children:"Event"}),e.jsx(f,{children:s.event})]}),e.jsxs("dl",{children:[e.jsx(u,{children:"Occurred"}),e.jsx(f,{children:r})]}),e.jsx(G,{event:s}),(n.length>0||c.length>0)&&e.jsxs("dl",{children:[e.jsx(u,{children:"Related Resources"}),e.jsxs("dd",{className:"flex flex-col gap-2 text-sm",children:[n.map(a=>{const t=v(a),l=W(a),o=H(t),b=Y[o],m=q[o],N=l||t.split(".").pop()||t;return e.jsxs(U,{resource:a,relatedResources:s.related??[],className:"flex items-center gap-2 hover:underline",children:[m&&e.jsx("span",{children:m}),e.jsx(i,{id:b,className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:N})]},t)}),c.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{children:"Tags"}),c.map(a=>{const t=v(a),l=t.split(".").pop()||t;return e.jsx(C,{variant:"secondary",children:l},t)})]})]})]})]})}function $({event:s}){const r=Q(s.event);return e.jsx(T,{children:e.jsxs(w,{children:[e.jsx(x,{children:e.jsx(I,{to:"/events",className:"text-xl font-semibold",children:"Event Feed"})}),e.jsx(L,{}),e.jsx(x,{className:"text-xl font-semibold",children:e.jsx(S,{children:r})})]})})}function ee({event:s,defaultTab:r="details",onTabChange:n}){return e.jsxs(B,{defaultValue:r,onValueChange:n,children:[e.jsxs(M,{children:[e.jsx(p,{value:"details",children:"Details"}),e.jsx(p,{value:"raw",children:"Raw"})]}),e.jsx(h,{value:"details",className:"pt-4",children:e.jsx(X,{event:s})}),e.jsx(h,{value:"raw",className:"pt-4",children:e.jsx(_,{value:JSON.stringify(s,null,2),className:"max-h-[600px] overflow-auto"})})]})}function se({eventId:s,eventDate:r,defaultTab:n,onTabChange:c}){const{data:a}=E(O(s,r));return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx($,{event:a}),e.jsx(K,{event:a})]}),e.jsx(V,{children:e.jsx(F,{children:e.jsx(ee,{event:a,defaultTab:n,onTabChange:c})})})]})}const he=function(){const{eventDate:r,eventId:n}=d.useParams(),c=d.useSearch(),a=d.useNavigate(),t=k(r),l=o=>{a({to:".",search:{tab:o},replace:!0})};return e.jsx(se,{eventId:n,eventDate:t,defaultTab:c.tab,onTabChange:l})};export{he as component};
//# sourceMappingURL=event._eventDate._eventId-CsNQtpre.js.map
