import{f as _,r as l,j as e,L as O,B as A,Q as W,J as Y,T as z,z as $,t as E,D as ee,a as te,b as se,c as oe,d as ae,e as ne,C as re}from"./index-o4rKtKfJ.js";import{C as w,a as M,b as ce,c as le,d as ie}from"./card-6Ae5ROGi.js";import{T as me,a as de,b as H,c as I}from"./tabs-CoTqT5ed.js";import{a as g}from"./alert-BV-5lkdi.js";import{I as J}from"./input-BfBi0wR2.js";import{B as f}from"./badge-CDGsL4jH.js";import{T as X,a as V,b as R,c as i,d as q,e as c}from"./table-FZ6-yFwR.js";import{S as xe}from"./search-C_UCkHB_.js";import{S as B}from"./switch-Dqj5wqUV.js";import{C as G}from"./checkbox-zTZ6SyDQ.js";import{r as pe,g as he,C as K,A as ge}from"./AlertRuleDialog-IbIdg7El.js";import{T as P}from"./trash-2-C2Niwqae.js";import{L as D}from"./label-DrX9VaVC.js";import{T as be}from"./textarea-9Podrtqd.js";import{P as U}from"./plus-BXcAPnTg.js";import{R as Ae,C as je,X as ue,Y as Ne,T as ve}from"./generateCategoricalChart-BeO9rjxr.js";import{A as fe,a as Q}from"./AreaChart-CIzu6WTF.js";import"./index-BeCACrpC.js";import"./message-square-CE152duc.js";import"./phone-C90KJWhC.js";function Te({alerts:m,loading:T,onReload:d}){_();const[p,u]=l.useState(""),[o,h]=l.useState("all"),[b,C]=l.useState("all"),j=m.filter(t=>{const r=(t.rule&&t.rule.name||t.message||"").toLowerCase().includes(p.toLowerCase())||(t.target||"").toLowerCase().includes(p.toLowerCase()),N=o==="all"||t.severity===o,v=b==="all"||t.status===b;return r&&N&&v}),y=t=>{switch(t){case"critical":return e.jsxs(f,{"code-path":"src/components/monitor/AlertEventsTab.tsx:45:11",variant:"outline",className:"border-red-500/30 text-red-400 bg-red-500/10",children:[e.jsx(z,{"code-path":"src/components/monitor/AlertEventsTab.tsx:46:13",className:"h-3 w-3 mr-1"}),"严重"]});case"warning":return e.jsxs(f,{"code-path":"src/components/monitor/AlertEventsTab.tsx:52:11",variant:"outline",className:"border-amber-500/30 text-amber-400 bg-amber-500/10",children:[e.jsx(z,{"code-path":"src/components/monitor/AlertEventsTab.tsx:53:13",className:"h-3 w-3 mr-1"}),"警告"]});case"info":return e.jsxs(f,{"code-path":"src/components/monitor/AlertEventsTab.tsx:59:11",variant:"outline",className:"border-blue-500/30 text-blue-400 bg-blue-500/10",children:[e.jsx(Y,{"code-path":"src/components/monitor/AlertEventsTab.tsx:60:13",className:"h-3 w-3 mr-1"}),"提示"]});default:return null}},a=t=>{switch(t){case"firing":return e.jsx(f,{"code-path":"src/components/monitor/AlertEventsTab.tsx:73:11",variant:"outline",className:"border-red-500/30 text-red-400 bg-red-500/10 animate-pulse",children:"触发中"});case"resolved":return e.jsx(f,{"code-path":"src/components/monitor/AlertEventsTab.tsx:79:11",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:"已恢复"});default:return null}},x=async t=>{try{await g.acknowledge(t),d()}catch(r){console.error("Failed to acknowledge alert:",r)}};return e.jsxs("div",{"code-path":"src/components/monitor/AlertEventsTab.tsx:98:5",className:"mt-4 space-y-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertEventsTab.tsx:100:7",className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertEventsTab.tsx:101:9",className:"relative w-64",children:[e.jsx(xe,{"code-path":"src/components/monitor/AlertEventsTab.tsx:102:11",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-500"}),e.jsx(J,{"code-path":"src/components/monitor/AlertEventsTab.tsx:103:11",placeholder:"搜索告警名称或目标...",value:p,onChange:t=>u(t.target.value),className:"pl-9 h-9 bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500"})]}),e.jsxs("select",{"code-path":"src/components/monitor/AlertEventsTab.tsx:110:9",value:o,onChange:t=>h(t.target.value),className:"h-9 px-3 rounded-md bg-slate-800/50 border border-slate-700 text-slate-200 text-sm",children:[e.jsx("option",{"code-path":"src/components/monitor/AlertEventsTab.tsx:115:11",value:"all",children:"全部级别"}),e.jsx("option",{"code-path":"src/components/monitor/AlertEventsTab.tsx:116:11",value:"critical",children:"严重"}),e.jsx("option",{"code-path":"src/components/monitor/AlertEventsTab.tsx:117:11",value:"warning",children:"警告"}),e.jsx("option",{"code-path":"src/components/monitor/AlertEventsTab.tsx:118:11",value:"info",children:"提示"})]}),e.jsxs("select",{"code-path":"src/components/monitor/AlertEventsTab.tsx:120:9",value:b,onChange:t=>C(t.target.value),className:"h-9 px-3 rounded-md bg-slate-800/50 border border-slate-700 text-slate-200 text-sm",children:[e.jsx("option",{"code-path":"src/components/monitor/AlertEventsTab.tsx:125:11",value:"all",children:"全部状态"}),e.jsx("option",{"code-path":"src/components/monitor/AlertEventsTab.tsx:126:11",value:"firing",children:"触发中"}),e.jsx("option",{"code-path":"src/components/monitor/AlertEventsTab.tsx:127:11",value:"resolved",children:"已恢复"})]})]}),e.jsx(w,{"code-path":"src/components/monitor/AlertEventsTab.tsx:132:7",className:"bg-slate-900 border-slate-800",children:e.jsx(M,{"code-path":"src/components/monitor/AlertEventsTab.tsx:133:9",className:"p-0",children:e.jsx("div",{"code-path":"src/components/monitor/AlertEventsTab.tsx:134:11",className:"border-t border-slate-800",children:e.jsxs(X,{"code-path":"src/components/monitor/AlertEventsTab.tsx:135:13",children:[e.jsx(V,{"code-path":"src/components/monitor/AlertEventsTab.tsx:136:15",children:e.jsxs(R,{"code-path":"src/components/monitor/AlertEventsTab.tsx:137:17",className:"border-slate-800 hover:bg-transparent",children:[e.jsx(i,{"code-path":"src/components/monitor/AlertEventsTab.tsx:138:19",className:"text-slate-400",children:"级别"}),e.jsx(i,{"code-path":"src/components/monitor/AlertEventsTab.tsx:139:19",className:"text-slate-400",children:"告警名称"}),e.jsx(i,{"code-path":"src/components/monitor/AlertEventsTab.tsx:140:19",className:"text-slate-400",children:"状态"}),e.jsx(i,{"code-path":"src/components/monitor/AlertEventsTab.tsx:141:19",className:"text-slate-400",children:"目标"}),e.jsx(i,{"code-path":"src/components/monitor/AlertEventsTab.tsx:142:19",className:"text-slate-400",children:"当前值"}),e.jsx(i,{"code-path":"src/components/monitor/AlertEventsTab.tsx:143:19",className:"text-slate-400",children:"阈值"}),e.jsx(i,{"code-path":"src/components/monitor/AlertEventsTab.tsx:144:19",className:"text-slate-400",children:"开始时间"}),e.jsx(i,{"code-path":"src/components/monitor/AlertEventsTab.tsx:145:19",className:"text-slate-400 text-right",children:"操作"})]})}),e.jsx(q,{"code-path":"src/components/monitor/AlertEventsTab.tsx:148:15",children:T?e.jsx(R,{"code-path":"src/components/monitor/AlertEventsTab.tsx:150:19",className:"border-slate-800",children:e.jsxs(c,{"code-path":"src/components/monitor/AlertEventsTab.tsx:151:21",colSpan:8,className:"text-center text-slate-500 py-8",children:[e.jsx(O,{"code-path":"src/components/monitor/AlertEventsTab.tsx:152:23",className:"h-5 w-5 animate-spin inline mr-2"}),"加载中..."]})}):j.map(t=>e.jsxs(R,{"code-path":"src/components/monitor/AlertEventsTab.tsx:157:19",className:"border-slate-800 hover:bg-slate-800/50",children:[e.jsx(c,{"code-path":"src/components/monitor/AlertEventsTab.tsx:158:21",children:y(t.severity)}),e.jsx(c,{"code-path":"src/components/monitor/AlertEventsTab.tsx:159:21",children:e.jsx("span",{"code-path":"src/components/monitor/AlertEventsTab.tsx:160:23",className:"text-sm font-medium text-slate-200",children:t.rule&&t.rule.name||t.message})}),e.jsx(c,{"code-path":"src/components/monitor/AlertEventsTab.tsx:164:21",children:a(t.status)}),e.jsx(c,{"code-path":"src/components/monitor/AlertEventsTab.tsx:165:21",className:"max-w-[160px]",children:e.jsx("span",{"code-path":"src/components/monitor/AlertEventsTab.tsx:166:23",className:"text-sm text-slate-300 block truncate",title:t.target,children:t.target})}),e.jsx(c,{"code-path":"src/components/monitor/AlertEventsTab.tsx:168:21",children:e.jsx("span",{"code-path":"src/components/monitor/AlertEventsTab.tsx:169:23",className:"text-sm text-slate-300",children:typeof t.value=="number"?t.value.toFixed(1):t.value})}),e.jsx(c,{"code-path":"src/components/monitor/AlertEventsTab.tsx:171:21",children:e.jsx("span",{"code-path":"src/components/monitor/AlertEventsTab.tsx:172:23",className:"text-sm text-slate-500",children:t.threshold})}),e.jsx(c,{"code-path":"src/components/monitor/AlertEventsTab.tsx:174:21",children:e.jsx("span",{"code-path":"src/components/monitor/AlertEventsTab.tsx:175:23",className:"text-sm text-slate-400",children:t.created_at?new Date(t.created_at).toLocaleString():"--"})}),e.jsx(c,{"code-path":"src/components/monitor/AlertEventsTab.tsx:179:21",className:"text-right",children:e.jsx("div",{"code-path":"src/components/monitor/AlertEventsTab.tsx:180:23",className:"flex items-center justify-end gap-1",children:t.status==="firing"&&e.jsxs(A,{"code-path":"src/components/monitor/AlertEventsTab.tsx:182:27",variant:"ghost",size:"sm",className:"h-8 text-slate-400 hover:text-emerald-400",onClick:()=>x(t.id),children:[e.jsx(W,{"code-path":"src/components/monitor/AlertEventsTab.tsx:188:29",className:"h-4 w-4 mr-1"}),"确认"]})})})]},t.id))})]})})})})]})}const Ce=9;function ye({rules:m,notifyChannels:T,onReload:d,onEditRule:p}){const u=_(),[o,h]=l.useState([]),b=()=>{m.length>0&&o.length===m.length?h([]):h(m.map(t=>t.id))},C=t=>{h(r=>r.includes(t)?r.filter(N=>N!==t):[...r,t])},j=async t=>{if(await u({title:"删除告警规则",description:"确定删除此告警规则?",confirmText:"删除",variant:"destructive"}))try{await g.deleteRule(t),E.success("告警规则已删除"),d()}catch(N){console.error("Failed to delete rule:",N),E.error("删除失败")}},y=async()=>{if(!(o.length===0||!await u({title:"批量删除告警规则",description:`确定删除选中的 ${o.length} 条告警规则吗?此操作不可撤销。`,confirmText:"批量删除",variant:"destructive"})))try{await g.batchDeleteRules(o),E.success(`已删除 ${o.length} 条告警规则`),h([]),d()}catch(r){console.error("Failed to batch delete rules:",r),E.error("批量删除失败")}},a=async t=>{try{await g.toggleRule(t),d()}catch(r){console.error("Failed to toggle rule:",r)}},x=m.length>0&&o.length===m.length;return e.jsxs("div",{"code-path":"src/components/monitor/AlertRulesTab.tsx:104:5",className:"mt-4",children:[o.length>0&&e.jsxs("div",{"code-path":"src/components/monitor/AlertRulesTab.tsx:107:9",className:"flex items-center gap-2 mb-3",children:[e.jsxs("span",{"code-path":"src/components/monitor/AlertRulesTab.tsx:108:11",className:"text-sm text-slate-400",children:["已选择 ",o.length," 项"]}),e.jsxs(A,{"code-path":"src/components/monitor/AlertRulesTab.tsx:109:11",variant:"outline",size:"sm",className:"border-red-500/30 text-red-400 hover:bg-red-500/10",onClick:y,children:[e.jsx(P,{"code-path":"src/components/monitor/AlertRulesTab.tsx:115:13",className:"h-4 w-4 mr-2"}),"批量删除"]})]}),e.jsx(w,{"code-path":"src/components/monitor/AlertRulesTab.tsx:121:7",className:"bg-slate-900 border-slate-800",children:e.jsx(M,{"code-path":"src/components/monitor/AlertRulesTab.tsx:122:9",className:"p-0",children:e.jsx("div",{"code-path":"src/components/monitor/AlertRulesTab.tsx:123:11",className:"border-t border-slate-800",children:e.jsxs(X,{"code-path":"src/components/monitor/AlertRulesTab.tsx:124:13",children:[e.jsx(V,{"code-path":"src/components/monitor/AlertRulesTab.tsx:125:15",children:e.jsxs(R,{"code-path":"src/components/monitor/AlertRulesTab.tsx:126:17",className:"border-slate-800 hover:bg-transparent",children:[e.jsx(i,{"code-path":"src/components/monitor/AlertRulesTab.tsx:127:19",className:"w-12",children:e.jsx(G,{"code-path":"src/components/monitor/AlertRulesTab.tsx:128:21",checked:x,onCheckedChange:b,className:"border-slate-600"})}),e.jsx(i,{"code-path":"src/components/monitor/AlertRulesTab.tsx:134:19",className:"text-slate-400",children:"规则名称"}),e.jsx(i,{"code-path":"src/components/monitor/AlertRulesTab.tsx:135:19",className:"text-slate-400",children:"数据源"}),e.jsx(i,{"code-path":"src/components/monitor/AlertRulesTab.tsx:136:19",className:"text-slate-400",children:"触发条件"}),e.jsx(i,{"code-path":"src/components/monitor/AlertRulesTab.tsx:137:19",className:"text-slate-400",children:"级别"}),e.jsx(i,{"code-path":"src/components/monitor/AlertRulesTab.tsx:138:19",className:"text-slate-400",children:"持续时间"}),e.jsx(i,{"code-path":"src/components/monitor/AlertRulesTab.tsx:139:19",className:"text-slate-400",children:"通知渠道"}),e.jsx(i,{"code-path":"src/components/monitor/AlertRulesTab.tsx:140:19",className:"text-slate-400",children:"状态"}),e.jsx(i,{"code-path":"src/components/monitor/AlertRulesTab.tsx:141:19",className:"text-slate-400 text-right",children:"操作"})]})}),e.jsx(q,{"code-path":"src/components/monitor/AlertRulesTab.tsx:144:15",children:m.length===0?e.jsx(R,{"code-path":"src/components/monitor/AlertRulesTab.tsx:146:19",className:"border-slate-800",children:e.jsx(c,{"code-path":"src/components/monitor/AlertRulesTab.tsx:147:21",colSpan:Ce,className:"text-center text-slate-500 py-12",children:"暂无告警规则"})}):m.map(t=>e.jsxs(R,{"code-path":"src/components/monitor/AlertRulesTab.tsx:153:21",className:"border-slate-800 hover:bg-slate-800/50",children:[e.jsx(c,{"code-path":"src/components/monitor/AlertRulesTab.tsx:154:23",children:e.jsx(G,{"code-path":"src/components/monitor/AlertRulesTab.tsx:155:25",checked:o.includes(t.id),onCheckedChange:()=>C(t.id),className:"border-slate-600"})}),e.jsx(c,{"code-path":"src/components/monitor/AlertRulesTab.tsx:161:23",children:e.jsxs("div",{"code-path":"src/components/monitor/AlertRulesTab.tsx:162:25",children:[e.jsx("span",{"code-path":"src/components/monitor/AlertRulesTab.tsx:163:27",className:"text-sm font-medium text-slate-200",children:t.name}),t.description&&e.jsx("p",{"code-path":"src/components/monitor/AlertRulesTab.tsx:165:29",className:"text-xs text-slate-500",children:t.description})]})}),e.jsx(c,{"code-path":"src/components/monitor/AlertRulesTab.tsx:169:23",children:e.jsx("code",{"code-path":"src/components/monitor/AlertRulesTab.tsx:170:25",className:"text-xs text-slate-300 bg-slate-800 px-2 py-0.5 rounded",children:t.source||"--"})}),e.jsx(c,{"code-path":"src/components/monitor/AlertRulesTab.tsx:174:23",className:"max-w-[180px]",children:e.jsx("code",{"code-path":"src/components/monitor/AlertRulesTab.tsx:175:25",className:"text-xs text-blue-300 block truncate",title:t.expression,children:t.expression||"--"})}),e.jsx(c,{"code-path":"src/components/monitor/AlertRulesTab.tsx:179:23",children:t.severity==="critical"?e.jsx(f,{"code-path":"src/components/monitor/AlertRulesTab.tsx:181:27",variant:"outline",className:"border-red-500/30 text-red-400 bg-red-500/10",children:"严重"}):t.severity==="warning"?e.jsx(f,{"code-path":"src/components/monitor/AlertRulesTab.tsx:185:27",variant:"outline",className:"border-amber-500/30 text-amber-400 bg-amber-500/10",children:"警告"}):e.jsx(f,{"code-path":"src/components/monitor/AlertRulesTab.tsx:189:27",variant:"outline",className:"border-blue-500/30 text-blue-400 bg-blue-500/10",children:"提示"})}),e.jsx(c,{"code-path":"src/components/monitor/AlertRulesTab.tsx:194:23",children:e.jsxs("span",{"code-path":"src/components/monitor/AlertRulesTab.tsx:195:25",className:"text-sm text-slate-300",children:[(t.duration||0)/60,"分钟"]})}),e.jsx(c,{"code-path":"src/components/monitor/AlertRulesTab.tsx:197:23",children:pe(t,T)}),e.jsx(c,{"code-path":"src/components/monitor/AlertRulesTab.tsx:200:23",children:e.jsx(B,{"code-path":"src/components/monitor/AlertRulesTab.tsx:201:25",checked:!!t.enabled,className:"data-[state=checked]:bg-blue-600",onCheckedChange:()=>a(t.id)})}),e.jsx(c,{"code-path":"src/components/monitor/AlertRulesTab.tsx:207:23",className:"text-right",children:e.jsxs("div",{"code-path":"src/components/monitor/AlertRulesTab.tsx:208:25",className:"flex items-center justify-end gap-1",children:[e.jsx(A,{"code-path":"src/components/monitor/AlertRulesTab.tsx:209:27",variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-slate-100",onClick:()=>p(t),children:e.jsx($,{"code-path":"src/components/monitor/AlertRulesTab.tsx:215:29",className:"h-4 w-4"})}),e.jsx(A,{"code-path":"src/components/monitor/AlertRulesTab.tsx:217:27",variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-red-400",onClick:()=>j(t.id),children:e.jsx(P,{"code-path":"src/components/monitor/AlertRulesTab.tsx:223:29",className:"h-4 w-4"})})]})})]},t.id))})]})})})})]})}const L={name:"",type:"dingtalk",config:"",enabled:!0};function we({open:m,onOpenChange:T,notifyChannels:d,onChannelsChanged:p}){const u=_(),[o,h]=l.useState(null),[b,C]=l.useState(!1),[j,y]=l.useState(null),[a,x]=l.useState({...L});l.useEffect(()=>{m&&(h(null),x({...L}))},[m]);const t=s=>{h(s),x({name:s.name||"",type:s.type||"dingtalk",config:s.config||"",enabled:s.enabled!==!1})},r=()=>{h(null),x({...L})},N=async()=>{if(a.name.trim()){C(!0);try{const s={name:a.name.trim(),type:a.type,config:a.config.trim()};o?await g.updateNotifyChannel(o.id,{...s,enabled:a.enabled}):await g.createNotifyChannel(s),r(),p()}catch(s){console.error("Failed to save notify channel:",s)}finally{C(!1)}}},v=async s=>{if(await u({title:"删除通知渠道",description:"确定删除此通知渠道?",confirmText:"删除",variant:"destructive"}))try{await g.deleteNotifyChannel(s),o&&o.id===s&&r(),p()}catch(n){console.error("Failed to delete notify channel:",n)}},k=async s=>{try{await g.updateNotifyChannel(s.id,{enabled:!s.enabled}),p()}catch(n){console.error("Failed to toggle notify channel:",n)}},S=async s=>{y(s);try{await g.testNotifyChannel(s),p()}catch(n){console.error("Failed to test notify channel:",n)}finally{y(null)}};return e.jsx(ee,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:119:5",open:m,onOpenChange:T,children:e.jsxs(te,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:120:7",className:"bg-slate-900 border-slate-700 text-slate-100 max-w-2xl",children:[e.jsxs(se,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:121:9",children:[e.jsx(oe,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:122:11",className:"text-slate-100",children:"通知渠道配置"}),e.jsx(ae,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:123:11",className:"text-slate-500",children:"管理告警通知渠道(钉钉/企业微信/邮件/短信/Webhook),配置后可在告警规则中引用"})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertChannelDialog.tsx:128:9",className:"grid grid-cols-1 lg:grid-cols-2 gap-4 max-h-[65vh] overflow-y-auto pr-1",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertChannelDialog.tsx:130:11",className:"space-y-2",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertChannelDialog.tsx:131:13",className:"flex items-center justify-between",children:[e.jsx(D,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:132:15",className:"text-slate-300 text-sm",children:"已配置渠道"}),e.jsxs(A,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:133:15",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 hover:bg-slate-800 text-xs",onClick:r,children:[e.jsx(U,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:139:17",className:"h-3 w-3 mr-1"}),"新建"]})]}),d.length===0?e.jsx("div",{"code-path":"src/components/monitor/AlertChannelDialog.tsx:144:15",className:"text-center py-8 text-sm text-slate-600 border border-dashed border-slate-800 rounded-lg",children:"暂无通知渠道,请在右侧添加"}):e.jsx("div",{"code-path":"src/components/monitor/AlertChannelDialog.tsx:148:15",className:"space-y-2",children:d.map(s=>e.jsxs("div",{"code-path":"src/components/monitor/AlertChannelDialog.tsx:150:19",className:`p-3 rounded-lg border cursor-pointer transition-colors ${o&&o.id===s.id?"border-blue-500/50 bg-blue-500/5":"border-slate-800 bg-slate-800/30 hover:border-slate-700"}`,onClick:()=>t(s),children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertChannelDialog.tsx:159:21",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertChannelDialog.tsx:160:23",className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{"code-path":"src/components/monitor/AlertChannelDialog.tsx:161:25",className:"text-sm text-slate-200 truncate",children:s.name}),e.jsx(f,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:162:25",variant:"outline",className:"border-slate-600 text-slate-400 text-[10px] py-0",children:he(s.type)})]}),e.jsx(B,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:166:23",checked:s.enabled!==!1,onCheckedChange:()=>k(s),onClick:n=>n.stopPropagation(),className:"data-[state=checked]:bg-emerald-600 scale-90"})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertChannelDialog.tsx:173:21",className:"flex items-center justify-between mt-2",children:[s.test_status==="success"?e.jsx("span",{"code-path":"src/components/monitor/AlertChannelDialog.tsx:175:25",className:"text-[11px] text-emerald-400",children:"测试通过"}):e.jsx("span",{"code-path":"src/components/monitor/AlertChannelDialog.tsx:177:25",className:"text-[11px] text-slate-600",children:"未测试"}),e.jsxs("div",{"code-path":"src/components/monitor/AlertChannelDialog.tsx:179:23",className:"flex items-center gap-1",onClick:n=>n.stopPropagation(),children:[e.jsx(A,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:180:25",size:"sm",variant:"ghost",className:"h-6 px-2 text-slate-400 hover:text-slate-200 hover:bg-slate-700 text-xs",disabled:j===s.id,onClick:()=>S(s.id),children:j===s.id?e.jsx(O,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:187:55",className:"h-3 w-3 animate-spin"}):"测试"}),e.jsx(A,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:189:25",size:"sm",variant:"ghost",className:"h-6 px-2 text-red-400/70 hover:text-red-400 hover:bg-red-500/10 text-xs",onClick:()=>v(s.id),children:e.jsx(P,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:195:27",className:"h-3 w-3"})})]})]})]},s.id))})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertChannelDialog.tsx:206:11",className:"space-y-4",children:[e.jsx(D,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:207:13",className:"text-slate-300 text-sm",children:o?"编辑渠道":"新建渠道"}),e.jsxs("div",{"code-path":"src/components/monitor/AlertChannelDialog.tsx:210:13",className:"space-y-1.5",children:[e.jsxs(D,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:211:15",className:"text-slate-400 text-xs",children:["渠道名称 ",e.jsx("span",{"code-path":"src/components/monitor/AlertChannelDialog.tsx:211:62",className:"text-red-400",children:"*"})]}),e.jsx(J,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:212:15",value:a.name,onChange:s=>x({...a,name:s.target.value}),placeholder:"如:运维告警群",className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-600 h-9"})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertChannelDialog.tsx:219:13",className:"space-y-1.5",children:[e.jsx(D,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:220:15",className:"text-slate-400 text-xs",children:"渠道类型"}),e.jsx("select",{"code-path":"src/components/monitor/AlertChannelDialog.tsx:221:15",value:a.type,onChange:s=>x({...a,type:s.target.value}),className:"w-full h-9 px-3 rounded-md bg-slate-800/50 border border-slate-700 text-slate-200 text-sm",children:K.map(({key:s,label:n})=>e.jsx("option",{"code-path":"src/components/monitor/AlertChannelDialog.tsx:227:19",value:s,children:n},s))})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertChannelDialog.tsx:231:13",className:"space-y-1.5",children:[e.jsx(D,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:232:15",className:"text-slate-400 text-xs",children:"配置(JSON)"}),e.jsx(be,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:233:15",value:a.config,onChange:s=>x({...a,config:s.target.value}),placeholder:K.find(s=>s.key===a.type)?.placeholder||"",rows:5,className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-600 font-mono text-xs resize-none"})]}),o&&e.jsxs("div",{"code-path":"src/components/monitor/AlertChannelDialog.tsx:242:15",className:"flex items-center gap-2",children:[e.jsx(B,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:243:17",checked:a.enabled,onCheckedChange:s=>x({...a,enabled:s}),className:"data-[state=checked]:bg-emerald-600"}),e.jsx(D,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:248:17",className:"text-slate-400 text-xs",children:"启用此渠道"})]})]})]}),e.jsxs(ne,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:254:9",children:[e.jsx(A,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:255:11",variant:"outline",className:"border-slate-700 text-slate-300 hover:bg-slate-800",onClick:()=>T(!1),children:"关闭"}),e.jsxs(A,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:262:11",className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:!a.name.trim()||b,onClick:N,children:[b&&e.jsx(O,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:267:31",className:"h-4 w-4 mr-2 animate-spin"}),o?"保存修改":"添加渠道"]})]})]})})}function $e(){const[m,T]=l.useState("events"),[d,p]=l.useState([]),[u,o]=l.useState([]),[h,b]=l.useState(!0),[C,j]=l.useState(!1),[y,a]=l.useState(null),[x,t]=l.useState(!1),[r,N]=l.useState([]),v=async()=>{try{b(!0);const[n,F,Z]=await Promise.all([g.getAlerts(),g.getRules(),g.getNotifyChannels()]);p(n?.list||[]),o(F?.list||(Array.isArray(F)?F:[])),N(Z?.list||[])}catch(n){console.error("Failed to load alert data:",n)}finally{b(!1)}};l.useEffect(()=>{v()},[]);const k=()=>{a(null),j(!0)},S=n=>{a(n),j(!0)},s=[{time:"00:00",critical:2,warning:5,info:8},{time:"04:00",critical:1,warning:3,info:6},{time:"08:00",critical:3,warning:7,info:12},{time:"12:00",critical:5,warning:10,info:15},{time:"16:00",critical:4,warning:8,info:10},{time:"20:00",critical:3,warning:6,info:9},{time:"24:00",critical:2,warning:4,info:7}];return e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:75:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:77:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:78:9",children:[e.jsx("h1",{"code-path":"src/components/monitor/AlertManager.tsx:79:11",className:"text-2xl font-bold text-slate-100",children:"监控告警"}),e.jsx("p",{"code-path":"src/components/monitor/AlertManager.tsx:80:11",className:"text-sm text-slate-500 mt-1",children:"告警规则管理与告警事件处理"})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:82:9",className:"flex items-center gap-2",children:[e.jsxs(A,{"code-path":"src/components/monitor/AlertManager.tsx:83:11",variant:"outline",className:"border-slate-700 text-slate-300 hover:text-slate-100 hover:bg-slate-800",onClick:()=>t(!0),children:[e.jsx($,{"code-path":"src/components/monitor/AlertManager.tsx:88:13",className:"h-4 w-4 mr-2"}),"通知配置"]}),e.jsxs(A,{"code-path":"src/components/monitor/AlertManager.tsx:91:11",className:"bg-blue-600 hover:bg-blue-700 text-white",onClick:k,children:[e.jsx(U,{"code-path":"src/components/monitor/AlertManager.tsx:92:13",className:"h-4 w-4 mr-2"}),"新建规则"]})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:99:7",className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx(w,{"code-path":"src/components/monitor/AlertManager.tsx:100:9",className:"bg-slate-900 border-slate-800",children:e.jsx(M,{"code-path":"src/components/monitor/AlertManager.tsx:101:11",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:102:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:103:15",children:[e.jsx("p",{"code-path":"src/components/monitor/AlertManager.tsx:104:17",className:"text-sm text-slate-500",children:"告警规则"}),e.jsx("p",{"code-path":"src/components/monitor/AlertManager.tsx:105:17",className:"text-2xl font-bold text-slate-100",children:u.length})]}),e.jsx("div",{"code-path":"src/components/monitor/AlertManager.tsx:107:15",className:"p-3 rounded-lg bg-blue-500/10 text-blue-400",children:e.jsx(Y,{"code-path":"src/components/monitor/AlertManager.tsx:108:17",className:"h-5 w-5"})})]})})}),e.jsx(w,{"code-path":"src/components/monitor/AlertManager.tsx:113:9",className:"bg-slate-900 border-slate-800",children:e.jsx(M,{"code-path":"src/components/monitor/AlertManager.tsx:114:11",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:115:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:116:15",children:[e.jsx("p",{"code-path":"src/components/monitor/AlertManager.tsx:117:17",className:"text-sm text-slate-500",children:"触发中"}),e.jsx("p",{"code-path":"src/components/monitor/AlertManager.tsx:118:17",className:"text-2xl font-bold text-red-400",children:d.filter(n=>n.status==="firing").length})]}),e.jsx("div",{"code-path":"src/components/monitor/AlertManager.tsx:122:15",className:"p-3 rounded-lg bg-red-500/10 text-red-400",children:e.jsx(z,{"code-path":"src/components/monitor/AlertManager.tsx:123:17",className:"h-5 w-5"})})]})})}),e.jsx(w,{"code-path":"src/components/monitor/AlertManager.tsx:128:9",className:"bg-slate-900 border-slate-800",children:e.jsx(M,{"code-path":"src/components/monitor/AlertManager.tsx:129:11",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:130:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:131:15",children:[e.jsx("p",{"code-path":"src/components/monitor/AlertManager.tsx:132:17",className:"text-sm text-slate-500",children:"今日告警"}),e.jsx("p",{"code-path":"src/components/monitor/AlertManager.tsx:133:17",className:"text-2xl font-bold text-amber-400",children:d.length})]}),e.jsx("div",{"code-path":"src/components/monitor/AlertManager.tsx:135:15",className:"p-3 rounded-lg bg-amber-500/10 text-amber-400",children:e.jsx(re,{"code-path":"src/components/monitor/AlertManager.tsx:136:17",className:"h-5 w-5"})})]})})}),e.jsx(w,{"code-path":"src/components/monitor/AlertManager.tsx:141:9",className:"bg-slate-900 border-slate-800",children:e.jsx(M,{"code-path":"src/components/monitor/AlertManager.tsx:142:11",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:143:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:144:15",children:[e.jsx("p",{"code-path":"src/components/monitor/AlertManager.tsx:145:17",className:"text-sm text-slate-500",children:"已恢复"}),e.jsx("p",{"code-path":"src/components/monitor/AlertManager.tsx:146:17",className:"text-2xl font-bold text-emerald-400",children:d.filter(n=>n.status==="resolved").length})]}),e.jsx("div",{"code-path":"src/components/monitor/AlertManager.tsx:150:15",className:"p-3 rounded-lg bg-emerald-500/10 text-emerald-400",children:e.jsx(W,{"code-path":"src/components/monitor/AlertManager.tsx:151:17",className:"h-5 w-5"})})]})})})]}),e.jsxs(w,{"code-path":"src/components/monitor/AlertManager.tsx:159:7",className:"bg-slate-900 border-slate-800",children:[e.jsxs(ce,{"code-path":"src/components/monitor/AlertManager.tsx:160:9",className:"pb-2",children:[e.jsx(le,{"code-path":"src/components/monitor/AlertManager.tsx:161:11",className:"text-slate-100",children:"告警趋势"}),e.jsx(ie,{"code-path":"src/components/monitor/AlertManager.tsx:162:11",className:"text-slate-500",children:"过去24小时告警统计"})]}),e.jsx(M,{"code-path":"src/components/monitor/AlertManager.tsx:164:9",children:e.jsx("div",{"code-path":"src/components/monitor/AlertManager.tsx:165:11",className:"h-[200px]",children:e.jsx(Ae,{"code-path":"src/components/monitor/AlertManager.tsx:166:13",width:"100%",height:"100%",children:e.jsxs(fe,{"code-path":"src/components/monitor/AlertManager.tsx:167:15",data:s,children:[e.jsxs("defs",{"code-path":"src/components/monitor/AlertManager.tsx:168:17",children:[e.jsxs("linearGradient",{"code-path":"src/components/monitor/AlertManager.tsx:169:19",id:"colorCritical",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{"code-path":"src/components/monitor/AlertManager.tsx:170:21",offset:"5%",stopColor:"#ef4444",stopOpacity:.3}),e.jsx("stop",{"code-path":"src/components/monitor/AlertManager.tsx:171:21",offset:"95%",stopColor:"#ef4444",stopOpacity:0})]}),e.jsxs("linearGradient",{"code-path":"src/components/monitor/AlertManager.tsx:173:19",id:"colorWarning",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{"code-path":"src/components/monitor/AlertManager.tsx:174:21",offset:"5%",stopColor:"#f59e0b",stopOpacity:.3}),e.jsx("stop",{"code-path":"src/components/monitor/AlertManager.tsx:175:21",offset:"95%",stopColor:"#f59e0b",stopOpacity:0})]})]}),e.jsx(je,{"code-path":"src/components/monitor/AlertManager.tsx:178:17",strokeDasharray:"3 3",stroke:"#1e293b"}),e.jsx(ue,{"code-path":"src/components/monitor/AlertManager.tsx:179:17",dataKey:"time",stroke:"#475569",fontSize:12}),e.jsx(Ne,{"code-path":"src/components/monitor/AlertManager.tsx:180:17",stroke:"#475569",fontSize:12}),e.jsx(ve,{"code-path":"src/components/monitor/AlertManager.tsx:181:17",contentStyle:{backgroundColor:"#0f172a",border:"1px solid #1e293b",borderRadius:"6px",color:"#f8fafc"}}),e.jsx(Q,{"code-path":"src/components/monitor/AlertManager.tsx:189:17",type:"monotone",dataKey:"critical",stroke:"#ef4444",fillOpacity:1,fill:"url(#colorCritical)",name:"严重"}),e.jsx(Q,{"code-path":"src/components/monitor/AlertManager.tsx:197:17",type:"monotone",dataKey:"warning",stroke:"#f59e0b",fillOpacity:1,fill:"url(#colorWarning)",name:"警告"})]})})})})]}),e.jsxs(me,{"code-path":"src/components/monitor/AlertManager.tsx:212:7",value:m,onValueChange:T,className:"w-full",children:[e.jsxs(de,{"code-path":"src/components/monitor/AlertManager.tsx:213:9",className:"bg-slate-800 border border-slate-700",children:[e.jsx(H,{"code-path":"src/components/monitor/AlertManager.tsx:214:11",value:"events",className:"data-[state=active]:bg-slate-700",children:"告警事件"}),e.jsx(H,{"code-path":"src/components/monitor/AlertManager.tsx:217:11",value:"rules",className:"data-[state=active]:bg-slate-700",children:"告警规则"})]}),e.jsx(I,{"code-path":"src/components/monitor/AlertManager.tsx:223:9",value:"events",children:e.jsx(Te,{"code-path":"src/components/monitor/AlertManager.tsx:224:11",alerts:d,loading:h,onReload:v})}),e.jsx(I,{"code-path":"src/components/monitor/AlertManager.tsx:227:9",value:"rules",children:e.jsx(ye,{"code-path":"src/components/monitor/AlertManager.tsx:228:11",rules:u,notifyChannels:r,onReload:v,onEditRule:S})})]}),e.jsx(ge,{"code-path":"src/components/monitor/AlertManager.tsx:239:7",open:C,onOpenChange:j,editingRule:y,notifyChannels:r,onSaved:v}),e.jsx(we,{"code-path":"src/components/monitor/AlertManager.tsx:246:7",open:x,onOpenChange:t,notifyChannels:r,onChannelsChanged:v})]})}export{$e as AlertManager};