1import{R as W,M as fe,a as xe,r as i,v as S,T as Ee,j as e,C as Ie,af as Pe,b as Ce,a5 as de,J as x,ap as qe}from"./CgBZl8m0.production.bundle.min.js";import{gp as Oe,gq as Me,c4 as n,gr as Le,gs as Re,u as be,gt as He,gu as we,gv as Be,gw as Ye,gx as Fe,e$ as Ge,gy as ze,r as $,gz as ue,gA as me,gB as Ue,gC as Ve,gD as Ke,gE as $e,gF as We,gG as Je,gH as Ze,bm as Qe,a as Xe}from"./CY9JcdZ7.production.bundle.min.js";import{G as et}from"./DYxQq3CM.production.bundle.min.js";import{P as A,D as j}from"./CHbJgqnE.production.bundle.min.js";import{ao as tt,ap as rt,aa as st}from"./DpOFvyFl.production.bundle.min.js";import{u as je,s as pe}from"./CUU-sqeu.production.bundle.min.js";import{c as at}from"./BpQvVIpM.production.bundle.min.js";import{a as it,S as U,b as ot,c as nt}from"./uYRgXL5M.production.bundle.min.js";import{u as E}from"./BWr4BVpJ.production.bundle.min.js";import{A as lt}from"./CuBqghHU.production.bundle.min.js";import{B as C}from"./B7jgtT_H.production.bundle.min.js";import{M as ge,U as he,e as ct}from"./BFsIcxdk.production.bundle.min.js";import{A as b}from"./D4lvmK5r.production.bundle.min.js";import{T as dt}from"./CHbz8HD7.production.bundle.min.js";import{u as ut}from"./bQk04zL4.production.bundle.min.js";import{T}from"./BhEpiGZx.production.bundle.min.js";import{A as mt}from"./CK-5Vo_r.production.bundle.min.js";import{b as pt}from"./BtDovqOx.production.bundle.min.js";import{G as gt}from"./PSw9bd14.production.bundle.min.js";import{b as ht,D as yt}from"./BEMZOgku.production.bundle.min.js";import{c as ft,A as xt}from"./CB7Wa2F8.production.bundle.min.js";import{A as Ct}from"./CrsULzDT.production.bundle.min.js";import{E as ye,D as bt,P as jt}from"./9zG8c1d8.production.bundle.min.js";import"./BTOj8ijf.production.bundle.min.js";import"./IimQW1M7.production.bundle.min.js";import"./CJLuAe4t.production.bundle.min.js";import"./Dsqj8S3w.production.bundle.min.js";import"./B_v3Fv2u.production.bundle.min.js";import"./BS0dGend.production.bundle.min.js";import"./BKtnA6hw.production.bundle.min.js";import"./BaeVAzEX.production.bundle.min.js";import"./Czbq-YEj.production.bundle.min.js";import"./C7aKDdDU.production.bundle.min.js";import"./BOFlCg2s.production.bundle.min.js";import"./M_FBjfQJ.production.bundle.min.js";import"./DhCfBX8j.production.bundle.min.js";import"./DohGM9_I.production.bundle.min.js";import"./Czj00ZrM.production.bundle.min.js";import"./vhNSgALD.production.bundle.min.js";import"./DvJkqRNe.production.bundle.min.js";import"./DuMSlPdM.production.bundle.min.js";import"./DV0DPFOt.production.bundle.min.js";import"./URTTg1rg.production.bundle.min.js";import"./CMxhj3GZ.production.bundle.min.js";import"./CIT-tl5U.production.bundle.min.js";import"./DnFKFUTo.production.bundle.min.js";import"./DlG3g9Q4.production.bundle.min.js";import"./BZwPEnwo.production.bundle.min.js";import"./CRSxynHN.production.bundle.min.js";import"./_LyuCvYL.production.bundle.min.js";import"./DnQqxH0F.production.bundle.min.js";import"./BAUftK01.production.bundle.min.js";import"./D4liyLd7.production.bundle.min.js";import"./DVYtYn_y.production.bundle.min.js";import"./v06WTCWU.production.bundle.min.js";import"./s2Tdj82o.production.bundle.min.js";import"./CzFgFX4I.production.bundle.min.js";import"./ss4v-xya.production.bundle.min.js";import"./D7jmmEF8.production.bundle.min.js";import"./DZSwJOZ8.production.bundle.min.js";import"./CubUk89f.production.bundle.min.js";import"./TBBi_2Zt.production.bundle.min.js";import"./BT9t0rec.production.bundle.min.js";import"./DgyXvJj2.production.bundle.min.js";import"./BRSgmdt8.production.bundle.min.js";import"./BtqAHeQv.production.bundle.min.js";import"./C4n433b4.production.bundle.min.js";import"./_LslFAjq.production.bundle.min.js";import"./Gi6I4Gst.production.bundle.min.js";import"./C4B-KCzX.production.bundle.min.js";import"./B-1PPDq0.production.bundle.min.js";import"./DmMemkO8.production.bundle.min.js";import"./C2sMKzUa.production.bundle.min.js";import"./BbzwJjzq.production.bundle.min.js";import"./Bq-kesRp.production.bundle.min.js";import"./DrIpg4yc.production.bundle.min.js";import"./fGcVTXcf.production.bundle.min.js";import"./BALKx90K.production.bundle.min.js";import"./C3q6rAL9.production.bundle.min.js";import"./jZHkhCas.production.bundle.min.js";const vt={key:"rule-graph",label:"rule-graph",builderId:0,scopeId:0,widgetAppId:at,builderViewOptions:{}},_t=()=>{const u=W.useContext(fe),{dateRange:l}=u.params,m=xe(),c=je(),s=E(Oe),d=E(Me);i.useEffect(()=>{const f=[],I=[S(l.fromTs).format("YYYY-MM-DD HH:mm:ss"),S(l.toTs).format("YYYY-MM-DD HH:mm:ss")];for(const P in n){const g=m.get(P);if(g!==void 0&&P!=n.triggered_at){const k=(g==null?void 0:g.length)!==void 0&&(g==null?void 0:g.length)>0?g.split(","):[];f.push({key:P,values:k})}}f.push({key:"timeZone",values:[Intl.DateTimeFormat().resolvedOptions().timeZone]}
1),f.push({key:"triggered_at",values:I}),c(Le({filters:f,page:1}))},[c,l.fromTs,l.toTs,m.get(n.status),m.get(n.type),m.get(n.created_by),m.get(n.tags),m.get(n.alert_search),m.get(n.muted)]);const v=i.useMemo(()=>({showLegend:!1,columnConfig:{Count:{title:"Count",color:Re(5)}},chartHeight:tt.HEIGHT_150,disableSkeleton:!0,xAxisConfigOptions:{xAxisFormatter:f=>S(f.value).format("MMM DD HH:mm"),showCrossHair:!1},yAxisConfigOptions:{showCrossHair:!1,yAxisVisible:!0},chartType:Ee}),[]),p=i.useMemo(()=>({series:[{name:"Count",data:s,custom:{groups:[],metricName:"Count",config:{type:it,config:{},label:""}}}],noDataFound:s.length===0,timeRange:{fromTs:l.fromTs,toTs:l.toTs,interval:0}}),[s,l.fromTs,l.toTs]);return e.jsx("div",{className:"rule__chart",children:e.jsx("div",{className:"chart-content",children:d?e.jsx(Ie,{}):e.jsx(rt,{chartType:Pe.TimeseriesChart,timeseriesChartData:p,nestedProps:v,widget:vt,dateRange:l,onDateChange:()=>{}})})})},Tt=[{label:"Type",value:"type"},{label:"Last Status",value:"status"},{label:"Created By",value:"created_by"},{label:"Created At",value:"created_at"},{label:"Last Triggered At",value:"triggered_at"},{label:"Tags",value:"tags"}],St=()=>{var ne,le;const u=be(),l=u(A.EditRules),m=u(A.DeleteRules),c=je(),s=W.useContext(fe),d=xe(),v=i.useContext(mt),p=E(He),f=E(we),I=E(Be),P=Number(s.params.query.get("page"))||1,[g,k]=i.useState(null),M=E(pt),J=i.useMemo(()=>{var t;return M&&M.length>0&&((t=M.find(r=>r.key===n.created_by))==null?void 0:t.values.reduce((r,o)=>(r[o.id]=o.label,r),{}))||{}},[M]),_=Ce(),L=i.useCallback(()=>{ft(t=>s.params.query.delete(t),Object.keys(s.params.allParams??{}))},[s.params.query,s.params.allParams]),R=i.useRef([]),V=[];Object.entries(n).forEach(([t,r])=>{const o=d.get(r);o&&V.push({key:t,values:o.split(",")})}),JSON.stringify(V)!==JSON.stringify(R.current)&&(R.current=V);const H=i.useCallback(t=>{const r=R.current;c(Ye({filters:r,page:t}))},[c]);i.useEffect(()=>{s.params.query.set("page","1"),H(1)},[R.current]);const w=i.useMemo(()=>p!=null&&p.rules&&p.rules.length>0?p.rules:[],[p==null?void 0:p.rules]),B=i.useCallback(t=>{if(!l)return;const r=!t.is_active;c(Fe(t.id,r))},[l,c]),N=i.useCallback(t=>t&&typeof t.id=="number",[]),Z=i.useCallback(t=>{_(`/alerts/edit-rule/${t.id}/${t.type}/step-1`)},[_]),y=i.useCallback(t=>{var o,h,q,O,ce;const r=Array.isArray((o=t.permission)==null?void 0:o.users)&&((q=t.permission)==null?void 0:q.users.includes(((h=v.user)==null?void 0:h.email)??""))||t.created_by===((O=v==null?void 0:v.user)==null?void 0:O.user_id);return l&&(((ce=t.permission)==null?void 0:ce.permission_type)===Ge.RESTRICTED?r:!0)},[l,v]),Q=i.useCallback(t=>{if(!y(t)){c(pe("error",j,{title:"Permission denied."}));return}N(t)?(ze(t.id),_(`/alerts/edit-rule/${t.id}/${t.type}/step-1`)):console.error("Row does not have an id property")},[y,c,_,N]),Y=i.useCallback(t=>{y(t)&&(t.type===$.synthetic?t.tags.includes(ht)?(s.params.query.set("id",`${ue(t.name)}`),_("/synthetics")):_(`/synthetics/edit/${ue(t.name)}`):N(t)?Z(t):console.error("Row does not have an id property"))},[y,_,Z,N,s.params.query]),X=i.useCallback(t=>{const r=me[t];return e.jsx(U,{labelText:de(Ue(t)),type:r})},[]),ee=i.useCallback(t=>e.jsx(U,{type:Ke(Number(t)),labelText:Ve(Number(t))}),[]),te=i.useCallback(t=>{const o=J[t];return e.jsxs("div",{className:"alert-user-details",children:[e.jsx(lt,{size:20,seed:o??""}),o||"Middleware"]})},[J]),re=i.useCallback(t=>{const r=t;return S(r).isValid()?S.utc(r).local().format("MMM DD YYYY"):"-"},[]),se=i.useCallback(t=>{const r=t;return S(r).isValid()?S.utc(r).local().format("MMM DD YYYY hh:mm A"):"-"},[]),ae=i.useCallback(t=>{if(!t)return null;const r=Object.values(t);return e.jsxs("div",{className:"rule-tags",children:[(r==null?void 0:r.length)>0&&r.slice(0,3).map((o,h)=>e.jsx(W.Fragment,{children:e.jsx(U,{labelText:o!=="tag"?o:"None",type:ot.Secondary})},"tag-"+h)),(r==null?void 0:r.length)>3&&e.jsx(T,{content:e.jsx("div",{className:"rule-tooltip",children:r.slice(3).map((o,h)=>e.jsx("div",{className:"tooltip_tag",children:o},"tooltip-tag-"+h))}),position:"bottom",children:e.jsx("span",{children:e.jsxs("div",{className:"more-tag-link",children:["+",r.length-3," More"]})})})]})},[]),ie=i.useCallback((t,r)=>{var O;const o=r,h=!!((O=o.ai_quality)!=null&&O.classification),q=y(o);return e.jsxs("div",{className:"actions-row",children:[o.type!==$.synthetic&&$e(o.type)&&e.jsx(T,{content:h?"Re-analyze with OpsAI":"Analyze with OpsAI",position:"bottom",children:e.jsx("div",{children:e.jsx(C,{className:"analyze",shouldStopPropagation:!0,background:!1,borderless:!0,prefixicon:e.jsx(Ct,{size:16}),onClick:()=>{Q(o)}})})}),e.jsx(T,{content:!l&&j,children:e.jsx("div",{children:e.jsx(C,{className:"edit action-icon",disabled:!l,shouldStopPropagation:!0,prefixicon:o.is_active?e.jsx(ge,{}):e.jsx(he,{}),onClick:()=>{B(r)}})})}),e.jsx(T,{content:!q&&j,children:e.jsx("div",{children:e.jsx(C,{className:"copy action-icon",disabled:!q,shouldStopPropagation:!0,prefixicon:e.jsx(ye,{}),onClick:()=>{Y(o)}})})}),o.type!==$.synthetic&&e.jsx(T,{content:!m&&j,children:e.jsx("div",{children:e.jsx(C,{className:"dlt action-icon",disabled:!m,shouldStopPropagation:!0,prefixicon:e.jsx(bt,{color:"var(--color-error)"}),onClick:()=>{N(o)&&k(o.id)}})})})]})},[y,l,m,B,Q,Y,N]),F=ut("rules-table-view-v3",Tt),ve=i.useMemo(()=>[{title:"Name",columnKey:"name",align:b.Left,width:300,defaultSortOrder:d.get(n.order_by)==="name"?d.get(n.direction):x.None},{title:"Type",width:120,align:b.Left,columnKey:"type",defaultSortOrder:d.get(n.order_by)==="type"?d.get(n.direction):x.None,render:X},{title:"Last Status",columnKey:"status",width:100,align:b.Left,defaultSortOrder:d.get(n.order_by)==="status"?d.get(n.direction):x.None,render:ee}
1,{title:"Created By",columnKey:"created_by",width:200,align:b.Left,defaultSortOrder:d.get(n.order_by)==="created_by"?d.get(n.direction):x.None,render:te},{title:"Created At",columnKey:"created_at",width:150,align:b.Left,defaultSortOrder:d.get(n.order_by)==="created_at"?d.get(n.direction):x.None,render:re},{title:"Last Triggered At",columnKey:"triggered_at",width:200,align:b.Left,defaultSortOrder:d.get(n.order_by)==="triggered_at"?d.get(n.direction):x.None,render:se},{title:"Tags",columnKey:"tags",width:200,align:b.Left,defaultSortOrder:d.get(n.order_by)==="tags"?d.get(n.direction):x.None,render:ae},{title:"Actions",columnKey:"mute-editor-delete-actions",width:150,align:b.Left,render:ie}],[d,X,ee,te,re,se,ae,ie]),[a,K]=i.useState(),[_e,G]=i.useState(!1),Te=i.useCallback((t,r)=>{r!==x.None?(s.params.query.set(n.order_by,t),s.params.query.set(n.direction,r),s.params.query.redirect()):(s.params.query.delete(n.order_by),s.params.query.delete(n.direction),s.params.query.redirect())},[s.params.query]),Se=i.useCallback(t=>{const r=t;u(A.ViewAlertHistory)?(s.params.query.delete("alert_id"),L(),s.params.query.set("ruleid",(r==null?void 0:r.id.toString())??""),s.params.query.redirect()):c(pe("error",j,{title:"Permission denied."}))},[s.params.query,L,c]),Ae=i.useCallback(t=>{s.params.query.set("page",t.toString()),s.params.query.redirect(),H(t)},[]),z=i.useCallback(()=>{s.params.query.delete("ruleid"),s.params.query.delete("alert_id"),L(),s.params.query.redirect(),G(!1),c(We()),c(Je())},[s.params.query,L,c]),ke=i.useCallback(()=>{a&&B(a)},[a,B]),Ne=i.useCallback(()=>{!a||!y(a)||(Y(a),s.params.query.set("ruleid",a.id.toString()),s.params.query.redirect())},[a,y,Y,s.params.query]),D=s.params.query.get("ruleid"),oe=i.useCallback(async()=>{if(!w||!D)return;const r=w.find(o=>String(o.id)===D);if(r!=null&&r.id)K(r),G(!0);else if(Number(D)>0){if(I&&I.id===Number(D)){K(I),G(!0);return}c(Ze(D,(o,h)=>{o&&h?(K(h),G(!0)):z()}))}},[w,D,c,z]);i.useEffect(()=>{oe()},[oe]);const De=i.useCallback(()=>e.jsxs(ct,{isOpen:!0,position:"center",overlayClassName:"common-confirmation-dialog test__delete__dialog__overlay",size:"sm",onClose:()=>k(null),children:[e.jsx("h4",{children:"Are you sure you want to delete rule?"}),e.jsxs("div",{className:"dialog-buttons-wrapper",children:[e.jsx(C,{secondary:!0,onClick:()=>{k(null)},children:"Cancel"}),e.jsx(C,{secondary:!0,onClick:()=>{const t=g;k(null),c(Qe(t)).then(()=>{s.params.query.set("page","1"),s.params.query.redirect(),H(1)})},children:"Delete"})]})]}),[g,c,H,s.params.query]);return e.jsxs("div",{className:"rules__table_data",children:[e.jsx(dt,{columnsSelection:F.available,onColumnsChange:F.onChange,onDefaultLabelClick:F.reset,children:e.jsx(nt,{columns:F.filterColumns(ve),onSortingChange:Te,dataProvider:w,loading:f,uniqId:"rules-table-view-v3",rowOnClick:Se,maxHeight:"calc(-415px + 100vh)",pagination:{totalRecords:p&&p.total_count>=0?p.total_count:0,page:P,recordsPerPage:10,onChange:Ae,recordsLabel:"Rules"}})}),g&&e.jsx(De,{}),a&&_e?e.jsx(gt,{shouldCloseOnOverlayClick:!1,title:qe((a==null?void 0:a.name)??"",80),isOpen:!0,onClose:z,onBackBtnClick:z,bodyPadding:!1,datePicker:!0,dialogContentClassName:"alert-list-panel",headerElements:e.jsx(U,{labelText:de(((ne=a==null?void 0:a.type)==null?void 0:ne.toString())??""),type:me[((le=a==null?void 0:a.type)==null?void 0:le.toString())??""]}),rightAlignedHeaderElements:e.jsxs("div",{className:"alert-actions",children:[e.jsx(T,{content:!l&&j,children:e.jsx("div",{children:e.jsx(C,{prefixicon:a!=null&&a.is_active?e.jsx(ge,{}):e.jsx(he,{}),onClick:ke,disabled:!l,children:a!=null&&a.is_active?"Mute Alert":"Unmute Alert"})})}),e.jsx(T,{content:!(a&&y(a))&&j,children:e.jsx("div",{children:e.jsx(C,{className:"copy action-icon",disabled:!(a&&y(a)),prefixicon:e.jsx(ye,{}),onClick:Ne})})})]}),children:(a==null?void 0:a.id)&&e.jsx(xt,{ruleID:a==null?void 0:a.id,ruleType:a==null?void 0:a.type,checkId:yt(a==null?void 0:a.name)},a.id)}):null]})},At=()=>{i.useEffect(()=>{localStorage.setItem("lastVisitedTime",Date.now().toString())},[]);const[u,l]=i.useState(!0);return e.jsxs("div",{className:"data-visualizations",children:[e.jsx(st,{expandItem:u,handleSectionExpand:()=>l(!u),showBorder:!1,shouldtitleStyleBold:!1,title:"Alerts Over Time",children:e.jsx("div",{className:"data-graph__rules",children:e.jsx(_t,{})})}),e.jsx("div",{className:"data-table__rules",children:e.jsx(St,{})})]})},Xr=()=>{const u=be(),l="alert_search",m=Ce(),c=()=>{m("/alerts/new-rule")},s=u(A.CreateAlerts);return s||u(A.EditRules)||u(A.DeleteRules)||u(A.ViewAlertHistory)?e.jsx("div",{className:"modules__rules",children:e.jsxs("div",{className:"rules-list",children:[e.jsx("div",{className:"header-view",children:e.jsx("div",{className:"alerts-header-outer-wrapper",children:e.jsx(et,{caller:l,placeholder:"Search by name, tag",extraBtnPrefixIcon:e.jsx(jt,{color:"var(--color-primary)"}),extraBtnDisabled:!s,extraBtnTooltip:s?void 0:j,onExtraBtnClick:()=>{s&&c()},extraBtnLabel:"Add New Rule"})})}),e.jsx("div",{className:"rules__body",children:e.jsx(At,{})})]})}):e.jsx(Xe,{})};export{Xr as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.