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