From 310196a791232da73e0da132ca02f57e65622e20 Mon Sep 17 00:00:00 2001 From: attacker Date: Fri, 26 Jun 2026 15:31:34 +0000 Subject: [PATCH] =?UTF-8?q?chore:=20gitignore=20=E6=8E=92=E9=99=A4?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E6=9E=84=E5=BB=BA=E4=BA=A7=E7=89=A9=20backen?= =?UTF-8?q?d/static/=20(111=20hash=20=E6=96=87=E4=BB=B6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .../static/assets/AIAlertAnalyzer-DPUeFL9p.js | 57 ---------- .../static/assets/AIOpsAssistant-D417_BSh.js | 19 ---- .../assets/AIPredictiveAnalytics-C1OkILDZ.js | 1 - backend/static/assets/AlertCenter-B1Dd-7wT.js | 1 - .../static/assets/AlertManager-Dt5F96tv.js | 1 - .../static/assets/AlertRuleDialog-BmYLySxp.js | 14 --- .../static/assets/ApprovalAppPage-CmDNSgHZ.js | 1 - .../assets/ApprovalCategoryPage-CA91WuCS.js | 1 - .../static/assets/ApprovalFlow-D6IpuZ50.js | 1 - .../assets/ApprovalPermissionPage-B9wgkK5L.js | 1 - .../assets/ApprovalResourcePage-E5m3aGX_.js | 1 - .../assets/ApprovalWorkflowPage-Cv6LjE48.js | 1 - backend/static/assets/AreaChart-yrR-Mxho.js | 61 ----------- .../assets/AuditOperationsTab-D8YChYS8.js | 1 - .../static/assets/CapacityPage-BOU6J8mE.js | 1 - .../assets/CloudAccountManager-CAH48BOY.js | 1 - .../static/assets/CloudBilling-BR3942nv.js | 1 - .../assets/ClusterOverviewPage-BoH2T6EJ.js | 1 - .../assets/CredentialManager-B4HbhIHz.js | 1 - .../static/assets/CronJobManager-C85uFdSz.js | 2 - backend/static/assets/Dashboard-jrJNQyDv.js | 4 - .../static/assets/DatasourcePage-DDZGHQYv.js | 1 - .../assets/DeployCredentials-Czv2LRln.js | 1 - backend/static/assets/DeployRBAC-BpXCLjj-.js | 1 - .../assets/DeploymentDetailPage-C2S9vbFs.js | 27 ----- .../static/assets/DomainManager-BVDiC0aB.js | 1 - backend/static/assets/EventTable-BaH7H8dT.js | 1 - backend/static/assets/EventsPage-CuT9Baqe.js | 1 - .../assets/GrafanaDashboard-9Clwln0E.js | 3 - backend/static/assets/HostMonitor-C6-o-ZDP.js | 1 - .../assets/K8sShortcutRedirect-L8Wq0IVi.js | 1 - .../assets/KubernetesClusters-XXR1jnN_.js | 10 -- .../static/assets/KubernetesNodes-Dtu2Ku7B.js | 1 - backend/static/assets/LogCenter-5z6NCoZg.js | 1 - .../static/assets/LoginLogsTab-8Twk1DRE.js | 1 - .../static/assets/MetricsExplorer-Db8y37-1.js | 1 - .../static/assets/MonitorCenter-CkAJXvtS.js | 1 - .../NamespaceManagementPage-CJJFp4Vm.js | 1 - .../assets/NamespaceOverviewPage-3EiRcdjy.js | 1 - .../assets/NamespaceResourcePage-llU4EE7M.js | 1 - .../static/assets/NodeDetailPage-C77WC8d_.js | 1 - .../static/assets/PipelineEditor-SgC_ThAp.js | 1 - .../static/assets/PipelineManager-GqwxvUIC.js | 1 - .../assets/PipelineRunDetail-D2Z0DKgo.js | 3 - .../static/assets/PlatformManager-DX8QfUd6.js | 1 - .../static/assets/PodFileBrowser-B-U8iHmY.js | 13 --- .../static/assets/PodMetricsPage-B8c-1jY7.js | 1 - backend/static/assets/ProfilePage-CG_6vD9d.js | 5 - .../static/assets/RegionManager-SQdvSTOO.js | 1 - .../assets/ResourceVisualEditor-BN2gGuH7.js | 1 - .../static/assets/ScriptManager-B_bCZqNG.js | 17 --- .../static/assets/ServerManager-DRO89iT_.js | 11 -- .../static/assets/SystemManager-B0EwYBti.js | 2 - .../assets/TerminalAuditTab-YhauEueR.js | 3 - .../static/assets/TopologyView-DC9BVIj6.js | 2 - .../static/assets/TraceManager-DC1TurMY.js | 1 - .../assets/UserGroupsManager-DaLDKm1_.js | 1 - .../assets/WorkloadViewPage-C6RjHvRS.js | 1 - backend/static/assets/account--x8iUlBA.js | 1 - backend/static/assets/agent-CZzlLHxR.js | 1 - backend/static/assets/ai-D8ZhLQOB.js | 4 - .../static/assets/alert-center-Dr8niqD0.js | 1 - backend/static/assets/alert-v1WaPeEX.js | 1 - backend/static/assets/approval-BY_CqGOr.js | 1 - backend/static/assets/audit-BpVBSeA1.js | 1 - backend/static/assets/automation-C9TdY9Jc.js | 1 - backend/static/assets/badge-CGJlVD3L.js | 1 - backend/static/assets/billing-DhtxUWwz.js | 1 - backend/static/assets/card-BIfzBCEy.js | 1 - backend/static/assets/checkbox-Bu55mX0G.js | 1 - .../assets/code-snippet-block-E9P2jHS4.js | 1 - backend/static/assets/config-BrfI0oO-.js | 1 - backend/static/assets/credential-Cu8tj7EE.js | 1 - backend/static/assets/dashboard-D0JujfHp.js | 1 - backend/static/assets/datasource-DsDBrwno.js | 1 - backend/static/assets/grafana-DTc3taUi.js | 1 - backend/static/assets/index-38xDxc7G.js | 1 - backend/static/assets/index-5FEebgvX.js | 1 - backend/static/assets/index-Dungj95X.js | 103 ------------------ backend/static/assets/index-GY9Szy-F.css | 1 - backend/static/assets/index-drGq01ok.js | 2 - backend/static/assets/input-CXoUQQLm.js | 1 - backend/static/assets/js-yaml-37NdyH6G.js | 32 ------ .../static/assets/k8s-yaml-utils-4KZB_Bq_.js | 8 -- backend/static/assets/label-CMpUoC87.js | 1 - backend/static/assets/log-center-ELxahGiS.js | 1 - backend/static/assets/metrics-DW1ylkmD.js | 1 - backend/static/assets/pipeline-DO4lDm_n.js | 1 - backend/static/assets/platform-BwZ5CngP.js | 1 - backend/static/assets/region-CNZ3vwAq.js | 1 - backend/static/assets/select-CiTqGGhE.js | 1 - backend/static/assets/server-P3fi-cmJ.js | 1 - backend/static/assets/site-Cslo2fp0.js | 1 - backend/static/assets/stat-strip-BSQFwFzG.js | 1 - backend/static/assets/switch-Bxiq4EHp.js | 1 - backend/static/assets/table-B2F10oba.js | 1 - backend/static/assets/tabs-D87nAyJR.js | 1 - backend/static/assets/terminal-D5kNzib0.js | 1 - backend/static/assets/textarea-BxfjmLq5.js | 1 - backend/static/assets/trace-L8uY5gM3.js | 1 - backend/static/assets/unwrap-DPwG25JA.js | 1 - backend/static/assets/use-toast-DNZLibQY.js | 1 - backend/static/assets/useMutation-BkCR1EeO.js | 1 - .../assets/vendor-codemirror-B1SGo4xl.js | 12 -- .../static/assets/vendor-icons-DmqcWdzX.js | 1 - .../static/assets/vendor-xterm-20M9KZE1.js | 9 -- .../static/assets/vendor-xterm-DXOU9pbP.css | 1 - backend/static/assets/xterm-utils-slbfdUHf.js | 1 - backend/static/favicon.ico | Bin 4632 -> 0 bytes backend/static/favicon.svg | 21 ---- backend/static/index.html | 18 --- 112 files changed, 1 insertion(+), 546 deletions(-) delete mode 100644 backend/static/assets/AIAlertAnalyzer-DPUeFL9p.js delete mode 100644 backend/static/assets/AIOpsAssistant-D417_BSh.js delete mode 100644 backend/static/assets/AIPredictiveAnalytics-C1OkILDZ.js delete mode 100644 backend/static/assets/AlertCenter-B1Dd-7wT.js delete mode 100644 backend/static/assets/AlertManager-Dt5F96tv.js delete mode 100644 backend/static/assets/AlertRuleDialog-BmYLySxp.js delete mode 100644 backend/static/assets/ApprovalAppPage-CmDNSgHZ.js delete mode 100644 backend/static/assets/ApprovalCategoryPage-CA91WuCS.js delete mode 100644 backend/static/assets/ApprovalFlow-D6IpuZ50.js delete mode 100644 backend/static/assets/ApprovalPermissionPage-B9wgkK5L.js delete mode 100644 backend/static/assets/ApprovalResourcePage-E5m3aGX_.js delete mode 100644 backend/static/assets/ApprovalWorkflowPage-Cv6LjE48.js delete mode 100644 backend/static/assets/AreaChart-yrR-Mxho.js delete mode 100644 backend/static/assets/AuditOperationsTab-D8YChYS8.js delete mode 100644 backend/static/assets/CapacityPage-BOU6J8mE.js delete mode 100644 backend/static/assets/CloudAccountManager-CAH48BOY.js delete mode 100644 backend/static/assets/CloudBilling-BR3942nv.js delete mode 100644 backend/static/assets/ClusterOverviewPage-BoH2T6EJ.js delete mode 100644 backend/static/assets/CredentialManager-B4HbhIHz.js delete mode 100644 backend/static/assets/CronJobManager-C85uFdSz.js delete mode 100644 backend/static/assets/Dashboard-jrJNQyDv.js delete mode 100644 backend/static/assets/DatasourcePage-DDZGHQYv.js delete mode 100644 backend/static/assets/DeployCredentials-Czv2LRln.js delete mode 100644 backend/static/assets/DeployRBAC-BpXCLjj-.js delete mode 100644 backend/static/assets/DeploymentDetailPage-C2S9vbFs.js delete mode 100644 backend/static/assets/DomainManager-BVDiC0aB.js delete mode 100644 backend/static/assets/EventTable-BaH7H8dT.js delete mode 100644 backend/static/assets/EventsPage-CuT9Baqe.js delete mode 100644 backend/static/assets/GrafanaDashboard-9Clwln0E.js delete mode 100644 backend/static/assets/HostMonitor-C6-o-ZDP.js delete mode 100644 backend/static/assets/K8sShortcutRedirect-L8Wq0IVi.js delete mode 100644 backend/static/assets/KubernetesClusters-XXR1jnN_.js delete mode 100644 backend/static/assets/KubernetesNodes-Dtu2Ku7B.js delete mode 100644 backend/static/assets/LogCenter-5z6NCoZg.js delete mode 100644 backend/static/assets/LoginLogsTab-8Twk1DRE.js delete mode 100644 backend/static/assets/MetricsExplorer-Db8y37-1.js delete mode 100644 backend/static/assets/MonitorCenter-CkAJXvtS.js delete mode 100644 backend/static/assets/NamespaceManagementPage-CJJFp4Vm.js delete mode 100644 backend/static/assets/NamespaceOverviewPage-3EiRcdjy.js delete mode 100644 backend/static/assets/NamespaceResourcePage-llU4EE7M.js delete mode 100644 backend/static/assets/NodeDetailPage-C77WC8d_.js delete mode 100644 backend/static/assets/PipelineEditor-SgC_ThAp.js delete mode 100644 backend/static/assets/PipelineManager-GqwxvUIC.js delete mode 100644 backend/static/assets/PipelineRunDetail-D2Z0DKgo.js delete mode 100644 backend/static/assets/PlatformManager-DX8QfUd6.js delete mode 100644 backend/static/assets/PodFileBrowser-B-U8iHmY.js delete mode 100644 backend/static/assets/PodMetricsPage-B8c-1jY7.js delete mode 100644 backend/static/assets/ProfilePage-CG_6vD9d.js delete mode 100644 backend/static/assets/RegionManager-SQdvSTOO.js delete mode 100644 backend/static/assets/ResourceVisualEditor-BN2gGuH7.js delete mode 100644 backend/static/assets/ScriptManager-B_bCZqNG.js delete mode 100644 backend/static/assets/ServerManager-DRO89iT_.js delete mode 100644 backend/static/assets/SystemManager-B0EwYBti.js delete mode 100644 backend/static/assets/TerminalAuditTab-YhauEueR.js delete mode 100644 backend/static/assets/TopologyView-DC9BVIj6.js delete mode 100644 backend/static/assets/TraceManager-DC1TurMY.js delete mode 100644 backend/static/assets/UserGroupsManager-DaLDKm1_.js delete mode 100644 backend/static/assets/WorkloadViewPage-C6RjHvRS.js delete mode 100644 backend/static/assets/account--x8iUlBA.js delete mode 100644 backend/static/assets/agent-CZzlLHxR.js delete mode 100644 backend/static/assets/ai-D8ZhLQOB.js delete mode 100644 backend/static/assets/alert-center-Dr8niqD0.js delete mode 100644 backend/static/assets/alert-v1WaPeEX.js delete mode 100644 backend/static/assets/approval-BY_CqGOr.js delete mode 100644 backend/static/assets/audit-BpVBSeA1.js delete mode 100644 backend/static/assets/automation-C9TdY9Jc.js delete mode 100644 backend/static/assets/badge-CGJlVD3L.js delete mode 100644 backend/static/assets/billing-DhtxUWwz.js delete mode 100644 backend/static/assets/card-BIfzBCEy.js delete mode 100644 backend/static/assets/checkbox-Bu55mX0G.js delete mode 100644 backend/static/assets/code-snippet-block-E9P2jHS4.js delete mode 100644 backend/static/assets/config-BrfI0oO-.js delete mode 100644 backend/static/assets/credential-Cu8tj7EE.js delete mode 100644 backend/static/assets/dashboard-D0JujfHp.js delete mode 100644 backend/static/assets/datasource-DsDBrwno.js delete mode 100644 backend/static/assets/grafana-DTc3taUi.js delete mode 100644 backend/static/assets/index-38xDxc7G.js delete mode 100644 backend/static/assets/index-5FEebgvX.js delete mode 100644 backend/static/assets/index-Dungj95X.js delete mode 100644 backend/static/assets/index-GY9Szy-F.css delete mode 100644 backend/static/assets/index-drGq01ok.js delete mode 100644 backend/static/assets/input-CXoUQQLm.js delete mode 100644 backend/static/assets/js-yaml-37NdyH6G.js delete mode 100644 backend/static/assets/k8s-yaml-utils-4KZB_Bq_.js delete mode 100644 backend/static/assets/label-CMpUoC87.js delete mode 100644 backend/static/assets/log-center-ELxahGiS.js delete mode 100644 backend/static/assets/metrics-DW1ylkmD.js delete mode 100644 backend/static/assets/pipeline-DO4lDm_n.js delete mode 100644 backend/static/assets/platform-BwZ5CngP.js delete mode 100644 backend/static/assets/region-CNZ3vwAq.js delete mode 100644 backend/static/assets/select-CiTqGGhE.js delete mode 100644 backend/static/assets/server-P3fi-cmJ.js delete mode 100644 backend/static/assets/site-Cslo2fp0.js delete mode 100644 backend/static/assets/stat-strip-BSQFwFzG.js delete mode 100644 backend/static/assets/switch-Bxiq4EHp.js delete mode 100644 backend/static/assets/table-B2F10oba.js delete mode 100644 backend/static/assets/tabs-D87nAyJR.js delete mode 100644 backend/static/assets/terminal-D5kNzib0.js delete mode 100644 backend/static/assets/textarea-BxfjmLq5.js delete mode 100644 backend/static/assets/trace-L8uY5gM3.js delete mode 100644 backend/static/assets/unwrap-DPwG25JA.js delete mode 100644 backend/static/assets/use-toast-DNZLibQY.js delete mode 100644 backend/static/assets/useMutation-BkCR1EeO.js delete mode 100644 backend/static/assets/vendor-codemirror-B1SGo4xl.js delete mode 100644 backend/static/assets/vendor-icons-DmqcWdzX.js delete mode 100644 backend/static/assets/vendor-xterm-20M9KZE1.js delete mode 100644 backend/static/assets/vendor-xterm-DXOU9pbP.css delete mode 100644 backend/static/assets/xterm-utils-slbfdUHf.js delete mode 100644 backend/static/favicon.ico delete mode 100644 backend/static/favicon.svg delete mode 100644 backend/static/index.html diff --git a/.gitignore b/.gitignore index 8f14b87..a597aa9 100644 --- a/.gitignore +++ b/.gitignore @@ -77,6 +77,7 @@ agent/aiops-agent agent/bin/ # embed 模式临时目录(前端构建产物,编译后清理) +backend/static/ backend/cmd/static/ # Hermes agent config (personal, not project) diff --git a/backend/static/assets/AIAlertAnalyzer-DPUeFL9p.js b/backend/static/assets/AIAlertAnalyzer-DPUeFL9p.js deleted file mode 100644 index 9f9a3d7..0000000 --- a/backend/static/assets/AIAlertAnalyzer-DPUeFL9p.js +++ /dev/null @@ -1,57 +0,0 @@ -import{j as s,r as l}from"./vendor-codemirror-B1SGo4xl.js";import{C as b,b as v,c as w,a as C}from"./card-BIfzBCEy.js";import{B as y}from"./badge-CGJlVD3L.js";import{q as z,B as A,D as O,a as U,b as B,c as J,d as E}from"./index-Dungj95X.js";import{a as L}from"./alert-v1WaPeEX.js";import{a as G}from"./ai-D8ZhLQOB.js";import{aD as R,aA as g,L as $,ab as D,aa as F,y as f,F as H,r as S,z as P,w as K,az as q,l as _,h as X,b as Q,a as W}from"./vendor-icons-DmqcWdzX.js";function Y(e){const c=(e.metric||"").toLowerCase(),t=e.source||"目标主机",a=e.severity==="critical";return c.includes("cpu")?{rootCause:`检测到 ${t} 上 CPU 使用率达到 ${e.currentValue},持续超过阈值 ${e.threshold}。可能原因:1) 某进程存在死循环或高计算负载;2) GC 频繁触发(Java/Go 应用);3) 业务流量突增导致处理能力不足。`,impact:a?"CPU 持续高负载将导致服务响应延迟显著增加,严重时可能触发雪崩效应,影响全部依赖该节点的业务。":"CPU 使用率偏高,可能导致部分请求处理变慢,建议及时排查避免进一步恶化。",recommendations:[`登录 ${t} 执行 top/htop 定位高 CPU 进程`,"检查是否有异常定时任务或批处理任务在运行","考虑临时扩容或将部分流量调度到其他节点","优化应用代码,排查是否存在低效算法或资源泄漏"],autoFixScript:`#!/bin/bash -# CPU 高负载诊断脚本 - ${t} -echo "===== CPU TOP 10 进程 =====" -ps aux --sort=-%cpu | head -11 -echo "" -echo "===== 系统负载 =====" -uptime -echo "" -echo "===== 高 CPU 进程详情 =====" -PID=$(ps aux --sort=-%cpu | sed -n '2p' | awk '{print $2}') -if [ -n "$PID" ]; then - echo "最高 CPU 进程: PID=$PID" - cat /proc/$PID/cmdline | tr '\\0' ' ' - echo "" -fi -`,similarCases:0,confidence:0}:c.includes("mem")||c.includes("ram")?{rootCause:`检测到 ${t} 内存使用率达到 ${e.currentValue},接近或超过阈值 ${e.threshold}。常见原因:1) 应用内存泄漏,对象未被正确释放;2) 缓存配置过大;3) 数据库连接池未及时释放。`,impact:a?"内存即将耗尽可能触发 OOM Killer,导致关键进程被强制终止,服务中断风险极高。":"内存持续增长,长期可能导致 OOM,建议尽快排查内存使用情况。",recommendations:[`检查 ${t} 上的内存占用最高的进程`,"如果是 Java 应用,检查 JVM 堆内存配置和 GC 日志","排查是否存在内存泄漏,必要时生成堆转储分析","调整缓存大小限制或增加交换分区"],similarCases:0,confidence:0}:c.includes("disk")||c.includes("space")?{rootCause:`检测到 ${t} 磁盘使用率达到 ${e.currentValue},超过阈值 ${e.threshold}。最常见原因:1) 日志文件未配置轮转/清理;2) 临时文件堆积;3) 数据库数据文件膨胀。`,impact:a?"磁盘空间不足可能导致服务无法写入数据/日志,数据库可能崩溃,文件系统变只读,影响范围极大。":"磁盘空间告警,如不及时清理可能导致服务异常。",recommendations:[`清理 ${t} 上 30 天前的日志文件`,"检查并清理临时目录 /tmp、/var/tmp","配置 logrotate 日志轮转策略","考虑扩容磁盘或将数据迁移到对象存储"],autoFixScript:`#!/bin/bash -# 磁盘清理脚本 - ${t} -echo "===== 清理前磁盘使用 =====" -df -h / -echo "" -echo "===== 清理 30 天前日志 =====" -find /var/log -name "*.log" -mtime +30 -delete 2>/dev/null -find /var/log -name "*.gz" -mtime +30 -delete 2>/dev/null -echo "" -echo "===== 清理系统缓存 =====" -journalctl --vacuum-time=7d 2>/dev/null -echo "" -echo "===== 清理后磁盘使用 =====" -df -h / -`,similarCases:0,confidence:0}:c.includes("net")||c.includes("latency")||c.includes("bandwidth")?{rootCause:`检测到 ${t} 网络指标异常(当前值 ${e.currentValue}),可能原因:1) 上游依赖服务响应变慢;2) 网络带宽打满;3) DNS 解析延迟;4) 连接数达到上限。`,impact:a?"网络异常将导致所有经过该节点的请求超时,影响所有上游业务的可用性。":"网络延迟偏高,可能影响用户体验,建议排查网络链路。",recommendations:[`检查 ${t} 的网络连接和带宽使用情况`,"排查上游依赖服务的健康状态和响应时间","检查防火墙规则是否有限速或异常丢弃","考虑启用熔断/降级机制保障核心链路"],similarCases:0,confidence:0}:c.includes("service")||c.includes("up")||c.includes("avail")?{rootCause:`检测到 ${t} 服务不可用(指标 ${e.metric} = ${e.currentValue})。可能原因:1) 进程崩溃或被 OOM Killer 终止;2) 端口被占用或监听异常;3) 健康检查端点返回错误;4) 配置文件错误导致启动失败。`,impact:a?"服务完全不可用,所有依赖该服务的业务功能将中断,需要立即处理。":"服务可用性下降,部分功能可能受影响。",recommendations:[`立即检查 ${t} 的服务状态: systemctl status `,"查看服务日志排查崩溃原因","检查端口占用和监听状态: ss -tlnp","必要时重启服务并监控恢复情况"],autoFixScript:`#!/bin/bash -# 服务恢复脚本 - ${t} -echo "===== 检查服务状态 =====" -systemctl list-units --state=failed -echo "" -echo "===== 检查端口监听 =====" -ss -tlnp | grep -E ':(80|443|8080|3306|6379|9090)' -echo "" -echo "===== 重启失败服务 =====" -systemctl reset-failed -`,similarCases:0,confidence:0}:{rootCause:`检测到 ${t} 触发告警「${e.name}」,当前指标值 ${e.currentValue} 超过阈值 ${e.threshold}。建议进一步排查具体指标数据和相关日志以确定根因。`,impact:a?"该告警级别为严重,可能影响业务正常运行,建议优先处理。":"该告警需要关注,持续恶化可能影响系统稳定性。",recommendations:[`查看 ${t} 的监控仪表盘,确认指标趋势`,"检查对应时间段的系统日志和应用日志","关联同时间段的其他告警,排查是否有连锁反应","若确认误报,调整告警规则阈值或持续时间"],similarCases:0,confidence:0}}function Z(e){const c=e.rule?.expression||"",t=c.match(/([\w_]+)\s*[><=!]+\s*([\d.]+)/),a=t?t[1]:c||"unknown",n=t?t[2]+"%":"-",r=e.value??0,d=a.includes("usage")||a.includes("cpu")||a.includes("disk")||a.includes("mem")?r.toFixed(1)+"%":r.toFixed(2),x=e.resolved_at?new Date(e.resolved_at):new Date,i=new Date(e.started_at),p=Math.max(1,Math.round((x.getTime()-i.getTime())/6e4)),h=p>=60?`${Math.floor(p/60)}小时${p%60}分钟`:`${p}分钟`,u=i.toLocaleString("zh-CN",{hour12:!1});return{id:String(e.id),name:e.rule_name||e.rule?.name||"未知告警",severity:e.severity==="critical"?"critical":e.severity==="warning"?"warning":"info",status:e.status==="firing"?"active":"resolved",source:e.target||"未知目标",metric:a,threshold:n,currentValue:d,duration:h,startedAt:u,description:e.message&&e.message!==`告警事件 ${e.id}`?e.message:e.rule?.description||`${e.rule_name||"告警"}: ${e.target} 当前值 ${d}`}}function ss(e){switch(e){case"critical":return"bg-red-500/10 text-red-400 border-red-500/30";case"warning":return"bg-amber-500/10 text-amber-400 border-amber-500/30";default:return"bg-blue-500/10 text-blue-400 border-blue-500/30"}}function es({selectedAlert:e,isAnalyzing:c,analysis:t,onAutoFix:a}){return s.jsxs(b,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:18:5",className:"bg-slate-800 border-slate-700 flex flex-col",children:[s.jsx(v,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:19:7",className:"border-b border-slate-700 pb-3",children:s.jsxs(w,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:20:9",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(R,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:21:11",className:"h-5 w-5 text-purple-400"}),"AI 分析结果"]})}),s.jsx(z,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:25:7",className:"flex-1",children:s.jsx(C,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:26:9",className:"p-4",children:e?c?s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:33:13",className:"flex flex-col items-center justify-center h-64",children:[s.jsx($,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:34:15",className:"h-8 w-8 animate-spin text-purple-400 mb-4"}),s.jsx("p",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:35:15",className:"text-slate-400",children:"AI正在分析告警根因..."}),s.jsx("p",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:36:15",className:"text-xs text-slate-500 mt-2",children:"正在关联日志、指标和历史案例"})]}):t?s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:39:13",className:"space-y-4",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:41:15",className:"flex items-center justify-between p-3 bg-purple-500/10 rounded-lg border border-purple-500/30",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:42:17",className:"flex items-center gap-2",children:[s.jsx(g,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:43:19",className:"h-5 w-5 text-purple-400"}),s.jsx("span",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:44:19",className:"text-slate-300",children:"分析置信度"})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:46:17",className:"flex items-center gap-2",children:[s.jsx("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:47:19",className:"w-32 h-2 bg-slate-700 rounded-full overflow-hidden",children:s.jsx("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:48:21",className:"h-full bg-gradient-to-r from-purple-500 to-pink-500",style:{width:`${t.confidence}%`}})}),s.jsxs("span",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:53:19",className:"text-purple-400 font-bold",children:[t.confidence,"%"]})]})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:58:15",className:"space-y-2",children:[s.jsxs("h4",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:59:17",className:"text-sm font-medium text-slate-300 flex items-center gap-2",children:[s.jsx(D,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:60:19",className:"h-4 w-4 text-red-400"}),"根因分析"]}),s.jsx("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:63:17",className:"p-3 bg-slate-900 rounded-lg border border-slate-700",children:s.jsx("p",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:64:19",className:"text-sm text-slate-300 leading-relaxed",children:t.rootCause})})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:69:15",className:"space-y-2",children:[s.jsxs("h4",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:70:17",className:"text-sm font-medium text-slate-300 flex items-center gap-2",children:[s.jsx(F,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:71:19",className:"h-4 w-4 text-amber-400"}),"影响范围"]}),s.jsx("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:74:17",className:"p-3 bg-slate-900 rounded-lg border border-slate-700",children:s.jsx("p",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:75:19",className:"text-sm text-slate-300 leading-relaxed",children:t.impact})})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:80:15",className:"space-y-2",children:[s.jsxs("h4",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:81:17",className:"text-sm font-medium text-slate-300 flex items-center gap-2",children:[s.jsx(f,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:82:19",className:"h-4 w-4 text-emerald-400"}),"修复建议"]}),s.jsx("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:85:17",className:"space-y-2",children:t.recommendations.map((n,r)=>s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:87:21",className:"flex items-start gap-2 p-2 bg-slate-900 rounded-lg border border-slate-700",children:[s.jsx("span",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:91:23",className:"flex-shrink-0 w-5 h-5 rounded-full bg-emerald-500/20 text-emerald-400 flex items-center justify-center text-xs",children:r+1}),s.jsx("span",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:94:23",className:"text-sm text-slate-300",children:n})]},r))})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:101:15",className:"flex items-center gap-2 p-3 bg-slate-900 rounded-lg border border-slate-700",children:[s.jsx(H,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:102:17",className:"h-4 w-4 text-blue-400"}),s.jsxs("span",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:103:17",className:"text-sm text-slate-400",children:["发现 ",s.jsx("span",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:104:22",className:"text-blue-400 font-medium",children:t.similarCases})," 个相似历史案例"]})]}),t.autoFixScript&&s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:110:17",className:"space-y-2",children:[s.jsxs("h4",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:111:19",className:"text-sm font-medium text-slate-300 flex items-center gap-2",children:[s.jsx(S,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:112:21",className:"h-4 w-4 text-purple-400"}),"自动修复脚本"]}),s.jsx("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:115:19",className:"p-3 bg-slate-950 rounded-lg border border-slate-700",children:s.jsx("pre",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:116:21",className:"text-xs text-slate-400 overflow-x-auto",children:t.autoFixScript})}),s.jsxs(A,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:118:19",className:"w-full bg-purple-600 hover:bg-purple-700",onClick:a,children:[s.jsx(P,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:122:21",className:"h-4 w-4 mr-2"}),"执行自动修复"]})]})]}):null:s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:28:13",className:"flex flex-col items-center justify-center h-64 text-slate-500",children:[s.jsx(g,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:29:15",className:"h-16 w-16 mb-4 opacity-30"}),s.jsx("p",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:30:15",children:"选择左侧告警进行AI智能分析"})]})})})]})}function ts({open:e,onOpenChange:c,script:t}){const[a,n]=l.useState(!1),r=()=>{t&&(navigator.clipboard.writeText(t),n(!0),setTimeout(()=>n(!1),2e3))};return s.jsx(O,{"code-path":"src/components/aiops/AutoFixDialog.tsx:31:5",open:e,onOpenChange:c,children:s.jsxs(U,{"code-path":"src/components/aiops/AutoFixDialog.tsx:32:7",className:"max-w-2xl bg-slate-900 border-slate-700 text-slate-100",children:[s.jsxs(B,{"code-path":"src/components/aiops/AutoFixDialog.tsx:33:9",children:[s.jsxs(J,{"code-path":"src/components/aiops/AutoFixDialog.tsx:34:11",className:"flex items-center gap-2",children:[s.jsx(S,{"code-path":"src/components/aiops/AutoFixDialog.tsx:35:13",className:"h-5 w-5 text-purple-400"}),"自动修复脚本"]}),s.jsx(E,{"code-path":"src/components/aiops/AutoFixDialog.tsx:38:11",className:"text-slate-500",children:"AI生成的自动修复脚本,请确认后执行"})]}),s.jsxs("div",{"code-path":"src/components/aiops/AutoFixDialog.tsx:42:9",className:"space-y-4 py-4",children:[s.jsxs("div",{"code-path":"src/components/aiops/AutoFixDialog.tsx:43:11",className:"p-4 bg-slate-950 rounded-lg border border-slate-700",children:[s.jsxs("div",{"code-path":"src/components/aiops/AutoFixDialog.tsx:44:13",className:"flex items-center justify-between mb-2",children:[s.jsx("span",{"code-path":"src/components/aiops/AutoFixDialog.tsx:45:15",className:"text-sm text-slate-400",children:"修复脚本"}),s.jsx(A,{"code-path":"src/components/aiops/AutoFixDialog.tsx:46:15",variant:"ghost",size:"sm",onClick:r,className:"text-slate-400",children:a?s.jsx(K,{"code-path":"src/components/aiops/AutoFixDialog.tsx:47:27",className:"h-4 w-4"}):s.jsx(q,{"code-path":"src/components/aiops/AutoFixDialog.tsx:47:59",className:"h-4 w-4"})})]}),s.jsx("pre",{"code-path":"src/components/aiops/AutoFixDialog.tsx:50:13",className:"text-sm text-slate-300 overflow-x-auto whitespace-pre-wrap",children:t})]}),s.jsxs("div",{"code-path":"src/components/aiops/AutoFixDialog.tsx:54:11",className:"flex items-center gap-2 p-3 bg-amber-500/10 rounded-lg border border-amber-500/30",children:[s.jsx(_,{"code-path":"src/components/aiops/AutoFixDialog.tsx:55:13",className:"h-4 w-4 text-amber-400"}),s.jsx("span",{"code-path":"src/components/aiops/AutoFixDialog.tsx:56:13",className:"text-sm text-amber-400",children:"警告:执行脚本前请确保已备份重要数据"})]})]}),s.jsxs("div",{"code-path":"src/components/aiops/AutoFixDialog.tsx:61:9",className:"flex gap-2",children:[s.jsx(A,{"code-path":"src/components/aiops/AutoFixDialog.tsx:62:11",variant:"outline",className:"flex-1 border-slate-700 text-slate-300",onClick:()=>c(!1),children:"取消"}),s.jsxs(A,{"code-path":"src/components/aiops/AutoFixDialog.tsx:65:11",className:"flex-1 bg-purple-600 hover:bg-purple-700",onClick:()=>c(!1),children:[s.jsx(P,{"code-path":"src/components/aiops/AutoFixDialog.tsx:66:13",className:"h-4 w-4 mr-2"}),"确认执行"]})]})]})})}function as(e,c){try{let t=e.replace(/```(?:json)?\s*\n?/g,"").replace(/```$/,"").trim();const a=JSON.parse(t);return{rootCause:a.root_cause||a.rootCause||c.rootCause,impact:a.impact||c.impact,recommendations:Array.isArray(a.recommendations)?a.recommendations:c.recommendations,autoFixScript:a.auto_fix_script||a.autoFixScript||c.autoFixScript,similarCases:typeof a.similar_cases=="number"?a.similar_cases:a.similarCases??c.similarCases,confidence:typeof a.confidence=="number"?a.confidence:c.confidence}}catch{return{...c,rootCause:e}}}function ds(){const[e,c]=l.useState([]),[t,a]=l.useState(!0),[n,r]=l.useState(null),[j,d]=l.useState(!1),[x,i]=l.useState(null),[p,h]=l.useState(!1);l.useEffect(()=>{u()},[]);const u=async()=>{a(!0);try{const o=await L.getAlerts({page:1,page_size:50}),m=o?.list||o||[];c(m.map(Z))}catch(o){console.error("加载告警失败:",o),c([])}finally{a(!1)}},T=async o=>{r(o),d(!0),i(null);const m=Y(o);try{const M=`你是运维专家。请分析以下告警并以 JSON 格式回复(不要 markdown 代码块)。 - -告警名称:${o.name} -严重程度:${o.severity} -目标:${o.source} -指标:${o.metric} = ${o.currentValue}(阈值 ${o.threshold}) -持续:${o.duration} -描述:${o.description} - -返回 JSON 格式(字段名用 snake_case): -{ - "root_cause": "根因分析(2-3句)", - "impact": "影响评估(1-2句)", - "recommendations": ["建议1", "建议2", "建议3"], - "auto_fix_script": "#!/bin/bash\\n...\\n(可选的自动修复脚本,无则 null)", - "similar_cases": 数字(类似案例数预估), - "confidence": 数字(0-100 置信度) -}`,N=await G.chat([{role:"user",content:M}]),I=N?.content||N?.message?.content||"";i(I?as(I,m):m)}catch{i(m)}finally{d(!1)}},k=()=>{h(!0)},V=o=>{switch(o){case"critical":return s.jsx(W,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:128:16",className:"h-4 w-4 text-red-400"});case"warning":return s.jsx(D,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:130:16",className:"h-4 w-4 text-amber-400"});default:return s.jsx(f,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:132:16",className:"h-4 w-4 text-blue-400"})}};return s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:137:5",className:"space-y-6",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:139:7",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:140:9",className:"flex items-center gap-3",children:[s.jsx("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:141:11",className:"w-10 h-10 rounded-lg bg-gradient-to-br from-amber-500 to-orange-500 flex items-center justify-center",children:s.jsx(g,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:142:13",className:"h-5 w-5 text-white"})}),s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:144:11",children:[s.jsx("h1",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:145:13",className:"text-2xl font-bold text-slate-100",children:"AI 告警智能分析"}),s.jsx("p",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:146:13",className:"text-sm text-slate-500",children:"基于大模型的告警根因分析和自动修复建议"})]})]}),s.jsx("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:149:9",className:"flex items-center gap-2",children:s.jsxs(y,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:150:11",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:[s.jsx(R,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:151:13",className:"h-3 w-3 mr-1"}),"AI 引擎运行中"]})})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:157:7",className:"grid grid-cols-2 gap-6 h-[calc(100vh-200px)]",children:[s.jsxs(b,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:159:9",className:"bg-slate-800 border-slate-700 flex flex-col",children:[s.jsx(v,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:160:11",className:"border-b border-slate-700 pb-3",children:s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:161:13",className:"flex items-center justify-between",children:[s.jsxs(w,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:162:15",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(_,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:163:17",className:"h-5 w-5 text-amber-400"}),"活跃告警"]}),s.jsxs(y,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:166:15",className:"bg-red-500/10 text-red-400 border-red-500/30",children:[e.filter(o=>o.status==="active").length," 个活跃"]})]})}),s.jsx(z,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:171:11",className:"flex-1",children:s.jsx(C,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:172:13",className:"p-4 space-y-3",children:t?s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:174:17",className:"flex flex-col items-center justify-center h-32",children:[s.jsx($,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:175:19",className:"h-6 w-6 animate-spin text-slate-500 mb-2"}),s.jsx("p",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:176:19",className:"text-sm text-slate-500",children:"加载告警数据..."})]}):e.length===0?s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:179:17",className:"flex flex-col items-center justify-center h-32 text-slate-500",children:[s.jsx(f,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:180:19",className:"h-8 w-8 mb-2 opacity-50"}),s.jsx("p",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:181:19",className:"text-sm",children:"暂无告警事件"})]}):e.map(o=>s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:185:17",className:`p-4 rounded-lg border cursor-pointer transition-all ${n?.id===o.id?"border-purple-500 bg-purple-500/10":"border-slate-700 bg-slate-800/50 hover:border-slate-600"}`,onClick:()=>T(o),children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:194:19",className:"flex items-start justify-between mb-2",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:195:21",className:"flex items-center gap-2",children:[V(o.severity),s.jsx("span",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:197:23",className:"font-medium text-slate-100",children:o.name})]}),s.jsx(y,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:199:21",variant:"outline",className:ss(o.severity),children:o.severity==="critical"?"严重":o.severity==="warning"?"警告":"提示"})]}),s.jsx("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:203:19",className:"text-sm text-slate-400 mb-2",children:o.description}),s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:204:19",className:"flex items-center gap-4 text-xs text-slate-500",children:[s.jsxs("span",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:205:21",className:"flex items-center gap-1",children:[s.jsx(X,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:206:23",className:"h-3 w-3"}),o.source]}),s.jsxs("span",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:209:21",className:"flex items-center gap-1",children:[s.jsx(Q,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:210:23",className:"h-3 w-3"}),o.duration]}),s.jsxs("span",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:213:21",className:"flex items-center gap-1",children:[s.jsx(F,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:214:23",className:"h-3 w-3"}),o.currentValue]})]})]},o.id))})})]}),s.jsx(es,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:226:9",selectedAlert:n,isAnalyzing:j,analysis:x,onAutoFix:k})]}),s.jsx(ts,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:235:7",open:p,onOpenChange:h,script:x?.autoFixScript})]})}export{ds as AIAlertAnalyzer}; diff --git a/backend/static/assets/AIOpsAssistant-D417_BSh.js b/backend/static/assets/AIOpsAssistant-D417_BSh.js deleted file mode 100644 index 29506eb..0000000 --- a/backend/static/assets/AIOpsAssistant-D417_BSh.js +++ /dev/null @@ -1,19 +0,0 @@ -import{r as x,j as s,b as _s}from"./vendor-codemirror-B1SGo4xl.js";import{C as D,b as T,c as Y,a as q}from"./card-BIfzBCEy.js";import{aa as ks,a1 as Es,Z as H,m as ds,B as N,q as Ls,D as Rs,a as Ms,b as Ps,c as Ds,d as Ts,e as qs,t as w}from"./index-Dungj95X.js";import{I as C}from"./input-CXoUQQLm.js";import{B as k}from"./badge-CGJlVD3L.js";import{L as y}from"./label-CMpUoC87.js";import{S as ss,a as ts,b as es,c as as,d as ns}from"./select-CiTqGGhE.js";import{S as Us}from"./switch-Bxiq4EHp.js";import{d as U}from"./dashboard-D0JujfHp.js";import{a as Bs}from"./alert-v1WaPeEX.js";import{a as Fs}from"./agent-CZzlLHxR.js";import{a as $}from"./ai-D8ZhLQOB.js";import{aA as zs,C as Hs,p as os,l as ms,A as xs,F as hs,aa as Vs,L as E,r as Ks,b6 as cs,am as Gs,ap as Ws,U as Qs,b7 as Zs,ay as Js,aR as Xs}from"./vendor-icons-DmqcWdzX.js";import"./index-5FEebgvX.js";function Ys(e,n=[]){let i=[];function r(a,d){const m=x.createContext(d);m.displayName=a+"Context";const l=i.length;i=[...i,d];const g=h=>{const{scope:u,children:c,...p}=h,A=u?.[e]?.[l]||m,j=x.useMemo(()=>p,Object.values(p));return s.jsx(A.Provider,{value:j,children:c})};g.displayName=a+"Provider";function v(h,u){const c=u?.[e]?.[l]||m,p=x.useContext(c);if(p)return p;if(d!==void 0)return d;throw new Error(`\`${h}\` must be used within \`${a}\``)}return[g,v]}const o=()=>{const a=i.map(d=>x.createContext(d));return function(m){const l=m?.[e]||a;return x.useMemo(()=>({[`__scope${e}`]:{...m,[e]:l}}),[m,l])}};return o.scopeName=e,[r,st(o,...n)]}function st(...e){const n=e[0];if(e.length===1)return n;const i=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const d=r.reduce((m,{useScope:l,scopeName:g})=>{const h=l(a)[`__scope${g}`];return{...m,...h}},{});return x.useMemo(()=>({[`__scope${n.scopeName}`]:d}),[d])}};return i.scopeName=n.scopeName,i}var tt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],V=tt.reduce((e,n)=>{const i=ks(`Primitive.${n}`),r=x.forwardRef((o,a)=>{const{asChild:d,...m}=o,l=d?i:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(l,{...m,ref:a})});return r.displayName=`Primitive.${n}`,{...e,[n]:r}},{}),B={exports:{}},F={};var rs;function et(){if(rs)return F;rs=1;var e=_s();function n(h,u){return h===u&&(h!==0||1/h===1/u)||h!==h&&u!==u}var i=typeof Object.is=="function"?Object.is:n,r=e.useState,o=e.useEffect,a=e.useLayoutEffect,d=e.useDebugValue;function m(h,u){var c=u(),p=r({inst:{value:c,getSnapshot:u}}),A=p[0].inst,j=p[1];return a(function(){A.value=c,A.getSnapshot=u,l(A)&&j({inst:A})},[h,c,u]),o(function(){return l(A)&&j({inst:A}),h(function(){l(A)&&j({inst:A})})},[h]),d(c),c}function l(h){var u=h.getSnapshot;h=h.value;try{var c=u();return!i(h,c)}catch{return!0}}function g(h,u){return u()}var v=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?g:m;return F.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:v,F}var is;function at(){return is||(is=1,B.exports=et()),B.exports}var nt=at();function ot(){return nt.useSyncExternalStore(ct,()=>!0,()=>!1)}function ct(){return()=>{}}var K="Avatar",[rt]=Ys(K),[it,us]=rt(K),As=x.forwardRef((e,n)=>{const{__scopeAvatar:i,...r}=e,[o,a]=x.useState("idle");return s.jsx(it,{scope:i,imageLoadingStatus:o,onImageLoadingStatusChange:a,children:s.jsx(V.span,{...r,ref:n})})});As.displayName=K;var fs="AvatarImage",pt=x.forwardRef((e,n)=>{const{__scopeAvatar:i,src:r,onLoadingStatusChange:o=()=>{},...a}=e,d=us(fs,i),m=lt(r,a),l=Es(g=>{o(g),d.onImageLoadingStatusChange(g)});return H(()=>{m!=="idle"&&l(m)},[m,l]),m==="loaded"?s.jsx(V.img,{...a,ref:n,src:r}):null});pt.displayName=fs;var gs="AvatarFallback",Is=x.forwardRef((e,n)=>{const{__scopeAvatar:i,delayMs:r,...o}=e,a=us(gs,i),[d,m]=x.useState(r===void 0);return x.useEffect(()=>{if(r!==void 0){const l=window.setTimeout(()=>m(!0),r);return()=>window.clearTimeout(l)}},[r]),d&&a.imageLoadingStatus!=="loaded"?s.jsx(V.span,{...o,ref:n}):null});Is.displayName=gs;function ps(e,n){return e?n?(e.src!==n&&(e.src=n),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function lt(e,{referrerPolicy:n,crossOrigin:i}){const r=ot(),o=x.useRef(null),a=r?(o.current||(o.current=new window.Image),o.current):null,[d,m]=x.useState(()=>ps(a,e));return H(()=>{m(ps(a,e))},[a,e]),H(()=>{const l=h=>()=>{m(h)};if(!a)return;const g=l("loaded"),v=l("error");return a.addEventListener("load",g),a.addEventListener("error",v),n&&(a.referrerPolicy=n),typeof i=="string"&&(a.crossOrigin=i),()=>{a.removeEventListener("load",g),a.removeEventListener("error",v)}},[a,i,n]),d}var dt=As,mt=Is;function xt({className:e,...n}){return s.jsx(dt,{"code-path":"src/components/ui/avatar.tsx:11:5","data-slot":"avatar",className:ds("relative flex size-8 shrink-0 overflow-hidden rounded-full",e),...n})}function ht({className:e,...n}){return s.jsx(mt,{"code-path":"src/components/ui/avatar.tsx:40:5","data-slot":"avatar-fallback",className:ds("bg-muted flex size-full items-center justify-center rounded-full",e),...n})}const z=[{id:"openai",name:"OpenAI",defaultEndpoint:"https://api.openai.com/v1",models:["gpt-4o-mini","gpt-4o","gpt-4-turbo"]},{id:"deepseek",name:"DeepSeek",defaultEndpoint:"https://api.deepseek.com/v1",models:["deepseek-chat","deepseek-reasoner"]},{id:"qwen",name:"通义千问 (DashScope)",defaultEndpoint:"https://dashscope.aliyuncs.com/compatible-mode/v1",models:["qwen-plus","qwen-turbo","qwen-max"]},{id:"moonshot",name:"Moonshot 月之暗面",defaultEndpoint:"https://api.moonshot.cn/v1",models:["moonshot-v1-8k","moonshot-v1-32k"]},{id:"ollama",name:"Ollama 本地",defaultEndpoint:"http://localhost:11434/v1",models:["qwen2.5:7b","llama3.2","deepseek-r1:7b"]},{id:"custom",name:"自定义 (OpenAI 兼容)",defaultEndpoint:"",models:[]}],ut={provider:"openai",model:"gpt-4o-mini",api_key:"",endpoint:"https://api.openai.com/v1",temperature:.7,max_tokens:2e3,system_prompt:"",enabled:!1};async function At(){const n=(await Bs.getAlerts({page:1,page_size:20}))?.list||[];if(!n.length)return"(当前无告警事件)";const i=n.slice(0,15).map((o,a)=>`${a+1}. [${o.severity||"未知"}|${o.status||"-"}] ${o.rule_name||"告警"} → 目标:${o.target||"-"} 值:${o.value??"-"} 时间:${(o.started_at||"").slice(0,16)}`),r=n.filter(o=>o.status==="firing").length;return`共 ${n.length} 条告警(firing ${r} 条),前 ${Math.min(15,n.length)} 条: -${i.join(` -`)}`}async function ls(){const e=await Fs.getLatest(),n=Array.isArray(e)?e:e?.list||[];if(!n.length)return"(当前无 Agent 上报数据,可能未部署监控 Agent)";const i=n.slice(0,20).map((a,d)=>{const m=a.cpu_usage??"-",l=a.mem_usage??"-";return`${d+1}. ${a.hostname||"-"} | CPU:${m}% | 内存:${l}% (${a.mem_used??"-"}/${a.mem_total??"-"}GB) | 核数:${a.cpu_cores??"-"} | 上报:${(a.report_time||"").slice(0,16)}`}),r=n.filter(a=>(a.cpu_usage??0)>=80||(a.mem_usage??0)>=80),o=r.length?` -⚠️ 高负载主机 ${r.length} 台:${r.map(a=>`${a.hostname}(CPU${a.cpu_usage}%/MEM${a.mem_usage}%)`).join("、")}`:"";return`Agent 监控的 ${n.length} 台主机实时指标: -${i.join(` -`)}${o}`}async function ft(){const[e,n,i]=await Promise.all([U.getStats().catch(()=>null),U.getAlerts(10).catch(()=>null),U.getReleases(10).catch(()=>null)]),r=e||{},o=r.server_stats||{},a=r.kubernetes_stats||{},d=r.alert_stats||{},m=r.pipeline_stats||{},l=r.cost_stats||{},g=`服务器:${o.total??0}(运行${o.running??0}) | Kubernetes集群:${a.total??0} 节点:${a.total_nodes??0} Pod:${a.total_pods??0} | 告警:${d.total??0}(firing ${d.firing??0}) | 流水线:${m.total??0}(成功率${m.success_rate??0}%) | 本月成本:¥${l.month_cost??0}`,v=Array.isArray(n)?n:n?.list||[],h=Array.isArray(i)?i:i?.list||[],u=v.slice(0,10).map((p,A)=>`${A+1}.[${p.severity||"?"}|${p.status||"?"}] ${p.rule_name||"-"} → ${p.target||"-"}`),c=h.slice(0,10).map((p,A)=>`${A+1}.${p.app_name||"-"} ${p.version||""} [${p.environment||"-"}/${p.status||"-"}] by ${p.author||"-"}`);return`平台概览:${g} - -最近告警: -${u.join(` -`)||"(无)"} - -最近发布: -${c.join(` -`)||"(无)"}`}const gt=[{id:"alerts",name:"分析今日告警",icon:ms,prompt:"帮我分析以下最近的告警事件,给出根因分析和处置建议(按严重程度排序,给出具体处置步骤)",contextLoader:At},{id:"performance",name:"性能瓶颈分析",icon:xs,prompt:"分析以下主机实时指标,找出 CPU/内存使用率最高的主机并给出性能优化建议",contextLoader:ls},{id:"report",name:"生成运维报告",icon:hs,prompt:"基于以下平台实时数据,生成一份简洁的今日运维报告,包括资源概览、告警情况和发布状态,用 Markdown 格式输出",contextLoader:ft},{id:"optimize",name:"资源优化建议",icon:Vs,prompt:"根据以下主机资源使用数据,提供成本优化和容量规划建议(识别闲置/过载主机,给出缩容/扩容建议)",contextLoader:ls}];function It(e){return new Date(e).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"})}function Rt(){const[e,n]=x.useState([]),[i,r]=x.useState(""),[o,a]=x.useState(!1),d=x.useRef(null);x.useEffect(()=>()=>d.current?.abort(),[]);const[m,l]=x.useState(!1),[g,v]=x.useState(!1),[h,u]=x.useState(!1),[c,p]=x.useState(ut),[A,j]=x.useState(!1),[L,G]=x.useState(null),W=()=>{try{return crypto.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const I=Math.random()*16|0;return(t==="x"?I:I&3|8).toString(16)})},[Q,vs]=x.useState(()=>W()),Z=x.useRef(null),js=()=>Z.current?.scrollIntoView({behavior:"smooth"});x.useEffect(()=>{js()},[e]);const Os=async()=>{try{const t=await $.getConfig();p(t),j(!!(t.enabled&&t.configured))}catch{j(!1)}},bs=async()=>{try{const I=(await $.getHistory(Q))?.list||[];n(I.map(f=>({id:String(f.id),role:f.role,content:f.content,timestamp:f.created_at})))}catch{}};x.useEffect(()=>{Os(),bs()},[]);const Ns=t=>{const I=z.find(f=>f.id===t);p(f=>({...f,provider:t,endpoint:I?.defaultEndpoint||f.endpoint,model:I?.models[0]||f.model}))},Ss=async()=>{if(c.enabled&&!c.api_key&&c.provider!=="ollama"){w.error("请填写 API Key");return}v(!0);try{const t=await $.saveConfig(c);p(t),j(!!(t.enabled&&t.configured)),w.success("配置已保存"),l(!1)}catch(t){w.error(t instanceof Error?t.message:"保存失败")}finally{v(!1)}},ys=async()=>{u(!0);try{await $.testConnection(),w.success("LLM 服务连接成功")}catch(t){w.error(t instanceof Error?t.message:"连接失败")}finally{u(!1)}},J=async t=>{const I={id:Date.now().toString(),role:"user",content:t,timestamp:new Date().toISOString()},f=(Date.now()+1).toString(),$s=[...e,I,{id:f,role:"assistant",content:"",timestamp:new Date().toISOString()}];n($s),a(!0);const M=new AbortController;d.current=M;let P=!1;try{const _=[...e,I].slice(-10).map(O=>({role:O.role,content:O.content}));await $.chatStream(_,O=>{P=!0,n(S=>S.map(b=>b.id===f?{...b,content:b.content+O}:b))},M.signal,Q)}catch(_){if(M.signal.aborted)n(O=>O.map(S=>S.id===f?{...S,content:S.content||"(已停止生成)",isStopped:!0}:S));else{const O=_ instanceof Error?_.message:"对话失败";n(S=>S.map(b=>b.id===f?{...b,content:P?b.content+` - -⚠️ ${O}`:`⚠️ ${O}`,isError:!P}:b))}}finally{a(!1),d.current=null}},X=async()=>{const t=i.trim();!t||o||(r(""),await J(t))},ws=async t=>{if(o||L)return;if(!A||!t.contextLoader){r(t.prompt);return}G(t.id);let I="";try{I=await t.contextLoader()}catch{I="(平台数据加载失败,请稍后重试或检查后端服务)"}finally{G(null)}const f=`${t.prompt} - -【平台实时数据】 -${I}`;await J(f)},Cs=async()=>{try{await $.clearHistory()}catch{}const t=W();vs(t),n([]),r(""),w.success("已开始新对话")},R=z.find(t=>t.id===c.provider);return s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:371:5",className:"space-y-6",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:373:7",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:374:9",className:"flex items-center gap-3",children:[s.jsx("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:375:11",className:"w-10 h-10 rounded-lg bg-gradient-to-br from-purple-500 to-pink-500 flex items-center justify-center",children:s.jsx(zs,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:376:13",className:"h-5 w-5 text-white"})}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:378:11",children:[s.jsx("h1",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:379:13",className:"text-2xl font-bold text-slate-100",children:"AIOps 智能助手"}),s.jsx("p",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:380:13",className:"text-sm text-slate-500",children:"AI 驱动的智能运维助手"})]})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:383:9",className:"flex items-center gap-3",children:[A?s.jsxs(k,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:385:13",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:[s.jsx(Hs,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:386:15",className:"h-3 w-3 mr-1"}),c.model]}):s.jsx(k,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:390:13",variant:"outline",className:"border-amber-500/30 text-amber-400 bg-amber-500/10",children:"未配置"}),s.jsxs(N,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:394:11",variant:"outline",className:"border-slate-700 text-slate-300",onClick:()=>l(!0),children:[s.jsx(os,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:395:13",className:"h-4 w-4 mr-2"}),"模型配置"]})]})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:401:7",className:"grid grid-cols-4 gap-6 h-[calc(100vh-200px)]",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:403:9",className:"col-span-1 space-y-4",children:[s.jsxs(D,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:404:11",className:"bg-slate-800 border-slate-700",children:[s.jsx(T,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:405:13",className:"pb-3",children:s.jsx(Y,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:406:15",className:"text-sm text-slate-300",children:"快速操作"})}),s.jsx(q,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:408:13",className:"space-y-2",children:gt.map(t=>s.jsxs(N,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:410:17",variant:"ghost",className:"w-full justify-start text-slate-300 hover:text-slate-100 hover:bg-slate-700",disabled:o||L!==null,onClick:()=>ws(t),children:[L===t.id?s.jsx(E,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:418:21",className:"h-4 w-4 mr-2 shrink-0 animate-spin"}):s.jsx(t.icon,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:420:21",className:"h-4 w-4 mr-2 shrink-0"}),s.jsx("span",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:422:19",className:"text-sm",children:t.name}),A&&t.contextLoader&&s.jsx("span",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:424:21",className:"ml-auto text-[10px] text-emerald-400/60 shrink-0",children:"实时"})]},t.id))})]}),s.jsxs(D,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:431:11",className:"bg-slate-800 border-slate-700",children:[s.jsx(T,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:432:13",className:"pb-3",children:s.jsx(Y,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:433:15",className:"text-sm text-slate-300",children:"能力展示"})}),s.jsxs(q,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:435:13",className:"space-y-3",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:436:15",className:"flex items-center gap-2 text-sm text-slate-400",children:[s.jsx(ms,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:437:17",className:"h-4 w-4 text-amber-400"}),s.jsx("span",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:438:17",children:"智能告警分析"})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:440:15",className:"flex items-center gap-2 text-sm text-slate-400",children:[s.jsx(xs,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:441:17",className:"h-4 w-4 text-blue-400"}),s.jsx("span",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:442:17",children:"性能瓶颈识别"})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:444:15",className:"flex items-center gap-2 text-sm text-slate-400",children:[s.jsx(hs,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:445:17",className:"h-4 w-4 text-emerald-400"}),s.jsx("span",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:446:17",children:"自动报告生成"})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:448:15",className:"flex items-center gap-2 text-sm text-slate-400",children:[s.jsx(Ks,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:449:17",className:"h-4 w-4 text-purple-400"}),s.jsx("span",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:450:17",children:"脚本自动生成"})]})]})]})]}),s.jsxs(D,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:457:9",className:"col-span-3 bg-slate-800 border-slate-700 flex flex-col",children:[s.jsx(T,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:458:11",className:"border-b border-slate-700 pb-3",children:s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:459:13",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:460:15",className:"flex items-center gap-2",children:[s.jsx(cs,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:461:17",className:"h-5 w-5 text-purple-400"}),s.jsx("span",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:462:17",className:"font-medium text-slate-100",children:"AI 助手"}),A?s.jsxs(k,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:464:19",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10 text-xs",children:[s.jsx("span",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:465:21",className:"w-2 h-2 rounded-full bg-emerald-400 mr-1 animate-pulse"}),"在线"]}):s.jsx(k,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:469:19",variant:"outline",className:"border-slate-600 text-slate-400 text-xs",children:"离线"})]}),s.jsxs(N,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:472:15",variant:"ghost",size:"sm",className:"text-slate-400",onClick:Cs,disabled:e.length===0,children:[s.jsx(Gs,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:473:17",className:"h-4 w-4 mr-1"}),"新对话"]})]})}),s.jsx(Ls,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:479:11",className:"flex-1 p-4",children:s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:480:13",className:"space-y-4",children:[e.length===0&&!o&&s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:482:17",className:"flex flex-col items-center justify-center py-16 text-slate-500",children:[s.jsx(Ws,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:483:19",className:"h-10 w-10 mb-3 opacity-30"}),s.jsx("p",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:484:19",children:A?"暂无对话记录,输入问题开始与 AI 助手对话":"AI 助手尚未配置大模型"}),!A&&s.jsxs(N,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:486:21",variant:"outline",size:"sm",className:"mt-4 border-slate-600 text-slate-300",onClick:()=>l(!0),children:[s.jsx(os,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:487:23",className:"h-4 w-4 mr-1"}),"前往配置"]})]}),e.map(t=>{const I=o&&t.role==="assistant"&&t.content==="";return s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:497:17",className:`flex gap-3 ${t.role==="user"?"flex-row-reverse":""}`,children:[s.jsx(xt,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:498:19",className:t.role==="assistant"?"bg-purple-500":"bg-blue-500",children:s.jsx(ht,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:499:21",children:t.role==="assistant"?s.jsx(cs,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:500:55",className:"h-4 w-4"}):s.jsx(Qs,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:500:85",className:"h-4 w-4"})})}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:503:19",className:`max-w-[80%] ${t.role==="user"?"text-right":""}`,children:[s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:504:21",className:`inline-block rounded-lg p-3 text-left whitespace-pre-wrap break-words ${t.isError?"bg-red-900/30 border border-red-500/30 text-red-300":t.role==="assistant"?"bg-slate-700 text-slate-100":"bg-blue-600 text-white"}`,children:[I?s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:514:25",className:"flex items-center gap-2 text-slate-400",children:[s.jsx(E,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:515:27",className:"h-4 w-4 animate-spin"}),s.jsx("span",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:516:27",className:"text-sm",children:"思考中..."})]}):t.content,o&&t.role==="assistant"&&!I&&t.content&&s.jsx("span",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:523:25",className:"inline-block w-2 h-4 ml-0.5 bg-purple-400 animate-pulse align-middle"})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:526:21",className:"text-xs text-slate-500 mt-1",children:[It(t.timestamp),t.isStopped&&s.jsx("span",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:528:45",className:"ml-2 text-slate-600",children:"(已停止)"})]})]})]},t.id)}),s.jsx("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:535:15",ref:Z})]})}),s.jsx(q,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:539:11",className:"border-t border-slate-700 pt-4",children:s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:540:13",className:"flex gap-2",children:[s.jsx(C,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:541:15",value:i,onChange:t=>r(t.target.value),onKeyDown:t=>t.key==="Enter"&&X(),placeholder:A?"输入运维问题,或选择左侧快速操作...":"请先配置大模型...",className:"flex-1 bg-slate-900 border-slate-700 text-slate-100",disabled:o}),s.jsx(N,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:549:15",className:"bg-purple-600 hover:bg-purple-700",onClick:X,disabled:o||!i.trim(),children:s.jsx(Zs,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:550:17",className:"h-4 w-4"})}),o&&s.jsx(N,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:554:17",variant:"outline",className:"border-red-500/40 text-red-400 hover:bg-red-500/10",onClick:()=>d.current?.abort(),title:"停止生成",children:s.jsx(Js,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:560:19",className:"h-4 w-4"})})]})})]})]}),s.jsx(Rs,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:569:7",open:m,onOpenChange:l,children:s.jsxs(Ms,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:570:9",className:"max-w-2xl bg-slate-900 border-slate-700 text-slate-100",children:[s.jsxs(Ps,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:571:11",children:[s.jsx(Ds,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:572:13",children:"大模型配置"}),s.jsx(Ts,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:573:13",className:"text-slate-500",children:"配置 AI 助手使用的大语言模型(支持 OpenAI 兼容接口)"})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:577:11",className:"space-y-4 py-4 max-h-[60vh] overflow-y-auto pr-1",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:579:13",className:"flex items-center justify-between rounded-lg border border-slate-700 p-3",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:580:15",children:[s.jsx("p",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:581:17",className:"text-sm font-medium text-slate-200",children:"启用 AI 助手"}),s.jsx("p",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:582:17",className:"text-xs text-slate-500",children:"关闭后将无法进行对话"})]}),s.jsx(Us,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:584:15",checked:c.enabled,onCheckedChange:t=>p({...c,enabled:t})})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:587:13",className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:588:15",children:[s.jsx(y,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:589:17",className:"text-slate-300",children:"提供商"}),s.jsxs(ss,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:590:17",value:c.provider,onValueChange:Ns,children:[s.jsx(ts,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:591:19",className:"bg-slate-800 border-slate-700 text-slate-100 mt-1",children:s.jsx(es,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:592:21"})}),s.jsx(as,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:594:19",className:"bg-slate-800 border-slate-700",children:z.map(t=>s.jsx(ns,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:596:23",value:t.id,className:"text-slate-100",children:t.name},t.id))})]})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:601:15",children:[s.jsx(y,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:602:17",className:"text-slate-300",children:"模型"}),R&&R.models.length>0?s.jsxs(ss,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:604:19",value:c.model,onValueChange:t=>p({...c,model:t}),children:[s.jsx(ts,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:605:21",className:"bg-slate-800 border-slate-700 text-slate-100 mt-1",children:s.jsx(es,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:606:23"})}),s.jsx(as,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:608:21",className:"bg-slate-800 border-slate-700",children:R.models.map(t=>s.jsx(ns,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:610:25",value:t,className:"text-slate-100",children:t},t))})]}):s.jsx(C,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:615:19",value:c.model,onChange:t=>p({...c,model:t.target.value}),placeholder:"输入模型名称",className:"bg-slate-800 border-slate-700 text-slate-100 mt-1"})]})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:624:13",children:[s.jsxs(y,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:625:15",className:"text-slate-300",children:["API Key ",c.provider==="ollama"&&s.jsx("span",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:625:90",className:"text-xs text-slate-500",children:"(本地 Ollama 通常无需)"})]}),s.jsx(C,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:626:15",type:"password",value:c.api_key,onChange:t=>p({...c,api_key:t.target.value}),placeholder:"sk-...",className:"bg-slate-800 border-slate-700 text-slate-100 mt-1"})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:634:13",children:[s.jsx(y,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:635:15",className:"text-slate-300",children:"API Endpoint"}),s.jsx(C,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:636:15",value:c.endpoint,onChange:t=>p({...c,endpoint:t.target.value}),placeholder:"https://api.openai.com/v1",className:"bg-slate-800 border-slate-700 text-slate-100 mt-1 font-mono text-sm"}),s.jsx("p",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:642:15",className:"text-xs text-slate-500 mt-1",children:"基础地址(不含 /chat/completions),OpenAI 兼容格式"})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:644:13",children:[s.jsx(y,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:645:15",className:"text-slate-300",children:"系统提示词(可选)"}),s.jsx("textarea",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:646:15",value:c.system_prompt,onChange:t=>p({...c,system_prompt:t.target.value}),placeholder:"留空则使用内置 AIOps 运维助手角色提示词",className:"w-full bg-slate-800 border border-slate-700 text-slate-100 mt-1 rounded-md p-2 text-sm min-h-[70px] resize-y"})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:653:13",className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:654:15",children:[s.jsx(y,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:655:17",className:"text-slate-300",children:"Temperature"}),s.jsx(C,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:656:17",type:"number",min:0,max:2,step:.1,value:Math.round(c.temperature*10)/10,onChange:t=>p({...c,temperature:parseFloat(t.target.value)||0}),className:"bg-slate-800 border-slate-700 text-slate-100 mt-1"}),s.jsx("p",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:665:17",className:"text-xs text-slate-500 mt-1",children:"值越高回答越创造性"})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:667:15",children:[s.jsx(y,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:668:17",className:"text-slate-300",children:"Max Tokens"}),s.jsx(C,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:669:17",type:"number",value:c.max_tokens,onChange:t=>p({...c,max_tokens:parseInt(t.target.value)||2e3}),className:"bg-slate-800 border-slate-700 text-slate-100 mt-1"})]})]})]}),s.jsxs(qs,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:678:11",className:"gap-2",children:[s.jsxs(N,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:679:13",variant:"outline",onClick:ys,disabled:h,className:"border-slate-700 text-slate-300",children:[h?s.jsx(E,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:680:26",className:"h-4 w-4 mr-2 animate-spin"}):s.jsx(Xs,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:680:78",className:"h-4 w-4 mr-2"}),"测试连接"]}),s.jsx(N,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:683:13",variant:"outline",onClick:()=>l(!1),className:"border-slate-700 text-slate-300",children:"取消"}),s.jsxs(N,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:686:13",className:"bg-purple-600 hover:bg-purple-700",onClick:Ss,disabled:g,children:[g?s.jsx(E,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:687:25",className:"h-4 w-4 mr-2 animate-spin"}):null,"保存配置"]})]})]})})]})}export{Rt as AIOpsAssistant}; diff --git a/backend/static/assets/AIPredictiveAnalytics-C1OkILDZ.js b/backend/static/assets/AIPredictiveAnalytics-C1OkILDZ.js deleted file mode 100644 index 2baf28e..0000000 --- a/backend/static/assets/AIPredictiveAnalytics-C1OkILDZ.js +++ /dev/null @@ -1 +0,0 @@ -import{j as e,r as g}from"./vendor-codemirror-B1SGo4xl.js";import{C as F,b as B,c as K,a as H}from"./card-BIfzBCEy.js";import{S as Z}from"./stat-strip-BSQFwFzG.js";import{B as q}from"./index-Dungj95X.js";import{B as G}from"./badge-CGJlVD3L.js";import{T as J,a as Q,b as D,c as $}from"./tabs-D87nAyJR.js";import{S as ee,a as se,b as te,c as ae,d as M}from"./select-CiTqGGhE.js";import{d as ce}from"./dashboard-D0JujfHp.js";import{s as ie}from"./server-P3fi-cmJ.js";import{a as z}from"./alert-v1WaPeEX.js";import{H as X,L as _,D as ne,a4 as Y,aA as re,aB as oe,A as le,aC as de,u as pe,l as L,aa as W,aD as me,g as xe,aE as he,N as ye,s as ve,aF as Ae}from"./vendor-icons-DmqcWdzX.js";import"./index-5FEebgvX.js";function ue({forecasts:c,loading:i}){return e.jsxs(F,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:14:5",className:"bg-slate-800 border-slate-700",children:[e.jsx(B,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:15:7",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:16:9",className:"flex items-center justify-between",children:[e.jsxs(K,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:17:11",className:"text-slate-100 flex items-center gap-2",children:[e.jsx(X,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:18:13",className:"h-5 w-5 text-amber-400"}),"容量规划预警"]}),e.jsx("span",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:21:11",className:"text-xs text-slate-500",children:"基于日均增长率推算阈值触及时间"})]})}),e.jsx(H,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:24:7",children:i?e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:26:11",className:"flex items-center justify-center py-12 text-slate-500",children:[e.jsx(_,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:27:13",className:"h-5 w-5 animate-spin mr-2"})," 加载容量数据..."]}):c.length===0?e.jsx("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:30:11",className:"text-center py-12 text-slate-500",children:"暂无容量数据"}):e.jsx("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:32:11",className:"space-y-4",children:c.map((a,p)=>e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:34:15",className:"p-4 rounded-lg border border-slate-700 bg-slate-800/50",children:[e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:35:17",className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:36:19",className:"flex items-center gap-2",children:[e.jsx(ne,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:37:21",className:"h-5 w-5 text-blue-400"}),e.jsx("span",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:38:21",className:"font-medium text-slate-200",children:a.resource})]}),e.jsx(G,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:40:19",variant:"outline",className:a.daysUntilThreshold<=7?"border-red-500/30 text-red-400 bg-red-500/10":a.daysUntilThreshold<=14?"border-amber-500/30 text-amber-400 bg-amber-500/10":"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:a.daysUntilThreshold<=7?"紧急":a.daysUntilThreshold<=14?"警告":"正常"})]}),e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:58:17",className:"mb-4",children:[e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:59:19",className:"flex items-center justify-between text-sm mb-1",children:[e.jsx("span",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:60:21",className:"text-slate-400",children:"7天使用率预测"}),e.jsx("span",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:61:21",className:"text-slate-400",children:a.daysUntilThreshold>=999?"增长平缓,暂无触顶风险":e.jsxs(e.Fragment,{children:["预计"," ",e.jsxs("span",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:67:27",className:"text-amber-400 font-medium",children:[a.daysUntilThreshold,"天"]})," ","后达到阈值"]})})]}),e.jsx("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:73:19",className:"h-3 bg-slate-700 rounded-full overflow-hidden",children:e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:74:21",className:"flex h-full",children:[e.jsx("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:75:23",className:"bg-blue-500",style:{width:`${a.currentUsage}%`}}),e.jsx("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:76:23",className:"bg-gradient-to-r from-blue-500/50 to-amber-500",style:{width:`${Math.max(0,a.predictedUsage-a.currentUsage)}%`}})]})}),e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:84:19",className:"flex items-center justify-between text-xs mt-1",children:[e.jsxs("span",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:85:21",className:"text-slate-500",children:["当前 ",a.currentUsage,"%"]}),e.jsxs("span",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:86:21",className:"text-amber-400",children:["预测 ",a.predictedUsage,"%"]}),e.jsxs("span",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:87:21",className:"text-red-400",children:["阈值 ",a.threshold,"%"]})]})]}),e.jsx("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:91:17",className:"p-3 bg-slate-900 rounded-lg border border-slate-700",children:e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:92:19",className:"flex items-start gap-2",children:[e.jsx(Y,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:93:21",className:"h-4 w-4 text-emerald-400 mt-0.5"}),e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:94:21",children:[e.jsx("span",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:95:23",className:"text-sm text-slate-400",children:"AI建议:"}),e.jsx("p",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:96:23",className:"text-sm text-slate-300 mt-1",children:a.recommendation})]})]})})]},p))})})]})}const T=[{key:"cpu",label:"CPU使用率",exprKey:"cpu_usage",threshold:85},{key:"memory",label:"内存使用率",exprKey:"memory_usage",threshold:85},{key:"disk",label:"磁盘使用率",exprKey:"disk_usage",threshold:90}],be={"1h":"1小时后","24h":"24小时后","7d":"7天后","30d":"30天后"},je={"1h":1,"24h":24,"7d":168,"30d":720};function R(c){const i=c.length;if(i<2)return{slope:0,r2:0};const a=c.map((r,h)=>h),p=a.reduce((r,h)=>r+h,0)/i,y=c.reduce((r,h)=>r+h,0)/i;let b=0,N=0,I=0,C=0;for(let r=0;ra.name===i).sort((a,p)=>new Date(a.timestamp).getTime()-new Date(p.timestamp).getTime()).map(a=>Number(a.value)||0)}function Pe(c){const i=c.match(/[><=]\s*([\d.]+)/);return i?parseFloat(i[1]):null}function ge(c,i){const a=i<=7?"urgent":i<=14?"warning":"normal";return{urgent:{cpu:"CPU增长趋势明显,建议尽快扩容计算资源或优化高负载进程",memory:"内存增长趋势明显,建议增加内存或排查内存泄漏",disk:"磁盘空间即将耗尽,建议立即扩容或清理历史数据与日志"},warning:{cpu:"CPU使用率呈上升趋势,建议持续监控并准备扩容计划",memory:"内存使用率呈上升趋势,建议优化应用内存使用",disk:"磁盘使用率持续增长,建议规划数据归档和清理策略"},normal:{cpu:"CPU使用正常,建议持续监控",memory:"内存使用正常,建议持续监控",disk:"磁盘空间充足,建议持续监控"}}[a]?.[c]||"建议持续监控资源使用趋势"}function O(c){return{cpu:"检查高负载进程,优化CPU密集型任务,考虑横向扩容",memory:"排查内存泄漏,优化进程内存配置,考虑增加节点",disk:"清理历史数据和日志,实施数据归档策略,扩容磁盘",service:"检查服务健康状态与依赖组件,查看服务日志",pod:"检查Pod重启原因,查看容器日志,排查OOM或健康检查失败"}[c]||"建议检查相关服务状态并持续监控"}function Ne(c){const{rawMetrics:i,serverStats:a,alertEvents:p,alertRules:y,selectedTimeRange:b}=c,N=je[b]||24,I=be[b]||"24小时后",C=T.map(t=>{const n=U(i,t.key),{slope:m,r2:x}=R(n),o=t.key==="cpu"?a.avg_cpu:t.key==="memory"?a.avg_memory:a.avg_disk,l=n.length>0?n[n.length-1]:o||0;let A=l+m*N;A=Math.max(0,Math.min(100,A));const s=m>.05?"up":m<-.05?"down":"stable",d=Math.round(60+x*35);return{name:t.label,current:Math.round(l),predicted:Math.round(A),unit:"%",trend:s,confidence:d,timeRange:I}}),j=T.map(t=>{const n=U(i,t.key),{slope:m}=R(n),x=t.key==="cpu"?a.avg_cpu:t.key==="memory"?a.avg_memory:a.avg_disk,o=Math.round(n.length>0?n[n.length-1]:x||0),l=m*24,A=Math.round(Math.min(100,o+l*7)),s=t.threshold;let d=999;return l>.01&&(d=Math.round((s-o)/l),d=d<1?1:d),{resource:{cpu:"服务器CPU算力",memory:"服务器内存",disk:"存储磁盘空间"}[t.key]||t.label,metricKey:t.key,currentUsage:o,predictedUsage:A,threshold:s,daysUntilThreshold:d,recommendation:ge(t.key,d)}}).filter(t=>t.currentUsage>0),f=[];for(const t of y){if(!t.enabled)continue;const n=Pe(t.expression||""),m=(t.expression||"").toLowerCase(),x=T.find(o=>m.includes(o.exprKey));if(x&&n){const o=U(i,x.key),{slope:l}=R(o),A=x.key==="cpu"?a.avg_cpu:x.key==="memory"?a.avg_memory:a.avg_disk,s=o.length>0?o[o.length-1]:A||0,d=n>0?s/n:0;let u=Math.round(d*55);l>.05&&(u+=15);const S=p.filter(v=>v.rule_id===t.id||v.rule_name===t.name).length;u+=Math.min(20,S*3),u=Math.max(5,Math.min(90,u));let P="未来24小时";if(l>.01&&n>s){const v=(n-s)/l;v<4?P="未来4小时":v<12?P="未来12小时":v<24?P="未来24小时":P=`未来${Math.ceil(v/24)}天`}f.push({metric:t.name,predictedAnomaly:t.description||`${t.name}可能触发`,probability:u,timeframe:P,suggestedAction:O(x.key)})}else{const o=p.filter(l=>l.rule_id===t.id||l.rule_name===t.name).length;if(o>0){const l=m.includes("service")?"service":m.includes("pod")?"pod":"service";f.push({metric:t.name,predictedAnomaly:t.description||`${t.name}可能再次发生`,probability:Math.min(60,20+o*5),timeframe:"未来24小时",suggestedAction:O(l)})}}}const w=f.sort((t,n)=>n.probability-t.probability).filter((t,n,m)=>m.findIndex(x=>x.metric===t.metric)===n),r=T.length>0?T.reduce((t,n)=>t+R(U(i,n.key)).r2,0)/T.length:0,h=Math.round(78+r*17),k=w.filter(t=>t.probability>=50).length,E=j.filter(t=>t.daysUntilThreshold<=14).length;return{predictions:C,capacityForecasts:j,dedupedAnomalies:w,accuracy:h,predictedAlertCount:k,capacityWarningCount:E}}function V(c){switch(c){case"up":return"text-red-400";case"down":return"text-emerald-400";default:return"text-slate-400"}}function De(){const[c,i]=g.useState("24h"),[a,p]=g.useState(!1),[y,b]=g.useState(!0),[N,I]=g.useState([]),[C,j]=g.useState({}),[f,w]=g.useState([]),[r,h]=g.useState([]);g.useEffect(()=>{k()},[]);const k=async()=>{b(!0);try{const[s,d,u,S]=await Promise.all([ce.getMetrics(72),ie.getServerStats(),z.getAlerts({page:1,page_size:100}),z.getRules()]);I(Array.isArray(s)?s:[]),j(d||{});const P=u?.list||u||[];w(Array.isArray(P)?P:[]);const v=S?.list||S||[];h(Array.isArray(v)?v:[])}catch{}finally{b(!1)}},E=async()=>{p(!0),await k(),p(!1)},{predictions:t,capacityForecasts:n,dedupedAnomalies:m,accuracy:x,predictedAlertCount:o,capacityWarningCount:l}=Ne({rawMetrics:N,serverStats:C,alertEvents:f,alertRules:r,selectedTimeRange:c}),A=s=>{switch(s){case"up":return e.jsx(W,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:100:16",className:"h-4 w-4 text-red-400"});case"down":return e.jsx(Ae,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:102:16",className:"h-4 w-4 text-emerald-400"});default:return e.jsx(ve,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:104:16",className:"h-4 w-4 text-slate-400"})}};return e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:109:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:111:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:112:9",className:"flex items-center gap-3",children:[e.jsx("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:113:11",className:"w-10 h-10 rounded-lg bg-gradient-to-br from-indigo-500 to-purple-500 flex items-center justify-center",children:e.jsx(re,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:114:13",className:"h-5 w-5 text-white"})}),e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:116:11",children:[e.jsx("h1",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:117:13",className:"text-2xl font-bold text-slate-100",children:"AI 预测分析"}),e.jsx("p",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:118:13",className:"text-sm text-slate-500",children:"基于实时指标时序数据的线性回归预测与容量规划"})]})]}),e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:121:9",className:"flex items-center gap-2",children:[e.jsxs(ee,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:122:11",value:c,onValueChange:i,children:[e.jsxs(se,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:123:13",className:"w-32 bg-slate-800 border-slate-700 text-slate-100",children:[e.jsx(oe,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:124:15",className:"h-4 w-4 mr-2"}),e.jsx(te,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:125:15"})]}),e.jsxs(ae,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:127:13",className:"bg-slate-800 border-slate-700",children:[e.jsx(M,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:128:15",value:"1h",children:"1小时"}),e.jsx(M,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:129:15",value:"24h",children:"24小时"}),e.jsx(M,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:130:15",value:"7d",children:"7天"}),e.jsx(M,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:131:15",value:"30d",children:"30天"})]})]}),e.jsx(q,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:134:11",variant:"outline",className:"border-slate-700 text-slate-300",onClick:E,children:a||y?e.jsx(_,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:135:39",className:"h-4 w-4 animate-spin"}):e.jsx(le,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:135:86",className:"h-4 w-4"})})]})]}),e.jsx(Z,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:141:7",items:[{label:"置信度",value:`${x}%`,color:"emerald"},{label:"高风险",value:o,color:"amber"},{label:"容量预警",value:l,color:"red"},{label:"指标",value:t.length,color:"purple"}]}),e.jsxs(J,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:150:7",defaultValue:"metrics",className:"space-y-4",children:[e.jsxs(Q,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:151:9",className:"bg-slate-800 border border-slate-700",children:[e.jsxs(D,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:152:11",value:"metrics",className:"data-[state=active]:bg-slate-700",children:[e.jsx(de,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:153:13",className:"h-4 w-4 mr-2"}),"指标预测"]}),e.jsxs(D,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:156:11",value:"capacity",className:"data-[state=active]:bg-slate-700",children:[e.jsx(pe,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:157:13",className:"h-4 w-4 mr-2"}),"容量规划"]}),e.jsxs(D,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:160:11",value:"anomaly",className:"data-[state=active]:bg-slate-700",children:[e.jsx(L,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:161:13",className:"h-4 w-4 mr-2"}),"异常预测"]})]}),e.jsx($,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:166:9",value:"metrics",className:"space-y-4",children:e.jsxs(F,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:167:11",className:"bg-slate-800 border-slate-700",children:[e.jsx(B,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:168:13",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:169:15",className:"flex items-center justify-between",children:[e.jsxs(K,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:170:17",className:"text-slate-100 flex items-center gap-2",children:[e.jsx(W,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:171:19",className:"h-5 w-5 text-blue-400"}),"关键指标预测"]}),e.jsxs(G,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:174:17",variant:"outline",className:"border-purple-500/30 text-purple-400 bg-purple-500/10",children:[e.jsx(me,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:175:19",className:"h-3 w-3 mr-1"}),"线性回归预测"]})]})}),e.jsx(H,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:180:13",children:y?e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:182:17",className:"flex items-center justify-center py-12 text-slate-500",children:[e.jsx(_,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:183:19",className:"h-5 w-5 animate-spin mr-2"})," 加载指标数据..."]}):t.length===0?e.jsx("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:186:17",className:"text-center py-12 text-slate-500",children:"暂无指标数据"}):e.jsx("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:188:17",className:"grid grid-cols-2 gap-4",children:t.map((s,d)=>e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:190:21",className:"p-4 rounded-lg border border-slate-700 bg-slate-800/50",children:[e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:191:23",className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:192:25",className:"flex items-center gap-2",children:[s.name.includes("CPU")&&e.jsx(xe,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:193:63",className:"h-4 w-4 text-blue-400"}),s.name.includes("内存")&&e.jsx(he,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:194:62",className:"h-4 w-4 text-emerald-400"}),s.name.includes("磁盘")&&e.jsx(X,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:195:62",className:"h-4 w-4 text-amber-400"}),s.name.includes("网络")&&e.jsx(ye,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:196:62",className:"h-4 w-4 text-purple-400"}),e.jsx("span",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:197:27",className:"font-medium text-slate-200",children:s.name})]}),e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:199:25",className:"flex items-center gap-1",children:[A(s.trend),e.jsx("span",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:201:27",className:`text-sm ${V(s.trend)}`,children:s.trend==="up"?"上升":s.trend==="down"?"下降":"平稳"})]})]}),e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:207:23",className:"grid grid-cols-2 gap-4 mb-3",children:[e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:208:25",children:[e.jsx("p",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:209:27",className:"text-xs text-slate-500 mb-1",children:"当前值"}),e.jsxs("p",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:210:27",className:"text-lg font-bold text-slate-100",children:[s.current,s.unit]})]}),e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:215:25",children:[e.jsxs("p",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:216:27",className:"text-xs text-slate-500 mb-1",children:["预测值 (",s.timeRange,")"]}),e.jsxs("p",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:217:27",className:`text-lg font-bold ${V(s.trend)}`,children:[s.predicted,s.unit]})]})]}),e.jsx("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:224:23",className:"flex items-center justify-between",children:e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:225:25",className:"flex items-center gap-2",children:[e.jsx("span",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:226:27",className:"text-xs text-slate-400",children:"置信度"}),e.jsx("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:227:27",className:"w-16 h-1.5 bg-slate-700 rounded-full overflow-hidden",children:e.jsx("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:228:29",className:"h-full bg-gradient-to-r from-blue-500 to-purple-500",style:{width:`${s.confidence}%`}})}),e.jsxs("span",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:233:27",className:"text-xs text-purple-400",children:[s.confidence,"%"]})]})})]},d))})})]})}),e.jsx($,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:244:9",value:"capacity",className:"space-y-4",children:e.jsx(ue,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:245:11",forecasts:n,loading:y})}),e.jsx($,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:248:9",value:"anomaly",className:"space-y-4",children:e.jsxs(F,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:249:11",className:"bg-slate-800 border-slate-700",children:[e.jsx(B,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:250:13",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:251:15",className:"flex items-center justify-between",children:[e.jsxs(K,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:252:17",className:"text-slate-100 flex items-center gap-2",children:[e.jsx(L,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:253:19",className:"h-5 w-5 text-red-400"}),"异常事件预测"]}),e.jsx("span",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:256:17",className:"text-xs text-slate-500",children:"基于告警规则阈值与实时趋势概率推算"})]})}),e.jsx(H,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:259:13",children:y?e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:261:17",className:"flex items-center justify-center py-12 text-slate-500",children:[e.jsx(_,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:262:19",className:"h-5 w-5 animate-spin mr-2"})," 加载异常预测..."]}):m.length===0?e.jsx("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:265:17",className:"text-center py-12 text-slate-500",children:"暂无异常预测数据"}):e.jsx("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:267:17",className:"space-y-3",children:m.map((s,d)=>e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:269:21",className:"p-4 rounded-lg border border-slate-700 bg-slate-800/50",children:[e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:270:23",className:"flex items-start justify-between",children:[e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:271:25",className:"flex items-start gap-3",children:[e.jsx("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:272:27",className:`w-10 h-10 rounded-lg flex items-center justify-center ${s.probability>=70?"bg-red-500/20":s.probability>=50?"bg-amber-500/20":"bg-blue-500/20"}`,children:e.jsx(L,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:281:29",className:`h-5 w-5 ${s.probability>=70?"text-red-400":s.probability>=50?"text-amber-400":"text-blue-400"}`})}),e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:291:27",children:[e.jsx("h4",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:292:29",className:"font-medium text-slate-200",children:s.metric}),e.jsx("p",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:293:29",className:"text-sm text-slate-400 mt-1",children:s.predictedAnomaly}),e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:294:29",className:"flex items-center gap-4 mt-2",children:[e.jsx("span",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:295:31",className:"text-xs text-slate-500",children:s.timeframe}),e.jsxs("span",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:296:31",className:"text-xs text-slate-500",children:["概率:"," ",e.jsxs("span",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:298:33",className:s.probability>=70?"text-red-400":"text-amber-400",children:[s.probability,"%"]})]})]})]})]}),e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:305:25",className:"w-16 h-16 relative shrink-0",children:[e.jsxs("svg",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:306:27",className:"w-full h-full transform -rotate-90",children:[e.jsx("circle",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:307:29",cx:"32",cy:"32",r:"28",stroke:"currentColor",strokeWidth:"4",fill:"transparent",className:"text-slate-700"}),e.jsx("circle",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:316:29",cx:"32",cy:"32",r:"28",stroke:"currentColor",strokeWidth:"4",fill:"transparent",strokeDasharray:`${s.probability*1.76} 176`,className:s.probability>=70?"text-red-400":s.probability>=50?"text-amber-400":"text-blue-400"})]}),e.jsx("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:333:27",className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("span",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:334:29",className:"text-sm font-bold text-slate-200",children:[s.probability,"%"]})})]})]}),e.jsx("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:338:23",className:"mt-3 p-3 bg-slate-900 rounded-lg border border-slate-700",children:e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:339:25",className:"flex items-start gap-2",children:[e.jsx(Y,{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:340:27",className:"h-4 w-4 text-emerald-400 mt-0.5"}),e.jsxs("div",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:341:27",children:[e.jsx("span",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:342:29",className:"text-sm text-slate-400",children:"建议操作:"}),e.jsx("p",{"code-path":"src/components/aiops/AIPredictiveAnalytics.tsx:343:29",className:"text-sm text-slate-300 mt-1",children:s.suggestedAction})]})]})})]},d))})})]})})]})]})}export{De as AIPredictiveAnalytics}; diff --git a/backend/static/assets/AlertCenter-B1Dd-7wT.js b/backend/static/assets/AlertCenter-B1Dd-7wT.js deleted file mode 100644 index 6164c8a..0000000 --- a/backend/static/assets/AlertCenter-B1Dd-7wT.js +++ /dev/null @@ -1 +0,0 @@ -import{j as e,r as a}from"./vendor-codemirror-B1SGo4xl.js";import{J as ct,D as K,a as Q,b as V,c as U,d as H,e as ie,B as m,t as d,f as Oe}from"./index-Dungj95X.js";import{I as _}from"./input-CXoUQQLm.js";import{B as A}from"./badge-CGJlVD3L.js";import{C as W,a as J,b as Te,c as _e}from"./card-BIfzBCEy.js";import{S as at}from"./stat-strip-BSQFwFzG.js";import{S as ne,a as se,b as oe,c as ce,d as T}from"./select-CiTqGGhE.js";import{T as lt,a as it,b as F,c as B}from"./tabs-D87nAyJR.js";import{S as Le}from"./switch-Bxiq4EHp.js";import{a as R}from"./alert-v1WaPeEX.js";import{a as E}from"./alert-center-Dr8niqD0.js";import{u as ze,q as ae,b as Ge,a as mt}from"./unwrap-DPwG25JA.js";import{u as $}from"./useMutation-BkCR1EeO.js";import{a as Ce}from"./agent-CZzlLHxR.js";import{I as dt,l as Me,ab as pt,aZ as le,y as $e,U as xt,a4 as ht,w as Ie,f as ut,R as te,P as re,b as gt,a_ as jt,aB as Ct,aJ as ft,T as vt,S as At,x as Nt,ao as yt}from"./vendor-icons-DmqcWdzX.js";import{L as j}from"./label-CMpUoC87.js";import{A as bt}from"./AlertRuleDialog-BmYLySxp.js";import{T as wt}from"./textarea-BxfjmLq5.js";import"./index-5FEebgvX.js";function St(t){return{id:String(t.id),title:t.rule_name||t.title||`告警 #${t.id}`,description:t.message||t.description||"",severity:t.severity||"info",status:t.status||"firing",source:t.target||t.source||"",service:t.service||"",metric:t.metric||"",value:t.value||0,threshold:t.threshold||0,startedAt:t.started_at||t.startedAt||t.created_at||new Date().toISOString(),resolvedAt:t.resolved_at||t.resolvedAt,labels:typeof t.labels=="string"?(()=>{try{return JSON.parse(t.labels||"{}")}catch{return{}}})():t.labels||{},annotations:typeof t.annotations=="string"?(()=>{try{return JSON.parse(t.annotations||"{}")}catch{return{}}})():t.annotations||{}}}function fe(t){switch(t){case"critical":return e.jsxs(A,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:107:14",variant:"destructive",className:"gap-1",children:[e.jsx(pt,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:107:61",className:"w-3 h-3"}),"严重"]});case"warning":return e.jsxs(A,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:109:14",variant:"default",className:"bg-orange-500 gap-1",children:[e.jsx(Me,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:109:71",className:"w-3 h-3"}),"警告"]});case"info":return e.jsxs(A,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:111:14",variant:"default",className:"bg-blue-500 gap-1",children:[e.jsx(dt,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:111:69",className:"w-3 h-3"}),"信息"]});default:return e.jsx(A,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:113:14",variant:"secondary",children:"未知"})}}function Dt(t){switch(t){case"firing":return e.jsxs(A,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:121:14",variant:"destructive",className:"gap-1 animate-pulse",children:[e.jsx(ht,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:121:75",className:"w-3 h-3"}),"触发中"]});case"acknowledged":return e.jsxs(A,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:123:14",variant:"default",className:"bg-yellow-500 gap-1",children:[e.jsx(xt,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:123:71",className:"w-3 h-3"}),"已确认"]});case"resolved":return e.jsxs(A,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:125:14",variant:"default",className:"bg-green-500 gap-1",children:[e.jsx($e,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:125:70",className:"w-3 h-3"}),"已解决"]});case"suppressed":return e.jsxs(A,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:127:14",variant:"secondary",className:"gap-1",children:[e.jsx(le,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:127:59",className:"w-3 h-3"}),"已静默"]});default:return e.jsx(A,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:129:14",variant:"secondary",children:"未知"})}}function kt(t){return{dingtalk:"钉钉",wechat:"企业微信",feishu:"飞书",email:"邮件",sms:"短信",webhook:"Webhook"}[t]||t}function Tt(t){return{firing:t.filter(s=>s.status==="firing").length,critical:t.filter(s=>s.severity==="critical"&&s.status==="firing").length,warning:t.filter(s=>s.severity==="warning"&&s.status==="firing").length,resolved:t.filter(s=>s.status==="resolved").length}}function _t(){return ze({queryKey:ae.agentAlertRules(),queryFn:async()=>{const t=await Ce.listRules();return Ge(t).map(n=>({id:n.id,name:String(n.name||""),description:`${n.metric} ${n.operator} ${n.threshold}%`,enabled:!!n.enabled,severity:"warning",type:String(n.metric||""),hostname:String(n.hostname||"全部主机"),threshold:Number(n.threshold||0)}))},staleTime:3e4})}function Rt(t={}){return ze({queryKey:ae.alerts(t),queryFn:async()=>{const s=await E.getAlerts({page:t.page,page_size:t.page_size,severity:t.severity!=="all"?t.severity:void 0,status:t.status!=="all"?t.status:void 0}),u=Ge(s).map(g=>St(g));return{list:u,total:mt(s),stats:Tt(u)}},staleTime:15e3,refetchInterval:3e4})}function Et(){const t=ct(),s=()=>t.invalidateQueries({queryKey:ae.alertRules()}),n=()=>t.invalidateQueries({queryKey:ae.agentAlertRules()}),u=()=>t.invalidateQueries({queryKey:["alerts"]}),g=$({mutationFn:o=>R.toggleRule(o),onSuccess:s}),h=$({mutationFn:o=>R.deleteRule(o),onSuccess:s}),l=$({mutationFn:({id:o,enabled:p})=>Ce.updateRule(o,{enabled:p}),onSuccess:n}),C=$({mutationFn:o=>Ce.deleteRule(o),onSuccess:n}),w=$({mutationFn:o=>E.acknowledge(o),onSuccess:u}),v=$({mutationFn:o=>E.resolve(o),onSuccess:u}),f=$({mutationFn:o=>E.quickSetup(o),onSuccess:n});return{toggleRuleMutation:g,deleteRuleMutation:h,toggleAgentRuleMutation:l,deleteAgentRuleMutation:C,ackMutation:w,resolveMutation:v,quickSetupMutation:f,invalidateRules:s,invalidateAgentRules:n,invalidateAlerts:u}}function Ot({alert:t,open:s,onOpenChange:n,onAcknowledge:u}){return e.jsx(K,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:22:5",open:s,onOpenChange:n,children:e.jsxs(Q,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:23:7",className:"max-w-3xl",children:[e.jsxs(V,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:24:9",children:[e.jsxs(U,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:25:11",className:"flex items-center gap-2",children:[t?.title,t&&fe(t.severity)]}),e.jsx(H,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:29:11",className:"sr-only",children:"查看告警详情"})]}),t&&e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:32:11",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:33:13",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:34:15",className:"text-muted-foreground",children:"描述"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:35:15",className:"mt-1",children:t.description})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:37:13",className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:38:15",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:39:17",className:"text-muted-foreground",children:"来源"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:40:17",className:"font-medium",children:t.source})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:42:15",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:43:17",className:"text-muted-foreground",children:"服务"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:44:17",className:"font-medium",children:t.service})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:46:15",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:47:17",className:"text-muted-foreground",children:"指标"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:48:17",className:"font-medium",children:t.metric})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:50:15",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:51:17",className:"text-muted-foreground",children:"当前值 / 阈值"}),e.jsxs("p",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:52:17",className:"font-medium",children:[t.value," / ",t.threshold]})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:54:15",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:55:17",className:"text-muted-foreground",children:"开始时间"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:56:17",className:"font-medium",children:t.startedAt})]}),t.resolvedAt&&e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:59:17",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:60:19",className:"text-muted-foreground",children:"解决时间"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:61:19",className:"font-medium",children:t.resolvedAt})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:65:13",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:66:15",className:"text-muted-foreground",children:"标签"}),e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:67:15",className:"flex flex-wrap gap-2 mt-1",children:Object.entries(t.labels).map(([g,h])=>e.jsxs(A,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:69:19",variant:"outline",children:[g,"=",h]},g))})]}),t.runbookUrl&&e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:74:15",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:75:17",className:"text-muted-foreground",children:"处理手册"}),e.jsx("a",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:76:17",href:t.runbookUrl,target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:underline block mt-1",children:"查看处理手册 →"})]})]}),e.jsxs(ie,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:83:9",children:[e.jsx(m,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:84:11",variant:"outline",onClick:()=>n(!1),children:"关闭"}),t?.status==="firing"&&e.jsxs(m,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:86:13",onClick:()=>{u(t.id),n(!1)},children:[e.jsx(Ie,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:87:15",className:"w-4 h-4 mr-2"}),"确认告警"]})]})]})})}function Lt({alert:t,open:s,onOpenChange:n,onSilence:u}){return e.jsx(K,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:109:5",open:s,onOpenChange:n,children:e.jsxs(Q,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:110:7",children:[e.jsxs(V,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:111:9",children:[e.jsx(U,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:112:11",children:"静默告警"}),e.jsx(H,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:113:11",children:"选择静默持续时间"})]}),e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:115:9",className:"space-y-2",children:["1h","4h","8h","24h","7d"].map(g=>e.jsxs(m,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:117:13",variant:"outline",className:"w-full justify-between",onClick:()=>t&&u(t.id,g),children:[e.jsxs("span",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:123:15",children:["静默 ",g]}),e.jsx(ut,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:124:15",className:"w-4 h-4"})]},g))})]})})}const Re=[{value:"feishu",label:"飞书",placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/..."},{value:"dingtalk",label:"钉钉",placeholder:"https://oapi.dingtalk.com/robot/send?access_token=..."},{value:"wechat",label:"企业微信",placeholder:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=..."},{value:"webhook",label:"自定义Webhook",placeholder:"https://your-webhook-url..."}];function zt({open:t,onOpenChange:s,editingContact:n,onSaved:u}){const[g,h]=a.useState("feishu"),[l,C]=a.useState({name:"",phone:"",email:"",webhook_url:""}),[w,v]=a.useState(!1);a.useEffect(()=>{t&&(n?(h(n.channel_type||"feishu"),C({name:n.name||"",phone:n.phone||"",email:n.email||"",webhook_url:n.webhook_url||""})):(h("feishu"),C({name:"",phone:"",email:"",webhook_url:""})))},[t,n]);const f=async()=>{if(!(!l.name.trim()||!l.webhook_url.trim())){v(!0);try{const p={name:l.name.trim(),phone:l.phone.trim()||void 0,email:l.email.trim()||void 0,channel_type:g,webhook_url:l.webhook_url.trim()};n?(await R.updateContact(n.id,p),d.success("联系人已更新")):(await R.createContact(p),d.success("联系人已添加")),s(!1),u()}catch{d.error("保存失败")}finally{v(!1)}}},o=Re.find(p=>p.value===g);return e.jsx(K,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:85:5",open:t,onOpenChange:s,children:e.jsxs(Q,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:86:7",children:[e.jsxs(V,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:87:9",children:[e.jsx(U,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:88:11",children:n?"编辑报警联系人":"添加报警联系人"}),e.jsx(H,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:89:11",children:"选择通知渠道并填入 Webhook 地址"})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:91:9",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:92:11",className:"space-y-2",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:93:13",children:"姓名 *"}),e.jsx(_,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:94:13",value:l.name,onChange:p=>C({...l,name:p.target.value}),placeholder:"如:张三"})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:100:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:101:13",className:"space-y-2",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:102:15",children:"手机号"}),e.jsx(_,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:103:15",value:l.phone,onChange:p=>C({...l,phone:p.target.value}),placeholder:"13800138000"})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:109:13",className:"space-y-2",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:110:15",children:"邮箱"}),e.jsx(_,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:111:15",value:l.email,onChange:p=>C({...l,email:p.target.value}),placeholder:"zhangsan@example.com"})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:118:11",className:"space-y-2",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:119:13",children:"渠道类型 *"}),e.jsxs(ne,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:120:13",value:g,onValueChange:h,children:[e.jsx(se,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:121:15",children:e.jsx(oe,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:122:17",placeholder:"选择渠道类型"})}),e.jsx(ce,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:124:15",children:Re.map(p=>e.jsx(T,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:126:19",value:p.value,children:p.label},p.value))})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:131:11",className:"space-y-2",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:132:13",children:"Webhook URL *"}),e.jsx(_,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:133:13",value:l.webhook_url,onChange:p=>C({...l,webhook_url:p.target.value}),placeholder:o?.placeholder||"https://...",className:"font-mono text-xs"})]})]}),e.jsxs(ie,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:141:9",children:[e.jsx(m,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:142:11",variant:"outline",onClick:()=>s(!1),children:"取消"}),e.jsx(m,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:143:11",onClick:f,disabled:!l.name.trim()||!l.webhook_url.trim()||w,children:w?"保存中...":n?"保存修改":"添加联系人"})]})]})})}function Gt({open:t,onOpenChange:s,editingGroup:n,contacts:u,onSaved:g}){const[h,l]=a.useState({group_name:"",notes:"",contact_ids:[]}),[C,w]=a.useState(!1);a.useEffect(()=>{if(t)if(n){let o=[];try{o=JSON.parse(n.contact_ids||"[]")}catch{}l({group_name:n.group_name||"",notes:n.notes||"",contact_ids:o})}else l({group_name:"",notes:"",contact_ids:[]})},[t,n]);const v=o=>{l(p=>({...p,contact_ids:p.contact_ids.includes(o)?p.contact_ids.filter(O=>O!==o):[...p.contact_ids,o]}))},f=async()=>{if(h.group_name.trim()){w(!0);try{const o={group_name:h.group_name.trim(),notes:h.notes.trim()||void 0,contact_ids:h.contact_ids};n?(await R.updateContactGroup(n.id,o),d.success("联系组已更新")):(await R.createContactGroup(o),d.success("联系组已添加")),s(!1),g()}catch{d.error("保存失败")}finally{w(!1)}}};return e.jsx(K,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:84:5",open:t,onOpenChange:s,children:e.jsxs(Q,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:85:7",children:[e.jsxs(V,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:86:9",children:[e.jsx(U,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:87:11",children:n?"编辑报警联系组":"添加报警联系组"}),e.jsx(H,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:88:11",children:"配置报警联系组,选择组内成员"})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:90:9",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:91:11",className:"space-y-2",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:92:13",children:"组名称 *"}),e.jsx(_,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:93:13",value:h.group_name,onChange:o=>l({...h,group_name:o.target.value}),placeholder:"如:运维值班组"})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:99:11",className:"space-y-2",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:100:13",children:"备注"}),e.jsx(wt,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:101:13",value:h.notes,onChange:o=>l({...h,notes:o.target.value}),placeholder:"如:周一至周五 9:00-21:00",rows:2})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:108:11",className:"space-y-2",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:109:13",children:"选择联系人"}),u.length===0?e.jsx("p",{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:111:15",className:"text-xs text-muted-foreground",children:"暂无联系人,请先在「报警联系人」标签页添加"}):e.jsx("div",{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:113:15",className:"flex flex-wrap gap-1.5 max-h-[180px] overflow-y-auto border rounded-md p-2",children:u.map(o=>e.jsxs(A,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:115:19",variant:h.contact_ids.includes(o.id)?"default":"outline",className:"cursor-pointer text-xs",onClick:()=>v(o.id),children:[o.name,h.contact_ids.includes(o.id)&&" ✓"]},o.id))}),h.contact_ids.length>0&&e.jsxs("p",{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:128:15",className:"text-xs text-muted-foreground",children:["已选择 ",h.contact_ids.length," 位联系人"]})]})]}),e.jsxs(ie,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:132:9",children:[e.jsx(m,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:133:11",variant:"outline",onClick:()=>s(!1),children:"取消"}),e.jsx(m,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:134:11",onClick:f,disabled:!h.group_name.trim()||C,children:C?"保存中...":n?"保存修改":"添加联系组"})]})]})})}const Mt={onetime:"一次性",daily:"每天循环",weekly:"每周循环"},$t=["周日","周一","周二","周三","周四","周五","周六"];function ee(t){const s=t.getTimezoneOffset();return new Date(t.getTime()-s*6e4).toISOString().slice(0,16)}function Ee(t,s){return new Date(t.getTime()+s*36e5)}function It({open:t,onOpenChange:s,editingSilence:n,onSaved:u}){const[g,h]=a.useState(!1),[l,C]=a.useState(""),[w,v]=a.useState(""),[f,o]=a.useState("onetime"),[p,O]=a.useState(""),[L,c]=a.useState(""),[N,k]=a.useState([]);a.useEffect(()=>{if(n){C(n.name||""),v(n.description||""),o(n.silence_type||"onetime");const x=n.start_time?new Date(n.start_time):new Date,y=n.end_time?new Date(n.end_time):Ee(new Date,1);O(ee(x)),c(ee(y));let G=[];if(n.weekday_list)G=n.weekday_list;else if(n.weekdays)try{G=JSON.parse(n.weekdays)}catch{}k(G)}else{C(""),v(""),o("onetime");const x=new Date;O(ee(x)),c(ee(Ee(x,2))),k([])}},[n,t]);const S=x=>{k(y=>y.includes(x)?y.filter(G=>G!==x):[...y,x])},z=async()=>{if(!l.trim()){d.error("请填写规则名称");return}if(!L){d.error("请设置结束时间");return}if(f==="weekly"&&N.length===0){d.error("每周静默需要选择至少一个星期");return}const x={name:l.trim(),description:w.trim(),silence_type:f,start_time:p,end_time:L,weekdays:f==="weekly"?N:[]};h(!0);try{n?(await E.updateSilence(n.id,x),d.success("静默规则已更新")):(await E.createSilence(x),d.success("静默规则已创建")),s(!1),u()}catch{d.error("保存失败")}finally{h(!1)}};return e.jsx(K,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:142:5",open:t,onOpenChange:s,children:e.jsxs(Q,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:143:7",showOverlay:!1,className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] max-w-lg",children:[e.jsxs(V,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:144:9",children:[e.jsx(U,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:145:11",className:"text-[var(--dg-text-primary)]",children:n?"编辑静默规则":"创建静默规则"}),e.jsx(H,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:148:11",className:"text-[var(--dg-text-secondary)]",children:"静默期间匹配的告警将不会触发通知"})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:152:9",className:"space-y-4 max-h-[60vh] overflow-y-auto pr-1",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:154:11",className:"space-y-1.5",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:155:13",className:"text-[var(--dg-text-primary)]",children:"规则名称 *"}),e.jsx(_,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:156:13",value:l,onChange:x=>C(x.target.value),placeholder:"如:维护窗口静默",className:"bg-[var(--dg-bg-primary)]"})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:165:11",className:"space-y-1.5",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:166:13",className:"text-[var(--dg-text-primary)]",children:"描述"}),e.jsx(_,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:167:13",value:w,onChange:x=>v(x.target.value),placeholder:"可选备注",className:"bg-[var(--dg-bg-primary)]"})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:176:11",className:"space-y-1.5",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:177:13",className:"text-[var(--dg-text-primary)]",children:"静默类型"}),e.jsxs(ne,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:178:13",value:f,onValueChange:o,children:[e.jsx(se,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:179:15",className:"bg-[var(--dg-bg-primary)]",children:e.jsx(oe,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:180:17"})}),e.jsx(ce,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:182:15",children:Object.entries(Mt).map(([x,y])=>e.jsx(T,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:184:19",value:x,children:y},x))})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:191:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:192:13",className:"space-y-1.5",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:193:15",className:"text-[var(--dg-text-primary)]",children:f==="onetime"?"开始时间":"每日开始"}),e.jsx(_,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:196:15",type:"datetime-local",value:p,onChange:x=>O(x.target.value),className:"bg-[var(--dg-bg-primary)]"})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:203:13",className:"space-y-1.5",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:204:15",className:"text-[var(--dg-text-primary)]",children:f==="onetime"?"结束时间":"每日结束"}),e.jsx(_,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:207:15",type:"datetime-local",value:L,onChange:x=>c(x.target.value),className:"bg-[var(--dg-bg-primary)]"})]})]}),f==="weekly"&&e.jsxs("div",{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:218:13",className:"space-y-1.5",children:[e.jsx(j,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:219:15",className:"text-[var(--dg-text-primary)]",children:"生效星期"}),e.jsx("div",{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:220:15",className:"flex flex-wrap gap-2",children:$t.map((x,y)=>e.jsx("button",{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:222:19",type:"button",onClick:()=>S(y),className:`px-3 py-1.5 rounded-md text-xs transition-colors ${N.includes(y)?"bg-primary text-primary-foreground":"bg-[var(--dg-bg-primary)] border border-[var(--dg-border)] text-[var(--dg-text-secondary)]"}`,children:x},y))})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:240:11",className:"text-xs text-muted-foreground bg-muted/50 rounded-md p-2",children:[f==="onetime"&&"在指定时间窗口内,所有匹配条件的告警将被静默。窗口结束后自动恢复正常。",f==="daily"&&"每天在指定时段内静默告警,适合非工作时间免打扰。",f==="weekly"&&"仅在选定星期的指定时段内静默,适合周末维护窗口。"]})]}),e.jsxs(ie,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:246:9",children:[e.jsx(m,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:247:11",variant:"outline",onClick:()=>s(!1),children:"取消"}),e.jsx(m,{"code-path":"src/components/monitor/alert-center/SilenceDialog.tsx:248:11",onClick:z,disabled:g,children:g?"保存中…":"保存"})]})]})})}const qt={onetime:"一次性",daily:"每天",weekly:"每周"},Ft=["日","一","二","三","四","五","六"];function P(t){if(!t)return"—";const s=typeof t=="string"?new Date(t):t;return isNaN(s.getTime())?"—":s.toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}const Bt=()=>{const t=Oe(),[s,n]=a.useState([]),[u,g]=a.useState(!1),[h,l]=a.useState(!1),[C,w]=a.useState(null),v=a.useCallback(async()=>{g(!0);try{const c=await E.getSilences(),N=c?.list||c?.data?.list||[];n(N)}catch{d.error("获取静默规则失败")}finally{g(!1)}},[]);a.useEffect(()=>{v()},[v]);const f=()=>{w(null),l(!0)},o=c=>{w(c),l(!0)},p=async c=>{if(await t({title:"删除静默规则",description:`确定删除「${c.name}」?删除后该规则匹配的告警将恢复通知。`,confirmText:"删除",variant:"destructive"}))try{await E.deleteSilence(c.id),d.success("已删除"),v()}catch{d.error("删除失败")}},O=async c=>{try{await E.toggleSilence(c.id),d.success(c.status===1?"已禁用":"已启用"),v()}catch{d.error("操作失败")}},L=c=>{if(c.is_active!==void 0)return c.is_active;if(c.status!==1)return!1;const N=new Date,k=new Date(c.start_time),S=new Date(c.end_time);return N>=k&&N<=S};return e.jsxs("div",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:103:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:105:7",className:"flex justify-between items-center",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:106:9",className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(le,{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:107:11",className:"w-4 h-4"}),e.jsxs("span",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:108:11",children:["共 ",s.length," 条规则"]})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:110:9",className:"flex items-center gap-2",children:[e.jsxs(m,{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:111:11",variant:"outline",size:"sm",onClick:v,disabled:u,children:[e.jsx(te,{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:112:13",className:"w-3.5 h-3.5 mr-1"}),"刷新"]}),e.jsxs(m,{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:115:11",size:"sm",onClick:f,children:[e.jsx(re,{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:116:13",className:"w-3.5 h-3.5 mr-1"}),"添加静默规则"]})]})]}),u&&s.length===0?e.jsx("div",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:124:9",className:"text-center py-12 text-muted-foreground",children:e.jsx("p",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:125:11",className:"text-sm",children:"加载中..."})}):s.length===0?e.jsxs("div",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:128:9",className:"text-center py-12 text-muted-foreground border border-dashed rounded-lg",children:[e.jsx(le,{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:129:11",className:"w-10 h-10 mx-auto mb-2 opacity-50"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:130:11",className:"text-sm",children:"暂无静默规则"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:131:11",className:"text-xs mt-1",children:"点击「添加静默规则」创建维护窗口或免打扰时段"})]}):e.jsx("div",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:134:9",className:"grid grid-cols-1 gap-3",children:s.map(c=>{const N=L(c),k=c.status===1,S=c.silence_type||"onetime",z=c.weekday_list||(()=>{try{return JSON.parse(c.weekdays||"[]")}catch{return[]}})();return e.jsx(W,{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:143:15",className:N?"border-primary/50":"",children:e.jsx(J,{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:144:17",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:145:19",className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:147:21",className:"flex-1 min-w-0",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:148:23",className:"flex items-center gap-2 mb-1.5 flex-wrap",children:[e.jsx("span",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:149:25",className:"font-medium text-sm",children:c.name}),e.jsxs(A,{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:151:25",variant:"outline",className:"text-xs",children:[S==="onetime"&&e.jsx(gt,{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:152:51",className:"w-3 h-3 mr-1"}),S==="daily"&&e.jsx(jt,{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:153:49",className:"w-3 h-3 mr-1"}),S==="weekly"&&e.jsx(Ct,{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:154:50",className:"w-3 h-3 mr-1"}),qt[S]||S]}),N&&e.jsx(A,{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:159:27",className:"bg-green-500 text-xs",children:"生效中"}),!k&&e.jsx(A,{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:162:27",variant:"secondary",className:"text-xs",children:"已禁用"})]}),c.description&&e.jsx("p",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:167:25",className:"text-xs text-muted-foreground mb-1.5",children:c.description}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:171:23",className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[e.jsx("span",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:172:25",children:S==="onetime"?`${P(c.start_time)} — ${P(c.end_time)}`:`每日 ${P(c.start_time)} — ${P(c.end_time)}`}),S==="weekly"&&z.length>0&&e.jsx("span",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:179:27",className:"flex items-center gap-1",children:z.sort((x,y)=>x-y).map(x=>e.jsx("span",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:181:31",className:"inline-flex items-center justify-center w-5 h-5 rounded-full bg-primary/10 text-primary text-[10px]",children:Ft[x]},x))})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:190:23",className:"text-[10px] text-muted-foreground/60 mt-1",children:["创建于 ",P(c.created_at)]})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:196:21",className:"flex items-center gap-2 shrink-0",children:[e.jsx(Le,{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:197:23",checked:k,onCheckedChange:()=>O(c)}),e.jsxs(m,{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:201:23",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>o(c),children:[e.jsx(ft,{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:202:25",className:"w-3 h-3 mr-1"}),"编辑"]}),e.jsxs(m,{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:204:23",variant:"ghost",size:"sm",className:"h-7 text-xs text-red-400",onClick:()=>p(c),children:[e.jsx(vt,{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:205:25",className:"w-3 h-3 mr-1"}),"删除"]})]})]})})},c.id)})}),e.jsx(It,{"code-path":"src/components/monitor/alert-center/SilenceRuleTab.tsx:217:7",open:h,onOpenChange:l,editingSilence:C,onSaved:v})]})},ir=()=>{const t=Oe(),[s,n]=a.useState(""),[u,g]=a.useState("all"),[h,l]=a.useState("all"),[C,w]=a.useState("alerts"),[v,f]=a.useState(null),[o,p]=a.useState(!1),[O,L]=a.useState(!1),[c,N]=a.useState(!1),[k,S]=a.useState(null),[z,x]=a.useState([]),[y,G]=a.useState([]),[qe,me]=a.useState(!1),[Fe,ve]=a.useState(null),[Be,de]=a.useState(!1),[Pe,Ae]=a.useState(null),[M,Y]=a.useState(1),[pe]=a.useState(10),We=a.useMemo(()=>({page:M,page_size:pe,severity:u,status:h}),[M,pe,u,h]),{data:xe,isLoading:Je,refetch:Ne}=Rt(We),{data:ye=[],refetch:be}=_t(),{ackMutation:Ke,resolveMutation:Qe,quickSetupMutation:he,toggleAgentRuleMutation:Ve,deleteAgentRuleMutation:Ue}=Et(),ue=xe?.list??[],ge=xe?.total??0,q=xe?.stats??{firing:0,critical:0,warning:0,resolved:0},I=Math.max(1,Math.ceil(ge/pe));a.useEffect(()=>{C==="contacts"&&Z(),C==="groups"&&(Z(),X())},[C]);const Z=async()=>{try{const r=await R.getContacts();x(r?.data?.list||r?.list||[])}catch{}},X=async()=>{try{const r=await R.getContactGroups();G(r?.data?.list||r?.list||[])}catch{}},we=async r=>{try{await Ke.mutateAsync(r),d.success("告警已确认")}catch{d.error("操作失败")}},He=async r=>{try{await Qe.mutateAsync(r),d.success("告警已解决")}catch{d.error("操作失败")}},Ye=async(r,i)=>{try{const D=ue.find(ot=>ot.id===r),b=new Date,je=i.match(/^(\d+)([hd])$/),ke=je?parseInt(je[1]):1,nt=(je?.[2]||"h")==="d"?ke*24:ke,st=new Date(b.getTime()+nt*36e5);await E.createSilence({name:`静默: ${D?.title||r} (${i})`,description:`从告警列表快速静默 — ${D?.source||""}`,silence_type:"onetime",start_time:b.toISOString(),end_time:st.toISOString()}),d.success(`告警已静默 ${i}`),L(!1),Ne()}catch{d.error("操作失败")}},Ze=async(r,i)=>{try{await Ve.mutateAsync({id:Number(r),enabled:i}),d.success("规则状态已更新")}catch{d.error("更新失败")}},Xe=()=>{S(null),N(!0)},et=r=>{S(r),N(!0)},Se=()=>{N(!1),S(null)},tt=async()=>{if(await t({title:"一键报警",description:"为 Agent 在线主机创建 CPU(>80%)/内存(>80%)/磁盘(>90%)/TIME_WAIT(>15000)/CLOSE_WAIT(>200)/进程检测 6 条告警规则。",confirmText:"确认创建"}))try{const i=await he.mutateAsync("ecs");d.success(typeof i=="string"?i:i?.message||"默认告警规则创建成功")}catch{d.error("创建失败,请检查 Agent 主机是否在线")}},rt=async r=>{if(await t({title:"删除规则",description:`确定删除规则「${r.name}」?`,confirmText:"删除",variant:"destructive"}))try{await Ue.mutateAsync(Number(r.id)),d.success("已删除")}catch{d.error("删除失败")}},De=(r,i)=>{r==="severity"?g(i):l(i),Y(1)};return e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:180:5",className:"space-y-3",children:[e.jsx(at,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:182:7",items:[{label:"触发中",value:q.firing,color:q.firing>0?"red":"muted"},{label:"严重",value:q.critical,color:"red"},{label:"警告",value:q.warning,color:"amber"},{label:"已解决",value:q.resolved,color:"emerald"}]}),e.jsxs(lt,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:191:7",value:C,onValueChange:w,children:[e.jsxs(it,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:192:9",className:"grid w-full grid-cols-5 lg:w-[600px] h-9",children:[e.jsx(F,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:193:11",value:"alerts",className:"text-xs",children:"告警列表"}),e.jsx(F,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:194:11",value:"rules",className:"text-xs",children:"告警规则"}),e.jsx(F,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:195:11",value:"silences",className:"text-xs",children:"静默规则"}),e.jsx(F,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:196:11",value:"contacts",className:"text-xs",children:"报警联系人"}),e.jsx(F,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:197:11",value:"groups",className:"text-xs",children:"报警联系组"})]}),e.jsxs(B,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:201:9",value:"alerts",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:202:11",className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:203:13",className:"flex items-center gap-2 flex-1 min-w-[280px]",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:204:15",className:"relative flex-1",children:[e.jsx(At,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:205:17",className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),e.jsx(_,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:206:17",placeholder:"搜索告警...",value:s,onChange:r=>n(r.target.value),className:"pl-8 h-8 text-xs"})]}),e.jsxs(ne,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:213:15",value:u,onValueChange:r=>De("severity",r),children:[e.jsx(se,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:214:17",className:"w-[100px] h-8 text-xs",children:e.jsx(oe,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:215:19",placeholder:"级别"})}),e.jsxs(ce,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:217:17",children:[e.jsx(T,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:218:19",value:"all",children:"全部级别"}),e.jsx(T,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:219:19",value:"critical",children:"严重"}),e.jsx(T,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:220:19",value:"warning",children:"警告"}),e.jsx(T,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:221:19",value:"info",children:"信息"})]})]}),e.jsxs(ne,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:224:15",value:h,onValueChange:r=>De("status",r),children:[e.jsx(se,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:225:17",className:"w-[100px] h-8 text-xs",children:e.jsx(oe,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:226:19",placeholder:"状态"})}),e.jsxs(ce,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:228:17",children:[e.jsx(T,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:229:19",value:"all",children:"全部状态"}),e.jsx(T,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:230:19",value:"firing",children:"触发中"}),e.jsx(T,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:231:19",value:"acknowledged",children:"已确认"}),e.jsx(T,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:232:19",value:"resolved",children:"已解决"})]})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:236:13",className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsxs("span",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:237:15",children:["共 ",ge," 条"]}),e.jsxs(m,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:238:15",variant:"outline",size:"sm",onClick:()=>Ne(),className:"h-7 text-xs px-2",children:[e.jsx(te,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:239:17",className:"w-3 h-3 mr-1"}),"刷新"]})]})]}),e.jsx(W,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:245:11",children:e.jsxs(J,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:246:13",className:"p-0",children:[e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:247:15",className:"overflow-x-auto",children:e.jsxs("table",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:248:17",className:"w-full text-sm",children:[e.jsx("thead",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:249:19",className:"bg-muted/50",children:e.jsxs("tr",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:250:21",children:[e.jsx("th",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:251:23",className:"px-3 py-2 text-left text-xs font-medium",children:"告警信息"}),e.jsx("th",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:252:23",className:"px-3 py-2 text-left text-xs font-medium w-16",children:"级别"}),e.jsx("th",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:253:23",className:"px-3 py-2 text-left text-xs font-medium w-16",children:"状态"}),e.jsx("th",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:254:23",className:"px-3 py-2 text-left text-xs font-medium w-24",children:"来源"}),e.jsx("th",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:255:23",className:"px-3 py-2 text-left text-xs font-medium w-20",children:"持续"}),e.jsx("th",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:256:23",className:"px-3 py-2 text-left text-xs font-medium w-28",children:"操作"})]})}),e.jsx("tbody",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:259:19",className:"divide-y",children:Je?e.jsx("tr",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:261:23",children:e.jsx("td",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:261:27",colSpan:6,className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"加载中..."})}):ue.length===0?e.jsx("tr",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:263:23",children:e.jsx("td",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:263:27",colSpan:6,className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"暂无告警"})}):ue.filter(r=>{if(!s)return!0;const i=s.toLowerCase();return r.title.toLowerCase().includes(i)||r.description.toLowerCase().includes(i)||r.source.toLowerCase().includes(i)}).map(r=>e.jsxs("tr",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:273:25",className:"hover:bg-muted/50",children:[e.jsxs("td",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:274:27",className:"px-3 py-2",children:[e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:275:29",className:"font-medium text-xs",children:r.title}),e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:276:29",className:"text-xs text-muted-foreground line-clamp-1",children:r.description}),e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:277:29",className:"flex gap-1 mt-0.5",children:Object.entries(r.labels).slice(0,2).map(([i,D])=>e.jsxs(A,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:279:33",variant:"outline",className:"text-[10px] px-1 py-0",children:[i,"=",D]},i))})]}),e.jsx("td",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:283:27",className:"px-3 py-2",children:fe(r.severity)}),e.jsx("td",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:284:27",className:"px-3 py-2",children:Dt(r.status)}),e.jsxs("td",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:285:27",className:"px-3 py-2 text-xs",children:[e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:286:29",children:r.source}),e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:287:29",className:"text-muted-foreground text-[10px]",children:r.service})]}),e.jsx("td",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:289:27",className:"px-3 py-2 text-xs text-muted-foreground",children:r.status==="resolved"&&r.resolvedAt?`${Math.floor((new Date(r.resolvedAt).getTime()-new Date(r.startedAt).getTime())/6e4)}分`:`${Math.floor((Date.now()-new Date(r.startedAt).getTime())/6e4)}分`}),e.jsx("td",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:294:27",className:"px-3 py-2",children:e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:295:29",className:"flex items-center gap-0.5",children:[e.jsx(m,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:296:31",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{f(r),p(!0)},children:e.jsx(Nt,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:298:33",className:"w-3.5 h-3.5"})}),r.status==="firing"&&e.jsx(m,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:301:33",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>we(r.id),children:e.jsx(Ie,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:303:35",className:"w-3.5 h-3.5 text-blue-600"})}),(r.status==="firing"||r.status==="acknowledged")&&e.jsx(m,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:307:33",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>He(r.id),children:e.jsx($e,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:309:35",className:"w-3.5 h-3.5 text-green-600"})}),e.jsx(m,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:312:31",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{f(r),L(!0)},children:e.jsx(le,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:314:33",className:"w-3.5 h-3.5 text-orange-600"})})]})})]},r.id))})]})}),I>1&&e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:326:17",className:"flex items-center justify-between px-3 py-2 border-t text-xs",children:[e.jsxs("span",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:327:19",className:"text-muted-foreground",children:["第 ",M,"/",I," 页,共 ",ge," 条"]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:328:19",className:"flex items-center gap-1",children:[e.jsx(m,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:329:21",variant:"outline",size:"sm",className:"h-7 text-xs px-2",disabled:M<=1,onClick:()=>Y(r=>r-1),children:"上一页"}),Array.from({length:Math.min(I,5)},(r,i)=>{const b=Math.max(1,Math.min(M-2,I-4))+i;return b>I?null:e.jsx(m,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:338:25",variant:b===M?"default":"outline",size:"sm",className:"h-7 min-w-[28px] text-xs px-1",onClick:()=>Y(b),children:b},b)}),e.jsx(m,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:345:21",variant:"outline",size:"sm",className:"h-7 text-xs px-2",disabled:M>=I,onClick:()=>Y(r=>r+1),children:"下一页"})]})]})]})})]}),e.jsxs(B,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:357:9",value:"rules",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:358:11",className:"flex justify-between items-center",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:359:13",className:"flex items-center gap-2",children:[e.jsxs(m,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:360:15",onClick:Xe,children:[e.jsx(re,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:361:17",className:"w-4 h-4 mr-1"}),"添加规则"]}),e.jsxs(m,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:363:15",variant:"secondary",onClick:tt,disabled:he.isPending,children:[e.jsx(yt,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:364:17",className:"w-4 h-4 mr-1"}),he.isPending?"创建中…":"一键报警"]})]}),e.jsxs(m,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:368:13",variant:"outline",onClick:()=>be(),children:[e.jsx(te,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:369:15",className:"w-4 h-4 mr-2"}),"刷新"]})]}),ye.length===0?e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:374:13",className:"text-center py-12 text-muted-foreground",children:[e.jsx(Me,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:375:15",className:"w-10 h-10 mx-auto mb-2 opacity-50"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:376:15",className:"text-sm",children:"暂无告警规则"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:377:15",className:"text-xs mt-1",children:"点击「添加规则」或「一键报警」快速创建"})]}):e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:380:11",className:"grid grid-cols-1 gap-4",children:ye.map(r=>e.jsx(W,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:382:15",children:e.jsx(J,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:383:17",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:384:19",className:"flex items-start justify-between",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:385:21",className:"flex-1",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:386:23",className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:387:25",className:"font-medium",children:r.name}),fe(r.severity),e.jsx(A,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:389:25",variant:r.enabled?"default":"secondary",children:r.enabled?"已启用":"已禁用"})]}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:393:23",className:"text-sm text-muted-foreground mb-2",children:r.description}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:394:23",className:"flex items-center gap-4 text-xs text-muted-foreground",children:[r.expression&&e.jsx("span",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:396:27",className:"font-mono bg-muted px-2 py-1 rounded",children:r.expression}),r.duration?e.jsxs("span",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:398:42",children:["持续 ",r.duration,"秒"]}):null]}),(()=>{let i=[];try{const D=r.notify_channels;D&&(i=Array.isArray(D)?D:JSON.parse(D))}catch{}return i.length?e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:408:27",className:"flex gap-1 mt-2",children:i.map(D=>e.jsx(A,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:410:31",variant:"outline",className:"text-xs",children:D},D))}):null})()]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:416:21",className:"flex items-center gap-2",children:[e.jsx(m,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:417:23",variant:"ghost",size:"sm",onClick:()=>et(r),children:"编辑"}),e.jsx(m,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:418:23",variant:"ghost",size:"sm",className:"text-red-400",onClick:()=>rt(r),children:"删除"}),e.jsx(Le,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:419:23",checked:r.enabled,onCheckedChange:i=>Ze(String(r.id),i)})]})]})})},r.id))})]}),e.jsx(B,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:433:9",value:"silences",children:e.jsx(Bt,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:434:11"})}),e.jsxs(B,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:438:9",value:"contacts",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:439:13",className:"flex justify-between items-center",children:[e.jsx("h3",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:440:15",className:"text-sm font-medium",children:"报警联系人"}),e.jsxs(m,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:441:15",size:"sm",onClick:()=>{ve(null),me(!0)},children:[e.jsx(re,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:442:17",className:"w-4 h-4 mr-1"}),"添加联系人"]})]}),z.length===0?e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:447:15",className:"text-center py-8 text-muted-foreground border border-dashed rounded-lg text-xs",children:"暂无报警联系人,点击「添加联系人」创建"}):e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:451:15",className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:z.map(r=>e.jsxs(W,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:453:19",className:"hover:border-primary/50 transition-colors",children:[e.jsx(Te,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:454:21",className:"pb-2",children:e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:455:23",className:"flex items-start justify-between",children:e.jsx(_e,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:456:25",className:"text-sm",children:r.name})})}),e.jsxs(J,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:459:21",className:"pt-0 space-y-1 text-xs text-muted-foreground",children:[r.phone&&e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:460:35",children:["📱 ",r.phone]}),r.email&&e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:461:35",children:["📧 ",r.email]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:462:23",className:"flex gap-1 flex-wrap",children:[r.channel_type&&e.jsx(A,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:464:27",variant:"outline",className:"text-[10px]",children:kt(r.channel_type)}),r.webhook_url&&e.jsx("span",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:469:27",className:"text-[10px] text-muted-foreground truncate max-w-[200px]",title:r.webhook_url,children:r.webhook_url})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:474:23",className:"flex gap-1.5 pt-1.5",children:[e.jsx(m,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:475:25",variant:"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>{ve(r),me(!0)},children:"编辑"}),e.jsx(m,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:479:25",variant:"outline",size:"sm",className:"h-7 text-xs",onClick:async()=>{if(await t({title:"删除联系人",description:`确定删除「${r.name}」?`,confirmText:"删除",variant:"destructive"}))try{await R.deleteContact(r.id),d.success("已删除"),Z()}catch{d.error("删除失败")}},children:"删除"})]})]})]},r.id))})]}),e.jsxs(B,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:497:9",value:"groups",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:498:11",className:"flex justify-between items-center",children:[e.jsxs(m,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:499:13",variant:"outline",onClick:X,children:[e.jsx(te,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:500:15",className:"w-4 h-4 mr-2"}),"刷新"]}),e.jsxs(m,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:503:13",onClick:()=>{Ae(null),de(!0)},children:[e.jsx(re,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:504:15",className:"w-4 h-4 mr-2"}),"添加联系组"]})]}),y.length===0?e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:509:13",className:"text-center py-16 text-muted-foreground border border-dashed rounded-lg",children:"暂无报警联系组,点击「添加联系组」创建"}):e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:513:13",className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:y.map(r=>{let i=[];try{i=JSON.parse(r.contact_ids||"[]")}catch{}const D=z.filter(b=>i.includes(b.id)).map(b=>b.name);return e.jsxs(W,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:521:19",className:"hover:border-primary/50 transition-colors",children:[e.jsx(Te,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:522:21",children:e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:523:23",className:"flex items-start justify-between",children:[e.jsx(_e,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:524:25",className:"text-base",children:r.group_name}),e.jsxs(A,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:525:25",variant:"secondary",children:[i.length," 人"]})]})}),e.jsxs(J,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:528:21",className:"pt-0 space-y-2",children:[r.notes&&e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:529:35",className:"text-sm text-muted-foreground",children:r.notes}),e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:530:23",className:"flex flex-wrap gap-1",children:D.map(b=>e.jsx(A,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:532:27",variant:"outline",className:"text-xs",children:b},b))}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:535:23",className:"flex gap-2 pt-2",children:[e.jsx(m,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:536:25",variant:"outline",size:"sm",className:"flex-1",onClick:()=>{Ae(r),de(!0)},children:"编辑"}),e.jsx(m,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:540:25",variant:"outline",size:"sm",onClick:async()=>{if(await t({title:"删除联系组",description:`确定删除联系组「${r.group_name}」?`,confirmText:"删除",variant:"destructive"}))try{await R.deleteContactGroup(r.id),d.success("已删除"),X()}catch{d.error("删除失败")}},children:"删除"})]})]})]},r.id)})})]})]}),e.jsx(Ot,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:559:7",alert:v,open:o,onOpenChange:p,onAcknowledge:we}),e.jsx(Lt,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:565:7",alert:v,open:O,onOpenChange:L,onSilence:Ye}),e.jsx(bt,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:571:7",open:c,onOpenChange:Se,editingRule:k,notifyChannels:[],onSaved:()=>{Se(),be()}}),e.jsx(zt,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:578:7",open:qe,onOpenChange:me,editingContact:Fe,onSaved:Z}),e.jsx(Gt,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:584:7",open:Be,onOpenChange:de,editingGroup:Pe,contacts:z,onSaved:()=>{X()}})]})};export{ir as default}; diff --git a/backend/static/assets/AlertManager-Dt5F96tv.js b/backend/static/assets/AlertManager-Dt5F96tv.js deleted file mode 100644 index 0d2106a..0000000 --- a/backend/static/assets/AlertManager-Dt5F96tv.js +++ /dev/null @@ -1 +0,0 @@ -import{r as l,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{C as w,a as M,b as ee,c as te,d as se}from"./card-BIfzBCEy.js";import{f as _,B as A,t as E,D as oe,a as ae,b as ne,c as re,d as ce,e as le}from"./index-Dungj95X.js";import{T as ie,a as me,b as H,c as I}from"./tabs-D87nAyJR.js";import{a as g}from"./alert-v1WaPeEX.js";import{I as Y}from"./input-CXoUQQLm.js";import{B as f}from"./badge-CGJlVD3L.js";import{T as $,a as Q,b as R,c as i,d as X,e as c}from"./table-B2F10oba.js";import{S as de,L as O,y as J,t as V,l as z,T as B,p as q,P as U,b as xe}from"./vendor-icons-DmqcWdzX.js";import{S as P}from"./switch-Bxiq4EHp.js";import{C as G}from"./checkbox-Bu55mX0G.js";import{r as pe,g as he,C as K,A as ge}from"./AlertRuleDialog-BmYLySxp.js";import{L as D}from"./label-CMpUoC87.js";import{T as be}from"./textarea-BxfjmLq5.js";import{R as Ae,A as je,C as ue,X as Ne,Y as ve,T as fe,a as W}from"./AreaChart-yrR-Mxho.js";import"./index-5FEebgvX.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(V,{"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(de,{"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(Y,{"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($,{"code-path":"src/components/monitor/AlertEventsTab.tsx:135:13",children:[e.jsx(Q,{"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(X,{"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(J,{"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(B,{"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($,{"code-path":"src/components/monitor/AlertRulesTab.tsx:124:13",children:[e.jsx(Q,{"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(X,{"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(P,{"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(q,{"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(B,{"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(oe,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:119:5",open:m,onOpenChange:T,children:e.jsxs(ae,{"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(ne,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:121:9",children:[e.jsx(re,{"code-path":"src/components/monitor/AlertChannelDialog.tsx:122:11",className:"text-slate-100",children:"通知渠道配置"}),e.jsx(ce,{"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(P,{"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(B,{"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(Y,{"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(P,{"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(le,{"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 Ke(){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:76:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:78:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:79:9",children:[e.jsx("h1",{"code-path":"src/components/monitor/AlertManager.tsx:80:11",className:"text-2xl font-bold text-slate-100",children:"监控告警"}),e.jsx("p",{"code-path":"src/components/monitor/AlertManager.tsx:81:11",className:"text-sm text-slate-500 mt-1",children:"告警规则管理与告警事件处理"})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:83:9",className:"flex items-center gap-2",children:[e.jsxs(A,{"code-path":"src/components/monitor/AlertManager.tsx:84:11",variant:"outline",className:"border-slate-700 text-slate-300 hover:text-slate-100 hover:bg-slate-800",onClick:()=>t(!0),children:[e.jsx(q,{"code-path":"src/components/monitor/AlertManager.tsx:89:13",className:"h-4 w-4 mr-2"}),"通知配置"]}),e.jsxs(A,{"code-path":"src/components/monitor/AlertManager.tsx:92:11",className:"bg-blue-600 hover:bg-blue-700 text-white",onClick:k,children:[e.jsx(U,{"code-path":"src/components/monitor/AlertManager.tsx:93:13",className:"h-4 w-4 mr-2"}),"新建规则"]})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:100:7",className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx(w,{"code-path":"src/components/monitor/AlertManager.tsx:101:9",className:"bg-slate-900 border-slate-800",children:e.jsx(M,{"code-path":"src/components/monitor/AlertManager.tsx:102:11",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:103:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:104:15",children:[e.jsx("p",{"code-path":"src/components/monitor/AlertManager.tsx:105:17",className:"text-sm text-slate-500",children:"告警规则"}),e.jsx("p",{"code-path":"src/components/monitor/AlertManager.tsx:106:17",className:"text-2xl font-bold text-slate-100",children:u.length})]}),e.jsx("div",{"code-path":"src/components/monitor/AlertManager.tsx:108:15",className:"p-3 rounded-lg bg-blue-500/10 text-blue-400",children:e.jsx(V,{"code-path":"src/components/monitor/AlertManager.tsx:109:17",className:"h-5 w-5"})})]})})}),e.jsx(w,{"code-path":"src/components/monitor/AlertManager.tsx:114:9",className:"bg-slate-900 border-slate-800",children:e.jsx(M,{"code-path":"src/components/monitor/AlertManager.tsx:115:11",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:116:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:117:15",children:[e.jsx("p",{"code-path":"src/components/monitor/AlertManager.tsx:118:17",className:"text-sm text-slate-500",children:"触发中"}),e.jsx("p",{"code-path":"src/components/monitor/AlertManager.tsx:119: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:123:15",className:"p-3 rounded-lg bg-red-500/10 text-red-400",children:e.jsx(z,{"code-path":"src/components/monitor/AlertManager.tsx:124:17",className:"h-5 w-5"})})]})})}),e.jsx(w,{"code-path":"src/components/monitor/AlertManager.tsx:129:9",className:"bg-slate-900 border-slate-800",children:e.jsx(M,{"code-path":"src/components/monitor/AlertManager.tsx:130:11",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:131:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:132:15",children:[e.jsx("p",{"code-path":"src/components/monitor/AlertManager.tsx:133:17",className:"text-sm text-slate-500",children:"今日告警"}),e.jsx("p",{"code-path":"src/components/monitor/AlertManager.tsx:134:17",className:"text-2xl font-bold text-amber-400",children:d.length})]}),e.jsx("div",{"code-path":"src/components/monitor/AlertManager.tsx:136:15",className:"p-3 rounded-lg bg-amber-500/10 text-amber-400",children:e.jsx(xe,{"code-path":"src/components/monitor/AlertManager.tsx:137:17",className:"h-5 w-5"})})]})})}),e.jsx(w,{"code-path":"src/components/monitor/AlertManager.tsx:142:9",className:"bg-slate-900 border-slate-800",children:e.jsx(M,{"code-path":"src/components/monitor/AlertManager.tsx:143:11",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:144:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertManager.tsx:145:15",children:[e.jsx("p",{"code-path":"src/components/monitor/AlertManager.tsx:146:17",className:"text-sm text-slate-500",children:"已恢复"}),e.jsx("p",{"code-path":"src/components/monitor/AlertManager.tsx:147: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:151:15",className:"p-3 rounded-lg bg-emerald-500/10 text-emerald-400",children:e.jsx(J,{"code-path":"src/components/monitor/AlertManager.tsx:152:17",className:"h-5 w-5"})})]})})})]}),e.jsxs(w,{"code-path":"src/components/monitor/AlertManager.tsx:160:7",className:"bg-slate-900 border-slate-800",children:[e.jsxs(ee,{"code-path":"src/components/monitor/AlertManager.tsx:161:9",className:"pb-2",children:[e.jsx(te,{"code-path":"src/components/monitor/AlertManager.tsx:162:11",className:"text-slate-100",children:"告警趋势"}),e.jsx(se,{"code-path":"src/components/monitor/AlertManager.tsx:163:11",className:"text-slate-500",children:"过去24小时告警统计"})]}),e.jsx(M,{"code-path":"src/components/monitor/AlertManager.tsx:165:9",children:e.jsx("div",{"code-path":"src/components/monitor/AlertManager.tsx:166:11",className:"h-[200px]",children:e.jsx(Ae,{"code-path":"src/components/monitor/AlertManager.tsx:167:13",width:"100%",height:"100%",children:e.jsxs(je,{"code-path":"src/components/monitor/AlertManager.tsx:168:15",data:s,children:[e.jsxs("defs",{"code-path":"src/components/monitor/AlertManager.tsx:169:17",children:[e.jsxs("linearGradient",{"code-path":"src/components/monitor/AlertManager.tsx:170:19",id:"colorCritical",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{"code-path":"src/components/monitor/AlertManager.tsx:171:21",offset:"5%",stopColor:"#ef4444",stopOpacity:.3}),e.jsx("stop",{"code-path":"src/components/monitor/AlertManager.tsx:172:21",offset:"95%",stopColor:"#ef4444",stopOpacity:0})]}),e.jsxs("linearGradient",{"code-path":"src/components/monitor/AlertManager.tsx:174:19",id:"colorWarning",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{"code-path":"src/components/monitor/AlertManager.tsx:175:21",offset:"5%",stopColor:"#f59e0b",stopOpacity:.3}),e.jsx("stop",{"code-path":"src/components/monitor/AlertManager.tsx:176:21",offset:"95%",stopColor:"#f59e0b",stopOpacity:0})]})]}),e.jsx(ue,{"code-path":"src/components/monitor/AlertManager.tsx:179:17",strokeDasharray:"3 3",stroke:"#1e293b"}),e.jsx(Ne,{"code-path":"src/components/monitor/AlertManager.tsx:180:17",dataKey:"time",stroke:"#475569",fontSize:12}),e.jsx(ve,{"code-path":"src/components/monitor/AlertManager.tsx:181:17",stroke:"#475569",fontSize:12}),e.jsx(fe,{"code-path":"src/components/monitor/AlertManager.tsx:182:17",contentStyle:{backgroundColor:"#0f172a",border:"1px solid #1e293b",borderRadius:"6px",color:"#f8fafc"}}),e.jsx(W,{"code-path":"src/components/monitor/AlertManager.tsx:190:17",type:"monotone",dataKey:"critical",stroke:"#ef4444",fillOpacity:1,fill:"url(#colorCritical)",name:"严重"}),e.jsx(W,{"code-path":"src/components/monitor/AlertManager.tsx:198:17",type:"monotone",dataKey:"warning",stroke:"#f59e0b",fillOpacity:1,fill:"url(#colorWarning)",name:"警告"})]})})})})]}),e.jsxs(ie,{"code-path":"src/components/monitor/AlertManager.tsx:213:7",value:m,onValueChange:T,className:"w-full",children:[e.jsxs(me,{"code-path":"src/components/monitor/AlertManager.tsx:214:9",className:"bg-slate-800 border border-slate-700",children:[e.jsx(H,{"code-path":"src/components/monitor/AlertManager.tsx:215:11",value:"events",className:"data-[state=active]:bg-slate-700",children:"告警事件"}),e.jsx(H,{"code-path":"src/components/monitor/AlertManager.tsx:218:11",value:"rules",className:"data-[state=active]:bg-slate-700",children:"告警规则"})]}),e.jsx(I,{"code-path":"src/components/monitor/AlertManager.tsx:224:9",value:"events",children:e.jsx(Te,{"code-path":"src/components/monitor/AlertManager.tsx:225:11",alerts:d,loading:h,onReload:v})}),e.jsx(I,{"code-path":"src/components/monitor/AlertManager.tsx:228:9",value:"rules",children:e.jsx(ye,{"code-path":"src/components/monitor/AlertManager.tsx:229:11",rules:u,notifyChannels:r,onReload:v,onEditRule:S})})]}),e.jsx(ge,{"code-path":"src/components/monitor/AlertManager.tsx:240:7",open:C,onOpenChange:j,editingRule:y,notifyChannels:r,onSaved:v}),e.jsx(we,{"code-path":"src/components/monitor/AlertManager.tsx:247:7",open:x,onOpenChange:t,notifyChannels:r,onChannelsChanged:v})]})}export{Ke as AlertManager}; diff --git a/backend/static/assets/AlertRuleDialog-BmYLySxp.js b/backend/static/assets/AlertRuleDialog-BmYLySxp.js deleted file mode 100644 index 19a8252..0000000 --- a/backend/static/assets/AlertRuleDialog-BmYLySxp.js +++ /dev/null @@ -1,14 +0,0 @@ -import{j as e,r as x}from"./vendor-codemirror-B1SGo4xl.js";import{D as v,a as k,b as w,c as S,d as _,e as C,B as A}from"./index-Dungj95X.js";import{I as h}from"./input-CXoUQQLm.js";import{L as c}from"./label-CMpUoC87.js";import{T as L}from"./textarea-BxfjmLq5.js";import{S as E}from"./switch-Bxiq4EHp.js";import{a as j}from"./alert-v1WaPeEX.js";import{t as F,ap as P,aq as I,ar as q,L as B}from"./vendor-icons-DmqcWdzX.js";function b(o){if(!o)return[];if(Array.isArray(o))return o;if(typeof o=="string"){try{const r=JSON.parse(o);if(Array.isArray(r))return r}catch{}return o.split(",").map(r=>r.trim()).filter(Boolean)}return[]}const T=["email","sms","dingtalk","wechat","webhook"],H={dingtalk:"钉钉",wechat:"企业微信",email:"邮件",sms:"短信",webhook:"Webhook"};function z(o,r){if(!o)return null;const a=r.find(i=>String(i.id)===String(o));return a?{type:a.type||"unknown",name:a.name||a.type||"未命名",isLegacy:!1}:T.includes(o)?{type:o,name:H[o]||o,isLegacy:!0}:null}const W=[{key:"dingtalk",label:"钉钉",placeholder:`{ - "webhook": "https://oapi.dingtalk.com/robot/send?access_token=***", - "secret": "SECxxx" -}`},{key:"wechat",label:"企业微信",placeholder:`{ - "webhook": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=***" -}`},{key:"email",label:"邮件",placeholder:`{ - "to": "ops@ezops.io", - "subject": "告警通知" -}`},{key:"sms",label:"短信",placeholder:`{ - "phones": "13800138000", - "sign": "AIOps" -}`},{key:"webhook",label:"Webhook",placeholder:`{ - "url": "https://example.com/alert" -}`}];function y(o){return W.find(r=>r.key===o)?.label||o}function f(o){switch(o){case"email":return q;case"sms":return I;case"dingtalk":case"wechat":return P;default:return F}}function Z(o,r){const a=b(o.notify_channels);return a.length===0?e.jsx("span",{"code-path":"src/components/monitor/alertShared.tsx:76:33",className:"text-xs text-slate-600",children:"--"}):e.jsx("div",{"code-path":"src/components/monitor/alertShared.tsx:78:5",className:"flex flex-wrap gap-1",children:a.map(i=>{const m=z(i,r);if(!m)return null;const p=f(m.type);return e.jsxs("span",{"code-path":"src/components/monitor/alertShared.tsx:84:11",title:`${m.name} (${y(m.type)})`,className:"inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-slate-800 text-slate-300",children:[e.jsx(p,{"code-path":"src/components/monitor/alertShared.tsx:89:13",className:"h-3 w-3 text-slate-400"}),m.name]},i)})})}const D={name:"",description:"",type:"metric",source:"prometheus",expression:"",severity:"warning",duration:300,notify_channels:[]};function G({open:o,onOpenChange:r,editingRule:a,notifyChannels:i,onSaved:m,defaultType:p="metric"}){const[s,l]=x.useState({...D}),[u,g]=x.useState(!1);x.useEffect(()=>{if(o)if(a)l({name:a.name||"",description:a.description||"",type:a.type||"metric",source:a.source||"prometheus",expression:a.expression||"",severity:a.severity||"warning",duration:a.duration||300,notify_channels:b(a.notify_channels)});else{const t={...D,type:p};p==="log"&&(t.source="loki"),l(t)}},[o,a,p]);const N=t=>{l(n=>({...n,notify_channels:n.notify_channels.includes(t)?n.notify_channels.filter(d=>d!==t):[...n.notify_channels,t]}))},R=async()=>{if(!(!s.name.trim()||!s.expression.trim())){g(!0);try{const t={name:s.name.trim(),description:s.description.trim(),type:s.type,source:s.source,expression:s.expression.trim(),severity:s.severity,duration:Number(s.duration)||0,notify_channels:s.notify_channels};a?await j.updateRule(a.id,t):await j.createRule(t),r(!1),m()}catch(t){console.error("Failed to save rule:",t)}finally{g(!1)}}};return e.jsx(v,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:111:5",open:o,onOpenChange:r,children:e.jsxs(k,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:112:7",className:"bg-slate-900 border-slate-700 text-slate-100 max-w-lg",children:[e.jsxs(w,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:113:9",children:[e.jsx(S,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:114:11",className:"text-slate-100",children:a?"编辑告警规则":"新建告警规则"}),e.jsx(_,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:117:11",className:"text-slate-500",children:a?"修改告警规则的触发条件和通知方式":"配置监控指标的告警触发条件"})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:122:9",className:"space-y-4 max-h-[60vh] overflow-y-auto pr-1",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:123:11",className:"space-y-1.5",children:[e.jsxs(c,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:124:13",className:"text-slate-300",children:["规则名称 ",e.jsx("span",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:124:52",className:"text-red-400",children:"*"})]}),e.jsx(h,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:125:13",value:s.name,onChange:t=>l({...s,name:t.target.value}),placeholder:"如:CPU 使用率告警",className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-600"})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:133:11",className:"space-y-1.5",children:[e.jsx(c,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:134:13",className:"text-slate-300",children:"描述"}),e.jsx(L,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:135:13",value:s.description,onChange:t=>l({...s,description:t.target.value}),placeholder:"规则说明",rows:2,className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-600 resize-none"})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:144:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:145:13",className:"space-y-1.5",children:[e.jsx(c,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:146:15",className:"text-slate-300",children:"规则类型"}),e.jsxs("select",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:147:15",value:s.type,onChange:t=>{const n=t.target.value;l({...s,type:n,source:n==="log"?"loki":"prometheus"})},className:"w-full 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/AlertRuleDialog.tsx:156:17",value:"metric",children:"指标监控"}),e.jsx("option",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:157:17",value:"log",children:"日志告警"}),e.jsx("option",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:158:17",value:"event",children:"事件告警"})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:161:13",className:"space-y-1.5",children:[e.jsx(c,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:162:15",className:"text-slate-300",children:"数据源"}),e.jsx("select",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:163:15",value:s.source,onChange:t=>l({...s,source:t.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:s.type==="log"?e.jsxs(e.Fragment,{children:[e.jsx("option",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:170:21",value:"loki",children:"Loki"}),e.jsx("option",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:171:21",value:"elasticsearch",children:"Elasticsearch"})]}):e.jsxs(e.Fragment,{children:[e.jsx("option",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:175:21",value:"prometheus",children:"Prometheus"}),e.jsx("option",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:176:21",value:"zabbix",children:"Zabbix"}),e.jsx("option",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:177:21",value:"custom",children:"自定义"})]})})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:184:11",className:"space-y-1.5",children:[e.jsxs(c,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:185:13",className:"text-slate-300",children:["触发表达式 ",e.jsx("span",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:185:53",className:"text-red-400",children:"*"})]}),e.jsx(h,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:186:13",value:s.expression,onChange:t=>l({...s,expression:t.target.value}),placeholder:s.type==="log"?'{app="api"} |= "error"':"cpu_usage > 80",className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-600 font-mono text-sm"}),e.jsx("p",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:192:13",className:"text-xs text-slate-600",children:s.type==="log"?s.source==="loki"?"LogQL 查询或 count_over_time 表达式":"Elasticsearch Lucene 查询":"PromQL 或指标表达式,例如 cpu_usage > 80"})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:199:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:200:13",className:"space-y-1.5",children:[e.jsx(c,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:201:15",className:"text-slate-300",children:"告警级别"}),e.jsxs("select",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:202:15",value:s.severity,onChange:t=>l({...s,severity:t.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:[e.jsx("option",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:207:17",value:"info",children:"提示"}),e.jsx("option",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:208:17",value:"warning",children:"警告"}),e.jsx("option",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:209:17",value:"critical",children:"严重"})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:212:13",className:"space-y-1.5",children:[e.jsx(c,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:213:15",className:"text-slate-300",children:"持续时间(秒)"}),e.jsx(h,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:214:15",type:"number",value:s.duration,onChange:t=>l({...s,duration:Number(t.target.value)}),className:"bg-slate-800/50 border-slate-700 text-slate-200"})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:223:11",className:"space-y-1.5",children:[e.jsx(c,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:224:13",className:"text-slate-300",children:"通知渠道"}),i.length===0?e.jsx("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:226:15",className:"text-xs text-amber-400/80 bg-amber-500/5 border border-amber-500/20 rounded-md px-3 py-2",children:"暂无已配置的通知渠道,请先在「通知渠道配置」中添加"}):e.jsx("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:230:15",className:"flex flex-wrap gap-3 pt-1",children:i.map(t=>{const n=f(t.type),d=s.notify_channels.includes(String(t.id));return e.jsxs("label",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:235:21",className:"flex items-center gap-2 cursor-pointer select-none text-sm text-slate-300",children:[e.jsx(E,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:239:23",checked:d,onCheckedChange:()=>N(String(t.id)),className:"data-[state=checked]:bg-blue-600"}),e.jsx(n,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:244:23",className:"h-4 w-4 text-slate-400"}),e.jsxs("span",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:245:23",children:[t.name,e.jsxs("span",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:247:25",className:"text-xs text-slate-500 ml-1",children:["(",y(t.type),")"]})]})]},t.id)})})]})]}),e.jsxs(C,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:257:9",children:[e.jsx(A,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:258:11",variant:"outline",className:"border-slate-700 text-slate-300 hover:bg-slate-800",onClick:()=>r(!1),children:"取消"}),e.jsxs(A,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:265:11",className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:!s.name.trim()||!s.expression.trim()||u,onClick:R,children:[u&&e.jsx(B,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:270:28",className:"h-4 w-4 mr-2 animate-spin"}),a?"保存修改":"创建规则"]})]})]})})}export{G as A,W as C,y as g,Z as r}; diff --git a/backend/static/assets/ApprovalAppPage-CmDNSgHZ.js b/backend/static/assets/ApprovalAppPage-CmDNSgHZ.js deleted file mode 100644 index fc71146..0000000 --- a/backend/static/assets/ApprovalAppPage-CmDNSgHZ.js +++ /dev/null @@ -1 +0,0 @@ -import{j as e}from"./vendor-codemirror-B1SGo4xl.js";import{A as t}from"./ApprovalCategoryPage-CA91WuCS.js";import"./card-BIfzBCEy.js";import"./index-Dungj95X.js";import"./vendor-icons-DmqcWdzX.js";import"./input-CXoUQQLm.js";import"./badge-CGJlVD3L.js";import"./label-CMpUoC87.js";import"./table-B2F10oba.js";import"./select-CiTqGGhE.js";import"./index-5FEebgvX.js";import"./approval-BY_CqGOr.js";const r=[{key:"app_name",label:"应用名称",type:"text",placeholder:"如 user-service",required:!0},{key:"git_url",label:"Git 地址",type:"text",placeholder:"如 https://github.com/org/repo.git",required:!0},{key:"branch",label:"分支",type:"text",defaultValue:"main",required:!0},{key:"language",label:"开发语言",type:"select",options:["Java","Go","Python","Node.js","C++"],required:!0},{key:"http_port",label:"HTTP 端口",type:"number",placeholder:"如 8080"},{key:"env",label:"部署环境",type:"select",options:["dev","staging","prod"],required:!0},{key:"replicas",label:"副本数",type:"number",defaultValue:2,required:!0},{key:"remark",label:"备注",type:"textarea"}];function g(){return e.jsx(t,{"code-path":"src/pages/ApprovalAppPage.tsx:17:5",category:"app",title:"应用申请",description:"申请应用部署、版本发布、流水线配置",fields:r,templateCode:"app_deploy"})}export{g as ApprovalAppPage}; diff --git a/backend/static/assets/ApprovalCategoryPage-CA91WuCS.js b/backend/static/assets/ApprovalCategoryPage-CA91WuCS.js deleted file mode 100644 index a7bd7b4..0000000 --- a/backend/static/assets/ApprovalCategoryPage-CA91WuCS.js +++ /dev/null @@ -1 +0,0 @@ -import{r as c,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{C as de,a as xe}from"./card-BIfzBCEy.js";import{B as x,D as Q,a as W,b as Y,c as Z,d as ee,t as l}from"./index-Dungj95X.js";import{I as H}from"./input-CXoUQQLm.js";import{B as z}from"./badge-CGJlVD3L.js";import{L as ne}from"./label-CMpUoC87.js";import{T as he,a as ie,b as q,c as N,d as ve,e as f}from"./table-B2F10oba.js";import{S as J,a as U,b as X,c as K,d as w}from"./select-CiTqGGhE.js";import{b as h}from"./approval-BY_CqGOr.js";import{P as me,S as ye,R as ue,L as G,F as Ce,X as I,w as B,x as je,b as Pe,a as Ae,y as be,U as Ne,z as fe,f as we}from"./vendor-icons-DmqcWdzX.js";const ae=t=>{switch(t){case"approved":return e.jsxs(z,{"code-path":"src/pages/ApprovalCategoryPage.tsx:44:29",className:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",children:[e.jsx(be,{"code-path":"src/pages/ApprovalCategoryPage.tsx:44:105",className:"h-3 w-3 mr-1"}),"已通过"]});case"rejected":return e.jsxs(z,{"code-path":"src/pages/ApprovalCategoryPage.tsx:45:29",className:"bg-red-500/20 text-red-400 border-red-500/30",children:[e.jsx(Ae,{"code-path":"src/pages/ApprovalCategoryPage.tsx:45:93",className:"h-3 w-3 mr-1"}),"已拒绝"]});default:return e.jsxs(z,{"code-path":"src/pages/ApprovalCategoryPage.tsx:46:21",className:"bg-amber-500/20 text-amber-400 border-amber-500/30",children:[e.jsx(Pe,{"code-path":"src/pages/ApprovalCategoryPage.tsx:46:91",className:"h-3 w-3 mr-1"}),"审批中"]})}};function M(t){try{return JSON.parse(t)||{}}catch{return{}}}function se(t){const p=t?.applicant_user;return p?p.real_name||p.username||`#${t.applicant}`:t?.applicant?`#${t.applicant}`:"--"}function ke(t){if(t.status!=="pending")return"--";const p=t.steps||[];if(p.length===0)return"管理员(待分配)";const d=p.find(g=>g.step===t.current_step&&g.status==="pending");return d?d.approver_user?d.approver_user.real_name||d.approver_user.username||`#${d.approver}`:"管理员":"管理员(待分配)"}function Re({category:t,title:p,description:d,fields:g,templateCode:C}){const[y,j]=c.useState([]),[k,_]=c.useState(!0),[P,S]=c.useState(""),[i,D]=c.useState(""),[s,o]=c.useState(!1),[n,A]=c.useState(!1),[$,F]=c.useState(null),[v,b]=c.useState({}),[te,L]=c.useState(null),[E,T]=c.useState(!1),m=c.useCallback(async()=>{_(!0);try{const a={page_size:"100"};t&&(a.category=t),i&&(a.status=i);const r=await h.getProcesses(a);j(r?.list??r?.data?.list??[])}catch{j([])}finally{_(!1)}},[t,i]),R=c.useCallback(async()=>{try{const a=await h.getTemplates({type:C}),r=a?.list??a?.data?.list??[];r.length>0&&F(r[0].id)}catch{}},[C]);c.useEffect(()=>{m()},[m]),c.useEffect(()=>{R()},[R]);const re=async()=>{if(!$){l.error("模板未加载");return}for(const a of g)if(a.required&&!v[a.key]){l.error(`请填写「${a.label}」`);return}A(!0);try{const a=v[g[0]?.key]||"",r=g[1]&&v[g[1].key]||"";await h.createProcess({template_id:$,title:`${p} - ${a}${r?" / "+r:""}`,form_data:JSON.stringify(v)}),l.success("申请已提交"),o(!1),b({}),m()}catch(a){l.error(a?.message||"提交失败")}finally{A(!1)}},O=()=>{const a={};g.forEach(r=>{a[r.key]=r.defaultValue?.toString()||""}),b(a),o(!0)},pe=async a=>{T(!0);try{await h.approveProcess(a),l.success("已通过"),m()}catch(r){l.error(r?.response?.data?.message||"审批失败")}finally{T(!1)}},ce=async a=>{T(!0);try{await h.rejectProcess(a,"审批拒绝"),l.success("已拒绝"),m()}catch(r){l.error(r?.response?.data?.message||"操作失败")}finally{T(!1)}},oe=async a=>{try{const r=await h.getProcesses({page_size:200}),ge=(r?.list??r?.data?.list??[]).find(le=>le.id===a.id);L(ge||a)}catch{L(a)}},V=y.filter(a=>!P||(a.title||"").toLowerCase().includes(P.toLowerCase()));return e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:155:5",className:"space-y-5",children:[e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:156:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:157:9",children:[e.jsx("h1",{"code-path":"src/pages/ApprovalCategoryPage.tsx:158:11",className:"text-2xl font-bold text-[var(--dg-text-primary)]",children:p}),e.jsx("p",{"code-path":"src/pages/ApprovalCategoryPage.tsx:159:11",className:"text-sm text-[var(--dg-text-secondary)] mt-1",children:d})]}),e.jsxs(x,{"code-path":"src/pages/ApprovalCategoryPage.tsx:161:9",onClick:O,className:"bg-[var(--dg-blue)] hover:bg-[var(--dg-blue)]/90",children:[e.jsx(me,{"code-path":"src/pages/ApprovalCategoryPage.tsx:162:11",className:"h-4 w-4 mr-2"}),"新建申请"]})]}),e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:166:7",className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:167:9",className:"relative w-64",children:[e.jsx(ye,{"code-path":"src/pages/ApprovalCategoryPage.tsx:168:11",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-[var(--dg-text-muted)]"}),e.jsx(H,{"code-path":"src/pages/ApprovalCategoryPage.tsx:169:11",placeholder:"搜索申请...",value:P,onChange:a=>S(a.target.value),className:"pl-9 h-9 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"})]}),e.jsxs(J,{"code-path":"src/pages/ApprovalCategoryPage.tsx:172:9",value:i,onValueChange:D,children:[e.jsx(U,{"code-path":"src/pages/ApprovalCategoryPage.tsx:173:11",className:"w-32 h-9 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]",children:e.jsx(X,{"code-path":"src/pages/ApprovalCategoryPage.tsx:174:13",placeholder:"全部状态"})}),e.jsxs(K,{"code-path":"src/pages/ApprovalCategoryPage.tsx:176:11",children:[e.jsx(w,{"code-path":"src/pages/ApprovalCategoryPage.tsx:177:13",value:"all",children:"全部状态"}),e.jsx(w,{"code-path":"src/pages/ApprovalCategoryPage.tsx:178:13",value:"pending",children:"审批中"}),e.jsx(w,{"code-path":"src/pages/ApprovalCategoryPage.tsx:179:13",value:"approved",children:"已通过"}),e.jsx(w,{"code-path":"src/pages/ApprovalCategoryPage.tsx:180:13",value:"rejected",children:"已拒绝"})]})]}),e.jsxs(x,{"code-path":"src/pages/ApprovalCategoryPage.tsx:183:9",variant:"outline",size:"sm",className:"border-[var(--dg-border)]",onClick:m,children:[e.jsx(ue,{"code-path":"src/pages/ApprovalCategoryPage.tsx:184:11",className:"h-4 w-4 mr-2"}),"刷新"]})]}),e.jsx(de,{"code-path":"src/pages/ApprovalCategoryPage.tsx:188:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsx(xe,{"code-path":"src/pages/ApprovalCategoryPage.tsx:189:9",className:"p-0",children:k?e.jsx("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:191:13",className:"flex items-center justify-center py-16",children:e.jsx(G,{"code-path":"src/pages/ApprovalCategoryPage.tsx:191:69",className:"h-6 w-6 animate-spin text-[var(--dg-blue)]"})}):V.length===0?e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:193:13",className:"flex flex-col items-center justify-center py-16 text-[var(--dg-text-muted)]",children:[e.jsx(Ce,{"code-path":"src/pages/ApprovalCategoryPage.tsx:194:15",className:"h-10 w-10 mb-3 opacity-30"}),e.jsx("p",{"code-path":"src/pages/ApprovalCategoryPage.tsx:195:15",className:"text-sm",children:"暂无申请记录"}),e.jsx(x,{"code-path":"src/pages/ApprovalCategoryPage.tsx:196:15",variant:"link",className:"mt-2",onClick:O,children:"立即申请"})]}):e.jsxs(he,{"code-path":"src/pages/ApprovalCategoryPage.tsx:199:13",children:[e.jsx(ie,{"code-path":"src/pages/ApprovalCategoryPage.tsx:200:15",children:e.jsxs(q,{"code-path":"src/pages/ApprovalCategoryPage.tsx:201:17",className:"border-[var(--dg-border)] hover:bg-transparent",children:[e.jsx(N,{"code-path":"src/pages/ApprovalCategoryPage.tsx:202:19",className:"text-[var(--dg-text-secondary)]",children:"提交时间"}),e.jsx(N,{"code-path":"src/pages/ApprovalCategoryPage.tsx:203:19",className:"text-[var(--dg-text-secondary)]",children:"提交账号"}),e.jsx(N,{"code-path":"src/pages/ApprovalCategoryPage.tsx:204:19",className:"text-[var(--dg-text-secondary)]",children:"当前审核人"}),e.jsx(N,{"code-path":"src/pages/ApprovalCategoryPage.tsx:205:19",className:"text-[var(--dg-text-secondary)]",children:"状态"}),e.jsx(N,{"code-path":"src/pages/ApprovalCategoryPage.tsx:206:19",className:"text-[var(--dg-text-secondary)] w-28",children:"操作"})]})}),e.jsx(ve,{"code-path":"src/pages/ApprovalCategoryPage.tsx:209:15",children:V.map(a=>e.jsxs(q,{"code-path":"src/pages/ApprovalCategoryPage.tsx:211:19",className:"border-[var(--dg-border)] hover:bg-[var(--dg-bg-hover)]",children:[e.jsx(f,{"code-path":"src/pages/ApprovalCategoryPage.tsx:212:21",className:"text-[var(--dg-text-muted)] text-sm whitespace-nowrap",children:a.created_at?new Date(a.created_at).toLocaleString("zh-CN"):"--"}),e.jsx(f,{"code-path":"src/pages/ApprovalCategoryPage.tsx:215:21",className:"text-[var(--dg-text-primary)]",children:se(a)}),e.jsx(f,{"code-path":"src/pages/ApprovalCategoryPage.tsx:216:21",className:"text-[var(--dg-text-muted)] text-sm",children:ke(a)}),e.jsx(f,{"code-path":"src/pages/ApprovalCategoryPage.tsx:217:21",children:ae(a.status)}),e.jsx(f,{"code-path":"src/pages/ApprovalCategoryPage.tsx:218:21",children:e.jsx("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:219:23",className:"flex items-center gap-1",children:a.status==="pending"?e.jsxs(e.Fragment,{children:[e.jsxs(x,{"code-path":"src/pages/ApprovalCategoryPage.tsx:222:29",variant:"ghost",size:"sm",className:"h-8 text-red-400 hover:bg-red-500/10",onClick:()=>ce(a.id),disabled:E,children:[e.jsx(I,{"code-path":"src/pages/ApprovalCategoryPage.tsx:223:31",className:"h-3.5 w-3.5 mr-1"}),"拒绝"]}),e.jsxs(x,{"code-path":"src/pages/ApprovalCategoryPage.tsx:225:29",variant:"ghost",size:"sm",className:"h-8 text-emerald-400 hover:bg-emerald-500/10",onClick:()=>pe(a.id),disabled:E,children:[e.jsx(B,{"code-path":"src/pages/ApprovalCategoryPage.tsx:226:31",className:"h-3.5 w-3.5 mr-1"}),"通过"]})]}):e.jsxs(x,{"code-path":"src/pages/ApprovalCategoryPage.tsx:230:27",variant:"ghost",size:"sm",className:"h-8 text-[var(--dg-text-muted)] hover:text-[var(--dg-text-primary)]",onClick:()=>oe(a),children:[e.jsx(je,{"code-path":"src/pages/ApprovalCategoryPage.tsx:231:29",className:"h-3.5 w-3.5 mr-1"}),"详情"]})})})]},a.id))})]})})}),e.jsx(Q,{"code-path":"src/pages/ApprovalCategoryPage.tsx:245:7",open:s,onOpenChange:o,children:e.jsxs(W,{"code-path":"src/pages/ApprovalCategoryPage.tsx:246:9",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsxs(Y,{"code-path":"src/pages/ApprovalCategoryPage.tsx:247:11",children:[e.jsxs(Z,{"code-path":"src/pages/ApprovalCategoryPage.tsx:248:13",className:"text-[var(--dg-text-primary)]",children:["新建",p]}),e.jsx(ee,{"code-path":"src/pages/ApprovalCategoryPage.tsx:249:13",className:"text-[var(--dg-text-secondary)]",children:d})]}),e.jsx("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:251:11",className:"space-y-4 py-2",children:g.map(a=>e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:253:15",className:"space-y-1.5",children:[e.jsxs(ne,{"code-path":"src/pages/ApprovalCategoryPage.tsx:254:17",className:"text-[var(--dg-text-primary)] text-sm",children:[a.label,a.required&&e.jsx("span",{"code-path":"src/pages/ApprovalCategoryPage.tsx:254:106",className:"text-red-400 ml-0.5",children:"*"})]}),a.type==="select"?e.jsxs(J,{"code-path":"src/pages/ApprovalCategoryPage.tsx:256:19",value:v[a.key]||"",onValueChange:r=>b(u=>({...u,[a.key]:r})),children:[e.jsx(U,{"code-path":"src/pages/ApprovalCategoryPage.tsx:257:21",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]",children:e.jsx(X,{"code-path":"src/pages/ApprovalCategoryPage.tsx:257:101",placeholder:a.placeholder||`选择${a.label}`})}),e.jsx(K,{"code-path":"src/pages/ApprovalCategoryPage.tsx:258:21",children:(a.options||[]).map(r=>e.jsx(w,{"code-path":"src/pages/ApprovalCategoryPage.tsx:258:73",value:r,children:r},r))})]}):a.type==="textarea"?e.jsx("textarea",{"code-path":"src/pages/ApprovalCategoryPage.tsx:261:19",value:v[a.key]||"",onChange:r=>b(u=>({...u,[a.key]:r.target.value})),placeholder:a.placeholder,rows:3,className:"w-full rounded-md bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] text-[var(--dg-text-primary)] px-3 py-2 text-sm resize-none focus:outline-none focus:border-[var(--dg-blue)]"}):e.jsx(H,{"code-path":"src/pages/ApprovalCategoryPage.tsx:265:19",type:a.type,value:v[a.key]||"",onChange:r=>b(u=>({...u,[a.key]:r.target.value})),placeholder:a.placeholder,className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"})]},a.key))}),e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:271:11",className:"flex justify-end gap-3 pt-2",children:[e.jsx(x,{"code-path":"src/pages/ApprovalCategoryPage.tsx:272:13",variant:"outline",className:"border-[var(--dg-border)]",onClick:()=>o(!1),children:"取消"}),e.jsx(x,{"code-path":"src/pages/ApprovalCategoryPage.tsx:273:13",onClick:re,disabled:n,className:"bg-[var(--dg-blue)] hover:bg-[var(--dg-blue)]/90",children:n?e.jsxs(e.Fragment,{children:[e.jsx(G,{"code-path":"src/pages/ApprovalCategoryPage.tsx:274:31",className:"h-4 w-4 mr-2 animate-spin"}),"提交中..."]}):"提交申请"})]})]})}),e.jsx(_e,{"code-path":"src/pages/ApprovalCategoryPage.tsx:281:7",item:te,onClose:()=>L(null),fields:g,onStatusChange:m})]})}function _e({item:t,onClose:p,fields:d,onStatusChange:g}){const[C,y]=c.useState(!1);if(!t)return null;const j=s=>s?new Date(s).toLocaleString("zh-CN"):"",k=t.steps||[],_=async()=>{y(!0);try{await h.approveProcess(t.id),l.success("已通过"),g(),p()}catch(s){l.error(s?.response?.data?.message||"审批失败")}finally{y(!1)}},P=async()=>{y(!0);try{await h.rejectProcess(t.id,"审批拒绝"),l.success("已拒绝"),g(),p()}catch(s){l.error(s?.response?.data?.message||"操作失败")}finally{y(!1)}},S=s=>s.status==="approved"?"通过":s.status==="rejected"?"拒绝":s.status==="pending"&&s.step===t.current_step?"待审批":s.status==="pending"?"待开始":s.status,i=s=>s.status==="approved"?"text-emerald-400":s.status==="rejected"?"text-red-400":s.step===t.current_step?"text-blue-400":"text-[var(--dg-text-muted)]",D=s=>s.approver_user?s.approver_user.real_name||s.approver_user.username||`#${s.approver}`:"管理员";return e.jsx(Q,{"code-path":"src/pages/ApprovalCategoryPage.tsx:338:5",open:!!t,onOpenChange:s=>{s||p()},children:e.jsxs(W,{"code-path":"src/pages/ApprovalCategoryPage.tsx:339:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsxs(Y,{"code-path":"src/pages/ApprovalCategoryPage.tsx:340:9",children:[e.jsx(Z,{"code-path":"src/pages/ApprovalCategoryPage.tsx:341:11",className:"text-[var(--dg-text-primary)]",children:"申请详情"}),e.jsx(ee,{"code-path":"src/pages/ApprovalCategoryPage.tsx:342:11",className:"text-[var(--dg-text-secondary)]",children:t.title})]}),e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:345:9",className:"space-y-4 py-2",children:[e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:347:11",className:"flex items-center gap-3",children:[e.jsx("span",{"code-path":"src/pages/ApprovalCategoryPage.tsx:348:13",className:"text-sm text-[var(--dg-text-muted)]",children:"状态:"}),ae(t.status),t.status==="pending"&&e.jsxs("span",{"code-path":"src/pages/ApprovalCategoryPage.tsx:351:15",className:"text-xs text-[var(--dg-text-muted)]",children:["第 ",t.current_step,"/",t.total_steps," 步"]})]}),e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:358:11",className:"border-t border-[var(--dg-border)] pt-4",children:[e.jsx("h4",{"code-path":"src/pages/ApprovalCategoryPage.tsx:359:13",className:"text-sm font-medium text-[var(--dg-text-primary)] mb-4",children:"操作时间线"}),e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:360:13",className:"space-y-0",children:[e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:362:15",className:"flex gap-3",children:[e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:363:17",className:"flex flex-col items-center",children:[e.jsx("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:364:19",className:"w-7 h-7 rounded-full bg-blue-500/20 flex items-center justify-center",children:e.jsx(Ne,{"code-path":"src/pages/ApprovalCategoryPage.tsx:364:105",className:"w-3.5 h-3.5 text-blue-400"})}),e.jsx("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:365:19",className:"w-0.5 flex-1 bg-[var(--dg-border)] my-1"})]}),e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:367:17",className:"flex-1 pb-4",children:[e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:368:19",className:"flex items-center gap-2",children:[e.jsx("span",{"code-path":"src/pages/ApprovalCategoryPage.tsx:369:21",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:"提交申请"}),e.jsx("span",{"code-path":"src/pages/ApprovalCategoryPage.tsx:370:21",className:"text-xs text-[var(--dg-text-muted)]",children:"·"}),e.jsx("span",{"code-path":"src/pages/ApprovalCategoryPage.tsx:371:21",className:"text-xs text-[var(--dg-text-secondary)]",children:se(t)}),e.jsx("span",{"code-path":"src/pages/ApprovalCategoryPage.tsx:372:21",className:"text-xs text-[var(--dg-text-muted)]",children:"·"}),e.jsx("span",{"code-path":"src/pages/ApprovalCategoryPage.tsx:373:21",className:"text-xs text-[var(--dg-text-muted)]",children:j(t.created_at)})]}),e.jsx("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:376:19",className:"mt-1 flex flex-wrap gap-2",children:(()=>{const s=M(t.form_data||"{}");return d.slice(0,4).map(o=>{const n=s[o.key];return n?e.jsxs("span",{"code-path":"src/pages/ApprovalCategoryPage.tsx:383:27",className:"text-[11px] px-1.5 py-0.5 rounded bg-[var(--dg-bg-tertiary)] text-[var(--dg-text-muted)]",children:[o.label,": ",e.jsx("span",{"code-path":"src/pages/ApprovalCategoryPage.tsx:384:40",className:"text-[var(--dg-text-secondary)]",children:n})]},o.key):null})})()})]})]}),k.map((s,o)=>{const n=o===k.length-1,A=s.step_type==="execute",$=A?"执行":"审核",F=s.status==="approved"?"bg-emerald-500/20":s.status==="rejected"?"bg-red-500/20":"bg-[var(--dg-bg-tertiary)]";return e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:402:19",className:"flex gap-3",children:[e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:403:21",className:"flex flex-col items-center",children:[e.jsx("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:404:23",className:`w-7 h-7 rounded-full flex items-center justify-center ${F}`,children:s.status==="approved"?e.jsx(B,{"code-path":"src/pages/ApprovalCategoryPage.tsx:405:52",className:"w-3.5 h-3.5 text-emerald-400"}):s.status==="rejected"?e.jsx(I,{"code-path":"src/pages/ApprovalCategoryPage.tsx:406:55",className:"w-3.5 h-3.5 text-red-400"}):A?e.jsx(fe,{"code-path":"src/pages/ApprovalCategoryPage.tsx:408:33",className:`w-3.5 h-3.5 ${s.step===t.current_step?"text-green-400":"text-[var(--dg-text-muted)]"}`}):e.jsx(we,{"code-path":"src/pages/ApprovalCategoryPage.tsx:409:33",className:`w-3.5 h-3.5 ${s.step===t.current_step?"text-blue-400":"text-[var(--dg-text-muted)]"}`})}),!n&&e.jsx("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:411:35",className:"w-0.5 flex-1 bg-[var(--dg-border)] my-1"})]}),e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:413:21",className:`flex-1 ${n?"":"pb-4"}`,children:[e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:414:23",className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{"code-path":"src/pages/ApprovalCategoryPage.tsx:415:25",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:$}),s.approver_user&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"code-path":"src/pages/ApprovalCategoryPage.tsx:418:29",className:"text-xs text-[var(--dg-text-muted)]",children:"·"}),e.jsxs("span",{"code-path":"src/pages/ApprovalCategoryPage.tsx:419:29",className:"text-xs text-[var(--dg-text-secondary)]",children:["指派人: ",D(s)]})]}),s.approved_at&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"code-path":"src/pages/ApprovalCategoryPage.tsx:424:29",className:"text-xs text-[var(--dg-text-muted)]",children:"·"}),e.jsxs("span",{"code-path":"src/pages/ApprovalCategoryPage.tsx:425:29",className:`text-xs ${i(s)}`,children:[D(s)," · ",S(s)," · ",j(s.approved_at)]})]}),!s.approved_at&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"code-path":"src/pages/ApprovalCategoryPage.tsx:432:29",className:"text-xs text-[var(--dg-text-muted)]",children:"·"}),e.jsx("span",{"code-path":"src/pages/ApprovalCategoryPage.tsx:433:29",className:`text-xs ${i(s)}`,children:S(s)})]})]}),s.comment&&s.comment!==s.status&&s.comment!=="pending"&&e.jsx("p",{"code-path":"src/pages/ApprovalCategoryPage.tsx:438:25",className:"text-xs text-[var(--dg-text-muted)] mt-1 ml-0",children:s.comment})]})]},s.id)})]})]}),e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:448:11",className:"border-t border-[var(--dg-border)] pt-4",children:[e.jsx("h4",{"code-path":"src/pages/ApprovalCategoryPage.tsx:449:13",className:"text-sm font-medium text-[var(--dg-text-primary)] mb-2",children:"申请内容"}),e.jsx("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:450:13",className:"space-y-2",children:(()=>{const s=M(t.form_data||"{}");return d.map(o=>{const n=s[o.key];return e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:456:21",className:"grid grid-cols-3 gap-2 text-sm",children:[e.jsxs("span",{"code-path":"src/pages/ApprovalCategoryPage.tsx:457:23",className:"text-[var(--dg-text-muted)]",children:[o.label,":"]}),e.jsx("span",{"code-path":"src/pages/ApprovalCategoryPage.tsx:458:23",className:"text-[var(--dg-text-primary)] col-span-2",children:n??"--"})]},o.key)})})()})]})]}),e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:467:9",className:"flex justify-end gap-3 pt-2",children:[t.status==="pending"&&e.jsxs(e.Fragment,{children:[e.jsxs(x,{"code-path":"src/pages/ApprovalCategoryPage.tsx:470:15",variant:"outline",className:"border-red-500/30 text-red-400 hover:bg-red-500/10",onClick:P,disabled:C,children:[e.jsx(I,{"code-path":"src/pages/ApprovalCategoryPage.tsx:471:17",className:"h-4 w-4 mr-1.5"}),"拒绝"]}),e.jsxs(x,{"code-path":"src/pages/ApprovalCategoryPage.tsx:473:15",className:"bg-emerald-600 hover:bg-emerald-700",onClick:_,disabled:C,children:[e.jsx(B,{"code-path":"src/pages/ApprovalCategoryPage.tsx:474:17",className:"h-4 w-4 mr-1.5"}),"通过"]})]}),e.jsx(x,{"code-path":"src/pages/ApprovalCategoryPage.tsx:478:11",variant:"outline",className:"border-[var(--dg-border)]",onClick:p,children:"关闭"})]})]})})}export{Re as A}; diff --git a/backend/static/assets/ApprovalFlow-D6IpuZ50.js b/backend/static/assets/ApprovalFlow-D6IpuZ50.js deleted file mode 100644 index 0738e92..0000000 --- a/backend/static/assets/ApprovalFlow-D6IpuZ50.js +++ /dev/null @@ -1 +0,0 @@ -import{j as e,r as v}from"./vendor-codemirror-B1SGo4xl.js";import{m as b,B as i,D as M,a as V,b as q,c as H,d as Q,e as G,t as T}from"./index-Dungj95X.js";import{C as u,a as j,b as ye,c as Ne,d as we}from"./card-BIfzBCEy.js";import{B as C}from"./badge-CGJlVD3L.js";import{T as pe}from"./textarea-BxfjmLq5.js";import{b as k}from"./approval-BY_CqGOr.js";import{I as le}from"./input-CXoUQQLm.js";import{h as fe,aQ as Te,F as _,C as D,a as F,L as $,S as De,x as Fe,af as Ce,J as oe,aJ as Pe,ae as Se,b as ce,P as ke}from"./vendor-icons-DmqcWdzX.js";import{L as _e}from"./label-CMpUoC87.js";import{S as Le,a as Oe,b as Ie,c as $e,d as Re}from"./select-CiTqGGhE.js";import"./index-5FEebgvX.js";function ze(a){if(Array.isArray(a))return a;if(typeof a=="string")try{const r=JSON.parse(a);return Array.isArray(r)?r:[]}catch{return[]}return[]}function I(a){if(!a)return[];const r=typeof a=="string"?(()=>{try{return JSON.parse(a)}catch{return null}})():a;return r?Array.isArray(r.fields)?r.fields:[]:[]}function Be(a,r){if(!a)return null;let s;try{s=typeof a=="string"?JSON.parse(a):a}catch{return null}if(!s||typeof s!="object")return null;const o=I(r?.form_schema),n=new Map;o.forEach(p=>n.set(p.key,p.label));const m=Object.entries(s).filter(([,p])=>p!=null&&p!=="");return m.length===0?null:e.jsx("div",{"code-path":"src/components/approval/helpers.tsx:54:5",className:"grid grid-cols-2 gap-x-4 gap-y-3",children:m.map(([p,d])=>e.jsxs("div",{"code-path":"src/components/approval/helpers.tsx:56:9",className:"min-w-0",children:[e.jsx("p",{"code-path":"src/components/approval/helpers.tsx:57:11",className:"text-xs text-[var(--dg-text-muted)] mb-0.5",children:n.get(p)||p}),e.jsx("p",{"code-path":"src/components/approval/helpers.tsx:58:11",className:"text-sm text-[var(--dg-text-primary)] break-words",children:String(d)})]},p))})}const R=[{value:"server_apply",label:"云服务器申请",icon:fe,color:"var(--dg-cyan)"},{value:"app_deploy",label:"应用部署申请",icon:Te,color:"var(--dg-blue)"}],Y=a=>R.find(r=>r.value===a)?.label||a||"通用审批",L=a=>R.find(r=>r.value===a)?.color||"var(--dg-text-secondary)",Ee=a=>R.find(r=>r.value===a)?.icon||_,A=a=>a?.template?.type||a?.type||"";function U(a){const r=ze(a.steps),s=a.current_step??0,o=r.length,n=r.filter(p=>p.status==="approved"||p.status==="completed").length,m=o>0?Math.round(n/o*100):0;return{steps:r,currentIndex:s,total:o,completed:n,percentage:m}}function X(a){const{steps:r,currentIndex:s}=U(a);return r.length===0?null:e.jsx("div",{"code-path":"src/components/approval/helpers.tsx:100:5",className:"flex items-center gap-1 overflow-x-auto",children:r.map((o,n)=>{const m=o.status==="approved"||o.status==="completed",p=n===s,d=o.status==="rejected";return e.jsxs("div",{"code-path":"src/components/approval/helpers.tsx:106:11",className:"flex items-center",children:[e.jsxs("div",{"code-path":"src/components/approval/helpers.tsx:107:13",className:b("flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs whitespace-nowrap",m&&"bg-emerald-500/10 text-emerald-400",p&&!d&&"bg-amber-500/10 text-amber-400 border border-amber-500/30",d&&"bg-red-500/10 text-red-400",!m&&!p&&!d&&"bg-[var(--dg-bg-tertiary)] text-[var(--dg-text-muted)]"),children:[m&&e.jsx(D,{"code-path":"src/components/approval/helpers.tsx:116:31",className:"h-3 w-3"}),d&&e.jsx(F,{"code-path":"src/components/approval/helpers.tsx:117:30",className:"h-3 w-3"}),p&&!d&&e.jsx($,{"code-path":"src/components/approval/helpers.tsx:118:44",className:"h-3 w-3 animate-spin"}),e.jsx("span",{"code-path":"src/components/approval/helpers.tsx:119:15",children:o.name||o.approver_name||`步骤 ${n+1}`})]}),no(c.target.value),className:"pl-9 h-9 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)]"})]}),e.jsx("div",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:109:9",className:"flex items-center gap-1 bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] rounded-lg p-1",children:Je.map(c=>e.jsx("button",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:111:13",onClick:()=>m(c.value),className:b("px-3 py-1.5 rounded-md text-sm transition-colors",n===c.value?"bg-[var(--dg-bg-hover)] text-[var(--dg-text-primary)] font-medium":"text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)]"),children:c.label},c.key))})]}),r?e.jsx(u,{"code-path":"src/components/approval/ApprovalProcessTab.tsx:129:9",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsx(j,{"code-path":"src/components/approval/ApprovalProcessTab.tsx:130:11",className:"p-12",children:e.jsxs("div",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:131:13",className:"flex items-center justify-center text-[var(--dg-text-muted)]",children:[e.jsx($,{"code-path":"src/components/approval/ApprovalProcessTab.tsx:132:15",className:"h-6 w-6 animate-spin mr-2"}),"加载中..."]})})}):a.length===0?e.jsx(u,{"code-path":"src/components/approval/ApprovalProcessTab.tsx:138:9",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsx(j,{"code-path":"src/components/approval/ApprovalProcessTab.tsx:139:11",className:"p-12",children:e.jsxs("div",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:140:13",className:"text-center",children:[e.jsx(_,{"code-path":"src/components/approval/ApprovalProcessTab.tsx:141:15",className:"h-12 w-12 mx-auto text-[var(--dg-text-muted)] mb-4"}),e.jsx("h3",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:142:15",className:"text-lg font-medium text-[var(--dg-text-secondary)] mb-2",children:"暂无审批流程"}),e.jsx("p",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:143:15",className:"text-sm text-[var(--dg-text-muted)]",children:"当前筛选条件下没有匹配的流程实例"})]})})}):e.jsx("div",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:148:9",className:"grid grid-cols-1 gap-4",children:a.map(c=>{const w=Ee(A(c)),{percentage:l}=U(c);return e.jsx(u,{"code-path":"src/components/approval/ApprovalProcessTab.tsx:153:15",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] hover:border-[var(--dg-border)] transition-colors",children:e.jsxs(j,{"code-path":"src/components/approval/ApprovalProcessTab.tsx:154:17",className:"p-4",children:[e.jsxs("div",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:155:19",className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:156:21",className:"flex items-start gap-3",children:[e.jsx("div",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:157:23",className:"w-10 h-10 rounded-lg bg-[var(--dg-bg-tertiary)] flex items-center justify-center",style:{color:L(A(c))},children:e.jsx(w,{"code-path":"src/components/approval/ApprovalProcessTab.tsx:158:25",className:"h-5 w-5"})}),e.jsxs("div",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:160:23",children:[e.jsxs("div",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:161:25",className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:162:27",className:"font-medium text-[var(--dg-text-primary)]",children:c.title}),Me(c.status)]}),e.jsxs("div",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:165:25",className:"flex items-center gap-3 text-xs text-[var(--dg-text-muted)]",children:[e.jsx("span",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:166:27",className:"flex items-center gap-1",children:e.jsx(C,{"code-path":"src/components/approval/ApprovalProcessTab.tsx:167:29",variant:"outline",className:"text-xs border-[var(--dg-border)]",style:{color:L(A(c))},children:Y(A(c))})}),e.jsxs("span",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:171:27",children:["申请人:",c.applicant_name||c.applicant||"--"]}),e.jsxs("span",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:172:27",children:["提交于 ",c.created_at?new Date(c.created_at).toLocaleString():"--"]})]})]})]}),e.jsxs("div",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:176:21",className:"flex items-center gap-2",children:[e.jsxs(i,{"code-path":"src/components/approval/ApprovalProcessTab.tsx:177:23",variant:"ghost",size:"sm",className:"text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)]",onClick:()=>p(c),children:[e.jsx(Fe,{"code-path":"src/components/approval/ApprovalProcessTab.tsx:178:25",className:"h-4 w-4 mr-1"}),"详情"]}),c.status==="pending"&&e.jsxs(e.Fragment,{children:[e.jsxs(i,{"code-path":"src/components/approval/ApprovalProcessTab.tsx:183:27",variant:"outline",size:"sm",className:"border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10",onClick:()=>d(c),children:[e.jsx(D,{"code-path":"src/components/approval/ApprovalProcessTab.tsx:189:29",className:"h-4 w-4 mr-1"}),"通过"]}),e.jsxs(i,{"code-path":"src/components/approval/ApprovalProcessTab.tsx:192:27",variant:"outline",size:"sm",className:"border-red-500/30 text-red-400 hover:bg-red-500/10",onClick:()=>y(c),children:[e.jsx(F,{"code-path":"src/components/approval/ApprovalProcessTab.tsx:198:29",className:"h-4 w-4 mr-1"}),"拒绝"]})]})]})]}),e.jsxs("div",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:206:19",className:"mb-3",children:[e.jsxs("div",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:207:21",className:"flex items-center justify-between text-xs text-[var(--dg-text-muted)] mb-1.5",children:[e.jsx("span",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:208:23",children:"审批进度"}),e.jsxs("span",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:209:23",children:[l,"%"]})]}),e.jsx("div",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:211:21",className:"w-full h-1.5 bg-[var(--dg-bg-tertiary)] rounded-full overflow-hidden",children:e.jsx("div",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:212:23",className:b("h-full rounded-full transition-all",c.status==="rejected"?"bg-red-400":"bg-[var(--dg-blue)]"),style:{width:`${l}%`}})})]}),e.jsx("div",{"code-path":"src/components/approval/ApprovalProcessTab.tsx:222:19",className:"bg-[var(--dg-bg-primary)] rounded-lg p-3",children:X(c)})]})},c.id)})})]})}function ne(a){if(Array.isArray(a))return a;if(typeof a=="string")try{const r=JSON.parse(a);return Array.isArray(r)?r:[]}catch{return[]}return[]}const K=[{value:"deploy",label:"发布审批",color:"var(--dg-blue)"},{value:"server",label:"服务器操作",color:"var(--dg-cyan)"},{value:"permission",label:"权限申请",color:"var(--dg-purple)"}],qe=a=>K.find(r=>r.value===a)?.label||a||"通用审批",He=a=>K.find(r=>r.value===a)?.color||"var(--dg-text-secondary)";function Qe(a){const r=ne(a.steps);return r.length===0?e.jsx("div",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:38:12",className:"text-[var(--dg-text-muted)] text-center py-4",children:"暂无流程节点"}):e.jsx("div",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:41:5",className:"flex items-center gap-2 overflow-x-auto py-4",children:r.map((s,o)=>e.jsxs("div",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:43:9",className:"flex items-center",children:[e.jsxs("div",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:44:11",className:b("px-4 py-2 rounded-lg border min-w-[100px] text-center",s.type==="start"&&"bg-emerald-500/10 border-emerald-500/30 text-emerald-400",s.type==="approval"&&"bg-[var(--dg-blue)]/10 border-[var(--dg-blue)]/30 text-[var(--dg-blue)]",s.type==="condition"&&"bg-amber-500/10 border-amber-500/30 text-amber-400",s.type==="end"&&"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-secondary)]"),children:[e.jsx("p",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:53:13",className:"text-sm font-medium",children:s.name}),s.approvers&&e.jsx("p",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:55:15",className:"text-xs text-[var(--dg-text-muted)] mt-1",children:Array.isArray(s.approvers)?s.approvers.join(", "):s.approvers})]}),os("all"),className:b("px-3 py-1.5 rounded-md text-sm transition-colors",r==="all"?"bg-[var(--dg-bg-hover)] text-[var(--dg-text-primary)] font-medium":"text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)]"),children:"全部类型"}),K.map(o=>e.jsxs("button",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:101:13",onClick:()=>s(o.value),className:b("px-3 py-1.5 rounded-md text-sm transition-colors flex items-center gap-1.5",r===o.value?"bg-[var(--dg-bg-hover)] text-[var(--dg-text-primary)] font-medium":"text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)]"),children:[e.jsx("span",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:111:15",style:{color:o.color},children:"●"}),o.label]},o.value))]})]}),e.jsx("div",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:118:7",className:"grid grid-cols-1 gap-4",children:a.length===0?e.jsx(u,{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:120:11",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsx(j,{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:121:13",className:"p-8",children:e.jsxs("div",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:122:15",className:"text-center",children:[e.jsx(oe,{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:123:17",className:"h-12 w-12 mx-auto text-[var(--dg-text-muted)] mb-4"}),e.jsx("h3",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:124:17",className:"text-lg font-medium text-[var(--dg-text-secondary)] mb-2",children:"暂无流程模板"}),e.jsx("p",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:125:17",className:"text-sm text-[var(--dg-text-muted)]",children:"当前筛选条件下没有匹配的模板"})]})})}):a.map(o=>e.jsxs(u,{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:131:13",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:[e.jsx(ye,{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:132:15",className:"pb-2",children:e.jsxs("div",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:133:17",className:"flex items-start justify-between",children:[e.jsxs("div",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:134:19",className:"flex items-center gap-3",children:[e.jsx("div",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:135:21",className:"w-10 h-10 rounded-lg bg-[var(--dg-blue)]/10 flex items-center justify-center",children:e.jsx(oe,{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:136:23",className:"h-5 w-5 text-[var(--dg-blue)]"})}),e.jsxs("div",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:138:21",children:[e.jsxs("div",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:139:23",className:"flex items-center gap-2",children:[e.jsx(Ne,{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:140:25",className:"text-base text-[var(--dg-text-primary)]",children:o.name}),o.type&&e.jsx(C,{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:142:27",variant:"outline",className:"text-xs border-[var(--dg-border)]",style:{color:He(o.type)},children:qe(o.type)})]}),e.jsx(we,{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:151:23",className:"text-[var(--dg-text-muted)]",children:o.description})]})]}),e.jsxs("div",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:154:19",className:"flex items-center gap-2",children:[e.jsx(C,{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:155:21",variant:"outline",className:o.status===1||o.status==="active"||o.status===!0?"border-emerald-500/30 text-emerald-400 bg-emerald-500/10":"border-[var(--dg-border)] text-[var(--dg-text-secondary)] bg-[var(--dg-bg-tertiary)]",children:o.status===1||o.status==="active"||o.status===!0?"已启用":"已停用"}),e.jsx(i,{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:165:21",variant:"ghost",size:"icon",className:"h-8 w-8 text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)]",children:e.jsx(Pe,{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:166:23",className:"h-4 w-4"})})]})]})}),e.jsxs(j,{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:171:15",children:[e.jsx("div",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:172:17",className:"bg-[var(--dg-bg-primary)] rounded-lg p-4 overflow-x-auto",children:Qe(o)}),e.jsxs("div",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:175:17",className:"flex items-center justify-between mt-4 text-sm text-[var(--dg-text-muted)]",children:[e.jsxs("span",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:176:19",children:["创建于 ",o.created_at?new Date(o.created_at).toLocaleDateString():"--"]}),e.jsxs("span",{"code-path":"src/components/approval/ApprovalTemplateTab.tsx:177:19",children:[ne(o.steps).length," 个节点"]})]})]})]},o.id))})]})}function Ye({open:a,onOpenChange:r,instance:s,templates:o,onApprove:n,onReject:m}){return s?e.jsx(M,{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:42:5",open:a,onOpenChange:r,children:e.jsxs(V,{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:43:7",className:"max-w-2xl bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] max-h-[90vh] overflow-y-auto",children:[e.jsxs(q,{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:44:9",children:[e.jsx(H,{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:45:11",className:"text-[var(--dg-text-primary)]",children:"审批详情"}),e.jsx(Q,{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:46:11",className:"text-[var(--dg-text-muted)]",children:"查看审批流程详细信息"})]}),e.jsxs("div",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:48:9",className:"space-y-4 py-2",children:[e.jsxs("div",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:49:11",children:[e.jsx("h3",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:50:13",className:"text-lg font-medium text-[var(--dg-text-primary)]",children:s.title}),e.jsxs("div",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:51:13",className:"flex items-center gap-2 mt-1",children:[e.jsx(C,{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:52:15",variant:"outline",className:"text-xs border-[var(--dg-border)]",style:{color:L(A(s))},children:Y(A(s))}),e.jsxs("span",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:55:15",className:"text-xs text-[var(--dg-text-muted)]",children:["申请人:",s.applicant_name||s.applicant||"--"]}),e.jsxs("span",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:58:15",className:"text-xs text-[var(--dg-text-muted)]",children:["提交于 ",s.created_at?new Date(s.created_at).toLocaleString():"--"]})]})]}),s.content&&e.jsx("div",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:66:13",className:"bg-[var(--dg-bg-primary)] rounded-lg p-4",children:e.jsx("p",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:67:15",className:"text-sm text-[var(--dg-text-secondary)] whitespace-pre-wrap",children:s.content})}),(()=>{const p=o.find(y=>y.id===s.template_id),d=Be(s.form_data,p);return d?e.jsxs("div",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:77:15",className:"bg-[var(--dg-bg-primary)] rounded-lg p-4",children:[e.jsx("p",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:78:17",className:"text-sm font-medium text-[var(--dg-text-secondary)] mb-3",children:"申请表单"}),d]}):null})(),e.jsxs("div",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:85:11",className:"bg-[var(--dg-bg-primary)] rounded-lg p-4",children:[e.jsx("p",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:86:13",className:"text-sm font-medium text-[var(--dg-text-secondary)] mb-3",children:"审批进度"}),X(s)]}),s.actions&&e.jsxs("div",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:92:13",className:"bg-[var(--dg-bg-primary)] rounded-lg p-4",children:[e.jsx("p",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:93:15",className:"text-sm font-medium text-[var(--dg-text-secondary)] mb-3",children:"操作记录"}),e.jsx("div",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:94:15",className:"space-y-2",children:s.actions.map((p,d)=>e.jsxs("div",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:96:19",className:"flex items-center gap-3 text-sm",children:[p.action==="approve"?e.jsx(D,{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:98:23",className:"h-4 w-4 text-emerald-400"}):p.action==="reject"?e.jsx(F,{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:100:23",className:"h-4 w-4 text-red-400"}):e.jsx(ce,{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:102:23",className:"h-4 w-4 text-[var(--dg-text-muted)]"}),e.jsxs("div",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:104:21",children:[e.jsx("span",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:105:23",className:"text-[var(--dg-text-secondary)]",children:p.operator_name||p.operator}),e.jsx("span",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:108:23",className:"text-[var(--dg-text-muted)] mx-1",children:"·"}),e.jsx("span",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:109:23",className:"text-[var(--dg-text-secondary)]",children:p.action==="approve"?"通过":p.action==="reject"?"拒绝":"提交"}),p.comment&&e.jsx("p",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:113:25",className:"text-xs text-[var(--dg-text-muted)] mt-0.5",children:p.comment})]}),e.jsx("span",{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:116:21",className:"text-xs text-[var(--dg-text-muted)] ml-auto",children:p.created_at?new Date(p.created_at).toLocaleString():""})]},d))})]})]}),e.jsxs(G,{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:125:9",children:[s.status==="pending"&&e.jsxs(e.Fragment,{children:[e.jsxs(i,{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:128:15",variant:"outline",className:"border-red-500/30 text-red-400 hover:bg-red-500/10",onClick:()=>{r(!1),m(s)},children:[e.jsx(F,{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:129:17",className:"h-4 w-4 mr-2"}),"拒绝"]}),e.jsxs(i,{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:131:15",className:"bg-emerald-500/90 hover:bg-emerald-500 text-white",onClick:()=>{r(!1),n(s)},children:[e.jsx(D,{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:132:17",className:"h-4 w-4 mr-2"}),"通过"]})]}),e.jsx(i,{"code-path":"src/components/approval/ApprovalDetailDialog.tsx:136:11",variant:"ghost",onClick:()=>r(!1),children:"关闭"})]})]})}):null}function Ue({open:a,onOpenChange:r,templates:s,onSuccess:o}){const[n,m]=v.useState(null),[p,d]=v.useState({}),[y,c]=v.useState(!1),w=async()=>{if(!n){T.error("请先选择申请类型");return}const l=I(n.form_schema);for(const x of l)if(x.required&&!p[x.key]){T.error(`请填写${x.label}`);return}c(!0);try{await k.createProcess({template_id:n.id,title:p.app_name||n.name,form_data:JSON.stringify(p)}),T.success("申请已提交"),r(!1),m(null),d({}),o()}catch(x){T.error("提交失败",{description:x?.message})}finally{c(!1)}};return e.jsx(M,{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:79:5",open:a,onOpenChange:l=>{l||(m(null),d({})),r(l)},children:e.jsxs(V,{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:90:7",className:"max-w-2xl bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] max-h-[90vh] overflow-y-auto",children:[e.jsxs(q,{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:91:9",children:[e.jsx(H,{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:92:11",className:"text-[var(--dg-text-primary)]",children:"新建资源申请"}),e.jsx(Q,{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:93:11",className:"text-[var(--dg-text-muted)]",children:n?"请填写申请信息":"请选择申请类型"})]}),n?e.jsxs("div",{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:136:11",className:"py-2",children:[e.jsx("div",{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:137:13",className:"flex items-center gap-2 mb-4",children:e.jsx("button",{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:138:15",type:"button",onClick:()=>{m(null),d({})},className:"text-xs text-[var(--dg-text-muted)] hover:text-[var(--dg-text-primary)]",children:"← 返回选择类型"})}),e.jsx("div",{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:146:13",className:"grid grid-cols-2 gap-x-4 gap-y-4",children:I(n.form_schema).map(l=>{const x=l.type==="textarea";return e.jsxs("div",{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:150:19",className:b("space-y-1.5",x&&"col-span-2"),children:[e.jsxs(_e,{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:151:21",className:"text-sm font-medium text-[var(--dg-text-secondary)]",children:[l.label,l.required&&e.jsx("span",{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:153:42",className:"text-red-400 ml-0.5",children:"*"})]}),l.type==="select"?e.jsxs(Le,{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:156:23",value:String(p[l.key]??""),onValueChange:h=>d(g=>({...g,[l.key]:h})),children:[e.jsx(Oe,{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:160:25",className:"bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",children:e.jsx(Ie,{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:161:27",placeholder:l.placeholder||`请选择${l.label}`})}),e.jsx($e,{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:163:25",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:(l.options||[]).map(h=>e.jsx(Re,{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:165:29",value:h,className:"text-[var(--dg-text-primary)] focus:bg-[var(--dg-bg-hover)]",children:h},h))})]}):l.type==="textarea"?e.jsx(pe,{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:172:23",placeholder:l.placeholder||`请输入${l.label}`,value:p[l.key]??"",onChange:h=>d(g=>({...g,[l.key]:h.target.value})),className:"bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)] min-h-[80px]"}):e.jsx(le,{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:179:23",type:l.type==="number"?"number":"text",placeholder:l.placeholder||`请输入${l.label}`,value:p[l.key]??"",onChange:h=>d(g=>({...g,[l.key]:h.target.value})),className:"bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)]"})]},l.key)})})]}):e.jsx("div",{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:100:11",className:"grid grid-cols-2 gap-4 py-2",children:R.map(l=>{const x=s.find(g=>g.type===l.value&&g.enabled!==!1),h=l.icon;return e.jsxs("button",{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:107:17",type:"button",disabled:!x,onClick:()=>{m(x),d({})},className:b("flex flex-col items-start gap-3 p-5 rounded-xl text-left transition-colors","bg-[var(--dg-bg-tertiary)] hover:bg-[var(--dg-bg-hover)]",!x&&"opacity-40 cursor-not-allowed hover:bg-[var(--dg-bg-tertiary)]"),children:[e.jsx("div",{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:118:19",className:"w-10 h-10 rounded-lg flex items-center justify-center",style:{backgroundColor:`color-mix(in srgb, ${l.color} 15%, transparent)`,color:l.color},children:e.jsx(h,{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:122:21",className:"h-5 w-5"})}),e.jsxs("div",{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:124:19",children:[e.jsx("p",{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:125:21",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:l.label}),e.jsx("p",{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:126:21",className:"text-xs text-[var(--dg-text-muted)] mt-0.5",children:x?x.description||`共 ${I(x.form_schema).length} 个字段`:"暂无可用模板"})]})]},l.value)})}),e.jsxs(G,{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:197:9",children:[e.jsx(i,{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:198:11",variant:"ghost",onClick:()=>r(!1),children:"取消"}),n&&e.jsxs(i,{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:200:13",className:"bg-[var(--dg-blue)] hover:opacity-90 text-white",onClick:w,disabled:y,children:[y&&e.jsx($,{"code-path":"src/components/approval/ApprovalCreateDialog.tsx:205:30",className:"h-4 w-4 mr-2 animate-spin"}),"提交申请"]})]})]})})}function Xe(){const[a,r]=v.useState("instances"),[s,o]=v.useState([]),[n,m]=v.useState([]),[p,d]=v.useState([]),[y,c]=v.useState(!0),[w,l]=v.useState(""),[x,h]=v.useState(""),[g,de]=v.useState("all"),[me,W]=v.useState(!1),[P,Z]=v.useState(null),[ve,O]=v.useState(!1),[f,xe]=v.useState("approve"),[z,ee]=v.useState(""),[ae,te]=v.useState(!1),[ie,se]=v.useState(!1),B=async()=>{try{c(!0);const[t,N,J]=await Promise.all([k.getProcesses().catch(()=>null),k.getTemplates().catch(()=>null),k.getProcesses({status:"pending"}).catch(()=>null)]);o(t?.list||[]),m(N?.list||[]),d(J?.list||[])}catch(t){console.error("加载审批数据失败:",t)}finally{c(!1)}};v.useEffect(()=>{B()},[]);const he=s.filter(t=>{const N=(t.title||"").toLowerCase().includes(w.toLowerCase())||(t.applicant_name||t.applicant||"").toLowerCase().includes(w.toLowerCase()),J=!x||t.status===x;return N&&J}),ge=n.filter(t=>g==="all"||t.type===g),re=t=>{Z(t),W(!0)},S=(t,N)=>{xe(t),Z(N),ee(""),O(!0)},be=async()=>{if(P)try{te(!0),f==="approve"?(await k.approveProcess(P.id,z),T.success("审批通过")):(await k.rejectProcess(P.id,z),T.success("已拒绝")),O(!1),B()}catch(t){T.error("操作失败",{description:t.message})}finally{te(!1)}},ue=s.filter(t=>t.status==="pending").length,je=s.filter(t=>t.status==="approved").length,Ae=s.filter(t=>t.status==="rejected").length,E=p.filter(t=>t.status==="pending").length;return e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:140:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:142:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:143:9",children:[e.jsx("h1",{"code-path":"src/components/approval/ApprovalFlow.tsx:144:11",className:"text-2xl font-bold text-[var(--dg-text-primary)]",children:"资源申请"}),e.jsx("p",{"code-path":"src/components/approval/ApprovalFlow.tsx:145:11",className:"text-sm text-[var(--dg-text-muted)] mt-1",children:"云服务器申请 · 应用部署申请"})]}),e.jsxs(i,{"code-path":"src/components/approval/ApprovalFlow.tsx:147:9",className:"bg-[var(--dg-blue)] hover:opacity-90 text-white",onClick:()=>se(!0),children:[e.jsx(ke,{"code-path":"src/components/approval/ApprovalFlow.tsx:151:11",className:"h-4 w-4 mr-2"}),"新建申请"]})]}),e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:157:7",className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx(u,{"code-path":"src/components/approval/ApprovalFlow.tsx:158:9",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsx(j,{"code-path":"src/components/approval/ApprovalFlow.tsx:159:11",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:160:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:161:15",children:[e.jsx("p",{"code-path":"src/components/approval/ApprovalFlow.tsx:162:17",className:"text-sm text-[var(--dg-text-muted)]",children:"待审批"}),e.jsx("p",{"code-path":"src/components/approval/ApprovalFlow.tsx:163:17",className:"text-2xl font-bold text-amber-400",children:ue})]}),e.jsx("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:165:15",className:"p-3 rounded-lg bg-amber-500/10 text-amber-400",children:e.jsx(ce,{"code-path":"src/components/approval/ApprovalFlow.tsx:166:17",className:"h-5 w-5"})})]})})}),e.jsx(u,{"code-path":"src/components/approval/ApprovalFlow.tsx:171:9",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsx(j,{"code-path":"src/components/approval/ApprovalFlow.tsx:172:11",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:173:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:174:15",children:[e.jsx("p",{"code-path":"src/components/approval/ApprovalFlow.tsx:175:17",className:"text-sm text-[var(--dg-text-muted)]",children:"已通过"}),e.jsx("p",{"code-path":"src/components/approval/ApprovalFlow.tsx:176:17",className:"text-2xl font-bold text-emerald-400",children:je})]}),e.jsx("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:178:15",className:"p-3 rounded-lg bg-emerald-500/10 text-emerald-400",children:e.jsx(D,{"code-path":"src/components/approval/ApprovalFlow.tsx:179:17",className:"h-5 w-5"})})]})})}),e.jsx(u,{"code-path":"src/components/approval/ApprovalFlow.tsx:184:9",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsx(j,{"code-path":"src/components/approval/ApprovalFlow.tsx:185:11",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:186:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:187:15",children:[e.jsx("p",{"code-path":"src/components/approval/ApprovalFlow.tsx:188:17",className:"text-sm text-[var(--dg-text-muted)]",children:"已拒绝"}),e.jsx("p",{"code-path":"src/components/approval/ApprovalFlow.tsx:189:17",className:"text-2xl font-bold text-red-400",children:Ae})]}),e.jsx("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:191:15",className:"p-3 rounded-lg bg-red-500/10 text-red-400",children:e.jsx(F,{"code-path":"src/components/approval/ApprovalFlow.tsx:192:17",className:"h-5 w-5"})})]})})}),e.jsx(u,{"code-path":"src/components/approval/ApprovalFlow.tsx:197:9",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsx(j,{"code-path":"src/components/approval/ApprovalFlow.tsx:198:11",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:199:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:200:15",children:[e.jsx("p",{"code-path":"src/components/approval/ApprovalFlow.tsx:201:17",className:"text-sm text-[var(--dg-text-muted)]",children:"我的待办"}),e.jsx("p",{"code-path":"src/components/approval/ApprovalFlow.tsx:202:17",className:"text-2xl font-bold text-[var(--dg-blue)]",children:E})]}),e.jsx("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:204:15",className:"p-3 rounded-lg bg-[var(--dg-blue)]/10 text-[var(--dg-blue)]",children:e.jsx(_,{"code-path":"src/components/approval/ApprovalFlow.tsx:205:17",className:"h-5 w-5"})})]})})})]}),e.jsx("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:213:7",className:"flex items-center gap-1 border-b border-[var(--dg-border)]",children:[{key:"instances",label:"审批实例"},{key:"flows",label:"流程模板"},{key:"my-approvals",label:"我的审批"}].map(t=>e.jsxs("button",{"code-path":"src/components/approval/ApprovalFlow.tsx:219:11",onClick:()=>r(t.key),className:b("px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",a===t.key?"border-[var(--dg-blue)] text-[var(--dg-blue)]":"border-transparent text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)]"),children:[t.label,t.key==="my-approvals"&&E>0&&e.jsx(C,{"code-path":"src/components/approval/ApprovalFlow.tsx:231:15",className:"ml-2 bg-red-500/20 text-red-400 border-0 text-xs",children:E})]},t.key))}),a==="instances"&&e.jsx(Ve,{"code-path":"src/components/approval/ApprovalFlow.tsx:239:9",processes:s,filteredInstances:he,loading:y,searchQuery:w,setSearchQuery:l,statusFilter:x,setStatusFilter:h,onView:re,onApprove:t=>S("approve",t),onReject:t=>S("reject",t)}),a==="flows"&&e.jsx(Ge,{"code-path":"src/components/approval/ApprovalFlow.tsx:254:9",filteredTemplates:ge,templateTypeFilter:g,setTemplateTypeFilter:de}),a==="my-approvals"&&e.jsx("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:262:9",className:"grid grid-cols-1 gap-4",children:p.length===0?e.jsx(u,{"code-path":"src/components/approval/ApprovalFlow.tsx:264:13",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsx(j,{"code-path":"src/components/approval/ApprovalFlow.tsx:265:15",className:"p-12",children:e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:266:17",className:"text-center",children:[e.jsx(_,{"code-path":"src/components/approval/ApprovalFlow.tsx:267:19",className:"h-12 w-12 mx-auto text-[var(--dg-text-muted)] mb-4"}),e.jsx("h3",{"code-path":"src/components/approval/ApprovalFlow.tsx:268:19",className:"text-lg font-medium text-[var(--dg-text-secondary)] mb-2",children:"暂无待办"}),e.jsx("p",{"code-path":"src/components/approval/ApprovalFlow.tsx:269:19",className:"text-sm text-[var(--dg-text-muted)]",children:"没有等待你处理的审批"})]})})}):p.map(t=>{const{percentage:N}=U(t);return e.jsx(u,{"code-path":"src/components/approval/ApprovalFlow.tsx:277:17",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(j,{"code-path":"src/components/approval/ApprovalFlow.tsx:278:19",className:"p-4",children:[e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:279:21",className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:280:23",className:"flex items-start gap-3",children:[e.jsx("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:281:25",className:"w-10 h-10 rounded-lg bg-[var(--dg-bg-tertiary)] flex items-center justify-center",style:{color:L(A(t))},children:e.jsx(_,{"code-path":"src/components/approval/ApprovalFlow.tsx:282:27",className:"h-5 w-5"})}),e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:284:25",children:[e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:285:27",className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{"code-path":"src/components/approval/ApprovalFlow.tsx:286:29",className:"font-medium text-[var(--dg-text-primary)]",children:t.title}),e.jsx(C,{"code-path":"src/components/approval/ApprovalFlow.tsx:287:29",variant:"outline",className:"text-xs border-[var(--dg-border)]",style:{color:L(A(t))},children:Y(A(t))})]}),e.jsxs("p",{"code-path":"src/components/approval/ApprovalFlow.tsx:291:27",className:"text-xs text-[var(--dg-text-muted)]",children:["申请人:",t.applicant_name||t.applicant||"--"]}),e.jsxs("p",{"code-path":"src/components/approval/ApprovalFlow.tsx:294:27",className:"text-xs text-[var(--dg-text-muted)]",children:["提交于 ",t.created_at?new Date(t.created_at).toLocaleString():"--"]})]})]}),e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:299:23",className:"flex items-center gap-2",children:[e.jsxs(i,{"code-path":"src/components/approval/ApprovalFlow.tsx:300:25",variant:"ghost",size:"sm",onClick:()=>re(t),children:[e.jsx(_,{"code-path":"src/components/approval/ApprovalFlow.tsx:301:27",className:"h-4 w-4 mr-1"}),"详情"]}),t.status==="pending"&&e.jsxs(e.Fragment,{children:[e.jsxs(i,{"code-path":"src/components/approval/ApprovalFlow.tsx:306:29",variant:"outline",size:"sm",className:"border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10",onClick:()=>S("approve",t),children:[e.jsx(D,{"code-path":"src/components/approval/ApprovalFlow.tsx:307:31",className:"h-4 w-4 mr-1"}),"通过"]}),e.jsxs(i,{"code-path":"src/components/approval/ApprovalFlow.tsx:309:29",variant:"outline",size:"sm",className:"border-red-500/30 text-red-400 hover:bg-red-500/10",onClick:()=>S("reject",t),children:[e.jsx(F,{"code-path":"src/components/approval/ApprovalFlow.tsx:310:31",className:"h-4 w-4 mr-1"}),"拒绝"]})]})]})]}),e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:316:21",className:"mb-3",children:[e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:317:23",className:"flex items-center justify-between text-xs text-[var(--dg-text-muted)] mb-1.5",children:[e.jsx("span",{"code-path":"src/components/approval/ApprovalFlow.tsx:318:25",children:"审批进度"}),e.jsxs("span",{"code-path":"src/components/approval/ApprovalFlow.tsx:319:25",children:[N,"%"]})]}),e.jsx("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:321:23",className:"w-full h-1.5 bg-[var(--dg-bg-tertiary)] rounded-full overflow-hidden",children:e.jsx("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:322:25",className:b("h-full rounded-full",t.status==="rejected"?"bg-red-400":"bg-[var(--dg-blue)]"),style:{width:`${N}%`}})})]}),e.jsx("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:325:21",className:"bg-[var(--dg-bg-primary)] rounded-lg p-3",children:X(t)})]})},t.id)})}),e.jsx(Ye,{"code-path":"src/components/approval/ApprovalFlow.tsx:337:7",open:me,onOpenChange:W,instance:P,templates:n,onApprove:t=>S("approve",t),onReject:t=>S("reject",t)}),e.jsx(M,{"code-path":"src/components/approval/ApprovalFlow.tsx:347:7",open:ve,onOpenChange:O,children:e.jsxs(V,{"code-path":"src/components/approval/ApprovalFlow.tsx:348:9",className:"max-w-md bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:[e.jsxs(q,{"code-path":"src/components/approval/ApprovalFlow.tsx:349:11",children:[e.jsx(H,{"code-path":"src/components/approval/ApprovalFlow.tsx:350:13",className:"text-[var(--dg-text-primary)] flex items-center gap-2",children:f==="approve"?e.jsxs(e.Fragment,{children:[e.jsx(D,{"code-path":"src/components/approval/ApprovalFlow.tsx:353:19",className:"h-5 w-5 text-emerald-400"}),"确认通过审批"]}):e.jsxs(e.Fragment,{children:[e.jsx(F,{"code-path":"src/components/approval/ApprovalFlow.tsx:358:19",className:"h-5 w-5 text-red-400"}),"确认拒绝审批"]})}),e.jsx(Q,{"code-path":"src/components/approval/ApprovalFlow.tsx:363:13",className:"text-[var(--dg-text-muted)]",children:f==="approve"?"请填写审批意见后确认通过":"请填写拒绝原因后确认拒绝"})]}),P&&e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:368:13",className:"py-2",children:[e.jsxs("p",{"code-path":"src/components/approval/ApprovalFlow.tsx:369:15",className:"text-sm text-[var(--dg-text-secondary)] mb-2",children:["审批标题:",e.jsx("span",{"code-path":"src/components/approval/ApprovalFlow.tsx:370:22",className:"text-[var(--dg-text-primary)]",children:P.title})]}),e.jsxs("div",{"code-path":"src/components/approval/ApprovalFlow.tsx:372:15",className:"space-y-2",children:[e.jsx("label",{"code-path":"src/components/approval/ApprovalFlow.tsx:373:17",className:"text-sm font-medium text-[var(--dg-text-secondary)]",children:f==="approve"?"审批意见":"拒绝原因"}),e.jsx(pe,{"code-path":"src/components/approval/ApprovalFlow.tsx:376:17",placeholder:f==="approve"?"请填写审批意见(可选)":"请填写拒绝原因",value:z,onChange:t=>ee(t.target.value),className:"bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)] min-h-[80px]"})]})]}),e.jsxs(G,{"code-path":"src/components/approval/ApprovalFlow.tsx:385:11",children:[e.jsx(i,{"code-path":"src/components/approval/ApprovalFlow.tsx:386:13",variant:"outline",onClick:()=>O(!1),className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)]",children:"取消"}),e.jsxs(i,{"code-path":"src/components/approval/ApprovalFlow.tsx:389:13",onClick:be,disabled:ae,className:f==="approve"?"bg-emerald-500/90 hover:bg-emerald-500 text-white":"bg-red-500 hover:bg-red-600 text-white",children:[ae&&e.jsx($,{"code-path":"src/components/approval/ApprovalFlow.tsx:394:36",className:"h-4 w-4 mr-2 animate-spin"}),f==="approve"?"确认通过":"确认拒绝"]})]})]})}),e.jsx(Ue,{"code-path":"src/components/approval/ApprovalFlow.tsx:402:7",open:ie,onOpenChange:se,templates:n,onSuccess:B})]})}const ca=Xe;export{Xe as ApprovalFlow,ca as ApprovalFlowManager}; diff --git a/backend/static/assets/ApprovalPermissionPage-B9wgkK5L.js b/backend/static/assets/ApprovalPermissionPage-B9wgkK5L.js deleted file mode 100644 index 72e25b1..0000000 --- a/backend/static/assets/ApprovalPermissionPage-B9wgkK5L.js +++ /dev/null @@ -1 +0,0 @@ -import{j as e}from"./vendor-codemirror-B1SGo4xl.js";import{A as r}from"./ApprovalCategoryPage-CA91WuCS.js";import"./card-BIfzBCEy.js";import"./index-Dungj95X.js";import"./vendor-icons-DmqcWdzX.js";import"./input-CXoUQQLm.js";import"./badge-CGJlVD3L.js";import"./label-CMpUoC87.js";import"./table-B2F10oba.js";import"./select-CiTqGGhE.js";import"./index-5FEebgvX.js";import"./approval-BY_CqGOr.js";const t=[{key:"perm_type",label:"权限类型",type:"select",options:["堡垒机权限","生产VPN权限","日志查询权限","数据库查询权限","服务器SSH权限","K8s集群权限"],required:!0},{key:"account",label:"申请账号",type:"text",placeholder:"如 logan.li",required:!0},{key:"reason",label:"申请理由",type:"textarea",placeholder:"说明为什么需要该权限",required:!0},{key:"duration",label:"权限时长",type:"select",options:["临时(24小时)","短期(7天)","中期(30天)","长期(90天)","永久"],required:!0}];function P(){return e.jsx(r,{"code-path":"src/pages/ApprovalPermissionPage.tsx:17:5",category:"permission",title:"权限审批",description:"申请堡垒机、VPN、日志查询、数据库查询等运维权限",fields:t,templateCode:"permission_request"})}export{P as ApprovalPermissionPage}; diff --git a/backend/static/assets/ApprovalResourcePage-E5m3aGX_.js b/backend/static/assets/ApprovalResourcePage-E5m3aGX_.js deleted file mode 100644 index 12367f8..0000000 --- a/backend/static/assets/ApprovalResourcePage-E5m3aGX_.js +++ /dev/null @@ -1 +0,0 @@ -import{j as e}from"./vendor-codemirror-B1SGo4xl.js";import{A as r}from"./ApprovalCategoryPage-CA91WuCS.js";import"./card-BIfzBCEy.js";import"./index-Dungj95X.js";import"./vendor-icons-DmqcWdzX.js";import"./input-CXoUQQLm.js";import"./badge-CGJlVD3L.js";import"./label-CMpUoC87.js";import"./table-B2F10oba.js";import"./select-CiTqGGhE.js";import"./index-5FEebgvX.js";import"./approval-BY_CqGOr.js";const t=[{key:"provider",label:"云厂商",type:"select",options:["阿里云","腾讯云","华为云","AWS"],required:!0},{key:"region",label:"地域",type:"text",placeholder:"如 cn-hangzhou",required:!0},{key:"spec",label:"规格",type:"select",options:["2C4G","4C8G","8C16G","16C32G","32C64G"],required:!0},{key:"disk",label:"系统盘(GB)",type:"number",defaultValue:40,required:!0},{key:"count",label:"数量(台)",type:"number",defaultValue:1,required:!0},{key:"duration",label:"时长",type:"select",options:["1个月","3个月","6个月","1年"],required:!0},{key:"purpose",label:"用途说明",type:"textarea",required:!0}];function b(){return e.jsx(r,{"code-path":"src/pages/ApprovalResourcePage.tsx:16:5",category:"resource",title:"资源申请",description:"申请云服务器、存储、网络等基础设施资源",fields:t,templateCode:"server_apply"})}export{b as ApprovalResourcePage}; diff --git a/backend/static/assets/ApprovalWorkflowPage-Cv6LjE48.js b/backend/static/assets/ApprovalWorkflowPage-Cv6LjE48.js deleted file mode 100644 index 010ff07..0000000 --- a/backend/static/assets/ApprovalWorkflowPage-Cv6LjE48.js +++ /dev/null @@ -1 +0,0 @@ -import{r as p,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{C as M,a as Q}from"./card-BIfzBCEy.js";import{f as V,u as X,t as C,B as $}from"./index-Dungj95X.js";import{a as S}from"./approval-BY_CqGOr.js";import{L as D,P as R,J as H,K as z,O as Z,Q as Y,z as J,c as ee,T as F,X as G,j as q,V as se,W as ae,Y as te,y as re}from"./vendor-icons-DmqcWdzX.js";const oe={resource:"资源申请",app:"应用申请",permission:"权限审批"},L={submit:"提交阶段",audit:"审核阶段",execute:"执行阶段"},B={submit:"bg-blue-500/15 text-blue-400 border-blue-500/30",audit:"bg-purple-500/15 text-purple-400 border-purple-500/30",execute:"bg-green-500/15 text-green-400 border-green-500/30"},pe={submit:se,audit:q,execute:J},le=[{value:"submit",label:"提交阶段",desc:"工单提交人"},{value:"audit",label:"审核阶段",desc:"审核人员审批"},{value:"execute",label:"执行阶段",desc:"执行人员操作"}];function ce({users:i,selectedIds:g,label:v,onToggle:b,onToggleAll:y,onClear:A,getUserName:_}){const[m,j]=p.useState(!1),k=p.useRef(null),[P,l]=p.useState({top:0,left:0,width:0}),h=()=>{if(k.current){const c=k.current.getBoundingClientRect();l({top:c.bottom+4,left:c.left,width:c.width})}};return e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:113:5",className:"relative",children:[e.jsxs("button",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:114:7",ref:k,type:"button",onClick:()=>{m||h(),j(!m)},className:`w-full flex items-center justify-between px-3 py-2 rounded-lg text-sm transition-colors ${g.length===0?"bg-[var(--dg-bg-tertiary)] border border-red-500/40 text-[var(--dg-text-muted)]":"bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] text-[var(--dg-text-primary)]"}`,children:[e.jsx("span",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:124:9",className:"truncate",children:g.length===0?`${v} * 请选择`:`${v} (${g.length}人)`}),e.jsx(Y,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:127:9",className:`w-4 h-4 text-[var(--dg-text-muted)] transition-transform ${m?"rotate-180":""}`})]}),g.length>1&&e.jsx("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:131:9",className:"flex flex-wrap gap-1 mt-1.5",children:g.map(c=>e.jsxs("span",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:133:13",className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] bg-blue-500/15 text-blue-400",children:[_(c),e.jsx("button",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:135:15",onClick:()=>b(c),className:"hover:text-red-400",children:e.jsx(G,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:135:84",className:"w-3 h-3"})})]},c))}),m&&e.jsxs(e.Fragment,{children:[e.jsx("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:143:11",className:"fixed inset-0 z-40",onClick:()=>j(!1)}),e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:144:11",className:"fixed z-50 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded-lg shadow-xl max-h-52 overflow-y-auto",style:{top:P.top,left:P.left,width:P.width},children:[e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:146:13",className:"flex items-center justify-between px-3 py-2 border-b border-[var(--dg-border)]",children:[e.jsx("button",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:147:15",onClick:y,className:"text-[11px] text-blue-400 hover:text-blue-300",children:g.length===i.length&&i.length>0?"取消全选":"全选"}),g.length>0&&e.jsx("button",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:151:17",onClick:A,className:"text-[11px] text-red-400 hover:text-red-300",children:"清空"})]}),i.map(c=>{const u=g.includes(c.id);return e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:157:17",onClick:()=>b(c.id),className:"flex items-center gap-2.5 px-3 py-2 cursor-pointer hover:bg-[var(--dg-bg-hover)] transition-colors",children:[e.jsx("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:159:19",className:`w-4 h-4 rounded border flex items-center justify-center flex-shrink-0 ${u?"bg-blue-500 border-blue-500":"border-[var(--dg-border)]"}`,children:u&&e.jsx(re,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:162:33",className:"w-3 h-3 text-white"})}),e.jsx("span",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:164:19",className:`text-sm flex-1 ${u?"text-[var(--dg-text-primary)]":"text-[var(--dg-text-secondary)]"}`,children:c.display_name||c.username}),e.jsx("span",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:167:19",className:"text-[10px] text-[var(--dg-text-muted)] px-1.5 py-0.5 rounded bg-[var(--dg-bg-tertiary)]",children:c.role})]},c.id)})]})]})]})}function de({workflow:i,users:g,onClose:v,onSaved:b}){const y=!!i,[A,_]=p.useState(i?.name||""),[m,j]=p.useState(i?.description||""),[k,P]=p.useState(i?.category||"resource"),[l,h]=p.useState([]),[c,u]=p.useState(!1),[E,W]=p.useState("");p.useEffect(()=>{i?.steps?.length?h(i.steps.map(s=>({name:s.name,step_type:s.step_type==="serial"||s.step_type==="parallel"?"audit":s.step_type,approver_ids:T(s.approver_ids)}))):h([{name:"提交申请",step_type:"submit",approver_ids:[]},{name:"审核",step_type:"audit",approver_ids:[]}])},[i]);const T=s=>{if(!s)return[];try{const t=JSON.parse(s);return Array.isArray(t)?t:[]}catch{return[]}},U=s=>{const t={submit:"提交",audit:"审核",execute:"执行"},r=l.filter(f=>f.step_type===s).length,x=r>0?` ${r+1}`:"";h([...l,{name:`${t[s]}${x}`,step_type:s,approver_ids:[]}])},a=s=>h(l.filter((t,r)=>r!==s)),d=(s,t)=>{const r=s+t;if(r<0||r>=l.length)return;const x=[...l];[x[s],x[r]]=[x[r],x[s]],h(x)},o=(s,t)=>{h(l.map((r,x)=>x===s?{...r,...t}:r))},n=(s,t)=>{const r=l[s],x=r.approver_ids.includes(t);o(s,{approver_ids:x?r.approver_ids.filter(f=>f!==t):[...r.approver_ids,t]})},w=s=>{const t=g.filter(r=>r.is_active!==!1);return s==="audit"?t:s==="execute"?t.filter(r=>["super_admin","k8s_admin","release_admin","resource_admin"].includes(r.role)):t},N=s=>{const t=l[s],r=w(t.step_type),x=t.approver_ids.length===r.length&&r.length>0;o(s,{approver_ids:x?[]:r.map(f=>f.id)})},I=async()=>{if(!A.trim()){W("请输入流程名称");return}if(l.length===0){W("请至少添加一个步骤");return}for(let s=0;s({step_number:r+1,name:t.name,step_type:t.step_type,approver_ids:t.approver_ids.length>0?JSON.stringify(t.approver_ids):null,is_required:!0,timeout_hours:24,auto_approve_on_timeout:!1}))};y&&i?await S.update(i.id,s):await S.create(s),b()}catch(s){const t=s?.response?.data?.detail||"保存失败";W(t)}finally{u(!1)}},K=s=>{const t=g.find(r=>r.id===s);return t?t.display_name||t.username:`#${s}`},O="w-full px-3 py-2 bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] rounded-lg text-sm focus:border-blue-400 focus:outline-none transition-colors text-[var(--dg-text-primary)]";return e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:315:5",className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:316:7",className:"absolute inset-0 bg-black/50",onClick:v}),e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:317:7",className:"relative bg-[var(--dg-bg-secondary)] rounded-xl shadow-2xl w-full max-w-2xl max-h-[90vh] overflow-y-auto m-4",children:[e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:318:9",className:"flex items-center justify-between px-5 py-4 border-b border-[var(--dg-border)]",children:[e.jsx("h2",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:319:11",className:"text-base font-semibold text-[var(--dg-text-primary)]",children:y?"编辑审批流程":"新建审批流程"}),e.jsx("button",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:322:11",onClick:v,className:"p-1.5 rounded-lg hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)] transition-colors",children:e.jsx(G,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:323:13",className:"w-4 h-4"})})]}),e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:327:9",className:"px-5 pb-5 space-y-4 pt-4",children:[E&&e.jsx("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:328:21",className:"px-3 py-2 text-sm text-red-400 bg-red-500/10 rounded-lg",children:E}),e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:330:11",className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:331:13",children:[e.jsx("label",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:332:15",className:"block text-xs font-medium text-[var(--dg-text-secondary)] mb-1",children:"流程名称 *"}),e.jsx("input",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:333:15",className:O,value:A,onChange:s=>_(s.target.value),placeholder:"输入流程名称"})]}),e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:335:13",children:[e.jsx("label",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:336:15",className:"block text-xs font-medium text-[var(--dg-text-secondary)] mb-1",children:"所属分类"}),e.jsxs("select",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:337:15",className:O,value:k,onChange:s=>P(s.target.value),children:[e.jsx("option",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:338:17",value:"resource",children:"资源申请"}),e.jsx("option",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:339:17",value:"app",children:"应用申请"}),e.jsx("option",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:340:17",value:"permission",children:"权限审批"})]})]})]}),e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:345:11",children:[e.jsx("label",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:346:13",className:"block text-xs font-medium text-[var(--dg-text-secondary)] mb-1",children:"描述"}),e.jsx("input",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:347:13",className:O,value:m,onChange:s=>j(s.target.value),placeholder:"可选"})]}),e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:351:11",children:[e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:352:13",className:"flex items-center justify-between mb-2",children:[e.jsx("label",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:353:15",className:"text-xs font-medium text-[var(--dg-text-secondary)]",children:"流程步骤"}),e.jsx("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:354:15",className:"flex items-center gap-1",children:le.map(s=>e.jsxs("button",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:356:19",onClick:()=>U(s.value),className:"flex items-center gap-1 px-2 py-1 text-[11px] font-medium bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 rounded transition-colors",children:[e.jsx(R,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:358:21",className:"w-3 h-3"}),s.label]},s.value))})]}),e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:364:13",className:"space-y-2",children:[l.map((s,t)=>{const r=B[s.step_type],x=pe[s.step_type]||q;return e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:369:19",className:"p-3 bg-[var(--dg-bg-primary)] rounded-lg border border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:370:21",className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:371:23",className:`w-7 h-7 rounded-md flex items-center justify-center flex-shrink-0 ${r.split(" ")[0]}`,children:e.jsx(x,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:372:25",className:`w-3.5 h-3.5 ${r.split(" ")[1]}`})}),e.jsx("input",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:374:23",className:"flex-1 px-2 py-1 bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] rounded text-sm focus:border-blue-400 focus:outline-none text-[var(--dg-text-primary)]",value:s.name,onChange:f=>o(t,{name:f.target.value}),placeholder:"步骤名称"}),e.jsx("span",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:379:23",className:`text-[10px] px-1.5 py-0.5 rounded ${r}`,children:L[s.step_type]}),e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:382:23",className:"flex items-center gap-0.5 ml-1",children:[e.jsx("button",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:383:25",onClick:()=>d(t,-1),disabled:t===0,className:"p-1 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-muted)] disabled:opacity-20 transition-colors",children:e.jsx(ae,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:385:27",className:"w-3.5 h-3.5"})}),e.jsx("button",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:387:25",onClick:()=>d(t,1),disabled:t===l.length-1,className:"p-1 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-muted)] disabled:opacity-20 transition-colors",children:e.jsx(te,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:389:27",className:"w-3.5 h-3.5"})}),e.jsx("button",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:391:25",onClick:()=>a(t),className:"p-1 rounded hover:bg-red-500/10 text-[var(--dg-text-muted)] hover:text-red-400 transition-colors",children:e.jsx(F,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:393:27",className:"w-3.5 h-3.5"})})]})]}),s.step_type!=="submit"&&e.jsx("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:399:23",className:"pl-9 mt-2",children:e.jsx(ce,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:400:25",users:w(s.step_type),selectedIds:s.approver_ids,label:s.step_type==="audit"?"审核人":"执行人",onToggle:f=>n(t,f),onToggleAll:()=>N(t),onClear:()=>o(t,{approver_ids:[]}),getUserName:K})})]},t)}),l.length===0&&e.jsx("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:416:17",className:"text-center py-4 text-sm text-[var(--dg-text-muted)]",children:"请点击上方按钮添加流程步骤"})]})]})]}),e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:424:9",className:"flex items-center justify-end gap-3 px-5 py-4 border-t border-[var(--dg-border)]",children:[e.jsx("button",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:425:11",onClick:v,className:"px-4 py-2 text-sm text-[var(--dg-text-secondary)] hover:bg-[var(--dg-bg-hover)] rounded-lg transition-colors",children:"取消"}),e.jsxs($,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:428:11",onClick:I,disabled:c,children:[c&&e.jsx(D,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:429:28",className:"w-4 h-4 animate-spin mr-1"}),y?"保存":"创建"]})]})]})]})}function ve(){const i=V(),[g,v]=p.useState([]),[b,y]=p.useState([]),[A,_]=p.useState(!0),[m,j]=p.useState(null),[k,P]=p.useState(null),[l,h]=p.useState(void 0),c=p.useCallback(async()=>{try{_(!0),j(null);const a=await S.list(),o=(Array.isArray(a?.list)?a.list:Array.isArray(a)?a:[]).map(n=>({...n,steps:n.steps||[]}));v(o)}catch{j("获取审批流程失败")}finally{_(!1)}},[]),u=p.useCallback(async()=>{try{const a=await X.getUsers(),o=(Array.isArray(a?.list)?a.list:Array.isArray(a)?a:[]).map(n=>({...n,role:n.role||(Array.isArray(n.roles)&&n.roles.length>0?n.roles[0].code:"")}));y(o)}catch{}},[]);p.useEffect(()=>{c(),u()},[c,u]);const E=p.useCallback(async a=>{try{await S.update(a.id,{is_active:!a.is_active}),v(d=>d.map(o=>o.id===a.id?{...o,is_active:!o.is_active}:o)),C.success(a.is_active?"已停用":"已启用")}catch{C.error("操作失败")}},[]),W=p.useCallback(async(a,d)=>{if(await i({title:"删除审批流程",description:`确定删除审批流程「${d}」?删除后不可恢复。`,confirmText:"删除",variant:"destructive"}))try{await S.delete(a),v(n=>n.filter(w=>w.id!==a)),C.success("已删除")}catch{C.error("删除失败")}},[i]),T=p.useCallback(async a=>{try{await S.setDefault(a),v(d=>d.map(o=>({...o,is_default:o.id===a}))),C.success("已设为默认")}catch{C.error("操作失败")}},[]),U=p.useCallback(a=>{const d=b.find(o=>o.id===a);return d?d.display_name||d.username:`#${a}`},[b]);return A?e.jsx("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:525:7",className:"flex items-center justify-center h-64",children:e.jsx(D,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:526:9",className:"w-8 h-8 animate-spin text-blue-400"})}):m?e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:533:7",className:"flex flex-col items-center justify-center h-64 text-[var(--dg-text-muted)]",children:[e.jsx("p",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:534:9",className:"text-sm",children:m}),e.jsx($,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:535:9",variant:"outline",onClick:c,className:"mt-3",children:"重试"})]}):e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:541:5",className:"space-y-5",children:[e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:543:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:544:9",children:[e.jsx("h1",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:545:11",className:"text-2xl font-semibold text-[var(--dg-text-primary)]",children:"审批流程配置"}),e.jsx("p",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:546:11",className:"text-sm text-[var(--dg-text-secondary)] mt-1",children:"为资源申请、应用申请、权限审批配置多级审批流程"})]}),e.jsxs($,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:550:9",onClick:()=>h(null),children:[e.jsx(R,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:551:11",className:"w-4 h-4 mr-1.5"}),"新建流程"]})]}),g.length===0?e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:556:9",className:"dg-card p-12 text-center",children:[e.jsx(H,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:557:11",className:"w-12 h-12 mx-auto mb-3 opacity-50 text-[var(--dg-text-muted)]"}),e.jsx("p",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:558:11",className:"text-sm text-[var(--dg-text-muted)] mb-4",children:"暂无审批流程"}),e.jsx($,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:559:11",variant:"outline",onClick:()=>h(null),children:"创建第一个流程"})]}):e.jsx(e.Fragment,{children:e.jsx("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:564:11",className:"space-y-4",children:g.map(a=>{const d=k===a.id;return e.jsx(M,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:568:17",className:`dg-card overflow-hidden ${a.is_active?"":"opacity-50"}`,children:e.jsxs(Q,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:569:19",className:"p-5",children:[e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:570:21",className:"flex items-start justify-between",children:[e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:571:23",className:"flex-1 min-w-0",children:[e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:572:25",className:"flex items-center gap-3 mb-2 flex-wrap",children:[e.jsx("h3",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:573:27",className:"text-lg font-semibold text-[var(--dg-text-primary)]",children:a.name}),a.is_default&&e.jsxs("span",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:574:45",className:"text-[10px] px-1.5 py-0.5 rounded bg-yellow-400/15 text-yellow-400 flex items-center gap-1",children:[e.jsx(z,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:574:154",className:"w-3 h-3"}),"默认"]}),e.jsx("span",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:575:27",className:`text-[10px] px-1.5 py-0.5 rounded ${a.is_active?"bg-green-500/15 text-green-400":"bg-red-500/15 text-red-400"}`,children:a.is_active?"启用":"停用"}),e.jsx("span",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:578:27",className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-500/15 text-blue-400",children:oe[a.category]||a.category})]}),a.description&&e.jsx("p",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:582:44",className:"text-sm text-[var(--dg-text-secondary)] mb-1",children:a.description}),e.jsx("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:583:25",className:"flex items-center gap-1.5 mt-2 flex-wrap",children:a.steps?.map((o,n)=>e.jsxs("span",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:585:29",className:"flex items-center gap-1",children:[e.jsx("span",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:586:31",className:`text-[10px] px-1.5 py-0.5 rounded ${B[o.step_type]||"bg-gray-500/15 text-gray-400 border-gray-500/30"}`,children:L[o.step_type]||o.step_type}),n<(a.steps?.length||0)-1&&e.jsx("span",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:590:33",className:"text-[var(--dg-text-muted)] text-[10px]",children:"→"})]},n))})]}),e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:597:23",className:"flex items-center gap-1 flex-shrink-0 ml-4",children:[e.jsx("button",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:598:25",onClick:()=>P(d?null:a.id),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-muted)] transition-colors",children:d?e.jsx(Z,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:600:41",className:"w-4 h-4"}):e.jsx(Y,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:600:77",className:"w-4 h-4"})}),!a.is_default&&e.jsx("button",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:603:27",onClick:()=>T(a.id),className:"p-1.5 rounded hover:bg-yellow-500/10 text-[var(--dg-text-muted)] hover:text-yellow-400 transition-colors",title:"设为默认",children:e.jsx(z,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:605:29",className:"w-4 h-4"})}),e.jsx("button",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:608:25",onClick:()=>E(a),className:`p-1.5 rounded transition-colors ${a.is_active?"hover:bg-red-500/10 text-green-400 hover:text-red-400":"hover:bg-green-500/10 text-red-400 hover:text-green-400"}`,title:a.is_active?"停用":"启用",children:e.jsx(J,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:611:27",className:`w-4 h-4 ${a.is_active?"":"rotate-180"}`})}),e.jsx("button",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:613:25",onClick:()=>h(a),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-muted)] hover:text-blue-400 transition-colors",title:"编辑",children:e.jsx(ee,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:615:27",className:"w-4 h-4"})}),e.jsx("button",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:617:25",onClick:()=>W(a.id,a.name),className:"p-1.5 rounded hover:bg-red-500/10 text-[var(--dg-text-muted)] hover:text-red-400 transition-colors",title:"删除",children:e.jsx(F,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:619:27",className:"w-4 h-4"})})]})]}),d&&e.jsx("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:625:23",className:"mt-4 pt-4 border-t border-[var(--dg-border)] space-y-3",children:a.steps?.map((o,n)=>{const w=(()=>{try{const N=JSON.parse(o.approver_ids||"[]");return Array.isArray(N)?N:[]}catch{return[]}})();return e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:629:29",className:"flex items-start gap-3 p-3 bg-[var(--dg-bg-primary)] rounded-lg",children:[e.jsx("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:630:31",className:"w-6 h-6 rounded-full bg-[var(--dg-bg-tertiary)] flex items-center justify-center text-xs font-medium text-[var(--dg-text-secondary)] flex-shrink-0 mt-0.5",children:o.step_number}),e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:633:31",className:"flex-1 min-w-0",children:[e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:634:33",className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:635:35",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:o.name}),e.jsx("span",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:636:35",className:`text-[10px] px-1.5 py-0.5 rounded ${B[o.step_type]||"bg-gray-500/15 text-gray-400 border-gray-500/30"}`,children:L[o.step_type]||o.step_type})]}),w.length>0&&e.jsx("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:641:35",className:"flex flex-wrap gap-1",children:w.map(N=>e.jsx("span",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:643:39",className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] bg-blue-500/15 text-blue-400",children:U(N)},N))}),w.length===0&&o.step_type!=="submit"&&e.jsx("span",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:650:35",className:"text-[11px] text-red-400",children:"未关联审批人"})]})]},n)})})]})},a.id)})})}),l!==void 0&&e.jsx(de,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:667:9",workflow:l,users:b,onClose:()=>h(void 0),onSaved:()=>{h(void 0),c()}})]})}export{ve as default}; diff --git a/backend/static/assets/AreaChart-yrR-Mxho.js b/backend/static/assets/AreaChart-yrR-Mxho.js deleted file mode 100644 index 0259147..0000000 --- a/backend/static/assets/AreaChart-yrR-Mxho.js +++ /dev/null @@ -1,61 +0,0 @@ -import{ay as ee}from"./index-Dungj95X.js";import{d as ti,g as ue,r as N,R as T}from"./vendor-codemirror-B1SGo4xl.js";var Wa,vh;function Re(){if(vh)return Wa;vh=1;var e=Array.isArray;return Wa=e,Wa}var Ua,yh;function Zg(){if(yh)return Ua;yh=1;var e=typeof ti=="object"&&ti&&ti.Object===Object&&ti;return Ua=e,Ua}var Ha,mh;function ot(){if(mh)return Ha;mh=1;var e=Zg(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return Ha=r,Ha}var Ga,gh;function Gn(){if(gh)return Ga;gh=1;var e=ot(),t=e.Symbol;return Ga=t,Ga}var Ka,bh;function sw(){if(bh)return Ka;bh=1;var e=Gn(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,i=e?e.toStringTag:void 0;function a(o){var u=r.call(o,i),c=o[i];try{o[i]=void 0;var s=!0}catch{}var f=n.call(o);return s&&(u?o[i]=c:delete o[i]),f}return Ka=a,Ka}var Va,xh;function lw(){if(xh)return Va;xh=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return Va=r,Va}var Xa,wh;function xt(){if(wh)return Xa;wh=1;var e=Gn(),t=sw(),r=lw(),n="[object Null]",i="[object Undefined]",a=e?e.toStringTag:void 0;function o(u){return u==null?u===void 0?i:n:a&&a in Object(u)?t(u):r(u)}return Xa=o,Xa}var Ya,Oh;function wt(){if(Oh)return Ya;Oh=1;function e(t){return t!=null&&typeof t=="object"}return Ya=e,Ya}var Za,_h;function Nr(){if(_h)return Za;_h=1;var e=xt(),t=wt(),r="[object Symbol]";function n(i){return typeof i=="symbol"||t(i)&&e(i)==r}return Za=n,Za}var Ja,Sh;function uf(){if(Sh)return Ja;Sh=1;var e=Re(),t=Nr(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function i(a,o){if(e(a))return!1;var u=typeof a;return u=="number"||u=="symbol"||u=="boolean"||a==null||t(a)?!0:n.test(a)||!r.test(a)||o!=null&&a in Object(o)}return Ja=i,Ja}var Qa,Ah;function Ct(){if(Ah)return Qa;Ah=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return Qa=e,Qa}var eo,Ph;function cf(){if(Ph)return eo;Ph=1;var e=xt(),t=Ct(),r="[object AsyncFunction]",n="[object Function]",i="[object GeneratorFunction]",a="[object Proxy]";function o(u){if(!t(u))return!1;var c=e(u);return c==n||c==i||c==r||c==a}return eo=o,eo}var to,Th;function fw(){if(Th)return to;Th=1;var e=ot(),t=e["__core-js_shared__"];return to=t,to}var ro,Eh;function hw(){if(Eh)return ro;Eh=1;var e=fw(),t=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function r(n){return!!t&&t in n}return ro=r,ro}var no,jh;function Jg(){if(jh)return no;jh=1;var e=Function.prototype,t=e.toString;function r(n){if(n!=null){try{return t.call(n)}catch{}try{return n+""}catch{}}return""}return no=r,no}var io,Mh;function pw(){if(Mh)return io;Mh=1;var e=cf(),t=hw(),r=Ct(),n=Jg(),i=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,o=Function.prototype,u=Object.prototype,c=o.toString,s=u.hasOwnProperty,f=RegExp("^"+c.call(s).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function l(h){if(!r(h)||t(h))return!1;var d=e(h)?f:a;return d.test(n(h))}return io=l,io}var ao,Ch;function dw(){if(Ch)return ao;Ch=1;function e(t,r){return t?.[r]}return ao=e,ao}var oo,$h;function Qt(){if($h)return oo;$h=1;var e=pw(),t=dw();function r(n,i){var a=t(n,i);return e(a)?a:void 0}return oo=r,oo}var uo,Ih;function ha(){if(Ih)return uo;Ih=1;var e=Qt(),t=e(Object,"create");return uo=t,uo}var co,Rh;function vw(){if(Rh)return co;Rh=1;var e=ha();function t(){this.__data__=e?e(null):{},this.size=0}return co=t,co}var so,kh;function yw(){if(kh)return so;kh=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return so=e,so}var lo,Dh;function mw(){if(Dh)return lo;Dh=1;var e=ha(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function i(a){var o=this.__data__;if(e){var u=o[a];return u===t?void 0:u}return n.call(o,a)?o[a]:void 0}return lo=i,lo}var fo,Nh;function gw(){if(Nh)return fo;Nh=1;var e=ha(),t=Object.prototype,r=t.hasOwnProperty;function n(i){var a=this.__data__;return e?a[i]!==void 0:r.call(a,i)}return fo=n,fo}var ho,qh;function bw(){if(qh)return ho;qh=1;var e=ha(),t="__lodash_hash_undefined__";function r(n,i){var a=this.__data__;return this.size+=this.has(n)?0:1,a[n]=e&&i===void 0?t:i,this}return ho=r,ho}var po,Bh;function xw(){if(Bh)return po;Bh=1;var e=vw(),t=yw(),r=mw(),n=gw(),i=bw();function a(o){var u=-1,c=o==null?0:o.length;for(this.clear();++u-1}return xo=t,xo}var wo,Gh;function Aw(){if(Gh)return wo;Gh=1;var e=pa();function t(r,n){var i=this.__data__,a=e(i,r);return a<0?(++this.size,i.push([r,n])):i[a][1]=n,this}return wo=t,wo}var Oo,Kh;function da(){if(Kh)return Oo;Kh=1;var e=ww(),t=Ow(),r=_w(),n=Sw(),i=Aw();function a(o){var u=-1,c=o==null?0:o.length;for(this.clear();++u0?1:-1},zt=function(t){return Xt(t)&&t.indexOf("%")===t.length-1},q=function(t){return Vw(t)&&!Br(t)},Xw=function(t){return J(t)},we=function(t){return q(t)||Xt(t)},Yw=0,Kn=function(t){var r=++Yw;return"".concat(t||"").concat(r)},Je=function(t,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!q(t)&&!Xt(t))return n;var a;if(zt(t)){var o=t.indexOf("%");a=r*parseFloat(t.slice(0,o))/100}else a=+t;return Br(a)&&(a=n),i&&a>r&&(a=r),a},Pt=function(t){if(!t)return null;var r=Object.keys(t);return r&&r.length?t[r[0]]:null},Zw=function(t){if(!Array.isArray(t))return!1;for(var r=t.length,n={},i=0;i=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function iO(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function Hs(e){"@babel/helpers - typeof";return Hs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Hs(e)}var wp={click:"onClick",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",mouseout:"onMouseOut",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",touchcancel:"onTouchCancel",touchend:"onTouchEnd",touchmove:"onTouchMove",touchstart:"onTouchStart",contextmenu:"onContextMenu",dblclick:"onDoubleClick"},pt=function(t){return typeof t=="string"?t:t?t.displayName||t.name||"Component":""},Op=null,Vo=null,vf=function e(t){if(t===Op&&Array.isArray(Vo))return Vo;var r=[];return N.Children.forEach(t,function(n){J(n)||(Uw.isFragment(n)?r=r.concat(e(n.props.children)):r.push(n))}),Vo=r,Op=t,r};function Qe(e,t){var r=[],n=[];return Array.isArray(t)?n=t.map(function(i){return pt(i)}):n=[pt(t)],vf(e).forEach(function(i){var a=He(i,"type.displayName")||He(i,"type.name");n.indexOf(a)!==-1&&r.push(i)}),r}function Ne(e,t){var r=Qe(e,t);return r&&r[0]}var _p=function(t){if(!t||!t.props)return!1;var r=t.props,n=r.width,i=r.height;return!(!q(n)||n<=0||!q(i)||i<=0)},aO=["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColormatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-url","foreignObject","g","glyph","glyphRef","hkern","image","line","lineGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"],oO=function(t){return t&&t.type&&Xt(t.type)&&aO.indexOf(t.type)>=0},uO=function(t){return t&&Hs(t)==="object"&&"clipDot"in t},cO=function(t,r,n,i){var a,o=(a=Ko?.[i])!==null&&a!==void 0?a:[];return r.startsWith("data-")||!V(t)&&(i&&o.includes(r)||eO.includes(r))||n&&df.includes(r)},Z=function(t,r,n){if(!t||typeof t=="function"||typeof t=="boolean")return null;var i=t;if(N.isValidElement(t)&&(i=t.props),!qr(i))return null;var a={};return Object.keys(i).forEach(function(o){var u;cO((u=i)===null||u===void 0?void 0:u[o],o,r,n)&&(a[o]=i[o])}),a},Gs=function e(t,r){if(t===r)return!0;var n=N.Children.count(t);if(n!==N.Children.count(r))return!1;if(n===0)return!0;if(n===1)return Sp(Array.isArray(t)?t[0]:t,Array.isArray(r)?r[0]:r);for(var i=0;i=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function pO(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function Vs(e){var t=e.children,r=e.width,n=e.height,i=e.viewBox,a=e.className,o=e.style,u=e.title,c=e.desc,s=hO(e,fO),f=i||{width:r,height:n,x:0,y:0},l=ee("recharts-surface",a);return T.createElement("svg",Ks({},Z(s,!0,"svg"),{className:l,width:r,height:n,style:o,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height)}),T.createElement("title",null,u),T.createElement("desc",null,c),t)}var dO=["children","className"];function Xs(){return Xs=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function yO(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}var fe=T.forwardRef(function(e,t){var r=e.children,n=e.className,i=vO(e,dO),a=ee("recharts-layer",n);return T.createElement("g",Xs({className:a},Z(i,!0),{ref:t}),r)}),dt=function(t,r){for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;aa?0:a+r),n=n>a?a:n,n<0&&(n+=a),a=r>n?0:n-r>>>0,r>>>=0;for(var o=Array(a);++i=a?r:e(r,n,i)}return Yo=t,Yo}var Zo,Ep;function ib(){if(Ep)return Zo;Ep=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",i=t+r+n,a="\\ufe0e\\ufe0f",o="\\u200d",u=RegExp("["+o+e+i+a+"]");function c(s){return u.test(s)}return Zo=c,Zo}var Jo,jp;function bO(){if(jp)return Jo;jp=1;function e(t){return t.split("")}return Jo=e,Jo}var Qo,Mp;function xO(){if(Mp)return Qo;Mp=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",i=t+r+n,a="\\ufe0e\\ufe0f",o="["+e+"]",u="["+i+"]",c="\\ud83c[\\udffb-\\udfff]",s="(?:"+u+"|"+c+")",f="[^"+e+"]",l="(?:\\ud83c[\\udde6-\\uddff]){2}",h="[\\ud800-\\udbff][\\udc00-\\udfff]",d="\\u200d",m=s+"?",v="["+a+"]?",p="(?:"+d+"(?:"+[f,l,h].join("|")+")"+v+m+")*",b=v+m+p,x="(?:"+[f+u+"?",u,l,h,o].join("|")+")",w=RegExp(c+"(?="+c+")|"+x+b,"g");function O(y){return y.match(w)||[]}return Qo=O,Qo}var eu,Cp;function wO(){if(Cp)return eu;Cp=1;var e=bO(),t=ib(),r=xO();function n(i){return t(i)?r(i):e(i)}return eu=n,eu}var tu,$p;function OO(){if($p)return tu;$p=1;var e=gO(),t=ib(),r=wO(),n=eb();function i(a){return function(o){o=n(o);var u=t(o)?r(o):void 0,c=u?u[0]:o.charAt(0),s=u?e(u,1).join(""):o.slice(1);return c[a]()+s}}return tu=i,tu}var ru,Ip;function _O(){if(Ip)return ru;Ip=1;var e=OO(),t=e("toUpperCase");return ru=t,ru}var SO=_O();const ma=ue(SO);function oe(e){return function(){return e}}const ab=Math.cos,gi=Math.sin,et=Math.sqrt,bi=Math.PI,ga=2*bi,Ys=Math.PI,Zs=2*Ys,Lt=1e-6,AO=Zs-Lt;function ob(e){this._+=e[0];for(let t=1,r=e.length;t=0))throw new Error(`invalid digits: ${e}`);if(t>15)return ob;const r=10**t;return function(n){this._+=n[0];for(let i=1,a=n.length;iLt)if(!(Math.abs(l*c-s*f)>Lt)||!a)this._append`L${this._x1=t},${this._y1=r}`;else{let d=n-o,m=i-u,v=c*c+s*s,p=d*d+m*m,b=Math.sqrt(v),x=Math.sqrt(h),w=a*Math.tan((Ys-Math.acos((v+h-p)/(2*b*x)))/2),O=w/x,y=w/b;Math.abs(O-1)>Lt&&this._append`L${t+O*f},${r+O*l}`,this._append`A${a},${a},0,0,${+(l*d>f*m)},${this._x1=t+y*c},${this._y1=r+y*s}`}}arc(t,r,n,i,a,o){if(t=+t,r=+r,n=+n,o=!!o,n<0)throw new Error(`negative radius: ${n}`);let u=n*Math.cos(i),c=n*Math.sin(i),s=t+u,f=r+c,l=1^o,h=o?i-a:a-i;this._x1===null?this._append`M${s},${f}`:(Math.abs(this._x1-s)>Lt||Math.abs(this._y1-f)>Lt)&&this._append`L${s},${f}`,n&&(h<0&&(h=h%Zs+Zs),h>AO?this._append`A${n},${n},0,1,${l},${t-u},${r-c}A${n},${n},0,1,${l},${this._x1=s},${this._y1=f}`:h>Lt&&this._append`A${n},${n},0,${+(h>=Ys)},${l},${this._x1=t+n*Math.cos(a)},${this._y1=r+n*Math.sin(a)}`)}rect(t,r,n,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+r}h${n=+n}v${+i}h${-n}Z`}toString(){return this._}}function yf(e){let t=3;return e.digits=function(r){if(!arguments.length)return t;if(r==null)t=null;else{const n=Math.floor(r);if(!(n>=0))throw new RangeError(`invalid digits: ${r}`);t=n}return e},()=>new TO(t)}function mf(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function ub(e){this._context=e}ub.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function ba(e){return new ub(e)}function cb(e){return e[0]}function sb(e){return e[1]}function lb(e,t){var r=oe(!0),n=null,i=ba,a=null,o=yf(u);e=typeof e=="function"?e:e===void 0?cb:oe(e),t=typeof t=="function"?t:t===void 0?sb:oe(t);function u(c){var s,f=(c=mf(c)).length,l,h=!1,d;for(n==null&&(a=i(d=o())),s=0;s<=f;++s)!(s=d;--m)u.point(w[m],O[m]);u.lineEnd(),u.areaEnd()}b&&(w[h]=+e(p,h,l),O[h]=+t(p,h,l),u.point(n?+n(p,h,l):w[h],r?+r(p,h,l):O[h]))}if(x)return u=null,x+""||null}function f(){return lb().defined(i).curve(o).context(a)}return s.x=function(l){return arguments.length?(e=typeof l=="function"?l:oe(+l),n=null,s):e},s.x0=function(l){return arguments.length?(e=typeof l=="function"?l:oe(+l),s):e},s.x1=function(l){return arguments.length?(n=l==null?null:typeof l=="function"?l:oe(+l),s):n},s.y=function(l){return arguments.length?(t=typeof l=="function"?l:oe(+l),r=null,s):t},s.y0=function(l){return arguments.length?(t=typeof l=="function"?l:oe(+l),s):t},s.y1=function(l){return arguments.length?(r=l==null?null:typeof l=="function"?l:oe(+l),s):r},s.lineX0=s.lineY0=function(){return f().x(e).y(t)},s.lineY1=function(){return f().x(e).y(r)},s.lineX1=function(){return f().x(n).y(t)},s.defined=function(l){return arguments.length?(i=typeof l=="function"?l:oe(!!l),s):i},s.curve=function(l){return arguments.length?(o=l,a!=null&&(u=o(a)),s):o},s.context=function(l){return arguments.length?(l==null?a=u=null:u=o(a=l),s):a},s}class fb{constructor(t,r){this._context=t,this._x=r}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,r){switch(t=+t,r=+r,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,r):this._context.moveTo(t,r);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,r,t,r):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+r)/2,t,this._y0,t,r);break}}this._x0=t,this._y0=r}}function EO(e){return new fb(e,!0)}function jO(e){return new fb(e,!1)}const gf={draw(e,t){const r=et(t/bi);e.moveTo(r,0),e.arc(0,0,r,0,ga)}},MO={draw(e,t){const r=et(t/5)/2;e.moveTo(-3*r,-r),e.lineTo(-r,-r),e.lineTo(-r,-3*r),e.lineTo(r,-3*r),e.lineTo(r,-r),e.lineTo(3*r,-r),e.lineTo(3*r,r),e.lineTo(r,r),e.lineTo(r,3*r),e.lineTo(-r,3*r),e.lineTo(-r,r),e.lineTo(-3*r,r),e.closePath()}},hb=et(1/3),CO=hb*2,$O={draw(e,t){const r=et(t/CO),n=r*hb;e.moveTo(0,-r),e.lineTo(n,0),e.lineTo(0,r),e.lineTo(-n,0),e.closePath()}},IO={draw(e,t){const r=et(t),n=-r/2;e.rect(n,n,r,r)}},RO=.8908130915292852,pb=gi(bi/10)/gi(7*bi/10),kO=gi(ga/10)*pb,DO=-ab(ga/10)*pb,NO={draw(e,t){const r=et(t*RO),n=kO*r,i=DO*r;e.moveTo(0,-r),e.lineTo(n,i);for(let a=1;a<5;++a){const o=ga*a/5,u=ab(o),c=gi(o);e.lineTo(c*r,-u*r),e.lineTo(u*n-c*i,c*n+u*i)}e.closePath()}},nu=et(3),qO={draw(e,t){const r=-et(t/(nu*3));e.moveTo(0,r*2),e.lineTo(-nu*r,-r),e.lineTo(nu*r,-r),e.closePath()}},Le=-.5,Fe=et(3)/2,Js=1/et(12),BO=(Js/2+1)*3,LO={draw(e,t){const r=et(t/BO),n=r/2,i=r*Js,a=n,o=r*Js+r,u=-a,c=o;e.moveTo(n,i),e.lineTo(a,o),e.lineTo(u,c),e.lineTo(Le*n-Fe*i,Fe*n+Le*i),e.lineTo(Le*a-Fe*o,Fe*a+Le*o),e.lineTo(Le*u-Fe*c,Fe*u+Le*c),e.lineTo(Le*n+Fe*i,Le*i-Fe*n),e.lineTo(Le*a+Fe*o,Le*o-Fe*a),e.lineTo(Le*u+Fe*c,Le*c-Fe*u),e.closePath()}};function FO(e,t){let r=null,n=yf(i);e=typeof e=="function"?e:oe(e||gf),t=typeof t=="function"?t:oe(t===void 0?64:+t);function i(){let a;if(r||(r=a=n()),e.apply(this,arguments).draw(r,+t.apply(this,arguments)),a)return r=null,a+""||null}return i.type=function(a){return arguments.length?(e=typeof a=="function"?a:oe(a),i):e},i.size=function(a){return arguments.length?(t=typeof a=="function"?a:oe(+a),i):t},i.context=function(a){return arguments.length?(r=a??null,i):r},i}function xi(){}function wi(e,t,r){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+r)/6)}function db(e){this._context=e}db.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:wi(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:wi(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function zO(e){return new db(e)}function vb(e){this._context=e}vb.prototype={areaStart:xi,areaEnd:xi,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:wi(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function WO(e){return new vb(e)}function yb(e){this._context=e}yb.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var r=(this._x0+4*this._x1+e)/6,n=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(r,n):this._context.moveTo(r,n);break;case 3:this._point=4;default:wi(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function UO(e){return new yb(e)}function mb(e){this._context=e}mb.prototype={areaStart:xi,areaEnd:xi,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function HO(e){return new mb(e)}function Rp(e){return e<0?-1:1}function kp(e,t,r){var n=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(n||i<0&&-0),o=(r-e._y1)/(i||n<0&&-0),u=(a*i+o*n)/(n+i);return(Rp(a)+Rp(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(u))||0}function Dp(e,t){var r=e._x1-e._x0;return r?(3*(e._y1-e._y0)/r-t)/2:t}function iu(e,t,r){var n=e._x0,i=e._y0,a=e._x1,o=e._y1,u=(a-n)/3;e._context.bezierCurveTo(n+u,i+u*t,a-u,o-u*r,a,o)}function Oi(e){this._context=e}Oi.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:iu(this,this._t0,Dp(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var r=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,iu(this,Dp(this,r=kp(this,e,t)),r);break;default:iu(this,this._t0,r=kp(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=r}}};function gb(e){this._context=new bb(e)}(gb.prototype=Object.create(Oi.prototype)).point=function(e,t){Oi.prototype.point.call(this,t,e)};function bb(e){this._context=e}bb.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,r,n,i,a){this._context.bezierCurveTo(t,e,n,r,a,i)}};function GO(e){return new Oi(e)}function KO(e){return new gb(e)}function xb(e){this._context=e}xb.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,r=e.length;if(r)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),r===2)this._context.lineTo(e[1],t[1]);else for(var n=Np(e),i=Np(t),a=0,o=1;o=0;--t)i[t]=(o[t]-i[t+1])/a[t];for(a[r-1]=(e[r]+i[r-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var r=this._x*(1-this._t)+e*this._t;this._context.lineTo(r,this._y),this._context.lineTo(r,t)}break}}this._x=e,this._y=t}};function XO(e){return new xa(e,.5)}function YO(e){return new xa(e,0)}function ZO(e){return new xa(e,1)}function vr(e,t){if((o=e.length)>1)for(var r=1,n,i,a=e[t[0]],o,u=a.length;r=0;)r[t]=t;return r}function JO(e,t){return e[t]}function QO(e){const t=[];return t.key=e,t}function e1(){var e=oe([]),t=Qs,r=vr,n=JO;function i(a){var o=Array.from(e.apply(this,arguments),QO),u,c=o.length,s=-1,f;for(const l of a)for(u=0,++s;u0){for(var r,n,i=0,a=e[0].length,o;i0){for(var r=0,n=e[t[0]],i,a=n.length;r0)||!((a=(i=e[t[0]]).length)>0))){for(var r=0,n=1,i,a,o;n=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function s1(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}var wb={symbolCircle:gf,symbolCross:MO,symbolDiamond:$O,symbolSquare:IO,symbolStar:NO,symbolTriangle:qO,symbolWye:LO},l1=Math.PI/180,f1=function(t){var r="symbol".concat(ma(t));return wb[r]||gf},h1=function(t,r,n){if(r==="area")return t;switch(n){case"cross":return 5*t*t/9;case"diamond":return .5*t*t/Math.sqrt(3);case"square":return t*t;case"star":{var i=18*l1;return 1.25*t*t*(Math.tan(i)-Math.tan(i*2)*Math.pow(Math.tan(i),2))}case"triangle":return Math.sqrt(3)*t*t/4;case"wye":return(21-10*Math.sqrt(3))*t*t/8;default:return Math.PI*t*t/4}},p1=function(t,r){wb["symbol".concat(ma(t))]=r},bf=function(t){var r=t.type,n=r===void 0?"circle":r,i=t.size,a=i===void 0?64:i,o=t.sizeType,u=o===void 0?"area":o,c=c1(t,i1),s=Bp(Bp({},c),{},{type:n,size:a,sizeType:u}),f=function(){var p=f1(n),b=FO().type(p).size(h1(a,u,n));return b()},l=s.className,h=s.cx,d=s.cy,m=Z(s,!0);return h===+h&&d===+d&&a===+a?T.createElement("path",el({},m,{className:ee("recharts-symbols",l),transform:"translate(".concat(h,", ").concat(d,")"),d:f()})):null};bf.registerSymbol=p1;function yr(e){"@babel/helpers - typeof";return yr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yr(e)}function tl(){return tl=Object.assign?Object.assign.bind():function(e){for(var t=1;t`);var x=d.inactive?s:d.color;return T.createElement("li",tl({className:p,style:l,key:"legend-item-".concat(m)},mi(n.props,d,m)),T.createElement(Vs,{width:o,height:o,viewBox:f,style:h},n.renderIcon(d)),T.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},v?v(b,d,m):b))})}},{key:"render",value:function(){var n=this.props,i=n.payload,a=n.layout,o=n.align;if(!i||!i.length)return null;var u={padding:0,margin:0,textAlign:a==="horizontal"?o:"left"};return T.createElement("ul",{className:"recharts-default-legend",style:u},this.renderItems())}}])})(N.PureComponent);fn(xf,"displayName","Legend");fn(xf,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var au,Fp;function _1(){if(Fp)return au;Fp=1;var e=da();function t(){this.__data__=new e,this.size=0}return au=t,au}var ou,zp;function S1(){if(zp)return ou;zp=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return ou=e,ou}var uu,Wp;function A1(){if(Wp)return uu;Wp=1;function e(t){return this.__data__.get(t)}return uu=e,uu}var cu,Up;function P1(){if(Up)return cu;Up=1;function e(t){return this.__data__.has(t)}return cu=e,cu}var su,Hp;function T1(){if(Hp)return su;Hp=1;var e=da(),t=lf(),r=ff(),n=200;function i(a,o){var u=this.__data__;if(u instanceof e){var c=u.__data__;if(!t||c.lengthd))return!1;var v=l.get(o),p=l.get(u);if(v&&p)return v==u&&p==o;var b=-1,x=!0,w=c&i?new e:void 0;for(l.set(o,u),l.set(u,o);++b-1&&n%1==0&&n-1&&r%1==0&&r<=e}return Cu=t,Cu}var $u,vd;function L1(){if(vd)return $u;vd=1;var e=xt(),t=Sf(),r=wt(),n="[object Arguments]",i="[object Array]",a="[object Boolean]",o="[object Date]",u="[object Error]",c="[object Function]",s="[object Map]",f="[object Number]",l="[object Object]",h="[object RegExp]",d="[object Set]",m="[object String]",v="[object WeakMap]",p="[object ArrayBuffer]",b="[object DataView]",x="[object Float32Array]",w="[object Float64Array]",O="[object Int8Array]",y="[object Int16Array]",g="[object Int32Array]",_="[object Uint8Array]",S="[object Uint8ClampedArray]",P="[object Uint16Array]",M="[object Uint32Array]",A={};A[x]=A[w]=A[O]=A[y]=A[g]=A[_]=A[S]=A[P]=A[M]=!0,A[n]=A[i]=A[p]=A[a]=A[b]=A[o]=A[u]=A[c]=A[s]=A[f]=A[l]=A[h]=A[d]=A[m]=A[v]=!1;function E(j){return r(j)&&t(j.length)&&!!A[e(j)]}return $u=E,$u}var Iu,yd;function Cb(){if(yd)return Iu;yd=1;function e(t){return function(r){return t(r)}}return Iu=e,Iu}var rn={exports:{}};rn.exports;var md;function F1(){return md||(md=1,(function(e,t){var r=Zg(),n=t&&!t.nodeType&&t,i=n&&!0&&e&&!e.nodeType&&e,a=i&&i.exports===n,o=a&&r.process,u=(function(){try{var c=i&&i.require&&i.require("util").types;return c||o&&o.binding&&o.binding("util")}catch{}})();e.exports=u})(rn,rn.exports)),rn.exports}var Ru,gd;function $b(){if(gd)return Ru;gd=1;var e=L1(),t=Cb(),r=F1(),n=r&&r.isTypedArray,i=n?t(n):e;return Ru=i,Ru}var ku,bd;function z1(){if(bd)return ku;bd=1;var e=N1(),t=Of(),r=Re(),n=Mb(),i=_f(),a=$b(),o=Object.prototype,u=o.hasOwnProperty;function c(s,f){var l=r(s),h=!l&&t(s),d=!l&&!h&&n(s),m=!l&&!h&&!d&&a(s),v=l||h||d||m,p=v?e(s.length,String):[],b=p.length;for(var x in s)(f||u.call(s,x))&&!(v&&(x=="length"||d&&(x=="offset"||x=="parent")||m&&(x=="buffer"||x=="byteLength"||x=="byteOffset")||i(x,b)))&&p.push(x);return p}return ku=c,ku}var Du,xd;function W1(){if(xd)return Du;xd=1;var e=Object.prototype;function t(r){var n=r&&r.constructor,i=typeof n=="function"&&n.prototype||e;return r===i}return Du=t,Du}var Nu,wd;function Ib(){if(wd)return Nu;wd=1;function e(t,r){return function(n){return t(r(n))}}return Nu=e,Nu}var qu,Od;function U1(){if(Od)return qu;Od=1;var e=Ib(),t=e(Object.keys,Object);return qu=t,qu}var Bu,_d;function H1(){if(_d)return Bu;_d=1;var e=W1(),t=U1(),r=Object.prototype,n=r.hasOwnProperty;function i(a){if(!e(a))return t(a);var o=[];for(var u in Object(a))n.call(a,u)&&u!="constructor"&&o.push(u);return o}return Bu=i,Bu}var Lu,Sd;function Vn(){if(Sd)return Lu;Sd=1;var e=cf(),t=Sf();function r(n){return n!=null&&t(n.length)&&!e(n)}return Lu=r,Lu}var Fu,Ad;function wa(){if(Ad)return Fu;Ad=1;var e=z1(),t=H1(),r=Vn();function n(i){return r(i)?e(i):t(i)}return Fu=n,Fu}var zu,Pd;function G1(){if(Pd)return zu;Pd=1;var e=I1(),t=D1(),r=wa();function n(i){return e(i,r,t)}return zu=n,zu}var Wu,Td;function K1(){if(Td)return Wu;Td=1;var e=G1(),t=1,r=Object.prototype,n=r.hasOwnProperty;function i(a,o,u,c,s,f){var l=u&t,h=e(a),d=h.length,m=e(o),v=m.length;if(d!=v&&!l)return!1;for(var p=d;p--;){var b=h[p];if(!(l?b in o:n.call(o,b)))return!1}var x=f.get(a),w=f.get(o);if(x&&w)return x==o&&w==a;var O=!0;f.set(a,o),f.set(o,a);for(var y=l;++p-1}return vc=t,vc}var yc,ev;function p_(){if(ev)return yc;ev=1;function e(t,r,n){for(var i=-1,a=t==null?0:t.length;++i=o){var b=s?null:i(c);if(b)return a(b);m=!1,h=n,p=new e}else p=s?[]:v;e:for(;++l=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function E_(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function j_(e){return e.value}function M_(e,t){if(T.isValidElement(e))return T.cloneElement(e,t);if(typeof e=="function")return T.createElement(e,t);t.ref;var r=T_(t,b_);return T.createElement(xf,r)}var cv=1,hr=(function(e){function t(){var r;x_(this,t);for(var n=arguments.length,i=new Array(n),a=0;acv||Math.abs(i.height-this.lastBoundingBox.height)>cv)&&(this.lastBoundingBox.width=i.width,this.lastBoundingBox.height=i.height,n&&n(i)):(this.lastBoundingBox.width!==-1||this.lastBoundingBox.height!==-1)&&(this.lastBoundingBox.width=-1,this.lastBoundingBox.height=-1,n&&n(null))}},{key:"getBBoxSnapshot",value:function(){return this.lastBoundingBox.width>=0&&this.lastBoundingBox.height>=0?ut({},this.lastBoundingBox):{width:0,height:0}}},{key:"getDefaultPosition",value:function(n){var i=this.props,a=i.layout,o=i.align,u=i.verticalAlign,c=i.margin,s=i.chartWidth,f=i.chartHeight,l,h;if(!n||(n.left===void 0||n.left===null)&&(n.right===void 0||n.right===null))if(o==="center"&&a==="vertical"){var d=this.getBBoxSnapshot();l={left:((s||0)-d.width)/2}}else l=o==="right"?{right:c&&c.right||0}:{left:c&&c.left||0};if(!n||(n.top===void 0||n.top===null)&&(n.bottom===void 0||n.bottom===null))if(u==="middle"){var m=this.getBBoxSnapshot();h={top:((f||0)-m.height)/2}}else h=u==="bottom"?{bottom:c&&c.bottom||0}:{top:c&&c.top||0};return ut(ut({},l),h)}},{key:"render",value:function(){var n=this,i=this.props,a=i.content,o=i.width,u=i.height,c=i.wrapperStyle,s=i.payloadUniqBy,f=i.payload,l=ut(ut({position:"absolute",width:o||"auto",height:u||"auto"},this.getDefaultPosition(c)),c);return T.createElement("div",{className:"recharts-legend-wrapper",style:l,ref:function(d){n.wrapperNode=d}},M_(a,ut(ut({},this.props),{},{payload:qb(f,s,j_)})))}}],[{key:"getWithHeight",value:function(n,i){var a=ut(ut({},this.defaultProps),n.props),o=a.layout;return o==="vertical"&&q(n.props.height)?{height:n.props.height}:o==="horizontal"?{width:n.props.width||i}:null}}])})(N.PureComponent);Oa(hr,"displayName","Legend");Oa(hr,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var wc,sv;function C_(){if(sv)return wc;sv=1;var e=Gn(),t=Of(),r=Re(),n=e?e.isConcatSpreadable:void 0;function i(a){return r(a)||t(a)||!!(n&&a&&a[n])}return wc=i,wc}var Oc,lv;function Fb(){if(lv)return Oc;lv=1;var e=jb(),t=C_();function r(n,i,a,o,u){var c=-1,s=n.length;for(a||(a=t),u||(u=[]);++c0&&a(f)?i>1?r(f,i-1,a,o,u):e(u,f):o||(u[u.length]=f)}return u}return Oc=r,Oc}var _c,fv;function $_(){if(fv)return _c;fv=1;function e(t){return function(r,n,i){for(var a=-1,o=Object(r),u=i(r),c=u.length;c--;){var s=u[t?c:++a];if(n(o[s],s,o)===!1)break}return r}}return _c=e,_c}var Sc,hv;function I_(){if(hv)return Sc;hv=1;var e=$_(),t=e();return Sc=t,Sc}var Ac,pv;function zb(){if(pv)return Ac;pv=1;var e=I_(),t=wa();function r(n,i){return n&&e(n,i,t)}return Ac=r,Ac}var Pc,dv;function R_(){if(dv)return Pc;dv=1;var e=Vn();function t(r,n){return function(i,a){if(i==null)return i;if(!e(i))return r(i,a);for(var o=i.length,u=n?o:-1,c=Object(i);(n?u--:++un||u&&c&&f&&!s&&!l||a&&c&&f||!i&&f||!o)return 1;if(!a&&!u&&!l&&r=s)return f;var l=i[a];return f*(l=="desc"?-1:1)}}return r.index-n.index}return Cc=t,Cc}var $c,xv;function q_(){if(xv)return $c;xv=1;var e=hf(),t=pf(),r=$t(),n=Wb(),i=k_(),a=Cb(),o=N_(),u=Lr(),c=Re();function s(f,l,h){l.length?l=e(l,function(v){return c(v)?function(p){return t(p,v.length===1?v[0]:v)}:v}):l=[u];var d=-1;l=e(l,a(r));var m=n(f,function(v,p,b){var x=e(l,function(w){return w(v)});return{criteria:x,index:++d,value:v}});return i(m,function(v,p){return o(v,p,h)})}return $c=s,$c}var Ic,wv;function B_(){if(wv)return Ic;wv=1;function e(t,r,n){switch(n.length){case 0:return t.call(r);case 1:return t.call(r,n[0]);case 2:return t.call(r,n[0],n[1]);case 3:return t.call(r,n[0],n[1],n[2])}return t.apply(r,n)}return Ic=e,Ic}var Rc,Ov;function L_(){if(Ov)return Rc;Ov=1;var e=B_(),t=Math.max;function r(n,i,a){return i=t(i===void 0?n.length-1:i,0),function(){for(var o=arguments,u=-1,c=t(o.length-i,0),s=Array(c);++u0){if(++a>=e)return arguments[0]}else a=0;return i.apply(void 0,arguments)}}return qc=n,qc}var Bc,Tv;function U_(){if(Tv)return Bc;Tv=1;var e=z_(),t=W_(),r=t(e);return Bc=r,Bc}var Lc,Ev;function H_(){if(Ev)return Lc;Ev=1;var e=Lr(),t=L_(),r=U_();function n(i,a){return r(t(i,a,e),i+"")}return Lc=n,Lc}var Fc,jv;function _a(){if(jv)return Fc;jv=1;var e=sf(),t=Vn(),r=_f(),n=Ct();function i(a,o,u){if(!n(u))return!1;var c=typeof o;return(c=="number"?t(u)&&r(o,u.length):c=="string"&&o in u)?e(u[o],a):!1}return Fc=i,Fc}var zc,Mv;function G_(){if(Mv)return zc;Mv=1;var e=Fb(),t=q_(),r=H_(),n=_a(),i=r(function(a,o){if(a==null)return[];var u=o.length;return u>1&&n(a,o[0],o[1])?o=[]:u>2&&n(o[0],o[1],o[2])&&(o=[o[0]]),t(a,e(o,1),[])});return zc=i,zc}var K_=G_();const Tf=ue(K_);function hn(e){"@babel/helpers - typeof";return hn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hn(e)}function il(){return il=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r=t.x),"".concat(Gr,"-left"),q(r)&&t&&q(t.x)&&r=t.y),"".concat(Gr,"-top"),q(n)&&t&&q(t.y)&&nv?Math.max(f,c[n]):Math.max(l,c[n])}function cS(e){var t=e.translateX,r=e.translateY,n=e.useTranslate3d;return{transform:n?"translate3d(".concat(t,"px, ").concat(r,"px, 0)"):"translate(".concat(t,"px, ").concat(r,"px)")}}function sS(e){var t=e.allowEscapeViewBox,r=e.coordinate,n=e.offsetTopLeft,i=e.position,a=e.reverseDirection,o=e.tooltipBox,u=e.useTranslate3d,c=e.viewBox,s,f,l;return o.height>0&&o.width>0&&r?(f=Iv({allowEscapeViewBox:t,coordinate:r,key:"x",offsetTopLeft:n,position:i,reverseDirection:a,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),l=Iv({allowEscapeViewBox:t,coordinate:r,key:"y",offsetTopLeft:n,position:i,reverseDirection:a,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),s=cS({translateX:f,translateY:l,useTranslate3d:u})):s=oS,{cssProperties:s,cssClasses:uS({translateX:f,translateY:l,coordinate:r})}}function gr(e){"@babel/helpers - typeof";return gr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},gr(e)}function Rv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function kv(e){for(var t=1;tDv||Math.abs(n.height-this.state.lastBoundingBox.height)>Dv)&&this.setState({lastBoundingBox:{width:n.width,height:n.height}})}else(this.state.lastBoundingBox.width!==-1||this.state.lastBoundingBox.height!==-1)&&this.setState({lastBoundingBox:{width:-1,height:-1}})}},{key:"componentDidMount",value:function(){document.addEventListener("keydown",this.handleKeyDown),this.updateBBox()}},{key:"componentWillUnmount",value:function(){document.removeEventListener("keydown",this.handleKeyDown)}},{key:"componentDidUpdate",value:function(){var n,i;this.props.active&&this.updateBBox(),this.state.dismissed&&(((n=this.props.coordinate)===null||n===void 0?void 0:n.x)!==this.state.dismissedAtCoordinate.x||((i=this.props.coordinate)===null||i===void 0?void 0:i.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}},{key:"render",value:function(){var n=this,i=this.props,a=i.active,o=i.allowEscapeViewBox,u=i.animationDuration,c=i.animationEasing,s=i.children,f=i.coordinate,l=i.hasPayload,h=i.isAnimationActive,d=i.offset,m=i.position,v=i.reverseDirection,p=i.useTranslate3d,b=i.viewBox,x=i.wrapperStyle,w=sS({allowEscapeViewBox:o,coordinate:f,offsetTopLeft:d,position:m,reverseDirection:v,tooltipBox:this.state.lastBoundingBox,useTranslate3d:p,viewBox:b}),O=w.cssClasses,y=w.cssProperties,g=kv(kv({transition:h&&a?"transform ".concat(u,"ms ").concat(c):void 0},y),{},{pointerEvents:"none",visibility:!this.state.dismissed&&a&&l?"visible":"hidden",position:"absolute",top:0,left:0},x);return T.createElement("div",{tabIndex:-1,className:O,style:g,ref:function(S){n.wrapperNode=S}},s)}}])})(N.PureComponent),bS=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},Fr={isSsr:bS()};function br(e){"@babel/helpers - typeof";return br=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},br(e)}function Nv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function qv(e){for(var t=1;t0;return T.createElement(gS,{allowEscapeViewBox:o,animationDuration:u,animationEasing:c,isAnimationActive:h,active:a,coordinate:f,hasPayload:g,offset:d,position:p,reverseDirection:b,useTranslate3d:x,viewBox:w,wrapperStyle:O},jS(s,qv(qv({},this.props),{},{payload:y})))}}])})(N.PureComponent);Ef(ct,"displayName","Tooltip");Ef(ct,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!Fr.isSsr,itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,viewBox:{x:0,y:0,height:0,width:0},wrapperStyle:{}});var Uc,Bv;function MS(){if(Bv)return Uc;Bv=1;var e=ot(),t=function(){return e.Date.now()};return Uc=t,Uc}var Hc,Lv;function CS(){if(Lv)return Hc;Lv=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return Hc=t,Hc}var Gc,Fv;function $S(){if(Fv)return Gc;Fv=1;var e=CS(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return Gc=r,Gc}var Kc,zv;function Xb(){if(zv)return Kc;zv=1;var e=$S(),t=Ct(),r=Nr(),n=NaN,i=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,o=/^0o[0-7]+$/i,u=parseInt;function c(s){if(typeof s=="number")return s;if(r(s))return n;if(t(s)){var f=typeof s.valueOf=="function"?s.valueOf():s;s=t(f)?f+"":f}if(typeof s!="string")return s===0?s:+s;s=e(s);var l=a.test(s);return l||o.test(s)?u(s.slice(2),l?2:8):i.test(s)?n:+s}return Kc=c,Kc}var Vc,Wv;function IS(){if(Wv)return Vc;Wv=1;var e=Ct(),t=MS(),r=Xb(),n="Expected a function",i=Math.max,a=Math.min;function o(u,c,s){var f,l,h,d,m,v,p=0,b=!1,x=!1,w=!0;if(typeof u!="function")throw new TypeError(n);c=r(c)||0,e(s)&&(b=!!s.leading,x="maxWait"in s,h=x?i(r(s.maxWait)||0,c):h,w="trailing"in s?!!s.trailing:w);function O(j){var I=f,C=l;return f=l=void 0,p=j,d=u.apply(C,I),d}function y(j){return p=j,m=setTimeout(S,c),b?O(j):d}function g(j){var I=j-v,C=j-p,R=c-I;return x?a(R,h-C):R}function _(j){var I=j-v,C=j-p;return v===void 0||I>=c||I<0||x&&C>=h}function S(){var j=t();if(_(j))return P(j);m=setTimeout(S,g(j))}function P(j){return m=void 0,w&&f?O(j):(f=l=void 0,d)}function M(){m!==void 0&&clearTimeout(m),p=0,f=v=l=m=void 0}function A(){return m===void 0?d:P(t())}function E(){var j=t(),I=_(j);if(f=arguments,l=this,v=j,I){if(m===void 0)return y(v);if(x)return clearTimeout(m),m=setTimeout(S,c),O(v)}return m===void 0&&(m=setTimeout(S,c)),d}return E.cancel=M,E.flush=A,E}return Vc=o,Vc}var Xc,Uv;function RS(){if(Uv)return Xc;Uv=1;var e=IS(),t=Ct(),r="Expected a function";function n(i,a,o){var u=!0,c=!0;if(typeof i!="function")throw new TypeError(r);return t(o)&&(u="leading"in o?!!o.leading:u,c="trailing"in o?!!o.trailing:c),e(i,a,{leading:u,maxWait:a,trailing:c})}return Xc=n,Xc}var kS=RS();const Yb=ue(kS);function dn(e){"@babel/helpers - typeof";return dn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},dn(e)}function Hv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function ii(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&(j=Yb(j,v,{trailing:!0,leading:!1}));var I=new ResizeObserver(j),C=y.current.getBoundingClientRect(),R=C.width,D=C.height;return A(R,D),I.observe(y.current),function(){I.disconnect()}},[A,v]);var E=N.useMemo(function(){var j=P.containerWidth,I=P.containerHeight;if(j<0||I<0)return null;dt(zt(o)||zt(c),`The width(%s) and height(%s) are both fixed numbers, - maybe you don't need to use a ResponsiveContainer.`,o,c),dt(!r||r>0,"The aspect(%s) must be greater than zero.",r);var C=zt(o)?j:o,R=zt(c)?I:c;r&&r>0&&(C?R=C/r:R&&(C=R*r),h&&R>h&&(R=h)),dt(C>0||R>0,`The width(%s) and height(%s) of chart should be greater than 0, - please check the style of container, or the props width(%s) and height(%s), - or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the - height and width.`,C,R,o,c,f,l,r);var D=!Array.isArray(d)&&pt(d.type).endsWith("Chart");return T.Children.map(d,function(B){return T.isValidElement(B)?N.cloneElement(B,ii({width:C,height:R},D?{style:ii({height:"100%",width:"100%",maxHeight:R,maxWidth:C},B.props.style)}:{})):B})},[r,d,c,h,l,f,P,o]);return T.createElement("div",{id:p?"".concat(p):void 0,className:ee("recharts-responsive-container",b),style:ii(ii({},O),{},{width:o,height:c,minWidth:f,minHeight:l,maxHeight:h}),ref:y},E)}),Zb=function(t){return null};Zb.displayName="Cell";function vn(e){"@babel/helpers - typeof";return vn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vn(e)}function Kv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function cl(e){for(var t=1;t1&&arguments[1]!==void 0?arguments[1]:{};if(t==null||Fr.isSsr)return{width:0,height:0};var n=XS(r),i=JSON.stringify({text:t,copyStyle:n});if(ar.widthCache[i])return ar.widthCache[i];try{var a=document.getElementById(Vv);a||(a=document.createElement("span"),a.setAttribute("id",Vv),a.setAttribute("aria-hidden","true"),document.body.appendChild(a));var o=cl(cl({},VS),n);Object.assign(a.style,o),a.textContent="".concat(t);var u=a.getBoundingClientRect(),c={width:u.width,height:u.height};return ar.widthCache[i]=c,++ar.cacheCount>KS&&(ar.cacheCount=0,ar.widthCache={}),c}catch{return{width:0,height:0}}},YS=function(t){return{top:t.top+window.scrollY-document.documentElement.clientTop,left:t.left+window.scrollX-document.documentElement.clientLeft}};function yn(e){"@babel/helpers - typeof";return yn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yn(e)}function Ti(e,t){return eA(e)||QS(e,t)||JS(e,t)||ZS()}function ZS(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function JS(e,t){if(e){if(typeof e=="string")return Xv(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Xv(e,t)}}function Xv(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function dA(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function ty(e,t){return gA(e)||mA(e,t)||yA(e,t)||vA()}function vA(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function yA(e,t){if(e){if(typeof e=="string")return ry(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ry(e,t)}}function ry(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&arguments[0]!==void 0?arguments[0]:[];return C.reduce(function(R,D){var B=D.word,L=D.width,U=R[R.length-1];if(U&&(i==null||a||U.width+L+nD.width?R:D})};if(!f)return d;for(var v="…",p=function(C){var R=l.slice(0,C),D=t0({breakAll:s,style:c,children:R+v}).wordsWithComputedWidth,B=h(D),L=B.length>o||m(B).width>Number(i);return[L,B]},b=0,x=l.length-1,w=0,O;b<=x&&w<=l.length-1;){var y=Math.floor((b+x)/2),g=y-1,_=p(g),S=ty(_,2),P=S[0],M=S[1],A=p(y),E=ty(A,1),j=E[0];if(!P&&!j&&(b=y+1),P&&j&&(x=y-1),!P&&j){O=M;break}w++}return O||d},ny=function(t){var r=J(t)?[]:t.toString().split(e0);return[{words:r}]},xA=function(t){var r=t.width,n=t.scaleToFit,i=t.children,a=t.style,o=t.breakAll,u=t.maxLines;if((r||n)&&!Fr.isSsr){var c,s,f=t0({breakAll:o,children:i,style:a});if(f){var l=f.wordsWithComputedWidth,h=f.spaceWidth;c=l,s=h}else return ny(i);return bA({breakAll:o,children:i,maxLines:u,style:a},c,s,r,n)}return ny(i)},iy="#808080",Ei=function(t){var r=t.x,n=r===void 0?0:r,i=t.y,a=i===void 0?0:i,o=t.lineHeight,u=o===void 0?"1em":o,c=t.capHeight,s=c===void 0?"0.71em":c,f=t.scaleToFit,l=f===void 0?!1:f,h=t.textAnchor,d=h===void 0?"start":h,m=t.verticalAnchor,v=m===void 0?"end":m,p=t.fill,b=p===void 0?iy:p,x=ey(t,hA),w=N.useMemo(function(){return xA({breakAll:x.breakAll,children:x.children,maxLines:x.maxLines,scaleToFit:l,style:x.style,width:x.width})},[x.breakAll,x.children,x.maxLines,l,x.style,x.width]),O=x.dx,y=x.dy,g=x.angle,_=x.className,S=x.breakAll,P=ey(x,pA);if(!we(n)||!we(a))return null;var M=n+(q(O)?O:0),A=a+(q(y)?y:0),E;switch(v){case"start":E=Yc("calc(".concat(s,")"));break;case"middle":E=Yc("calc(".concat((w.length-1)/2," * -").concat(u," + (").concat(s," / 2))"));break;default:E=Yc("calc(".concat(w.length-1," * -").concat(u,")"));break}var j=[];if(l){var I=w[0].width,C=x.width;j.push("scale(".concat((q(C)?C/I:1)/I,")"))}return g&&j.push("rotate(".concat(g,", ").concat(M,", ").concat(A,")")),j.length&&(P.transform=j.join(" ")),T.createElement("text",sl({},Z(P,!0),{x:M,y:A,className:ee("recharts-text",_),textAnchor:d,fill:b.includes("url")?iy:b}),w.map(function(R,D){var B=R.words.join(S?"":" ");return T.createElement("tspan",{x:M,dy:D===0?E:u,key:"".concat(B,"-").concat(D)},B)}))};function jt(e,t){return e==null||t==null?NaN:et?1:e>=t?0:NaN}function wA(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}function jf(e){let t,r,n;e.length!==2?(t=jt,r=(u,c)=>jt(e(u),c),n=(u,c)=>e(u)-c):(t=e===jt||e===wA?e:OA,r=e,n=e);function i(u,c,s=0,f=u.length){if(s>>1;r(u[l],c)<0?s=l+1:f=l}while(s>>1;r(u[l],c)<=0?s=l+1:f=l}while(ss&&n(u[l-1],c)>-n(u[l],c)?l-1:l}return{left:i,center:o,right:a}}function OA(){return 0}function r0(e){return e===null?NaN:+e}function*_A(e,t){for(let r of e)r!=null&&(r=+r)>=r&&(yield r)}const SA=jf(jt),Xn=SA.right;jf(r0).center;class ay extends Map{constructor(t,r=TA){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:r}}),t!=null)for(const[n,i]of t)this.set(n,i)}get(t){return super.get(oy(this,t))}has(t){return super.has(oy(this,t))}set(t,r){return super.set(AA(this,t),r)}delete(t){return super.delete(PA(this,t))}}function oy({_intern:e,_key:t},r){const n=t(r);return e.has(n)?e.get(n):r}function AA({_intern:e,_key:t},r){const n=t(r);return e.has(n)?e.get(n):(e.set(n,r),r)}function PA({_intern:e,_key:t},r){const n=t(r);return e.has(n)&&(r=e.get(n),e.delete(n)),r}function TA(e){return e!==null&&typeof e=="object"?e.valueOf():e}function EA(e=jt){if(e===jt)return n0;if(typeof e!="function")throw new TypeError("compare is not a function");return(t,r)=>{const n=e(t,r);return n||n===0?n:(e(r,r)===0)-(e(t,t)===0)}}function n0(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(et?1:0)}const jA=Math.sqrt(50),MA=Math.sqrt(10),CA=Math.sqrt(2);function ji(e,t,r){const n=(t-e)/Math.max(0,r),i=Math.floor(Math.log10(n)),a=n/Math.pow(10,i),o=a>=jA?10:a>=MA?5:a>=CA?2:1;let u,c,s;return i<0?(s=Math.pow(10,-i)/o,u=Math.round(e*s),c=Math.round(t*s),u/st&&--c,s=-s):(s=Math.pow(10,i)*o,u=Math.round(e/s),c=Math.round(t/s),u*st&&--c),c0))return[];if(e===t)return[e];const n=t=i))return[];const u=a-i+1,c=new Array(u);if(n)if(o<0)for(let s=0;s=n)&&(r=n);return r}function cy(e,t){let r;for(const n of e)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function i0(e,t,r=0,n=1/0,i){if(t=Math.floor(t),r=Math.floor(Math.max(0,r)),n=Math.floor(Math.min(e.length-1,n)),!(r<=t&&t<=n))return e;for(i=i===void 0?n0:EA(i);n>r;){if(n-r>600){const c=n-r+1,s=t-r+1,f=Math.log(c),l=.5*Math.exp(2*f/3),h=.5*Math.sqrt(f*l*(c-l)/c)*(s-c/2<0?-1:1),d=Math.max(r,Math.floor(t-s*l/c+h)),m=Math.min(n,Math.floor(t+(c-s)*l/c+h));i0(e,t,d,m,i)}const a=e[t];let o=r,u=n;for(Kr(e,r,t),i(e[n],a)>0&&Kr(e,r,n);o0;)--u}i(e[r],a)===0?Kr(e,r,u):(++u,Kr(e,u,n)),u<=t&&(r=u+1),t<=u&&(n=u-1)}return e}function Kr(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function $A(e,t,r){if(e=Float64Array.from(_A(e)),!(!(n=e.length)||isNaN(t=+t))){if(t<=0||n<2)return cy(e);if(t>=1)return uy(e);var n,i=(n-1)*t,a=Math.floor(i),o=uy(i0(e,a).subarray(0,a+1)),u=cy(e.subarray(a+1));return o+(u-o)*(i-a)}}function IA(e,t,r=r0){if(!(!(n=e.length)||isNaN(t=+t))){if(t<=0||n<2)return+r(e[0],0,e);if(t>=1)return+r(e[n-1],n-1,e);var n,i=(n-1)*t,a=Math.floor(i),o=+r(e[a],a,e),u=+r(e[a+1],a+1,e);return o+(u-o)*(i-a)}}function RA(e,t,r){e=+e,t=+t,r=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+r;for(var n=-1,i=Math.max(0,Math.ceil((t-e)/r))|0,a=new Array(i);++n>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):r===8?oi(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):r===4?oi(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=DA.exec(e))?new Ie(t[1],t[2],t[3],1):(t=NA.exec(e))?new Ie(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=qA.exec(e))?oi(t[1],t[2],t[3],t[4]):(t=BA.exec(e))?oi(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=LA.exec(e))?vy(t[1],t[2]/100,t[3]/100,1):(t=FA.exec(e))?vy(t[1],t[2]/100,t[3]/100,t[4]):sy.hasOwnProperty(e)?hy(sy[e]):e==="transparent"?new Ie(NaN,NaN,NaN,0):null}function hy(e){return new Ie(e>>16&255,e>>8&255,e&255,1)}function oi(e,t,r,n){return n<=0&&(e=t=r=NaN),new Ie(e,t,r,n)}function UA(e){return e instanceof Yn||(e=xn(e)),e?(e=e.rgb(),new Ie(e.r,e.g,e.b,e.opacity)):new Ie}function dl(e,t,r,n){return arguments.length===1?UA(e):new Ie(e,t,r,n??1)}function Ie(e,t,r,n){this.r=+e,this.g=+t,this.b=+r,this.opacity=+n}Cf(Ie,dl,o0(Yn,{brighter(e){return e=e==null?Mi:Math.pow(Mi,e),new Ie(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?gn:Math.pow(gn,e),new Ie(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ie(Kt(this.r),Kt(this.g),Kt(this.b),Ci(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:py,formatHex:py,formatHex8:HA,formatRgb:dy,toString:dy}));function py(){return`#${Wt(this.r)}${Wt(this.g)}${Wt(this.b)}`}function HA(){return`#${Wt(this.r)}${Wt(this.g)}${Wt(this.b)}${Wt((isNaN(this.opacity)?1:this.opacity)*255)}`}function dy(){const e=Ci(this.opacity);return`${e===1?"rgb(":"rgba("}${Kt(this.r)}, ${Kt(this.g)}, ${Kt(this.b)}${e===1?")":`, ${e})`}`}function Ci(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Kt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Wt(e){return e=Kt(e),(e<16?"0":"")+e.toString(16)}function vy(e,t,r,n){return n<=0?e=t=r=NaN:r<=0||r>=1?e=t=NaN:t<=0&&(e=NaN),new Ye(e,t,r,n)}function u0(e){if(e instanceof Ye)return new Ye(e.h,e.s,e.l,e.opacity);if(e instanceof Yn||(e=xn(e)),!e)return new Ye;if(e instanceof Ye)return e;e=e.rgb();var t=e.r/255,r=e.g/255,n=e.b/255,i=Math.min(t,r,n),a=Math.max(t,r,n),o=NaN,u=a-i,c=(a+i)/2;return u?(t===a?o=(r-n)/u+(r0&&c<1?0:o,new Ye(o,u,c,e.opacity)}function GA(e,t,r,n){return arguments.length===1?u0(e):new Ye(e,t,r,n??1)}function Ye(e,t,r,n){this.h=+e,this.s=+t,this.l=+r,this.opacity=+n}Cf(Ye,GA,o0(Yn,{brighter(e){return e=e==null?Mi:Math.pow(Mi,e),new Ye(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?gn:Math.pow(gn,e),new Ye(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*t,i=2*r-n;return new Ie(Zc(e>=240?e-240:e+120,i,n),Zc(e,i,n),Zc(e<120?e+240:e-120,i,n),this.opacity)},clamp(){return new Ye(yy(this.h),ui(this.s),ui(this.l),Ci(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Ci(this.opacity);return`${e===1?"hsl(":"hsla("}${yy(this.h)}, ${ui(this.s)*100}%, ${ui(this.l)*100}%${e===1?")":`, ${e})`}`}}));function yy(e){return e=(e||0)%360,e<0?e+360:e}function ui(e){return Math.max(0,Math.min(1,e||0))}function Zc(e,t,r){return(e<60?t+(r-t)*e/60:e<180?r:e<240?t+(r-t)*(240-e)/60:t)*255}const $f=e=>()=>e;function KA(e,t){return function(r){return e+r*t}}function VA(e,t,r){return e=Math.pow(e,r),t=Math.pow(t,r)-e,r=1/r,function(n){return Math.pow(e+n*t,r)}}function XA(e){return(e=+e)==1?c0:function(t,r){return r-t?VA(t,r,e):$f(isNaN(t)?r:t)}}function c0(e,t){var r=t-e;return r?KA(e,r):$f(isNaN(e)?t:e)}const my=(function e(t){var r=XA(t);function n(i,a){var o=r((i=dl(i)).r,(a=dl(a)).r),u=r(i.g,a.g),c=r(i.b,a.b),s=c0(i.opacity,a.opacity);return function(f){return i.r=o(f),i.g=u(f),i.b=c(f),i.opacity=s(f),i+""}}return n.gamma=e,n})(1);function YA(e,t){t||(t=[]);var r=e?Math.min(t.length,e.length):0,n=t.slice(),i;return function(a){for(i=0;ir&&(a=t.slice(r,a),u[o]?u[o]+=a:u[++o]=a),(n=n[0])===(i=i[0])?u[o]?u[o]+=i:u[++o]=i:(u[++o]=null,c.push({i:o,x:$i(n,i)})),r=Jc.lastIndex;return rt&&(r=e,e=t,t=r),function(n){return Math.max(e,Math.min(t,n))}}function uP(e,t,r){var n=e[0],i=e[1],a=t[0],o=t[1];return i2?cP:uP,c=s=null,l}function l(h){return h==null||isNaN(h=+h)?a:(c||(c=u(e.map(n),t,r)))(n(o(h)))}return l.invert=function(h){return o(i((s||(s=u(t,e.map(n),$i)))(h)))},l.domain=function(h){return arguments.length?(e=Array.from(h,Ii),f()):e.slice()},l.range=function(h){return arguments.length?(t=Array.from(h),f()):t.slice()},l.rangeRound=function(h){return t=Array.from(h),r=If,f()},l.clamp=function(h){return arguments.length?(o=h?!0:Me,f()):o!==Me},l.interpolate=function(h){return arguments.length?(r=h,f()):r},l.unknown=function(h){return arguments.length?(a=h,l):a},function(h,d){return n=h,i=d,f()}}function Rf(){return Sa()(Me,Me)}function sP(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function Ri(e,t){if((r=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var r,n=e.slice(0,r);return[n.length>1?n[0]+n.slice(2):n,+e.slice(r+1)]}function xr(e){return e=Ri(Math.abs(e)),e?e[1]:NaN}function lP(e,t){return function(r,n){for(var i=r.length,a=[],o=0,u=e[0],c=0;i>0&&u>0&&(c+u+1>n&&(u=Math.max(1,n-c)),a.push(r.substring(i-=u,i+u)),!((c+=u+1)>n));)u=e[o=(o+1)%e.length];return a.reverse().join(t)}}function fP(e){return function(t){return t.replace(/[0-9]/g,function(r){return e[+r]})}}var hP=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function wn(e){if(!(t=hP.exec(e)))throw new Error("invalid format: "+e);var t;return new kf({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}wn.prototype=kf.prototype;function kf(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}kf.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function pP(e){e:for(var t=e.length,r=1,n=-1,i;r0&&(n=0);break}return n>0?e.slice(0,n)+e.slice(i+1):e}var s0;function dP(e,t){var r=Ri(e,t);if(!r)return e+"";var n=r[0],i=r[1],a=i-(s0=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=n.length;return a===o?n:a>o?n+new Array(a-o+1).join("0"):a>0?n.slice(0,a)+"."+n.slice(a):"0."+new Array(1-a).join("0")+Ri(e,Math.max(0,t+a-1))[0]}function by(e,t){var r=Ri(e,t);if(!r)return e+"";var n=r[0],i=r[1];return i<0?"0."+new Array(-i).join("0")+n:n.length>i+1?n.slice(0,i+1)+"."+n.slice(i+1):n+new Array(i-n.length+2).join("0")}const xy={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:sP,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>by(e*100,t),r:by,s:dP,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function wy(e){return e}var Oy=Array.prototype.map,_y=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function vP(e){var t=e.grouping===void 0||e.thousands===void 0?wy:lP(Oy.call(e.grouping,Number),e.thousands+""),r=e.currency===void 0?"":e.currency[0]+"",n=e.currency===void 0?"":e.currency[1]+"",i=e.decimal===void 0?".":e.decimal+"",a=e.numerals===void 0?wy:fP(Oy.call(e.numerals,String)),o=e.percent===void 0?"%":e.percent+"",u=e.minus===void 0?"−":e.minus+"",c=e.nan===void 0?"NaN":e.nan+"";function s(l){l=wn(l);var h=l.fill,d=l.align,m=l.sign,v=l.symbol,p=l.zero,b=l.width,x=l.comma,w=l.precision,O=l.trim,y=l.type;y==="n"?(x=!0,y="g"):xy[y]||(w===void 0&&(w=12),O=!0,y="g"),(p||h==="0"&&d==="=")&&(p=!0,h="0",d="=");var g=v==="$"?r:v==="#"&&/[boxX]/.test(y)?"0"+y.toLowerCase():"",_=v==="$"?n:/[%p]/.test(y)?o:"",S=xy[y],P=/[defgprs%]/.test(y);w=w===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,w)):Math.max(0,Math.min(20,w));function M(A){var E=g,j=_,I,C,R;if(y==="c")j=S(A)+j,A="";else{A=+A;var D=A<0||1/A<0;if(A=isNaN(A)?c:S(Math.abs(A),w),O&&(A=pP(A)),D&&+A==0&&m!=="+"&&(D=!1),E=(D?m==="("?m:u:m==="-"||m==="("?"":m)+E,j=(y==="s"?_y[8+s0/3]:"")+j+(D&&m==="("?")":""),P){for(I=-1,C=A.length;++IR||R>57){j=(R===46?i+A.slice(I+1):A.slice(I))+j,A=A.slice(0,I);break}}}x&&!p&&(A=t(A,1/0));var B=E.length+A.length+j.length,L=B>1)+E+A+j+L.slice(B);break;default:A=L+E+A+j;break}return a(A)}return M.toString=function(){return l+""},M}function f(l,h){var d=s((l=wn(l),l.type="f",l)),m=Math.max(-8,Math.min(8,Math.floor(xr(h)/3)))*3,v=Math.pow(10,-m),p=_y[8+m/3];return function(b){return d(v*b)+p}}return{format:s,formatPrefix:f}}var ci,Df,l0;yP({thousands:",",grouping:[3],currency:["$",""]});function yP(e){return ci=vP(e),Df=ci.format,l0=ci.formatPrefix,ci}function mP(e){return Math.max(0,-xr(Math.abs(e)))}function gP(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(xr(t)/3)))*3-xr(Math.abs(e)))}function bP(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,xr(t)-xr(e))+1}function f0(e,t,r,n){var i=hl(e,t,r),a;switch(n=wn(n??",f"),n.type){case"s":{var o=Math.max(Math.abs(e),Math.abs(t));return n.precision==null&&!isNaN(a=gP(i,o))&&(n.precision=a),l0(n,o)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(a=bP(i,Math.max(Math.abs(e),Math.abs(t))))&&(n.precision=a-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(a=mP(i))&&(n.precision=a-(n.type==="%")*2);break}}return Df(n)}function It(e){var t=e.domain;return e.ticks=function(r){var n=t();return ll(n[0],n[n.length-1],r??10)},e.tickFormat=function(r,n){var i=t();return f0(i[0],i[i.length-1],r??10,n)},e.nice=function(r){r==null&&(r=10);var n=t(),i=0,a=n.length-1,o=n[i],u=n[a],c,s,f=10;for(u0;){if(s=fl(o,u,r),s===c)return n[i]=o,n[a]=u,t(n);if(s>0)o=Math.floor(o/s)*s,u=Math.ceil(u/s)*s;else if(s<0)o=Math.ceil(o*s)/s,u=Math.floor(u*s)/s;else break;c=s}return e},e}function ki(){var e=Rf();return e.copy=function(){return Zn(e,ki())},Ke.apply(e,arguments),It(e)}function h0(e){var t;function r(n){return n==null||isNaN(n=+n)?t:n}return r.invert=r,r.domain=r.range=function(n){return arguments.length?(e=Array.from(n,Ii),r):e.slice()},r.unknown=function(n){return arguments.length?(t=n,r):t},r.copy=function(){return h0(e).unknown(t)},e=arguments.length?Array.from(e,Ii):[0,1],It(r)}function p0(e,t){e=e.slice();var r=0,n=e.length-1,i=e[r],a=e[n],o;return aMath.pow(e,t)}function SP(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function Py(e){return(t,r)=>-e(-t,r)}function Nf(e){const t=e(Sy,Ay),r=t.domain;let n=10,i,a;function o(){return i=SP(n),a=_P(n),r()[0]<0?(i=Py(i),a=Py(a),e(xP,wP)):e(Sy,Ay),t}return t.base=function(u){return arguments.length?(n=+u,o()):n},t.domain=function(u){return arguments.length?(r(u),o()):r()},t.ticks=u=>{const c=r();let s=c[0],f=c[c.length-1];const l=f0){for(;h<=d;++h)for(m=1;mf)break;b.push(v)}}else for(;h<=d;++h)for(m=n-1;m>=1;--m)if(v=h>0?m/a(-h):m*a(h),!(vf)break;b.push(v)}b.length*2{if(u==null&&(u=10),c==null&&(c=n===10?"s":","),typeof c!="function"&&(!(n%1)&&(c=wn(c)).precision==null&&(c.trim=!0),c=Df(c)),u===1/0)return c;const s=Math.max(1,n*u/t.ticks().length);return f=>{let l=f/a(Math.round(i(f)));return l*nr(p0(r(),{floor:u=>a(Math.floor(i(u))),ceil:u=>a(Math.ceil(i(u)))})),t}function d0(){const e=Nf(Sa()).domain([1,10]);return e.copy=()=>Zn(e,d0()).base(e.base()),Ke.apply(e,arguments),e}function Ty(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function Ey(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function qf(e){var t=1,r=e(Ty(t),Ey(t));return r.constant=function(n){return arguments.length?e(Ty(t=+n),Ey(t)):t},It(r)}function v0(){var e=qf(Sa());return e.copy=function(){return Zn(e,v0()).constant(e.constant())},Ke.apply(e,arguments)}function jy(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function AP(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function PP(e){return e<0?-e*e:e*e}function Bf(e){var t=e(Me,Me),r=1;function n(){return r===1?e(Me,Me):r===.5?e(AP,PP):e(jy(r),jy(1/r))}return t.exponent=function(i){return arguments.length?(r=+i,n()):r},It(t)}function Lf(){var e=Bf(Sa());return e.copy=function(){return Zn(e,Lf()).exponent(e.exponent())},Ke.apply(e,arguments),e}function TP(){return Lf.apply(null,arguments).exponent(.5)}function My(e){return Math.sign(e)*e*e}function EP(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function y0(){var e=Rf(),t=[0,1],r=!1,n;function i(a){var o=EP(e(a));return isNaN(o)?n:r?Math.round(o):o}return i.invert=function(a){return e.invert(My(a))},i.domain=function(a){return arguments.length?(e.domain(a),i):e.domain()},i.range=function(a){return arguments.length?(e.range((t=Array.from(a,Ii)).map(My)),i):t.slice()},i.rangeRound=function(a){return i.range(a).round(!0)},i.round=function(a){return arguments.length?(r=!!a,i):r},i.clamp=function(a){return arguments.length?(e.clamp(a),i):e.clamp()},i.unknown=function(a){return arguments.length?(n=a,i):n},i.copy=function(){return y0(e.domain(),t).round(r).clamp(e.clamp()).unknown(n)},Ke.apply(i,arguments),It(i)}function m0(){var e=[],t=[],r=[],n;function i(){var o=0,u=Math.max(1,t.length);for(r=new Array(u-1);++o0?r[u-1]:e[0],u=r?[n[r-1],t]:[n[s-1],n[s]]},o.unknown=function(c){return arguments.length&&(a=c),o},o.thresholds=function(){return n.slice()},o.copy=function(){return g0().domain([e,t]).range(i).unknown(a)},Ke.apply(It(o),arguments)}function b0(){var e=[.5],t=[0,1],r,n=1;function i(a){return a!=null&&a<=a?t[Xn(e,a,0,n)]:r}return i.domain=function(a){return arguments.length?(e=Array.from(a),n=Math.min(e.length,t.length-1),i):e.slice()},i.range=function(a){return arguments.length?(t=Array.from(a),n=Math.min(e.length,t.length-1),i):t.slice()},i.invertExtent=function(a){var o=t.indexOf(a);return[e[o-1],e[o]]},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return b0().domain(e).range(t).unknown(r)},Ke.apply(i,arguments)}const Qc=new Date,es=new Date;function Oe(e,t,r,n){function i(a){return e(a=arguments.length===0?new Date:new Date(+a)),a}return i.floor=a=>(e(a=new Date(+a)),a),i.ceil=a=>(e(a=new Date(a-1)),t(a,1),e(a),a),i.round=a=>{const o=i(a),u=i.ceil(a);return a-o(t(a=new Date(+a),o==null?1:Math.floor(o)),a),i.range=(a,o,u)=>{const c=[];if(a=i.ceil(a),u=u==null?1:Math.floor(u),!(a0))return c;let s;do c.push(s=new Date(+a)),t(a,u),e(a);while(sOe(o=>{if(o>=o)for(;e(o),!a(o);)o.setTime(o-1)},(o,u)=>{if(o>=o)if(u<0)for(;++u<=0;)for(;t(o,-1),!a(o););else for(;--u>=0;)for(;t(o,1),!a(o););}),r&&(i.count=(a,o)=>(Qc.setTime(+a),es.setTime(+o),e(Qc),e(es),Math.floor(r(Qc,es))),i.every=a=>(a=Math.floor(a),!isFinite(a)||!(a>0)?null:a>1?i.filter(n?o=>n(o)%a===0:o=>i.count(0,o)%a===0):i)),i}const Di=Oe(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);Di.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?Oe(t=>{t.setTime(Math.floor(t/e)*e)},(t,r)=>{t.setTime(+t+r*e)},(t,r)=>(r-t)/e):Di);Di.range;const lt=1e3,Ue=lt*60,ft=Ue*60,yt=ft*24,Ff=yt*7,Cy=yt*30,ts=yt*365,Ut=Oe(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*lt)},(e,t)=>(t-e)/lt,e=>e.getUTCSeconds());Ut.range;const zf=Oe(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*lt)},(e,t)=>{e.setTime(+e+t*Ue)},(e,t)=>(t-e)/Ue,e=>e.getMinutes());zf.range;const Wf=Oe(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*Ue)},(e,t)=>(t-e)/Ue,e=>e.getUTCMinutes());Wf.range;const Uf=Oe(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*lt-e.getMinutes()*Ue)},(e,t)=>{e.setTime(+e+t*ft)},(e,t)=>(t-e)/ft,e=>e.getHours());Uf.range;const Hf=Oe(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*ft)},(e,t)=>(t-e)/ft,e=>e.getUTCHours());Hf.range;const Jn=Oe(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Ue)/yt,e=>e.getDate()-1);Jn.range;const Aa=Oe(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/yt,e=>e.getUTCDate()-1);Aa.range;const x0=Oe(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/yt,e=>Math.floor(e/yt));x0.range;function er(e){return Oe(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(t,r)=>{t.setDate(t.getDate()+r*7)},(t,r)=>(r-t-(r.getTimezoneOffset()-t.getTimezoneOffset())*Ue)/Ff)}const Pa=er(0),Ni=er(1),jP=er(2),MP=er(3),wr=er(4),CP=er(5),$P=er(6);Pa.range;Ni.range;jP.range;MP.range;wr.range;CP.range;$P.range;function tr(e){return Oe(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(t,r)=>{t.setUTCDate(t.getUTCDate()+r*7)},(t,r)=>(r-t)/Ff)}const Ta=tr(0),qi=tr(1),IP=tr(2),RP=tr(3),Or=tr(4),kP=tr(5),DP=tr(6);Ta.range;qi.range;IP.range;RP.range;Or.range;kP.range;DP.range;const Gf=Oe(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());Gf.range;const Kf=Oe(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());Kf.range;const mt=Oe(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());mt.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Oe(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,r)=>{t.setFullYear(t.getFullYear()+r*e)});mt.range;const gt=Oe(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());gt.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Oe(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,r)=>{t.setUTCFullYear(t.getUTCFullYear()+r*e)});gt.range;function w0(e,t,r,n,i,a){const o=[[Ut,1,lt],[Ut,5,5*lt],[Ut,15,15*lt],[Ut,30,30*lt],[a,1,Ue],[a,5,5*Ue],[a,15,15*Ue],[a,30,30*Ue],[i,1,ft],[i,3,3*ft],[i,6,6*ft],[i,12,12*ft],[n,1,yt],[n,2,2*yt],[r,1,Ff],[t,1,Cy],[t,3,3*Cy],[e,1,ts]];function u(s,f,l){const h=fp).right(o,h);if(d===o.length)return e.every(hl(s/ts,f/ts,l));if(d===0)return Di.every(Math.max(hl(s,f,l),1));const[m,v]=o[h/o[d-1][2]53)return null;"w"in k||(k.w=1),"Z"in k?(Q=ns(Vr(k.y,0,1)),me=Q.getUTCDay(),Q=me>4||me===0?qi.ceil(Q):qi(Q),Q=Aa.offset(Q,(k.V-1)*7),k.y=Q.getUTCFullYear(),k.m=Q.getUTCMonth(),k.d=Q.getUTCDate()+(k.w+6)%7):(Q=rs(Vr(k.y,0,1)),me=Q.getDay(),Q=me>4||me===0?Ni.ceil(Q):Ni(Q),Q=Jn.offset(Q,(k.V-1)*7),k.y=Q.getFullYear(),k.m=Q.getMonth(),k.d=Q.getDate()+(k.w+6)%7)}else("W"in k||"U"in k)&&("w"in k||(k.w="u"in k?k.u%7:"W"in k?1:0),me="Z"in k?ns(Vr(k.y,0,1)).getUTCDay():rs(Vr(k.y,0,1)).getDay(),k.m=0,k.d="W"in k?(k.w+6)%7+k.W*7-(me+5)%7:k.w+k.U*7-(me+6)%7);return"Z"in k?(k.H+=k.Z/100|0,k.M+=k.Z%100,ns(k)):rs(k)}}function S(F,X,Y,k){for(var he=0,Q=X.length,me=Y.length,ge,$e;he=me)return-1;if(ge=X.charCodeAt(he++),ge===37){if(ge=X.charAt(he++),$e=y[ge in $y?X.charAt(he++):ge],!$e||(k=$e(F,Y,k))<0)return-1}else if(ge!=Y.charCodeAt(k++))return-1}return k}function P(F,X,Y){var k=s.exec(X.slice(Y));return k?(F.p=f.get(k[0].toLowerCase()),Y+k[0].length):-1}function M(F,X,Y){var k=d.exec(X.slice(Y));return k?(F.w=m.get(k[0].toLowerCase()),Y+k[0].length):-1}function A(F,X,Y){var k=l.exec(X.slice(Y));return k?(F.w=h.get(k[0].toLowerCase()),Y+k[0].length):-1}function E(F,X,Y){var k=b.exec(X.slice(Y));return k?(F.m=x.get(k[0].toLowerCase()),Y+k[0].length):-1}function j(F,X,Y){var k=v.exec(X.slice(Y));return k?(F.m=p.get(k[0].toLowerCase()),Y+k[0].length):-1}function I(F,X,Y){return S(F,t,X,Y)}function C(F,X,Y){return S(F,r,X,Y)}function R(F,X,Y){return S(F,n,X,Y)}function D(F){return o[F.getDay()]}function B(F){return a[F.getDay()]}function L(F){return c[F.getMonth()]}function U(F){return u[F.getMonth()]}function G(F){return i[+(F.getHours()>=12)]}function z(F){return 1+~~(F.getMonth()/3)}function K(F){return o[F.getUTCDay()]}function ce(F){return a[F.getUTCDay()]}function de(F){return c[F.getUTCMonth()]}function ke(F){return u[F.getUTCMonth()]}function Dt(F){return i[+(F.getUTCHours()>=12)]}function Ce(F){return 1+~~(F.getUTCMonth()/3)}return{format:function(F){var X=g(F+="",w);return X.toString=function(){return F},X},parse:function(F){var X=_(F+="",!1);return X.toString=function(){return F},X},utcFormat:function(F){var X=g(F+="",O);return X.toString=function(){return F},X},utcParse:function(F){var X=_(F+="",!0);return X.toString=function(){return F},X}}}var $y={"-":"",_:" ",0:"0"},Se=/^\s*\d+/,zP=/^%/,WP=/[\\^$*+?|[\]().{}]/g;function te(e,t,r){var n=e<0?"-":"",i=(n?-e:e)+"",a=i.length;return n+(a[t.toLowerCase(),r]))}function HP(e,t,r){var n=Se.exec(t.slice(r,r+1));return n?(e.w=+n[0],r+n[0].length):-1}function GP(e,t,r){var n=Se.exec(t.slice(r,r+1));return n?(e.u=+n[0],r+n[0].length):-1}function KP(e,t,r){var n=Se.exec(t.slice(r,r+2));return n?(e.U=+n[0],r+n[0].length):-1}function VP(e,t,r){var n=Se.exec(t.slice(r,r+2));return n?(e.V=+n[0],r+n[0].length):-1}function XP(e,t,r){var n=Se.exec(t.slice(r,r+2));return n?(e.W=+n[0],r+n[0].length):-1}function Iy(e,t,r){var n=Se.exec(t.slice(r,r+4));return n?(e.y=+n[0],r+n[0].length):-1}function Ry(e,t,r){var n=Se.exec(t.slice(r,r+2));return n?(e.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function YP(e,t,r){var n=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(r,r+6));return n?(e.Z=n[1]?0:-(n[2]+(n[3]||"00")),r+n[0].length):-1}function ZP(e,t,r){var n=Se.exec(t.slice(r,r+1));return n?(e.q=n[0]*3-3,r+n[0].length):-1}function JP(e,t,r){var n=Se.exec(t.slice(r,r+2));return n?(e.m=n[0]-1,r+n[0].length):-1}function ky(e,t,r){var n=Se.exec(t.slice(r,r+2));return n?(e.d=+n[0],r+n[0].length):-1}function QP(e,t,r){var n=Se.exec(t.slice(r,r+3));return n?(e.m=0,e.d=+n[0],r+n[0].length):-1}function Dy(e,t,r){var n=Se.exec(t.slice(r,r+2));return n?(e.H=+n[0],r+n[0].length):-1}function eT(e,t,r){var n=Se.exec(t.slice(r,r+2));return n?(e.M=+n[0],r+n[0].length):-1}function tT(e,t,r){var n=Se.exec(t.slice(r,r+2));return n?(e.S=+n[0],r+n[0].length):-1}function rT(e,t,r){var n=Se.exec(t.slice(r,r+3));return n?(e.L=+n[0],r+n[0].length):-1}function nT(e,t,r){var n=Se.exec(t.slice(r,r+6));return n?(e.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function iT(e,t,r){var n=zP.exec(t.slice(r,r+1));return n?r+n[0].length:-1}function aT(e,t,r){var n=Se.exec(t.slice(r));return n?(e.Q=+n[0],r+n[0].length):-1}function oT(e,t,r){var n=Se.exec(t.slice(r));return n?(e.s=+n[0],r+n[0].length):-1}function Ny(e,t){return te(e.getDate(),t,2)}function uT(e,t){return te(e.getHours(),t,2)}function cT(e,t){return te(e.getHours()%12||12,t,2)}function sT(e,t){return te(1+Jn.count(mt(e),e),t,3)}function O0(e,t){return te(e.getMilliseconds(),t,3)}function lT(e,t){return O0(e,t)+"000"}function fT(e,t){return te(e.getMonth()+1,t,2)}function hT(e,t){return te(e.getMinutes(),t,2)}function pT(e,t){return te(e.getSeconds(),t,2)}function dT(e){var t=e.getDay();return t===0?7:t}function vT(e,t){return te(Pa.count(mt(e)-1,e),t,2)}function _0(e){var t=e.getDay();return t>=4||t===0?wr(e):wr.ceil(e)}function yT(e,t){return e=_0(e),te(wr.count(mt(e),e)+(mt(e).getDay()===4),t,2)}function mT(e){return e.getDay()}function gT(e,t){return te(Ni.count(mt(e)-1,e),t,2)}function bT(e,t){return te(e.getFullYear()%100,t,2)}function xT(e,t){return e=_0(e),te(e.getFullYear()%100,t,2)}function wT(e,t){return te(e.getFullYear()%1e4,t,4)}function OT(e,t){var r=e.getDay();return e=r>=4||r===0?wr(e):wr.ceil(e),te(e.getFullYear()%1e4,t,4)}function _T(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+te(t/60|0,"0",2)+te(t%60,"0",2)}function qy(e,t){return te(e.getUTCDate(),t,2)}function ST(e,t){return te(e.getUTCHours(),t,2)}function AT(e,t){return te(e.getUTCHours()%12||12,t,2)}function PT(e,t){return te(1+Aa.count(gt(e),e),t,3)}function S0(e,t){return te(e.getUTCMilliseconds(),t,3)}function TT(e,t){return S0(e,t)+"000"}function ET(e,t){return te(e.getUTCMonth()+1,t,2)}function jT(e,t){return te(e.getUTCMinutes(),t,2)}function MT(e,t){return te(e.getUTCSeconds(),t,2)}function CT(e){var t=e.getUTCDay();return t===0?7:t}function $T(e,t){return te(Ta.count(gt(e)-1,e),t,2)}function A0(e){var t=e.getUTCDay();return t>=4||t===0?Or(e):Or.ceil(e)}function IT(e,t){return e=A0(e),te(Or.count(gt(e),e)+(gt(e).getUTCDay()===4),t,2)}function RT(e){return e.getUTCDay()}function kT(e,t){return te(qi.count(gt(e)-1,e),t,2)}function DT(e,t){return te(e.getUTCFullYear()%100,t,2)}function NT(e,t){return e=A0(e),te(e.getUTCFullYear()%100,t,2)}function qT(e,t){return te(e.getUTCFullYear()%1e4,t,4)}function BT(e,t){var r=e.getUTCDay();return e=r>=4||r===0?Or(e):Or.ceil(e),te(e.getUTCFullYear()%1e4,t,4)}function LT(){return"+0000"}function By(){return"%"}function Ly(e){return+e}function Fy(e){return Math.floor(+e/1e3)}var or,P0,T0;FT({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function FT(e){return or=FP(e),P0=or.format,or.parse,T0=or.utcFormat,or.utcParse,or}function zT(e){return new Date(e)}function WT(e){return e instanceof Date?+e:+new Date(+e)}function Vf(e,t,r,n,i,a,o,u,c,s){var f=Rf(),l=f.invert,h=f.domain,d=s(".%L"),m=s(":%S"),v=s("%I:%M"),p=s("%I %p"),b=s("%a %d"),x=s("%b %d"),w=s("%B"),O=s("%Y");function y(g){return(c(g)t(i/(e.length-1)))},r.quantiles=function(n){return Array.from({length:n+1},(i,a)=>$A(e,a/n))},r.copy=function(){return C0(t).domain(e)},Ot.apply(r,arguments)}function ja(){var e=0,t=.5,r=1,n=1,i,a,o,u,c,s=Me,f,l=!1,h;function d(v){return isNaN(v=+v)?h:(v=.5+((v=+f(v))-a)*(n*vr}return as=e,as}var os,Hy;function XT(){if(Hy)return os;Hy=1;var e=k0(),t=VT(),r=Lr();function n(i){return i&&i.length?e(i,r,t):void 0}return os=n,os}var YT=XT();const Tt=ue(YT);var us,Gy;function ZT(){if(Gy)return us;Gy=1;function e(t,r){return te.e^a.s<0?1:-1;for(n=a.d.length,i=e.d.length,t=0,r=ne.d[t]^a.s<0?1:-1;return n===i?0:n>i^a.s<0?1:-1};W.decimalPlaces=W.dp=function(){var e=this,t=e.d.length-1,r=(t-e.e)*se;if(t=e.d[t],t)for(;t%10==0;t/=10)r--;return r<0?0:r};W.dividedBy=W.div=function(e){return vt(this,new this.constructor(e))};W.dividedToIntegerBy=W.idiv=function(e){var t=this,r=t.constructor;return ae(vt(t,new r(e),0,1),r.precision)};W.equals=W.eq=function(e){return!this.cmp(e)};W.exponent=function(){return ye(this)};W.greaterThan=W.gt=function(e){return this.cmp(e)>0};W.greaterThanOrEqualTo=W.gte=function(e){return this.cmp(e)>=0};W.isInteger=W.isint=function(){return this.e>this.d.length-2};W.isNegative=W.isneg=function(){return this.s<0};W.isPositive=W.ispos=function(){return this.s>0};W.isZero=function(){return this.s===0};W.lessThan=W.lt=function(e){return this.cmp(e)<0};W.lessThanOrEqualTo=W.lte=function(e){return this.cmp(e)<1};W.logarithm=W.log=function(e){var t,r=this,n=r.constructor,i=n.precision,a=i+5;if(e===void 0)e=new n(10);else if(e=new n(e),e.s<1||e.eq(qe))throw Error(Ge+"NaN");if(r.s<1)throw Error(Ge+(r.s?"NaN":"-Infinity"));return r.eq(qe)?new n(0):(le=!1,t=vt(_n(r,a),_n(e,a),a),le=!0,ae(t,i))};W.minus=W.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?B0(t,e):N0(t,(e.s=-e.s,e))};W.modulo=W.mod=function(e){var t,r=this,n=r.constructor,i=n.precision;if(e=new n(e),!e.s)throw Error(Ge+"NaN");return r.s?(le=!1,t=vt(r,e,0,1).times(e),le=!0,r.minus(t)):ae(new n(r),i)};W.naturalExponential=W.exp=function(){return q0(this)};W.naturalLogarithm=W.ln=function(){return _n(this)};W.negated=W.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e};W.plus=W.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?N0(t,e):B0(t,(e.s=-e.s,e))};W.precision=W.sd=function(e){var t,r,n,i=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Vt+e);if(t=ye(i)+1,n=i.d.length-1,r=n*se+1,n=i.d[n],n){for(;n%10==0;n/=10)r--;for(n=i.d[0];n>=10;n/=10)r++}return e&&t>r?t:r};W.squareRoot=W.sqrt=function(){var e,t,r,n,i,a,o,u=this,c=u.constructor;if(u.s<1){if(!u.s)return new c(0);throw Error(Ge+"NaN")}for(e=ye(u),le=!1,i=Math.sqrt(+u),i==0||i==1/0?(t=tt(u.d),(t.length+e)%2==0&&(t+="0"),i=Math.sqrt(t),e=Ur((e+1)/2)-(e<0||e%2),i==1/0?t="5e"+e:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),n=new c(t)):n=new c(i.toString()),r=c.precision,i=o=r+3;;)if(a=n,n=a.plus(vt(u,a,o+2)).times(.5),tt(a.d).slice(0,o)===(t=tt(n.d)).slice(0,o)){if(t=t.slice(o-3,o+1),i==o&&t=="4999"){if(ae(a,r+1,0),a.times(a).eq(u)){n=a;break}}else if(t!="9999")break;o+=4}return le=!0,ae(n,r)};W.times=W.mul=function(e){var t,r,n,i,a,o,u,c,s,f=this,l=f.constructor,h=f.d,d=(e=new l(e)).d;if(!f.s||!e.s)return new l(0);for(e.s*=f.s,r=f.e+e.e,c=h.length,s=d.length,c=0;){for(t=0,i=c+n;i>n;)u=a[i]+d[n]*h[i-n-1]+t,a[i--]=u%_e|0,t=u/_e|0;a[i]=(a[i]+t)%_e|0}for(;!a[--o];)a.pop();return t?++r:a.shift(),e.d=a,e.e=r,le?ae(e,l.precision):e};W.toDecimalPlaces=W.todp=function(e,t){var r=this,n=r.constructor;return r=new n(r),e===void 0?r:(at(e,0,Wr),t===void 0?t=n.rounding:at(t,0,8),ae(r,e+ye(r)+1,t))};W.toExponential=function(e,t){var r,n=this,i=n.constructor;return e===void 0?r=Yt(n,!0):(at(e,0,Wr),t===void 0?t=i.rounding:at(t,0,8),n=ae(new i(n),e+1,t),r=Yt(n,!0,e+1)),r};W.toFixed=function(e,t){var r,n,i=this,a=i.constructor;return e===void 0?Yt(i):(at(e,0,Wr),t===void 0?t=a.rounding:at(t,0,8),n=ae(new a(i),e+ye(i)+1,t),r=Yt(n.abs(),!1,e+ye(n)+1),i.isneg()&&!i.isZero()?"-"+r:r)};W.toInteger=W.toint=function(){var e=this,t=e.constructor;return ae(new t(e),ye(e)+1,t.rounding)};W.toNumber=function(){return+this};W.toPower=W.pow=function(e){var t,r,n,i,a,o,u=this,c=u.constructor,s=12,f=+(e=new c(e));if(!e.s)return new c(qe);if(u=new c(u),!u.s){if(e.s<1)throw Error(Ge+"Infinity");return u}if(u.eq(qe))return u;if(n=c.precision,e.eq(qe))return ae(u,n);if(t=e.e,r=e.d.length-1,o=t>=r,a=u.s,o){if((r=f<0?-f:f)<=D0){for(i=new c(qe),t=Math.ceil(n/se+4),le=!1;r%2&&(i=i.times(u),Jy(i.d,t)),r=Ur(r/2),r!==0;)u=u.times(u),Jy(u.d,t);return le=!0,e.s<0?new c(qe).div(i):ae(i,n)}}else if(a<0)throw Error(Ge+"NaN");return a=a<0&&e.d[Math.max(t,r)]&1?-1:1,u.s=1,le=!1,i=e.times(_n(u,n+s)),le=!0,i=q0(i),i.s=a,i};W.toPrecision=function(e,t){var r,n,i=this,a=i.constructor;return e===void 0?(r=ye(i),n=Yt(i,r<=a.toExpNeg||r>=a.toExpPos)):(at(e,1,Wr),t===void 0?t=a.rounding:at(t,0,8),i=ae(new a(i),e,t),r=ye(i),n=Yt(i,e<=r||r<=a.toExpNeg,e)),n};W.toSignificantDigits=W.tosd=function(e,t){var r=this,n=r.constructor;return e===void 0?(e=n.precision,t=n.rounding):(at(e,1,Wr),t===void 0?t=n.rounding:at(t,0,8)),ae(new n(r),e,t)};W.toString=W.valueOf=W.val=W.toJSON=W[Symbol.for("nodejs.util.inspect.custom")]=function(){var e=this,t=ye(e),r=e.constructor;return Yt(e,t<=r.toExpNeg||t>=r.toExpPos)};function N0(e,t){var r,n,i,a,o,u,c,s,f=e.constructor,l=f.precision;if(!e.s||!t.s)return t.s||(t=new f(e)),le?ae(t,l):t;if(c=e.d,s=t.d,o=e.e,i=t.e,c=c.slice(),a=o-i,a){for(a<0?(n=c,a=-a,u=s.length):(n=s,i=o,u=c.length),o=Math.ceil(l/se),u=o>u?o+1:u+1,a>u&&(a=u,n.length=1),n.reverse();a--;)n.push(0);n.reverse()}for(u=c.length,a=s.length,u-a<0&&(a=u,n=s,s=c,c=n),r=0;a;)r=(c[--a]=c[a]+s[a]+r)/_e|0,c[a]%=_e;for(r&&(c.unshift(r),++i),u=c.length;c[--u]==0;)c.pop();return t.d=c,t.e=i,le?ae(t,l):t}function at(e,t,r){if(e!==~~e||er)throw Error(Vt+e)}function tt(e){var t,r,n,i=e.length-1,a="",o=e[0];if(i>0){for(a+=o,t=1;to?1:-1;else for(u=c=0;ui[u]?1:-1;break}return c}function r(n,i,a){for(var o=0;a--;)n[a]-=o,o=n[a]1;)n.shift()}return function(n,i,a,o){var u,c,s,f,l,h,d,m,v,p,b,x,w,O,y,g,_,S,P=n.constructor,M=n.s==i.s?1:-1,A=n.d,E=i.d;if(!n.s)return new P(n);if(!i.s)throw Error(Ge+"Division by zero");for(c=n.e-i.e,_=E.length,y=A.length,d=new P(M),m=d.d=[],s=0;E[s]==(A[s]||0);)++s;if(E[s]>(A[s]||0)&&--c,a==null?x=a=P.precision:o?x=a+(ye(n)-ye(i))+1:x=a,x<0)return new P(0);if(x=x/se+2|0,s=0,_==1)for(f=0,E=E[0],x++;(s1&&(E=e(E,f),A=e(A,f),_=E.length,y=A.length),O=_,v=A.slice(0,_),p=v.length;p<_;)v[p++]=0;S=E.slice(),S.unshift(0),g=E[0],E[1]>=_e/2&&++g;do f=0,u=t(E,v,_,p),u<0?(b=v[0],_!=p&&(b=b*_e+(v[1]||0)),f=b/g|0,f>1?(f>=_e&&(f=_e-1),l=e(E,f),h=l.length,p=v.length,u=t(l,v,h,p),u==1&&(f--,r(l,_16)throw Error(Zf+ye(e));if(!e.s)return new f(qe);for(le=!1,u=l,o=new f(.03125);e.abs().gte(.1);)e=e.times(o),s+=5;for(n=Math.log(Ft(2,s))/Math.LN10*2+5|0,u+=n,r=i=a=new f(qe),f.precision=u;;){if(i=ae(i.times(e),u),r=r.times(++c),o=a.plus(vt(i,r,u)),tt(o.d).slice(0,u)===tt(a.d).slice(0,u)){for(;s--;)a=ae(a.times(a),u);return f.precision=l,t==null?(le=!0,ae(a,l)):a}a=o}}function ye(e){for(var t=e.e*se,r=e.d[0];r>=10;r/=10)t++;return t}function hs(e,t,r){if(t>e.LN10.sd())throw le=!0,r&&(e.precision=r),Error(Ge+"LN10 precision limit exceeded");return ae(new e(e.LN10),t)}function At(e){for(var t="";e--;)t+="0";return t}function _n(e,t){var r,n,i,a,o,u,c,s,f,l=1,h=10,d=e,m=d.d,v=d.constructor,p=v.precision;if(d.s<1)throw Error(Ge+(d.s?"NaN":"-Infinity"));if(d.eq(qe))return new v(0);if(t==null?(le=!1,s=p):s=t,d.eq(10))return t==null&&(le=!0),hs(v,s);if(s+=h,v.precision=s,r=tt(m),n=r.charAt(0),a=ye(d),Math.abs(a)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)d=d.times(e),r=tt(d.d),n=r.charAt(0),l++;a=ye(d),n>1?(d=new v("0."+r),a++):d=new v(n+"."+r.slice(1))}else return c=hs(v,s+2,p).times(a+""),d=_n(new v(n+"."+r.slice(1)),s-h).plus(c),v.precision=p,t==null?(le=!0,ae(d,p)):d;for(u=o=d=vt(d.minus(qe),d.plus(qe),s),f=ae(d.times(d),s),i=3;;){if(o=ae(o.times(f),s),c=u.plus(vt(o,new v(i),s)),tt(c.d).slice(0,s)===tt(u.d).slice(0,s))return u=u.times(2),a!==0&&(u=u.plus(hs(v,s+2,p).times(a+""))),u=vt(u,new v(l),s),v.precision=p,t==null?(le=!0,ae(u,p)):u;u=c,i+=2}}function Zy(e,t){var r,n,i;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;t.charCodeAt(n)===48;)++n;for(i=t.length;t.charCodeAt(i-1)===48;)--i;if(t=t.slice(n,i),t){if(i-=n,r=r-n-1,e.e=Ur(r/se),e.d=[],n=(r+1)%se,r<0&&(n+=se),nBi||e.e<-Bi))throw Error(Zf+r)}else e.s=0,e.e=0,e.d=[0];return e}function ae(e,t,r){var n,i,a,o,u,c,s,f,l=e.d;for(o=1,a=l[0];a>=10;a/=10)o++;if(n=t-o,n<0)n+=se,i=t,s=l[f=0];else{if(f=Math.ceil((n+1)/se),a=l.length,f>=a)return e;for(s=a=l[f],o=1;a>=10;a/=10)o++;n%=se,i=n-se+o}if(r!==void 0&&(a=Ft(10,o-i-1),u=s/a%10|0,c=t<0||l[f+1]!==void 0||s%a,c=r<4?(u||c)&&(r==0||r==(e.s<0?3:2)):u>5||u==5&&(r==4||c||r==6&&(n>0?i>0?s/Ft(10,o-i):0:l[f-1])%10&1||r==(e.s<0?8:7))),t<1||!l[0])return c?(a=ye(e),l.length=1,t=t-a-1,l[0]=Ft(10,(se-t%se)%se),e.e=Ur(-t/se)||0):(l.length=1,l[0]=e.e=e.s=0),e;if(n==0?(l.length=f,a=1,f--):(l.length=f+1,a=Ft(10,se-n),l[f]=i>0?(s/Ft(10,o-i)%Ft(10,i)|0)*a:0),c)for(;;)if(f==0){(l[0]+=a)==_e&&(l[0]=1,++e.e);break}else{if(l[f]+=a,l[f]!=_e)break;l[f--]=0,a=1}for(n=l.length;l[--n]===0;)l.pop();if(le&&(e.e>Bi||e.e<-Bi))throw Error(Zf+ye(e));return e}function B0(e,t){var r,n,i,a,o,u,c,s,f,l,h=e.constructor,d=h.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new h(e),le?ae(t,d):t;if(c=e.d,l=t.d,n=t.e,s=e.e,c=c.slice(),o=s-n,o){for(f=o<0,f?(r=c,o=-o,u=l.length):(r=l,n=s,u=c.length),i=Math.max(Math.ceil(d/se),u)+2,o>i&&(o=i,r.length=1),r.reverse(),i=o;i--;)r.push(0);r.reverse()}else{for(i=c.length,u=l.length,f=i0;--i)c[u++]=0;for(i=l.length;i>o;){if(c[--i]0?a=a.charAt(0)+"."+a.slice(1)+At(n):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+At(-i-1)+a,r&&(n=r-o)>0&&(a+=At(n))):i>=o?(a+=At(i+1-o),r&&(n=r-i-1)>0&&(a=a+"."+At(n))):((n=i+1)0&&(i+1===o&&(a+="."),a+=At(n))),e.s<0?"-"+a:a}function Jy(e,t){if(e.length>t)return e.length=t,!0}function L0(e){var t,r,n;function i(a){var o=this;if(!(o instanceof i))return new i(a);if(o.constructor=i,a instanceof i){o.s=a.s,o.e=a.e,o.d=(a=a.d)?a.slice():a;return}if(typeof a=="number"){if(a*0!==0)throw Error(Vt+a);if(a>0)o.s=1;else if(a<0)a=-a,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(a===~~a&&a<1e7){o.e=0,o.d=[a];return}return Zy(o,a.toString())}else if(typeof a!="string")throw Error(Vt+a);if(a.charCodeAt(0)===45?(a=a.slice(1),o.s=-1):o.s=1,uE.test(a))Zy(o,a);else throw Error(Vt+a)}if(i.prototype=W,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=L0,i.config=i.set=cE,e===void 0&&(e={}),e)for(n=["precision","rounding","toExpNeg","toExpPos","LN10"],t=0;t=i[t+1]&&n<=i[t+2])this[r]=n;else throw Error(Vt+r+": "+n);if((n=e[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(Vt+r+": "+n);return this}var Jf=L0(oE);qe=new Jf(1);const ie=Jf;function sE(e){return pE(e)||hE(e)||fE(e)||lE()}function lE(){throw new TypeError(`Invalid attempt to spread non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function fE(e,t){if(e){if(typeof e=="string")return ml(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ml(e,t)}}function hE(e){if(typeof Symbol<"u"&&Symbol.iterator in Object(e))return Array.from(e)}function pE(e){if(Array.isArray(e))return ml(e)}function ml(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=t?r.apply(void 0,i):e(t-o,Qy(function(){for(var u=arguments.length,c=new Array(u),s=0;se.length)&&(t=e.length);for(var r=0,n=new Array(t);r"u"||!(Symbol.iterator in Object(e)))){var r=[],n=!0,i=!1,a=void 0;try{for(var o=e[Symbol.iterator](),u;!(n=(u=o.next()).done)&&(r.push(u.value),!(t&&r.length===t));n=!0);}catch(c){i=!0,a=c}finally{try{!n&&o.return!=null&&o.return()}finally{if(i)throw a}}return r}}function EE(e){if(Array.isArray(e))return e}function H0(e){var t=Sn(e,2),r=t[0],n=t[1],i=r,a=n;return r>n&&(i=n,a=r),[i,a]}function G0(e,t,r){if(e.lte(0))return new ie(0);var n=$a.getDigitCount(e.toNumber()),i=new ie(10).pow(n),a=e.div(i),o=n!==1?.05:.1,u=new ie(Math.ceil(a.div(o).toNumber())).add(r).mul(o),c=u.mul(i);return t?c:new ie(Math.ceil(c))}function jE(e,t,r){var n=1,i=new ie(e);if(!i.isint()&&r){var a=Math.abs(e);a<1?(n=new ie(10).pow($a.getDigitCount(e)-1),i=new ie(Math.floor(i.div(n).toNumber())).mul(n)):a>1&&(i=new ie(Math.floor(e)))}else e===0?i=new ie(Math.floor((t-1)/2)):r||(i=new ie(Math.floor(e)));var o=Math.floor((t-1)/2),u=mE(yE(function(c){return i.add(new ie(c-o).mul(n)).toNumber()}),gl);return u(0,t)}function K0(e,t,r,n){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((t-e)/(r-1)))return{step:new ie(0),tickMin:new ie(0),tickMax:new ie(0)};var a=G0(new ie(t).sub(e).div(r-1),n,i),o;e<=0&&t>=0?o=new ie(0):(o=new ie(e).add(t).div(2),o=o.sub(new ie(o).mod(a)));var u=Math.ceil(o.sub(e).div(a).toNumber()),c=Math.ceil(new ie(t).sub(o).div(a).toNumber()),s=u+c+1;return s>r?K0(e,t,r,n,i+1):(s0?c+(r-s):c,u=t>0?u:u+(r-s)),{step:a,tickMin:o.sub(new ie(u).mul(a)),tickMax:o.add(new ie(c).mul(a))})}function ME(e){var t=Sn(e,2),r=t[0],n=t[1],i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=Math.max(i,2),u=H0([r,n]),c=Sn(u,2),s=c[0],f=c[1];if(s===-1/0||f===1/0){var l=f===1/0?[s].concat(xl(gl(0,i-1).map(function(){return 1/0}))):[].concat(xl(gl(0,i-1).map(function(){return-1/0})),[f]);return r>n?bl(l):l}if(s===f)return jE(s,i,a);var h=K0(s,f,o,a),d=h.step,m=h.tickMin,v=h.tickMax,p=$a.rangeStep(m,v.add(new ie(.1).mul(d)),d);return r>n?bl(p):p}function CE(e,t){var r=Sn(e,2),n=r[0],i=r[1],a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=H0([n,i]),u=Sn(o,2),c=u[0],s=u[1];if(c===-1/0||s===1/0)return[n,i];if(c===s)return[c];var f=Math.max(t,2),l=G0(new ie(s).sub(c).div(f-1),a,0),h=[].concat(xl($a.rangeStep(new ie(c),new ie(s).sub(new ie(.99).mul(l)),l)),[s]);return n>i?bl(h):h}var $E=W0(ME),IE=W0(CE),RE="Invariant failed";function Zt(e,t){throw new Error(RE)}var kE=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function _r(e){"@babel/helpers - typeof";return _r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_r(e)}function Li(){return Li=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function zE(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function WE(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function UE(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r1&&arguments[1]!==void 0?arguments[1]:[],i=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,o=-1,u=(r=n?.length)!==null&&r!==void 0?r:0;if(u<=1)return 0;if(a&&a.axisType==="angleAxis"&&Math.abs(Math.abs(a.range[1]-a.range[0])-360)<=1e-6)for(var c=a.range,s=0;s0?i[s-1].coordinate:i[u-1].coordinate,l=i[s].coordinate,h=s>=u-1?i[0].coordinate:i[s+1].coordinate,d=void 0;if(Ze(l-f)!==Ze(h-l)){var m=[];if(Ze(h-l)===Ze(c[1]-c[0])){d=h;var v=l+c[1]-c[0];m[0]=Math.min(v,(v+f)/2),m[1]=Math.max(v,(v+f)/2)}else{d=f;var p=h+c[1]-c[0];m[0]=Math.min(l,(p+l)/2),m[1]=Math.max(l,(p+l)/2)}var b=[Math.min(l,(d+l)/2),Math.max(l,(d+l)/2)];if(t>b[0]&&t<=b[1]||t>=m[0]&&t<=m[1]){o=i[s].index;break}}else{var x=Math.min(f,h),w=Math.max(f,h);if(t>(x+l)/2&&t<=(w+l)/2){o=i[s].index;break}}}else for(var O=0;O0&&O(n[O].coordinate+n[O-1].coordinate)/2&&t<=(n[O].coordinate+n[O+1].coordinate)/2||O===u-1&&t>(n[O].coordinate+n[O-1].coordinate)/2){o=n[O].index;break}return o},Qf=function(t){var r,n=t,i=n.type.displayName,a=(r=t.type)!==null&&r!==void 0&&r.defaultProps?pe(pe({},t.type.defaultProps),t.props):t.props,o=a.stroke,u=a.fill,c;switch(i){case"Line":c=o;break;case"Area":case"Radar":c=o&&o!=="none"?o:u;break;default:c=u;break}return c},uj=function(t){var r=t.barSize,n=t.totalSize,i=t.stackGroups,a=i===void 0?{}:i;if(!a)return{};for(var o={},u=Object.keys(a),c=0,s=u.length;c=0});if(b&&b.length){var x=b[0].type.defaultProps,w=x!==void 0?pe(pe({},x),b[0].props):b[0].props,O=w.barSize,y=w[p];o[y]||(o[y]=[]);var g=J(O)?r:O;o[y].push({item:b[0],stackList:b.slice(1),barSize:J(g)?void 0:Je(g,n,0)})}}return o},cj=function(t){var r=t.barGap,n=t.barCategoryGap,i=t.bandSize,a=t.sizeList,o=a===void 0?[]:a,u=t.maxBarSize,c=o.length;if(c<1)return null;var s=Je(r,i,0,!0),f,l=[];if(o[0].barSize===+o[0].barSize){var h=!1,d=i/c,m=o.reduce(function(O,y){return O+y.barSize||0},0);m+=(c-1)*s,m>=i&&(m-=(c-1)*s,s=0),m>=i&&d>0&&(h=!0,d*=.9,m=c*d);var v=(i-m)/2>>0,p={offset:v-s,size:0};f=o.reduce(function(O,y){var g={item:y.item,position:{offset:p.offset+p.size+s,size:h?d:y.barSize}},_=[].concat(rm(O),[g]);return p=_[_.length-1].position,y.stackList&&y.stackList.length&&y.stackList.forEach(function(S){_.push({item:S,position:p})}),_},l)}else{var b=Je(n,i,0,!0);i-2*b-(c-1)*s<=0&&(s=0);var x=(i-2*b-(c-1)*s)/c;x>1&&(x>>=0);var w=u===+u?Math.min(x,u):x;f=o.reduce(function(O,y,g){var _=[].concat(rm(O),[{item:y.item,position:{offset:b+(x+s)*g+(x-w)/2,size:w}}]);return y.stackList&&y.stackList.length&&y.stackList.forEach(function(S){_.push({item:S,position:_[_.length-1].position})}),_},l)}return f},sj=function(t,r,n,i){var a=n.children,o=n.width,u=n.margin,c=o-(u.left||0)-(u.right||0),s=Z0({children:a,legendWidth:c});if(s){var f=i||{},l=f.width,h=f.height,d=s.align,m=s.verticalAlign,v=s.layout;if((v==="vertical"||v==="horizontal"&&m==="middle")&&d!=="center"&&q(t[d]))return pe(pe({},t),{},dr({},d,t[d]+(l||0)));if((v==="horizontal"||v==="vertical"&&d==="center")&&m!=="middle"&&q(t[m]))return pe(pe({},t),{},dr({},m,t[m]+(h||0)))}return t},lj=function(t,r,n){return J(r)?!0:t==="horizontal"?r==="yAxis":t==="vertical"||n==="x"?r==="xAxis":n==="y"?r==="yAxis":!0},J0=function(t,r,n,i,a){var o=r.props.children,u=Qe(o,Ia).filter(function(s){return lj(i,a,s.props.direction)});if(u&&u.length){var c=u.map(function(s){return s.props.dataKey});return t.reduce(function(s,f){var l=Be(f,n);if(J(l))return s;var h=Array.isArray(l)?[Ma(l),Tt(l)]:[l,l],d=c.reduce(function(m,v){var p=Be(f,v,0),b=h[0]-Math.abs(Array.isArray(p)?p[0]:p),x=h[1]+Math.abs(Array.isArray(p)?p[1]:p);return[Math.min(b,m[0]),Math.max(x,m[1])]},[1/0,-1/0]);return[Math.min(d[0],s[0]),Math.max(d[1],s[1])]},[1/0,-1/0])}return null},fj=function(t,r,n,i,a){var o=r.map(function(u){return J0(t,u,n,a,i)}).filter(function(u){return!J(u)});return o&&o.length?o.reduce(function(u,c){return[Math.min(u[0],c[0]),Math.max(u[1],c[1])]},[1/0,-1/0]):null},Q0=function(t,r,n,i,a){var o=r.map(function(c){var s=c.props.dataKey;return n==="number"&&s&&J0(t,c,s,i)||un(t,s,n,a)});if(n==="number")return o.reduce(function(c,s){return[Math.min(c[0],s[0]),Math.max(c[1],s[1])]},[1/0,-1/0]);var u={};return o.reduce(function(c,s){for(var f=0,l=s.length;f=2?Ze(u[0]-u[1])*2*s:s,r&&(t.ticks||t.niceTicks)){var f=(t.ticks||t.niceTicks).map(function(l){var h=a?a.indexOf(l):l;return{coordinate:i(h)+s,value:l,offset:s}});return f.filter(function(l){return!Br(l.coordinate)})}return t.isCategorical&&t.categoricalDomain?t.categoricalDomain.map(function(l,h){return{coordinate:i(l)+s,value:l,index:h,offset:s}}):i.ticks&&!n?i.ticks(t.tickCount).map(function(l){return{coordinate:i(l)+s,value:l,offset:s}}):i.domain().map(function(l,h){return{coordinate:i(l)+s,value:a?a[l]:l,index:h,offset:s}})},ps=new WeakMap,si=function(t,r){if(typeof r!="function")return t;ps.has(t)||ps.set(t,new WeakMap);var n=ps.get(t);if(n.has(r))return n.get(r);var i=function(){t.apply(void 0,arguments),r.apply(void 0,arguments)};return n.set(r,i),i},rx=function(t,r,n){var i=t.scale,a=t.type,o=t.layout,u=t.axisType;if(i==="auto")return o==="radial"&&u==="radiusAxis"?{scale:mn(),realScaleType:"band"}:o==="radial"&&u==="angleAxis"?{scale:ki(),realScaleType:"linear"}:a==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?{scale:on(),realScaleType:"point"}:a==="category"?{scale:mn(),realScaleType:"band"}:{scale:ki(),realScaleType:"linear"};if(Xt(i)){var c="scale".concat(ma(i));return{scale:(zy[c]||on)(),realScaleType:zy[c]?c:"point"}}return V(i)?{scale:i}:{scale:on(),realScaleType:"point"}},im=1e-4,nx=function(t){var r=t.domain();if(!(!r||r.length<=2)){var n=r.length,i=t.range(),a=Math.min(i[0],i[1])-im,o=Math.max(i[0],i[1])+im,u=t(r[0]),c=t(r[n-1]);(uo||co)&&t.domain([r[0],r[n-1]])}},hj=function(t,r){if(!t)return null;for(var n=0,i=t.length;ni)&&(a[1]=i),a[0]>i&&(a[0]=i),a[1]=0?(t[u][n][0]=a,t[u][n][1]=a+c,a=t[u][n][1]):(t[u][n][0]=o,t[u][n][1]=o+c,o=t[u][n][1])}},vj=function(t){var r=t.length;if(!(r<=0))for(var n=0,i=t[0].length;n=0?(t[o][n][0]=a,t[o][n][1]=a+u,a=t[o][n][1]):(t[o][n][0]=0,t[o][n][1]=0)}},yj={sign:dj,expand:t1,none:vr,silhouette:r1,wiggle:n1,positive:vj},mj=function(t,r,n){var i=r.map(function(u){return u.props.dataKey}),a=yj[n],o=e1().keys(i).value(function(u,c){return+Be(u,c,0)}).order(Qs).offset(a);return o(t)},gj=function(t,r,n,i,a,o){if(!t)return null;var u=o?r.reverse():r,c={},s=u.reduce(function(l,h){var d,m=(d=h.type)!==null&&d!==void 0&&d.defaultProps?pe(pe({},h.type.defaultProps),h.props):h.props,v=m.stackId,p=m.hide;if(p)return l;var b=m[n],x=l[b]||{hasStack:!1,stackGroups:{}};if(we(v)){var w=x.stackGroups[v]||{numericAxisId:n,cateAxisId:i,items:[]};w.items.push(h),x.hasStack=!0,x.stackGroups[v]=w}else x.stackGroups[Kn("_stackId_")]={numericAxisId:n,cateAxisId:i,items:[h]};return pe(pe({},l),{},dr({},b,x))},c),f={};return Object.keys(s).reduce(function(l,h){var d=s[h];if(d.hasStack){var m={};d.stackGroups=Object.keys(d.stackGroups).reduce(function(v,p){var b=d.stackGroups[p];return pe(pe({},v),{},dr({},p,{numericAxisId:n,cateAxisId:i,items:b.items,stackedData:mj(t,b.items,a)}))},m)}return pe(pe({},l),{},dr({},h,d))},f)},ix=function(t,r){var n=r.realScaleType,i=r.type,a=r.tickCount,o=r.originalDomain,u=r.allowDecimals,c=n||r.scale;if(c!=="auto"&&c!=="linear")return null;if(a&&i==="number"&&o&&(o[0]==="auto"||o[1]==="auto")){var s=t.domain();if(!s.length)return null;var f=$E(s,a,u);return t.domain([Ma(f),Tt(f)]),{niceTicks:f}}if(a&&i==="number"){var l=t.domain(),h=IE(l,a,u);return{niceTicks:h}}return null};function am(e){var t=e.axis,r=e.ticks,n=e.bandSize,i=e.entry,a=e.index,o=e.dataKey;if(t.type==="category"){if(!t.allowDuplicatedCategory&&t.dataKey&&!J(i[t.dataKey])){var u=vi(r,"value",i[t.dataKey]);if(u)return u.coordinate+n/2}return r[a]?r[a].coordinate+n/2:null}var c=Be(i,J(o)?t.dataKey:o);return J(c)?null:t.scale(c)}var om=function(t){var r=t.axis,n=t.ticks,i=t.offset,a=t.bandSize,o=t.entry,u=t.index;if(r.type==="category")return n[u]?n[u].coordinate+i:null;var c=Be(o,r.dataKey,r.domain[u]);return J(c)?null:r.scale(c)-a/2+i},bj=function(t){var r=t.numericAxis,n=r.scale.domain();if(r.type==="number"){var i=Math.min(n[0],n[1]),a=Math.max(n[0],n[1]);return i<=0&&a>=0?0:a<0?a:i}return n[0]},xj=function(t,r){var n,i=(n=t.type)!==null&&n!==void 0&&n.defaultProps?pe(pe({},t.type.defaultProps),t.props):t.props,a=i.stackId;if(we(a)){var o=r[a];if(o){var u=o.items.indexOf(t);return u>=0?o.stackedData[u]:null}}return null},wj=function(t){return t.reduce(function(r,n){return[Ma(n.concat([r[0]]).filter(q)),Tt(n.concat([r[1]]).filter(q))]},[1/0,-1/0])},ax=function(t,r,n){return Object.keys(t).reduce(function(i,a){var o=t[a],u=o.stackedData,c=u.reduce(function(s,f){var l=wj(f.slice(r,n+1));return[Math.min(s[0],l[0]),Math.max(s[1],l[1])]},[1/0,-1/0]);return[Math.min(c[0],i[0]),Math.max(c[1],i[1])]},[1/0,-1/0]).map(function(i){return i===1/0||i===-1/0?0:i})},um=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,cm=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Sl=function(t,r,n){if(V(t))return t(r,n);if(!Array.isArray(t))return r;var i=[];if(q(t[0]))i[0]=n?t[0]:Math.min(t[0],r[0]);else if(um.test(t[0])){var a=+um.exec(t[0])[1];i[0]=r[0]-a}else V(t[0])?i[0]=t[0](r[0]):i[0]=r[0];if(q(t[1]))i[1]=n?t[1]:Math.max(t[1],r[1]);else if(cm.test(t[1])){var o=+cm.exec(t[1])[1];i[1]=r[1]+o}else V(t[1])?i[1]=t[1](r[1]):i[1]=r[1];return i},zi=function(t,r,n){if(t&&t.scale&&t.scale.bandwidth){var i=t.scale.bandwidth();if(!n||i>0)return i}if(t&&r&&r.length>=2){for(var a=Tf(r,function(l){return l.coordinate}),o=1/0,u=1,c=a.length;ue.length)&&(t=e.length);for(var r=0,n=new Array(t);r2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(t-(n.left||0)-(n.right||0)),Math.abs(r-(n.top||0)-(n.bottom||0)))/2},cN=function(t,r,n,i,a){var o=t.width,u=t.height,c=t.startAngle,s=t.endAngle,f=Je(t.cx,o,o/2),l=Je(t.cy,u,u/2),h=Mj(o,u,n),d=Je(t.innerRadius,h,0),m=Je(t.outerRadius,h,h*.8),v=Object.keys(r);return v.reduce(function(p,b){var x=r[b],w=x.domain,O=x.reversed,y;if(J(x.range))i==="angleAxis"?y=[c,s]:i==="radiusAxis"&&(y=[d,m]),O&&(y=[y[1],y[0]]);else{y=x.range;var g=y,_=Sj(g,2);c=_[0],s=_[1]}var S=rx(x,a),P=S.realScaleType,M=S.scale;M.domain(w).range(y),nx(M);var A=ix(M,st(st({},x),{},{realScaleType:P})),E=st(st(st({},x),A),{},{range:y,radius:m,realScaleType:P,scale:M,cx:f,cy:l,innerRadius:d,outerRadius:m,startAngle:c,endAngle:s});return st(st({},p),{},ux({},b,E))},{})},Cj=function(t,r){var n=t.x,i=t.y,a=r.x,o=r.y;return Math.sqrt(Math.pow(n-a,2)+Math.pow(i-o,2))},$j=function(t,r){var n=t.x,i=t.y,a=r.cx,o=r.cy,u=Cj({x:n,y:i},{x:a,y:o});if(u<=0)return{radius:u};var c=(n-a)/u,s=Math.acos(c);return i>o&&(s=2*Math.PI-s),{radius:u,angle:jj(s),angleInRadian:s}},Ij=function(t){var r=t.startAngle,n=t.endAngle,i=Math.floor(r/360),a=Math.floor(n/360),o=Math.min(i,a);return{startAngle:r-o*360,endAngle:n-o*360}},Rj=function(t,r){var n=r.startAngle,i=r.endAngle,a=Math.floor(n/360),o=Math.floor(i/360),u=Math.min(a,o);return t+u*360},hm=function(t,r){var n=t.x,i=t.y,a=$j({x:n,y:i},r),o=a.radius,u=a.angle,c=r.innerRadius,s=r.outerRadius;if(os)return!1;if(o===0)return!0;var f=Ij(r),l=f.startAngle,h=f.endAngle,d=u,m;if(l<=h){for(;d>h;)d-=360;for(;d=l&&d<=h}else{for(;d>l;)d-=360;for(;d=h&&d<=l}return m?st(st({},r),{},{radius:o,angle:Rj(d,r)}):null},sN=function(t){return!N.isValidElement(t)&&!V(t)&&typeof t!="boolean"?t.className:""};function En(e){"@babel/helpers - typeof";return En=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},En(e)}var kj=["offset"];function Dj(e){return Lj(e)||Bj(e)||qj(e)||Nj()}function Nj(){throw new TypeError(`Invalid attempt to spread non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function qj(e,t){if(e){if(typeof e=="string")return Al(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Al(e,t)}}function Bj(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Lj(e){if(Array.isArray(e))return Al(e)}function Al(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function zj(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function pm(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function xe(e){for(var t=1;t=0?1:-1,w,O;i==="insideStart"?(w=d+x*o,O=v):i==="insideEnd"?(w=m-x*o,O=!v):i==="end"&&(w=m+x*o,O=v),O=b<=0?O:!O;var y=Pe(s,f,p,w),g=Pe(s,f,p,w+(O?1:-1)*359),_="M".concat(y.x,",").concat(y.y,` - A`).concat(p,",").concat(p,",0,1,").concat(O?0:1,`, - `).concat(g.x,",").concat(g.y),S=J(t.id)?Kn("recharts-radial-line-"):t.id;return T.createElement("text",jn({},n,{dominantBaseline:"central",className:ee("recharts-radial-bar-label",u)}),T.createElement("defs",null,T.createElement("path",{id:S,d:_})),T.createElement("textPath",{xlinkHref:"#".concat(S)},r))},Xj=function(t){var r=t.viewBox,n=t.offset,i=t.position,a=r,o=a.cx,u=a.cy,c=a.innerRadius,s=a.outerRadius,f=a.startAngle,l=a.endAngle,h=(f+l)/2;if(i==="outside"){var d=Pe(o,u,s+n,h),m=d.x,v=d.y;return{x:m,y:v,textAnchor:m>=o?"start":"end",verticalAnchor:"middle"}}if(i==="center")return{x:o,y:u,textAnchor:"middle",verticalAnchor:"middle"};if(i==="centerTop")return{x:o,y:u,textAnchor:"middle",verticalAnchor:"start"};if(i==="centerBottom")return{x:o,y:u,textAnchor:"middle",verticalAnchor:"end"};var p=(c+s)/2,b=Pe(o,u,p,h),x=b.x,w=b.y;return{x,y:w,textAnchor:"middle",verticalAnchor:"middle"}},Yj=function(t){var r=t.viewBox,n=t.parentViewBox,i=t.offset,a=t.position,o=r,u=o.x,c=o.y,s=o.width,f=o.height,l=f>=0?1:-1,h=l*i,d=l>0?"end":"start",m=l>0?"start":"end",v=s>=0?1:-1,p=v*i,b=v>0?"end":"start",x=v>0?"start":"end";if(a==="top"){var w={x:u+s/2,y:c-l*i,textAnchor:"middle",verticalAnchor:d};return xe(xe({},w),n?{height:Math.max(c-n.y,0),width:s}:{})}if(a==="bottom"){var O={x:u+s/2,y:c+f+h,textAnchor:"middle",verticalAnchor:m};return xe(xe({},O),n?{height:Math.max(n.y+n.height-(c+f),0),width:s}:{})}if(a==="left"){var y={x:u-p,y:c+f/2,textAnchor:b,verticalAnchor:"middle"};return xe(xe({},y),n?{width:Math.max(y.x-n.x,0),height:f}:{})}if(a==="right"){var g={x:u+s+p,y:c+f/2,textAnchor:x,verticalAnchor:"middle"};return xe(xe({},g),n?{width:Math.max(n.x+n.width-g.x,0),height:f}:{})}var _=n?{width:s,height:f}:{};return a==="insideLeft"?xe({x:u+p,y:c+f/2,textAnchor:x,verticalAnchor:"middle"},_):a==="insideRight"?xe({x:u+s-p,y:c+f/2,textAnchor:b,verticalAnchor:"middle"},_):a==="insideTop"?xe({x:u+s/2,y:c+h,textAnchor:"middle",verticalAnchor:m},_):a==="insideBottom"?xe({x:u+s/2,y:c+f-h,textAnchor:"middle",verticalAnchor:d},_):a==="insideTopLeft"?xe({x:u+p,y:c+h,textAnchor:x,verticalAnchor:m},_):a==="insideTopRight"?xe({x:u+s-p,y:c+h,textAnchor:b,verticalAnchor:m},_):a==="insideBottomLeft"?xe({x:u+p,y:c+f-h,textAnchor:x,verticalAnchor:d},_):a==="insideBottomRight"?xe({x:u+s-p,y:c+f-h,textAnchor:b,verticalAnchor:d},_):qr(a)&&(q(a.x)||zt(a.x))&&(q(a.y)||zt(a.y))?xe({x:u+Je(a.x,s),y:c+Je(a.y,f),textAnchor:"end",verticalAnchor:"end"},_):xe({x:u+s/2,y:c+f/2,textAnchor:"middle",verticalAnchor:"middle"},_)},Zj=function(t){return"cx"in t&&q(t.cx)};function Ee(e){var t=e.offset,r=t===void 0?5:t,n=Fj(e,kj),i=xe({offset:r},n),a=i.viewBox,o=i.position,u=i.value,c=i.children,s=i.content,f=i.className,l=f===void 0?"":f,h=i.textBreakAll;if(!a||J(u)&&J(c)&&!N.isValidElement(s)&&!V(s))return null;if(N.isValidElement(s))return N.cloneElement(s,i);var d;if(V(s)){if(d=N.createElement(s,i),N.isValidElement(d))return d}else d=Gj(i);var m=Zj(a),v=Z(i,!0);if(m&&(o==="insideStart"||o==="insideEnd"||o==="end"))return Vj(i,d,v);var p=m?Xj(i):Yj(i);return T.createElement(Ei,jn({className:ee("recharts-label",l)},v,p,{breakAll:h}),d)}Ee.displayName="Label";var cx=function(t){var r=t.cx,n=t.cy,i=t.angle,a=t.startAngle,o=t.endAngle,u=t.r,c=t.radius,s=t.innerRadius,f=t.outerRadius,l=t.x,h=t.y,d=t.top,m=t.left,v=t.width,p=t.height,b=t.clockWise,x=t.labelViewBox;if(x)return x;if(q(v)&&q(p)){if(q(l)&&q(h))return{x:l,y:h,width:v,height:p};if(q(d)&&q(m))return{x:d,y:m,width:v,height:p}}return q(l)&&q(h)?{x:l,y:h,width:0,height:0}:q(r)&&q(n)?{cx:r,cy:n,startAngle:a||i||0,endAngle:o||i||0,innerRadius:s||0,outerRadius:f||c||u||0,clockWise:b}:t.viewBox?t.viewBox:{}},Jj=function(t,r){return t?t===!0?T.createElement(Ee,{key:"label-implicit",viewBox:r}):we(t)?T.createElement(Ee,{key:"label-implicit",viewBox:r,value:t}):N.isValidElement(t)?t.type===Ee?N.cloneElement(t,{key:"label-implicit",viewBox:r}):T.createElement(Ee,{key:"label-implicit",content:t,viewBox:r}):V(t)?T.createElement(Ee,{key:"label-implicit",content:t,viewBox:r}):qr(t)?T.createElement(Ee,jn({viewBox:r},t,{key:"label-implicit"})):null:null},Qj=function(t,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!t||!t.children&&n&&!t.label)return null;var i=t.children,a=cx(t),o=Qe(i,Ee).map(function(c,s){return N.cloneElement(c,{viewBox:r||a,key:"label-".concat(s)})});if(!n)return o;var u=Jj(t.label,r||a);return[u].concat(Dj(o))};Ee.parseViewBox=cx;Ee.renderCallByParent=Qj;var ds,dm;function eM(){if(dm)return ds;dm=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return ds=e,ds}var tM=eM();const rM=ue(tM);function Mn(e){"@babel/helpers - typeof";return Mn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Mn(e)}var nM=["valueAccessor"],iM=["data","dataKey","clockWise","id","textBreakAll"];function aM(e){return sM(e)||cM(e)||uM(e)||oM()}function oM(){throw new TypeError(`Invalid attempt to spread non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function uM(e,t){if(e){if(typeof e=="string")return Pl(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Pl(e,t)}}function cM(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function sM(e){if(Array.isArray(e))return Pl(e)}function Pl(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function pM(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}var dM=function(t){return Array.isArray(t.value)?rM(t.value):t.value};function Mt(e){var t=e.valueAccessor,r=t===void 0?dM:t,n=mm(e,nM),i=n.data,a=n.dataKey,o=n.clockWise,u=n.id,c=n.textBreakAll,s=mm(n,iM);return!i||!i.length?null:T.createElement(fe,{className:"recharts-label-list"},i.map(function(f,l){var h=J(a)?r(f,l):Be(f&&f.payload,a),d=J(u)?{}:{id:"".concat(u,"-").concat(l)};return T.createElement(Ee,Ui({},Z(f,!0),s,d,{parentViewBox:f.parentViewBox,value:h,textBreakAll:c,viewBox:Ee.parseViewBox(J(o)?f:ym(ym({},f),{},{clockWise:o})),key:"label-".concat(l),index:l}))}))}Mt.displayName="LabelList";function vM(e,t){return e?e===!0?T.createElement(Mt,{key:"labelList-implicit",data:t}):T.isValidElement(e)||V(e)?T.createElement(Mt,{key:"labelList-implicit",data:t,content:e}):qr(e)?T.createElement(Mt,Ui({data:t},e,{key:"labelList-implicit"})):null:null}function yM(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e||!e.children&&r&&!e.label)return null;var n=e.children,i=Qe(n,Mt).map(function(o,u){return N.cloneElement(o,{data:t,key:"labelList-".concat(u)})});if(!r)return i;var a=vM(e.label,t);return[a].concat(aM(i))}Mt.renderCallByParent=yM;function Cn(e){"@babel/helpers - typeof";return Cn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Cn(e)}function Tl(){return Tl=Object.assign?Object.assign.bind():function(e){for(var t=1;t180),",").concat(+(o>s),`, - `).concat(l.x,",").concat(l.y,` - `);if(i>0){var d=Pe(r,n,i,o),m=Pe(r,n,i,s);h+="L ".concat(m.x,",").concat(m.y,` - A `).concat(i,",").concat(i,`,0, - `).concat(+(Math.abs(c)>180),",").concat(+(o<=s),`, - `).concat(d.x,",").concat(d.y," Z")}else h+="L ".concat(r,",").concat(n," Z");return h},wM=function(t){var r=t.cx,n=t.cy,i=t.innerRadius,a=t.outerRadius,o=t.cornerRadius,u=t.forceCornerRadius,c=t.cornerIsExternal,s=t.startAngle,f=t.endAngle,l=Ze(f-s),h=li({cx:r,cy:n,radius:a,angle:s,sign:l,cornerRadius:o,cornerIsExternal:c}),d=h.circleTangency,m=h.lineTangency,v=h.theta,p=li({cx:r,cy:n,radius:a,angle:f,sign:-l,cornerRadius:o,cornerIsExternal:c}),b=p.circleTangency,x=p.lineTangency,w=p.theta,O=c?Math.abs(s-f):Math.abs(s-f)-v-w;if(O<0)return u?"M ".concat(m.x,",").concat(m.y,` - a`).concat(o,",").concat(o,",0,0,1,").concat(o*2,`,0 - a`).concat(o,",").concat(o,",0,0,1,").concat(-o*2,`,0 - `):sx({cx:r,cy:n,innerRadius:i,outerRadius:a,startAngle:s,endAngle:f});var y="M ".concat(m.x,",").concat(m.y,` - A`).concat(o,",").concat(o,",0,0,").concat(+(l<0),",").concat(d.x,",").concat(d.y,` - A`).concat(a,",").concat(a,",0,").concat(+(O>180),",").concat(+(l<0),",").concat(b.x,",").concat(b.y,` - A`).concat(o,",").concat(o,",0,0,").concat(+(l<0),",").concat(x.x,",").concat(x.y,` - `);if(i>0){var g=li({cx:r,cy:n,radius:i,angle:s,sign:l,isExternal:!0,cornerRadius:o,cornerIsExternal:c}),_=g.circleTangency,S=g.lineTangency,P=g.theta,M=li({cx:r,cy:n,radius:i,angle:f,sign:-l,isExternal:!0,cornerRadius:o,cornerIsExternal:c}),A=M.circleTangency,E=M.lineTangency,j=M.theta,I=c?Math.abs(s-f):Math.abs(s-f)-P-j;if(I<0&&o===0)return"".concat(y,"L").concat(r,",").concat(n,"Z");y+="L".concat(E.x,",").concat(E.y,` - A`).concat(o,",").concat(o,",0,0,").concat(+(l<0),",").concat(A.x,",").concat(A.y,` - A`).concat(i,",").concat(i,",0,").concat(+(I>180),",").concat(+(l>0),",").concat(_.x,",").concat(_.y,` - A`).concat(o,",").concat(o,",0,0,").concat(+(l<0),",").concat(S.x,",").concat(S.y,"Z")}else y+="L".concat(r,",").concat(n,"Z");return y},OM={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},lx=function(t){var r=bm(bm({},OM),t),n=r.cx,i=r.cy,a=r.innerRadius,o=r.outerRadius,u=r.cornerRadius,c=r.forceCornerRadius,s=r.cornerIsExternal,f=r.startAngle,l=r.endAngle,h=r.className;if(o0&&Math.abs(f-l)<360?p=wM({cx:n,cy:i,innerRadius:a,outerRadius:o,cornerRadius:Math.min(v,m/2),forceCornerRadius:c,cornerIsExternal:s,startAngle:f,endAngle:l}):p=sx({cx:n,cy:i,innerRadius:a,outerRadius:o,startAngle:f,endAngle:l}),T.createElement("path",Tl({},Z(r,!0),{className:d,d:p,role:"img"}))};function $n(e){"@babel/helpers - typeof";return $n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$n(e)}function El(){return El=Object.assign?Object.assign.bind():function(e){for(var t=1;tRM.call(e,t));function rr(e,t){return e===t||!e&&!t&&e!==e&&t!==t}const NM="__v",qM="__o",BM="_owner",{getOwnPropertyDescriptor:Tm,keys:Em}=Object;function LM(e,t){return e.byteLength===t.byteLength&&Hi(new Uint8Array(e),new Uint8Array(t))}function FM(e,t,r){let n=e.length;if(t.length!==n)return!1;for(;n-- >0;)if(!r.equals(e[n],t[n],n,n,e,t,r))return!1;return!0}function zM(e,t){return e.byteLength===t.byteLength&&Hi(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function WM(e,t){return rr(e.getTime(),t.getTime())}function UM(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function HM(e,t){return e===t}function jm(e,t,r){const n=e.size;if(n!==t.size)return!1;if(!n)return!0;const i=new Array(n),a=e.entries();let o,u,c=0;for(;(o=a.next())&&!o.done;){const s=t.entries();let f=!1,l=0;for(;(u=s.next())&&!u.done;){if(i[l]){l++;continue}const h=o.value,d=u.value;if(r.equals(h[0],d[0],c,l,e,t,r)&&r.equals(h[1],d[1],h[0],d[0],e,t,r)){f=i[l]=!0;break}l++}if(!f)return!1;c++}return!0}const GM=rr;function KM(e,t,r){const n=Em(e);let i=n.length;if(Em(t).length!==i)return!1;for(;i-- >0;)if(!fx(e,t,r,n[i]))return!1;return!0}function Qr(e,t,r){const n=Pm(e);let i=n.length;if(Pm(t).length!==i)return!1;let a,o,u;for(;i-- >0;)if(a=n[i],!fx(e,t,r,a)||(o=Tm(e,a),u=Tm(t,a),(o||u)&&(!o||!u||o.configurable!==u.configurable||o.enumerable!==u.enumerable||o.writable!==u.writable)))return!1;return!0}function VM(e,t){return rr(e.valueOf(),t.valueOf())}function XM(e,t){return e.source===t.source&&e.flags===t.flags}function Mm(e,t,r){const n=e.size;if(n!==t.size)return!1;if(!n)return!0;const i=new Array(n),a=e.values();let o,u;for(;(o=a.next())&&!o.done;){const c=t.values();let s=!1,f=0;for(;(u=c.next())&&!u.done;){if(!i[f]&&r.equals(o.value,u.value,o.value,u.value,e,t,r)){s=i[f]=!0;break}f++}if(!s)return!1}return!0}function Hi(e,t){let r=e.byteLength;if(t.byteLength!==r||e.byteOffset!==t.byteOffset)return!1;for(;r-- >0;)if(e[r]!==t[r])return!1;return!0}function YM(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function fx(e,t,r,n){return(n===BM||n===qM||n===NM)&&(e.$$typeof||t.$$typeof)?!0:DM(t,n)&&r.equals(e[n],t[n],n,n,e,t,r)}const ZM="[object ArrayBuffer]",JM="[object Arguments]",QM="[object Boolean]",eC="[object DataView]",tC="[object Date]",rC="[object Error]",nC="[object Map]",iC="[object Number]",aC="[object Object]",oC="[object RegExp]",uC="[object Set]",cC="[object String]",sC={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},lC="[object URL]",fC=Object.prototype.toString;function hC({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:r,areDatesEqual:n,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:u,areObjectsEqual:c,arePrimitiveWrappersEqual:s,areRegExpsEqual:f,areSetsEqual:l,areTypedArraysEqual:h,areUrlsEqual:d,unknownTagComparators:m}){return function(p,b,x){if(p===b)return!0;if(p==null||b==null)return!1;const w=typeof p;if(w!==typeof b)return!1;if(w!=="object")return w==="number"?u(p,b,x):w==="function"?a(p,b,x):!1;const O=p.constructor;if(O!==b.constructor)return!1;if(O===Object)return c(p,b,x);if(Array.isArray(p))return t(p,b,x);if(O===Date)return n(p,b,x);if(O===RegExp)return f(p,b,x);if(O===Map)return o(p,b,x);if(O===Set)return l(p,b,x);const y=fC.call(p);if(y===tC)return n(p,b,x);if(y===oC)return f(p,b,x);if(y===nC)return o(p,b,x);if(y===uC)return l(p,b,x);if(y===aC)return typeof p.then!="function"&&typeof b.then!="function"&&c(p,b,x);if(y===lC)return d(p,b,x);if(y===rC)return i(p,b,x);if(y===JM)return c(p,b,x);if(sC[y])return h(p,b,x);if(y===ZM)return e(p,b,x);if(y===eC)return r(p,b,x);if(y===QM||y===iC||y===cC)return s(p,b,x);if(m){let g=m[y];if(!g){const _=kM(p);_&&(g=m[_])}if(g)return g(p,b,x)}return!1}}function pC({circular:e,createCustomConfig:t,strict:r}){let n={areArrayBuffersEqual:LM,areArraysEqual:r?Qr:FM,areDataViewsEqual:zM,areDatesEqual:WM,areErrorsEqual:UM,areFunctionsEqual:HM,areMapsEqual:r?gs(jm,Qr):jm,areNumbersEqual:GM,areObjectsEqual:r?Qr:KM,arePrimitiveWrappersEqual:VM,areRegExpsEqual:XM,areSetsEqual:r?gs(Mm,Qr):Mm,areTypedArraysEqual:r?gs(Hi,Qr):Hi,areUrlsEqual:YM,unknownTagComparators:void 0};if(t&&(n=Object.assign({},n,t(n))),e){const i=hi(n.areArraysEqual),a=hi(n.areMapsEqual),o=hi(n.areObjectsEqual),u=hi(n.areSetsEqual);n=Object.assign({},n,{areArraysEqual:i,areMapsEqual:a,areObjectsEqual:o,areSetsEqual:u})}return n}function dC(e){return function(t,r,n,i,a,o,u){return e(t,r,u)}}function vC({circular:e,comparator:t,createState:r,equals:n,strict:i}){if(r)return function(u,c){const{cache:s=e?new WeakMap:void 0,meta:f}=r();return t(u,c,{cache:s,equals:n,meta:f,strict:i})};if(e)return function(u,c){return t(u,c,{cache:new WeakMap,equals:n,meta:void 0,strict:i})};const a={cache:void 0,equals:n,meta:void 0,strict:i};return function(u,c){return t(u,c,a)}}const yC=kt();kt({strict:!0});kt({circular:!0});kt({circular:!0,strict:!0});kt({createInternalComparator:()=>rr});kt({strict:!0,createInternalComparator:()=>rr});kt({circular:!0,createInternalComparator:()=>rr});kt({circular:!0,createInternalComparator:()=>rr,strict:!0});function kt(e={}){const{circular:t=!1,createInternalComparator:r,createState:n,strict:i=!1}=e,a=pC(e),o=hC(a),u=r?r(o):dC(o);return vC({circular:t,comparator:o,createState:n,equals:u,strict:i})}function mC(e){typeof requestAnimationFrame<"u"&&requestAnimationFrame(e)}function Cm(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=-1,n=function i(a){r<0&&(r=a),a-r>t?(e(a),r=-1):mC(i)};requestAnimationFrame(n)}function jl(e){"@babel/helpers - typeof";return jl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},jl(e)}function gC(e){return OC(e)||wC(e)||xC(e)||bC()}function bC(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function xC(e,t){if(e){if(typeof e=="string")return $m(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return $m(e,t)}}function $m(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);re.length)&&(t=e.length);for(var r=0,n=new Array(t);r1?1:b<0?0:b},v=function(b){for(var x=b>1?1:b,w=x,O=0;O<8;++O){var y=l(w)-x,g=d(w);if(Math.abs(y-x)0&&arguments[0]!==void 0?arguments[0]:{},r=t.stiff,n=r===void 0?100:r,i=t.damping,a=i===void 0?8:i,o=t.dt,u=o===void 0?17:o,c=function(f,l,h){var d=-(f-l)*n,m=h*a,v=h+(d-m)*u/1e3,p=h*u/1e3+f;return Math.abs(p-l)e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function QC(e,t){if(e==null)return{};var r={},n=Object.keys(e),i,a;for(a=0;a=0)&&(r[i]=e[i]);return r}function bs(e){return n$(e)||r$(e)||t$(e)||e$()}function e$(){throw new TypeError(`Invalid attempt to spread non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function t$(e,t){if(e){if(typeof e=="string")return Rl(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Rl(e,t)}}function r$(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function n$(e){if(Array.isArray(e))return Rl(e)}function Rl(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Vi(e){return Vi=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Vi(e)}var bt=(function(e){c$(r,e);var t=s$(r);function r(n,i){var a;i$(this,r),a=t.call(this,n,i);var o=a.props,u=o.isActive,c=o.attributeName,s=o.from,f=o.to,l=o.steps,h=o.children,d=o.duration;if(a.handleStyleChange=a.handleStyleChange.bind(Nl(a)),a.changeStyle=a.changeStyle.bind(Nl(a)),!u||d<=0)return a.state={style:{}},typeof h=="function"&&(a.state={style:f}),Dl(a);if(l&&l.length)a.state={style:l[0].style};else if(s){if(typeof h=="function")return a.state={style:s},Dl(a);a.state={style:c?nn({},c,s):s}}else a.state={style:{}};return a}return o$(r,[{key:"componentDidMount",value:function(){var i=this.props,a=i.isActive,o=i.canBegin;this.mounted=!0,!(!a||!o)&&this.runAnimation(this.props)}},{key:"componentDidUpdate",value:function(i){var a=this.props,o=a.isActive,u=a.canBegin,c=a.attributeName,s=a.shouldReAnimate,f=a.to,l=a.from,h=this.state.style;if(u){if(!o){var d={style:c?nn({},c,f):f};this.state&&h&&(c&&h[c]!==f||!c&&h!==f)&&this.setState(d);return}if(!(yC(i.to,f)&&i.canBegin&&i.isActive)){var m=!i.canBegin||!i.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var v=m||s?l:i.to;if(this.state&&h){var p={style:c?nn({},c,v):v};(c&&h[c]!==v||!c&&h!==v)&&this.setState(p)}this.runAnimation(Ve(Ve({},this.props),{},{from:v,begin:0}))}}}},{key:"componentWillUnmount",value:function(){this.mounted=!1;var i=this.props.onAnimationEnd;this.unSubscribe&&this.unSubscribe(),this.manager&&(this.manager.stop(),this.manager=null),this.stopJSAnimation&&this.stopJSAnimation(),i&&i()}},{key:"handleStyleChange",value:function(i){this.changeStyle(i)}},{key:"changeStyle",value:function(i){this.mounted&&this.setState({style:i})}},{key:"runJSAnimation",value:function(i){var a=this,o=i.from,u=i.to,c=i.duration,s=i.easing,f=i.begin,l=i.onAnimationEnd,h=i.onAnimationStart,d=YC(o,u,BC(s),c,this.changeStyle),m=function(){a.stopJSAnimation=d()};this.manager.start([h,f,m,c,l])}},{key:"runStepAnimation",value:function(i){var a=this,o=i.steps,u=i.begin,c=i.onAnimationStart,s=o[0],f=s.style,l=s.duration,h=l===void 0?0:l,d=function(v,p,b){if(b===0)return v;var x=p.duration,w=p.easing,O=w===void 0?"ease":w,y=p.style,g=p.properties,_=p.onAnimationEnd,S=b>0?o[b-1]:p,P=g||Object.keys(y);if(typeof O=="function"||O==="spring")return[].concat(bs(v),[a.runJSAnimation.bind(a,{from:S.style,to:y,duration:x,easing:O}),x]);var M=km(P,x,O),A=Ve(Ve(Ve({},S.style),y),{},{transition:M});return[].concat(bs(v),[A,x,_]).filter(TC)};return this.manager.start([c].concat(bs(o.reduce(d,[f,Math.max(h,u)])),[i.onAnimationEnd]))}},{key:"runAnimation",value:function(i){this.manager||(this.manager=_C());var a=i.begin,o=i.duration,u=i.attributeName,c=i.to,s=i.easing,f=i.onAnimationStart,l=i.onAnimationEnd,h=i.steps,d=i.children,m=this.manager;if(this.unSubscribe=m.subscribe(this.handleStyleChange),typeof s=="function"||typeof d=="function"||s==="spring"){this.runJSAnimation(i);return}if(h.length>1){this.runStepAnimation(i);return}var v=u?nn({},u,c):c,p=km(Object.keys(v),o,s);m.start([f,a,Ve(Ve({},v),{},{transition:p}),o,l])}},{key:"render",value:function(){var i=this.props,a=i.children;i.begin;var o=i.duration;i.attributeName,i.easing;var u=i.isActive;i.steps,i.from,i.to,i.canBegin,i.onAnimationEnd,i.shouldReAnimate,i.onAnimationReStart;var c=JC(i,ZC),s=N.Children.count(a),f=this.state.style;if(typeof a=="function")return a(f);if(!u||s===0||o<=0)return a;var l=function(d){var m=d.props,v=m.style,p=v===void 0?{}:v,b=m.className,x=N.cloneElement(d,Ve(Ve({},c),{},{style:Ve(Ve({},p),f),className:b}));return x};return s===1?l(N.Children.only(a)):T.createElement("div",null,N.Children.map(a,function(h){return l(h)}))}}]),r})(N.PureComponent);bt.displayName="Animate";bt.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};bt.propTypes={from:ne.oneOfType([ne.object,ne.string]),to:ne.oneOfType([ne.object,ne.string]),attributeName:ne.string,duration:ne.number,begin:ne.number,easing:ne.oneOfType([ne.string,ne.func]),steps:ne.arrayOf(ne.shape({duration:ne.number.isRequired,style:ne.object.isRequired,easing:ne.oneOfType([ne.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),ne.func]),properties:ne.arrayOf("string"),onAnimationEnd:ne.func})),children:ne.oneOfType([ne.node,ne.func]),isActive:ne.bool,canBegin:ne.bool,onAnimationEnd:ne.func,shouldReAnimate:ne.bool,onAnimationStart:ne.func,onAnimationReStart:ne.func};function kn(e){"@babel/helpers - typeof";return kn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},kn(e)}function Xi(){return Xi=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0?1:-1,c=n>=0?1:-1,s=i>=0&&n>=0||i<0&&n<0?1:0,f;if(o>0&&a instanceof Array){for(var l=[0,0,0,0],h=0,d=4;ho?o:a[h];f="M".concat(t,",").concat(r+u*l[0]),l[0]>0&&(f+="A ".concat(l[0],",").concat(l[0],",0,0,").concat(s,",").concat(t+c*l[0],",").concat(r)),f+="L ".concat(t+n-c*l[1],",").concat(r),l[1]>0&&(f+="A ".concat(l[1],",").concat(l[1],",0,0,").concat(s,`, - `).concat(t+n,",").concat(r+u*l[1])),f+="L ".concat(t+n,",").concat(r+i-u*l[2]),l[2]>0&&(f+="A ".concat(l[2],",").concat(l[2],",0,0,").concat(s,`, - `).concat(t+n-c*l[2],",").concat(r+i)),f+="L ".concat(t+c*l[3],",").concat(r+i),l[3]>0&&(f+="A ".concat(l[3],",").concat(l[3],",0,0,").concat(s,`, - `).concat(t,",").concat(r+i-u*l[3])),f+="Z"}else if(o>0&&a===+a&&a>0){var m=Math.min(o,a);f="M ".concat(t,",").concat(r+u*m,` - A `).concat(m,",").concat(m,",0,0,").concat(s,",").concat(t+c*m,",").concat(r,` - L `).concat(t+n-c*m,",").concat(r,` - A `).concat(m,",").concat(m,",0,0,").concat(s,",").concat(t+n,",").concat(r+u*m,` - L `).concat(t+n,",").concat(r+i-u*m,` - A `).concat(m,",").concat(m,",0,0,").concat(s,",").concat(t+n-c*m,",").concat(r+i,` - L `).concat(t+c*m,",").concat(r+i,` - A `).concat(m,",").concat(m,",0,0,").concat(s,",").concat(t,",").concat(r+i-u*m," Z")}else f="M ".concat(t,",").concat(r," h ").concat(n," v ").concat(i," h ").concat(-n," Z");return f},b$=function(t,r){if(!t||!r)return!1;var n=t.x,i=t.y,a=r.x,o=r.y,u=r.width,c=r.height;if(Math.abs(u)>0&&Math.abs(c)>0){var s=Math.min(a,a+u),f=Math.max(a,a+u),l=Math.min(o,o+c),h=Math.max(o,o+c);return n>=s&&n<=f&&i>=l&&i<=h}return!1},x$={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},eh=function(t){var r=Wm(Wm({},x$),t),n=N.useRef(),i=N.useState(-1),a=f$(i,2),o=a[0],u=a[1];N.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var O=n.current.getTotalLength();O&&u(O)}catch{}},[]);var c=r.x,s=r.y,f=r.width,l=r.height,h=r.radius,d=r.className,m=r.animationEasing,v=r.animationDuration,p=r.animationBegin,b=r.isAnimationActive,x=r.isUpdateAnimationActive;if(c!==+c||s!==+s||f!==+f||l!==+l||f===0||l===0)return null;var w=ee("recharts-rectangle",d);return x?T.createElement(bt,{canBegin:o>0,from:{width:f,height:l,x:c,y:s},to:{width:f,height:l,x:c,y:s},duration:v,animationEasing:m,isActive:x},function(O){var y=O.width,g=O.height,_=O.x,S=O.y;return T.createElement(bt,{canBegin:o>0,from:"0px ".concat(o===-1?1:o,"px"),to:"".concat(o,"px 0px"),attributeName:"strokeDasharray",begin:p,duration:v,isActive:b,easing:m},T.createElement("path",Xi({},Z(r,!0),{className:w,d:Um(_,S,y,g,h),ref:n})))}):T.createElement("path",Xi({},Z(r,!0),{className:w,d:Um(c,s,f,l,h)}))};function ql(){return ql=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function T$(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}var E$=function(t,r,n,i,a,o){return"M".concat(t,",").concat(a,"v").concat(i,"M").concat(o,",").concat(r,"h").concat(n)},j$=function(t){var r=t.x,n=r===void 0?0:r,i=t.y,a=i===void 0?0:i,o=t.top,u=o===void 0?0:o,c=t.left,s=c===void 0?0:c,f=t.width,l=f===void 0?0:f,h=t.height,d=h===void 0?0:h,m=t.className,v=P$(t,w$),p=O$({x:n,y:a,top:u,left:s,width:l,height:d},v);return!q(n)||!q(a)||!q(l)||!q(d)||!q(u)||!q(s)?null:T.createElement("path",Bl({},Z(p,!0),{className:ee("recharts-cross",m),d:E$(n,a,l,d,u,s)}))},xs,Gm;function M$(){if(Gm)return xs;Gm=1;var e=Ib(),t=e(Object.getPrototypeOf,Object);return xs=t,xs}var ws,Km;function C$(){if(Km)return ws;Km=1;var e=xt(),t=M$(),r=wt(),n="[object Object]",i=Function.prototype,a=Object.prototype,o=i.toString,u=a.hasOwnProperty,c=o.call(Object);function s(f){if(!r(f)||e(f)!=n)return!1;var l=t(f);if(l===null)return!0;var h=u.call(l,"constructor")&&l.constructor;return typeof h=="function"&&h instanceof h&&o.call(h)==c}return ws=s,ws}var $$=C$();const I$=ue($$);var Os,Vm;function R$(){if(Vm)return Os;Vm=1;var e=xt(),t=wt(),r="[object Boolean]";function n(i){return i===!0||i===!1||t(i)&&e(i)==r}return Os=n,Os}var k$=R$();const D$=ue(k$);function Nn(e){"@babel/helpers - typeof";return Nn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Nn(e)}function Yi(){return Yi=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r0,from:{upperWidth:0,lowerWidth:0,height:h,x:c,y:s},to:{upperWidth:f,lowerWidth:l,height:h,x:c,y:s},duration:v,animationEasing:m,isActive:b},function(w){var O=w.upperWidth,y=w.lowerWidth,g=w.height,_=w.x,S=w.y;return T.createElement(bt,{canBegin:o>0,from:"0px ".concat(o===-1?1:o,"px"),to:"".concat(o,"px 0px"),attributeName:"strokeDasharray",begin:p,duration:v,easing:m},T.createElement("path",Yi({},Z(r,!0),{className:x,d:Jm(_,S,O,y,g),ref:n})))}):T.createElement("g",null,T.createElement("path",Yi({},Z(r,!0),{className:x,d:Jm(c,s,f,l,h)})))},K$=["option","shapeType","propTransformer","activeClassName","isActive"];function qn(e){"@babel/helpers - typeof";return qn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},qn(e)}function V$(e,t){if(e==null)return{};var r=X$(e,t),n,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function X$(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function Qm(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Zi(e){for(var t=1;t0&&n.handleDrag(i.changedTouches[0])}),De(n,"handleDragEnd",function(){n.setState({isTravellerMoving:!1,isSlideMoving:!1},function(){var i=n.props,a=i.endIndex,o=i.onDragEnd,u=i.startIndex;o?.({endIndex:a,startIndex:u})}),n.detachDragEndListener()}),De(n,"handleLeaveWrapper",function(){(n.state.isTravellerMoving||n.state.isSlideMoving)&&(n.leaveTimer=window.setTimeout(n.handleDragEnd,n.props.leaveTimeOut))}),De(n,"handleEnterSlideOrTraveller",function(){n.setState({isTextActive:!0})}),De(n,"handleLeaveSlideOrTraveller",function(){n.setState({isTextActive:!1})}),De(n,"handleSlideDragStart",function(i){var a=sg(i)?i.changedTouches[0]:i;n.setState({isTravellerMoving:!1,isSlideMoving:!0,slideMoveStartX:a.pageX}),n.attachDragEndListener()}),n.travellerDragStartHandlers={startX:n.handleTravellerDragStart.bind(n,"startX"),endX:n.handleTravellerDragStart.bind(n,"endX")},n.state={},n}return _I(t,e),bI(t,[{key:"componentWillUnmount",value:function(){this.leaveTimer&&(clearTimeout(this.leaveTimer),this.leaveTimer=null),this.detachDragEndListener()}},{key:"getIndex",value:function(n){var i=n.startX,a=n.endX,o=this.state.scaleValues,u=this.props,c=u.gap,s=u.data,f=s.length-1,l=Math.min(i,a),h=Math.max(i,a),d=t.getIndexInRange(o,l),m=t.getIndexInRange(o,h);return{startIndex:d-d%c,endIndex:m===f?f:m-m%c}}},{key:"getTextOfTick",value:function(n){var i=this.props,a=i.data,o=i.tickFormatter,u=i.dataKey,c=Be(a[n],u,n);return V(o)?o(c,n):c}},{key:"attachDragEndListener",value:function(){window.addEventListener("mouseup",this.handleDragEnd,!0),window.addEventListener("touchend",this.handleDragEnd,!0),window.addEventListener("mousemove",this.handleDrag,!0)}},{key:"detachDragEndListener",value:function(){window.removeEventListener("mouseup",this.handleDragEnd,!0),window.removeEventListener("touchend",this.handleDragEnd,!0),window.removeEventListener("mousemove",this.handleDrag,!0)}},{key:"handleSlideDrag",value:function(n){var i=this.state,a=i.slideMoveStartX,o=i.startX,u=i.endX,c=this.props,s=c.x,f=c.width,l=c.travellerWidth,h=c.startIndex,d=c.endIndex,m=c.onChange,v=n.pageX-a;v>0?v=Math.min(v,s+f-l-u,s+f-l-o):v<0&&(v=Math.max(v,s-o,s-u));var p=this.getIndex({startX:o+v,endX:u+v});(p.startIndex!==h||p.endIndex!==d)&&m&&m(p),this.setState({startX:o+v,endX:u+v,slideMoveStartX:n.pageX})}},{key:"handleTravellerDragStart",value:function(n,i){var a=sg(i)?i.changedTouches[0]:i;this.setState({isSlideMoving:!1,isTravellerMoving:!0,movingTravellerId:n,brushMoveStartX:a.pageX}),this.attachDragEndListener()}},{key:"handleTravellerMove",value:function(n){var i=this.state,a=i.brushMoveStartX,o=i.movingTravellerId,u=i.endX,c=i.startX,s=this.state[o],f=this.props,l=f.x,h=f.width,d=f.travellerWidth,m=f.onChange,v=f.gap,p=f.data,b={startX:this.state.startX,endX:this.state.endX},x=n.pageX-a;x>0?x=Math.min(x,l+h-d-s):x<0&&(x=Math.max(x,l-s)),b[o]=s+x;var w=this.getIndex(b),O=w.startIndex,y=w.endIndex,g=function(){var S=p.length-1;return o==="startX"&&(u>c?O%v===0:y%v===0)||uc?y%v===0:O%v===0)||u>c&&y===S};this.setState(De(De({},o,s+x),"brushMoveStartX",n.pageX),function(){m&&g()&&m(w)})}},{key:"handleTravellerMoveKeyboard",value:function(n,i){var a=this,o=this.state,u=o.scaleValues,c=o.startX,s=o.endX,f=this.state[i],l=u.indexOf(f);if(l!==-1){var h=l+n;if(!(h===-1||h>=u.length)){var d=u[h];i==="startX"&&d>=s||i==="endX"&&d<=c||this.setState(De({},i,d),function(){a.props.onChange(a.getIndex({startX:a.state.startX,endX:a.state.endX}))})}}}},{key:"renderBackground",value:function(){var n=this.props,i=n.x,a=n.y,o=n.width,u=n.height,c=n.fill,s=n.stroke;return T.createElement("rect",{stroke:s,fill:c,x:i,y:a,width:o,height:u})}},{key:"renderPanorama",value:function(){var n=this.props,i=n.x,a=n.y,o=n.width,u=n.height,c=n.data,s=n.children,f=n.padding,l=N.Children.only(s);return l?T.cloneElement(l,{x:i,y:a,width:o,height:u,margin:f,compact:!0,data:c}):null}},{key:"renderTravellerLayer",value:function(n,i){var a,o,u=this,c=this.props,s=c.y,f=c.travellerWidth,l=c.height,h=c.traveller,d=c.ariaLabel,m=c.data,v=c.startIndex,p=c.endIndex,b=Math.max(n,this.props.x),x=Ts(Ts({},Z(this.props,!1)),{},{x:b,y:s,width:f,height:l}),w=d||"Min value: ".concat((a=m[v])===null||a===void 0?void 0:a.name,", Max value: ").concat((o=m[p])===null||o===void 0?void 0:o.name);return T.createElement(fe,{tabIndex:0,role:"slider","aria-label":w,"aria-valuenow":n,className:"recharts-brush-traveller",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.travellerDragStartHandlers[i],onTouchStart:this.travellerDragStartHandlers[i],onKeyDown:function(y){["ArrowLeft","ArrowRight"].includes(y.key)&&(y.preventDefault(),y.stopPropagation(),u.handleTravellerMoveKeyboard(y.key==="ArrowRight"?1:-1,i))},onFocus:function(){u.setState({isTravellerFocused:!0})},onBlur:function(){u.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},t.renderTraveller(h,x))}},{key:"renderSlide",value:function(n,i){var a=this.props,o=a.y,u=a.height,c=a.stroke,s=a.travellerWidth,f=Math.min(n,i)+s,l=Math.max(Math.abs(i-n)-s,0);return T.createElement("rect",{className:"recharts-brush-slide",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.handleSlideDragStart,onTouchStart:this.handleSlideDragStart,style:{cursor:"move"},stroke:"none",fill:c,fillOpacity:.2,x:f,y:o,width:l,height:u})}},{key:"renderText",value:function(){var n=this.props,i=n.startIndex,a=n.endIndex,o=n.y,u=n.height,c=n.travellerWidth,s=n.stroke,f=this.state,l=f.startX,h=f.endX,d=5,m={pointerEvents:"none",fill:s};return T.createElement(fe,{className:"recharts-brush-texts"},T.createElement(Ei,Qi({textAnchor:"end",verticalAnchor:"middle",x:Math.min(l,h)-d,y:o+u/2},m),this.getTextOfTick(i)),T.createElement(Ei,Qi({textAnchor:"start",verticalAnchor:"middle",x:Math.max(l,h)+c+d,y:o+u/2},m),this.getTextOfTick(a)))}},{key:"render",value:function(){var n=this.props,i=n.data,a=n.className,o=n.children,u=n.x,c=n.y,s=n.width,f=n.height,l=n.alwaysShowText,h=this.state,d=h.startX,m=h.endX,v=h.isTextActive,p=h.isSlideMoving,b=h.isTravellerMoving,x=h.isTravellerFocused;if(!i||!i.length||!q(u)||!q(c)||!q(s)||!q(f)||s<=0||f<=0)return null;var w=ee("recharts-brush",a),O=T.Children.count(o)===1,y=mI("userSelect","none");return T.createElement(fe,{className:w,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:y},this.renderBackground(),O&&this.renderPanorama(),this.renderSlide(d,m),this.renderTravellerLayer(d,"startX"),this.renderTravellerLayer(m,"endX"),(v||p||b||x||l)&&this.renderText())}}],[{key:"renderDefaultTraveller",value:function(n){var i=n.x,a=n.y,o=n.width,u=n.height,c=n.stroke,s=Math.floor(a+u/2)-1;return T.createElement(T.Fragment,null,T.createElement("rect",{x:i,y:a,width:o,height:u,fill:c,stroke:"none"}),T.createElement("line",{x1:i+1,y1:s,x2:i+o-1,y2:s,fill:"none",stroke:"#fff"}),T.createElement("line",{x1:i+1,y1:s+2,x2:i+o-1,y2:s+2,fill:"none",stroke:"#fff"}))}},{key:"renderTraveller",value:function(n,i){var a;return T.isValidElement(n)?a=T.cloneElement(n,i):V(n)?a=n(i):a=t.renderDefaultTraveller(i),a}},{key:"getDerivedStateFromProps",value:function(n,i){var a=n.data,o=n.width,u=n.x,c=n.travellerWidth,s=n.updateId,f=n.startIndex,l=n.endIndex;if(a!==i.prevData||s!==i.prevUpdateId)return Ts({prevData:a,prevTravellerWidth:c,prevUpdateId:s,prevX:u,prevWidth:o},a&&a.length?AI({data:a,width:o,x:u,travellerWidth:c,startIndex:f,endIndex:l}):{scale:null,scaleValues:null});if(i.scale&&(o!==i.prevWidth||u!==i.prevX||c!==i.prevTravellerWidth)){i.scale.range([u,u+o-c]);var h=i.scale.domain().map(function(d){return i.scale(d)});return{prevData:a,prevTravellerWidth:c,prevUpdateId:s,prevX:u,prevWidth:o,startX:i.scale(n.startIndex),endX:i.scale(n.endIndex),scaleValues:h}}return null}},{key:"getIndexInRange",value:function(n,i){for(var a=n.length,o=0,u=a-1;u-o>1;){var c=Math.floor((o+u)/2);n[c]>i?u=c:o=c}return i>=n[u]?u:o}}])})(N.PureComponent);De(Pr,"displayName","Brush");De(Pr,"defaultProps",{height:40,travellerWidth:5,gap:1,fill:"#fff",stroke:"#666",padding:{top:1,right:1,bottom:1,left:1},leaveTimeOut:1e3,alwaysShowText:!1});var Es,lg;function PI(){if(lg)return Es;lg=1;var e=Pf();function t(r,n){var i;return e(r,function(a,o,u){return i=n(a,o,u),!i}),!!i}return Es=t,Es}var js,fg;function TI(){if(fg)return js;fg=1;var e=Pb(),t=$t(),r=PI(),n=Re(),i=_a();function a(o,u,c){var s=n(o)?e:r;return c&&i(o,u,c)&&(u=void 0),s(o,t(u,3))}return js=a,js}var EI=TI();const jI=ue(EI);var it=function(t,r){var n=t.alwaysShow,i=t.ifOverflow;return n&&(i="extendDomain"),i===r},Ms,hg;function MI(){if(hg)return Ms;hg=1;var e=Ub();function t(r,n,i){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:i,writable:!0}):r[n]=i}return Ms=t,Ms}var Cs,pg;function CI(){if(pg)return Cs;pg=1;var e=MI(),t=zb(),r=$t();function n(i,a){var o={};return a=r(a,3),t(i,function(u,c,s){e(o,c,a(u,c,s))}),o}return Cs=n,Cs}var $I=CI();const II=ue($I);var $s,dg;function RI(){if(dg)return $s;dg=1;function e(t,r){for(var n=-1,i=t==null?0:t.length;++n=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function WI(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function UI(e,t){var r=e.x,n=e.y,i=zI(e,qI),a="".concat(r),o=parseInt(a,10),u="".concat(n),c=parseInt(u,10),s="".concat(t.height||i.height),f=parseInt(s,10),l="".concat(t.width||i.width),h=parseInt(l,10);return en(en(en(en(en({},t),i),o?{x:o}:{}),c?{y:c}:{}),{},{height:f,width:h,name:t.name,radius:t.radius})}function gg(e){return T.createElement(rI,Fl({shapeType:"rectangle",propTransformer:UI,activeClassName:"recharts-active-bar"},e))}var HI=function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return function(n,i){if(typeof t=="number")return t;var a=q(n)||Xw(n);return a?t(n,i):(a||Zt(),r)}},GI=["value","background"],_x;function Tr(e){"@babel/helpers - typeof";return Tr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Tr(e)}function KI(e,t){if(e==null)return{};var r=VI(e,t),n,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function VI(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function ta(){return ta=Object.assign?Object.assign.bind():function(e){for(var t=1;t0&&Math.abs(C)0&&Math.abs(I)0&&(j=Math.min((ce||0)-(I[de-1]||0),j))}),Number.isFinite(j)){var C=j/E,R=v.layout==="vertical"?n.height:n.width;if(v.padding==="gap"&&(_=C*R/2),v.padding==="no-gap"){var D=Je(t.barCategoryGap,C*R),B=C*R/2;_=B-D-(B-D)/R*D}}}i==="xAxis"?S=[n.left+(w.left||0)+(_||0),n.left+n.width-(w.right||0)-(_||0)]:i==="yAxis"?S=c==="horizontal"?[n.top+n.height-(w.bottom||0),n.top+(w.top||0)]:[n.top+(w.top||0)+(_||0),n.top+n.height-(w.bottom||0)-(_||0)]:S=v.range,y&&(S=[S[1],S[0]]);var L=rx(v,a,h),U=L.scale,G=L.realScaleType;U.domain(b).range(S),nx(U);var z=ix(U,Xe(Xe({},v),{},{realScaleType:G}));i==="xAxis"?(A=p==="top"&&!O||p==="bottom"&&O,P=n.left,M=l[g]-A*v.height):i==="yAxis"&&(A=p==="left"&&!O||p==="right"&&O,P=l[g]-A*v.width,M=n.top);var K=Xe(Xe(Xe({},v),z),{},{realScaleType:G,x:P,y:M,scale:U,width:i==="xAxis"?n.width:v.width,height:i==="yAxis"?n.height:v.height});return K.bandSize=zi(K,z),!v.hide&&i==="xAxis"?l[g]+=(A?-1:1)*K.height:v.hide||(l[g]+=(A?-1:1)*K.width),Xe(Xe({},d),{},Da({},m,K))},{})},Tx=function(t,r){var n=t.x,i=t.y,a=r.x,o=r.y;return{x:Math.min(n,a),y:Math.min(i,o),width:Math.abs(a-n),height:Math.abs(o-i)}},oR=function(t){var r=t.x1,n=t.y1,i=t.x2,a=t.y2;return Tx({x:r,y:n},{x:i,y:a})},Ex=(function(){function e(t){rR(this,e),this.scale=t}return nR(e,[{key:"domain",get:function(){return this.scale.domain}},{key:"range",get:function(){return this.scale.range}},{key:"rangeMin",get:function(){return this.range()[0]}},{key:"rangeMax",get:function(){return this.range()[1]}},{key:"bandwidth",get:function(){return this.scale.bandwidth}},{key:"apply",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=n.bandAware,a=n.position;if(r!==void 0){if(a)switch(a){case"start":return this.scale(r);case"middle":{var o=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+o}case"end":{var u=this.bandwidth?this.bandwidth():0;return this.scale(r)+u}default:return this.scale(r)}if(i){var c=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+c}return this.scale(r)}}},{key:"isInRange",value:function(r){var n=this.range(),i=n[0],a=n[n.length-1];return i<=a?r>=i&&r<=a:r>=a&&r<=i}}],[{key:"create",value:function(r){return new e(r)}}])})();Da(Ex,"EPS",1e-4);var rh=function(t){var r=Object.keys(t).reduce(function(n,i){return Xe(Xe({},n),{},Da({},i,Ex.create(t[i])))},{});return Xe(Xe({},r),{},{apply:function(i){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=a.bandAware,u=a.position;return II(i,function(c,s){return r[s].apply(c,{bandAware:o,position:u})})},isInRange:function(i){return Ox(i,function(a,o){return r[o].isInRange(a)})}})};function uR(e){return(e%180+180)%180}var cR=function(t){var r=t.width,n=t.height,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=uR(i),o=a*Math.PI/180,u=Math.atan(n/r),c=o>u&&o-1?c[s?a[f]:f]:void 0}}return ks=n,ks}var Ds,Sg;function lR(){if(Sg)return Ds;Sg=1;var e=gx();function t(r){var n=e(r),i=n%1;return n===n?i?n-i:n:0}return Ds=t,Ds}var Ns,Ag;function fR(){if(Ag)return Ns;Ag=1;var e=Nb(),t=$t(),r=lR(),n=Math.max;function i(a,o,u){var c=a==null?0:a.length;if(!c)return-1;var s=u==null?0:r(u);return s<0&&(s=n(c+s,0)),e(a,t(o,3),s)}return Ns=i,Ns}var qs,Pg;function hR(){if(Pg)return qs;Pg=1;var e=sR(),t=fR(),r=e(t);return qs=r,qs}var pR=hR();const dR=ue(pR);var vR=Qg();const yR=ue(vR);var mR=yR(function(e){return{x:e.left,y:e.top,width:e.width,height:e.height}},function(e){return["l",e.left,"t",e.top,"w",e.width,"h",e.height].join("")}),nh=N.createContext(void 0),ih=N.createContext(void 0),jx=N.createContext(void 0),Mx=N.createContext({}),Cx=N.createContext(void 0),$x=N.createContext(0),Ix=N.createContext(0),Tg=function(t){var r=t.state,n=r.xAxisMap,i=r.yAxisMap,a=r.offset,o=t.clipPathId,u=t.children,c=t.width,s=t.height,f=mR(a);return T.createElement(nh.Provider,{value:n},T.createElement(ih.Provider,{value:i},T.createElement(Mx.Provider,{value:a},T.createElement(jx.Provider,{value:f},T.createElement(Cx.Provider,{value:o},T.createElement($x.Provider,{value:s},T.createElement(Ix.Provider,{value:c},u)))))))},gR=function(){return N.useContext(Cx)},Rx=function(t){var r=N.useContext(nh);r==null&&Zt();var n=r[t];return n==null&&Zt(),n},bR=function(){var t=N.useContext(nh);return Pt(t)},xR=function(){var t=N.useContext(ih),r=dR(t,function(n){return Ox(n.domain,Number.isFinite)});return r||Pt(t)},kx=function(t){var r=N.useContext(ih);r==null&&Zt();var n=r[t];return n==null&&Zt(),n},wR=function(){var t=N.useContext(jx);return t},OR=function(){return N.useContext(Mx)},ah=function(){return N.useContext(Ix)},oh=function(){return N.useContext($x)};function Er(e){"@babel/helpers - typeof";return Er=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Er(e)}function _R(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function SR(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);re*i)return!1;var a=r();return e*(t-e*a/2-n)>=0&&e*(t+e*a/2-i)<=0}function ak(e,t){return zx(e,t+1)}function ok(e,t,r,n,i){for(var a=(n||[]).slice(),o=t.start,u=t.end,c=0,s=1,f=o,l=function(){var m=n?.[c];if(m===void 0)return{v:zx(n,s)};var v=c,p,b=function(){return p===void 0&&(p=r(m,v)),p},x=m.coordinate,w=c===0||oa(e,x,b,f,u);w||(c=0,f=o,s+=1),w&&(f=x+e*(b()/2+i),c+=s)},h;s<=a.length;)if(h=l(),h)return h.v;return[]}function Wn(e){"@babel/helpers - typeof";return Wn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Wn(e)}function kg(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Te(e){for(var t=1;t0?d.coordinate-p*e:d.coordinate})}else a[h]=d=Te(Te({},d),{},{tickCoord:d.coordinate});var b=oa(e,d.tickCoord,v,u,c);b&&(c=d.tickCoord-e*(v()/2+i),a[h]=Te(Te({},d),{},{isShow:!0}))},f=o-1;f>=0;f--)s(f);return a}function fk(e,t,r,n,i,a){var o=(n||[]).slice(),u=o.length,c=t.start,s=t.end;if(a){var f=n[u-1],l=r(f,u-1),h=e*(f.coordinate+e*l/2-s);o[u-1]=f=Te(Te({},f),{},{tickCoord:h>0?f.coordinate-h*e:f.coordinate});var d=oa(e,f.tickCoord,function(){return l},c,s);d&&(s=f.tickCoord-e*(l/2+i),o[u-1]=Te(Te({},f),{},{isShow:!0}))}for(var m=a?u-1:u,v=function(x){var w=o[x],O,y=function(){return O===void 0&&(O=r(w,x)),O};if(x===0){var g=e*(w.coordinate-e*y()/2-c);o[x]=w=Te(Te({},w),{},{tickCoord:g<0?w.coordinate-g*e:w.coordinate})}else o[x]=w=Te(Te({},w),{},{tickCoord:w.coordinate});var _=oa(e,w.tickCoord,y,c,s);_&&(c=w.tickCoord+e*(y()/2+i),o[x]=Te(Te({},w),{},{isShow:!0}))},p=0;p=2?Ze(i[1].coordinate-i[0].coordinate):1,b=ik(a,p,d);return c==="equidistantPreserveStart"?ok(p,b,v,i,o):(c==="preserveStart"||c==="preserveStartEnd"?h=fk(p,b,v,i,o,c==="preserveStartEnd"):h=lk(p,b,v,i,o),h.filter(function(x){return x.isShow}))}var hk=["viewBox"],pk=["viewBox"],dk=["ticks"];function Cr(e){"@babel/helpers - typeof";return Cr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Cr(e)}function sr(){return sr=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function vk(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function yk(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ng(e,t){for(var r=0;r0?c(this.props):c(d)),o<=0||u<=0||!m||!m.length?null:T.createElement(fe,{className:ee("recharts-cartesian-axis",s),ref:function(p){n.layerReference=p}},a&&this.renderAxisLine(),this.renderTicks(m,this.state.fontSize,this.state.letterSpacing),Ee.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(n,i,a){var o,u=ee(i.className,"recharts-cartesian-axis-tick-value");return T.isValidElement(n)?o=T.cloneElement(n,be(be({},i),{},{className:u})):V(n)?o=n(be(be({},i),{},{className:u})):o=T.createElement(Ei,sr({},i,{className:"recharts-cartesian-axis-tick-value"}),a),o}}])})(N.Component);lh(Hr,"displayName","CartesianAxis");lh(Hr,"defaultProps",{x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd"});var _k=["x1","y1","x2","y2","key"],Sk=["offset"];function Jt(e){"@babel/helpers - typeof";return Jt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Jt(e)}function qg(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function je(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Ek(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}var jk=function(t){var r=t.fill;if(!r||r==="none")return null;var n=t.fillOpacity,i=t.x,a=t.y,o=t.width,u=t.height,c=t.ry;return T.createElement("rect",{x:i,y:a,ry:c,width:o,height:u,stroke:"none",fill:r,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function Hx(e,t){var r;if(T.isValidElement(e))r=T.cloneElement(e,t);else if(V(e))r=e(t);else{var n=t.x1,i=t.y1,a=t.x2,o=t.y2,u=t.key,c=Bg(t,_k),s=Z(c,!1);s.offset;var f=Bg(s,Sk);r=T.createElement("line",Ht({},f,{x1:n,y1:i,x2:a,y2:o,fill:"none",key:u}))}return r}function Mk(e){var t=e.x,r=e.width,n=e.horizontal,i=n===void 0?!0:n,a=e.horizontalPoints;if(!i||!a||!a.length)return null;var o=a.map(function(u,c){var s=je(je({},e),{},{x1:t,y1:u,x2:t+r,y2:u,key:"line-".concat(c),index:c});return Hx(i,s)});return T.createElement("g",{className:"recharts-cartesian-grid-horizontal"},o)}function Ck(e){var t=e.y,r=e.height,n=e.vertical,i=n===void 0?!0:n,a=e.verticalPoints;if(!i||!a||!a.length)return null;var o=a.map(function(u,c){var s=je(je({},e),{},{x1:u,y1:t,x2:u,y2:t+r,key:"line-".concat(c),index:c});return Hx(i,s)});return T.createElement("g",{className:"recharts-cartesian-grid-vertical"},o)}function $k(e){var t=e.horizontalFill,r=e.fillOpacity,n=e.x,i=e.y,a=e.width,o=e.height,u=e.horizontalPoints,c=e.horizontal,s=c===void 0?!0:c;if(!s||!t||!t.length)return null;var f=u.map(function(h){return Math.round(h+i-i)}).sort(function(h,d){return h-d});i!==f[0]&&f.unshift(0);var l=f.map(function(h,d){var m=!f[d+1],v=m?i+o-h:f[d+1]-h;if(v<=0)return null;var p=d%t.length;return T.createElement("rect",{key:"react-".concat(d),y:h,x:n,height:v,width:a,stroke:"none",fill:t[p],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return T.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},l)}function Ik(e){var t=e.vertical,r=t===void 0?!0:t,n=e.verticalFill,i=e.fillOpacity,a=e.x,o=e.y,u=e.width,c=e.height,s=e.verticalPoints;if(!r||!n||!n.length)return null;var f=s.map(function(h){return Math.round(h+a-a)}).sort(function(h,d){return h-d});a!==f[0]&&f.unshift(0);var l=f.map(function(h,d){var m=!f[d+1],v=m?a+u-h:f[d+1]-h;if(v<=0)return null;var p=d%n.length;return T.createElement("rect",{key:"react-".concat(d),x:h,y:o,width:v,height:c,stroke:"none",fill:n[p],fillOpacity:i,className:"recharts-cartesian-grid-bg"})});return T.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},l)}var Rk=function(t,r){var n=t.xAxis,i=t.width,a=t.height,o=t.offset;return tx(sh(je(je(je({},Hr.defaultProps),n),{},{ticks:ht(n,!0),viewBox:{x:0,y:0,width:i,height:a}})),o.left,o.left+o.width,r)},kk=function(t,r){var n=t.yAxis,i=t.width,a=t.height,o=t.offset;return tx(sh(je(je(je({},Hr.defaultProps),n),{},{ticks:ht(n,!0),viewBox:{x:0,y:0,width:i,height:a}})),o.top,o.top+o.height,r)},ur={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function Dk(e){var t,r,n,i,a,o,u=ah(),c=oh(),s=OR(),f=je(je({},e),{},{stroke:(t=e.stroke)!==null&&t!==void 0?t:ur.stroke,fill:(r=e.fill)!==null&&r!==void 0?r:ur.fill,horizontal:(n=e.horizontal)!==null&&n!==void 0?n:ur.horizontal,horizontalFill:(i=e.horizontalFill)!==null&&i!==void 0?i:ur.horizontalFill,vertical:(a=e.vertical)!==null&&a!==void 0?a:ur.vertical,verticalFill:(o=e.verticalFill)!==null&&o!==void 0?o:ur.verticalFill,x:q(e.x)?e.x:s.left,y:q(e.y)?e.y:s.top,width:q(e.width)?e.width:s.width,height:q(e.height)?e.height:s.height}),l=f.x,h=f.y,d=f.width,m=f.height,v=f.syncWithTicks,p=f.horizontalValues,b=f.verticalValues,x=bR(),w=xR();if(!q(d)||d<=0||!q(m)||m<=0||!q(l)||l!==+l||!q(h)||h!==+h)return null;var O=f.verticalCoordinatesGenerator||Rk,y=f.horizontalCoordinatesGenerator||kk,g=f.horizontalPoints,_=f.verticalPoints;if((!g||!g.length)&&V(y)){var S=p&&p.length,P=y({yAxis:w?je(je({},w),{},{ticks:S?p:w.ticks}):void 0,width:u,height:c,offset:s},S?!0:v);dt(Array.isArray(P),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(Jt(P),"]")),Array.isArray(P)&&(g=P)}if((!_||!_.length)&&V(O)){var M=b&&b.length,A=O({xAxis:x?je(je({},x),{},{ticks:M?b:x.ticks}):void 0,width:u,height:c,offset:s},M?!0:v);dt(Array.isArray(A),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(Jt(A),"]")),Array.isArray(A)&&(_=A)}return T.createElement("g",{className:"recharts-cartesian-grid"},T.createElement(jk,{fill:f.fill,fillOpacity:f.fillOpacity,x:f.x,y:f.y,width:f.width,height:f.height,ry:f.ry}),T.createElement(Mk,Ht({},f,{offset:s,horizontalPoints:g,xAxis:x,yAxis:w})),T.createElement(Ck,Ht({},f,{offset:s,verticalPoints:_,xAxis:x,yAxis:w})),T.createElement($k,Ht({},f,{horizontalPoints:g})),T.createElement(Ik,Ht({},f,{verticalPoints:_})))}Dk.displayName="CartesianGrid";var Nk=["layout","type","stroke","connectNulls","isRange","ref"],qk=["key"],Gx;function $r(e){"@babel/helpers - typeof";return $r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$r(e)}function Kx(e,t){if(e==null)return{};var r=Bk(e,t),n,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Bk(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function Gt(){return Gt=Object.assign?Object.assign.bind():function(e){for(var t=1;t0||!On(f,o)||!On(l,u))?this.renderAreaWithAnimation(n,i):this.renderAreaStatically(o,u,n,i)}},{key:"render",value:function(){var n,i=this.props,a=i.hide,o=i.dot,u=i.points,c=i.className,s=i.top,f=i.left,l=i.xAxis,h=i.yAxis,d=i.width,m=i.height,v=i.isAnimationActive,p=i.id;if(a||!u||!u.length)return null;var b=this.state.isAnimationFinished,x=u.length===1,w=ee("recharts-area",c),O=l&&l.allowDataOverflow,y=h&&h.allowDataOverflow,g=O||y,_=J(p)?this.id:p,S=(n=Z(o,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},P=S.r,M=P===void 0?3:P,A=S.strokeWidth,E=A===void 0?2:A,j=uO(o)?o:{},I=j.clipDot,C=I===void 0?!0:I,R=M*2+E;return T.createElement(fe,{className:w},O||y?T.createElement("defs",null,T.createElement("clipPath",{id:"clipPath-".concat(_)},T.createElement("rect",{x:O?f:f-d/2,y:y?s:s-m/2,width:O?d:d*2,height:y?m:m*2})),!C&&T.createElement("clipPath",{id:"clipPath-dots-".concat(_)},T.createElement("rect",{x:f-R/2,y:s-R/2,width:d+R,height:m+R}))):null,x?null:this.renderArea(g,_),(o||x)&&this.renderDots(g,C,_),(!v||b)&&Mt.renderCallByParent(this.props,u))}}],[{key:"getDerivedStateFromProps",value:function(n,i){return n.animationId!==i.prevAnimationId?{prevAnimationId:n.animationId,curPoints:n.points,curBaseLine:n.baseLine,prevPoints:i.curPoints,prevBaseLine:i.curBaseLine}:n.points!==i.curPoints||n.baseLine!==i.curBaseLine?{curPoints:n.points,curBaseLine:n.baseLine}:null}}])})(N.PureComponent);Gx=nr;rt(nr,"displayName","Area");rt(nr,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!Fr.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});rt(nr,"getBaseValue",function(e,t,r,n){var i=e.layout,a=e.baseValue,o=t.props.baseValue,u=o??a;if(q(u)&&typeof u=="number")return u;var c=i==="horizontal"?n:r,s=c.scale.domain();if(c.type==="number"){var f=Math.max(s[0],s[1]),l=Math.min(s[0],s[1]);return u==="dataMin"?l:u==="dataMax"||f<0?f:Math.max(Math.min(s[0],s[1]),0)}return u==="dataMin"?s[0]:u==="dataMax"?s[1]:s[0]});rt(nr,"getComposedData",function(e){var t=e.props,r=e.item,n=e.xAxis,i=e.yAxis,a=e.xAxisTicks,o=e.yAxisTicks,u=e.bandSize,c=e.dataKey,s=e.stackedData,f=e.dataStartIndex,l=e.displayedData,h=e.offset,d=t.layout,m=s&&s.length,v=Gx.getBaseValue(t,r,n,i),p=d==="horizontal",b=!1,x=l.map(function(O,y){var g;m?g=s[f+y]:(g=Be(O,c),Array.isArray(g)?b=!0:g=[v,g]);var _=g[1]==null||m&&Be(O,c)==null;return p?{x:am({axis:n,ticks:a,bandSize:u,entry:O,index:y}),y:_?null:i.scale(g[1]),value:g,payload:O}:{x:_?null:n.scale(g[1]),y:am({axis:i,ticks:o,bandSize:u,entry:O,index:y}),value:g,payload:O}}),w;return m||b?w=x.map(function(O){var y=Array.isArray(O.value)?O.value[0]:null;return p?{x:O.x,y:y!=null&&O.y!=null?i.scale(y):null}:{x:y!=null?n.scale(y):null,y:O.y}}):w=p?i.scale(v):n.scale(v),St({points:x,baseLine:w,layout:d,isRange:b},h)});rt(nr,"renderDotItem",function(e,t){var r;if(T.isValidElement(e))r=T.cloneElement(e,t);else if(V(e))r=e(t);else{var n=ee("recharts-area-dot",typeof e!="boolean"?e.className:""),i=t.key,a=Kx(t,qk);r=T.createElement(th,Gt({},a,{key:i,className:n}))}return r});function Ir(e){"@babel/helpers - typeof";return Ir=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ir(e)}function Kk(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Vk(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function kD(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function DD(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ND(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r0?o:t&&t.length&&q(i)&&q(a)?t.slice(i,a+1):[]};function cw(e){return e==="number"?[0,"auto"]:void 0}var of=function(t,r,n,i){var a=t.graphicalItems,o=t.tooltipAxis,u=Fa(r,t);return n<0||!a||!a.length||n>=u.length?null:a.reduce(function(c,s){var f,l=(f=s.props.data)!==null&&f!==void 0?f:r;l&&t.dataStartIndex+t.dataEndIndex!==0&&t.dataEndIndex-t.dataStartIndex>=n&&(l=l.slice(t.dataStartIndex,t.dataEndIndex+1));var h;if(o.dataKey&&!o.allowDuplicatedCategory){var d=l===void 0?u:l;h=vi(d,o.dataKey,i)}else h=l&&l[n]||u[n];return h?[].concat(Dr(c),[ox(s,h)]):c},[])},Vg=function(t,r,n,i){var a=i||{x:t.chartX,y:t.chartY},o=XD(a,n),u=t.orderedTooltipTicks,c=t.tooltipAxis,s=t.tooltipTicks,f=oj(o,u,s,c);if(f>=0&&s){var l=s[f]&&s[f].value,h=of(t,r,f,l),d=YD(n,u,f,a);return{activeTooltipIndex:f,activeLabel:l,activePayload:h,activeCoordinate:d}}return null},ZD=function(t,r){var n=r.axes,i=r.graphicalItems,a=r.axisType,o=r.axisIdKey,u=r.stackGroups,c=r.dataStartIndex,s=r.dataEndIndex,f=t.layout,l=t.children,h=t.stackOffset,d=ex(f,a);return n.reduce(function(m,v){var p,b=v.type.defaultProps!==void 0?$($({},v.type.defaultProps),v.props):v.props,x=b.type,w=b.dataKey,O=b.allowDataOverflow,y=b.allowDuplicatedCategory,g=b.scale,_=b.ticks,S=b.includeHidden,P=b[o];if(m[P])return m;var M=Fa(t.data,{graphicalItems:i.filter(function(z){var K,ce=o in z.props?z.props[o]:(K=z.type.defaultProps)===null||K===void 0?void 0:K[o];return ce===P}),dataStartIndex:c,dataEndIndex:s}),A=M.length,E,j,I;_D(b.domain,O,x)&&(E=Sl(b.domain,null,O),d&&(x==="number"||g!=="auto")&&(I=un(M,w,"category")));var C=cw(x);if(!E||E.length===0){var R,D=(R=b.domain)!==null&&R!==void 0?R:C;if(w){if(E=un(M,w,x),x==="category"&&d){var B=Zw(E);y&&B?(j=E,E=Ji(0,A)):y||(E=sm(D,E,v).reduce(function(z,K){return z.indexOf(K)>=0?z:[].concat(Dr(z),[K])},[]))}else if(x==="category")y?E=E.filter(function(z){return z!==""&&!J(z)}):E=sm(D,E,v).reduce(function(z,K){return z.indexOf(K)>=0||K===""||J(K)?z:[].concat(Dr(z),[K])},[]);else if(x==="number"){var L=fj(M,i.filter(function(z){var K,ce,de=o in z.props?z.props[o]:(K=z.type.defaultProps)===null||K===void 0?void 0:K[o],ke="hide"in z.props?z.props.hide:(ce=z.type.defaultProps)===null||ce===void 0?void 0:ce.hide;return de===P&&(S||!ke)}),w,a,f);L&&(E=L)}d&&(x==="number"||g!=="auto")&&(I=un(M,w,"category"))}else d?E=Ji(0,A):u&&u[P]&&u[P].hasStack&&x==="number"?E=h==="expand"?[0,1]:ax(u[P].stackGroups,c,s):E=Q0(M,i.filter(function(z){var K=o in z.props?z.props[o]:z.type.defaultProps[o],ce="hide"in z.props?z.props.hide:z.type.defaultProps.hide;return K===P&&(S||!ce)}),x,f,!0);if(x==="number")E=rf(l,E,P,a,_),D&&(E=Sl(D,E,O));else if(x==="category"&&D){var U=D,G=E.every(function(z){return U.indexOf(z)>=0});G&&(E=U)}}return $($({},m),{},H({},P,$($({},b),{},{axisType:a,domain:E,categoricalDomain:I,duplicateDomain:j,originalDomain:(p=b.domain)!==null&&p!==void 0?p:C,isCategorical:d,layout:f})))},{})},JD=function(t,r){var n=r.graphicalItems,i=r.Axis,a=r.axisType,o=r.axisIdKey,u=r.stackGroups,c=r.dataStartIndex,s=r.dataEndIndex,f=t.layout,l=t.children,h=Fa(t.data,{graphicalItems:n,dataStartIndex:c,dataEndIndex:s}),d=h.length,m=ex(f,a),v=-1;return n.reduce(function(p,b){var x=b.type.defaultProps!==void 0?$($({},b.type.defaultProps),b.props):b.props,w=x[o],O=cw("number");if(!p[w]){v++;var y;return m?y=Ji(0,d):u&&u[w]&&u[w].hasStack?(y=ax(u[w].stackGroups,c,s),y=rf(l,y,w,a)):(y=Sl(O,Q0(h,n.filter(function(g){var _,S,P=o in g.props?g.props[o]:(_=g.type.defaultProps)===null||_===void 0?void 0:_[o],M="hide"in g.props?g.props.hide:(S=g.type.defaultProps)===null||S===void 0?void 0:S.hide;return P===w&&!M}),"number",f),i.defaultProps.allowDataOverflow),y=rf(l,y,w,a)),$($({},p),{},H({},w,$($({axisType:a},i.defaultProps),{},{hide:!0,orientation:He(KD,"".concat(a,".").concat(v%2),null),domain:y,originalDomain:O,isCategorical:m,layout:f})))}return p},{})},QD=function(t,r){var n=r.axisType,i=n===void 0?"xAxis":n,a=r.AxisComp,o=r.graphicalItems,u=r.stackGroups,c=r.dataStartIndex,s=r.dataEndIndex,f=t.children,l="".concat(i,"Id"),h=Qe(f,a),d={};return h&&h.length?d=ZD(t,{axes:h,graphicalItems:o,axisType:i,axisIdKey:l,stackGroups:u,dataStartIndex:c,dataEndIndex:s}):o&&o.length&&(d=JD(t,{Axis:a,graphicalItems:o,axisType:i,axisIdKey:l,stackGroups:u,dataStartIndex:c,dataEndIndex:s})),d},eN=function(t){var r=Pt(t),n=ht(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:Tf(n,function(i){return i.coordinate}),tooltipAxis:r,tooltipAxisBandSize:zi(r,n)}},Xg=function(t){var r=t.children,n=t.defaultShowTooltip,i=Ne(r,Pr),a=0,o=0;return t.data&&t.data.length!==0&&(o=t.data.length-1),i&&i.props&&(i.props.startIndex>=0&&(a=i.props.startIndex),i.props.endIndex>=0&&(o=i.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:a,dataEndIndex:o,activeTooltipIndex:-1,isTooltipActive:!!n}},tN=function(t){return!t||!t.length?!1:t.some(function(r){var n=pt(r&&r.type);return n&&n.indexOf("Bar")>=0})},Yg=function(t){return t==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:t==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:t==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},rN=function(t,r){var n=t.props,i=t.graphicalItems,a=t.xAxisMap,o=a===void 0?{}:a,u=t.yAxisMap,c=u===void 0?{}:u,s=n.width,f=n.height,l=n.children,h=n.margin||{},d=Ne(l,Pr),m=Ne(l,hr),v=Object.keys(c).reduce(function(y,g){var _=c[g],S=_.orientation;return!_.mirror&&!_.hide?$($({},y),{},H({},S,y[S]+_.width)):y},{left:h.left||0,right:h.right||0}),p=Object.keys(o).reduce(function(y,g){var _=o[g],S=_.orientation;return!_.mirror&&!_.hide?$($({},y),{},H({},S,He(y,"".concat(S))+_.height)):y},{top:h.top||0,bottom:h.bottom||0}),b=$($({},p),v),x=b.bottom;d&&(b.bottom+=d.props.height||Pr.defaultProps.height),m&&r&&(b=sj(b,i,n,r));var w=s-b.left-b.right,O=f-b.top-b.bottom;return $($({brushBottom:x},b),{},{width:Math.max(w,0),height:Math.max(O,0)})},nN=function(t,r){if(r==="xAxis")return t[r].width;if(r==="yAxis")return t[r].height},iN=function(t){var r=t.chartName,n=t.GraphicalChild,i=t.defaultTooltipEventType,a=i===void 0?"axis":i,o=t.validateTooltipEventTypes,u=o===void 0?["axis"]:o,c=t.axisComponents,s=t.legendContent,f=t.formatAxisMap,l=t.defaultProps,h=function(b,x){var w=x.graphicalItems,O=x.stackGroups,y=x.offset,g=x.updateId,_=x.dataStartIndex,S=x.dataEndIndex,P=b.barSize,M=b.layout,A=b.barGap,E=b.barCategoryGap,j=b.maxBarSize,I=Yg(M),C=I.numericAxisName,R=I.cateAxisName,D=tN(w),B=[];return w.forEach(function(L,U){var G=Fa(b.data,{graphicalItems:[L],dataStartIndex:_,dataEndIndex:S}),z=L.type.defaultProps!==void 0?$($({},L.type.defaultProps),L.props):L.props,K=z.dataKey,ce=z.maxBarSize,de=z["".concat(C,"Id")],ke=z["".concat(R,"Id")],Dt={},Ce=c.reduce(function(Nt,qt){var za=x["".concat(qt.axisType,"Map")],ph=z["".concat(qt.axisType,"Id")];za&&za[ph]||qt.axisType==="zAxis"||Zt();var dh=za[ph];return $($({},Nt),{},H(H({},qt.axisType,dh),"".concat(qt.axisType,"Ticks"),ht(dh)))},Dt),F=Ce[R],X=Ce["".concat(R,"Ticks")],Y=O&&O[de]&&O[de].hasStack&&xj(L,O[de].stackGroups),k=pt(L.type).indexOf("Bar")>=0,he=zi(F,X),Q=[],me=D&&uj({barSize:P,stackGroups:O,totalSize:nN(Ce,R)});if(k){var ge,$e,_t=J(ce)?j:ce,ir=(ge=($e=zi(F,X,!0))!==null&&$e!==void 0?$e:_t)!==null&&ge!==void 0?ge:0;Q=cj({barGap:A,barCategoryGap:E,bandSize:ir!==he?ir:he,sizeList:me[ke],maxBarSize:_t}),ir!==he&&(Q=Q.map(function(Nt){return $($({},Nt),{},{position:$($({},Nt.position),{},{offset:Nt.position.offset-ir/2})})}))}var ei=L&&L.type&&L.type.getComposedData;ei&&B.push({props:$($({},ei($($({},Ce),{},{displayedData:G,props:b,dataKey:K,item:L,bandSize:he,barPosition:Q,offset:y,stackedData:Y,layout:M,dataStartIndex:_,dataEndIndex:S}))),{},H(H(H({key:L.key||"item-".concat(U)},C,Ce[C]),R,Ce[R]),"animationId",g)),childIndex:lO(L,b.children),item:L})}),B},d=function(b,x){var w=b.props,O=b.dataStartIndex,y=b.dataEndIndex,g=b.updateId;if(!_p({props:w}))return null;var _=w.children,S=w.layout,P=w.stackOffset,M=w.data,A=w.reverseStackOrder,E=Yg(S),j=E.numericAxisName,I=E.cateAxisName,C=Qe(_,n),R=gj(M,C,"".concat(j,"Id"),"".concat(I,"Id"),P,A),D=c.reduce(function(z,K){var ce="".concat(K.axisType,"Map");return $($({},z),{},H({},ce,QD(w,$($({},K),{},{graphicalItems:C,stackGroups:K.axisType===j&&R,dataStartIndex:O,dataEndIndex:y}))))},{}),B=rN($($({},D),{},{props:w,graphicalItems:C}),x?.legendBBox);Object.keys(D).forEach(function(z){D[z]=f(w,D[z],B,z.replace("Map",""),r)});var L=D["".concat(I,"Map")],U=eN(L),G=h(w,$($({},D),{},{dataStartIndex:O,dataEndIndex:y,updateId:g,graphicalItems:C,stackGroups:R,offset:B}));return $($({formattedGraphicalItems:G,graphicalItems:C,offset:B,stackGroups:R},U),D)},m=(function(p){function b(x){var w,O,y;return DD(this,b),y=BD(this,b,[x]),H(y,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),H(y,"accessibilityManager",new OD),H(y,"handleLegendBBoxUpdate",function(g){if(g){var _=y.state,S=_.dataStartIndex,P=_.dataEndIndex,M=_.updateId;y.setState($({legendBBox:g},d({props:y.props,dataStartIndex:S,dataEndIndex:P,updateId:M},$($({},y.state),{},{legendBBox:g}))))}}),H(y,"handleReceiveSyncEvent",function(g,_,S){if(y.props.syncId===g){if(S===y.eventEmitterSymbol&&typeof y.props.syncMethod!="function")return;y.applySyncEvent(_)}}),H(y,"handleBrushChange",function(g){var _=g.startIndex,S=g.endIndex;if(_!==y.state.dataStartIndex||S!==y.state.dataEndIndex){var P=y.state.updateId;y.setState(function(){return $({dataStartIndex:_,dataEndIndex:S},d({props:y.props,dataStartIndex:_,dataEndIndex:S,updateId:P},y.state))}),y.triggerSyncEvent({dataStartIndex:_,dataEndIndex:S})}}),H(y,"handleMouseEnter",function(g){var _=y.getMouseInfo(g);if(_){var S=$($({},_),{},{isTooltipActive:!0});y.setState(S),y.triggerSyncEvent(S);var P=y.props.onMouseEnter;V(P)&&P(S,g)}}),H(y,"triggeredAfterMouseMove",function(g){var _=y.getMouseInfo(g),S=_?$($({},_),{},{isTooltipActive:!0}):{isTooltipActive:!1};y.setState(S),y.triggerSyncEvent(S);var P=y.props.onMouseMove;V(P)&&P(S,g)}),H(y,"handleItemMouseEnter",function(g){y.setState(function(){return{isTooltipActive:!0,activeItem:g,activePayload:g.tooltipPayload,activeCoordinate:g.tooltipPosition||{x:g.cx,y:g.cy}}})}),H(y,"handleItemMouseLeave",function(){y.setState(function(){return{isTooltipActive:!1}})}),H(y,"handleMouseMove",function(g){g.persist(),y.throttleTriggeredAfterMouseMove(g)}),H(y,"handleMouseLeave",function(g){y.throttleTriggeredAfterMouseMove.cancel();var _={isTooltipActive:!1};y.setState(_),y.triggerSyncEvent(_);var S=y.props.onMouseLeave;V(S)&&S(_,g)}),H(y,"handleOuterEvent",function(g){var _=sO(g),S=He(y.props,"".concat(_));if(_&&V(S)){var P,M;/.*touch.*/i.test(_)?M=y.getMouseInfo(g.changedTouches[0]):M=y.getMouseInfo(g),S((P=M)!==null&&P!==void 0?P:{},g)}}),H(y,"handleClick",function(g){var _=y.getMouseInfo(g);if(_){var S=$($({},_),{},{isTooltipActive:!0});y.setState(S),y.triggerSyncEvent(S);var P=y.props.onClick;V(P)&&P(S,g)}}),H(y,"handleMouseDown",function(g){var _=y.props.onMouseDown;if(V(_)){var S=y.getMouseInfo(g);_(S,g)}}),H(y,"handleMouseUp",function(g){var _=y.props.onMouseUp;if(V(_)){var S=y.getMouseInfo(g);_(S,g)}}),H(y,"handleTouchMove",function(g){g.changedTouches!=null&&g.changedTouches.length>0&&y.throttleTriggeredAfterMouseMove(g.changedTouches[0])}),H(y,"handleTouchStart",function(g){g.changedTouches!=null&&g.changedTouches.length>0&&y.handleMouseDown(g.changedTouches[0])}),H(y,"handleTouchEnd",function(g){g.changedTouches!=null&&g.changedTouches.length>0&&y.handleMouseUp(g.changedTouches[0])}),H(y,"handleDoubleClick",function(g){var _=y.props.onDoubleClick;if(V(_)){var S=y.getMouseInfo(g);_(S,g)}}),H(y,"handleContextMenu",function(g){var _=y.props.onContextMenu;if(V(_)){var S=y.getMouseInfo(g);_(S,g)}}),H(y,"triggerSyncEvent",function(g){y.props.syncId!==void 0&&Fs.emit(zs,y.props.syncId,g,y.eventEmitterSymbol)}),H(y,"applySyncEvent",function(g){var _=y.props,S=_.layout,P=_.syncMethod,M=y.state.updateId,A=g.dataStartIndex,E=g.dataEndIndex;if(g.dataStartIndex!==void 0||g.dataEndIndex!==void 0)y.setState($({dataStartIndex:A,dataEndIndex:E},d({props:y.props,dataStartIndex:A,dataEndIndex:E,updateId:M},y.state)));else if(g.activeTooltipIndex!==void 0){var j=g.chartX,I=g.chartY,C=g.activeTooltipIndex,R=y.state,D=R.offset,B=R.tooltipTicks;if(!D)return;if(typeof P=="function")C=P(B,g);else if(P==="value"){C=-1;for(var L=0;L=0){var Y,k;if(j.dataKey&&!j.allowDuplicatedCategory){var he=typeof j.dataKey=="function"?X:"payload.".concat(j.dataKey.toString());Y=vi(L,he,C),k=U&&G&&vi(G,he,C)}else Y=L?.[I],k=U&&G&&G[I];if(ke||de){var Q=g.props.activeIndex!==void 0?g.props.activeIndex:I;return[N.cloneElement(g,$($($({},P.props),Ce),{},{activeIndex:Q})),null,null]}if(!J(Y))return[F].concat(Dr(y.renderActivePoints({item:P,activePoint:Y,basePoint:k,childIndex:I,isRange:U})))}else{var me,ge=(me=y.getItemByXY(y.state.activeCoordinate))!==null&&me!==void 0?me:{graphicalItem:F},$e=ge.graphicalItem,_t=$e.item,ir=_t===void 0?g:_t,ei=$e.childIndex,Nt=$($($({},P.props),Ce),{},{activeIndex:ei});return[N.cloneElement(ir,Nt),null,null]}return U?[F,null,null]:[F,null]}),H(y,"renderCustomized",function(g,_,S){return N.cloneElement(g,$($({key:"recharts-customized-".concat(S)},y.props),y.state))}),H(y,"renderMap",{CartesianGrid:{handler:di,once:!0},ReferenceArea:{handler:y.renderReferenceElement},ReferenceLine:{handler:di},ReferenceDot:{handler:y.renderReferenceElement},XAxis:{handler:di},YAxis:{handler:di},Brush:{handler:y.renderBrush,once:!0},Bar:{handler:y.renderGraphicChild},Line:{handler:y.renderGraphicChild},Area:{handler:y.renderGraphicChild},Radar:{handler:y.renderGraphicChild},RadialBar:{handler:y.renderGraphicChild},Scatter:{handler:y.renderGraphicChild},Pie:{handler:y.renderGraphicChild},Funnel:{handler:y.renderGraphicChild},Tooltip:{handler:y.renderCursor,once:!0},PolarGrid:{handler:y.renderPolarGrid,once:!0},PolarAngleAxis:{handler:y.renderPolarAxis},PolarRadiusAxis:{handler:y.renderPolarAxis},Customized:{handler:y.renderCustomized}}),y.clipPathId="".concat((w=x.id)!==null&&w!==void 0?w:Kn("recharts"),"-clip"),y.throttleTriggeredAfterMouseMove=Yb(y.triggeredAfterMouseMove,(O=x.throttleDelay)!==null&&O!==void 0?O:1e3/60),y.state={},y}return zD(b,p),qD(b,[{key:"componentDidMount",value:function(){var w,O;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(w=this.props.margin.left)!==null&&w!==void 0?w:0,top:(O=this.props.margin.top)!==null&&O!==void 0?O:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var w=this.props,O=w.children,y=w.data,g=w.height,_=w.layout,S=Ne(O,ct);if(S){var P=S.props.defaultIndex;if(!(typeof P!="number"||P<0||P>this.state.tooltipTicks.length-1)){var M=this.state.tooltipTicks[P]&&this.state.tooltipTicks[P].value,A=of(this.state,y,P,M),E=this.state.tooltipTicks[P].coordinate,j=(this.state.offset.top+g)/2,I=_==="horizontal",C=I?{x:E,y:j}:{y:E,x:j},R=this.state.formattedGraphicalItems.find(function(B){var L=B.item;return L.type.name==="Scatter"});R&&(C=$($({},C),R.props.points[P].tooltipPosition),A=R.props.points[P].tooltipPayload);var D={activeTooltipIndex:P,isTooltipActive:!0,activeLabel:M,activePayload:A,activeCoordinate:C};this.setState(D),this.renderCursor(S),this.accessibilityManager.setIndex(P)}}}},{key:"getSnapshotBeforeUpdate",value:function(w,O){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==O.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==w.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==w.margin){var y,g;this.accessibilityManager.setDetails({offset:{left:(y=this.props.margin.left)!==null&&y!==void 0?y:0,top:(g=this.props.margin.top)!==null&&g!==void 0?g:0}})}return null}},{key:"componentDidUpdate",value:function(w){Gs([Ne(w.children,ct)],[Ne(this.props.children,ct)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var w=Ne(this.props.children,ct);if(w&&typeof w.props.shared=="boolean"){var O=w.props.shared?"axis":"item";return u.indexOf(O)>=0?O:a}return a}},{key:"getMouseInfo",value:function(w){if(!this.container)return null;var O=this.container,y=O.getBoundingClientRect(),g=YS(y),_={chartX:Math.round(w.pageX-g.left),chartY:Math.round(w.pageY-g.top)},S=y.width/O.offsetWidth||1,P=this.inRange(_.chartX,_.chartY,S);if(!P)return null;var M=this.state,A=M.xAxisMap,E=M.yAxisMap,j=this.getTooltipEventType(),I=Vg(this.state,this.props.data,this.props.layout,P);if(j!=="axis"&&A&&E){var C=Pt(A).scale,R=Pt(E).scale,D=C&&C.invert?C.invert(_.chartX):null,B=R&&R.invert?R.invert(_.chartY):null;return $($({},_),{},{xValue:D,yValue:B},I)}return I?$($({},_),I):null}},{key:"inRange",value:function(w,O){var y=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,g=this.props.layout,_=w/y,S=O/y;if(g==="horizontal"||g==="vertical"){var P=this.state.offset,M=_>=P.left&&_<=P.left+P.width&&S>=P.top&&S<=P.top+P.height;return M?{x:_,y:S}:null}var A=this.state,E=A.angleAxisMap,j=A.radiusAxisMap;if(E&&j){var I=Pt(E);return hm({x:_,y:S},I)}return null}},{key:"parseEventsOfWrapper",value:function(){var w=this.props.children,O=this.getTooltipEventType(),y=Ne(w,ct),g={};y&&O==="axis"&&(y.props.trigger==="click"?g={onClick:this.handleClick}:g={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var _=yi(this.props,this.handleOuterEvent);return $($({},_),g)}},{key:"addListener",value:function(){Fs.on(zs,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){Fs.removeListener(zs,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(w,O,y){for(var g=this.state.formattedGraphicalItems,_=0,S=g.length;_{const a=await m.getLogs(s);return{list:V(a),total:J(a)}},staleTime:2e4})}function se(s){return{id:String(s.id??""),userId:String(s.user_id??s.userId??""),username:s.username??"",module:s.module??s.resource??"",action:s.action??"",resource:s.resource??"",ip:s.ip??"",userAgent:s.user_agent??s.userAgent??"",result:s.result==="failure"?"failure":"success",message:s.message??s.detail??"",createdAt:s.createdAt??s.created_at??""}}function be(){K();const[s,a]=c.useState(""),[i,r]=c.useState(""),[d,u]=c.useState(""),N=c.useMemo(()=>({page:1,page_size:100,...i?{module:i}:{},...d?{action:d}:{}}),[i,d]),{data:g,isLoading:y,refetch:w}=ee(N),C=c.useMemo(()=>(g?.list||[]).map(t=>se(t)),[g]),[S,L]=c.useState([]),[k,_]=c.useState([]),[D,A]=c.useState(null),[I,z]=c.useState(!1),[R,re]=c.useState(null),[B,ce]=c.useState(!1),j=c.useCallback(async()=>{try{const[t,l]=await Promise.all([m.getModules(),m.getActions()]);L(t?.list??t??[]),_(l?.list??l??[])}catch{}},[]);c.useEffect(()=>{j()},[j]);const T=C.filter(t=>{const l=s.toLowerCase();return!l||t.username.toLowerCase().includes(l)||t.module.toLowerCase().includes(l)||t.action.toLowerCase().includes(l)||t.resource.toLowerCase().includes(l)}),M=t=>t==="success"?e.jsx(b,{"code-path":"src/pages/AuditOperationsTab.tsx:111:7",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:"成功"}):e.jsx(b,{"code-path":"src/pages/AuditOperationsTab.tsx:115:7",variant:"outline",className:"border-red-500/30 text-red-400 bg-red-500/10",children:"失败"}),E=async()=>{try{const t={};i&&(t.module=i),d&&(t.action=d),await m.exportLogs(t)}catch{}},F=t=>{A(t)};return e.jsxs("div",{"code-path":"src/pages/AuditOperationsTab.tsx:150:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/pages/AuditOperationsTab.tsx:152:7",className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{"code-path":"src/pages/AuditOperationsTab.tsx:153:9",className:"relative w-64",children:[e.jsx(v,{"code-path":"src/pages/AuditOperationsTab.tsx:154:11",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-500"}),e.jsx(H,{"code-path":"src/pages/AuditOperationsTab.tsx:155:11",placeholder:"搜索操作日志...",value:s,onChange:t=>a(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/pages/AuditOperationsTab.tsx:164:9",value:i,onChange:t=>r(t.target.value),className:"h-9 px-3 text-sm rounded-md bg-slate-800/50 border border-slate-700 text-slate-300 focus:outline-none focus:border-blue-500",children:[e.jsx("option",{"code-path":"src/pages/AuditOperationsTab.tsx:169:11",value:"",children:"全部模块"}),S.map(t=>e.jsx("option",{"code-path":"src/pages/AuditOperationsTab.tsx:171:13",value:t.value,children:t.label},t.value))]}),e.jsxs("select",{"code-path":"src/pages/AuditOperationsTab.tsx:178:9",value:d,onChange:t=>u(t.target.value),className:"h-9 px-3 text-sm rounded-md bg-slate-800/50 border border-slate-700 text-slate-300 focus:outline-none focus:border-blue-500",children:[e.jsx("option",{"code-path":"src/pages/AuditOperationsTab.tsx:183:11",value:"",children:"全部操作"}),k.map(t=>e.jsx("option",{"code-path":"src/pages/AuditOperationsTab.tsx:185:13",value:t.value,children:t.label},t.value))]}),e.jsxs(x,{"code-path":"src/pages/AuditOperationsTab.tsx:191:9",variant:"outline",className:"border-slate-700 text-slate-300 hover:text-slate-100 hover:bg-slate-800",onClick:()=>w(),children:[e.jsx(W,{"code-path":"src/pages/AuditOperationsTab.tsx:196:11",className:"h-4 w-4 mr-2"}),"刷新"]}),e.jsxs(x,{"code-path":"src/pages/AuditOperationsTab.tsx:199:9",variant:"outline",className:"border-slate-700 text-slate-300 hover:text-slate-100 hover:bg-slate-800",onClick:E,children:[e.jsx(Y,{"code-path":"src/pages/AuditOperationsTab.tsx:204:11",className:"h-4 w-4 mr-2"}),"导出"]})]}),e.jsx(q,{"code-path":"src/pages/AuditOperationsTab.tsx:210:7",className:"bg-slate-900 border-slate-800",children:e.jsx(P,{"code-path":"src/pages/AuditOperationsTab.tsx:211:9",className:"p-0",children:e.jsx("div",{"code-path":"src/pages/AuditOperationsTab.tsx:212:11",className:"border-t border-slate-800",children:y?e.jsx("div",{"code-path":"src/pages/AuditOperationsTab.tsx:214:15",className:"flex items-center justify-center py-16",children:e.jsx("div",{"code-path":"src/pages/AuditOperationsTab.tsx:215:17",className:"w-8 h-8 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"})}):T.length===0?e.jsxs("div",{"code-path":"src/pages/AuditOperationsTab.tsx:218:15",className:"flex flex-col items-center justify-center py-16 text-slate-500",children:[e.jsx(v,{"code-path":"src/pages/AuditOperationsTab.tsx:219:17",className:"h-8 w-8 mb-3 opacity-40"}),e.jsx("p",{"code-path":"src/pages/AuditOperationsTab.tsx:220:17",className:"text-sm",children:"暂无操作日志"})]}):e.jsxs(Q,{"code-path":"src/pages/AuditOperationsTab.tsx:223:15",children:[e.jsx(U,{"code-path":"src/pages/AuditOperationsTab.tsx:224:17",children:e.jsxs(O,{"code-path":"src/pages/AuditOperationsTab.tsx:225:19",className:"border-slate-800 hover:bg-transparent",children:[e.jsx(p,{"code-path":"src/pages/AuditOperationsTab.tsx:226:21",className:"text-slate-400",children:"时间"}),e.jsx(p,{"code-path":"src/pages/AuditOperationsTab.tsx:227:21",className:"text-slate-400",children:"用户"}),e.jsx(p,{"code-path":"src/pages/AuditOperationsTab.tsx:228:21",className:"text-slate-400",children:"模块"}),e.jsx(p,{"code-path":"src/pages/AuditOperationsTab.tsx:229:21",className:"text-slate-400",children:"操作类型"}),e.jsx(p,{"code-path":"src/pages/AuditOperationsTab.tsx:230:21",className:"text-slate-400",children:"资源"}),e.jsx(p,{"code-path":"src/pages/AuditOperationsTab.tsx:231:21",className:"text-slate-400",children:"IP"}),e.jsx(p,{"code-path":"src/pages/AuditOperationsTab.tsx:232:21",className:"text-slate-400",children:"结果"}),e.jsx(p,{"code-path":"src/pages/AuditOperationsTab.tsx:233:21",className:"text-slate-400 text-right",children:"详情"})]})}),e.jsx(X,{"code-path":"src/pages/AuditOperationsTab.tsx:236:17",children:T.map(t=>e.jsxs(O,{"code-path":"src/pages/AuditOperationsTab.tsx:238:21",className:"border-slate-800 hover:bg-slate-800/50",children:[e.jsx(n,{"code-path":"src/pages/AuditOperationsTab.tsx:239:23",children:e.jsx("span",{"code-path":"src/pages/AuditOperationsTab.tsx:240:25",className:"text-sm text-slate-400",children:t.createdAt?new Date(t.createdAt).toLocaleString():"--"})}),e.jsx(n,{"code-path":"src/pages/AuditOperationsTab.tsx:244:23",children:e.jsx("span",{"code-path":"src/pages/AuditOperationsTab.tsx:245:25",className:"text-sm text-slate-200",children:t.username||"--"})}),e.jsx(n,{"code-path":"src/pages/AuditOperationsTab.tsx:247:23",children:e.jsx("span",{"code-path":"src/pages/AuditOperationsTab.tsx:248:25",className:"text-sm text-slate-300",children:t.module||"--"})}),e.jsx(n,{"code-path":"src/pages/AuditOperationsTab.tsx:250:23",children:e.jsx(b,{"code-path":"src/pages/AuditOperationsTab.tsx:251:25",variant:"outline",className:"border-blue-500/30 text-blue-400 bg-blue-500/10",children:t.action||"--"})}),e.jsx(n,{"code-path":"src/pages/AuditOperationsTab.tsx:255:23",children:e.jsx("code",{"code-path":"src/pages/AuditOperationsTab.tsx:256:25",className:"text-xs text-slate-400 bg-slate-800 px-2 py-0.5 rounded",children:t.resource||"--"})}),e.jsx(n,{"code-path":"src/pages/AuditOperationsTab.tsx:260:23",children:e.jsx("span",{"code-path":"src/pages/AuditOperationsTab.tsx:261:25",className:"text-sm text-slate-400",children:t.ip||"--"})}),e.jsx(n,{"code-path":"src/pages/AuditOperationsTab.tsx:263:23",children:M(t.result)}),e.jsx(n,{"code-path":"src/pages/AuditOperationsTab.tsx:264:23",children:e.jsx("div",{"code-path":"src/pages/AuditOperationsTab.tsx:265:25",className:"flex items-center justify-end",children:e.jsx(x,{"code-path":"src/pages/AuditOperationsTab.tsx:266:27",variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-blue-400 hover:bg-slate-800",onClick:()=>F(t),title:"查看详情",children:e.jsx(Z,{"code-path":"src/pages/AuditOperationsTab.tsx:273:29",className:"h-4 w-4"})})})})]},t.id))})]})})})}),e.jsx(te,{"code-path":"src/pages/AuditOperationsTab.tsx:287:7",log:D,onClose:()=>A(null)}),e.jsx(ae,{"code-path":"src/pages/AuditOperationsTab.tsx:290:7",open:I,onClose:()=>z(!1),loading:B,stats:R})]})}function te({log:s,onClose:a}){return s?e.jsxs("div",{"code-path":"src/pages/AuditOperationsTab.tsx:308:5",className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{"code-path":"src/pages/AuditOperationsTab.tsx:309:7",className:"absolute inset-0 bg-black/60",onClick:a}),e.jsxs("div",{"code-path":"src/pages/AuditOperationsTab.tsx:310:7",className:"relative bg-slate-900 border border-slate-800 rounded-lg p-6 max-w-lg w-full mx-4 shadow-2xl",children:[e.jsxs("div",{"code-path":"src/pages/AuditOperationsTab.tsx:311:9",className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{"code-path":"src/pages/AuditOperationsTab.tsx:312:11",className:"text-lg font-semibold text-slate-100",children:"操作日志详情"}),e.jsx(x,{"code-path":"src/pages/AuditOperationsTab.tsx:313:11",variant:"ghost",size:"icon",className:"h-7 w-7 text-slate-400 hover:text-slate-100",onClick:a,children:e.jsx(f,{"code-path":"src/pages/AuditOperationsTab.tsx:319:13",className:"h-4 w-4"})})]}),e.jsxs("div",{"code-path":"src/pages/AuditOperationsTab.tsx:323:9",className:"space-y-3 text-sm",children:[e.jsx(o,{"code-path":"src/pages/AuditOperationsTab.tsx:324:11",label:"ID",value:s.id}),e.jsx(o,{"code-path":"src/pages/AuditOperationsTab.tsx:325:11",label:"时间",value:s.createdAt?new Date(s.createdAt).toLocaleString():"--"}),e.jsx(o,{"code-path":"src/pages/AuditOperationsTab.tsx:326:11",label:"用户",value:s.username||"--"}),e.jsx(o,{"code-path":"src/pages/AuditOperationsTab.tsx:327:11",label:"用户ID",value:s.userId||"--"}),e.jsx(o,{"code-path":"src/pages/AuditOperationsTab.tsx:328:11",label:"模块",value:s.module||"--"}),e.jsx(o,{"code-path":"src/pages/AuditOperationsTab.tsx:329:11",label:"操作类型",value:s.action||"--"}),e.jsx(o,{"code-path":"src/pages/AuditOperationsTab.tsx:330:11",label:"资源",value:s.resource||"--"}),e.jsx(o,{"code-path":"src/pages/AuditOperationsTab.tsx:331:11",label:"IP地址",value:s.ip||"--"}),e.jsx(o,{"code-path":"src/pages/AuditOperationsTab.tsx:332:11",label:"User-Agent",value:s.userAgent||"--"}),e.jsx(o,{"code-path":"src/pages/AuditOperationsTab.tsx:333:11",label:"结果",value:e.jsx(b,{"code-path":"src/pages/AuditOperationsTab.tsx:336:15",variant:"outline",className:s.result==="success"?"border-emerald-500/30 text-emerald-400 bg-emerald-500/10":"border-red-500/30 text-red-400 bg-red-500/10",children:s.result==="success"?"成功":"失败"})}),s.message&&e.jsx(o,{"code-path":"src/pages/AuditOperationsTab.tsx:348:27",label:"详情",value:s.message,mono:!0})]}),e.jsx("div",{"code-path":"src/pages/AuditOperationsTab.tsx:351:9",className:"mt-5 flex justify-end",children:e.jsx(x,{"code-path":"src/pages/AuditOperationsTab.tsx:352:11",variant:"outline",className:"border-slate-700 text-slate-300 hover:bg-slate-800",onClick:a,children:"关闭"})})]})]}):null}function o({label:s,value:a,mono:i}){return e.jsxs("div",{"code-path":"src/pages/AuditOperationsTab.tsx:367:5",className:"flex items-start gap-4",children:[e.jsx("span",{"code-path":"src/pages/AuditOperationsTab.tsx:368:7",className:"text-slate-500 w-20 flex-shrink-0",children:s}),e.jsx("span",{"code-path":"src/pages/AuditOperationsTab.tsx:369:7",className:i?"text-slate-300 font-mono text-xs break-all":"text-slate-200 break-all",children:a})]})}function ae({open:s,onClose:a,loading:i,stats:r}){return s?e.jsxs("div",{"code-path":"src/pages/AuditOperationsTab.tsx:394:5",className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{"code-path":"src/pages/AuditOperationsTab.tsx:395:7",className:"absolute inset-0 bg-black/60",onClick:a}),e.jsxs("div",{"code-path":"src/pages/AuditOperationsTab.tsx:396:7",className:"relative bg-slate-900 border border-slate-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:[e.jsxs("div",{"code-path":"src/pages/AuditOperationsTab.tsx:397:9",className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{"code-path":"src/pages/AuditOperationsTab.tsx:398:11",className:"text-lg font-semibold text-slate-100",children:"审计统计"}),e.jsx(x,{"code-path":"src/pages/AuditOperationsTab.tsx:399:11",variant:"ghost",size:"icon",className:"h-7 w-7 text-slate-400 hover:text-slate-100",onClick:a,children:e.jsx(f,{"code-path":"src/pages/AuditOperationsTab.tsx:405:13",className:"h-4 w-4"})})]}),i?e.jsx("div",{"code-path":"src/pages/AuditOperationsTab.tsx:410:11",className:"flex items-center justify-center py-10",children:e.jsx("div",{"code-path":"src/pages/AuditOperationsTab.tsx:411:13",className:"w-8 h-8 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"})}):r?e.jsxs("div",{"code-path":"src/pages/AuditOperationsTab.tsx:414:11",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/pages/AuditOperationsTab.tsx:415:13",className:"grid grid-cols-2 gap-3",children:[e.jsx(h,{"code-path":"src/pages/AuditOperationsTab.tsx:416:15",label:"总日志数",value:String(r.total_logs??"--"),color:"blue"}),e.jsx(h,{"code-path":"src/pages/AuditOperationsTab.tsx:417:15",label:"今日日志",value:String(r.today_count??"--"),color:"emerald"}),e.jsx(h,{"code-path":"src/pages/AuditOperationsTab.tsx:418:15",label:"成功数",value:String(r.success_count??"--"),color:"emerald"}),e.jsx(h,{"code-path":"src/pages/AuditOperationsTab.tsx:419:15",label:"失败数",value:String(r.failure_count??"--"),color:"red"})]}),r.top_modules&&r.top_modules.length>0&&e.jsxs("div",{"code-path":"src/pages/AuditOperationsTab.tsx:423:15",children:[e.jsx("h4",{"code-path":"src/pages/AuditOperationsTab.tsx:424:17",className:"text-xs font-semibold text-slate-400 mb-2",children:"热门模块"}),e.jsx("div",{"code-path":"src/pages/AuditOperationsTab.tsx:425:17",className:"space-y-1",children:r.top_modules.slice(0,5).map((d,u)=>e.jsxs("div",{"code-path":"src/pages/AuditOperationsTab.tsx:427:21",className:"flex justify-between text-xs",children:[e.jsx("span",{"code-path":"src/pages/AuditOperationsTab.tsx:428:23",className:"text-slate-300",children:d.module}),e.jsx("span",{"code-path":"src/pages/AuditOperationsTab.tsx:429:23",className:"text-slate-500",children:d.count})]},u))})]}),r.top_users&&r.top_users.length>0&&e.jsxs("div",{"code-path":"src/pages/AuditOperationsTab.tsx:437:15",children:[e.jsx("h4",{"code-path":"src/pages/AuditOperationsTab.tsx:438:17",className:"text-xs font-semibold text-slate-400 mb-2",children:"活跃用户"}),e.jsx("div",{"code-path":"src/pages/AuditOperationsTab.tsx:439:17",className:"space-y-1",children:r.top_users.slice(0,5).map((d,u)=>e.jsxs("div",{"code-path":"src/pages/AuditOperationsTab.tsx:441:21",className:"flex justify-between text-xs",children:[e.jsx("span",{"code-path":"src/pages/AuditOperationsTab.tsx:442:23",className:"text-slate-300",children:d.username}),e.jsx("span",{"code-path":"src/pages/AuditOperationsTab.tsx:443:23",className:"text-slate-500",children:d.count})]},u))})]})]}):e.jsx("p",{"code-path":"src/pages/AuditOperationsTab.tsx:451:11",className:"text-slate-500 text-center py-10 text-sm",children:"暂无统计数据"}),e.jsx("div",{"code-path":"src/pages/AuditOperationsTab.tsx:454:9",className:"mt-5 flex justify-end",children:e.jsx(x,{"code-path":"src/pages/AuditOperationsTab.tsx:455:11",variant:"outline",className:"border-slate-700 text-slate-300 hover:bg-slate-800",onClick:a,children:"关闭"})})]})]}):null}function h({label:s,value:a,color:i}){const r={blue:"border-blue-500/20 bg-blue-500/5 text-blue-400",emerald:"border-emerald-500/20 bg-emerald-500/5 text-emerald-400",red:"border-red-500/20 bg-red-500/5 text-red-400"};return e.jsxs("div",{"code-path":"src/pages/AuditOperationsTab.tsx:475:5",className:`rounded-lg border p-3 ${r[i]}`,children:[e.jsx("div",{"code-path":"src/pages/AuditOperationsTab.tsx:476:7",className:"text-xs text-slate-500",children:s}),e.jsx("div",{"code-path":"src/pages/AuditOperationsTab.tsx:477:7",className:"text-xl font-bold mt-0.5",children:a})]})}export{be as AuditOperationsTab}; diff --git a/backend/static/assets/CapacityPage-BOU6J8mE.js b/backend/static/assets/CapacityPage-BOU6J8mE.js deleted file mode 100644 index c8ba4f3..0000000 --- a/backend/static/assets/CapacityPage-BOU6J8mE.js +++ /dev/null @@ -1 +0,0 @@ -import{r as c,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{C as E,a as L}from"./card-BIfzBCEy.js";import{g as H,i as M,L as k,B as j}from"./index-Dungj95X.js";import{B as D}from"./badge-CGJlVD3L.js";import{S as P,a as N,b as f,c as v,d as x}from"./select-CiTqGGhE.js";import{T as z,a as U,b as d,c as r,d as F,e as n}from"./table-B2F10oba.js";import{k as p}from"./index-drGq01ok.js";import{f as S,u as I,R as G,v as J,g as w,H as _}from"./vendor-icons-DmqcWdzX.js";import"./index-5FEebgvX.js";function te(){const{clusterCode:$}=H(),h=M(),[l,u]=c.useState(!1),[b,g]=c.useState([]),[q,T]=c.useState([]),[A,R]=c.useState([]),[o,V]=c.useState("all"),[a,C]=c.useState($||"");c.useEffect(()=>{p.getClusters().then(s=>{const t=s?.list||[];if(T(t),!a&&t.length>0){const y=t[0].code||String(t[0].id);C(y),h(`/kubernetes/${y}/capacity`,{replace:!0})}}).catch(()=>{})},[]),c.useEffect(()=>{a&&p.getNamespaces(a).then(s=>{R(Array.isArray(s)?s:s?.list||s?.data||[])}).catch(()=>{})},[a]);const i=c.useCallback(async()=>{if(a){u(!0);try{const s=o==="all"?void 0:o,t=await p.getCapacity(a,s);g(Array.isArray(t)?t:t?.list||[])}catch{g([])}finally{u(!1)}}},[a,o]);c.useEffect(()=>{i()},[i]);const m=c.useMemo(()=>b.flatMap(s=>(s.containers||[]).map(t=>({namespace:s.namespace,deployment:s.name,replicas:s.replicas,container:t.name,cpu_req:t.cpu_request||"-",cpu_lim:t.cpu_limit||"-",mem_req:t.mem_request||"-",mem_lim:t.mem_limit||"-"}))),[b]),B=()=>p.exportAsCSV(`capacity-${a}.csv`,m);return e.jsxs("div",{"code-path":"src/components/kubernetes/CapacityPage.tsx:74:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/CapacityPage.tsx:75:7",className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx(k,{"code-path":"src/components/kubernetes/CapacityPage.tsx:76:9",to:"/kubernetes",className:"hover:text-slate-300",children:"集群"}),a&&e.jsxs(e.Fragment,{children:[e.jsx(S,{"code-path":"src/components/kubernetes/CapacityPage.tsx:77:29",className:"h-3 w-3"}),e.jsx(k,{"code-path":"src/components/kubernetes/CapacityPage.tsx:77:65",to:`/kubernetes/${a}`,className:"hover:text-slate-300",children:a})]}),e.jsx(S,{"code-path":"src/components/kubernetes/CapacityPage.tsx:78:9",className:"h-3 w-3"}),e.jsx("span",{"code-path":"src/components/kubernetes/CapacityPage.tsx:78:45",className:"text-slate-300",children:"容量分析"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/CapacityPage.tsx:81:7",className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("h2",{"code-path":"src/components/kubernetes/CapacityPage.tsx:82:9",className:"text-lg font-semibold text-slate-100 flex items-center gap-2",children:[e.jsx(I,{"code-path":"src/components/kubernetes/CapacityPage.tsx:82:86",className:"h-5 w-5 text-purple-400"}),"资源容量分析"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/CapacityPage.tsx:83:9",className:"flex items-center gap-2",children:[e.jsxs(P,{"code-path":"src/components/kubernetes/CapacityPage.tsx:84:11",value:a,onValueChange:s=>{C(s),h(`/kubernetes/${s}/capacity`)},children:[e.jsx(N,{"code-path":"src/components/kubernetes/CapacityPage.tsx:85:13",className:"w-40 h-8 text-xs bg-slate-800 border-slate-700",children:e.jsx(f,{"code-path":"src/components/kubernetes/CapacityPage.tsx:85:87"})}),e.jsx(v,{"code-path":"src/components/kubernetes/CapacityPage.tsx:86:13",className:"bg-slate-800 border-slate-700",children:q.map(s=>e.jsx(x,{"code-path":"src/components/kubernetes/CapacityPage.tsx:87:46",value:s.code||String(s.id),className:"text-xs",children:s.name||s.code},s.id))})]}),e.jsxs(P,{"code-path":"src/components/kubernetes/CapacityPage.tsx:90:11",value:o,onValueChange:V,children:[e.jsx(N,{"code-path":"src/components/kubernetes/CapacityPage.tsx:91:13",className:"w-32 h-8 text-xs bg-slate-800 border-slate-700",children:e.jsx(f,{"code-path":"src/components/kubernetes/CapacityPage.tsx:91:87",placeholder:"所有命名空间"})}),e.jsxs(v,{"code-path":"src/components/kubernetes/CapacityPage.tsx:92:13",className:"bg-slate-800 border-slate-700",children:[e.jsx(x,{"code-path":"src/components/kubernetes/CapacityPage.tsx:93:15",value:"all",className:"text-xs",children:"所有命名空间"}),A.map(s=>e.jsx(x,{"code-path":"src/components/kubernetes/CapacityPage.tsx:94:36",value:s,className:"text-xs",children:s},s))]})]}),e.jsxs(j,{"code-path":"src/components/kubernetes/CapacityPage.tsx:97:11",variant:"outline",size:"sm",className:"h-8 border-slate-700 text-slate-300 text-xs",onClick:i,disabled:l,children:[e.jsx(G,{"code-path":"src/components/kubernetes/CapacityPage.tsx:98:13",className:`h-3 w-3 mr-1 ${l?"animate-spin":""}`}),"刷新"]}),e.jsxs(j,{"code-path":"src/components/kubernetes/CapacityPage.tsx:100:11",variant:"outline",size:"sm",className:"h-8 border-slate-700 text-slate-300 text-xs",onClick:B,children:[e.jsx(J,{"code-path":"src/components/kubernetes/CapacityPage.tsx:101:13",className:"h-3 w-3 mr-1"}),"CSV"]})]})]}),e.jsx(E,{"code-path":"src/components/kubernetes/CapacityPage.tsx:106:7",className:"bg-slate-900 border-slate-800",children:e.jsx(L,{"code-path":"src/components/kubernetes/CapacityPage.tsx:107:9",className:"p-0",children:e.jsxs(z,{"code-path":"src/components/kubernetes/CapacityPage.tsx:108:11",children:[e.jsx(U,{"code-path":"src/components/kubernetes/CapacityPage.tsx:109:13",children:e.jsxs(d,{"code-path":"src/components/kubernetes/CapacityPage.tsx:109:26",className:"border-slate-800 hover:bg-transparent",children:[e.jsx(r,{"code-path":"src/components/kubernetes/CapacityPage.tsx:110:15",className:"text-slate-400",children:"Deployment"}),e.jsx(r,{"code-path":"src/components/kubernetes/CapacityPage.tsx:111:15",className:"text-slate-400",children:"命名空间"}),e.jsx(r,{"code-path":"src/components/kubernetes/CapacityPage.tsx:112:15",className:"text-slate-400",children:"副本"}),e.jsx(r,{"code-path":"src/components/kubernetes/CapacityPage.tsx:113:15",className:"text-slate-400",children:"容器"}),e.jsxs(r,{"code-path":"src/components/kubernetes/CapacityPage.tsx:114:15",className:"text-slate-400",children:[e.jsx(w,{"code-path":"src/components/kubernetes/CapacityPage.tsx:114:53",className:"h-3 w-3 inline mr-1"}),"CPU Req"]}),e.jsxs(r,{"code-path":"src/components/kubernetes/CapacityPage.tsx:115:15",className:"text-slate-400",children:[e.jsx(w,{"code-path":"src/components/kubernetes/CapacityPage.tsx:115:53",className:"h-3 w-3 inline mr-1"}),"CPU Lim"]}),e.jsxs(r,{"code-path":"src/components/kubernetes/CapacityPage.tsx:116:15",className:"text-slate-400",children:[e.jsx(_,{"code-path":"src/components/kubernetes/CapacityPage.tsx:116:53",className:"h-3 w-3 inline mr-1"}),"Mem Req"]}),e.jsxs(r,{"code-path":"src/components/kubernetes/CapacityPage.tsx:117:15",className:"text-slate-400",children:[e.jsx(_,{"code-path":"src/components/kubernetes/CapacityPage.tsx:117:53",className:"h-3 w-3 inline mr-1"}),"Mem Lim"]})]})}),e.jsx(F,{"code-path":"src/components/kubernetes/CapacityPage.tsx:119:13",children:m.length===0?e.jsx(d,{"code-path":"src/components/kubernetes/CapacityPage.tsx:121:17",children:e.jsxs(n,{"code-path":"src/components/kubernetes/CapacityPage.tsx:121:27",colSpan:8,className:"text-center text-slate-500 py-8",children:["暂无数据",l?e.jsx("span",{"code-path":"src/components/kubernetes/CapacityPage.tsx:121:109",className:"animate-spin inline-block ml-2",children:"⏳"}):""]})}):m.map((s,t)=>e.jsxs(d,{"code-path":"src/components/kubernetes/CapacityPage.tsx:123:17",className:"border-slate-800 hover:bg-slate-800/30",children:[e.jsx(n,{"code-path":"src/components/kubernetes/CapacityPage.tsx:124:19",className:"font-medium text-slate-200 text-sm",children:s.deployment}),e.jsx(n,{"code-path":"src/components/kubernetes/CapacityPage.tsx:125:19",children:e.jsx(D,{"code-path":"src/components/kubernetes/CapacityPage.tsx:125:30",variant:"outline",className:"border-slate-700 text-slate-400 text-xs",children:s.namespace})}),e.jsx(n,{"code-path":"src/components/kubernetes/CapacityPage.tsx:126:19",className:"text-sm text-slate-300",children:s.replicas}),e.jsx(n,{"code-path":"src/components/kubernetes/CapacityPage.tsx:127:19",className:"text-sm text-slate-400",children:s.container}),e.jsx(n,{"code-path":"src/components/kubernetes/CapacityPage.tsx:128:19",className:`text-sm ${s.cpu_req!=="-"?"text-blue-400":"text-slate-600"}`,children:s.cpu_req}),e.jsx(n,{"code-path":"src/components/kubernetes/CapacityPage.tsx:129:19",className:`text-sm ${s.cpu_lim!=="-"?"text-cyan-400":"text-slate-600"}`,children:s.cpu_lim}),e.jsx(n,{"code-path":"src/components/kubernetes/CapacityPage.tsx:130:19",className:`text-sm ${s.mem_req!=="-"?"text-emerald-400":"text-slate-600"}`,children:s.mem_req}),e.jsx(n,{"code-path":"src/components/kubernetes/CapacityPage.tsx:131:19",className:`text-sm ${s.mem_lim!=="-"?"text-teal-400":"text-slate-600"}`,children:s.mem_lim})]},`${s.deployment}-${s.container}-${t}`))})]})})})]})}export{te as default}; diff --git a/backend/static/assets/CloudAccountManager-CAH48BOY.js b/backend/static/assets/CloudAccountManager-CAH48BOY.js deleted file mode 100644 index 7159ec3..0000000 --- a/backend/static/assets/CloudAccountManager-CAH48BOY.js +++ /dev/null @@ -1 +0,0 @@ -import{j as e,r as a}from"./vendor-codemirror-B1SGo4xl.js";import{B as d,D as R,a as W,b as Q,c as V,d as $,e as G}from"./index-Dungj95X.js";import{I as h}from"./input-CXoUQQLm.js";import{L as u}from"./label-CMpUoC87.js";import{C as N,a as y}from"./card-BIfzBCEy.js";import{B as A}from"./badge-CGJlVD3L.js";import{c as v}from"./account--x8iUlBA.js";import{R as _,P as F,S as X,ag as S,C as Z,a as q,d as k,T as J,i as U,L as Y}from"./vendor-icons-DmqcWdzX.js";const L={aws:{viewBox:"0 0 24 24",color:"#FF9900",path:"M6.763 10.036c0 .296.032.535.088.71.064.176.144.368.256.576.04.063.056.127.056.183 0 .08-.048.16-.152.24l-.503.335a.383.383 0 0 1-.208.072c-.08 0-.16-.04-.24-.112a2.47 2.47 0 0 1-.288-.375 6.18 6.18 0 0 1-.248-.471c-.622.734-1.405 1.101-2.347 1.101-.671 0-1.205-.191-1.596-.574-.391-.384-.59-.894-.59-1.533 0-.678.239-1.23.726-1.644.487-.415 1.133-.623 1.955-.623.272 0 .551.024.846.064.296.04.6.104.918.176v-.583c0-.607-.127-1.03-.375-1.277-.255-.248-.686-.367-1.3-.367-.28 0-.568.031-.863.103-.295.072-.583.16-.862.272a2.287 2.287 0 0 1-.28.104.488.488 0 0 1-.127.023c-.112 0-.168-.08-.168-.247v-.391c0-.128.016-.224.056-.28a.597.597 0 0 1 .224-.167c.279-.144.614-.264 1.005-.36a4.84 4.84 0 0 1 1.246-.151c.95 0 1.644.216 2.091.647.439.43.662 1.085.662 1.963v2.586zm-3.24 1.21c.265 0 .538-.048.822-.144.283-.096.535-.271.742-.51.128-.152.224-.32.264-.512.04-.191.072-.423.072-.694v-.335a6.66 6.66 0 0 0-.735-.136 6.02 6.02 0 0 0-.75-.048c-.535 0-.926.104-1.19.32-.263.215-.39.518-.39.917 0 .375.095.654.295.846.191.2.47.296.838.296zm3.89.527c-.073 0-.12-.016-.152-.048-.032-.024-.064-.08-.088-.152L6.155 5.563a.715.715 0 0 1-.032-.16c0-.128.064-.2.192.2h.703c.08 0 .136.016.168.048.032.024.064.08.088.152l1.348 5.298 1.252-5.298c.024-.08.056-.128.088-.152a.355.355 0 0 1 .176-.048h.575c.08 0 .136.016.176.048.032.024.072.08.088.152l1.268 5.362 1.39-5.362c.024-.08.056-.128.088-.152a.344.344 0 0 1 .168-.048h.67c.128 0 .2.072.2.2 0 .04-.008.072-.016.112 0 0-.04.128-.088.152l-1.916 6.15c-.032.08-.064.128-.096.152a.355.355 0 0 1-.176.048h-.622c-.08 0-.136-.016-.176-.048-.032-.024-.064-.08-.088-.152l-1.26-5.186-1.252 5.178c-.024.08-.056.128-.088.152a.355.355 0 0 1-.176.048h-.623zm9.166.215c-.367 0-.734-.04-1.094-.127-.359-.088-.638-.184-.822-.296-.112-.064-.191-.136-.223-.2a.498.498 0 0 1-.032-.128v-.399c0-.167.064-.247.183-.247a.45.45 0 0 1 .144.024c.048.016.12.048.2.08.271.12.566.215.878.279.319.064.63.096.95.096.502 0 .893-.088 1.164-.264a.86.86 0 0 0 .415-.758.777.777 0 0 0-.215-.55c-.144-.151-.423-.287-.83-.415l-1.188-.367c-.598-.192-1.044-.471-1.316-.838a1.95 1.95 0 0 1-.415-1.205c0-.351.072-.662.215-.918.144-.255.335-.479.575-.654.24-.184.51-.319.822-.415.311-.096.638-.136.982-.136.176 0 .36.008.535.032.184.024.351.056.518.088.152.04.303.08.439.127.136.048.24.096.311.144a.66.66 0 0 1 .176.144.298.298 0 0 1 .048.184v.359c0 .168-.064.256-.183.256a.83.83 0 0 1-.304-.096 3.68 3.68 0 0 0-1.548-.311c-.463 0-.83.072-1.085.231-.255.16-.39.4-.39.743 0 .351.128.59.383.758.255.168.702.335 1.331.48.583.135 1.005.311 1.268.518.263.207.39.495.39.862 0 .367-.128.662-.375.902-.247.247-.67.375-1.26.375zm2.004 1.332c-2.637 1.948-6.488 2.984-9.793 2.984-4.635 0-8.81-1.715-11.966-4.566-.255-.224-.024-.335.271-.144 3.41 1.987 7.622 3.183 11.966 3.183 2.936 0 6.158-.61 9.119-1.876.44-.207.815.287.383.615zm1.078-1.23c-.336-.431-2.223-.2-3.073-.103-.255.024-.295-.192-.064-.351 1.5-1.053 3.962-.75 4.246-.4.287.359-.08 2.824-1.484 4.004-.215.184-.423.088-.319-.151.311-.774 1.005-2.51.662-2.956v-.443z"},azure:{viewBox:"0 0 24 24",color:"#0078D4",path:"M5.483 21.3H24L14.025 4.013l-3.022 5.915 5.99 9.357H8.787l-3.304 6.015zM8.7 3.197L0 21.3h6.395l4.49-8.51L8.7 3.196z"},gcp:{viewBox:"0 0 24 24",color:"#4285F4",path:"M12.19 2.38a9.344 9.344 0 0 0-9.234 6.893c.053-.02-.055.013 0 0-3.875 2.551-3.922 8.11-.247 10.941l.006-.007-.007.03a6.717 6.717 0 0 0 4.077 1.356h5.173l.03.03h5.192c6.687.053 9.376-8.605 3.835-12.35a9.365 9.365 0 0 0-2.821-4.552l-.043.043.006-.05A9.344 9.344 0 0 0 12.19 2.38zm-.358 4.146c1.244-.04 2.518.368 3.486 1.15a5.186 5.186 0 0 1 1.862 4.078v.518c3.53-.07 3.53 5.262 0 5.193h-5.193l-.008.009v-.04H6.785a2.59 2.59 0 0 1-1.067-.23h.001a2.597 2.597 0 1 1 3.437-3.437l3.013-3.012A6.747 6.747 0 0 0 8.11 8.24c.018-.01.04-.026.054-.023a5.186 5.186 0 0 1 3.67-1.69z"},aliyun:{viewBox:"0 0 24 24",color:"#FF6A00",path:"M3.996 4.517h5.291L8.01 6.324 4.153 7.506a1.668 1.668 0 0 0-1.165 1.601v5.786a1.668 1.668 0 0 0 1.165 1.6l3.857 1.183 1.277 1.807H3.996A3.996 3.996 0 0 1 0 15.487V8.513a3.996 3.996 0 0 1 3.996-3.996m16.008 0h-5.291l1.277 1.807 3.857 1.182c.715.227 1.17.889 1.165 1.601v5.786a1.668 1.668 0 0 1-1.165 1.6l-3.857 1.183-1.277 1.807h5.291A3.996 3.996 0 0 0 24 15.487V8.513a3.996 3.996 0 0 0-3.996-3.996m-4.007 8.345H8.002v-1.804h7.995Z"},tencent:{viewBox:"220 60 620 430",color:"#006EFF",paths:[{fill:"#006EFF",d:"M685.3,188.5c-24.7-66.3-88-110.4-158.8-110.5c-84.8,0-152.2,62.8-165.3,140.8c6.5,0,13.1-2.1,21.8-2.1c8.7,0,19.6,2.1,28.3,2.1c10.9-54.2,58.7-93.2,115.3-93.2c47.8,0,89.2,28.2,108.7,69.3c0,0,2.2,2.2,2.2,0C652.6,192.8,670,188.5,685.3,188.5L685.3,188.5"},{fill:"#00C8DC",d:"M456.9,242.6c-23.9-17.3-47.9-26-76.1-26c-33.9,0-66.2,14.2-89.2,39c-48.4,49.7-47.4,129.2,2.2,177.7c21.7,19.5,43.5,30.3,69.6,32.5l50-47.7h-28.3c-28.3-2.1-45.7-10.8-56.5-21.6c-30-29.6-30.9-77.6-2.2-108.3c15.2-15.2,32.6-21.7,54.4-21.7c13.1,0,32.6,2.1,52.2,21.6c8.7,8.7,32.6,26,41.3,34.7h2.1l32.6-32.5v-2.2C493.9,273,470,253.5,456.9,242.6"},{fill:"#00A3FF",d:"M724.4,396.5c-8.7,8.7-26.1,21.7-56.5,21.7h-187c56.5-54.1,104.4-99.6,108.8-104c8.3-8.4,17-16.3,26.1-23.8c21.8-19.5,39.1-21.7,54.4-21.7c21.7,0,39.1,8.7,54.4,21.6C754.9,318.5,754.9,368.4,724.4,396.5z M761.4,255.6c-23-24.8-55.3-39-89.2-39c-30.4,0-56.5,10.9-80.5,28.2c-8.8,8.7-21.8,17.3-32.7,30.3c-8.7,8.7-195.7,190.7-195.7,190.7c10.9,2.2,23.9,2.2,34.8,2.2h237.1c17.4,0,30.5,0,43.5-2.2c30-2.2,58.3-14.4,80.5-34.7C809.2,383.5,809.2,303.4,761.4,255.6L761.4,255.6"}]},huawei:{viewBox:"0 0 24 24",color:"#FF0000",path:"M3.67 6.14S1.82 7.91 1.72 9.78v.35c.08 1.51 1.22 2.4 1.22 2.4 1.83 1.79 6.26 4.04 7.3 4.55 0 0 .06.03.1-.01l.02-.04v-.04C7.52 10.8 3.67 6.14 3.67 6.14zM9.65 18.6c-.02-.08-.1-.08-.1-.08l-7.38.26c.8 1.43 2.15 2.53 3.56 2.2.96-.25 3.16-1.78 3.88-2.3.06-.05.04-.09.04-.09zm.08-.78C6.49 15.63.21 12.28.21 12.28c-.15.46-.2.9-.21 1.3v.07c0 1.07.4 1.82.4 1.82.8 1.69 2.34 2.2 2.34 2.2.7.3 1.4.31 1.4.31.12.02 4.4 0 5.54 0 .05 0 .08-.05.08-.05v-.06c0-.03-.03-.05-.03-.05zM9.06 3.19a3.42 3.42 0 00-2.57 3.15v.41c.03.6.16 1.05.16 1.05.66 2.9 3.86 7.65 4.55 8.65.05.05.1.03.1.03a.1.1 0 00.06-.1c1.06-10.6-1.11-13.42-1.11-13.42-.32.02-1.19.23-1.19.23zm8.299 2.27s-.49-1.8-2.44-2.28c0 0-.57-.14-1.17-.22 0 0-2.18 2.81-1.12 13.43.01.07.06.08.06.08.07.03.1-.03.1-.03.72-1.03 3.9-5.76 4.55-8.64 0 0 .36-1.4.02-2.34zm-2.92 13.07s-.07 0-.09.05c0 0-.01.07.03.1.7.51 2.85 2 3.88 2.3 0 0 .16.05.43.06h.14c.69-.02 1.9-.37 3-2.26l-7.4-.25zm7.83-8.41c.14-2.06-1.94-3.97-1.94-3.98 0 0-3.85 4.66-6.67 10.8 0 0-.03.08.02.13l.04.01h.06c1.06-.53 5.46-2.77 7.28-4.54 0 0 1.15-.93 1.21-2.42zm1.52 2.14s-6.28 3.37-9.52 5.55c0 0-.05.04-.03.11 0 0 .03.06.07.06 1.16 0 5.56 0 5.67-.02 0 0 .57-.02 1.27-.29 0 0 1.56-.5 2.37-2.27 0 0 .73-1.45.17-3.14z"}};function ee({provider:t,className:p="h-5 w-5"}){const n=L[t]||L.aliyun;return e.jsx("svg",{"code-path":"src/components/icons/CloudBrandIcon.tsx:69:5",className:p,viewBox:n.viewBox,fill:"currentColor",style:{color:n.color},role:"img","aria-label":t,children:n.paths?n.paths.map((m,x)=>e.jsx("path",{"code-path":"src/components/icons/CloudBrandIcon.tsx:79:11",d:m.d,fill:m.fill||"currentColor"},x)):e.jsx("path",{"code-path":"src/components/icons/CloudBrandIcon.tsx:82:9",d:n.path})})}function ce(t){return{aws:"#FF9900",azure:"#0078D4",gcp:"#4285F4",aliyun:"#FF6A00",tencent:"#006EFF",huawei:"#FF0000"}[t]||"#64748B"}const se={aws:"AWS",aliyun:"阿里云",tencent:"腾讯云",huawei:"华为云",azure:"Azure",gcp:"GCP"};function pe(){const[t,p]=a.useState([]),[n,m]=a.useState(!0),[x,B]=a.useState(""),[M,D]=a.useState("all"),[E,i]=a.useState(!1),[b,f]=a.useState(!1),[o,w]=a.useState(null),[s,l]=a.useState({name:"",provider:"aliyun",access_key:"",secret_key:"",monthly_cost:"",status:"active"}),I=()=>{w(null),l({name:"",provider:"aliyun",access_key:"",secret_key:"",monthly_cost:"",status:"active"})},K=()=>{I(),i(!0)},P=c=>{w(c),l({name:c.name||"",provider:c.provider||"aliyun",access_key:"",secret_key:"",monthly_cost:String(c.monthly_cost??0),status:c.status||"active"}),i(!0)},H=async()=>{if(!(!s.name.trim()||!s.provider.trim()))try{f(!0);const c={name:s.name.trim(),provider:s.provider,access_key:s.access_key.trim(),secret_key:s.secret_key.trim(),monthly_cost:Number(s.monthly_cost)||0,status:s.status};o?await v.updateAccount(o.id,c):await v.createAccount(c),i(!1),g()}catch(c){console.error(o?"更新云账号失败:":"创建云账号失败:",c)}finally{f(!1)}},g=async()=>{try{m(!0);const c=await v.getAccounts();p(c?.list||[])}catch(c){console.error("加载云账号列表失败:",c),p([])}finally{m(!1)}};a.useEffect(()=>{g()},[]);const O=async c=>{try{await v.deleteAccount(c),g()}catch(r){console.error("删除云账号失败:",r)}},z=t.filter(c=>{const r=c.access_key||c.accessKey||"",j=(c.name||"").toLowerCase().includes(x.toLowerCase())||r.toLowerCase().includes(x.toLowerCase()),C=M==="all"||c.provider===M;return j&&C});return t.length,t.filter(c=>c.status==="active").length,t.filter(c=>c.status==="inactive").length,t.filter(c=>c.status==="error").length,e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:157:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:159:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:160:9",children:[e.jsx("h1",{"code-path":"src/components/cloud/CloudAccountManager.tsx:161:11",className:"text-2xl font-bold text-slate-100",children:"云账号管理"}),e.jsx("p",{"code-path":"src/components/cloud/CloudAccountManager.tsx:162:11",className:"text-slate-400 mt-1",children:"管理多云平台的访问凭证和账号信息"})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:164:9",className:"flex items-center gap-2",children:[e.jsxs(d,{"code-path":"src/components/cloud/CloudAccountManager.tsx:165:11",variant:"outline",onClick:g,className:"border-slate-700 text-slate-300",children:[e.jsx(_,{"code-path":"src/components/cloud/CloudAccountManager.tsx:166:13",className:`h-4 w-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]}),e.jsxs(d,{"code-path":"src/components/cloud/CloudAccountManager.tsx:169:11",className:"bg-blue-600 hover:bg-blue-700",onClick:K,children:[e.jsx(F,{"code-path":"src/components/cloud/CloudAccountManager.tsx:170:13",className:"h-4 w-4 mr-2"}),"添加账号"]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:177:7",className:"flex items-center gap-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:178:9",className:"relative flex-1 max-w-md",children:[e.jsx(X,{"code-path":"src/components/cloud/CloudAccountManager.tsx:179:11",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(h,{"code-path":"src/components/cloud/CloudAccountManager.tsx:180:11",placeholder:"搜索账号名称或AccessKey...",value:x,onChange:c=>B(c.target.value),className:"pl-10 bg-slate-800 border-slate-700 text-slate-100"})]}),e.jsxs("select",{"code-path":"src/components/cloud/CloudAccountManager.tsx:187:9",value:M,onChange:c=>D(c.target.value),className:"px-3 py-2 bg-slate-800 border border-slate-700 rounded-md text-slate-100 text-sm",children:[e.jsx("option",{"code-path":"src/components/cloud/CloudAccountManager.tsx:192:11",value:"all",children:"全部平台"}),e.jsx("option",{"code-path":"src/components/cloud/CloudAccountManager.tsx:193:11",value:"aws",children:"AWS"}),e.jsx("option",{"code-path":"src/components/cloud/CloudAccountManager.tsx:194:11",value:"aliyun",children:"阿里云"}),e.jsx("option",{"code-path":"src/components/cloud/CloudAccountManager.tsx:195:11",value:"tencent",children:"腾讯云"}),e.jsx("option",{"code-path":"src/components/cloud/CloudAccountManager.tsx:196:11",value:"huawei",children:"华为云"}),e.jsx("option",{"code-path":"src/components/cloud/CloudAccountManager.tsx:197:11",value:"azure",children:"Azure"})]})]}),n?e.jsx(N,{"code-path":"src/components/cloud/CloudAccountManager.tsx:203:9",className:"bg-slate-800 border-slate-700",children:e.jsxs(y,{"code-path":"src/components/cloud/CloudAccountManager.tsx:204:11",className:"p-12 text-center text-slate-500",children:[e.jsx(_,{"code-path":"src/components/cloud/CloudAccountManager.tsx:205:13",className:"h-6 w-6 animate-spin mx-auto mb-3"}),"加载中..."]})}):z.length===0?e.jsx(N,{"code-path":"src/components/cloud/CloudAccountManager.tsx:210:9",className:"bg-slate-800 border-slate-700",children:e.jsx(y,{"code-path":"src/components/cloud/CloudAccountManager.tsx:211:11",className:"p-12 text-center text-slate-500",children:"暂无云账号数据"})}):e.jsx("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:214:9",className:"grid grid-cols-2 gap-4",children:z.map(c=>{const r=c.access_key||c.accessKey||"",j=c.server_count??c.serverCount??0,C=c.last_sync||c.lastSync||c.created_at||"-",T=c.monthly_cost??c.monthlyCost??0;return e.jsx(N,{"code-path":"src/components/cloud/CloudAccountManager.tsx:221:15",className:"bg-slate-800 border-slate-700",children:e.jsxs(y,{"code-path":"src/components/cloud/CloudAccountManager.tsx:222:17",className:"p-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:223:19",className:"flex items-start justify-between",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:224:21",className:"flex items-start gap-3",children:[e.jsx("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:225:23",className:"w-10 h-10 rounded-lg bg-slate-800 flex items-center justify-center",style:{borderBottom:`2px solid ${ce(c.provider)}`},children:e.jsx(ee,{"code-path":"src/components/cloud/CloudAccountManager.tsx:226:25",provider:c.provider,className:"h-6 w-6"})}),e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:228:23",children:[e.jsx("h3",{"code-path":"src/components/cloud/CloudAccountManager.tsx:229:25",className:"font-medium text-slate-100",children:c.name}),e.jsx("p",{"code-path":"src/components/cloud/CloudAccountManager.tsx:230:25",className:"text-sm text-slate-400 mt-0.5",children:se[c.provider]||c.provider}),e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:231:25",className:"flex items-center gap-3 mt-2",children:[r&&e.jsxs(A,{"code-path":"src/components/cloud/CloudAccountManager.tsx:233:29",variant:"secondary",className:"bg-slate-700 text-slate-300",children:[e.jsx(S,{"code-path":"src/components/cloud/CloudAccountManager.tsx:234:31",className:"h-3 w-3 mr-1"}),r.slice(0,8),"..."]}),c.status==="active"&&e.jsxs(A,{"code-path":"src/components/cloud/CloudAccountManager.tsx:239:29",className:"bg-green-500/20 text-green-400 border-0",children:[e.jsx(Z,{"code-path":"src/components/cloud/CloudAccountManager.tsx:240:31",className:"h-3 w-3 mr-1"}),"正常"]}),c.status==="inactive"&&e.jsxs(A,{"code-path":"src/components/cloud/CloudAccountManager.tsx:245:29",className:"bg-slate-500/20 text-slate-400 border-0",children:[e.jsx(q,{"code-path":"src/components/cloud/CloudAccountManager.tsx:246:31",className:"h-3 w-3 mr-1"}),"已停用"]}),c.status==="error"&&e.jsxs(A,{"code-path":"src/components/cloud/CloudAccountManager.tsx:251:29",className:"bg-red-500/20 text-red-400 border-0",children:[e.jsx(S,{"code-path":"src/components/cloud/CloudAccountManager.tsx:252:31",className:"h-3 w-3 mr-1"}),"异常"]})]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:259:21",className:"flex items-center gap-1",children:[e.jsx(d,{"code-path":"src/components/cloud/CloudAccountManager.tsx:260:23",variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-blue-400",onClick:()=>P(c),children:e.jsx(k,{"code-path":"src/components/cloud/CloudAccountManager.tsx:266:25",className:"h-4 w-4"})}),e.jsx(d,{"code-path":"src/components/cloud/CloudAccountManager.tsx:268:23",variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-red-400",onClick:()=>O(c.id),children:e.jsx(J,{"code-path":"src/components/cloud/CloudAccountManager.tsx:274:25",className:"h-4 w-4"})})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:278:19",className:"grid grid-cols-3 gap-4 mt-4 pt-4 border-t border-slate-700",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:279:21",children:[e.jsx("p",{"code-path":"src/components/cloud/CloudAccountManager.tsx:280:23",className:"text-xs text-slate-400",children:"月费用"}),e.jsxs("p",{"code-path":"src/components/cloud/CloudAccountManager.tsx:281:23",className:"text-lg font-medium text-emerald-400",children:["¥",Number(T).toLocaleString()]})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:283:21",children:[e.jsx("p",{"code-path":"src/components/cloud/CloudAccountManager.tsx:284:23",className:"text-xs text-slate-400",children:"服务器数"}),e.jsx("p",{"code-path":"src/components/cloud/CloudAccountManager.tsx:285:23",className:"text-lg font-medium text-slate-100",children:j})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:287:21",children:[e.jsx("p",{"code-path":"src/components/cloud/CloudAccountManager.tsx:288:23",className:"text-xs text-slate-400",children:"最后同步"}),e.jsx("p",{"code-path":"src/components/cloud/CloudAccountManager.tsx:289:23",className:"text-sm text-slate-300",children:C!=="-"?new Date(C).toLocaleString():"-"})]})]})]})},c.id)})}),e.jsx(R,{"code-path":"src/components/cloud/CloudAccountManager.tsx:302:7",open:E,onOpenChange:i,children:e.jsxs(W,{"code-path":"src/components/cloud/CloudAccountManager.tsx:303:9",className:"bg-slate-800 border-slate-700 text-slate-100 max-w-lg",children:[e.jsxs(Q,{"code-path":"src/components/cloud/CloudAccountManager.tsx:304:11",children:[e.jsxs(V,{"code-path":"src/components/cloud/CloudAccountManager.tsx:305:13",className:"text-slate-100 flex items-center gap-2",children:[e.jsx(U,{"code-path":"src/components/cloud/CloudAccountManager.tsx:306:15",className:"h-5 w-5 text-blue-400"}),o?"编辑云账号":"添加云账号"]}),e.jsx($,{"code-path":"src/components/cloud/CloudAccountManager.tsx:309:13",className:"text-slate-400",children:o?"修改账号信息和访问凭证,留空则保持原凭证不变":"录入多云平台的访问凭证,用于资源同步与成本统计"})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:314:11",className:"space-y-4 py-2",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:315:13",className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:316:15",className:"space-y-1.5",children:[e.jsxs(u,{"code-path":"src/components/cloud/CloudAccountManager.tsx:317:17",className:"text-slate-300",children:["账号名称 ",e.jsx("span",{"code-path":"src/components/cloud/CloudAccountManager.tsx:318:24",className:"text-red-400",children:"*"})]}),e.jsx(h,{"code-path":"src/components/cloud/CloudAccountManager.tsx:320:17",placeholder:"阿里云生产账号",value:s.name,onChange:c=>l({...s,name:c.target.value}),className:"bg-slate-900 border-slate-700 text-slate-100 placeholder:text-slate-500"})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:327:15",className:"space-y-1.5",children:[e.jsxs(u,{"code-path":"src/components/cloud/CloudAccountManager.tsx:328:17",className:"text-slate-300",children:["云平台 ",e.jsx("span",{"code-path":"src/components/cloud/CloudAccountManager.tsx:329:23",className:"text-red-400",children:"*"})]}),e.jsxs("select",{"code-path":"src/components/cloud/CloudAccountManager.tsx:331:17",value:s.provider,onChange:c=>l({...s,provider:c.target.value}),className:"w-full px-3 py-2 bg-slate-900 border border-slate-700 rounded-md text-slate-100 text-sm",children:[e.jsx("option",{"code-path":"src/components/cloud/CloudAccountManager.tsx:336:19",value:"aliyun",children:"阿里云"}),e.jsx("option",{"code-path":"src/components/cloud/CloudAccountManager.tsx:337:19",value:"tencent",children:"腾讯云"}),e.jsx("option",{"code-path":"src/components/cloud/CloudAccountManager.tsx:338:19",value:"aws",children:"AWS"}),e.jsx("option",{"code-path":"src/components/cloud/CloudAccountManager.tsx:339:19",value:"huawei",children:"华为云"}),e.jsx("option",{"code-path":"src/components/cloud/CloudAccountManager.tsx:340:19",value:"azure",children:"Azure"})]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:345:13",className:"space-y-1.5",children:[e.jsxs(u,{"code-path":"src/components/cloud/CloudAccountManager.tsx:346:15",className:"text-slate-300",children:["AccessKey",o&&e.jsx("span",{"code-path":"src/components/cloud/CloudAccountManager.tsx:348:36",className:"text-xs text-slate-500 ml-2",children:"留空保持不变"})]}),e.jsx(h,{"code-path":"src/components/cloud/CloudAccountManager.tsx:350:15",placeholder:"LTAI...",value:s.access_key,onChange:c=>l({...s,access_key:c.target.value}),className:"bg-slate-900 border-slate-700 text-slate-100 placeholder:text-slate-500 font-mono text-sm"})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:358:13",className:"space-y-1.5",children:[e.jsxs(u,{"code-path":"src/components/cloud/CloudAccountManager.tsx:359:15",className:"text-slate-300",children:["SecretKey",o&&e.jsx("span",{"code-path":"src/components/cloud/CloudAccountManager.tsx:361:36",className:"text-xs text-slate-500 ml-2",children:"留空保持不变"})]}),e.jsx(h,{"code-path":"src/components/cloud/CloudAccountManager.tsx:363:15",type:"password",placeholder:"••••••••",value:s.secret_key,onChange:c=>l({...s,secret_key:c.target.value}),className:"bg-slate-900 border-slate-700 text-slate-100 placeholder:text-slate-500 font-mono text-sm"})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:372:13",className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:373:15",className:"space-y-1.5",children:[e.jsx(u,{"code-path":"src/components/cloud/CloudAccountManager.tsx:374:17",className:"text-slate-300",children:"月费用 (元)"}),e.jsx(h,{"code-path":"src/components/cloud/CloudAccountManager.tsx:375:17",type:"number",min:"0",placeholder:"0",value:s.monthly_cost,onChange:c=>l({...s,monthly_cost:c.target.value}),className:"bg-slate-900 border-slate-700 text-slate-100 placeholder:text-slate-500"})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudAccountManager.tsx:384:15",className:"space-y-1.5",children:[e.jsx(u,{"code-path":"src/components/cloud/CloudAccountManager.tsx:385:17",className:"text-slate-300",children:"状态"}),e.jsxs("select",{"code-path":"src/components/cloud/CloudAccountManager.tsx:386:17",value:s.status,onChange:c=>l({...s,status:c.target.value}),className:"w-full px-3 py-2 bg-slate-900 border border-slate-700 rounded-md text-slate-100 text-sm",children:[e.jsx("option",{"code-path":"src/components/cloud/CloudAccountManager.tsx:391:19",value:"active",children:"正常"}),e.jsx("option",{"code-path":"src/components/cloud/CloudAccountManager.tsx:392:19",value:"inactive",children:"已停用"}),e.jsx("option",{"code-path":"src/components/cloud/CloudAccountManager.tsx:393:19",value:"error",children:"异常"})]})]})]})]}),e.jsxs(G,{"code-path":"src/components/cloud/CloudAccountManager.tsx:399:11",children:[e.jsx(d,{"code-path":"src/components/cloud/CloudAccountManager.tsx:400:13",variant:"outline",onClick:()=>i(!1),className:"border-slate-700 text-slate-300 hover:bg-slate-700",children:"取消"}),e.jsxs(d,{"code-path":"src/components/cloud/CloudAccountManager.tsx:403:13",className:"bg-blue-600 hover:bg-blue-700",disabled:!s.name.trim()||b,onClick:H,children:[b?e.jsx(Y,{"code-path":"src/components/cloud/CloudAccountManager.tsx:408:29",className:"h-4 w-4 mr-2 animate-spin"}):o?e.jsx(k,{"code-path":"src/components/cloud/CloudAccountManager.tsx:408:98",className:"h-4 w-4 mr-2"}):e.jsx(F,{"code-path":"src/components/cloud/CloudAccountManager.tsx:408:136",className:"h-4 w-4 mr-2"}),o?"保存修改":"创建账号"]})]})]})})]})}export{pe as CloudAccountManager}; diff --git a/backend/static/assets/CloudBilling-BR3942nv.js b/backend/static/assets/CloudBilling-BR3942nv.js deleted file mode 100644 index 7a418ec..0000000 --- a/backend/static/assets/CloudBilling-BR3942nv.js +++ /dev/null @@ -1 +0,0 @@ -import{j as e,r as c}from"./vendor-codemirror-B1SGo4xl.js";import{D as X,a as Y,b as Z,c as ee,d as se,e as le,B as m,t as p,f as ve}from"./index-Dungj95X.js";import{I as j}from"./input-CXoUQQLm.js";import{L as r}from"./label-CMpUoC87.js";import{C as H,a as T}from"./card-BIfzBCEy.js";import{B as Ne}from"./badge-CGJlVD3L.js";import{S as oe}from"./switch-Bxiq4EHp.js";import{S as R,a as w,b as S,c as k,d as x}from"./select-CiTqGGhE.js";import{b as h}from"./billing-DhtxUWwz.js";import{S as fe}from"./stat-strip-BSQFwFzG.js";import{L as _,R as G,P as q,t as O,aG as be,d as J,T as K}from"./vendor-icons-DmqcWdzX.js";import"./index-5FEebgvX.js";const v={aliyun:"阿里云",tencent:"腾讯云",aws:"AWS",huawei:"华为云",azure:"Azure"},V={aliyun:"bg-orange-500",tencent:"bg-blue-500",aws:"bg-amber-500",huawei:"bg-red-500",azure:"bg-sky-500"};function g(d){return`¥${d.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2})}`}function De({data:d}){if(d.length===0)return e.jsx("p",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:54:12",className:"text-sm text-slate-500 py-8 text-center",children:"暂无数据"});const n=Math.max(...d.map(a=>a.cost),1),t=d.slice(-30);return e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:60:5",children:[e.jsx("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:61:7",className:"flex items-end gap-0.5 h-40",children:t.map((a,o)=>{const i=Math.max(a.cost/n*100,2);return e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:65:13",className:"flex-1 group relative",style:{height:"100%"},children:[e.jsx("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:70:15",className:"absolute bottom-0 w-full rounded-t-sm bg-gradient-to-t from-blue-600/60 to-blue-400/80 group-hover:from-blue-500 group-hover:to-blue-300 transition-colors",style:{height:`${i}%`}}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:74:15",className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block whitespace-nowrap text-xs bg-slate-800 text-slate-200 px-2 py-1 rounded border border-slate-700 z-10",children:[a.date,": ",g(a.cost)]})]},o)})}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:81:7",className:"flex justify-between mt-2 text-xs text-slate-500",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:82:9",children:t[0]?.date}),e.jsx("span",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:83:9",children:t[t.length-1]?.date})]})]})}const Q={provider:"aliyun",billing_date:"",cost:"",service:"",region:"",account_name:"",description:""};function ye({open:d,onOpenChange:n,editingRecord:t,onSuccess:a}){const[o,i]=c.useState(Q),[B,C]=c.useState(!1);c.useEffect(()=>{d&&i(t?{provider:t.provider,billing_date:t.billing_date,cost:t.cost,service:t.service||"",region:t.region||"",account_name:t.account_name||"",description:t.description||""}:{...Q,billing_date:new Date().toISOString().slice(0,10)})},[d,t]);const y=async()=>{if(!o.provider||!o.billing_date||!o.cost){p.error("请填写必填字段");return}C(!0);try{const l={...o,cost:parseFloat(o.cost)};t?(await h.remove(t.id),await h.create(l)):await h.create(l),n(!1),a(),p("保存成功")}catch(l){p.error("保存失败",{description:l.message})}finally{C(!1)}};return e.jsx(X,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:91:5",open:d,onOpenChange:n,children:e.jsxs(Y,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:92:7",className:"max-w-md",children:[e.jsxs(Z,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:93:9",children:[e.jsx(ee,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:94:11",children:t?"编辑成本记录":"记录成本"}),e.jsx(se,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:95:11",children:"记录一条每日云资源成本"})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:97:9",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:98:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:99:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:100:15",className:"text-sm text-slate-300",children:"厂商 *"}),e.jsxs(R,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:101:15",value:o.provider,onValueChange:l=>i({...o,provider:l}),children:[e.jsx(w,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:102:17",className:"mt-1",children:e.jsx(S,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:102:49"})}),e.jsx(k,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:103:17",children:Object.entries(v).map(([l,f])=>e.jsx(x,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:105:21",value:l,children:f},l))})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:110:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:111:15",className:"text-sm text-slate-300",children:"日期 *"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:112:15",type:"date",className:"mt-1",value:o.billing_date,onChange:l=>i({...o,billing_date:l.target.value})})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:115:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:116:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:117:15",className:"text-sm text-slate-300",children:"费用(元) *"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:118:15",type:"number",step:"0.01",className:"mt-1",placeholder:"0.00",value:o.cost,onChange:l=>i({...o,cost:l.target.value})})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:120:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:121:15",className:"text-sm text-slate-300",children:"服务"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:122:15",className:"mt-1",placeholder:"ECS, RDS...",value:o.service,onChange:l=>i({...o,service:l.target.value})})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:125:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:126:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:127:15",className:"text-sm text-slate-300",children:"区域"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:128:15",className:"mt-1",placeholder:"cn-hangzhou",value:o.region,onChange:l=>i({...o,region:l.target.value})})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:130:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:131:15",className:"text-sm text-slate-300",children:"账号名称"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:132:15",className:"mt-1",placeholder:"主账号",value:o.account_name,onChange:l=>i({...o,account_name:l.target.value})})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:135:11",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:136:13",className:"text-sm text-slate-300",children:"备注"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:137:13",className:"mt-1",placeholder:"可选",value:o.description,onChange:l=>i({...o,description:l.target.value})})]})]}),e.jsxs(le,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:140:9",children:[e.jsx(m,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:141:11",variant:"outline",onClick:()=>n(!1),children:"取消"}),e.jsxs(m,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:142:11",onClick:y,disabled:B,children:[B&&e.jsx(_,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:143:28",className:"h-4 w-4 mr-1 animate-spin"}),"保存"]})]})]})})}const U={name:"",provider:"",metric:"daily",threshold:"",operator:">",enabled:!0};function Re({open:d,onOpenChange:n,editingRule:t,onSuccess:a}){const[o,i]=c.useState(U),[B,C]=c.useState(!1);c.useEffect(()=>{d&&i(t?{name:t.name,provider:t.provider||"",metric:t.metric||"daily",threshold:t.threshold,operator:t.operator||">",enabled:t.enabled}:{...U})},[d,t]);const y=async()=>{if(!o.name||!o.threshold){p.error("请填写规则名称和阈值");return}C(!0);try{const l={...o,threshold:parseFloat(o.threshold)};t?await h.updateAlertRule(t.id,l):await h.createAlertRule(l),n(!1),a(),p("保存成功")}catch(l){p.error("保存失败",{description:l.message})}finally{C(!1)}};return e.jsx(X,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:82:5",open:d,onOpenChange:n,children:e.jsxs(Y,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:83:7",className:"max-w-md",children:[e.jsxs(Z,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:84:9",children:[e.jsx(ee,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:85:11",children:t?"编辑预警规则":"添加预警规则"}),e.jsx(se,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:86:11",children:"设置成本阈值,超标时自动预警"})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:88:9",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:89:11",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:90:13",className:"text-sm text-slate-300",children:"规则名称 *"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:91:13",className:"mt-1",placeholder:"如:日成本超 500 元预警",value:o.name,onChange:l=>i({...o,name:l.target.value})})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:93:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:94:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:95:15",className:"text-sm text-slate-300",children:"厂商"}),e.jsxs(R,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:96:15",value:o.provider||"all",onValueChange:l=>i({...o,provider:l==="all"?"":l}),children:[e.jsx(w,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:97:17",className:"mt-1",children:e.jsx(S,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:97:49"})}),e.jsxs(k,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:98:17",children:[e.jsx(x,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:99:19",value:"all",children:"全部厂商"}),Object.entries(v).map(([l,f])=>e.jsx(x,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:101:21",value:l,children:f},l))]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:106:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:107:15",className:"text-sm text-slate-300",children:"指标"}),e.jsxs(R,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:108:15",value:o.metric,onValueChange:l=>i({...o,metric:l}),children:[e.jsx(w,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:109:17",className:"mt-1",children:e.jsx(S,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:109:49"})}),e.jsxs(k,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:110:17",children:[e.jsx(x,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:111:19",value:"daily",children:"日成本"}),e.jsx(x,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:112:19",value:"monthly",children:"月累计"})]})]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:117:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:118:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:119:15",className:"text-sm text-slate-300",children:"比较"}),e.jsxs(R,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:120:15",value:o.operator,onValueChange:l=>i({...o,operator:l}),children:[e.jsx(w,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:121:17",className:"mt-1",children:e.jsx(S,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:121:49"})}),e.jsxs(k,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:122:17",children:[e.jsx(x,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:123:19",value:">",children:"大于 >"}),e.jsx(x,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:124:19",value:">=",children:"大于等于 ≥"}),e.jsx(x,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:125:19",value:"<",children:"小于 <"}),e.jsx(x,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:126:19",value:"<=",children:"小于等于 ≤"})]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:130:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:131:15",className:"text-sm text-slate-300",children:"阈值(元) *"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:132:15",type:"number",step:"0.01",className:"mt-1",placeholder:"500.00",value:o.threshold,onChange:l=>i({...o,threshold:l.target.value})})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:135:11",className:"flex items-center gap-2",children:[e.jsx(oe,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:136:13",checked:o.enabled,onCheckedChange:l=>i({...o,enabled:l})}),e.jsx(r,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:137:13",className:"text-sm text-slate-300",children:"启用"})]})]}),e.jsxs(le,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:140:9",children:[e.jsx(m,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:141:11",variant:"outline",onClick:()=>n(!1),children:"取消"}),e.jsxs(m,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:142:11",onClick:y,disabled:B,children:[B&&e.jsx(_,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:143:28",className:"h-4 w-4 mr-1 animate-spin"}),"保存"]})]})]})})}function Oe(){const d=ve(),[n,t]=c.useState("overview"),[a,o]=c.useState(null),[i,B]=c.useState(!0),[C,y]=c.useState([]),[l,f]=c.useState(!0),[z,te]=c.useState(""),[E,ce]=c.useState(""),[F,ne]=c.useState(""),[P,ae]=c.useState([]),[ie,I]=c.useState(!0),[de,L]=c.useState(!1),[re,M]=c.useState(null),[pe,$]=c.useState(!1),[ue,W]=c.useState(null),N=c.useCallback(async()=>{B(!0);try{const s=await h.getStats();o(s)}catch(s){p.error("加载统计失败",{description:s.message})}finally{B(!1)}},[]),b=c.useCallback(async()=>{f(!0);try{const s={};z&&(s.provider=z),E&&(s.start_date=E),F&&(s.end_date=F);const u=await h.list(s);y(u.list||[])}catch(s){p.error("加载账单失败",{description:s.message})}finally{f(!1)}},[z,E,F]),D=c.useCallback(async()=>{I(!0);try{const s=await h.listAlertRules();ae(s.list||[])}catch(s){p.error("加载预警规则失败",{description:s.message})}finally{I(!1)}},[]);c.useEffect(()=>{N()},[N]),c.useEffect(()=>{n==="records"&&b()},[n,b]),c.useEffect(()=>{n==="alerts"&&D()},[n,D]);const me=()=>{M(null),L(!0)},xe=s=>{M(s),L(!0)},he=()=>{W(null),$(!0)},ge=s=>{W(s),$(!0)},je=async s=>{if(await d({title:"删除账单记录",description:"确定删除这条成本记录?",variant:"destructive"}))try{await h.remove(s),b(),N(),p("删除成功")}catch(A){p.error("删除失败",{description:A.message})}},Be=async s=>{if(await d({title:"删除预警规则",description:"确定删除此预警规则?",variant:"destructive"}))try{await h.deleteAlertRule(s),D(),p("删除成功")}catch(A){p.error("删除失败",{description:A.message})}},Ce=async s=>{try{await h.toggleAlertRule(s),D(),N()}catch(u){p.error("操作失败",{description:u.message})}};return e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:164:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:165:7",className:"flex items-center justify-between",children:[e.jsx("h2",{"code-path":"src/components/cloud/CloudBilling.tsx:166:9",className:"text-lg font-semibold text-slate-100",children:"云账单管理"}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:167:9",className:"flex items-center gap-2",children:[e.jsxs(m,{"code-path":"src/components/cloud/CloudBilling.tsx:168:11",variant:"outline",size:"sm",onClick:()=>{N(),n==="records"&&b(),n==="alerts"&&D()},children:[e.jsx(G,{"code-path":"src/components/cloud/CloudBilling.tsx:169:13",className:"h-4 w-4 mr-1"}),"刷新"]}),n==="records"&&e.jsxs(m,{"code-path":"src/components/cloud/CloudBilling.tsx:172:13",size:"sm",onClick:me,children:[e.jsx(q,{"code-path":"src/components/cloud/CloudBilling.tsx:173:15",className:"h-4 w-4 mr-1"}),"记录成本"]}),n==="alerts"&&e.jsxs(m,{"code-path":"src/components/cloud/CloudBilling.tsx:177:13",size:"sm",onClick:he,children:[e.jsx(q,{"code-path":"src/components/cloud/CloudBilling.tsx:178:15",className:"h-4 w-4 mr-1"}),"添加规则"]})]})]}),e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:184:7",className:"flex gap-1 border-b border-slate-800",children:[{key:"overview",label:"概览统计"},{key:"records",label:"成本记录"},{key:"alerts",label:"预警规则"}].map(s=>e.jsx("button",{"code-path":"src/components/cloud/CloudBilling.tsx:190:11",onClick:()=>t(s.key),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${n===s.key?"text-blue-400 border-blue-400":"text-slate-400 border-transparent hover:text-slate-200"}`,children:s.label},s.key))}),n==="overview"&&e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:205:9",className:"space-y-4",children:i?e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:207:13",className:"flex items-center justify-center py-20 text-slate-500",children:[e.jsx(_,{"code-path":"src/components/cloud/CloudBilling.tsx:207:84",className:"h-6 w-6 animate-spin mr-2"}),"加载中..."]}):a?e.jsxs(e.Fragment,{children:[e.jsx(fe,{"code-path":"src/components/cloud/CloudBilling.tsx:210:15",items:[{label:"今日",value:g(a.today_cost||0),color:"blue"},{label:"本月",value:g(a.month_cost||0),color:"amber"},{label:"年度",value:g(a.year_cost||0),color:"purple"},{label:"预警",value:`${a.alerts?.length||0} 条`,color:a.alerts?.length>0?"red":"muted"}]}),a.alerts?.length>0&&e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:220:17",className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:221:19",className:"flex items-center gap-2 mb-3",children:[e.jsx(O,{"code-path":"src/components/cloud/CloudBilling.tsx:222:21",className:"h-4 w-4 text-amber-400"}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:223:21",className:"text-sm font-medium text-amber-300",children:"成本预警"})]}),e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:225:19",className:"space-y-2",children:a.alerts.map((s,u)=>e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:227:23",className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:228:25",className:"flex items-center gap-2",children:[e.jsx(Ne,{"code-path":"src/components/cloud/CloudBilling.tsx:229:27",variant:"outline",className:"border-amber-500/50 text-amber-300",children:s.rule_name}),e.jsxs("span",{"code-path":"src/components/cloud/CloudBilling.tsx:230:27",className:"text-slate-400",children:[s.provider," · ",s.metric==="daily"?"日":"月","成本"]})]}),e.jsxs("span",{"code-path":"src/components/cloud/CloudBilling.tsx:234:25",className:"text-slate-300",children:["当前 ",e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:235:30",className:"text-amber-300 font-medium",children:g(s.current)})," ",s.operator," ","阈值 ",e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:237:30",className:"text-red-400 font-medium",children:g(s.threshold)})]})]},u))})]}),e.jsx(H,{"code-path":"src/components/cloud/CloudBilling.tsx:245:15",className:"bg-slate-900/50 border-slate-800",children:e.jsxs(T,{"code-path":"src/components/cloud/CloudBilling.tsx:246:17",className:"pt-4",children:[e.jsx("h3",{"code-path":"src/components/cloud/CloudBilling.tsx:247:19",className:"text-sm font-medium text-slate-200 mb-4",children:"近 30 天成本趋势"}),e.jsx(De,{"code-path":"src/components/cloud/CloudBilling.tsx:248:19",data:a.month_trend||[]})]})}),e.jsx(H,{"code-path":"src/components/cloud/CloudBilling.tsx:252:15",className:"bg-slate-900/50 border-slate-800",children:e.jsxs(T,{"code-path":"src/components/cloud/CloudBilling.tsx:253:17",className:"pt-4",children:[e.jsx("h3",{"code-path":"src/components/cloud/CloudBilling.tsx:254:19",className:"text-sm font-medium text-slate-200 mb-4",children:"本月厂商成本分布"}),(a.provider_dist||[]).length===0?e.jsx("p",{"code-path":"src/components/cloud/CloudBilling.tsx:256:21",className:"text-sm text-slate-500 py-8 text-center",children:"暂无数据"}):e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:258:21",className:"space-y-3",children:[e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:259:23",className:"flex h-8 rounded-lg overflow-hidden",children:a.provider_dist.map((s,u)=>e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:261:27",className:`${V[s.provider]||"bg-slate-600"} flex items-center justify-center text-xs text-white font-medium`,style:{width:`${s.percent}%`},title:`${v[s.provider]||s.provider}: ${g(s.cost)} (${s.percent.toFixed(1)}%)`,children:s.percent>8?v[s.provider]||s.provider:""},u))}),e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:271:23",className:"grid grid-cols-2 md:grid-cols-3 gap-2",children:a.provider_dist.map((s,u)=>e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:273:27",className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:274:29",className:"flex items-center gap-2",children:[e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:275:31",className:`w-3 h-3 rounded ${V[s.provider]||"bg-slate-600"}`}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:276:31",className:"text-slate-300",children:v[s.provider]||s.provider})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:278:29",className:"text-right",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:279:31",className:"text-slate-200 font-medium",children:g(s.cost)}),e.jsxs("span",{"code-path":"src/components/cloud/CloudBilling.tsx:280:31",className:"text-slate-500 ml-2",children:[s.percent.toFixed(1),"%"]})]})]},u))})]})]})})]}):null}),n==="records"&&e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:295:9",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:296:11",className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:297:13",children:[e.jsx(r,{"code-path":"src/components/cloud/CloudBilling.tsx:298:15",className:"text-xs text-slate-400 mb-1",children:"厂商"}),e.jsxs(R,{"code-path":"src/components/cloud/CloudBilling.tsx:299:15",value:z||"all",onValueChange:s=>te(s==="all"?"":s),children:[e.jsx(w,{"code-path":"src/components/cloud/CloudBilling.tsx:300:17",className:"w-32 h-9",children:e.jsx(S,{"code-path":"src/components/cloud/CloudBilling.tsx:300:53"})}),e.jsxs(k,{"code-path":"src/components/cloud/CloudBilling.tsx:301:17",children:[e.jsx(x,{"code-path":"src/components/cloud/CloudBilling.tsx:302:19",value:"all",children:"全部"}),Object.entries(v).map(([s,u])=>e.jsx(x,{"code-path":"src/components/cloud/CloudBilling.tsx:304:21",value:s,children:u},s))]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:309:13",children:[e.jsx(r,{"code-path":"src/components/cloud/CloudBilling.tsx:310:15",className:"text-xs text-slate-400 mb-1",children:"开始日期"}),e.jsx(j,{"code-path":"src/components/cloud/CloudBilling.tsx:311:15",type:"date",className:"w-40 h-9",value:E,onChange:s=>ce(s.target.value)})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:313:13",children:[e.jsx(r,{"code-path":"src/components/cloud/CloudBilling.tsx:314:15",className:"text-xs text-slate-400 mb-1",children:"结束日期"}),e.jsx(j,{"code-path":"src/components/cloud/CloudBilling.tsx:315:15",type:"date",className:"w-40 h-9",value:F,onChange:s=>ne(s.target.value)})]}),e.jsxs(m,{"code-path":"src/components/cloud/CloudBilling.tsx:317:13",variant:"outline",size:"sm",onClick:b,children:[e.jsx(G,{"code-path":"src/components/cloud/CloudBilling.tsx:318:15",className:"h-4 w-4 mr-1"}),"查询"]})]}),l?e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:323:13",className:"flex items-center justify-center py-20 text-slate-500",children:[e.jsx(_,{"code-path":"src/components/cloud/CloudBilling.tsx:323:84",className:"h-6 w-6 animate-spin mr-2"}),"加载中..."]}):C.length===0?e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:325:13",className:"py-20 text-center text-slate-500",children:[e.jsx(be,{"code-path":"src/components/cloud/CloudBilling.tsx:326:15",className:"h-12 w-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{"code-path":"src/components/cloud/CloudBilling.tsx:327:15",className:"text-sm",children:"暂无成本记录"})]}):e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:330:13",className:"overflow-x-auto rounded-lg border border-slate-800",children:e.jsxs("table",{"code-path":"src/components/cloud/CloudBilling.tsx:331:15",className:"w-full text-sm",children:[e.jsx("thead",{"code-path":"src/components/cloud/CloudBilling.tsx:332:17",className:"bg-slate-900/80 text-slate-400",children:e.jsxs("tr",{"code-path":"src/components/cloud/CloudBilling.tsx:333:19",children:[e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:334:21",className:"px-4 py-2.5 text-left font-medium",children:"日期"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:335:21",className:"px-4 py-2.5 text-left font-medium",children:"厂商"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:336:21",className:"px-4 py-2.5 text-left font-medium",children:"服务"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:337:21",className:"px-4 py-2.5 text-left font-medium",children:"区域"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:338:21",className:"px-4 py-2.5 text-left font-medium",children:"账号"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:339:21",className:"px-4 py-2.5 text-right font-medium",children:"费用"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:340:21",className:"px-4 py-2.5 text-left font-medium",children:"说明"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:341:21",className:"px-4 py-2.5 text-center font-medium",children:"操作"})]})}),e.jsx("tbody",{"code-path":"src/components/cloud/CloudBilling.tsx:344:17",children:C.map(s=>e.jsxs("tr",{"code-path":"src/components/cloud/CloudBilling.tsx:346:21",className:"border-t border-slate-800 hover:bg-slate-800/30",children:[e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:347:23",className:"px-4 py-2.5 text-slate-300",children:s.billing_date}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:348:23",className:"px-4 py-2.5",children:e.jsxs("span",{"code-path":"src/components/cloud/CloudBilling.tsx:349:25",className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:350:27",className:`w-2 h-2 rounded-full ${V[s.provider]||"bg-slate-500"}`}),v[s.provider]||s.provider]})}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:354:23",className:"px-4 py-2.5 text-slate-400",children:s.service||"-"}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:355:23",className:"px-4 py-2.5 text-slate-400",children:s.region||"-"}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:356:23",className:"px-4 py-2.5 text-slate-400",children:s.account_name||"-"}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:357:23",className:"px-4 py-2.5 text-right text-slate-200 font-medium",children:g(s.cost)}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:358:23",className:"px-4 py-2.5 text-slate-500 max-w-xs truncate",children:s.description||"-"}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:359:23",className:"px-4 py-2.5",children:e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:360:25",className:"flex items-center justify-center gap-1",children:[e.jsx(m,{"code-path":"src/components/cloud/CloudBilling.tsx:361:27",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>xe(s),children:e.jsx(J,{"code-path":"src/components/cloud/CloudBilling.tsx:362:29",className:"h-3.5 w-3.5"})}),e.jsx(m,{"code-path":"src/components/cloud/CloudBilling.tsx:364:27",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-400 hover:text-red-300",onClick:()=>je(s.id),children:e.jsx(K,{"code-path":"src/components/cloud/CloudBilling.tsx:365:29",className:"h-3.5 w-3.5"})})]})})]},s.id))})]})})]}),n==="alerts"&&e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:379:9",className:"space-y-3",children:ie?e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:381:13",className:"flex items-center justify-center py-20 text-slate-500",children:[e.jsx(_,{"code-path":"src/components/cloud/CloudBilling.tsx:381:84",className:"h-6 w-6 animate-spin mr-2"}),"加载中..."]}):P.length===0?e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:383:13",className:"py-20 text-center text-slate-500",children:[e.jsx(O,{"code-path":"src/components/cloud/CloudBilling.tsx:384:15",className:"h-12 w-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{"code-path":"src/components/cloud/CloudBilling.tsx:385:15",className:"text-sm",children:"暂无预警规则"})]}):e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:388:13",className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:P.map(s=>e.jsx(H,{"code-path":"src/components/cloud/CloudBilling.tsx:390:17",className:"bg-slate-900/50 border-slate-800",children:e.jsxs(T,{"code-path":"src/components/cloud/CloudBilling.tsx:391:19",className:"pt-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:392:21",className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:393:23",className:"flex items-center gap-2",children:[e.jsx(O,{"code-path":"src/components/cloud/CloudBilling.tsx:394:25",className:`h-4 w-4 ${s.enabled?"text-amber-400":"text-slate-600"}`}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:395:25",className:"text-sm font-medium text-slate-200",children:s.name})]}),e.jsx(oe,{"code-path":"src/components/cloud/CloudBilling.tsx:397:23",checked:s.enabled,onCheckedChange:()=>Ce(s.id)})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:399:21",className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:400:23",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:401:25",className:"text-slate-500",children:"厂商"}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:402:25",className:"ml-2 text-slate-300",children:s.provider?v[s.provider]||s.provider:"全部"})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:404:23",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:405:25",className:"text-slate-500",children:"指标"}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:406:25",className:"ml-2 text-slate-300",children:s.metric==="daily"?"日成本":"月累计"})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:408:23",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:409:25",className:"text-slate-500",children:"阈值"}),e.jsxs("span",{"code-path":"src/components/cloud/CloudBilling.tsx:410:25",className:"ml-2 text-amber-300 font-medium",children:[s.operator," ",g(s.threshold)]})]}),s.last_triggered&&e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:413:25",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:414:27",className:"text-slate-500",children:"最后触发"}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:415:27",className:"ml-2 text-slate-400",children:new Date(s.last_triggered).toLocaleString("zh-CN")})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:419:21",className:"flex justify-end gap-1 mt-3",children:[e.jsx(m,{"code-path":"src/components/cloud/CloudBilling.tsx:420:23",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>ge(s),children:e.jsx(J,{"code-path":"src/components/cloud/CloudBilling.tsx:421:25",className:"h-3.5 w-3.5"})}),e.jsx(m,{"code-path":"src/components/cloud/CloudBilling.tsx:423:23",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-400 hover:text-red-300",onClick:()=>Be(s.id),children:e.jsx(K,{"code-path":"src/components/cloud/CloudBilling.tsx:424:25",className:"h-3.5 w-3.5"})})]})]})},s.id))})}),e.jsx(ye,{"code-path":"src/components/cloud/CloudBilling.tsx:435:7",open:de,onOpenChange:L,editingRecord:re,onSuccess:()=>{b(),N()}}),e.jsx(Re,{"code-path":"src/components/cloud/CloudBilling.tsx:441:7",open:pe,onOpenChange:$,editingRule:ue,onSuccess:()=>{D(),N()}})]})}export{Oe as CloudBilling}; diff --git a/backend/static/assets/ClusterOverviewPage-BoH2T6EJ.js b/backend/static/assets/ClusterOverviewPage-BoH2T6EJ.js deleted file mode 100644 index fae9e7c..0000000 --- a/backend/static/assets/ClusterOverviewPage-BoH2T6EJ.js +++ /dev/null @@ -1 +0,0 @@ -import{r as c,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{C as i,a as u}from"./card-BIfzBCEy.js";import{g as F,i as K,L as w,B as G}from"./index-Dungj95X.js";import{B as A}from"./badge-CGJlVD3L.js";import{T as H,a as z,b as x,c as n,d as D,e as a}from"./table-B2F10oba.js";import{k as C}from"./index-drGq01ok.js";import{u as q}from"./use-toast-DNZLibQY.js";import{f as k,L as R,R as J,g as j,B as M,h as T,i as Q,A as V,j as W,k as X}from"./vendor-icons-DmqcWdzX.js";const Y={"kube-system":T,"kube-public":W,"kube-node-lease":V,default:Q};function oe(){const{clusterCode:r}=F(),B=K(),{toast:E}=q(),[,P]=c.useState([]),[m,O]=c.useState([]),[N,f]=c.useState([]),[d,I]=c.useState(null),[p,y]=c.useState(!1),_=c.useCallback(async()=>{try{const t=(await C.getClusters())?.list||[];P(t);const o=t.find(l=>(l.code||String(l.id))===r);I(o||null),!o&&t.length>0&&r&&E({title:"集群未找到",description:`找不到集群 ${r}`,variant:"destructive"})}catch{P([])}},[r]),v=c.useCallback(async()=>{if(r){y(!0);try{const[s,t]=await Promise.all([C.getNodes(r).catch(()=>[]),C.getNamespaces(r).catch(()=>[])]);O(Array.isArray(s)?s:s?.list||s?.data||[]);const o=Array.isArray(t)?t:t?.list||t?.data||[];f(o)}catch{O([]),f([])}finally{y(!1)}}},[r]);c.useEffect(()=>{_()},[_]),c.useEffect(()=>{v()},[v]);const L=s=>s?.role==="master"||s?.role==="control-plane"?"bg-blue-500/20 text-blue-400 border-blue-500/30":"bg-slate-500/20 text-slate-400 border-slate-500/30";return e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:82:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:84:7",className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx(w,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:85:9",to:"/kubernetes",className:"hover:text-slate-300 transition-colors",children:"集群"}),e.jsx(k,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:86:9",className:"h-3 w-3"}),e.jsx("span",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:87:9",className:"text-slate-300",children:r})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:91:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:92:9",children:[e.jsx("h1",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:93:11",className:"text-2xl font-bold text-slate-100",children:r}),e.jsxs("p",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:94:11",className:"text-sm text-slate-500 mt-1",children:["集群概览",d?.version?` — Kubernetes ${d.version}`:""]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:99:9",className:"flex items-center gap-2",children:e.jsx(G,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:100:11",variant:"outline",size:"icon",className:"h-9 w-9 border-slate-700 text-slate-400",onClick:v,disabled:p,children:p?e.jsx(R,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:102:24",className:"h-4 w-4 animate-spin"}):e.jsx(J,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:102:71",className:"h-4 w-4"})})})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:108:7",className:"grid grid-cols-3 md:grid-cols-3 gap-4",children:[e.jsx(i,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:109:9",className:"bg-slate-900 border-slate-800",children:e.jsx(u,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:110:11",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:111:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:112:15",children:[e.jsx("p",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:112:20",className:"text-sm text-slate-500",children:"节点"}),e.jsx("p",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:112:64",className:"text-2xl font-bold text-blue-400",children:m.length})]}),e.jsx(j,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:113:15",className:"h-8 w-8 opacity-30 text-blue-400"})]})})}),e.jsx(i,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:117:9",className:"bg-slate-900 border-slate-800",children:e.jsx(u,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:118:11",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:119:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:120:15",children:[e.jsx("p",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:120:20",className:"text-sm text-slate-500",children:"命名空间"}),e.jsx("p",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:120:66",className:"text-2xl font-bold text-emerald-400",children:N.length})]}),e.jsx(M,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:121:15",className:"h-8 w-8 opacity-30 text-emerald-400"})]})})}),e.jsx(i,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:125:9",className:"bg-slate-900 border-slate-800",children:e.jsx(u,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:126:11",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:127:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:128:15",children:[e.jsx("p",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:128:20",className:"text-sm text-slate-500",children:"版本"}),e.jsx("p",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:128:64",className:"text-lg font-bold text-slate-300",children:d?.version||"-"})]}),e.jsx(T,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:129:15",className:"h-8 w-8 opacity-30 text-slate-400"})]})})})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:136:7",children:[e.jsxs("h2",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:137:9",className:"text-lg font-semibold text-slate-100 mb-3 flex items-center gap-2",children:[e.jsx(j,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:138:11",className:"h-4 w-4 text-blue-400"}),"节点列表"]}),e.jsx(i,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:140:9",className:"bg-slate-900 border-slate-800",children:e.jsx(u,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:141:11",className:"p-0",children:e.jsxs(H,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:142:13",children:[e.jsx(z,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:143:15",children:e.jsxs(x,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:144:17",className:"border-slate-800 hover:bg-transparent",children:[e.jsx(n,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:145:19",className:"text-slate-400",children:"名称"}),e.jsx(n,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:146:19",className:"text-slate-400",children:"角色"}),e.jsx(n,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:147:19",className:"text-slate-400",children:"状态"}),e.jsx(n,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:148:19",className:"text-slate-400",children:"IP"}),e.jsx(n,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:149:19",className:"text-slate-400",children:"OS"}),e.jsx(n,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:150:19",className:"text-slate-400",children:"Kubelet"}),e.jsx(n,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:151:19",className:"text-slate-400",children:"CPU"}),e.jsx(n,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:152:19",className:"text-slate-400",children:"内存"})]})}),e.jsx(D,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:155:15",children:p?e.jsx(x,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:157:19",children:e.jsxs(a,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:157:29",colSpan:8,className:"text-center text-slate-500 py-12",children:[e.jsx(R,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:157:97",className:"h-5 w-5 animate-spin mx-auto mb-2"}),"加载中..."]})}):m.length===0?e.jsx(x,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:159:19",children:e.jsxs(a,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:159:29",colSpan:8,className:"text-center text-slate-500 py-12",children:[e.jsx(j,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:159:97",className:"h-8 w-8 mx-auto mb-2 opacity-50"}),"暂无节点"]})}):m.map(s=>{const t=s.cpu||0,o=s.cpu_usage_m?parseFloat(s.cpu_usage_m.replace("m","")):0,l=t>0?o/1e3/t*100:0,h=s.memory_mb||0,b=s.mem_usage_mi?parseFloat(s.mem_usage_mi.replace("Mi","").replace("Ki","").replace("Gi","")):0,U=s.mem_usage_mi?.includes("Ki")?b/1024:s.mem_usage_mi?.includes("Gi")?b*1024:b,g=h>0?U/h*100:0,S=$=>$>80?"bg-red-500":$>60?"bg-yellow-500":"bg-emerald-500";return e.jsxs(x,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:172:21",className:"border-slate-800 hover:bg-slate-800/30 cursor-pointer",onClick:()=>B(`/kubernetes/${r}/nodes/${s.name}`),children:[e.jsx(a,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:174:23",className:"font-medium text-blue-400 hover:text-blue-300",children:s.name}),e.jsx(a,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:175:23",children:e.jsx(A,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:175:34",className:L(s),children:s.role||"worker"})}),e.jsx(a,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:176:23",children:e.jsx(A,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:176:34",className:s.status==="Ready"?"bg-emerald-500/20 text-emerald-400":"bg-red-500/20 text-red-400",children:s.status||"Unknown"})}),e.jsx(a,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:177:23",className:"text-sm text-slate-400",children:s.ip||"-"}),e.jsx(a,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:178:23",className:"text-sm text-slate-400 max-w-[200px] truncate",children:s.os||"-"}),e.jsx(a,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:179:23",className:"text-sm text-slate-400",children:s.kubelet_version||"-"}),e.jsx(a,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:180:23",className:"text-xs",children:s.cpu_usage_m?e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:182:27",className:"flex items-center gap-1.5 min-w-[80px]",children:[e.jsx("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:183:29",className:"flex-1 h-1.5 rounded-full bg-slate-700/50 overflow-hidden",children:e.jsx("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:184:31",className:`h-full rounded-full ${S(l)}`,style:{width:`${Math.min(l,100)}%`}})}),e.jsxs("span",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:186:29",className:"text-slate-400",children:[l.toFixed(0),"%"]})]}):e.jsxs("span",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:189:27",className:"text-slate-500",children:[t," 核"]})}),e.jsx(a,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:192:23",className:"text-xs",children:s.mem_usage_mi?e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:194:27",className:"flex items-center gap-1.5 min-w-[80px]",children:[e.jsx("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:195:29",className:"flex-1 h-1.5 rounded-full bg-slate-700/50 overflow-hidden",children:e.jsx("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:196:31",className:`h-full rounded-full ${S(g)}`,style:{width:`${Math.min(g,100)}%`}})}),e.jsxs("span",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:198:29",className:"text-slate-400",children:[g.toFixed(0),"%"]})]}):e.jsxs("span",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:201:27",className:"text-slate-500",children:[h,"Mi"]})})]},s.name)})})]})})})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:215:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:216:9",className:"flex items-center justify-between mb-3",children:[e.jsxs("h2",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:217:11",className:"text-lg font-semibold text-slate-100 flex items-center gap-2",children:[e.jsx(M,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:218:13",className:"h-4 w-4 text-emerald-400"}),"命名空间"]}),e.jsxs(w,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:220:11",to:`/kubernetes/${r}/namespaces`,className:"text-sm text-blue-400 hover:text-blue-300 transition-colors flex items-center gap-1",children:["管理全部 ",e.jsx(k,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:221:18",className:"h-3 w-3"})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:224:9",className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:N.map(s=>{const t=Y[s]||X;return e.jsx(w,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:228:15",to:`/kubernetes/${r}/namespace/${s}`,className:"bg-slate-900 border border-slate-800 rounded-lg p-4 hover:border-slate-600 hover:bg-slate-800/50 transition-all group",children:e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:232:17",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:233:19",className:"flex items-center gap-2",children:[e.jsx(t,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:234:21",className:"h-5 w-5 text-slate-500 group-hover:text-slate-300 transition-colors"}),e.jsx("span",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:235:21",className:"text-sm font-medium text-slate-300 group-hover:text-slate-100 transition-colors",children:s})]}),e.jsx(k,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:237:19",className:"h-4 w-4 text-slate-600 group-hover:text-slate-400 transition-colors"})]})},s)})})]})]})}export{oe as default}; diff --git a/backend/static/assets/CredentialManager-B4HbhIHz.js b/backend/static/assets/CredentialManager-B4HbhIHz.js deleted file mode 100644 index b6f156f..0000000 --- a/backend/static/assets/CredentialManager-B4HbhIHz.js +++ /dev/null @@ -1 +0,0 @@ -import{r as t,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{J as na,D as ze,a as Be,b as Ge,c as Ue,e as Qe,B as N,t as S,d as ca,f as da}from"./index-Dungj95X.js";import{I as p}from"./input-CXoUQQLm.js";import{B as w}from"./badge-CGJlVD3L.js";import{S as Me,a as Ke,b as Ae,c as Pe,d as M}from"./select-CiTqGGhE.js";import{u as $e,q as Ye,b as la}from"./unwrap-DPwG25JA.js";import{u as V}from"./useMutation-BkCR1EeO.js";import{c as P}from"./credential-Cu8tj7EE.js";import{F as ia,G as pa,D as ma,i as xa,j as Ze,k as ga,h as ha,ag as z,C as Je,a as We,l as ya,az as Re,aO as va,ak as Xe,x as ea,R as Ca,P as Ve,S as ua,a4 as Da,b as ba,d as ja,T as Na}from"./vendor-icons-DmqcWdzX.js";import{L as i}from"./label-CMpUoC87.js";import"./index-5FEebgvX.js";function fa(c={page_size:100}){return $e({queryKey:Ye.credentials(c),queryFn:async()=>{const d=await P.list(c);return la(d)},staleTime:3e4})}function Fa(c,d=!0){return $e({queryKey:Ye.credentialDetail(c),queryFn:()=>P.get(c),enabled:!!c&&d,staleTime:1e4})}function Sa(){const c=na(),d=()=>c.invalidateQueries({queryKey:["credentials"]}),u=V({mutationFn:h=>P.create(h),onSuccess:d}),x=V({mutationFn:({id:h,data:D})=>P.update(h,D),onSuccess:d}),g=V({mutationFn:h=>P.delete(h),onSuccess:d}),v=V({mutationFn:({id:h,isActive:D})=>P.toggleActive(h,D),onSuccess:d});return{createMutation:u,updateMutation:x,deleteMutation:g,toggleActiveMutation:v,invalidate:d}}const H={ssh:{label:"SSH 密钥",icon:ha,color:"text-amber-400",desc:"SSH 私钥/公钥/密码"},docker:{label:"Docker 凭证",icon:ga,color:"text-cyan-400",desc:"Docker Registry 登录凭据"},tls:{label:"TLS 证书",icon:Ze,color:"text-green-400",desc:"TLS/SSL 证书与私钥"},aksk:{label:"AKSK 密钥",icon:xa,color:"text-purple-400",desc:"云服务 AccessKey/SecretKey"},database:{label:"数据库凭证",icon:ma,color:"text-blue-400",desc:"数据库连接信息"},api:{label:"API 密钥",icon:pa,color:"text-orange-400",desc:"API Token/Key + 端点"},generic:{label:"通用凭证",icon:ia,color:"text-gray-400",desc:"自定义 Key/Value 键值对"}},aa={ssh:"bg-amber-500/20 text-amber-400 border-amber-500/30",docker:"bg-cyan-500/20 text-cyan-400 border-cyan-500/30",tls:"bg-green-500/20 text-green-400 border-green-500/30",aksk:"bg-purple-500/20 text-purple-400 border-purple-500/30",database:"bg-blue-500/20 text-blue-400 border-blue-500/30",api:"bg-orange-500/20 text-orange-400 border-orange-500/30",generic:"bg-gray-500/20 text-gray-400 border-gray-500/30"};function wa({open:c,onClose:d,credId:u}){const[x,g]=t.useState({}),{data:v,isLoading:h}=Fa(u,c);if(!c||!u)return null;const D=m=>g(y=>({...y,[m]:!y[m]})),k=m=>{navigator.clipboard.writeText(m),S.success("已复制")},s=v?.secret_type,f=H[s],o=v?.content||{},n=({label:m,value:y,sensitive:_,fieldKey:K})=>{if(y==null||y==="")return null;const I=typeof y=="string"&&y.length>80,T=K?x[K]:!1;return e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:40:7",className:"mb-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:41:9",className:"flex items-center gap-2 text-xs text-[var(--dg-text-muted)] mb-1",children:[e.jsx(va,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:42:11",className:"h-3 w-3"}),m]}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:44:9",className:"flex gap-1",children:[I?e.jsx("textarea",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:46:13",readOnly:!0,value:_&&!T?"••••••••":String(y),className:"flex-1 rounded-md bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] text-[var(--dg-text-primary)] p-2 text-xs font-mono resize-none",rows:4}):e.jsx(p,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:50:13",readOnly:!0,value:_&&!T?"••••••••":String(y),className:"flex-1 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] font-mono text-xs"}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:53:11",className:"flex flex-col gap-0.5 shrink-0",children:[_&&e.jsx(N,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:55:15",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>D(K),children:T?e.jsx(Xe,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:56:25",className:"h-3 w-3"}):e.jsx(ea,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:56:58",className:"h-3 w-3"})}),e.jsx(N,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:59:13",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>k(String(y)),children:e.jsx(Re,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:60:15",className:"h-3 w-3"})})]})]})]})},l=v;return e.jsx(ze,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:71:5",open:c,onOpenChange:d,children:e.jsxs(Be,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:72:7",className:"sm:max-w-[680px] max-h-[85vh] overflow-y-auto bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:[e.jsx(Ge,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:73:9",children:e.jsxs(Ue,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:74:11",className:"text-[var(--dg-text-primary)] flex items-center gap-2",children:[f?e.jsx(f.icon,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:75:20",className:`h-5 w-5 ${f.color}`}):e.jsx(z,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:75:70",className:"h-5 w-5 text-[var(--dg-text-muted)]"}),"凭据详情"]})}),h?e.jsx("div",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:80:11",className:"text-center py-8 text-[var(--dg-text-muted)]",children:"加载中..."}):v?e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:82:11",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:84:13",className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:85:15",children:[e.jsx("span",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:85:20",className:"text-[var(--dg-text-muted)]",children:"名称:"}),e.jsx("span",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:85:76",className:"text-[var(--dg-text-primary)] font-medium",children:l?.name})]}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:86:15",children:[e.jsx("span",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:86:20",className:"text-[var(--dg-text-muted)]",children:"类型:"}),e.jsx(w,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:87:17",variant:"outline",className:`text-xs ml-1 ${aa[s]||""}`,children:f?.label||s})]}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:89:15",children:[e.jsx("span",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:89:20",className:"text-[var(--dg-text-muted)]",children:"状态:"}),l?.is_active?e.jsxs(w,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:91:21",className:"bg-green-500/20 text-green-400 text-xs ml-1",children:[e.jsx(Je,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:91:84",className:"h-3 w-3 mr-0.5"}),"启用"]}):e.jsxs(w,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:92:21",className:"bg-red-500/20 text-red-400 text-xs ml-1",children:[e.jsx(We,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:92:80",className:"h-3 w-3 mr-0.5"}),"禁用"]}),l?.expires_at&&new Date(l.expires_at)k(l?.env_prefix||""),children:[e.jsx("span",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:98:17",className:"text-[var(--dg-text-muted)]",children:"引用ID:"}),e.jsx("code",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:99:17",className:"text-[var(--dg-blue)] font-mono text-xs",children:l?.env_prefix||"无"}),e.jsx(Re,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:100:17",className:"h-3 w-3 inline ml-1 text-[var(--dg-text-muted)]"})]}),l?.tags?.length>0&&e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:103:17",className:"col-span-2",children:[e.jsx("span",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:104:19",className:"text-[var(--dg-text-muted)]",children:"标签:"}),(l?.tags).map(m=>e.jsx(w,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:106:21",variant:"outline",className:"text-xs ml-1 border-[var(--dg-border)]",children:m},m))]}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:110:15",className:"col-span-2",children:[e.jsx("span",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:110:43",className:"text-[var(--dg-text-muted)]",children:"描述:"}),e.jsx("span",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:110:99",className:"text-[var(--dg-text-secondary)]",children:l?.description||"无"})]}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:111:15",children:[e.jsx("span",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:111:20",className:"text-[var(--dg-text-muted)]",children:"创建:"}),e.jsx("span",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:111:76",className:"text-[var(--dg-text-secondary)] text-xs",children:new Date(l?.created_at).toLocaleString()})]}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:112:15",children:[e.jsx("span",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:112:20",className:"text-[var(--dg-text-muted)]",children:"更新:"}),e.jsx("span",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:112:76",className:"text-[var(--dg-text-secondary)] text-xs",children:new Date(l?.updated_at).toLocaleString()})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:116:13",className:"border-t border-[var(--dg-border)] pt-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:117:15",className:"flex items-center gap-2 text-sm text-[var(--dg-text-primary)] font-medium mb-3",children:[e.jsx(z,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:118:17",className:"h-4 w-4 text-yellow-500"}),"密钥数据"]}),e.jsx("div",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:120:15",className:"p-3 rounded-md bg-yellow-500/5 border border-yellow-500/20 mb-3",children:e.jsx("p",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:121:17",className:"text-xs text-yellow-400/80",children:"以下内容包含敏感信息,请妥善保管,不要泄露给他人。"})}),s==="ssh"&&e.jsxs(e.Fragment,{children:[e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:125:17",label:"SSH 用户",value:o.ssh_user}),e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:126:17",label:"SSH 端口",value:o.ssh_port}),e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:127:17",label:"SSH 密码",value:o.password,sensitive:!0,fieldKey:"ssh_password"}),e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:128:17",label:"私钥",value:o.private_key,sensitive:!0,fieldKey:"ssh_private_key"}),e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:129:17",label:"公钥",value:o.public_key,fieldKey:"ssh_public_key"})]}),s==="docker"&&e.jsxs(e.Fragment,{children:[e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:132:17",label:"Registry 地址",value:o.server}),e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:133:17",label:"用户名",value:o.username}),e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:134:17",label:"密码",value:o.password,sensitive:!0,fieldKey:"docker_password"})]}),s==="tls"&&e.jsxs(e.Fragment,{children:[e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:137:17",label:"证书",value:o.cert,sensitive:!0,fieldKey:"tls_cert"}),e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:138:17",label:"私钥",value:o.key,sensitive:!0,fieldKey:"tls_key"}),e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:139:17",label:"CA 证书",value:o.ca,sensitive:!0,fieldKey:"tls_ca"})]}),s==="aksk"&&e.jsxs(e.Fragment,{children:[e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:142:17",label:"Access Key ID",value:o.access_key}),e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:143:17",label:"Secret Access Key",value:o.secret_key,sensitive:!0,fieldKey:"aksk_secret_key"})]}),s==="database"&&e.jsxs(e.Fragment,{children:[e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:146:17",label:"数据库类型",value:String(o.db_type||"").toUpperCase()}),e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:147:17",label:"主机",value:o.host}),e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:148:17",label:"端口",value:o.port}),e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:149:17",label:"数据库名",value:o.db_name}),e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:150:17",label:"用户名",value:o.username}),e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:151:17",label:"密码",value:o.password,sensitive:!0,fieldKey:"db_password"})]}),s==="api"&&e.jsxs(e.Fragment,{children:[e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:154:17",label:"API Key",value:o.api_key,sensitive:!0,fieldKey:"api_key"}),e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:155:17",label:"API 端点",value:o.endpoint})]}),s==="generic"&&e.jsxs(e.Fragment,{children:[e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:158:17",label:"Key",value:o.generic_key}),e.jsx(n,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:159:17",label:"Value",value:o.generic_value,sensitive:!0,fieldKey:"generic_value"})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:164:13",className:"border-t border-[var(--dg-border)] pt-3",children:[e.jsx("div",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:165:15",className:"text-xs text-[var(--dg-text-muted)] mb-2",children:"在流水线/脚本中引用此凭据:"}),e.jsxs("code",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:166:15",className:"text-xs bg-[var(--dg-bg-tertiary)] px-3 py-1.5 rounded block text-[var(--dg-blue)]",children:["${",String(l?.variable_name||String(l?.name||"").toUpperCase().replace(/[^A-Z0-9]/g,"_")),"}"]})]})]}):e.jsx("div",{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:172:11",className:"text-center py-8 text-[var(--dg-text-muted)]",children:"未找到凭据数据"}),e.jsx(Qe,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:174:9",children:e.jsx(N,{"code-path":"src/components/deploy/credential-manager/CredDetailDialog.tsx:175:11",variant:"outline",onClick:d,children:"关闭"})})]})})}function ka({open:c,onClose:d,onSaved:u,editData:x}){const g=!!x,[v,h]=t.useState(""),[D,k]=t.useState(""),[s,f]=t.useState("ssh"),[o,n]=t.useState(""),[l,m]=t.useState(""),[y,_]=t.useState(!0),[K,I]=t.useState(!1),[T,O]=t.useState({}),[E,L]=t.useState("root"),[r,b]=t.useState("22"),[A,q]=t.useState(""),[F,B]=t.useState(""),[G,U]=t.useState(""),[Q,$]=t.useState(""),[Y,Z]=t.useState(""),[J,W]=t.useState(""),[X,ee]=t.useState(""),[ae,te]=t.useState(""),[re,se]=t.useState(""),[,Te]=t.useState(""),[oe,ne]=t.useState(""),[ce,de]=t.useState(""),[,Ie]=t.useState(""),[le,ie]=t.useState("mysql"),[pe,me]=t.useState(""),[xe,ge]=t.useState("3306"),[he,ye]=t.useState(""),[ve,Ce]=t.useState(""),[ue,De]=t.useState(""),[be,je]=t.useState(""),[Ne,fe]=t.useState(""),[Fe,Se]=t.useState(""),[we,ke]=t.useState("");t.useEffect(()=>{c&&(x?(h(x.name),k(x.variable_name||""),f(x.secret_type),n(x.description||""),m((x.tags||[]).join(", ")),_(x.is_active),L(""),b("22"),q(""),B(""),U(""),$(""),Z(""),W(""),ee(""),te(""),se(""),Te(""),ne(""),de(""),Ie(""),ie("mysql"),me(""),ge("3306"),ye(""),Ce(""),De(""),je(""),fe(""),Se(""),ke("")):(h(""),k(""),f("ssh"),n(""),m(""),_(!0),L("root"),b("22"),q(""),B(""),U(""),$(""),Z(""),W(""),ee(""),te(""),se(""),Te(""),ne(""),de(""),Ie(""),ie("mysql"),me(""),ge("3306"),ye(""),Ce(""),De(""),je(""),fe(""),Se(""),ke("")),O({}))},[x,c]);const ta=a=>O(C=>({...C,[a]:!C[a]})),ra=async()=>{if(!v.trim()){S.error("请填写凭据名称");return}I(!0);try{const a={name:v.trim(),secret_type:s,description:o.trim(),tags:l.split(",").map(C=>C.trim()).filter(Boolean),is_active:y};D.trim()&&(a.variable_name=D.trim()),s==="ssh"?(E.trim()&&(a.ssh_user=E.trim()),r&&(a.ssh_port=parseInt(r)||22),A.trim()&&(a.ssh_password=A.trim()),F.trim()&&(a.ssh_private_key=F.trim()),G.trim()&&(a.ssh_public_key=G.trim())):s==="docker"?(Q.trim()&&(a.docker_server=Q.trim()),Y.trim()&&(a.docker_username=Y.trim()),J.trim()&&(a.docker_password=J.trim())):s==="tls"?(X.trim()&&(a.tls_cert=X.trim()),ae.trim()&&(a.tls_key=ae.trim()),re.trim()&&(a.tls_ca=re.trim())):s==="aksk"?(oe.trim()&&(a.aksk_access_key=oe.trim()),ce.trim()&&(a.aksk_secret_key=ce.trim())):s==="database"?(le.trim()&&(a.db_type=le.trim()),pe.trim()&&(a.db_host=pe.trim()),xe&&(a.db_port=parseInt(xe)||3306),he.trim()&&(a.db_name=he.trim()),ve.trim()&&(a.db_username=ve.trim()),ue.trim()&&(a.db_password=ue.trim())):s==="api"?(be.trim()&&(a.api_key=be.trim()),Ne.trim()&&(a.api_endpoint=Ne.trim())):s==="generic"&&(Fe.trim()&&(a.generic_key=Fe.trim()),we.trim()&&(a.generic_value=we.trim())),g?(await P.update(x.id,a),S.success("已更新")):(await P.create(a),S.success("已创建")),u(),d()}catch(a){const C=a;S.error(C?.response?.data?.message||"操作失败")}finally{I(!1)}},j=({label:a,value:C,onChange:Le,placeholder:qe,fieldKey:He,required:sa,isLong:oa})=>{const Oe=T[He];return e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:163:7",className:"space-y-1",children:[e.jsxs(i,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:164:9",className:"text-[var(--dg-text-secondary)] text-xs",children:[a,sa&&!g&&e.jsx("span",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:164:99",className:"text-red-400",children:" *"})]}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:165:9",className:"relative",children:[oa?e.jsx("textarea",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:167:13",value:C,onChange:_e=>Le(_e.target.value),placeholder:qe,rows:5,className:"w-full rounded-md bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] text-[var(--dg-text-primary)] p-2 text-sm font-mono placeholder:text-[var(--dg-text-muted)]"}):e.jsx(p,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:171:13",value:C,onChange:_e=>Le(_e.target.value),type:Oe?"text":"password",placeholder:qe,className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] pr-10 font-mono text-sm"}),e.jsx("button",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:175:11",type:"button",onClick:()=>ta(He),className:"absolute right-2 top-1/2 -translate-y-1/2 text-[var(--dg-text-muted)] hover:text-[var(--dg-text-primary)] text-xs",children:Oe?e.jsx(Xe,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:177:21",className:"h-3.5 w-3.5"}):e.jsx(ea,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:177:58",className:"h-3.5 w-3.5"})})]})]})},R=H[s],Ee=R?.icon||z;return e.jsx(ze,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:188:5",open:c,onOpenChange:d,children:e.jsxs(Be,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:189:7",className:"sm:max-w-[620px] max-h-[90vh] overflow-y-auto bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:[e.jsxs(Ge,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:190:9",children:[e.jsxs(Ue,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:191:11",className:"text-[var(--dg-text-primary)] flex items-center gap-2",children:[e.jsx(Ee,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:192:13",className:`h-5 w-5 ${R?.color||""}`}),g?"编辑凭据":"新增凭据"]}),e.jsx(ca,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:195:11",className:"text-[var(--dg-text-muted)] text-xs",children:R?.desc||"管理敏感凭据信息"})]}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:199:9",className:"space-y-4 py-2",children:[e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:201:11",className:"border-b border-[var(--dg-border)] pb-3",children:[e.jsx("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:202:13",className:"text-xs font-medium text-[var(--dg-text-secondary)] mb-2",children:"基本信息"}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:203:13",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:204:15",className:"space-y-1",children:[e.jsxs(i,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:205:17",className:"text-[var(--dg-text-secondary)] text-xs",children:["凭据名称 ",e.jsx("span",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:205:81",className:"text-red-400",children:"*"})]}),e.jsx(p,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:206:17",value:v,onChange:a=>h(a.target.value),placeholder:"如:生产环境 SSH",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:209:15",className:"space-y-1",children:[e.jsx(i,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:210:17",className:"text-[var(--dg-text-secondary)] text-xs",children:"变量别名"}),e.jsx(p,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:211:17",value:D,onChange:a=>k(a.target.value),placeholder:"如:MYSQL_PROD",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] font-mono text-sm"})]}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:214:15",className:"space-y-1",children:[e.jsxs(i,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:215:17",className:"text-[var(--dg-text-secondary)] text-xs",children:["类型",!g&&e.jsx("span",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:215:90",className:"text-red-400",children:" *"})]}),e.jsxs(Me,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:216:17",value:s,onValueChange:a=>f(a),disabled:g,children:[e.jsx(Ke,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:217:19",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",children:e.jsx(Ae,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:218:21"})}),e.jsx(Pe,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:220:19",className:"max-h-[300px]",children:Object.entries(H).map(([a,C])=>e.jsx(M,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:222:23",value:a,children:e.jsxs("span",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:223:25",className:"flex items-center gap-2",children:[e.jsx(C.icon,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:223:67",className:"h-4 w-4"}),C.label]})},a))})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:229:15",className:"space-y-1",children:[e.jsx(i,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:230:17",className:"text-[var(--dg-text-secondary)] text-xs",children:"标签"}),e.jsx(p,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:231:17",value:l,onChange:a=>m(a.target.value),placeholder:"生产环境, 阿里云",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:235:13",className:"mt-2 space-y-1",children:[e.jsx(i,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:236:15",className:"text-[var(--dg-text-secondary)] text-xs",children:"描述"}),e.jsx(p,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:237:15",value:o,onChange:a=>n(a.target.value),placeholder:"可选备注信息",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:243:11",children:[e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:244:13",className:"text-xs font-medium text-[var(--dg-text-secondary)] mb-2 flex items-center gap-2",children:[e.jsx(Ee,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:245:15",className:"h-3.5 w-3.5"}),R?.label||s," 配置",g&&e.jsx("span",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:246:26",className:"text-[var(--dg-text-muted)]",children:"(仅填写需要修改的字段)"})]}),s==="ssh"&&e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:250:15",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:251:17",className:"space-y-1",children:[e.jsx(i,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:252:19",className:"text-[var(--dg-text-secondary)] text-xs",children:"SSH 用户"}),e.jsx(p,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:253:19",value:E,onChange:a=>L(a.target.value),placeholder:"root",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:256:17",className:"space-y-1",children:[e.jsx(i,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:257:19",className:"text-[var(--dg-text-secondary)] text-xs",children:"SSH 端口"}),e.jsx(p,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:258:19",value:r,onChange:a=>b(a.target.value),placeholder:"22",type:"number",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),e.jsx("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:261:17",className:"col-span-2",children:e.jsx(j,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:262:19",label:"SSH 密码",value:A,onChange:q,placeholder:"密码(或留空用密钥)",fieldKey:"ssh_pwd"})}),e.jsx("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:265:17",className:"col-span-2",children:e.jsx(j,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:266:19",label:"私钥内容",value:F,onChange:B,placeholder:"粘贴 SSH 私钥...",fieldKey:"ssh_pk",isLong:!0})}),e.jsx("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:269:17",className:"col-span-2",children:e.jsx(j,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:270:19",label:"公钥内容",value:G,onChange:U,placeholder:"粘贴 SSH 公钥...",fieldKey:"ssh_pub",isLong:!0})})]}),s==="docker"&&e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:277:15",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:278:17",className:"col-span-2 space-y-1",children:[e.jsxs(i,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:279:19",className:"text-[var(--dg-text-secondary)] text-xs",children:["Registry 地址 ",e.jsx("span",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:279:90",className:"text-red-400",children:"*"})]}),e.jsx(p,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:280:19",value:Q,onChange:a=>$(a.target.value),placeholder:"registry.example.com",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] font-mono"})]}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:283:17",className:"space-y-1",children:[e.jsx(i,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:284:19",className:"text-[var(--dg-text-secondary)] text-xs",children:"用户名"}),e.jsx(p,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:285:19",value:Y,onChange:a=>Z(a.target.value),placeholder:"admin",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),e.jsx("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:288:17",children:e.jsx(j,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:288:22",label:"密码",value:J,onChange:W,placeholder:"Registry 密码",fieldKey:"docker_pwd",required:!0})})]}),s==="tls"&&e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:294:15",className:"space-y-3",children:[e.jsx(j,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:295:17",label:"证书 (PEM)",value:X,onChange:ee,placeholder:"-----BEGIN CERTIFICATE-----",fieldKey:"tls_cert",isLong:!0,required:!0}),e.jsx(j,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:297:17",label:"私钥 (PEM)",value:ae,onChange:te,placeholder:"-----BEGIN PRIVATE KEY-----",fieldKey:"tls_key",isLong:!0,required:!0}),e.jsx(j,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:299:17",label:"CA 证书",value:re,onChange:se,placeholder:"CA 证书内容...",fieldKey:"tls_ca",isLong:!0})]}),s==="aksk"&&e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:305:15",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:306:17",className:"col-span-2 space-y-1",children:[e.jsxs(i,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:307:19",className:"text-[var(--dg-text-secondary)] text-xs",children:["Access Key ID ",e.jsx("span",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:307:92",className:"text-red-400",children:"*"})]}),e.jsx(p,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:308:19",value:oe,onChange:a=>ne(a.target.value),placeholder:"AKIDxxxx...",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] font-mono"})]}),e.jsx("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:311:17",className:"col-span-2",children:e.jsx(j,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:312:19",label:"Secret Access Key",value:ce,onChange:de,placeholder:"输入 Secret Key",fieldKey:"aksk_sk",required:!0})})]}),s==="database"&&e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:319:15",className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:320:17",className:"space-y-1",children:[e.jsx(i,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:321:19",className:"text-[var(--dg-text-secondary)] text-xs",children:"数据库类型"}),e.jsxs(Me,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:322:19",value:le,onValueChange:ie,children:[e.jsx(Ke,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:323:21",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",children:e.jsx(Ae,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:324:23"})}),e.jsxs(Pe,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:326:21",children:[e.jsx(M,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:327:23",value:"mysql",children:"MySQL"}),e.jsx(M,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:328:23",value:"postgres",children:"PostgreSQL"}),e.jsx(M,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:329:23",value:"mongodb",children:"MongoDB"}),e.jsx(M,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:330:23",value:"redis",children:"Redis"}),e.jsx(M,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:331:23",value:"mssql",children:"SQL Server"}),e.jsx(M,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:332:23",value:"oracle",children:"Oracle"})]})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:336:17",className:"space-y-1",children:[e.jsxs(i,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:337:19",className:"text-[var(--dg-text-secondary)] text-xs",children:["主机 ",e.jsx("span",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:337:81",className:"text-red-400",children:"*"})]}),e.jsx(p,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:338:19",value:pe,onChange:a=>me(a.target.value),placeholder:"10.0.0.1",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] font-mono"})]}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:341:17",className:"space-y-1",children:[e.jsx(i,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:342:19",className:"text-[var(--dg-text-secondary)] text-xs",children:"端口"}),e.jsx(p,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:343:19",value:xe,onChange:a=>ge(a.target.value),placeholder:"3306",type:"number",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:346:17",className:"space-y-1",children:[e.jsx(i,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:347:19",className:"text-[var(--dg-text-secondary)] text-xs",children:"数据库名"}),e.jsx(p,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:348:19",value:he,onChange:a=>ye(a.target.value),placeholder:"aiops",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:351:17",className:"space-y-1",children:[e.jsx(i,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:352:19",className:"text-[var(--dg-text-secondary)] text-xs",children:"用户名"}),e.jsx(p,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:353:19",value:ve,onChange:a=>Ce(a.target.value),placeholder:"root",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),e.jsx("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:356:17",children:e.jsx(j,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:356:22",label:"密码",value:ue,onChange:De,placeholder:"数据库密码",fieldKey:"db_pwd"})})]}),s==="api"&&e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:362:15",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:363:17",className:"space-y-1",children:[e.jsx(i,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:364:19",className:"text-[var(--dg-text-secondary)] text-xs",children:"API 端点"}),e.jsx(p,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:365:19",value:Ne,onChange:a=>fe(a.target.value),placeholder:"https://api.example.com",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] font-mono"})]}),e.jsx(j,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:368:17",label:"API Key / Token",value:be,onChange:je,placeholder:"sk-xxxx...",fieldKey:"api_key",required:!0})]}),s==="generic"&&e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:374:15",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:375:17",className:"space-y-1",children:[e.jsxs(i,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:376:19",className:"text-[var(--dg-text-secondary)] text-xs",children:["Key ",e.jsx("span",{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:376:82",className:"text-red-400",children:"*"})]}),e.jsx(p,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:377:19",value:Fe,onChange:a=>Se(a.target.value),placeholder:"MY_SECRET",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] font-mono"})]}),e.jsx(j,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:380:17",label:"Value",value:we,onChange:ke,placeholder:"密钥值",fieldKey:"generic_val",required:!0})]})]})]}),e.jsxs(Qe,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:386:9",children:[e.jsx(N,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:387:11",variant:"outline",onClick:d,children:"取消"}),e.jsx(N,{"code-path":"src/components/deploy/credential-manager/CredFormDialog.tsx:388:11",onClick:ra,disabled:K,className:"bg-[var(--dg-blue)] hover:bg-[var(--dg-blue)]/80",children:K?"保存中...":g?"更新":"创建"})]})]})})}function Oa(){const c=da(),[d,u]=t.useState(!1),[x,g]=t.useState(null),[v,h]=t.useState(null),[D,k]=t.useState(!1),[s,f]=t.useState("all"),[o,n]=t.useState(""),l={page_size:100,...o?{search:o}:{},...s&&s!=="all"?{secret_type:s}:{}},{data:m=[],isLoading:y,refetch:_}=fa(l),{deleteMutation:K,toggleActiveMutation:I}=Sa(),T=async r=>{if(await c({title:"删除凭据",description:`确定删除凭据「${r.name}」?此操作不可撤销。`,confirmText:"删除",variant:"destructive"}))try{await K.mutateAsync(r.id),S.success("已删除")}catch{S.error("删除失败")}},O=async r=>{try{await I.mutateAsync({id:r.id,isActive:!r.is_active}),S.success(r.is_active?"已禁用":"已启用")}catch{S.error("操作失败")}},E=r=>{navigator.clipboard.writeText(r),S.success("引用 ID 已复制")},L=Object.entries(H);return e.jsxs("div",{"code-path":"src/components/deploy/CredentialManager.tsx:68:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/CredentialManager.tsx:69:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/deploy/CredentialManager.tsx:70:9",children:[e.jsx("h2",{"code-path":"src/components/deploy/CredentialManager.tsx:71:11",className:"text-lg font-semibold text-[var(--dg-text-primary)]",children:"凭据管理"}),e.jsx("p",{"code-path":"src/components/deploy/CredentialManager.tsx:72:11",className:"text-sm text-[var(--dg-text-muted)] mt-0.5",children:"统一管理 SSH 密钥、Docker 密码、AKSK、数据库等敏感凭据(AES 加密存储)"})]}),e.jsxs("div",{"code-path":"src/components/deploy/CredentialManager.tsx:76:9",className:"flex items-center gap-2",children:[e.jsxs(N,{"code-path":"src/components/deploy/CredentialManager.tsx:77:11",variant:"outline",size:"sm",onClick:()=>_(),children:[e.jsx(Ca,{"code-path":"src/components/deploy/CredentialManager.tsx:78:13",className:"w-4 h-4 mr-1"}),"刷新"]}),e.jsxs(N,{"code-path":"src/components/deploy/CredentialManager.tsx:80:11",size:"sm",onClick:()=>{g(null),u(!0)},children:[e.jsx(Ve,{"code-path":"src/components/deploy/CredentialManager.tsx:81:13",className:"w-4 h-4 mr-1"}),"新增凭据"]})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/CredentialManager.tsx:87:7",className:"flex items-center gap-3 flex-wrap",children:[e.jsxs(Me,{"code-path":"src/components/deploy/CredentialManager.tsx:88:9",value:s,onValueChange:f,children:[e.jsx(Ke,{"code-path":"src/components/deploy/CredentialManager.tsx:89:11",className:"w-[140px] bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] h-9 text-sm",children:e.jsx(Ae,{"code-path":"src/components/deploy/CredentialManager.tsx:90:13",placeholder:"全部类型"})}),e.jsxs(Pe,{"code-path":"src/components/deploy/CredentialManager.tsx:92:11",children:[e.jsx(M,{"code-path":"src/components/deploy/CredentialManager.tsx:93:13",value:"all",children:"全部类型"}),L.map(([r,b])=>e.jsx(M,{"code-path":"src/components/deploy/CredentialManager.tsx:95:15",value:r,children:e.jsxs("span",{"code-path":"src/components/deploy/CredentialManager.tsx:96:17",className:"flex items-center gap-2",children:[e.jsx(b.icon,{"code-path":"src/components/deploy/CredentialManager.tsx:96:59",className:"h-3.5 w-3.5"}),b.label]})},r))]})]}),e.jsxs("div",{"code-path":"src/components/deploy/CredentialManager.tsx:101:9",className:"relative flex-1 max-w-xs",children:[e.jsx(ua,{"code-path":"src/components/deploy/CredentialManager.tsx:102:11",className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-[var(--dg-text-muted)]"}),e.jsx(p,{"code-path":"src/components/deploy/CredentialManager.tsx:103:11",value:o,onChange:r=>n(r.target.value),placeholder:"搜索名称、描述...",className:"pl-8 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] h-9 text-sm"})]}),e.jsxs("span",{"code-path":"src/components/deploy/CredentialManager.tsx:107:9",className:"text-xs text-[var(--dg-text-muted)]",children:[m.length," 个凭据"]})]}),y?e.jsxs("div",{"code-path":"src/components/deploy/CredentialManager.tsx:111:9",className:"text-center py-16 text-[var(--dg-text-secondary)]",children:[e.jsx(Da,{"code-path":"src/components/deploy/CredentialManager.tsx:112:11",className:"w-6 h-6 animate-spin mx-auto mb-2 text-[var(--dg-blue)]"}),"加载中..."]}):m.length===0?e.jsxs("div",{"code-path":"src/components/deploy/CredentialManager.tsx:115:9",className:"text-center py-16 border border-dashed border-[var(--dg-border)] rounded-lg",children:[e.jsx(Ze,{"code-path":"src/components/deploy/CredentialManager.tsx:116:11",className:"w-12 h-12 mx-auto mb-3 text-[var(--dg-text-muted)]"}),e.jsx("p",{"code-path":"src/components/deploy/CredentialManager.tsx:117:11",className:"text-[var(--dg-text-secondary)] mb-2",children:"暂无凭据"}),e.jsx("p",{"code-path":"src/components/deploy/CredentialManager.tsx:118:11",className:"text-xs text-[var(--dg-text-muted)] mb-4",children:"创建 SSH、Docker、AKSK 等类型的凭据,供流水线和服务器使用"}),e.jsxs(N,{"code-path":"src/components/deploy/CredentialManager.tsx:119:11",onClick:()=>{g(null),u(!0)},children:[e.jsx(Ve,{"code-path":"src/components/deploy/CredentialManager.tsx:120:13",className:"w-4 h-4 mr-1"}),"创建第一个凭据"]})]}):e.jsx("div",{"code-path":"src/components/deploy/CredentialManager.tsx:124:9",className:"rounded-md border border-[var(--dg-border)] overflow-hidden",children:e.jsxs("table",{"code-path":"src/components/deploy/CredentialManager.tsx:125:11",className:"w-full text-sm",children:[e.jsx("thead",{"code-path":"src/components/deploy/CredentialManager.tsx:126:13",className:"bg-[var(--dg-bg-tertiary)] border-b border-[var(--dg-border)]",children:e.jsxs("tr",{"code-path":"src/components/deploy/CredentialManager.tsx:127:15",children:[e.jsx("th",{"code-path":"src/components/deploy/CredentialManager.tsx:128:17",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)]",children:"名称"}),e.jsx("th",{"code-path":"src/components/deploy/CredentialManager.tsx:129:17",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)]",children:"类型"}),e.jsx("th",{"code-path":"src/components/deploy/CredentialManager.tsx:130:17",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)] hidden md:table-cell",children:"摘要"}),e.jsx("th",{"code-path":"src/components/deploy/CredentialManager.tsx:131:17",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)] hidden lg:table-cell",children:"标签"}),e.jsx("th",{"code-path":"src/components/deploy/CredentialManager.tsx:132:17",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)] hidden xl:table-cell",children:"引用ID"}),e.jsx("th",{"code-path":"src/components/deploy/CredentialManager.tsx:133:17",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)]",children:"状态"}),e.jsx("th",{"code-path":"src/components/deploy/CredentialManager.tsx:134:17",className:"px-3 py-2.5 text-right font-medium text-[var(--dg-text-secondary)]",children:"操作"})]})}),e.jsx("tbody",{"code-path":"src/components/deploy/CredentialManager.tsx:137:13",children:m.map(r=>{const b=r.secret_type,A=H[b],q=r.expires_at&&new Date(r.expires_at){h(r.id),k(!0)},children:[e.jsx("td",{"code-path":"src/components/deploy/CredentialManager.tsx:146:21",className:"px-3 py-2.5",children:e.jsxs("div",{"code-path":"src/components/deploy/CredentialManager.tsx:147:23",className:"flex items-center gap-2",children:[A?e.jsx(A.icon,{"code-path":"src/components/deploy/CredentialManager.tsx:148:32",className:`h-4 w-4 ${A.color} shrink-0`}):e.jsx(z,{"code-path":"src/components/deploy/CredentialManager.tsx:148:91",className:"h-4 w-4 text-[var(--dg-text-muted)] shrink-0"}),e.jsxs("div",{"code-path":"src/components/deploy/CredentialManager.tsx:149:25",children:[e.jsx("div",{"code-path":"src/components/deploy/CredentialManager.tsx:150:27",className:"font-medium text-[var(--dg-text-primary)]",children:r.name}),r.variable_name&&e.jsx("div",{"code-path":"src/components/deploy/CredentialManager.tsx:152:29",className:"text-xs text-[var(--dg-text-muted)] font-mono",children:r.variable_name})]})]})}),e.jsx("td",{"code-path":"src/components/deploy/CredentialManager.tsx:157:21",className:"px-3 py-2.5",children:e.jsx(w,{"code-path":"src/components/deploy/CredentialManager.tsx:158:23",variant:"outline",className:`text-xs ${aa[b]||""}`,children:A?.label||b})}),e.jsx("td",{"code-path":"src/components/deploy/CredentialManager.tsx:162:21",className:"px-3 py-2.5 text-[var(--dg-text-secondary)] text-xs hidden md:table-cell max-w-[180px] truncate font-mono",children:r.summary||"-"}),e.jsx("td",{"code-path":"src/components/deploy/CredentialManager.tsx:165:21",className:"px-3 py-2.5 hidden lg:table-cell",children:e.jsxs("div",{"code-path":"src/components/deploy/CredentialManager.tsx:166:23",className:"flex gap-1 flex-wrap",children:[(r.tags||[]).slice(0,3).map(F=>e.jsx(w,{"code-path":"src/components/deploy/CredentialManager.tsx:168:27",variant:"outline",className:"text-xs border-[var(--dg-border)] text-[var(--dg-text-muted)]",children:F},F)),(r.tags||[]).length>3&&e.jsxs("span",{"code-path":"src/components/deploy/CredentialManager.tsx:171:27",className:"text-xs text-[var(--dg-text-muted)]",children:["+",r.tags.length-3]})]})}),e.jsx("td",{"code-path":"src/components/deploy/CredentialManager.tsx:175:21",className:"px-3 py-2.5 hidden xl:table-cell",children:e.jsx("code",{"code-path":"src/components/deploy/CredentialManager.tsx:176:23",className:"text-xs text-[var(--dg-blue)] cursor-pointer font-mono",onClick:F=>{F.stopPropagation(),E(r.env_prefix)},children:r.env_prefix})}),e.jsx("td",{"code-path":"src/components/deploy/CredentialManager.tsx:181:21",className:"px-3 py-2.5",children:e.jsxs("div",{"code-path":"src/components/deploy/CredentialManager.tsx:182:23",className:"flex items-center gap-1",children:[r.is_active?e.jsx(w,{"code-path":"src/components/deploy/CredentialManager.tsx:184:27",className:"bg-green-500/20 text-green-400 text-xs border-0",children:"启用"}):e.jsx(w,{"code-path":"src/components/deploy/CredentialManager.tsx:186:27",className:"bg-red-500/20 text-red-400 text-xs border-0",children:"禁用"}),q&&e.jsxs(w,{"code-path":"src/components/deploy/CredentialManager.tsx:189:27",className:"bg-yellow-500/20 text-yellow-400 text-xs border-0",children:[e.jsx(ba,{"code-path":"src/components/deploy/CredentialManager.tsx:189:96",className:"h-2.5 w-2.5 mr-0.5"}),"过期"]})]})}),e.jsx("td",{"code-path":"src/components/deploy/CredentialManager.tsx:193:21",className:"px-3 py-2.5 text-right",onClick:F=>F.stopPropagation(),children:e.jsxs("div",{"code-path":"src/components/deploy/CredentialManager.tsx:194:23",className:"flex justify-end gap-1",children:[e.jsx(N,{"code-path":"src/components/deploy/CredentialManager.tsx:195:25",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{g(r),u(!0)},title:"编辑",children:e.jsx(ja,{"code-path":"src/components/deploy/CredentialManager.tsx:197:27",className:"w-3.5 h-3.5"})}),e.jsx(N,{"code-path":"src/components/deploy/CredentialManager.tsx:199:25",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>O(r),title:r.is_active?"禁用":"启用",children:r.is_active?e.jsx(We,{"code-path":"src/components/deploy/CredentialManager.tsx:202:45",className:"w-3.5 h-3.5 text-yellow-500"}):e.jsx(Je,{"code-path":"src/components/deploy/CredentialManager.tsx:202:99",className:"w-3.5 h-3.5 text-green-500"})}),e.jsx(N,{"code-path":"src/components/deploy/CredentialManager.tsx:204:25",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-500",onClick:()=>T(r),title:"删除",children:e.jsx(Na,{"code-path":"src/components/deploy/CredentialManager.tsx:206:27",className:"w-3.5 h-3.5"})})]})})]},r.id)})})]})}),e.jsx(ka,{"code-path":"src/components/deploy/CredentialManager.tsx:218:7",open:d,onClose:()=>u(!1),onSaved:()=>_(),editData:x}),e.jsx(wa,{"code-path":"src/components/deploy/CredentialManager.tsx:219:7",open:D,onClose:()=>k(!1),credId:v})]})}export{Oa as default}; diff --git a/backend/static/assets/CronJobManager-C85uFdSz.js b/backend/static/assets/CronJobManager-C85uFdSz.js deleted file mode 100644 index 8baf90c..0000000 --- a/backend/static/assets/CronJobManager-C85uFdSz.js +++ /dev/null @@ -1,2 +0,0 @@ -import{j as t,r as n}from"./vendor-codemirror-B1SGo4xl.js";import{C as lt,a as dt}from"./card-BIfzBCEy.js";import{S as mt}from"./stat-strip-BSQFwFzG.js";import{D as X,a as G,b as K,c as U,d as W,e as xt,B as p,t as l,f as pt}from"./index-Dungj95X.js";import{I as P}from"./input-CXoUQQLm.js";import{B as C}from"./badge-CGJlVD3L.js";import{C as I}from"./checkbox-Bu55mX0G.js";import{s as $,c as y,t as ht}from"./automation-C9TdY9Jc.js";import{L as k,a as gt,y as ut,aw as Y,r as Z,R as bt,P as vt,S as yt,T as z,aH as Ct,b as jt,o as Jt,z as B,aI as Nt,aJ as ft}from"./vendor-icons-DmqcWdzX.js";import{S as O,a as R,b as A,c as V,d as J}from"./select-CiTqGGhE.js";import{T as Q}from"./textarea-BxfjmLq5.js";import{L as N}from"./label-CMpUoC87.js";import{T as Dt,a as Ft,b as L,c as w,d as Mt,e as f}from"./table-B2F10oba.js";import"./index-5FEebgvX.js";function tt(i){switch(i){case"success":return t.jsxs(C,{"code-path":"src/components/automation/cronJobHelpers.tsx:9:9",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:[t.jsx(ut,{"code-path":"src/components/automation/cronJobHelpers.tsx:10:11",className:"h-3 w-3 mr-1"}),"成功"]});case"failed":return t.jsxs(C,{"code-path":"src/components/automation/cronJobHelpers.tsx:16:9",variant:"outline",className:"border-red-500/30 text-red-400 bg-red-500/10",children:[t.jsx(gt,{"code-path":"src/components/automation/cronJobHelpers.tsx:17:11",className:"h-3 w-3 mr-1"}),"失败"]});case"running":return t.jsxs(C,{"code-path":"src/components/automation/cronJobHelpers.tsx:23:9",variant:"outline",className:"border-blue-500/30 text-blue-400 bg-blue-500/10 animate-pulse",children:[t.jsx(k,{"code-path":"src/components/automation/cronJobHelpers.tsx:24:11",className:"h-3 w-3 mr-1 animate-spin"}),"执行中"]});default:return t.jsx(C,{"code-path":"src/components/automation/cronJobHelpers.tsx:30:9",variant:"outline",className:"border-[var(--dg-border)] text-[var(--dg-text-muted)]",children:"从未执行"})}}function wt(i){return{"0 2 * * *":"每天 02:00","0 3 * * 0":"每周日 03:00","*/5 * * * *":"每 5 分钟","0 * * * *":"每小时","0 9 * * 1":"每周一 09:00"}[i]||i}const q=[{value:"shell",label:"Shell 脚本",desc:"关联脚本库中的 Shell 脚本"},{value:"python",label:"Python 脚本",desc:"关联脚本库中的 Python 脚本"},{value:"command",label:"自定义命令",desc:"手动输入命令或脚本路径"}];function St({open:i,onOpenChange:g,editJob:s,onSuccess:D}){const[a,d]=n.useState({name:"",description:"",cron_expr:"",type:"shell",content:"",script_id:null}),[h,v]=n.useState([]),[r,m]=n.useState(null),[S,F]=n.useState(!1);n.useEffect(()=>{i&&($.getScripts({page_size:200}).then(e=>{v(e?.list||[])}).catch(()=>v([])),s?(d({name:s.name||"",description:s.description||"",cron_expr:s.cron_expr||"",type:s.type||"shell",content:s.content||"",script_id:s.script_id||null}),s.script_id?$.getScript(s.script_id).then(e=>{m(e)}).catch(()=>m(null)):m(null)):(d({name:"",description:"",cron_expr:"",type:"shell",content:"",script_id:null}),m(null)))},[i,s]);const M=a.type==="shell"||a.type==="python"?h.filter(e=>e.type===a.type):[],E=e=>{const x=h.find(j=>String(j.id)===e);x&&(m(x),d(j=>({...j,script_id:x.id,content:x.content})))},T=e=>{d(x=>({...x,type:e,script_id:null,content:e==="command"?x.content:""})),m(null)},H=async()=>{if(!a.name||!a.cron_expr){l.error("请填写任务名称和 Cron 表达式");return}if((a.type==="shell"||a.type==="python")&&!a.script_id){l.error("请选择关联的脚本");return}try{F(!0);const e={name:a.name,description:a.description,cron_expr:a.cron_expr,type:a.type,content:a.content,script_id:a.script_id};s?(await y.updateJob(s.id,e),l.success("任务更新成功")):(await y.createJob(e),l.success("任务创建成功")),g(!1),D()}catch(e){console.error("Failed to save cron job:",e),l.error(s?"更新失败":"创建失败")}finally{F(!1)}};return t.jsx(X,{"code-path":"src/components/automation/CronJobFormDialog.tsx:150:5",open:i,onOpenChange:g,children:t.jsxs(G,{"code-path":"src/components/automation/CronJobFormDialog.tsx:151:7",className:"max-w-2xl bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",children:[t.jsxs(K,{"code-path":"src/components/automation/CronJobFormDialog.tsx:152:9",children:[t.jsx(U,{"code-path":"src/components/automation/CronJobFormDialog.tsx:153:11",children:s?"编辑定时任务":"新建定时任务"}),t.jsx(W,{"code-path":"src/components/automation/CronJobFormDialog.tsx:154:11",className:"text-[var(--dg-text-secondary)]",children:"配置 Cron 定时任务"})]}),t.jsxs("div",{"code-path":"src/components/automation/CronJobFormDialog.tsx:156:9",className:"space-y-4 py-4 max-h-[60vh] overflow-y-auto pr-1",children:[t.jsxs("div",{"code-path":"src/components/automation/CronJobFormDialog.tsx:158:11",children:[t.jsx(N,{"code-path":"src/components/automation/CronJobFormDialog.tsx:159:13",className:"text-[var(--dg-text-primary)]",children:"任务名称"}),t.jsx(P,{"code-path":"src/components/automation/CronJobFormDialog.tsx:160:13",value:a.name,onChange:e=>d({...a,name:e.target.value}),placeholder:"例如: 数据库备份",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] mt-1"})]}),t.jsxs("div",{"code-path":"src/components/automation/CronJobFormDialog.tsx:169:11",children:[t.jsx(N,{"code-path":"src/components/automation/CronJobFormDialog.tsx:170:13",className:"text-[var(--dg-text-primary)]",children:"描述"}),t.jsx(Q,{"code-path":"src/components/automation/CronJobFormDialog.tsx:171:13",value:a.description,onChange:e=>d({...a,description:e.target.value}),placeholder:"任务描述...",rows:2,className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] mt-1"})]}),t.jsxs("div",{"code-path":"src/components/automation/CronJobFormDialog.tsx:181:11",children:[t.jsx(N,{"code-path":"src/components/automation/CronJobFormDialog.tsx:182:13",className:"text-[var(--dg-text-primary)]",children:"Cron 表达式"}),t.jsxs("div",{"code-path":"src/components/automation/CronJobFormDialog.tsx:183:13",className:"flex gap-2",children:[t.jsx(P,{"code-path":"src/components/automation/CronJobFormDialog.tsx:184:15",value:a.cron_expr,onChange:e=>d({...a,cron_expr:e.target.value}),placeholder:"0 2 * * *",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] mt-1"}),t.jsxs(O,{"code-path":"src/components/automation/CronJobFormDialog.tsx:190:15",onValueChange:e=>d({...a,cron_expr:e}),children:[t.jsx(R,{"code-path":"src/components/automation/CronJobFormDialog.tsx:191:17",className:"w-48 bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] mt-1",children:t.jsx(A,{"code-path":"src/components/automation/CronJobFormDialog.tsx:192:19",placeholder:"快速选择"})}),t.jsxs(V,{"code-path":"src/components/automation/CronJobFormDialog.tsx:194:17",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:[t.jsx(J,{"code-path":"src/components/automation/CronJobFormDialog.tsx:195:19",value:"*/5 * * * *",className:"text-[var(--dg-text-primary)]",children:"每 5 分钟"}),t.jsx(J,{"code-path":"src/components/automation/CronJobFormDialog.tsx:196:19",value:"0 * * * *",className:"text-[var(--dg-text-primary)]",children:"每小时"}),t.jsx(J,{"code-path":"src/components/automation/CronJobFormDialog.tsx:197:19",value:"0 2 * * *",className:"text-[var(--dg-text-primary)]",children:"每天 02:00"}),t.jsx(J,{"code-path":"src/components/automation/CronJobFormDialog.tsx:198:19",value:"0 3 * * 0",className:"text-[var(--dg-text-primary)]",children:"每周日 03:00"}),t.jsx(J,{"code-path":"src/components/automation/CronJobFormDialog.tsx:199:19",value:"0 9 * * 1",className:"text-[var(--dg-text-primary)]",children:"每周一 09:00"})]})]})]}),t.jsx("p",{"code-path":"src/components/automation/CronJobFormDialog.tsx:203:13",className:"text-xs text-[var(--dg-text-muted)] mt-1",children:"格式: 分 时 日 月 周"})]}),t.jsxs("div",{"code-path":"src/components/automation/CronJobFormDialog.tsx:207:11",children:[t.jsx(N,{"code-path":"src/components/automation/CronJobFormDialog.tsx:208:13",className:"text-[var(--dg-text-primary)]",children:"执行类型"}),t.jsx("div",{"code-path":"src/components/automation/CronJobFormDialog.tsx:209:13",className:"grid grid-cols-3 gap-2 mt-1",children:q.map(e=>t.jsx("button",{"code-path":"src/components/automation/CronJobFormDialog.tsx:211:17",type:"button",onClick:()=>T(e.value),className:`px-3 py-2 rounded-md border text-sm transition-colors text-left ${a.type===e.value?"border-[var(--dg-blue)] bg-[var(--dg-blue)]/10 text-[var(--dg-blue)]":"border-[var(--dg-border)] text-[var(--dg-text-secondary)] hover:bg-[var(--dg-bg-hover)]"}`,children:t.jsx("div",{"code-path":"src/components/automation/CronJobFormDialog.tsx:221:19",className:"font-medium",children:e.label})},e.value))}),t.jsx("p",{"code-path":"src/components/automation/CronJobFormDialog.tsx:225:13",className:"text-xs text-[var(--dg-text-muted)] mt-1",children:q.find(e=>e.value===a.type)?.desc})]}),a.type==="shell"||a.type==="python"?t.jsxs("div",{"code-path":"src/components/automation/CronJobFormDialog.tsx:232:13",className:"space-y-3",children:[t.jsxs("div",{"code-path":"src/components/automation/CronJobFormDialog.tsx:233:15",children:[t.jsxs(N,{"code-path":"src/components/automation/CronJobFormDialog.tsx:234:17",className:"text-[var(--dg-text-primary)]",children:["选择脚本 ",t.jsx("span",{"code-path":"src/components/automation/CronJobFormDialog.tsx:235:24",className:"text-red-400",children:"*"})]}),M.length===0?t.jsxs("div",{"code-path":"src/components/automation/CronJobFormDialog.tsx:238:19",className:"mt-1 px-3 py-4 rounded-md border border-dashed border-[var(--dg-border)] text-center",children:[t.jsxs("p",{"code-path":"src/components/automation/CronJobFormDialog.tsx:239:21",className:"text-sm text-[var(--dg-text-muted)]",children:["脚本库中没有 ",a.type==="shell"?"Shell":"Python"," 脚本"]}),t.jsxs("p",{"code-path":"src/components/automation/CronJobFormDialog.tsx:242:21",className:"text-xs text-[var(--dg-text-muted)] mt-1",children:["请先到「脚本库」创建 ",a.type==="shell"?"Shell":"Python"," 脚本"]})]}):t.jsxs(O,{"code-path":"src/components/automation/CronJobFormDialog.tsx:247:19",value:a.script_id?String(a.script_id):"",onValueChange:E,children:[t.jsx(R,{"code-path":"src/components/automation/CronJobFormDialog.tsx:251:21",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] mt-1",children:t.jsx(A,{"code-path":"src/components/automation/CronJobFormDialog.tsx:252:23",placeholder:"选择脚本库中的脚本..."})}),t.jsx(V,{"code-path":"src/components/automation/CronJobFormDialog.tsx:254:21",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:M.map(e=>t.jsxs(J,{"code-path":"src/components/automation/CronJobFormDialog.tsx:256:25",value:String(e.id),className:"text-[var(--dg-text-primary)]",children:[e.name,e.description?` — ${e.description}`:""]},e.id))})]})]}),r&&t.jsxs("div",{"code-path":"src/components/automation/CronJobFormDialog.tsx:267:17",children:[t.jsxs("div",{"code-path":"src/components/automation/CronJobFormDialog.tsx:268:19",className:"flex items-center gap-2 mb-1",children:[t.jsx(C,{"code-path":"src/components/automation/CronJobFormDialog.tsx:269:21",variant:"outline",className:"border-[var(--dg-border)] text-[var(--dg-text-muted)]",children:r.type==="shell"?"Shell":"Python"}),t.jsxs("span",{"code-path":"src/components/automation/CronJobFormDialog.tsx:272:21",className:"text-xs text-[var(--dg-text-muted)]",children:[(r.content||"").split(` -`).length," 行"]})]}),t.jsx("pre",{"code-path":"src/components/automation/CronJobFormDialog.tsx:276:19",className:"max-h-48 overflow-auto rounded-md bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] p-3 text-xs font-mono text-[var(--dg-text-secondary)] whitespace-pre-wrap break-all",children:r.content||"(空脚本)"})]})]}):t.jsxs("div",{"code-path":"src/components/automation/CronJobFormDialog.tsx:283:13",children:[t.jsx(N,{"code-path":"src/components/automation/CronJobFormDialog.tsx:284:15",className:"text-[var(--dg-text-primary)]",children:"执行命令"}),t.jsx(Q,{"code-path":"src/components/automation/CronJobFormDialog.tsx:285:15",value:a.content,onChange:e=>d({...a,content:e.target.value}),placeholder:"/scripts/backup.sh arg1 arg2",rows:4,className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] mt-1 font-mono"})]})]}),t.jsxs(xt,{"code-path":"src/components/automation/CronJobFormDialog.tsx:295:9",children:[t.jsx(p,{"code-path":"src/components/automation/CronJobFormDialog.tsx:296:11",variant:"outline",onClick:()=>g(!1),className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)]",children:"取消"}),t.jsx(p,{"code-path":"src/components/automation/CronJobFormDialog.tsx:299:11",className:"bg-blue-600 hover:bg-blue-700",onClick:H,disabled:S,children:S?"保存中...":s?"保存修改":"创建任务"})]})]})})}function Et({open:i,onOpenChange:g}){const[s,D]=n.useState([]),[a,d]=n.useState(!1),[h,v]=n.useState(null);return n.useEffect(()=>{if(!i)return;(async()=>{try{d(!0);const m=await ht.getExecutions({task_type:"cron",page_size:50});D(m.list||[])}catch(m){console.error("Failed to load executions:",m)}finally{d(!1)}})()},[i]),t.jsx(X,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:52:5",open:i,onOpenChange:g,children:t.jsxs(G,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:53:7",className:"max-w-4xl bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] max-h-[85vh] overflow-y-auto",children:[t.jsxs(K,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:54:9",children:[t.jsx(U,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:55:11",children:"执行历史"}),t.jsx(W,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:56:11",className:"text-[var(--dg-text-secondary)]",children:"定时任务执行记录与输出日志"})]}),t.jsx("div",{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:58:9",className:"mt-4",children:a?t.jsx("div",{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:60:13",className:"flex items-center justify-center py-8",children:t.jsx(k,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:61:15",className:"h-6 w-6 text-[var(--dg-text-secondary)] animate-spin"})}):s.length===0?t.jsxs("div",{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:64:13",className:"flex flex-col items-center justify-center py-12 text-[var(--dg-text-secondary)]",children:[t.jsx(Y,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:65:15",className:"h-10 w-10 mb-3 opacity-40"}),t.jsx("p",{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:66:15",className:"text-sm",children:"暂无执行记录"})]}):t.jsxs(Dt,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:69:13",children:[t.jsx(Ft,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:70:15",children:t.jsxs(L,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:71:17",className:"border-[var(--dg-border)]",children:[t.jsx(w,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:72:19",className:"text-[var(--dg-text-secondary)]",children:"任务"}),t.jsx(w,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:73:19",className:"text-[var(--dg-text-secondary)]",children:"状态"}),t.jsx(w,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:74:19",className:"text-[var(--dg-text-secondary)]",children:"耗时"}),t.jsx(w,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:75:19",className:"text-[var(--dg-text-secondary)]",children:"执行时间"}),t.jsx(w,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:76:19",className:"text-[var(--dg-text-secondary)]",children:"输出"})]})}),t.jsx(Mt,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:79:15",children:s.map(r=>t.jsxs(n.Fragment,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:81:19",children:[t.jsxs(L,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:82:21",className:"border-[var(--dg-border)] cursor-pointer hover:bg-[var(--dg-bg-hover)]/50",onClick:()=>v(h===r.id?null:r.id),children:[t.jsx(f,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:83:23",className:"text-[var(--dg-text-primary)]",children:r.task_name}),t.jsx(f,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:84:23",children:tt(r.status)}),t.jsx(f,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:85:23",className:"text-[var(--dg-text-secondary)]",children:r.duration?`${r.duration}ms`:"--"}),t.jsx(f,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:86:23",className:"text-[var(--dg-text-secondary)]",children:r.started_at?new Date(r.started_at).toLocaleString():"--"}),t.jsx(f,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:89:23",className:"text-[var(--dg-text-secondary)]",children:r.output?t.jsxs("span",{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:91:27",className:"text-blue-400 text-xs flex items-center gap-1",children:[t.jsx(Z,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:92:29",className:"h-3 w-3"}),h===r.id?"收起":"查看"]}):"--"})]}),h===r.id&&r.output&&t.jsx(L,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:101:23",className:"border-[var(--dg-border)]",children:t.jsx(f,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:102:25",colSpan:5,className:"bg-[var(--dg-bg-tertiary)] p-0",children:t.jsx("pre",{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:103:27",className:"p-4 text-xs text-[var(--dg-text-primary)] font-mono whitespace-pre-wrap max-h-64 overflow-y-auto",children:r.output})})},`${r.id}-out`)]},r.id))})]})})]})})}function Qt(){const[i,g]=n.useState(""),[s,D]=n.useState([]),[a,d]=n.useState(!0),[h,v]=n.useState(!1),[r,m]=n.useState(!1),[S,F]=n.useState(!1),[M,E]=n.useState(null),[T,H]=n.useState(null),[e,x]=n.useState([]),j=pt(),ot=()=>{H(null),m(!0)},et=o=>{H(o),m(!0)},u=n.useCallback(async()=>{v(!0);try{const o=await y.getJobs();D(o.list||[])}catch(o){console.error("Failed to load cron jobs:",o),l.error("加载失败")}finally{v(!1),d(!1)}},[]);n.useEffect(()=>{u()},[u]);const b=s.filter(o=>(o.name||"").toLowerCase().includes(i.toLowerCase())||(o.description||"").toLowerCase().includes(i.toLowerCase())),at=async o=>{try{await y.toggleJob(o),l.success("状态已切换"),u()}catch(c){console.error("Failed to toggle job:",c),l.error("操作失败")}},st=async o=>{E(o);try{const c=await y.executeJob(o);(c?.status||"success")==="success"?l.success("执行成功",{description:`耗时 ${c?.duration||0}ms`}):l.error("执行失败",{description:(c?.output||"").slice(0,100)}),u()}catch(c){console.error("Failed to execute job:",c),l.error("执行失败")}finally{E(null)}},rt=async o=>{if(await j({title:"删除定时任务",description:`确定删除「${o.name}」吗?此操作不可恢复。`,variant:"destructive"}))try{await y.deleteJob(o.id),l.success("任务已删除"),u()}catch(_){console.error("Failed to delete job:",_),l.error("删除失败")}},nt=o=>{x(c=>c.includes(o)?c.filter(_=>_!==o):[...c,o])},ct=()=>{e.length===b.length&&b.length>0?x([]):x(b.map(o=>o.id))},it=async()=>{if(!(e.length===0||!await j({title:"批量删除定时任务",description:`确定删除选中的 ${e.length} 个任务吗?此操作不可恢复。`,confirmText:"批量删除",variant:"destructive"})))try{await y.batchDelete(e),l.success(`已删除 ${e.length} 个任务`),x([]),u()}catch(c){console.error("Failed to batch delete jobs:",c),l.error("批量删除失败")}};return t.jsxs("div",{"code-path":"src/components/automation/CronJobManager.tsx:165:5",className:"space-y-6",children:[t.jsxs("div",{"code-path":"src/components/automation/CronJobManager.tsx:167:7",className:"flex items-center justify-between",children:[t.jsxs("div",{"code-path":"src/components/automation/CronJobManager.tsx:168:9",children:[t.jsx("h1",{"code-path":"src/components/automation/CronJobManager.tsx:169:11",className:"text-2xl font-bold text-[var(--dg-text-primary)]",children:"定时任务"}),t.jsx("p",{"code-path":"src/components/automation/CronJobManager.tsx:170:11",className:"text-sm text-[var(--dg-text-secondary)] mt-1",children:"Cron 任务管理与执行"})]}),t.jsxs("div",{"code-path":"src/components/automation/CronJobManager.tsx:172:9",className:"flex items-center gap-2",children:[t.jsxs(p,{"code-path":"src/components/automation/CronJobManager.tsx:173:11",variant:"outline",className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)]",onClick:()=>F(!0),children:[t.jsx(Y,{"code-path":"src/components/automation/CronJobManager.tsx:178:13",className:"h-4 w-4 mr-2"}),"执行历史"]}),t.jsxs(p,{"code-path":"src/components/automation/CronJobManager.tsx:181:11",variant:"outline",className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)]",onClick:()=>u(),disabled:h,children:[t.jsx(bt,{"code-path":"src/components/automation/CronJobManager.tsx:187:13",className:`h-4 w-4 mr-2 ${h?"animate-spin":""}`}),"刷新"]}),t.jsxs(p,{"code-path":"src/components/automation/CronJobManager.tsx:190:11",className:"bg-blue-600 hover:bg-blue-700",onClick:ot,children:[t.jsx(vt,{"code-path":"src/components/automation/CronJobManager.tsx:191:13",className:"h-4 w-4 mr-2"}),"新建任务"]})]})]}),t.jsx(mt,{"code-path":"src/components/automation/CronJobManager.tsx:198:7",items:[{label:"任务总数",value:s.length,color:"blue"},{label:"已启用",value:s.filter(o=>o.enabled).length,color:"emerald"},{label:"累计成功",value:s.reduce((o,c)=>o+(c.success_count||0),0),color:"emerald"},{label:"累计失败",value:s.reduce((o,c)=>o+(c.fail_count||0),0),color:"red"}]}),t.jsxs("div",{"code-path":"src/components/automation/CronJobManager.tsx:208:7",className:"flex items-center justify-between flex-wrap gap-4",children:[t.jsxs("div",{"code-path":"src/components/automation/CronJobManager.tsx:209:9",className:"flex items-center gap-3 flex-wrap",children:[t.jsxs("div",{"code-path":"src/components/automation/CronJobManager.tsx:210:11",className:"relative flex-1 max-w-md",children:[t.jsx(yt,{"code-path":"src/components/automation/CronJobManager.tsx:211:13",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-[var(--dg-text-secondary)]"}),t.jsx(P,{"code-path":"src/components/automation/CronJobManager.tsx:212:13",placeholder:"搜索任务...",value:i,onChange:o=>g(o.target.value),className:"pl-10 bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),b.length>0&&t.jsxs("label",{"code-path":"src/components/automation/CronJobManager.tsx:220:13",className:"flex items-center gap-2 text-sm text-[var(--dg-text-secondary)] cursor-pointer select-none",children:[t.jsx(I,{"code-path":"src/components/automation/CronJobManager.tsx:221:15",checked:e.length===b.length&&b.length>0,onCheckedChange:ct,className:"border-[var(--dg-border)]"}),"全选"]})]}),e.length>0&&t.jsxs("div",{"code-path":"src/components/automation/CronJobManager.tsx:233:11",className:"flex items-center gap-2",children:[t.jsxs("span",{"code-path":"src/components/automation/CronJobManager.tsx:234:13",className:"text-sm text-[var(--dg-text-secondary)]",children:["已选择 ",e.length," 项"]}),t.jsxs(p,{"code-path":"src/components/automation/CronJobManager.tsx:235:13",variant:"outline",size:"sm",className:"border-red-500/30 text-red-400 hover:bg-red-500/10",onClick:it,children:[t.jsx(z,{"code-path":"src/components/automation/CronJobManager.tsx:241:15",className:"h-4 w-4 mr-2"}),"批量删除"]})]})]}),a?t.jsx("div",{"code-path":"src/components/automation/CronJobManager.tsx:249:9",className:"flex items-center justify-center py-12",children:t.jsx(k,{"code-path":"src/components/automation/CronJobManager.tsx:250:11",className:"h-6 w-6 text-[var(--dg-text-secondary)] animate-spin"})}):b.length===0?t.jsxs("div",{"code-path":"src/components/automation/CronJobManager.tsx:253:9",className:"flex flex-col items-center justify-center py-16 text-[var(--dg-text-secondary)]",children:[t.jsx(Ct,{"code-path":"src/components/automation/CronJobManager.tsx:254:11",className:"h-12 w-12 mb-3 opacity-40"}),t.jsx("p",{"code-path":"src/components/automation/CronJobManager.tsx:255:11",className:"text-sm",children:"暂无定时任务"})]}):null,t.jsx("div",{"code-path":"src/components/automation/CronJobManager.tsx:260:7",className:"space-y-3",children:b.map(o=>t.jsx(lt,{"code-path":"src/components/automation/CronJobManager.tsx:262:11",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:t.jsx(dt,{"code-path":"src/components/automation/CronJobManager.tsx:263:13",className:"p-4",children:t.jsxs("div",{"code-path":"src/components/automation/CronJobManager.tsx:264:15",className:"flex items-start justify-between gap-3",children:[t.jsx("div",{"code-path":"src/components/automation/CronJobManager.tsx:265:17",className:"flex items-center pt-1",children:t.jsx(I,{"code-path":"src/components/automation/CronJobManager.tsx:266:19",checked:e.includes(o.id),onCheckedChange:()=>nt(o.id),className:"border-[var(--dg-border)]"})}),t.jsxs("div",{"code-path":"src/components/automation/CronJobManager.tsx:272:17",className:"flex-1 min-w-0",children:[t.jsxs("div",{"code-path":"src/components/automation/CronJobManager.tsx:273:19",className:"flex items-center gap-3 flex-wrap",children:[t.jsx("h3",{"code-path":"src/components/automation/CronJobManager.tsx:274:21",className:"font-medium text-[var(--dg-text-primary)]",children:o.name}),t.jsx(C,{"code-path":"src/components/automation/CronJobManager.tsx:275:21",variant:"outline",className:o.enabled?"border-emerald-500/30 text-emerald-400 bg-emerald-500/10":"border-[var(--dg-border)] text-[var(--dg-text-muted)]",children:o.enabled?"已启用":"已禁用"}),tt(o.last_status),t.jsx(C,{"code-path":"src/components/automation/CronJobManager.tsx:286:21",variant:"outline",className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)]",children:o.type==="shell"?"Shell":o.type==="python"?"Python":"命令"})]}),t.jsx("p",{"code-path":"src/components/automation/CronJobManager.tsx:290:19",className:"text-sm text-[var(--dg-text-secondary)] mt-1",children:o.description||"—"}),t.jsxs("div",{"code-path":"src/components/automation/CronJobManager.tsx:291:19",className:"flex items-center gap-4 mt-2 text-sm",children:[t.jsxs("span",{"code-path":"src/components/automation/CronJobManager.tsx:292:21",className:"flex items-center gap-1 text-[var(--dg-text-secondary)]",children:[t.jsx(jt,{"code-path":"src/components/automation/CronJobManager.tsx:293:23",className:"h-3 w-3"}),wt(o.cron_expr)]}),(o.type==="shell"||o.type==="python")&&o.script?.name?t.jsxs("span",{"code-path":"src/components/automation/CronJobManager.tsx:297:23",className:"flex items-center gap-1 text-[var(--dg-text-secondary)]",children:[t.jsx(Jt,{"code-path":"src/components/automation/CronJobManager.tsx:298:25",className:"h-3 w-3"}),t.jsx("span",{"code-path":"src/components/automation/CronJobManager.tsx:299:25",className:"text-xs",children:o.script.name})]}):o.content&&t.jsxs("span",{"code-path":"src/components/automation/CronJobManager.tsx:302:23",className:"flex items-center gap-1 text-[var(--dg-text-secondary)]",children:[t.jsx(Z,{"code-path":"src/components/automation/CronJobManager.tsx:303:25",className:"h-3 w-3"}),t.jsx("code",{"code-path":"src/components/automation/CronJobManager.tsx:304:25",className:"text-xs bg-[var(--dg-bg-tertiary)] px-2 py-0.5 rounded truncate max-w-xs",children:o.content})]})]}),t.jsxs("div",{"code-path":"src/components/automation/CronJobManager.tsx:310:19",className:"flex items-center gap-4 mt-2 text-xs text-[var(--dg-text-muted)]",children:[t.jsxs("span",{"code-path":"src/components/automation/CronJobManager.tsx:311:21",children:["上次执行: ",o.last_run_at?new Date(o.last_run_at).toLocaleString():"--"]}),t.jsxs("span",{"code-path":"src/components/automation/CronJobManager.tsx:312:21",children:["成功: ",o.success_count||0," / 失败: ",o.fail_count||0]}),t.jsxs("span",{"code-path":"src/components/automation/CronJobManager.tsx:313:21",children:["累计: ",o.run_count||0," 次"]})]})]}),t.jsxs("div",{"code-path":"src/components/automation/CronJobManager.tsx:317:17",className:"flex items-center gap-2 shrink-0",children:[t.jsxs(p,{"code-path":"src/components/automation/CronJobManager.tsx:318:19",variant:"outline",size:"sm",className:"border-emerald-600 text-emerald-400 hover:bg-emerald-600/20",disabled:M===o.id,onClick:()=>st(o.id),children:[M===o.id?t.jsx(k,{"code-path":"src/components/automation/CronJobManager.tsx:326:23",className:"h-4 w-4 mr-1 animate-spin"}):t.jsx(B,{"code-path":"src/components/automation/CronJobManager.tsx:328:23",className:"h-4 w-4 mr-1"}),"立即执行"]}),t.jsx(p,{"code-path":"src/components/automation/CronJobManager.tsx:332:19",variant:"ghost",size:"icon",className:"h-8 w-8 text-[var(--dg-text-secondary)] hover:text-blue-400",title:o.enabled?"禁用":"启用",onClick:()=>at(o.id),children:o.enabled?t.jsx(Nt,{"code-path":"src/components/automation/CronJobManager.tsx:339:36",className:"h-4 w-4"}):t.jsx(B,{"code-path":"src/components/automation/CronJobManager.tsx:339:68",className:"h-4 w-4"})}),t.jsx(p,{"code-path":"src/components/automation/CronJobManager.tsx:341:19",variant:"ghost",size:"icon",className:"h-8 w-8 text-[var(--dg-text-secondary)] hover:text-blue-400",title:"编辑",onClick:()=>et(o),children:t.jsx(ft,{"code-path":"src/components/automation/CronJobManager.tsx:348:21",className:"h-4 w-4"})}),t.jsx(p,{"code-path":"src/components/automation/CronJobManager.tsx:350:19",variant:"ghost",size:"icon",className:"h-8 w-8 text-[var(--dg-text-secondary)] hover:text-red-400",title:"删除",onClick:()=>rt(o),children:t.jsx(z,{"code-path":"src/components/automation/CronJobManager.tsx:357:21",className:"h-4 w-4"})})]})]})})},o.id))}),t.jsx(St,{"code-path":"src/components/automation/CronJobManager.tsx:367:7",open:r,onOpenChange:m,editJob:T,onSuccess:u}),t.jsx(Et,{"code-path":"src/components/automation/CronJobManager.tsx:375:7",open:S,onOpenChange:F})]})}export{Qt as CronJobManager}; diff --git a/backend/static/assets/Dashboard-jrJNQyDv.js b/backend/static/assets/Dashboard-jrJNQyDv.js deleted file mode 100644 index 023bbd9..0000000 --- a/backend/static/assets/Dashboard-jrJNQyDv.js +++ /dev/null @@ -1,4 +0,0 @@ -import{R as m,g as st,r as A,j as s}from"./vendor-codemirror-B1SGo4xl.js";import{ay as K,m as u,i as ie,B as se,q as rt}from"./index-Dungj95X.js";import{d as he}from"./dashboard-D0JujfHp.js";import{s as Ct}from"./server-P3fi-cmJ.js";import{k as kt}from"./index-drGq01ok.js";import{S as Rt}from"./stat-strip-BSQFwFzG.js";import{C as B,b as U,c as z,d as V,a as q}from"./card-BIfzBCEy.js";import{B as L}from"./badge-CGJlVD3L.js";import{g as ot,A as At,H as wt,aE as St,D as Ot,ae as le,l as nt,j as Me,ao as Ke,aK as Pt,h as ct,i as Be,b as _t}from"./vendor-icons-DmqcWdzX.js";import{f as C,r as dt,b as Et,c as it,d as Tt,i as X,e as Ee,p as I,L as T,g as lt,h as Te,j as ht,D as Lt,k as It,l as ae,m as J,S as $t,n as Ft,o as Mt,q as Ue,s as Kt,t as Q,u as Bt,v as Ut,G as zt,w as me,x as Vt,y as pt,z as qt,E as pe,F as ze,H as mt,I as ut,X as Le,Y as Ie,J as Wt,K as Ht,R as Re,A as Gt,C as xt,T as Ae,a as Ne}from"./AreaChart-yrR-Mxho.js";var Zt=["points","className","baseLinePoints","connectNulls"];function ee(){return ee=Object.assign?Object.assign.bind():function(t){for(var a=1;a=0)&&Object.prototype.propertyIsEnumerable.call(t,e)&&(r[e]=t[e])}return r}function Yt(t,a){if(t==null)return{};var r={};for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e)){if(a.indexOf(e)>=0)continue;r[e]=t[e]}return r}function Ve(t){return ta(t)||ea(t)||Qt(t)||Jt()}function Jt(){throw new TypeError(`Invalid attempt to spread non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Qt(t,a){if(t){if(typeof t=="string")return we(t,a);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return we(t,a)}}function ea(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function ta(t){if(Array.isArray(t))return we(t)}function we(t,a){(a==null||a>t.length)&&(a=t.length);for(var r=0,e=new Array(a);r0&&arguments[0]!==void 0?arguments[0]:[],r=[[]];return a.forEach(function(e){qe(e)?r[r.length-1].push(e):r[r.length-1].length>0&&r.push([])}),qe(a[0])&&r[r.length-1].push(a[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},ce=function(a,r){var e=aa(a);r&&(e=[e.reduce(function(n,c){return[].concat(Ve(n),Ve(c))},[])]);var o=e.map(function(n){return n.reduce(function(c,d,l){return"".concat(c).concat(l===0?"M":"L").concat(d.x,",").concat(d.y)},"")}).join("");return e.length===1?"".concat(o,"Z"):o},sa=function(a,r,e){var o=ce(a,e);return"".concat(o.slice(-1)==="Z"?o.slice(0,-1):o,"L").concat(ce(r.reverse(),e).slice(1))},ra=function(a){var r=a.points,e=a.className,o=a.baseLinePoints,n=a.connectNulls,c=Xt(a,Zt);if(!r||!r.length)return null;var d=K("recharts-polygon",e);if(o&&o.length){var l=c.stroke&&c.stroke!=="none",i=sa(r,o,n);return m.createElement("g",{className:d},m.createElement("path",ee({},C(c,!0),{fill:i.slice(-1)==="Z"?c.fill:"none",stroke:"none",d:i})),l?m.createElement("path",ee({},C(c,!0),{fill:"none",d:ce(r,n)})):null,l?m.createElement("path",ee({},C(c,!0),{fill:"none",d:ce(o,n)})):null)}var p=ce(r,n);return m.createElement("path",ee({},C(c,!0),{fill:p.slice(-1)==="Z"?c.fill:"none",className:d,d:p}))},Ce,We;function oa(){if(We)return Ce;We=1;var t=dt(),a=Et(),r=it();function e(o,n){return o&&o.length?t(o,r(n,2),a):void 0}return Ce=e,Ce}var na=oa();const ca=st(na);var ke,He;function da(){if(He)return ke;He=1;var t=dt(),a=it(),r=Tt();function e(o,n){return o&&o.length?t(o,a(n,2),r):void 0}return ke=e,ke}var ia=da();const la=st(ia);var ha=["cx","cy","angle","ticks","axisLine"],pa=["ticks","tick","angle","tickFormatter","stroke"];function re(t){"@babel/helpers - typeof";return re=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},re(t)}function de(){return de=Object.assign?Object.assign.bind():function(t){for(var a=1;a=0)&&Object.prototype.propertyIsEnumerable.call(t,e)&&(r[e]=t[e])}return r}function ma(t,a){if(t==null)return{};var r={};for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e)){if(a.indexOf(e)>=0)continue;r[e]=t[e]}return r}function ua(t,a){if(!(t instanceof a))throw new TypeError("Cannot call a class as a function")}function Xe(t,a){for(var r=0;rQe?c=o==="outer"?"start":"end":n<-Qe?c=o==="outer"?"end":"start":c="middle",c}},{key:"renderAxisLine",value:function(){var e=this.props,o=e.cx,n=e.cy,c=e.radius,d=e.axisLine,l=e.axisLineType,i=Z(Z({},C(this.props,!1)),{},{fill:"none"},C(d,!1));if(l==="circle")return m.createElement(Lt,Y({className:"recharts-polar-angle-axis-line"},i,{cx:o,cy:n,r:c}));var p=this.props.ticks,x=p.map(function(b){return I(o,n,c,b.coordinate)});return m.createElement(ra,Y({className:"recharts-polar-angle-axis-line"},i,{points:x}))}},{key:"renderTicks",value:function(){var e=this,o=this.props,n=o.ticks,c=o.tick,d=o.tickLine,l=o.tickFormatter,i=o.stroke,p=C(this.props,!1),x=C(c,!1),b=Z(Z({},p),{},{fill:"none"},C(d,!1)),N=n.map(function(f,h){var v=e.getTickLineCoord(f),y=e.getTickTextAnchor(f),j=Z(Z(Z({textAnchor:y},p),{},{stroke:"none",fill:i},x),{},{index:h,payload:f,x:v.x2,y:v.y2});return m.createElement(T,Y({className:K("recharts-polar-angle-axis-tick",lt(c)),key:"tick-".concat(f.coordinate)},Te(e.props,f,h)),d&&m.createElement("line",Y({className:"recharts-polar-angle-axis-tick-line"},b,v)),c&&a.renderTickItem(c,j,l?l(f.value,h):f.value))});return m.createElement(T,{className:"recharts-polar-angle-axis-ticks"},N)}},{key:"render",value:function(){var e=this.props,o=e.ticks,n=e.radius,c=e.axisLine;return n<=0||!o||!o.length?null:m.createElement(T,{className:K("recharts-polar-angle-axis",this.props.className)},c&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(e,o,n){var c;return m.isValidElement(e)?c=m.cloneElement(e,o):X(e)?c=e(o):c=m.createElement(Ee,Y({},o,{className:"recharts-polar-angle-axis-tick-value"}),n),c}}])})(A.PureComponent);je(De,"displayName","PolarAngleAxis");je(De,"axisType","angleAxis");je(De,"defaultProps",{type:"category",angleAxisId:0,scale:"auto",cx:0,cy:0,orientation:"outer",axisLine:!0,tickLine:!0,tickSize:8,tick:!0,hide:!1,allowDuplicatedCategory:!0});var ue;function ne(t){"@babel/helpers - typeof";return ne=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},ne(t)}function te(){return te=Object.assign?Object.assign.bind():function(t){for(var a=1;a0?Mt(k,"paddingAngle",0):0;if(w){var F=Ue(w.endAngle-w.startAngle,k.endAngle-k.startAngle),D=g(g({},k),{},{startAngle:j+_,endAngle:j+F(h)+_});v.push(D),j=D.endAngle}else{var M=k.endAngle,O=k.startAngle,W=Ue(0,M-O),H=W(h),E=g(g({},k),{},{startAngle:j+_,endAngle:j+H+_});v.push(E),j=E.endAngle}}),m.createElement(T,null,e.renderSectorsStatically(v))})}},{key:"attachKeyboardHandlers",value:function(e){var o=this;e.onkeydown=function(n){if(!n.altKey)switch(n.key){case"ArrowLeft":{var c=++o.state.sectorToFocus%o.sectorRefs.length;o.sectorRefs[c].focus(),o.setState({sectorToFocus:c});break}case"ArrowRight":{var d=--o.state.sectorToFocus<0?o.sectorRefs.length-1:o.state.sectorToFocus%o.sectorRefs.length;o.sectorRefs[d].focus(),o.setState({sectorToFocus:d});break}case"Escape":{o.sectorRefs[o.state.sectorToFocus].blur(),o.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var e=this.props,o=e.sectors,n=e.isAnimationActive,c=this.state.prevSectors;return n&&o&&o.length&&(!c||!Kt(c,o))?this.renderSectorsWithAnimation():this.renderSectorsStatically(o)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var e=this,o=this.props,n=o.hide,c=o.sectors,d=o.className,l=o.label,i=o.cx,p=o.cy,x=o.innerRadius,b=o.outerRadius,N=o.isAnimationActive,f=this.state.isAnimationFinished;if(n||!c||!c.length||!Q(i)||!Q(p)||!Q(x)||!Q(b))return null;var h=K("recharts-pie",d);return m.createElement(T,{tabIndex:this.props.rootTabIndex,className:h,ref:function(y){e.pieRef=y}},this.renderSectors(),l&&this.renderLabels(c),ht.renderCallByParent(this.props,null,!1),(!N||f)&&Bt.renderCallByParent(this.props,c,!1))}}],[{key:"getDerivedStateFromProps",value:function(e,o){return o.prevIsAnimationActive!==e.isAnimationActive?{prevIsAnimationActive:e.isAnimationActive,prevAnimationId:e.animationId,curSectors:e.sectors,prevSectors:[],isAnimationFinished:!0}:e.isAnimationActive&&e.animationId!==o.prevAnimationId?{prevAnimationId:e.animationId,curSectors:e.sectors,prevSectors:o.curSectors,isAnimationFinished:!0}:e.sectors!==o.curSectors?{curSectors:e.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(e,o){return e>o?"start":e=360?j:j-1)*l,S=v-j*N-k,w=o.reduce(function(D,M){var O=J(M,y,0);return D+(Q(O)?O:0)},0),_;if(w>0){var F;_=o.map(function(D,M){var O=J(D,y,0),W=J(D,p,M),H=(Q(O)?O:0)/w,E;M?E=F.endAngle+me(h)*l*(O!==0?1:0):E=c;var R=E+me(h)*((O!==0?N:0)+H*S),$e=(E+R)/2,Fe=(f.innerRadius+f.outerRadius)/2,Dt=[{name:W,value:O,payload:D,dataKey:y,type:b}],Nt=I(f.cx,f.cy,Fe,$e);return F=g(g(g({percent:H,cornerRadius:n,name:W,tooltipPayload:Dt,midAngle:$e,middleRadius:Fe,tooltipPosition:Nt},D),f),{},{value:J(D,y),startAngle:E,endAngle:R,payload:D,paddingAngle:me(h)*l}),F})}return g(g({},f),{},{sectors:_,data:o})});var Ia=mt({chartName:"BarChart",GraphicalChild:ut,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:Le},{axisType:"yAxis",AxisComp:Ie}],formatAxisMap:Wt}),$a=mt({chartName:"PieChart",GraphicalChild:$,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:De},{axisType:"radiusAxis",AxisComp:ye}],formatAxisMap:Ht,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});const Fa={阿里云:"#ff6a00",aliyun:"#ff6a00",AWS:"#ff9900",aws:"#ff9900",腾讯云:"#006eff",tencent:"#006eff",华为云:"#ff0000",huawei:"#ff0000",Azure:"#0078d4",azure:"#0078d4"},at=["#ff6a00","#ff9900","#006eff","#ff0000","#0078d4","#10b981","#a855f7","#ec4899"];function Ma(t){if(!t||t.length<2)return{pct:0,label:"暂无数据",direction:"neutral"};const a=Number(t[t.length-1].cost??0),r=Number(t[t.length-2].cost??0);if(r===0)return{pct:0,label:a>0?"新增费用":"持平",direction:"neutral"};const e=(a-r)/r*100,o=e>.05?"up":e<-.05?"down":"neutral",n=`${e>0?"+":""}${e.toFixed(1)}% 较上月`;return{pct:e,label:n,direction:o}}function Ka(t,a,r,e=24){const o=[];for(let n=e-1;n>=0;n--){const c=new Date(Date.now()-n*60*60*1e3);o.push({time:`${c.getHours().toString().padStart(2,"0")}:00`,cpu:Number(Math.max(0,Math.min(100,t+(Math.random()-.5)*15)).toFixed(1)),memory:Number(Math.max(0,Math.min(100,a+(Math.random()-.5)*10)).toFixed(1)),disk:Number(Math.max(0,Math.min(100,r+(Math.random()-.5)*5)).toFixed(1))})}return o}function Ba(t,a){if(!t||t.length===0)return[];const r={};for(const e of t){const o=e.timestamp;if(!o)continue;const c=`${new Date(o).getHours().toString().padStart(2,"0")}:00`;r[c]||(r[c]={}),e.name==="cpu"&&(r[c].cpu=Number(e.value)||0),e.name==="memory"&&(r[c].memory=Number(e.value)||0)}return Object.entries(r).sort((e,o)=>e[0].localeCompare(o[0])).map(([e,o])=>({time:e,cpu:Number((o.cpu??0).toFixed(1)),memory:Number((o.memory??0).toFixed(1)),disk:Number(a.toFixed(1))}))}function _e({active:t,payload:a,label:r}){return!t||!a?null:s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:95:5",className:"chart-tooltip px-3 py-2",children:[s.jsx("p",{"code-path":"src/components/dashboard/DashboardCharts.tsx:96:7",className:"text-xs font-medium mb-1.5",style:{color:"var(--dg-text-secondary)"},children:r}),a.map((e,o)=>s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:98:9",className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{"code-path":"src/components/dashboard/DashboardCharts.tsx:99:11",className:"w-2 h-2 rounded-full",style:{backgroundColor:e.color}}),s.jsxs("span",{"code-path":"src/components/dashboard/DashboardCharts.tsx:100:11",style:{color:"var(--dg-text-muted)"},children:[e.name,":"]}),s.jsx("span",{"code-path":"src/components/dashboard/DashboardCharts.tsx:101:11",className:"font-medium",style:{color:"var(--dg-text-primary)"},children:typeof e.value=="number"?`${e.value}%`:e.value})]},o))]})}function Ua({costStats:t}){const a=t?.cloud_costs??[],r=t?.month_trend??[],e=a.map((d,l)=>({name:d.cloud,value:d.cost,color:Fa[d.cloud]||at[l%at.length]})),o=r.map(d=>({month:d.month,cost:d.cost})),n=t?.total_cost??e.reduce((d,l)=>d+l.value,0),c=Ma(r);return s.jsxs(B,{"code-path":"src/components/dashboard/DashboardCharts.tsx:124:5",className:"dg-card dg-card-hover",children:[s.jsx(U,{"code-path":"src/components/dashboard/DashboardCharts.tsx:125:7",className:"pb-2",children:s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:126:9",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:127:11",children:[s.jsx(z,{"code-path":"src/components/dashboard/DashboardCharts.tsx:128:13",className:"text-[var(--dg-text-primary)]",children:"云成本概览"}),s.jsx(V,{"code-path":"src/components/dashboard/DashboardCharts.tsx:129:13",className:"text-[var(--dg-text-muted)]",children:"本月各云平台费用支出"})]}),s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:131:11",className:"text-right",children:[s.jsxs("p",{"code-path":"src/components/dashboard/DashboardCharts.tsx:132:13",className:"text-2xl font-bold text-[var(--dg-text-primary)] tracking-tight",children:["¥",Number(n).toLocaleString()]}),s.jsx("p",{"code-path":"src/components/dashboard/DashboardCharts.tsx:135:13",className:u("text-xs font-medium mt-0.5",c.direction==="up"?"text-[var(--dg-green)]":c.direction==="down"?"text-[var(--dg-red)]":"text-[var(--dg-text-muted)]"),children:c.label})]})]})}),s.jsxs(q,{"code-path":"src/components/dashboard/DashboardCharts.tsx:146:7",children:[s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:147:9",className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:148:11",children:[s.jsx("p",{"code-path":"src/components/dashboard/DashboardCharts.tsx:149:13",className:"text-sm text-[var(--dg-text-secondary)] mb-2",children:"费用分布"}),s.jsx("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:150:13",className:"h-[180px]",children:s.jsx(Re,{"code-path":"src/components/dashboard/DashboardCharts.tsx:151:15",width:"100%",height:"100%",children:s.jsxs($a,{"code-path":"src/components/dashboard/DashboardCharts.tsx:152:17",children:[s.jsx($,{"code-path":"src/components/dashboard/DashboardCharts.tsx:153:19",data:e,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",stroke:"none",children:e.map((d,l)=>s.jsx(pt,{"code-path":"src/components/dashboard/DashboardCharts.tsx:164:23",fill:d.color},`cell-${l}`))}),s.jsx(Ae,{"code-path":"src/components/dashboard/DashboardCharts.tsx:167:19",content:s.jsx(_e,{"code-path":"src/components/dashboard/DashboardCharts.tsx:167:37"})})]})})})]}),s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:172:11",children:[s.jsx("p",{"code-path":"src/components/dashboard/DashboardCharts.tsx:173:13",className:"text-sm text-[var(--dg-text-secondary)] mb-2",children:"月度趋势"}),s.jsx("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:174:13",className:"h-[180px]",children:s.jsx(Re,{"code-path":"src/components/dashboard/DashboardCharts.tsx:175:15",width:"100%",height:"100%",children:s.jsxs(Ia,{"code-path":"src/components/dashboard/DashboardCharts.tsx:176:17",data:o,margin:{top:5,right:5,left:0,bottom:5},children:[s.jsx(xt,{"code-path":"src/components/dashboard/DashboardCharts.tsx:177:19",strokeDasharray:"3 3",className:"chart-grid-stroke",stroke:"var(--chart-grid)"}),s.jsx(Le,{"code-path":"src/components/dashboard/DashboardCharts.tsx:178:19",dataKey:"month",stroke:"var(--chart-axis)",fontSize:10,tickLine:!1,axisLine:!1}),s.jsx(Ie,{"code-path":"src/components/dashboard/DashboardCharts.tsx:179:19",stroke:"var(--chart-axis)",fontSize:10,tickLine:!1,axisLine:!1}),s.jsx(Ae,{"code-path":"src/components/dashboard/DashboardCharts.tsx:180:19",content:s.jsx(_e,{"code-path":"src/components/dashboard/DashboardCharts.tsx:180:37"})}),s.jsx(ut,{"code-path":"src/components/dashboard/DashboardCharts.tsx:181:19",dataKey:"cost",fill:"var(--dg-blue)",radius:[4,4,0,0]})]})})})]})]}),s.jsx("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:187:9",className:"mt-4 space-y-2",children:e.map(d=>s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:189:13",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:190:15",className:"flex items-center gap-2",children:[s.jsx("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:191:17",className:"w-3 h-3 rounded-full",style:{backgroundColor:d.color}}),s.jsx("span",{"code-path":"src/components/dashboard/DashboardCharts.tsx:192:17",className:"text-sm text-[var(--dg-text-secondary)]",children:d.name})]}),s.jsxs("span",{"code-path":"src/components/dashboard/DashboardCharts.tsx:194:15",className:"text-sm font-semibold text-[var(--dg-text-primary)]",children:["¥",Number(d.value).toLocaleString()]})]},d.name))})]})]})}function za({topUsage:t}){const a=(t?.cpu??[]).slice(0,5),r=(t?.memory??[]).slice(0,5),e=(t?.disk??[]).slice(0,5),o=(n,c,d,l,i)=>s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:216:5",children:[s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:217:7",className:"flex items-center gap-2 mb-3",children:[l,s.jsx("span",{"code-path":"src/components/dashboard/DashboardCharts.tsx:219:9",className:"text-sm font-semibold text-[var(--dg-text-secondary)]",children:i})]}),s.jsx("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:221:7",className:"space-y-2.5",children:n.map((p,x)=>{const b=Number(p.usage??0);return s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:225:13",className:"flex items-center gap-2.5",children:[s.jsx("span",{"code-path":"src/components/dashboard/DashboardCharts.tsx:226:15",className:"text-xs font-mono text-[var(--dg-text-muted)] w-5 text-center",children:x+1}),s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:229:15",className:"flex-1 min-w-0",children:[s.jsx("p",{"code-path":"src/components/dashboard/DashboardCharts.tsx:230:17",className:"text-xs text-[var(--dg-text-secondary)] truncate font-medium",children:p.hostname}),s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:231:17",className:"flex items-center gap-2 mt-1",children:[s.jsx("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:232:19",className:"flex-1 h-1.5 bg-[var(--dg-bg-tertiary)] rounded-full overflow-hidden",children:s.jsx("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:233:21",className:u("h-full rounded-full transition-all duration-500",b>80?"bg-[var(--dg-red)]":b>60?"bg-[var(--dg-yellow)]":d),style:{width:`${Math.min(b,100)}%`}})}),s.jsxs("span",{"code-path":"src/components/dashboard/DashboardCharts.tsx:241:19",className:u("text-xs font-mono font-medium w-12 text-right",b>80?"text-[var(--dg-red)]":b>60?"text-[var(--dg-yellow)]":"text-[var(--dg-text-muted)]"),children:[b.toFixed(1),"%"]})]})]})]},p.id??x)})})]});return s.jsxs(B,{"code-path":"src/components/dashboard/DashboardCharts.tsx:257:5",className:"dg-card dg-card-hover",children:[s.jsx(U,{"code-path":"src/components/dashboard/DashboardCharts.tsx:258:7",className:"pb-2",children:s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:259:9",children:[s.jsx(z,{"code-path":"src/components/dashboard/DashboardCharts.tsx:260:11",className:"text-[var(--dg-text-primary)]",children:"Top5 资源使用"}),s.jsx(V,{"code-path":"src/components/dashboard/DashboardCharts.tsx:261:11",className:"text-[var(--dg-text-muted)]",children:"CPU、内存、磁盘使用率最高"})]})}),s.jsx(q,{"code-path":"src/components/dashboard/DashboardCharts.tsx:264:7",children:s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:265:9",className:"grid grid-cols-3 gap-4",children:[o(a,"blue","bg-[var(--dg-blue)]",s.jsx(ot,{"code-path":"src/components/dashboard/DashboardCharts.tsx:266:69",className:"h-4 w-4 text-[var(--dg-blue)]"}),"CPU"),o(r,"emerald","bg-[var(--dg-green)]",s.jsx(St,{"code-path":"src/components/dashboard/DashboardCharts.tsx:267:76",className:"h-4 w-4 text-[var(--dg-green)]"}),"内存"),o(e,"purple","bg-[var(--dg-purple)]",s.jsx(Ot,{"code-path":"src/components/dashboard/DashboardCharts.tsx:268:74",className:"h-4 w-4 text-[var(--dg-purple)]"}),"磁盘")]})})]})}function Va({avgCpu:t,avgMemory:a,avgDisk:r,metrics:e}){const o=Ba(e??[],r),n=o.length>0?o:Ka(t,a,r,24);return s.jsxs(B,{"code-path":"src/components/dashboard/DashboardCharts.tsx:290:5",className:"dg-card",children:[s.jsx(U,{"code-path":"src/components/dashboard/DashboardCharts.tsx:291:7",className:"pb-2",children:s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:292:9",className:"flex items-center justify-between flex-wrap gap-3",children:[s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:293:11",children:[s.jsx(z,{"code-path":"src/components/dashboard/DashboardCharts.tsx:294:13",className:"text-[var(--dg-text-primary)]",children:"资源使用率趋势"}),s.jsx(V,{"code-path":"src/components/dashboard/DashboardCharts.tsx:295:13",className:"text-[var(--dg-text-muted)]",children:"过去24小时系统资源使用情况"})]}),s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:297:11",className:"flex items-center gap-2",children:[s.jsxs(L,{"code-path":"src/components/dashboard/DashboardCharts.tsx:298:13",variant:"outline",className:"dg-badge-blue border",children:[s.jsx(ot,{"code-path":"src/components/dashboard/DashboardCharts.tsx:299:15",className:"h-3 w-3 mr-1"}),"CPU"]}),s.jsxs(L,{"code-path":"src/components/dashboard/DashboardCharts.tsx:302:13",variant:"outline",className:"dg-badge-green border",children:[s.jsx(At,{"code-path":"src/components/dashboard/DashboardCharts.tsx:303:15",className:"h-3 w-3 mr-1"}),"内存"]}),s.jsxs(L,{"code-path":"src/components/dashboard/DashboardCharts.tsx:306:13",variant:"outline",className:"dg-badge-purple border",children:[s.jsx(wt,{"code-path":"src/components/dashboard/DashboardCharts.tsx:307:15",className:"h-3 w-3 mr-1"}),"磁盘"]})]})]})}),s.jsx(q,{"code-path":"src/components/dashboard/DashboardCharts.tsx:313:7",children:s.jsx("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:314:9",className:"h-[280px]",children:s.jsx(Re,{"code-path":"src/components/dashboard/DashboardCharts.tsx:315:11",width:"100%",height:"100%",children:s.jsxs(Gt,{"code-path":"src/components/dashboard/DashboardCharts.tsx:316:13",data:n,margin:{top:10,right:10,left:0,bottom:0},children:[s.jsxs("defs",{"code-path":"src/components/dashboard/DashboardCharts.tsx:317:15",children:[s.jsxs("linearGradient",{"code-path":"src/components/dashboard/DashboardCharts.tsx:318:17",id:"colorCpu",x1:"0",y1:"0",x2:"0",y2:"1",children:[s.jsx("stop",{"code-path":"src/components/dashboard/DashboardCharts.tsx:319:19",offset:"5%",stopColor:"var(--dg-blue)",stopOpacity:.3}),s.jsx("stop",{"code-path":"src/components/dashboard/DashboardCharts.tsx:320:19",offset:"95%",stopColor:"var(--dg-blue)",stopOpacity:0})]}),s.jsxs("linearGradient",{"code-path":"src/components/dashboard/DashboardCharts.tsx:322:17",id:"colorMemory",x1:"0",y1:"0",x2:"0",y2:"1",children:[s.jsx("stop",{"code-path":"src/components/dashboard/DashboardCharts.tsx:323:19",offset:"5%",stopColor:"var(--dg-green)",stopOpacity:.3}),s.jsx("stop",{"code-path":"src/components/dashboard/DashboardCharts.tsx:324:19",offset:"95%",stopColor:"var(--dg-green)",stopOpacity:0})]}),s.jsxs("linearGradient",{"code-path":"src/components/dashboard/DashboardCharts.tsx:326:17",id:"colorDisk",x1:"0",y1:"0",x2:"0",y2:"1",children:[s.jsx("stop",{"code-path":"src/components/dashboard/DashboardCharts.tsx:327:19",offset:"5%",stopColor:"var(--dg-purple)",stopOpacity:.3}),s.jsx("stop",{"code-path":"src/components/dashboard/DashboardCharts.tsx:328:19",offset:"95%",stopColor:"var(--dg-purple)",stopOpacity:0})]})]}),s.jsx(xt,{"code-path":"src/components/dashboard/DashboardCharts.tsx:331:15",strokeDasharray:"3 3",stroke:"var(--chart-grid)"}),s.jsx(Le,{"code-path":"src/components/dashboard/DashboardCharts.tsx:332:15",dataKey:"time",stroke:"var(--chart-axis)",fontSize:12,tickLine:!1,axisLine:!1}),s.jsx(Ie,{"code-path":"src/components/dashboard/DashboardCharts.tsx:333:15",stroke:"var(--chart-axis)",fontSize:12,tickLine:!1,axisLine:!1,unit:"%"}),s.jsx(Ae,{"code-path":"src/components/dashboard/DashboardCharts.tsx:334:15",content:s.jsx(_e,{"code-path":"src/components/dashboard/DashboardCharts.tsx:334:33"})}),s.jsx(Ne,{"code-path":"src/components/dashboard/DashboardCharts.tsx:335:15",type:"monotone",dataKey:"cpu",stroke:"var(--dg-blue)",fillOpacity:1,fill:"url(#colorCpu)",strokeWidth:2,name:"CPU"}),s.jsx(Ne,{"code-path":"src/components/dashboard/DashboardCharts.tsx:336:15",type:"monotone",dataKey:"memory",stroke:"var(--dg-green)",fillOpacity:1,fill:"url(#colorMemory)",strokeWidth:2,name:"内存"}),s.jsx(Ne,{"code-path":"src/components/dashboard/DashboardCharts.tsx:337:15",type:"monotone",dataKey:"disk",stroke:"var(--dg-purple)",fillOpacity:1,fill:"url(#colorDisk)",strokeWidth:2,name:"磁盘"})]})})})})]})}function qa({severity:t}){return s.jsx("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:31:5",className:u("w-2 h-2 rounded-full flex-shrink-0 mt-1.5",t==="critical"&&"bg-[var(--dg-red)]",t==="warning"&&"bg-[var(--dg-yellow)]",t==="info"&&"bg-[var(--dg-blue)]")})}function Wa({severity:t}){return s.jsx(L,{"code-path":"src/components/dashboard/DashboardRecent.tsx:45:5",variant:"outline",className:u("text-xs font-medium",t==="critical"&&"dg-badge-red border",t==="warning"&&"dg-badge-yellow border",t==="info"&&"dg-badge-blue border"),children:t==="critical"?"严重":t==="warning"?"警告":"提示"})}function Ha({alerts:t}){const a=ie(),r=t.filter(e=>e.status==="firing").slice(0,8);return s.jsxs(B,{"code-path":"src/components/dashboard/DashboardRecent.tsx:64:5",className:"dg-card dg-card-hover",children:[s.jsx(U,{"code-path":"src/components/dashboard/DashboardRecent.tsx:65:7",className:"pb-2",children:s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:66:9",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:67:11",children:[s.jsx(z,{"code-path":"src/components/dashboard/DashboardRecent.tsx:68:13",className:"text-[var(--dg-text-primary)]",children:"告警消息"}),s.jsx(V,{"code-path":"src/components/dashboard/DashboardRecent.tsx:69:13",className:"text-[var(--dg-text-muted)]",children:"最近触发的告警事件"})]}),s.jsxs(se,{"code-path":"src/components/dashboard/DashboardRecent.tsx:71:11",variant:"ghost",size:"sm",className:"dg-btn-ghost text-xs",onClick:()=>a("/alerts"),children:["查看全部",s.jsx(le,{"code-path":"src/components/dashboard/DashboardRecent.tsx:78:13",className:"h-3.5 w-3.5 ml-1"})]})]})}),s.jsx(q,{"code-path":"src/components/dashboard/DashboardRecent.tsx:82:7",children:s.jsx(rt,{"code-path":"src/components/dashboard/DashboardRecent.tsx:83:9",className:"h-[320px] scrollbar-thin",children:r.length===0?s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:85:13",className:"flex flex-col items-center justify-center py-12 text-[var(--dg-text-muted)]",children:[s.jsx(nt,{"code-path":"src/components/dashboard/DashboardRecent.tsx:86:15",className:"h-10 w-10 mb-3 opacity-30"}),s.jsx("p",{"code-path":"src/components/dashboard/DashboardRecent.tsx:87:15",className:"text-sm",children:"暂无告警事件"}),s.jsx("p",{"code-path":"src/components/dashboard/DashboardRecent.tsx:88:15",className:"text-xs mt-1 opacity-60",children:"所有系统运行正常"})]}):s.jsx("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:91:13",className:"space-y-1.5 pr-2",children:r.map(e=>s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:93:17",className:"flex items-start gap-3 p-3 rounded-lg bg-[var(--dg-bg-tertiary)]/50 hover:bg-[var(--dg-bg-hover)] transition-all duration-200 cursor-pointer group",onClick:()=>a("/alert-center"),children:[s.jsx(qa,{"code-path":"src/components/dashboard/DashboardRecent.tsx:98:19",severity:e.severity||"info"}),s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:99:19",className:"flex-1 min-w-0",children:[s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:100:21",className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{"code-path":"src/components/dashboard/DashboardRecent.tsx:101:23",className:"text-sm font-medium text-[var(--dg-text-primary)] truncate",children:e.rule_name}),s.jsx(Wa,{"code-path":"src/components/dashboard/DashboardRecent.tsx:104:23",severity:e.severity||"info"})]}),s.jsx("p",{"code-path":"src/components/dashboard/DashboardRecent.tsx:106:21",className:"text-xs text-[var(--dg-text-muted)] mt-1",children:e.target}),s.jsx("p",{"code-path":"src/components/dashboard/DashboardRecent.tsx:107:21",className:"text-xs text-[var(--dg-text-muted)]/70 line-clamp-1",children:e.message})]}),s.jsx("span",{"code-path":"src/components/dashboard/DashboardRecent.tsx:109:19",className:"text-[11px] text-[var(--dg-text-muted)]/50 whitespace-nowrap flex-shrink-0",children:e.created_at?new Date(e.created_at).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):""})]},e.id))})})})]})}function Ga({expCerts:t}){const a=(t??[]).map(o=>({...o,daysUntilExpiry:o.days_until_expiry??Math.ceil((new Date(o.expire_date).getTime()-Date.now())/864e5)})).sort((o,n)=>o.daysUntilExpiry-n.daysUntilExpiry),r=a.filter(o=>o.daysUntilExpiry<30).length,e=a.filter(o=>o.daysUntilExpiry>=30&&o.daysUntilExpiry<60).length;return s.jsxs(B,{"code-path":"src/components/dashboard/DashboardRecent.tsx:134:5",className:"dg-card dg-card-hover",children:[s.jsx(U,{"code-path":"src/components/dashboard/DashboardRecent.tsx:135:7",className:"pb-2",children:s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:136:9",className:"flex items-center justify-between flex-wrap gap-2",children:[s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:137:11",children:[s.jsx(z,{"code-path":"src/components/dashboard/DashboardRecent.tsx:138:13",className:"text-[var(--dg-text-primary)]",children:"证书到期提醒"}),s.jsx(V,{"code-path":"src/components/dashboard/DashboardRecent.tsx:139:13",className:"text-[var(--dg-text-muted)]",children:"SSL证书到期时间监控"})]}),s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:141:11",className:"flex items-center gap-2",children:[r>0&&s.jsxs(L,{"code-path":"src/components/dashboard/DashboardRecent.tsx:143:15",className:"dg-badge-red border",children:[s.jsx(nt,{"code-path":"src/components/dashboard/DashboardRecent.tsx:144:17",className:"h-3 w-3 mr-1"}),r," 即将过期"]}),e>0&&s.jsxs(L,{"code-path":"src/components/dashboard/DashboardRecent.tsx:149:15",className:"dg-badge-yellow border",children:[e," 30天内过期"]})]})]})}),s.jsx(q,{"code-path":"src/components/dashboard/DashboardRecent.tsx:156:7",children:s.jsx(rt,{"code-path":"src/components/dashboard/DashboardRecent.tsx:157:9",className:"h-[280px] scrollbar-thin",children:a.length===0?s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:159:13",className:"flex flex-col items-center justify-center py-10 text-[var(--dg-text-muted)]",children:[s.jsx(Me,{"code-path":"src/components/dashboard/DashboardRecent.tsx:160:15",className:"h-10 w-10 mb-3 opacity-30"}),s.jsx("p",{"code-path":"src/components/dashboard/DashboardRecent.tsx:161:15",className:"text-sm",children:"暂无证书数据"})]}):s.jsx("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:164:13",className:"space-y-1.5 pr-2",children:a.map(o=>s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:166:17",className:"flex items-center justify-between p-3 rounded-lg bg-[var(--dg-bg-tertiary)]/50 hover:bg-[var(--dg-bg-hover)] transition-all duration-200",children:[s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:170:19",className:"flex items-center gap-3 min-w-0",children:[s.jsx("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:171:21",className:u("w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0",o.daysUntilExpiry<30?"bg-[var(--dg-red)]/10":o.daysUntilExpiry<60?"bg-[var(--dg-yellow)]/10":"bg-[var(--dg-green)]/10"),children:s.jsx(Me,{"code-path":"src/components/dashboard/DashboardRecent.tsx:179:23",className:u("h-4 w-4",o.daysUntilExpiry<30?"text-[var(--dg-red)]":o.daysUntilExpiry<60?"text-[var(--dg-yellow)]":"text-[var(--dg-green)]")})}),s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:186:21",className:"min-w-0",children:[s.jsx("p",{"code-path":"src/components/dashboard/DashboardRecent.tsx:187:23",className:"text-sm font-medium text-[var(--dg-text-primary)] truncate",children:o.name}),s.jsxs("p",{"code-path":"src/components/dashboard/DashboardRecent.tsx:188:23",className:"text-xs text-[var(--dg-text-muted)]",children:["到期: ",o.expire_date?.substring(0,10)]})]})]}),s.jsx(L,{"code-path":"src/components/dashboard/DashboardRecent.tsx:191:19",variant:"outline",className:u("text-xs flex-shrink-0",o.daysUntilExpiry<30?"dg-badge-red border":o.daysUntilExpiry<60?"dg-badge-yellow border":"dg-badge-green border"),children:o.daysUntilExpiry<0?"已过期":`${o.daysUntilExpiry} 天`})]},o.id))})})})]})}function Za({releases:t}){const a=ie(),r=t?.slice(0,5)??[];return s.jsxs(B,{"code-path":"src/components/dashboard/DashboardRecent.tsx:217:5",className:"dg-card dg-card-hover",children:[s.jsx(U,{"code-path":"src/components/dashboard/DashboardRecent.tsx:218:7",className:"pb-2",children:s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:219:9",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:220:11",children:[s.jsx(z,{"code-path":"src/components/dashboard/DashboardRecent.tsx:221:13",className:"text-[var(--dg-text-primary)]",children:"发布历史"}),s.jsx(V,{"code-path":"src/components/dashboard/DashboardRecent.tsx:222:13",className:"text-[var(--dg-text-muted)]",children:"今日应用发布记录"})]}),s.jsxs(se,{"code-path":"src/components/dashboard/DashboardRecent.tsx:224:11",variant:"ghost",size:"sm",className:"dg-btn-ghost text-xs",onClick:()=>a("/pipelines"),children:["查看全部",s.jsx(le,{"code-path":"src/components/dashboard/DashboardRecent.tsx:231:13",className:"h-3.5 w-3.5 ml-1"})]})]})}),s.jsx(q,{"code-path":"src/components/dashboard/DashboardRecent.tsx:235:7",children:r.length===0?s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:237:11",className:"flex flex-col items-center justify-center py-10 text-[var(--dg-text-muted)]",children:[s.jsx(Ke,{"code-path":"src/components/dashboard/DashboardRecent.tsx:238:13",className:"h-10 w-10 mb-3 opacity-30"}),s.jsx("p",{"code-path":"src/components/dashboard/DashboardRecent.tsx:239:13",className:"text-sm",children:"暂无发布记录"})]}):s.jsx("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:242:11",className:"space-y-2",children:r.map(e=>s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:244:15",className:"flex items-center gap-3 p-3 rounded-lg bg-[var(--dg-bg-tertiary)]/50 hover:bg-[var(--dg-bg-hover)] transition-all duration-200",children:[s.jsx("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:248:17",className:u("w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0",e.status==="success"?"bg-[var(--dg-green)]/10":e.status==="failed"?"bg-[var(--dg-red)]/10":e.status==="deploying"?"bg-[var(--dg-blue)]/10":"bg-[var(--dg-yellow)]/10"),children:s.jsx(Ke,{"code-path":"src/components/dashboard/DashboardRecent.tsx:257:19",className:u("h-4 w-4",e.status==="success"?"text-[var(--dg-green)]":e.status==="failed"?"text-[var(--dg-red)]":e.status==="deploying"?"text-[var(--dg-blue)]":"text-[var(--dg-yellow)]")})}),s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:265:17",className:"flex-1 min-w-0",children:[s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:266:19",className:"flex items-center gap-2",children:[s.jsx("span",{"code-path":"src/components/dashboard/DashboardRecent.tsx:267:21",className:"text-sm font-medium text-[var(--dg-text-primary)] truncate",children:e.app_name}),s.jsx(L,{"code-path":"src/components/dashboard/DashboardRecent.tsx:268:21",variant:"outline",className:"text-xs border-[var(--dg-border)] text-[var(--dg-text-muted)] flex-shrink-0",children:e.version})]}),s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:272:19",className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{"code-path":"src/components/dashboard/DashboardRecent.tsx:273:21",className:"text-xs text-[var(--dg-text-muted)]",children:e.environment}),s.jsx("span",{"code-path":"src/components/dashboard/DashboardRecent.tsx:274:21",className:"text-xs text-[var(--dg-border)]",children:"·"}),s.jsx("span",{"code-path":"src/components/dashboard/DashboardRecent.tsx:275:21",className:"text-xs text-[var(--dg-text-muted)] truncate",children:e.commit_id})]})]}),s.jsx(L,{"code-path":"src/components/dashboard/DashboardRecent.tsx:278:17",variant:"outline",className:u("text-xs flex-shrink-0",e.status==="success"?"dg-badge-green border":e.status==="failed"?"dg-badge-red border":e.status==="deploying"?"dg-badge-blue border":"dg-badge-yellow border"),children:e.status==="success"?"成功":e.status==="failed"?"失败":e.status==="deploying"?"发布中":e.status==="rolled_back"?"已回滚":"构建中"})]},e.id))})})]})}function Xa({servers:t}){const a=ie(),r=t.filter(n=>n.status==="running").length,e=t.filter(n=>n.status==="stopped").length,o=t.filter(n=>n.status==="maintenance").length;return s.jsxs(B,{"code-path":"src/components/dashboard/DashboardRecent.tsx:309:5",className:"dg-card dg-card-hover",children:[s.jsx(U,{"code-path":"src/components/dashboard/DashboardRecent.tsx:310:7",className:"pb-2",children:s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:311:9",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:312:11",children:[s.jsx(z,{"code-path":"src/components/dashboard/DashboardRecent.tsx:313:13",className:"text-[var(--dg-text-primary)]",children:"服务器状态"}),s.jsx(V,{"code-path":"src/components/dashboard/DashboardRecent.tsx:314:13",className:"text-[var(--dg-text-muted)]",children:"服务器运行状态分布"})]}),s.jsxs(se,{"code-path":"src/components/dashboard/DashboardRecent.tsx:316:11",variant:"ghost",size:"sm",className:"dg-btn-ghost text-xs",onClick:()=>a("/servers"),children:["查看全部",s.jsx(le,{"code-path":"src/components/dashboard/DashboardRecent.tsx:323:13",className:"h-3.5 w-3.5 ml-1"})]})]})}),s.jsxs(q,{"code-path":"src/components/dashboard/DashboardRecent.tsx:327:7",children:[s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:329:9",className:"grid grid-cols-3 gap-3 mb-4",children:[s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:330:11",className:"text-center p-3 rounded-xl bg-[var(--dg-green)]/8 border border-[var(--dg-green)]/15",children:[s.jsx("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:331:13",className:"text-2xl font-bold text-[var(--dg-green)]",children:r}),s.jsx("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:332:13",className:"text-xs text-[var(--dg-text-muted)] mt-1",children:"运行中"})]}),s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:334:11",className:"text-center p-3 rounded-xl bg-[var(--dg-yellow)]/8 border border-[var(--dg-yellow)]/15",children:[s.jsx("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:335:13",className:"text-2xl font-bold text-[var(--dg-yellow)]",children:o}),s.jsx("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:336:13",className:"text-xs text-[var(--dg-text-muted)] mt-1",children:"维护中"})]}),s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:338:11",className:"text-center p-3 rounded-xl bg-[var(--dg-text-muted)]/8 border border-[var(--dg-border)]",children:[s.jsx("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:339:13",className:"text-2xl font-bold text-[var(--dg-text-muted)]",children:e}),s.jsx("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:340:13",className:"text-xs text-[var(--dg-text-muted)] mt-1",children:"已停止"})]})]}),s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:345:9",className:"space-y-1.5",children:[t.slice(0,4).map(n=>s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:347:13",className:"flex items-center gap-3 p-2.5 rounded-lg bg-[var(--dg-bg-tertiary)]/50 hover:bg-[var(--dg-bg-hover)] transition-all duration-200",children:[s.jsx(Pt,{"code-path":"src/components/dashboard/DashboardRecent.tsx:351:15",className:u("h-2.5 w-2.5 flex-shrink-0 fill-current",n.status==="running"?"text-[var(--dg-green)]":n.status==="maintenance"?"text-[var(--dg-yellow)]":"text-[var(--dg-text-muted)]")}),s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:359:15",className:"flex-1 min-w-0",children:[s.jsx("p",{"code-path":"src/components/dashboard/DashboardRecent.tsx:360:17",className:"text-sm text-[var(--dg-text-primary)] truncate",children:n.hostname}),s.jsx("p",{"code-path":"src/components/dashboard/DashboardRecent.tsx:361:17",className:"text-xs text-[var(--dg-text-muted)]",children:n.ip})]}),s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:363:15",className:"text-right flex-shrink-0",children:[s.jsxs("p",{"code-path":"src/components/dashboard/DashboardRecent.tsx:364:17",className:"text-xs text-[var(--dg-text-muted)]",children:["CPU ",s.jsxs("span",{"code-path":"src/components/dashboard/DashboardRecent.tsx:365:23",className:"text-[var(--dg-text-secondary)] font-medium",children:[Number(n.cpu_usage??0).toFixed(1),"%"]})]}),s.jsxs("p",{"code-path":"src/components/dashboard/DashboardRecent.tsx:367:17",className:"text-xs text-[var(--dg-text-muted)]",children:["内存 ",s.jsxs("span",{"code-path":"src/components/dashboard/DashboardRecent.tsx:368:22",className:"text-[var(--dg-text-secondary)] font-medium",children:[Number(n.memory_usage??0).toFixed(1),"%"]})]})]})]},n.id)),t.length===0&&s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:374:13",className:"flex flex-col items-center justify-center py-6 text-[var(--dg-text-muted)]",children:[s.jsx(ct,{"code-path":"src/components/dashboard/DashboardRecent.tsx:375:15",className:"h-8 w-8 mb-2 opacity-30"}),s.jsx("p",{"code-path":"src/components/dashboard/DashboardRecent.tsx:376:15",className:"text-sm",children:"暂无服务器"})]})]})]})]})}function Ya({clusters:t}){const a=ie();return s.jsxs(B,{"code-path":"src/components/dashboard/DashboardRecent.tsx:389:5",className:"dg-card dg-card-hover",children:[s.jsx(U,{"code-path":"src/components/dashboard/DashboardRecent.tsx:390:7",className:"pb-2",children:s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:391:9",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:392:11",children:[s.jsx(z,{"code-path":"src/components/dashboard/DashboardRecent.tsx:393:13",className:"text-[var(--dg-text-primary)]",children:"Kubernetes 集群"}),s.jsx(V,{"code-path":"src/components/dashboard/DashboardRecent.tsx:394:13",className:"text-[var(--dg-text-muted)]",children:"Kubernetes集群健康状态"})]}),s.jsxs(se,{"code-path":"src/components/dashboard/DashboardRecent.tsx:396:11",variant:"ghost",size:"sm",className:"dg-btn-ghost text-xs",onClick:()=>a("/kubernetes"),children:["查看全部",s.jsx(le,{"code-path":"src/components/dashboard/DashboardRecent.tsx:403:13",className:"h-3.5 w-3.5 ml-1"})]})]})}),s.jsx(q,{"code-path":"src/components/dashboard/DashboardRecent.tsx:407:7",children:t.length===0?s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:409:11",className:"flex flex-col items-center justify-center py-10 text-[var(--dg-text-muted)]",children:[s.jsx(Be,{"code-path":"src/components/dashboard/DashboardRecent.tsx:410:13",className:"h-10 w-10 mb-3 opacity-30"}),s.jsx("p",{"code-path":"src/components/dashboard/DashboardRecent.tsx:411:13",className:"text-sm",children:"暂无集群数据"})]}):s.jsx("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:414:11",className:"space-y-3",children:t.map(r=>{const e=Number(r.cpu_usage??0),o=Number(r.memory_usage??0);return s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:419:17",className:"p-3.5 rounded-xl bg-[var(--dg-bg-tertiary)]/50 hover:bg-[var(--dg-bg-hover)] transition-all duration-200 cursor-pointer",onClick:()=>a(`/kubernetes/${r.code||r.id}`),children:[s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:424:19",className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:425:21",className:"flex items-center gap-2.5",children:[s.jsx(Be,{"code-path":"src/components/dashboard/DashboardRecent.tsx:426:23",className:"h-4.5 w-4.5 text-[var(--dg-blue)]"}),s.jsx("span",{"code-path":"src/components/dashboard/DashboardRecent.tsx:427:23",className:"text-sm font-semibold text-[var(--dg-text-primary)]",children:r.name})]}),s.jsx(L,{"code-path":"src/components/dashboard/DashboardRecent.tsx:429:21",variant:"outline",className:u("text-xs",r.status==="healthy"?"dg-badge-green border":r.status==="warning"?"dg-badge-yellow border":"dg-badge-red border"),children:r.status==="healthy"?"健康":r.status==="warning"?"警告":"异常"})]}),s.jsx("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:441:19",className:"grid grid-cols-4 gap-2 text-center",children:[{label:"节点",value:r.node_count??0},{label:"Pod",value:r.pod_count??0},{label:"CPU",value:`${e.toFixed(1)}%`},{label:"内存",value:`${o.toFixed(1)}%`}].map(n=>s.jsxs("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:448:23",className:"p-1.5 rounded-lg bg-[var(--dg-bg-primary)]/50",children:[s.jsx("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:449:25",className:"text-sm font-semibold text-[var(--dg-text-primary)]",children:n.value}),s.jsx("div",{"code-path":"src/components/dashboard/DashboardRecent.tsx:450:25",className:"text-[10px] text-[var(--dg-text-muted)] mt-0.5",children:n.label})]},n.label))})]},r.id)})})})]})}function xe({variant:t="card",className:a}){const r="dg-skeleton";return t==="stat"?s.jsxs("div",{"code-path":"src/components/layout/SkeletonCard.tsx:22:7",className:u("dg-card p-6 space-y-4",a),children:[s.jsxs("div",{"code-path":"src/components/layout/SkeletonCard.tsx:23:9",className:"flex items-start justify-between",children:[s.jsxs("div",{"code-path":"src/components/layout/SkeletonCard.tsx:24:11",className:"space-y-3 flex-1",children:[s.jsx("div",{"code-path":"src/components/layout/SkeletonCard.tsx:25:13",className:u("h-4 w-24 rounded",r)}),s.jsx("div",{"code-path":"src/components/layout/SkeletonCard.tsx:26:13",className:u("h-8 w-16 rounded",r)})]}),s.jsx("div",{"code-path":"src/components/layout/SkeletonCard.tsx:28:11",className:u("h-10 w-10 rounded-lg",r)})]}),s.jsx("div",{"code-path":"src/components/layout/SkeletonCard.tsx:30:9",className:u("h-3 w-32 rounded",r)})]}):t==="chart"?s.jsxs("div",{"code-path":"src/components/layout/SkeletonCard.tsx:37:7",className:u("dg-card p-6 space-y-4",a),children:[s.jsxs("div",{"code-path":"src/components/layout/SkeletonCard.tsx:38:9",className:"space-y-2",children:[s.jsx("div",{"code-path":"src/components/layout/SkeletonCard.tsx:39:11",className:u("h-5 w-32 rounded",r)}),s.jsx("div",{"code-path":"src/components/layout/SkeletonCard.tsx:40:11",className:u("h-3 w-48 rounded",r)})]}),s.jsx("div",{"code-path":"src/components/layout/SkeletonCard.tsx:42:9",className:u("h-[200px] rounded-lg",r)})]}):t==="table"?s.jsxs("div",{"code-path":"src/components/layout/SkeletonCard.tsx:49:7",className:u("dg-card overflow-hidden",a),children:[s.jsxs("div",{"code-path":"src/components/layout/SkeletonCard.tsx:51:9",className:"flex items-center gap-4 p-4 border-b border-[var(--dg-border)]",children:[s.jsx("div",{"code-path":"src/components/layout/SkeletonCard.tsx:52:11",className:u("h-4 w-8 rounded",r)}),Array.from({length:6}).map((e,o)=>s.jsx("div",{"code-path":"src/components/layout/SkeletonCard.tsx:54:13",className:u("h-4 flex-1 rounded",r)},o))]}),Array.from({length:5}).map((e,o)=>s.jsxs("div",{"code-path":"src/components/layout/SkeletonCard.tsx:59:11",className:"flex items-center gap-4 p-4 border-b border-[var(--dg-border)] last:border-0",children:[s.jsx("div",{"code-path":"src/components/layout/SkeletonCard.tsx:60:13",className:u("h-4 w-8 rounded",r)}),Array.from({length:6}).map((n,c)=>s.jsx("div",{"code-path":"src/components/layout/SkeletonCard.tsx:62:15",className:u("h-4 flex-1 rounded",r)},c))]},o))]}):s.jsxs("div",{"code-path":"src/components/layout/SkeletonCard.tsx:72:5",className:u("dg-card p-6 space-y-4",a),children:[s.jsxs("div",{"code-path":"src/components/layout/SkeletonCard.tsx:73:7",className:"space-y-2",children:[s.jsx("div",{"code-path":"src/components/layout/SkeletonCard.tsx:74:9",className:u("h-5 w-40 rounded",r)}),s.jsx("div",{"code-path":"src/components/layout/SkeletonCard.tsx:75:9",className:u("h-3 w-56 rounded",r)})]}),s.jsx("div",{"code-path":"src/components/layout/SkeletonCard.tsx:77:7",className:"space-y-3",children:Array.from({length:4}).map((e,o)=>s.jsxs("div",{"code-path":"src/components/layout/SkeletonCard.tsx:79:11",className:"flex items-center gap-3",children:[s.jsx("div",{"code-path":"src/components/layout/SkeletonCard.tsx:80:13",className:u("h-8 w-8 rounded-lg",r)}),s.jsxs("div",{"code-path":"src/components/layout/SkeletonCard.tsx:81:13",className:"flex-1 space-y-2",children:[s.jsx("div",{"code-path":"src/components/layout/SkeletonCard.tsx:82:15",className:u("h-3 w-full rounded",r)}),s.jsx("div",{"code-path":"src/components/layout/SkeletonCard.tsx:83:15",className:u("h-3 w-2/3 rounded",r)})]})]},o))})]})}function Ja({count:t=4}){return s.jsx("div",{"code-path":"src/components/layout/SkeletonCard.tsx:97:5",className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:Array.from({length:t}).map((a,r)=>s.jsx(xe,{"code-path":"src/components/layout/SkeletonCard.tsx:99:9",variant:"stat"},r))})}function Qa(){return s.jsxs("div",{"code-path":"src/components/layout/SkeletonCard.tsx:110:5",className:"space-y-6",children:[s.jsxs("div",{"code-path":"src/components/layout/SkeletonCard.tsx:112:7",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/layout/SkeletonCard.tsx:113:9",className:"space-y-2",children:[s.jsx("div",{"code-path":"src/components/layout/SkeletonCard.tsx:114:11",className:"dg-skeleton h-7 w-24 rounded"}),s.jsx("div",{"code-path":"src/components/layout/SkeletonCard.tsx:115:11",className:"dg-skeleton h-4 w-48 rounded"})]}),s.jsx("div",{"code-path":"src/components/layout/SkeletonCard.tsx:117:9",className:"dg-skeleton h-9 w-20 rounded-lg"})]}),s.jsx(Ja,{"code-path":"src/components/layout/SkeletonCard.tsx:121:7",count:4}),s.jsx(xe,{"code-path":"src/components/layout/SkeletonCard.tsx:124:7",variant:"chart"}),s.jsxs("div",{"code-path":"src/components/layout/SkeletonCard.tsx:127:7",className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[s.jsx(xe,{"code-path":"src/components/layout/SkeletonCard.tsx:128:9",variant:"list"}),s.jsx(xe,{"code-path":"src/components/layout/SkeletonCard.tsx:129:9",variant:"list"})]})]})}function ls(){const t=ie(),[a,r]=A.useState(!0),[e,o]=A.useState(!1),[n,c]=A.useState(null),[d,l]=A.useState([]),[i,p]=A.useState([]),[x,b]=A.useState([]),[N,f]=A.useState([]),[h,v]=A.useState([]),[y,j]=A.useState([]),k=A.useCallback(async()=>{o(!0);try{const[D,M,O,W,H,E]=await Promise.all([he.getStats().catch(R=>(console.error("Failed to fetch dashboard stats:",R),null)),Ct.getServers({page:1,page_size:100}).catch(R=>(console.error("Failed to fetch servers:",R),null)),kt.getClusters().catch(R=>(console.error("Failed to fetch k8s clusters:",R),null)),he.getAlerts(10).catch(R=>(console.error("Failed to fetch dashboard alerts:",R),null)),he.getReleases(5).catch(R=>(console.error("Failed to fetch dashboard releases:",R),null)),he.getMetrics(6).catch(R=>(console.error("Failed to fetch metrics:",R),[]))]);c(D),l(M?.list??[]),p(O?.list??[]),b(Array.isArray(W)?W:[]),f(Array.isArray(H)?H:[]),v(D?.expiring_certs??[]),j(Array.isArray(E)?E:[])}catch(D){console.error("Failed to load dashboard data:",D)}finally{o(!1),r(!1)}},[]);if(A.useEffect(()=>{k();const D=setInterval(k,5e3);return()=>clearInterval(D)},[k]),a)return s.jsx(Qa,{"code-path":"src/components/dashboard/Dashboard.tsx:95:12"});const S=n?.server_stats,w=n?.kubernetes_stats,_=n?.alert_stats,F=n?.cost_stats;return s.jsxs("div",{"code-path":"src/components/dashboard/Dashboard.tsx:104:5",className:"dg-page",children:[s.jsxs("div",{"code-path":"src/components/dashboard/Dashboard.tsx:106:7",className:"dg-page-header",children:[s.jsxs("div",{"code-path":"src/components/dashboard/Dashboard.tsx:107:9",children:[s.jsx("h1",{"code-path":"src/components/dashboard/Dashboard.tsx:108:11",className:"dg-page-title",children:"仪表盘"}),s.jsxs("p",{"code-path":"src/components/dashboard/Dashboard.tsx:109:11",className:"dg-page-subtitle",children:["实时监控和运维概览 · 最后更新: ",new Date().toLocaleTimeString("zh-CN")]})]}),s.jsxs("div",{"code-path":"src/components/dashboard/Dashboard.tsx:111:9",className:"dg-page-actions",children:[s.jsxs(se,{"code-path":"src/components/dashboard/Dashboard.tsx:112:11",variant:"outline",className:"dg-btn-secondary",onClick:k,disabled:e,children:[s.jsx(_t,{"code-path":"src/components/dashboard/Dashboard.tsx:118:13",className:u("h-4 w-4",e&&"animate-spin")}),e?"刷新中":"刷新"]}),s.jsxs(se,{"code-path":"src/components/dashboard/Dashboard.tsx:121:11",className:"dg-btn-primary",onClick:()=>t("/servers"),children:[s.jsx(ct,{"code-path":"src/components/dashboard/Dashboard.tsx:125:13",className:"h-4 w-4"}),"服务器",s.jsx(le,{"code-path":"src/components/dashboard/Dashboard.tsx:127:13",className:"h-3.5 w-3.5"})]})]})]}),s.jsx("div",{"code-path":"src/components/dashboard/Dashboard.tsx:133:7",className:"animate-fade-in-delay-1",children:s.jsx(Rt,{"code-path":"src/components/dashboard/Dashboard.tsx:134:9",items:[{label:"服务器",value:S?.total??0,color:"blue"},{label:"运行中",value:S?.running??0,color:"emerald"},{label:"K8s 集群",value:w?.total??0,color:"purple"},{label:"健康集群",value:w?.healthy??0,color:"cyan"},{label:"告警",value:_?.firing??0,color:_?.firing>0?"red":"muted"},{label:"严重",value:_?.critical??0,color:"red"},{label:"本月成本",value:`¥${Number(F?.month_cost??0).toLocaleString()}`,color:"amber"}]})}),s.jsx("div",{"code-path":"src/components/dashboard/Dashboard.tsx:148:7",className:"animate-fade-in-delay-2",children:s.jsx(Va,{"code-path":"src/components/dashboard/Dashboard.tsx:149:9",avgCpu:Number(S?.avg_cpu??0),avgMemory:Number(S?.avg_memory??0),avgDisk:Number(S?.avg_disk??0),metrics:y})}),s.jsxs("div",{"code-path":"src/components/dashboard/Dashboard.tsx:158:7",className:"grid grid-cols-1 lg:grid-cols-2 gap-6 animate-fade-in-delay-3",children:[s.jsx(Ua,{"code-path":"src/components/dashboard/Dashboard.tsx:159:9",costStats:F}),s.jsx(za,{"code-path":"src/components/dashboard/Dashboard.tsx:160:9",topUsage:n?.top_resource_usage})]}),s.jsxs("div",{"code-path":"src/components/dashboard/Dashboard.tsx:164:7",className:"grid grid-cols-1 lg:grid-cols-2 gap-6 animate-fade-in-delay-3",children:[s.jsx(Ha,{"code-path":"src/components/dashboard/Dashboard.tsx:165:9",alerts:x}),s.jsx(Ga,{"code-path":"src/components/dashboard/Dashboard.tsx:166:9",expCerts:h})]}),s.jsxs("div",{"code-path":"src/components/dashboard/Dashboard.tsx:170:7",className:"grid grid-cols-1 lg:grid-cols-3 gap-6 animate-fade-in-delay-4",children:[s.jsx(Za,{"code-path":"src/components/dashboard/Dashboard.tsx:171:9",releases:N}),s.jsx(Xa,{"code-path":"src/components/dashboard/Dashboard.tsx:172:9",servers:d}),s.jsx(Ya,{"code-path":"src/components/dashboard/Dashboard.tsx:173:9",clusters:i})]})]})}export{ls as Dashboard}; diff --git a/backend/static/assets/DatasourcePage-DDZGHQYv.js b/backend/static/assets/DatasourcePage-DDZGHQYv.js deleted file mode 100644 index e8dbda5..0000000 --- a/backend/static/assets/DatasourcePage-DDZGHQYv.js +++ /dev/null @@ -1 +0,0 @@ -import{r as d,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{T as ye,a as Me,b as ce,c as ne}from"./tabs-D87nAyJR.js";import{J as we,t as n,D as ie,a as le,b as ue,c as pe,d as he,B as h,e as xe,f as ge}from"./index-Dungj95X.js";import{B as P}from"./badge-CGJlVD3L.js";import{C as se,b as Fe,c as Ze,a as ae}from"./card-BIfzBCEy.js";import{u as Ce,q as ke,b as Se}from"./unwrap-DPwG25JA.js";import{u as O}from"./useMutation-BkCR1EeO.js";import{p as q,z as T}from"./datasource-DsDBrwno.js";import{I as x}from"./input-CXoUQQLm.js";import{L as m}from"./label-CMpUoC87.js";import{S as j}from"./switch-Bxiq4EHp.js";import{S as W,a as X,b as Y,c as ee,d as A}from"./select-CiTqGGhE.js";import{D as L,G as be,j as De,O as z,Q as E,a6 as Te,P as B,X as Ae,l as qe,b as te,p as je,y as ze,a as ve,R as oe,aW as re,ag as Ee,K as $,aJ as _e,T as Ne,C as Le}from"./vendor-icons-DmqcWdzX.js";import"./index-5FEebgvX.js";function Ie(){return Ce({queryKey:ke.promDatasources(),queryFn:async()=>{const a=await q.list();return Se(a)},staleTime:3e4})}function fe(){const a=we(),o=()=>a.invalidateQueries({queryKey:["prom-datasources"]}),p=O({mutationFn:l=>q.create(l),onSuccess:o}),y=O({mutationFn:({id:l,data:t})=>q.update(l,t),onSuccess:o}),M=O({mutationFn:l=>q.delete(l),onSuccess:o}),w=O({mutationFn:l=>q.setDefault(l),onSuccess:o});return{createMutation:p,updateMutation:y,deleteMutation:M,setDefaultMutation:w,invalidate:o}}function Re(a){return{name:a.name,url:a.url,access:a.access||"server",http_method:a.http_method||"POST",basic_auth:a.basic_auth||!1,basic_auth_user:a.basic_auth_user||"",basic_auth_pass:a.basic_auth_pass||"",with_credentials:a.with_credentials||!1,tls_client_auth:a.tls_client_auth||!1,with_ca_cert:a.with_ca_cert||!1,ca_cert:a.ca_cert||"",skip_tls_verify:a.skip_tls_verify||!1,custom_headers_json:a.custom_headers||"",enable_alerting:a.enable_alerting!==!1,alertmanager_ds:a.alertmanager_ds||"",scrape_interval:a.scrape_interval||15,query_timeout:a.query_timeout||60,disable_metrics_lookup:a.disable_metrics_lookup||!1,custom_query_params:a.custom_query_params||"",is_default:a.is_default||!1}}function He(a){try{const o=JSON.parse(a||"[]");return Array.isArray(o)?o:[]}catch{return[]}}function Oe(a,o){return{name:a.name.trim(),url:a.url.trim(),access:a.access,http_method:a.http_method,basic_auth:a.basic_auth,basic_auth_user:a.basic_auth_user,basic_auth_pass:a.basic_auth_pass,with_credentials:a.with_credentials,tls_client_auth:a.tls_client_auth,with_ca_cert:a.with_ca_cert,ca_cert:a.ca_cert,skip_tls_verify:a.skip_tls_verify,custom_headers:JSON.stringify(o),enable_alerting:a.enable_alerting,alertmanager_ds:a.alertmanager_ds,scrape_interval:a.scrape_interval,query_timeout:a.query_timeout,disable_metrics_lookup:a.disable_metrics_lookup,custom_query_params:a.custom_query_params,is_default:a.is_default}}async function Pe(a){const o=await q.testConnection({url:a.url.trim(),basic_auth:a.basic_auth,basic_auth_user:a.basic_auth_user,basic_auth_pass:a.basic_auth_pass,skip_tls_verify:a.skip_tls_verify});return o?.data||o}async function Be(a){try{const o=await Pe({url:a.url,basic_auth:a.basic_auth,basic_auth_user:a.basic_auth_user,basic_auth_pass:a.basic_auth_pass,skip_tls_verify:a.skip_tls_verify});o?.success?n.success(`连接成功 · ${o.target_count||0} targets`):n.error(o?.message||"连接失败")}catch(o){const p=o instanceof Error?o.message:"测试失败";n.error(p)}}const me={name:"",url:"",access:"server",http_method:"POST",basic_auth:!1,basic_auth_user:"",basic_auth_pass:"",with_credentials:!1,tls_client_auth:!1,with_ca_cert:!1,ca_cert:"",skip_tls_verify:!1,custom_headers_json:"",enable_alerting:!0,alertmanager_ds:"",scrape_interval:15,query_timeout:60,disable_metrics_lookup:!1,custom_query_params:"",is_default:!1};function $e({open:a,onOpenChange:o,editingDs:p,sources:y}){const{createMutation:M,updateMutation:w}=fe(),l=p?.id??null,[t,F]=d.useState({...me}),[r,v]=d.useState([]),[N,Z]=d.useState(!1),[,C]=d.useState(!1),[c,f]=d.useState(!1),[S,I]=d.useState(!1),[R,k]=d.useState(!1),[b,_]=d.useState(null);d.useEffect(()=>{a&&(p?(F(Re(p)),v(He(p.custom_headers))):(F({...me}),v([])),_(null),Z(!1),C(!1),f(!1),I(!1))},[a,p]);const i=(s,u)=>{F(D=>({...D,[s]:u}))},U=()=>{v(s=>[...s,{header:"",value:""}])},g=s=>{v(u=>u.filter((D,K)=>K!==s))},H=(s,u,D)=>{v(K=>{const J=[...K];return J[s]={...J[s],[u]:D},J})},V=async()=>{if(!t.name.trim()){n.error("请输入数据源名称");return}if(!t.url.trim()){n.error("请输入 Prometheus URL");return}const s=Oe(t,r);try{l?(await w.mutateAsync({id:l,data:s}),n.success("数据源更新成功")):(await M.mutateAsync(s),n.success("数据源创建成功")),o(!1)}catch(u){const D=u instanceof Error?u.message:"操作失败";n.error(D)}},Q=async()=>{if(!t.url.trim()){n.error("请先输入 URL");return}k(!0),_(null);try{const s=await Pe({url:t.url,basic_auth:t.basic_auth,basic_auth_user:t.basic_auth_user,basic_auth_pass:t.basic_auth_pass,skip_tls_verify:t.skip_tls_verify});_(s)}catch(s){const u=s instanceof Error?s.message:"测试失败";_({success:!1,message:u})}finally{k(!1)}},G=M.isPending||w.isPending;return e.jsx(ie,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:147:5",open:a,onOpenChange:o,children:e.jsxs(le,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:148:7",className:"max-w-2xl max-h-[90vh] overflow-y-auto bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:[e.jsxs(ue,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:149:9",children:[e.jsxs(pe,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:150:11",className:"flex items-center gap-2 text-lg",children:[e.jsx(L,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:151:13",className:"w-5 h-5 text-orange-400"}),l?"编辑数据源":"添加数据源"]}),e.jsx(he,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:154:11",children:"Prometheus 数据源配置 · 参考 Grafana 数据源管理"})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:159:9",className:"space-y-5 py-2",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:161:11",className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:162:13",className:"space-y-2",children:[e.jsxs(m,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:163:15",htmlFor:"ds-name",className:"text-sm",children:["Name ",e.jsx("span",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:163:65",className:"text-red-400",children:"*"})]}),e.jsx(x,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:164:15",id:"ds-name",placeholder:"Prometheus 数据源名称",value:t.name,onChange:s=>i("name",s.target.value),className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"})]}),e.jsx("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:172:13",className:"flex items-end pb-2",children:e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:173:15",className:"flex items-center gap-3",children:[e.jsx(j,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:174:17",id:"ds-default",checked:t.is_default,onCheckedChange:s=>i("is_default",s)}),e.jsx(m,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:179:17",htmlFor:"ds-default",className:"text-sm cursor-pointer",children:"Default"})]})})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:185:11",className:"space-y-3 bg-[var(--dg-bg-tertiary)]/50 rounded-lg p-4 border border-[var(--dg-border)]/50",children:[e.jsxs("h4",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:186:13",className:"text-sm font-medium flex items-center gap-2 text-[var(--dg-text-primary)]",children:[e.jsx(be,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:187:15",className:"w-4 h-4"})," HTTP"]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:189:13",className:"space-y-2",children:[e.jsxs(m,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:190:15",htmlFor:"ds-url",className:"text-sm",children:["URL ",e.jsx("span",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:190:63",className:"text-red-400",children:"*"})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:191:15",className:"flex gap-2",children:[e.jsxs(W,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:192:17",value:t.access,onValueChange:s=>i("access",s),children:[e.jsx(X,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:193:19",className:"w-32 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-sm",children:e.jsx(Y,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:194:21"})}),e.jsxs(ee,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:196:19",children:[e.jsx(A,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:197:21",value:"server",children:"Server"}),e.jsx(A,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:198:21",value:"browser",children:"Browser"})]})]}),e.jsx(x,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:201:17",id:"ds-url",placeholder:"http://localhost:9090",value:t.url,onChange:s=>i("url",s.target.value),className:"flex-1 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] font-mono text-sm"})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:210:13",className:"text-xs text-[var(--dg-text-secondary)]",children:["Access: ",e.jsx("span",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:211:23",className:"text-[var(--dg-text-primary)]",children:t.access==="server"?"Server (default)":"Browser"})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:216:11",className:"border border-[var(--dg-border)]/50 rounded-lg overflow-hidden",children:[e.jsxs("button",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:217:13",type:"button",className:"w-full flex items-center justify-between px-4 py-3 bg-[var(--dg-bg-tertiary)]/30 hover:bg-[var(--dg-bg-tertiary)]/60 transition-colors",onClick:()=>Z(!N),children:[e.jsxs("span",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:222:15",className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(De,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:223:17",className:"w-4 h-4"})," Auth"]}),N?e.jsx(z,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:225:27",className:"w-4 h-4"}):e.jsx(E,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:225:63",className:"w-4 h-4"})]}),N&&e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:228:15",className:"p-4 space-y-4 border-t border-[var(--dg-border)]/50",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:229:17",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:230:19",className:"flex items-center gap-3",children:[e.jsx(j,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:231:21",id:"ds-basic-auth",checked:t.basic_auth,onCheckedChange:s=>i("basic_auth",s)}),e.jsx(m,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:236:21",htmlFor:"ds-basic-auth",className:"text-sm cursor-pointer",children:"Basic auth"})]}),t.basic_auth&&e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:239:21",className:"grid grid-cols-2 gap-3 ml-9",children:[e.jsx(x,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:240:23",placeholder:"用户名",value:t.basic_auth_user,onChange:s=>i("basic_auth_user",s.target.value),className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-sm"}),e.jsx(x,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:246:23",type:"password",placeholder:"密码",value:t.basic_auth_pass,onChange:s=>i("basic_auth_pass",s.target.value),className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-sm"})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:257:17",className:"flex items-center gap-3",children:[e.jsx(j,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:258:19",id:"ds-with-creds",checked:t.with_credentials,onCheckedChange:s=>i("with_credentials",s)}),e.jsx(m,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:263:19",htmlFor:"ds-with-creds",className:"text-sm cursor-pointer",children:"With Credentials"})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:266:17",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:267:19",className:"flex items-center gap-3",children:[e.jsx(j,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:268:21",id:"ds-tls-auth",checked:t.tls_client_auth,onCheckedChange:s=>i("tls_client_auth",s)}),e.jsx(m,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:273:21",htmlFor:"ds-tls-auth",className:"text-sm cursor-pointer",children:"TLS Client Auth"})]}),t.tls_client_auth&&e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:276:21",className:"ml-9 space-y-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:277:23",className:"flex items-center gap-3",children:[e.jsx(j,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:278:25",id:"ds-ca-cert",checked:t.with_ca_cert,onCheckedChange:s=>i("with_ca_cert",s)}),e.jsx(m,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:283:25",htmlFor:"ds-ca-cert",className:"text-sm cursor-pointer",children:"With CA Cert"})]}),t.with_ca_cert&&e.jsx("textarea",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:286:25",placeholder:"PEM 格式的 CA 证书内容...",value:t.ca_cert,onChange:s=>i("ca_cert",s.target.value),rows:4,className:"w-full bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] rounded-md p-3 text-xs font-mono text-[var(--dg-text-primary)] resize-y"})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:298:17",className:"flex items-center gap-3",children:[e.jsx(j,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:299:19",id:"ds-skip-tls",checked:t.skip_tls_verify,onCheckedChange:s=>i("skip_tls_verify",s)}),e.jsx(m,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:304:19",htmlFor:"ds-skip-tls",className:"text-sm cursor-pointer",children:"Skip TLS Verify"})]}),e.jsx("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:307:17",className:"text-xs text-[var(--dg-text-secondary)] italic",children:"Forward OAuth Identity"})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:315:11",className:"space-y-3 bg-[var(--dg-bg-tertiary)]/30 rounded-lg p-4 border border-[var(--dg-border)]/50",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:316:13",className:"flex items-center justify-between",children:[e.jsxs("h4",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:317:15",className:"text-sm font-medium flex items-center gap-2 text-[var(--dg-text-primary)]",children:[e.jsx(Te,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:318:17",className:"w-4 h-4"})," Custom HTTP Headers"]}),e.jsxs(h,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:320:15",variant:"outline",size:"sm",className:"h-7 text-xs",onClick:U,children:[e.jsx(B,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:321:17",className:"w-3 h-3 mr-1"})," Add header"]})]}),r.length===0?e.jsx("p",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:325:15",className:"text-xs text-[var(--dg-text-secondary)] italic",children:"暂无自定义 Header"}):e.jsx("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:327:15",className:"space-y-2",children:r.map((s,u)=>e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:329:19",className:"flex items-center gap-2",children:[e.jsx(x,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:330:21",placeholder:"Header",value:s.header,onChange:D=>H(u,"header",D.target.value),className:"flex-1 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-sm h-8"}),e.jsx(x,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:336:21",placeholder:"Value",value:s.value,onChange:D=>H(u,"value",D.target.value),className:"flex-1 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-sm h-8"}),e.jsx(h,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:342:21",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-red-400 hover:text-red-300",onClick:()=>g(u),children:e.jsx(Ae,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:346:23",className:"w-3.5 h-3.5"})})]},u))})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:355:11",className:"border border-[var(--dg-border)]/50 rounded-lg overflow-hidden",children:[e.jsxs("button",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:356:13",type:"button",className:"w-full flex items-center justify-between px-4 py-3 bg-[var(--dg-bg-tertiary)]/30 hover:bg-[var(--dg-bg-tertiary)]/60 transition-colors",onClick:()=>f(!c),children:[e.jsxs("span",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:361:15",className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(qe,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:362:17",className:"w-4 h-4"})," Alerting"]}),c?e.jsx(z,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:364:31",className:"w-4 h-4"}):e.jsx(E,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:364:67",className:"w-4 h-4"})]}),c&&e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:367:15",className:"p-4 space-y-4 border-t border-[var(--dg-border)]/50",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:368:17",className:"flex items-center gap-3",children:[e.jsx(j,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:369:19",id:"ds-enable-alerting",checked:t.enable_alerting,onCheckedChange:s=>i("enable_alerting",s)}),e.jsx(m,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:374:19",htmlFor:"ds-enable-alerting",className:"text-sm cursor-pointer",children:"Manage alerts via Alerting UI"})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:378:17",className:"space-y-2",children:[e.jsx(m,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:379:19",className:"text-sm text-[var(--dg-text-secondary)]",children:"Alertmanager data source"}),e.jsxs(W,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:380:19",value:t.alertmanager_ds,onValueChange:s=>i("alertmanager_ds",s),children:[e.jsx(X,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:381:21",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-sm",children:e.jsx(Y,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:382:23",placeholder:"Choose"})}),e.jsxs(ee,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:384:21",children:[e.jsx(A,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:385:23",value:"__none",children:"无"}),y.filter(s=>s.id!==l).map(s=>e.jsx(A,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:387:25",value:String(s.id),children:s.name},s.id))]})]})]})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:397:11",className:"grid grid-cols-2 gap-4 bg-[var(--dg-bg-tertiary)]/30 rounded-lg p-4 border border-[var(--dg-border)]/50",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:398:13",className:"space-y-2",children:[e.jsxs(m,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:399:15",className:"text-sm flex items-center gap-1.5",children:[e.jsx(te,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:400:17",className:"w-3.5 h-3.5"})," Scrape interval"]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:402:15",className:"flex items-center gap-2",children:[e.jsx(x,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:403:17",type:"number",min:1,value:t.scrape_interval,onChange:s=>i("scrape_interval",Number(s.target.value)),className:"w-20 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-sm text-center"}),e.jsx("span",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:410:17",className:"text-xs text-[var(--dg-text-secondary)]",children:"秒"})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:413:13",className:"space-y-2",children:[e.jsxs(m,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:414:15",className:"text-sm flex items-center gap-1.5",children:[e.jsx(te,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:415:17",className:"w-3.5 h-3.5"})," Query timeout"]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:417:15",className:"flex items-center gap-2",children:[e.jsx(x,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:418:17",type:"number",min:1,value:t.query_timeout,onChange:s=>i("query_timeout",Number(s.target.value)),className:"w-20 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-sm text-center"}),e.jsx("span",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:425:17",className:"text-xs text-[var(--dg-text-secondary)]",children:"秒"})]})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:431:11",className:"space-y-2",children:[e.jsx(m,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:432:13",className:"text-sm",children:"HTTP Method"}),e.jsxs(W,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:433:13",value:t.http_method,onValueChange:s=>i("http_method",s),children:[e.jsx(X,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:434:15",className:"w-32 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-sm",children:e.jsx(Y,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:435:17"})}),e.jsxs(ee,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:437:15",children:[e.jsx(A,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:438:17",value:"POST",children:"POST"}),e.jsx(A,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:439:17",value:"GET",children:"GET"})]})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:445:11",className:"border border-[var(--dg-border)]/50 rounded-lg overflow-hidden",children:[e.jsxs("button",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:446:13",type:"button",className:"w-full flex items-center justify-between px-4 py-3 bg-[var(--dg-bg-tertiary)]/30 hover:bg-[var(--dg-bg-tertiary)]/60 transition-colors",onClick:()=>I(!S),children:[e.jsxs("span",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:451:15",className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(je,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:452:17",className:"w-4 h-4"})," Misc"]}),S?e.jsx(z,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:454:27",className:"w-4 h-4"}):e.jsx(E,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:454:63",className:"w-4 h-4"})]}),S&&e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:457:15",className:"p-4 space-y-4 border-t border-[var(--dg-border)]/50",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:458:17",className:"flex items-center gap-3",children:[e.jsx(j,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:459:19",id:"ds-disable-lookup",checked:t.disable_metrics_lookup,onCheckedChange:s=>i("disable_metrics_lookup",s)}),e.jsx(m,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:464:19",htmlFor:"ds-disable-lookup",className:"text-sm cursor-pointer",children:"Disable metrics lookup"})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:468:17",className:"space-y-2",children:[e.jsx(m,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:469:19",className:"text-sm text-[var(--dg-text-secondary)]",children:"Custom query parameters"}),e.jsx(x,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:470:19",placeholder:'例: {"timeout": "30s"}',value:t.custom_query_params,onChange:s=>i("custom_query_params",s.target.value),className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-sm font-mono"})]})]})]}),b&&e.jsxs("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:483:13",className:`rounded-lg p-3 flex items-center gap-2 text-sm ${b.success?"bg-emerald-500/10 border border-emerald-500/30 text-emerald-400":"bg-red-500/10 border border-red-500/30 text-red-400"}`,children:[b.success?e.jsx(ze,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:489:19",className:"w-4 h-4 shrink-0"}):e.jsx(ve,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:490:19",className:"w-4 h-4 shrink-0"}),e.jsx("span",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:492:15",children:b.message}),b.target_count!==void 0&&e.jsxs(P,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:494:17",variant:"secondary",className:"ml-auto text-xs",children:[b.target_count," targets"]})]})]}),e.jsxs(xe,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:502:9",className:"flex items-center gap-2 pt-2 border-t border-[var(--dg-border)]/50",children:[e.jsxs(h,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:503:11",variant:"outline",onClick:Q,disabled:R||!t.url.trim(),className:"gap-2",children:[R?e.jsx(oe,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:510:15",className:"w-4 h-4 animate-spin"}):e.jsx(re,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:512:15",className:"w-4 h-4"}),"Save & test"]}),e.jsx("div",{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:516:11",className:"flex-1"}),e.jsx(h,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:517:11",variant:"ghost",onClick:()=>o(!1),children:"取消"}),e.jsx(h,{"code-path":"src/components/monitor/datasource/prometheus-ds/PromDsFormDialog.tsx:520:11",onClick:V,disabled:G,children:l?"更新":"保存"})]})]})})}function Ue(){const a=ge(),{data:o=[],isLoading:p,isError:y}=Ie(),{deleteMutation:M,setDefaultMutation:w}=fe(),[l,t]=d.useState(!1),[F,r]=d.useState(null);d.useEffect(()=>{y&&n.error("获取数据源列表失败")},[y]);const v=()=>{r(null),t(!0)},N=c=>{r(c),t(!0)},Z=async c=>{if(await a({title:"删除数据源",description:`确定删除数据源「${c.name}」吗?此操作不可撤销。`,variant:"destructive"}))try{await M.mutateAsync(c.id),n.success("已删除")}catch{n.error("删除失败")}},C=async c=>{try{await w.mutateAsync(c.id),n.success(`已将「${c.name}」设为默认数据源`)}catch{n.error("设置失败")}};return p?e.jsx("div",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:73:7",className:"flex items-center justify-center h-96",children:e.jsx(oe,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:74:9",className:"animate-spin w-8 h-8 text-[var(--dg-text-secondary)]"})}):e.jsxs("div",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:80:5",className:"p-6 space-y-6 max-w-7xl mx-auto",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:82:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:83:9",children:[e.jsx("h1",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:84:11",className:"text-2xl font-bold text-[var(--dg-text-primary)]",children:"数据源管理"}),e.jsx("p",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:85:11",className:"text-sm text-[var(--dg-text-secondary)] mt-1",children:"Prometheus 数据源配置,用于指标监控与监控大屏"})]}),e.jsxs(h,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:89:9",onClick:v,className:"gap-2",children:[e.jsx(B,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:90:11",className:"w-4 h-4"}),"添加数据源"]})]}),e.jsxs(se,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:96:7",className:"border-[var(--dg-border)] bg-[var(--dg-bg-secondary)]",children:[e.jsx(Fe,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:97:9",className:"pb-2",children:e.jsxs(Ze,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:98:11",className:"text-base flex items-center gap-2",children:[e.jsx(L,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:99:13",className:"w-4 h-4 text-blue-400"}),"已配置的数据源",e.jsx(P,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:101:13",variant:"secondary",className:"ml-2",children:o.length})]})}),e.jsx(ae,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:104:9",className:"p-0",children:o.length===0?e.jsxs("div",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:106:13",className:"py-12 text-center text-[var(--dg-text-secondary)]",children:[e.jsx(L,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:107:15",className:"w-12 h-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:108:15",className:"text-sm",children:"暂无数据源"}),e.jsx("p",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:109:15",className:"text-xs mt-1",children:"点击「添加数据源」开始配置"})]}):e.jsx("div",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:112:13",className:"overflow-x-auto",children:e.jsxs("table",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:113:15",className:"w-full",children:[e.jsx("thead",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:114:17",className:"border-b border-[var(--dg-border)]",children:e.jsxs("tr",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:115:19",className:"text-xs text-[var(--dg-text-secondary)]",children:[e.jsx("th",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:116:21",className:"text-left py-3 px-4 font-medium",children:"名称"}),e.jsx("th",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:117:21",className:"text-left py-3 px-4 font-medium",children:"URL"}),e.jsx("th",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:118:21",className:"text-left py-3 px-4 font-medium w-20",children:"默认"}),e.jsx("th",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:119:21",className:"text-left py-3 px-4 font-medium w-16",children:"状态"}),e.jsx("th",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:120:21",className:"text-right py-3 px-4 font-medium w-36",children:"操作"})]})}),e.jsx("tbody",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:123:17",children:o.map(c=>e.jsxs("tr",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:125:21",className:"border-b border-[var(--dg-border)]/50 hover:bg-[var(--dg-bg-tertiary)]/50 transition-colors",children:[e.jsx("td",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:129:23",className:"py-3 px-4",children:e.jsxs("div",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:130:25",className:"flex items-center gap-2",children:[e.jsx("img",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:131:27",src:"https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/prometheus.png",alt:"Prometheus",className:"w-5 h-5 rounded",onError:f=>{f.target.style.display="none"}}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:137:27",children:[e.jsx("span",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:138:29",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:c.name}),c.basic_auth&&e.jsx(Ee,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:139:47",className:"w-3 h-3 inline ml-1.5 text-amber-400"})]})]})}),e.jsx("td",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:143:23",className:"py-3 px-4",children:e.jsx("code",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:144:25",className:"text-xs text-blue-300 bg-slate-800/50 px-2 py-0.5 rounded max-w-[320px] block truncate",title:c.url,children:c.url})}),e.jsx("td",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:149:23",className:"py-3 px-4",children:c.is_default?e.jsxs(P,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:151:27",variant:"default",className:"bg-amber-500/15 text-amber-400 border-amber-500/30 text-xs",children:[e.jsx($,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:152:29",className:"w-3 h-3 mr-1"})," 默认"]}):e.jsx("span",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:155:27",className:"text-xs text-[var(--dg-text-secondary)]",children:"--"})}),e.jsx("td",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:158:23",className:"py-3 px-4",children:c.status===1?e.jsx(P,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:160:27",variant:"default",className:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30 text-xs",children:"启用"}):e.jsx(P,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:164:27",variant:"secondary",className:"text-xs",children:"禁用"})}),e.jsx("td",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:167:23",className:"py-3 px-4",children:e.jsxs("div",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:168:25",className:"flex items-center justify-end gap-1",children:[e.jsx(h,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:169:27",variant:"ghost",size:"sm",className:"h-8 px-2",onClick:()=>Be(c),title:"测试连接",children:e.jsx(re,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:175:29",className:"w-3.5 h-3.5"})}),!c.is_default&&e.jsx(h,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:178:29",variant:"ghost",size:"sm",className:"h-8 px-2 text-amber-400 hover:text-amber-300",onClick:()=>C(c),title:"设为默认",children:e.jsx($,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:184:31",className:"w-3.5 h-3.5"})}),e.jsx(h,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:187:27",variant:"ghost",size:"sm",className:"h-8 px-2",onClick:()=>N(c),children:e.jsx(_e,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:192:29",className:"w-3.5 h-3.5"})}),e.jsx(h,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:194:27",variant:"ghost",size:"sm",className:"h-8 px-2 text-red-400 hover:text-red-300",onClick:()=>Z(c),children:e.jsx(Ne,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:199:29",className:"w-3.5 h-3.5"})})]})})]},c.id))})]})})})]}),e.jsx($e,{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:212:7",open:l,onOpenChange:t,editingDs:F,sources:o})]})}const de={name:"",url:"",username:"",password:"",trends_after:0,trends_range:0,trends_cache_ttl:3600,trends_timeout:30,direct_db:!1,disable_acknowledges:!1,disable_data_alignment:!1,is_default:!1};function Ve(){const a=ge(),[o,p]=d.useState([]),[y,M]=d.useState(!0),[w,l]=d.useState(!1),[t,F]=d.useState(null),[r,v]=d.useState({...de}),[N,Z]=d.useState(!1),[C,c]=d.useState(!1),[f,S]=d.useState(!1),[I,R]=d.useState(!1),[k,b]=d.useState(null),_=d.useCallback(async()=>{try{const s=await T.list();p(s?.data||s||[])}catch{n.error("获取数据源列表失败")}finally{M(!1)}},[]);d.useEffect(()=>{_()},[_]);const i=()=>{F(null),v({...de}),b(null),Z(!1),c(!1),S(!1),l(!0)},U=s=>{F(s.id),v({name:s.name,url:s.url,username:s.username||"",password:s.password||"",trends_after:s.trends_after||0,trends_range:s.trends_range||0,trends_cache_ttl:s.trends_cache_ttl||3600,trends_timeout:s.trends_timeout||30,direct_db:s.direct_db||!1,disable_acknowledges:s.disable_acknowledges||!1,disable_data_alignment:s.disable_data_alignment||!1,is_default:s.is_default||!1}),b(null),l(!0)},g=(s,u)=>{v(D=>({...D,[s]:u}))},H=async()=>{if(!r.name.trim()){n.error("请输入数据源名称");return}if(!r.url.trim()){n.error("请输入 Zabbix API URL");return}if(!r.username.trim()){n.error("请输入用户名");return}if(!r.password.trim()){n.error("请输入密码");return}try{t?(await T.update(t,r),n.success("数据源已更新")):(await T.create(r),n.success("数据源已创建")),l(!1),_()}catch(s){n.error(s?.message||"操作失败")}},V=async s=>{if(await a({title:"删除数据源",description:`确定删除「${s.name}」?`,variant:"destructive"}))try{await T.delete(s.id),n.success("已删除"),_()}catch{n.error("删除失败")}},Q=async s=>{try{await T.setDefault(s.id),n.success(`已将「${s.name}」设为默认`),_()}catch{n.error("设置失败")}},G=async()=>{if(!r.url.trim()||!r.username.trim()){n.error("请填写 URL 和用户名");return}R(!0),b(null);try{const s=await T.testConnection({url:r.url.trim(),username:r.username.trim(),password:r.password||""}),u=s?.data||s;b(u)}catch(s){b({success:!1,message:s?.message||"测试失败"})}finally{R(!1)}};return y?e.jsx("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:184:7",className:"flex items-center justify-center h-96",children:e.jsx(oe,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:185:9",className:"animate-spin w-8 h-8 text-[var(--dg-text-secondary)]"})}):e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:191:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:192:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:193:9",children:[e.jsxs("h2",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:194:11",className:"text-lg font-semibold text-[var(--dg-text-primary)] flex items-center gap-2",children:[e.jsx("img",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:195:13",src:"https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/zabbix.png",className:"w-5 h-5 rounded",onError:s=>{s.target.style.display="none"}}),"Zabbix 数据源"]}),e.jsx("p",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:202:11",className:"text-xs text-[var(--dg-text-muted)]",children:"配置 Zabbix API 连接,获取主机监控数据"})]}),e.jsxs(h,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:204:9",onClick:i,size:"sm",children:[e.jsx(B,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:205:11",className:"w-4 h-4 mr-1"}),"添加"]})]}),o.length===0?e.jsx(se,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:210:9",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(ae,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:211:11",className:"py-12 text-center text-[var(--dg-text-muted)]",children:[e.jsx(L,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:212:13",className:"w-12 h-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:213:13",className:"text-sm",children:"暂无 Zabbix 数据源"}),e.jsxs(h,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:214:13",size:"sm",className:"mt-4",onClick:i,children:[e.jsx(B,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:215:15",className:"w-4 h-4 mr-1"}),"添加数据源"]})]})}):e.jsx("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:220:9",className:"grid gap-3",children:o.map(s=>e.jsx(se,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:222:13",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] hover:border-orange-500/30 transition-colors",children:e.jsx(ae,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:223:15",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:224:17",className:"flex items-start justify-between",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:225:19",className:"flex-1 min-w-0",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:226:21",className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:227:23",className:`w-2 h-2 rounded-full ${s.status===1?"bg-emerald-400":"bg-slate-500"}`}),e.jsx("span",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:228:23",className:"font-medium text-[var(--dg-text-primary)]",children:s.name}),s.is_default&&e.jsxs(P,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:229:41",className:"bg-amber-500/20 text-amber-400 text-[10px]",children:[e.jsx($,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:229:103",className:"w-3 h-3 mr-0.5"}),"默认"]}),s.status===1?e.jsx(P,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:231:27",className:"bg-emerald-500/20 text-emerald-400 text-[10px]",children:"启用"}):e.jsx(P,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:232:27",className:"bg-slate-500/20 text-slate-400 text-[10px]",children:"禁用"})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:234:21",className:"text-xs text-[var(--dg-text-muted)] space-x-3",children:[e.jsx("code",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:235:23",className:"text-orange-300",children:s.url}),e.jsxs("span",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:236:23",children:["用户: ",s.username]}),s.direct_db&&e.jsx(P,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:237:40",variant:"outline",className:"text-[10px]",children:"直连DB"})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:240:19",className:"flex items-center gap-1",children:[!s.is_default&&e.jsxs(h,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:242:23",variant:"ghost",size:"sm",className:"h-7 text-xs text-amber-400",onClick:()=>Q(s),children:[e.jsx($,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:243:25",className:"w-3 h-3 mr-0.5"}),"默认"]}),e.jsxs(h,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:246:21",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>U(s),children:[e.jsx(_e,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:247:23",className:"w-3 h-3 mr-0.5"}),"编辑"]}),e.jsx(h,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:249:21",variant:"ghost",size:"sm",className:"h-7 text-xs text-red-400",onClick:()=>V(s),children:e.jsx(Ne,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:250:23",className:"w-3 h-3"})})]})]})})},s.id))}),e.jsx(ie,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:261:7",open:w,onOpenChange:l,children:e.jsxs(le,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:262:9",className:"max-w-xl max-h-[85vh] overflow-y-auto bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:[e.jsxs(ue,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:263:11",children:[e.jsxs(pe,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:264:13",className:"text-[var(--dg-text-primary)] flex items-center gap-2",children:[e.jsx(L,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:265:15",className:"h-5 w-5 text-orange-400"}),t?"编辑 Zabbix 数据源":"新建 Zabbix 数据源"]}),e.jsx(he,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:268:13",children:"配置 Zabbix API 连接,用于主机监控与告警数据获取"})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:273:11",className:"space-y-4 py-2",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:275:13",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:276:15",children:[e.jsx(m,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:277:17",className:"text-xs text-[var(--dg-text-secondary)]",children:"名称 *"}),e.jsx(x,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:278:17",className:"mt-1 h-9 text-sm bg-[var(--dg-bg-primary)]",placeholder:"如:生产 Zabbix",value:r.name,onChange:s=>g("name",s.target.value)})]}),e.jsx("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:281:15",className:"flex items-end pb-1",children:e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:282:17",className:"flex items-center gap-2",children:[e.jsx(j,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:283:19",checked:r.is_default,onCheckedChange:s=>g("is_default",s)}),e.jsx(m,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:284:19",className:"text-xs cursor-pointer",children:"设为默认"})]})})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:290:13",className:"border border-[var(--dg-border)] rounded-lg p-3 space-y-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:291:15",className:"flex items-center gap-2 text-sm text-[var(--dg-text-primary)]",children:[e.jsx(be,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:292:17",className:"w-4 h-4"})," HTTP"]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:294:15",children:[e.jsx(m,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:295:17",className:"text-xs text-[var(--dg-text-secondary)]",children:"URL *"}),e.jsx(x,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:296:17",className:"mt-1 h-9 text-sm font-mono bg-[var(--dg-bg-primary)]",placeholder:"http://zabbix.example.com/api_jsonrpc.php",value:r.url,onChange:s=>g("url",s.target.value)})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:303:13",className:"border border-[var(--dg-border)] rounded-lg overflow-hidden",children:[e.jsxs("button",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:304:15",className:"w-full flex items-center justify-between px-3 py-2.5 text-sm hover:bg-[var(--dg-bg-tertiary)]",onClick:()=>Z(!N),children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:306:17",className:"flex items-center gap-2",children:[e.jsx(De,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:307:19",className:"w-4 h-4"}),e.jsx("span",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:308:19",children:"Zabbix API 认证"})]}),N?e.jsx(z,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:310:29",className:"w-4 h-4"}):e.jsx(E,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:310:65",className:"w-4 h-4"})]}),N&&e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:313:17",className:"px-3 pb-3 space-y-3",children:[e.jsx(x,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:314:19",className:"h-9 text-sm bg-[var(--dg-bg-primary)]",placeholder:"用户名 *",value:r.username,onChange:s=>g("username",s.target.value)}),e.jsx(x,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:316:19",className:"h-9 text-sm bg-[var(--dg-bg-primary)]",type:"password",placeholder:"密码 *",value:r.password,onChange:s=>g("password",s.target.value)})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:323:13",className:"border border-[var(--dg-border)] rounded-lg overflow-hidden",children:[e.jsxs("button",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:324:15",className:"w-full flex items-center justify-between px-3 py-2.5 text-sm hover:bg-[var(--dg-bg-tertiary)]",onClick:()=>c(!C),children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:326:17",className:"flex items-center gap-2",children:[e.jsx(te,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:327:19",className:"w-4 h-4"}),e.jsx("span",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:328:19",children:"Trends 设置"})]}),C?e.jsx(z,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:330:31",className:"w-4 h-4"}):e.jsx(E,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:330:67",className:"w-4 h-4"})]}),C&&e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:333:17",className:"px-3 pb-3 space-y-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:334:19",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:335:21",children:[e.jsx(m,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:336:23",className:"text-xs text-[var(--dg-text-secondary)]",children:"After (天)"}),e.jsx(x,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:337:23",className:"mt-1 h-9 text-sm bg-[var(--dg-bg-primary)]",type:"number",min:0,value:r.trends_after,onChange:s=>g("trends_after",parseInt(s.target.value)||0)})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:340:21",children:[e.jsx(m,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:341:23",className:"text-xs text-[var(--dg-text-secondary)]",children:"Range (秒)"}),e.jsx(x,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:342:23",className:"mt-1 h-9 text-sm bg-[var(--dg-bg-primary)]",type:"number",min:0,value:r.trends_range,onChange:s=>g("trends_range",parseInt(s.target.value)||0)})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:346:19",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:347:21",children:[e.jsx(m,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:348:23",className:"text-xs text-[var(--dg-text-secondary)]",children:"Cache TTL (秒)"}),e.jsx(x,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:349:23",className:"mt-1 h-9 text-sm bg-[var(--dg-bg-primary)]",type:"number",min:0,value:r.trends_cache_ttl,onChange:s=>g("trends_cache_ttl",parseInt(s.target.value)||3600)})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:352:21",children:[e.jsx(m,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:353:23",className:"text-xs text-[var(--dg-text-secondary)]",children:"Timeout (秒)"}),e.jsx(x,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:354:23",className:"mt-1 h-9 text-sm bg-[var(--dg-bg-primary)]",type:"number",min:1,value:r.trends_timeout,onChange:s=>g("trends_timeout",parseInt(s.target.value)||30)})]})]})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:363:13",className:"border border-[var(--dg-border)] rounded-lg overflow-hidden",children:[e.jsxs("button",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:364:15",className:"w-full flex items-center justify-between px-3 py-2.5 text-sm hover:bg-[var(--dg-bg-tertiary)]",onClick:()=>S(!f),children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:366:17",className:"flex items-center gap-2",children:[e.jsx(je,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:367:19",className:"w-4 h-4"}),e.jsx("span",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:368:19",children:"其他设置"})]}),f?e.jsx(z,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:370:30",className:"w-4 h-4"}):e.jsx(E,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:370:66",className:"w-4 h-4"})]}),f&&e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:373:17",className:"px-3 pb-3 space-y-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:374:19",className:"flex items-center justify-between",children:[e.jsx(m,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:375:21",className:"text-xs",children:"Direct DB Connection"}),e.jsx(j,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:376:21",checked:r.direct_db,onCheckedChange:s=>g("direct_db",s)})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:378:19",className:"flex items-center justify-between",children:[e.jsx(m,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:379:21",className:"text-xs",children:"只读用户禁用确认"}),e.jsx(j,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:380:21",checked:r.disable_acknowledges,onCheckedChange:s=>g("disable_acknowledges",s)})]}),e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:382:19",className:"flex items-center justify-between",children:[e.jsx(m,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:383:21",className:"text-xs",children:"禁用数据对齐"}),e.jsx(j,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:384:21",checked:r.disable_data_alignment,onCheckedChange:s=>g("disable_data_alignment",s)})]})]})]}),k&&e.jsxs("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:392:15",className:`flex items-center gap-2 p-2.5 rounded text-sm ${k.success?"bg-emerald-500/10 text-emerald-400":"bg-red-500/10 text-red-400"}`,children:[k.success?e.jsx(Le,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:395:39",className:"h-4 w-4"}):e.jsx(ve,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:395:78",className:"h-4 w-4"}),k.message]})]}),e.jsxs(xe,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:401:11",className:"gap-2",children:[e.jsxs(h,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:402:13",variant:"outline",size:"sm",onClick:G,disabled:I,children:[e.jsx(re,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:403:15",className:`w-4 h-4 mr-1 ${I?"animate-pulse":""}`}),"测试连接"]}),e.jsx("div",{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:406:13",className:"flex-1"}),e.jsx(h,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:407:13",variant:"ghost",size:"sm",onClick:()=>l(!1),children:"取消"}),e.jsx(h,{"code-path":"src/components/monitor/datasource/ZabbixDatasourceManager.tsx:408:13",size:"sm",onClick:H,children:"保存"})]})]})})]})}function ns(){const[a,o]=d.useState("prometheus");return e.jsxs("div",{"code-path":"src/components/monitor/datasource/DatasourcePage.tsx:12:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/datasource/DatasourcePage.tsx:13:7",className:"flex items-center gap-2",children:[e.jsx(L,{"code-path":"src/components/monitor/datasource/DatasourcePage.tsx:14:9",className:"h-5 w-5 text-blue-400"}),e.jsx("h1",{"code-path":"src/components/monitor/datasource/DatasourcePage.tsx:15:9",className:"text-xl font-bold text-[var(--dg-text-primary)]",children:"数据源管理"})]}),e.jsxs(ye,{"code-path":"src/components/monitor/datasource/DatasourcePage.tsx:18:7",value:a,onValueChange:o,children:[e.jsxs(Me,{"code-path":"src/components/monitor/datasource/DatasourcePage.tsx:19:9",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:[e.jsxs(ce,{"code-path":"src/components/monitor/datasource/DatasourcePage.tsx:20:11",value:"prometheus",className:"data-[state=active]:bg-orange-500/10 data-[state=active]:text-orange-400",children:[e.jsx("img",{"code-path":"src/components/monitor/datasource/DatasourcePage.tsx:21:13",src:"https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/prometheus.png",className:"w-4 h-4 rounded mr-1.5",onError:p=>{p.target.style.display="none"}}),"Prometheus"]}),e.jsxs(ce,{"code-path":"src/components/monitor/datasource/DatasourcePage.tsx:28:11",value:"zabbix",className:"data-[state=active]:bg-orange-500/10 data-[state=active]:text-orange-400",children:[e.jsx("img",{"code-path":"src/components/monitor/datasource/DatasourcePage.tsx:29:13",src:"https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/zabbix.png",className:"w-4 h-4 rounded mr-1.5",onError:p=>{p.target.style.display="none"}}),"Zabbix"]})]}),e.jsx(ne,{"code-path":"src/components/monitor/datasource/DatasourcePage.tsx:38:9",value:"prometheus",className:"mt-4",children:e.jsx(Ue,{"code-path":"src/components/monitor/datasource/DatasourcePage.tsx:39:11"})}),e.jsx(ne,{"code-path":"src/components/monitor/datasource/DatasourcePage.tsx:41:9",value:"zabbix",className:"mt-4",children:e.jsx(Ve,{"code-path":"src/components/monitor/datasource/DatasourcePage.tsx:42:11"})})]})]})}export{ns as default}; diff --git a/backend/static/assets/DeployCredentials-Czv2LRln.js b/backend/static/assets/DeployCredentials-Czv2LRln.js deleted file mode 100644 index d4ca24f..0000000 --- a/backend/static/assets/DeployCredentials-Czv2LRln.js +++ /dev/null @@ -1 +0,0 @@ -import{r as o,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{D as A,a as H,b as J,c as K,e as te,B as d,t as r,d as oe,f as ae}from"./index-Dungj95X.js";import{I as z}from"./input-CXoUQQLm.js";import{B as w}from"./badge-CGJlVD3L.js";import{T as ne,a as le,b as O,c as B}from"./tabs-D87nAyJR.js";import{L as _}from"./label-CMpUoC87.js";import{S as M,a as Q,b as W,c as X,d as E}from"./select-CiTqGGhE.js";import{d as i}from"./config-BrfI0oO-.js";import{c as ce}from"./credential-Cu8tj7EE.js";import{G as Y,k as Z,ag as de,P as G,R as ee,L as k,y as re,a as pe,b as ie,v as I,Q as xe,al as me,J as ye,a6 as he,d as P,T as U}from"./vendor-icons-DmqcWdzX.js";import"./index-5FEebgvX.js";function ge({open:S,onOpenChange:b,type:L,editId:n,repos:h,registries:j,onSave:m}){const c=L==="repo",[g,u]=o.useState(""),[C,f]=o.useState(""),[p,v]=o.useState(""),[y,N]=o.useState(""),[D,T]=o.useState(""),[s,l]=o.useState([]),[x,V]=o.useState(!1),t=s.filter(a=>c?!0:a.secret_type==="docker"),F=async()=>{try{const a=await ce.list({page_size:100});l(a?.list||[])}catch{}};o.useEffect(()=>{if(F(),n)if(c){const a=h.find(R=>R.id===n);a&&(u(a.name),f(""),v(a.url),T(a.credential_id||""))}else{const a=j.find(R=>R.id===n);a&&(u(a.name),f(""),v(a.registry_url),N(a.namespace||""),T(a.credential_id||""))}else u(""),f(""),v(""),N(""),T("")},[n,S,c]);const $=async()=>{if(!g.trim()||!p.trim()){r.error("请填写名称和地址");return}V(!0);try{const a=D?Number(D):null,R=c?{name:g.trim(),description:C.trim(),url:p.trim(),credential_id:a}:{name:g.trim(),description:C.trim(),registry_url:p.trim(),namespace:y.trim(),credential_id:a};n?(c?await i.updateRepo(n,R):await i.updateRegistry(n,R),r.success("已更新")):(c?await i.createRepo(R):await i.createRegistry(R),r.success("已创建")),b(!1),m()}catch{r.error("保存失败")}finally{V(!1)}},se=c?Y:Z;return e.jsx(A,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:97:5",open:S,onOpenChange:b,children:e.jsxs(H,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:98:7",className:"sm:max-w-[480px] bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:[e.jsx(J,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:99:9",children:e.jsxs(K,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:100:11",className:"text-[var(--dg-text-primary)] flex items-center gap-2",children:[e.jsx(se,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:101:13",className:"h-5 w-5 text-[var(--dg-blue)]"}),n?"编辑":"新增",c?" Git 仓库":" 镜像仓库"]})}),e.jsxs("div",{"code-path":"src/components/deploy/CredentialFormDialog.tsx:105:9",className:"space-y-4 py-2",children:[e.jsxs("div",{"code-path":"src/components/deploy/CredentialFormDialog.tsx:106:11",className:"space-y-1",children:[e.jsx(_,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:106:38",children:"名称 *"}),e.jsx(z,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:107:13",value:g,onChange:a=>u(a.target.value),placeholder:c?"如:GitLab CE":"如:Harbor",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),e.jsxs("div",{"code-path":"src/components/deploy/CredentialFormDialog.tsx:108:11",className:"space-y-1",children:[e.jsx(_,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:108:38",children:c?"仓库 URL *":"Registry URL *"}),e.jsx(z,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:109:13",value:p,onChange:a=>v(a.target.value),placeholder:c?"http://10.10.10.72:9000/group/repo.git":"http://10.10.10.72",className:"font-mono text-sm bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),!c&&e.jsxs("div",{"code-path":"src/components/deploy/CredentialFormDialog.tsx:110:23",className:"space-y-1",children:[e.jsx(_,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:110:50",children:"默认命名空间"}),e.jsx(z,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:111:13",value:y,onChange:a=>N(a.target.value),placeholder:"如:aiops",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),e.jsxs("div",{"code-path":"src/components/deploy/CredentialFormDialog.tsx:114:11",className:"space-y-1",children:[e.jsxs(_,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:115:13",children:["关联凭证 ",e.jsx("span",{"code-path":"src/components/deploy/CredentialFormDialog.tsx:115:25",className:"text-xs text-[var(--dg-text-secondary)] opacity-70",children:"(认证由凭据管理统一配置)"})]}),e.jsxs(M,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:116:13",value:String(D),onValueChange:a=>T(a==="__none"?"":a),children:[e.jsx(Q,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:117:15",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",children:e.jsx(W,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:118:17",placeholder:c?"选择凭据(API/密码等)":"选择 Docker 密码凭据"})}),e.jsxs(X,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:120:15",children:[e.jsx(E,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:121:17",value:"__none",children:"不关联凭证"}),t.map(a=>e.jsx(E,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:123:19",value:String(a.id),children:e.jsxs("span",{"code-path":"src/components/deploy/CredentialFormDialog.tsx:124:21",className:"flex items-center gap-1.5",children:[e.jsx(de,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:125:23",className:"h-3 w-3 opacity-60"}),a.name," ",a.summary&&e.jsxs("span",{"code-path":"src/components/deploy/CredentialFormDialog.tsx:126:46",className:"text-[10px] opacity-50",children:["(",a.summary,")"]})]})},a.id))]})]}),t.length===0&&e.jsxs("p",{"code-path":"src/components/deploy/CredentialFormDialog.tsx:133:15",className:"text-xs text-amber-400 flex items-center gap-1 mt-1",children:[e.jsx(G,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:134:17",className:"h-3 w-3"}),"暂无",c?"":"Docker 密码","类型凭证,请在凭证配置页面新增"]})]})]}),e.jsxs(te,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:140:9",children:[e.jsx(d,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:141:11",variant:"outline",onClick:()=>b(!1),children:"取消"}),e.jsx(d,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:142:11",onClick:$,disabled:x,children:x?"保存中...":"保存"})]})]})})}const Ce={build:"构建",deploy:"部署",automation:"自动化",other:"其他"},q={build:"bg-amber-500/20 text-amber-400 border-amber-500/30",deploy:"bg-cyan-500/20 text-cyan-400 border-cyan-500/30",automation:"bg-purple-500/20 text-purple-400 border-purple-500/30",other:"bg-slate-500/20 text-slate-400 border-slate-500/30"},be=["jdk","nodejs","maven"];function je(){const[S,b]=o.useState([]),[L,n]=o.useState(!1),[h,j]=o.useState(null),[m,c]=o.useState(null),[g,u]=o.useState(""),[C,f]=o.useState(null),p=async()=>{n(!0);try{const s=await i.getTools();b(s?.list||[])}catch{r.error("获取工具配置失败")}finally{n(!1)}};o.useEffect(()=>{p()},[]);const v=async s=>{try{const x=(await i.getToolVersions(s.id))?.versions||[];if(x.length===0){y(s);return}c({tool:s,versions:x}),u(s.default_version||x[0]?.version||"")}catch{y(s)}},y=async(s,l)=>{j(s.id);try{const x=l||s.default_version;await i.installTool(s.id,x),r.success(`${s.display_name}${x?` (${x})`:""} 安装已触发`),c(null),setTimeout(async()=>{try{await i.checkTool(s.id),p()}catch{}j(null)},3e3)}catch{r.error("触发安装失败"),j(null)}},N=async s=>{try{const l=await i.checkTool(s.id);r.success(l?.available?`${s.display_name} 可用`:`${s.display_name} 不可用`),p()}catch{r.error("检测失败")}},D=async(s,l)=>{try{await i.updateTool(s.id,{install_method:l}),r.success("已更新"),p()}catch{r.error("更新失败")}},T=async s=>{f(s.id);const l=Date.now();try{const x=await i.getToolVersions(s.id),V=((Date.now()-l)/1e3).toFixed(1);x?.versions?.length>0?r.success(`${s.display_name} 镜像可访问 (${V}s)`):r(`${s.display_name} 无法获取版本列表`,{description:"请检查网络连接"})}catch{r.error(`${s.display_name} 网络不可达`)}f(null)};return e.jsxs("div",{"code-path":"src/components/deploy/ToolConfigTab.tsx:138:5",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/ToolConfigTab.tsx:139:7",className:"flex items-center justify-between",children:[e.jsx("p",{"code-path":"src/components/deploy/ToolConfigTab.tsx:140:9",className:"text-xs text-[var(--dg-text-secondary)]",children:"管理 DevOps 工具的安装策略:预装在镜像中、首次使用自动下载(懒加载)、或禁用不安装"}),e.jsxs(d,{"code-path":"src/components/deploy/ToolConfigTab.tsx:143:9",variant:"outline",size:"sm",onClick:p,children:[e.jsx(ee,{"code-path":"src/components/deploy/ToolConfigTab.tsx:144:11",className:"w-3.5 h-3.5 mr-1"}),"刷新"]})]}),L?e.jsxs("div",{"code-path":"src/components/deploy/ToolConfigTab.tsx:149:9",className:"text-center py-12 text-[var(--dg-text-secondary)]",children:[e.jsx(k,{"code-path":"src/components/deploy/ToolConfigTab.tsx:150:11",className:"w-5 h-5 animate-spin mx-auto mb-2"}),"加载中..."]}):S.length===0?e.jsx("div",{"code-path":"src/components/deploy/ToolConfigTab.tsx:153:9",className:"text-center py-12 text-[var(--dg-text-secondary)]",children:"暂无工具配置,请检查后端种子数据"}):e.jsx("div",{"code-path":"src/components/deploy/ToolConfigTab.tsx:157:9",className:"rounded-md border border-[var(--dg-border)] overflow-hidden",children:e.jsxs("table",{"code-path":"src/components/deploy/ToolConfigTab.tsx:158:11",className:"w-full text-sm",children:[e.jsx("thead",{"code-path":"src/components/deploy/ToolConfigTab.tsx:159:13",className:"bg-[var(--dg-bg-tertiary)] border-b border-[var(--dg-border)]",children:e.jsxs("tr",{"code-path":"src/components/deploy/ToolConfigTab.tsx:160:15",children:[e.jsx("th",{"code-path":"src/components/deploy/ToolConfigTab.tsx:161:17",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)]",children:"工具"}),e.jsx("th",{"code-path":"src/components/deploy/ToolConfigTab.tsx:162:17",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)] hidden sm:table-cell",children:"分类"}),e.jsx("th",{"code-path":"src/components/deploy/ToolConfigTab.tsx:163:17",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)]",children:"安装方式"}),e.jsx("th",{"code-path":"src/components/deploy/ToolConfigTab.tsx:164:17",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)]",children:"状态"}),e.jsx("th",{"code-path":"src/components/deploy/ToolConfigTab.tsx:165:17",className:"px-3 py-2 text-right font-medium text-[var(--dg-text-secondary)]",children:"操作"})]})}),e.jsx("tbody",{"code-path":"src/components/deploy/ToolConfigTab.tsx:168:13",children:S.map(s=>{const l=be.includes(s.name);return e.jsxs("tr",{"code-path":"src/components/deploy/ToolConfigTab.tsx:172:19",className:"border-b border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/50",children:[e.jsxs("td",{"code-path":"src/components/deploy/ToolConfigTab.tsx:173:21",className:"px-3 py-2",children:[e.jsx("div",{"code-path":"src/components/deploy/ToolConfigTab.tsx:174:23",className:"font-medium text-[var(--dg-text-primary)]",children:s.display_name}),e.jsx("div",{"code-path":"src/components/deploy/ToolConfigTab.tsx:175:23",className:"text-xs text-[var(--dg-text-secondary)] font-mono",children:s.name}),s.description&&e.jsx("div",{"code-path":"src/components/deploy/ToolConfigTab.tsx:177:25",className:"text-[10px] text-[var(--dg-text-muted)] mt-0.5 max-w-[220px] leading-tight",children:s.description}),s.installed_version&&s.status==="installed"&&e.jsxs("div",{"code-path":"src/components/deploy/ToolConfigTab.tsx:180:25",className:"text-xs text-emerald-400 font-mono mt-0.5",children:["v",s.installed_version]}),s.error_msg&&e.jsx("div",{"code-path":"src/components/deploy/ToolConfigTab.tsx:183:25",className:"text-xs text-red-400 mt-0.5 max-w-[200px] truncate",title:s.error_msg,children:s.error_msg})]}),e.jsx("td",{"code-path":"src/components/deploy/ToolConfigTab.tsx:186:21",className:"px-3 py-2 hidden sm:table-cell",children:e.jsx(w,{"code-path":"src/components/deploy/ToolConfigTab.tsx:187:23",className:`text-xs ${q[s.category]||q.other}`,children:Ce[s.category]||s.category})}),e.jsx("td",{"code-path":"src/components/deploy/ToolConfigTab.tsx:191:21",className:"px-3 py-2",children:e.jsxs(M,{"code-path":"src/components/deploy/ToolConfigTab.tsx:192:23",value:s.install_method,onValueChange:x=>D(s,x),children:[e.jsx(Q,{"code-path":"src/components/deploy/ToolConfigTab.tsx:196:25",className:"h-7 w-[90px] text-xs",children:e.jsx(W,{"code-path":"src/components/deploy/ToolConfigTab.tsx:197:27"})}),e.jsxs(X,{"code-path":"src/components/deploy/ToolConfigTab.tsx:199:25",children:[e.jsx(E,{"code-path":"src/components/deploy/ToolConfigTab.tsx:200:27",value:"preinstall",children:"预装"}),e.jsx(E,{"code-path":"src/components/deploy/ToolConfigTab.tsx:201:27",value:"lazy",children:"懒加载"}),e.jsx(E,{"code-path":"src/components/deploy/ToolConfigTab.tsx:202:27",value:"disabled",children:"禁用"})]})]})}),e.jsx("td",{"code-path":"src/components/deploy/ToolConfigTab.tsx:206:21",className:"px-3 py-2",children:s.status==="installed"?e.jsxs(w,{"code-path":"src/components/deploy/ToolConfigTab.tsx:208:25",className:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30 text-xs gap-1",children:[e.jsx(re,{"code-path":"src/components/deploy/ToolConfigTab.tsx:209:27",className:"w-3 h-3"}),"已安装"]}):s.status==="installing"?e.jsxs(w,{"code-path":"src/components/deploy/ToolConfigTab.tsx:212:25",className:"bg-amber-500/20 text-amber-400 border-amber-500/30 text-xs gap-1",children:[e.jsx(k,{"code-path":"src/components/deploy/ToolConfigTab.tsx:213:27",className:"w-3 h-3 animate-spin"}),"安装中"]}):s.status==="failed"?e.jsxs(w,{"code-path":"src/components/deploy/ToolConfigTab.tsx:216:25",className:"bg-red-500/20 text-red-400 border-red-500/30 text-xs gap-1",children:[e.jsx(pe,{"code-path":"src/components/deploy/ToolConfigTab.tsx:217:27",className:"w-3 h-3"}),"失败"]}):e.jsxs(w,{"code-path":"src/components/deploy/ToolConfigTab.tsx:220:25",className:"bg-slate-500/20 text-slate-400 border-slate-500/30 text-xs gap-1",children:[e.jsx(ie,{"code-path":"src/components/deploy/ToolConfigTab.tsx:221:27",className:"w-3 h-3"}),"未安装"]})}),e.jsx("td",{"code-path":"src/components/deploy/ToolConfigTab.tsx:225:21",className:"px-3 py-2 text-right",children:e.jsxs("div",{"code-path":"src/components/deploy/ToolConfigTab.tsx:226:23",className:"flex justify-end gap-1",children:[s.install_method==="lazy"&&s.status!=="installed"&&(l?e.jsxs(d,{"code-path":"src/components/deploy/ToolConfigTab.tsx:229:29",variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>v(s),disabled:h===s.id,children:[h===s.id?e.jsx(k,{"code-path":"src/components/deploy/ToolConfigTab.tsx:235:33",className:"w-3 h-3 animate-spin mr-1"}):e.jsx(I,{"code-path":"src/components/deploy/ToolConfigTab.tsx:237:33",className:"w-3 h-3 mr-1"}),"安装"]}):e.jsxs(d,{"code-path":"src/components/deploy/ToolConfigTab.tsx:242:29",variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>y(s),disabled:h===s.id,children:[h===s.id?e.jsx(k,{"code-path":"src/components/deploy/ToolConfigTab.tsx:248:33",className:"w-3 h-3 animate-spin mr-1"}):e.jsx(I,{"code-path":"src/components/deploy/ToolConfigTab.tsx:250:33",className:"w-3 h-3 mr-1"}),"安装"]})),s.install_method==="lazy"&&e.jsxs(d,{"code-path":"src/components/deploy/ToolConfigTab.tsx:257:27",variant:"ghost",size:"sm",className:"h-7 text-xs text-[var(--dg-text-secondary)]",onClick:()=>T(s),disabled:C===s.id,children:[C===s.id?e.jsx(k,{"code-path":"src/components/deploy/ToolConfigTab.tsx:263:31",className:"w-3 h-3 animate-spin mr-1"}):e.jsx(xe,{"code-path":"src/components/deploy/ToolConfigTab.tsx:265:31",className:"w-3 h-3 mr-1"}),"测试"]}),e.jsx(d,{"code-path":"src/components/deploy/ToolConfigTab.tsx:270:25",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>N(s),title:"检测",children:e.jsx(me,{"code-path":"src/components/deploy/ToolConfigTab.tsx:271:27",className:"w-3.5 h-3.5"})})]})})]},s.id)})})]})}),e.jsx(A,{"code-path":"src/components/deploy/ToolConfigTab.tsx:284:7",open:!!m,onOpenChange:()=>c(null),children:e.jsxs(H,{"code-path":"src/components/deploy/ToolConfigTab.tsx:285:9",className:"max-w-sm",children:[e.jsxs(J,{"code-path":"src/components/deploy/ToolConfigTab.tsx:286:11",children:[e.jsx(K,{"code-path":"src/components/deploy/ToolConfigTab.tsx:287:13",children:"选择安装版本"}),e.jsxs(oe,{"code-path":"src/components/deploy/ToolConfigTab.tsx:288:13",children:[m?.tool.display_name," — 请选择要安装的版本"]})]}),e.jsxs("div",{"code-path":"src/components/deploy/ToolConfigTab.tsx:292:11",className:"space-y-4 py-2",children:[e.jsx("div",{"code-path":"src/components/deploy/ToolConfigTab.tsx:293:13",className:"space-y-2",children:m?.versions.map((s,l)=>e.jsxs("button",{"code-path":"src/components/deploy/ToolConfigTab.tsx:295:17",onClick:()=>u(s.version),className:`w-full flex items-center justify-between px-3 py-2.5 rounded-lg text-sm border transition-all ${g===s.version?"border-indigo-400/50 bg-indigo-400/10 text-[var(--dg-text-primary)]":"border-[var(--dg-border)] bg-[var(--dg-bg-secondary)] text-[var(--dg-text-secondary)] hover:border-[var(--dg-text-secondary)]/30"}`,children:[e.jsx("span",{"code-path":"src/components/deploy/ToolConfigTab.tsx:304:19",children:s.label}),e.jsx("span",{"code-path":"src/components/deploy/ToolConfigTab.tsx:305:19",className:"text-xs font-mono text-[var(--dg-text-muted)]",children:s.version})]},s.version))}),e.jsxs("div",{"code-path":"src/components/deploy/ToolConfigTab.tsx:309:13",className:"flex justify-end gap-2 pt-2 border-t border-[var(--dg-border)]",children:[e.jsx(d,{"code-path":"src/components/deploy/ToolConfigTab.tsx:310:15",variant:"outline",size:"sm",onClick:()=>c(null),children:"取消"}),e.jsxs(d,{"code-path":"src/components/deploy/ToolConfigTab.tsx:311:15",size:"sm",onClick:()=>m&&y(m.tool,g),disabled:!g||h===m?.tool.id,children:[h===m?.tool.id?e.jsx(k,{"code-path":"src/components/deploy/ToolConfigTab.tsx:317:19",className:"w-3.5 h-3.5 animate-spin mr-1"}):e.jsx(I,{"code-path":"src/components/deploy/ToolConfigTab.tsx:319:19",className:"w-3.5 h-3.5 mr-1"}),"安装"]})]})]})]})})]})}function ue({open:S,onClose:b,onSaved:L,editData:n}){const[h,j]=o.useState(""),[m,c]=o.useState(""),[g,u]=o.useState("development"),[C,f]=o.useState("#3B82F6"),[p,v]=o.useState(""),[y,N]=o.useState(50),[D,T]=o.useState(!1);o.useEffect(()=>{n?(j(n.name),c(n.display_name),u(n.type),f(n.color),v(n.description||""),N(n.sort_order)):(j(""),c(""),u("development"),f("#3B82F6"),v(""),N(50))},[n,S]);const s=async()=>{if(!h.trim()||!m.trim()){r.error("请填写名称");return}T(!0);try{n?await i.updateEnvironment(n.id,{name:h,display_name:m,type:g,color:C,sort_order:y,description:p}):await i.createEnvironment({name:h,display_name:m,type:g,color:C,sort_order:y,description:p}),r.success(n?"已更新":"已创建"),L(),b()}catch{r.error("操作失败")}finally{T(!1)}};return e.jsx(A,{"code-path":"src/components/deploy/DeployCredentials.tsx:68:5",open:S,onOpenChange:b,children:e.jsxs(H,{"code-path":"src/components/deploy/DeployCredentials.tsx:69:7",children:[e.jsx(J,{"code-path":"src/components/deploy/DeployCredentials.tsx:70:9",children:e.jsx(K,{"code-path":"src/components/deploy/DeployCredentials.tsx:70:23",children:n?"编辑环境":"新增环境"})}),e.jsxs("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:71:9",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:72:11",className:"space-y-1",children:[e.jsx(_,{"code-path":"src/components/deploy/DeployCredentials.tsx:72:38",children:"环境标识"}),e.jsx(z,{"code-path":"src/components/deploy/DeployCredentials.tsx:72:57",value:h,onChange:l=>j(l.target.value),placeholder:"production"})]}),e.jsxs("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:73:11",className:"space-y-1",children:[e.jsx(_,{"code-path":"src/components/deploy/DeployCredentials.tsx:73:38",children:"显示名称"}),e.jsx(z,{"code-path":"src/components/deploy/DeployCredentials.tsx:73:57",value:m,onChange:l=>c(l.target.value),placeholder:"生产环境"})]}),e.jsxs("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:74:11",className:"space-y-1",children:[e.jsx(_,{"code-path":"src/components/deploy/DeployCredentials.tsx:74:38",children:"环境类型"}),e.jsxs(M,{"code-path":"src/components/deploy/DeployCredentials.tsx:75:13",value:g,onValueChange:u,children:[e.jsx(Q,{"code-path":"src/components/deploy/DeployCredentials.tsx:76:15",children:e.jsx(W,{"code-path":"src/components/deploy/DeployCredentials.tsx:76:30"})}),e.jsxs(X,{"code-path":"src/components/deploy/DeployCredentials.tsx:77:15",children:[e.jsx(E,{"code-path":"src/components/deploy/DeployCredentials.tsx:78:17",value:"production",children:"生产环境"}),e.jsx(E,{"code-path":"src/components/deploy/DeployCredentials.tsx:79:17",value:"staging",children:"预发布"}),e.jsx(E,{"code-path":"src/components/deploy/DeployCredentials.tsx:80:17",value:"testing",children:"测试环境"}),e.jsx(E,{"code-path":"src/components/deploy/DeployCredentials.tsx:81:17",value:"development",children:"开发环境"})]})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:85:11",className:"space-y-1",children:[e.jsx(_,{"code-path":"src/components/deploy/DeployCredentials.tsx:85:38",children:"标志颜色"}),e.jsx(z,{"code-path":"src/components/deploy/DeployCredentials.tsx:85:57",value:C,onChange:l=>f(l.target.value),type:"color",className:"w-16 h-9 p-1"})]}),e.jsxs("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:86:11",className:"space-y-1",children:[e.jsx(_,{"code-path":"src/components/deploy/DeployCredentials.tsx:86:38",children:"排序序号"}),e.jsx(z,{"code-path":"src/components/deploy/DeployCredentials.tsx:86:57",value:y,onChange:l=>N(Number(l.target.value)),type:"number"})]}),e.jsxs("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:87:11",className:"space-y-1",children:[e.jsx(_,{"code-path":"src/components/deploy/DeployCredentials.tsx:87:38",children:"描述"}),e.jsx(z,{"code-path":"src/components/deploy/DeployCredentials.tsx:87:55",value:p,onChange:l=>v(l.target.value),placeholder:"可选"})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:89:9",className:"flex justify-end gap-2 mt-4",children:[e.jsx(d,{"code-path":"src/components/deploy/DeployCredentials.tsx:90:11",variant:"outline",onClick:b,children:"取消"}),e.jsx(d,{"code-path":"src/components/deploy/DeployCredentials.tsx:91:11",onClick:s,disabled:D,children:D?"...":n?"保存":"创建"})]})]})})}function Re(){const S=ae(),[b,L]=o.useState([]),[n,h]=o.useState([]),[j,m]=o.useState([]),[c,g]=o.useState(!1),[u,C]=o.useState(!1),[f,p]=o.useState("repo"),[v,y]=o.useState(null),[N,D]=o.useState(!1),[T,s]=o.useState(null),l=async()=>{g(!0);try{const[t,F,$]=await Promise.all([i.getRepos(),i.getRegistries(),i.getEnvironments()]);L(t?.list||[]),h(F?.list||[]),m($?.list||[])}catch{r.error("获取数据失败")}finally{g(!1)}};o.useEffect(()=>{l()},[]);const x=async(t,F)=>{if(await S({title:"删除",description:`确定删除「${F.name||F.display_name}」?`,confirmText:"删除",variant:"destructive"}))try{t==="repo"?await i.deleteRepo(F.id):t==="registry"?await i.deleteRegistry(F.id):await i.deleteEnvironment(F.id),r.success("已删除"),l()}catch{r.error("删除失败")}},V={production:"生产",staging:"预发布",testing:"测试",development:"开发"};return e.jsxs("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:138:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:139:7",className:"flex items-center justify-between",children:[e.jsx("h2",{"code-path":"src/components/deploy/DeployCredentials.tsx:140:9",className:"text-lg font-semibold text-[var(--dg-text-primary)]",children:"发布配置管理"}),e.jsxs("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:141:9",className:"flex items-center gap-2",children:[e.jsxs(d,{"code-path":"src/components/deploy/DeployCredentials.tsx:142:11",variant:"outline",size:"sm",onClick:l,children:[e.jsx(ee,{"code-path":"src/components/deploy/DeployCredentials.tsx:142:66",className:"w-4 h-4 mr-1"}),"刷新"]}),e.jsxs(d,{"code-path":"src/components/deploy/DeployCredentials.tsx:143:11",size:"sm",onClick:()=>{p("repo"),y(null),C(!0)},children:[e.jsx(G,{"code-path":"src/components/deploy/DeployCredentials.tsx:144:13",className:"w-4 h-4 mr-1"}),"新增 Git 仓库"]}),e.jsxs(d,{"code-path":"src/components/deploy/DeployCredentials.tsx:146:11",size:"sm",variant:"secondary",onClick:()=>{p("registry"),y(null),C(!0)},children:[e.jsx(G,{"code-path":"src/components/deploy/DeployCredentials.tsx:147:13",className:"w-4 h-4 mr-1"}),"新增镜像仓库"]})]})]}),e.jsxs(ne,{"code-path":"src/components/deploy/DeployCredentials.tsx:152:7",defaultValue:"repos",children:[e.jsxs(le,{"code-path":"src/components/deploy/DeployCredentials.tsx:153:9",children:[e.jsxs(O,{"code-path":"src/components/deploy/DeployCredentials.tsx:154:11",value:"repos",className:"gap-1",children:[e.jsx(ye,{"code-path":"src/components/deploy/DeployCredentials.tsx:154:56",className:"w-4 h-4"}),"Git 仓库 (",b.length,")"]}),e.jsxs(O,{"code-path":"src/components/deploy/DeployCredentials.tsx:155:11",value:"registries",className:"gap-1",children:[e.jsx(Z,{"code-path":"src/components/deploy/DeployCredentials.tsx:155:61",className:"w-4 h-4"}),"镜像仓库 (",n.length,")"]}),e.jsxs(O,{"code-path":"src/components/deploy/DeployCredentials.tsx:156:11",value:"environments",className:"gap-1",children:[e.jsx(Y,{"code-path":"src/components/deploy/DeployCredentials.tsx:156:63",className:"w-4 h-4"}),"环境管理 (",j.length,")"]}),e.jsxs(O,{"code-path":"src/components/deploy/DeployCredentials.tsx:157:11",value:"tools",className:"gap-1",children:[e.jsx(he,{"code-path":"src/components/deploy/DeployCredentials.tsx:157:56",className:"w-4 h-4"}),"工具配置"]})]}),e.jsx(B,{"code-path":"src/components/deploy/DeployCredentials.tsx:160:9",value:"repos",className:"mt-3",children:c?e.jsxs("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:161:22",className:"text-center py-8 text-[var(--dg-text-secondary)]",children:[e.jsx(k,{"code-path":"src/components/deploy/DeployCredentials.tsx:161:88",className:"w-5 h-5 animate-spin mx-auto mb-2"}),"加载中..."]}):b.length===0?e.jsx("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:162:34",className:"text-center py-8 text-[var(--dg-text-secondary)]",children:"暂无 Git 仓库认证配置"}):e.jsx("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:164:13",className:"rounded-md border border-[var(--dg-border)] overflow-hidden",children:e.jsxs("table",{"code-path":"src/components/deploy/DeployCredentials.tsx:165:15",className:"w-full text-sm",children:[e.jsx("thead",{"code-path":"src/components/deploy/DeployCredentials.tsx:166:17",className:"bg-[var(--dg-bg-tertiary)] border-b border-[var(--dg-border)]",children:e.jsxs("tr",{"code-path":"src/components/deploy/DeployCredentials.tsx:167:19",children:[e.jsx("th",{"code-path":"src/components/deploy/DeployCredentials.tsx:168:21",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)]",children:"名称"}),e.jsx("th",{"code-path":"src/components/deploy/DeployCredentials.tsx:169:21",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)] hidden md:table-cell",children:"仓库 URL"}),e.jsx("th",{"code-path":"src/components/deploy/DeployCredentials.tsx:170:21",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)]",children:"认证方式"}),e.jsx("th",{"code-path":"src/components/deploy/DeployCredentials.tsx:171:21",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)]",children:"状态"}),e.jsx("th",{"code-path":"src/components/deploy/DeployCredentials.tsx:172:21",className:"px-3 py-2 text-right font-medium text-[var(--dg-text-secondary)]",children:"操作"})]})}),e.jsx("tbody",{"code-path":"src/components/deploy/DeployCredentials.tsx:175:17",children:b.map(t=>e.jsxs("tr",{"code-path":"src/components/deploy/DeployCredentials.tsx:177:21",className:"border-b border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/50",children:[e.jsx("td",{"code-path":"src/components/deploy/DeployCredentials.tsx:178:23",className:"px-3 py-2 font-medium text-[var(--dg-text-primary)]",children:t.name}),e.jsx("td",{"code-path":"src/components/deploy/DeployCredentials.tsx:179:23",className:"px-3 py-2 text-[var(--dg-text-secondary)] hidden md:table-cell font-mono text-xs max-w-[300px] truncate",children:t.url}),e.jsx("td",{"code-path":"src/components/deploy/DeployCredentials.tsx:180:23",className:"px-3 py-2",children:e.jsx(w,{"code-path":"src/components/deploy/DeployCredentials.tsx:180:49",variant:"outline",className:"text-xs",children:t.auth_type})}),e.jsx("td",{"code-path":"src/components/deploy/DeployCredentials.tsx:181:23",className:"px-3 py-2",children:e.jsx(w,{"code-path":"src/components/deploy/DeployCredentials.tsx:182:25",className:t.enabled?"bg-emerald-500/20 text-emerald-400 border-emerald-500/30":"bg-slate-500/20 text-slate-400 border-slate-500/30",children:t.enabled?"启用":"禁用"})}),e.jsx("td",{"code-path":"src/components/deploy/DeployCredentials.tsx:184:23",className:"px-3 py-2 text-right",children:e.jsxs("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:185:25",className:"flex justify-end gap-1",children:[e.jsx(d,{"code-path":"src/components/deploy/DeployCredentials.tsx:186:27",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{p("repo"),y(t.id),C(!0)},children:e.jsx(P,{"code-path":"src/components/deploy/DeployCredentials.tsx:186:165",className:"w-3.5 h-3.5"})}),e.jsx(d,{"code-path":"src/components/deploy/DeployCredentials.tsx:187:27",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-500",onClick:()=>x("repo",t),children:e.jsx(U,{"code-path":"src/components/deploy/DeployCredentials.tsx:187:136",className:"w-3.5 h-3.5"})})]})})]},t.id))})]})})}),e.jsx(B,{"code-path":"src/components/deploy/DeployCredentials.tsx:198:9",value:"registries",className:"mt-3",children:c?e.jsxs("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:199:22",className:"text-center py-8 text-[var(--dg-text-secondary)]",children:[e.jsx(k,{"code-path":"src/components/deploy/DeployCredentials.tsx:199:88",className:"w-5 h-5 animate-spin mx-auto mb-2"}),"加载中..."]}):n.length===0?e.jsx("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:200:39",className:"text-center py-8 text-[var(--dg-text-secondary)]",children:"暂无镜像仓库认证配置"}):e.jsx("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:202:13",className:"rounded-md border border-[var(--dg-border)] overflow-hidden",children:e.jsxs("table",{"code-path":"src/components/deploy/DeployCredentials.tsx:203:15",className:"w-full text-sm",children:[e.jsx("thead",{"code-path":"src/components/deploy/DeployCredentials.tsx:204:17",className:"bg-[var(--dg-bg-tertiary)] border-b border-[var(--dg-border)]",children:e.jsxs("tr",{"code-path":"src/components/deploy/DeployCredentials.tsx:205:19",children:[e.jsx("th",{"code-path":"src/components/deploy/DeployCredentials.tsx:206:21",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)]",children:"名称"}),e.jsx("th",{"code-path":"src/components/deploy/DeployCredentials.tsx:207:21",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)] hidden md:table-cell",children:"Registry URL"}),e.jsx("th",{"code-path":"src/components/deploy/DeployCredentials.tsx:208:21",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)] hidden sm:table-cell",children:"命名空间"}),e.jsx("th",{"code-path":"src/components/deploy/DeployCredentials.tsx:209:21",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)]",children:"认证"}),e.jsx("th",{"code-path":"src/components/deploy/DeployCredentials.tsx:210:21",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)]",children:"状态"}),e.jsx("th",{"code-path":"src/components/deploy/DeployCredentials.tsx:211:21",className:"px-3 py-2 text-right font-medium text-[var(--dg-text-secondary)]",children:"操作"})]})}),e.jsx("tbody",{"code-path":"src/components/deploy/DeployCredentials.tsx:214:17",children:n.map(t=>e.jsxs("tr",{"code-path":"src/components/deploy/DeployCredentials.tsx:216:21",className:"border-b border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/50",children:[e.jsx("td",{"code-path":"src/components/deploy/DeployCredentials.tsx:217:23",className:"px-3 py-2 font-medium text-[var(--dg-text-primary)]",children:t.name}),e.jsx("td",{"code-path":"src/components/deploy/DeployCredentials.tsx:218:23",className:"px-3 py-2 text-[var(--dg-text-secondary)] hidden md:table-cell font-mono text-xs max-w-[250px] truncate",children:t.registry_url}),e.jsx("td",{"code-path":"src/components/deploy/DeployCredentials.tsx:219:23",className:"px-3 py-2 text-[var(--dg-text-secondary)] hidden sm:table-cell",children:t.namespace||"-"}),e.jsx("td",{"code-path":"src/components/deploy/DeployCredentials.tsx:220:23",className:"px-3 py-2",children:e.jsx(w,{"code-path":"src/components/deploy/DeployCredentials.tsx:220:49",variant:"outline",className:"text-xs",children:t.auth_type})}),e.jsx("td",{"code-path":"src/components/deploy/DeployCredentials.tsx:221:23",className:"px-3 py-2",children:e.jsx(w,{"code-path":"src/components/deploy/DeployCredentials.tsx:222:25",className:t.enabled?"bg-emerald-500/20 text-emerald-400 border-emerald-500/30":"bg-slate-500/20 text-slate-400 border-slate-500/30",children:t.enabled?"启用":"禁用"})}),e.jsx("td",{"code-path":"src/components/deploy/DeployCredentials.tsx:224:23",className:"px-3 py-2 text-right",children:e.jsxs("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:225:25",className:"flex justify-end gap-1",children:[e.jsx(d,{"code-path":"src/components/deploy/DeployCredentials.tsx:226:27",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{p("registry"),y(t.id),C(!0)},children:e.jsx(P,{"code-path":"src/components/deploy/DeployCredentials.tsx:226:169",className:"w-3.5 h-3.5"})}),e.jsx(d,{"code-path":"src/components/deploy/DeployCredentials.tsx:227:27",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-500",onClick:()=>x("registry",t),children:e.jsx(U,{"code-path":"src/components/deploy/DeployCredentials.tsx:227:140",className:"w-3.5 h-3.5"})})]})})]},t.id))})]})})}),e.jsxs(B,{"code-path":"src/components/deploy/DeployCredentials.tsx:239:9",value:"environments",className:"mt-3",children:[e.jsx("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:240:11",className:"flex items-center justify-end mb-3",children:e.jsxs(d,{"code-path":"src/components/deploy/DeployCredentials.tsx:241:13",size:"sm",onClick:()=>{s(null),D(!0)},children:[e.jsx(G,{"code-path":"src/components/deploy/DeployCredentials.tsx:242:15",className:"w-4 h-4 mr-1"}),"新增环境"]})}),c?e.jsxs("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:245:22",className:"text-center py-8 text-[var(--dg-text-secondary)]",children:[e.jsx(k,{"code-path":"src/components/deploy/DeployCredentials.tsx:245:88",className:"w-5 h-5 animate-spin mx-auto mb-2"}),"加载中..."]}):j.length===0?e.jsx("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:246:41",className:"text-center py-8 text-[var(--dg-text-secondary)]",children:'暂无环境配置,点击"新增环境"创建'}):e.jsx("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:248:13",className:"rounded-md border border-[var(--dg-border)] overflow-hidden",children:e.jsxs("table",{"code-path":"src/components/deploy/DeployCredentials.tsx:249:15",className:"w-full text-sm",children:[e.jsx("thead",{"code-path":"src/components/deploy/DeployCredentials.tsx:250:17",className:"bg-[var(--dg-bg-tertiary)] border-b border-[var(--dg-border)]",children:e.jsxs("tr",{"code-path":"src/components/deploy/DeployCredentials.tsx:251:19",children:[e.jsx("th",{"code-path":"src/components/deploy/DeployCredentials.tsx:252:21",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)]",children:"环境标识"}),e.jsx("th",{"code-path":"src/components/deploy/DeployCredentials.tsx:253:21",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)]",children:"显示名称"}),e.jsx("th",{"code-path":"src/components/deploy/DeployCredentials.tsx:254:21",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)]",children:"类型"}),e.jsx("th",{"code-path":"src/components/deploy/DeployCredentials.tsx:255:21",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)]",children:"颜色"}),e.jsx("th",{"code-path":"src/components/deploy/DeployCredentials.tsx:256:21",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)]",children:"排序"}),e.jsx("th",{"code-path":"src/components/deploy/DeployCredentials.tsx:257:21",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)]",children:"状态"}),e.jsx("th",{"code-path":"src/components/deploy/DeployCredentials.tsx:258:21",className:"px-3 py-2 text-right font-medium text-[var(--dg-text-secondary)]",children:"操作"})]})}),e.jsx("tbody",{"code-path":"src/components/deploy/DeployCredentials.tsx:261:17",children:j.map(t=>e.jsxs("tr",{"code-path":"src/components/deploy/DeployCredentials.tsx:263:21",className:"border-b border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/50",children:[e.jsx("td",{"code-path":"src/components/deploy/DeployCredentials.tsx:264:23",className:"px-3 py-2 font-mono text-xs font-medium text-[var(--dg-text-primary)]",children:t.name}),e.jsx("td",{"code-path":"src/components/deploy/DeployCredentials.tsx:265:23",className:"px-3 py-2 text-[var(--dg-text-primary)]",children:e.jsxs("span",{"code-path":"src/components/deploy/DeployCredentials.tsx:266:25",className:"flex items-center gap-1.5",children:[e.jsx("span",{"code-path":"src/components/deploy/DeployCredentials.tsx:267:27",className:"w-2.5 h-2.5 rounded-full inline-block",style:{backgroundColor:t.color}}),t.display_name]})}),e.jsx("td",{"code-path":"src/components/deploy/DeployCredentials.tsx:271:23",className:"px-3 py-2",children:e.jsx(w,{"code-path":"src/components/deploy/DeployCredentials.tsx:271:49",variant:"secondary",className:"text-xs",children:V[t.type]||t.type})}),e.jsx("td",{"code-path":"src/components/deploy/DeployCredentials.tsx:272:23",className:"px-3 py-2",children:e.jsx("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:272:49",className:"w-6 h-6 rounded border",style:{backgroundColor:t.color}})}),e.jsx("td",{"code-path":"src/components/deploy/DeployCredentials.tsx:273:23",className:"px-3 py-2 text-[var(--dg-text-secondary)]",children:t.sort_order}),e.jsx("td",{"code-path":"src/components/deploy/DeployCredentials.tsx:274:23",className:"px-3 py-2",children:e.jsx(w,{"code-path":"src/components/deploy/DeployCredentials.tsx:275:25",className:t.enabled?"bg-emerald-500/20 text-emerald-400 border-emerald-500/30":"bg-slate-500/20 text-slate-400 border-slate-500/30",children:t.enabled?"启用":"禁用"})}),e.jsx("td",{"code-path":"src/components/deploy/DeployCredentials.tsx:277:23",className:"px-3 py-2 text-right",children:e.jsxs("div",{"code-path":"src/components/deploy/DeployCredentials.tsx:278:25",className:"flex justify-end gap-1",children:[e.jsx(d,{"code-path":"src/components/deploy/DeployCredentials.tsx:279:27",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{s(t),D(!0)},children:e.jsx(P,{"code-path":"src/components/deploy/DeployCredentials.tsx:279:144",className:"w-3.5 h-3.5"})}),e.jsx(d,{"code-path":"src/components/deploy/DeployCredentials.tsx:280:27",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-500",onClick:()=>x("env",t),children:e.jsx(U,{"code-path":"src/components/deploy/DeployCredentials.tsx:280:137",className:"w-3.5 h-3.5"})})]})})]},t.id))})]})})]}),e.jsx(B,{"code-path":"src/components/deploy/DeployCredentials.tsx:292:9",value:"tools",className:"mt-3",children:e.jsx(je,{"code-path":"src/components/deploy/DeployCredentials.tsx:293:11"})})]}),e.jsx(ge,{"code-path":"src/components/deploy/DeployCredentials.tsx:297:7",open:u,onOpenChange:C,type:f,editId:v,repos:b,registries:n,onSave:l}),e.jsx(ue,{"code-path":"src/components/deploy/DeployCredentials.tsx:302:7",open:N,onClose:()=>D(!1),onSaved:l,editData:T})]})}export{Re as default}; diff --git a/backend/static/assets/DeployRBAC-BpXCLjj-.js b/backend/static/assets/DeployRBAC-BpXCLjj-.js deleted file mode 100644 index 495c6ea..0000000 --- a/backend/static/assets/DeployRBAC-BpXCLjj-.js +++ /dev/null @@ -1 +0,0 @@ -import{r as o,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{C as D,a as g}from"./card-BIfzBCEy.js";import{f as Ne,B as a,u as ve,t as c}from"./index-Dungj95X.js";import{I as h}from"./input-CXoUQQLm.js";import{B as m}from"./badge-CGJlVD3L.js";import{S as N,a as v,b as f,c as w,d as r}from"./select-CiTqGGhE.js";import{L as i}from"./label-CMpUoC87.js";import{p as fe}from"./pipeline-DO4lDm_n.js";import{d as x}from"./config-BrfI0oO-.js";import{L as T,j as ae,P as le,J as b,a8 as pe,$ as ne,w as we,X as de,T as be,a3 as re,V as Se}from"./vendor-icons-DmqcWdzX.js";import"./index-5FEebgvX.js";function Je(){const[p,xe]=o.useState([]),[me,F]=o.useState(!0),[S,A]=o.useState(!1),[y,ie]=o.useState([]),[n,k]=o.useState(null),[J,ye]=o.useState([]),[I,_]=o.useState([]),[l,he]=o.useState(""),[j,M]=o.useState(""),[G,X]=o.useState(!1),[q,z]=o.useState(!1),[P,H]=o.useState(""),[E,K]=o.useState(""),[C,O]=o.useState(""),[Q,W]=o.useState("editor"),[Y,Z]=o.useState(""),[Ce,U]=o.useState(null),[$,ee]=o.useState(""),[se,te]=o.useState(""),Re=Ne(),R=async()=>{F(!0);try{const[s,t,d]=await Promise.all([x.getItemRoles(),fe.getPipelines({page_size:200}),ve.getUsers({page_size:500})]);xe(Array.isArray(s)?s:s?.list||s?.data||[]),ie(Array.isArray(t)?t:t?.list||t?.data||[]);const u=Array.isArray(d)?d:d?.list||d?.data||[];ye(u)}catch{}finally{F(!1)}};o.useEffect(()=>{R()},[]);const L=async()=>{if(!l){_([]);return}try{const s=await x.getUserItemRoles(Number(l));_(Array.isArray(s)?s:s?.data||s?.list||[])}catch{_([])}};o.useEffect(()=>{L()},[l]);const B=o.useMemo(()=>{const s={};return p.forEach(t=>{try{const d=new RegExp(t.pattern);s[t.id]=y.filter(u=>d.test(u.code)).map(u=>u.code)}catch{s[t.id]=[]}}),s},[p,y]),oe=(n?p.find(s=>s.id===n):null)?B[n]||[]:[],ue=async()=>{if(!P.trim()||!E.trim()||!C.trim()){c.error("名称、代码、正则表达式不能为空");return}A(!0);try{await x.createItemRole({name:P.trim(),code:E.trim(),pattern:C.trim(),role:Q,description:Y}),c.success("已创建"),z(!1),H(""),K(""),O(""),W("editor"),Z(""),R()}catch(s){c.error(s?.message||"创建失败")}finally{A(!1)}},Ae=async s=>{if(!$.trim()){c.error("正则不能为空");return}A(!0);try{await x.updateItemRole(s,{pattern:$,role:se}),c.success("已更新"),U(null),R()}catch(t){c.error(t?.message||"更新失败")}finally{A(!1)}},je=async s=>{if(await Re({title:"删除角色",description:`确定删除「${s.name}」?匹配 ${B[s.id]?.length||0} 条流水线`,variant:"destructive"}))try{await x.deleteItemRole(s.id),c.success("已删除"),R()}catch{c.error("删除失败")}},Be=async s=>{try{await x.updateItemRole(s.id,{status:s.status?0:1}),c.success(s.status?"已禁用":"已启用"),R()}catch{c.error("操作失败")}},De=async()=>{if(!l||!j){c.error("请选择用户和角色");return}X(!0);try{await x.assignItemRole(Number(l),{user_id:Number(l),item_role_id:Number(j)}),c.success("已分配"),M(""),L()}catch(s){c.error(s?.message||"分配失败")}finally{X(!1)}},ge=async s=>{try{await x.removeItemRole(Number(l),s),c.success("已撤销"),L()}catch{c.error("撤销失败")}},ce=s=>s==="owner"?"bg-amber-500/20 text-amber-400 border-amber-500/30":s==="editor"?"bg-blue-500/20 text-blue-400 border-blue-500/30":"bg-slate-500/20 text-slate-400 border-slate-500/30",V=J.find(s=>String(s.id)===l);return me?e.jsx("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:168:23",className:"flex items-center justify-center py-20",children:e.jsx(T,{"code-path":"src/components/deploy/DeployRBAC.tsx:168:79",className:"w-6 h-6 animate-spin"})}):e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:171:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:173:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:174:9",children:[e.jsxs("h1",{"code-path":"src/components/deploy/DeployRBAC.tsx:175:11",className:"text-xl font-bold flex items-center gap-2 text-[var(--dg-text-primary)]",children:[e.jsx(ae,{"code-path":"src/components/deploy/DeployRBAC.tsx:176:13",className:"w-5 h-5 text-purple-500"}),"发布权限"]}),e.jsx("p",{"code-path":"src/components/deploy/DeployRBAC.tsx:178:11",className:"text-sm text-[var(--dg-text-secondary)] mt-1",children:"Jenkins-style Role Strategy — 按流水线 code 正则匹配分配角色"})]}),e.jsxs(a,{"code-path":"src/components/deploy/DeployRBAC.tsx:182:9",onClick:()=>z(!0),disabled:q,children:[e.jsx(le,{"code-path":"src/components/deploy/DeployRBAC.tsx:183:11",className:"w-4 h-4 mr-1"}),"新建角色"]})]}),e.jsx(D,{"code-path":"src/components/deploy/DeployRBAC.tsx:188:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(g,{"code-path":"src/components/deploy/DeployRBAC.tsx:189:9",className:"p-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:190:11",className:"flex items-center gap-2 mb-3",children:[e.jsx(b,{"code-path":"src/components/deploy/DeployRBAC.tsx:191:13",className:"w-4 h-4 text-blue-500"}),e.jsx("span",{"code-path":"src/components/deploy/DeployRBAC.tsx:192:13",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:"流水线命中预览"}),e.jsx("span",{"code-path":"src/components/deploy/DeployRBAC.tsx:193:13",className:"text-xs text-[var(--dg-text-muted)]",children:"— 选择一个角色查看哪些流水线会被匹配"})]}),e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:195:11",className:"flex gap-2 mb-3 flex-wrap",children:[e.jsxs(a,{"code-path":"src/components/deploy/DeployRBAC.tsx:196:13",variant:n===null?"secondary":"ghost",size:"sm",onClick:()=>k(null),children:["全部 (",y.length,")"]}),p.map(s=>e.jsxs(a,{"code-path":"src/components/deploy/DeployRBAC.tsx:198:15",variant:n===s.id?"secondary":"ghost",size:"sm",onClick:()=>k(s.id),className:s.status===0?"opacity-40":"",children:[s.name," (",B[s.id]?.length||0,")"]},s.id))]}),e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:204:11",className:"flex flex-wrap gap-1.5 max-h-32 overflow-y-auto",children:[n===null?y.map(s=>e.jsxs(m,{"code-path":"src/components/deploy/DeployRBAC.tsx:206:36",variant:"secondary",className:"text-xs",children:[e.jsx(b,{"code-path":"src/components/deploy/DeployRBAC.tsx:206:94",className:"w-3 h-3 mr-0.5"}),s.code]},s.id)):y.map(s=>{const t=oe.includes(s.code);return e.jsxs(m,{"code-path":"src/components/deploy/DeployRBAC.tsx:210:21",variant:t?"default":"secondary",className:`text-xs ${t?"bg-purple-500/20 text-purple-300 border-purple-500/30":"opacity-30"}`,children:[e.jsx(b,{"code-path":"src/components/deploy/DeployRBAC.tsx:212:23",className:"w-3 h-3 mr-0.5"}),s.code]},s.id)}),n!==null&&oe.length===0&&e.jsx("span",{"code-path":"src/components/deploy/DeployRBAC.tsx:218:15",className:"text-xs text-red-400",children:"无匹配 — 请调整正则表达式"})]})]})}),q&&e.jsx(D,{"code-path":"src/components/deploy/DeployRBAC.tsx:226:9",className:"bg-[var(--dg-bg-secondary)] border-purple-500/20",children:e.jsxs(g,{"code-path":"src/components/deploy/DeployRBAC.tsx:227:11",className:"p-4 space-y-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:228:13",className:"flex items-center justify-between",children:[e.jsxs("span",{"code-path":"src/components/deploy/DeployRBAC.tsx:229:15",className:"text-sm font-medium text-[var(--dg-text-primary)] flex items-center gap-2",children:[e.jsx(le,{"code-path":"src/components/deploy/DeployRBAC.tsx:229:107",className:"w-4 h-4"}),"新建 Item Role"]}),e.jsx(a,{"code-path":"src/components/deploy/DeployRBAC.tsx:230:15",variant:"ghost",size:"sm",onClick:()=>z(!1),children:"取消"})]}),e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:232:13",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:233:15",className:"space-y-1",children:[e.jsx(i,{"code-path":"src/components/deploy/DeployRBAC.tsx:233:42",className:"text-xs",children:"名称"}),e.jsx(h,{"code-path":"src/components/deploy/DeployRBAC.tsx:233:79",value:P,onChange:s=>H(s.target.value),placeholder:"如: backend",className:"h-8 text-sm"})]}),e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:234:15",className:"space-y-1",children:[e.jsx(i,{"code-path":"src/components/deploy/DeployRBAC.tsx:234:42",className:"text-xs",children:"代码 (唯一标识)"}),e.jsx(h,{"code-path":"src/components/deploy/DeployRBAC.tsx:234:86",value:E,onChange:s=>K(s.target.value),placeholder:"如: backend",className:"h-8 text-sm font-mono"})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:236:13",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:237:15",className:"space-y-1",children:[e.jsxs(i,{"code-path":"src/components/deploy/DeployRBAC.tsx:238:17",className:"text-xs flex items-center gap-1",children:[e.jsx(pe,{"code-path":"src/components/deploy/DeployRBAC.tsx:238:68",className:"w-3 h-3"}),"正则匹配 Pattern"]}),e.jsx(h,{"code-path":"src/components/deploy/DeployRBAC.tsx:239:17",value:C,onChange:s=>{O(s.target.value)},placeholder:"如: ^cex-.*",className:"h-8 text-sm font-mono"}),C&&e.jsxs("p",{"code-path":"src/components/deploy/DeployRBAC.tsx:241:19",className:"text-xs text-[var(--dg-text-muted)]",children:["实时匹配: ",(()=>{try{const s=y.filter(t=>new RegExp(C).test(t.code)).length;return s>0?`✅ 命中 ${s} 条流水线`:"⚠️ 无匹配"}catch{return"❌ 正则语法错误"}})()]})]}),e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:246:15",className:"space-y-1",children:[e.jsx(i,{"code-path":"src/components/deploy/DeployRBAC.tsx:247:17",className:"text-xs",children:"角色"}),e.jsxs(N,{"code-path":"src/components/deploy/DeployRBAC.tsx:248:17",value:Q,onValueChange:W,children:[e.jsx(v,{"code-path":"src/components/deploy/DeployRBAC.tsx:249:19",className:"h-8 text-sm",children:e.jsx(f,{"code-path":"src/components/deploy/DeployRBAC.tsx:249:58"})}),e.jsxs(w,{"code-path":"src/components/deploy/DeployRBAC.tsx:250:19",children:[e.jsx(r,{"code-path":"src/components/deploy/DeployRBAC.tsx:251:21",value:"owner",children:"拥有者 (owner)"}),e.jsx(r,{"code-path":"src/components/deploy/DeployRBAC.tsx:252:21",value:"editor",children:"编辑者 (editor)"}),e.jsx(r,{"code-path":"src/components/deploy/DeployRBAC.tsx:253:21",value:"viewer",children:"查看者 (viewer)"})]})]})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:258:13",className:"space-y-1",children:[e.jsx(i,{"code-path":"src/components/deploy/DeployRBAC.tsx:258:40",className:"text-xs",children:"描述 (可选)"}),e.jsx(h,{"code-path":"src/components/deploy/DeployRBAC.tsx:258:82",value:Y,onChange:s=>Z(s.target.value),placeholder:"简要说明此角色的用途",className:"h-8 text-sm"})]}),e.jsxs(a,{"code-path":"src/components/deploy/DeployRBAC.tsx:259:13",onClick:ue,disabled:S,className:"w-full",children:[S?e.jsx(T,{"code-path":"src/components/deploy/DeployRBAC.tsx:260:25",className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(ne,{"code-path":"src/components/deploy/DeployRBAC.tsx:260:77",className:"w-4 h-4 mr-1"}),S?"创建中...":"创建"]})]})}),p.length===0?e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:269:9",className:"text-center py-12 text-[var(--dg-text-secondary)]",children:[e.jsx(ae,{"code-path":"src/components/deploy/DeployRBAC.tsx:270:11",className:"w-10 h-10 mx-auto mb-2 opacity-20"}),e.jsx("p",{"code-path":"src/components/deploy/DeployRBAC.tsx:271:11",className:"text-sm",children:"暂无 Item Role"})]}):e.jsx("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:274:9",className:"space-y-2",children:p.map(s=>e.jsx(D,{"code-path":"src/components/deploy/DeployRBAC.tsx:276:13",className:`bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] ${s.status===0?"opacity-50":""}`,children:e.jsx(g,{"code-path":"src/components/deploy/DeployRBAC.tsx:277:15",className:"p-3",children:e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:278:17",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:279:19",className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:280:21",className:"w-9 h-9 rounded-lg bg-purple-500/20 flex items-center justify-center shrink-0",children:e.jsx(pe,{"code-path":"src/components/deploy/DeployRBAC.tsx:281:23",className:"w-4 h-4 text-purple-400"})}),e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:283:21",className:"min-w-0",children:[e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:284:23",className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{"code-path":"src/components/deploy/DeployRBAC.tsx:285:25",className:"text-sm font-semibold text-[var(--dg-text-primary)]",children:s.name}),e.jsx(m,{"code-path":"src/components/deploy/DeployRBAC.tsx:286:25",className:`text-xs border ${ce(s.role)}`,children:s.role==="owner"?"拥有者":s.role==="editor"?"编辑者":"查看者"}),s.status===0&&e.jsx(m,{"code-path":"src/components/deploy/DeployRBAC.tsx:287:47",variant:"secondary",className:"text-xs text-red-400",children:"已禁用"}),e.jsxs(m,{"code-path":"src/components/deploy/DeployRBAC.tsx:288:25",variant:"secondary",className:"text-xs cursor-pointer",onClick:()=>k(n===s.id?null:s.id),children:[e.jsx(b,{"code-path":"src/components/deploy/DeployRBAC.tsx:289:27",className:"w-3 h-3 mr-0.5"}),B[s.id]?.length||0," 条"]})]}),e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:292:23",className:"text-xs text-[var(--dg-text-secondary)] mt-0.5 truncate",children:[e.jsx("code",{"code-path":"src/components/deploy/DeployRBAC.tsx:293:25",className:"font-mono text-purple-400 bg-purple-500/10 px-1 rounded",children:s.code}),e.jsx("span",{"code-path":"src/components/deploy/DeployRBAC.tsx:294:25",className:"mx-1",children:"→"}),e.jsx("code",{"code-path":"src/components/deploy/DeployRBAC.tsx:295:25",className:"font-mono text-blue-400 bg-blue-500/10 px-1 rounded",children:s.pattern}),s.description&&e.jsx("span",{"code-path":"src/components/deploy/DeployRBAC.tsx:296:46",className:"ml-2 opacity-60",children:s.description})]})]})]}),e.jsx("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:300:19",className:"flex items-center gap-1 shrink-0",children:Ce===s.id?e.jsxs(e.Fragment,{children:[e.jsx(h,{"code-path":"src/components/deploy/DeployRBAC.tsx:303:25",value:$,onChange:t=>ee(t.target.value),className:"h-7 w-36 text-xs font-mono",placeholder:"正则表达式"}),e.jsxs(N,{"code-path":"src/components/deploy/DeployRBAC.tsx:304:25",value:se,onValueChange:te,children:[e.jsx(v,{"code-path":"src/components/deploy/DeployRBAC.tsx:305:27",className:"h-7 w-20 text-xs",children:e.jsx(f,{"code-path":"src/components/deploy/DeployRBAC.tsx:305:71"})}),e.jsxs(w,{"code-path":"src/components/deploy/DeployRBAC.tsx:306:27",children:[e.jsx(r,{"code-path":"src/components/deploy/DeployRBAC.tsx:307:29",value:"owner",children:"拥有者"}),e.jsx(r,{"code-path":"src/components/deploy/DeployRBAC.tsx:308:29",value:"editor",children:"编辑者"}),e.jsx(r,{"code-path":"src/components/deploy/DeployRBAC.tsx:309:29",value:"viewer",children:"查看者"})]})]}),e.jsx(a,{"code-path":"src/components/deploy/DeployRBAC.tsx:312:25",size:"icon",variant:"ghost",className:"h-7 w-7 text-green-400",onClick:()=>Ae(s.id),children:e.jsx(we,{"code-path":"src/components/deploy/DeployRBAC.tsx:312:134",className:"w-3.5 h-3.5"})}),e.jsx(a,{"code-path":"src/components/deploy/DeployRBAC.tsx:313:25",size:"icon",variant:"ghost",className:"h-7 w-7 text-red-400",onClick:()=>U(null),children:e.jsx(de,{"code-path":"src/components/deploy/DeployRBAC.tsx:313:127",className:"w-3.5 h-3.5"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(a,{"code-path":"src/components/deploy/DeployRBAC.tsx:317:25",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>{U(s.id),ee(s.pattern),te(s.role)},children:[e.jsx(ne,{"code-path":"src/components/deploy/DeployRBAC.tsx:317:178",className:"w-3 h-3 mr-1"}),"编辑"]}),e.jsx(a,{"code-path":"src/components/deploy/DeployRBAC.tsx:318:25",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>Be(s),children:s.status?"禁用":"启用"}),e.jsx(a,{"code-path":"src/components/deploy/DeployRBAC.tsx:319:25",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-500",onClick:()=>je(s),children:e.jsx(be,{"code-path":"src/components/deploy/DeployRBAC.tsx:319:129",className:"w-3.5 h-3.5"})})]})})]})})},s.id))}),e.jsx(D,{"code-path":"src/components/deploy/DeployRBAC.tsx:331:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(g,{"code-path":"src/components/deploy/DeployRBAC.tsx:332:9",className:"p-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:333:11",className:"flex items-center gap-2 mb-3",children:[e.jsx(re,{"code-path":"src/components/deploy/DeployRBAC.tsx:334:13",className:"w-4 h-4 text-amber-400"}),e.jsx("span",{"code-path":"src/components/deploy/DeployRBAC.tsx:335:13",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:"分配角色给用户"})]}),e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:337:11",className:"flex gap-3 items-end mb-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:338:13",className:"space-y-1 flex-1",children:[e.jsx(i,{"code-path":"src/components/deploy/DeployRBAC.tsx:339:15",className:"text-xs",children:"选择用户"}),e.jsxs(N,{"code-path":"src/components/deploy/DeployRBAC.tsx:340:15",value:l,onValueChange:he,children:[e.jsx(v,{"code-path":"src/components/deploy/DeployRBAC.tsx:341:17",className:"h-8 text-sm",children:e.jsx(f,{"code-path":"src/components/deploy/DeployRBAC.tsx:341:56",placeholder:"选择用户..."})}),e.jsxs(w,{"code-path":"src/components/deploy/DeployRBAC.tsx:342:17",className:"max-h-60",children:[e.jsx("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:343:19",className:"px-2 py-1.5 sticky top-0 bg-popover z-10",children:e.jsx(h,{"code-path":"src/components/deploy/DeployRBAC.tsx:343:77",placeholder:"搜索用户...",className:"h-7 text-xs"})}),J.map(s=>e.jsxs(r,{"code-path":"src/components/deploy/DeployRBAC.tsx:345:21",value:String(s.id),children:[s.real_name||s.username," (",s.username,")",I.some(t=>t.user_id===s.id)&&e.jsx("span",{"code-path":"src/components/deploy/DeployRBAC.tsx:347:69",className:"ml-2 text-xs text-purple-400",children:"已分配"})]},s.id))]})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:353:13",className:"space-y-1 w-48",children:[e.jsx(i,{"code-path":"src/components/deploy/DeployRBAC.tsx:354:15",className:"text-xs",children:"Item Role"}),e.jsxs(N,{"code-path":"src/components/deploy/DeployRBAC.tsx:355:15",value:j,onValueChange:M,children:[e.jsx(v,{"code-path":"src/components/deploy/DeployRBAC.tsx:356:17",className:"h-8 text-sm",children:e.jsx(f,{"code-path":"src/components/deploy/DeployRBAC.tsx:356:56",placeholder:"选择角色"})}),e.jsx(w,{"code-path":"src/components/deploy/DeployRBAC.tsx:357:17",children:p.filter(s=>s.status===1).map(s=>e.jsxs(r,{"code-path":"src/components/deploy/DeployRBAC.tsx:359:21",value:String(s.id),children:[s.name," (",s.role,")"]},s.id))})]})]}),e.jsxs(a,{"code-path":"src/components/deploy/DeployRBAC.tsx:364:13",className:"h-8",onClick:De,disabled:G||!l||!j,children:[G?e.jsx(T,{"code-path":"src/components/deploy/DeployRBAC.tsx:365:32",className:"w-3.5 h-3.5 mr-1 animate-spin"}):e.jsx(re,{"code-path":"src/components/deploy/DeployRBAC.tsx:365:88",className:"w-3.5 h-3.5 mr-1"}),"分配"]})]}),V&&e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:372:13",children:[e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:373:15",className:"flex items-center gap-2 mb-2",children:[e.jsxs(m,{"code-path":"src/components/deploy/DeployRBAC.tsx:374:17",variant:"secondary",className:"text-xs",children:[e.jsx(Se,{"code-path":"src/components/deploy/DeployRBAC.tsx:375:19",className:"w-3 h-3 mr-1"}),V.real_name||V.username]}),e.jsx("span",{"code-path":"src/components/deploy/DeployRBAC.tsx:377:17",className:"text-xs text-[var(--dg-text-muted)]",children:"已分配角色:"})]}),I.length===0?e.jsx("p",{"code-path":"src/components/deploy/DeployRBAC.tsx:380:17",className:"text-xs text-[var(--dg-text-muted)] py-2",children:"该用户尚未分配任何 Item Role"}):e.jsx("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:382:17",className:"space-y-1",children:I.map(s=>{const t=s.item_role||p.find(d=>d.id===s.item_role_id);return e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:386:23",className:"flex items-center justify-between py-1.5 px-2 rounded bg-[var(--dg-bg-tertiary)] text-xs",children:[e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:387:25",className:"flex items-center gap-2",children:[e.jsx(m,{"code-path":"src/components/deploy/DeployRBAC.tsx:388:27",className:`text-xs border ${ce(t?.role||"viewer")}`,children:t?.role==="owner"?"拥有者":t?.role==="editor"?"编辑者":"查看者"}),e.jsx("span",{"code-path":"src/components/deploy/DeployRBAC.tsx:391:27",className:"text-[var(--dg-text-primary)]",children:t?.name||`#${s.item_role_id}`}),t&&e.jsx("code",{"code-path":"src/components/deploy/DeployRBAC.tsx:393:29",className:"font-mono text-[var(--dg-text-muted)] bg-[var(--dg-bg-primary)] px-1 rounded text-xs",children:t.pattern})]}),e.jsx(a,{"code-path":"src/components/deploy/DeployRBAC.tsx:398:25",variant:"ghost",size:"icon",className:"h-6 w-6 text-red-400",onClick:()=>ge(s.id),children:e.jsx(de,{"code-path":"src/components/deploy/DeployRBAC.tsx:399:27",className:"w-3 h-3"})})]},s.id)})})]})]})})]})}export{Je as default}; diff --git a/backend/static/assets/DeploymentDetailPage-C2S9vbFs.js b/backend/static/assets/DeploymentDetailPage-C2S9vbFs.js deleted file mode 100644 index d77481e..0000000 --- a/backend/static/assets/DeploymentDetailPage-C2S9vbFs.js +++ /dev/null @@ -1,27 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PodFileBrowser-B-U8iHmY.js","assets/vendor-codemirror-B1SGo4xl.js","assets/index-Dungj95X.js","assets/vendor-icons-DmqcWdzX.js","assets/index-GY9Szy-F.css","assets/use-toast-DNZLibQY.js","assets/index-drGq01ok.js","assets/k8s-yaml-utils-4KZB_Bq_.js","assets/select-CiTqGGhE.js","assets/index-5FEebgvX.js","assets/vendor-xterm-20M9KZE1.js","assets/vendor-xterm-DXOU9pbP.css","assets/badge-CGJlVD3L.js"])))=>i.map(i=>d[i]); -import{j as e,r as d}from"./vendor-codemirror-B1SGo4xl.js";import{B as v,ab as Os,ac as $s,ad as _s,ag as bt,f as dt,r as Ls,u as zs,L as yt,s as Ws,o as is,i as ps,ah as Gs,g as Vs}from"./index-Dungj95X.js";import{C as U,a as Y,b as he,c as ue}from"./card-BIfzBCEy.js";import{B as ae}from"./badge-CGJlVD3L.js";import{k as K}from"./index-drGq01ok.js";import{u as Me}from"./use-toast-DNZLibQY.js";import{c as vt,m as Fs,h as Us,p as ms,i as Gt,Y as kt,P as Ys,a as qs}from"./PodFileBrowser-B-U8iHmY.js";import{I as f}from"./input-CXoUQQLm.js";import{e as Vt,a as Ft,f as Pt,S as Ce,s as Ks}from"./k8s-yaml-utils-4KZB_Bq_.js";import{E as Js,n as Xs}from"./EventTable-BaH7H8dT.js";import{Q as xs,f as hs,r as us,H as bs,bb as Qs,F as At,o as Zs,T as be,L as ve,N as Ae,E as en,A as ys,b as vs,n as tn,k as Ue,P as te,aw as sn,s as Tt,bc as nn,aO as ks,bd as gt,$ as it,g as on,be as an,a4 as gs,j as js,as as rn,am as fs,aj as cn,z as Ns,R as Ye,D as tt,b4 as ln,h as Mt,aY as dn,aX as pn,G as mn,M as xn,p as wt,y as Ct,d as Ut,J as jt,X as Ss,ae as Yt,l as ws,a as hn,m as qt,aI as Kt,bf as un,ao as bn}from"./vendor-icons-DmqcWdzX.js";import{T as Ge,a as Ve,b as Ee,c as ce,d as Fe,e as le}from"./table-B2F10oba.js";import{L as H}from"./label-CMpUoC87.js";import{T as st}from"./textarea-BxfjmLq5.js";import{S as nt,a as ot,b as at,c as rt,d as fe}from"./select-CiTqGGhE.js";import{S as Ht}from"./switch-Bxiq4EHp.js";import{R as Cs,c as yn}from"./ResourceVisualEditor-BN2gGuH7.js";import{C as Jt}from"./code-snippet-block-E9P2jHS4.js";import"./vendor-xterm-20M9KZE1.js";import"./index-5FEebgvX.js";const vn=t=>Array.isArray(t)?t:t?.list||t?.items||t?.data||[];function kn(t,s){return Object.keys(s).length===0?!1:Object.entries(s).every(([a,o])=>t[a]===o)}function gn(t,s,a){const o=new Set;for(const n of a){const c=n.name||n.metadata?.name||"";if(!c)continue;const r=n.spec?.selector||n.selector||{};(c===t||kn(s,r))&&o.add(c)}return[...o].sort()}async function jn(t,s,a){const o=await K.getResourceYaml(t,s,"deployments",a),{manifest:n}=await vt(o),c=n?.spec?.selector?.matchLabels||n?.spec?.template?.metadata?.labels||{},r=await K.getNamespaceServices(t,s).catch(()=>[]),i=gn(a,c,vn(r)),k=[];if(n)k.push(await Fs(n));else{const{yaml:l}=await vt(o);l.trim()&&k.push(l)}for(const l of i)try{const x=await K.getResourceYaml(t,s,"services",l),{yaml:S}=await vt(x);S.trim()&&k.push(S)}catch{}return k.join(` ---- -`)}async function fn(t,s,a){const{manifests:o}=await Us(a);if(o.length===0)throw new Error("YAML 内容为空或解析失败");for(const n of o){const c=String(n.kind||"").toLowerCase(),r=String(n.metadata?.name||"").trim();if(!c||!r)throw new Error("每个 YAML 文档必须包含 kind 和 metadata.name");const i=await ms(n);if(c==="deployment"){await K.updateResourceYaml(t,s,"deployments",r,i);continue}if(c==="service"){await K.applyYAML(t,i);continue}throw new Error(`不支持的资源类型: ${n.kind}(仅支持 Deployment / Service)`)}}function Nn(t){const s=t.conditions||t.pod_conditions||[],a=n=>s.find(c=>(c.type||c.Type)===n),o=n=>n?.lastTransitionTime||n?.LastTransitionTime||n?.last_transition_time;return{scheduled:o(a("PodScheduled")||{}),initialized:o(a("Initialized")||{}),containersReady:o(a("ContainersReady")||{}),ready:o(a("Ready")||{}),startTime:t.start_time||t.startTime}}function Sn(t){const s=Nn(t);return[{label:"已调度",ts:s.scheduled,color:Ce.blue},{label:"已初始化",ts:s.initialized,color:Ce.orange},{label:"容器已就绪",ts:s.containersReady,color:Ce.green},{label:"容器组已就绪",ts:s.ready,color:Ce.green}]}function Re({label:t,value:s}){return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:43:5",children:[e.jsx("p",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:44:7",className:"text-xs text-[var(--dg-text-muted)] mb-1",children:t}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:45:7",className:"text-sm text-[var(--dg-text-primary)]",children:s})]})}function Es({pod:t}){const s=Sn(t),a=Vt(s[0]?.ts,s[s.length-1]?.ts);return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:92:5",className:"rounded-lg bg-[var(--dg-bg-tertiary)]/60 px-4 py-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:93:7",className:"flex items-center justify-between mb-3",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:94:9",className:"text-xs text-[var(--dg-text-muted)]",children:"启动时间线"}),a!=null&&e.jsxs("span",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:96:11",className:"text-[11px] text-[var(--dg-text-muted)]",children:["总耗时 ",e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:97:17",className:"font-mono text-[var(--dg-text-secondary)]",children:Ft(a)})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:101:7",className:"flex items-start gap-0 overflow-x-auto",children:s.map((o,n)=>{const c=s[n-1],r=Vt(c?.ts,o.ts),i=!!o.ts;return e.jsxs(d.Fragment,{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:107:13",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:108:15",className:"flex flex-col min-w-[108px]",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:109:17",className:"flex items-center gap-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:110:19",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-[10px] font-semibold",style:{background:i?`${o.color}22`:"var(--dg-bg-secondary)",color:i?o.color:"var(--dg-text-muted)",border:`1px solid ${i?`${o.color}55`:"var(--dg-border)"}`},children:n+1}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:120:19",className:"text-xs font-medium",style:{color:i?o.color:"var(--dg-text-muted)"},children:o.label})]}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/helpers.tsx:124:17",className:"mt-1.5 pl-7 text-[11px] font-mono text-[var(--dg-text-muted)]",children:o.ts?Pt(o.ts):"—"})]}),n{const x=i===l.name,S=l.node_name||l.node,C=Ks(l.status),y=l.containers;return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:50:15",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:52:17",className:`grid grid-cols-[28px_minmax(140px,1fr)_72px_100px_96px_48px_56px_88px] gap-2 min-w-[740px] items-center px-4 py-3 transition-colors ${x?"bg-[var(--dg-bg-tertiary)]/30":"hover:bg-[var(--dg-bg-tertiary)]/20"}`,children:[e.jsx(v,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:57:19",variant:"ghost",size:"icon",className:"h-6 w-6 text-[var(--dg-text-muted)]",onClick:()=>k(x?null:l.name),children:x?e.jsx(xs,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:63:33",className:"h-4 w-4"}):e.jsx(hs,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:63:71",className:"h-4 w-4"})}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:66:19",className:"font-mono text-sm text-[var(--dg-text-primary)] truncate",title:l.name,children:l.name}),e.jsx(ae,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:70:19",className:"w-fit text-[11px] font-normal",style:{background:`${C}18`,color:C,border:`1px solid ${C}33`},children:l.status||"Unknown"}),e.jsx("button",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:77:19",className:"text-xs text-[var(--dg-blue)] hover:underline truncate text-left",title:S,onClick:()=>S&&window.open(`/kubernetes/${t}/nodes/${S}`,"_blank"),children:S||"—"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:85:19",className:"text-xs font-mono text-[var(--dg-text-muted)] truncate",children:l.ip||l.pod_ip||"—"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:89:19",className:`text-xs text-center font-mono ${(l.restart_count||0)>0?"text-amber-400":"text-[var(--dg-text-muted)]"}`,children:l.restart_count||0}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:93:19",className:"text-xs text-[var(--dg-text-muted)] whitespace-nowrap",children:l.age||"—"}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:97:19",className:"flex items-center justify-end gap-0.5 shrink-0 w-[88px]",children:[e.jsx(v,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:98:21",variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0 text-emerald-400",title:"终端",onClick:()=>o(l),children:e.jsx(us,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:99:23",className:"h-3.5 w-3.5"})}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:101:21",variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0 text-amber-400",title:"文件",onClick:()=>c(l),children:e.jsx(bs,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:102:23",className:"h-3.5 w-3.5"})}),e.jsxs(Os,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:104:21",children:[e.jsx($s,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:105:23",asChild:!0,children:e.jsx(v,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:106:25",variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0 text-[var(--dg-text-muted)] hover:text-[var(--dg-blue)]",title:"更多","aria-label":"更多",children:e.jsx(Qs,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:113:27",className:"h-3.5 w-3.5"})})}),e.jsxs(_s,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:116:23",align:"end",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:[e.jsxs(bt,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:117:25",onClick:()=>a(l),className:"text-[var(--dg-text-primary)]",children:[e.jsx(At,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:118:27",className:"h-3.5 w-3.5 mr-2"})," 日志"]}),e.jsxs(bt,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:120:25",onClick:()=>n(l),className:"text-[var(--dg-text-primary)]",children:[e.jsx(Zs,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:121:27",className:"h-3.5 w-3.5 mr-2"})," YAML"]}),e.jsxs(bt,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:123:25",onClick:()=>r?.(l),className:"text-red-400 focus:text-red-400",children:[e.jsx(be,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:124:27",className:"h-3.5 w-3.5 mr-2"})," 删除"]})]})]})]})]}),x&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:133:19",className:"px-4 pb-4 pt-1 space-y-3 bg-[var(--dg-bg-tertiary)]/20",children:[e.jsx(Es,{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:134:21",pod:l}),y&&y.length>0&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:136:23",children:[e.jsx("p",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:137:25",className:"text-xs text-[var(--dg-text-muted)] mb-2",children:"容器"}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:138:25",className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:y.map((b,w)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:140:29",className:"rounded-md border border-[var(--dg-border)] bg-[var(--dg-bg-secondary)] px-3 py-2.5 text-xs",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:141:31",className:"flex items-center justify-between gap-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:142:33",className:"font-medium text-[var(--dg-text-primary)]",children:b.name}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:143:33",className:b.ready?"text-emerald-400":"text-[var(--dg-text-muted)]",children:b.ready?"Ready":"Pending"})]}),e.jsx("p",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:147:31",className:"text-[var(--dg-text-muted)] mt-1 truncate",title:b.image,children:b.image}),b.resources&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:149:33",className:"mt-1.5 flex gap-4 text-[var(--dg-text-muted)]",children:[e.jsxs("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:150:35",children:["CPU ",b.resources?.requests?.cpu||"0"," / ",b.resources?.limits?.cpu||"—"]}),e.jsxs("span",{"code-path":"src/components/kubernetes/deployment-view/PodsTab.tsx:151:35",children:["内存 ",b.resources?.requests?.memory||"0"," / ",b.resources?.limits?.memory||"—"]})]})]},w))})]})]})]},l.name)})})]})})}function Cn({services:t,ingresses:s,loading:a}){return a==="services"?e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:12:12",className:"flex items-center justify-center py-12",children:e.jsx(ve,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:12:68",className:"h-6 w-6 animate-spin text-[var(--dg-text-muted)]"})}):e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:15:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:17:7",children:[e.jsxs("h3",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:18:9",className:"text-sm font-semibold text-[var(--dg-text-primary)] mb-3 flex items-center gap-2",children:[e.jsx(Ae,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:19:11",className:"h-4 w-4 text-[var(--dg-blue)]"}),"关联 Service"]}),t.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:22:11",className:"text-sm text-[var(--dg-text-muted)] py-4",children:"暂无匹配的 Service(Deployment 选择器未关联任何 Service)"}):e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:24:11",className:"overflow-x-auto",children:e.jsxs(Ge,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:25:13",children:[e.jsx(Ve,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:26:15",children:e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:27:17",className:"border-[var(--dg-border)]",children:[e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:28:19",className:"text-[var(--dg-text-muted)]",children:"名称"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:29:19",className:"text-[var(--dg-text-muted)]",children:"类型"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:30:19",className:"text-[var(--dg-text-muted)]",children:"ClusterIP"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:31:19",className:"text-[var(--dg-text-muted)]",children:"端口"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:32:19",className:"text-[var(--dg-text-muted)]",children:"Selector"})]})}),e.jsx(Fe,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:35:15",children:t.map(o=>e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:37:19",className:"border-[var(--dg-border)]",children:[e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:38:21",className:"font-medium text-[var(--dg-text-primary)]",children:o.name}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:39:21",children:e.jsx(ae,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:39:32",variant:"outline",className:"text-xs",children:o.type})}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:40:21",className:"font-mono text-sm text-[var(--dg-text-muted)]",children:o.clusterIP}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:41:21",className:"text-sm text-[var(--dg-text-muted)]",children:o.ports.join(", ")}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:42:21",className:"text-xs text-[var(--dg-text-muted)]",children:Object.entries(o.selector).map(([n,c])=>e.jsxs("code",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:44:25",className:"mr-1 bg-[var(--dg-bg-tertiary)] px-1 rounded",children:[n,"=",c]},n))})]},o.name))})]})})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:56:7",children:[e.jsxs("h3",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:57:9",className:"text-sm font-semibold text-[var(--dg-text-primary)] mb-3 flex items-center gap-2",children:[e.jsx(en,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:58:11",className:"h-4 w-4 text-[var(--dg-purple)]"}),"关联 Ingress"]}),s.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:61:11",className:"text-sm text-[var(--dg-text-muted)] py-4",children:"暂无匹配的 Ingress"}):e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:63:11",className:"overflow-x-auto",children:e.jsxs(Ge,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:64:13",children:[e.jsx(Ve,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:65:15",children:e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:66:17",className:"border-[var(--dg-border)]",children:[e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:67:19",className:"text-[var(--dg-text-muted)]",children:"名称"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:68:19",className:"text-[var(--dg-text-muted)]",children:"Class"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:69:19",className:"text-[var(--dg-text-muted)]",children:"Host"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:70:19",className:"text-[var(--dg-text-muted)]",children:"路径"})]})}),e.jsx(Fe,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:73:15",children:s.map(o=>e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:75:19",className:"border-[var(--dg-border)]",children:[e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:76:21",className:"font-medium text-[var(--dg-text-primary)]",children:o.name}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:77:21",className:"text-sm text-[var(--dg-text-muted)]",children:o.className}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:78:21",className:"text-sm text-[var(--dg-text-muted)]",children:o.hosts.join(", ")}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/ServicesTab.tsx:79:21",className:"text-xs text-[var(--dg-text-muted)]",children:o.rules.flatMap(n=>(n.http?.paths||n.paths||[]).map(c=>c.path||"/")).join(", ")})]},o.name))})]})})]})]})}function En({events:t,loading:s}){return e.jsx(Js,{"code-path":"src/components/kubernetes/deployment-view/EventsTab.tsx:7:5",events:t,loading:s,emptyText:"暂无事件"})}function Dn({hpas:t,cronHpas:s,loading:a,replicas:o}){return a==="scale"?e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:13:12",className:"flex items-center justify-center py-12",children:e.jsx(ve,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:13:68",className:"h-6 w-6 animate-spin text-[var(--dg-text-muted)]"})}):e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:17:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:19:7",className:"flex items-center gap-2 px-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:20:9",className:"text-sm text-[var(--dg-text-muted)]",children:"当前副本:"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:21:9",className:"text-sm font-bold text-[var(--dg-text-primary)]",children:o}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:22:9",className:"text-xs text-[var(--dg-text-muted)]",children:"(可通过 Tab 栏右侧 +/- 手动调整)"})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:26:7",className:"dg-card",children:[e.jsx(he,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:27:9",className:"pb-2",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:27:38",className:"text-sm flex items-center gap-2",children:[e.jsx(ys,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:27:93",className:"h-4 w-4 text-[var(--dg-orange)]"}),"HPA — 水平自动伸缩"]})}),e.jsx(Y,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:28:9",children:t.length===0?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:30:13",className:"text-sm text-[var(--dg-text-muted)] py-4",children:["未关联 HPA — ",e.jsx(v,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:31:25",variant:"link",className:"h-auto p-0 text-[var(--dg-blue)] text-sm",children:"创建 HPA"})]}):e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:34:13",className:"overflow-x-auto",children:e.jsxs(Ge,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:35:15",children:[e.jsx(Ve,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:36:17",children:e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:37:19",className:"border-[var(--dg-border)]",children:[e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:38:21",className:"text-[var(--dg-text-muted)]",children:"名称"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:39:21",className:"text-[var(--dg-text-muted)]",children:"最小/最大"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:40:21",className:"text-[var(--dg-text-muted)]",children:"指标"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:41:21",className:"text-[var(--dg-text-muted)]",children:"当前负载"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:42:21",className:"text-[var(--dg-text-muted)]",children:"状态"})]})}),e.jsx(Fe,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:45:17",children:t.map((n,c)=>{const r=n.spec?.minReplicas??n.minReplicas??1,i=n.spec?.maxReplicas??n.maxReplicas??10,k=n.spec?.metrics||n.metrics||[],l=n.status?.currentReplicas??n.currentReplicas??0,C=(n.status?.conditions||n.conditions||[]).find(y=>y.type==="AbleToScale")?.status==="True";return e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:55:23",className:"border-[var(--dg-border)]",children:[e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:56:25",className:"font-medium text-[var(--dg-text-primary)]",children:n.name||n.metadata?.name}),e.jsxs(le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:57:25",className:"text-sm text-[var(--dg-text-secondary)] font-mono",children:[r," → ",i]}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:58:25",className:"text-xs text-[var(--dg-text-muted)]",children:k.map((y,b)=>{const w=y.resource||y.object?.metric?.name||"",P=y.resource?.target?.averageUtilization||y.resource?.target?.averageValue||y.resource?.target?.type||"-";return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:62:36",children:[w?.name||w,": ",P,y.resource?.target?.averageUtilization?"%":""]},b)})}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:65:25",className:"text-sm font-mono text-[var(--dg-text-secondary)]",children:l}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:66:25",children:e.jsx(ae,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:67:27",className:C?"bg-[var(--dg-green)]/20 text-[var(--dg-green)]":"bg-[var(--dg-red)]/20 text-[var(--dg-red)]",children:C?"正常":"异常"})})]},n.name||c)})})]})})})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:82:7",className:"dg-card",children:[e.jsx(he,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:83:9",className:"pb-2",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:83:38",className:"text-sm flex items-center gap-2",children:[e.jsx(vs,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:83:93",className:"h-4 w-4 text-[var(--dg-blue)]"}),"CronHPA — 定时伸缩"]})}),e.jsx(Y,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:84:9",children:s.length===0?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:86:13",className:"text-sm text-[var(--dg-text-muted)] py-4",children:["未关联 CronHPA — ",e.jsx(v,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:87:29",variant:"link",className:"h-auto p-0 text-[var(--dg-blue)] text-sm",children:"创建 CronHPA"})]}):e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:90:13",className:"overflow-x-auto",children:e.jsxs(Ge,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:91:15",children:[e.jsx(Ve,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:92:17",children:e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:93:19",className:"border-[var(--dg-border)]",children:[e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:94:21",className:"text-[var(--dg-text-muted)]",children:"名称"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:95:21",className:"text-[var(--dg-text-muted)]",children:"目标副本"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:96:21",className:"text-[var(--dg-text-muted)]",children:"调度规则"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:97:21",className:"text-[var(--dg-text-muted)]",children:"时区"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:98:21",className:"text-[var(--dg-text-muted)]",children:"状态"})]})}),e.jsx(Fe,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:101:17",children:s.map((n,c)=>{const r=n.spec?.jobs||n.jobs||[],i=n.spec?.timezone||"UTC";return e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:106:23",className:"border-[var(--dg-border)]",children:[e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:107:25",className:"font-medium text-[var(--dg-text-primary)]",children:n.name||n.metadata?.name}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:108:25",className:"text-sm text-[var(--dg-text-secondary)]",children:r.map(k=>k.targetSize||k.targetReplicas||"?").join(", ")}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:111:25",className:"text-xs font-mono text-[var(--dg-text-muted)]",children:r.map(k=>k.schedule||"?").join(", ")}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:112:25",className:"text-xs text-[var(--dg-text-muted)]",children:i}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:113:25",children:e.jsx(ae,{"code-path":"src/components/kubernetes/deployment-view/HPACronHPATab.tsx:114:27",className:"bg-[var(--dg-green)]/20 text-[var(--dg-green)]",children:"已启用"})})]},n.name||c)})})]})})})]})]})}function Pn({revisions:t,rollbackLoading:s,onRollback:a}){return t.length===0?e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:13:12",className:"text-center text-[var(--dg-text-muted)] py-12",children:"暂无历史版本"}):e.jsx("div",{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:16:5",className:"overflow-x-auto",children:e.jsxs(Ge,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:17:7",children:[e.jsx(Ve,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:18:9",children:e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:19:11",className:"border-[var(--dg-border)]",children:[e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:20:13",className:"text-[var(--dg-text-muted)] w-24",children:"Revision"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:21:13",className:"text-[var(--dg-text-muted)]",children:"镜像"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:22:13",className:"text-[var(--dg-text-muted)] w-24",children:"状态"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:23:13",className:"text-[var(--dg-text-muted)] w-40",children:"更新时间"}),e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:24:13",className:"text-[var(--dg-text-muted)] w-24",children:"操作"})]})}),e.jsx(Fe,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:27:9",children:t.map((o,n)=>{const c=o.revision??o.revision_number??o.number??n+1,r=n===0;return e.jsxs(Ee,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:32:15",className:"border-[var(--dg-border)]",children:[e.jsxs(le,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:33:17",className:"font-mono text-[var(--dg-text-primary)]",children:["#",c]}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:34:17",className:"text-xs font-mono text-[var(--dg-text-muted)] max-w-[300px] truncate",children:o.image||o.images?.[0]||"-"}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:35:17",children:r?e.jsx(ae,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:37:23",className:"bg-[var(--dg-green)]/20 text-[var(--dg-green)] border-[var(--dg-green)]/30",children:"当前"}):e.jsx(ae,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:38:23",variant:"outline",className:"text-[var(--dg-text-muted)]",children:"历史"})}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:40:17",className:"text-xs text-[var(--dg-text-muted)]",children:Pt(o.created_at||o.time)}),e.jsx(le,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:41:17",children:e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:42:19",variant:"ghost",size:"sm",className:"h-7 text-amber-400",disabled:r||s!==null,onClick:()=>a(o),children:[s===c?e.jsx(ve,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:43:53",className:"h-3 w-3 animate-spin mr-1"}):e.jsx(tn,{"code-path":"src/components/kubernetes/deployment-view/HistoryTab.tsx:43:105",className:"h-3 w-3 mr-1"}),"回滚"]})})]},c)})})]})})}function An(t){const{clusterCode:s,namespace:a,deployment:o,pods:n,revisions:c,onRefresh:r}=t,{toast:i}=Me(),k=dt(),[l,x]=d.useState("pods"),[S,C]=d.useState(null),[y,b]=d.useState(null),[w,P]=d.useState(o?.replicas||0),[I,M]=d.useState(!1),[F,V]=d.useState([]),[X,q]=d.useState([]),[W,Q]=d.useState([]),[$,Z]=d.useState(""),[N,_]=d.useState([]),[J,ee]=d.useState([]),me=o?.ready_replicas??o?.readyReplicas??0,ye=o?.replicas??0,ge=me===ye&&ye>0;d.useEffect(()=>{l==="services"&&(Z("services"),Promise.all([K.getNamespaceServices(s,a).catch(()=>[]),K.getNamespaceIngresses(s,a).catch(()=>[])]).then(([u,A])=>{const L=B=>Array.isArray(B)?B:B?.list||B?.items||B?.data||[],m=L(u),g=L(A),j=o?.spec?.selector?.matchLabels||o?.spec?.template?.metadata?.labels||{},O=m.filter(B=>{const de=B.spec?.selector||B.selector||{};return Object.keys(de).length===0?!1:Object.entries(de).every(([De,Se])=>j[De]===Se)}).map(B=>({name:B.name||B.metadata?.name,type:B.spec?.type||B.type||"ClusterIP",clusterIP:B.spec?.clusterIP||B.cluster_ip||"",ports:(B.spec?.ports||B.ports||[]).map(de=>`${de.port}${de.targetPort?":"+de.targetPort:""}/${de.protocol||"TCP"}`),selector:B.spec?.selector||B.selector||{},age:B.age||""})),xe=new Set(O.map(B=>B.name)),se=g.filter(B=>(B.spec?.rules||B.rules||[]).some(De=>(De.http?.paths||De.paths||[]).some(Se=>{const Ie=Se.backend?.service?.name||Se.backendService||"";return xe.has(Ie)}))).map(B=>({name:B.name||B.metadata?.name,className:B.spec?.ingressClassName||B.ingressClass||"-",hosts:(B.spec?.rules||B.rules||[]).map(de=>de.host).filter(Boolean),rules:B.spec?.rules||B.rules||[],age:B.age||""}));V(O),q(se)}).catch(()=>{}).finally(()=>Z("")))},[l,s,a,o]),d.useEffect(()=>{l==="events"&&(Z("events"),K.getEvents(s,a,void 0).then(u=>{const A=Array.isArray(u)?u:u?.list||u?.items||u?.data||[],L=o?.name||"",m=A.filter(g=>{const j=String(g.object||"");if(!L||!j)return!1;if(j.endsWith(`/${L}`))return!0;const O=j.split("/").pop()||"";return O===L||O.startsWith(`${L}-`)}).map(g=>Xs(g));Q(m)}).catch(()=>{}).finally(()=>Z("")))},[l,s,a,o?.name]),d.useEffect(()=>{l==="scale"&&(Z("scale"),Promise.all([K.getHPAs(s,a).catch(()=>[]),Promise.resolve([])]).then(([u])=>{const L=(g=>Array.isArray(g)?g:g?.list||g?.items||g?.data||[])(u),m=o?.name||"";_(L.filter(g=>(g.scaleTargetRef?.name||g.targetRef?.name||"")===m)),ee([])}).catch(()=>{}).finally(()=>Z("")))},[l,s,a,o?.name]);const R=async u=>{const A=u.revision??u.revision_number??u.number;if(await k({title:"回滚版本",description:`确认回滚到修订版本 #${A}?`,confirmText:"回滚",variant:"destructive"})){b(A);try{await K.rollbackDeployment(s,a,o.name,Number(A)),i({title:"回滚已下发",description:`正在回滚到 #${A}`}),r()}catch(m){i({title:"回滚失败",description:m?.message||String(m),variant:"destructive"})}finally{b(null)}}},p=async()=>{M(!0);try{await K.scaleDeployment(s,a,o.name,w),i({title:"伸缩已提交",description:`副本数 → ${w}`}),r()}catch(u){i({title:"伸缩失败",description:u?.message||String(u),variant:"destructive"})}finally{M(!1)}},h=[{key:"pods",label:"容器组",icon:Ue,count:n.length},{key:"services",label:"访问方式",icon:Ae,count:F.length},{key:"events",label:"事件",icon:ys,count:W.length},{key:"scale",label:"容器伸缩",icon:te},{key:"history",label:"历史版本",icon:sn,count:c.length}];return e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentView.tsx:178:5",className:"space-y-4",children:[e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentView.tsx:180:7",className:"dg-card",children:e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentView.tsx:181:9",className:"p-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentView.tsx:182:11",className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3 text-sm",children:[e.jsx(Re,{"code-path":"src/components/kubernetes/DeploymentView.tsx:183:13",label:"状态",value:e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentView.tsx:184:15",style:{background:`${ge?Ce.green:Ce.orange}22`,color:ge?Ce.green:Ce.orange,border:`1px solid ${ge?Ce.green:Ce.orange}44`},children:ge?"Running":"Updating"})}),e.jsx(Re,{"code-path":"src/components/kubernetes/DeploymentView.tsx:188:13",label:"副本",value:e.jsxs("span",{"code-path":"src/components/kubernetes/DeploymentView.tsx:188:41",className:"font-mono",children:[me,"/",ye]})}),e.jsx(Re,{"code-path":"src/components/kubernetes/DeploymentView.tsx:189:13",label:"策略",value:o?.strategy||"RollingUpdate"}),n[0]&&e.jsxs(e.Fragment,{children:[e.jsx(Re,{"code-path":"src/components/kubernetes/DeploymentView.tsx:192:17",label:"所在节点",value:e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentView.tsx:193:19",className:"text-[var(--dg-blue)] hover:underline",onClick:()=>window.open(`/kubernetes/${s}/nodes/${n[0].node_name||n[0].node}`,"_blank"),children:n[0].node_name||n[0].node||"-"})}),e.jsx(Re,{"code-path":"src/components/kubernetes/DeploymentView.tsx:197:17",label:"容器组 IP",value:e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentView.tsx:197:49",className:"font-mono",children:n[0].ip||n[0].pod_ip||"-"})})]}),e.jsx(Re,{"code-path":"src/components/kubernetes/DeploymentView.tsx:200:13",label:"创建时间",value:Pt(o?.created_at||o?.creationTimestamp)})]}),n.length===1&&e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentView.tsx:203:13",className:"mt-3 pt-3 border-t border-[var(--dg-border)]",children:e.jsx(Es,{"code-path":"src/components/kubernetes/DeploymentView.tsx:204:15",pod:n[0]})})]})}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentView.tsx:211:7",className:"flex items-center gap-0.5 border-b border-[var(--dg-border)] overflow-x-auto",children:[h.map(u=>e.jsxs("button",{"code-path":"src/components/kubernetes/DeploymentView.tsx:213:11",className:`flex items-center gap-1.5 px-4 py-2.5 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${l===u.key?"border-[var(--dg-blue)] text-[var(--dg-blue)]":"border-transparent text-[var(--dg-text-muted)] hover:text-[var(--dg-text-secondary)]"}`,onClick:()=>x(u.key),children:[e.jsx(u.icon,{"code-path":"src/components/kubernetes/DeploymentView.tsx:222:13",className:"h-4 w-4"}),u.label,u.key==="pods"&&e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentView.tsx:224:34",className:"ml-1 text-[10px] px-1.5 py-0 bg-[var(--dg-bg-tertiary)] text-[var(--dg-text-muted)]",children:u.count})]},u.key)),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentView.tsx:227:9",className:"ml-auto flex items-center gap-1 pr-2 shrink-0",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentView.tsx:228:11",variant:"ghost",size:"icon",className:"h-7 w-7 text-[var(--dg-text-muted)] hover:text-[var(--dg-text-primary)]",disabled:I||w<=0,onClick:()=>P(u=>Math.max(0,u-1)),children:e.jsx(Tt,{"code-path":"src/components/kubernetes/DeploymentView.tsx:231:13",className:"h-4 w-4"})}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentView.tsx:233:11",type:"number",min:0,value:w,onChange:u=>P(Math.max(0,Number(u.target.value))),className:"w-16 h-7 text-center text-sm font-bold bg-slate-800 border-slate-700 text-slate-200"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentView.tsx:238:11",variant:"ghost",size:"icon",className:"h-7 w-7 text-[var(--dg-text-muted)] hover:text-[var(--dg-text-primary)]",disabled:I,onClick:()=>P(u=>u+1),children:e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentView.tsx:241:13",className:"h-4 w-4"})}),w!==ye&&e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentView.tsx:244:13",size:"sm",className:"h-7 text-xs bg-[var(--dg-blue)] hover:bg-[var(--dg-blue-hover)]",disabled:I,onClick:p,children:I?e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentView.tsx:246:31",className:"h-3 w-3 animate-spin"}):"应用"})]})]}),l==="pods"&&e.jsx(wn,{"code-path":"src/components/kubernetes/DeploymentView.tsx:253:26",...t,onDeletePod:t.onDeletePod,expandedPod:S,setExpandedPod:C}),l==="services"&&e.jsx(Cn,{"code-path":"src/components/kubernetes/DeploymentView.tsx:254:30",services:F,ingresses:X,loading:$,namespace:a}),l==="events"&&e.jsx(En,{"code-path":"src/components/kubernetes/DeploymentView.tsx:255:28",events:W,loading:$}),l==="scale"&&e.jsx(Dn,{"code-path":"src/components/kubernetes/DeploymentView.tsx:257:9",hpas:N,cronHpas:J,loading:$,replicas:ye}),l==="history"&&e.jsx(Pn,{"code-path":"src/components/kubernetes/DeploymentView.tsx:264:29",revisions:c,rollbackLoading:y,onRollback:R})]})}const Ds="_create";function It(t){return t===Ds}async function pt(t,s,a,o){const n=String(o?.metadata?.name||"").trim();if(!n)throw new Error("Deployment 名称不能为空");const c=await ms(o);return It(a)?await K.applyYAML(t,c):await K.updateResourceYaml(t,s,"deployments",n,c),n}function Ze(t){return!t||typeof t!="object"?[]:Object.entries(t).map(([s,a])=>({key:s,value:String(a)}))}function Oe(t){const s={};for(const{key:a,value:o}of t){const n=a.trim();n&&(s[n]=o)}return s}function Tn({clusterCode:t,namespace:s,deploymentName:a,manifest:o,onSaved:n,onCancel:c,isCreate:r=!1}){const{toast:i}=Me(),[k,l]=d.useState(!1),[x,S]=d.useState(!o),[C,y]=d.useState(o||{}),[b,w]=d.useState(o?.metadata?.name||""),[P,I]=d.useState(1),[M,F]=d.useState([]),[V,X]=d.useState([]),[q,W]=d.useState([]),[Q,$]=d.useState([]);d.useEffect(()=>{const m=o;if(!m){S(!1);return}y(m),w(m?.metadata?.name||""),I(m?.spec?.replicas??1),F(Ze(m?.metadata?.labels)),X(Ze(m?.metadata?.annotations)),W(Ze(m?.spec?.selector?.matchLabels)),$(Ze(m?.spec?.template?.metadata?.labels)),S(!1)},[o]);const Z=(m,g)=>{F(j=>j.map((O,xe)=>xe===m?{...O,...g}:O))},N=()=>F(m=>[...m,{key:"",value:""}]),_=m=>F(g=>g.filter((j,O)=>O!==m)),J=(m,g)=>{X(j=>j.map((O,xe)=>xe===m?{...O,...g}:O))},ee=()=>X(m=>[...m,{key:"",value:""}]),me=m=>X(g=>g.filter((j,O)=>O!==m)),ye=(m,g)=>{W(j=>j.map((O,xe)=>xe===m?{...O,...g}:O))},ge=()=>W(m=>[...m,{key:"",value:""}]),R=m=>W(g=>g.filter((j,O)=>O!==m)),p=(m,g)=>{$(j=>j.map((O,xe)=>xe===m?{...O,...g}:O))},h=()=>$(m=>[...m,{key:"",value:""}]),u=m=>$(g=>g.filter((j,O)=>O!==m)),A=()=>{const m=Oe(q);$(g=>{const j={...Oe(g),...m};return Object.entries(j).map(([O,xe])=>({key:O,value:xe}))}),i({title:"已同步",description:"Selector 标签已合并到 Pod 模板标签"})},L=async()=>{l(!0);try{const m=JSON.parse(JSON.stringify(C));m.spec=m.spec||{},m.spec.replicas=P;const g=Oe(M);if(m.metadata=m.metadata||{},r){const B=b.trim();if(!B)throw new Error("名称不能为空");m.metadata.name=B,m.metadata.namespace=s}m.metadata.labels=Object.keys(g).length>0?g:void 0;const j=Oe(V);m.metadata.annotations=Object.keys(j).length>0?j:void 0;const O=Oe(q);Object.keys(O).length>0&&(m.spec.selector=m.spec.selector||{},m.spec.selector.matchLabels=O);const xe=Oe(Q);m.spec.template=m.spec.template||{},m.spec.template.metadata=m.spec.template.metadata||{},Object.keys(xe).length>0?m.spec.template.metadata.labels=xe:delete m.spec.template.metadata.labels;const se=await pt(t,s,a,m);i({title:r?"创建成功":"基本信息已保存",description:r?`${se} 已创建`:`${se} 更新已提交`}),n(m)}catch(m){i({title:"保存失败",description:m?.message||String(m),variant:"destructive"})}finally{l(!1)}};return x?e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:139:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:140:9",className:"p-12 text-center",children:[e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:141:11",className:"h-6 w-6 animate-spin mx-auto text-slate-500"}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:142:11",className:"text-slate-500 mt-3 text-sm",children:"加载中..."})]})}):o?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:159:5",className:"space-y-4",children:[e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:161:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:162:9",className:"pb-3",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:163:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(nn,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:164:13",className:"h-4 w-4 text-blue-400"}),"副本数 (Replicas)"]})}),e.jsx(Y,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:168:9",className:"pt-0",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:169:11",className:"flex items-center gap-3",children:[e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:170:13",type:"number",min:0,value:P,onChange:m=>I(Math.max(0,Number(m.target.value)||0)),className:"w-32 bg-slate-800 border-slate-700 text-slate-200"}),e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:177:13",className:"text-xs text-slate-500",children:"期望运行的 Pod 实例数量"})]})})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:183:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:184:9",className:"pb-3",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:185:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(ks,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:186:13",className:"h-4 w-4 text-slate-500"}),r?"基本标识":"基本标识(只读)"]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:190:9",className:"pt-0 grid grid-cols-2 gap-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:191:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:192:13",className:"text-slate-400 text-xs",children:"名称 (name)"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:193:13",value:r?b:a,readOnly:!r,onChange:m=>r&&w(m.target.value),className:`mt-1 font-mono text-sm ${r?"bg-slate-800 border-slate-700 text-slate-200":"bg-slate-950 border-slate-800 text-slate-500 cursor-not-allowed"}`})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:200:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:201:13",className:"text-slate-400 text-xs",children:"命名空间 (namespace)"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:202:13",value:s,readOnly:!0,className:"mt-1 bg-slate-950 border-slate-800 text-slate-500 font-mono text-sm cursor-not-allowed"})]})]})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:209:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:210:9",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:211:11",className:"flex items-center justify-between",children:[e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:212:13",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(gt,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:213:15",className:"h-4 w-4 text-emerald-400"}),"标签 (Labels)",e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:215:15",variant:"outline",className:"border-slate-700 text-slate-500 text-[10px]",children:M.length})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:217:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:N,children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:218:15",className:"h-3 w-3 mr-1"}),"新增"]})]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:222:9",className:"pt-0 space-y-1.5",children:[M.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:223:35",className:"text-[11px] text-slate-600",children:"无标签"}),M.map((m,g)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:225:13",className:"grid grid-cols-[1fr_1.4fr_auto] gap-2",children:[e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:226:15",value:m.key,placeholder:"app",onChange:j=>Z(g,{key:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:229:15",value:m.value,placeholder:"nginx",onChange:j=>Z(g,{value:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:232:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400 hover:text-red-300",onClick:()=>_(g),children:e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:233:48",className:"h-3.5 w-3.5"})})]},g))]})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:240:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:241:9",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:242:11",className:"flex items-center justify-between",children:[e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:243:13",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(gt,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:244:15",className:"h-4 w-4 text-amber-400"}),"选择器 (Selector)",e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:246:15",variant:"outline",className:"border-amber-700/50 text-amber-500 text-[10px]",children:"⚠️ 需与模板标签一致"})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:248:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:ge,children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:249:15",className:"h-3 w-3 mr-1"}),"新增"]})]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:253:9",className:"pt-0 space-y-1.5",children:[e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:254:11",className:"text-[11px] text-amber-500/70 mb-1",children:"Selector 决定哪些 Pod 归属此 Deployment。修改时必须确保与 Pod Template Labels 匹配,否则 Deployment 将无法管理 Pod。"}),q.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:255:43",className:"text-[11px] text-slate-600",children:"无选择器"}),q.map((m,g)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:257:13",className:"grid grid-cols-[1fr_1.4fr_auto] gap-2",children:[e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:258:15",value:m.key,placeholder:"app",onChange:j=>ye(g,{key:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:261:15",value:m.value,placeholder:"nginx",onChange:j=>ye(g,{value:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:264:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400 hover:text-red-300",onClick:()=>R(g),children:e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:265:51",className:"h-3.5 w-3.5"})})]},g))]})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:272:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:273:9",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:274:11",className:"flex items-center justify-between",children:[e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:275:13",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(gt,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:276:15",className:"h-4 w-4 text-cyan-400"}),"Pod 模板标签 (template.metadata.labels)"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:279:13",className:"flex gap-1",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:280:15",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:A,children:"从 Selector 同步"}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:283:15",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:h,children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:284:17",className:"h-3 w-3 mr-1"}),"新增"]})]})]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:289:9",className:"pt-0 space-y-1.5",children:[e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:290:11",className:"text-[11px] text-slate-600 mb-1",children:"Pod 模板标签必须包含 Selector 全部键值,否则 Deployment 无法管理 Pod"}),Q.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:291:43",className:"text-[11px] text-slate-600",children:"无模板标签"}),Q.map((m,g)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:293:13",className:"grid grid-cols-[1fr_1.4fr_auto] gap-2",children:[e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:294:15",value:m.key,placeholder:"app",onChange:j=>p(g,{key:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:297:15",value:m.value,placeholder:"nginx",onChange:j=>p(g,{value:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:300:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400 hover:text-red-300",onClick:()=>u(g),children:e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:301:56",className:"h-3.5 w-3.5"})})]},g))]})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:308:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:309:9",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:310:11",className:"flex items-center justify-between",children:[e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:311:13",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(At,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:312:15",className:"h-4 w-4 text-purple-400"}),"注解 (Annotations)",e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:314:15",variant:"outline",className:"border-slate-700 text-slate-500 text-[10px]",children:V.length})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:316:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:ee,children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:317:15",className:"h-3 w-3 mr-1"}),"新增"]})]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:321:9",className:"pt-0 space-y-1.5",children:[V.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:322:40",className:"text-[11px] text-slate-600",children:"无注解"}),V.map((m,g)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:324:13",className:"grid grid-cols-[1fr_1.4fr_auto] gap-2",children:[e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:325:15",value:m.key,placeholder:"deployment.kubernetes.io/revision",onChange:j=>J(g,{key:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:328:15",value:m.value,placeholder:"1",onChange:j=>J(g,{value:j.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:331:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400 hover:text-red-300",onClick:()=>me(g),children:e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:332:53",className:"h-3.5 w-3.5"})})]},g))]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:339:7",className:"sticky bottom-0 bg-slate-950/80 backdrop-blur border-t border-slate-800 p-3 flex items-center justify-between",children:[e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:340:9",className:"text-[11px] text-slate-500",children:["保存将通过 ",e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:341:17",className:"text-slate-400",children:"PUT application/yaml"})," 提交(自动剥离 status/managedFields 等只读字段)"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:343:9",className:"flex gap-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:344:11",variant:"outline",className:"border-slate-700 text-slate-400",onClick:c,children:"取消"}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:345:11",className:"bg-blue-600 hover:bg-blue-700",disabled:k,onClick:L,children:[k?e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:346:23",className:"h-4 w-4 animate-spin mr-1"}):e.jsx(it,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:346:75",className:"h-4 w-4 mr-1"}),"保存"]})]})]})]}):e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:150:7",className:"bg-slate-900 border-slate-800",children:e.jsx(Y,{"code-path":"src/components/kubernetes/DeploymentEditBasic.tsx:151:9",className:"p-8 text-center text-slate-500",children:"未获取到 manifest 数据,请使用 YAML 编辑模式直接修改。"})})}function Xt(t){const s=n=>{if(!n)return null;let c="none";return n.httpGet?c="httpGet":n.tcpSocket?c="tcpSocket":n.exec&&(c="exec"),{type:c,httpPath:n.httpGet?.path||"",httpPort:n.httpGet?.port??"",httpHost:n.httpGet?.host||"",tcpPort:n.tcpSocket?.port??"",execCommand:Array.isArray(n.exec?.command)?n.exec.command.join(` -`):n.exec?.command||"",initialDelaySeconds:n.initialDelaySeconds,periodSeconds:n.periodSeconds,timeoutSeconds:n.timeoutSeconds,successThreshold:n.successThreshold,failureThreshold:n.failureThreshold}},a=n=>{if(!n)return{type:"none"};let c="none";return n.exec?c="exec":n.httpGet?c="httpGet":n.tcpSocket&&(c="tcpSocket"),{type:c,execCommand:Array.isArray(n.exec?.command)?n.exec.command.join(` -`):"",httpPath:n.httpGet?.path||"",httpPort:n.httpGet?.port??"",tcpPort:n.tcpSocket?.port??""}},o=t.securityContext;return{name:t.name||"",image:t.image||"",imagePullPolicy:t.imagePullPolicy||"",command:Array.isArray(t.command)?t.command:[],args:Array.isArray(t.args)?t.args:[],workingDir:t.workingDir||"",env:(Array.isArray(t.env)?t.env:[]).map(n=>({name:n.name||"",value:n.value??""})),ports:(Array.isArray(t.ports)?t.ports:[]).map(n=>({name:n.name||"",containerPort:n.containerPort??"",protocol:n.protocol||"TCP"})),resources:{requests:t.resources?.requests||{},limits:t.resources?.limits||{}},livenessProbe:s(t.livenessProbe),readinessProbe:s(t.readinessProbe),startupProbe:s(t.startupProbe),lifecycle:t.lifecycle?{postStart:t.lifecycle.postStart?a(t.lifecycle.postStart):void 0,preStop:t.lifecycle.preStop?a(t.lifecycle.preStop):void 0}:null,securityContext:o?{runAsUser:o.runAsUser,runAsGroup:o.runAsGroup,runAsNonRoot:o.runAsNonRoot,privileged:o.privileged,readOnlyRootFilesystem:o.readOnlyRootFilesystem,allowPrivilegeEscalation:o.allowPrivilegeEscalation,capabilitiesAdd:o.capabilities?.add||[],capabilitiesDrop:o.capabilities?.drop||[]}:null,volumeMounts:(Array.isArray(t.volumeMounts)?t.volumeMounts:[]).map(n=>({name:n.name||"",mountPath:n.mountPath||"",subPath:n.subPath||"",readOnly:n.readOnly||!1}))}}function Qt(t=""){return{name:t,image:"",imagePullPolicy:"IfNotPresent",command:[],args:[],workingDir:"",env:[],ports:[],resources:{},livenessProbe:null,readinessProbe:null,startupProbe:null,lifecycle:null,securityContext:null,volumeMounts:[]}}function ft(t){if(!t||t.type==="none"||!t.type)return;const s={};if(t.type==="httpGet")s.httpGet={},t.httpPath&&(s.httpGet.path=t.httpPath),t.httpPort!==""&&t.httpPort!=null&&(s.httpGet.port=typeof t.httpPort=="number"?t.httpPort:Number(t.httpPort)),t.httpHost&&(s.httpGet.host=t.httpHost);else if(t.type==="tcpSocket")s.tcpSocket={},t.tcpPort!==""&&t.tcpPort!=null&&(s.tcpSocket.port=typeof t.tcpPort=="number"?t.tcpPort:Number(t.tcpPort));else if(t.type==="exec"){const a=(t.execCommand||"").split(` -`).map(o=>o.trim()).filter(Boolean);a.length&&(s.exec={command:a})}return t.initialDelaySeconds!=null&&(s.initialDelaySeconds=t.initialDelaySeconds),t.periodSeconds!=null&&(s.periodSeconds=t.periodSeconds),t.timeoutSeconds!=null&&(s.timeoutSeconds=t.timeoutSeconds),t.successThreshold!=null&&(s.successThreshold=t.successThreshold),t.failureThreshold!=null&&(s.failureThreshold=t.failureThreshold),Object.keys(s).length>0?s:void 0}function Zt(t){if(!(!t||t.type==="none"||!t.type)){if(t.type==="exec"){const s=(t.execCommand||"").split(` -`).map(a=>a.trim()).filter(Boolean);return s.length?{exec:{command:s}}:void 0}if(t.type==="httpGet"){const s={httpGet:{}};return t.httpPath&&(s.httpGet.path=t.httpPath),t.httpPort!==""&&t.httpPort!=null&&(s.httpGet.port=Number(t.httpPort)),s}if(t.type==="tcpSocket"){const s={tcpSocket:{}};return t.tcpPort!==""&&t.tcpPort!=null&&(s.tcpSocket.port=Number(t.tcpPort)),s}}}function es(t){const s={name:t.name};t.image&&(s.image=t.image),t.imagePullPolicy&&(s.imagePullPolicy=t.imagePullPolicy),t.workingDir&&(s.workingDir=t.workingDir),t.command.length>0&&(s.command=t.command),t.args.length>0&&(s.args=t.args),t.env.length>0&&(s.env=t.env.filter(l=>l.name.trim()).map(l=>{const x={name:l.name};return l.value!=null&&(x.value=l.value),x})),t.ports.length>0&&(s.ports=t.ports.filter(l=>l.containerPort!=="").map(l=>{const x={containerPort:typeof l.containerPort=="number"?l.containerPort:Number(l.containerPort)};return l.name&&(x.name=l.name),l.protocol&&(x.protocol=l.protocol),x}));const a=t.resources.requests,o=t.resources.limits,n=a&&Object.values(a).some(l=>l&&l.trim()),c=o&&Object.values(o).some(l=>l&&l.trim());(n||c)&&(s.resources={},n&&(s.resources.requests={},a.cpu?.trim()&&(s.resources.requests.cpu=a.cpu),a.memory?.trim()&&(s.resources.requests.memory=a.memory)),c&&(s.resources.limits={},o.cpu?.trim()&&(s.resources.limits.cpu=o.cpu),o.memory?.trim()&&(s.resources.limits.memory=o.memory)));const r=ft(t.livenessProbe);r&&(s.livenessProbe=r);const i=ft(t.readinessProbe);i&&(s.readinessProbe=i);const k=ft(t.startupProbe);if(k&&(s.startupProbe=k),t.lifecycle){const l={},x=Zt(t.lifecycle.postStart);x&&(l.postStart=x);const S=Zt(t.lifecycle.preStop);S&&(l.preStop=S),Object.keys(l).length>0&&(s.lifecycle=l)}if(t.securityContext){const l=t.securityContext,x={};l.runAsUser!==""&&l.runAsUser!=null&&(x.runAsUser=Number(l.runAsUser)),l.runAsGroup!==""&&l.runAsGroup!=null&&(x.runAsGroup=Number(l.runAsGroup)),l.runAsNonRoot!=null&&(x.runAsNonRoot=l.runAsNonRoot),l.privileged!=null&&(x.privileged=l.privileged),l.readOnlyRootFilesystem!=null&&(x.readOnlyRootFilesystem=l.readOnlyRootFilesystem),l.allowPrivilegeEscalation!=null&&(x.allowPrivilegeEscalation=l.allowPrivilegeEscalation);const S=(l.capabilitiesAdd||[]).filter(Boolean),C=(l.capabilitiesDrop||[]).filter(Boolean);(S.length||C.length)&&(x.capabilities={},S.length&&(x.capabilities.add=S),C.length&&(x.capabilities.drop=C)),Object.keys(x).length>0&&(s.securityContext=x)}return t.volumeMounts.length>0&&(s.volumeMounts=t.volumeMounts.filter(l=>l.name.trim()&&l.mountPath.trim()).map(l=>{const x={name:l.name,mountPath:l.mountPath};return l.subPath&&(x.subPath=l.subPath),l.readOnly&&(x.readOnly=!0),x})),s}function ts(t){return t.join(` -`)}function ss(t){return t.split(` -`).map(s=>s.trim()).filter(Boolean)}function Mn({container:t,onUpdate:s}){const a=t,o="flex items-center gap-1.5 text-xs font-semibold text-slate-300 mb-2";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:36:7",className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:37:9",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:38:11",className:"text-slate-400 text-xs",children:"容器名称"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:39:11",value:a.name,onChange:n=>s({name:n.target.value}),placeholder:"my-app",className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:43:9",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:44:11",className:"text-slate-400 text-xs",children:"容器镜像"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:45:11",value:a.image,onChange:n=>s({image:n.target.value}),placeholder:"nginx:1.25",className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:49:9",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:50:11",className:"text-slate-400 text-xs",children:"镜像拉取策略"}),e.jsxs(nt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:51:11",value:a.imagePullPolicy||"__none",onValueChange:n=>s({imagePullPolicy:n==="__none"?"":n}),children:[e.jsx(ot,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:52:13",className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 text-xs h-8",children:e.jsx(at,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:53:15"})}),e.jsxs(rt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:55:13",className:"bg-slate-900 border-slate-700",children:[e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:56:15",value:"__none",className:"text-slate-400",children:"不设置(默认 IfNotPresent)"}),e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:57:15",value:"Always",className:"text-slate-200",children:"Always"}),e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:58:15",value:"IfNotPresent",className:"text-slate-200",children:"IfNotPresent"}),e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:59:15",value:"Never",className:"text-slate-200",children:"Never"})]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:63:9",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:64:11",className:"text-slate-400 text-xs",children:"工作目录 (workingDir)"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:65:11",value:a.workingDir||"",onChange:n=>s({workingDir:n.target.value}),placeholder:"/app",className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:72:7",className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:73:9",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:74:11",className:"text-slate-400 text-xs",children:"启动命令 (command) — 每行一个"}),e.jsx(st,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:75:11",value:ts(a.command),placeholder:`/bin/sh --c`,onChange:n=>s({command:ss(n.target.value)}),className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs min-h-[60px]"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:79:9",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:80:11",className:"text-slate-400 text-xs",children:"启动参数 (args) — 每行一个"}),e.jsx(st,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:81:11",value:ts(a.args),placeholder:`--config=/etc/app.yaml ---debug`,onChange:n=>s({args:ss(n.target.value)}),className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs min-h-[60px]"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:88:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:89:9",className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:90:11",className:o,children:[e.jsx(us,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:90:39",className:"h-3.5 w-3.5 text-cyan-400"})," 环境变量"]}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:91:11",size:"sm",variant:"outline",className:"h-6 border-slate-700 text-slate-300 text-[11px]",onClick:()=>s({env:[...a.env,{name:"",value:""}]}),children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:93:13",className:"h-3 w-3 mr-1"}),"新增"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:96:9",className:"space-y-1.5",children:[a.env.map((n,c)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:98:13",className:"grid grid-cols-[1fr_1.4fr_auto] gap-2",children:[e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:99:15",value:n.name,placeholder:"KEY",onChange:r=>{const i=[...a.env];i[c]={...n,name:r.target.value},s({env:i})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:102:15",value:n.value||"",placeholder:"value",onChange:r=>{const i=[...a.env];i[c]={...n,value:r.target.value},s({env:i})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:105:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400",onClick:()=>s({env:a.env.filter((r,i)=>i!==c)}),children:e.jsx(be,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:107:17",className:"h-3.5 w-3.5"})})]},c)),a.env.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:111:34",className:"text-[11px] text-slate-600",children:"无环境变量"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:116:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:117:9",className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:118:11",className:o,children:[e.jsx(Ae,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:118:39",className:"h-3.5 w-3.5 text-indigo-400"})," 端口"]}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:119:11",size:"sm",variant:"outline",className:"h-6 border-slate-700 text-slate-300 text-[11px]",onClick:()=>s({ports:[...a.ports,{name:"",containerPort:"",protocol:"TCP"}]}),children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:121:13",className:"h-3 w-3 mr-1"}),"新增"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:124:9",className:"space-y-1.5",children:[a.ports.map((n,c)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:126:13",className:"grid grid-cols-[1fr_1fr_100px_auto] gap-2",children:[e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:127:15",value:n.name||"",placeholder:"http",onChange:r=>{const i=[...a.ports];i[c]={...n,name:r.target.value},s({ports:i})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:130:15",type:"number",value:n.containerPort,placeholder:"8080",onChange:r=>{const i=[...a.ports];i[c]={...n,containerPort:r.target.value},s({ports:i})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsxs(nt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:133:15",value:n.protocol||"TCP",onValueChange:r=>{const i=[...a.ports];i[c]={...n,protocol:r},s({ports:i})},children:[e.jsx(ot,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:134:17",className:"bg-slate-800 border-slate-700 text-slate-200 text-xs h-8",children:e.jsx(at,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:135:19"})}),e.jsxs(rt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:137:17",className:"bg-slate-900 border-slate-700",children:[e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:138:19",value:"TCP",className:"text-slate-200",children:"TCP"}),e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:139:19",value:"UDP",className:"text-slate-200",children:"UDP"}),e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:140:19",value:"SCTP",className:"text-slate-200",children:"SCTP"})]})]}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:143:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400",onClick:()=>s({ports:a.ports.filter((r,i)=>i!==c)}),children:e.jsx(be,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:145:17",className:"h-3.5 w-3.5"})})]},c)),a.ports.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:149:36",className:"text-[11px] text-slate-600",children:"无端口暴露"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:154:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:155:9",className:o,children:[e.jsx(on,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:155:37",className:"h-3.5 w-3.5 text-amber-400"})," 资源 (requests / limits)"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:156:9",className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:157:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:158:13",className:"text-[11px] text-slate-500",children:"CPU 请求"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:159:13",value:a.resources.requests?.cpu||"",placeholder:"100m",onChange:n=>s({resources:{...a.resources,requests:{...a.resources.requests,cpu:n.target.value}}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:163:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:164:13",className:"text-[11px] text-slate-500",children:"CPU 上限"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:165:13",value:a.resources.limits?.cpu||"",placeholder:"500m",onChange:n=>s({resources:{...a.resources,limits:{...a.resources.limits,cpu:n.target.value}}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:169:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:170:13",className:"text-[11px] text-slate-500",children:"内存请求"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:171:13",value:a.resources.requests?.memory||"",placeholder:"128Mi",onChange:n=>s({resources:{...a.resources,requests:{...a.resources.requests,memory:n.target.value}}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:175:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:176:13",className:"text-[11px] text-slate-500",children:"内存上限"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:177:13",value:a.resources.limits?.memory||"",placeholder:"512Mi",onChange:n=>s({resources:{...a.resources,limits:{...a.resources.limits,memory:n.target.value}}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:185:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:186:9",className:o,children:[e.jsx(an,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:186:37",className:"h-3.5 w-3.5 text-rose-400"})," 健康检查 (Probes)"]}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:187:9",className:"space-y-2",children:["livenessProbe","readinessProbe","startupProbe"].map(n=>e.jsx(Hn,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:189:13",label:{livenessProbe:"存活探针 (liveness)",readinessProbe:"就绪探针 (readiness)",startupProbe:"启动探针 (startup)"}[n],probe:a[n],onChange:c=>s({[n]:c})},n))})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:199:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:200:9",className:o,children:[e.jsx(gs,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:200:37",className:"h-3.5 w-3.5 text-yellow-400"})," 生命周期回调 (Lifecycle)"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:201:9",className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(ns,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:202:11",label:"启动后 (postStart)",handler:a.lifecycle?.postStart,onChange:n=>s({lifecycle:{...a.lifecycle,postStart:n}})}),e.jsx(ns,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:204:11",label:"终止前 (preStop)",handler:a.lifecycle?.preStop,onChange:n=>s({lifecycle:{...a.lifecycle,preStop:n}})})]}),!a.lifecycle&&e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:208:11",size:"sm",variant:"outline",className:"h-6 border-slate-700 text-slate-300 text-[11px] mt-1",onClick:()=>s({lifecycle:{postStart:{type:"none"},preStop:{type:"none"}}}),children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:210:13",className:"h-3 w-3 mr-1"}),"启用生命周期回调"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:216:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:217:9",className:o,children:[e.jsx(js,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:217:37",className:"h-3.5 w-3.5 text-emerald-400"})," 安全上下文 (SecurityContext)"]}),a.securityContext?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:219:11",className:"space-y-2 border border-slate-800 rounded-md p-3 bg-slate-950/30",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:220:13",className:"grid grid-cols-2 md:grid-cols-3 gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:221:15",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:222:17",className:"text-[11px] text-slate-500",children:"runAsUser"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:223:17",type:"number",value:a.securityContext.runAsUser??"",placeholder:"1000",onChange:n=>s({securityContext:{...a.securityContext,runAsUser:n.target.value===""?void 0:Number(n.target.value)}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:227:15",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:228:17",className:"text-[11px] text-slate-500",children:"runAsGroup"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:229:17",type:"number",value:a.securityContext.runAsGroup??"",placeholder:"1000",onChange:n=>s({securityContext:{...a.securityContext,runAsGroup:n.target.value===""?void 0:Number(n.target.value)}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:233:15",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:234:17",className:"text-[11px] text-slate-500",children:"Capabilities Add (逗号分隔)"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:235:17",value:(a.securityContext.capabilitiesAdd||[]).join(","),placeholder:"NET_ADMIN",onChange:n=>s({securityContext:{...a.securityContext,capabilitiesAdd:n.target.value.split(",").map(c=>c.trim()).filter(Boolean)}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:239:15",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:240:17",className:"text-[11px] text-slate-500",children:"Capabilities Drop (逗号分隔)"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:241:17",value:(a.securityContext.capabilitiesDrop||[]).join(","),placeholder:"ALL",onChange:n=>s({securityContext:{...a.securityContext,capabilitiesDrop:n.target.value.split(",").map(c=>c.trim()).filter(Boolean)}}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:246:13",className:"flex items-center gap-4 flex-wrap",children:[e.jsx(et,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:247:15",label:"runAsNonRoot",value:!!a.securityContext.runAsNonRoot,onChange:n=>s({securityContext:{...a.securityContext,runAsNonRoot:n}})}),e.jsx(et,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:249:15",label:"privileged",value:!!a.securityContext.privileged,onChange:n=>s({securityContext:{...a.securityContext,privileged:n}})}),e.jsx(et,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:251:15",label:"readOnlyRootFilesystem",value:!!a.securityContext.readOnlyRootFilesystem,onChange:n=>s({securityContext:{...a.securityContext,readOnlyRootFilesystem:n}})}),e.jsx(et,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:253:15",label:"allowPrivilegeEscalation",value:a.securityContext.allowPrivilegeEscalation??!1,onChange:n=>s({securityContext:{...a.securityContext,allowPrivilegeEscalation:n}})})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:256:13",size:"sm",variant:"ghost",className:"h-6 text-red-400 text-[11px]",onClick:()=>s({securityContext:null}),children:[e.jsx(be,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:258:15",className:"h-3 w-3 mr-1"}),"移除安全上下文"]})]}):e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:262:11",size:"sm",variant:"outline",className:"h-6 border-slate-700 text-slate-300 text-[11px]",onClick:()=>s({securityContext:{runAsNonRoot:!1,privileged:!1}}),children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:264:13",className:"h-3 w-3 mr-1"}),"启用安全上下文"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:270:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:271:9",className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:272:11",className:o,children:[e.jsx(rn,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:272:39",className:"h-3.5 w-3.5 text-teal-400"})," 卷挂载 (VolumeMounts)"]}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:273:11",size:"sm",variant:"outline",className:"h-6 border-slate-700 text-slate-300 text-[11px]",onClick:()=>s({volumeMounts:[...a.volumeMounts,{name:"",mountPath:"",subPath:"",readOnly:!1}]}),children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:275:13",className:"h-3 w-3 mr-1"}),"新增"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:278:9",className:"space-y-1.5",children:[a.volumeMounts.map((n,c)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:280:13",className:"grid grid-cols-[1fr_1fr_1fr_60px_auto] gap-2 items-center",children:[e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:281:15",value:n.name,placeholder:"volume 名称",onChange:r=>{const i=[...a.volumeMounts];i[c]={...n,name:r.target.value},s({volumeMounts:i})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:284:15",value:n.mountPath,placeholder:"/data",onChange:r=>{const i=[...a.volumeMounts];i[c]={...n,mountPath:r.target.value},s({volumeMounts:i})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:287:15",value:n.subPath||"",placeholder:"subPath (可选)",onChange:r=>{const i=[...a.volumeMounts];i[c]={...n,subPath:r.target.value},s({volumeMounts:i})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsxs("label",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:290:15",className:"flex items-center gap-1 text-[10px] text-slate-500 cursor-pointer",children:[e.jsx(Ht,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:291:17",checked:!!n.readOnly,onCheckedChange:r=>{const i=[...a.volumeMounts];i[c]={...n,readOnly:r},s({volumeMounts:i})}}),"RO"]}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:295:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400",onClick:()=>s({volumeMounts:a.volumeMounts.filter((r,i)=>i!==c)}),children:e.jsx(be,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:297:17",className:"h-3.5 w-3.5"})})]},c)),a.volumeMounts.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:301:43",className:"text-[11px] text-slate-600",children:"无卷挂载"})]})]})]})}function Hn({label:t,probe:s,onChange:a}){const o=!!s,n=s||{type:"httpGet"},c=r=>a({...n,...r});return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:315:5",className:"border border-slate-800 rounded-md p-2.5 bg-slate-950/30",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:316:7",className:"flex items-center justify-between mb-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:317:9",className:"text-xs text-slate-300 font-medium",children:t}),e.jsx(Ht,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:318:9",checked:o,onCheckedChange:r=>a(r?{type:"httpGet",httpPath:"/",httpPort:8080,initialDelaySeconds:10,periodSeconds:10}:null)})]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:323:11",className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:324:13",className:"text-[10px] text-slate-500 w-8",children:"类型"}),e.jsxs(nt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:325:13",value:n.type||"httpGet",onValueChange:r=>c({type:r}),children:[e.jsx(ot,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:326:15",className:"bg-slate-800 border-slate-700 text-slate-200 text-xs h-7 flex-1",children:e.jsx(at,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:327:17"})}),e.jsxs(rt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:329:15",className:"bg-slate-900 border-slate-700",children:[e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:330:17",value:"httpGet",className:"text-slate-200",children:"HTTP GET"}),e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:331:17",value:"tcpSocket",className:"text-slate-200",children:"TCP Socket"}),e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:332:17",value:"exec",className:"text-slate-200",children:"Exec 命令"})]})]})]}),n.type==="httpGet"&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:337:13",className:"grid grid-cols-3 gap-2 mb-2",children:[e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:338:15",value:n.httpPath||"",placeholder:"/healthz",onChange:r=>c({httpPath:r.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:341:15",type:"number",value:n.httpPort??"",placeholder:"8080",onChange:r=>c({httpPort:r.target.value===""?void 0:Number(r.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:344:15",value:n.httpHost||"",placeholder:"host (可选)",onChange:r=>c({httpHost:r.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]}),n.type==="tcpSocket"&&e.jsx("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:350:13",className:"mb-2",children:e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:351:15",type:"number",value:n.tcpPort??"",placeholder:"端口",onChange:r=>c({tcpPort:r.target.value===""?void 0:Number(r.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})}),n.type==="exec"&&e.jsx("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:357:13",className:"mb-2",children:e.jsx(st,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:358:15",value:n.execCommand||"",placeholder:"每行一个命令片段,如:\\ncat\\n/tmp/healthy",onChange:r=>c({execCommand:r.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs min-h-[50px]"})}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:363:11",className:"grid grid-cols-5 gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:364:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:365:15",className:"text-[10px] text-slate-500",children:"延迟(s)"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:366:15",type:"number",value:n.initialDelaySeconds??"",placeholder:"10",onChange:r=>c({initialDelaySeconds:r.target.value===""?void 0:Number(r.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:370:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:371:15",className:"text-[10px] text-slate-500",children:"间隔(s)"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:372:15",type:"number",value:n.periodSeconds??"",placeholder:"10",onChange:r=>c({periodSeconds:r.target.value===""?void 0:Number(r.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:376:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:377:15",className:"text-[10px] text-slate-500",children:"超时(s)"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:378:15",type:"number",value:n.timeoutSeconds??"",placeholder:"1",onChange:r=>c({timeoutSeconds:r.target.value===""?void 0:Number(r.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:382:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:383:15",className:"text-[10px] text-slate-500",children:"成功"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:384:15",type:"number",value:n.successThreshold??"",placeholder:"1",onChange:r=>c({successThreshold:r.target.value===""?void 0:Number(r.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:388:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:389:15",className:"text-[10px] text-slate-500",children:"失败"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:390:15",type:"number",value:n.failureThreshold??"",placeholder:"3",onChange:r=>c({failureThreshold:r.target.value===""?void 0:Number(r.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]})]})]})]})}function ns({label:t,handler:s,onChange:a}){const o=s||{type:"none"},n=!o.type||o.type==="none"?"__none":o.type;return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:406:5",className:"border border-slate-800 rounded-md p-2.5 bg-slate-950/30",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:407:7",className:"text-xs text-slate-300 font-medium block mb-2",children:t}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:408:7",className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:409:9",className:"text-[10px] text-slate-500 w-8",children:"类型"}),e.jsxs(nt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:410:9",value:n,onValueChange:c=>a({...o,type:c==="__none"?"none":c}),children:[e.jsx(ot,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:411:11",className:"bg-slate-800 border-slate-700 text-slate-200 text-xs h-7 flex-1",children:e.jsx(at,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:412:13"})}),e.jsxs(rt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:414:11",className:"bg-slate-900 border-slate-700",children:[e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:415:13",value:"__none",className:"text-slate-400",children:"不设置"}),e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:416:13",value:"exec",className:"text-slate-200",children:"Exec 命令"}),e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:417:13",value:"httpGet",className:"text-slate-200",children:"HTTP GET"}),e.jsx(fe,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:418:13",value:"tcpSocket",className:"text-slate-200",children:"TCP Socket"})]})]})]}),o.type==="exec"&&e.jsx(st,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:423:9",value:o.execCommand||"",placeholder:"每行一个命令片段",onChange:c=>a({...o,execCommand:c.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs min-h-[50px]"}),o.type==="httpGet"&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:428:9",className:"grid grid-cols-2 gap-2",children:[e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:429:11",value:o.httpPath||"",placeholder:"/shutdown",onChange:c=>a({...o,httpPath:c.target.value}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:432:11",type:"number",value:o.httpPort??"",placeholder:"8080",onChange:c=>a({...o,httpPort:c.target.value===""?void 0:Number(c.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]}),o.type==="tcpSocket"&&e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:438:9",type:"number",value:o.tcpPort??"",placeholder:"端口",onChange:c=>a({...o,tcpPort:c.target.value===""?void 0:Number(c.target.value)}),className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-7"})]})}function et({label:t,value:s,onChange:a}){return e.jsxs("label",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:448:5",className:"flex items-center gap-1.5 cursor-pointer",children:[e.jsx(Ht,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:449:7",checked:s,onCheckedChange:a}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:450:7",className:"text-[11px] text-slate-400 font-mono",children:t})]})}function os({title:t,description:s,icon:a,containers:o,accentColor:n,onAdd:c,onRemove:r,onUpdate:i,onDuplicate:k}){const l=dt(),[x,S]=d.useState(new Set([0])),C=w=>{S(P=>{const I=new Set(P);return I.has(w)?I.delete(w):I.add(w),I})},y=n==="blue"?"border-blue-500/30":"border-purple-500/30",b=n==="blue"?"bg-blue-500/5":"bg-purple-500/5";return e.jsxs(U,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:37:5",className:"bg-slate-900 border-slate-800",children:[e.jsxs(he,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:38:7",className:"pb-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:39:9",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:40:11",className:"flex items-center gap-2",children:[a,e.jsx(ue,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:42:13",className:"text-sm text-slate-200",children:t}),e.jsx(ae,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:43:13",variant:"outline",className:"border-slate-700 text-slate-400 text-[10px]",children:o.length})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:45:11",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:c,children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:46:13",className:"h-3 w-3 mr-1"}),"新增容器"]})]}),e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:49:9",className:"text-[11px] text-slate-600",children:s})]}),e.jsxs(Y,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:51:7",className:"pt-0 space-y-3",children:[o.length===0&&e.jsx("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:53:11",className:"text-center py-6 text-slate-600 text-xs",children:"暂无容器,点击「新增容器」添加"}),o.map((w,P)=>{const I=x.has(P)||o.length===1;return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:58:13",className:`rounded-lg border ${y} overflow-hidden`,children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:60:15",className:`flex items-center justify-between px-3 py-2 ${b} cursor-pointer`,onClick:()=>C(P),children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:61:17",className:"flex items-center gap-2",children:[I?e.jsx(xs,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:62:29",className:"h-4 w-4 text-slate-500"}):e.jsx(hs,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:62:82",className:"h-4 w-4 text-slate-500"}),e.jsx(Ue,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:63:19",className:`h-4 w-4 ${n==="blue"?"text-blue-400":"text-purple-400"}`}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:64:19",className:"text-sm font-mono text-slate-200 font-semibold",children:w.name||"(未命名)"}),w.image&&e.jsx("code",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:65:31",className:"text-[10px] text-slate-500 font-mono truncate max-w-[300px]",children:w.image})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:67:17",className:"flex items-center gap-1",onClick:M=>M.stopPropagation(),children:[k&&e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:69:21",variant:"ghost",size:"icon",className:"h-7 w-7 text-slate-500 hover:text-slate-300",title:"复制",onClick:()=>k(P),children:e.jsx(fs,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:71:23",className:"h-3.5 w-3.5"})}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:74:19",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-400 hover:text-red-300",title:"删除",onClick:async()=>{await l({title:"删除容器",description:`确认删除容器「${w.name}」?`,confirmText:"删除",variant:"destructive"})&&r(P)},children:e.jsx(be,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:84:21",className:"h-3.5 w-3.5"})})]})]}),I&&e.jsx("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:90:17",className:"p-3 space-y-4 bg-slate-950/30",children:e.jsx(Mn,{"code-path":"src/components/kubernetes/deployment-edit/ContainerGroupSection.tsx:91:19",container:w,onUpdate:M=>i(P,M)})})]},P)})]})]})}function In({clusterCode:t,namespace:s,deploymentName:a,manifest:o,onSaved:n,onCancel:c}){const{toast:r}=Me(),[i,k]=d.useState(!1),[l,x]=d.useState(!o),[S,C]=d.useState(o||{}),[y,b]=d.useState([]),[w,P]=d.useState([]),[I,M]=d.useState([]);d.useEffect(()=>{if(!o){x(!1);return}C(o);const N=o?.spec?.template?.spec||{};b((Array.isArray(N.containers)?N.containers:[]).map(Xt)),P((Array.isArray(N.initContainers)?N.initContainers:[]).map(Xt)),M((Array.isArray(N.imagePullSecrets)?N.imagePullSecrets:[]).map(_=>_.name||"")),x(!1)},[o]);const F=(N,_)=>{b(J=>J.map((ee,me)=>me===N?{...ee,..._}:ee))},V=()=>{b(N=>[...N,Qt(`container-${N.length+1}`)])},X=N=>{b(_=>_.filter((J,ee)=>ee!==N))},q=N=>{b(_=>{const J=JSON.parse(JSON.stringify(_[N]));J.name=`${J.name}-copy`;const ee=[..._];return ee.splice(N+1,0,J),ee})},W=(N,_)=>{P(J=>J.map((ee,me)=>me===N?{...ee,..._}:ee))},Q=()=>{P(N=>[...N,Qt(`init-${N.length+1}`)])},$=N=>{P(_=>_.filter((J,ee)=>ee!==N))},Z=async()=>{for(const N of[...w,...y]){if(!N.name.trim()){r({title:"保存失败",description:"容器名称不能为空",variant:"destructive"});return}if(!N.image.trim()){r({title:"保存失败",description:`容器 ${N.name} 的镜像不能为空`,variant:"destructive"});return}}k(!0);try{const N=JSON.parse(JSON.stringify(S));N.spec=N.spec||{},N.spec.template=N.spec.template||{},N.spec.template.spec=N.spec.template.spec||{},N.spec.template.spec.containers=y.map(es),N.spec.template.spec.initContainers=w.length>0?w.map(es):void 0,N.spec.template.spec.imagePullSecrets=I.filter(_=>_.trim()).length>0?I.filter(_=>_.trim()).map(_=>({name:_})):void 0,await pt(t,s,a,N),r({title:"容器配置已保存",description:`${a} 更新已提交`}),n(N)}catch(N){r({title:"保存失败",description:N?.message||String(N),variant:"destructive"})}finally{k(!1)}};return l?e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:113:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:114:9",className:"p-12 text-center",children:[e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:115:11",className:"h-6 w-6 animate-spin mx-auto text-slate-500"}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:116:11",className:"text-slate-500 mt-3 text-sm",children:"加载中..."})]})}):o?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:132:5",className:"space-y-4",children:[e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:134:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:135:9",className:"pb-3",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:136:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(cn,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:137:13",className:"h-4 w-4 text-amber-400"}),"镜像拉取凭证 (imagePullSecrets)",e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:139:13",variant:"outline",className:"border-slate-700 text-slate-500 text-[10px]",children:"Pod 级别"})]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:142:9",className:"pt-0 space-y-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:143:11",className:"flex items-center gap-2 flex-wrap",children:[I.map((N,_)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:145:15",className:"flex items-center gap-1 bg-slate-800 rounded px-2 py-1",children:[e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:146:17",className:"text-xs text-slate-300 font-mono",children:N}),e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:147:17",onClick:()=>M(J=>J.filter((ee,me)=>me!==_)),className:"text-red-400 hover:text-red-300 ml-1",children:e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:148:68",className:"h-3 w-3"})})]},_)),I.length===0&&e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:151:47",className:"text-[11px] text-slate-600",children:"无"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:153:11",className:"flex gap-2",children:[e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:154:13",placeholder:"输入 Secret 名称后回车",className:"bg-slate-800 border-slate-700 text-slate-200 text-xs h-8",onKeyDown:N=>{if(N.key==="Enter"){const _=N.target.value.trim();_&&(M(J=>[...J,_]),N.target.value="")}}}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:161:13",size:"sm",variant:"outline",className:"h-8 border-slate-700 text-slate-300 text-xs",onClick:()=>M(N=>[...N,""]),children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:163:15",className:"h-3 w-3 mr-1"}),"新增"]})]})]})]}),e.jsx(os,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:170:7",title:"初始化容器",description:"在主容器启动前按顺序执行的容器,用于初始化环境",icon:e.jsx(Ns,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:173:15",className:"h-4 w-4 text-purple-400"}),containers:w,accentColor:"purple",onAdd:Q,onRemove:$,onUpdate:W}),e.jsx(os,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:182:7",title:"工作容器",description:"Deployment 运行的主容器,定义应用进程及其运行时配置",icon:e.jsx(Ue,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:185:15",className:"h-4 w-4 text-blue-400"}),containers:y,accentColor:"blue",onAdd:V,onRemove:X,onUpdate:F,onDuplicate:q}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:195:7",className:"sticky bottom-0 bg-slate-950/80 backdrop-blur border-t border-slate-800 p-3 flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:196:9",className:"text-[11px] text-slate-500",children:["共 ",e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:197:13",className:"text-slate-300 font-semibold",children:w.length})," 个初始化容器 +",e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:198:11",className:"text-slate-300 font-semibold ml-1",children:y.length})," 个工作容器"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:200:9",className:"flex gap-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:201:11",variant:"outline",className:"border-slate-700 text-slate-400",onClick:c,children:"取消"}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:202:11",className:"bg-blue-600 hover:bg-blue-700",disabled:i,onClick:Z,children:[i?e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:203:23",className:"h-4 w-4 animate-spin mr-1"}):e.jsx(it,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:203:75",className:"h-4 w-4 mr-1"}),"保存"]})]})]})]}):e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:123:7",className:"bg-slate-900 border-slate-800",children:e.jsx(Y,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:124:9",className:"p-8 text-center text-slate-500",children:"未获取到 manifest 数据,请使用 YAML 编辑模式直接修改。"})})}function Nt(t){const s=Array.isArray(t)?t:t?.list||t?.data||[];return Array.isArray(s)?s.map(a=>String(a?.name||"")).filter(Boolean).sort():[]}function St({label:t,value:s,options:a,loading:o,onChange:n,onRefresh:c,onCreate:r}){const i=s&&!a.includes(s);return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:36:5",className:"flex items-center gap-2 flex-wrap flex-1 min-w-0",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:37:7",className:"text-[10px] text-slate-500 w-20 shrink-0",children:t}),e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:38:7",value:s||"",onChange:k=>n(k.target.value),disabled:o,className:"h-7 flex-1 min-w-[160px] max-w-xs bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-2 font-mono",children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:44:9",value:"",disabled:!0,children:a.length===0?"暂无资源":"请选择"}),i&&e.jsxs("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:45:20",value:s,children:[s,"(未在集群中找到)"]}),a.map(k=>e.jsx("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:46:29",value:k,children:k},k))]}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:48:7",type:"button",size:"sm",variant:"outline",className:"h-7 px-2 border-slate-700 text-slate-400 text-xs",onClick:c,disabled:o,children:o?e.jsx(ve,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:49:20",className:"h-3 w-3 animate-spin"}):e.jsx(Ye,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:49:67",className:"h-3 w-3"})}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:51:7",type:"button",size:"sm",variant:"outline",className:"h-7 px-2 border-slate-700 text-blue-400 text-xs",onClick:r,children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:52:9",className:"h-3 w-3 mr-0.5"}),"新建"]}),a.length===0&&!i&&e.jsxs("span",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:55:9",className:"text-[10px] text-amber-400/90",children:["命名空间内暂无",t,",请先新建"]})]})}function Bn({vol:t,resources:s,resourcesLoading:a,onChange:o,onRefreshResources:n,onCreateResource:c}){return t.type==="persistentVolumeClaim"?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:75:7",className:"space-y-2",children:[e.jsx(St,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:76:9",label:"PVC 关联",value:t.pvcName||"",options:s.pvcs,loading:a,onChange:r=>o({pvcName:r}),onRefresh:n,onCreate:()=>c("pvcs")}),e.jsxs("label",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:85:9",className:"flex items-center gap-1.5 text-xs text-slate-400 cursor-pointer whitespace-nowrap pl-[88px]",children:[e.jsx("input",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:86:11",type:"checkbox",checked:!!t.pvcReadOnly,onChange:r=>o({pvcReadOnly:r.target.checked}),className:"accent-blue-500"}),"卷只读"]})]}):t.type==="emptyDir"?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:94:7",className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:95:9",className:"text-[10px] text-slate-500 w-20 shrink-0",children:"介质"}),e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:96:9",value:t.medium||"",onChange:r=>o({medium:r.target.value}),className:"h-7 w-28 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5",children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:98:11",value:"",children:"默认磁盘"}),e.jsx("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:99:11",value:"Memory",children:"Memory"})]}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:101:9",value:t.sizeLimit||"",onChange:r=>o({sizeLimit:r.target.value}),placeholder:"sizeLimit 如 512Mi",className:"h-7 flex-1 min-w-[120px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]}):t.type==="hostPath"?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:108:7",className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:109:9",className:"text-[10px] text-slate-500 w-20 shrink-0",children:"主机路径"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:110:9",value:t.path||"",onChange:r=>o({path:r.target.value}),placeholder:"/data/app",className:"h-7 flex-1 min-w-[160px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:112:9",value:t.pathType||"Directory",onChange:r=>o({pathType:r.target.value}),className:"h-7 w-28 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5",children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:114:11",value:"Directory",children:"Directory"}),e.jsx("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:115:11",value:"File",children:"File"}),e.jsx("option",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:116:11",value:"",children:"默认"})]})]}):t.type==="nfs"?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:123:7",className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:124:9",className:"text-[10px] text-slate-500 w-20 shrink-0",children:"NFS"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:125:9",value:t.nfsServer||"",onChange:r=>o({nfsServer:r.target.value}),placeholder:"Server IP",className:"h-7 w-36 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:127:9",value:t.nfsPath||"",onChange:r=>o({nfsPath:r.target.value}),placeholder:"/export/path",className:"h-7 flex-1 min-w-[120px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]}):t.type==="configMap"?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:134:7",className:"space-y-2",children:[e.jsx(St,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:135:9",label:"ConfigMap",value:t.configMapName||"",options:s.configMaps,loading:a,onChange:r=>o({configMapName:r}),onRefresh:n,onCreate:()=>c("configmaps")}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:144:9",className:"flex items-center gap-2 pl-[88px]",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:145:11",className:"text-[10px] text-slate-500 shrink-0",children:"键映射"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:146:11",value:t.cmItems||"",onChange:r=>o({cmItems:r.target.value}),placeholder:"key:path(可选,挂载子项)",className:"h-7 flex-1 max-w-md bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]})]}):t.type==="secret"?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:154:7",className:"space-y-2",children:[e.jsx(St,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:155:9",label:"Secret",value:t.secretName||"",options:s.secrets,loading:a,onChange:r=>o({secretName:r}),onRefresh:n,onCreate:()=>c("secrets")}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:164:9",className:"flex items-center gap-2 pl-[88px]",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:165:11",className:"text-[10px] text-slate-500 shrink-0",children:"键映射"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:166:11",value:t.secItems||"",onChange:r=>o({secItems:r.target.value}),placeholder:"key:path(可选,挂载子项)",className:"h-7 flex-1 max-w-md bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]})]}):t.type==="custom"?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-storage-fields.tsx:173:12",className:"text-[11px] text-amber-400/80",children:"未识别卷类型,保存时将保留原始 YAML 结构"}):null}function ct(t=""){return{containerName:t,mountPath:"",subPath:"",readOnly:!1}}function Rn(t=""){return{volume:{name:"",type:"emptyDir"},mounts:[ct(t)]}}const On=["kube-api-access-","default-token-","kube-"];function Et(t){if(!t||typeof t!="object")return!1;const s=String(t.name||"");return On.some(a=>s.startsWith(a))?!0:!!(t.projected||t.downwardAPI||t.csi||t.ephemeral)}function as(t){const s=t?.trim();if(!s)return;if(s.startsWith("["))try{const o=JSON.parse(s);if(Array.isArray(o))return o.filter(n=>n?.key&&n?.path)}catch{}const a=s.split(",").map(o=>o.trim()).filter(Boolean).map(o=>{const n=o.indexOf(":");return n<=0?null:{key:o.slice(0,n).trim(),path:o.slice(n+1).trim()}}).filter(Boolean);return a.length?a:void 0}function $n(t){if(!t||typeof t!="object")return{name:"",type:"emptyDir"};const s=t.name||"";return t.persistentVolumeClaim?{name:s,type:"persistentVolumeClaim",pvcName:t.persistentVolumeClaim.claimName||"",pvcReadOnly:!!t.persistentVolumeClaim.readOnly}:t.nfs?{name:s,type:"nfs",nfsServer:t.nfs.server||"",nfsPath:t.nfs.path||"",nfsReadOnly:!!t.nfs.readOnly}:t.configMap?{name:s,type:"configMap",configMapName:t.configMap.name||"",cmItems:t.configMap.items?JSON.stringify(t.configMap.items):""}:t.secret?{name:s,type:"secret",secretName:t.secret.secretName||"",secItems:t.secret.items?JSON.stringify(t.secret.items):""}:t.hostPath?{name:s,type:"hostPath",path:t.hostPath.path||"",pathType:t.hostPath.type||""}:t.emptyDir!=null?{name:s,type:"emptyDir",medium:t.emptyDir.medium||"",sizeLimit:t.emptyDir.sizeLimit||""}:Et(t)?{name:s,type:"custom",_raw:t}:{name:s,type:"custom",_raw:t}}function Ps(t){if(t.type==="custom"&&t._raw)return JSON.parse(JSON.stringify(t._raw));const s=t.name?.trim();if(!s)return null;const a={name:s};switch(t.type){case"emptyDir":{const o={};t.medium?.trim()&&(o.medium=t.medium.trim()),t.sizeLimit?.trim()&&(o.sizeLimit=t.sizeLimit.trim()),a.emptyDir=o;break}case"hostPath":{const o={path:t.path?.trim()||"/"};t.pathType?.trim()&&(o.type=t.pathType.trim()),a.hostPath=o;break}case"configMap":{const o=t.configMapName?.trim();if(!o)return null;const n={name:o},c=as(t.cmItems);c&&(n.items=c),a.configMap=n;break}case"secret":{const o=t.secretName?.trim();if(!o)return null;const n={secretName:o},c=as(t.secItems);c&&(n.items=c),a.secret=n;break}case"persistentVolumeClaim":{const o=t.pvcName?.trim();if(!o)return null;const n={claimName:o};t.pvcReadOnly&&(n.readOnly=!0),a.persistentVolumeClaim=n;break}case"nfs":{const o=t.nfsServer?.trim(),n=t.nfsPath?.trim();if(!o||!n)return null;const c={server:o,path:n};t.nfsReadOnly&&(c.readOnly=!0),a.nfs=c;break}default:return null}return a}function _n(t,s){return{containerName:t,volumeName:s.name||"",mountPath:s.mountPath||"",subPath:s.subPath||"",readOnly:!!s.readOnly}}function Ln(t){if(!t.volumeName?.trim()||!t.mountPath?.trim())return null;const s={name:t.volumeName.trim(),mountPath:t.mountPath.trim()};return t.subPath?.trim()&&(s.subPath=t.subPath.trim()),t.readOnly&&(s.readOnly=!0),s}const zn=["/var/run/secrets/kubernetes.io/serviceaccount"];function As(t,s){if(!t)return!1;if(s.has(t.name))return!0;const a=t.mountPath||"";return zn.some(o=>a.startsWith(o))}function Wn(t){const s=t?.spec?.template?.spec||{},a=Array.isArray(s.volumes)?s.volumes:[],o=a.filter(Et),n=a.filter(l=>!Et(l)),c=[...Array.isArray(s.containers)?s.containers:[],...Array.isArray(s.initContainers)?s.initContainers:[]],r=c.map(l=>l.name||"(unnamed)"),i=new Set(o.map(l=>l.name)),k=[];for(const l of c){const x=l.name||"(unnamed)",S=Array.isArray(l.volumeMounts)?l.volumeMounts:[];for(const C of S)As(C,i)||k.push(_n(x,C))}return{volumes:n.map($n),mounts:k,containers:r,passthroughVolumes:o}}function Gn(t){const{volumes:s,mounts:a,containers:o,passthroughVolumes:n}=Wn(t),c=o.find(i=>i!=="(unnamed)")||o[0]||"";return{entries:s.map(i=>{const k=a.filter(l=>l.volumeName===i.name);return{volume:i,mounts:k.length>0?k.map(l=>({containerName:l.containerName,mountPath:l.mountPath,subPath:l.subPath,readOnly:l.readOnly})):[ct(c)]}}),containers:o,passthroughVolumes:n}}function Vn(t){const s=t.map(o=>o.volume),a=[];for(const o of t){const n=o.volume.name.trim();if(n)for(const c of o.mounts)c.mountPath.trim()&&a.push({containerName:c.containerName,volumeName:n,mountPath:c.mountPath.trim(),subPath:c.subPath.trim(),readOnly:c.readOnly})}return{volumes:s,mounts:a}}function Fn(t,s,a,o){const n=JSON.parse(JSON.stringify(t));n.spec=n.spec||{},n.spec.template=n.spec.template||{},n.spec.template.spec=n.spec.template.spec||{};const c=n.spec.template.spec,r=s.map(Ps).filter(Boolean),i=[...o,...r];i.length>0?c.volumes=i:delete c.volumes;const k=new Set(o.map(x=>x.name)),l=x=>{const S=x.name||"(unnamed)",y=(Array.isArray(x.volumeMounts)?x.volumeMounts:[]).filter(P=>As(P,k)),b=a.filter(P=>P.containerName===S).map(Ln).filter(Boolean),w=[...y,...b];w.length>0?x.volumeMounts=w:delete x.volumeMounts};return(c.containers||[]).forEach(l),(c.initContainers||[]).forEach(l),n}const Dt=[{key:"persistentVolumeClaim",label:"存储卷声明",icon:tt,color:"text-emerald-400"},{key:"emptyDir",label:"临时目录(EmptyDir)",icon:ln,color:"text-slate-400"},{key:"hostPath",label:"HostPath",icon:bs,color:"text-amber-400"},{key:"nfs",label:"NFS",icon:Mt,color:"text-purple-400"},{key:"configMap",label:"配置字典",icon:dn,color:"text-blue-400"},{key:"secret",label:"密文",icon:ks,color:"text-rose-400"}],Un=new Set(Dt.map(t=>t.key));function Yn({clusterCode:t,namespace:s,deploymentName:a,manifest:o,onSaved:n,onCancel:c}){const{toast:r}=Me(),[i,k]=d.useState(!1),[l,x]=d.useState(!o),[S,C]=d.useState(o||{}),[y,b]=d.useState([]),[w,P]=d.useState([]),[I,M]=d.useState([]),[F,V]=d.useState({configMaps:[],secrets:[],pvcs:[]}),[X,q]=d.useState(!1),[W,Q]=d.useState(null),$=d.useCallback(async()=>{if(!(!t||!s)){q(!0);try{const[R,p,h]=await Promise.all([K.getNamespaceConfigMaps(t,s).catch(()=>[]),K.getNamespaceSecrets(t,s).catch(()=>[]),K.getPVCs(t,s).catch(()=>[])]);V({configMaps:Nt(R),secrets:Nt(p),pvcs:Nt(h)})}finally{q(!1)}}},[t,s]);d.useEffect(()=>{$()},[$]),d.useEffect(()=>{if(!o){x(!1);return}C(o);const R=Gn(o);b(R.entries),P(R.containers),M(R.passthroughVolumes),x(!1)},[o]);const Z=w.find(R=>R!=="(unnamed)")||w[0]||"",N=(R,p)=>b(h=>h.map((u,A)=>A===R?{...u,volume:{...u.volume,...p}}:u)),_=(R,p,h)=>b(u=>u.map((A,L)=>L!==R?A:{...A,mounts:A.mounts.map((m,g)=>g===p?{...m,...h}:m)})),J=R=>b(p=>p.map((h,u)=>u!==R?h:{...h,mounts:[...h.mounts,ct(Z)]})),ee=(R,p)=>b(h=>h.map((u,A)=>{if(A!==R)return u;const L=u.mounts.filter((m,g)=>g!==p);return{...u,mounts:L.length>0?L:[ct(Z)]}})),me=()=>b(R=>[...R,Rn(Z)]),ye=R=>b(p=>p.filter((h,u)=>u!==R)),ge=async()=>{for(const R of y){if(!R.volume.name.trim()){r({title:"请填写数据卷名称",variant:"destructive"});return}if(!Ps(R.volume)){const h=R.volume.type==="configMap"?"请选择 ConfigMap":R.volume.type==="secret"?"请选择 Secret":R.volume.type==="persistentVolumeClaim"?"请选择 PVC":"的类型必填项";r({title:"数据卷配置不完整",description:`请为「${R.volume.name}」${h}`,variant:"destructive"});return}if(R.mounts.filter(h=>h.mountPath.trim()).length===0){r({title:"请填写挂载路径",description:`数据卷「${R.volume.name}」需至少挂载到一个容器`,variant:"destructive"});return}}k(!0);try{const{volumes:R,mounts:p}=Vn(y),h=Fn(S,R,p,I);await pt(t,s,a,h),r({title:"存储配置已保存",description:`${a} 更新已提交`}),n(h)}catch(R){r({title:"保存失败",description:R?.message||String(R),variant:"destructive"})}finally{k(!1)}};return l?e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:165:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:166:9",className:"p-12 text-center",children:[e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:167:11",className:"h-6 w-6 animate-spin mx-auto text-slate-500"}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:168:11",className:"text-slate-500 mt-3 text-sm",children:"加载中..."})]})}):o?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:183:5",className:"space-y-4",children:[W&&e.jsx(Cs,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:185:9",clusterCode:t,namespace:s,resource:W,name:"",isCreate:!0,onClose:()=>Q(null),onSaved:()=>{$(),Q(null)}}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:195:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:196:9",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:197:11",className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:198:13",children:[e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:199:15",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(tt,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:200:17",className:"h-4 w-4 text-emerald-400"}),"数据卷",e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:202:17",variant:"outline",className:"border-slate-700 text-slate-400",children:y.length})]}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:204:15",className:"text-[11px] text-slate-500 mt-1",children:"定义数据卷,并将其挂载到工作负载的容器中"})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:206:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs shrink-0",onClick:me,children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:207:15",className:"h-3 w-3 mr-1"}),"添加数据卷"]})]})}),e.jsx(Y,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:211:9",className:"pt-0 space-y-4",children:y.length===0?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:213:13",className:"text-center py-10 text-slate-500 text-sm border border-dashed border-slate-800 rounded-lg",children:[e.jsx(tt,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:214:15",className:"h-8 w-8 mx-auto mb-2 text-slate-700"}),"未配置数据卷,点击「添加数据卷」开始"]}):y.map((R,p)=>{const h=R.volume,u=Dt.find(m=>m.key===h.type),A=u?.icon||pn,L=Un.has(h.type)?h.type:"emptyDir";return e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:223:15",className:"bg-slate-950/60 border border-slate-800 rounded-lg",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:225:17",className:"p-3 space-y-2.5 border-b border-slate-800/80",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:226:19",className:"flex items-center gap-2 flex-wrap",children:[e.jsx(A,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:227:21",className:`h-4 w-4 ${u?.color||"text-slate-400"}`}),e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:228:21",className:"text-xs text-slate-400 shrink-0",children:"数据卷名称"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:229:21",value:h.name,onChange:m=>{const g=m.target.value,j={name:g};h.type==="configMap"&&!h.configMapName&&(j.configMapName=g),h.type==="secret"&&!h.secretName&&(j.secretName=g),h.type==="persistentVolumeClaim"&&!h.pvcName&&(j.pvcName=g),N(p,j)},placeholder:"如 app-logs / fluent-bit-config",className:"h-8 w-44 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"}),e.jsx("select",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:243:21",value:L,onChange:m=>{const g=m.target.value,j={type:g};g==="configMap"&&F.configMaps.length===1&&(j.configMapName=F.configMaps[0]),g==="secret"&&F.secrets.length===1&&(j.secretName=F.secrets[0]),g==="persistentVolumeClaim"&&F.pvcs.length===1&&(j.pvcName=F.pvcs[0]),N(p,j)},className:"h-8 min-w-[168px] bg-slate-800 border border-slate-700 rounded-md text-xs text-slate-300 px-2",children:Dt.map(m=>e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:256:25",value:m.key,children:m.label},m.key))}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:259:21",size:"icon",variant:"ghost",className:"h-8 w-8 text-red-400 ml-auto",onClick:()=>ye(p),children:e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:260:23",className:"h-4 w-4"})})]}),e.jsx(Bn,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:263:19",vol:h,resources:F,resourcesLoading:X,onChange:m=>{const g=y[p]?.volume,j={};g&&!g.name.trim()&&(m.configMapName&&(j.name=m.configMapName),m.secretName&&(j.name=m.secretName),m.pvcName&&(j.name=m.pvcName)),N(p,{...m,...j})},onRefreshResources:$,onCreateResource:Q})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:283:17",className:"px-3 py-2.5 bg-slate-900/40 space-y-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:284:19",className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:285:21",className:"text-[11px] text-slate-500 flex items-center gap-1.5",children:[e.jsx(Ue,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:286:23",className:"h-3.5 w-3.5 text-blue-400"}),"将上述数据卷挂载到容器"]}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:289:21",size:"sm",variant:"ghost",className:"h-6 px-2 text-[11px] text-slate-400 hover:text-slate-200",onClick:()=>J(p),children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:290:23",className:"h-3 w-3 mr-0.5"}),"添加挂载"]})]}),R.mounts.map((m,g)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:294:21",className:"space-y-2 rounded-md border border-slate-800/60 bg-slate-950/40 p-2.5",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:295:23",className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:296:25",value:m.containerName,onChange:j=>_(p,g,{containerName:j.target.value}),className:"h-8 min-w-[140px] max-w-[280px] bg-slate-800 border border-slate-700 rounded-md text-sm text-slate-200 px-2 font-medium truncate",children:[w.length===0&&e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:301:55",value:"",children:"(无容器)"}),w.map(j=>e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:302:51",value:j,children:j},j))]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:304:25",className:"flex items-center gap-1 bg-slate-800 rounded-lg p-0.5 border border-slate-700",children:[e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:305:27",type:"button",onClick:()=>_(p,g,{readOnly:!0}),className:`px-2.5 py-1 rounded text-xs font-medium transition-all ${m.readOnly?"bg-amber-500/20 text-amber-300":"text-slate-500 hover:text-slate-300"}`,children:"只读"}),e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:309:27",type:"button",onClick:()=>_(p,g,{readOnly:!1}),className:`px-2.5 py-1 rounded text-xs font-medium transition-all ${m.readOnly?"text-slate-500 hover:text-slate-300":"bg-blue-500/20 text-blue-300"}`,children:"读写"})]}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:314:25",value:m.mountPath,onChange:j=>_(p,g,{mountPath:j.target.value}),placeholder:"挂载路径 /bitcloud/app/.../logs",className:"h-8 flex-1 min-w-[200px] bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"}),R.mounts.length>1&&e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:321:27",size:"icon",variant:"ghost",className:"h-8 w-8 text-red-400/70 shrink-0",onClick:()=>ee(p,g),children:e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:322:29",className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:326:23",className:"flex items-center gap-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:327:25",className:"text-[11px] text-slate-500 shrink-0",children:"子路径 subPath"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:328:25",value:m.subPath,onChange:j=>_(p,g,{subPath:j.target.value}),placeholder:"如 config.yaml(挂载单文件时填写)",className:"h-7 flex-1 max-w-md bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]})]},g))]})]},p)})})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:344:7",className:"flex justify-end gap-2 pt-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:345:9",variant:"outline",className:"border-slate-700 text-slate-400",onClick:c,children:"取消"}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:346:9",className:"bg-blue-600 hover:bg-blue-700",disabled:i,onClick:ge,children:[i?e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:347:21",className:"h-4 w-4 animate-spin mr-1"}):e.jsx(it,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:347:73",className:"h-4 w-4 mr-1"}),"保存"]})]})]}):e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:176:7",className:"bg-slate-900 border-slate-800",children:e.jsx(Y,{"code-path":"src/components/kubernetes/DeploymentEditStorage.tsx:177:9",className:"p-8 text-center text-slate-500",children:"未获取到 manifest 数据,请使用 YAML 编辑模式。"})})}const qn=[{key:"nodeName",label:"节点名称"},{key:"nodeSelector",label:"标签选择器"},{key:"nodeAffinity",label:"节点亲和性"}];function Kn({scheduleMode:t,onScheduleModeChange:s,nodeName:a,onNodeNameChange:o,availableNodes:n,nodesLoading:c,labelSelectorKv:r,onAddLabelSelector:i,onRemoveLabelSelector:k,onUpdateLabelSelector:l,nodeLabels:x}){return e.jsxs(U,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:54:5",className:"bg-slate-900 border-slate-800",children:[e.jsxs(he,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:55:7",className:"pb-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:56:9",className:"flex items-center justify-between",children:[e.jsxs(ue,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:57:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(Mt,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:58:13",className:"h-4 w-4 text-emerald-400"}),"调度 (Scheduling)"]}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:60:11",className:"flex items-center gap-1 bg-slate-800 rounded-lg p-0.5 border border-slate-700",children:qn.map(S=>e.jsx("button",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:62:15",onClick:()=>s(S.key),className:`px-2.5 py-1 rounded text-[10px] font-medium transition-all ${t===S.key?"bg-emerald-500/20 text-emerald-300 shadow-sm":"text-slate-400 hover:text-slate-300"}`,children:S.label},S.key))})]}),e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:76:9",className:"text-xs text-slate-500 mt-1",children:[t==="nodeName"&&"Pod 将直接调度到指定节点",t==="nodeSelector"&&"Pod 将调度到匹配标签的节点",t==="nodeAffinity"&&"通过亲和性规则控制 Pod 调度到指定节点"]})]}),e.jsxs(Y,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:82:7",className:"pt-0",children:[t==="nodeName"&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:84:11",className:"space-y-2",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:85:13",className:"text-slate-400 text-xs",children:"请选择节点"}),c?e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:87:15",className:"flex items-center gap-1 text-slate-500 text-xs",children:[e.jsx(ve,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:88:17",className:"h-3 w-3 animate-spin"}),"加载节点列表..."]}):e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:91:15",value:a,onChange:S=>o(S.target.value),className:"h-8 w-full bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-2",children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:96:17",value:"",children:"(不指定)"}),n.map(S=>e.jsxs("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:98:19",value:S.name,children:[S.name," ",S.ip?`(${S.ip})`:""]},S.name))]}),a&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:105:15",className:"text-[10px] text-slate-500",children:["已选择: ",e.jsx("code",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:106:22",className:"bg-slate-800 px-1 py-0.5 rounded text-emerald-400",children:a})]})]}),t==="nodeSelector"&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:113:11",className:"space-y-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:114:13",className:"flex items-center justify-between",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:115:15",className:"text-slate-400 text-xs",children:"请选择标签"}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:116:15",size:"sm",variant:"ghost",className:"h-6 text-xs text-slate-400",onClick:i,children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:117:17",className:"h-3 w-3 mr-1"}),"添加"]})]}),r.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:121:15",className:"text-xs text-slate-600 italic",children:"未配置标签选择器"}):r.map((S,C)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:124:17",className:"flex items-center gap-2",children:[e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:125:19",value:S.key,onChange:y=>l(C,{key:y.target.value,value:""}),className:"flex-1 h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5",children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:130:21",value:"",children:"选择标签"}),Object.entries(x).map(([y,b])=>e.jsxs("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:132:23",value:y,children:[y," (",b.length,")"]},y))]}),e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:135:19",value:S.value,onChange:y=>l(C,{value:y.target.value}),className:"flex-1 h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5",disabled:!S.key,children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:141:21",value:"",children:"选择值"}),(x[S.key]||[]).map(y=>e.jsx("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:143:23",value:y,children:y},y))]}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:146:19",size:"icon",variant:"ghost",className:"h-6 w-6 text-red-400",onClick:()=>k(C),children:e.jsx(be,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:152:21",className:"h-3 w-3"})})]},C))]}),t==="nodeAffinity"&&e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:161:11",className:"space-y-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:162:13",className:"flex items-center justify-between",children:[e.jsxs(H,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:163:15",className:"text-slate-400 text-xs",children:["请选择标签 ",e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:164:23",className:"text-slate-600",children:"(生成 requiredDuringScheduling 规则)"})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:166:15",size:"sm",variant:"ghost",className:"h-6 text-xs text-slate-400",onClick:i,children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:167:17",className:"h-3 w-3 mr-1"}),"添加"]})]}),r.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:171:15",className:"text-xs text-slate-600 italic",children:"未配置亲和性规则"}):r.map((S,C)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:174:17",className:"flex items-center gap-2",children:[e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:175:19",value:S.key,onChange:y=>l(C,{key:y.target.value,value:""}),className:"flex-1 h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5",children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:180:21",value:"",children:"选择标签"}),Object.entries(x).map(([y,b])=>e.jsxs("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:182:23",value:y,children:[y," (",b.length,")"]},y))]}),e.jsxs("select",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:185:19",value:S.value,onChange:y=>l(C,{value:y.target.value}),className:"flex-1 h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5",disabled:!S.key,children:[e.jsx("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:191:21",value:"",children:"选择值"}),(x[S.key]||[]).map(y=>e.jsx("option",{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:193:23",value:y,children:y},y))]}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:196:19",size:"icon",variant:"ghost",className:"h-6 w-6 text-red-400",onClick:()=>k(C),children:e.jsx(be,{"code-path":"src/components/kubernetes/deployment-edit-advanced/SchedulingSection.tsx:202:21",className:"h-3 w-3"})})]},C))]})]})]})}function Jn({dnsNameservers:t,onDnsNameserversChange:s,dnsSearches:a,onDnsSearchesChange:o,dnsOptions:n,onDnsOptionsChange:c,hostAliases:r,onHostAliasesChange:i}){const k=()=>c([...n,{name:"",value:""}]),l=(b,w)=>c(n.map((P,I)=>I===b?{...P,...w}:P)),x=b=>c(n.filter((w,P)=>P!==b)),S=()=>i([...r,{ip:"",hostnames:""}]),C=(b,w)=>i(r.map((P,I)=>I===b?{...P,...w}:P)),y=b=>i(r.filter((w,P)=>P!==b));return e.jsxs(e.Fragment,{children:[e.jsxs(U,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:53:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:54:9",className:"pb-3",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:55:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(mn,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:56:13",className:"h-4 w-4 text-indigo-400"}),"DNS 配置 (dnsConfig)"]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:59:9",className:"pt-0 space-y-3",children:[e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:60:11",className:"text-[11px] text-slate-500",children:["提示:dnsConfig 通常与 ",e.jsx("code",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:61:30",className:"text-slate-400",children:"dnsPolicy: None"})," 搭配使用。每行一个值。"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:63:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:64:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:65:15",className:"text-slate-500 text-xs",children:"nameservers(每行一个 IP)"}),e.jsx("textarea",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:66:15",value:t,onChange:b=>s(b.target.value),placeholder:`8.8.8.8 -114.114.114.114`,rows:3,className:"w-full mt-1 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 font-mono p-2 resize-y"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:74:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:75:15",className:"text-slate-500 text-xs",children:"searches(搜索域,每行一个)"}),e.jsx("textarea",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:76:15",value:a,onChange:b=>o(b.target.value),placeholder:`svc.cluster.local -cluster.local`,rows:3,className:"w-full mt-1 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 font-mono p-2 resize-y"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:85:11",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:86:13",className:"flex items-center justify-between mb-1",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:87:15",className:"text-slate-400 text-xs",children:"options(DNS 选项)"}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:88:15",size:"sm",variant:"ghost",className:"h-6 text-xs text-slate-400",onClick:k,children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:89:17",className:"h-3 w-3 mr-1"}),"添加"]})]}),n.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:93:15",className:"text-xs text-slate-600 italic",children:"未配置"}):n.map((b,w)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:96:17",className:"flex items-center gap-2 mb-1.5",children:[e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:97:19",value:b.name,onChange:P=>l(w,{name:P.target.value}),placeholder:"ndots",className:"flex-1 h-7 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:103:19",className:"text-slate-600",children:":"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:104:19",value:b.value,onChange:P=>l(w,{value:P.target.value}),placeholder:"5(可留空)",className:"flex-1 h-7 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:110:19",size:"icon",variant:"ghost",className:"h-6 w-6 text-red-400",onClick:()=>x(w),children:e.jsx(be,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:111:21",className:"h-3 w-3"})})]},w))]})]})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:120:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:121:9",className:"pb-3",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:122:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(xn,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:123:13",className:"h-4 w-4 text-amber-400"}),"主机别名 (hostAliases)"]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:126:9",className:"pt-0 space-y-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:127:11",className:"flex items-center justify-between mb-1",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:128:13",className:"text-slate-400 text-xs",children:"IP → 主机名映射(注入 Pod 的 /etc/hosts)"}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:129:13",size:"sm",variant:"ghost",className:"h-6 text-xs text-slate-400",onClick:S,children:[e.jsx(te,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:130:15",className:"h-3 w-3 mr-1"}),"添加"]})]}),r.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:134:13",className:"text-xs text-slate-600 italic",children:"未配置"}):r.map((b,w)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:137:15",className:"flex items-center gap-2",children:[e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:138:17",value:b.ip,onChange:P=>C(w,{ip:P.target.value}),placeholder:"10.10.10.72",className:"w-40 h-7 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:144:17",className:"text-slate-600",children:"→"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:145:17",value:b.hostnames,onChange:P=>C(w,{hostnames:P.target.value}),placeholder:"gitlab.local, registry.local",className:"flex-1 h-7 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:151:17",size:"icon",variant:"ghost",className:"h-6 w-6 text-red-400",onClick:()=>y(w),children:e.jsx(be,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:152:19",className:"h-3 w-3"})})]},w))]})]})]})}function Xn({clusterCode:t,namespace:s,deploymentName:a,manifest:o,onSaved:n,onCancel:c}){const{toast:r}=Me(),[i,k]=d.useState(!1),[l,x]=d.useState(!o),[S,C]=d.useState(o||{}),[y,b]=d.useState("RollingUpdate"),[w,P]=d.useState("25%"),[I,M]=d.useState("25%"),[F,V]=d.useState("10"),[X,q]=d.useState("600"),[W,Q]=d.useState("nodeSelector"),[$,Z]=d.useState(""),[N,_]=d.useState([]),[J,ee]=d.useState(!1),[me,ye]=d.useState([]),[ge,R]=d.useState({}),[p,h]=d.useState([]),[u,A]=d.useState("ClusterFirst"),[L,m]=d.useState("Always"),[g,j]=d.useState("default-scheduler"),[O,xe]=d.useState("30"),[se,B]=d.useState(""),[de,De]=d.useState(""),[Se,Ie]=d.useState(""),[$e,_e]=d.useState(""),[Be,Le]=d.useState(!1),[E,ie]=d.useState(!1),[je,Ne]=d.useState(!1),[Te,mt]=d.useState(!1),[qe,xt]=d.useState(!1),[Ke,Pe]=d.useState([]),[Bt,Rt]=d.useState(""),[Ot,$t]=d.useState(""),[_t,Lt]=d.useState([]);d.useEffect(()=>{const D=o;if(!D){x(!1);return}C(D);const T=D?.spec||{},G=T?.template?.spec||{},ne=T.strategy||{};b(ne.type||"RollingUpdate");const re=ne.rollingUpdate||{};P(String(re.maxSurge??"25%")),M(String(re.maxUnavailable??"25%")),V(T.revisionHistoryLimit!=null?String(T.revisionHistoryLimit):"10"),q(T.progressDeadlineSeconds!=null?String(T.progressDeadlineSeconds):"600");const ke=G.nodeSelector||{},ze=Object.entries(ke).map(([pe,zt])=>({key:pe,value:String(zt)}));ye(ze),Z(G.nodeName||""),G.nodeName?Q("nodeName"):G.affinity?.nodeAffinity?Q("nodeAffinity"):ze.length>0&&Q("nodeSelector"),t&&(ee(!0),K.getClusterNodes(t).then(pe=>{const Wt=(Array.isArray(pe)?pe:pe?.items||pe?.list||[]).map(Xe=>{const He=Xe.metadata||{},Qe=Xe.status||{},Bs=(Array.isArray(Qe.addresses)?Qe.addresses:[]).find(Rs=>Rs.type==="InternalIP")?.address||"";return{name:He.name||"",ip:Bs,labels:He.labels||{}}});_(Wt);const We={};for(const Xe of Wt)for(const[He,Qe]of Object.entries(Xe.labels)){const ut=String(Qe);We[He]||(We[He]=[]),We[He].includes(ut)||We[He].push(ut)}R(We)}).catch(()=>{}).finally(()=>ee(!1)));const Je=Array.isArray(G.tolerations)?G.tolerations:[];h(Je.map(pe=>({key:pe.key||"",operator:pe.operator||"Equal",value:pe.value||"",effect:pe.effect||"",tolerationSeconds:pe.tolerationSeconds!=null?String(pe.tolerationSeconds):""}))),A(G.dnsPolicy||"ClusterFirst"),m(G.restartPolicy||"Always"),j(G.schedulerName||"default-scheduler"),xe(G.terminationGracePeriodSeconds!=null?String(G.terminationGracePeriodSeconds):"30"),B(G.serviceAccountName||"");const we=G.securityContext||{};De(we.fsGroup!=null?String(we.fsGroup):""),Ie(we.runAsUser!=null?String(we.runAsUser):""),_e(we.runAsGroup!=null?String(we.runAsGroup):""),Le(!!we.runAsNonRoot),ie(!!G.hostNetwork),Ne(!!G.hostIPC),mt(!!G.hostPID),xt(!!G.shareProcessNamespace);const z=Array.isArray(G.hostAliases)?G.hostAliases:[];Pe(z.map(pe=>({ip:pe.ip||"",hostnames:Array.isArray(pe.hostnames)?pe.hostnames.join(", "):""})));const oe=G.dnsConfig||{};Rt(Array.isArray(oe.nameservers)?oe.nameservers.join(` -`):""),$t(Array.isArray(oe.searches)?oe.searches.join(` -`):"");const ht=Array.isArray(oe.options)?oe.options:[];Lt(ht.map(pe=>({name:pe.name||"",value:pe.value||""}))),x(!1)},[o]);const Ts=()=>ye(D=>[...D,{key:"",value:""}]),Ms=D=>ye(T=>T.filter((G,ne)=>ne!==D)),Hs=(D,T)=>ye(G=>G.map((ne,re)=>re===D?{...ne,...T}:ne)),Is=async()=>{k(!0);try{const D=JSON.parse(JSON.stringify(S));D.spec=D.spec||{},D.spec.template=D.spec.template||{},D.spec.template.spec=D.spec.template.spec||{};const T=D.spec.template.spec;if(D.spec.strategy={type:y},y==="RollingUpdate"&&(D.spec.strategy.rollingUpdate={maxSurge:w,maxUnavailable:I}),F&&(D.spec.revisionHistoryLimit=Number(F)),X&&(D.spec.progressDeadlineSeconds=Number(X)),W==="nodeName"&&$.trim())T.nodeName=$.trim(),delete T.nodeSelector,T.affinity&&delete T.affinity.nodeAffinity;else if(W==="nodeSelector"){const z={};for(const{key:oe,value:ht}of me){const pe=oe.trim();pe&&(z[pe]=ht)}Object.keys(z).length>0?T.nodeSelector=z:delete T.nodeSelector,T.nodeName&&delete T.nodeName,T.affinity&&delete T.affinity.nodeAffinity}else if(W==="nodeAffinity"){const z=me.filter(oe=>oe.key.trim()).map(oe=>({key:oe.key.trim(),operator:"In",values:[oe.value]}));z.length>0?(T.affinity=T.affinity||{},T.affinity.nodeAffinity={requiredDuringSchedulingIgnoredDuringExecution:{nodeSelectorTerms:[{matchExpressions:z}]}}):T.affinity&&delete T.affinity.nodeAffinity,delete T.nodeSelector,T.nodeName&&delete T.nodeName}const G=p.filter(z=>z.key||z.operator==="Exists").map(z=>{const oe={};return z.key&&(oe.key=z.key),z.operator&&(oe.operator=z.operator),z.value&&z.operator!=="Exists"&&(oe.value=z.value),z.effect&&(oe.effect=z.effect),z.tolerationSeconds&&z.effect==="NoExecute"&&(oe.tolerationSeconds=Number(z.tolerationSeconds)),oe});G.length>0?T.tolerations=G:delete T.tolerations,u&&(T.dnsPolicy=u),L&&(T.restartPolicy=L),g&&(T.schedulerName=g),O&&(T.terminationGracePeriodSeconds=Number(O)),se&&(T.serviceAccountName=se);const ne={};de&&(ne.fsGroup=Number(de)),Se&&(ne.runAsUser=Number(Se)),$e&&(ne.runAsGroup=Number($e)),Be&&(ne.runAsNonRoot=!0),Object.keys(ne).length>0?T.securityContext=ne:delete T.securityContext,E?T.hostNetwork=!0:delete T.hostNetwork,je?T.hostIPC=!0:delete T.hostIPC,Te?T.hostPID=!0:delete T.hostPID,qe?T.shareProcessNamespace=!0:delete T.shareProcessNamespace;const re=Ke.filter(z=>z.ip.trim()).map(z=>({ip:z.ip.trim(),hostnames:z.hostnames.split(/[,\s]+/).map(oe=>oe.trim()).filter(Boolean)})).filter(z=>z.hostnames.length>0);re.length>0?T.hostAliases=re:delete T.hostAliases;const ke={},ze=Bt.split(` -`).map(z=>z.trim()).filter(Boolean);ze.length>0&&(ke.nameservers=ze);const Je=Ot.split(` -`).map(z=>z.trim()).filter(Boolean);Je.length>0&&(ke.searches=Je);const we=_t.filter(z=>z.name.trim()).map(z=>{const oe={name:z.name.trim()};return z.value.trim()&&(oe.value=z.value.trim()),oe});we.length>0&&(ke.options=we),Object.keys(ke).length>0?T.dnsConfig=ke:delete T.dnsConfig,await pt(t,s,a,D),r({title:"高级设置已保存",description:`${a} 更新已提交`}),n(D)}catch(D){r({title:"保存失败",description:D?.message||String(D),variant:"destructive"})}finally{k(!1)}};return l?e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:323:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:324:9",className:"p-12 text-center",children:[e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:325:11",className:"h-6 w-6 animate-spin mx-auto text-slate-500"}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:326:11",className:"text-slate-500 mt-3 text-sm",children:"加载中..."})]})}):o?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:343:5",className:"space-y-4",children:[e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:345:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:346:9",className:"pb-3",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:347:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(Ye,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:348:13",className:"h-4 w-4 text-blue-400"}),"更新策略 (Strategy)"]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:351:9",className:"pt-0 space-y-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:352:11",className:"flex items-center gap-4",children:[e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:353:13",className:"flex items-center gap-1.5 text-xs text-slate-300 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:354:15",type:"radio",checked:y==="RollingUpdate",onChange:()=>b("RollingUpdate"),className:"accent-blue-500"}),"RollingUpdate(滚动更新)"]}),e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:358:13",className:"flex items-center gap-1.5 text-xs text-slate-300 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:359:15",type:"radio",checked:y==="Recreate",onChange:()=>b("Recreate"),className:"accent-blue-500"}),"Recreate(重建)"]})]}),y==="RollingUpdate"&&e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:365:13",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:366:15",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:367:17",className:"text-slate-500 text-xs",children:"maxSurge(整数或百分比,超出期望副本数)"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:368:17",value:w,onChange:D=>P(D.target.value),placeholder:"25%",className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:371:15",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:372:17",className:"text-slate-500 text-xs",children:"maxUnavailable(整数或百分比,不可用上限)"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:373:17",value:I,onChange:D=>M(D.target.value),placeholder:"25%",className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]})]})]})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:382:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:383:9",className:"pb-3",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:384:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(vs,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:385:13",className:"h-4 w-4 text-amber-400"}),"历史版本 & 进度"]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:388:9",className:"pt-0 grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:389:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:390:13",className:"text-slate-500 text-xs",children:"revisionHistoryLimit(保留 RS 历史)"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:391:13",type:"number",value:F,onChange:D=>V(D.target.value),className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:394:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:395:13",className:"text-slate-500 text-xs",children:"progressDeadlineSeconds(升级超时秒数)"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:396:13",type:"number",value:X,onChange:D=>q(D.target.value),className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]})]})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:403:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:404:9",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:405:11",className:"flex items-center justify-between",children:[e.jsx(ue,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:406:13",className:"text-sm text-slate-200",children:"容忍 (Tolerations)"}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:407:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:()=>h(D=>[...D,{key:"",operator:"Equal",value:"",effect:"NoSchedule",tolerationSeconds:""}]),children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:409:15",className:"h-3 w-3 mr-1"}),"添加"]})]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:413:9",className:"pt-0 space-y-2",children:[p.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:414:40",className:"text-xs text-slate-600",children:"未配置容忍"}),p.map((D,T)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:416:13",className:"grid grid-cols-[1fr_80px_1fr_100px_80px_auto] gap-2 items-center",children:[e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:417:15",value:D.key,placeholder:"key",onChange:G=>h(ne=>ne.map((re,ke)=>ke===T?{...re,key:G.target.value}:re)),className:"h-7 bg-slate-800 border-slate-700 text-xs font-mono"}),e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:419:15",value:D.operator,onChange:G=>h(ne=>ne.map((re,ke)=>ke===T?{...re,operator:G.target.value}:re)),className:"h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1",children:[e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:421:17",value:"Equal",children:"Equal"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:422:17",value:"Exists",children:"Exists"})]}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:424:15",value:D.value,placeholder:"value",disabled:D.operator==="Exists",onChange:G=>h(ne=>ne.map((re,ke)=>ke===T?{...re,value:G.target.value}:re)),className:"h-7 bg-slate-800 border-slate-700 text-xs font-mono"}),e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:427:15",value:D.effect,onChange:G=>h(ne=>ne.map((re,ke)=>ke===T?{...re,effect:G.target.value}:re)),className:"h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1",children:[e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:429:17",value:"",children:"任意"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:430:17",value:"NoSchedule",children:"NoSchedule"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:431:17",value:"PreferNoSchedule",children:"PreferNoSchedule"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:432:17",value:"NoExecute",children:"NoExecute"})]}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:434:15",value:D.tolerationSeconds,placeholder:"秒",disabled:D.effect!=="NoExecute",onChange:G=>h(ne=>ne.map((re,ke)=>ke===T?{...re,tolerationSeconds:G.target.value}:re)),className:"h-7 bg-slate-800 border-slate-700 text-xs font-mono"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:437:15",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-400",onClick:()=>h(G=>G.filter((ne,re)=>re!==T)),children:e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:438:17",className:"h-3 w-3"})})]},T))]})]}),e.jsx(Kn,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:445:7",scheduleMode:W,onScheduleModeChange:Q,nodeName:$,onNodeNameChange:Z,availableNodes:N,nodesLoading:J,labelSelectorKv:me,onAddLabelSelector:Ts,onRemoveLabelSelector:Ms,onUpdateLabelSelector:Hs,nodeLabels:ge}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:460:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:461:9",className:"pb-3",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:462:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(wt,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:463:13",className:"h-4 w-4 text-slate-400"}),"Pod 级别"]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:466:9",className:"pt-0 grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:467:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:468:13",className:"text-slate-500 text-xs",children:"dnsPolicy"}),e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:469:13",value:u,onChange:D=>A(D.target.value),className:"h-8 mt-1 w-full bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-2",children:[e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:471:15",value:"ClusterFirst",children:"ClusterFirst"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:472:15",value:"ClusterFirstWithHostNet",children:"ClusterFirstWithHostNet"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:473:15",value:"Default",children:"Default"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:474:15",value:"None",children:"None"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:477:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:478:13",className:"text-slate-500 text-xs",children:"restartPolicy"}),e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:479:13",value:L,onChange:D=>m(D.target.value),className:"h-8 mt-1 w-full bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-2",children:[e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:481:15",value:"Always",children:"Always"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:482:15",value:"OnFailure",children:"OnFailure"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:483:15",value:"Never",children:"Never"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:486:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:487:13",className:"text-slate-500 text-xs",children:"schedulerName"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:488:13",value:g,onChange:D=>j(D.target.value),className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:491:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:492:13",className:"text-slate-500 text-xs",children:"terminationGracePeriodSeconds"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:493:13",type:"number",value:O,onChange:D=>xe(D.target.value),className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:496:11",className:"col-span-2",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:497:13",className:"text-slate-500 text-xs",children:"serviceAccountName"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:498:13",value:se,onChange:D=>B(D.target.value),placeholder:"default",className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]})]})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:505:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:506:9",className:"pb-3",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:507:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(js,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:508:13",className:"h-4 w-4 text-rose-400"}),"Pod 安全上下文 (securityContext)"]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:511:9",className:"pt-0 grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:512:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:513:13",className:"text-slate-500 text-xs",children:"fsGroup"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:514:13",type:"number",value:de,onChange:D=>De(D.target.value),placeholder:"1000",className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:517:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:518:13",className:"text-slate-500 text-xs",children:"runAsUser"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:519:13",type:"number",value:Se,onChange:D=>Ie(D.target.value),placeholder:"1000",className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:522:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:523:13",className:"text-slate-500 text-xs",children:"runAsGroup"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:524:13",type:"number",value:$e,onChange:D=>_e(D.target.value),placeholder:"1000",className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:527:11",className:"flex items-end pb-1",children:e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:528:13",className:"flex items-center gap-2 text-xs text-slate-400 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:529:15",type:"checkbox",checked:Be,onChange:D=>Le(D.target.checked),className:"accent-blue-500"}),"runAsNonRoot"]})})]})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:538:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:539:9",className:"pb-3",children:e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:540:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(Ae,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:541:13",className:"h-4 w-4 text-cyan-400"}),"主机设置 (Host Namespace)"]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:544:9",className:"pt-0 grid grid-cols-2 gap-3",children:[e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:545:11",className:"flex items-center gap-2 text-xs text-slate-300 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:546:13",type:"checkbox",checked:E,onChange:D=>ie(D.target.checked),className:"accent-blue-500"}),"hostNetwork(共享主机网络命名空间)"]}),e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:550:11",className:"flex items-center gap-2 text-xs text-slate-300 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:551:13",type:"checkbox",checked:je,onChange:D=>Ne(D.target.checked),className:"accent-blue-500"}),"hostIPC(共享主机 IPC 命名空间)"]}),e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:555:11",className:"flex items-center gap-2 text-xs text-slate-300 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:556:13",type:"checkbox",checked:Te,onChange:D=>mt(D.target.checked),className:"accent-blue-500"}),"hostPID(共享主机 PID 命名空间)"]}),e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:560:11",className:"flex items-center gap-2 text-xs text-slate-300 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:561:13",type:"checkbox",checked:qe,onChange:D=>xt(D.target.checked),className:"accent-blue-500"}),"shareProcessNamespace(共享进程命名空间)"]})]})]}),e.jsx(Jn,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:568:7",dnsNameservers:Bt,onDnsNameserversChange:Rt,dnsSearches:Ot,onDnsSearchesChange:$t,dnsOptions:_t,onDnsOptionsChange:Lt,hostAliases:Ke,onHostAliasesChange:Pe}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:580:7",className:"flex justify-end gap-2 pt-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:581:9",variant:"outline",className:"border-slate-700 text-slate-400",onClick:c,children:"取消"}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:582:9",className:"bg-blue-600 hover:bg-blue-700",disabled:i,onClick:Is,children:[i?e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:583:21",className:"h-4 w-4 animate-spin mr-1"}):e.jsx(it,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:583:73",className:"h-4 w-4 mr-1"}),"保存"]})]})]}):e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:334:7",className:"bg-slate-900 border-slate-800",children:e.jsx(Y,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:335:9",className:"p-8 text-center text-slate-500",children:"未获取到 manifest 数据,请使用 YAML 编辑模式直接修改。"})})}const Qn=[{label:"HTTP",protocol:"TCP",port:8080,targetPort:8080,name:"http"},{label:"WebSocket",protocol:"TCP",port:8001,targetPort:8002,name:"ws"},{label:"gRPC",protocol:"TCP",port:8002,targetPort:8002,name:"grpc"}],rs=t=>Array.isArray(t)?t:t?.list||t?.items||t?.data||[];function Zn({clusterCode:t,namespace:s,deploymentName:a,manifest:o,onSaved:n,onCancel:c}){const{toast:r}=Me(),i=dt(),[k,l]=d.useState(!0),[x,S]=d.useState([]),[C,y]=d.useState([]),[b,w]=d.useState({}),[P,I]=d.useState(null),[M,F]=d.useState(null),[V,X]=d.useState({name:"",type:"ClusterIP",ports:[{name:"http",port:"8080",targetPort:"8080",protocol:"TCP",nodePort:""}]}),[q,W]=d.useState({name:"",className:"nginx",host:"",path:"/",pathType:"Prefix",svcPort:"80"}),Q=p=>{X(h=>({...h,ports:[...h.ports,p?{name:p.name,port:String(p.port),targetPort:String(p.targetPort),protocol:p.protocol,nodePort:""}:{name:"",port:"",targetPort:"",protocol:"TCP",nodePort:""}]}))},$=(p,h,u)=>{X(A=>({...A,ports:A.ports.map((L,m)=>m===p?{...L,[h]:u}:L)}))},Z=p=>{V.ports.length<=1||X(h=>({...h,ports:h.ports.filter((u,A)=>A!==p)}))},N=d.useCallback(async()=>{l(!0);try{const p=o?.spec?.selector?.matchLabels||o?.selector||{};w(p);const[h,u]=await Promise.all([K.getNamespaceServices(t,s).catch(()=>[]),K.getNamespaceIngresses(t,s).catch(()=>[])]),A=rs(h),L=rs(u),m=A.map(j=>{const O=j.spec||{},xe=Array.isArray(O.ports)?O.ports.map(se=>({port:se.port,targetPort:se.targetPort,protocol:se.protocol||"TCP",nodePort:se.nodePort,name:se.name})):Array.isArray(j.portList)?j.portList.map(se=>({port:se.port,targetPort:se.targetPort,protocol:se.protocol||"TCP",nodePort:se.nodePort,name:se.name})):[];return{name:j.name||j.metadata?.name||"",type:O.type||j.type||"ClusterIP",clusterIP:O.clusterIP||j.cluster_ip||"",externalIP:Array.isArray(O.externalIPs)?O.externalIPs.join(","):"",ports:xe,selector:O.selector||j.selector||{},age:j.age||j.created_at||"",raw:j}}),g=L.map(j=>{const O=j.spec||{},se=(Array.isArray(O.rules)?O.rules:Array.isArray(j.rules)?j.rules:[]).map(B=>({host:B.host||"",paths:(B.http?.paths||B.paths||[]).map(de=>({path:de.path||"/",backend:{service:de.backend?.service?.name||de.backendService||"",port:de.backend?.service?.port?.number||de.backend?.service?.port?.name||de.backendPort||""}}))}));return{name:j.name||j.metadata?.name||"",className:O.ingressClassName||j.ingressClass||"",hosts:se.map(B=>B.host).filter(Boolean),rules:se,raw:j}});S(m),y(g)}catch(p){console.error("M9 load error:",p)}finally{l(!1)}},[t,s,o]);d.useEffect(()=>{N()},[N]);const _=p=>Object.keys(p).length===0?!1:Object.entries(p).every(([h,u])=>b[h]===u),J=x.filter(p=>_(p.selector)),ee=new Set(J.map(p=>p.name)),me=C.filter(p=>p.rules.some(h=>h.paths.some(u=>ee.has(u.backend.service)))),ye=async()=>{const p=V.name.trim()||`${a}-svc`,h=V.ports.map(A=>{const L={name:A.name||"http",port:Number(A.port)||80,targetPort:/^\d+$/.test(String(A.targetPort))?Number(A.targetPort):A.targetPort,protocol:A.protocol||"TCP"};return V.type==="NodePort"&&A.nodePort&&(L.nodePort=Number(A.nodePort)),L}),u={apiVersion:"v1",kind:"Service",metadata:{name:p,namespace:s,labels:{app:a}},spec:{type:V.type,selector:b,ports:h}};try{const A=await Gt(u);await K.applyYAML(t,A),r({title:"Service 已创建",description:p}),F(null),N()}catch(A){r({title:"创建失败",description:A?.message||String(A),variant:"destructive"})}},ge=async()=>{const p=q.name.trim()||`${a}-ingress`,h=J[0]?.name||`${a}-svc`,u=Number(q.svcPort)||80,A={apiVersion:"networking.k8s.io/v1",kind:"Ingress",metadata:{name:p,namespace:s,labels:{app:a}},spec:{ingressClassName:q.className||void 0,rules:[{host:q.host||void 0,http:{paths:[{path:q.path||"/",pathType:q.pathType||"Prefix",backend:{service:{name:h,port:{number:u}}}}]}}]}};q.className||delete A.spec.ingressClassName;try{const L=await Gt(A);await K.applyYAML(t,L),r({title:"Ingress 已创建",description:p}),F(null),N()}catch(L){r({title:"创建失败",description:L?.message||String(L),variant:"destructive"})}},R=async(p,h)=>{if(await i({title:"删除资源",description:`确认删除 ${p==="service"?"Service":"Ingress"} 「${h}」?此操作不可撤销。`,confirmText:"删除",variant:"destructive"}))try{const A=p==="service"?"services":"ingresses";await K.deleteResourceYaml(t,s,A,h),r({title:"已删除",description:`${p==="service"?"Service":"Ingress"} ${h} 已删除`}),N()}catch(A){r({title:"删除失败",description:A?.message||String(A),variant:"destructive"})}};return k?e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:291:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:292:9",className:"p-12 text-center",children:[e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:293:11",className:"h-6 w-6 animate-spin mx-auto text-slate-500"}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:294:11",className:"text-slate-500 mt-3 text-sm",children:"加载中..."})]})}):e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:301:5",className:"space-y-4",children:[e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:303:7",className:"bg-slate-900/50 border-slate-800",children:e.jsx(Y,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:304:9",className:"p-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:305:11",className:"flex items-center gap-2 text-xs text-slate-400",children:[e.jsx(Ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:306:13",className:"h-3.5 w-3.5 text-blue-400"}),e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:307:13",children:"选择器:"}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:308:13",className:"flex flex-wrap gap-1",children:[Object.entries(b).map(([p,h])=>e.jsxs("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:310:17",className:"bg-slate-800 px-1.5 py-0.5 rounded text-slate-300 text-[11px]",children:[p,"=",h]},p)),Object.keys(b).length===0&&e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:313:17",className:"text-slate-600 italic",children:"(无 selector)"})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:316:13",size:"sm",variant:"ghost",className:"h-6 ml-auto text-xs text-slate-400",onClick:N,children:[e.jsx(Ye,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:317:15",className:"h-3 w-3 mr-1"}),"刷新"]})]})})}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:324:7",className:"bg-slate-900 border-slate-800",children:[e.jsxs(he,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:325:9",className:"pb-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:326:11",className:"flex items-center justify-between",children:[e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:327:13",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(Ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:328:15",className:"h-4 w-4 text-blue-400"}),"Services",e.jsxs(ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:330:15",variant:"outline",className:"border-slate-700 text-slate-400",children:[J.length," 个关联"]})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:332:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:()=>{X({name:`${a}-svc`,type:"ClusterIP",ports:[{name:"http",port:"8080",targetPort:"8080",protocol:"TCP",nodePort:""}]}),F("service")},children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:337:15",className:"h-3 w-3 mr-1"}),"创建 Service"]})]}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:340:11",className:"text-xs text-slate-500 mt-1",children:"仅显示 selector 匹配此 Deployment 的关联 Service"})]}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:342:9",className:"pt-0",children:[J.length===0&&M!=="service"?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:344:13",className:"text-center py-6 text-slate-500 text-sm border border-dashed border-slate-800 rounded-lg",children:[e.jsx(Ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:345:15",className:"h-8 w-8 mx-auto mb-2 text-slate-700"}),"当前命名空间暂无关联 Service"]}):e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:349:13",className:"space-y-2",children:J.map(p=>{const h=_(p.selector);return e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:353:19",className:`rounded-lg border p-3 ${h?"border-blue-700/50 bg-blue-950/20":"border-slate-800 bg-slate-950/30"}`,children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:354:21",className:"flex items-center gap-2 flex-wrap",children:[h?e.jsx(Ct,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:355:34",className:"h-4 w-4 text-blue-400"}):e.jsx(Ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:355:86",className:"h-4 w-4 text-slate-500"}),e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:356:23",className:"text-sm font-semibold text-slate-200",children:p.name}),e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:357:23",variant:"outline",className:"border-slate-700 text-slate-400 text-[10px]",children:p.type}),h&&e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:358:35",className:"bg-blue-500/20 text-blue-300 border-blue-500/30 text-[10px]",children:"关联"}),e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:359:23",className:"text-[11px] text-slate-500 ml-auto",children:p.clusterIP}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:360:23",size:"sm",variant:"ghost",className:"h-6 text-xs text-emerald-400",onClick:()=>I({resource:"services",name:p.name}),children:[e.jsx(Ut,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:362:25",className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:364:23",size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-red-400 hover:text-red-300",title:"删除 Service",onClick:()=>R("service",p.name),children:e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:366:25",className:"h-3 w-3"})})]}),e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:370:21",className:"mt-2 flex flex-wrap gap-1.5 text-[11px]",children:p.ports.map((u,A)=>e.jsxs("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:372:25",className:"bg-slate-800/60 px-1.5 py-0.5 rounded text-slate-300",children:[u.name&&e.jsxs("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:373:38",className:"text-slate-500",children:[u.name,": "]}),u.port,"→",u.targetPort,u.nodePort?`/NodePort:${u.nodePort}`:"","/",u.protocol]},A))}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:379:21",className:"mt-1 flex flex-wrap gap-1 text-[10px]",children:[e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:380:23",className:"text-slate-600",children:"selector:"}),Object.entries(p.selector).map(([u,A])=>e.jsxs("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:382:25",className:"text-slate-500",children:[u,"=",A]},u))]})]},p.name)})}),M==="service"&&e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:393:13",className:"mt-3 border border-blue-800/50 rounded-lg p-3 bg-blue-950/20 space-y-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:394:15",className:"text-xs font-semibold text-blue-300 flex items-center gap-1.5",children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:395:17",className:"h-3 w-3"}),"创建新 Service"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:399:15",className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:400:17",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:401:19",className:"text-slate-500 text-[11px]",children:"名称"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:402:19",value:V.name,onChange:p=>X(h=>({...h,name:p.target.value})),placeholder:`${a}-svc`,className:"h-7 mt-0.5 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:406:17",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:407:19",className:"text-slate-500 text-[11px]",children:"类型"}),e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:408:19",value:V.type,onChange:p=>X(h=>({...h,type:p.target.value})),className:"h-7 mt-0.5 w-full bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-2",children:[e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:410:21",value:"ClusterIP",children:"ClusterIP"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:411:21",value:"NodePort",children:"NodePort"})]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:417:15",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:418:17",className:"text-slate-500 text-[11px] mb-1 block",children:"快速添加常用端口"}),e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:419:17",className:"flex gap-1.5",children:Qn.map(p=>e.jsxs("button",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:421:21",onClick:()=>Q(p),className:`flex items-center gap-1 px-2 py-1 rounded text-[10px] font-medium - bg-slate-800 border border-slate-700 text-slate-300 hover:border-blue-500/50 hover:text-blue-300 transition-colors`,children:[e.jsx(gs,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:424:23",className:"h-2.5 w-2.5"}),p.label,e.jsxs("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:426:23",className:"text-slate-500 text-[9px]",children:[p.protocol," ",p.port,":",p.targetPort]})]},p.name))})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:433:15",className:"space-y-2",children:[e.jsxs(H,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:434:17",className:"text-slate-500 text-[11px]",children:["端口配置 ",e.jsxs("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:435:24",className:"text-slate-600",children:["(",V.ports.length," 个端口)"]})]}),V.ports.map((p,h)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:438:19",className:"flex items-center gap-1.5 p-2 rounded bg-slate-800/50 border border-slate-700/50",children:[e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:440:21",value:p.name,onChange:u=>$(h,"name",u.target.value),placeholder:"http",className:"h-7 w-[72px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:444:21",value:p.protocol,onChange:u=>$(h,"protocol",u.target.value),className:"h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5 w-16",children:[e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:446:23",value:"TCP",children:"TCP"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:447:23",value:"UDP",children:"UDP"})]}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:450:21",value:p.port,onChange:u=>$(h,"port",u.target.value),type:"number",placeholder:"port",className:"h-7 w-[72px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:453:21",className:"text-slate-600 text-[10px]",children:"→"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:454:21",value:p.targetPort,onChange:u=>$(h,"targetPort",u.target.value),type:"number",placeholder:"targetPort",className:"h-7 w-[72px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),V.type==="NodePort"&&e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:459:23",value:p.nodePort,onChange:u=>$(h,"nodePort",u.target.value),type:"number",placeholder:"30000-32767",className:"h-7 w-[80px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:464:21",size:"icon",variant:"ghost",className:"h-6 w-6 text-slate-500 hover:text-red-400",onClick:()=>Z(h),disabled:V.ports.length<=1,children:e.jsx(Tt,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:466:23",className:"h-3 w-3"})})]},h)),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:471:17",size:"sm",variant:"outline",className:"h-7 w-full border-dashed border-slate-700 text-slate-400 text-xs",onClick:()=>Q(),children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:473:19",className:"h-3 w-3 mr-1"}),"添加自定义端口"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:478:15",className:"text-[10px] text-slate-500 border-t border-slate-700/50 pt-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:479:17",className:"text-slate-600",children:"selector (自动检测): "}),Object.keys(b).length>0?Object.entries(b).map(([p,h])=>e.jsxs("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:482:21",className:"bg-slate-800 px-1 py-0.5 rounded text-slate-400 ml-1",children:[p,"=",h]},p)):e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:485:19",className:"text-slate-600 italic",children:"未检测到"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:489:15",className:"flex justify-end gap-2 pt-1",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:490:17",size:"sm",variant:"ghost",className:"h-7 text-xs text-slate-400",onClick:()=>F(null),children:"取消"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:491:17",size:"sm",className:"h-7 bg-blue-600 hover:bg-blue-700 text-xs",onClick:ye,children:"创建"})]})]})]})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:499:7",className:"bg-slate-900 border-slate-800",children:[e.jsxs(he,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:500:9",className:"pb-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:501:11",className:"flex items-center justify-between",children:[e.jsxs(ue,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:502:13",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(jt,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:503:15",className:"h-4 w-4 text-purple-400"}),"Ingresses (应用路由)",e.jsxs(ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:505:15",variant:"outline",className:"border-slate-700 text-slate-400",children:[me.length,"/",C.length]})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:507:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:()=>{W(p=>({...p,name:`${a}-ingress`,svcPort:String(J[0]?.ports[0]?.port||80)})),F("ingress")},children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:512:15",className:"h-3 w-3 mr-1"}),"创建 Ingress"]})]}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:515:11",className:"text-xs text-slate-500 mt-1",children:"backend 指向关联 Service 的 Ingress 自动高亮"})]}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:517:9",className:"pt-0",children:[C.length===0?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:519:13",className:"text-center py-6 text-slate-500 text-sm border border-dashed border-slate-800 rounded-lg",children:[e.jsx(jt,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:520:15",className:"h-8 w-8 mx-auto mb-2 text-slate-700"}),"当前命名空间暂无 Ingress"]}):e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:524:13",className:"space-y-2",children:C.map(p=>{const h=me.includes(p);return e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:528:19",className:`rounded-lg border p-3 ${h?"border-purple-700/50 bg-purple-950/20":"border-slate-800 bg-slate-950/30"}`,children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:529:21",className:"flex items-center gap-2 flex-wrap",children:[h?e.jsx(Ct,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:530:34",className:"h-4 w-4 text-purple-400"}):e.jsx(jt,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:530:88",className:"h-4 w-4 text-slate-500"}),e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:531:23",className:"text-sm font-semibold text-slate-200",children:p.name}),e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:532:23",variant:"outline",className:"border-slate-700 text-slate-400 text-[10px]",children:p.className}),h&&e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:533:35",className:"bg-purple-500/20 text-purple-300 border-purple-500/30 text-[10px]",children:"关联"}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:534:23",size:"sm",variant:"ghost",className:"h-6 text-xs text-emerald-400 ml-auto",onClick:()=>I({resource:"ingresses",name:p.name}),children:[e.jsx(Ut,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:536:25",className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:538:23",size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-red-400 hover:text-red-300",title:"删除 Ingress",onClick:()=>R("ingress",p.name),children:e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:540:25",className:"h-3 w-3"})})]}),e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:544:21",className:"mt-2 space-y-1 text-[11px]",children:p.rules.map((u,A)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:546:25",className:"flex items-start gap-1.5",children:[e.jsx(Mt,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:547:27",className:"h-3 w-3 text-slate-500 mt-0.5"}),e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:548:27",className:"text-slate-300",children:u.host||"*"}),u.paths.map((L,m)=>e.jsxs("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:550:29",className:"bg-slate-800/60 px-1.5 py-0.5 rounded text-slate-400",children:[L.path," → ",L.backend?.service,":",L.backend?.port]},m))]},A))})]},p.name)})}),M==="ingress"&&e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:565:13",className:"mt-3 border border-purple-800/50 rounded-lg p-3 bg-purple-950/20 space-y-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:566:15",className:"text-xs font-semibold text-purple-300 flex items-center gap-1.5",children:[e.jsx(te,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:567:17",className:"h-3 w-3"}),"创建新 Ingress"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:569:15",className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:570:17",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:571:19",className:"text-slate-500 text-[11px]",children:"名称"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:572:19",value:q.name,onChange:p=>W(h=>({...h,name:p.target.value})),placeholder:`${a}-ingress`,className:"h-7 mt-0.5 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:576:17",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:577:19",className:"text-slate-500 text-[11px]",children:"ingressClassName"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:578:19",value:q.className,onChange:p=>W(h=>({...h,className:p.target.value})),placeholder:"nginx",className:"h-7 mt-0.5 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:582:17",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:583:19",className:"text-slate-500 text-[11px]",children:"host (域名)"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:584:19",value:q.host,onChange:p=>W(h=>({...h,host:p.target.value})),placeholder:"app.example.com",className:"h-7 mt-0.5 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:588:17",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:589:19",className:"text-slate-500 text-[11px]",children:"path"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:590:19",value:q.path,onChange:p=>W(h=>({...h,path:p.target.value})),placeholder:"/",className:"h-7 mt-0.5 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:594:17",children:[e.jsx(H,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:595:19",className:"text-slate-500 text-[11px]",children:"Service 端口"}),e.jsx(f,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:596:19",type:"number",value:q.svcPort,onChange:p=>W(h=>({...h,svcPort:p.target.value})),className:"h-7 mt-0.5 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:600:15",className:"flex justify-end gap-2 pt-1",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:601:17",size:"sm",variant:"ghost",className:"h-7 text-xs text-slate-400",onClick:()=>F(null),children:"取消"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:602:17",size:"sm",className:"h-7 bg-purple-600 hover:bg-purple-700 text-xs",onClick:ge,children:"创建"})]})]})]})]}),P&&e.jsx(Cs,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:610:9",clusterCode:t,namespace:s,resource:P.resource,name:P.name,onClose:()=>I(null),onSaved:()=>{I(null),N()}}),e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:620:7",className:"flex justify-end gap-2 pt-2",children:e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:621:9",size:"sm",variant:"outline",className:"h-7 text-xs border-slate-700 text-slate-400",onClick:c,children:"返回查看"})})]})}function cs({clusterCode:t,namespace:s,deploymentName:a,manifest:o,onSaved:n,onCancel:c,isCreate:r=!1}){const[i,k]=d.useState("basic"),[l,x]=d.useState(o);d.useEffect(()=>{o&&x(o)},[o]);const S=b=>{b&&x(b),n(b)},C=[{key:"basic",label:"基本信息",icon:wt},{key:"containers",label:"容器信息",icon:Ue},{key:"storage",label:"存储挂载",icon:tt},{key:"advanced",label:"高级设置",icon:wt},{key:"service",label:"服务/应用路由",icon:Ae}],y={clusterCode:t,namespace:s,deploymentName:a,manifest:l,onSaved:S,onCancel:c,isCreate:r};return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:54:5",className:"space-y-4",children:[e.jsx("div",{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:55:7",className:"flex items-center gap-1 border-b border-slate-800 pb-px overflow-x-auto",children:C.map(b=>{const w=i===b.key,P=b.icon;return e.jsxs("button",{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:60:13",onClick:()=>k(b.key),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium border-b-2 transition-colors whitespace-nowrap ${w?"border-blue-500 text-blue-400":"border-transparent text-slate-400 hover:text-slate-200"}`,children:[e.jsx(P,{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:67:15",className:"h-3.5 w-3.5"}),b.label]},b.key)})}),i==="basic"&&e.jsx(Tn,{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:74:33",...y}),i==="containers"&&e.jsx(In,{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:75:38",...y}),i==="storage"&&e.jsx(Yn,{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:76:35",...y}),i==="advanced"&&e.jsx(Xn,{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:77:36",...y}),i==="service"&&e.jsx(Zn,{"code-path":"src/components/kubernetes/deployment-workload/EditModeContainer.tsx:78:35",...y})]})}function eo({clusterCode:t,namespace:s,deploymentName:a,image:o="",containerName:n=""}){const c=Ws(),[r,i]=d.useState(!0),[k,l]=d.useState(!1),[x,S]=d.useState(!1),[C,y]=d.useState("");d.useEffect(()=>{let V=!1;return(async()=>{i(!0);const X=Ls();X&&y(X);try{const q=await zs.getApiAccessKey();V||(l(!!q?.has_token),S(!!q?.expired))}catch{V||l(!!X)}finally{V||i(!1)}})(),()=>{V=!0}},[]);const b=`${c}/kubernetes/${t}/namespace/${s}/deployments/${a}/update-image`,w=`${c}/kubernetes/${t}/namespace/${s}/deployments/${a}/restart`,P=d.useMemo(()=>{const V={image:o||"<新镜像地址>"};return n&&(V.container_name=n),JSON.stringify(V)},[o,n]),I=C?`curl -X POST '${b}' \\ - -H 'X-AIOps-Access-Key: ${C}' \\ - -H 'Content-Type: application/json' \\ - -d '${P}'`:`curl -X POST '${b}' \\ - -H 'X-AIOps-Access-Key: <个人中心生成的访问密钥>' \\ - -H 'Content-Type: application/json' \\ - -d '${P}'`,M=C?`curl -X POST '${w}' \\ - -H 'X-AIOps-Access-Key: ${C}'`:`curl -X POST '${w}' \\ - -H 'X-AIOps-Access-Key: <个人中心生成的访问密钥>'`,F=!!C&&!x;return e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:82:5",className:"space-y-4",children:[e.jsx("div",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:83:7",className:"rounded-md bg-[var(--dg-bg-tertiary)]/50 px-3 py-2 text-xs text-[var(--dg-text-muted)] leading-relaxed",children:r?e.jsxs("span",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:85:11",className:"inline-flex items-center gap-1.5",children:[e.jsx(ve,{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:86:13",className:"h-3 w-3 animate-spin"}),"正在读取 API 密钥…"]}):x?e.jsxs(e.Fragment,{children:["访问凭证已过期,请前往",e.jsx(yt,{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:91:13",to:"/profile",className:"text-[var(--dg-blue)] hover:underline mx-1",children:"个人中心"}),"调整有效期或轮换凭证后再复制 curl。"]}):C?e.jsx(e.Fragment,{children:"已填入本机保存的访问凭证,复制 curl 后可直接在终端执行触发更新。"}):k?e.jsxs(e.Fragment,{children:["已检测到访问凭证,但本机未缓存明文。请前往",e.jsx(yt,{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:99:13",to:"/profile",className:"text-[var(--dg-blue)] hover:underline mx-1",children:"个人中心"}),"轮换凭证一次,之后 curl 将自动填入。"]}):e.jsxs(e.Fragment,{children:["请先在",e.jsx(yt,{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:105:13",to:"/profile",className:"text-[var(--dg-blue)] hover:underline mx-1",children:"个人中心"}),"签发 CI/CD 访问凭证,curl 将自动填入。"]})}),e.jsx(Jt,{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:111:7",label:"更新镜像",code:I,copyLabel:"curl 已复制,可直接粘贴到终端执行",copyDisabled:!F,copyDisabledTitle:"请先在个人中心签发访问凭证"}),e.jsx(Jt,{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:118:7",label:"滚动重启",code:M,copyLabel:"curl 已复制,可直接粘贴到终端执行",copyDisabled:!F,copyDisabledTitle:"请先在个人中心签发访问凭证"}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:126:7",className:"text-xs text-[var(--dg-text-muted)] space-y-1",children:[e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:127:9",children:["• 示例镜像:",e.jsx("code",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:127:19",className:"text-[var(--dg-text-secondary)]",children:o||"—"}),n?e.jsxs(e.Fragment,{children:[" · 容器 ",e.jsx("code",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:128:36",className:"text-[var(--dg-text-secondary)]",children:n})]}):null]}),e.jsx("p",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:130:9",children:"• 使用长期 API 密钥,不会随登录 JWT 过期"}),e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:131:9",children:["• 修改 ",e.jsx("code",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:131:17",className:"text-[var(--dg-text-secondary)]",children:"image"})," 字段后执行 curl 即可触发滚动更新"]}),e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:132:9",children:["• 也可用 ",e.jsx("code",{"code-path":"src/components/kubernetes/deployment-workload/CICDWebhookContent.tsx:132:18",className:"text-[var(--dg-text-secondary)]",children:"Authorization: Bearer <密钥>"})]})]})]})}function lt({title:t,children:s,onClose:a,size:o="default"}){const n=o==="xl"?"w-[780px]":o==="lg"?"w-[680px]":"w-[460px]";return e.jsx("div",{"code-path":"src/components/kubernetes/deployment-workload/ModalShell.tsx:18:5",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",onClick:a,children:e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ModalShell.tsx:19:7",className:`bg-slate-900 border border-slate-700 rounded-xl ${n} max-w-[92vw] max-h-[85vh] flex flex-col shadow-2xl`,onClick:c=>c.stopPropagation(),children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ModalShell.tsx:23:9",className:"flex items-center justify-between gap-3 px-6 pt-6 pb-4 shrink-0",children:[e.jsx("h2",{"code-path":"src/components/kubernetes/deployment-workload/ModalShell.tsx:24:11",className:"text-base font-bold text-slate-100 truncate min-w-0",title:t,children:t}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/ModalShell.tsx:25:11",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-slate-400",onClick:a,children:e.jsx(Ss,{"code-path":"src/components/kubernetes/deployment-workload/ModalShell.tsx:25:109",className:"h-4 w-4"})})]}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-workload/ModalShell.tsx:27:9",className:"flex-1 min-h-0 overflow-y-auto px-6 pb-6",children:s})]})})}function to({clusterCode:t,namespace:s,podName:a,containers:o,onClose:n}){const{toast:c}=Me(),[r,i]=d.useState(""),[k,l]=d.useState(200),[x,S]=d.useState(o[0]||""),[C,y]=d.useState(!1),[b,w]=d.useState(!1),P=async()=>{y(!0);try{const M=await K.getPodLogs(t,s,a,k,x||void 0);i(M?.data?.logs||M?.logs||M||"无日志")}catch{i("获取日志失败")}finally{y(!1)}};d.useEffect(()=>{P()},[x,k]);const I=async()=>{w(!0);const M=is.getState().token||"",F="",V=x?`&container=${encodeURIComponent(x)}`:"",X=`${F}/api/v1/kubernetes/${t}/namespace/${s}/pods/${a}/logs?tail=${k}&stream=true${V}`;try{const W=(await fetch(X,{headers:{Authorization:`Bearer ${M}`}})).body?.getReader();if(!W)return;const Q=new TextDecoder;let $="";for(;;){const{done:Z,value:N}=await W.read();if(Z)break;$+=Q.decode(N,{stream:!0}),i($)}}catch{c({title:"流式日志连接中断",variant:"destructive"})}finally{w(!1)}};return e.jsx("div",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:65:5",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:n,children:e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:66:7",className:"bg-slate-900 border border-slate-700 rounded-xl w-[90vw] max-w-4xl max-h-[80vh] flex flex-col",onClick:M=>M.stopPropagation(),children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:67:9",className:"flex items-center justify-between p-3 border-b border-slate-700 gap-3 shrink-0",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:68:11",className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(At,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:69:13",className:"h-4 w-4 shrink-0 text-blue-400"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:70:13",className:"text-sm font-semibold text-slate-200 truncate",title:a,children:a}),x&&e.jsx(ae,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:71:27",variant:"outline",className:"border-slate-700 text-slate-400 text-[10px] shrink-0",children:x})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:73:11",className:"flex items-center gap-2 shrink-0 flex-wrap justify-end",children:[o.length>0&&e.jsx("select",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:75:15",value:x,onChange:M=>S(M.target.value),className:"bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-2 py-1",children:o.map(M=>e.jsx("option",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:77:38",value:M,children:M},M))}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:80:13",className:"text-[11px] text-slate-500",children:"最近"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:81:13",type:"number",value:k,onChange:M=>l(Number(M.target.value)||200),className:"w-16 h-7 bg-slate-800 border-slate-700 text-slate-200 text-xs"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:83:13",className:"text-[11px] text-slate-500",children:"行"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:84:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:P,disabled:C,children:C?e.jsx(ve,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:85:26",className:"h-3 w-3 animate-spin"}):e.jsx(Ye,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:85:73",className:"h-3 w-3"})}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:87:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-emerald-400 text-xs",onClick:I,disabled:b,children:b?"流中...":"实时流"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:90:13",variant:"ghost",size:"icon",className:"h-7 w-7 text-slate-400",onClick:n,children:e.jsx(Ss,{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:90:102",className:"h-4 w-4"})})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:93:9",className:"flex-1 overflow-auto p-3",children:e.jsx("pre",{"code-path":"src/components/kubernetes/deployment-workload/PodLogsModal.tsx:94:11",className:"bg-slate-950 rounded p-3 text-xs text-slate-300 font-mono whitespace-pre-wrap max-h-[60vh] overflow-auto",children:r||"无日志内容"})})]})})}function ls(t){const s=(t||"").trim();if(!s)return{repository:"",tag:"latest"};if(s.includes("@")){const n=s.lastIndexOf("@");return{repository:s.slice(0,n),tag:s.slice(n+1),digest:s.slice(n+1)}}const a=s.lastIndexOf("/"),o=s.lastIndexOf(":");return o>a?{repository:s.slice(0,o),tag:s.slice(o+1)||"latest"}:{repository:s,tag:"latest"}}function ds(t,s){const a=t.trim(),o=s.trim();return a?o?o.startsWith("sha256:")?`${a}@${o}`:`${a}:${o}`:a:""}function so({deployment:t,newImage:s,setNewImage:a,actionLoading:o,onClose:n,onUpdateImage:c}){const r=t?.image||"",i=d.useMemo(()=>ls(r),[r]),[k,l]=d.useState(""),[x,S]=d.useState("");d.useEffect(()=>{const I=ls(s||r);l(I.repository),S(I.tag)},[s,r]);const C=d.useMemo(()=>ds(k,x),[k,x]),y=x.trim()!==i.tag,b=k.trim()!==i.repository,w=C!==r,P=(I,M)=>{a(ds(I,M))};return e.jsx(lt,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:49:5",title:"调整镜像版本",onClose:n,size:"xl",children:e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:50:7",className:"space-y-5",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:52:9",className:"rounded-lg border border-slate-700/80 bg-slate-800/40 p-4 space-y-3",children:[e.jsx("p",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:53:11",className:"text-xs font-medium text-slate-400",children:"当前镜像"}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:54:11",className:"grid grid-cols-[1fr_180px] gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:55:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:56:15",className:"text-slate-500 text-xs",children:"镜像地址"}),e.jsx("p",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:57:15",className:"mt-1.5 text-sm text-slate-200 font-mono break-all leading-relaxed bg-slate-900/60 rounded-md px-3 py-2.5 min-h-[42px]",title:i.repository||"-",children:i.repository||"-"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:64:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:65:15",className:"text-slate-500 text-xs",children:"当前 Tag"}),e.jsx("p",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:66:15",className:"mt-1.5 text-sm text-cyan-300 font-mono break-all leading-relaxed bg-slate-900/60 rounded-md px-3 py-2.5 min-h-[42px]",title:i.tag||"-",children:i.tag||"-"})]})]}),e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:74:11",className:"text-[11px] text-slate-500 font-mono break-all",title:r,children:["完整引用:",e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:75:18",className:"text-slate-400",children:r||"-"})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:79:9",className:"flex items-center justify-center text-slate-600",children:e.jsx(Yt,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:80:11",className:"h-4 w-4"})}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:84:9",className:"rounded-lg border border-blue-500/30 bg-blue-500/5 p-4 space-y-3",children:[e.jsx("p",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:85:11",className:"text-xs font-medium text-blue-300/90",children:"新镜像"}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:86:11",className:"grid grid-cols-[1fr_180px] gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:87:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:88:15",className:"text-slate-400 text-xs",children:"镜像地址"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:89:15",value:k,onChange:I=>{const M=I.target.value;l(M),P(M,x)},placeholder:"harbor.example.com/project/app",className:"mt-1.5 h-10 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:100:13",children:[e.jsx(H,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:101:15",className:"text-slate-400 text-xs",children:"新版本 Tag"}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:102:15",value:x,onChange:I=>{const M=I.target.value;S(M),P(k,M)},placeholder:"v2.0.0",className:"mt-1.5 h-10 bg-slate-800 border-slate-700 text-cyan-200 text-sm font-mono"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:115:11",className:"flex flex-wrap items-center gap-2 text-xs",children:[e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:116:13",className:"text-slate-500",children:"Tag 变更:"}),e.jsx("code",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:117:13",className:"px-2 py-0.5 rounded bg-slate-800 text-slate-400 font-mono",children:i.tag}),e.jsx(Yt,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:118:13",className:"h-3 w-3 text-slate-600"}),e.jsx("code",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:119:13",className:`px-2 py-0.5 rounded font-mono ${y?"bg-cyan-500/15 text-cyan-300":"bg-slate-800 text-slate-400"}`,children:x.trim()||"-"}),!y&&!b&&e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:127:15",className:"text-slate-600",children:"(未修改)"}),b&&!y&&e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:130:15",className:"text-amber-400/80",children:"地址已变更"})]}),e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:134:11",className:"text-[11px] text-slate-500 font-mono break-all",children:["更新预览:",e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:135:18",className:"text-slate-300",children:C||"-"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:139:9",className:"flex justify-end gap-2 pt-1",children:[e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:140:11",variant:"outline",className:"border-slate-700 text-slate-400",onClick:n,children:"取消"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:143:11",className:"bg-blue-600 hover:bg-blue-700",disabled:o==="image"||!C.trim()||!w,onClick:c,children:o==="image"?e.jsx(ve,{"code-path":"src/components/kubernetes/deployment-workload/UpdateImageModal.tsx:148:42",className:"h-4 w-4 animate-spin"}):"更新镜像"})]})]})})}function no({modal:t,deployment:s,namespace:a,deploymentName:o,newImage:n,setNewImage:c,scaleValue:r,setScaleValue:i,actionLoading:k,onClose:l,onUpdateImage:x,onScaleTo:S,onDelete:C}){return e.jsxs(e.Fragment,{children:[t?.kind==="image"&&e.jsx(so,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:46:9",deployment:s,newImage:n,setNewImage:c,actionLoading:k,onClose:l,onUpdateImage:x}),t?.kind==="scale"&&e.jsx(lt,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:58:9",title:"伸缩 (Scale)",onClose:l,children:e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:59:11",className:"space-y-3",children:[e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:60:13",className:"text-xs text-slate-500",children:["当前副本: ",s.replicas||0]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:61:13",className:"flex items-center justify-center gap-3 py-3",children:[e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:62:15",variant:"outline",size:"icon",className:"border-slate-700 text-slate-300",disabled:k==="scale"||r<=0,onClick:()=>i(y=>Math.max(0,y-1)),children:e.jsx(Tt,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:65:17",className:"h-4 w-4"})}),e.jsx(f,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:67:15",type:"number",min:0,value:r,onChange:y=>i(Math.max(0,Number(y.target.value))),className:"w-24 text-center text-lg font-bold bg-slate-800 border-slate-700 text-slate-200"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:70:15",variant:"outline",size:"icon",className:"border-slate-700 text-slate-300",disabled:k==="scale",onClick:()=>i(y=>y+1),children:e.jsx(te,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:73:17",className:"h-4 w-4"})})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:76:13",className:"flex justify-end gap-2 pt-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:77:15",variant:"outline",className:"border-slate-700 text-slate-400",onClick:l,children:"取消"}),e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:78:15",className:"bg-blue-600 hover:bg-blue-700",disabled:k==="scale",onClick:S,children:k==="scale"?e.jsx(ve,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:79:46",className:"h-4 w-4 animate-spin"}):"确认"})]})]})}),t?.kind==="delete"&&e.jsx(lt,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:88:9",title:"删除 Deployment",onClose:l,children:e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:89:11",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:90:13",className:"flex items-center gap-2 text-red-400",children:[e.jsx(ws,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:91:15",className:"h-5 w-5"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:92:15",className:"font-semibold",children:"此操作不可撤销"})]}),e.jsxs("p",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:94:13",className:"text-sm text-slate-400",children:["确认删除 Deployment ",e.jsxs("code",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:95:31",className:"text-slate-200 font-mono",children:[a,"/",o]}),"? 其管理的所有 Pod 将被一并回收。"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:98:13",className:"flex justify-end gap-2 pt-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:99:15",variant:"outline",className:"border-slate-700 text-slate-400",onClick:l,children:"取消"}),e.jsxs(v,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:100:15",variant:"destructive",disabled:k==="delete",onClick:C,children:[k==="delete"?e.jsx(ve,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:101:47",className:"h-4 w-4 animate-spin mr-1"}):e.jsx(be,{"code-path":"src/components/kubernetes/deployment-workload/ActionModals.tsx:101:99",className:"h-4 w-4 mr-1"}),"确认删除"]})]})]})})]})}function oo(t){const s=t?.containers;return Array.isArray(s)?s.map(a=>typeof a=="string"?a:a?.name||a?.Name).filter(Boolean):Array.isArray(t?.container_statuses)?t.container_statuses.map(a=>a?.name).filter(Boolean):Array.isArray(t?.containerNames)?t.containerNames.filter(Boolean):[]}function ao({clusterCode:t,namespace:s,deploymentName:a,mode:o,onBack:n,onModeChange:c}){const r=It(a),i=ps(),{toast:k}=Me(),l=dt(),[x,S]=d.useState(null),[C,y]=d.useState(null),[b,w]=d.useState([]),[P,I]=d.useState([]),[M,F]=d.useState([]),[V,X]=d.useState(!0),[q,W]=d.useState(""),[Q,$]=d.useState(null),[Z,N]=d.useState(""),[_,J]=d.useState(0),[ee,me]=d.useState(null),[ye,ge]=d.useState(null),R=x?.cluster_id||x?.clusterId||t,p=d.useMemo(()=>{const E=C?.spec?.template?.spec?.containers?.[0]?.name;if(E)return E;if(b.length>0){const ie=oo(b[0]);if(ie.length)return ie[0]}return""},[C,b]),h=E=>Array.isArray(E)?E:E?.list||E?.items||E?.data||[],u=d.useCallback(async()=>{if(r){const E=yn("deployments",s,"my-app");S({name:"my-app",namespace:s,replicas:1}),y(E),w([]),I([]),F([]),X(!1);return}X(!0);try{const[E,ie,je,Ne]=await Promise.all([K.getDeployment(t,s,a).catch(()=>null),K.getNamespacePods(t,s).catch(()=>[]),K.getReplicaSets(t,s).catch(()=>[]),K.getDeploymentRevisions(t,s,a).catch(()=>[])]),Te=E||(Array.isArray(E)?E[0]:null);S(Te),J(Te?.replicas||0),N(Te?.image||"");const qe=h(ie).filter(Pe=>Pe.namespace===s&&(Pe.name||"").startsWith(a));w(qe);const Ke=h(je).filter(Pe=>Pe.namespace===s&&(Pe.owner_deployment===a||(Pe.name||"").startsWith(a)));I(Ke),F(h(Ne))}catch(E){console.error("加载详情失败:",E)}finally{X(!1)}},[t,s,a,r]),A=d.useCallback(async()=>{if(!r)try{const E=await K.getResourceYaml(t,s,"deployments",a),{parseEditableManifest:ie}=await Gs(async()=>{const{parseEditableManifest:Ne}=await import("./PodFileBrowser-B-U8iHmY.js").then(Te=>Te.k);return{parseEditableManifest:Ne}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])),{manifest:je}=await ie(E);y(je||x)}catch(E){console.warn("加载 manifest 失败(编辑功能降级):",E),y(x)}},[t,s,a,x]),L=d.useCallback(()=>jn(t,s,a),[t,s,a]),m=d.useCallback(E=>fn(t,s,E),[t,s]);d.useEffect(()=>{u()},[u]),d.useEffect(()=>{r||o!=="edit"||C||A()},[o,C,A,r]);const g=async()=>{W("scale");try{await K.scaleDeployment(t,s,a,_),k({title:"伸缩成功",description:`副本数已设置为 ${_}`}),$(null),u()}catch(E){k({title:"操作失败",description:E?.message||String(E),variant:"destructive"})}finally{W("")}},j=async()=>{if(await l({title:"滚动重启",description:`确认滚动重启 Deployment "${a}"?`,confirmText:"重启"})){W("restart");try{await K.restartDeployment(t,s,a),k({title:"重启指令已下发",description:"Deployment 正在滚动重启"}),setTimeout(u,1500)}catch(ie){k({title:"重启失败",description:ie?.message||String(ie),variant:"destructive"})}finally{W("")}}},O=async()=>{const E=!!x?.paused,ie=E?"恢复":"暂停";if(await l({title:`${ie}滚动更新`,description:`确认${ie} Deployment "${a}" 的滚动更新?`,confirmText:ie})){W(E?"resume":"pause");try{E?await K.resumeDeployment(t,s,a):await K.pauseDeployment(t,s,a),k({title:`${ie}成功`,description:`Deployment 滚动更新已${ie}`}),setTimeout(u,1e3)}catch(Ne){k({title:`${ie}失败`,description:Ne?.message||String(Ne),variant:"destructive"})}finally{W("")}}},xe=async()=>{!r&&!C&&await A(),$({kind:"cicd"})},se=async()=>{if(Z.trim()){W("image");try{await K.updateDeploymentImage(t,s,a,Z,p||void 0),k({title:"镜像更新成功",description:`正在滚动更新为 ${Z}`}),$(null),u()}catch(E){k({title:"更新失败",description:E?.message||String(E),variant:"destructive"})}finally{W("")}}},B=async()=>{W("delete");try{const E=is.getState().token||"",je=`/api/v1/kubernetes/${t}/namespace/${s}/deployments/${a}`,Ne=await fetch(je,{method:"DELETE",headers:{Authorization:`Bearer ${E}`}});if(!Ne.ok)throw new Error(`HTTP ${Ne.status}`);k({title:"删除成功",description:`${a} 已删除`}),$(null),setTimeout(()=>i(`/kubernetes/${t}/namespace/${s}/deployments`),800)}catch(E){k({title:"删除失败",description:E?.message||String(E),variant:"destructive"})}finally{W("")}},de=E=>$({kind:"podLogs",pod:E.name}),De=E=>$({kind:"podYaml",pod:E.name}),Se=E=>{me(E.name)},Ie=E=>{ge(E.name)},$e=async E=>{if(await l({title:"删除 Pod",description:`确认删除 Pod "${E.name}"?操作不可恢复。`,confirmText:"删除"}))try{await K.deletePod(t,s,E.name),k({title:"Pod 已删除"}),u()}catch(je){k({title:"删除失败",description:je?.message||String(je),variant:"destructive"})}};if(V)return e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:288:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:289:9",className:"p-12 text-center",children:[e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:290:11",className:"h-6 w-6 animate-spin mx-auto text-slate-500"}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:291:11",className:"text-slate-500 mt-3",children:"加载中..."})]})});if(!x&&!r)return e.jsx(U,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:299:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:300:9",className:"p-12 text-center",children:[e.jsx(hn,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:301:11",className:"h-8 w-8 mx-auto text-red-400"}),e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:302:11",className:"text-slate-400 mt-3",children:["未找到 Deployment: ",a]}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:303:11",variant:"outline",className:"mt-4",onClick:n,children:"返回"})]})});if(r){const E=ie=>{const je=ie?.metadata?.name;je&&i(`/kubernetes/${t}/namespace/${s}/workload/view/Deployment/${je}`)};return e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:317:7",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:318:9",className:"flex items-center gap-3",children:[e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:319:11",variant:"ghost",size:"sm",className:"text-slate-400",onClick:n,children:[e.jsx(qt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:320:13",className:"h-4 w-4 mr-1"}),"返回"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:322:11",children:[e.jsx("h1",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:323:13",className:"text-xl font-bold text-slate-100",children:"新建 Deployment"}),e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:324:13",className:"text-xs text-slate-500 mt-0.5",children:[s," · ",t]})]})]}),e.jsx(cs,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:327:9",clusterCode:t,namespace:s,deploymentName:Ds,manifest:C,isCreate:!0,onSaved:E,onCancel:n})]})}const _e=x.ready_replicas||x.readyReplicas||0,Be=x.replicas||0,Le=_e===Be&&Be>0;return e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:346:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:348:7",className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:349:9",className:"flex items-center gap-3 min-w-0",children:[e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:350:11",variant:"ghost",size:"sm",className:"text-slate-400",onClick:n,children:[e.jsx(qt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:351:13",className:"h-4 w-4 mr-1"}),"返回"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:353:11",className:"min-w-0",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:354:13",className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h1",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:355:15",className:"text-xl font-bold text-slate-100 truncate",children:a}),e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:356:15",variant:"outline",className:"border-slate-700 text-slate-400",children:s}),e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:357:15",variant:"outline",className:"border-slate-700 text-slate-400",children:"Deployment"}),e.jsxs(ae,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:358:15",className:Le?"bg-emerald-500/20 text-emerald-400 border-emerald-500/30":"bg-amber-500/20 text-amber-400 border-amber-500/30",children:[Le?e.jsx(Ct,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:363:30",className:"h-3 w-3 mr-1"}):e.jsx(ws,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:363:73",className:"h-3 w-3 mr-1"}),_e,"/",Be]}),x?.paused&&e.jsxs(ae,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:367:17",className:"bg-orange-500/20 text-orange-400 border-orange-500/30",children:[e.jsx(Kt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:368:19",className:"h-3 w-3 mr-1"}),"已暂停更新"]})]}),e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:372:13",className:"text-xs text-slate-500 mt-0.5 truncate",children:["镜像: ",e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:373:19",className:"text-slate-400",children:x.image||"-"})]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:378:9",className:"flex items-center gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:380:11",className:"inline-flex rounded-md border border-slate-700 overflow-hidden",children:[e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:381:13",className:`px-3 py-1.5 text-xs font-medium transition-colors ${o==="view"?"bg-slate-700 text-slate-100":"bg-transparent text-slate-400 hover:text-slate-200"}`,onClick:()=>c("view"),children:"查看"}),e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:387:13",className:`px-3 py-1.5 text-xs font-medium transition-colors ${o==="edit"?"bg-blue-600 text-white":"bg-transparent text-slate-400 hover:text-slate-200"}`,onClick:()=>c("edit"),children:"编辑"}),e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:393:13",className:`px-3 py-1.5 text-xs font-medium transition-colors ${o==="yaml"?"bg-emerald-600 text-white":"bg-transparent text-slate-400 hover:text-slate-200"}`,onClick:()=>c("yaml"),children:"YAML"})]}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:401:11",variant:"outline",size:"sm",className:"border-slate-700 text-slate-400",onClick:u,title:"刷新",children:e.jsx(Ye,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:402:13",className:"h-4 w-4"})}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:406:11",className:"flex items-center gap-1.5",children:[e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:407:13",variant:"outline",size:"sm",className:"border-slate-700 text-slate-300",onClick:()=>{N(x?.image||""),$({kind:"image"})},children:[e.jsx(un,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:416:15",className:"h-3.5 w-3.5 mr-1"}),"调整镜像"]}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:418:13",variant:"outline",size:"sm",className:"border-slate-700 text-slate-300",onClick:j,children:[e.jsx(fs,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:419:15",className:"h-3.5 w-3.5 mr-1"}),"重启"]}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:421:13",variant:"outline",size:"sm",className:"border-slate-700 text-slate-300",disabled:!!q,onClick:O,children:x?.paused?e.jsxs(e.Fragment,{children:[e.jsx(Ns,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:428:21",className:"h-3.5 w-3.5 mr-1 text-green-400"}),"恢复"]}):e.jsxs(e.Fragment,{children:[e.jsx(Kt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:429:21",className:"h-3.5 w-3.5 mr-1 text-orange-400"}),"暂停"]})}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:432:13",variant:"outline",size:"sm",className:"border-slate-700 text-slate-300",onClick:xe,children:[e.jsx(bn,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:433:15",className:"h-3.5 w-3.5 mr-1 text-purple-400"}),"CI/CD"]}),e.jsxs(v,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:435:13",variant:"outline",size:"sm",className:"border-slate-700 text-red-400 hover:bg-red-500/10",onClick:()=>$({kind:"delete"}),children:[e.jsx(be,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:436:15",className:"h-3.5 w-3.5 mr-1"}),"删除"]})]})]})]}),o==="view"?e.jsx(An,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:444:9",clusterCode:t,namespace:s,deployment:x,pods:b,replicaSets:P,revisions:M,onRefresh:u,onShowPodLogs:de,onShowPodTerminal:Se,onShowPodYaml:De,onShowPodFileBrowser:Ie,onDeletePod:$e}):o==="yaml"?e.jsx(kt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:460:9",clusterCode:t,namespace:s,resource:"deployments",name:a,inline:!0,resourceHint:"含关联 Service",loadYamlFn:L,saveYamlFn:m,onSaved:u,onClose:()=>c("view")}):e.jsx(cs,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:474:9",clusterCode:t,namespace:s,deploymentName:a,manifest:C,onSaved:()=>{A(),u()},onCancel:()=>c("view")}),Q?.kind==="yaml"&&e.jsx(kt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:486:9",clusterCode:t,namespace:s,resource:"deployments",name:a,resourceHint:"含关联 Service",loadYamlFn:L,saveYamlFn:m,onClose:()=>$(null),onSaved:u}),e.jsx(no,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:499:7",modal:Q,deployment:x,namespace:s,deploymentName:a,newImage:Z,setNewImage:N,scaleValue:_,setScaleValue:J,actionLoading:q,onClose:()=>$(null),onUpdateImage:se,onScaleTo:g,onDelete:B}),Q?.kind==="cicd"&&e.jsx(lt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:517:9",title:"CI/CD Webhook",onClose:()=>$(null),size:"lg",children:e.jsx(eo,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:518:11",clusterCode:t,namespace:s,deploymentName:a,image:x?.image||Z||"",containerName:p})}),Q?.kind==="podYaml"&&e.jsx(kt,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:530:9",clusterCode:t,namespace:s,resource:"pods",name:Q.pod,readOnly:!0,onClose:()=>$(null)}),Q?.kind==="podLogs"&&e.jsx(to,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:542:9",clusterCode:t,namespace:s,podName:Q.pod,containers:(b.find(E=>E.name===Q.pod)?.containers||[]).map(E=>E.name).filter(Boolean),onClose:()=>$(null)}),e.jsx(Ys,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:552:7",open:!!ee,onOpenChange:E=>{E||me(null)},clusterId:R,namespace:s,podName:ee||"",containers:(b.find(E=>E.name===ee)?.containers||[]).map(E=>E.name).filter(Boolean)}),e.jsx(qs,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:561:7",open:!!ye,onOpenChange:E=>{E||ge(null)},clusterCode:t,namespace:s,podName:ye||"",containers:(b.find(E=>E.name===ye)?.containers||[]).map(E=>E.name).filter(Boolean)})]})}function Eo(){const t=Vs(),s=ps(),a=t.clusterCode||"",o=t.namespace||"",n=t.name||"",c=It(n)?"edit":t.mode==="edit"||t.mode==="yaml"?t.mode:"view",r=i=>{i!==c&&s(`/kubernetes/${a}/namespace/${o}/workload/${i}/Deployment/${n}`,{replace:!0})};return e.jsx(ao,{"code-path":"src/components/kubernetes/DeploymentDetailPage.tsx:41:5",clusterCode:a,namespace:o,deploymentName:n,mode:c,onBack:()=>s(-1),onModeChange:r})}export{Eo as default}; diff --git a/backend/static/assets/DomainManager-BVDiC0aB.js b/backend/static/assets/DomainManager-BVDiC0aB.js deleted file mode 100644 index 4e03d5d..0000000 --- a/backend/static/assets/DomainManager-BVDiC0aB.js +++ /dev/null @@ -1 +0,0 @@ -import{r as n,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{B as m,D as U,a as A,b as H,c as X,d as q,e as J}from"./index-Dungj95X.js";import{I as l}from"./input-CXoUQQLm.js";import{L as d}from"./label-CMpUoC87.js";import{C as j,a as M}from"./card-BIfzBCEy.js";import{B as h}from"./badge-CGJlVD3L.js";import{c as u}from"./account--x8iUlBA.js";import{R as E,P as L,S as K,G as k,C as P,a as V,b as W,c as O,T as Y,L as Z}from"./vendor-icons-DmqcWdzX.js";function le(){const[i,b]=n.useState([]),[N,v]=n.useState(!0),[g,B]=n.useState(""),[D,F]=n.useState("all"),[I,p]=n.useState(!1),[f,_]=n.useState(!1),[r,y]=n.useState(null),[a,t]=n.useState({name:"",registrar:"",status:"active",expire_date:"",dns_provider:"",record_count:"",ssl_enabled:!1,ssl_expire_date:""}),T=()=>{y(null),t({name:"",registrar:"",status:"active",expire_date:"",dns_provider:"",record_count:"",ssl_enabled:!1,ssl_expire_date:""})},R=()=>{T(),p(!0)},$=s=>{y(s);const c=o=>o?o.substring(0,10):"";t({name:s.name||"",registrar:s.registrar||"",status:s.status||"active",expire_date:c(s.expire_date||""),dns_provider:s.dns_provider||s.dnsProvider||"",record_count:String(s.record_count??s.recordCount??""),ssl_enabled:s.ssl_enabled??s.sslEnabled??!1,ssl_expire_date:c(s.ssl_expire_date||"")}),p(!0)},z=async()=>{if(a.name.trim())try{_(!0);const s={name:a.name.trim(),registrar:a.registrar.trim(),status:a.status,expire_date:a.expire_date,dns_provider:a.dns_provider.trim(),record_count:Number(a.record_count)||0,ssl_enabled:a.ssl_enabled,ssl_expire_date:a.ssl_expire_date};r?await u.updateDomain(r.id,s):await u.createDomain(s),p(!1),x()}catch(s){console.error(r?"更新域名失败:":"创建域名失败:",s)}finally{_(!1)}},x=async()=>{try{v(!0);const s=await u.getDomains();b(s?.list||[])}catch(s){console.error("加载域名列表失败:",s),b([])}finally{v(!1)}};n.useEffect(()=>{x()},[]);const G=async s=>{try{await u.deleteDomain(s),x()}catch(c){console.error("删除域名失败:",c)}},w=i.filter(s=>{const c=(s.name||"").toLowerCase().includes(g.toLowerCase())||(s.registrar||"").toLowerCase().includes(g.toLowerCase()),o=D==="all"||s.status===D;return c&&o});i.length,i.filter(s=>s.status==="active").length,i.filter(s=>s.status==="expired").length,i.filter(s=>s.status==="pending").length,i.filter(s=>s.ssl_enabled||s.sslEnabled).length;const Q=s=>s?Math.ceil((new Date(s).getTime()-Date.now())/(1e3*60*60*24)):1/0;return e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:163:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:165:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:166:9",children:[e.jsx("h1",{"code-path":"src/components/cloud/DomainManager.tsx:167:11",className:"text-2xl font-bold text-slate-100",children:"域名管理"}),e.jsx("p",{"code-path":"src/components/cloud/DomainManager.tsx:168:11",className:"text-slate-400 mt-1",children:"管理域名注册信息和DNS解析记录"})]}),e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:170:9",className:"flex items-center gap-2",children:[e.jsxs(m,{"code-path":"src/components/cloud/DomainManager.tsx:171:11",variant:"outline",onClick:x,className:"border-slate-700 text-slate-300",children:[e.jsx(E,{"code-path":"src/components/cloud/DomainManager.tsx:172:13",className:`h-4 w-4 mr-2 ${N?"animate-spin":""}`}),"刷新"]}),e.jsxs(m,{"code-path":"src/components/cloud/DomainManager.tsx:175:11",className:"bg-blue-600 hover:bg-blue-700",onClick:R,children:[e.jsx(L,{"code-path":"src/components/cloud/DomainManager.tsx:176:13",className:"h-4 w-4 mr-2"}),"添加域名"]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:183:7",className:"flex items-center gap-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:184:9",className:"relative flex-1 max-w-md",children:[e.jsx(K,{"code-path":"src/components/cloud/DomainManager.tsx:185:11",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(l,{"code-path":"src/components/cloud/DomainManager.tsx:186:11",placeholder:"搜索域名...",value:g,onChange:s=>B(s.target.value),className:"pl-10 bg-slate-800 border-slate-700 text-slate-100"})]}),e.jsxs("select",{"code-path":"src/components/cloud/DomainManager.tsx:193:9",value:D,onChange:s=>F(s.target.value),className:"px-3 py-2 bg-slate-800 border border-slate-700 rounded-md text-slate-100 text-sm",children:[e.jsx("option",{"code-path":"src/components/cloud/DomainManager.tsx:198:11",value:"all",children:"全部状态"}),e.jsx("option",{"code-path":"src/components/cloud/DomainManager.tsx:199:11",value:"active",children:"正常"}),e.jsx("option",{"code-path":"src/components/cloud/DomainManager.tsx:200:11",value:"expired",children:"已过期"}),e.jsx("option",{"code-path":"src/components/cloud/DomainManager.tsx:201:11",value:"pending",children:"待审核"})]})]}),N?e.jsx(j,{"code-path":"src/components/cloud/DomainManager.tsx:207:9",className:"bg-slate-800 border-slate-700",children:e.jsxs(M,{"code-path":"src/components/cloud/DomainManager.tsx:208:11",className:"p-12 text-center text-slate-500",children:[e.jsx(E,{"code-path":"src/components/cloud/DomainManager.tsx:209:13",className:"h-6 w-6 animate-spin mx-auto mb-3"}),"加载中..."]})}):w.length===0?e.jsx(j,{"code-path":"src/components/cloud/DomainManager.tsx:214:9",className:"bg-slate-800 border-slate-700",children:e.jsx(M,{"code-path":"src/components/cloud/DomainManager.tsx:215:11",className:"p-12 text-center text-slate-500",children:"暂无域名数据"})}):e.jsx("div",{"code-path":"src/components/cloud/DomainManager.tsx:218:9",className:"space-y-3",children:w.map(s=>{const c=s.ssl_enabled||s.sslEnabled,o=s.expire_date||s.expireDate||"",C=s.ssl_expire_date||s.sslExpireDate||"",S=Q(o);return e.jsx(j,{"code-path":"src/components/cloud/DomainManager.tsx:225:15",className:"bg-slate-800 border-slate-700",children:e.jsx(M,{"code-path":"src/components/cloud/DomainManager.tsx:226:17",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:227:19",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:228:21",className:"flex items-center gap-4",children:[e.jsx("div",{"code-path":"src/components/cloud/DomainManager.tsx:229:23",className:"w-10 h-10 rounded-lg bg-gradient-to-br from-blue-500 to-cyan-500 flex items-center justify-center",children:e.jsx(k,{"code-path":"src/components/cloud/DomainManager.tsx:230:25",className:"h-5 w-5 text-white"})}),e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:232:23",children:[e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:233:25",className:"flex items-center gap-2",children:[e.jsx("h3",{"code-path":"src/components/cloud/DomainManager.tsx:234:27",className:"font-medium text-slate-100 text-lg",children:s.name}),s.status==="active"&&e.jsxs(h,{"code-path":"src/components/cloud/DomainManager.tsx:236:29",className:"bg-green-500/20 text-green-400 border-0",children:[e.jsx(P,{"code-path":"src/components/cloud/DomainManager.tsx:237:31",className:"h-3 w-3 mr-1"}),"正常"]}),s.status==="expired"&&e.jsxs(h,{"code-path":"src/components/cloud/DomainManager.tsx:242:29",className:"bg-red-500/20 text-red-400 border-0",children:[e.jsx(V,{"code-path":"src/components/cloud/DomainManager.tsx:243:31",className:"h-3 w-3 mr-1"}),"已过期"]}),s.status==="pending"&&e.jsxs(h,{"code-path":"src/components/cloud/DomainManager.tsx:248:29",className:"bg-yellow-500/20 text-yellow-400 border-0",children:[e.jsx(W,{"code-path":"src/components/cloud/DomainManager.tsx:249:31",className:"h-3 w-3 mr-1"}),"待审核"]}),c&&e.jsxs(h,{"code-path":"src/components/cloud/DomainManager.tsx:254:29",className:"bg-cyan-500/20 text-cyan-400 border-0",children:[e.jsx(P,{"code-path":"src/components/cloud/DomainManager.tsx:255:31",className:"h-3 w-3 mr-1"}),"SSL"]})]}),e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:260:25",className:"flex items-center gap-4 mt-1 text-sm text-slate-400",children:[e.jsxs("span",{"code-path":"src/components/cloud/DomainManager.tsx:261:27",children:["注册商: ",s.registrar||"-"]}),e.jsxs("span",{"code-path":"src/components/cloud/DomainManager.tsx:262:27",children:["DNS: ",s.dns_provider||s.dnsProvider||"-"]}),e.jsxs("span",{"code-path":"src/components/cloud/DomainManager.tsx:263:27",children:["解析记录: ",s.record_count??s.recordCount??0,"条"]})]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:267:21",className:"flex items-center gap-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:268:23",className:"text-right",children:[e.jsx("p",{"code-path":"src/components/cloud/DomainManager.tsx:269:25",className:"text-sm text-slate-400",children:"到期时间"}),e.jsxs("p",{"code-path":"src/components/cloud/DomainManager.tsx:270:25",className:`text-sm font-medium ${S<30?"text-red-400":"text-slate-200"}`,children:[o?o.substring(0,10):"-",o&&` (${S}天)`,c&&C&&e.jsxs("span",{"code-path":"src/components/cloud/DomainManager.tsx:273:29",className:"text-slate-500",children:[" · SSL: ",C.substring(0,10)]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:277:23",className:"flex items-center gap-1",children:[e.jsx(m,{"code-path":"src/components/cloud/DomainManager.tsx:278:25",variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-blue-400",onClick:()=>$(s),children:e.jsx(O,{"code-path":"src/components/cloud/DomainManager.tsx:284:27",className:"h-4 w-4"})}),e.jsx(m,{"code-path":"src/components/cloud/DomainManager.tsx:286:25",variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-red-400",onClick:()=>G(s.id),children:e.jsx(Y,{"code-path":"src/components/cloud/DomainManager.tsx:292:27",className:"h-4 w-4"})})]})]})]})})},s.id)})}),e.jsx(U,{"code-path":"src/components/cloud/DomainManager.tsx:305:7",open:I,onOpenChange:p,children:e.jsxs(A,{"code-path":"src/components/cloud/DomainManager.tsx:306:9",className:"bg-slate-800 border-slate-700 text-slate-100 max-w-lg",children:[e.jsxs(H,{"code-path":"src/components/cloud/DomainManager.tsx:307:11",children:[e.jsxs(X,{"code-path":"src/components/cloud/DomainManager.tsx:308:13",className:"text-slate-100 flex items-center gap-2",children:[e.jsx(k,{"code-path":"src/components/cloud/DomainManager.tsx:309:15",className:"h-5 w-5 text-blue-400"}),r?"编辑域名":"添加域名"]}),e.jsx(q,{"code-path":"src/components/cloud/DomainManager.tsx:312:13",className:"text-slate-400",children:r?"修改域名注册信息、DNS 配置和 SSL 证书状态":"录入域名信息,包括注册商、DNS 服务商和到期时间"})]}),e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:317:11",className:"space-y-4 py-2",children:[e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:318:13",className:"space-y-2",children:[e.jsx(d,{"code-path":"src/components/cloud/DomainManager.tsx:319:15",className:"text-slate-300",children:"域名 *"}),e.jsx(l,{"code-path":"src/components/cloud/DomainManager.tsx:320:15",placeholder:"example.com",value:a.name,onChange:s=>t({...a,name:s.target.value}),className:"bg-slate-900 border-slate-700 text-slate-100"})]}),e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:328:13",className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:329:15",className:"space-y-2",children:[e.jsx(d,{"code-path":"src/components/cloud/DomainManager.tsx:330:17",className:"text-slate-300",children:"注册商"}),e.jsx(l,{"code-path":"src/components/cloud/DomainManager.tsx:331:17",placeholder:"阿里云 / Cloudflare ...",value:a.registrar,onChange:s=>t({...a,registrar:s.target.value}),className:"bg-slate-900 border-slate-700 text-slate-100"})]}),e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:338:15",className:"space-y-2",children:[e.jsx(d,{"code-path":"src/components/cloud/DomainManager.tsx:339:17",className:"text-slate-300",children:"状态"}),e.jsxs("select",{"code-path":"src/components/cloud/DomainManager.tsx:340:17",value:a.status,onChange:s=>t({...a,status:s.target.value}),className:"w-full px-3 py-2 bg-slate-900 border border-slate-700 rounded-md text-slate-100 text-sm",children:[e.jsx("option",{"code-path":"src/components/cloud/DomainManager.tsx:345:19",value:"active",children:"正常"}),e.jsx("option",{"code-path":"src/components/cloud/DomainManager.tsx:346:19",value:"expired",children:"已过期"}),e.jsx("option",{"code-path":"src/components/cloud/DomainManager.tsx:347:19",value:"pending",children:"待审核"})]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:352:13",className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:353:15",className:"space-y-2",children:[e.jsx(d,{"code-path":"src/components/cloud/DomainManager.tsx:354:17",className:"text-slate-300",children:"到期时间"}),e.jsx(l,{"code-path":"src/components/cloud/DomainManager.tsx:355:17",type:"date",value:a.expire_date,onChange:s=>t({...a,expire_date:s.target.value}),className:"bg-slate-900 border-slate-700 text-slate-100"})]}),e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:362:15",className:"space-y-2",children:[e.jsx(d,{"code-path":"src/components/cloud/DomainManager.tsx:363:17",className:"text-slate-300",children:"DNS 服务商"}),e.jsx(l,{"code-path":"src/components/cloud/DomainManager.tsx:364:17",placeholder:"Cloudflare / DNSPod ...",value:a.dns_provider,onChange:s=>t({...a,dns_provider:s.target.value}),className:"bg-slate-900 border-slate-700 text-slate-100"})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:373:13",className:"space-y-2",children:[e.jsx(d,{"code-path":"src/components/cloud/DomainManager.tsx:374:15",className:"text-slate-300",children:"解析记录数"}),e.jsx(l,{"code-path":"src/components/cloud/DomainManager.tsx:375:15",type:"number",placeholder:"0",value:a.record_count,onChange:s=>t({...a,record_count:s.target.value}),className:"bg-slate-900 border-slate-700 text-slate-100"})]}),e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:384:13",className:"grid grid-cols-2 gap-4 items-end",children:[e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:385:15",className:"space-y-2",children:[e.jsx(d,{"code-path":"src/components/cloud/DomainManager.tsx:386:17",className:"text-slate-300",children:"SSL 证书到期"}),e.jsx(l,{"code-path":"src/components/cloud/DomainManager.tsx:387:17",type:"date",value:a.ssl_expire_date,onChange:s=>t({...a,ssl_expire_date:s.target.value}),disabled:!a.ssl_enabled,className:"bg-slate-900 border-slate-700 text-slate-100 disabled:opacity-40"})]}),e.jsxs("label",{"code-path":"src/components/cloud/DomainManager.tsx:395:15",className:"flex items-center gap-2 cursor-pointer pb-2",children:[e.jsx("input",{"code-path":"src/components/cloud/DomainManager.tsx:396:17",type:"checkbox",checked:a.ssl_enabled,onChange:s=>t({...a,ssl_enabled:s.target.checked}),className:"h-4 w-4 rounded border-slate-600 bg-slate-900 accent-cyan-500"}),e.jsx("span",{"code-path":"src/components/cloud/DomainManager.tsx:402:17",className:"text-slate-300 text-sm",children:"启用 SSL"})]})]})]}),e.jsxs(J,{"code-path":"src/components/cloud/DomainManager.tsx:407:11",children:[e.jsx(m,{"code-path":"src/components/cloud/DomainManager.tsx:408:13",variant:"outline",onClick:()=>p(!1),className:"border-slate-700 text-slate-300",children:"取消"}),e.jsxs(m,{"code-path":"src/components/cloud/DomainManager.tsx:411:13",className:"bg-blue-600 hover:bg-blue-700",disabled:!a.name.trim()||f,onClick:z,children:[f?e.jsx(Z,{"code-path":"src/components/cloud/DomainManager.tsx:416:29",className:"h-4 w-4 mr-2 animate-spin"}):r?e.jsx(O,{"code-path":"src/components/cloud/DomainManager.tsx:416:97",className:"h-4 w-4 mr-2"}):e.jsx(L,{"code-path":"src/components/cloud/DomainManager.tsx:416:134",className:"h-4 w-4 mr-2"}),r?"保存修改":"创建域名"]})]})]})})]})}export{le as DomainManager}; diff --git a/backend/static/assets/EventTable-BaH7H8dT.js b/backend/static/assets/EventTable-BaH7H8dT.js deleted file mode 100644 index edacdf0..0000000 --- a/backend/static/assets/EventTable-BaH7H8dT.js +++ /dev/null @@ -1 +0,0 @@ -import{r as k,j as t}from"./vendor-codemirror-B1SGo4xl.js";import{B as f}from"./badge-CGJlVD3L.js";import{T as N,a as y,b as p,c as o,d as $,e as r}from"./table-B2F10oba.js";import{f as _,a as K,e as C}from"./k8s-yaml-utils-4KZB_Bq_.js";import{L as S}from"./vendor-icons-DmqcWdzX.js";function z(e){const a=e.object_kind||e.objectKind||"",n=e.object_name||e.objectName||"",c=e.object||(a&&n?`${a}/${n}`:"")||"",d=e.first_time||e.firstTime||e.first_timestamp||e.firstTimestamp||"",i=e.last_time||e.lastTime||e.last_timestamp||e.lastTimestamp||"",x=e.event_time||e.eventTime||"",b=Number(e.count)>0?Number(e.count):1,l=e.source||e.source_component||e.sourceComponent||(e.source?.component?`${e.source.component}${e.source.host?`@${e.source.host}`:""}`:"")||"-";return{name:e.name||"",namespace:e.namespace||"",type:e.type||"Normal",reason:e.reason||"-",message:e.message||"-",object:c||"-",objectKind:a,objectName:n,source:l,count:b,firstTime:d||x,lastTime:i||x,eventTime:x}}function B(e){if(!e)return"";const a=Date.now()-new Date(e).getTime();if(a<0)return"";const n=Math.floor(a/6e4);if(n<1)return"刚刚";if(n<60)return`${n}分钟前`;const c=Math.floor(n/60);return c<24?`${c}小时前`:`${Math.floor(c/24)}天前`}function D(e,a,n){if(n<=1)return"-";const c=K(C(e,a));return c==="-"?`×${n}`:`${c} · ×${n}`}function j(e){return{absolute:_(e),relative:B(e)}}function q({events:e,loading:a=!1,emptyText:n="暂无事件",maxRows:c,showNamespace:d=!1}){const[i,x]=k.useState(null),b=a===!0||a==="events",l=c?e.slice(0,c):e,v=d?10:9;return t.jsxs("div",{"code-path":"src/components/kubernetes/EventTable.tsx:35:5",className:"overflow-x-auto",children:[t.jsxs(N,{"code-path":"src/components/kubernetes/EventTable.tsx:36:7",children:[t.jsx(y,{"code-path":"src/components/kubernetes/EventTable.tsx:37:9",children:t.jsxs(p,{"code-path":"src/components/kubernetes/EventTable.tsx:38:11",className:"border-[var(--dg-border)] hover:bg-transparent",children:[t.jsx(o,{"code-path":"src/components/kubernetes/EventTable.tsx:39:13",className:"text-[var(--dg-text-muted)] w-[148px]",children:"最后时间"}),t.jsx(o,{"code-path":"src/components/kubernetes/EventTable.tsx:40:13",className:"text-[var(--dg-text-muted)] w-[148px]",children:"首次时间"}),t.jsx(o,{"code-path":"src/components/kubernetes/EventTable.tsx:41:13",className:"text-[var(--dg-text-muted)] w-16 text-center",children:"次数"}),t.jsx(o,{"code-path":"src/components/kubernetes/EventTable.tsx:42:13",className:"text-[var(--dg-text-muted)] w-20",children:"重复"}),t.jsx(o,{"code-path":"src/components/kubernetes/EventTable.tsx:43:13",className:"text-[var(--dg-text-muted)] w-20",children:"类型"}),t.jsx(o,{"code-path":"src/components/kubernetes/EventTable.tsx:44:13",className:"text-[var(--dg-text-muted)] w-28",children:"原因"}),t.jsx(o,{"code-path":"src/components/kubernetes/EventTable.tsx:45:13",className:"text-[var(--dg-text-muted)] min-w-[120px]",children:"对象"}),d&&t.jsx(o,{"code-path":"src/components/kubernetes/EventTable.tsx:46:31",className:"text-[var(--dg-text-muted)] w-24",children:"命名空间"}),t.jsx(o,{"code-path":"src/components/kubernetes/EventTable.tsx:47:13",className:"text-[var(--dg-text-muted)] w-28",children:"来源"}),t.jsx(o,{"code-path":"src/components/kubernetes/EventTable.tsx:48:13",className:"text-[var(--dg-text-muted)] min-w-[200px]",children:"消息"})]})}),t.jsx($,{"code-path":"src/components/kubernetes/EventTable.tsx:51:9",children:b?t.jsx(p,{"code-path":"src/components/kubernetes/EventTable.tsx:53:13",children:t.jsx(r,{"code-path":"src/components/kubernetes/EventTable.tsx:54:15",colSpan:v,className:"text-center py-10",children:t.jsx(S,{"code-path":"src/components/kubernetes/EventTable.tsx:55:17",className:"h-5 w-5 animate-spin mx-auto text-[var(--dg-text-muted)]"})})}):l.length===0?t.jsx(p,{"code-path":"src/components/kubernetes/EventTable.tsx:59:13",children:t.jsx(r,{"code-path":"src/components/kubernetes/EventTable.tsx:60:15",colSpan:v,className:"text-center text-[var(--dg-text-muted)] py-10",children:n})}):l.map((s,g)=>{const u=`${s.name||s.object}-${g}`,m=i===u,E=s.type==="Warning",h=j(s.lastTime),T=j(s.firstTime);return t.jsxs(p,{"code-path":"src/components/kubernetes/EventTable.tsx:69:15",className:`border-[var(--dg-border)] cursor-pointer hover:bg-[var(--dg-bg-tertiary)]/40 ${m?"bg-[var(--dg-bg-tertiary)]/30":""}`,onClick:()=>x(m?null:u),children:[t.jsxs(r,{"code-path":"src/components/kubernetes/EventTable.tsx:74:17",className:"text-xs text-[var(--dg-text-muted)]",children:[t.jsx("div",{"code-path":"src/components/kubernetes/EventTable.tsx:75:19",children:h.absolute}),t.jsx("div",{"code-path":"src/components/kubernetes/EventTable.tsx:76:19",className:"text-[10px]",children:h.relative})]}),t.jsxs(r,{"code-path":"src/components/kubernetes/EventTable.tsx:78:17",className:"text-xs text-[var(--dg-text-muted)]",children:[t.jsx("div",{"code-path":"src/components/kubernetes/EventTable.tsx:79:19",children:T.absolute}),t.jsx("div",{"code-path":"src/components/kubernetes/EventTable.tsx:80:19",className:"text-[10px]",children:T.relative})]}),t.jsx(r,{"code-path":"src/components/kubernetes/EventTable.tsx:82:17",className:"text-sm text-center tabular-nums text-[var(--dg-text-secondary)]",children:s.count}),t.jsx(r,{"code-path":"src/components/kubernetes/EventTable.tsx:83:17",className:"text-xs text-[var(--dg-text-muted)]",children:D(s.firstTime,s.lastTime,s.count)}),t.jsx(r,{"code-path":"src/components/kubernetes/EventTable.tsx:84:17",children:t.jsx(f,{"code-path":"src/components/kubernetes/EventTable.tsx:85:19",variant:"outline",className:E?"text-[var(--dg-warning)] border-[var(--dg-warning)]/30 text-[10px]":"text-[var(--dg-text-muted)] border-[var(--dg-border)] text-[10px]",children:s.type})}),t.jsx(r,{"code-path":"src/components/kubernetes/EventTable.tsx:94:17",className:"text-xs font-medium text-[var(--dg-text-secondary)]",children:s.reason}),t.jsx(r,{"code-path":"src/components/kubernetes/EventTable.tsx:95:17",className:"text-xs font-mono text-[var(--dg-text-muted)]",children:s.objectKind?t.jsxs("span",{"code-path":"src/components/kubernetes/EventTable.tsx:97:21",children:[t.jsx("span",{"code-path":"src/components/kubernetes/EventTable.tsx:97:27",className:"text-[var(--dg-text-secondary)]",children:s.objectKind}),"/",s.objectName||s.object.split("/").pop()]}):s.object}),d&&t.jsx(r,{"code-path":"src/components/kubernetes/EventTable.tsx:100:35",className:"text-xs text-[var(--dg-text-muted)]",children:s.namespace||"-"}),t.jsx(r,{"code-path":"src/components/kubernetes/EventTable.tsx:101:17",className:"text-xs text-[var(--dg-text-muted)] font-mono",children:s.source}),t.jsxs(r,{"code-path":"src/components/kubernetes/EventTable.tsx:102:17",className:"text-xs text-[var(--dg-text-secondary)] max-w-[360px]",children:[t.jsx("div",{"code-path":"src/components/kubernetes/EventTable.tsx:103:19",className:`${m?"whitespace-normal break-words":"truncate"}`,title:m?void 0:s.message,children:s.message}),m&&s.name&&t.jsxs("div",{"code-path":"src/components/kubernetes/EventTable.tsx:107:21",className:"mt-1 pt-1 border-t border-[var(--dg-border)] text-[10px] text-[var(--dg-text-muted)]",children:["事件名: ",s.name]})]})]},u)})})]}),c&&e.length>c&&t.jsxs("div",{"code-path":"src/components/kubernetes/EventTable.tsx:118:9",className:"text-center py-2 text-xs text-[var(--dg-text-muted)] border-t border-[var(--dg-border)]",children:["仅显示前 ",c," 条,共 ",e.length," 条"]})]})}export{q as E,B as f,z as n}; diff --git a/backend/static/assets/EventsPage-CuT9Baqe.js b/backend/static/assets/EventsPage-CuT9Baqe.js deleted file mode 100644 index fbb52ba..0000000 --- a/backend/static/assets/EventsPage-CuT9Baqe.js +++ /dev/null @@ -1 +0,0 @@ -import{r as t,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{C as S,a as C}from"./card-BIfzBCEy.js";import{g as Q,i as Y,L,B as Z}from"./index-Dungj95X.js";import{S as j,a as P,b as N,c as f,d}from"./select-CiTqGGhE.js";import{k as y}from"./index-drGq01ok.js";import{n as ee,f as se,E as te}from"./EventTable-BaH7H8dT.js";import{f as z,t as ne,R as ae,X as F,l as ce}from"./vendor-icons-DmqcWdzX.js";import"./index-5FEebgvX.js";import"./badge-CGJlVD3L.js";import"./table-B2F10oba.js";import"./k8s-yaml-utils-4KZB_Bq_.js";function M({title:g,items:x,selected:m,onSelect:b,emptyText:l}){const k=Math.max(...x.map(o=>o.count),1);return e.jsx(S,{"code-path":"src/components/kubernetes/EventsPage.tsx:28:5",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(C,{"code-path":"src/components/kubernetes/EventsPage.tsx:29:7",className:"p-4",children:[e.jsx("h3",{"code-path":"src/components/kubernetes/EventsPage.tsx:30:9",className:"text-sm font-medium text-[var(--dg-text-primary)] mb-3",children:g}),x.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/EventsPage.tsx:32:11",className:"text-xs text-[var(--dg-text-muted)] py-6 text-center",children:l||"暂无数据"}):e.jsx("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:34:11",className:"space-y-1.5 max-h-[220px] overflow-y-auto pr-1",children:x.map(o=>{const h=m===o.name;return e.jsxs("button",{"code-path":"src/components/kubernetes/EventsPage.tsx:38:17",type:"button",className:`w-full flex items-center gap-2 rounded px-2 py-1.5 text-left transition-colors ${h?"bg-[var(--dg-bg-tertiary)]":"hover:bg-[var(--dg-bg-tertiary)]/60"}`,onClick:()=>b?.(h?"":o.name),children:[e.jsx("span",{"code-path":"src/components/kubernetes/EventsPage.tsx:46:19",className:"w-[88px] shrink-0 truncate text-xs text-[var(--dg-text-secondary)]",title:o.name,children:o.name}),e.jsx("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:49:19",className:"flex-1 h-1.5 rounded-full bg-[var(--dg-bg-tertiary)] overflow-hidden",children:e.jsx("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:50:21",className:`h-full rounded-full ${h?"bg-[var(--dg-accent)]":"bg-[var(--dg-text-muted)]/50"}`,style:{width:`${o.count/k*100}%`}})}),e.jsx("span",{"code-path":"src/components/kubernetes/EventsPage.tsx:55:19",className:"w-8 text-right text-xs tabular-nums text-[var(--dg-text-muted)]",children:o.count})]},o.name)})})]})})}function w({label:g,value:x,hint:m}){return e.jsxs("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:68:5",className:"px-4 py-3 border-r border-[var(--dg-border)] last:border-r-0",children:[e.jsx("p",{"code-path":"src/components/kubernetes/EventsPage.tsx:69:7",className:"text-xs text-[var(--dg-text-muted)]",children:g}),e.jsx("p",{"code-path":"src/components/kubernetes/EventsPage.tsx:70:7",className:"text-xl font-semibold tabular-nums text-[var(--dg-text-primary)] mt-0.5",children:x}),m&&e.jsx("p",{"code-path":"src/components/kubernetes/EventsPage.tsx:71:16",className:"text-[10px] text-[var(--dg-text-muted)] mt-0.5",children:m})]})}function ve(){const{clusterCode:g}=Q(),x=Y(),[m,b]=t.useState(!1),[l,k]=t.useState([]),[o,h]=t.useState([]),[U,X]=t.useState([]),[u,q]=t.useState("all"),[E,G]=t.useState("all"),[v,H]=t.useState("0"),[a,W]=t.useState(g||""),[r,D]=t.useState(null),[i,R]=t.useState(""),[p,T]=t.useState("");t.useEffect(()=>{y.getClusters().then(s=>{const c=s?.list||[];if(h(c),!a&&c.length>0){const n=c[0].code||String(c[0].id);W(n),x(`/kubernetes/${n}/events`,{replace:!0})}}).catch(()=>{})},[]),t.useEffect(()=>{a&&y.getNamespaces(a).then(s=>{X(Array.isArray(s)?s:s?.list||s?.data||[])}).catch(()=>{})},[a]);const _=t.useCallback(async()=>{if(a){b(!0);try{const s=u==="all"?void 0:u,c=E==="all"?void 0:E,n=await y.getEvents(a,s,c);k(Array.isArray(n)?n:n?.list||[])}catch{k([])}finally{b(!1)}}},[a,u,E]),$=t.useCallback(async()=>{if(a)try{const s=u==="all"?void 0:u,c=parseInt(v)||void 0,n=await y.getEventsSummary(a,s,c);D(n||null)}catch{D(null)}},[a,u,v]);t.useEffect(()=>{_()},[_]),t.useEffect(()=>{$()},[$]);const V=t.useMemo(()=>{let s=l.map(n=>ee(n));const c=parseInt(v,10);if(c>0){const n=Date.now()-c*3600*1e3;s=s.filter(I=>!I.lastTime||new Date(I.lastTime).getTime()>=n)}return i&&(s=s.filter(n=>n.reason===i)),p&&(s=s.filter(n=>n.objectKind===p||n.object.startsWith(`${p}/`))),s},[l,i,p,v]),J=t.useMemo(()=>l.filter(s=>s.type==="Warning").length,[l]),O=t.useMemo(()=>l.filter(s=>s.type==="Normal").length,[l]),A=t.useMemo(()=>(r?.by_reason||[]).map(s=>({name:s.reason||"Unknown",count:s.count})),[r]),K=t.useMemo(()=>(r?.by_namespace||[]).map(s=>({name:s.namespace||"",count:s.count})),[r]),B=t.useMemo(()=>(r?.by_kind||[]).map(s=>({name:s.kind||"Unknown",count:s.count})),[r]);return e.jsxs("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:167:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:168:7",className:"flex items-center gap-2 text-sm text-[var(--dg-text-muted)]",children:[e.jsx(L,{"code-path":"src/components/kubernetes/EventsPage.tsx:169:9",to:"/kubernetes",className:"hover:text-[var(--dg-text-secondary)]",children:"集群"}),a&&e.jsxs(e.Fragment,{children:[e.jsx(z,{"code-path":"src/components/kubernetes/EventsPage.tsx:172:13",className:"h-3 w-3"}),e.jsx(L,{"code-path":"src/components/kubernetes/EventsPage.tsx:173:13",to:`/kubernetes/${a}`,className:"hover:text-[var(--dg-text-secondary)]",children:a})]}),e.jsx(z,{"code-path":"src/components/kubernetes/EventsPage.tsx:176:9",className:"h-3 w-3"}),e.jsx("span",{"code-path":"src/components/kubernetes/EventsPage.tsx:177:9",className:"text-[var(--dg-text-secondary)]",children:"事件"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:180:7",className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("h2",{"code-path":"src/components/kubernetes/EventsPage.tsx:181:9",className:"text-lg font-semibold text-[var(--dg-text-primary)] flex items-center gap-2",children:[e.jsx(ne,{"code-path":"src/components/kubernetes/EventsPage.tsx:182:11",className:"h-5 w-5 text-[var(--dg-text-muted)]"}),"事件中心"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:185:9",className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(j,{"code-path":"src/components/kubernetes/EventsPage.tsx:186:11",value:a,onValueChange:s=>{W(s),x(`/kubernetes/${s}/events`)},children:[e.jsx(P,{"code-path":"src/components/kubernetes/EventsPage.tsx:187:13",className:"w-40 h-8 text-xs",children:e.jsx(N,{"code-path":"src/components/kubernetes/EventsPage.tsx:187:57"})}),e.jsx(f,{"code-path":"src/components/kubernetes/EventsPage.tsx:188:13",children:o.map(s=>e.jsx(d,{"code-path":"src/components/kubernetes/EventsPage.tsx:190:17",value:s.code||String(s.id),className:"text-xs",children:s.name||s.code},s.id))})]}),e.jsxs(j,{"code-path":"src/components/kubernetes/EventsPage.tsx:194:11",value:u,onValueChange:s=>{q(s),R(""),T("")},children:[e.jsx(P,{"code-path":"src/components/kubernetes/EventsPage.tsx:195:13",className:"w-36 h-8 text-xs",children:e.jsx(N,{"code-path":"src/components/kubernetes/EventsPage.tsx:195:57",placeholder:"命名空间"})}),e.jsxs(f,{"code-path":"src/components/kubernetes/EventsPage.tsx:196:13",children:[e.jsx(d,{"code-path":"src/components/kubernetes/EventsPage.tsx:197:15",value:"all",className:"text-xs",children:"所有命名空间"}),U.map(s=>e.jsx(d,{"code-path":"src/components/kubernetes/EventsPage.tsx:198:38",value:s,className:"text-xs",children:s},s))]})]}),e.jsxs(j,{"code-path":"src/components/kubernetes/EventsPage.tsx:201:11",value:v,onValueChange:H,children:[e.jsx(P,{"code-path":"src/components/kubernetes/EventsPage.tsx:202:13",className:"w-32 h-8 text-xs",children:e.jsx(N,{"code-path":"src/components/kubernetes/EventsPage.tsx:202:57"})}),e.jsxs(f,{"code-path":"src/components/kubernetes/EventsPage.tsx:203:13",children:[e.jsx(d,{"code-path":"src/components/kubernetes/EventsPage.tsx:204:15",value:"0",className:"text-xs",children:"全部时间"}),e.jsx(d,{"code-path":"src/components/kubernetes/EventsPage.tsx:205:15",value:"1",className:"text-xs",children:"近 1 小时"}),e.jsx(d,{"code-path":"src/components/kubernetes/EventsPage.tsx:206:15",value:"6",className:"text-xs",children:"近 6 小时"}),e.jsx(d,{"code-path":"src/components/kubernetes/EventsPage.tsx:207:15",value:"24",className:"text-xs",children:"近 24 小时"}),e.jsx(d,{"code-path":"src/components/kubernetes/EventsPage.tsx:208:15",value:"168",className:"text-xs",children:"近 7 天"})]})]}),e.jsxs(Z,{"code-path":"src/components/kubernetes/EventsPage.tsx:211:11",variant:"outline",size:"sm",className:"h-8 text-xs",onClick:()=>{_(),$()},disabled:m,children:[e.jsx(ae,{"code-path":"src/components/kubernetes/EventsPage.tsx:212:13",className:`h-3 w-3 mr-1 ${m?"animate-spin":""}`}),"刷新"]})]})]}),e.jsx(S,{"code-path":"src/components/kubernetes/EventsPage.tsx:219:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsx(C,{"code-path":"src/components/kubernetes/EventsPage.tsx:220:9",className:"p-0",children:e.jsxs("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:221:11",className:"grid grid-cols-2 md:grid-cols-4",children:[e.jsx(w,{"code-path":"src/components/kubernetes/EventsPage.tsx:222:13",label:"事件总数",value:r?.total??l.length}),e.jsx(w,{"code-path":"src/components/kubernetes/EventsPage.tsx:223:13",label:"告警事件",value:r?.warning_count??J,hint:"Warning"}),e.jsx(w,{"code-path":"src/components/kubernetes/EventsPage.tsx:224:13",label:"正常事件",value:r?.normal_count??O,hint:"Normal"}),e.jsx(w,{"code-path":"src/components/kubernetes/EventsPage.tsx:225:13",label:"告警类型",value:A.length,hint:"不同 Reason"})]})})}),(i||p)&&e.jsxs("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:231:9",className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{"code-path":"src/components/kubernetes/EventsPage.tsx:232:11",className:"text-[var(--dg-text-muted)]",children:"筛选:"}),i&&e.jsxs("button",{"code-path":"src/components/kubernetes/EventsPage.tsx:234:13",type:"button",className:"inline-flex items-center gap-1 rounded border border-[var(--dg-border)] px-2 py-0.5 text-[var(--dg-text-secondary)] hover:bg-[var(--dg-bg-tertiary)]",onClick:()=>R(""),children:["原因 ",i," ",e.jsx(F,{"code-path":"src/components/kubernetes/EventsPage.tsx:235:35",className:"h-3 w-3"})]}),p&&e.jsxs("button",{"code-path":"src/components/kubernetes/EventsPage.tsx:239:13",type:"button",className:"inline-flex items-center gap-1 rounded border border-[var(--dg-border)] px-2 py-0.5 text-[var(--dg-text-secondary)] hover:bg-[var(--dg-bg-tertiary)]",onClick:()=>T(""),children:["类型 ",p," ",e.jsx(F,{"code-path":"src/components/kubernetes/EventsPage.tsx:240:33",className:"h-3 w-3"})]})]}),A.length>0&&e.jsxs("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:247:9",className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[e.jsx(M,{"code-path":"src/components/kubernetes/EventsPage.tsx:248:11",title:"告警原因",items:A,selected:i,onSelect:R}),K.length>0&&e.jsx(M,{"code-path":"src/components/kubernetes/EventsPage.tsx:249:33",title:"命名空间",items:K}),B.length>0&&e.jsx(M,{"code-path":"src/components/kubernetes/EventsPage.tsx:251:13",title:"资源类型",items:B,selected:p,onSelect:T})]}),r?.recent_warnings?.length>0&&e.jsx(S,{"code-path":"src/components/kubernetes/EventsPage.tsx:257:9",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] border-l-2 border-l-[var(--dg-warning)]",children:e.jsxs(C,{"code-path":"src/components/kubernetes/EventsPage.tsx:258:11",className:"p-4",children:[e.jsxs("h3",{"code-path":"src/components/kubernetes/EventsPage.tsx:259:13",className:"text-sm font-medium text-[var(--dg-text-primary)] mb-3 flex items-center gap-1.5",children:[e.jsx(ce,{"code-path":"src/components/kubernetes/EventsPage.tsx:260:15",className:"h-4 w-4 text-[var(--dg-warning)]"}),"最新告警 (",r.recent_warnings.length,")"]}),e.jsx("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:263:13",className:"space-y-1",children:r.recent_warnings.map((s,c)=>e.jsxs("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:265:17",className:"text-xs py-1.5 px-2 rounded hover:bg-[var(--dg-bg-tertiary)]/50",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:266:19",className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{"code-path":"src/components/kubernetes/EventsPage.tsx:267:21",className:"shrink-0 font-mono text-[var(--dg-warning)]",children:s.reason}),e.jsx("span",{"code-path":"src/components/kubernetes/EventsPage.tsx:268:21",className:"text-[var(--dg-text-muted)] font-mono truncate",children:s.object}),e.jsx("span",{"code-path":"src/components/kubernetes/EventsPage.tsx:269:21",className:"text-[var(--dg-text-muted)]",children:s.namespace}),s.source&&e.jsx("span",{"code-path":"src/components/kubernetes/EventsPage.tsx:270:34",className:"text-[var(--dg-text-muted)] font-mono",children:s.source}),e.jsxs("span",{"code-path":"src/components/kubernetes/EventsPage.tsx:271:21",className:"text-[var(--dg-text-muted)]",children:["×",s.count]}),e.jsx("span",{"code-path":"src/components/kubernetes/EventsPage.tsx:272:21",className:"ml-auto text-[var(--dg-text-muted)]",children:se(s.last_time)})]}),e.jsx("p",{"code-path":"src/components/kubernetes/EventsPage.tsx:274:19",className:"text-[var(--dg-text-secondary)] truncate mt-0.5",title:s.message,children:s.message})]},c))})]})}),e.jsx(S,{"code-path":"src/components/kubernetes/EventsPage.tsx:282:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(C,{"code-path":"src/components/kubernetes/EventsPage.tsx:283:9",className:"p-0",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:284:11",className:"flex items-center justify-between px-4 py-2 border-b border-[var(--dg-border)]",children:[e.jsxs("span",{"code-path":"src/components/kubernetes/EventsPage.tsx:285:13",className:"text-sm text-[var(--dg-text-secondary)]",children:["事件列表 (",V.length,")"]}),e.jsxs(j,{"code-path":"src/components/kubernetes/EventsPage.tsx:286:13",value:E,onValueChange:G,children:[e.jsx(P,{"code-path":"src/components/kubernetes/EventsPage.tsx:287:15",className:"w-28 h-7 text-xs",children:e.jsx(N,{"code-path":"src/components/kubernetes/EventsPage.tsx:287:59"})}),e.jsxs(f,{"code-path":"src/components/kubernetes/EventsPage.tsx:288:15",children:[e.jsx(d,{"code-path":"src/components/kubernetes/EventsPage.tsx:289:17",value:"all",className:"text-xs",children:"所有类型"}),e.jsx(d,{"code-path":"src/components/kubernetes/EventsPage.tsx:290:17",value:"Warning",className:"text-xs",children:"Warning"}),e.jsx(d,{"code-path":"src/components/kubernetes/EventsPage.tsx:291:17",value:"Normal",className:"text-xs",children:"Normal"})]})]})]}),e.jsx(te,{"code-path":"src/components/kubernetes/EventsPage.tsx:295:11",events:V,loading:m,showNamespace:!0,maxRows:200})]})})]})}export{ve as default}; diff --git a/backend/static/assets/GrafanaDashboard-9Clwln0E.js b/backend/static/assets/GrafanaDashboard-9Clwln0E.js deleted file mode 100644 index c5ce78a..0000000 --- a/backend/static/assets/GrafanaDashboard-9Clwln0E.js +++ /dev/null @@ -1,3 +0,0 @@ -import{j as a,r as o}from"./vendor-codemirror-B1SGo4xl.js";import{B as D,o as za,D as oa,a as ra,b as na,c as da,d as ka,t as u,f as Ja,i as Qa,e as Na}from"./index-Dungj95X.js";import{I as X}from"./input-CXoUQQLm.js";import{B as O}from"./badge-CGJlVD3L.js";import{C as U,b as ya,c as Ga,a as H}from"./card-BIfzBCEy.js";import{S as xa,a as pa,b as ba,c as ua,d as B}from"./select-CiTqGGhE.js";import{L}from"./label-CMpUoC87.js";import{s as Wa}from"./server-P3fi-cmJ.js";import{d as ga}from"./grafana-DTc3taUi.js";import{z as Xa,p as as}from"./datasource-DsDBrwno.js";import{a as fa}from"./agent-CZzlLHxR.js";import{aa as ss,A as Y,R as ca,L as aa,l as va,h as Q,aR as _a,aN as $a,W as Za,Y as Fa,k as es,a4 as ta,g as Ta,r as ja,w as ts,az as os,j as rs,v as ns,p as ds,z as cs,at as hs,au as ms,_ as Ia,ao as is,aH as Pa,T as ls,I as xs,aS as ps,u as Ba,D as Oa,E as Ma,P as Aa}from"./vendor-icons-DmqcWdzX.js";import{z as bs,p as Sa}from"./metrics-DW1ylkmD.js";import{S as Ea}from"./stat-strip-BSQFwFzG.js";import{T as Ua,a as Ha,b as R,c as K}from"./tabs-D87nAyJR.js";import{C as Da}from"./checkbox-Bu55mX0G.js";import"./index-5FEebgvX.js";function us(s){const e=[];for(let c=0;c<24;c++)e.push({time:new Date(Date.now()-(24-c)*36e5).toLocaleTimeString(),value:Math.random()*100});return e}function gs({panel:s}){const r=us();switch(s.type){case"stat":return a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:24:9",className:"flex flex-col items-center justify-center h-full",children:[a.jsx("span",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:25:11",className:"text-4xl font-bold text-blue-500",children:Math.floor(Math.random()*1e3)}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:26:11",className:"text-sm text-muted-foreground mt-2",children:s.options?.unit||"requests/s"}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:27:11",className:"flex items-center gap-1 mt-2 text-green-500 text-sm",children:[a.jsx(ss,{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:28:13",className:"w-4 h-4"}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:29:13",children:"+12.5%"})]})]});case"gauge":return a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:35:9",className:"flex flex-col items-center justify-center h-full",children:[a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:36:11",className:"relative w-24 h-24",children:[a.jsxs("svg",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:37:13",className:"w-full h-full",viewBox:"0 0 100 100",children:[a.jsx("circle",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:38:15",cx:"50",cy:"50",r:"40",fill:"none",stroke:"#e5e7eb",strokeWidth:"10"}),a.jsx("circle",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:39:15",cx:"50",cy:"50",r:"40",fill:"none",stroke:"#3b82f6",strokeWidth:"10",strokeDasharray:`${Math.random()*251} 251`,transform:"rotate(-90 50 50)"})]}),a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:50:13",className:"absolute inset-0 flex items-center justify-center",children:a.jsxs("span",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:51:15",className:"text-xl font-bold",children:[Math.floor(Math.random()*100),"%"]})})]}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:54:11",className:"text-sm text-muted-foreground mt-2",children:"CPU使用率"})]});default:return a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:60:9",className:"h-full flex flex-col",children:[a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:61:11",className:"flex-1 flex items-end gap-1 px-2",children:r.map((e,c)=>a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:63:15",className:"flex-1 bg-blue-500 rounded-t",style:{height:`${e.value}%`,opacity:.3+c/r.length*.7}},c))}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:70:11",className:"flex justify-between text-xs text-muted-foreground px-2 pt-2",children:[a.jsx("span",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:71:13",children:r[0].time}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:72:13",children:r[r.length-1].time})]})]})}}const fs=({dsUrl:s,dsUsername:r,dsPassword:e})=>{const[c,i]=o.useState(!1),[x,b]=o.useState(!1),[g,N]=o.useState([]),[w,m]=o.useState(""),[P,y]=o.useState(""),[z,v]=o.useState("cpu_usage"),[h,A]=o.useState("desc");o.useEffect(()=>{s&&r&&e&&W(s,r,e)},[s,r,e]);const W=async(n,l,S)=>{b(!0),y("");try{const j=await bs.connect(n,l,S);N(j.hosts||[]),m(j.version||""),i(!0)}catch(j){i(!1),y(j.message||"连接失败")}finally{b(!1)}},Z=()=>{s&&r&&e&&W(s,r,e)},F=n=>{z===n?A(l=>l==="asc"?"desc":"asc"):(v(n),A("desc"))},T=[...g].sort((n,l)=>{const S=n[z]??"",j=l[z]??"";return typeof S=="number"?h==="asc"?S-j:j-S:h==="asc"?String(S).localeCompare(String(j)):String(j).localeCompare(String(S))}),$=({f:n})=>z!==n?a.jsx($a,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:69:33",className:"w-3 h-3 text-slate-500"}):h==="asc"?a.jsx(Za,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:70:32",className:"w-3 h-3 text-blue-400"}):a.jsx(Fa,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:70:80",className:"w-3 h-3 text-blue-400"}),p=(n,l)=>a.jsxs("div",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:74:5",className:"flex items-center gap-2 min-w-[90px]",children:[a.jsx("div",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:75:7",className:"flex-1 h-2.5 rounded-full bg-[var(--dg-bg-tertiary)] overflow-hidden",children:a.jsx("div",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:76:9",className:`h-full rounded-full transition-all duration-500 ${n>=80?"bg-orange-500":"bg-blue-500"}`,style:{width:`${Math.min(n,100)}%`}})}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:78:7",className:`w-14 text-right text-xs font-mono tabular-nums ${n>=80?"text-orange-400":""}`,children:l})]}),f=n=>!n||n===0?"—":n>1e9?`${(n/1e9).toFixed(1)} GB/s`:n>1e6?`${(n/1e6).toFixed(1)} MB/s`:n>1e3?`${(n/1e3).toFixed(1)} KB/s`:`${n.toFixed(1)} B/s`;return!c&&!x&&!P?null:a.jsxs(U,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:93:5",className:"bg-[var(--dg-bg-secondary)] border-blue-500/20",children:[a.jsx(ya,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:94:7",className:"py-3 px-4 pb-2",children:a.jsxs("div",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:95:9",className:"flex items-center gap-2",children:[a.jsx(Y,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:96:11",className:"h-4 w-4 text-blue-400"}),a.jsx(Ga,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:97:11",className:"text-sm font-medium",children:"Zabbix 主机监控"}),w&&a.jsxs(O,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:98:23",className:"text-[10px] bg-blue-500/10 text-blue-400",children:["v",w]}),c&&a.jsxs("span",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:99:25",className:"text-[10px] text-[var(--dg-text-muted)] ml-2",children:[g.length," 台"]}),c&&a.jsx("div",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:100:25",className:"ml-auto flex gap-1",children:a.jsxs(D,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:100:61",variant:"ghost",size:"sm",className:"h-6 px-2 text-[10px]",onClick:Z,children:[a.jsx(ca,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:100:146",className:"w-3 h-3 mr-1"}),"刷新"]})})]})}),a.jsx(H,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:103:7",className:"px-4 pb-3 pt-0",children:x?a.jsxs("div",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:104:21",className:"text-center py-12",children:[a.jsx(aa,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:104:56",className:"h-6 w-6 mx-auto mb-2 animate-spin text-blue-400"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:104:127",className:"text-xs text-[var(--dg-text-muted)]",children:"连接中…"})]}):P?a.jsxs("div",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:105:20",className:"p-3 rounded-lg bg-red-500/10 border border-red-500/20 text-xs text-red-400 flex items-start gap-2",children:[a.jsx(va,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:105:135",className:"h-4 w-4 mt-0.5"}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:105:179",children:P})]}):g.length===0?a.jsxs("div",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:106:33",className:"text-center py-8 text-[var(--dg-text-muted)]",children:[a.jsx(Q,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:106:95",className:"h-8 w-8 mx-auto mb-2 text-slate-600"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:106:153",className:"text-sm",children:"未找到被监控的 Zabbix 主机"})]}):a.jsx("div",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:108:11",className:"overflow-x-auto rounded-lg border border-[var(--dg-border)]",children:a.jsxs("table",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:109:13",className:"w-full text-xs",children:[a.jsx("thead",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:110:15",className:"bg-[var(--dg-bg-tertiary)] border-b border-[var(--dg-border)]",children:a.jsx("tr",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:110:96",children:[{f:"hostname",l:"主机名"},{f:"cpu_usage",l:"CPU"},{f:"memory_usage",l:"内存"},{f:"disk_usage",l:"磁盘"},{f:"load5",l:"Load5"},{f:"net_in_bps",l:"流入"},{f:"net_out_bps",l:"流出"},{f:"problem_count",l:"问题"},{f:"uptime_days",l:"运行"}].map(({f:n,l})=>a.jsx("th",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:116:19",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)] cursor-pointer hover:text-[var(--dg-text-primary)] select-none whitespace-nowrap",onClick:()=>F(n),children:a.jsxs("div",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:117:21",className:"flex items-center gap-1",children:[l,a.jsx($,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:117:65",f:n})]})},n))})}),a.jsx("tbody",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:119:15",children:T.map((n,l)=>a.jsxs("tr",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:121:19",className:"border-b border-[var(--dg-border)] last:border-0 hover:bg-[var(--dg-bg-tertiary)]/50",children:[a.jsxs("td",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:122:21",className:"px-3 py-2.5 whitespace-nowrap",children:[a.jsxs(O,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:122:67",className:`text-[10px] ${n.available==="1"?"bg-emerald-500/20 text-emerald-400":"bg-red-500/20 text-red-400"}`,children:[a.jsx(_a,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:122:193",className:"w-3 h-3 mr-1"}),n.available==="1"?"UP":"DOWN"]})," ",a.jsx("span",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:122:272",className:"font-medium text-[var(--dg-text-primary)] ml-1",children:n.name||n.hostname})]}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:123:21",className:"px-3 py-2.5",children:p(Number(n.cpu_usage||0),`${Number(n.cpu_usage||0).toFixed(1)}%`)}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:124:21",className:"px-3 py-2.5",children:p(Number(n.memory_usage||0),`${Number(n.memory_usage||0).toFixed(1)}%`)}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:125:21",className:"px-3 py-2.5",children:p(Number(n.disk_usage||0),`${Number(n.disk_usage||0).toFixed(1)}%`)}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:126:21",className:"px-3 py-2.5 text-[var(--dg-text-secondary)]",children:n.load5>0?n.load5.toFixed(1):"—"}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:127:21",className:"px-3 py-2.5 font-mono text-[var(--dg-text-secondary)]",children:f(n.net_in_bps)}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:128:21",className:"px-3 py-2.5 font-mono text-[var(--dg-text-secondary)]",children:f(n.net_out_bps)}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:129:21",className:"px-3 py-2.5 text-center",children:a.jsx("span",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:129:61",className:`font-mono font-bold ${n.problem_count>0?n.problem_count>2?"text-red-400":"text-amber-400":"text-emerald-400"}`,children:n.problem_count>0?a.jsxs(a.Fragment,{children:[a.jsx(va,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:129:230",className:"w-3 h-3 inline mr-1"}),n.problem_count]}):"0"})}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:130:21",className:"px-3 py-2.5 text-[var(--dg-text-secondary)]",children:n.uptime_days>0?`${n.uptime_days}d`:"—"})]},n.hostid||l))})]})})})]})},V=({val:s,label:r,color:e})=>{const c=Math.min(s,100);return a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:17:5",className:"flex items-center gap-1.5 min-w-[80px]",children:[a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:18:7",className:"flex-1 h-2 rounded-full bg-[var(--dg-bg-tertiary)] overflow-hidden",children:a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:19:9",className:`h-full rounded-full ${e||"bg-purple-500"}`,style:{width:`${c}%`}})}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:21:7",className:"w-14 text-right text-[11px] font-mono text-[var(--dg-text-secondary)]",children:r})]})},js=s=>s?s>1e9?`${(s/1e9).toFixed(1)} GB`:s>1e6?`${(s/1e6).toFixed(1)} MB`:`${(s/1e3).toFixed(1)} KB`:"—",Ca=s=>s?s>1e9?`${(s/1e9).toFixed(1)} GB/s`:s>1e6?`${(s/1e6).toFixed(1)} MB/s`:s>1e3?`${(s/1e3).toFixed(1)} KB/s`:`${s.toFixed(1)} B/s`:"—";function Ds(s){return(s||[]).map(r=>{const e={...r.metric||{}};return r.value&&(e.value=r.value[1]),e})}const Ns=s=>a.jsx("svg",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:48:30",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...s,children:a.jsx("path",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:48:215",d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})}),vs=({d:s})=>a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:51:3",className:"space-y-4",children:[a.jsx(Ea,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:52:5",items:[{label:"Pods",value:s.podCount?.[0]?.value||0,color:"purple"},{label:"Deployments",value:s.deployCount?.[0]?.value||0,color:"blue"},{label:"Nodes",value:s.nodeCount?.[0]?.value||0,color:"emerald"},{label:"Namespaces",value:s.nsPods?.length||0,color:"amber"}]}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:60:5",className:"rounded-lg bg-[var(--dg-bg-primary)] border border-[var(--dg-border)] p-3 max-h-60 overflow-y-auto",children:[a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:61:7",className:"text-xs font-medium mb-2 flex items-center gap-1",children:[a.jsx(Ta,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:61:73",className:"w-3 h-3 text-purple-400"}),"节点 CPU / 内存利用率"]}),(s.nodeCPU||[]).map((r,e)=>{const c=(s.nodeMem||[]).find(i=>i.node===r.node);return a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:64:16",className:"flex items-center gap-3 text-[11px] mb-1.5",children:[a.jsx("span",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:64:84",className:"w-28 truncate",title:r.node,children:r.node}),a.jsx(V,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:64:146",val:Number(r.value||0),label:`${Number(r.value||0).toFixed(1)}%`}),a.jsx(V,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:64:226",val:Number(c?.value||0),label:`${Number(c?.value||0).toFixed(1)}%`,color:"bg-blue-500"})]},e)})]})]}),ys=({d:s})=>a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:71:3",className:"overflow-x-auto rounded-lg border border-[var(--dg-border)]",children:a.jsxs("table",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:72:5",className:"w-full text-xs",children:[a.jsx("thead",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:73:7",className:"bg-[var(--dg-bg-tertiary)]",children:a.jsxs("tr",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:73:53",children:[a.jsx("th",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:73:57",className:"px-3 py-2 text-left",children:"节点"}),a.jsx("th",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:73:100",className:"px-3 py-2 text-left",children:"状态"}),a.jsx("th",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:73:143",className:"px-3 py-2 text-left",children:"CPU"}),a.jsx("th",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:73:187",className:"px-3 py-2 text-left",children:"内存"}),a.jsx("th",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:73:230",className:"px-3 py-2 text-left",children:"磁盘"}),a.jsx("th",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:73:273",className:"px-3 py-2 text-left",children:"流入"}),a.jsx("th",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:73:316",className:"px-3 py-2 text-left",children:"流出"})]})}),a.jsx("tbody",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:74:7",children:(s.nodes||[]).map((r,e)=>{const c=r.instance||r.exported_instance||"",i=(s.cpuUsage||[]).find(m=>m.instance===c),x=(s.memUsage||[]).find(m=>m.instance===c),b=(s.diskUsage||[]).find(m=>m.instance===c),g=(s.up||[]).find(m=>m.instance===c),N=(s.netRx||[]).find(m=>m.instance===c),w=(s.netTx||[]).find(m=>m.instance===c);return a.jsxs("tr",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:83:18",className:"border-b border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/50",children:[a.jsx("td",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:84:13",className:"px-3 py-2 font-medium",children:r.nodename||c}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:85:13",className:"px-3 py-2",children:a.jsx(O,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:85:39",className:`text-[10px] ${g?.value===1?"bg-emerald-500/20 text-emerald-400":"bg-red-500/20 text-red-400"}`,children:g?.value===1?"UP":"DOWN"})}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:86:13",className:"px-3 py-2",children:a.jsx(V,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:86:39",val:Number(i?.value||0),label:`${Number(i?.value||0).toFixed(1)}%`})}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:87:13",className:"px-3 py-2",children:a.jsx(V,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:87:39",val:Number(x?.value||0),label:`${Number(x?.value||0).toFixed(1)}%`,color:"bg-blue-500"})}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:88:13",className:"px-3 py-2",children:a.jsx(V,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:88:39",val:Number(b?.value||0),label:`${Number(b?.value||0).toFixed(1)}%`,color:"bg-amber-500"})}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:89:13",className:"px-3 py-2 font-mono text-[var(--dg-text-secondary)]",children:Ca(Number(N?.value||0))}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:90:13",className:"px-3 py-2 font-mono text-[var(--dg-text-secondary)]",children:Ca(Number(w?.value||0))})]},e)})})]})}),Gs=({d:s})=>a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:99:3",className:"space-y-4",children:[a.jsx(Ea,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:100:5",items:[{label:"Running",value:s.running?.[0]?.value||0,color:"emerald"},{label:"Pending",value:s.pending?.[0]?.value||0,color:"amber"}]}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:106:5",className:"rounded-lg bg-[var(--dg-bg-primary)] p-3 max-h-40 overflow-y-auto",children:[a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:106:88",className:"text-xs font-medium mb-2",children:"CPU Top 10"}),(s.cpuTop||[]).map((r,e)=>a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:106:191",className:"flex items-center gap-2 text-[11px] mb-1",children:[a.jsx("span",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:106:257",className:"w-10 text-right text-[var(--dg-text-muted)]",children:e+1}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:106:331",className:"w-32 truncate",title:r.pod,children:r.pod}),a.jsx(V,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:106:391",val:Number(r.value||0)*100,label:`${Number(r.value||0).toFixed(2)}c`,color:"bg-purple-500"})]},e))]}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:107:5",className:"rounded-lg bg-[var(--dg-bg-primary)] p-3 max-h-40 overflow-y-auto",children:[a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:107:88",className:"text-xs font-medium mb-2",children:"内存 Top 10"}),(s.memTop||[]).map((r,e)=>a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:107:190",className:"flex items-center gap-2 text-[11px] mb-1",children:[a.jsx("span",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:107:256",className:"w-10 text-right text-[var(--dg-text-muted)]",children:e+1}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:107:330",className:"w-32 truncate",title:r.pod,children:r.pod}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:107:390",className:"ml-auto",children:js(Number(r.value||0))})]},e))]})]}),ws=({d:s})=>{const r=Number(s.heapUsed?.[0]?.value||0),e=Number(s.uptime?.[0]?.value||0);return a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:115:5",className:"grid grid-cols-5 gap-3",children:[a.jsx(U,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:116:7",className:"bg-[var(--dg-bg-primary)]",children:a.jsxs(H,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:116:51",className:"p-3 text-center",children:[a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:116:92",className:"text-lg font-bold",children:e>86400?`${(e/86400).toFixed(1)}d`:`${(e/3600).toFixed(1)}h`}),a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:116:210",className:"text-[10px] text-[var(--dg-text-muted)]",children:"Uptime"})]})}),a.jsx(U,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:117:7",className:"bg-[var(--dg-bg-primary)]",children:a.jsxs(H,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:117:51",className:"p-3 text-center",children:[a.jsx(V,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:117:92",val:r,label:`${r.toFixed(1)}%`,color:r>80?"bg-orange-500":"bg-purple-500"}),a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:117:183",className:"text-[10px] text-[var(--dg-text-muted)] mt-1",children:"Heap"})]})}),a.jsx(U,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:118:7",className:"bg-[var(--dg-bg-primary)]",children:a.jsxs(H,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:118:51",className:"p-3 text-center",children:[a.jsx(V,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:118:92",val:Number(s.nonHeapUsed?.[0]?.value||0),label:`${Number(s.nonHeapUsed?.[0]?.value||0).toFixed(1)}%`,color:"bg-blue-500"}),a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:118:228",className:"text-[10px] text-[var(--dg-text-muted)] mt-1",children:"Non-Heap"})]})}),a.jsx(U,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:119:7",className:"bg-[var(--dg-bg-primary)]",children:a.jsxs(H,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:119:51",className:"p-3 text-center",children:[a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:119:92",className:"text-lg font-bold text-emerald-400",children:s.threadCount?.[0]?.value||0}),a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:119:180",className:"text-[10px] text-[var(--dg-text-muted)]",children:"Threads"})]})}),a.jsx(U,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:120:7",className:"bg-[var(--dg-bg-primary)]",children:a.jsxs(H,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:120:51",className:"p-3 text-center",children:[a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:120:92",className:"text-lg font-bold text-amber-400",children:Number(s.gcPause?.[0]?.value||0).toFixed(3)}),a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:120:193",className:"text-[10px] text-[var(--dg-text-muted)]",children:"GC Pause (s)"})]})})]})},Ps=({dsUrl:s})=>{const[r,e]=o.useState(!1),[c,i]=o.useState(!1),[x,b]=o.useState(0),[g,N]=o.useState(""),[w,m]=o.useState("kubernetes"),[P,y]=o.useState({}),[z,v]=o.useState({}),[h,A]=o.useState({}),[W,Z]=o.useState({});o.useEffect(()=>{s&&F(s)},[s]);const F=async p=>{i(!0),N("");try{const f=await Sa.connect(p);e(!0),b(f.targets||0),T(p)}catch(f){e(!1),N(f.message||"连接失败")}finally{i(!1)}},T=async p=>{for(const f of["kubernetes","node","pod","jvm"])try{const n=await Sa.dashboard(p,f),l={};for(const[S,j]of Object.entries(n||{}))l[S]=Array.isArray(j)?j:j?.data?.result?Ds(j.data.result):j;f==="kubernetes"&&y(l),f==="node"&&v(l),f==="pod"&&A(l),f==="jvm"&&Z(l)}catch{}},$=()=>{s&&F(s)};return!r&&!g?null:a.jsxs(U,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:168:5",className:"bg-[var(--dg-bg-secondary)] border-purple-500/20",children:[a.jsx(ya,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:169:7",className:"py-3 px-4 pb-2",children:a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:170:9",className:"flex items-center gap-2",children:[a.jsx(Y,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:171:11",className:"h-4 w-4 text-purple-400"}),a.jsx(Ga,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:172:11",className:"text-sm font-medium",children:"Prometheus 监控"}),r&&a.jsxs(O,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:173:25",className:"text-[10px] bg-purple-500/10 text-purple-400",children:[x," targets"]}),r&&a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:174:25",className:"ml-auto",children:a.jsxs(D,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:174:50",variant:"ghost",size:"sm",className:"h-6 px-2 text-[10px]",onClick:$,children:[a.jsx(ca,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:174:135",className:"w-3 h-3 mr-1"}),"刷新"]})})]})}),a.jsx(H,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:177:7",className:"px-4 pb-3 pt-0",children:c?a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:178:21",className:"text-center py-12",children:[a.jsx(aa,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:178:56",className:"h-6 w-6 mx-auto mb-2 animate-spin text-purple-400"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:178:129",className:"text-xs text-[var(--dg-text-muted)]",children:"连接中…"})]}):g?a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:179:20",className:"p-3 rounded-lg bg-red-500/10 border border-red-500/20 text-xs text-red-400",children:[a.jsx(va,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:179:112",className:"h-4 w-4 inline mr-1"}),g]}):a.jsxs(Ua,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:181:11",value:w,onValueChange:m,children:[a.jsxs(Ha,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:182:13",className:"bg-[var(--dg-bg-tertiary)] mb-3",children:[a.jsxs(R,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:183:15",value:"kubernetes",className:"text-xs",children:[a.jsx(es,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:183:67",className:"w-3 h-3 mr-1"}),"Kubernetes"]}),a.jsxs(R,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:184:15",value:"node",className:"text-xs",children:[a.jsx(Q,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:184:61",className:"w-3 h-3 mr-1"}),"Node"]}),a.jsxs(R,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:185:15",value:"pod",className:"text-xs",children:[a.jsx(Ns,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:185:60",className:"w-3 h-3 mr-1"}),"Pod"]}),a.jsxs(R,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:186:15",value:"jvm",className:"text-xs",children:[a.jsx(ta,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:186:60",className:"w-3 h-3 mr-1"}),"JVM"]})]}),a.jsx(K,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:188:13",value:"kubernetes",children:a.jsx(vs,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:188:45",d:P})}),a.jsx(K,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:189:13",value:"node",children:a.jsx(ys,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:189:39",d:z})}),a.jsx(K,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:190:13",value:"pod",children:a.jsx(Gs,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:190:38",d:h})}),a.jsx(K,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:191:13",value:"jvm",children:a.jsx(ws,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:191:38",d:W})})]})})]})};function As(s){return s?Array.isArray(s)?s:Array.isArray(s.list)?s.list:Array.isArray(s.items)?s.items:Array.isArray(s.data)?s.data:[]:[]}function Ss(){return typeof window<"u"&&window.location?{origin:window.location.origin,backend:`${window.location.protocol}//${window.location.hostname}:8080`}:{origin:"http://127.0.0.1",backend:"http://127.0.0.1:8080"}}function Cs({open:s,onOpenChange:r,server:e,onInstalled:c,onFailed:i}){const x=za(d=>d.token)||"",{origin:b,backend:g}=Ss(),[N,w]=o.useState(!1),[m,P]=o.useState(!1),[y,z]=o.useState(!1),[v,h]=o.useState("auto"),[A,W]=o.useState("root"),[Z,F]=o.useState(""),[T,$]=o.useState(""),[p,f]=o.useState("password"),n=e&&!e.has_auth,l=`curl -fsSL ${b}/agent/install.sh | bash -s -- --server ${g} --token ${x}`,S=()=>{const d=document.createElement("textarea");d.value=l,d.style.position="fixed",d.style.top="0",d.style.left="0",d.style.width="2em",d.style.height="2em",d.style.padding="0",d.style.border="none",d.style.outline="none",d.style.boxShadow="none",d.style.background="transparent",d.style.opacity="0",d.style.pointerEvents="none",d.style.zIndex="-1",d.style.fontSize="16px",d.contentEditable="true",d.readOnly=!0,document.body.appendChild(d),d.focus(),d.select(),d.setSelectionRange&&d.setSelectionRange(0,999999);let _=!1;try{_=document.execCommand("copy")}catch{}document.body.removeChild(d),_?(w(!0),u.success("安装命令已复制到剪贴板,粘贴到目标主机执行"),setTimeout(()=>w(!1),3e3)):(u.error("自动复制失败,请在下方手动全选复制 (Ctrl+A → Ctrl+C)"),P(!0))},j=`${b}/agent/aiops-agent-linux-amd64`,ha=[{icon:ns,title:"1. 下载二进制",commands:[`curl -fsSL ${j} -o /usr/local/bin/aiops-agent`]},{icon:ds,title:"2. 赋予执行权限",commands:["chmod +x /usr/local/bin/aiops-agent"]},{icon:Ta,title:"3. 创建 systemd 服务",commands:["cat > /etc/systemd/system/aiops-agent.service << 'EOF'","[Unit]","Description=AIOps Agent","After=network.target","","[Service]","Type=simple",`ExecStart=/usr/local/bin/aiops-agent --server ${g} --token ${x}`,"Restart=always","RestartSec=5","","[Install]","WantedBy=multi-user.target","EOF"]},{icon:cs,title:"4. 启动并设置开机自启",commands:["systemctl daemon-reload","systemctl enable --now aiops-agent","systemctl status aiops-agent"]}],I=async()=>{if(!(!e||!x)){if(n&&!Z&&!T){u.error("请填写 SSH 登录凭据(密码或密钥)");return}z(!0);try{const d=n?{username:A,password:Z,ssh_key:T,auth_type:p}:void 0;(await Wa.installAgent(e.id,x,d))?.installed||!1?(u.success(`${e.hostname} Agent 安装成功`),c?.(e.id),r(!1)):(u.warning(`${e.hostname}: Agent 安装命令已执行,但服务未检测到运行`),c?.(e.id),r(!1))}catch(d){const _=d?.message||"安装失败";u.error(`${e.hostname} ${_}`),i?.(e.id,_)}finally{z(!1)}}};return a.jsx(oa,{"code-path":"src/components/agent/AgentWizard.tsx:190:5",open:s,onOpenChange:r,children:a.jsxs(ra,{"code-path":"src/components/agent/AgentWizard.tsx:191:7",className:"max-w-2xl bg-slate-900 border-slate-800 text-slate-100",children:[a.jsxs(na,{"code-path":"src/components/agent/AgentWizard.tsx:192:9",children:[a.jsx(da,{"code-path":"src/components/agent/AgentWizard.tsx:193:11",className:"text-slate-100",children:e?`部署 Agent → ${e.hostname}`:"部署 Agent"}),a.jsx(ka,{"code-path":"src/components/agent/AgentWizard.tsx:196:11",className:"text-slate-400",children:e?`目标主机 ${e.hostname} (${e.ip}),选择安装方式:`:"在目标主机上执行以下命令即可完成 Agent 安装与注册"})]}),a.jsxs(Ua,{"code-path":"src/components/agent/AgentWizard.tsx:204:9",value:v,onValueChange:h,className:"w-full",children:[a.jsxs(Ha,{"code-path":"src/components/agent/AgentWizard.tsx:205:11",className:"bg-slate-800 border border-slate-700",children:[a.jsxs(R,{"code-path":"src/components/agent/AgentWizard.tsx:206:13",value:"auto",className:"data-[state=active]:bg-slate-700",children:[a.jsx(ja,{"code-path":"src/components/agent/AgentWizard.tsx:207:15",className:"h-4 w-4 mr-1.5"}),"安装Agent"]}),e&&a.jsxs(R,{"code-path":"src/components/agent/AgentWizard.tsx:211:15",value:"ssh",className:"data-[state=active]:bg-slate-700",children:[a.jsx(ta,{"code-path":"src/components/agent/AgentWizard.tsx:212:17",className:"h-4 w-4 mr-1.5"}),"SSH一键安装"]}),!e&&a.jsxs(R,{"code-path":"src/components/agent/AgentWizard.tsx:217:15",value:"ssh",className:"data-[state=active]:bg-slate-700 opacity-50 cursor-not-allowed",disabled:!0,children:[a.jsx(ta,{"code-path":"src/components/agent/AgentWizard.tsx:218:17",className:"h-4 w-4 mr-1.5"}),"SSH一键安装"]}),a.jsx(R,{"code-path":"src/components/agent/AgentWizard.tsx:222:13",value:"manual",className:"data-[state=active]:bg-slate-700",children:"手动安装"})]}),a.jsxs(K,{"code-path":"src/components/agent/AgentWizard.tsx:228:11",value:"auto",className:"mt-4 space-y-3",children:[a.jsx("p",{"code-path":"src/components/agent/AgentWizard.tsx:229:13",className:"text-sm text-slate-400",children:"在目标主机执行以下命令,Agent 将自动下载、安装并启动:"}),a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:232:13",className:"relative rounded-lg bg-slate-950 border border-slate-800 p-4",children:[a.jsx("pre",{"code-path":"src/components/agent/AgentWizard.tsx:233:15",className:"text-xs text-emerald-400 font-mono whitespace-pre-wrap break-all pr-10",children:l}),a.jsx(D,{"code-path":"src/components/agent/AgentWizard.tsx:236:15",size:"icon",variant:"ghost",onClick:S,className:"absolute top-2 right-2 h-8 w-8 text-slate-400 hover:text-slate-100 hover:bg-slate-800",title:"复制到剪贴板",children:N?a.jsx(ts,{"code-path":"src/components/agent/AgentWizard.tsx:243:27",className:"h-4 w-4 text-emerald-400"}):a.jsx(os,{"code-path":"src/components/agent/AgentWizard.tsx:243:76",className:"h-4 w-4"})})]}),m&&a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:249:15",className:"rounded-lg bg-amber-950/30 border border-amber-800/50 p-4",children:[a.jsx("p",{"code-path":"src/components/agent/AgentWizard.tsx:250:17",className:"text-xs text-amber-400 mb-2",children:"⚠️ 自动复制失败。请点击下方输入框全选 (Ctrl+A) 后复制 (Ctrl+C):"}),a.jsx("textarea",{"code-path":"src/components/agent/AgentWizard.tsx:253:17",readOnly:!0,value:l,className:"w-full h-24 bg-slate-950 border border-amber-800/30 text-emerald-400 font-mono text-xs p-3 rounded resize-none focus:outline-none focus:border-amber-600",onClick:d=>d.target.select()})]}),a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:261:13",className:"flex items-start gap-2 text-xs text-slate-500",children:[a.jsx(ja,{"code-path":"src/components/agent/AgentWizard.tsx:262:15",className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),a.jsxs("span",{"code-path":"src/components/agent/AgentWizard.tsx:263:15",children:["服务器地址已自动检测 — 安装脚本通过 Nginx 代理 (",b,"),Agent 直连后端 (",g,")。安装成功后将自动连接并开始上报指标。"]})]})]}),!e&&a.jsx(K,{"code-path":"src/components/agent/AgentWizard.tsx:271:13",value:"ssh",className:"mt-4 space-y-4",children:a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:272:15",className:"text-center py-12 text-slate-400",children:[a.jsx(Q,{"code-path":"src/components/agent/AgentWizard.tsx:273:17",className:"h-10 w-10 mx-auto mb-3 opacity-50"}),a.jsx("p",{"code-path":"src/components/agent/AgentWizard.tsx:274:17",className:"text-sm font-medium mb-1",children:"未选择目标主机"}),a.jsx("p",{"code-path":"src/components/agent/AgentWizard.tsx:275:17",className:"text-xs",children:"请先在主机列表中勾选一台主机,再点击「安装 Agent」打开此页面"})]})}),e&&a.jsxs(K,{"code-path":"src/components/agent/AgentWizard.tsx:281:13",value:"ssh",className:"mt-4 space-y-4",children:[a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:282:15",className:"rounded-lg bg-slate-950 border border-slate-800 p-4",children:[a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:283:17",className:"flex items-center gap-3 mb-3",children:[a.jsx(Q,{"code-path":"src/components/agent/AgentWizard.tsx:284:19",className:"h-5 w-5 text-blue-400"}),a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:285:19",children:[a.jsx("p",{"code-path":"src/components/agent/AgentWizard.tsx:286:21",className:"text-sm font-medium text-slate-200",children:e.hostname}),a.jsx("code",{"code-path":"src/components/agent/AgentWizard.tsx:287:21",className:"text-xs text-slate-400",children:e.ip})]})]}),n&&a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:293:19",className:"mb-4 p-3 rounded-lg bg-amber-950/30 border border-amber-800/40 space-y-3",children:[a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:294:21",className:"flex items-center gap-2 text-xs text-amber-300/80",children:[a.jsx(rs,{"code-path":"src/components/agent/AgentWizard.tsx:295:23",className:"h-3.5 w-3.5"}),a.jsx("span",{"code-path":"src/components/agent/AgentWizard.tsx:296:23",children:"该服务器未配置 SSH 凭据,请填写以下信息(首次连接成功后自动保存)"})]}),a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:298:21",className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:299:23",children:[a.jsx(L,{"code-path":"src/components/agent/AgentWizard.tsx:300:25",className:"text-xs text-slate-400",children:"用户名"}),a.jsx(X,{"code-path":"src/components/agent/AgentWizard.tsx:301:25",value:A,onChange:d=>W(d.target.value),placeholder:"root",className:"h-8 text-sm bg-slate-900 border-slate-700 text-slate-200 mt-1"})]}),a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:308:23",className:"flex items-end gap-1",children:[a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:309:25",className:"flex-1",children:[a.jsx(L,{"code-path":"src/components/agent/AgentWizard.tsx:310:27",className:"text-xs text-slate-400",children:"密码"}),a.jsx(X,{"code-path":"src/components/agent/AgentWizard.tsx:311:27",type:"password",value:Z,onChange:d=>{F(d.target.value),f("password")},placeholder:"******",className:"h-8 text-sm bg-slate-900 border-slate-700 text-slate-200 mt-1"})]}),a.jsx("span",{"code-path":"src/components/agent/AgentWizard.tsx:319:25",className:"text-xs text-slate-500 px-1 pb-1",children:"或"}),a.jsx(D,{"code-path":"src/components/agent/AgentWizard.tsx:320:25",variant:"ghost",size:"sm",onClick:()=>{f("key"),F("")},className:`text-xs h-7 px-2 ${p==="key"?"text-blue-400":"text-slate-500"}`,children:"密钥"})]})]}),p==="key"&&a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:328:23",children:[a.jsx(L,{"code-path":"src/components/agent/AgentWizard.tsx:329:25",className:"text-xs text-slate-400",children:"SSH 私钥(PEM 格式)"}),a.jsx("textarea",{"code-path":"src/components/agent/AgentWizard.tsx:330:25",value:T,onChange:d=>$(d.target.value),placeholder:`-----BEGIN OPENSSH PRIVATE KEY----- -... ------END OPENSSH PRIVATE KEY-----`,rows:3,className:"w-full mt-1 bg-slate-900 border border-slate-700 text-slate-200 font-mono text-xs p-2 rounded-md resize-none"})]})]}),a.jsx("p",{"code-path":"src/components/agent/AgentWizard.tsx:342:17",className:"text-sm text-slate-400 mb-4",children:"通过 SSH 远程连接到目标主机,自动下载并安装 Agent,完成后立即启动运行。"}),a.jsx(D,{"code-path":"src/components/agent/AgentWizard.tsx:345:17",onClick:I,disabled:y,className:"w-full bg-blue-600 hover:bg-blue-700 text-white",children:y?a.jsxs(a.Fragment,{children:[a.jsx(aa,{"code-path":"src/components/agent/AgentWizard.tsx:352:23",className:"h-4 w-4 mr-2 animate-spin"}),"SSH 连接中,正在安装..."]}):a.jsxs(a.Fragment,{children:[a.jsx(ta,{"code-path":"src/components/agent/AgentWizard.tsx:357:23",className:"h-4 w-4 mr-2"}),n?"连接并安装 Agent(凭据将自动保存)":"一键安装 Agent"]})})]}),a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:363:15",className:"flex items-start gap-2 text-xs text-slate-500",children:[a.jsx(ja,{"code-path":"src/components/agent/AgentWizard.tsx:364:17",className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),a.jsxs("span",{"code-path":"src/components/agent/AgentWizard.tsx:365:17",children:["系统将通过 SSH 连接 ",e.ip,",执行安装脚本。请确保服务器 SSH 凭据已正确配置(编辑服务器可修改密码/密钥)。"]})]})]}),a.jsxs(K,{"code-path":"src/components/agent/AgentWizard.tsx:373:11",value:"manual",className:"mt-4 space-y-4",children:[a.jsx("div",{"code-path":"src/components/agent/AgentWizard.tsx:374:13",className:"max-h-[420px] overflow-y-auto space-y-3 pr-1",children:ha.map(d=>a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:376:17",className:"rounded-lg bg-slate-950 border border-slate-800 overflow-hidden",children:[a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:377:19",className:"flex items-center gap-2 px-4 py-2.5 bg-slate-800/50",children:[a.jsx(d.icon,{"code-path":"src/components/agent/AgentWizard.tsx:378:21",className:"h-4 w-4 text-blue-400"}),a.jsx("span",{"code-path":"src/components/agent/AgentWizard.tsx:379:21",className:"text-sm font-medium text-slate-200",children:d.title})]}),a.jsx("div",{"code-path":"src/components/agent/AgentWizard.tsx:381:19",className:"p-3 space-y-1",children:d.commands.map((_,sa)=>a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:383:23",className:"flex items-start gap-2",children:[a.jsx("span",{"code-path":"src/components/agent/AgentWizard.tsx:384:25",className:"text-slate-600 font-mono text-xs select-none mt-0.5",children:"$"}),a.jsx("code",{"code-path":"src/components/agent/AgentWizard.tsx:385:25",className:"text-xs text-slate-300 font-mono whitespace-pre-wrap break-all flex-1",children:_})]},sa))})]},d.title))}),a.jsx("p",{"code-path":"src/components/agent/AgentWizard.tsx:394:13",className:"text-xs text-slate-500",children:"完成上述步骤后,Agent 将作为 systemd 服务运行并自动上报指标。"})]})]})]})})}const zs=[{id:"agent",label:"Agent 主机",icon:a.jsx(Q,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:51:43",className:"w-3.5 h-3.5"})},{id:"zabbix",label:"Zabbix",icon:a.jsx(Y,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:52:42",className:"w-3.5 h-3.5"})},{id:"prometheus",label:"Prometheus",icon:a.jsx(Y,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:53:50",className:"w-3.5 h-3.5"})},{id:"dashboard",label:"自定义",icon:a.jsx(Ia,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:54:42",className:"w-3.5 h-3.5"})}],ks=()=>{const s=Ja(),r=Qa(),[e,c]=o.useState([]),[i,x]=o.useState(!0),[b,g]=o.useState("cpu_usage"),[N,w]=o.useState("desc"),[m,P]=o.useState(1),[y,z]=o.useState(10),[v,h]=o.useState(new Set),[A,W]=o.useState(!1),[Z,F]=o.useState(null),[T,$]=o.useState(!1),[p,f]=o.useState("install"),[n,l]=o.useState(!1),[S,j]=o.useState(!1),[ha,I]=o.useState(new Set),[d,_]=o.useState(!1),sa=async()=>{if(await s({title:"批量卸载 Agent",description:`确定卸载选中的 ${ea.length} 台主机的 AIOps Agent?卸载将在后台异步执行。`,confirmText:"卸载",variant:"destructive"})){_(!0),I(new Set(ea));try{await fa.batchUninstall(ea),u.success(`已提交:批量卸载 ${ea.length} 台主机的 Agent,后台执行中,30秒后自动刷新`),h(new Set),setTimeout(()=>{q(),I(new Set)},3e4)}catch{u.error("提交失败"),I(new Set)}finally{_(!1)}}},wa=Math.max(1,Math.ceil(e.length/y)),q=async()=>{try{c(As(await fa.getLatest()))}catch{}finally{x(!1)}};o.useEffect(()=>{q();const t=setInterval(q,3e4);return()=>clearInterval(t)},[]);const La=t=>{b===t?w(C=>C==="asc"?"desc":"asc"):(g(t),w("desc"))},Ra=[...e].sort((t,C)=>{let G=t[b]??"",k=C[b]??"";return b==="agent_status"&&(G=t.agent_status||"",k=C.agent_status||""),typeof G=="number"?N==="asc"?G-k:k-G:N==="asc"?String(G).localeCompare(String(k)):String(k).localeCompare(String(G))}).slice((m-1)*y,m*y),Ka=({f:t})=>b!==t?a.jsx($a,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:106:54",className:"w-3 h-3 text-slate-500"}):N==="asc"?a.jsx(Za,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:106:122",className:"w-3 h-3 text-emerald-400"}):a.jsx(Fa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:106:173",className:"w-3 h-3 text-emerald-400"}),ma=(t,C)=>a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:108:5",className:"flex items-center gap-2 min-w-[90px]",children:[a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:108:59",className:"flex-1 h-2.5 rounded-full bg-[var(--dg-bg-tertiary)] overflow-hidden",children:a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:108:145",className:`h-full rounded-full transition-all duration-500 ${t>=80?"bg-orange-500":"bg-emerald-500"}`,style:{width:`${Math.min(t,100)}%`}})}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:108:310",className:`w-14 text-right text-xs font-mono tabular-nums ${t>=80?"text-orange-400":""}`,children:C})]}),Va=v.size===e.length&&e.length>0,ia=v.size>0,ea=[...v].map(Number).filter(t=>!isNaN(t)),J=o.useMemo(()=>e.filter(t=>v.has(String(t.server_id))),[e,v]),M=o.useMemo(()=>J.filter(t=>t.agent_status!=="online"),[J]),E=o.useMemo(()=>J.filter(t=>t.agent_status==="online"),[J]),qa=()=>{l(!1),M.length>0&&E.length===0?f("install"):M.length===0&&E.length>0?f("upgrade"):f("install"),$(!0)},Ya=async()=>{if(!n){u.error("请先确认并勾选「我已知悉」");return}j(!0);const t=za.getState().token,C=J.map(G=>G.server_id);I(new Set(C));try{if(p==="install"){if(!t){u.error("未登录");return}const G=M.map(la=>la.server_id);if(G.length===0){u.warning("所选主机均已安装 Agent,无需安装");return}const k=await Wa.batchInstallAgent(G,t);u.success(`已提交:批量安装 ${k?.total??G.length} 台主机的 Agent,后台执行中,30秒后自动刷新`),h(new Set),setTimeout(()=>{q(),I(new Set)},3e4)}else{const G=E.map(la=>la.server_id);if(G.length===0){u.warning("所选主机中没有在线 Agent,无法升级");return}const k=await fa.batchUpgrade(G);u.success(k?.message||`已提交:批量升级 ${G.length} 台主机的 Agent,后台执行中,30秒后自动刷新`),h(new Set),setTimeout(()=>{q(),I(new Set)},3e4)}$(!1)}catch{u.error("提交失败"),I(new Set)}finally{j(!1)}};return i?a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:163:23",className:"text-center py-20 text-[var(--dg-text-muted)]",children:[a.jsx(Y,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:163:86",className:"h-6 w-6 mx-auto mb-2 animate-spin"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:163:144",className:"text-xs",children:"加载中…"})]}):e.length?a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:166:5",children:[a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:168:7",className:"flex items-center gap-2 mb-3 flex-wrap",children:[ia&&a.jsxs("span",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:169:20",className:"text-xs text-[var(--dg-text-secondary)]",children:["已选 ",v.size," 项"]}),a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:170:9",className:"flex-1"}),a.jsxs(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:171:9",size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:()=>{const t=ia?e.find(C=>v.has(String(C.server_id))):null;F(t?{id:t.server_id,hostname:t.hostname,ip:t.ip,has_auth:t.has_auth}:null),W(!0)},children:[a.jsx(is,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:176:11",className:"w-3 h-3"}),"安装 Agent"]}),ia&&a.jsxs(a.Fragment,{children:[a.jsxs(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:180:13",size:"sm",variant:"outline",className:"h-7 text-xs gap-1 border-blue-500/30 text-blue-400 hover:bg-blue-500/10",onClick:qa,children:[a.jsx(Pa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:181:15",className:"w-3 h-3"}),"批量部署 (",v.size,")"]}),a.jsxs(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:183:13",size:"sm",variant:"outline",className:"h-7 text-xs gap-1 border-red-500/30 text-red-400 hover:bg-red-500/10",onClick:sa,disabled:d,children:[a.jsx(ls,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:184:15",className:"w-3 h-3"}),"批量卸载 (",v.size,")"]})]}),a.jsxs(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:188:9",size:"sm",variant:"ghost",className:"h-7 text-xs gap-1",onClick:q,children:[a.jsx(ca,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:188:89",className:"w-3 h-3"}),"刷新"]})]}),a.jsx(Cs,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:191:7",open:A,onOpenChange:W,server:Z,onInstalled:()=>{u.success("Agent 安装成功"),W(!1),q()},onFailed:()=>u.error("安装失败")}),a.jsx(oa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:196:7",open:T,onOpenChange:t=>{t||($(!1),l(!1))},children:a.jsxs(ra,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:197:9",className:"max-w-2xl max-h-[85vh] overflow-auto bg-slate-900 border-slate-700 text-slate-100",children:[a.jsxs(na,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:198:11",children:[a.jsxs(da,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:199:13",className:"flex items-center gap-2 text-base",children:[a.jsx(Pa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:200:15",className:"w-5 h-5 text-blue-400"}),"批量部署 Agent"]}),a.jsxs(ka,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:203:13",className:"text-slate-400 text-xs",children:["选中 ",J.length," 台主机(需安装: ",M.length,",待升级: ",E.length,")"]})]}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:208:11",className:"space-y-4",children:[a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:210:13",className:"flex items-center gap-2 p-1 rounded-lg bg-slate-800 border border-slate-700 w-fit",children:["install","upgrade"].map(t=>a.jsx("button",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:212:17",disabled:t==="install"?M.length===0:E.length===0,onClick:()=>f(t),className:`px-4 py-1.5 rounded text-xs font-medium transition-colors disabled:opacity-30 disabled:cursor-not-allowed ${p===t?"bg-blue-600 text-white shadow-sm":"text-slate-400 hover:text-slate-200"}`,children:t==="install"?`⚡ 安装 (${M.length})`:`🔄 升级到最新版 (${E.length})`},t))}),a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:226:13",className:"rounded-md border border-slate-700 overflow-hidden",children:a.jsxs("table",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:227:15",className:"w-full text-xs",children:[a.jsx("thead",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:228:17",className:"bg-slate-800",children:a.jsxs("tr",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:229:19",children:[a.jsx("th",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:230:21",className:"px-3 py-2 text-left font-medium text-slate-400",children:"主机名"}),a.jsx("th",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:231:21",className:"px-3 py-2 text-left font-medium text-slate-400",children:"IP"}),a.jsx("th",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:232:21",className:"px-3 py-2 text-left font-medium text-slate-400",children:"状态"}),a.jsx("th",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:233:21",className:"px-3 py-2 text-left font-medium text-slate-400",children:"当前版本"}),a.jsx("th",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:234:21",className:"px-3 py-2 text-left font-medium text-slate-400",children:"操作"})]})}),a.jsx("tbody",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:237:17",children:(p==="install"?M:E).map(t=>a.jsxs("tr",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:239:21",className:"border-t border-slate-800 hover:bg-slate-800/50",children:[a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:240:23",className:"px-3 py-2 font-medium text-slate-200",children:t.hostname}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:241:23",className:"px-3 py-2 font-mono text-slate-400",children:t.ip}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:242:23",className:"px-3 py-2",children:t.agent_status==="online"?a.jsx(O,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:244:29",className:"text-[10px] bg-emerald-500/20 text-emerald-400",children:"在线"}):a.jsx(O,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:245:29",className:"text-[10px] bg-slate-500/20 text-slate-400",children:t.agent_status==="not_installed"?"未安装":t.agent_status||"离线"})}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:249:23",className:"px-3 py-2 font-mono text-slate-400",children:t.agent_version||"—"}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:250:23",className:"px-3 py-2",children:a.jsx("span",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:251:25",className:"text-blue-400 text-[11px]",children:p==="install"?"即将安装":"即将升级"})})]},t.server_id))})]})}),a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:262:13",className:"rounded-md border border-amber-500/30 bg-amber-500/5 p-3 space-y-2",children:a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:263:15",className:"flex items-start gap-2",children:[a.jsx(xs,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:264:17",className:"w-4 h-4 text-amber-400 mt-0.5 shrink-0"}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:265:17",children:[a.jsxs("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:266:19",className:"text-xs font-medium text-amber-300 mb-1",children:[p==="install"?"本次安装":"本次升级",",主机监控探针将部署 AIOps Agent。AIOps Agent 是 AIOps 平台推出的新一代数据采集器,提供主机监控指标采集和可观测数据采集能力。"]}),a.jsxs("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:269:19",className:"text-[11px] text-amber-400/80 leading-relaxed",children:[p==="upgrade"&&"升级前请注意以下事项:",p==="install"&&"安装前请注意以下事项:"]}),a.jsxs("ul",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:273:19",className:"mt-1 space-y-0.5 text-[11px] text-slate-400 list-disc list-inside",children:[p==="upgrade"&&a.jsxs(a.Fragment,{children:[a.jsx("li",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:276:25",children:"如果您的机器已经安装旧版 Agent,升级操作将停止旧版并替换为最新版本。"}),a.jsx("li",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:277:25",children:"如果您的机器之前安装过 Agent 但已卸载,遗留有相关采集配置,本次升级可能导致配置重新生效。升级前请确保存量废弃配置已经移除。"}),a.jsx("li",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:278:25",children:"如果您的机器采用自定义安装的 Agent(非 AIOps 提供的一键安装脚本),请不要直接使用批量升级。"}),a.jsx("li",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:279:25",children:"批量升级前,请务必先单机灰度升级,确保升级成功且不影响业务后再操作。"})]}),p==="install"&&a.jsxs(a.Fragment,{children:[a.jsx("li",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:284:25",children:"安装将自动检测目标主机架构(amd64/arm64),下载对应版本的 Agent 二进制并启动服务。"}),a.jsx("li",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:285:25",children:"请确保目标主机的 SSH 端口(默认 22)可访问,且已关联有效的 SSH 凭据。"}),a.jsx("li",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:286:25",children:"安装过程约 30-60 秒,期间目标主机 CPU 负载会短暂升高。"}),a.jsx("li",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:287:25",children:"若安装失败,请检查目标主机的防火墙规则和 SSH 服务状态后重试。"})]}),a.jsx("li",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:290:21",children:"操作不可回滚,请在操作前确认已备份关键配置。"}),a.jsx("li",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:291:21",children:"操作将在后台异步执行,您可以在「任务执行记录」中查看详细进度。"})]})]})]})}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:298:13",className:"flex items-center gap-2",children:[a.jsx(Da,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:299:15",id:"batch-ack",checked:n,onCheckedChange:t=>l(!!t)}),a.jsx("label",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:300:15",htmlFor:"batch-ack",className:"text-xs text-slate-300 cursor-pointer select-none",children:"我已知悉以上风险和注意事项"})]})]}),a.jsxs(Na,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:304:11",className:"gap-2",children:[a.jsx(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:305:13",variant:"outline",className:"border-slate-700 text-slate-300 h-8 text-xs",onClick:()=>{$(!1),l(!1)},children:"取消"}),a.jsxs(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:308:13",className:"bg-blue-600 hover:bg-blue-700 text-white h-8 text-xs gap-1",disabled:S||!n||(p==="install"?M.length===0:E.length===0),onClick:Ya,children:[S&&a.jsx(aa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:313:35",className:"w-3 h-3 animate-spin"}),p==="install"?"确认安装":"确认升级"]})]})]})}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:320:7",className:"overflow-x-auto rounded-lg border border-[var(--dg-border)]",children:[a.jsxs("table",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:321:9",className:"w-full text-xs",children:[a.jsx("thead",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:322:11",className:"bg-[var(--dg-bg-tertiary)] border-b",children:a.jsxs("tr",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:322:66",children:[a.jsx("th",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:323:13",className:"px-2 py-2 w-8",children:a.jsx(Da,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:324:15",checked:Va,onCheckedChange:t=>h(t?new Set(e.map(C=>String(C.server_id))):new Set)})}),["hostname","agent_version","agent_status","cpu_usage","mem_usage","disk_usage","region","ip"].map(t=>a.jsx("th",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:327:15",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)] cursor-pointer hover:text-[var(--dg-text-primary)] select-none whitespace-nowrap",onClick:()=>La(t),children:a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:328:17",className:"flex items-center gap-1",children:[{hostname:"主机名",agent_version:"Agent版本",agent_status:"状态",cpu_usage:"CPU",mem_usage:"内存",disk_usage:"磁盘",region:"区域",ip:"IP"}[t],a.jsx(Ka,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:328:188",f:t})]})},t)),a.jsx("th",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:331:13",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)] whitespace-nowrap",children:"操作"})]})}),a.jsx("tbody",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:332:11",children:Ra.map((t,C)=>a.jsxs("tr",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:334:15",className:"border-b border-[var(--dg-border)] last:border-0 hover:bg-[var(--dg-bg-tertiary)]/50",children:[a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:335:17",className:"px-2 py-2.5",children:a.jsx(Da,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:336:19",checked:v.has(String(t.server_id)),onCheckedChange:G=>{const k=new Set(v);G?k.add(String(t.server_id)):k.delete(String(t.server_id)),h(k)}})}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:342:17",className:"px-3 py-2.5 font-medium text-[var(--dg-text-primary)]",children:t.hostname}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:343:17",className:"px-3 py-2.5 font-mono text-[var(--dg-text-secondary)]",children:ha.has(t.server_id)?a.jsxs("span",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:345:21",className:"inline-flex items-center gap-1 text-blue-400",children:[a.jsx(aa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:346:23",className:"w-3 h-3 animate-spin"}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:347:23",className:"text-[10px]",children:"部署中"})]}):t.agent_version||"—"}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:353:17",className:"px-3 py-2.5",children:t.agent_status==="online"?a.jsxs(O,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:353:72",className:"text-[10px] bg-emerald-500/20 text-emerald-400",children:[a.jsx(_a,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:353:138",className:"w-3 h-3 mr-1"}),"在线"]}):t.agent_status==="not_installed"?a.jsx(O,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:353:214",className:"text-[10px] bg-amber-500/20 text-amber-400",children:"未安装"}):a.jsxs(O,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:353:288",className:"text-[10px] bg-slate-500/10 text-slate-400",children:[a.jsx(ps,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:353:350",className:"w-3 h-3 mr-1"}),"离线"]})}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:354:17",className:"px-3 py-2.5",children:ma(Number(t.cpu_usage||0),`${Number(t.cpu_usage||0).toFixed(1)}%`)}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:355:17",className:"px-3 py-2.5",children:ma(Number(t.mem_usage||0),`${Number(t.mem_usage||0).toFixed(1)}%`)}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:356:17",className:"px-3 py-2.5",children:ma(Number(t.disk_usage||0),`${Number(t.disk_usage||0).toFixed(1)}%`)}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:357:17",className:"px-3 py-2.5 text-[var(--dg-text-secondary)]",children:t.region||"—"}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:358:17",className:"px-3 py-2.5 font-mono text-[var(--dg-text-secondary)]",children:t.ip||"—"}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:359:17",className:"px-3 py-2.5",children:a.jsxs(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:360:19",variant:"ghost",size:"sm",className:"h-7 text-xs text-blue-400 hover:text-blue-300 hover:bg-blue-500/10 px-2",onClick:()=>r(`/host-monitor?host=${encodeURIComponent(t.hostname)}`),children:[a.jsx(Ba,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:362:21",className:"w-3.5 h-3.5 mr-1"}),"图表"]})})]},t.hostname+C))})]}),e.length>y&&a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:370:11",className:"flex items-center justify-between px-3 py-2 bg-[var(--dg-bg-tertiary)] border-t border-[var(--dg-border)] text-xs",children:[a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:371:13",className:"flex items-center gap-2 text-[var(--dg-text-muted)]",children:[a.jsxs("span",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:372:15",children:["共 ",e.length," 条"]}),a.jsxs("select",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:373:15",className:"bg-[var(--dg-bg-primary)] border border-[var(--dg-border)] rounded px-2 py-0.5 text-xs",value:y,onChange:t=>{z(Number(t.target.value)),P(1)},children:[a.jsx("option",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:374:17",value:10,children:"10/页"}),a.jsx("option",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:375:17",value:20,children:"20/页"}),a.jsx("option",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:376:17",value:30,children:"30/页"})]})]}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:379:13",className:"flex items-center gap-1",children:[a.jsx("button",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:380:15",className:"px-2 py-0.5 rounded hover:bg-[var(--dg-bg-primary)] disabled:opacity-30",disabled:m<=1,onClick:()=>P(t=>t-1),children:"上一页"}),a.jsxs("span",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:381:15",className:"px-2 text-[var(--dg-text-primary)]",children:[m," / ",wa]}),a.jsx("button",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:382:15",className:"px-2 py-0.5 rounded hover:bg-[var(--dg-bg-primary)] disabled:opacity-30",disabled:m>=wa,onClick:()=>P(t=>t+1),children:"下一页"})]})]})]})]}):a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:164:29",className:"text-center py-20 text-[var(--dg-text-muted)]",children:[a.jsx(Q,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:164:92",className:"h-8 w-8 mx-auto mb-2"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:164:135",className:"text-sm",children:"暂无服务器资产"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:164:169",className:"text-xs mt-1",children:"请先在「服务器管理」中添加主机,然后在此安装 Agent"})]})},Ws=()=>{const[s,r]=o.useState(null),[e,c]=o.useState(!0);return o.useEffect(()=>{Xa.list().then(i=>{const x=i?.data||i||[];r(x.find(b=>b.is_default)||x[0]||null)}).catch(()=>{}).finally(()=>c(!1))},[]),e?a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:401:23",className:"text-center py-20 text-[var(--dg-text-muted)]",children:[a.jsx(Y,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:401:86",className:"h-6 w-6 mx-auto mb-2 animate-spin"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:401:144",className:"text-xs",children:"加载数据源…"})]}):s?a.jsx(fs,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:403:10",dsUrl:s.url,dsUsername:s.username,dsPassword:s.password}):a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:402:19",className:"text-center py-20 text-[var(--dg-text-muted)]",children:[a.jsx(Oa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:402:82",className:"h-8 w-8 mx-auto mb-2"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:402:127",className:"text-sm",children:"未配置 Zabbix 数据源"}),a.jsxs("a",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:402:168",href:"/datasources",className:"text-xs text-blue-400 hover:underline inline-flex items-center gap-1",children:["前往配置 ",a.jsx(Ma,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:402:277",className:"w-3 h-3"})]})]})},_s=()=>{const[s,r]=o.useState(null),[e,c]=o.useState(!0);return o.useEffect(()=>{as.list().then(i=>{const x=i?.data||i||[];r(x.find(b=>b.is_default)||x[0]||null)}).catch(()=>{}).finally(()=>c(!1))},[]),e?a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:415:23",className:"text-center py-20 text-[var(--dg-text-muted)]",children:[a.jsx(Y,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:415:86",className:"h-6 w-6 mx-auto mb-2 animate-spin"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:415:144",className:"text-xs",children:"加载数据源…"})]}):s?a.jsx(Ps,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:417:10",dsUrl:s.url}):a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:416:19",className:"text-center py-20 text-[var(--dg-text-muted)]",children:[a.jsx(Oa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:416:82",className:"h-8 w-8 mx-auto mb-2"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:416:127",className:"text-sm",children:"未配置 Prometheus 数据源"}),a.jsxs("a",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:416:172",href:"/datasources",className:"text-xs text-blue-400 hover:underline inline-flex items-center gap-1",children:["前往配置 ",a.jsx(Ma,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:416:281",className:"w-3 h-3"})]})]})},$s=()=>{const[s,r]=o.useState([]),[e,c]=o.useState(null),[i,x]=o.useState(!1),[b,g]=o.useState(!1),[N,w]=o.useState({name:"",description:"",datasource:"prometheus",datasourceUrl:""}),[m,P]=o.useState({title:"",type:"graph",query:"",width:6,height:4}),y=async()=>{try{const A=(await ga.getDashboards()).data||[];r(A),A.length>0&&!e&&c(A[0])}catch{}};o.useEffect(()=>{y()},[]);const z=async()=>{if(!N.name){u.error("请输入名称");return}try{await ga.createDashboard({...N,panels:[]}),u.success("创建成功"),x(!1),w({name:"",description:"",datasource:"prometheus",datasourceUrl:""}),y()}catch{u.error("创建失败")}},v=async()=>{if(!(!m.title||!m.query||!e))try{const h={id:Date.now().toString(),...m,datasource:e.datasource,x:0,y:0,options:{legend:!0,tooltip:!0,refreshInterval:30}};await ga.updateDashboard(e.id,{...e,panels:[...e.panels,h]}),u.success("面板添加成功"),g(!1),P({title:"",type:"graph",query:"",width:6,height:4}),y()}catch{u.error("添加失败")}};return a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:451:5",className:"space-y-4",children:[a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:452:7",className:"flex items-center gap-2",children:[a.jsxs(xa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:453:9",value:e?.id,onValueChange:h=>{const A=s.find(W=>W.id===h);A&&c(A)},children:[a.jsx(pa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:454:11",className:"w-[240px] h-8 text-xs",children:a.jsx(ba,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:454:60",placeholder:"选择仪表盘"})}),a.jsx(ua,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:455:11",children:s.map(h=>a.jsxs(B,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:455:47",value:h.id,children:[h.name,h.isDefault?" (默认)":""]},h.id))})]}),a.jsxs(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:457:9",variant:"outline",size:"sm",className:"h-8 text-[10px]",onClick:y,children:[a.jsx(ca,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:457:89",className:"w-3 h-3 mr-1"}),"刷新"]}),e&&a.jsxs(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:458:20",variant:"outline",size:"sm",className:"h-8 text-[10px]",onClick:()=>g(!0),children:[a.jsx(Aa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:458:117",className:"w-3 h-3 mr-1"}),"添加面板"]}),a.jsxs(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:459:9",variant:"outline",size:"sm",className:"h-8 text-[10px]",onClick:()=>x(!0),children:[a.jsx(Aa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:459:109",className:"w-3 h-3 mr-1"}),"新建"]})]}),e?e.panels.length===0?a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:464:11",className:"text-center py-16 text-[var(--dg-text-muted)]",children:[a.jsx(Ba,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:464:74",className:"w-10 h-10 mx-auto mb-2 opacity-50"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:464:133",className:"text-xs",children:"暂无面板"})]}):a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:466:11",className:"grid grid-cols-12 gap-3",children:e.panels.map(h=>a.jsxs(U,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:468:15",style:{gridColumn:`span ${h.width}`,minHeight:`${h.height*80}px`},children:[a.jsx(ya,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:469:17",className:"py-2 px-3",children:a.jsx(Ga,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:469:51",className:"text-[11px] font-medium",children:h.title})}),a.jsx(H,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:470:17",className:"p-3 pt-0",children:a.jsx(gs,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:470:51",panel:h})})]},h.id))}):a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:476:9",className:"text-center py-16 text-[var(--dg-text-muted)]",children:[a.jsx(Ia,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:476:72",className:"w-10 h-10 mx-auto mb-2 opacity-50"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:476:129",className:"text-xs",children:"暂无仪表盘"})]}),a.jsx(oa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:479:7",open:i,onOpenChange:x,children:a.jsxs(ra,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:479:62",children:[a.jsx(na,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:479:77",children:a.jsx(da,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:479:91",children:"新建仪表盘"})}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:480:9",className:"space-y-3",children:[a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:480:36",children:[a.jsx(L,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:480:41",children:"名称"}),a.jsx(X,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:480:58",value:N.name,onChange:h=>w({...N,name:h.target.value})})]}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:481:11",children:[a.jsx(L,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:481:16",children:"数据源"}),a.jsxs(xa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:481:34",value:N.datasource,onValueChange:h=>w({...N,datasource:h}),children:[a.jsx(pa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:481:124",children:a.jsx(ba,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:481:139"})}),a.jsxs(ua,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:481:170",children:[a.jsx(B,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:481:185",value:"prometheus",children:"Prometheus"}),a.jsx(B,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:481:239",value:"zabbix",children:"Zabbix"}),a.jsx(B,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:481:285",value:"skywalking",children:"SkyWalking"}),a.jsx(B,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:481:339",value:"custom",children:"自定义"})]})]})]})]}),a.jsxs(Na,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:482:9",children:[a.jsx(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:482:23",variant:"outline",onClick:()=>x(!1),children:"取消"}),a.jsx(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:482:97",onClick:z,children:"创建"})]})]})}),a.jsx(oa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:484:7",open:b,onOpenChange:g,children:a.jsxs(ra,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:484:56",children:[a.jsx(na,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:484:71",children:a.jsx(da,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:484:85",children:"添加面板"})}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:485:9",className:"space-y-3",children:[a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:485:36",children:[a.jsx(L,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:485:41",children:"标题"}),a.jsx(X,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:485:58",value:m.title,onChange:h=>P({...m,title:h.target.value})})]}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:486:11",children:[a.jsx(L,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:486:16",children:"类型"}),a.jsxs(xa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:486:33",value:m.type,onValueChange:h=>P({...m,type:h}),children:[a.jsx(pa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:486:111",children:a.jsx(ba,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:486:126"})}),a.jsxs(ua,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:486:157",children:[a.jsx(B,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:486:172",value:"graph",children:"折线图"}),a.jsx(B,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:486:214",value:"stat",children:"数值"}),a.jsx(B,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:486:254",value:"gauge",children:"仪表盘"}),a.jsx(B,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:486:296",value:"table",children:"表格"})]})]})]}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:487:11",children:[a.jsx(L,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:487:16",children:"查询"}),a.jsx(X,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:487:33",value:m.query,onChange:h=>P({...m,query:h.target.value})})]})]}),a.jsxs(Na,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:488:9",children:[a.jsx(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:488:23",variant:"outline",onClick:()=>g(!1),children:"取消"}),a.jsx(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:488:94",onClick:v,children:"添加"})]})]})})]})},Xs=()=>{const[s,r]=o.useState("agent"),[e,c]=o.useState(!1);return a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:499:5",className:`space-y-4 ${e?"fixed inset-0 z-50 bg-background p-4 overflow-auto":""}`,children:[a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:502:7",className:"flex items-center gap-1 p-1 rounded-lg bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)]",children:[zs.map(i=>a.jsxs("button",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:504:11",onClick:()=>r(i.id),className:`flex items-center gap-1.5 px-4 py-2 rounded-md text-xs font-medium transition-colors ${s===i.id?"bg-[var(--dg-bg-primary)] text-[var(--dg-text-primary)] shadow-sm":"text-[var(--dg-text-muted)] hover:text-[var(--dg-text-secondary)]"}`,children:[i.icon,i.label]},i.id)),a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:517:9",className:"ml-auto",children:a.jsx(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:518:11",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>c(!e),children:e?a.jsx(hs,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:519:27",className:"w-3.5 h-3.5"}):a.jsx(ms,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:519:67",className:"w-3.5 h-3.5"})})})]}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:525:7",className:"min-h-[50vh]",children:[s==="agent"&&a.jsx(ks,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:526:29"}),s==="zabbix"&&a.jsx(Ws,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:527:30"}),s==="prometheus"&&a.jsx(_s,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:528:34"}),s==="dashboard"&&a.jsx($s,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:529:33"})]})]})};export{Xs as default}; diff --git a/backend/static/assets/HostMonitor-C6-o-ZDP.js b/backend/static/assets/HostMonitor-C6-o-ZDP.js deleted file mode 100644 index 781483d..0000000 --- a/backend/static/assets/HostMonitor-C6-o-ZDP.js +++ /dev/null @@ -1 +0,0 @@ -import{j as t,r as H}from"./vendor-codemirror-B1SGo4xl.js";import{f as Et,J as Mt,B as L,D as wt,a as Pt,b as Ct,c as kt,d as Dt,e as Tt,t as qt,av as Kt}from"./index-Dungj95X.js";import{a as B}from"./agent-CZzlLHxR.js";import{u as ct,q as K,b as pt}from"./unwrap-DPwG25JA.js";import{C,a as k}from"./card-BIfzBCEy.js";import{S as ft,a as yt,b as Nt,c as Ht,d as et}from"./select-CiTqGGhE.js";import{c as q,T as Ot,a as Rt,b as Gt}from"./tabs-D87nAyJR.js";import{B as Q}from"./badge-CGJlVD3L.js";import{R as mt,A as gt,C as ut,X as bt,Y as jt,T as vt,a as at,B as Lt}from"./AreaChart-yrR-Mxho.js";import{N as st,R as Ft,P as Wt,y as zt,a as ht,b as ot,aJ as Ut,T as Vt,A as $t,H as W,L as Qt,h as V,_ as Xt,b2 as _t,I as Jt,b3 as Yt,g as Zt,b4 as lt}from"./vendor-icons-DmqcWdzX.js";import"./index-5FEebgvX.js";function te(){return ct({queryKey:K.hostMonitor.hosts(),queryFn:async()=>{const e=await B.getLatest();return pt(e)},staleTime:3e4})}function ee(e,a){return ct({queryKey:K.hostMonitor.history(e,a),queryFn:async()=>{if(!e)return[];const i=await B.getHistory(e,a);return pt(i)},enabled:!!e,staleTime:3e4})}function se(e){return ct({queryKey:K.hostMonitor.probes(e),queryFn:async()=>{if(!e)return[];const a=await B.getHealthProbes({hostname:e});return pt(a)},enabled:!!e})}function oe(e){return ct({queryKey:K.hostMonitor.portPolicy(e),queryFn:async()=>{if(!e)return{port_filter_mode:"whitelist",port_whitelist:[]};const a=await B.getPortPolicy(e);return{port_filter_mode:a?.data?.port_filter_mode||"blacklist",port_whitelist:a?.data?.port_whitelist||[]}},enabled:!!e})}const xt=[{label:"1小时",hours:1,window:60,buckets:60},{label:"6小时",hours:6,window:300,buckets:72},{label:"12小时",hours:12,window:600,buckets:72},{label:"1天",hours:24,window:1800,buckets:96},{label:"3天",hours:72,window:3600,buckets:72},{label:"7天",hours:168,window:10800,buckets:56},{label:"14天",hours:336,window:21600,buckets:48}],St=(e="")=>({name:"",hostname:e,probe_type:"http_get",http_url:"",http_method:"GET",http_expect_code:200,http_expect_body:"",tcp_host:"localhost",tcp_port:3306,exec_command:"",timeout:10,interval:60,description:""});function j(e,a,i){if(!e||e.length===0)return[];const l=Math.max(1,Math.ceil(e.length/i)),p=[];for(let n=0;nM+F,0)/c.length,x=Math.max(...c),N=Math.min(...c),D=d[Math.floor(d.length/2)]||0;p.push({time:new Date(D*1e3).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}),timestamp:D,avg:Number(s.toFixed(2)),max:Number(x.toFixed(2)),min:Number(N.toFixed(2)),count:c.length})}return p.slice(-i)}function v(e){if(!e)return{};if(typeof e=="object")return e;try{return JSON.parse(e)}catch{return{}}}function rt(e){return e>=1024*1024*1024?`${(e/1024/1024/1024).toFixed(1)} GB/s`:e>=1024*1024?`${(e/1024/1024).toFixed(1)} MB/s`:e>=1024?`${(e/1024).toFixed(1)} KB/s`:`${e.toFixed(1)} B/s`}function ae(e,a){const i=[],l=[],p=[],n=[],c=[],d=[],m=[],s=[],x=[],N=[],D=[],M=[],F=[],o=[],E=[],X=[],z=[],$=[],J=[],w=[],g=[];for(const h of e){const it=h.report_time?new Date(h.report_time).getTime()/1e3:h.created_at?new Date(h.created_at).getTime()/1e3:0;g.push(it),i.push(h.cpu_usage||0),o.push(h.cpu_iowait||0),l.push(h.mem_usage||0),E.push(h.mem_available||0),p.push(h.load1||0),n.push(h.disk_usage||0);const O=v(h.disk_info);if(Array.isArray(O)&&O.length>0){const u=O.find(f=>f.mount==="/")||O[0];w.push(u?.inode_usage_pct||0)}else w.push(0);const _=v(h.net_info);c.push(_.tcp_established||0),d.push(_.tcp_time_wait||0),m.push(_.tcp_close_wait||0),z.push((_.tcp_established||0)+(_.tcp_time_wait||0)+(_.tcp_close_wait||0)),s.push(_.net_rx_bps||0),x.push(_.net_tx_bps||0),$.push(_.net_rx_errors||0),J.push(_.net_tx_errors||0);const U=v(h.disk_io_info);N.push(U.read_bps||0),D.push(U.write_bps||0),X.push(U.util||0);const P=v(h.swap_info);M.push(P?.usage_percent||0);const b=v(h.fd_info);F.push(b?.usage_pct||0)}return{cpu:j(i,g,a.buckets),mem:j(l,g,a.buckets),load1:j(p,g,a.buckets),disk:j(n,g,a.buckets),tcpEst:j(c,g,a.buckets),tcpTW:j(d,g,a.buckets),tcpCW:j(m,g,a.buckets),rx:j(s.map(h=>h/1024),g,a.buckets),tx:j(x.map(h=>h/1024),g,a.buckets),ioRead:j(N.map(h=>h/1024),g,a.buckets),ioWrite:j(D.map(h=>h/1024),g,a.buckets),swap:j(M,g,a.buckets),fd:j(F,g,a.buckets),iowait:j(o,g,a.buckets),memAvail:j(E,g,a.buckets),ioUtil:j(X,g,a.buckets),connTotal:j(z,g,a.buckets),rxErr:j($,g,a.buckets),txErr:j(J,g,a.buckets),inode:j(w,g,a.buckets)}}function re(e,a,i,l,p,n,c="--"){return e?n==="cpu"?e.cpu_usage!=null?`${e.cpu_usage.toFixed(1)}%`:c:n==="mem"?e.mem_usage!=null?`${e.mem_usage.toFixed(1)}%`:c:n==="disk"?e.disk_usage!=null?`${e.disk_usage.toFixed(1)}%`:c:n==="load1"?e.load1!=null?String(e.load1):c:n==="tcp"?a.tcp_established!=null?String(a.tcp_established):c:n==="tw"?a.tcp_time_wait!=null?String(a.tcp_time_wait):c:n==="rx"?a.net_rx_bps!=null?`${(a.net_rx_bps/1024).toFixed(1)} KB/s`:c:n==="tx"?a.net_tx_bps!=null?`${(a.net_tx_bps/1024).toFixed(1)} KB/s`:c:n==="ioR"?i.read_bps!=null?`${rt(i.read_bps)}`:c:n==="ioW"?i.write_bps!=null?`${rt(i.write_bps)}`:c:n==="swap"?l?.usage_percent!=null?`${l.usage_percent.toFixed(1)}%`:c:n==="fd"&&p?.usage_pct!=null?`${p.usage_pct.toFixed(1)}%`:c:c}function y({title:e,value:a,icon:i,data:l,color:p,unit:n,domain:c,aggType:d}){const m=l.map(s=>({...s,value:s[d]}));return t.jsx(C,{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:26:5",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:t.jsxs(k,{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:27:7",className:"p-3",children:[t.jsx("div",{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:28:9",className:"flex items-center justify-between mb-1",children:t.jsxs("div",{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:29:11",className:"flex items-center gap-1.5",children:[i,t.jsx("span",{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:29:60",className:"text-xs text-[var(--dg-text-primary)] font-medium truncate",children:e})]})}),t.jsxs("div",{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:31:9",className:"mb-2",children:[t.jsx("span",{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:32:11",className:"text-xl font-bold text-[var(--dg-text-primary)] tabular-nums",children:a}),n&&t.jsx("span",{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:33:20",className:"text-xs text-[var(--dg-text-muted)] ml-1",children:n})]}),t.jsx("div",{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:35:9",className:"h-48",children:m.length===0?t.jsx("div",{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:37:13",className:"h-full flex items-center justify-center text-xs text-[var(--dg-text-muted)] border border-dashed border-[var(--dg-border)] rounded-md",children:"暂无数据"}):t.jsx(mt,{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:39:13",width:"100%",height:"100%",children:t.jsxs(gt,{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:40:15",data:m,margin:{top:2,right:2,bottom:0,left:-10},children:[t.jsx("defs",{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:41:17",children:t.jsxs("linearGradient",{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:42:19",id:`grad-${e}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:43:21",offset:"5%",stopColor:p,stopOpacity:.3}),t.jsx("stop",{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:44:21",offset:"95%",stopColor:p,stopOpacity:0})]})}),t.jsx(ut,{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:47:17",strokeDasharray:"3 3",stroke:"#1e293b",strokeOpacity:.5}),t.jsx(bt,{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:48:17",dataKey:"time",hide:!0}),t.jsx(jt,{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:49:17",hide:!0,domain:c[1]==="auto"?[0,s=>s*1.1]:c}),t.jsx(vt,{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:50:17",contentStyle:{backgroundColor:"#0f172a",border:"1px solid #1e293b",borderRadius:"4px",color:"#f8fafc",fontSize:"11px",padding:"4px 8px"},formatter:s=>[`${s.toFixed(2)} ${n}`,e.replace(/\(.+\)/,"")],labelFormatter:s=>`时间: ${s}`}),t.jsx(at,{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:53:17",type:"monotone",dataKey:"value",stroke:p,strokeWidth:1.5,fill:`url(#grad-${e})`}),t.jsx(Lt,{"code-path":"src/pages/host-monitor/MetricChartCard.tsx:54:17",dataKey:"time",height:24,stroke:"#334155",fill:"#0f172a",startIndex:Math.max(0,m.length-Math.min(20,m.length))})]})})})]})})}function ce({title:e,currentRx:a,currentTx:i,rxData:l,txData:p,aggType:n,unit:c}){const d=l.map((x,N)=>({time:x.time,timestamp:x.timestamp,rx:x[n]??0,tx:p[N]?.[n]??0})),m=`grad-rx-${e.replace(/\s/g,"")}`,s=`grad-tx-${e.replace(/\s/g,"")}`;return t.jsx(C,{"code-path":"src/pages/host-monitor/DualLineChart.tsx:32:5",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:t.jsxs(k,{"code-path":"src/pages/host-monitor/DualLineChart.tsx:33:7",className:"p-3",children:[t.jsxs("div",{"code-path":"src/pages/host-monitor/DualLineChart.tsx:34:9",className:"flex items-center justify-between mb-1",children:[t.jsxs("div",{"code-path":"src/pages/host-monitor/DualLineChart.tsx:35:11",className:"flex items-center gap-1.5",children:[t.jsx(st,{"code-path":"src/pages/host-monitor/DualLineChart.tsx:36:13",className:"h-4 w-4 text-blue-400"}),t.jsx("span",{"code-path":"src/pages/host-monitor/DualLineChart.tsx:37:13",className:"text-xs text-[var(--dg-text-primary)] font-medium",children:e})]}),t.jsxs("div",{"code-path":"src/pages/host-monitor/DualLineChart.tsx:39:11",className:"flex items-center gap-3 text-xs",children:[t.jsxs("span",{"code-path":"src/pages/host-monitor/DualLineChart.tsx:40:13",children:[t.jsx("span",{"code-path":"src/pages/host-monitor/DualLineChart.tsx:40:19",className:"inline-block w-2.5 h-2.5 rounded-sm bg-blue-400 mr-1 align-middle"}),"接收 ",t.jsx("b",{"code-path":"src/pages/host-monitor/DualLineChart.tsx:40:108",className:"text-blue-300",children:a})]}),t.jsxs("span",{"code-path":"src/pages/host-monitor/DualLineChart.tsx:41:13",children:[t.jsx("span",{"code-path":"src/pages/host-monitor/DualLineChart.tsx:41:19",className:"inline-block w-2.5 h-2.5 rounded-sm bg-emerald-400 mr-1 align-middle"}),"发送 ",t.jsx("b",{"code-path":"src/pages/host-monitor/DualLineChart.tsx:41:111",className:"text-emerald-300",children:i})]})]})]}),t.jsx("div",{"code-path":"src/pages/host-monitor/DualLineChart.tsx:44:9",className:"h-56",children:d.length===0?t.jsx("div",{"code-path":"src/pages/host-monitor/DualLineChart.tsx:46:13",className:"h-full flex items-center justify-center text-xs text-[var(--dg-text-muted)] border border-dashed border-[var(--dg-border)] rounded-md",children:"暂无数据"}):t.jsx(mt,{"code-path":"src/pages/host-monitor/DualLineChart.tsx:48:13",width:"100%",height:"100%",children:t.jsxs(gt,{"code-path":"src/pages/host-monitor/DualLineChart.tsx:49:15",data:d,margin:{top:2,right:2,bottom:0,left:-10},children:[t.jsxs("defs",{"code-path":"src/pages/host-monitor/DualLineChart.tsx:50:17",children:[t.jsxs("linearGradient",{"code-path":"src/pages/host-monitor/DualLineChart.tsx:51:19",id:m,x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{"code-path":"src/pages/host-monitor/DualLineChart.tsx:52:21",offset:"5%",stopColor:"#3b82f6",stopOpacity:.3}),t.jsx("stop",{"code-path":"src/pages/host-monitor/DualLineChart.tsx:53:21",offset:"95%",stopColor:"#3b82f6",stopOpacity:0})]}),t.jsxs("linearGradient",{"code-path":"src/pages/host-monitor/DualLineChart.tsx:55:19",id:s,x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{"code-path":"src/pages/host-monitor/DualLineChart.tsx:56:21",offset:"5%",stopColor:"#10b981",stopOpacity:.3}),t.jsx("stop",{"code-path":"src/pages/host-monitor/DualLineChart.tsx:57:21",offset:"95%",stopColor:"#10b981",stopOpacity:0})]})]}),t.jsx(ut,{"code-path":"src/pages/host-monitor/DualLineChart.tsx:60:17",strokeDasharray:"3 3",stroke:"#1e293b",strokeOpacity:.5}),t.jsx(bt,{"code-path":"src/pages/host-monitor/DualLineChart.tsx:61:17",dataKey:"time",hide:!0}),t.jsx(jt,{"code-path":"src/pages/host-monitor/DualLineChart.tsx:62:17",hide:!0,domain:[0,"auto"]}),t.jsx(vt,{"code-path":"src/pages/host-monitor/DualLineChart.tsx:63:17",contentStyle:{backgroundColor:"#0f172a",border:"1px solid #1e293b",borderRadius:"4px",color:"#f8fafc",fontSize:"11px",padding:"4px 8px"},formatter:(x,N)=>[`${x.toFixed(2)} ${c}`,N==="rx"?"接收":"发送"],labelFormatter:x=>`时间: ${x}`}),t.jsx(at,{"code-path":"src/pages/host-monitor/DualLineChart.tsx:66:17",type:"monotone",dataKey:"rx",stroke:"#3b82f6",strokeWidth:1.5,fill:`url(#${m})`,name:"rx"}),t.jsx(at,{"code-path":"src/pages/host-monitor/DualLineChart.tsx:67:17",type:"monotone",dataKey:"tx",stroke:"#10b981",strokeWidth:1.5,fill:`url(#${s})`,name:"tx"}),t.jsx(Lt,{"code-path":"src/pages/host-monitor/DualLineChart.tsx:68:17",dataKey:"time",height:24,stroke:"#334155",fill:"#0f172a",startIndex:Math.max(0,d.length-Math.min(20,d.length))})]})})})]})})}function ie({selectedHost:e}){const a=Et(),i=Mt(),{data:l=[],refetch:p}=se(e),[n,c]=H.useState(!1),[d,m]=H.useState(null),[s,x]=H.useState(St()),N=()=>{m(null),x(St(e)),c(!0)},D=o=>{m(o),x({name:String(o.name||""),hostname:String(o.hostname||""),probe_type:String(o.probe_type||"http_get"),http_url:String(o.http_url||""),http_method:String(o.http_method||"GET"),http_expect_code:Number(o.http_expect_code)||200,http_expect_body:String(o.http_expect_body||""),tcp_host:String(o.tcp_host||""),tcp_port:Number(o.tcp_port)||3306,exec_command:String(o.exec_command||""),timeout:Number(o.timeout)||10,interval:Number(o.interval)||60,description:String(o.description||"")}),c(!0)},M=async()=>{if(!(!s.name||!s.hostname))try{d?await B.updateHealthProbe(d.id,s):await B.createHealthProbe(s),c(!1),i.invalidateQueries({queryKey:K.hostMonitor.probes(e)})}catch{qt.error("保存失败")}},F=async o=>{await a({title:"删除探针",description:`确定删除探针「${o.name}」?`,confirmText:"删除",variant:"destructive"})&&(await B.deleteHealthProbe(o.id),i.invalidateQueries({queryKey:K.hostMonitor.probes(e)}))};return t.jsxs(t.Fragment,{children:[t.jsxs(q,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:88:7",value:"health_probes",className:"mt-3 space-y-3",children:[t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:89:9",className:"flex items-center justify-between",children:[t.jsx("h3",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:90:11",className:"text-xs font-medium text-[var(--dg-text-primary)]",children:"探针列表(Agent 在目标主机本地执行探测)"}),t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:91:11",className:"flex gap-2",children:[t.jsxs(L,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:92:13",size:"sm",variant:"outline",className:"h-7 text-[11px]",onClick:()=>p(),children:[t.jsx(Ft,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:93:15",className:"w-3 h-3 mr-1"}),"刷新"]}),t.jsxs(L,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:95:13",size:"sm",className:"h-7 text-[11px] bg-blue-600 hover:bg-blue-500",onClick:N,children:[t.jsx(Wt,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:96:15",className:"w-3 h-3 mr-1"}),"添加探针"]})]})]}),l.length===0?t.jsx(C,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:101:11",className:"bg-[var(--dg-bg-secondary)] border-dashed border-[var(--dg-border)]",children:t.jsx(k,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:102:13",className:"p-8 text-center text-xs text-[var(--dg-text-muted)]",children:'暂无健康探针,点击"添加探针"创建'})}):t.jsx("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:107:11",className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:l.map(o=>t.jsx(C,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:109:15",className:`bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] ${o.last_status==="down"?"border-red-700/50":""}`,children:t.jsxs(k,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:110:17",className:"p-3",children:[t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:111:19",className:"flex items-start justify-between mb-2",children:[t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:112:21",className:"flex items-center gap-2",children:[o.last_status==="up"?t.jsx(zt,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:113:49",className:"w-4 h-4 text-emerald-400"}):o.last_status==="down"?t.jsx(ht,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:114:51",className:"w-4 h-4 text-red-400"}):t.jsx(ot,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:115:24",className:"w-4 h-4 text-slate-500"}),t.jsx("span",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:116:23",className:"text-xs font-medium text-[var(--dg-text-primary)]",children:String(o.name)}),t.jsx(Q,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:117:23",variant:"outline",className:"text-[10px] h-5 px-1.5 capitalize",children:o.probe_type==="http_get"?"HTTP":o.probe_type==="tcp_socket"?"TCP":"Exec"})]}),t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:121:21",className:"flex gap-1",children:[t.jsx(L,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:122:23",variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>D(o),children:t.jsx(Ut,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:123:25",className:"w-3 h-3"})}),t.jsx(L,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:125:23",variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-red-400 hover:text-red-300",onClick:()=>F(o),children:t.jsx(Vt,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:126:25",className:"w-3 h-3"})})]})]}),t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:130:19",className:"space-y-1 text-[11px] text-[var(--dg-text-muted)]",children:[o.probe_type==="http_get"&&t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:132:23",className:"truncate",children:["URL: ",String(o.http_url)]}),o.probe_type==="tcp_socket"&&t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:135:23",children:[String(o.tcp_host),":",String(o.tcp_port)]}),o.probe_type==="exec_command"&&t.jsx("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:138:23",className:"truncate font-mono",children:String(o.exec_command)}),t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:140:21",className:"flex items-center gap-3",children:[t.jsxs("span",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:141:23",children:["状态: ",t.jsx("span",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:141:33",className:o.last_status==="up"?"text-emerald-400":o.last_status==="down"?"text-red-400":"text-slate-400",children:o.last_status?String(o.last_status).toUpperCase():"未检测"})]}),Number(o.last_latency_ms)>0&&t.jsxs("span",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:144:57",children:["延迟: ",String(o.last_latency_ms),"ms"]}),Number(o.fail_count)>0&&t.jsxs("span",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:145:52",className:"text-red-400",children:["连续失败: ",String(o.fail_count),"次"]}),o.last_checked_at&&t.jsx("span",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:146:45",className:"text-[10px]",children:new Date(String(o.last_checked_at)).toLocaleString("zh-CN")})]})]})]})},String(o.id)))})]}),t.jsx(wt,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:156:7",open:n,onOpenChange:c,children:t.jsxs(Pt,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:157:9",showOverlay:!1,className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] max-w-lg",children:[t.jsxs(Ct,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:158:11",children:[t.jsx(kt,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:159:13",className:"text-[var(--dg-text-primary)]",children:d?"编辑探针":"添加探针"}),t.jsx(Dt,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:162:13",className:"text-[var(--dg-text-secondary)]",children:d?"修改健康探针配置":"创建新的健康探针,Agent 在目标主机本地执行探测"})]}),t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:166:11",className:"space-y-3 max-h-[60vh] overflow-y-auto pr-1",children:[t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:167:13",children:[t.jsxs("label",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:168:15",className:"text-[11px] text-[var(--dg-text-muted)] mb-1 block",children:["探针名称 ",t.jsx("span",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:168:90",className:"text-red-400",children:"*"})]}),t.jsx("input",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:169:15",className:"w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]",value:s.name,onChange:o=>x({...s,name:o.target.value}),placeholder:"如:cex-agent 健康检查"})]}),t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:171:13",children:[t.jsx("label",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:172:15",className:"text-[11px] text-[var(--dg-text-muted)] mb-1 block",children:"目标主机"}),t.jsx("input",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:173:15",className:"w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]",value:s.hostname,onChange:o=>x({...s,hostname:o.target.value})})]}),t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:175:13",children:[t.jsx("label",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:176:15",className:"text-[11px] text-[var(--dg-text-muted)] mb-1 block",children:"探针类型"}),t.jsxs("select",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:177:15",className:"w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]",value:s.probe_type,onChange:o=>x({...s,probe_type:o.target.value}),children:[t.jsx("option",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:178:17",value:"http_get",children:"HTTP GET"}),t.jsx("option",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:179:17",value:"tcp_socket",children:"TCP Socket"}),t.jsx("option",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:180:17",value:"exec_command",children:"Exec Command"})]})]}),s.probe_type==="http_get"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:186:17",children:[t.jsxs("label",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:186:22",className:"text-[11px] text-[var(--dg-text-muted)] mb-1 block",children:["HTTP URL ",t.jsx("span",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:186:101",className:"text-red-400",children:"*"})]}),t.jsx("input",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:187:19",className:"w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]",value:s.http_url,onChange:o=>x({...s,http_url:o.target.value}),placeholder:"http://localhost:8080/health"})]}),t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:188:17",className:"grid grid-cols-2 gap-2",children:[t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:189:19",children:[t.jsx("label",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:189:24",className:"text-[11px] text-[var(--dg-text-muted)] mb-1 block",children:"期望状态码"}),t.jsx("input",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:190:21",type:"number",className:"w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]",value:s.http_expect_code,onChange:o=>x({...s,http_expect_code:Number(o.target.value)})})]}),t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:191:19",children:[t.jsx("label",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:191:24",className:"text-[11px] text-[var(--dg-text-muted)] mb-1 block",children:"期望响应内容(可选)"}),t.jsx("input",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:192:21",className:"w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]",value:s.http_expect_body,onChange:o=>x({...s,http_expect_body:o.target.value})})]})]})]}),s.probe_type==="tcp_socket"&&t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:198:15",className:"grid grid-cols-2 gap-2",children:[t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:199:17",children:[t.jsx("label",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:199:22",className:"text-[11px] text-[var(--dg-text-muted)] mb-1 block",children:"TCP 目标地址"}),t.jsx("input",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:200:19",className:"w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]",value:s.tcp_host,onChange:o=>x({...s,tcp_host:o.target.value}),placeholder:"localhost"})]}),t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:201:17",children:[t.jsx("label",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:201:22",className:"text-[11px] text-[var(--dg-text-muted)] mb-1 block",children:"TCP 端口"}),t.jsx("input",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:202:19",type:"number",className:"w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]",value:s.tcp_port,onChange:o=>x({...s,tcp_port:Number(o.target.value)})})]})]}),s.probe_type==="exec_command"&&t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:207:15",children:[t.jsxs("label",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:207:20",className:"text-[11px] text-[var(--dg-text-muted)] mb-1 block",children:["执行命令 ",t.jsx("span",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:207:95",className:"text-red-400",children:"*"})]}),t.jsx("input",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:208:17",className:"w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs font-mono text-[var(--dg-text-primary)]",value:s.exec_command,onChange:o=>x({...s,exec_command:o.target.value}),placeholder:"pgrep -x mysqld"})]}),t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:211:13",className:"grid grid-cols-2 gap-2",children:[t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:212:15",children:[t.jsx("label",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:212:20",className:"text-[11px] text-[var(--dg-text-muted)] mb-1 block",children:"超时(秒)"}),t.jsx("input",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:213:17",type:"number",className:"w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]",value:s.timeout,onChange:o=>x({...s,timeout:Number(o.target.value)})})]}),t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:214:15",children:[t.jsx("label",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:214:20",className:"text-[11px] text-[var(--dg-text-muted)] mb-1 block",children:"间隔(秒)"}),t.jsx("input",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:215:17",type:"number",className:"w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]",value:s.interval,onChange:o=>x({...s,interval:Number(o.target.value)})})]})]}),t.jsxs("div",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:218:13",children:[t.jsx("label",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:218:18",className:"text-[11px] text-[var(--dg-text-muted)] mb-1 block",children:"描述"}),t.jsx("input",{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:219:15",className:"w-full h-8 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 text-xs text-[var(--dg-text-primary)]",value:s.description,onChange:o=>x({...s,description:o.target.value})})]})]}),t.jsxs(Tt,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:221:11",children:[t.jsx(L,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:222:13",variant:"outline",size:"sm",className:"h-7 text-[11px]",onClick:()=>c(!1),children:"取消"}),t.jsx(L,{"code-path":"src/pages/host-monitor/HealthProbeSection.tsx:223:13",size:"sm",className:"h-7 text-[11px] bg-blue-600 hover:bg-blue-500",onClick:M,disabled:!s.name||!s.hostname,children:d?"保存":"创建"})]})]})})]})}function ne(e){const a=Number(e);return Number.isInteger(a)&&a>0&&a<=65535}function de(e){return e.split(",").map(a=>parseInt(a.trim(),10)).filter(a=>ne(a))}function le({open:e,onOpenChange:a,portPolicyMode:i,onModeChange:l,portWhitelist:p,onWhitelistChange:n,onSave:c,saving:d}){return t.jsx(wt,{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:30:5",open:e,onOpenChange:a,children:t.jsxs(Pt,{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:31:7",showOverlay:!1,className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] max-w-md",children:[t.jsxs(Ct,{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:32:9",children:[t.jsx(kt,{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:33:11",className:"text-[var(--dg-text-primary)]",children:"端口监控策略"}),t.jsx(Dt,{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:34:11",className:"text-[var(--dg-text-secondary)]",children:"配置 Agent 端口上报过滤规则"})]}),t.jsxs("div",{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:36:9",className:"space-y-4",children:[t.jsxs("div",{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:37:11",children:[t.jsx("label",{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:38:13",className:"text-[11px] text-[var(--dg-text-muted)] mb-1.5 block",children:"过滤模式"}),t.jsxs("div",{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:39:13",className:"flex gap-2",children:[t.jsx("button",{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:40:15",className:`flex-1 h-9 rounded text-xs font-medium border transition-colors ${i==="whitelist"?"bg-blue-500/20 border-blue-500 text-blue-400":"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-muted)]"}`,onClick:()=>l("whitelist"),children:"白名单 ─ 全量上报"}),t.jsx("button",{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:46:15",className:`flex-1 h-9 rounded text-xs font-medium border transition-colors ${i==="blacklist"?"bg-amber-500/20 border-amber-500 text-amber-400":"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-muted)]"}`,onClick:()=>l("blacklist"),children:"黑名单 ─ 仅上报选中"})]}),t.jsx("p",{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:53:13",className:"text-[10px] text-[var(--dg-text-muted)] mt-1.5 leading-relaxed",children:i==="whitelist"?"所有发现的端口都上报,任意端口变化都会触发告警 + 恢复通知。":"仅上报选中端口的变化,其余端口变化静默忽略(不告警)。系统进程端口(sshd/rpcbind/systemd等)永远忽略。"})]}),t.jsxs("div",{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:60:11",children:[t.jsxs("label",{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:61:13",className:"text-[11px] text-[var(--dg-text-muted)] mb-1.5 block",children:["端口列表 ",t.jsx("span",{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:62:20",className:"text-[var(--dg-text-muted)]",children:"(逗号分隔,如: 80,443,3306,6379)"}),i==="whitelist"&&t.jsx("span",{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:63:50",className:"text-blue-400 ml-1",children:"— 白名单模式无需配置"})]}),t.jsx("textarea",{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:65:13",className:`w-full h-20 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded px-2 py-1.5 text-xs font-mono resize-none ${i==="whitelist"?"text-[var(--dg-text-muted)] opacity-50 cursor-not-allowed":"text-[var(--dg-text-primary)]"}`,value:p.join(","),onChange:m=>{if(i==="whitelist")return;const s=m.target.value;n(de(s))},placeholder:i==="whitelist"?"白名单模式下所有端口自动上报":"80,443,3306,6379",readOnly:i==="whitelist"}),t.jsxs("p",{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:78:13",className:"text-[10px] text-[var(--dg-text-muted)] mt-1",children:["已输入 ",p.length," 个端口"]})]}),t.jsx("div",{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:83:11",className:"bg-amber-500/5 border border-amber-500/20 rounded p-2.5",children:t.jsxs("p",{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:84:13",className:"text-[10px] text-amber-300/80 leading-relaxed",children:["⚠️ 无论选择哪种模式,以下系统进程端口",t.jsx("b",{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:85:35",children:"永远不上报"}),":sshd、rpcbind、master、systemd、dbus-daemon、rsyslogd 等。Agent 采集时自动跳过。"]})})]}),t.jsxs(Tt,{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:89:9",children:[t.jsx(L,{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:90:11",variant:"outline",size:"sm",className:"h-7 text-[11px]",onClick:()=>a(!1),children:"取消"}),t.jsx(L,{"code-path":"src/pages/host-monitor/PortPolicyDialog.tsx:91:11",size:"sm",className:"h-7 text-[11px] bg-blue-600 hover:bg-blue-500",onClick:c,disabled:d,children:d?"保存中…":"保存策略"})]})]})})}function xe({selectedHost:e,serverInfo:a,latest:i,heartbeatInfo:l,portInfoCount:p}){const n=i?.disk_info?v(i.disk_info):null,c=n?Array.isArray(n)?n:n.partitions||[]:[];return t.jsxs(q,{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:23:5",value:"system",className:"mt-3 space-y-3",children:[t.jsx(C,{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:24:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:t.jsx(k,{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:25:9",className:"p-4",children:t.jsx("div",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:26:11",className:"grid grid-cols-2 md:grid-cols-4 gap-x-6 gap-y-3 text-xs",children:[["主机名",a?.hostname||e],["IP 地址",a?.ip||"—"],["操作系统",a?.os||"—"],["内核版本",a?.kernel||"—"],["CPU 核心数",a?.cpu_cores||"—"],["总内存",a?.mem_total?`${a.mem_total.toFixed(0)} GB`:"—"],["已用内存",a?.mem_used?`${a.mem_used.toFixed(1)} GB`:"—"],["运行时长",a?.uptime?`${Math.floor(a.uptime/86400)}天 ${Math.floor(a.uptime%86400/3600)}时`:"—"],["Agent 版本",l?.version||a?.agent_version||"—"],["Agent 序列号",l?.report_seq!=null?String(l.report_seq):"—"],["监听端口数",p>0?`${p}`:"—"],["Agent RSS",l?.self_rss_mb?`${l.self_rss_mb.toFixed(1)} MB`:"—"]].map(([d,m])=>t.jsxs("div",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:41:15",children:[t.jsxs("span",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:42:17",className:"text-[var(--dg-text-muted)]",children:[d,":"]}),t.jsx("span",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:43:17",className:"text-[var(--dg-text-primary)] font-mono",children:m})]},d))})})}),i&&t.jsx(C,{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:51:9",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:t.jsxs(k,{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:52:11",className:"p-4",children:[t.jsxs("div",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:53:13",className:"flex items-center gap-2 mb-2",children:[t.jsx($t,{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:54:15",className:"h-4 w-4 text-[var(--dg-text-muted)]"}),t.jsx("h3",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:55:15",className:"text-xs font-medium text-[var(--dg-text-primary)]",children:"系统负载 (Load Average)"})]}),t.jsxs("div",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:57:13",className:"flex items-center gap-6 text-xs",children:[t.jsxs("div",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:58:15",children:[t.jsx("span",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:58:20",className:"text-[var(--dg-text-muted)]",children:"1min "}),t.jsx("span",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:58:78",className:"text-sm font-bold text-slate-200",children:i.load1??"--"})]}),t.jsxs("div",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:59:15",children:[t.jsx("span",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:59:20",className:"text-[var(--dg-text-muted)]",children:"5min "}),t.jsx("span",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:59:78",className:"text-sm font-bold text-slate-200",children:i.load5??"--"})]}),t.jsxs("div",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:60:15",children:[t.jsx("span",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:60:20",className:"text-[var(--dg-text-muted)]",children:"15min "}),t.jsx("span",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:60:79",className:"text-sm font-bold text-slate-200",children:i.load15??"--"})]})]})]})}),c.length>0&&t.jsx(C,{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:67:9",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:t.jsxs(k,{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:68:11",className:"p-4",children:[t.jsxs("h3",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:69:13",className:"text-xs font-medium text-[var(--dg-text-primary)] mb-2 flex items-center gap-2",children:[t.jsx(W,{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:69:108",className:"h-4 w-4"}),"磁盘分区"]}),t.jsx("div",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:70:13",className:"space-y-1.5",children:c.map((d,m)=>t.jsxs("div",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:72:17",className:"flex items-center gap-2 text-xs",children:[t.jsx("span",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:73:19",className:"text-[var(--dg-text-muted)] w-24 font-mono truncate",children:d.mount||d.mountpoint||d.device||`disk${m}`}),t.jsx("div",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:74:19",className:"flex-1 h-1.5 bg-slate-700 rounded-full overflow-hidden",children:t.jsx("div",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:75:21",className:"h-full rounded-full bg-blue-500",style:{width:`${Math.min(d.usage_percent||d.used_percent||0,100)}%`}})}),t.jsxs("span",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:77:19",className:"text-[var(--dg-text-primary)] w-28 text-right tabular-nums whitespace-nowrap",children:[(d.used_gb??0).toFixed(1),"/",(d.total_gb??0).toFixed(0),"GB"]}),t.jsxs("span",{"code-path":"src/pages/host-monitor/SystemInfoSection.tsx:78:19",className:"text-blue-400 w-14 text-right tabular-nums whitespace-nowrap",children:[(d.usage_percent??d.used_percent??0).toFixed(1),"%"]})]},m))})]})})]})}function He(){const e=Mt(),[a]=Kt(),i=a.get("host")||"",[l,p]=H.useState(i),[n,c]=H.useState("basic"),[d,m]=H.useState(1),[s,x]=H.useState("avg"),[N,D]=H.useState("whitelist"),[M,F]=H.useState([]),[o,E]=H.useState(!1),[X,z]=H.useState(!1),{data:$=[],isLoading:J}=te(),{data:w=[],isLoading:g}=ee(l,d),{data:h,refetch:it}=oe(l);H.useEffect(()=>{h&&(D(h.port_filter_mode),F(h.port_whitelist))},[h]),H.useEffect(()=>{if($.length>0&&!l){const r=i?$.find(T=>T.hostname===i):null;p(String(r?.hostname||$[0]?.hostname||""))}},[$,l,i]);const O=async()=>{if(l){z(!0);try{await B.savePortPolicy(l,{port_filter_mode:N,port_whitelist:M}),E(!1),e.invalidateQueries({queryKey:K.hostMonitor.portPolicy(l)})}catch{}finally{z(!1)}}},_=xt.find(r=>r.hours===d)||xt[0],U=J||g,P=$.find(r=>r.hostname===l)||null,b=H.useMemo(()=>{const r=P||{};return w.length===0?r:{...r,...w[w.length-1]}},[P,w]),u=H.useMemo(()=>ae(w,_),[w,_]),f=v(b?.net_info),Y=Array.isArray(b?.port_info)?b.port_info:Array.isArray(v(b?.port_info))?v(b?.port_info):[],nt=v(b?.disk_io_info),At=v(b?.swap_info),dt=Array.isArray(v(b?.process_top_info))?v(b?.process_top_info):[],I=v(b?.fd_info),S=v(b?.cs_info),It=v(b?.heartbeat_info),A=(r,T="--")=>re(b,f,nt,At,I,r,T);return U&&!w.length?t.jsx("div",{"code-path":"src/pages/HostMonitor.tsx:99:12",className:"flex items-center justify-center h-64",children:t.jsx(Qt,{"code-path":"src/pages/HostMonitor.tsx:99:67",className:"h-8 w-8 animate-spin text-slate-500"})}):t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:103:5",className:"space-y-3",children:[t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:104:7",className:"flex items-center justify-between flex-wrap gap-2",children:[t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:105:9",className:"flex items-center gap-2",children:[t.jsx(V,{"code-path":"src/pages/HostMonitor.tsx:106:11",className:"h-4 w-4 text-blue-400"}),t.jsxs(ft,{"code-path":"src/pages/HostMonitor.tsx:107:11",value:l,onValueChange:p,children:[t.jsx(yt,{"code-path":"src/pages/HostMonitor.tsx:108:13",className:"w-52 h-8 text-xs bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:t.jsx(Nt,{"code-path":"src/pages/HostMonitor.tsx:109:15",placeholder:"选择主机..."})}),t.jsx(Ht,{"code-path":"src/pages/HostMonitor.tsx:111:13",className:"bg-slate-800 border-slate-700 text-slate-200",children:$.map(r=>t.jsx(et,{"code-path":"src/pages/HostMonitor.tsx:113:17",value:r.hostname,children:r.hostname},r.hostname))})]}),P&&t.jsxs("span",{"code-path":"src/pages/HostMonitor.tsx:118:13",className:"text-xs text-[var(--dg-text-muted)] ml-2",children:[String(P.os||""),P.cpu_cores?` | ${P.cpu_cores} 核`:"",P.mem_total?` | ${P.mem_total.toFixed(0)}GB`:""]})]}),t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:123:9",className:"flex items-center gap-2",children:[t.jsxs(ft,{"code-path":"src/pages/HostMonitor.tsx:124:11",value:s,onValueChange:r=>x(r),children:[t.jsx(yt,{"code-path":"src/pages/HostMonitor.tsx:125:13",className:"w-24 h-7 text-xs bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:t.jsx(Nt,{"code-path":"src/pages/HostMonitor.tsx:126:15"})}),t.jsxs(Ht,{"code-path":"src/pages/HostMonitor.tsx:128:13",className:"bg-slate-800 border-slate-700 text-slate-200",children:[t.jsx(et,{"code-path":"src/pages/HostMonitor.tsx:129:15",value:"avg",children:"平均值"}),t.jsx(et,{"code-path":"src/pages/HostMonitor.tsx:130:15",value:"max",children:"最大值"}),t.jsx(et,{"code-path":"src/pages/HostMonitor.tsx:131:15",value:"min",children:"最小值"})]})]}),t.jsx("div",{"code-path":"src/pages/HostMonitor.tsx:134:11",className:"flex items-center gap-1",children:xt.map(r=>t.jsx(L,{"code-path":"src/pages/HostMonitor.tsx:136:15",variant:d===r.hours?"default":"outline",size:"sm",className:"h-7 text-xs px-2.5",onClick:()=>m(r.hours),children:r.label},r.hours))})]})]}),t.jsxs(Ot,{"code-path":"src/pages/HostMonitor.tsx:143:7",value:n,onValueChange:c,children:[t.jsx(Rt,{"code-path":"src/pages/HostMonitor.tsx:144:9",className:"h-8 bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] gap-0 overflow-x-auto",children:[{id:"basic",label:"基础监控",icon:t.jsx(Xt,{"code-path":"src/pages/HostMonitor.tsx:146:49",className:"w-3 h-3"})},{id:"disk",label:"磁盘监控",icon:t.jsx(W,{"code-path":"src/pages/HostMonitor.tsx:147:48",className:"w-3 h-3"})},{id:"network",label:"网络监控",icon:t.jsx(st,{"code-path":"src/pages/HostMonitor.tsx:148:51",className:"w-3 h-3"})},{id:"ports",label:"端口监控",icon:t.jsx(V,{"code-path":"src/pages/HostMonitor.tsx:149:49",className:"w-3 h-3"})},{id:"process",label:"进程监控",icon:t.jsx(_t,{"code-path":"src/pages/HostMonitor.tsx:150:51",className:"w-3 h-3"})},{id:"system",label:"系统信息",icon:t.jsx(Jt,{"code-path":"src/pages/HostMonitor.tsx:151:50",className:"w-3 h-3"})},{id:"health_probes",label:"健康探针",icon:t.jsx(Yt,{"code-path":"src/pages/HostMonitor.tsx:152:57",className:"w-3 h-3"})}].map(r=>t.jsxs(Gt,{"code-path":"src/pages/HostMonitor.tsx:154:13",value:r.id,className:"text-[11px] h-7 gap-1 data-[state=active]:bg-[var(--dg-bg-primary)]",children:[r.icon,r.label]},r.id))}),t.jsxs(q,{"code-path":"src/pages/HostMonitor.tsx:160:9",value:"basic",className:"mt-3 grid grid-cols-1 md:grid-cols-3 gap-3",children:[t.jsx(y,{"code-path":"src/pages/HostMonitor.tsx:161:11",title:"CPU 使用率(%)",value:A("cpu"),icon:t.jsx(Zt,{"code-path":"src/pages/HostMonitor.tsx:161:79",className:"h-4 w-4 text-blue-400"}),data:u.cpu,color:"#3b82f6",unit:"%",domain:[0,100],aggType:s}),t.jsx(y,{"code-path":"src/pages/HostMonitor.tsx:163:11",title:"CPU IO等待(%)",value:b?.cpu_iowait!=null?`${b.cpu_iowait.toFixed(1)}%`:"--",icon:t.jsx(ot,{"code-path":"src/pages/HostMonitor.tsx:163:145",className:"h-4 w-4 text-orange-400"}),data:u.iowait,color:"#f97316",unit:"%",domain:[0,100],aggType:s}),t.jsx(y,{"code-path":"src/pages/HostMonitor.tsx:165:11",title:"内存使用率(%)",value:A("mem"),icon:t.jsx(V,{"code-path":"src/pages/HostMonitor.tsx:165:77",className:"h-4 w-4 text-emerald-400"}),data:u.mem,color:"#10b981",unit:"%",domain:[0,100],aggType:s}),t.jsx(y,{"code-path":"src/pages/HostMonitor.tsx:167:11",title:"可用内存(GB)",value:b?.mem_available!=null?`${b.mem_available.toFixed(1)}GB`:"--",icon:t.jsx(V,{"code-path":"src/pages/HostMonitor.tsx:167:149",className:"h-4 w-4 text-emerald-400"}),data:u.memAvail,color:"#34d399",unit:"GB",domain:[0,"auto"],aggType:s}),t.jsx(y,{"code-path":"src/pages/HostMonitor.tsx:169:11",title:"Swap 使用率(%)",value:A("swap"),icon:t.jsx(W,{"code-path":"src/pages/HostMonitor.tsx:169:81",className:"h-4 w-4 text-red-400"}),data:u.swap,color:"#ef4444",unit:"%",domain:[0,100],aggType:s}),t.jsx(y,{"code-path":"src/pages/HostMonitor.tsx:171:11",title:"系统负载(1m)",value:A("load1"),icon:t.jsx($t,{"code-path":"src/pages/HostMonitor.tsx:171:79",className:"h-4 w-4 text-purple-400"}),data:u.load1,color:"#8b5cf6",unit:"",domain:[0,"auto"],aggType:s})]}),t.jsx(q,{"code-path":"src/pages/HostMonitor.tsx:175:9",value:"disk",className:"mt-3 space-y-3",children:t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:176:11",className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[t.jsx(y,{"code-path":"src/pages/HostMonitor.tsx:177:13",title:"磁盘使用率(%)",value:A("disk"),icon:t.jsx(W,{"code-path":"src/pages/HostMonitor.tsx:177:80",className:"h-4 w-4 text-orange-400"}),data:u.disk,color:"#f97316",unit:"%",domain:[0,100],aggType:s}),t.jsx(y,{"code-path":"src/pages/HostMonitor.tsx:179:13",title:"Inode 使用率(%)",value:(()=>{const r=Array.isArray(v(b?.disk_info))?v(b?.disk_info):[],T=r.find(R=>R.mount==="/")||r[0];return T?.inode_usage_pct!=null?`${T.inode_usage_pct.toFixed(1)}%`:"--"})(),icon:t.jsx(W,{"code-path":"src/pages/HostMonitor.tsx:183:25",className:"h-4 w-4 text-purple-400"}),data:u.inode,color:"#8b5cf6",unit:"%",domain:[0,100],aggType:s}),t.jsx(y,{"code-path":"src/pages/HostMonitor.tsx:185:13",title:"磁盘读取(KB/s)",value:A("ioR"),icon:t.jsx(lt,{"code-path":"src/pages/HostMonitor.tsx:185:81",className:"h-4 w-4 text-blue-400"}),data:u.ioRead,color:"#3b82f6",unit:"KB/s",domain:[0,"auto"],aggType:s}),t.jsx(y,{"code-path":"src/pages/HostMonitor.tsx:187:13",title:"磁盘写入(KB/s)",value:A("ioW"),icon:t.jsx(lt,{"code-path":"src/pages/HostMonitor.tsx:187:81",className:"h-4 w-4 text-emerald-400"}),data:u.ioWrite,color:"#10b981",unit:"KB/s",domain:[0,"auto"],aggType:s}),t.jsx(y,{"code-path":"src/pages/HostMonitor.tsx:189:13",title:"磁盘IO繁忙度(%)",value:nt?.util!=null?`${nt.util.toFixed(1)}%`:"--",icon:t.jsx(lt,{"code-path":"src/pages/HostMonitor.tsx:189:130",className:"h-4 w-4 text-red-400"}),data:u.ioUtil,color:"#ef4444",unit:"%",domain:[0,100],aggType:s})]})}),t.jsxs(q,{"code-path":"src/pages/HostMonitor.tsx:194:9",value:"network",className:"mt-3 space-y-3",children:[t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:195:11",className:"grid grid-cols-1 md:grid-cols-4 gap-3",children:[t.jsx(y,{"code-path":"src/pages/HostMonitor.tsx:196:13",title:"TCP EST",value:A("tcp"),icon:t.jsx(st,{"code-path":"src/pages/HostMonitor.tsx:196:78",className:"h-4 w-4 text-purple-400"}),data:u.tcpEst,color:"#8b5cf6",unit:"个",domain:[0,"auto"],aggType:s}),t.jsx(y,{"code-path":"src/pages/HostMonitor.tsx:198:13",title:"TCP TIME_WAIT",value:A("tw"),icon:t.jsx(ot,{"code-path":"src/pages/HostMonitor.tsx:198:83",className:"h-4 w-4 text-amber-400"}),data:u.tcpTW,color:"#f59e0b",unit:"个",domain:[0,"auto"],aggType:s}),t.jsx(y,{"code-path":"src/pages/HostMonitor.tsx:200:13",title:"TCP CLOSE_WAIT",value:f?.tcp_close_wait!=null?String(f.tcp_close_wait):"--",icon:t.jsx(ot,{"code-path":"src/pages/HostMonitor.tsx:200:139",className:"h-4 w-4 text-red-400"}),data:u.tcpCW,color:"#ef4444",unit:"个",domain:[0,"auto"],aggType:s}),t.jsx(y,{"code-path":"src/pages/HostMonitor.tsx:202:13",title:"TCP 总连接",value:f?String((f.tcp_established||0)+(f.tcp_time_wait||0)+(f.tcp_close_wait||0)):"--",icon:t.jsx(st,{"code-path":"src/pages/HostMonitor.tsx:202:169",className:"h-4 w-4 text-cyan-400"}),data:u.connTotal,color:"#22d3ee",unit:"个",domain:[0,"auto"],aggType:s})]}),t.jsx(ce,{"code-path":"src/pages/HostMonitor.tsx:205:11",title:"网卡带宽吞吐",currentRx:f?.net_rx_bps!=null?rt(f.net_rx_bps):"--",currentTx:f?.net_tx_bps!=null?rt(f.net_tx_bps):"--",rxData:u.rx,txData:u.tx,aggType:s,unit:"KB/s"}),t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:212:11",className:"grid grid-cols-1 md:grid-cols-2 gap-3 mt-3",children:[t.jsx(y,{"code-path":"src/pages/HostMonitor.tsx:213:13",title:"网卡接收错误",value:f?.net_rx_errors!=null?String(f.net_rx_errors):"--",icon:t.jsx(ht,{"code-path":"src/pages/HostMonitor.tsx:213:129",className:"h-4 w-4 text-red-400"}),data:u.rxErr,color:"#ef4444",unit:"个",domain:[0,"auto"],aggType:s}),t.jsx(y,{"code-path":"src/pages/HostMonitor.tsx:215:13",title:"网卡发送错误",value:f?.net_tx_errors!=null?String(f.net_tx_errors):"--",icon:t.jsx(ht,{"code-path":"src/pages/HostMonitor.tsx:215:129",className:"h-4 w-4 text-orange-400"}),data:u.txErr,color:"#f97316",unit:"个",domain:[0,"auto"],aggType:s})]})]}),t.jsx(q,{"code-path":"src/pages/HostMonitor.tsx:220:9",value:"ports",className:"mt-3 space-y-3",children:t.jsx(C,{"code-path":"src/pages/HostMonitor.tsx:221:11",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:t.jsxs(k,{"code-path":"src/pages/HostMonitor.tsx:222:13",className:"p-4",children:[t.jsxs("h3",{"code-path":"src/pages/HostMonitor.tsx:223:15",className:"text-xs font-medium text-[var(--dg-text-primary)] mb-3 flex items-center gap-2",children:[t.jsx(V,{"code-path":"src/pages/HostMonitor.tsx:224:17",className:"h-4 w-4 text-emerald-400"}),"监听端口 ",Y.length,t.jsxs("span",{"code-path":"src/pages/HostMonitor.tsx:225:17",className:"ml-auto flex items-center gap-2",children:[N==="blacklist"&&M.length>0&&t.jsxs(Q,{"code-path":"src/pages/HostMonitor.tsx:227:21",variant:"outline",className:"text-[10px] text-amber-400 border-amber-500/30",children:["黑名单: ",M.join(",")]}),N==="whitelist"&&t.jsx(Q,{"code-path":"src/pages/HostMonitor.tsx:232:21",variant:"outline",className:"text-[10px] text-blue-400 border-blue-500/30",children:"白名单模式"}),t.jsx(L,{"code-path":"src/pages/HostMonitor.tsx:236:19",variant:"outline",size:"sm",className:"h-6 text-[10px] px-2",onClick:()=>{it(),E(!0)},children:"策略配置"})]})]}),Y.length===0?t.jsx("div",{"code-path":"src/pages/HostMonitor.tsx:243:17",className:"text-center py-6 text-xs text-[var(--dg-text-muted)] border border-dashed border-[var(--dg-border)] rounded-lg",children:"暂无端口数据"}):t.jsx("div",{"code-path":"src/pages/HostMonitor.tsx:247:17",className:"overflow-x-auto",children:t.jsxs("table",{"code-path":"src/pages/HostMonitor.tsx:248:19",className:"w-full text-xs",children:[t.jsx("thead",{"code-path":"src/pages/HostMonitor.tsx:249:21",children:t.jsxs("tr",{"code-path":"src/pages/HostMonitor.tsx:250:23",className:"text-[var(--dg-text-muted)] border-b border-[var(--dg-border)]",children:[t.jsx("th",{"code-path":"src/pages/HostMonitor.tsx:251:25",className:"py-1.5 text-left font-medium",children:"端口"}),t.jsx("th",{"code-path":"src/pages/HostMonitor.tsx:252:25",className:"py-1.5 text-left font-medium",children:"协议"}),t.jsx("th",{"code-path":"src/pages/HostMonitor.tsx:253:25",className:"py-1.5 text-left font-medium",children:"进程"}),t.jsx("th",{"code-path":"src/pages/HostMonitor.tsx:254:25",className:"py-1.5 text-right font-medium",children:"状态"})]})}),t.jsx("tbody",{"code-path":"src/pages/HostMonitor.tsx:257:21",children:Y.map((r,T)=>t.jsxs("tr",{"code-path":"src/pages/HostMonitor.tsx:259:25",className:"border-b border-[var(--dg-border)]/30 hover:bg-slate-800/30 transition-colors",children:[t.jsx("td",{"code-path":"src/pages/HostMonitor.tsx:260:27",className:"py-1.5 font-mono text-[var(--dg-text-primary)]",children:r.port}),t.jsx("td",{"code-path":"src/pages/HostMonitor.tsx:261:27",className:"py-1.5",children:t.jsx(Q,{"code-path":"src/pages/HostMonitor.tsx:262:29",variant:"outline",className:"text-[10px] font-mono",children:r.protocol||"tcp"})}),t.jsx("td",{"code-path":"src/pages/HostMonitor.tsx:266:27",className:"py-1.5 font-mono text-[var(--dg-text-muted)]",children:r.process||"—"}),t.jsx("td",{"code-path":"src/pages/HostMonitor.tsx:267:27",className:"py-1.5 text-right",children:t.jsx(Q,{"code-path":"src/pages/HostMonitor.tsx:268:29",variant:"default",className:"text-[10px] bg-emerald-500/20 text-emerald-400 border-emerald-500/30",children:"LISTEN"})})]},T))})]})})]})})}),t.jsxs(q,{"code-path":"src/pages/HostMonitor.tsx:282:9",value:"process",className:"mt-3 space-y-3",children:[t.jsx(C,{"code-path":"src/pages/HostMonitor.tsx:283:11",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:t.jsxs(k,{"code-path":"src/pages/HostMonitor.tsx:284:13",className:"p-4",children:[t.jsxs("h3",{"code-path":"src/pages/HostMonitor.tsx:285:15",className:"text-xs font-medium text-[var(--dg-text-primary)] mb-3 flex items-center gap-2",children:[t.jsx(_t,{"code-path":"src/pages/HostMonitor.tsx:286:17",className:"h-4 w-4 text-cyan-400"}),"进程 TOP ",dt.length]}),dt.length===0?t.jsx("div",{"code-path":"src/pages/HostMonitor.tsx:289:17",className:"text-center py-6 text-xs text-[var(--dg-text-muted)] border border-dashed border-[var(--dg-border)] rounded-lg",children:"Agent v2.0+ 支持,等待数据上报…"}):t.jsx("div",{"code-path":"src/pages/HostMonitor.tsx:293:17",className:"overflow-x-auto",children:t.jsxs("table",{"code-path":"src/pages/HostMonitor.tsx:294:19",className:"w-full text-xs",children:[t.jsx("thead",{"code-path":"src/pages/HostMonitor.tsx:295:21",children:t.jsxs("tr",{"code-path":"src/pages/HostMonitor.tsx:296:23",className:"text-[var(--dg-text-muted)] border-b border-[var(--dg-border)]",children:[t.jsx("th",{"code-path":"src/pages/HostMonitor.tsx:297:25",className:"py-1.5 text-left font-medium w-[40%]",children:"进程名称 / CMD"}),t.jsx("th",{"code-path":"src/pages/HostMonitor.tsx:298:25",className:"py-1.5 text-right font-medium w-[8%]",children:"PID"}),t.jsx("th",{"code-path":"src/pages/HostMonitor.tsx:299:25",className:"py-1.5 text-right font-medium w-[16%]",children:"内存使用率(%)"}),t.jsx("th",{"code-path":"src/pages/HostMonitor.tsx:300:25",className:"py-1.5 text-right font-medium w-[16%]",children:"CPU使用率(%)"}),t.jsx("th",{"code-path":"src/pages/HostMonitor.tsx:301:25",className:"py-1.5 text-right font-medium w-[20%]",children:"打开文件数"})]})}),t.jsx("tbody",{"code-path":"src/pages/HostMonitor.tsx:304:21",children:dt.map((r,T)=>{const R=r.cmdline||r.name||"?",Z=r.cpu_pct!=null?Number(r.cpu_pct):null,tt=r.mem_pct!=null?Number(r.mem_pct):null;return t.jsxs("tr",{"code-path":"src/pages/HostMonitor.tsx:310:27",className:"border-b border-[var(--dg-border)]/30 hover:bg-slate-800/30 transition-colors",children:[t.jsx("td",{"code-path":"src/pages/HostMonitor.tsx:311:29",className:"py-1.5 pr-2",children:t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:312:31",className:"flex items-center gap-1 group/cmd",children:[t.jsx("span",{"code-path":"src/pages/HostMonitor.tsx:313:33",className:"font-mono text-[var(--dg-text-primary)] truncate max-w-[320px] inline-block align-middle",title:R,children:R}),t.jsx("button",{"code-path":"src/pages/HostMonitor.tsx:316:33",className:"opacity-0 group-hover/cmd:opacity-100 transition-opacity p-0.5 hover:text-cyan-400 shrink-0",title:"复制命令行",onClick:async Bt=>{Bt.stopPropagation();try{await navigator.clipboard.writeText(R)}catch{const G=document.createElement("textarea");G.value=R,G.style.position="fixed",G.style.opacity="0",document.body.appendChild(G),G.select(),document.execCommand("copy"),document.body.removeChild(G)}},children:t.jsxs("svg",{"code-path":"src/pages/HostMonitor.tsx:331:35",className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("rect",{"code-path":"src/pages/HostMonitor.tsx:332:37",x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),t.jsx("path",{"code-path":"src/pages/HostMonitor.tsx:333:37",d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]})}),t.jsx("td",{"code-path":"src/pages/HostMonitor.tsx:338:29",className:"py-1.5 text-right font-mono text-[var(--dg-text-muted)]",children:r.pid}),t.jsx("td",{"code-path":"src/pages/HostMonitor.tsx:339:29",className:"py-1.5 text-right font-mono",children:t.jsx("span",{"code-path":"src/pages/HostMonitor.tsx:340:31",className:tt!=null&&tt>50?"text-rose-400":"text-cyan-400",children:tt!=null?tt.toFixed(2):"--"})}),t.jsx("td",{"code-path":"src/pages/HostMonitor.tsx:344:29",className:"py-1.5 text-right font-mono",children:t.jsx("span",{"code-path":"src/pages/HostMonitor.tsx:345:31",className:Z!=null&&Z>50?"text-rose-400":"text-[var(--dg-text-primary)]",children:Z!=null?Z.toFixed(2):"--"})}),t.jsx("td",{"code-path":"src/pages/HostMonitor.tsx:349:29",className:"py-1.5 text-right font-mono text-[var(--dg-text-muted)]",children:r.fd_count??"--"})]},T)})})]})})]})}),t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:360:11",className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[t.jsx(C,{"code-path":"src/pages/HostMonitor.tsx:361:13",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:t.jsxs(k,{"code-path":"src/pages/HostMonitor.tsx:362:15",className:"p-4",children:[t.jsxs("h3",{"code-path":"src/pages/HostMonitor.tsx:363:17",className:"text-xs font-medium text-[var(--dg-text-primary)] mb-3 flex items-center gap-2",children:[t.jsx(W,{"code-path":"src/pages/HostMonitor.tsx:364:19",className:"h-4 w-4 text-violet-400"}),"FD 文件句柄"]}),I?.allocated!=null?t.jsxs(t.Fragment,{children:[t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:368:21",className:"flex items-center gap-4 mb-3 text-xs",children:[t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:369:23",children:[t.jsx("span",{"code-path":"src/pages/HostMonitor.tsx:370:25",className:"text-[var(--dg-text-muted)]",children:"已分配 "}),t.jsx("span",{"code-path":"src/pages/HostMonitor.tsx:371:25",className:"font-mono text-[var(--dg-text-primary)] font-semibold",children:I.allocated.toLocaleString()})]}),t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:373:23",children:[t.jsx("span",{"code-path":"src/pages/HostMonitor.tsx:374:25",className:"text-[var(--dg-text-muted)]",children:"上限 "}),t.jsx("span",{"code-path":"src/pages/HostMonitor.tsx:375:25",className:"font-mono text-[var(--dg-text-primary)] font-semibold",children:I.max===-1?"无限制":I.max?.toLocaleString()||"—"})]}),t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:377:23",children:[t.jsx("span",{"code-path":"src/pages/HostMonitor.tsx:378:25",className:"text-[var(--dg-text-muted)]",children:"使用率 "}),t.jsx("span",{"code-path":"src/pages/HostMonitor.tsx:379:25",className:`font-mono font-semibold ${I.usage_pct>80?"text-rose-400":"text-violet-400"}`,children:I.usage_pct!=null?`${I.usage_pct.toFixed(1)}%`:"—"})]})]}),u.fd.length>0&&t.jsx("div",{"code-path":"src/pages/HostMonitor.tsx:385:23",className:"h-[120px]",children:t.jsx(mt,{"code-path":"src/pages/HostMonitor.tsx:386:25",width:"100%",height:"100%",children:t.jsxs(gt,{"code-path":"src/pages/HostMonitor.tsx:387:27",data:u.fd,children:[t.jsx(ut,{"code-path":"src/pages/HostMonitor.tsx:388:29",strokeDasharray:"3 3",stroke:"var(--dg-border)"}),t.jsx(bt,{"code-path":"src/pages/HostMonitor.tsx:389:29",dataKey:"time",tick:{fontSize:10,fill:"var(--dg-text-muted)"},interval:"preserveStartEnd"}),t.jsx(jt,{"code-path":"src/pages/HostMonitor.tsx:390:29",tick:{fontSize:10,fill:"var(--dg-text-muted)"},unit:"%",domain:[0,"auto"]}),t.jsx(vt,{"code-path":"src/pages/HostMonitor.tsx:391:29",contentStyle:{background:"#1e293b",border:"1px solid #334155",borderRadius:6,fontSize:11}}),t.jsx("defs",{"code-path":"src/pages/HostMonitor.tsx:392:29",children:t.jsxs("linearGradient",{"code-path":"src/pages/HostMonitor.tsx:393:31",id:"fdGrad",x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{"code-path":"src/pages/HostMonitor.tsx:394:33",offset:"0%",stopColor:"#a78bfa",stopOpacity:.3}),t.jsx("stop",{"code-path":"src/pages/HostMonitor.tsx:395:33",offset:"100%",stopColor:"#a78bfa",stopOpacity:.05})]})}),t.jsx(at,{"code-path":"src/pages/HostMonitor.tsx:398:29",type:"monotone",dataKey:s,stroke:"#a78bfa",strokeWidth:1.5,fill:"url(#fdGrad)",name:"FD使用率"})]})})})]}):t.jsx("div",{"code-path":"src/pages/HostMonitor.tsx:405:19",className:"text-center py-4 text-xs text-[var(--dg-text-muted)]",children:"等待数据…"})]})}),t.jsx(C,{"code-path":"src/pages/HostMonitor.tsx:410:13",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:t.jsxs(k,{"code-path":"src/pages/HostMonitor.tsx:411:15",className:"p-4",children:[t.jsxs("h3",{"code-path":"src/pages/HostMonitor.tsx:412:17",className:"text-xs font-medium text-[var(--dg-text-primary)] mb-3 flex items-center gap-2",children:[t.jsx(Ft,{"code-path":"src/pages/HostMonitor.tsx:413:19",className:"h-4 w-4 text-emerald-400"}),"上下文切换"]}),S?.ctx_per_sec!=null?t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:416:19",className:"space-y-4",children:[t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:417:21",className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:418:23",className:"bg-[var(--dg-bg-primary)] rounded-lg p-3 text-center",children:[t.jsx("div",{"code-path":"src/pages/HostMonitor.tsx:419:25",className:"text-[10px] text-[var(--dg-text-muted)] mb-1",children:"CTX 切换/秒"}),t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:420:25",className:"text-lg font-bold font-mono text-emerald-400",children:[(S.ctx_per_sec/1e6).toFixed(1),t.jsx("span",{"code-path":"src/pages/HostMonitor.tsx:421:66",className:"text-xs font-normal text-[var(--dg-text-muted)] ml-0.5",children:"M"})]}),t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:423:25",className:"text-[10px] text-[var(--dg-text-muted)] mt-1 font-mono",children:[S.ctx_per_sec?.toLocaleString()," 次"]})]}),t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:425:23",className:"bg-[var(--dg-bg-primary)] rounded-lg p-3 text-center",children:[t.jsx("div",{"code-path":"src/pages/HostMonitor.tsx:426:25",className:"text-[10px] text-[var(--dg-text-muted)] mb-1",children:"IRQ 中断/秒"}),t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:427:25",className:"text-lg font-bold font-mono text-amber-400",children:[(S.irq_per_sec/1e6).toFixed(1),t.jsx("span",{"code-path":"src/pages/HostMonitor.tsx:428:66",className:"text-xs font-normal text-[var(--dg-text-muted)] ml-0.5",children:"M"})]}),t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:430:25",className:"text-[10px] text-[var(--dg-text-muted)] mt-1 font-mono",children:[S.irq_per_sec?.toLocaleString()," 次"]})]})]}),t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:433:21",className:"space-y-1",children:[t.jsxs("div",{"code-path":"src/pages/HostMonitor.tsx:434:23",className:"flex justify-between text-[10px]",children:[t.jsx("span",{"code-path":"src/pages/HostMonitor.tsx:435:25",className:"text-emerald-400",children:"CTX"}),t.jsx("span",{"code-path":"src/pages/HostMonitor.tsx:436:25",className:"text-amber-400",children:"IRQ"})]}),t.jsx("div",{"code-path":"src/pages/HostMonitor.tsx:438:23",className:"h-2 bg-[var(--dg-bg-primary)] rounded-full overflow-hidden flex",children:S.ctx_per_sec+S.irq_per_sec>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{"code-path":"src/pages/HostMonitor.tsx:441:29",className:"h-full bg-emerald-500/60 rounded-l-full transition-all",style:{width:`${(S.ctx_per_sec/(S.ctx_per_sec+S.irq_per_sec)*100).toFixed(1)}%`}}),t.jsx("div",{"code-path":"src/pages/HostMonitor.tsx:443:29",className:"h-full bg-amber-500/60 rounded-r-full transition-all",style:{width:`${(S.irq_per_sec/(S.ctx_per_sec+S.irq_per_sec)*100).toFixed(1)}%`}})]})})]})]}):t.jsx("div",{"code-path":"src/pages/HostMonitor.tsx:451:19",className:"text-center py-4 text-xs text-[var(--dg-text-muted)]",children:"等待数据…"})]})})]})]}),t.jsx(xe,{"code-path":"src/pages/HostMonitor.tsx:458:9",selectedHost:l,serverInfo:P,latest:b,heartbeatInfo:It,portInfoCount:Y.length}),t.jsx(ie,{"code-path":"src/pages/HostMonitor.tsx:466:9",selectedHost:l})]}),t.jsx(le,{"code-path":"src/pages/HostMonitor.tsx:469:7",open:o,onOpenChange:E,portPolicyMode:N,onModeChange:D,portWhitelist:M,onWhitelistChange:F,onSave:O,saving:X})]})}export{He as HostMonitor}; diff --git a/backend/static/assets/K8sShortcutRedirect-L8Wq0IVi.js b/backend/static/assets/K8sShortcutRedirect-L8Wq0IVi.js deleted file mode 100644 index 6a457a5..0000000 --- a/backend/static/assets/K8sShortcutRedirect-L8Wq0IVi.js +++ /dev/null @@ -1 +0,0 @@ -import{r as n,j as s}from"./vendor-codemirror-B1SGo4xl.js";import{i as a}from"./index-Dungj95X.js";import{k as i}from"./index-drGq01ok.js";import{L as u}from"./vendor-icons-DmqcWdzX.js";function x({target:r}){const e=a();return n.useEffect(()=>{i.getClusters().then(c=>{const t=c?.list||[];if(t.length>0){const o=t[0].code||String(t[0].id);e(`/kubernetes/${o}/${r}`,{replace:!0})}else e("/kubernetes",{replace:!0})}).catch(()=>e("/kubernetes",{replace:!0}))},[e,r]),s.jsxs("div",{"code-path":"src/components/kubernetes/K8sShortcutRedirect.tsx:31:5",className:"flex flex-col items-center justify-center py-24 text-slate-500 gap-2",children:[s.jsx(u,{"code-path":"src/components/kubernetes/K8sShortcutRedirect.tsx:32:7",className:"h-6 w-6 animate-spin"}),s.jsx("span",{"code-path":"src/components/kubernetes/K8sShortcutRedirect.tsx:33:7",className:"text-sm",children:"正在跳转..."})]})}export{x as default}; diff --git a/backend/static/assets/KubernetesClusters-XXR1jnN_.js b/backend/static/assets/KubernetesClusters-XXR1jnN_.js deleted file mode 100644 index a0c8dee..0000000 --- a/backend/static/assets/KubernetesClusters-XXR1jnN_.js +++ /dev/null @@ -1,10 +0,0 @@ -import{r,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{B as T,Q as oe,N as Pe,y as Te,w as le,R as Me,x as q,z as Y,T as Ee,A as X,P as Ae,C as Ie,m as M,D as ue,a as de,b as Fe,c as ie,d as xe,e as Ge,t as I,o as Le,ab as Oe,ac as ze,ad as Be,ae as Ue,af as ee,ag as F}from"./index-Dungj95X.js";import{C as G,b as W,c as $,d as pe,a as L}from"./card-BIfzBCEy.js";import{I as z}from"./input-CXoUQQLm.js";import{B as y}from"./badge-CGJlVD3L.js";import{k as w}from"./index-drGq01ok.js";import{T as We,a as $e,b as E,c as A}from"./tabs-D87nAyJR.js";import{i as me,a as be,R as V,aK as Ve,r as qe,L as he,at as He,au as Xe,X as Ye,P as Je,S as Qe,aP as Ze,x as et,p as tt,k as st,v as te,T as rt,l as nt,y as at}from"./vendor-icons-DmqcWdzX.js";import{R as ct,A as ot,C as lt,X as ut,Y as dt,T as it,a as se}from"./AreaChart-yrR-Mxho.js";import{T as re}from"./textarea-BxfjmLq5.js";import{L as P}from"./label-CMpUoC87.js";import{u as xt}from"./index-5FEebgvX.js";import{x as pt,a as mt}from"./vendor-xterm-20M9KZE1.js";function bt({cluster:a,onClose:p}){const[n,g]=r.useState([]),[s,l]=r.useState([]),[x,j]=r.useState([]),[k,C]=r.useState([]),[b,f]=r.useState([]),h=r.useMemo(()=>{if(!n||n.length===0)return{cpuPct:0,memPct:0};let t=0,u=0,v=0;for(const K of n){const o=K.cpu||0,i=K.cpu_usage_m?parseFloat(String(K.cpu_usage_m).replace("m","")):0,N=o>0?i/1e3/o*100:0,S=K.memory_mb||0,O=K.mem_usage_mi?parseFloat(String(K.mem_usage_mi).replace("Mi","").replace("Ki","")):0,B=K.mem_usage_mi?.includes?.("Ki")?O/1024:K.mem_usage_mi?.includes?.("Gi")?O*1024:O,U=S>0?B/S*100:0;(N>0||U>0)&&(t+=N,u+=U,v++)}return{cpuPct:v>0?t/v:0,memPct:v>0?u/v:0}},[n]),m=r.useMemo(()=>{const t=Math.max(0,Math.min(100,Number(h.cpuPct.toFixed(1)))),u=Math.max(0,Math.min(100,Number(h.memPct.toFixed(1))));return[{time:"10m前",cpu:Math.max(0,t*.72),memory:Math.max(0,u*.78)},{time:"7m前",cpu:Math.max(0,t*.82),memory:Math.max(0,u*.85)},{time:"4m前",cpu:Math.max(0,t*.9),memory:Math.max(0,u*.93)},{time:"2m前",cpu:Math.max(0,t*.96),memory:Math.max(0,u*.97)},{time:"现在",cpu:t,memory:u}]},[h]),d=async t=>{try{const[u,v,K,o,i]=await Promise.all([w.getNodes(t).catch(()=>[]),w.getPods(t).catch(()=>[]),w.getDeployments(t).catch(()=>[]),w.getServices(t).catch(()=>[]),w.getIngresses(t).catch(()=>[])]),N=S=>Array.isArray(S)?S:S?.list||[];g(N(u)),l(N(v)),j(N(K)),C(N(o)),f(N(i))}catch(u){console.error("加载集群详情失败:",u)}};return r.useEffect(()=>{a?.id&&d(a.id)},[a?.id]),e.jsxs(G,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:98:5",className:"bg-slate-900 border-slate-800",children:[e.jsx(W,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:99:7",children:e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:100:9",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:101:11",className:"flex items-center gap-3",children:[e.jsx(me,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:102:13",className:"h-6 w-6 text-blue-400"}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:103:13",children:[e.jsx($,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:104:15",className:"text-slate-100",children:a.name}),e.jsxs(pe,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:105:15",className:"text-slate-500",children:[a.version," · ",a.node_count||0," 节点 · 创建于"," ",a.created_at?new Date(a.created_at).toLocaleDateString():"-"]})]})]}),e.jsxs(T,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:111:11",variant:"ghost",size:"sm",className:"text-slate-400 hover:text-slate-100",onClick:p,children:[e.jsx(be,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:117:13",className:"h-4 w-4 mr-2"}),"关闭"]})]})}),e.jsx(L,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:122:7",children:e.jsxs(We,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:123:9",defaultValue:"overview",className:"w-full",children:[e.jsxs($e,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:124:11",className:"bg-slate-800 border border-slate-700 flex-wrap h-auto",children:[e.jsx(E,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:125:13",value:"overview",className:"data-[state=active]:bg-slate-700",children:"概览"}),e.jsxs(E,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:128:13",value:"nodes",className:"data-[state=active]:bg-slate-700",children:["节点 (",n.length,")"]}),e.jsxs(E,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:131:13",value:"pods",className:"data-[state=active]:bg-slate-700",children:["Pod (",s.length,")"]}),e.jsxs(E,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:134:13",value:"deployments",className:"data-[state=active]:bg-slate-700",children:["Deployment (",x.length,")"]}),e.jsxs(E,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:137:13",value:"services",className:"data-[state=active]:bg-slate-700",children:["Service (",k.length,")"]}),e.jsxs(E,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:140:13",value:"ingresses",className:"data-[state=active]:bg-slate-700",children:["Ingress (",b.length,")"]}),e.jsx(E,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:143:13",value:"events",className:"data-[state=active]:bg-slate-700",children:"事件"})]}),e.jsx(A,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:148:11",value:"overview",className:"mt-4 space-y-4",children:e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:149:13",className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(G,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:150:15",className:"bg-slate-800/50 border-slate-700",children:[e.jsx(W,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:151:17",className:"pb-2",children:e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:152:19",className:"flex items-center justify-between w-full",children:[e.jsx($,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:153:21",className:"text-sm text-slate-400",children:"资源使用趋势(模拟最近变化)"}),e.jsx(T,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:154:21",variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-slate-400 hover:text-slate-200",onClick:()=>a?.id&&d(a.id),title:"刷新节点指标",children:e.jsx(V,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:161:23",className:"h-3.5 w-3.5"})})]})}),e.jsxs(L,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:165:17",children:[e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:166:19",className:"h-[200px]",children:e.jsx(ct,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:167:21",width:"100%",height:"100%",children:e.jsxs(ot,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:168:23",data:m,margin:{top:5,right:10,left:0,bottom:5},children:[e.jsxs("defs",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:169:25",children:[e.jsxs("linearGradient",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:170:27",id:"colorCpu",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:171:29",offset:"5%",stopColor:"#3b82f6",stopOpacity:.35}),e.jsx("stop",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:172:29",offset:"95%",stopColor:"#3b82f6",stopOpacity:.05})]}),e.jsxs("linearGradient",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:174:27",id:"colorMemory",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:175:29",offset:"5%",stopColor:"#10b981",stopOpacity:.35}),e.jsx("stop",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:176:29",offset:"95%",stopColor:"#10b981",stopOpacity:.05})]})]}),e.jsx(lt,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:179:25",strokeDasharray:"2 2",stroke:"#1e293b"}),e.jsx(ut,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:180:25",dataKey:"time",stroke:"#475569",fontSize:11,tickLine:!1}),e.jsx(dt,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:181:25",stroke:"#475569",fontSize:11,domain:[0,100],unit:"%",tickLine:!1}),e.jsx(it,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:182:25",contentStyle:{backgroundColor:"#0f172a",border:"1px solid #1e293b",borderRadius:"6px",color:"#f8fafc",fontSize:"12px"}}),e.jsx(se,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:191:25",type:"monotone",dataKey:"cpu",stroke:"#3b82f6",strokeWidth:2,fill:"url(#colorCpu)",dot:!1,activeDot:{r:3,fill:"#3b82f6"},name:"CPU(%)"}),e.jsx(se,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:201:25",type:"monotone",dataKey:"memory",stroke:"#10b981",strokeWidth:2,fill:"url(#colorMemory)",dot:!1,activeDot:{r:3,fill:"#10b981"},name:"内存(%)"})]})})}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:214:19",className:"flex justify-center gap-6 mt-2 text-xs text-slate-400",children:[e.jsxs("span",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:215:21",children:["CPU: ",e.jsxs("span",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:215:32",className:"text-blue-400 font-bold",children:[h.cpuPct.toFixed(1),"%"]})]}),e.jsxs("span",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:216:21",children:["内存: ",e.jsxs("span",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:216:31",className:"text-emerald-400 font-bold",children:[h.memPct.toFixed(1),"%"]})]})]})]})]}),e.jsxs(G,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:221:15",className:"bg-slate-800/50 border-slate-700",children:[e.jsx(W,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:222:17",className:"pb-2",children:e.jsx($,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:223:19",className:"text-sm text-slate-400",children:"资源分布"})}),e.jsx(L,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:225:17",children:e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:226:19",className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:227:21",className:"text-center p-4 rounded-lg bg-slate-800",children:[e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:228:23",className:"text-3xl font-bold text-blue-400",children:a.pod_count||0}),e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:229:23",className:"text-sm text-slate-500 mt-1",children:"Pod"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:231:21",className:"text-center p-4 rounded-lg bg-slate-800",children:[e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:232:23",className:"text-3xl font-bold text-emerald-400",children:a.service_count||0}),e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:233:23",className:"text-sm text-slate-500 mt-1",children:"Service"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:235:21",className:"text-center p-4 rounded-lg bg-slate-800",children:[e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:236:23",className:"text-3xl font-bold text-purple-400",children:a.deployment_count||0}),e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:237:23",className:"text-sm text-slate-500 mt-1",children:"Deployment"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:239:21",className:"text-center p-4 rounded-lg bg-slate-800",children:[e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:240:23",className:"text-3xl font-bold text-amber-400",children:a.node_count||0}),e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:241:23",className:"text-sm text-slate-500 mt-1",children:"节点"})]})]})})]})]})}),e.jsx(A,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:249:11",value:"nodes",className:"mt-4",children:e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:250:13",className:"border rounded-lg border-slate-700 overflow-hidden",children:e.jsxs("table",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:251:15",className:"w-full",children:[e.jsx("thead",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:252:17",className:"bg-slate-800",children:e.jsxs("tr",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:253:19",children:[e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:254:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"名称"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:255:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"角色"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:256:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"状态"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:257:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"CPU"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:258:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"内存"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:259:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"Pod"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:260:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"操作系统"})]})}),e.jsx("tbody",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:263:17",className:"divide-y divide-slate-800",children:n.length===0?e.jsx("tr",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:265:21",children:e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:266:23",colSpan:7,className:"px-4 py-8 text-center text-slate-500",children:"暂无节点数据"})}):n.map(t=>e.jsxs("tr",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:270:21",className:"hover:bg-slate-800/50",children:[e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:271:23",className:"px-4 py-3 text-sm text-slate-200",children:t.name}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:272:23",className:"px-4 py-3",children:e.jsx(y,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:273:25",variant:"outline",className:t.role==="master"?"border-purple-500/30 text-purple-400 bg-purple-500/10":"border-blue-500/30 text-blue-400 bg-blue-500/10",children:t.role==="master"?"Master":"Worker"})}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:284:23",className:"px-4 py-3",children:e.jsx(y,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:285:25",variant:"outline",className:(t.status||"").toLowerCase()==="ready"?"border-emerald-500/30 text-emerald-400 bg-emerald-500/10":"border-red-500/30 text-red-400 bg-red-500/10",children:(t.status||"").toLowerCase()==="ready"?"Ready":"NotReady"})}),e.jsxs("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:296:23",className:"px-4 py-3 text-sm text-slate-300",children:[t.cpu_usage_m||"0m"," / ",t.cpu,"核"]}),e.jsxs("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:299:23",className:"px-4 py-3 text-sm text-slate-300",children:[t.mem_usage_mi||"0Mi"," / ",t.memory_mb?(t.memory_mb/1024).toFixed(0)+"GB":"-"]}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:302:23",className:"px-4 py-3 text-sm text-slate-300",children:t.max_pods??0}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:303:23",className:"px-4 py-3 text-sm text-slate-400",children:t.os})]},t.id||t.name))})]})})}),e.jsx(A,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:312:11",value:"pods",className:"mt-4",children:e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:313:13",className:"border rounded-lg border-slate-700 overflow-hidden",children:e.jsxs("table",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:314:15",className:"w-full",children:[e.jsx("thead",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:315:17",className:"bg-slate-800",children:e.jsxs("tr",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:316:19",children:[e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:317:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"名称"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:318:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"命名空间"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:319:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"状态"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:320:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"重启次数"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:321:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"CPU"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:322:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"内存"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:323:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"节点"})]})}),e.jsx("tbody",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:326:17",className:"divide-y divide-slate-800",children:s.length===0?e.jsx("tr",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:328:21",children:e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:329:23",colSpan:7,className:"px-4 py-8 text-center text-slate-500",children:"暂无Pod数据"})}):s.map(t=>e.jsxs("tr",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:333:21",className:"hover:bg-slate-800/50",children:[e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:334:23",className:"px-4 py-3 text-sm text-slate-200",children:t.name}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:335:23",className:"px-4 py-3",children:e.jsx(y,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:336:25",variant:"outline",className:"border-slate-700 text-slate-400",children:t.namespace})}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:340:23",className:"px-4 py-3",children:e.jsx(y,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:341:25",variant:"outline",className:(t.status||"").toLowerCase()==="running"?"border-emerald-500/30 text-emerald-400 bg-emerald-500/10":(t.status||"").toLowerCase()==="pending"?"border-amber-500/30 text-amber-400 bg-amber-500/10":"border-red-500/30 text-red-400 bg-red-500/10",children:t.status})}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:354:23",className:"px-4 py-3 text-sm text-slate-300",children:t.restart_count??0}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:355:23",className:"px-4 py-3 text-sm text-slate-300",children:t.cpu_usage_m||"0m"}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:356:23",className:"px-4 py-3 text-sm text-slate-300",children:t.mem_usage_mi||"0Mi"}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:357:23",className:"px-4 py-3 text-sm text-slate-400",children:t.node_name})]},t.id||t.name))})]})})}),e.jsx(A,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:366:11",value:"deployments",className:"mt-4",children:e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:367:13",className:"border rounded-lg border-slate-700 overflow-hidden",children:e.jsxs("table",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:368:15",className:"w-full",children:[e.jsx("thead",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:369:17",className:"bg-slate-800",children:e.jsxs("tr",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:370:19",children:[e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:371:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"名称"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:372:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"命名空间"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:373:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"副本数"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:374:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"可用副本"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:375:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"镜像"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:376:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"创建时间"})]})}),e.jsx("tbody",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:379:17",className:"divide-y divide-slate-800",children:x.length===0?e.jsx("tr",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:381:21",children:e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:382:23",colSpan:6,className:"px-4 py-8 text-center text-slate-500",children:"暂无Deployment数据"})}):x.map(t=>e.jsxs("tr",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:386:21",className:"hover:bg-slate-800/50",children:[e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:387:23",className:"px-4 py-3 text-sm text-slate-200",children:t.name}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:388:23",className:"px-4 py-3",children:e.jsx(y,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:389:25",variant:"outline",className:"border-slate-700 text-slate-400",children:t.namespace})}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:393:23",className:"px-4 py-3 text-sm text-slate-300",children:t.replicas}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:394:23",className:"px-4 py-3",children:e.jsxs("span",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:395:25",className:`text-sm ${(t.available_replicas??t.availableReplicas)===t.replicas?"text-emerald-400":"text-amber-400"}`,children:[t.available_replicas??t.availableReplicas," / ",t.replicas]})}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:399:23",className:"px-4 py-3 text-sm text-slate-400 truncate max-w-[200px]",children:t.image}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:400:23",className:"px-4 py-3 text-sm text-slate-400",children:t.created_at||t.createdAt})]},t.id||t.name))})]})})}),e.jsx(A,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:409:11",value:"services",className:"mt-4",children:e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:410:13",className:"border rounded-lg border-slate-700 overflow-hidden",children:e.jsxs("table",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:411:15",className:"w-full",children:[e.jsx("thead",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:412:17",className:"bg-slate-800",children:e.jsxs("tr",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:413:19",children:[e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:414:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"名称"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:415:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"命名空间"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:416:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"类型"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:417:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"ClusterIP"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:418:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"端口"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:419:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"Selector"})]})}),e.jsx("tbody",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:422:17",className:"divide-y divide-slate-800",children:k.length===0?e.jsx("tr",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:424:21",children:e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:425:23",colSpan:6,className:"px-4 py-8 text-center text-slate-500",children:"暂无Service数据"})}):k.map(t=>e.jsxs("tr",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:429:21",className:"hover:bg-slate-800/50",children:[e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:430:23",className:"px-4 py-3 text-sm text-slate-200",children:t.name}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:431:23",className:"px-4 py-3",children:e.jsx(y,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:432:25",variant:"outline",className:"border-slate-700 text-slate-400",children:t.namespace})}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:436:23",className:"px-4 py-3",children:e.jsx(y,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:437:25",variant:"outline",className:t.type==="ClusterIP"?"border-blue-500/30 text-blue-400 bg-blue-500/10":t.type==="NodePort"?"border-purple-500/30 text-purple-400 bg-purple-500/10":"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:t.type})}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:450:23",className:"px-4 py-3 text-sm text-slate-300",children:t.cluster_ip??t.clusterIP}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:451:23",className:"px-4 py-3 text-sm text-slate-300",children:t.ports}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:452:23",className:"px-4 py-3 text-sm text-slate-400",children:t.selector})]},t.id||t.name))})]})})}),e.jsx(A,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:461:11",value:"ingresses",className:"mt-4",children:e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:462:13",className:"border rounded-lg border-slate-700 overflow-hidden",children:e.jsxs("table",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:463:15",className:"w-full",children:[e.jsx("thead",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:464:17",className:"bg-slate-800",children:e.jsxs("tr",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:465:19",children:[e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:466:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"名称"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:467:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"命名空间"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:468:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"Hosts"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:469:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"后端服务"}),e.jsx("th",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:470:21",className:"px-4 py-3 text-left text-xs font-medium text-slate-400",children:"TLS"})]})}),e.jsx("tbody",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:473:17",className:"divide-y divide-slate-800",children:b.length===0?e.jsx("tr",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:475:21",children:e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:476:23",colSpan:5,className:"px-4 py-8 text-center text-slate-500",children:"暂无Ingress数据"})}):b.map(t=>e.jsxs("tr",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:480:21",className:"hover:bg-slate-800/50",children:[e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:481:23",className:"px-4 py-3 text-sm text-slate-200",children:t.name}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:482:23",className:"px-4 py-3",children:e.jsx(y,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:483:25",variant:"outline",className:"border-slate-700 text-slate-400",children:t.namespace})}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:487:23",className:"px-4 py-3 text-sm text-slate-300",children:t.hosts}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:488:23",className:"px-4 py-3 text-sm text-slate-300",children:t.backend}),e.jsx("td",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:489:23",className:"px-4 py-3",children:e.jsx(y,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:490:25",variant:"outline",className:t.tls?"border-emerald-500/30 text-emerald-400 bg-emerald-500/10":"border-slate-700 text-slate-400",children:t.tls?"已启用":"未启用"})})]},t.id||t.name))})]})})}),e.jsx(A,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:509:11",value:"events",className:"mt-4",children:e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:510:13",className:"space-y-2",children:[{type:"Normal",reason:"Started",message:"Started container nginx",time:"2分钟前"},{type:"Normal",reason:"Created",message:"Created pod nginx-deployment-xxx",time:"5分钟前"},{type:"Warning",reason:"FailedScheduling",message:"0/3 nodes are available",time:"10分钟前"},{type:"Normal",reason:"Pulling",message:'Pulling image "nginx:latest"',time:"15分钟前"},{type:"Normal",reason:"Pulled",message:"Successfully pulled image",time:"12分钟前"}].map((t,u)=>e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:518:17",className:"flex items-center gap-3 p-3 rounded-lg bg-slate-800/50",children:[e.jsx(y,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:522:19",variant:"outline",className:t.type==="Normal"?"border-emerald-500/30 text-emerald-400 bg-emerald-500/10":"border-amber-500/30 text-amber-400 bg-amber-500/10",children:t.type}),e.jsx("span",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:532:19",className:"text-sm font-medium text-slate-300 min-w-[120px]",children:t.reason}),e.jsx("span",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:533:19",className:"text-sm text-slate-400 flex-1",children:t.message}),e.jsx("span",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:534:19",className:"text-xs text-slate-500",children:t.time})]},u))})})]})})]})}var J="Radio",[ht,ge]=le(J),[gt,Ct]=ht(J),Ce=r.forwardRef((a,p)=>{const{__scopeRadio:n,name:g,checked:s=!1,required:l,disabled:x,value:j="on",onCheck:k,form:C,...b}=a,[f,h]=r.useState(null),m=Y(p,u=>h(u)),d=r.useRef(!1),t=f?C||!!f.closest("form"):!0;return e.jsxs(gt,{scope:n,checked:s,disabled:x,children:[e.jsx(q.button,{type:"button",role:"radio","aria-checked":s,"data-state":Ke(s),"data-disabled":x?"":void 0,disabled:x,value:j,...b,ref:m,onClick:X(a.onClick,u=>{s||k?.(),t&&(d.current=u.isPropagationStopped(),d.current||u.stopPropagation())})}),t&&e.jsx(je,{control:f,bubbles:!d.current,name:g,value:j,checked:s,required:l,disabled:x,form:C,style:{transform:"translateX(-100%)"}})]})});Ce.displayName=J;var ke="RadioIndicator",fe=r.forwardRef((a,p)=>{const{__scopeRadio:n,forceMount:g,...s}=a,l=Ct(ke,n);return e.jsx(Ae,{present:g||l.checked,children:e.jsx(q.span,{"data-state":Ke(l.checked),"data-disabled":l.disabled?"":void 0,...s,ref:p})})});fe.displayName=ke;var kt="RadioBubbleInput",je=r.forwardRef(({__scopeRadio:a,control:p,checked:n,bubbles:g=!0,...s},l)=>{const x=r.useRef(null),j=Y(x,l),k=xt(n),C=Ie(p);return r.useEffect(()=>{const b=x.current;if(!b)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(k!==n&&m){const d=new Event("click",{bubbles:g});m.call(b,n),b.dispatchEvent(d)}},[k,n,g]),e.jsx(q.input,{type:"radio","aria-hidden":!0,defaultChecked:n,...s,tabIndex:-1,ref:j,style:{...s.style,...C,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});je.displayName=kt;function Ke(a){return a?"checked":"unchecked"}var ft=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],H="RadioGroup",[jt]=le(H,[oe,ge]),ve=oe(),Ne=ge(),[Kt,vt]=jt(H),De=r.forwardRef((a,p)=>{const{__scopeRadioGroup:n,name:g,defaultValue:s,value:l,required:x=!1,disabled:j=!1,orientation:k,dir:C,loop:b=!0,onValueChange:f,...h}=a,m=ve(n),d=Pe(C),[t,u]=Te({prop:l,defaultProp:s??null,onChange:f,caller:H});return e.jsx(Kt,{scope:n,name:g,required:x,disabled:j,value:t,onValueChange:u,children:e.jsx(Me,{asChild:!0,...m,orientation:k,dir:d,loop:b,children:e.jsx(q.div,{role:"radiogroup","aria-required":x,"aria-orientation":k,"data-disabled":j?"":void 0,dir:d,...h,ref:p})})})});De.displayName=H;var ye="RadioGroupItem",we=r.forwardRef((a,p)=>{const{__scopeRadioGroup:n,disabled:g,...s}=a,l=vt(ye,n),x=l.disabled||g,j=ve(n),k=Ne(n),C=r.useRef(null),b=Y(p,C),f=l.value===s.value,h=r.useRef(!1);return r.useEffect(()=>{const m=t=>{ft.includes(t.key)&&(h.current=!0)},d=()=>h.current=!1;return document.addEventListener("keydown",m),document.addEventListener("keyup",d),()=>{document.removeEventListener("keydown",m),document.removeEventListener("keyup",d)}},[]),e.jsx(Ee,{asChild:!0,...j,focusable:!x,active:f,children:e.jsx(Ce,{disabled:x,required:l.required,checked:f,...k,...s,name:l.name,ref:b,onCheck:()=>l.onValueChange(s.value),onKeyDown:X(m=>{m.key==="Enter"&&m.preventDefault()}),onFocus:X(s.onFocus,()=>{h.current&&C.current?.click()})})})});we.displayName=ye;var Nt="RadioGroupIndicator",Se=r.forwardRef((a,p)=>{const{__scopeRadioGroup:n,...g}=a,s=Ne(n);return e.jsx(fe,{...s,...g,ref:p})});Se.displayName=Nt;var Dt=De,yt=we,wt=Se;function St({className:a,...p}){return e.jsx(Dt,{"code-path":"src/components/ui/radio-group.tsx:14:5","data-slot":"radio-group",className:M("grid gap-3",a),...p})}function ne({className:a,...p}){return e.jsx(yt,{"code-path":"src/components/ui/radio-group.tsx:27:5","data-slot":"radio-group-item",className:M("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",a),...p,children:e.jsx(wt,{"code-path":"src/components/ui/radio-group.tsx:35:7","data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:e.jsx(Ve,{"code-path":"src/components/ui/radio-group.tsx:39:9",className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})})})}const ae=/^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?$/,ce={name:"",version:"",description:"",config_type:1,api_server:"",token:"",kube_config:""};function _t({open:a,onOpenChange:p,editingCluster:n,onSaved:g}){const[s,l]=r.useState({...ce}),[x,j]=r.useState(!1),[k,C]=r.useState(!1),[b,f]=r.useState(!1),[h,m]=r.useState("");r.useEffect(()=>{a&&(n&&n.id?w.getClusterDetail(n.id).then(o=>{const i=o||{};C(!!i.has_token),f(!!i.has_kube_config),l({name:i.name||"",version:i.version||"",description:i.description||"",config_type:Number(i.config_type??1),api_server:i.api_server||"",token:"",kube_config:""}),m("")}).catch(()=>{l({name:n.name||"",version:n.version||"",description:n.description||"",config_type:Number(n.config_type??1),api_server:n.api_server||"",token:"",kube_config:""}),m("")}):(C(!1),f(!1),l({...ce}),m("")))},[a,n]);const d=o=>{l({...s,name:o}),o.trim()?ae.test(o)?m(""):m("只允许英文、数字和连字符(-),首尾不能是连字符"):m("")},t=o=>{const i=o.match(/^\s*server:\s*(\S+)\s*$/m);return i?i[1]:""},u=o=>{const i=t(o);l(N=>({...N,kube_config:o,api_server:i||N.api_server}))},v=async()=>{if(!s.name.trim()||!ae.test(s.name.trim())){I.error("请输入有效的集群名称(英文/数字/连字符)");return}try{j(!0);const o={name:s.name.trim(),code:s.name.trim(),version:s.version,description:s.description,config_type:s.config_type,api_server:s.api_server,token:s.config_type===0?s.token:"",kube_config:s.config_type===1?s.kube_config:""};n?await w.updateCluster(n.id,o):await w.createCluster(o),p(!1),g()}catch(o){console.error("保存集群失败:",o)}finally{j(!1)}},K=x||!s.name.trim()||!!h;return e.jsx(ue,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:144:5",open:a,onOpenChange:p,children:e.jsxs(de,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:145:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] max-w-2xl",children:[e.jsxs(Fe,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:146:9",children:[e.jsx(ie,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:147:11",className:"text-[var(--dg-text-primary)]",children:n?"编辑集群":"添加集群"}),e.jsx(xe,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:150:11",className:"text-[var(--dg-text-secondary)]",children:n?"修改集群接入配置":"配置新的 Kubernetes 集群接入信息"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:154:9",className:"space-y-4 py-2 max-h-[60vh] overflow-y-auto pr-1",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:155:11",className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:156:13",className:"space-y-2",children:[e.jsx(P,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:157:15",className:"text-[var(--dg-text-secondary)]",children:"集群名称"}),e.jsx(z,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:158:15",value:s.name,onChange:o=>d(o.target.value),placeholder:"如: prod-cluster",className:`bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)] ${h?"border-red-500":""}`}),h&&e.jsx("p",{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:164:29",className:"text-xs text-red-400",children:h}),e.jsx("p",{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:165:15",className:"text-xs text-[var(--dg-text-muted)]",children:"只允许英文、数字和连字符(-),首尾不能是连字符。名称将作为集群唯一标识。"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:169:13",className:"space-y-2",children:[e.jsx(P,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:170:15",className:"text-[var(--dg-text-secondary)]",children:"版本(可选)"}),e.jsx(z,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:171:15",value:s.version,onChange:o=>l({...s,version:o.target.value}),placeholder:"如: 1.28.0",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)]"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:180:11",className:"space-y-2",children:[e.jsx(P,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:181:13",className:"text-[var(--dg-text-secondary)]",children:"描述"}),e.jsx(z,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:182:13",value:s.description,onChange:o=>l({...s,description:o.target.value}),placeholder:"集群用途描述",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)]"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:190:11",className:"space-y-2",children:[e.jsx(P,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:191:13",className:"text-[var(--dg-text-secondary)]",children:"接入方式"}),e.jsxs(St,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:192:13",value:String(s.config_type),onValueChange:o=>l({...s,config_type:Number(o)}),className:"flex gap-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:197:15",className:"flex items-center gap-2 px-3 py-2 rounded-md border border-[var(--dg-border)] cursor-pointer hover:bg-[var(--dg-bg-hover)]",children:[e.jsx(ne,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:198:17",value:"0",id:"ct-0"}),e.jsx(P,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:199:17",htmlFor:"ct-0",className:"cursor-pointer text-[var(--dg-text-primary)] font-normal",children:"Token"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:201:15",className:"flex items-center gap-2 px-3 py-2 rounded-md border border-[var(--dg-border)] cursor-pointer hover:bg-[var(--dg-bg-hover)]",children:[e.jsx(ne,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:202:17",value:"1",id:"ct-1"}),e.jsx(P,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:203:17",htmlFor:"ct-1",className:"cursor-pointer text-[var(--dg-text-primary)] font-normal",children:"Kubeconfig"})]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:208:11",className:"space-y-2",children:[e.jsx(P,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:209:13",className:"text-[var(--dg-text-secondary)]",children:"API Server"}),e.jsx(z,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:210:13",value:s.api_server,onChange:o=>l({...s,api_server:o.target.value}),placeholder:"https://10.0.0.1:6443",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)]"})]}),s.config_type===0?e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:219:13",className:"space-y-2",children:[e.jsxs(P,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:220:15",className:"text-[var(--dg-text-secondary)]",children:["Token ",k&&e.jsx("span",{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:221:36",className:"text-emerald-400 text-xs ml-1",children:"✓ 已配置(留空不修改)"})]}),e.jsx(re,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:223:15",value:s.token,onChange:o=>l({...s,token:o.target.value}),placeholder:k?"已配置,输入新值覆盖...":"粘贴 Service Account Token...",rows:4,className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)] font-mono text-xs"})]}):e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:232:13",className:"space-y-2",children:[e.jsxs(P,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:233:15",className:"text-[var(--dg-text-secondary)]",children:["Kubeconfig ",b&&e.jsx("span",{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:234:46",className:"text-emerald-400 text-xs ml-1",children:"✓ 已配置(留空不修改)"})]}),e.jsx(re,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:236:15",value:s.kube_config,onChange:o=>u(o.target.value),placeholder:b?"已配置,输入新值覆盖...":`apiVersion: v1 -kind: Config -clusters: -- cluster: - server: https://10.0.0.1:6443 - ...`,rows:10,className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)] font-mono text-xs"}),!b&&e.jsx("p",{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:244:17",className:"text-xs text-[var(--dg-text-muted)]",children:"粘贴 kubeconfig 内容后将自动解析 API Server 地址"})]})]}),e.jsxs(Ge,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:251:9",children:[e.jsx(T,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:252:11",variant:"outline",onClick:()=>{p(!1)},className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)] hover:bg-[var(--dg-bg-hover)]",children:"取消"}),e.jsx(T,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:259:11",onClick:v,disabled:K,className:"bg-[var(--dg-blue)] hover:opacity-90 text-white",children:x?"保存中...":n?"保存":"添加"})]})]})})}function Rt({open:a,onOpenChange:p,clusterId:n,clusterName:g}){const s=r.useRef(null),l=r.useRef(null),x=r.useRef(null),j=r.useRef(null),[k,C]=r.useState(!1),[b,f]=r.useState(!1),[h,m]=r.useState("");return r.useEffect(()=>{a||f(!1)},[a]),r.useEffect(()=>{if(!a||!n)return;const d=new pt.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,theme:{background:"#0f172a",foreground:"#e2e8f0",cursor:"#38bdf8",selectionBackground:"#1e40af",black:"#1e293b",red:"#ef4444",green:"#10b981",yellow:"#f59e0b",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#e2e8f0",brightBlack:"#475569",brightRed:"#f87171",brightGreen:"#34d399",brightYellow:"#fbbf24",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#f8fafc"}}),t=new mt.FitAddon;d.loadAddon(t),l.current=d,j.current=t;const v=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}`,K=Le.getState().token||"",o=`${v.replace(/^http/,"ws").replace("/api/v1","")}/ws/kubectl?token=${encodeURIComponent(K)}&id=${n}`,i=new WebSocket(o);return x.current=i,d.onData(N=>{i.readyState===WebSocket.OPEN&&i.send(JSON.stringify({status:0,data:N}))}),i.onmessage=N=>{try{const S=JSON.parse(N.data);S.status===0&&typeof S.data=="string"&&d.write(S.data)}catch{typeof N.data=="string"&&d.write(N.data)}},i.onopen=()=>{C(!0),m(""),s.current&&(d.open(s.current),requestAnimationFrame(()=>{try{t.fit()}catch{}}),setTimeout(()=>{try{d.focus()}catch{}},150))},i.onclose=()=>{C(!1),d.write(`\r -\x1B[31m[连接已断开]\x1B[0m\r -`)},i.onerror=()=>{m("WebSocket 连接失败"),d.write(`\r -\x1B[31m[连接发生错误]\x1B[0m\r -`)},()=>{try{(i.readyState===WebSocket.OPEN||i.readyState===WebSocket.CONNECTING)&&i.close(),d.dispose()}catch{}l.current=null,x.current=null,C(!1)}},[a,n]),r.useEffect(()=>{if(!a)return;const d=s.current;if(!d)return;let t;const u=new ResizeObserver(()=>{clearTimeout(t),t=setTimeout(()=>{if(j.current&&l.current&&x.current)try{j.current.fit(),l.current.focus();const{cols:v,rows:K}=l.current;x.current.readyState===WebSocket.OPEN&&x.current.send(JSON.stringify({status:1,cols:v,rows:K}))}catch{}},60)});return u.observe(d),()=>{clearTimeout(t),u.disconnect()}},[a]),e.jsx(ue,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:161:5",open:a,onOpenChange:p,children:e.jsxs(de,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:162:7",showCloseButton:!1,onOpenAutoFocus:d=>d.preventDefault(),className:M("bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] p-0 gap-0","!duration-0 !transition-none",b?"!max-w-none !w-screen !h-screen !rounded-none !translate-x-0 !translate-y-0 !left-0 !top-0":""),style:b?{maxWidth:"100vw",width:"100vw",height:"100vh"}:{maxWidth:"900px",width:"90vw"},children:[e.jsxs(ie,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:174:9",className:"sr-only",children:["kubectl — ",g]}),e.jsx(xe,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:175:9",className:"sr-only",children:"Kubernetes 集群命令行终端"}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:178:9",className:"flex items-center justify-between px-4 py-2 border-b border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:179:11",className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:180:13",className:M("w-2 h-2 rounded-full",k?"bg-emerald-400":h?"bg-red-400":"bg-yellow-400")}),e.jsx(qe,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:181:13",className:"h-4 w-4 text-blue-400"}),e.jsxs("span",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:182:13",className:"text-[var(--dg-text-primary)] font-medium",children:["kubectl — ",g]}),!k&&!h&&e.jsx(he,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:183:38",className:"h-3 w-3 animate-spin text-[var(--dg-text-muted)]"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:185:11",className:"flex items-center gap-1",children:[e.jsx("button",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:186:13",onClick:()=>f(!b),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",children:b?e.jsx(He,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:190:29",className:"h-4 w-4"}):e.jsx(Xe,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:190:65",className:"h-4 w-4"})}),e.jsx("button",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:192:13",onClick:()=>p(!1),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",children:e.jsx(Ye,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:196:15",className:"h-4 w-4"})})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:202:9",ref:s,className:"bg-[#0f172a]",style:{height:b?"calc(100vh - 49px)":"480px"}})]})})}function Wt(){const[a,p]=r.useState([]),[n,g]=r.useState(!0),[s,l]=r.useState(null),[x,j]=r.useState(""),[k,C]=r.useState(!1),[b,f]=r.useState(null),[h,m]=r.useState(null),[d,t]=r.useState(!1),[u,v]=r.useState(null),[K,o]=r.useState(!1),i=async()=>{try{g(!0);const c=await w.getClusters();p(c?.list||[])}catch(c){console.error("加载集群列表失败:",c),p([])}finally{g(!1)}};r.useEffect(()=>{i()},[]);const[,N]=r.useState(null),S=()=>{i().then(()=>{b||setTimeout(async()=>{const D=(await w.getClusters())?.list||[];D.length>0&&B(D[D.length-1].id,!0)},500)})},O=async c=>{try{await w.deleteCluster(c),i()}catch(D){console.error("删除集群失败:",D)}},B=async(c,D)=>{try{D||I.info("正在同步集群资源...");const R=await w.syncCluster(c);D||I.success(R?.message||"同步完成"),i()}catch(R){D||I.error(R?.message||"同步失败")}},U=async()=>{if(!u)return;const c=u.code||String(u.id);try{o(!0),I.info(`正在导出 ${u.name} 所有命名空间的资源...`),await w.exportAllResources(c),I.success("导出完成,已开始下载"),v(null)}catch(D){I.error(D?.message||"导出失败")}finally{o(!1)}},Q=a.filter(c=>(c.name||"").toLowerCase().includes(x.toLowerCase())||(c.version||"").includes(x)),_e=c=>{switch(c){case"healthy":return e.jsxs(y,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:138:11",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:[e.jsx(at,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:139:13",className:"h-3 w-3 mr-1"}),"健康"]});case"warning":return e.jsxs(y,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:145:11",variant:"outline",className:"border-amber-500/30 text-amber-400 bg-amber-500/10",children:[e.jsx(nt,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:146:13",className:"h-3 w-3 mr-1"}),"警告"]});case"error":return e.jsxs(y,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:152:11",variant:"outline",className:"border-red-500/30 text-red-400 bg-red-500/10",children:[e.jsx(be,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:153:13",className:"h-3 w-3 mr-1"}),"异常"]});default:return null}},Z=s?a.find(c=>c.id===s):null;return e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:165:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:167:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:168:9",children:[e.jsx("h1",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:169:11",className:"text-2xl font-bold text-slate-100",children:"集群列表"}),e.jsx("p",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:170:11",className:"text-sm text-slate-500 mt-1",children:"管理Kubernetes集群资源"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:172:9",className:"flex items-center gap-2",children:[e.jsxs(T,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:173:11",variant:"outline",className:"border-slate-700 text-slate-300 hover:text-slate-100 hover:bg-slate-800",onClick:i,children:[e.jsx(V,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:178:13",className:M("h-4 w-4 mr-2",n&&"animate-spin")}),"刷新"]}),e.jsxs(T,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:181:11",className:"bg-blue-600 hover:bg-blue-700 text-white",onClick:()=>{f(null),C(!0)},children:[e.jsx(Je,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:182:13",className:"h-4 w-4 mr-2"}),"添加集群"]})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:189:7",className:"flex items-center gap-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:190:9",className:"relative w-80",children:[e.jsx(Qe,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:191:11",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-500"}),e.jsx(z,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:192:11",placeholder:"搜索集群名称或版本...",value:x,onChange:c=>j(c.target.value),className:"pl-9 h-9 bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500"})]})}),e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:202:7",className:"grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-4",children:n?e.jsx(G,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:204:11",className:"bg-slate-900 border-slate-800 col-span-full",children:e.jsxs(L,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:205:13",className:"p-12 text-center text-slate-500",children:[e.jsx(V,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:206:15",className:"h-6 w-6 animate-spin mx-auto mb-3"}),"加载中..."]})}):Q.length===0?e.jsx(G,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:211:11",className:"bg-slate-900 border-slate-800 col-span-full",children:e.jsx(L,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:212:13",className:"p-12 text-center text-slate-500",children:"暂无集群数据"})}):Q.map(c=>{const D=Number(c.cpu_usage||0),R=Number(c.memory_usage||0),Re=D>0||R>0;return e.jsxs(G,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:220:15",className:M("bg-slate-900 border-slate-800 cursor-pointer transition-all",s===c.id?"border-blue-500 ring-1 ring-blue-500/30":"hover:border-slate-700"),onClick:()=>l(c.id),children:[e.jsx(W,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:230:17",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:231:19",className:"flex items-start justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:232:21",className:"flex items-center gap-3",children:[e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:233:23",className:"w-10 h-10 rounded-lg bg-blue-500/10 flex items-center justify-center",children:e.jsx(me,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:234:25",className:"h-5 w-5 text-blue-400"})}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:236:23",children:[e.jsx($,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:237:25",className:"text-base text-slate-100",children:c.name}),e.jsx(pe,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:238:25",className:"text-slate-500",children:c.version})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:241:21",className:"flex items-center gap-1",children:[_e(c.status),e.jsxs(Oe,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:243:23",children:[e.jsx(ze,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:244:25",asChild:!0,children:e.jsx(T,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:245:27",variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-slate-100",onClick:_=>_.stopPropagation(),children:e.jsx(Ze,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:251:29",className:"h-4 w-4"})})}),e.jsxs(Be,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:254:25",align:"end",className:"w-48 bg-slate-800 border-slate-700",children:[e.jsx(Ue,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:255:27",className:"text-slate-300",children:"操作"}),e.jsx(ee,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:256:27",className:"bg-slate-700"}),e.jsxs(F,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:257:27",className:"text-slate-300 focus:bg-slate-700 focus:text-slate-100",children:[e.jsx(et,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:258:29",className:"h-4 w-4 mr-2"}),"查看详情"]}),e.jsxs(F,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:261:27",className:"text-slate-300 focus:bg-slate-700 focus:text-slate-100",onClick:_=>{_.stopPropagation(),f(c),C(!0)},children:[e.jsx(tt,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:269:29",className:"h-4 w-4 mr-2"}),"配置"]}),e.jsxs(F,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:272:27",className:"text-cyan-400 focus:bg-slate-700 focus:text-cyan-300",onClick:_=>{_.stopPropagation(),B(c.id)},children:[e.jsx(V,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:279:29",className:"h-4 w-4 mr-2"}),"同步"]}),e.jsxs(F,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:282:27",className:"text-emerald-400 focus:bg-slate-700 focus:text-emerald-300",onClick:_=>{_.stopPropagation(),m({id:c.id,name:c.name}),t(!0)},children:[e.jsx(st,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:290:29",className:"h-4 w-4 mr-2"}),"kubectl"]}),e.jsxs(F,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:293:27",className:"text-blue-400 focus:bg-slate-700 focus:text-blue-300",onClick:_=>{_.stopPropagation(),v(c)},children:[e.jsx(te,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:300:29",className:"h-4 w-4 mr-2"}),"导出资源"]}),e.jsx(ee,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:303:27",className:"bg-slate-700"}),e.jsxs(F,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:304:27",className:"text-red-400 focus:bg-slate-700 focus:text-red-400",onClick:_=>{_.stopPropagation(),O(c.id)},children:[e.jsx(rt,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:311:29",className:"h-4 w-4 mr-2"}),"删除"]})]})]})]})]})}),e.jsxs(L,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:319:17",className:"pt-0",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:320:19",className:"grid grid-cols-4 gap-2 mb-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:321:21",className:"text-center p-2 rounded-lg bg-slate-800/50",children:[e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:322:23",className:"text-lg font-semibold text-slate-200",children:c.ingress_count||0}),e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:323:23",className:"text-xs text-slate-500",children:"Ingress"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:325:21",className:"text-center p-2 rounded-lg bg-slate-800/50",children:[e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:326:23",className:"text-lg font-semibold text-slate-200",children:c.service_count||0}),e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:327:23",className:"text-xs text-slate-500",children:"SVC"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:329:21",className:"text-center p-2 rounded-lg bg-slate-800/50",children:[e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:330:23",className:"text-lg font-semibold text-slate-200",children:c.deployment_count||0}),e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:331:23",className:"text-xs text-slate-500",children:"Deployment"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:333:21",className:"text-center p-2 rounded-lg bg-slate-800/50",children:[e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:334:23",className:"text-lg font-semibold text-slate-200",children:c.pod_count||0}),e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:335:23",className:"text-xs text-slate-500",children:"Pod"})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:338:19",className:"space-y-2",children:Re?e.jsxs(e.Fragment,{children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:341:25",className:"flex items-center gap-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:342:27",className:"text-xs text-slate-500 w-10",children:"CPU"}),e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:343:27",className:"flex-1 h-1.5 bg-slate-800 rounded-full overflow-hidden",children:e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:344:29",className:M("h-full rounded-full",D>80?"bg-red-400":D>60?"bg-amber-400":"bg-emerald-400"),style:{width:`${Math.min(D,100)}%`}})}),e.jsxs("span",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:352:27",className:"text-xs text-slate-400 w-10 text-right",children:[D.toFixed(1),"%"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:354:25",className:"flex items-center gap-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:355:27",className:"text-xs text-slate-500 w-10",children:"内存"}),e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:356:27",className:"flex-1 h-1.5 bg-slate-800 rounded-full overflow-hidden",children:e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:357:29",className:M("h-full rounded-full",R>80?"bg-red-400":R>60?"bg-amber-400":"bg-emerald-400"),style:{width:`${Math.min(R,100)}%`}})}),e.jsxs("span",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:365:27",className:"text-xs text-slate-400 w-10 text-right",children:[R.toFixed(1),"%"]})]})]}):e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:369:23",className:"text-xs text-slate-600 text-center",children:["Ingress ",c.ingress_count||0," · SVC ",c.service_count||0," · Deployment ",c.deployment_count||0," · Pod ",c.pod_count||0," · 资源使用率待采集"]})})]})]},c.id)})}),Z&&e.jsx(bt,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:383:9",cluster:Z,onClose:()=>l(null)}),e.jsx(_t,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:387:7",open:k,onOpenChange:C,editingCluster:b,onSaved:S}),h&&e.jsx(Rt,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:396:9",open:d,onOpenChange:c=>{t(c),c||m(null)},clusterId:h.id,clusterName:h.name}),u&&e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:409:9",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>{K||v(null)},children:e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:413:11",className:"bg-slate-900 border border-slate-700 rounded-lg p-5 w-[420px] shadow-xl",onClick:c=>c.stopPropagation(),children:[e.jsx("h3",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:414:13",className:"text-base font-semibold text-slate-100 mb-1",children:"导出集群资源"}),K?e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:416:15",className:"flex flex-col items-center py-6 gap-3",children:[e.jsx(he,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:417:17",className:"h-9 w-9 animate-spin text-blue-400"}),e.jsxs("p",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:418:17",className:"text-sm text-slate-200",children:["正在导出 ",u.name]}),e.jsxs("p",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:419:17",className:"text-xs text-slate-500 text-center leading-relaxed px-2",children:["正在拉取所有命名空间的 Deployment、Service、Ingress、ConfigMap、Secret 并打包为 tar.gz",e.jsx("br",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:421:19"}),"资源较多时可能需要 1~3 分钟,请稍候勿关闭页面"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:427:17",className:"text-xs text-slate-400 mb-4 leading-relaxed",children:["导出 ",e.jsx("span",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:428:22",className:"text-slate-300",children:u.name})," 所有命名空间的 Deployment、Service、Ingress、ConfigMap、Secret 为 tar.gz"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:431:17",className:"flex justify-end gap-2",children:[e.jsx(T,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:432:19",variant:"outline",className:"border-slate-700 text-slate-300",onClick:()=>v(null),children:"取消"}),e.jsxs(T,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:433:19",className:"bg-blue-600 hover:bg-blue-700 text-white",onClick:U,children:[e.jsx(te,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:434:21",className:"h-4 w-4 mr-1.5"}),"确认导出"]})]})]})]})})]})}export{Wt as KubernetesClusters}; diff --git a/backend/static/assets/KubernetesNodes-Dtu2Ku7B.js b/backend/static/assets/KubernetesNodes-Dtu2Ku7B.js deleted file mode 100644 index f578090..0000000 --- a/backend/static/assets/KubernetesNodes-Dtu2Ku7B.js +++ /dev/null @@ -1 +0,0 @@ -import{r as t,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{C as F,a as I}from"./card-BIfzBCEy.js";import{B as A}from"./index-Dungj95X.js";import{I as P}from"./input-CXoUQQLm.js";import{B as l}from"./badge-CGJlVD3L.js";import{S as w,a as y,b as C,c as S,d as x}from"./select-CiTqGGhE.js";import{T as V,a as H,b as u,c as o,d as U,e as n}from"./table-B2F10oba.js";import{k as B}from"./index-drGq01ok.js";import{L as T,R as W,S as z,h as G}from"./vendor-icons-DmqcWdzX.js";import"./index-5FEebgvX.js";function te(){const[$,h]=t.useState([]),[c,i]=t.useState(""),[R,N]=t.useState([]),[b,k]=t.useState(!1),[j,M]=t.useState(""),[p,L]=t.useState("all"),K=t.useCallback(async()=>{try{const r=(await B.getClusters())?.list||[];h(r),r.length>0&&!c&&i(String(r[0].id))}catch{h([])}},[]);t.useEffect(()=>{K()},[K]);const m=t.useCallback(async()=>{if(c){k(!0);try{const s=await B.getNodes(c);N(Array.isArray(s)?s:s?.list||[])}catch{N([])}finally{k(!1)}}},[c]);t.useEffect(()=>{m()},[m]);const g=R.filter(s=>(s.name||"").toLowerCase().includes(j.toLowerCase())&&(p==="all"||s.role===p)),_=s=>s==="master"?e.jsx(l,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:53:9",className:"bg-blue-500/20 text-blue-400 border-blue-500/30",children:"Master"}):e.jsx(l,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:54:9",className:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",children:"Worker"}),E=s=>s==="Ready"?e.jsx(l,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:58:9",className:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",children:s}):e.jsx(l,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:59:9",variant:"destructive",children:s||"Unknown"});return e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:62:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:63:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:64:9",children:[e.jsx("h1",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:65:11",className:"text-2xl font-bold text-slate-100",children:"节点管理"}),e.jsx("p",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:66:11",className:"text-sm text-slate-500 mt-1",children:"Kubernetes 集群工作节点状态与资源"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:68:9",className:"flex items-center gap-2",children:[e.jsxs(w,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:69:11",value:c,onValueChange:i,children:[e.jsx(y,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:70:13",className:"w-48 h-9 bg-slate-800/50 border-slate-700 text-slate-200",children:e.jsx(C,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:71:15",placeholder:"选择集群"})}),e.jsx(S,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:73:13",className:"bg-slate-800 border-slate-700",children:$.map(s=>e.jsx(x,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:75:17",value:String(s.id),children:s.name},s.id))})]}),e.jsx(A,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:79:11",variant:"outline",size:"icon",className:"h-9 w-9 border-slate-700 text-slate-400",onClick:m,disabled:b,children:b?e.jsx(T,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:80:24",className:"h-4 w-4 animate-spin"}):e.jsx(W,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:80:71",className:"h-4 w-4"})})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:85:7",className:"flex items-center gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:86:9",className:"relative w-56",children:[e.jsx(z,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:87:11",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-500"}),e.jsx(P,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:88:11",placeholder:"搜索节点...",value:j,onChange:s=>M(s.target.value),className:"pl-9 h-9 bg-slate-800/50 border-slate-700 text-slate-200"})]}),e.jsxs(w,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:90:9",value:p,onValueChange:L,children:[e.jsx(y,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:91:11",className:"w-32 h-9 bg-slate-800/50 border-slate-700 text-slate-200",children:e.jsx(C,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:92:13"})}),e.jsxs(S,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:94:11",className:"bg-slate-800 border-slate-700",children:[e.jsx(x,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:95:13",value:"all",children:"全部角色"}),e.jsx(x,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:96:13",value:"master",children:"Master"}),e.jsx(x,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:97:13",value:"worker",children:"Worker"})]})]})]}),e.jsx(F,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:102:7",className:"bg-slate-900 border-slate-800",children:e.jsx(I,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:103:9",className:"p-0",children:e.jsxs(V,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:104:11",children:[e.jsx(H,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:105:13",children:e.jsxs(u,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:106:15",className:"border-slate-800 hover:bg-transparent",children:[e.jsx(o,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:107:17",className:"text-slate-400",children:"节点名称"}),e.jsx(o,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:108:17",className:"text-slate-400",children:"IP"}),e.jsx(o,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:109:17",className:"text-slate-400",children:"角色"}),e.jsx(o,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:110:17",className:"text-slate-400",children:"状态"}),e.jsx(o,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:111:17",className:"text-slate-400",children:"配置"}),e.jsx(o,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:112:17",className:"text-slate-400",children:"使用率"}),e.jsx(o,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:113:17",className:"text-slate-400",children:"Pods"}),e.jsx(o,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:114:17",className:"text-slate-400",children:"Kubelet"})]})}),e.jsx(U,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:117:13",children:b?e.jsx(u,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:119:17",children:e.jsxs(n,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:119:27",colSpan:8,className:"text-center text-slate-500 py-12",children:[e.jsx(T,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:119:95",className:"h-5 w-5 animate-spin mx-auto mb-2"}),"加载中..."]})}):g.length===0?e.jsx(u,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:121:17",children:e.jsxs(n,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:121:27",colSpan:8,className:"text-center text-slate-500 py-12",children:[e.jsx(G,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:121:95",className:"h-8 w-8 mx-auto mb-2 opacity-50"}),c?"暂无节点数据":"请选择集群"]})}):g.map(s=>e.jsxs(u,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:124:19",className:"border-slate-800 hover:bg-slate-800/30",children:[e.jsx(n,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:125:21",className:"font-medium text-slate-200",children:s.name}),e.jsx(n,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:126:21",children:e.jsx("code",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:126:32",className:"text-sm text-slate-300 bg-slate-800 px-1.5 py-0.5 rounded",children:s.ip||"-"})}),e.jsx(n,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:127:21",children:_(s.role)}),e.jsx(n,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:128:21",children:E(s.status)}),e.jsxs(n,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:129:21",className:"text-sm text-slate-400",children:[s.cpu?`${s.cpu}核`:"-"," / ",s.memory?`${Math.round(s.memory/1024)}GB`:"-"]}),e.jsx(n,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:132:21",children:(()=>{const r=s.cpu_usage||0,d=s.memory_usage||0,f=a=>a>=85?"bg-red-500":a>=60?"bg-yellow-500":"bg-emerald-500",v=a=>a>=85?"text-red-400":a>=60?"text-yellow-400":"text-emerald-400";return e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:139:27",className:"flex flex-col gap-1 min-w-[120px]",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:140:29",className:"flex items-center gap-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:141:31",className:"text-xs text-slate-500 w-7",children:"CPU"}),e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:142:31",className:"flex-1 h-1.5 rounded-full bg-slate-700/50 overflow-hidden",children:e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:143:33",className:`h-full rounded-full ${f(r)}`,style:{width:`${Math.min(r,100)}%`}})}),e.jsxs("span",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:145:31",className:`text-xs w-9 text-right ${v(r)}`,children:[r.toFixed(0),"%"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:147:29",className:"flex items-center gap-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:148:31",className:"text-xs text-slate-500 w-7",children:"Mem"}),e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:149:31",className:"flex-1 h-1.5 rounded-full bg-slate-700/50 overflow-hidden",children:e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:150:33",className:`h-full rounded-full ${f(d)}`,style:{width:`${Math.min(d,100)}%`}})}),e.jsxs("span",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:152:31",className:`text-xs w-9 text-right ${v(d)}`,children:[d.toFixed(0),"%"]})]})]})})()}),e.jsxs(n,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:158:21",className:"text-sm text-slate-400",children:[s.pod_count||0," / ",s.max_pods||"-"]}),e.jsx(n,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:159:21",className:"text-xs text-slate-500",children:s.kubelet_version||"-"})]},s.id))})]})})})]})}export{te as KubernetesNodes}; diff --git a/backend/static/assets/LogCenter-5z6NCoZg.js b/backend/static/assets/LogCenter-5z6NCoZg.js deleted file mode 100644 index 2eafe03..0000000 --- a/backend/static/assets/LogCenter-5z6NCoZg.js +++ /dev/null @@ -1 +0,0 @@ -import{r as t,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{D as X,a as Y,b as Z,c as ee,d as te,e as oe,B as b,f as le,g as ie,aw as me}from"./index-Dungj95X.js";import{I as k}from"./input-CXoUQQLm.js";import{L as g}from"./label-CMpUoC87.js";import{T as K}from"./textarea-BxfjmLq5.js";import{S as $,a as z,b as B,c as q,d as O}from"./select-CiTqGGhE.js";import{u as _}from"./use-toast-DNZLibQY.js";import{l as T}from"./log-center-ELxahGiS.js";import{S as M}from"./switch-Bxiq4EHp.js";import{L as F,aW as de,P as U,R as W,z as se,d as ge,T as xe,b5 as pe,aD as he,I as ue,a7 as ve}from"./vendor-icons-DmqcWdzX.js";import{B as R}from"./badge-CGJlVD3L.js";import{C as G,a as J}from"./card-BIfzBCEy.js";import{a as I}from"./alert-v1WaPeEX.js";import{A as ye}from"./AlertRuleDialog-BmYLySxp.js";import"./index-5FEebgvX.js";const re=t.createContext(null);function Le({children:r}){const[s,o]=t.useState(null),n=t.useCallback(i=>o(i),[]);return e.jsx(re.Provider,{"code-path":"src/components/monitor/log-center/LogQueryContext.tsx:16:5",value:{context:s,setContext:n},children:r})}function H(){const r=t.useContext(re);if(!r)throw new Error("useLogQueryContext must be used within LogQueryProvider");return r}function ne({open:r,onOpenChange:s,engine:o,editing:n,onSaved:i}){const{toast:x}=_(),[d,j]=t.useState(""),[p,v]=t.useState(""),[h,D]=t.useState("logstash-*"),[y,Q]=t.useState(!1),[P,c]=t.useState(""),[f,u]=t.useState(""),[m,C]=t.useState(!1),[A,l]=t.useState(!1),[S,a]=t.useState(!1),[N,E]=t.useState(!1);t.useEffect(()=>{r&&(n?(j(n.name),v(n.url),D(n.default_index||"logstash-*"),Q(!!n.basic_auth),c(n.basic_auth_user||""),u(""),C(!!n.skip_tls_verify),l(!!n.is_default)):(j(o==="loki"?"Loki":"Elasticsearch"),v(o==="loki"?"http://localhost:3100":"http://localhost:9200"),D("logstash-*"),Q(!1),c(""),u(""),C(!1),l(!1)))},[r,n,o]);const w=()=>({name:d.trim(),type:o,url:p.trim(),basic_auth:y,basic_auth_user:P,basic_auth_pass:f,skip_tls_verify:m,default_index:o==="elasticsearch"?h:void 0,is_default:A}),V=async()=>{E(!0);try{await T.testDatasource(w()),x({title:"连接成功"})}catch(L){x({title:"连接失败",description:L?.message||String(L),variant:"destructive"})}finally{E(!1)}},ce=async()=>{if(!(!d.trim()||!p.trim())){a(!0);try{n?await T.updateDatasource(n.id,w()):await T.createDatasource(w()),x({title:"已保存"}),s(!1),i()}catch(L){x({title:"保存失败",description:L?.message||String(L),variant:"destructive"})}finally{a(!1)}}};return e.jsx(X,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:103:5",open:r,onOpenChange:s,children:e.jsxs(Y,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:104:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] max-w-md max-h-[85vh] overflow-y-auto",children:[e.jsxs(Z,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:105:9",children:[e.jsxs(ee,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:106:11",className:"text-[var(--dg-text-primary)]",children:[n?"编辑":"添加",o==="loki"?" Loki":" Elasticsearch"," 数据源"]}),e.jsx(te,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:109:11",className:"text-[var(--dg-text-muted)]",children:"仅保存连接信息,日志本体存储在您的 Loki / ES 集群"})]}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:113:9",className:"space-y-3 py-1",children:[e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:114:11",children:[e.jsx(g,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:115:13",className:"text-xs text-[var(--dg-text-muted)]",children:"名称"}),e.jsx(k,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:116:13",value:d,onChange:L=>j(L.target.value),className:"mt-1 h-9 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"})]}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:118:11",children:[e.jsx(g,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:119:13",className:"text-xs text-[var(--dg-text-muted)]",children:"地址"}),e.jsx(k,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:120:13",value:p,onChange:L=>v(L.target.value),placeholder:"http://host:port",className:"mt-1 h-9 font-mono text-xs bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"})]}),o==="elasticsearch"&&e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:123:13",children:[e.jsx(g,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:124:15",className:"text-xs text-[var(--dg-text-muted)]",children:"默认索引"}),e.jsx(k,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:125:15",value:h,onChange:L=>D(L.target.value),className:"mt-1 h-9 font-mono text-xs bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"})]}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:128:11",className:"flex items-center justify-between",children:[e.jsx(g,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:129:13",className:"text-xs text-[var(--dg-text-muted)]",children:"基础认证"}),e.jsx(M,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:130:13",checked:y,onCheckedChange:Q})]}),y&&e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:133:13",className:"grid grid-cols-2 gap-2",children:[e.jsx(k,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:134:15",value:P,onChange:L=>c(L.target.value),placeholder:"用户名",className:"h-9 text-xs bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"}),e.jsx(k,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:135:15",type:"password",value:f,onChange:L=>u(L.target.value),placeholder:"密码",className:"h-9 text-xs bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"})]}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:138:11",className:"flex items-center justify-between",children:[e.jsx(g,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:139:13",className:"text-xs text-[var(--dg-text-muted)]",children:"跳过 TLS 校验"}),e.jsx(M,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:140:13",checked:m,onCheckedChange:C})]}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:142:11",className:"flex items-center justify-between",children:[e.jsx(g,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:143:13",className:"text-xs text-[var(--dg-text-muted)]",children:"设为默认"}),e.jsx(M,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:144:13",checked:A,onCheckedChange:l})]})]}),e.jsxs(oe,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:147:9",className:"gap-2",children:[e.jsxs(b,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:148:11",variant:"outline",size:"sm",onClick:V,disabled:N,children:[N?e.jsx(F,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:149:24",className:"h-4 w-4 animate-spin mr-1"}):e.jsx(de,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:149:76",className:"h-4 w-4 mr-1"}),"测试"]}),e.jsxs(b,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:152:11",size:"sm",onClick:ce,disabled:S,children:[S&&e.jsx(F,{"code-path":"src/components/monitor/log-center/LogDatasourceDialog.tsx:153:24",className:"h-4 w-4 animate-spin mr-1"}),"保存"]})]})]})})}const be={error:"bg-red-500/15 text-red-400 border-red-500/30",warn:"bg-amber-500/15 text-amber-400 border-amber-500/30",warning:"bg-amber-500/15 text-amber-400 border-amber-500/30",info:"bg-blue-500/15 text-blue-400 border-blue-500/30",debug:"bg-slate-500/15 text-slate-400 border-slate-500/30"};function ae({entries:r,loading:s}){return s?e.jsx("div",{"code-path":"src/components/monitor/log-center/LogResultsTable.tsx:15:12",className:"text-center py-16 text-[var(--dg-text-muted)] text-sm",children:"查询中..."}):r.length===0?e.jsx("div",{"code-path":"src/components/monitor/log-center/LogResultsTable.tsx:18:12",className:"text-center py-16 text-[var(--dg-text-muted)] text-sm",children:"暂无日志,调整查询条件后重试"}):e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogResultsTable.tsx:21:5",className:"border border-[var(--dg-border)] rounded-lg overflow-hidden",children:[e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogResultsTable.tsx:22:7",className:"grid grid-cols-[160px_72px_1fr] gap-2 px-3 py-2 bg-[var(--dg-bg-tertiary)]/50 text-[11px] font-medium text-[var(--dg-text-muted)] uppercase",children:[e.jsx("span",{"code-path":"src/components/monitor/log-center/LogResultsTable.tsx:23:9",children:"时间"}),e.jsx("span",{"code-path":"src/components/monitor/log-center/LogResultsTable.tsx:24:9",children:"级别"}),e.jsx("span",{"code-path":"src/components/monitor/log-center/LogResultsTable.tsx:25:9",children:"内容"})]}),e.jsx("div",{"code-path":"src/components/monitor/log-center/LogResultsTable.tsx:27:7",className:"max-h-[480px] overflow-y-auto divide-y divide-[var(--dg-border)]",children:r.map((o,n)=>e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogResultsTable.tsx:29:11",className:"grid grid-cols-[160px_72px_1fr] gap-2 px-3 py-2 text-xs hover:bg-[var(--dg-bg-tertiary)]/30",children:[e.jsx("span",{"code-path":"src/components/monitor/log-center/LogResultsTable.tsx:30:13",className:"font-mono text-[var(--dg-text-muted)] truncate",title:o.timestamp,children:o.timestamp}),e.jsx("span",{"code-path":"src/components/monitor/log-center/LogResultsTable.tsx:31:13",children:o.level?e.jsx(R,{"code-path":"src/components/monitor/log-center/LogResultsTable.tsx:33:17",variant:"outline",className:`text-[10px] ${be[o.level.toLowerCase()]||"border-[var(--dg-border)]"}`,children:o.level}):"—"}),e.jsx("pre",{"code-path":"src/components/monitor/log-center/LogResultsTable.tsx:36:13",className:"font-mono text-[var(--dg-text-secondary)] whitespace-pre-wrap break-all leading-relaxed",children:o.message})]},n))})]})}const je=[{label:"15 分钟",value:"15m"},{label:"1 小时",value:"1h"},{label:"6 小时",value:"6h"},{label:"24 小时",value:"24h"}];function fe(r){const s=r.match(/^(\d+)(m|h)$/);if(!s)return new Date(Date.now()-36e5).toISOString();const o=parseInt(s[1],10),n=s[2]==="h"?o*36e5:o*6e4;return new Date(Date.now()-n).toISOString()}function De(){const{toast:r}=_(),{setContext:s}=H(),[o,n]=t.useState([]),[i,x]=t.useState(""),[d,j]=t.useState('{namespace="default"} |= "error"'),[p,v]=t.useState("1h"),[h,D]=t.useState(200),[y,Q]=t.useState([]),[P,c]=t.useState(!1),[f,u]=t.useState(!1),m=t.useCallback(async()=>{const l=await T.listDatasources("loki").catch(()=>[]),S=Array.isArray(l)?l:[];if(n(S),!i&&S.length){const a=S.find(N=>N.is_default)||S[0];x(String(a.id))}},[i]);t.useEffect(()=>{m()},[m]);const C=t.useCallback((l,S)=>{const a=o.find(N=>String(N.id)===S);s({engine:"loki",datasourceId:a?a.id:void 0,datasourceName:a?.name,query:l,timeRange:p})},[o,p,s]);t.useEffect(()=>{C(d,i)},[d,i,C]);const A=async()=>{if(!(!i||!d.trim())){c(!0);try{const l=await T.queryLoki({datasource_id:Number(i),query:d.trim(),limit:h,start:fe(p),end:new Date().toISOString()});Q(l?.entries||[]),r({title:"查询完成",description:`共 ${l?.total??0} 条`})}catch(l){r({title:"查询失败",description:l?.message||String(l),variant:"destructive"}),Q([])}finally{c(!1)}}};return e.jsxs("div",{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:91:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:92:7",className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:93:9",className:"min-w-[200px] flex-1",children:[e.jsx(g,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:94:11",className:"text-xs text-[var(--dg-text-muted)]",children:"数据源"}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:95:11",className:"flex gap-2 mt-1",children:[e.jsxs($,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:96:13",value:i,onValueChange:x,children:[e.jsx(z,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:97:15",className:"h-9 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]",children:e.jsx(B,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:98:17",placeholder:"选择 Loki"})}),e.jsx(q,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:100:15",children:o.map(l=>e.jsxs(O,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:102:19",value:String(l.id),children:[l.name,l.is_default?" (默认)":""]},l.id))})]}),e.jsx(b,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:106:13",variant:"outline",size:"icon",className:"h-9 w-9 shrink-0",onClick:()=>u(!0),title:"添加数据源",children:e.jsx(U,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:107:15",className:"h-4 w-4"})}),e.jsx(b,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:109:13",variant:"outline",size:"icon",className:"h-9 w-9 shrink-0",onClick:m,title:"刷新",children:e.jsx(W,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:110:15",className:"h-4 w-4"})})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:114:9",className:"w-[120px]",children:[e.jsx(g,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:115:11",className:"text-xs text-[var(--dg-text-muted)]",children:"时间范围"}),e.jsxs($,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:116:11",value:p,onValueChange:v,children:[e.jsx(z,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:117:13",className:"h-9 mt-1 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]",children:e.jsx(B,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:118:15"})}),e.jsx(q,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:120:13",children:je.map(l=>e.jsx(O,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:121:38",value:l.value,children:l.label},l.value))})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:125:9",className:"w-[88px]",children:[e.jsx(g,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:126:11",className:"text-xs text-[var(--dg-text-muted)]",children:"条数"}),e.jsx(k,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:127:11",type:"number",value:h,onChange:l=>D(Number(l.target.value)||200),className:"h-9 mt-1 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"})]}),e.jsxs(b,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:129:9",className:"h-9 bg-[var(--dg-blue)] hover:opacity-90",onClick:A,disabled:P||!i,children:[P?e.jsx(F,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:130:22",className:"h-4 w-4 animate-spin mr-1"}):e.jsx(se,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:130:74",className:"h-4 w-4 mr-1"}),"查询"]})]}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:135:7",children:[e.jsx(g,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:136:9",className:"text-xs text-[var(--dg-text-muted)]",children:"LogQL"}),e.jsx(K,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:137:9",value:d,onChange:l=>j(l.target.value),rows:3,className:"mt-1 font-mono text-xs bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] resize-y",placeholder:'{app="nginx"} |= "error"'}),e.jsxs("p",{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:144:9",className:"text-[10px] text-[var(--dg-text-muted)] mt-1",children:["示例:",'{job="varlogs"}',' | json | level="error" · 单次最多 500 条,不落库']})]}),e.jsx(ae,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:149:7",entries:y,loading:P}),e.jsx(ne,{"code-path":"src/components/monitor/log-center/LokiQueryPanel.tsx:151:7",open:f,onOpenChange:u,engine:"loki",onSaved:m})]})}const Ne=[{label:"15 分钟",value:"15m"},{label:"1 小时",value:"1h"},{label:"6 小时",value:"6h"},{label:"24 小时",value:"24h"}];function Qe(r){const s=r.match(/^(\d+)(m|h)$/);if(!s)return new Date(Date.now()-36e5).toISOString();const o=parseInt(s[1],10),n=s[2]==="h"?o*36e5:o*6e4;return new Date(Date.now()-n).toISOString()}function Pe(){const{toast:r}=_(),{setContext:s}=H(),[o,n]=t.useState([]),[i,x]=t.useState(""),[d,j]=t.useState("logstash-*"),[p,v]=t.useState("level:error AND message:*timeout*"),[h,D]=t.useState("1h"),[y,Q]=t.useState(200),[P,c]=t.useState([]),[f,u]=t.useState(!1),[m,C]=t.useState(!1),A=t.useCallback(async()=>{const a=await T.listDatasources("elasticsearch").catch(()=>[]),N=Array.isArray(a)?a:[];if(n(N),!i&&N.length){const E=N.find(w=>w.is_default)||N[0];x(String(E.id)),E.default_index&&j(E.default_index)}},[i]);t.useEffect(()=>{A()},[A]);const l=t.useCallback((a,N,E)=>{const w=o.find(V=>String(V.id)===N);s({engine:"elasticsearch",datasourceId:w?w.id:void 0,datasourceName:w?.name,query:a,index:E,timeRange:h})},[o,h,s]);t.useEffect(()=>{l(p,i,d)},[p,i,d,l]);const S=async()=>{if(i){u(!0);try{const a=await T.queryElasticsearch({datasource_id:Number(i),index:d.trim()||void 0,query:p.trim()||"*",size:y,start:Qe(h),end:new Date().toISOString()});c(a?.entries||[]),r({title:"查询完成",description:`共 ${a?.total??0} 条`})}catch(a){r({title:"查询失败",description:a?.message||String(a),variant:"destructive"}),c([])}finally{u(!1)}}};return e.jsxs("div",{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:94:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:95:7",className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:96:9",className:"min-w-[200px] flex-1",children:[e.jsx(g,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:97:11",className:"text-xs text-[var(--dg-text-muted)]",children:"数据源"}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:98:11",className:"flex gap-2 mt-1",children:[e.jsxs($,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:99:13",value:i,onValueChange:x,children:[e.jsx(z,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:100:15",className:"h-9 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]",children:e.jsx(B,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:101:17",placeholder:"选择 ES"})}),e.jsx(q,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:103:15",children:o.map(a=>e.jsxs(O,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:105:19",value:String(a.id),children:[a.name,a.is_default?" (默认)":""]},a.id))})]}),e.jsx(b,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:109:13",variant:"outline",size:"icon",className:"h-9 w-9 shrink-0",onClick:()=>C(!0),children:e.jsx(U,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:110:15",className:"h-4 w-4"})}),e.jsx(b,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:112:13",variant:"outline",size:"icon",className:"h-9 w-9 shrink-0",onClick:A,children:e.jsx(W,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:113:15",className:"h-4 w-4"})})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:117:9",className:"w-[140px]",children:[e.jsx(g,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:118:11",className:"text-xs text-[var(--dg-text-muted)]",children:"索引"}),e.jsx(k,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:119:11",value:d,onChange:a=>j(a.target.value),className:"h-9 mt-1 font-mono text-xs bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"})]}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:121:9",className:"w-[120px]",children:[e.jsx(g,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:122:11",className:"text-xs text-[var(--dg-text-muted)]",children:"时间范围"}),e.jsxs($,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:123:11",value:h,onValueChange:D,children:[e.jsx(z,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:124:13",className:"h-9 mt-1 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]",children:e.jsx(B,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:125:15"})}),e.jsx(q,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:127:13",children:Ne.map(a=>e.jsx(O,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:128:38",value:a.value,children:a.label},a.value))})]})]}),e.jsxs(b,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:132:9",className:"h-9 bg-[var(--dg-blue)] hover:opacity-90",onClick:S,disabled:f||!i,children:[f?e.jsx(F,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:133:22",className:"h-4 w-4 animate-spin mr-1"}):e.jsx(se,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:133:74",className:"h-4 w-4 mr-1"}),"查询"]})]}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:138:7",children:[e.jsx(g,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:139:9",className:"text-xs text-[var(--dg-text-muted)]",children:"Lucene 查询"}),e.jsx(k,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:140:9",value:p,onChange:a=>v(a.target.value),className:"mt-1 font-mono text-xs h-10 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]",placeholder:'status:500 AND path:"/api/*"'}),e.jsx("p",{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:146:9",className:"text-[10px] text-[var(--dg-text-muted)] mt-1",children:"支持 Lucene 语法;留空则匹配全部 · 单次最多 500 条,不落库"})]}),e.jsx(ae,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:149:7",entries:P,loading:f}),e.jsx(ne,{"code-path":"src/components/monitor/log-center/EsQueryPanel.tsx:151:7",open:m,onOpenChange:C,engine:"elasticsearch",onSaved:A})]})}function Se(){const{toast:r}=_(),s=le(),[o,n]=t.useState([]),[i,x]=t.useState([]),[d,j]=t.useState(!0),[p,v]=t.useState(!1),[h,D]=t.useState(null),y=t.useCallback(async()=>{j(!0);try{const[c,f]=await Promise.all([I.getRules(),I.getNotifyChannels()]),u=c?.list||(Array.isArray(c)?c:[]);n(u.filter(m=>m.type==="log"||m.source==="loki"||m.source==="elasticsearch")),x(f?.list||[])}finally{j(!1)}},[]);t.useEffect(()=>{y()},[y]);const Q=async c=>{if(await s({title:"删除规则",description:`删除「${c.name}」?`,variant:"destructive",confirmText:"删除"}))try{await I.deleteRule(c.id),r({title:"已删除"}),y()}catch(u){r({title:"删除失败",description:u?.message||String(u),variant:"destructive"})}},P={critical:"bg-red-500/15 text-red-400",warning:"bg-amber-500/15 text-amber-400",info:"bg-blue-500/15 text-blue-400"};return e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:57:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:58:7",className:"flex items-center justify-between",children:[e.jsx("p",{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:59:9",className:"text-sm text-[var(--dg-text-muted)]",children:"仅保存告警策略(LogQL / Lucene),日志数据仍在外部 Loki / ES"}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:60:9",className:"flex gap-2",children:[e.jsxs(b,{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:61:11",variant:"outline",size:"sm",onClick:y,disabled:d,children:[e.jsx(W,{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:62:13",className:`h-4 w-4 mr-1 ${d?"animate-spin":""}`}),"刷新"]}),e.jsxs(b,{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:64:11",size:"sm",onClick:()=>{D(null),v(!0)},children:[e.jsx(U,{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:65:13",className:"h-4 w-4 mr-1"}),"新建"]})]})]}),d?e.jsx("div",{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:71:9",className:"flex justify-center py-16",children:e.jsx(F,{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:71:52",className:"h-6 w-6 animate-spin text-[var(--dg-text-muted)]"})}):o.length===0?e.jsx(G,{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:73:9",className:"dg-card",children:e.jsx(J,{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:74:11",className:"py-12 text-center text-[var(--dg-text-muted)] text-sm",children:"暂无日志告警。在 Loki/ES 查询页点击右下角「叮当」可从当前查询快速创建。"})}):e.jsx("div",{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:79:9",className:"space-y-2",children:o.map(c=>e.jsx(G,{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:81:13",className:"dg-card",children:e.jsxs(J,{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:82:15",className:"py-3 px-4 flex flex-wrap items-center gap-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:83:17",className:"flex-1 min-w-[200px]",children:[e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:84:19",className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:85:21",className:"font-medium text-[var(--dg-text-primary)]",children:c.name}),e.jsx(R,{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:86:21",variant:"outline",className:"text-[10px] border-[var(--dg-border)]",children:c.source||"log"}),e.jsx(R,{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:87:21",className:`text-[10px] ${P[c.severity]||""}`,children:c.severity}),!c.enabled&&c.enabled!==void 0&&e.jsx(R,{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:89:23",variant:"outline",className:"text-[10px] text-[var(--dg-text-muted)]",children:"已禁用"})]}),e.jsx("p",{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:92:19",className:"text-[11px] font-mono text-[var(--dg-text-muted)] mt-1 truncate",title:c.expression,children:c.expression})]}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:94:17",className:"flex gap-1 shrink-0",children:[e.jsx(b,{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:95:19",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{D(c),v(!0)},children:e.jsx(ge,{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:96:21",className:"h-3.5 w-3.5"})}),e.jsx(b,{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:98:19",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400",onClick:()=>Q(c),children:e.jsx(xe,{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:99:21",className:"h-3.5 w-3.5"})})]})]})},c.id))}),e.jsx(ye,{"code-path":"src/components/monitor/log-center/LogAlertsPanel.tsx:108:7",open:p,onOpenChange:v,editingRule:h,notifyChannels:i,onSaved:y,defaultType:"log"})]})}function ke({open:r,onOpenChange:s,ctx:o,onSaved:n}){const{toast:i}=_(),[x,d]=t.useState(""),[j,p]=t.useState(""),[v,h]=t.useState(""),[D,y]=t.useState("warning"),[Q,P]=t.useState(300),[c,f]=t.useState(!1);t.useEffect(()=>{if(!r||!o)return;const m=o.engine==="loki"?"Loki":"ES";d(`${m} 日志告警`),p(`数据源: ${o.datasourceName||"—"} · 范围: ${o.timeRange||"—"}${o.index?` · 索引: ${o.index}`:""}`),o.engine==="loki"?h(`count_over_time(${Ce(o.query)}[5m]) > 0`):h(o.query||"*")},[r,o]);const u=async()=>{if(!(!x.trim()||!v.trim()||!o)){f(!0);try{await I.createRule({name:x.trim(),description:j.trim(),type:"log",source:o.engine==="loki"?"loki":"elasticsearch",expression:v.trim(),severity:D,duration:Q,notify_channels:[]}),i({title:"告警规则已创建",description:"可在「日志告警」Tab 中继续配置通知渠道"}),s(!1),n?.()}catch(m){i({title:"创建失败",description:m?.message||String(m),variant:"destructive"})}finally{f(!1)}}};return e.jsx(X,{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:70:5",open:r,onOpenChange:s,children:e.jsxs(Y,{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:71:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsxs(Z,{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:72:9",children:[e.jsxs(ee,{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:73:11",className:"text-[var(--dg-text-primary)] flex items-center gap-2",children:[e.jsx(pe,{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:74:13",className:"h-5 w-5 text-amber-400"}),"叮当 · 添加告警"]}),e.jsx(te,{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:77:11",className:"text-[var(--dg-text-muted)]",children:"将当前查询条件保存为日志告警规则,命中时触发通知"})]}),o?.query?.trim()?e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:84:11",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:85:13",children:[e.jsx(g,{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:86:15",className:"text-xs text-[var(--dg-text-muted)]",children:"规则名称"}),e.jsx(k,{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:87:15",value:x,onChange:m=>d(m.target.value),className:"mt-1 h-9 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"})]}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:89:13",children:[e.jsx(g,{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:90:15",className:"text-xs text-[var(--dg-text-muted)]",children:"描述"}),e.jsx(K,{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:91:15",value:j,onChange:m=>p(m.target.value),rows:2,className:"mt-1 text-xs bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] resize-none"})]}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:93:13",children:[e.jsx(g,{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:94:15",className:"text-xs text-[var(--dg-text-muted)]",children:"触发条件"}),e.jsx(K,{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:95:15",value:v,onChange:m=>h(m.target.value),rows:4,className:"mt-1 font-mono text-xs bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"}),e.jsx("p",{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:96:15",className:"text-[10px] text-[var(--dg-text-muted)] mt-1",children:o.engine==="loki"?"LogQL 告警表达式,默认 count_over_time":"ES Lucene 查询,匹配到日志即告警"})]}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:100:13",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:101:15",children:[e.jsx(g,{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:102:17",className:"text-xs text-[var(--dg-text-muted)]",children:"级别"}),e.jsxs("select",{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:103:17",value:D,onChange:m=>y(m.target.value),className:"w-full h-9 mt-1 px-2 rounded-md bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] text-sm",children:[e.jsx("option",{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:104:19",value:"info",children:"提示"}),e.jsx("option",{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:105:19",value:"warning",children:"警告"}),e.jsx("option",{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:106:19",value:"critical",children:"严重"})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:109:15",children:[e.jsx(g,{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:110:17",className:"text-xs text-[var(--dg-text-muted)]",children:"持续(秒)"}),e.jsx(k,{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:111:17",type:"number",value:Q,onChange:m=>P(Number(m.target.value)||300),className:"mt-1 h-9 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:114:13",className:"rounded-md bg-[var(--dg-bg-tertiary)]/60 p-2 text-[10px] font-mono text-[var(--dg-text-secondary)] break-all",children:["原始查询: ",o.query]})]}):e.jsx("p",{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:82:11",className:"text-sm text-amber-400/90 py-4",children:"请先在 Loki 或 ES 查询页输入查询语句"}),e.jsxs(oe,{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:119:9",children:[e.jsx(b,{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:120:11",variant:"outline",onClick:()=>s(!1),children:"取消"}),e.jsxs(b,{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:121:11",onClick:u,disabled:c||!o?.query?.trim(),children:[c&&e.jsx(F,{"code-path":"src/components/monitor/log-center/LogAlertFromQueryDialog.tsx:122:24",className:"h-4 w-4 animate-spin mr-1"}),"创建规则"]})]})]})})}function Ce(r){const s=r.trim();return s.startsWith("{")?s:`{job=~".+"} |= "${s.replace(/"/g,'\\"')}"`}function Ae({onRuleCreated:r}){const{context:s}=H(),[o,n]=t.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogDingAssistant.tsx:14:7",className:"fixed bottom-6 right-6 z-40 flex flex-col items-end gap-2",children:[e.jsx("div",{"code-path":"src/components/monitor/log-center/LogDingAssistant.tsx:15:9",className:"hidden sm:block rounded-lg bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] px-3 py-1.5 text-[11px] text-[var(--dg-text-muted)] shadow-lg opacity-0 hover:opacity-100 transition-opacity pointer-events-none",children:"将当前查询添加为告警"}),e.jsxs(b,{"code-path":"src/components/monitor/log-center/LogDingAssistant.tsx:18:9",size:"lg",className:"h-12 rounded-full shadow-lg bg-gradient-to-r from-amber-500 to-orange-500 hover:from-amber-400 hover:to-orange-400 text-white gap-2 px-5",onClick:()=>n(!0),title:"叮当 · 添加告警",children:[e.jsx(he,{"code-path":"src/components/monitor/log-center/LogDingAssistant.tsx:24:11",className:"h-5 w-5"}),e.jsx("span",{"code-path":"src/components/monitor/log-center/LogDingAssistant.tsx:25:11",className:"font-medium",children:"叮当"})]})]}),e.jsx(ke,{"code-path":"src/components/monitor/log-center/LogDingAssistant.tsx:28:7",open:o,onOpenChange:n,ctx:s,onSaved:r})]})}function we(){return e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogCenterArchBanner.tsx:6:5",className:"flex gap-3 rounded-lg border border-cyan-500/20 bg-cyan-500/5 px-4 py-3 text-xs text-[var(--dg-text-secondary)] leading-relaxed",children:[e.jsx(ue,{"code-path":"src/components/monitor/log-center/LogCenterArchBanner.tsx:7:7",className:"h-4 w-4 shrink-0 text-cyan-400 mt-0.5"}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogCenterArchBanner.tsx:8:7",children:[e.jsx("p",{"code-path":"src/components/monitor/log-center/LogCenterArchBanner.tsx:9:9",className:"text-[var(--dg-text-primary)] font-medium mb-1",children:"无状态查询网关"}),e.jsxs("p",{"code-path":"src/components/monitor/log-center/LogCenterArchBanner.tsx:10:9",children:["AIOps 不存储 Loki / Elasticsearch 中的海量日志,仅保存",e.jsx("strong",{"code-path":"src/components/monitor/log-center/LogCenterArchBanner.tsx:11:52",className:"text-[var(--dg-text-primary)] font-normal",children:"数据源连接"}),"与",e.jsx("strong",{"code-path":"src/components/monitor/log-center/LogCenterArchBanner.tsx:12:11",className:"text-[var(--dg-text-primary)] font-normal",children:"告警策略"}),"。查询时实时转发至外部集群,结果仅在当前页面展示,刷新即清空。"]})]})]})}const Ee={loki:{title:"Loki 查询",description:"对接外部 Loki · LogQL 实时检索"},es:{title:"ES 查询",description:"对接 Elasticsearch · 索引日志检索"},alerts:{title:"日志告警",description:"基于查询条件的日志告警策略"}};function He(){const{section:r}=ie(),s=r&&["loki","es","alerts"].includes(r)?r:null,[o,n]=t.useState(0);if(!s)return e.jsx(me,{"code-path":"src/components/monitor/log-center/LogCenter.tsx:25:20",to:"/log-center/loki",replace:!0});const i=Ee[s];return e.jsx(Le,{"code-path":"src/components/monitor/log-center/LogCenter.tsx:30:5",children:e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogCenter.tsx:31:7",className:"space-y-4 pb-20",children:[e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogCenter.tsx:32:9",className:"flex items-center gap-3",children:[e.jsx("div",{"code-path":"src/components/monitor/log-center/LogCenter.tsx:33:11",className:"h-10 w-10 rounded-xl bg-gradient-to-br from-cyan-500/20 to-blue-500/20 flex items-center justify-center border border-cyan-500/20",children:e.jsx(ve,{"code-path":"src/components/monitor/log-center/LogCenter.tsx:34:13",className:"h-5 w-5 text-cyan-400"})}),e.jsxs("div",{"code-path":"src/components/monitor/log-center/LogCenter.tsx:36:11",children:[e.jsx("h1",{"code-path":"src/components/monitor/log-center/LogCenter.tsx:37:13",className:"text-xl font-bold text-[var(--dg-text-primary)]",children:i.title}),e.jsx("p",{"code-path":"src/components/monitor/log-center/LogCenter.tsx:38:13",className:"text-sm text-[var(--dg-text-muted)]",children:i.description})]})]}),s!=="alerts"&&e.jsx(we,{"code-path":"src/components/monitor/log-center/LogCenter.tsx:42:30"}),s==="loki"&&e.jsx(De,{"code-path":"src/components/monitor/log-center/LogCenter.tsx:44:28"}),s==="es"&&e.jsx(Pe,{"code-path":"src/components/monitor/log-center/LogCenter.tsx:45:26"}),s==="alerts"&&e.jsx(Se,{"code-path":"src/components/monitor/log-center/LogCenter.tsx:46:30"},o),s!=="alerts"&&e.jsx(Ae,{"code-path":"src/components/monitor/log-center/LogCenter.tsx:49:11",onRuleCreated:()=>n(x=>x+1)})]})})}export{He as default}; diff --git a/backend/static/assets/LoginLogsTab-8Twk1DRE.js b/backend/static/assets/LoginLogsTab-8Twk1DRE.js deleted file mode 100644 index 306e68e..0000000 --- a/backend/static/assets/LoginLogsTab-8Twk1DRE.js +++ /dev/null @@ -1 +0,0 @@ -import{r as n,j as s}from"./vendor-codemirror-B1SGo4xl.js";import{C as N,a as v}from"./card-BIfzBCEy.js";import{B as h}from"./index-Dungj95X.js";import{I as _}from"./input-CXoUQQLm.js";import{B as i}from"./badge-CGJlVD3L.js";import{T as y,a as C,b as L,c as o,d as w,e as c}from"./table-B2F10oba.js";import{l as S}from"./terminal-D5kNzib0.js";import{S as k,R as B,Z as I,G as A,_ as R}from"./vendor-icons-DmqcWdzX.js";function z(a){return{id:a.id??0,username:a.username??"",login_type:a.login_type??"password",ip:a.ip??"",location:a.location??"",browser:a.browser??"",os:a.os??"",user_agent:a.user_agent??a.userAgent??"",status:a.status==="failed"||a.status==="fail"?"fail":"success",fail_reason:a.fail_reason??a.message??"",login_at:a.login_at??a.created_at??"",created_at:a.created_at??a.login_at??""}}function M(){const[a,g]=n.useState([]),[b,d]=n.useState(!0),[p,m]=n.useState(""),[r,u]=n.useState(""),l=n.useCallback(async()=>{d(!0);try{const e={page:1,page_size:100};r&&(e.status=r==="fail"?"failed":r);const f=(await S.list(e))?.list??[];g(f.map(z))}catch{g([])}finally{d(!1)}},[r]);n.useEffect(()=>{l()},[l]);const x=a.filter(e=>{const t=p.toLowerCase();return!t||(e.username||"").toLowerCase().includes(t)||(e.ip||"").toLowerCase().includes(t)||(e.location||"").toLowerCase().includes(t)||(e.user_agent||"").toLowerCase().includes(t)}),T=(e,t)=>e==="success"?s.jsx(i,{"code-path":"src/pages/LoginLogsTab.tsx:89:7",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:"成功"}):s.jsx(i,{"code-path":"src/pages/LoginLogsTab.tsx:93:7",variant:"outline",className:"border-red-500/30 text-red-400 bg-red-500/10",title:t||void 0,children:t||"失败"}),j=e=>{switch(e){case"password":return"密码登录";case"ldap":return"LDAP";case"token":return"Token";case"oauth":return"OAuth";default:return e||"密码登录"}};return s.jsxs("div",{"code-path":"src/pages/LoginLogsTab.tsx:114:5",className:"space-y-4",children:[s.jsxs("div",{"code-path":"src/pages/LoginLogsTab.tsx:116:7",className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("div",{"code-path":"src/pages/LoginLogsTab.tsx:117:9",className:"relative w-64",children:[s.jsx(k,{"code-path":"src/pages/LoginLogsTab.tsx:118:11",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-500"}),s.jsx(_,{"code-path":"src/pages/LoginLogsTab.tsx:119:11",placeholder:"搜索用户/IP/归属地...",value:p,onChange:e=>m(e.target.value),className:"pl-9 h-9 bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500"})]}),s.jsx("div",{"code-path":"src/pages/LoginLogsTab.tsx:127:9",className:"flex items-center gap-1",children:[{value:"",label:"全部"},{value:"success",label:"成功"},{value:"fail",label:"失败"}].map(({value:e,label:t})=>s.jsx(h,{"code-path":"src/pages/LoginLogsTab.tsx:133:13",variant:r===e?"default":"outline",size:"sm",className:r===e?"h-8 bg-blue-600 hover:bg-blue-700 text-white":"h-8 border-slate-700 text-slate-400 hover:text-slate-100 hover:bg-slate-800",onClick:()=>u(e),children:t},e||"all"))}),s.jsxs(h,{"code-path":"src/pages/LoginLogsTab.tsx:149:9",variant:"outline",className:"border-slate-700 text-slate-300 hover:text-slate-100 hover:bg-slate-800",onClick:l,children:[s.jsx(B,{"code-path":"src/pages/LoginLogsTab.tsx:154:11",className:"h-4 w-4 mr-2"}),"刷新"]})]}),s.jsx(N,{"code-path":"src/pages/LoginLogsTab.tsx:160:7",className:"bg-slate-900 border-slate-800",children:s.jsx(v,{"code-path":"src/pages/LoginLogsTab.tsx:161:9",className:"p-0",children:s.jsx("div",{"code-path":"src/pages/LoginLogsTab.tsx:162:11",className:"border-t border-slate-800",children:b?s.jsx("div",{"code-path":"src/pages/LoginLogsTab.tsx:164:15",className:"flex items-center justify-center py-16",children:s.jsx("div",{"code-path":"src/pages/LoginLogsTab.tsx:165:17",className:"w-8 h-8 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"})}):x.length===0?s.jsxs("div",{"code-path":"src/pages/LoginLogsTab.tsx:168:15",className:"flex flex-col items-center justify-center py-16 text-slate-500",children:[s.jsx(I,{"code-path":"src/pages/LoginLogsTab.tsx:169:17",className:"h-8 w-8 mb-3 opacity-40"}),s.jsx("p",{"code-path":"src/pages/LoginLogsTab.tsx:170:17",className:"text-sm",children:"暂无登录日志"})]}):s.jsxs(y,{"code-path":"src/pages/LoginLogsTab.tsx:173:15",children:[s.jsx(C,{"code-path":"src/pages/LoginLogsTab.tsx:174:17",children:s.jsxs(L,{"code-path":"src/pages/LoginLogsTab.tsx:175:19",className:"border-slate-800 hover:bg-transparent",children:[s.jsx(o,{"code-path":"src/pages/LoginLogsTab.tsx:176:21",className:"text-slate-400",children:"登录时间"}),s.jsx(o,{"code-path":"src/pages/LoginLogsTab.tsx:177:21",className:"text-slate-400",children:"用户"}),s.jsx(o,{"code-path":"src/pages/LoginLogsTab.tsx:178:21",className:"text-slate-400",children:"登录方式"}),s.jsx(o,{"code-path":"src/pages/LoginLogsTab.tsx:179:21",className:"text-slate-400",children:"IP"}),s.jsx(o,{"code-path":"src/pages/LoginLogsTab.tsx:180:21",className:"text-slate-400",children:"归属地"}),s.jsx(o,{"code-path":"src/pages/LoginLogsTab.tsx:181:21",className:"text-slate-400",children:"浏览器/OS"}),s.jsx(o,{"code-path":"src/pages/LoginLogsTab.tsx:182:21",className:"text-slate-400",children:"状态"})]})}),s.jsx(w,{"code-path":"src/pages/LoginLogsTab.tsx:185:17",children:x.map(e=>s.jsxs(L,{"code-path":"src/pages/LoginLogsTab.tsx:187:21",className:"border-slate-800 hover:bg-slate-800/50",children:[s.jsx(c,{"code-path":"src/pages/LoginLogsTab.tsx:188:23",children:s.jsx("span",{"code-path":"src/pages/LoginLogsTab.tsx:189:25",className:"text-sm text-slate-400",children:e.login_at?new Date(e.login_at).toLocaleString():"--"})}),s.jsx(c,{"code-path":"src/pages/LoginLogsTab.tsx:193:23",children:s.jsx("span",{"code-path":"src/pages/LoginLogsTab.tsx:194:25",className:"text-sm text-slate-200 font-medium",children:e.username||"--"})}),s.jsx(c,{"code-path":"src/pages/LoginLogsTab.tsx:196:23",children:s.jsx(i,{"code-path":"src/pages/LoginLogsTab.tsx:197:25",variant:"outline",className:"border-blue-500/30 text-blue-400 bg-blue-500/10 text-xs",children:j(e.login_type)})}),s.jsx(c,{"code-path":"src/pages/LoginLogsTab.tsx:201:23",children:s.jsx("code",{"code-path":"src/pages/LoginLogsTab.tsx:202:25",className:"text-xs text-slate-400 bg-slate-800 px-2 py-0.5 rounded",children:e.ip||"--"})}),s.jsx(c,{"code-path":"src/pages/LoginLogsTab.tsx:206:23",children:s.jsxs("span",{"code-path":"src/pages/LoginLogsTab.tsx:207:25",className:"text-xs text-slate-500 flex items-center gap-1",children:[s.jsx(A,{"code-path":"src/pages/LoginLogsTab.tsx:208:27",className:"h-3 w-3"}),e.location||"--"]})}),s.jsx(c,{"code-path":"src/pages/LoginLogsTab.tsx:212:23",children:s.jsxs("span",{"code-path":"src/pages/LoginLogsTab.tsx:213:25",className:"text-xs text-slate-500 flex items-center gap-1",title:e.user_agent,children:[s.jsx(R,{"code-path":"src/pages/LoginLogsTab.tsx:214:27",className:"h-3 w-3 flex-shrink-0"}),e.browser||e.os?[e.browser,e.os].filter(Boolean).join(" / "):e.user_agent?e.user_agent.length>40?e.user_agent.slice(0,40)+"...":e.user_agent:"--"]})}),s.jsx(c,{"code-path":"src/pages/LoginLogsTab.tsx:224:23",children:T(e.status,e.fail_reason)})]},e.id))})]})})})})]})}export{M as LoginLogsTab}; diff --git a/backend/static/assets/MetricsExplorer-Db8y37-1.js b/backend/static/assets/MetricsExplorer-Db8y37-1.js deleted file mode 100644 index 6eea951..0000000 --- a/backend/static/assets/MetricsExplorer-Db8y37-1.js +++ /dev/null @@ -1 +0,0 @@ -import{r as l,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{C as u,a as b}from"./card-BIfzBCEy.js";import{S as I,a as z,b as P,c as B,d as V}from"./select-CiTqGGhE.js";import{B as q}from"./index-Dungj95X.js";import{I as F}from"./input-CXoUQQLm.js";import{m as M}from"./metrics-DW1ylkmD.js";import{S as H,af as K,u as G,A as y,P as Q,D as U,N as W,H as v,g as J}from"./vendor-icons-DmqcWdzX.js";import"./index-5FEebgvX.js";const N={cpu:{label:"CPU",icon:e.jsx(J,{"code-path":"src/pages/MetricsExplorer.tsx:35:30",className:"h-4 w-4"})},memory:{label:"内存",icon:e.jsx(v,{"code-path":"src/pages/MetricsExplorer.tsx:36:32",className:"h-4 w-4"})},disk:{label:"磁盘",icon:e.jsx(v,{"code-path":"src/pages/MetricsExplorer.tsx:37:30",className:"h-4 w-4"})},network:{label:"网络",icon:e.jsx(W,{"code-path":"src/pages/MetricsExplorer.tsx:38:33",className:"h-4 w-4"})},middleware:{label:"中间件",icon:e.jsx(U,{"code-path":"src/pages/MetricsExplorer.tsx:39:37",className:"h-4 w-4"})},device:{label:"设备",icon:e.jsx(y,{"code-path":"src/pages/MetricsExplorer.tsx:40:32",className:"h-4 w-4"})}};function ce(){const[n,w]=l.useState([]),[j,S]=l.useState([]),[x,C]=l.useState(""),[o,E]=l.useState([]),[k,f]=l.useState([]),[T,O]=l.useState(!0),[m,_]=l.useState(""),A=l.useCallback(async()=>{try{const s=await M.getTargets({page_size:200});w(s?.list||[])}catch{}finally{O(!1)}},[]),D=l.useCallback(async()=>{try{const s=await M.getNames();S(s||[])}catch{}},[]);l.useEffect(()=>{A(),D()},[]),l.useEffect(()=>{if(!x||o.length===0||!n.find(c=>String(c.id)===x))return;const t=Math.floor(Date.now()/1e3),r=t-3600;Promise.all(o.map(c=>M.query({target_id:x,metric_name:c,from:String(r),to:String(t),limit:200}).then(a=>Array.isArray(a)?a:[]).catch(()=>[]))).then(c=>{f(c.flat())})},[x,o,n]);const L=m?j.filter(s=>s.toLowerCase().includes(m.toLowerCase())):j,g=n.find(s=>String(s.id)===x),R=L.reduce((s,t)=>{const r=t.split("_")[0]||"other";return s[r]||(s[r]=[]),s[r].push(t),s},{}),d={};k.forEach(s=>{d[s.timestamp]||(d[s.timestamp]={}),d[s.timestamp][s.metric_name]=s.value});const p=Object.keys(d).map(Number).sort((s,t)=>s-t),$=Math.max(1,...Object.values(d).flatMap(s=>Object.values(s))),h=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899","#06b6d4","#f97316"];return e.jsxs("div",{"code-path":"src/pages/MetricsExplorer.tsx:119:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/pages/MetricsExplorer.tsx:121:7",className:"flex items-center gap-4 flex-wrap",children:[e.jsxs(I,{"code-path":"src/pages/MetricsExplorer.tsx:122:9",value:x,onValueChange:C,children:[e.jsx(z,{"code-path":"src/pages/MetricsExplorer.tsx:123:11",className:"w-64 bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsx(P,{"code-path":"src/pages/MetricsExplorer.tsx:124:13",placeholder:T?"加载中...":"选择监控目标..."})}),e.jsx(B,{"code-path":"src/pages/MetricsExplorer.tsx:126:11",className:"bg-slate-800 border-slate-700 text-slate-200 max-h-80",children:n.map(s=>e.jsx(V,{"code-path":"src/pages/MetricsExplorer.tsx:128:15",value:String(s.id),children:e.jsxs("span",{"code-path":"src/pages/MetricsExplorer.tsx:129:17",className:"flex items-center gap-2",children:[e.jsx("span",{"code-path":"src/pages/MetricsExplorer.tsx:130:19",className:`inline-block w-1.5 h-1.5 rounded-full ${s.status==="online"?"bg-emerald-400":"bg-slate-500"}`}),s.name," (",s.ip||s.type,")"]})},s.id))})]}),e.jsxs("div",{"code-path":"src/pages/MetricsExplorer.tsx:138:9",className:"relative flex-1 max-w-sm",children:[e.jsx(H,{"code-path":"src/pages/MetricsExplorer.tsx:139:11",className:"absolute left-2.5 top-2 h-4 w-4 text-slate-500"}),e.jsx(F,{"code-path":"src/pages/MetricsExplorer.tsx:140:11",className:"pl-8 bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] h-9",placeholder:"搜索指标...",value:m,onChange:s=>_(s.target.value)})]}),e.jsx(q,{"code-path":"src/pages/MetricsExplorer.tsx:147:9",variant:"ghost",size:"sm",onClick:()=>{E([]),f([])},children:"清除"})]}),x?e.jsxs("div",{"code-path":"src/pages/MetricsExplorer.tsx:160:9",className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsx(u,{"code-path":"src/pages/MetricsExplorer.tsx:162:11",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] lg:col-span-1",children:e.jsxs(b,{"code-path":"src/pages/MetricsExplorer.tsx:163:13",className:"p-4",children:[e.jsxs("div",{"code-path":"src/pages/MetricsExplorer.tsx:164:15",className:"flex items-center gap-2 mb-3",children:[e.jsx(G,{"code-path":"src/pages/MetricsExplorer.tsx:165:17",className:"h-4 w-4 text-[var(--dg-text-muted)]"}),e.jsx("h3",{"code-path":"src/pages/MetricsExplorer.tsx:166:17",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:"指标列表"}),e.jsxs("span",{"code-path":"src/pages/MetricsExplorer.tsx:167:17",className:"text-xs text-[var(--dg-text-muted)] ml-auto",children:[o.length," 已选"]})]}),e.jsx("div",{"code-path":"src/pages/MetricsExplorer.tsx:169:15",className:"space-y-4 max-h-[60vh] overflow-y-auto",children:Object.entries(R).map(([s,t])=>e.jsxs("div",{"code-path":"src/pages/MetricsExplorer.tsx:171:19",children:[e.jsxs("div",{"code-path":"src/pages/MetricsExplorer.tsx:172:21",className:"flex items-center gap-1.5 mb-1.5 text-xs text-[var(--dg-text-muted)]",children:[N[s]?.icon,e.jsx("span",{"code-path":"src/pages/MetricsExplorer.tsx:174:23",children:N[s]?.label||s})]}),e.jsx("div",{"code-path":"src/pages/MetricsExplorer.tsx:176:21",className:"space-y-0.5",children:t.map(r=>{const c=o.includes(r);return e.jsxs("label",{"code-path":"src/pages/MetricsExplorer.tsx:180:27",className:`flex items-center gap-2 px-2 py-1 rounded cursor-pointer text-xs transition-colors ${c?"bg-blue-500/10 text-blue-300":"text-[var(--dg-text-secondary)] hover:bg-[var(--dg-bg-tertiary)]"}`,children:[e.jsx("input",{"code-path":"src/pages/MetricsExplorer.tsx:181:29",type:"checkbox",className:"rounded border-slate-600 bg-slate-800 accent-blue-500",checked:c,onChange:()=>{E(a=>c?a.filter(i=>i!==r):[...a,r])}}),e.jsx("span",{"code-path":"src/pages/MetricsExplorer.tsx:191:29",className:"truncate",children:r})]},r)})})]},s))})]})}),e.jsx(u,{"code-path":"src/pages/MetricsExplorer.tsx:203:11",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] lg:col-span-2",children:e.jsxs(b,{"code-path":"src/pages/MetricsExplorer.tsx:204:13",className:"p-4",children:[e.jsxs("div",{"code-path":"src/pages/MetricsExplorer.tsx:205:15",className:"flex items-center gap-2 mb-3",children:[e.jsx(y,{"code-path":"src/pages/MetricsExplorer.tsx:206:17",className:"h-4 w-4 text-[var(--dg-text-muted)]"}),e.jsxs("h3",{"code-path":"src/pages/MetricsExplorer.tsx:207:17",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:[g?.name||""," — 最近 1 小时"]})]}),o.length===0?e.jsx("div",{"code-path":"src/pages/MetricsExplorer.tsx:212:17",className:"h-64 flex items-center justify-center text-sm text-[var(--dg-text-muted)] border border-dashed border-[var(--dg-border)] rounded-lg",children:e.jsxs("div",{"code-path":"src/pages/MetricsExplorer.tsx:213:19",className:"text-center",children:[e.jsx(Q,{"code-path":"src/pages/MetricsExplorer.tsx:214:21",className:"h-8 w-8 text-slate-600 mx-auto mb-2"}),"请从左侧勾选指标"]})}):p.length===0?e.jsx("div",{"code-path":"src/pages/MetricsExplorer.tsx:219:17",className:"h-64 flex items-center justify-center text-sm text-[var(--dg-text-muted)] border border-dashed border-[var(--dg-border)] rounded-lg",children:"暂无数据"}):e.jsx("div",{"code-path":"src/pages/MetricsExplorer.tsx:223:17",className:"h-80 overflow-x-auto",children:e.jsxs("svg",{"code-path":"src/pages/MetricsExplorer.tsx:224:19",viewBox:`0 0 ${Math.max(p.length*4,400)} 300`,className:"w-full h-full min-w-[400px]",children:[[0,25,50,75,100].map(s=>e.jsx("line",{"code-path":"src/pages/MetricsExplorer.tsx:227:23",x1:"0",y1:300-s/100*260,x2:Math.max(p.length*4,400),y2:300-s/100*260,stroke:"#1e293b",strokeDasharray:"3 3"},s)),o.map((s,t)=>{const r=p.map((a,i)=>({x:i*4+2,y:300-(d[a][s]??0)/$*260})).filter(a=>d[p[Math.round((a.x-2)/4)]]?.[s]!=null);if(r.length<2)return null;const c=r.map((a,i)=>`${i===0?"M":"L"}${a.x} ${a.y}`).join(" ");return e.jsx("g",{"code-path":"src/pages/MetricsExplorer.tsx:237:25",children:e.jsx("path",{"code-path":"src/pages/MetricsExplorer.tsx:238:27",d:c,fill:"none",stroke:h[t%h.length],strokeWidth:"1.5"})},s)}),p.filter((s,t)=>t%15===0).map((s,t)=>e.jsx("text",{"code-path":"src/pages/MetricsExplorer.tsx:244:23",x:t*60+2,y:"295",fill:"#475569",fontSize:"9",children:new Date(s*1e3).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"})},s))]})}),o.length>0&&e.jsx("div",{"code-path":"src/pages/MetricsExplorer.tsx:253:17",className:"flex flex-wrap gap-3 mt-3",children:o.map((s,t)=>e.jsxs("div",{"code-path":"src/pages/MetricsExplorer.tsx:255:21",className:"flex items-center gap-1.5 text-xs text-[var(--dg-text-secondary)]",children:[e.jsx("span",{"code-path":"src/pages/MetricsExplorer.tsx:256:23",className:"w-2.5 h-2.5 rounded-full",style:{backgroundColor:h[t%h.length]}}),s]},s))})]})})]}):e.jsx(u,{"code-path":"src/pages/MetricsExplorer.tsx:153:9",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(b,{"code-path":"src/pages/MetricsExplorer.tsx:154:11",className:"p-12 text-center",children:[e.jsx(K,{"code-path":"src/pages/MetricsExplorer.tsx:155:13",className:"h-12 w-12 text-slate-600 mx-auto mb-4"}),e.jsx("p",{"code-path":"src/pages/MetricsExplorer.tsx:156:13",className:"text-[var(--dg-text-muted)]",children:"请先选择监控目标,然后勾选要查看的指标"})]})}),g&&Object.keys(g.latest_metrics||{}).length>0&&e.jsx("div",{"code-path":"src/pages/MetricsExplorer.tsx:269:9",className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-3",children:Object.entries(g.latest_metrics).map(([s,t])=>e.jsxs("div",{"code-path":"src/pages/MetricsExplorer.tsx:271:13",className:"bg-[var(--dg-bg-secondary)] rounded-lg p-3 border border-[var(--dg-border)] text-center",children:[e.jsx("p",{"code-path":"src/pages/MetricsExplorer.tsx:272:15",className:"text-[10px] text-[var(--dg-text-muted)] truncate",children:s}),e.jsx("p",{"code-path":"src/pages/MetricsExplorer.tsx:273:15",className:"text-lg font-bold text-[var(--dg-text-primary)]",children:typeof t=="number"?t.toFixed(1):"--"})]},s))})]})}export{ce as MetricsExplorer,ce as default}; diff --git a/backend/static/assets/MonitorCenter-CkAJXvtS.js b/backend/static/assets/MonitorCenter-CkAJXvtS.js deleted file mode 100644 index b4bf916..0000000 --- a/backend/static/assets/MonitorCenter-CkAJXvtS.js +++ /dev/null @@ -1 +0,0 @@ -import{r as i,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{D as K,j as ue,B as w,a as X,b as W,c as Y,d as Z,e as J,f as Ne,t as C,m as ve}from"./index-Dungj95X.js";import{HostMonitor as je}from"./HostMonitor-C6-o-ZDP.js";import{C as h,a as M}from"./card-BIfzBCEy.js";import{B as u}from"./badge-CGJlVD3L.js";import{m as be,s as $}from"./metrics-DW1ylkmD.js";import{L as O,A as R,D as B,h as ee,aK as Se,aL as z,H as ye,aM as te,P as se,T as ae,G as I,aN as fe,R as we,b as Pe,a as Ce,C as _e,g as Te}from"./vendor-icons-DmqcWdzX.js";import{I as y}from"./input-CXoUQQLm.js";import{L as j}from"./label-CMpUoC87.js";import{S as re,a as oe,b as ce,c as de,d as A}from"./select-CiTqGGhE.js";import{T as ie,a as ne,b as q,c as l,d as xe,e as p}from"./table-B2F10oba.js";import{S as De}from"./switch-Bxiq4EHp.js";import{s as L}from"./site-Cslo2fp0.js";import"./agent-CZzlLHxR.js";import"./unwrap-DPwG25JA.js";import"./tabs-D87nAyJR.js";import"./AreaChart-yrR-Mxho.js";import"./index-5FEebgvX.js";function Fe(t){return t==null||t===0?"--":t>1e9?`${(t/1e9).toFixed(1)} GB`:t>1e6?`${(t/1e6).toFixed(1)} MB`:t>1e3?`${(t/1e3).toFixed(1)} KB`:`${t} B`}function E(t){return t==null||Number.isNaN(t)?"--":`${(t*100).toFixed(1)}%`}function F(t,n=0){return t==null||Number.isNaN(t)?"--":t.toFixed(n)}function ke(t){switch(t){case"online":return"text-emerald-400";case"warning":return"text-amber-400";case"error":return"text-red-400";default:return"text-slate-500"}}function Le(t){switch(t){case"online":return"bg-emerald-400";case"warning":return"bg-amber-400";case"error":return"bg-red-400";default:return"bg-slate-500"}}function Ie(){const[t,n]=i.useState([]),[d,N]=i.useState(!0),[v,_]=i.useState(""),T=i.useCallback(async()=>{try{N(!0),_("");const r=await be.getTargets({type:"middleware",page_size:200});n(r?.list||[])}catch(r){_(r.message||"加载失败"),n([])}finally{N(!1)}},[]);i.useEffect(()=>{T()},[]);const b=t.filter(r=>r.type==="redis"||r.name?.toLowerCase().includes("redis")),o=t.filter(r=>r.type==="mysql"||r.name?.toLowerCase().includes("mysql")),x=b.find(r=>r.status==="online")||b[0],c=x?.latest_metrics||{},m=o.find(r=>r.status==="online")||o[0],S=m?.latest_metrics||{};return e.jsxs("div",{"code-path":"src/pages/MiddlewareMonitor.tsx:97:5",className:"space-y-6",children:[d&&e.jsxs("div",{"code-path":"src/pages/MiddlewareMonitor.tsx:99:9",className:"flex items-center justify-center py-12",children:[e.jsx(O,{"code-path":"src/pages/MiddlewareMonitor.tsx:100:11",className:"h-6 w-6 animate-spin text-slate-500 mr-2"}),e.jsx("span",{"code-path":"src/pages/MiddlewareMonitor.tsx:101:11",className:"text-sm text-[var(--dg-text-muted)]",children:"正在加载中间件指标..."})]}),v&&!d&&e.jsx(h,{"code-path":"src/pages/MiddlewareMonitor.tsx:106:9",className:"bg-[var(--dg-bg-secondary)] border-red-500/30",children:e.jsxs(M,{"code-path":"src/pages/MiddlewareMonitor.tsx:107:11",className:"p-6 text-center",children:[e.jsx(R,{"code-path":"src/pages/MiddlewareMonitor.tsx:108:13",className:"h-8 w-8 text-red-400 mx-auto mb-2"}),e.jsx("p",{"code-path":"src/pages/MiddlewareMonitor.tsx:109:13",className:"text-sm text-red-400",children:v}),e.jsx("p",{"code-path":"src/pages/MiddlewareMonitor.tsx:110:13",className:"text-xs text-[var(--dg-text-muted)] mt-2",children:"请确认后端服务可用且已配置中间件采集"})]})}),!d&&!v&&t.length===0&&e.jsx(h,{"code-path":"src/pages/MiddlewareMonitor.tsx:116:9",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(M,{"code-path":"src/pages/MiddlewareMonitor.tsx:117:11",className:"p-12 text-center",children:[e.jsx(B,{"code-path":"src/pages/MiddlewareMonitor.tsx:118:13",className:"h-12 w-12 text-slate-600 mx-auto mb-4"}),e.jsx("p",{"code-path":"src/pages/MiddlewareMonitor.tsx:119:13",className:"text-sm text-[var(--dg-text-muted)]",children:"暂无中间件监控目标"}),e.jsx("p",{"code-path":"src/pages/MiddlewareMonitor.tsx:120:13",className:"text-xs text-[var(--dg-text-muted)] mt-2",children:"需在 Agent 配置 Redis / MySQL 连接信息后启用采集"})]})}),e.jsx(h,{"code-path":"src/pages/MiddlewareMonitor.tsx:126:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(M,{"code-path":"src/pages/MiddlewareMonitor.tsx:127:9",className:"p-4",children:[e.jsxs("div",{"code-path":"src/pages/MiddlewareMonitor.tsx:128:11",className:"flex items-center gap-2 mb-4",children:[e.jsx(B,{"code-path":"src/pages/MiddlewareMonitor.tsx:129:13",className:"h-4 w-4 text-red-400"}),e.jsx("h3",{"code-path":"src/pages/MiddlewareMonitor.tsx:130:13",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:"Redis 监控"}),x&&e.jsxs(u,{"code-path":"src/pages/MiddlewareMonitor.tsx:132:15",variant:"outline",className:"ml-auto text-[10px] border-[var(--dg-border)] text-[var(--dg-text-muted)]",children:[x.name," (",x.ip,")"]})]}),x?e.jsxs("div",{"code-path":"src/pages/MiddlewareMonitor.tsx:140:13",className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(f,{"code-path":"src/pages/MiddlewareMonitor.tsx:141:15",label:"连接数",value:F(c.redis_connected_clients)}),e.jsx(f,{"code-path":"src/pages/MiddlewareMonitor.tsx:145:15",label:"内存",value:Fe(c.redis_used_memory)}),e.jsx(f,{"code-path":"src/pages/MiddlewareMonitor.tsx:149:15",label:"命中率",value:E(c.redis_hit_rate)}),e.jsx(f,{"code-path":"src/pages/MiddlewareMonitor.tsx:153:15",label:"QPS",value:F(c.redis_qps,0)})]}):e.jsx("p",{"code-path":"src/pages/MiddlewareMonitor.tsx:138:13",className:"text-sm text-[var(--dg-text-muted)] mb-4",children:"需在 Agent 配置 Redis 连接地址和密码后启用采集。"})]})}),e.jsx(h,{"code-path":"src/pages/MiddlewareMonitor.tsx:163:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(M,{"code-path":"src/pages/MiddlewareMonitor.tsx:164:9",className:"p-4",children:[e.jsxs("div",{"code-path":"src/pages/MiddlewareMonitor.tsx:165:11",className:"flex items-center gap-2 mb-4",children:[e.jsx(ee,{"code-path":"src/pages/MiddlewareMonitor.tsx:166:13",className:"h-4 w-4 text-blue-400"}),e.jsx("h3",{"code-path":"src/pages/MiddlewareMonitor.tsx:167:13",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:"MySQL 监控"}),m&&e.jsxs(u,{"code-path":"src/pages/MiddlewareMonitor.tsx:169:15",variant:"outline",className:"ml-auto text-[10px] border-[var(--dg-border)] text-[var(--dg-text-muted)]",children:[m.name," (",m.ip,")"]})]}),m?e.jsxs("div",{"code-path":"src/pages/MiddlewareMonitor.tsx:177:13",className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(f,{"code-path":"src/pages/MiddlewareMonitor.tsx:178:15",label:"连接数",value:F(S.mysql_connections)}),e.jsx(f,{"code-path":"src/pages/MiddlewareMonitor.tsx:182:15",label:"QPS",value:F(S.mysql_qps,1)}),e.jsx(f,{"code-path":"src/pages/MiddlewareMonitor.tsx:186:15",label:"慢查询",value:F(S.mysql_slow_queries)}),e.jsx(f,{"code-path":"src/pages/MiddlewareMonitor.tsx:190:15",label:"缓冲池命中率",value:E(S.mysql_buffer_hit_rate)})]}):e.jsx("p",{"code-path":"src/pages/MiddlewareMonitor.tsx:175:13",className:"text-sm text-[var(--dg-text-muted)] mb-4",children:"需在 Agent 配置 MySQL 连接地址、用户名和密码后启用采集。"})]})}),t.length>0&&e.jsx(h,{"code-path":"src/pages/MiddlewareMonitor.tsx:201:9",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(M,{"code-path":"src/pages/MiddlewareMonitor.tsx:202:11",className:"p-4",children:[e.jsxs("div",{"code-path":"src/pages/MiddlewareMonitor.tsx:203:13",className:"flex items-center gap-2 mb-4",children:[e.jsx(R,{"code-path":"src/pages/MiddlewareMonitor.tsx:204:15",className:"h-4 w-4 text-[var(--dg-text-muted)]"}),e.jsxs("h3",{"code-path":"src/pages/MiddlewareMonitor.tsx:205:15",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:["中间件实例(",t.length,")"]})]}),e.jsx("div",{"code-path":"src/pages/MiddlewareMonitor.tsx:209:13",className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:t.map(r=>e.jsx($e,{"code-path":"src/pages/MiddlewareMonitor.tsx:211:17",target:r},r.id))})]})}),t.filter(r=>!b.includes(r)&&!o.includes(r)).length>0&&e.jsx("div",{"code-path":"src/pages/MiddlewareMonitor.tsx:220:9",className:"space-y-4",children:t.filter(r=>!b.includes(r)&&!o.includes(r)).map(r=>e.jsx(h,{"code-path":"src/pages/MiddlewareMonitor.tsx:224:15",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(M,{"code-path":"src/pages/MiddlewareMonitor.tsx:225:17",className:"p-4",children:[e.jsxs("div",{"code-path":"src/pages/MiddlewareMonitor.tsx:226:19",className:"flex items-center gap-2 mb-3",children:[e.jsx(Se,{"code-path":"src/pages/MiddlewareMonitor.tsx:227:21",className:`h-3 w-3 ${ke(r.status)}`}),e.jsx("h3",{"code-path":"src/pages/MiddlewareMonitor.tsx:228:21",className:"text-sm font-medium text-[var(--dg-text-primary)] capitalize",children:r.type}),e.jsxs(u,{"code-path":"src/pages/MiddlewareMonitor.tsx:229:21",variant:"outline",className:"text-[10px] border-[var(--dg-border)] text-[var(--dg-text-muted)]",children:[r.name," (",r.ip,")"]})]}),Object.keys(r.latest_metrics||{}).length>0?e.jsx("div",{"code-path":"src/pages/MiddlewareMonitor.tsx:234:21",className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:Object.entries(r.latest_metrics).map(([g,D])=>e.jsx(f,{"code-path":"src/pages/MiddlewareMonitor.tsx:236:25",label:g,value:F(D,1)},g))}):e.jsx("p",{"code-path":"src/pages/MiddlewareMonitor.tsx:240:21",className:"text-xs text-[var(--dg-text-muted)]",children:"暂无指标数据"})]})},r.id))})]})}function f({label:t,value:n}){return e.jsxs("div",{"code-path":"src/pages/MiddlewareMonitor.tsx:254:5",className:"bg-[var(--dg-bg-tertiary)] rounded-lg p-3 text-center",children:[e.jsx("p",{"code-path":"src/pages/MiddlewareMonitor.tsx:255:7",className:"text-xs text-[var(--dg-text-muted)]",children:t}),e.jsx("p",{"code-path":"src/pages/MiddlewareMonitor.tsx:256:7",className:"text-lg font-bold text-[var(--dg-text-primary)]",children:n})]})}function $e({target:t}){const n=t.latest_metrics||{},d=Object.keys(n).length;return e.jsxs("div",{"code-path":"src/pages/MiddlewareMonitor.tsx:267:5",className:"bg-[var(--dg-bg-tertiary)] rounded-lg p-3 border border-[var(--dg-border)] hover:border-[var(--dg-border)]/80 transition-colors",children:[e.jsxs("div",{"code-path":"src/pages/MiddlewareMonitor.tsx:268:7",className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{"code-path":"src/pages/MiddlewareMonitor.tsx:269:9",className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{"code-path":"src/pages/MiddlewareMonitor.tsx:270:11",className:`inline-block w-2 h-2 rounded-full ${Le(t.status)}`}),e.jsx("span",{"code-path":"src/pages/MiddlewareMonitor.tsx:271:11",className:"text-sm font-medium text-[var(--dg-text-primary)] truncate",children:t.name})]}),e.jsx(u,{"code-path":"src/pages/MiddlewareMonitor.tsx:273:9",variant:"outline",className:`text-[10px] capitalize ${t.status==="online"?"border-emerald-400/50 text-emerald-400":"border-[var(--dg-border)] text-[var(--dg-text-muted)]"}`,children:t.status})]}),e.jsxs("div",{"code-path":"src/pages/MiddlewareMonitor.tsx:280:7",className:"text-xs text-[var(--dg-text-muted)] mb-2",children:[t.ip," · ",t.type]}),d>0?e.jsxs("div",{"code-path":"src/pages/MiddlewareMonitor.tsx:284:9",className:"flex flex-wrap gap-1.5",children:[Object.entries(n).slice(0,4).map(([N,v])=>e.jsxs("span",{"code-path":"src/pages/MiddlewareMonitor.tsx:286:13",className:"inline-flex items-center gap-1 text-[10px] bg-[var(--dg-bg-primary)] rounded px-1.5 py-0.5 text-[var(--dg-text-secondary)]",children:[e.jsx("span",{"code-path":"src/pages/MiddlewareMonitor.tsx:287:15",className:"text-[var(--dg-text-muted)]",children:N}),e.jsx("span",{"code-path":"src/pages/MiddlewareMonitor.tsx:288:15",className:"font-mono font-medium text-[var(--dg-text-primary)]",children:typeof v=="number"?v.toFixed(1):v})]},N)),d>4&&e.jsxs("span",{"code-path":"src/pages/MiddlewareMonitor.tsx:294:13",className:"text-[10px] text-[var(--dg-text-muted)]",children:["+",d-4," 项"]})]}):e.jsx("p",{"code-path":"src/pages/MiddlewareMonitor.tsx:298:9",className:"text-[10px] text-[var(--dg-text-muted)]",children:"暂无指标"})]})}const G={name:"",ip:"",port:161,snmp_version:"v2c",community:"public",template_id:""};function qe(){const[t,n]=i.useState({total:0,online:0,abnormal:0}),[d,N]=i.useState([]),[v,_]=i.useState(!0),[T,b]=i.useState(!1),[o,x]=i.useState({...G}),[c,m]=i.useState(!1),S=i.useCallback(async()=>{try{const a=await $.getStats();n(a)}catch{}},[]),r=i.useCallback(async()=>{try{const a=await $.getDevices();N(a.list??[])}catch{N([])}finally{_(!1)}},[]),g=i.useCallback(()=>{S(),r()},[S,r]);i.useEffect(()=>{g()},[g]);const D=async()=>{if(!(!o.name.trim()||!o.ip.trim())){m(!0);try{await $.createDevice({name:o.name.trim(),ip:o.ip.trim(),port:Number(o.port),snmp_version:o.snmp_version,community:o.community.trim(),template_id:o.template_id?Number(o.template_id):0}),b(!1),x({...G}),g()}catch{}finally{m(!1)}}},H=async a=>{try{await $.deleteDevice(a),g()}catch{}},P=a=>a==="online"?e.jsx(u,{"code-path":"src/pages/SNMPMonitor.tsx:146:14",className:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",children:"在线"}):a==="abnormal"?e.jsx(u,{"code-path":"src/pages/SNMPMonitor.tsx:149:14",className:"bg-red-500/15 text-red-400 border-red-500/30",children:"异常"}):e.jsx(u,{"code-path":"src/pages/SNMPMonitor.tsx:151:12",className:"bg-slate-500/15 text-slate-400 border-slate-500/30",children:"离线"});return e.jsxs("div",{"code-path":"src/pages/SNMPMonitor.tsx:156:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/pages/SNMPMonitor.tsx:158:7",className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(h,{"code-path":"src/pages/SNMPMonitor.tsx:159:9",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(M,{"code-path":"src/pages/SNMPMonitor.tsx:160:11",className:"p-4",children:[e.jsxs("div",{"code-path":"src/pages/SNMPMonitor.tsx:161:13",className:"flex items-center gap-2 mb-3",children:[e.jsx(z,{"code-path":"src/pages/SNMPMonitor.tsx:162:15",className:"h-4 w-4 text-cyan-400"}),e.jsx("h3",{"code-path":"src/pages/SNMPMonitor.tsx:163:15",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:"网络设备"})]}),e.jsx("p",{"code-path":"src/pages/SNMPMonitor.tsx:165:13",className:"text-xs text-[var(--dg-text-muted)] mb-3",children:"交换机 / 路由器 / 防火墙"}),e.jsxs("div",{"code-path":"src/pages/SNMPMonitor.tsx:166:13",className:"space-y-2",children:[e.jsxs("div",{"code-path":"src/pages/SNMPMonitor.tsx:167:15",className:"flex justify-between text-sm",children:[e.jsx("span",{"code-path":"src/pages/SNMPMonitor.tsx:168:17",className:"text-[var(--dg-text-muted)]",children:"设备总数"}),e.jsx("span",{"code-path":"src/pages/SNMPMonitor.tsx:169:17",className:"text-[var(--dg-text-primary)] font-mono",children:t.total})]}),e.jsxs("div",{"code-path":"src/pages/SNMPMonitor.tsx:171:15",className:"flex justify-between text-sm",children:[e.jsx("span",{"code-path":"src/pages/SNMPMonitor.tsx:172:17",className:"text-[var(--dg-text-muted)]",children:"在线"}),e.jsx("span",{"code-path":"src/pages/SNMPMonitor.tsx:173:17",className:"text-emerald-400 font-mono",children:t.online})]})]})]})}),e.jsx(h,{"code-path":"src/pages/SNMPMonitor.tsx:179:9",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(M,{"code-path":"src/pages/SNMPMonitor.tsx:180:11",className:"p-4",children:[e.jsxs("div",{"code-path":"src/pages/SNMPMonitor.tsx:181:13",className:"flex items-center gap-2 mb-3",children:[e.jsx(ye,{"code-path":"src/pages/SNMPMonitor.tsx:182:15",className:"h-4 w-4 text-purple-400"}),e.jsx("h3",{"code-path":"src/pages/SNMPMonitor.tsx:183:15",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:"服务器硬件"})]}),e.jsx("p",{"code-path":"src/pages/SNMPMonitor.tsx:185:13",className:"text-xs text-[var(--dg-text-muted)] mb-3",children:"iLO / iDRAC / IPMI"}),e.jsx("div",{"code-path":"src/pages/SNMPMonitor.tsx:186:13",className:"space-y-2",children:e.jsxs("div",{"code-path":"src/pages/SNMPMonitor.tsx:187:15",className:"flex justify-between text-sm",children:[e.jsx("span",{"code-path":"src/pages/SNMPMonitor.tsx:188:17",className:"text-[var(--dg-text-muted)]",children:"异常"}),e.jsx("span",{"code-path":"src/pages/SNMPMonitor.tsx:189:17",className:"text-red-400 font-mono",children:t.abnormal})]})})]})})]}),e.jsx(h,{"code-path":"src/pages/SNMPMonitor.tsx:197:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(M,{"code-path":"src/pages/SNMPMonitor.tsx:198:9",className:"p-4",children:[e.jsxs("div",{"code-path":"src/pages/SNMPMonitor.tsx:199:11",className:"flex items-center gap-2 mb-3",children:[e.jsx(te,{"code-path":"src/pages/SNMPMonitor.tsx:200:13",className:"h-4 w-4 text-[var(--dg-text-muted)]"}),e.jsx("h3",{"code-path":"src/pages/SNMPMonitor.tsx:201:13",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:"OID 监控模板"})]}),e.jsx("p",{"code-path":"src/pages/SNMPMonitor.tsx:203:11",className:"text-sm text-[var(--dg-text-muted)]",children:"支持 Zabbix 兼容的 SNMP OID 模板(XML 格式),内置思科/H3C/华为交换机模板、服务器硬件监控模板。"}),e.jsx("div",{"code-path":"src/pages/SNMPMonitor.tsx:206:11",className:"mt-3 grid grid-cols-2 md:grid-cols-4 gap-2 text-xs text-[var(--dg-text-secondary)]",children:["思科交换机","H3C S5000","华为交换机","iLO/Dell"].map(a=>e.jsx("div",{"code-path":"src/pages/SNMPMonitor.tsx:208:15",className:"bg-[var(--dg-bg-tertiary)] rounded px-2 py-1 text-center border border-[var(--dg-border)]",children:a},a))})]})}),e.jsx(h,{"code-path":"src/pages/SNMPMonitor.tsx:220:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(M,{"code-path":"src/pages/SNMPMonitor.tsx:221:9",className:"p-4",children:[e.jsxs("div",{"code-path":"src/pages/SNMPMonitor.tsx:222:11",className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{"code-path":"src/pages/SNMPMonitor.tsx:223:13",className:"flex items-center gap-2",children:[e.jsx(z,{"code-path":"src/pages/SNMPMonitor.tsx:224:15",className:"h-4 w-4 text-cyan-400"}),e.jsxs("h3",{"code-path":"src/pages/SNMPMonitor.tsx:225:15",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:["SNMP 设备列表",!v&&e.jsxs("span",{"code-path":"src/pages/SNMPMonitor.tsx:228:19",className:"ml-2 text-xs text-[var(--dg-text-muted)] font-normal",children:["(",d.length," 台)"]})]})]}),e.jsxs(K,{"code-path":"src/pages/SNMPMonitor.tsx:236:13",open:T,onOpenChange:b,children:[e.jsx(ue,{"code-path":"src/pages/SNMPMonitor.tsx:237:15",asChild:!0,children:e.jsxs(w,{"code-path":"src/pages/SNMPMonitor.tsx:238:17",size:"sm",className:"bg-cyan-500/10 text-cyan-400 hover:bg-cyan-500/20 border border-cyan-500/30",children:[e.jsx(se,{"code-path":"src/pages/SNMPMonitor.tsx:239:19",className:"h-4 w-4"}),"添加设备"]})}),e.jsxs(X,{"code-path":"src/pages/SNMPMonitor.tsx:243:15",className:"bg-slate-900 border-[var(--dg-border)] text-[var(--dg-text-primary)] sm:max-w-md",children:[e.jsxs(W,{"code-path":"src/pages/SNMPMonitor.tsx:244:17",children:[e.jsx(Y,{"code-path":"src/pages/SNMPMonitor.tsx:245:19",className:"text-[var(--dg-text-primary)]",children:"添加 SNMP 设备"}),e.jsx(Z,{"code-path":"src/pages/SNMPMonitor.tsx:246:19",className:"text-[var(--dg-text-muted)]",children:"输入设备信息以开始 SNMP 监控采集。"})]}),e.jsxs("div",{"code-path":"src/pages/SNMPMonitor.tsx:251:17",className:"grid gap-4 py-2",children:[e.jsxs("div",{"code-path":"src/pages/SNMPMonitor.tsx:253:19",className:"grid gap-1.5",children:[e.jsx(j,{"code-path":"src/pages/SNMPMonitor.tsx:254:21",htmlFor:"snmp-name",className:"text-[var(--dg-text-muted)]",children:"设备名称"}),e.jsx(y,{"code-path":"src/pages/SNMPMonitor.tsx:257:21",id:"snmp-name",placeholder:"例如: 核心交换机",value:o.name,onChange:a=>x({...o,name:a.target.value}),className:"bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),e.jsxs("div",{"code-path":"src/pages/SNMPMonitor.tsx:267:19",className:"grid gap-1.5",children:[e.jsx(j,{"code-path":"src/pages/SNMPMonitor.tsx:268:21",htmlFor:"snmp-ip",className:"text-[var(--dg-text-muted)]",children:"IP 地址"}),e.jsx(y,{"code-path":"src/pages/SNMPMonitor.tsx:271:21",id:"snmp-ip",placeholder:"例如: 192.168.1.1",value:o.ip,onChange:a=>x({...o,ip:a.target.value}),className:"bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),e.jsxs("div",{"code-path":"src/pages/SNMPMonitor.tsx:281:19",className:"grid gap-1.5",children:[e.jsx(j,{"code-path":"src/pages/SNMPMonitor.tsx:282:21",htmlFor:"snmp-port",className:"text-[var(--dg-text-muted)]",children:"SNMP 端口"}),e.jsx(y,{"code-path":"src/pages/SNMPMonitor.tsx:285:21",id:"snmp-port",type:"number",placeholder:"161",value:o.port,onChange:a=>x({...o,port:Number(a.target.value)||161}),className:"bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),e.jsxs("div",{"code-path":"src/pages/SNMPMonitor.tsx:296:19",className:"grid gap-1.5",children:[e.jsx(j,{"code-path":"src/pages/SNMPMonitor.tsx:297:21",htmlFor:"snmp-version",className:"text-[var(--dg-text-muted)]",children:"SNMP 版本"}),e.jsxs(re,{"code-path":"src/pages/SNMPMonitor.tsx:300:21",value:o.snmp_version,onValueChange:a=>x({...o,snmp_version:a}),children:[e.jsx(oe,{"code-path":"src/pages/SNMPMonitor.tsx:304:23",id:"snmp-version",className:"w-full bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",children:e.jsx(ce,{"code-path":"src/pages/SNMPMonitor.tsx:308:25"})}),e.jsxs(de,{"code-path":"src/pages/SNMPMonitor.tsx:310:23",className:"bg-slate-800 border-slate-700 text-slate-200",children:[e.jsx(A,{"code-path":"src/pages/SNMPMonitor.tsx:311:25",value:"v2c",children:"v2c"}),e.jsx(A,{"code-path":"src/pages/SNMPMonitor.tsx:312:25",value:"v3",children:"v3"})]})]})]}),e.jsxs("div",{"code-path":"src/pages/SNMPMonitor.tsx:318:19",className:"grid gap-1.5",children:[e.jsx(j,{"code-path":"src/pages/SNMPMonitor.tsx:319:21",htmlFor:"snmp-community",className:"text-[var(--dg-text-muted)]",children:"Community"}),e.jsx(y,{"code-path":"src/pages/SNMPMonitor.tsx:322:21",id:"snmp-community",placeholder:"public",value:o.community,onChange:a=>x({...o,community:a.target.value}),className:"bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),e.jsxs("div",{"code-path":"src/pages/SNMPMonitor.tsx:332:19",className:"grid gap-1.5",children:[e.jsx(j,{"code-path":"src/pages/SNMPMonitor.tsx:333:21",htmlFor:"snmp-template",className:"text-[var(--dg-text-muted)]",children:"模板 ID"}),e.jsx(y,{"code-path":"src/pages/SNMPMonitor.tsx:336:21",id:"snmp-template",type:"number",placeholder:"模板 ID",value:o.template_id,onChange:a=>x({...o,template_id:a.target.value}),className:"bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]})]}),e.jsxs(J,{"code-path":"src/pages/SNMPMonitor.tsx:347:17",children:[e.jsx(w,{"code-path":"src/pages/SNMPMonitor.tsx:348:19",variant:"outline",onClick:()=>b(!1),className:"border-[var(--dg-border)] text-[var(--dg-text-muted)] hover:bg-slate-800",children:"取消"}),e.jsx(w,{"code-path":"src/pages/SNMPMonitor.tsx:355:19",onClick:D,disabled:c||!o.name.trim()||!o.ip.trim(),className:"bg-cyan-500/10 text-cyan-400 hover:bg-cyan-500/20 border border-cyan-500/30",children:c?"添加中...":"确认添加"})]})]})]})]}),v?e.jsx("div",{"code-path":"src/pages/SNMPMonitor.tsx:369:13",className:"py-12 text-center text-sm text-[var(--dg-text-muted)]",children:"加载中..."}):d.length===0?e.jsx("div",{"code-path":"src/pages/SNMPMonitor.tsx:371:13",className:"py-12 text-center text-sm text-[var(--dg-text-muted)] border border-dashed border-[var(--dg-border)] rounded-lg",children:"暂无 SNMP 设备,点击「添加设备」开始监控"}):e.jsxs(ie,{"code-path":"src/pages/SNMPMonitor.tsx:375:13",children:[e.jsx(ne,{"code-path":"src/pages/SNMPMonitor.tsx:376:15",children:e.jsxs(q,{"code-path":"src/pages/SNMPMonitor.tsx:377:17",className:"border-[var(--dg-border)] hover:bg-transparent",children:[e.jsx(l,{"code-path":"src/pages/SNMPMonitor.tsx:378:19",className:"text-[var(--dg-text-muted)]",children:"名称"}),e.jsx(l,{"code-path":"src/pages/SNMPMonitor.tsx:379:19",className:"text-[var(--dg-text-muted)]",children:"IP 地址"}),e.jsx(l,{"code-path":"src/pages/SNMPMonitor.tsx:380:19",className:"text-[var(--dg-text-muted)]",children:"端口"}),e.jsx(l,{"code-path":"src/pages/SNMPMonitor.tsx:381:19",className:"text-[var(--dg-text-muted)]",children:"版本"}),e.jsx(l,{"code-path":"src/pages/SNMPMonitor.tsx:382:19",className:"text-[var(--dg-text-muted)]",children:"Community"}),e.jsx(l,{"code-path":"src/pages/SNMPMonitor.tsx:383:19",className:"text-[var(--dg-text-muted)]",children:"模板 ID"}),e.jsx(l,{"code-path":"src/pages/SNMPMonitor.tsx:384:19",className:"text-[var(--dg-text-muted)]",children:"状态"}),e.jsx(l,{"code-path":"src/pages/SNMPMonitor.tsx:385:19",className:"text-[var(--dg-text-muted)] w-16",children:"操作"})]})}),e.jsx(xe,{"code-path":"src/pages/SNMPMonitor.tsx:388:15",children:d.map(a=>e.jsxs(q,{"code-path":"src/pages/SNMPMonitor.tsx:390:19",className:"border-[var(--dg-border)]",children:[e.jsx(p,{"code-path":"src/pages/SNMPMonitor.tsx:391:21",className:"text-[var(--dg-text-primary)] font-medium",children:a.name}),e.jsx(p,{"code-path":"src/pages/SNMPMonitor.tsx:394:21",className:"text-[var(--dg-text-muted)] font-mono text-xs",children:a.ip}),e.jsx(p,{"code-path":"src/pages/SNMPMonitor.tsx:397:21",className:"text-[var(--dg-text-muted)]",children:a.port}),e.jsx(p,{"code-path":"src/pages/SNMPMonitor.tsx:398:21",children:e.jsx(u,{"code-path":"src/pages/SNMPMonitor.tsx:399:23",variant:"outline",className:"border-[var(--dg-border)] text-[var(--dg-text-muted)]",children:a.snmp_version})}),e.jsx(p,{"code-path":"src/pages/SNMPMonitor.tsx:403:21",className:"text-[var(--dg-text-muted)] font-mono text-xs",children:a.community}),e.jsx(p,{"code-path":"src/pages/SNMPMonitor.tsx:406:21",className:"text-[var(--dg-text-muted)]",children:a.template_id||"--"}),e.jsx(p,{"code-path":"src/pages/SNMPMonitor.tsx:407:21",children:P(a.status)}),e.jsx(p,{"code-path":"src/pages/SNMPMonitor.tsx:408:21",children:e.jsx(w,{"code-path":"src/pages/SNMPMonitor.tsx:409:23",variant:"ghost",size:"icon-sm",onClick:()=>H(a.id),className:"text-slate-500 hover:text-red-400 hover:bg-red-500/10",title:"删除设备",children:e.jsx(ae,{"code-path":"src/pages/SNMPMonitor.tsx:416:25",className:"h-4 w-4"})})})]},a.id))})]})]})})]})}const He=[{icon:I,name:"HTTP",color:"text-blue-400",desc:"HTTP URL 状态码 & 响应时间"},{icon:I,name:"HTTPS",color:"text-emerald-400",desc:"HTTPS SSL 证书 & 响应时间"},{icon:ee,name:"TCP",color:"text-orange-400",desc:"TCP 端口连通性检测"},{icon:I,name:"DNS",color:"text-cyan-400",desc:"域名解析延迟 & 结果验证"},{icon:fe,name:"PING",color:"text-purple-400",desc:"ICMP 连通性 & 延迟"}],Oe=["HTTP","HTTPS","TCP","DNS","PING"],Q={name:"",url:"",type:"HTTP",frequency_sec:60,timeout_sec:10,expected_status_code:200};function Re(t){switch(t){case"up":return e.jsx(_e,{"code-path":"src/pages/SiteMonitor.tsx:107:14",className:"h-4 w-4 text-emerald-400"});case"down":return e.jsx(Ce,{"code-path":"src/pages/SiteMonitor.tsx:109:14",className:"h-4 w-4 text-red-400"});default:return e.jsx(Pe,{"code-path":"src/pages/SiteMonitor.tsx:111:14",className:"h-4 w-4 text-gray-400"})}}function Be(t){switch(t){case"up":return e.jsx(u,{"code-path":"src/pages/SiteMonitor.tsx:118:14",className:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",children:"正常"});case"down":return e.jsx(u,{"code-path":"src/pages/SiteMonitor.tsx:120:14",className:"bg-red-500/15 text-red-400 border-red-500/30",children:"异常"});default:return e.jsx(u,{"code-path":"src/pages/SiteMonitor.tsx:122:14",className:"bg-gray-500/15 text-gray-400 border-gray-500/30",children:"未知"})}}function Ae(t){return t==null||t===0?"--":t<1e3?`${t.toFixed(0)}ms`:`${(t/1e3).toFixed(2)}s`}function Ue(t){if(!t)return"--";const n=new Date(t),d=N=>String(N).padStart(2,"0");return`${d(n.getMonth()+1)}-${d(n.getDate())} ${d(n.getHours())}:${d(n.getMinutes())}`}function ze(){const[t,n]=i.useState(null),[d,N]=i.useState([]),[v,_]=i.useState(!0),[T,b]=i.useState(!1),[o,x]=i.useState(!1),[c,m]=i.useState({...Q}),[S,r]=i.useState(!1),[g,D]=i.useState(null),H=Ne(),P=i.useCallback(async()=>{try{const s=await L.getStats();n(s)}catch{}},[]),a=i.useCallback(async()=>{b(!0);try{const s=await L.getTasks();N(s?.list||[])}catch{}finally{b(!1),_(!1)}},[]);i.useEffect(()=>{P(),a()},[P,a]);const U=g?d.filter(s=>s.type?.toUpperCase()===g.toUpperCase()):d,le=()=>{m({...Q}),x(!0)},pe=async()=>{if(!c.name.trim()||!c.url.trim()){C.error("名称和 URL 不能为空");return}r(!0);try{await L.createTask({name:c.name.trim(),url:c.url.trim(),type:c.type.toLowerCase(),frequency_sec:Number(c.frequency_sec)||60,timeout_sec:Number(c.timeout_sec)||10,expected_status_code:Number(c.expected_status_code)||200}),C.success("拨测任务已创建"),x(!1),a(),P()}catch(s){C.error(s.message||"创建失败")}finally{r(!1)}},me=async s=>{if(await H({title:"删除拨测任务",description:`确定删除「${s.name}」吗?此操作不可恢复。`,variant:"destructive"}))try{await L.deleteTask(s.id),C.success("任务已删除"),a(),P()}catch(Me){C.error(Me.message||"删除失败")}},ge=async s=>{try{await L.toggleTask(s.id,!s.enabled),C.success(s.enabled?"已停用":"已启用"),a(),P()}catch(k){C.error(k.message||"操作失败")}},he=t?.availability!=null?`${(t.availability*100).toFixed(1)}%`:"--";return v?e.jsx("div",{"code-path":"src/pages/SiteMonitor.tsx:250:7",className:"flex items-center justify-center py-20",children:e.jsx(O,{"code-path":"src/pages/SiteMonitor.tsx:251:9",className:"h-8 w-8 animate-spin text-[var(--dg-text-muted)]"})}):e.jsxs("div",{"code-path":"src/pages/SiteMonitor.tsx:257:5",className:"space-y-6",children:[e.jsx("div",{"code-path":"src/pages/SiteMonitor.tsx:259:7",className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-3",children:He.map(s=>{const k=g===s.name;return e.jsx(h,{"code-path":"src/pages/SiteMonitor.tsx:263:13",onClick:()=>D(k?null:s.name),className:`bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] transition-colors cursor-pointer ${k?"border-[var(--dg-blue)]/60 ring-1 ring-[var(--dg-blue)]/30":"hover:border-[var(--dg-blue)]/30"}`,children:e.jsxs(M,{"code-path":"src/pages/SiteMonitor.tsx:270:15",className:"p-3 text-center",children:[e.jsx(s.icon,{"code-path":"src/pages/SiteMonitor.tsx:271:17",className:`h-5 w-5 mx-auto mb-1.5 ${s.color}`}),e.jsx("p",{"code-path":"src/pages/SiteMonitor.tsx:272:17",className:"text-xs font-medium text-[var(--dg-text-primary)]",children:s.name}),e.jsx("p",{"code-path":"src/pages/SiteMonitor.tsx:273:17",className:"text-[10px] text-[var(--dg-text-muted)] mt-0.5",children:s.desc})]})},s.name)})}),e.jsx(h,{"code-path":"src/pages/SiteMonitor.tsx:281:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(M,{"code-path":"src/pages/SiteMonitor.tsx:282:9",className:"p-4",children:[e.jsxs("div",{"code-path":"src/pages/SiteMonitor.tsx:283:11",className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{"code-path":"src/pages/SiteMonitor.tsx:284:13",className:"flex items-center gap-2",children:[e.jsx(I,{"code-path":"src/pages/SiteMonitor.tsx:285:15",className:"h-4 w-4 text-[var(--dg-text-muted)]"}),e.jsx("h3",{"code-path":"src/pages/SiteMonitor.tsx:286:15",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:"拨测任务概览"})]}),e.jsxs(w,{"code-path":"src/pages/SiteMonitor.tsx:288:13",size:"sm",variant:"ghost",className:"h-7 text-xs text-[var(--dg-text-muted)] hover:text-[var(--dg-text-primary)]",onClick:()=>{P(),a()},disabled:T,children:[e.jsx(we,{"code-path":"src/pages/SiteMonitor.tsx:295:15",className:`h-3.5 w-3.5 ${T?"animate-spin":""}`}),"刷新"]})]}),e.jsx("div",{"code-path":"src/pages/SiteMonitor.tsx:299:11",className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[{label:"总任务数",value:t?.total_tasks??"--"},{label:"已启用",value:t?.enabled_tasks??"--"},{label:"正常",value:t?.up_count??"--",color:"text-emerald-400"},{label:"异常",value:t?.down_count??"--",color:"text-red-400"},{label:"可用率",value:he,color:"text-blue-400"}].map(s=>e.jsxs("div",{"code-path":"src/pages/SiteMonitor.tsx:307:15",className:"bg-[var(--dg-bg-tertiary)] rounded-lg p-3 text-center",children:[e.jsx("p",{"code-path":"src/pages/SiteMonitor.tsx:308:17",className:"text-xs text-[var(--dg-text-muted)]",children:s.label}),e.jsx("p",{"code-path":"src/pages/SiteMonitor.tsx:309:17",className:`text-lg font-bold ${s.color||"text-[var(--dg-text-primary)]"}`,children:s.value})]},s.label))})]})}),e.jsx(h,{"code-path":"src/pages/SiteMonitor.tsx:319:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(M,{"code-path":"src/pages/SiteMonitor.tsx:320:9",className:"p-4",children:[e.jsxs("div",{"code-path":"src/pages/SiteMonitor.tsx:321:11",className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{"code-path":"src/pages/SiteMonitor.tsx:322:13",className:"flex items-center gap-2",children:[e.jsx(R,{"code-path":"src/pages/SiteMonitor.tsx:323:15",className:"h-4 w-4 text-[var(--dg-text-muted)]"}),e.jsxs("h3",{"code-path":"src/pages/SiteMonitor.tsx:324:15",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:["拨测任务列表",g&&e.jsxs(u,{"code-path":"src/pages/SiteMonitor.tsx:327:19",variant:"outline",className:"ml-2 text-[10px] cursor-pointer border-[var(--dg-blue)]/40 text-[var(--dg-blue)] h-5",onClick:()=>D(null),children:[g," ×"]})]})]}),e.jsxs(w,{"code-path":"src/pages/SiteMonitor.tsx:337:13",size:"sm",className:"h-8 gap-1.5",onClick:le,children:[e.jsx(se,{"code-path":"src/pages/SiteMonitor.tsx:342:15",className:"h-3.5 w-3.5"}),"添加任务"]})]}),U.length===0?e.jsx("div",{"code-path":"src/pages/SiteMonitor.tsx:348:13",className:"text-center py-12 text-sm text-[var(--dg-text-muted)]",children:d.length===0?"暂无拨测任务,点击「添加任务」创建第一个":"当前筛选条件下无任务"}):e.jsx("div",{"code-path":"src/pages/SiteMonitor.tsx:354:13",className:"overflow-x-auto",children:e.jsxs(ie,{"code-path":"src/pages/SiteMonitor.tsx:355:15",children:[e.jsx(ne,{"code-path":"src/pages/SiteMonitor.tsx:356:17",children:e.jsxs(q,{"code-path":"src/pages/SiteMonitor.tsx:357:19",className:"border-[var(--dg-border)] hover:bg-transparent",children:[e.jsx(l,{"code-path":"src/pages/SiteMonitor.tsx:358:21",className:"text-xs text-[var(--dg-text-muted)]",children:"名称"}),e.jsx(l,{"code-path":"src/pages/SiteMonitor.tsx:359:21",className:"text-xs text-[var(--dg-text-muted)]",children:"URL"}),e.jsx(l,{"code-path":"src/pages/SiteMonitor.tsx:360:21",className:"text-xs text-[var(--dg-text-muted)]",children:"类型"}),e.jsx(l,{"code-path":"src/pages/SiteMonitor.tsx:361:21",className:"text-xs text-[var(--dg-text-muted)]",children:"间隔"}),e.jsx(l,{"code-path":"src/pages/SiteMonitor.tsx:362:21",className:"text-xs text-[var(--dg-text-muted)]",children:"状态"}),e.jsx(l,{"code-path":"src/pages/SiteMonitor.tsx:363:21",className:"text-xs text-[var(--dg-text-muted)]",children:"延迟"}),e.jsx(l,{"code-path":"src/pages/SiteMonitor.tsx:364:21",className:"text-xs text-[var(--dg-text-muted)]",children:"上次检测"}),e.jsx(l,{"code-path":"src/pages/SiteMonitor.tsx:365:21",className:"text-xs text-[var(--dg-text-muted)]",children:"启用"}),e.jsx(l,{"code-path":"src/pages/SiteMonitor.tsx:366:21",className:"text-xs text-[var(--dg-text-muted)]",children:"操作"})]})}),e.jsx(xe,{"code-path":"src/pages/SiteMonitor.tsx:369:17",children:U.map(s=>e.jsxs(q,{"code-path":"src/pages/SiteMonitor.tsx:371:21",className:"border-[var(--dg-border)]",children:[e.jsx(p,{"code-path":"src/pages/SiteMonitor.tsx:372:23",className:"text-sm text-[var(--dg-text-primary)] font-medium",children:s.name}),e.jsx(p,{"code-path":"src/pages/SiteMonitor.tsx:375:23",className:"text-sm text-[var(--dg-text-muted)] max-w-[200px] truncate",children:s.url}),e.jsx(p,{"code-path":"src/pages/SiteMonitor.tsx:378:23",children:e.jsx(u,{"code-path":"src/pages/SiteMonitor.tsx:379:25",variant:"outline",className:"text-[11px] border-[var(--dg-border)]",children:s.type?.toUpperCase()})}),e.jsxs(p,{"code-path":"src/pages/SiteMonitor.tsx:383:23",className:"text-sm text-[var(--dg-text-muted)]",children:[s.frequency_sec,"s"]}),e.jsx(p,{"code-path":"src/pages/SiteMonitor.tsx:386:23",children:e.jsxs("div",{"code-path":"src/pages/SiteMonitor.tsx:387:25",className:"flex items-center gap-1.5",children:[Re(s.last_status),e.jsx("span",{"code-path":"src/pages/SiteMonitor.tsx:389:27",className:"text-sm text-[var(--dg-text-muted)]",children:Be(s.last_status)})]})}),e.jsx(p,{"code-path":"src/pages/SiteMonitor.tsx:394:23",className:"text-sm text-[var(--dg-text-muted)]",children:Ae(s.last_response_time_ms)}),e.jsx(p,{"code-path":"src/pages/SiteMonitor.tsx:397:23",className:"text-sm text-[var(--dg-text-muted)]",children:Ue(s.last_checked_at)}),e.jsx(p,{"code-path":"src/pages/SiteMonitor.tsx:400:23",children:e.jsx(De,{"code-path":"src/pages/SiteMonitor.tsx:401:25",checked:s.enabled,onCheckedChange:()=>ge(s)})}),e.jsx(p,{"code-path":"src/pages/SiteMonitor.tsx:406:23",children:e.jsx(w,{"code-path":"src/pages/SiteMonitor.tsx:407:25",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>me(s),children:e.jsx(ae,{"code-path":"src/pages/SiteMonitor.tsx:413:27",className:"h-4 w-4"})})})]},s.id))})]})})]})}),e.jsx(K,{"code-path":"src/pages/SiteMonitor.tsx:426:7",open:o,onOpenChange:x,children:e.jsxs(X,{"code-path":"src/pages/SiteMonitor.tsx:427:9",className:"sm:max-w-md bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",children:[e.jsxs(W,{"code-path":"src/pages/SiteMonitor.tsx:428:11",children:[e.jsx(Y,{"code-path":"src/pages/SiteMonitor.tsx:429:13",children:"添加拨测任务"}),e.jsx(Z,{"code-path":"src/pages/SiteMonitor.tsx:430:13",className:"text-[var(--dg-text-muted)]",children:"配置站点探活任务,系统将按指定频率自动检测"})]}),e.jsxs("div",{"code-path":"src/pages/SiteMonitor.tsx:435:11",className:"grid gap-4 py-2",children:[e.jsxs("div",{"code-path":"src/pages/SiteMonitor.tsx:437:13",className:"grid gap-1.5",children:[e.jsx(j,{"code-path":"src/pages/SiteMonitor.tsx:438:15",htmlFor:"task-name",className:"text-[var(--dg-text-primary)]",children:"任务名称"}),e.jsx(y,{"code-path":"src/pages/SiteMonitor.tsx:439:15",id:"task-name",placeholder:"例如:官网首页检测",value:c.name,onChange:s=>m({...c,name:s.target.value})})]}),e.jsxs("div",{"code-path":"src/pages/SiteMonitor.tsx:448:13",className:"grid gap-1.5",children:[e.jsx(j,{"code-path":"src/pages/SiteMonitor.tsx:449:15",htmlFor:"task-url",className:"text-[var(--dg-text-primary)]",children:"目标 URL"}),e.jsx(y,{"code-path":"src/pages/SiteMonitor.tsx:450:15",id:"task-url",placeholder:"例如:https://example.com 或 192.168.1.1",value:c.url,onChange:s=>m({...c,url:s.target.value})})]}),e.jsxs("div",{"code-path":"src/pages/SiteMonitor.tsx:459:13",className:"grid gap-1.5",children:[e.jsx(j,{"code-path":"src/pages/SiteMonitor.tsx:460:15",className:"text-[var(--dg-text-primary)]",children:"协议类型"}),e.jsxs(re,{"code-path":"src/pages/SiteMonitor.tsx:461:15",value:c.type,onValueChange:s=>m({...c,type:s}),children:[e.jsx(oe,{"code-path":"src/pages/SiteMonitor.tsx:465:17",children:e.jsx(ce,{"code-path":"src/pages/SiteMonitor.tsx:466:19"})}),e.jsx(de,{"code-path":"src/pages/SiteMonitor.tsx:468:17",children:Oe.map(s=>e.jsx(A,{"code-path":"src/pages/SiteMonitor.tsx:470:21",value:s,children:s},s))})]})]}),e.jsxs("div",{"code-path":"src/pages/SiteMonitor.tsx:477:13",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/pages/SiteMonitor.tsx:478:15",className:"grid gap-1.5",children:[e.jsx(j,{"code-path":"src/pages/SiteMonitor.tsx:479:17",htmlFor:"freq",className:"text-[var(--dg-text-primary)]",children:"检测间隔 (秒)"}),e.jsx(y,{"code-path":"src/pages/SiteMonitor.tsx:482:17",id:"freq",type:"number",min:10,max:86400,value:c.frequency_sec,onChange:s=>m({...c,frequency_sec:Number(s.target.value)||60})})]}),e.jsxs("div",{"code-path":"src/pages/SiteMonitor.tsx:493:15",className:"grid gap-1.5",children:[e.jsx(j,{"code-path":"src/pages/SiteMonitor.tsx:494:17",htmlFor:"timeout",className:"text-[var(--dg-text-primary)]",children:"超时 (秒)"}),e.jsx(y,{"code-path":"src/pages/SiteMonitor.tsx:497:17",id:"timeout",type:"number",min:1,max:300,value:c.timeout_sec,onChange:s=>m({...c,timeout_sec:Number(s.target.value)||10})})]})]}),(c.type==="HTTP"||c.type==="HTTPS")&&e.jsxs("div",{"code-path":"src/pages/SiteMonitor.tsx:512:15",className:"grid gap-1.5",children:[e.jsx(j,{"code-path":"src/pages/SiteMonitor.tsx:513:17",htmlFor:"status-code",className:"text-[var(--dg-text-primary)]",children:"期望状态码"}),e.jsx(y,{"code-path":"src/pages/SiteMonitor.tsx:516:17",id:"status-code",type:"number",min:100,max:599,value:c.expected_status_code,onChange:s=>m({...c,expected_status_code:Number(s.target.value)||200})})]})]}),e.jsxs(J,{"code-path":"src/pages/SiteMonitor.tsx:530:11",children:[e.jsx(w,{"code-path":"src/pages/SiteMonitor.tsx:531:13",variant:"outline",onClick:()=>x(!1),disabled:S,children:"取消"}),e.jsxs(w,{"code-path":"src/pages/SiteMonitor.tsx:534:13",onClick:pe,disabled:S,children:[S&&e.jsx(O,{"code-path":"src/pages/SiteMonitor.tsx:535:26",className:"h-4 w-4 animate-spin mr-1"}),"创建任务"]})]})]})})]})}const V=[{id:"host",name:"主机监控",icon:Te,description:"CPU / 内存 / 磁盘 / 网络 / 磁盘IO"},{id:"middleware",name:"中间件监控",icon:B,description:"Redis / MySQL 指标采集"},{id:"snmp",name:"SNMP 监控",icon:te,description:"网络设备 / 服务器硬件 (OID 模板)"},{id:"site",name:"站点拨测",icon:I,description:"HTTP / PING / DNS / TCP / WS 拨测"}];function it(){const[t,n]=i.useState("host");return e.jsxs("div",{"code-path":"src/pages/MonitorCenter.tsx:30:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/pages/MonitorCenter.tsx:31:7",children:[e.jsx("h1",{"code-path":"src/pages/MonitorCenter.tsx:32:9",className:"text-2xl font-bold text-[var(--dg-text-primary)]",children:"监控中心"}),e.jsx("p",{"code-path":"src/pages/MonitorCenter.tsx:33:9",className:"text-sm text-[var(--dg-text-muted)] mt-1",children:"全面的基础设施与应用监控"})]}),e.jsx("div",{"code-path":"src/pages/MonitorCenter.tsx:37:7",className:"flex gap-1 bg-[var(--dg-bg-secondary)] p-1 rounded-lg border border-[var(--dg-border)]",children:V.map(d=>e.jsxs("button",{"code-path":"src/pages/MonitorCenter.tsx:39:11",onClick:()=>n(d.id),className:ve("flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-md text-sm font-medium transition-all",t===d.id?"bg-[var(--dg-bg-tertiary)] text-[var(--dg-text-primary)] shadow-sm":"text-[var(--dg-text-muted)] hover:text-[var(--dg-text-secondary)]"),children:[e.jsx(d.icon,{"code-path":"src/pages/MonitorCenter.tsx:49:13",className:"h-4 w-4"}),e.jsx("span",{"code-path":"src/pages/MonitorCenter.tsx:50:13",className:"hidden sm:inline",children:d.name})]},d.id))}),e.jsx("p",{"code-path":"src/pages/MonitorCenter.tsx:56:7",className:"text-sm text-[var(--dg-text-muted)] -mt-4",children:V.find(d=>d.id===t)?.description}),e.jsxs("div",{"code-path":"src/pages/MonitorCenter.tsx:61:7",className:"min-h-[400px]",children:[t==="host"&&e.jsx(je,{"code-path":"src/pages/MonitorCenter.tsx:62:34"}),t==="middleware"&&e.jsx(Ie,{"code-path":"src/pages/MonitorCenter.tsx:63:40"}),t==="snmp"&&e.jsx(qe,{"code-path":"src/pages/MonitorCenter.tsx:64:34"}),t==="site"&&e.jsx(ze,{"code-path":"src/pages/MonitorCenter.tsx:65:34"})]})]})}export{it as MonitorCenter}; diff --git a/backend/static/assets/NamespaceManagementPage-CJJFp4Vm.js b/backend/static/assets/NamespaceManagementPage-CJJFp4Vm.js deleted file mode 100644 index 614dd67..0000000 --- a/backend/static/assets/NamespaceManagementPage-CJJFp4Vm.js +++ /dev/null @@ -1 +0,0 @@ -import{r as n,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{C as p,a as l}from"./card-BIfzBCEy.js";import{g as Z,i as ee,L as A,B as m,D as L,j as se,a as O,b as B,c as E,e as R,t as q}from"./index-Dungj95X.js";import{B as H}from"./badge-CGJlVD3L.js";import{I as $}from"./input-CXoUQQLm.js";import{L as ae}from"./label-CMpUoC87.js";import{T as te,a as ne,b as i,c,d as ce,e as a}from"./table-B2F10oba.js";import{k as j}from"./index-drGq01ok.js";import{f as z,B as P,L as N,R as re,P as me,k as oe,A as pe,N as le,j as I,C as xe,l as Q,T as de}from"./vendor-icons-DmqcWdzX.js";const ge=new Set(["kube-system","kube-public","kube-node-lease","default","devops"]);function fe(){const{clusterCode:t}=Z(),F=ee(),[o,M]=n.useState([]),[u,f]=n.useState(!1),[b,J]=n.useState(""),[K,k]=n.useState(!1),[d,y]=n.useState(""),[v,w]=n.useState(!1),[g,h]=n.useState(null),[C,S]=n.useState(!1),x=n.useCallback(async()=>{if(t){f(!0);try{const s=await j.getNamespacesDetail(t);M(Array.isArray(s)?s:[])}catch{M([])}finally{f(!1)}}},[t]);n.useEffect(()=>{x()},[x]);const D=async()=>{if(!(!t||!d.trim())){w(!0);try{await j.createNamespace(t,d.trim()),y(""),k(!1),await x()}catch(s){q.error(s?.message||"创建失败")}finally{w(!1)}}},Y=async()=>{if(!(!t||!g)){S(!0);try{await j.deleteNamespace(t,g),h(null),await x()}catch(s){q.error(s?.message||"删除失败")}finally{S(!1)}}},T=o.filter(s=>!b||s.name.toLowerCase().includes(b.toLowerCase())),G=o.reduce((s,r)=>s+(r.resource_counts?.deployments||0),0),U=o.reduce((s,r)=>s+(r.resource_counts?.pods||0),0),V=o.reduce((s,r)=>s+(r.resource_counts?.services||0),0),W=o.filter(s=>s.has_resource_quota).length;return e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:109:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:111:7",className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx(A,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:112:9",to:"/kubernetes",className:"hover:text-slate-300 transition-colors",children:"集群"}),e.jsx(z,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:113:9",className:"h-3 w-3"}),e.jsx(A,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:114:9",to:`/kubernetes/${t}`,className:"hover:text-slate-300 transition-colors",children:t}),e.jsx(z,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:115:9",className:"h-3 w-3"}),e.jsx("span",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:116:9",className:"text-slate-300",children:"命名空间管理"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:120:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:121:9",children:[e.jsxs("h1",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:122:11",className:"text-2xl font-bold text-slate-100 flex items-center gap-2",children:[e.jsx(P,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:123:13",className:"h-6 w-6 text-emerald-400"}),"命名空间管理"]}),e.jsx("p",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:126:11",className:"text-sm text-slate-500 mt-1",children:"命名空间资源配额与生命周期管理"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:128:9",className:"flex items-center gap-2",children:[e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:129:11",variant:"outline",size:"icon",className:"h-9 w-9 border-slate-700 text-slate-400",onClick:x,disabled:u,children:u?e.jsx(N,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:131:24",className:"h-4 w-4 animate-spin"}):e.jsx(re,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:131:71",className:"h-4 w-4"})}),e.jsxs(L,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:133:11",open:K,onOpenChange:k,children:[e.jsx(se,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:134:13",asChild:!0,children:e.jsxs(m,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:135:15",className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(me,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:136:17",className:"h-4 w-4 mr-1"}),"创建命名空间"]})}),e.jsxs(O,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:139:13",children:[e.jsx(B,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:140:15",children:e.jsx(E,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:141:17",children:"创建命名空间"})}),e.jsx("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:143:15",className:"space-y-4 py-4",children:e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:144:17",className:"space-y-2",children:[e.jsx(ae,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:145:19",children:"命名空间名称"}),e.jsx($,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:146:19",value:d,onChange:s=>y(s.target.value),placeholder:"例如: my-app",onKeyDown:s=>s.key==="Enter"&&D()}),e.jsx("p",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:152:19",className:"text-xs text-slate-500",children:"名称需符合 DNS-1123 标准(小写字母/数字/连字符)"})]})}),e.jsxs(R,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:157:15",children:[e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:158:17",variant:"outline",onClick:()=>k(!1),children:"取消"}),e.jsxs(m,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:159:17",onClick:D,disabled:v||!d.trim(),children:[v?e.jsx(N,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:160:31",className:"h-4 w-4 animate-spin mr-1"}):null,"创建"]})]})]})]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:170:7",className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[e.jsx(p,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:171:9",className:"bg-slate-900 border-slate-800",children:e.jsxs(l,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:172:11",className:"p-4 flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:173:13",children:[e.jsx("p",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:173:18",className:"text-xs text-slate-500",children:"命名空间"}),e.jsx("p",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:173:64",className:"text-xl font-bold text-emerald-400",children:o.length})]}),e.jsx(P,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:174:13",className:"h-6 w-6 opacity-30 text-emerald-400"})]})}),e.jsx(p,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:177:9",className:"bg-slate-900 border-slate-800",children:e.jsxs(l,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:178:11",className:"p-4 flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:179:13",children:[e.jsx("p",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:179:18",className:"text-xs text-slate-500",children:"Deployments"}),e.jsx("p",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:179:71",className:"text-xl font-bold text-blue-400",children:G})]}),e.jsx(oe,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:180:13",className:"h-6 w-6 opacity-30 text-blue-400"})]})}),e.jsx(p,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:183:9",className:"bg-slate-900 border-slate-800",children:e.jsxs(l,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:184:11",className:"p-4 flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:185:13",children:[e.jsx("p",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:185:18",className:"text-xs text-slate-500",children:"Pods"}),e.jsx("p",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:185:64",className:"text-xl font-bold text-purple-400",children:U})]}),e.jsx(pe,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:186:13",className:"h-6 w-6 opacity-30 text-purple-400"})]})}),e.jsx(p,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:189:9",className:"bg-slate-900 border-slate-800",children:e.jsxs(l,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:190:11",className:"p-4 flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:191:13",children:[e.jsx("p",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:191:18",className:"text-xs text-slate-500",children:"Services"}),e.jsx("p",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:191:68",className:"text-xl font-bold text-cyan-400",children:V})]}),e.jsx(le,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:192:13",className:"h-6 w-6 opacity-30 text-cyan-400"})]})}),e.jsx(p,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:195:9",className:"bg-slate-900 border-slate-800",children:e.jsxs(l,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:196:11",className:"p-4 flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:197:13",children:[e.jsx("p",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:197:18",className:"text-xs text-slate-500",children:"配额限制"}),e.jsx("p",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:197:64",className:"text-xl font-bold text-amber-400",children:W})]}),e.jsx(I,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:198:13",className:"h-6 w-6 opacity-30 text-amber-400"})]})})]}),e.jsx("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:204:7",className:"flex items-center gap-3",children:e.jsx($,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:205:9",value:b,onChange:s=>J(s.target.value),placeholder:"搜索命名空间...",className:"max-w-xs bg-slate-900 border-slate-700"})}),e.jsx(p,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:214:7",className:"bg-slate-900 border-slate-800",children:e.jsx(l,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:215:9",className:"p-0",children:e.jsxs(te,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:216:11",children:[e.jsx(ne,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:217:13",children:e.jsxs(i,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:218:15",className:"border-slate-800 hover:bg-transparent",children:[e.jsx(c,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:219:17",className:"text-slate-400",children:"名称"}),e.jsx(c,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:220:17",className:"text-slate-400",children:"状态"}),e.jsx(c,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:221:17",className:"text-slate-400",children:"年龄"}),e.jsx(c,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:222:17",className:"text-slate-400 text-center",children:"Deploy"}),e.jsx(c,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:223:17",className:"text-slate-400 text-center",children:"Pods"}),e.jsx(c,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:224:17",className:"text-slate-400 text-center",children:"Svc"}),e.jsx(c,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:225:17",className:"text-slate-400 text-center",children:"配额"}),e.jsx(c,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:226:17",className:"text-slate-400",children:"标签"}),e.jsx(c,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:227:17",className:"text-slate-400 text-center",children:"操作"})]})}),e.jsx(ce,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:230:13",children:u?e.jsx(i,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:232:17",children:e.jsxs(a,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:232:27",colSpan:9,className:"text-center text-slate-500 py-12",children:[e.jsx(N,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:233:19",className:"h-5 w-5 animate-spin mx-auto mb-2"}),"加载中..."]})}):T.length===0?e.jsx(i,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:236:17",children:e.jsxs(a,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:236:27",colSpan:9,className:"text-center text-slate-500 py-12",children:[e.jsx(P,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:237:19",className:"h-8 w-8 mx-auto mb-2 opacity-50"}),"暂无命名空间"]})}):T.map(s=>{const r=ge.has(s.name);return e.jsxs(i,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:243:21",className:"border-slate-800 hover:bg-slate-800/30",children:[e.jsx(a,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:244:23",className:"font-medium",children:e.jsx("button",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:245:25",className:"text-blue-400 hover:text-blue-300 hover:underline text-left",onClick:()=>F(`/kubernetes/${t}/namespace/${s.name}`),children:s.name})}),e.jsx(a,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:252:23",children:e.jsxs(H,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:253:25",className:s.status==="Active"?"bg-emerald-500/20 text-emerald-400":"bg-red-500/20 text-red-400",children:[s.status==="Active"?e.jsx(xe,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:254:53",className:"h-3 w-3 mr-1"}):e.jsx(Q,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:254:97",className:"h-3 w-3 mr-1"}),s.status]})}),e.jsx(a,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:258:23",className:"text-sm text-slate-400",children:s.age}),e.jsx(a,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:259:23",className:"text-center text-sm text-slate-300",children:s.resource_counts?.deployments??0}),e.jsx(a,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:260:23",className:"text-center text-sm text-slate-300",children:s.resource_counts?.pods??0}),e.jsx(a,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:261:23",className:"text-center text-sm text-slate-300",children:s.resource_counts?.services??0}),e.jsx(a,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:262:23",className:"text-center",children:s.has_resource_quota?e.jsxs(H,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:264:27",className:"bg-amber-500/20 text-amber-400",title:JSON.stringify(s.resource_quotas?.[0]?.status),children:[e.jsx(I,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:265:29",className:"h-3 w-3 mr-1"}),"有"]}):e.jsx("span",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:268:27",className:"text-xs text-slate-600",children:"-"})}),e.jsx(a,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:271:23",className:"text-xs",children:s.labels&&Object.keys(s.labels).length>0?e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:273:27",className:"flex flex-wrap gap-1 max-w-[200px]",children:[Object.entries(s.labels).slice(0,3).map(([_,X])=>e.jsxs("span",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:275:31",className:"px-1.5 py-0.5 bg-slate-800 rounded text-slate-400",children:[_,"=",X]},_)),Object.keys(s.labels).length>3&&e.jsxs("span",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:278:31",className:"text-slate-600",children:["+",Object.keys(s.labels).length-3]})]}):e.jsx("span",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:282:27",className:"text-slate-600",children:"-"})}),e.jsx(a,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:285:23",className:"text-center",children:r?e.jsx("span",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:287:27",className:"text-xs text-slate-600",children:"系统"}):e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:289:27",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>h(s.name),title:"删除命名空间",children:e.jsx(de,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:295:29",className:"h-3.5 w-3.5"})})})]},s.name)})})]})})}),e.jsx(L,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:309:7",open:!!g,onOpenChange:s=>!s&&h(null),children:e.jsxs(O,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:310:9",children:[e.jsx(B,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:311:11",children:e.jsxs(E,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:312:13",className:"text-red-400 flex items-center gap-2",children:[e.jsx(Q,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:313:15",className:"h-5 w-5"}),"删除命名空间"]})}),e.jsx("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:316:11",className:"space-y-3 py-4",children:e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:317:13",className:"bg-red-500/10 border border-red-500/30 rounded-lg p-3",children:[e.jsxs("p",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:318:15",className:"text-sm text-red-300",children:["⚠️ 即将删除命名空间 ",e.jsx("span",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:319:29",className:"font-bold",children:g})," 及其中所有资源。"]}),e.jsx("p",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:321:15",className:"text-xs text-red-400/70 mt-1",children:"此操作不可逆,所有 Deployment/Pod/Service/ConfigMap 等资源将被永久删除。"})]})}),e.jsxs(R,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:326:11",children:[e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:327:13",variant:"outline",onClick:()=>h(null),children:"取消"}),e.jsxs(m,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:328:13",variant:"destructive",onClick:Y,disabled:C,children:[C?e.jsx(N,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:329:27",className:"h-4 w-4 animate-spin mr-1"}):null,"确认删除"]})]})]})})]})}export{fe as default}; diff --git a/backend/static/assets/NamespaceOverviewPage-3EiRcdjy.js b/backend/static/assets/NamespaceOverviewPage-3EiRcdjy.js deleted file mode 100644 index 7bbe531..0000000 --- a/backend/static/assets/NamespaceOverviewPage-3EiRcdjy.js +++ /dev/null @@ -1 +0,0 @@ -import{r,j as s}from"./vendor-codemirror-B1SGo4xl.js";import{g,L as l}from"./index-Dungj95X.js";import{k as o}from"./index-drGq01ok.js";import{f as i,i as h,B as b,k as N,b as f,N as u,F as k,j as w,A as j}from"./vendor-icons-DmqcWdzX.js";const P=[{type:"deployments",label:"Deployments",icon:b,desc:"工作负载副本管理"},{type:"pods",label:"Pods",icon:N,desc:"容器实例运行状态"},{type:"cronjobs",label:"CronJobs",icon:f,desc:"定时任务管理"},{type:"services",label:"Services",icon:u,desc:"服务发现与负载均衡"},{type:"ingresses",label:"Ingresses",icon:u,desc:"外部流量路由规则"},{type:"configmaps",label:"ConfigMaps",icon:k,desc:"配置字典"},{type:"secrets",label:"Secrets",icon:w,desc:"密钥与凭证"},{type:"hpas",label:"HPAs",icon:j,desc:"水平自动伸缩策略"}];function A(){const{clusterCode:t,namespace:a}=g(),[x,p]=r.useState({}),[v,m]=r.useState(!1),d=r.useCallback(async()=>{if(!(!t||!a)){m(!0);try{const e=await Promise.allSettled([o.getNamespaceDeployments(t,a),o.getNamespacePods(t,a),o.getNamespaceServices(t,a),o.getNamespaceIngresses(t,a),o.getNamespaceConfigMaps(t,a),o.getNamespaceSecrets(t,a),o.getHPAs(t,a),o.getCronJobs(t,a)]),c=n=>Array.isArray(n)?n:n?.list||n?.data||[];p({deployments:c(e[0].status==="fulfilled"?e[0].value:[]).length,pods:c(e[1].status==="fulfilled"?e[1].value:[]).length,services:c(e[2].status==="fulfilled"?e[2].value:[]).length,ingresses:c(e[3].status==="fulfilled"?e[3].value:[]).length,configmaps:c(e[4].status==="fulfilled"?e[4].value:[]).length,secrets:c(e[5].status==="fulfilled"?e[5].value:[]).length,hpas:c(e[6].status==="fulfilled"?e[6].value:[]).length,cronjobs:c(e[7].status==="fulfilled"?e[7].value:[]).length})}catch{p({})}finally{m(!1)}}},[t,a]);return r.useEffect(()=>{d()},[d]),s.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:66:5",className:"space-y-4",children:[s.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:68:7",className:"flex items-center gap-2 text-sm text-slate-500",children:[s.jsx(l,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:69:9",to:"/kubernetes",className:"hover:text-slate-300 transition-colors",children:"集群"}),s.jsx(i,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:70:9",className:"h-3 w-3"}),s.jsx(l,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:71:9",to:`/kubernetes/${t}`,className:"hover:text-slate-300 transition-colors",children:t}),s.jsx(i,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:72:9",className:"h-3 w-3"}),s.jsx("span",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:73:9",className:"text-slate-300",children:a})]}),s.jsx("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:77:7",className:"flex items-center justify-between",children:s.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:78:9",children:[s.jsxs("h1",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:79:11",className:"text-2xl font-bold text-slate-100 flex items-center gap-2",children:[s.jsx(h,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:80:13",className:"h-6 w-6 text-blue-400"}),a]}),s.jsx("p",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:83:11",className:"text-sm text-slate-500 mt-1",children:"命名空间概览"})]})}),s.jsx("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:88:7",className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:P.map(e=>s.jsxs(l,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:90:11",to:`/kubernetes/${t}/namespace/${a}/${e.type}`,className:"bg-slate-900 border border-slate-800 rounded-lg p-4 hover:border-slate-600 hover:bg-slate-800/50 transition-all group",children:[s.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:94:13",className:"flex items-center justify-between mb-2",children:[s.jsx(e.icon,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:95:15",className:"h-5 w-5 text-slate-500 group-hover:text-blue-400 transition-colors"}),s.jsx(i,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:96:15",className:"h-4 w-4 text-slate-600 group-hover:text-slate-400 transition-colors"})]}),s.jsx("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:98:13",className:"text-lg font-bold text-slate-100",children:v?"-":x[e.type]??0}),s.jsx("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:99:13",className:"text-sm text-slate-500",children:e.label}),s.jsx("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:100:13",className:"text-xs text-slate-600 mt-1",children:e.desc})]},e.type))})]})}export{A as default}; diff --git a/backend/static/assets/NamespaceResourcePage-llU4EE7M.js b/backend/static/assets/NamespaceResourcePage-llU4EE7M.js deleted file mode 100644 index 3d95ac5..0000000 --- a/backend/static/assets/NamespaceResourcePage-llU4EE7M.js +++ /dev/null @@ -1 +0,0 @@ -import{r as x,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{C as xe,a as ue}from"./card-BIfzBCEy.js";import{B as p,g as ie,k as de,i as he,L as I}from"./index-Dungj95X.js";import{I as ge}from"./input-CXoUQQLm.js";import{B as m}from"./badge-CGJlVD3L.js";import{S as X,a as G,b as K,c as q,d as Q}from"./select-CiTqGGhE.js";import{T as be,a as Ne,b as u,c as ke,d as Pe,e as t}from"./table-B2F10oba.js";import{M as je,b as Re,Y as ve,P as we,a as fe}from"./PodFileBrowser-B-U8iHmY.js";import{R as Ce}from"./ResourceVisualEditor-BN2gGuH7.js";import{u as ee}from"./use-toast-DNZLibQY.js";import{k as l}from"./index-drGq01ok.js";import{ah as T,X as Se,L as M,j as C,B as S,b as ye,A as Ye,F as _e,N as W,k as $e,f as A,R as De,v as L,P as Ie,S as Ae,o as j,d as B,r as Le,H as Ee}from"./vendor-icons-DmqcWdzX.js";import"./index-5FEebgvX.js";import"./k8s-yaml-utils-4KZB_Bq_.js";import"./vendor-xterm-20M9KZE1.js";import"./label-CMpUoC87.js";import"./textarea-BxfjmLq5.js";function Te({clusterCode:s,onClose:a,onApplied:o}){const{toast:r}=ee(),[h,n]=x.useState(""),[d,g]=x.useState(!1),R=async()=>{if(!h.trim()){r({title:"请输入 YAML",variant:"destructive"});return}g(!0);try{await l.applyYAML(s,h),r({title:"导入成功",description:"YAML 已应用到集群"}),o?.(),a()}catch(N){r({title:"导入失败",description:N.message,variant:"destructive"})}finally{g(!1)}};return e.jsx(je,{"code-path":"src/components/kubernetes/YamlImportDialog.tsx:39:5",onClose:a,children:e.jsxs("div",{"code-path":"src/components/kubernetes/YamlImportDialog.tsx:40:7",className:"bg-[var(--dg-bg-primary)] border border-[var(--dg-border)] rounded-xl w-[92vw] max-w-4xl h-[85vh] flex flex-col shadow-2xl",onClick:N=>N.stopPropagation(),children:[e.jsxs("div",{"code-path":"src/components/kubernetes/YamlImportDialog.tsx:44:9",className:"flex items-center justify-between p-4 border-b border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/YamlImportDialog.tsx:45:11",className:"flex items-center gap-2",children:[e.jsx(T,{"code-path":"src/components/kubernetes/YamlImportDialog.tsx:46:13",className:"h-5 w-5 text-[var(--dg-text-muted)]"}),e.jsxs("div",{"code-path":"src/components/kubernetes/YamlImportDialog.tsx:47:13",children:[e.jsx("h2",{"code-path":"src/components/kubernetes/YamlImportDialog.tsx:48:15",className:"text-lg font-bold text-[var(--dg-text-primary)]",children:"导入 YAML"}),e.jsx("p",{"code-path":"src/components/kubernetes/YamlImportDialog.tsx:49:15",className:"text-xs text-[var(--dg-text-muted)]",children:"支持多文档(--- 分隔),适用于新建或更新资源"})]})]}),e.jsx(p,{"code-path":"src/components/kubernetes/YamlImportDialog.tsx:52:11",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:a,children:e.jsx(Se,{"code-path":"src/components/kubernetes/YamlImportDialog.tsx:52:85",className:"h-4 w-4"})})]}),e.jsx("div",{"code-path":"src/components/kubernetes/YamlImportDialog.tsx:54:9",className:"flex-1 min-h-0 flex flex-col overflow-hidden p-4",children:e.jsx(Re,{"code-path":"src/components/kubernetes/YamlImportDialog.tsx:55:11",value:h,fill:!0,fontSize:"12px",onChange:n})}),e.jsxs("div",{"code-path":"src/components/kubernetes/YamlImportDialog.tsx:62:9",className:"flex justify-end gap-2 p-4 border-t border-[var(--dg-border)] shrink-0",children:[e.jsx(p,{"code-path":"src/components/kubernetes/YamlImportDialog.tsx:63:11",variant:"outline",onClick:a,children:"取消"}),e.jsxs(p,{"code-path":"src/components/kubernetes/YamlImportDialog.tsx:64:11",className:"bg-blue-600 hover:bg-blue-700",onClick:R,disabled:d,children:[d?e.jsx(M,{"code-path":"src/components/kubernetes/YamlImportDialog.tsx:65:25",className:"h-4 w-4 animate-spin mr-1"}):e.jsx(T,{"code-path":"src/components/kubernetes/YamlImportDialog.tsx:65:77",className:"h-4 w-4 mr-1"}),"应用"]})]})]})})}const Z=["services","ingresses","configmaps","secrets","pvcs"],Me=["deployments"],Be=["services","ingresses","configmaps","secrets"],ze=["services","ingresses","configmaps","secrets","pvcs"],P=({name:s,opts:a})=>e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:42:3",className:"flex items-center gap-0.5",children:[e.jsxs(p,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:43:5",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-emerald-400 hover:text-emerald-300",title:"可视化编辑",onClick:()=>a.onEdit?.(s),children:[e.jsx(B,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:44:43",className:"h-3.5 w-3.5 mr-1"}),"编辑"]}),e.jsxs(p,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:45:5",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-slate-400 hover:text-slate-300",title:"YAML",onClick:()=>a.onYaml?.(s),children:[e.jsx(j,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:46:43",className:"h-3.5 w-3.5 mr-1"}),"YAML"]})]}),E={deployments:{title:"Deployments",subtitle:"Deployment 工作负载运行状态",icon:S,columns:["名称","命名空间","副本","镜像"],renderRow:(s,a)=>e.jsxs(u,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:61:7",className:"border-slate-800 hover:bg-slate-800/30 cursor-pointer",onClick:()=>a.onDetail?.(s),children:[e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:62:9",className:"font-medium text-slate-200",children:s.name}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:63:9",children:e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:63:20",variant:"outline",className:"border-slate-700 text-slate-400",children:s.namespace})}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:64:9",children:(()=>{const o=s.ready_replicas||0,r=s.replicas||0,h=r>0?o/r*100:0,n=o===r;return e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:69:15",className:"flex items-center gap-2 min-w-[100px]",children:[e.jsx("div",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:70:17",className:"flex-1 h-1.5 rounded-full bg-slate-700/50 overflow-hidden",children:e.jsx("div",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:71:19",className:`h-full rounded-full ${n?"bg-emerald-500":"bg-yellow-500"}`,style:{width:`${h}%`}})}),e.jsxs("span",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:73:17",className:`text-xs ${n?"text-emerald-400":"text-yellow-400"}`,children:[o,"/",r]})]})})()}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:78:9",className:"text-xs text-slate-500 max-w-[200px] truncate",children:s.image||"-"})]},s.name)},pods:{title:"Pods",subtitle:"Pod 实例运行状态",icon:$e,columns:["名称","命名空间","状态","节点","CPU","内存","重启","镜像","操作"],renderRow:(s,a)=>{const o={Running:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",Pending:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",Failed:"bg-red-500/20 text-red-400 border-red-500/30"};return e.jsxs(u,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:88:9",className:"border-slate-800 hover:bg-slate-800/30",children:[e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:89:11",className:"font-medium text-slate-200",children:s.name}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:90:11",children:e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:90:22",variant:"outline",className:"border-slate-700 text-slate-400",children:s.namespace})}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:91:11",children:e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:91:22",className:o[s.status]||"bg-slate-500/20 text-slate-400",children:s.status||"Unknown"})}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:92:11",className:"text-sm text-slate-400",children:s.node_name||"-"}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:93:11",className:"text-sm text-cyan-400",children:s.cpu_usage_m||"-"}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:94:11",className:"text-sm text-amber-400",children:s.mem_usage_mi||"-"}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:95:11",className:s.restart_count>0?"text-yellow-400":"text-slate-500",children:s.restart_count||0}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:96:11",className:"text-xs text-slate-500 max-w-[200px] truncate",children:s.image||"-"}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:97:11",children:e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:98:13",className:"flex items-center gap-0.5",children:[e.jsx(p,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:99:15",variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0 text-emerald-400",title:"终端",onClick:()=>a.onTerminal?.(s),children:e.jsx(Le,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:100:79",className:"h-3.5 w-3.5"})}),e.jsx(p,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:101:15",variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0 text-amber-400",title:"文件",onClick:()=>a.onFileBrowser?.(s),children:e.jsx(Ee,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:102:82",className:"h-3.5 w-3.5"})}),e.jsx(p,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:103:15",variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0 text-blue-400",title:"YAML",onClick:()=>a.onYaml?.(s.name),children:e.jsx(j,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:104:55",className:"h-3.5 w-3.5"})})]})})]},s.name)}},services:{title:"Services",subtitle:"Service 网络服务",icon:W,columns:["名称","命名空间","类型","Cluster IP","端口","操作"],renderRow:(s,a)=>e.jsxs(u,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:115:7",className:"border-slate-800 hover:bg-slate-800/30",children:[e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:116:9",className:"font-medium text-slate-200",children:s.name}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:117:9",children:e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:117:20",variant:"outline",className:"border-slate-700 text-slate-400",children:s.namespace})}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:118:9",children:e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:118:20",className:"bg-blue-500/20 text-blue-400 border-blue-500/30",children:s.type||"-"})}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:119:9",className:"text-sm text-slate-400",children:s.cluster_ip||"-"}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:120:9",className:"text-sm text-slate-400",children:s.ports||"-"}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:121:9",onClick:o=>o.stopPropagation(),children:e.jsx(P,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:121:57",name:s.name,opts:a})})]},s.name)},ingresses:{title:"Ingresses",subtitle:"Ingress 路由规则",icon:W,columns:["名称","命名空间","Hosts","TLS","操作"],renderRow:(s,a)=>{const o=s.hosts||[];return e.jsxs(u,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:131:9",className:"border-slate-800 hover:bg-slate-800/30",children:[e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:132:11",className:"font-medium text-slate-200",children:s.name}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:133:11",children:e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:133:22",variant:"outline",className:"border-slate-700 text-slate-400",children:s.namespace})}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:134:11",className:"text-sm text-slate-400 max-w-[250px] truncate",children:o.length>0?o.join(", "):"-"}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:135:11",children:e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:135:22",className:s.tls?"bg-emerald-500/20 text-emerald-400":"bg-slate-500/20 text-slate-400",children:s.tls?"HTTPS":"HTTP"})}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:136:11",onClick:r=>r.stopPropagation(),children:e.jsx(P,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:136:59",name:s.name,opts:a})})]},s.name)}},configmaps:{title:"ConfigMaps",subtitle:"配置字典",icon:_e,columns:["名称","命名空间","键数量","操作"],renderRow:(s,a)=>e.jsxs(u,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:145:7",className:"border-slate-800 hover:bg-slate-800/30",children:[e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:146:9",className:"font-medium text-slate-200",children:s.name}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:147:9",children:e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:147:20",variant:"outline",className:"border-slate-700 text-slate-400",children:s.namespace})}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:148:9",className:"text-sm text-slate-400",children:s.key_count||"-"}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:149:9",onClick:o=>o.stopPropagation(),children:e.jsx(P,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:149:57",name:s.name,opts:a})})]},s.name)},secrets:{title:"Secrets",subtitle:"密钥管理(仅名称与类型)",icon:C,columns:["名称","命名空间","类型","操作"],renderRow:(s,a)=>e.jsxs(u,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:157:7",className:"border-slate-800 hover:bg-slate-800/30",children:[e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:158:9",className:"font-medium text-slate-200",children:s.name}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:159:9",children:e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:159:20",variant:"outline",className:"border-slate-700 text-slate-400",children:s.namespace})}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:160:9",className:"text-sm text-slate-400",children:s.type||"-"}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:161:9",onClick:o=>o.stopPropagation(),children:e.jsx(P,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:161:57",name:s.name,opts:a})})]},s.name)},hpas:{title:"HPAs",subtitle:"水平自动伸缩",icon:Ye,columns:["名称","命名空间","目标","最小/最大","CPU%","Mem%"],renderRow:(s,a)=>e.jsxs(u,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:169:7",className:"border-slate-800 hover:bg-slate-800/30",children:[e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:170:9",className:"font-medium text-slate-200",children:s.name}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:171:9",children:e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:171:20",variant:"outline",className:"border-slate-700 text-slate-400",children:s.namespace})}),e.jsxs(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:172:9",className:"text-sm text-slate-400",children:[s.target_kind,"/",s.target_name]}),e.jsxs(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:173:9",className:"text-sm text-slate-400",children:[s.min_replicas,"/",s.max_replicas]}),e.jsxs(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:174:9",className:"text-sm text-slate-400",children:[s.cpu_percent??"-","%"]}),e.jsxs(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:175:9",className:"text-sm text-slate-400",children:[s.mem_percent??"-","%"]})]},s.name)},cronjobs:{title:"CronJobs",subtitle:"定时任务",icon:ye,columns:["名称","命名空间","调度","状态","上次执行"],renderRow:s=>e.jsxs(u,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:183:7",className:"border-slate-800 hover:bg-slate-800/30",children:[e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:184:9",className:"font-medium text-slate-200",children:s.name}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:185:9",children:e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:185:20",variant:"outline",className:"border-slate-700 text-slate-400",children:s.namespace})}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:186:9",className:"text-sm font-mono text-slate-400",children:s.schedule||"-"}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:187:9",children:e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:187:20",className:s.suspend?"bg-yellow-500/20 text-yellow-400":"bg-emerald-500/20 text-emerald-400",children:s.suspend?"已暂停":"运行中"})}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:188:9",className:"text-sm text-slate-400",children:s.last_schedule||"-"})]},s.name)},pvcs:{title:"存储卷声明",subtitle:"PersistentVolumeClaim",icon:S,columns:["名称","命名空间","状态","大小","StorageClass","操作"],renderRow:(s,a)=>e.jsxs(u,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:196:7",className:"border-slate-800 hover:bg-slate-800/30",children:[e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:197:9",className:"font-medium text-slate-200",children:s.name}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:198:9",children:e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:198:20",variant:"outline",className:"border-slate-700 text-slate-400",children:s.namespace})}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:199:9",children:e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:199:20",className:s.phase==="Bound"?"bg-emerald-500/20 text-emerald-400":"bg-yellow-500/20 text-yellow-400",children:s.phase||"-"})}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:200:9",className:"text-sm text-slate-400",children:s.size||"-"}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:201:9",className:"text-sm text-slate-400",children:s.storage_class||"-"}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:202:9",onClick:o=>o.stopPropagation(),children:e.jsx(P,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:202:57",name:s.name,opts:a})})]},s.name)},statefulsets:{title:"StatefulSets",subtitle:"有状态应用",icon:S,columns:["名称","命名空间","副本","就绪","镜像"],renderRow:(s,a)=>e.jsxs(u,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:210:7",className:"border-slate-800 hover:bg-slate-800/30 cursor-pointer",onClick:()=>a.onDetail?.(s),children:[e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:211:9",className:"font-medium text-slate-200",children:s.name}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:212:9",children:e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:212:20",variant:"outline",className:"border-slate-700 text-slate-400",children:s.namespace})}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:213:9",className:"text-sm text-slate-400",children:s.replicas||0}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:214:9",className:"text-sm text-slate-400",children:s.ready||0}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:215:9",className:"text-xs text-slate-500 max-w-[200px] truncate",children:s.image||"-"})]},s.name)},daemonsets:{title:"DaemonSets",subtitle:"守护进程集",icon:S,columns:["名称","命名空间","期望","当前","就绪","镜像"],renderRow:(s,a)=>e.jsxs(u,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:223:7",className:"border-slate-800 hover:bg-slate-800/30 cursor-pointer",onClick:()=>a.onDetail?.(s),children:[e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:224:9",className:"font-medium text-slate-200",children:s.name}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:225:9",children:e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:225:20",variant:"outline",className:"border-slate-700 text-slate-400",children:s.namespace})}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:226:9",className:"text-sm text-slate-400",children:s.desired||0}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:227:9",className:"text-sm text-slate-400",children:s.current||0}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:228:9",className:"text-sm text-slate-400",children:s.ready||0}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:229:9",className:"text-xs text-slate-500 max-w-[200px] truncate",children:s.image||"-"})]},s.name)},serviceaccounts:{title:"ServiceAccounts",subtitle:"服务账号(RBAC 身份标识)",icon:C,columns:["名称","命名空间","Secret数","镜像拉取凭证","创建时间","操作"],renderRow:(s,a)=>e.jsxs(u,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:237:7",className:"border-slate-800 hover:bg-slate-800/30",children:[e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:238:9",className:"font-medium text-slate-200",children:s.name}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:239:9",children:e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:239:20",variant:"outline",className:"border-slate-700 text-slate-400",children:s.namespace})}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:240:9",className:"text-sm text-slate-400",children:s.secret_count??0}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:241:9",className:"text-xs text-slate-500 max-w-[200px] truncate",children:s.image_pull_secrets&&s.image_pull_secrets.length>0?s.image_pull_secrets.join(", "):"-"}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:244:9",className:"text-xs text-slate-500",children:s.age||"-"}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:245:9",onClick:o=>o.stopPropagation(),children:e.jsx(p,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:246:11",variant:"ghost",size:"icon",className:"h-7 w-7 text-slate-400 hover:text-blue-400",title:"查看YAML",onClick:()=>a.onYaml?.(s.name),children:e.jsx(j,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:247:52",className:"h-3.5 w-3.5"})})})]},s.name)},roles:{title:"Roles",subtitle:"命名空间级角色权限(RBAC)",icon:C,columns:["名称","命名空间","规则数","权限范围","创建时间","操作"],renderRow:(s,a)=>{const o=s.verbs||[],r=s.resources||[],h=o.length>4?o.slice(0,4).join(", ")+` +${o.length-4}`:o.join(", "),n=r.length>4?r.slice(0,4).join(", ")+` +${r.length-4}`:r.join(", ");return e.jsxs(u,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:261:9",className:"border-slate-800 hover:bg-slate-800/30",children:[e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:262:11",className:"font-medium text-slate-200",children:s.name}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:263:11",children:e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:263:22",variant:"outline",className:"border-slate-700 text-slate-400",children:s.namespace})}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:264:11",className:"text-sm text-slate-400",children:s.rule_count??0}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:265:11",className:"text-xs text-slate-500 max-w-[280px]",children:e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:266:13",className:"flex flex-col gap-0.5",children:[e.jsxs("span",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:267:15",className:"text-cyan-400 truncate",title:o.join(", "),children:["verbs: ",h||"-"]}),e.jsxs("span",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:268:15",className:"text-amber-400 truncate",title:r.join(", "),children:["resources: ",n||"-"]})]})}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:271:11",className:"text-xs text-slate-500",children:s.age||"-"}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:272:11",onClick:d=>d.stopPropagation(),children:e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:273:13",className:"flex items-center gap-0.5",children:[e.jsx(p,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:274:15",variant:"ghost",size:"icon",className:"h-7 w-7 text-slate-400 hover:text-blue-400",title:"查看YAML",onClick:()=>a.onYaml?.(s.name),children:e.jsx(j,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:275:55",className:"h-3.5 w-3.5"})}),e.jsx(p,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:276:15",variant:"ghost",size:"icon",className:"h-7 w-7 text-emerald-400 hover:text-emerald-300",title:"编辑",onClick:()=>a.onEdit?.(s.name),children:e.jsx(B,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:277:55",className:"h-3.5 w-3.5"})})]})})]},s.name)}},rolebindings:{title:"RoleBindings",subtitle:"角色绑定关系(RBAC 授权)",icon:C,columns:["名称","命名空间","角色引用","绑定主体","创建时间","操作"],renderRow:(s,a)=>{const o=s.subjects||[],r=o.length>3?o.slice(0,3).join(", ")+` +${o.length-3}`:o.join(", ");return e.jsxs(u,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:291:9",className:"border-slate-800 hover:bg-slate-800/30",children:[e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:292:11",className:"font-medium text-slate-200",children:s.name}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:293:11",children:e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:293:22",variant:"outline",className:"border-slate-700 text-slate-400",children:s.namespace})}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:294:11",children:e.jsxs(m,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:295:13",className:"bg-purple-500/20 text-purple-400 border-purple-500/30",children:[s.role_ref_kind||"-","/",s.role_ref_name||"-"]})}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:299:11",className:"text-xs text-slate-500 max-w-[200px] truncate",title:o.join(", "),children:r||"-"}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:302:11",className:"text-xs text-slate-500",children:s.age||"-"}),e.jsx(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:303:11",onClick:h=>h.stopPropagation(),children:e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:304:13",className:"flex items-center gap-0.5",children:[e.jsx(p,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:305:15",variant:"ghost",size:"icon",className:"h-7 w-7 text-slate-400 hover:text-blue-400",title:"查看YAML",onClick:()=>a.onYaml?.(s.name),children:e.jsx(j,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:306:56",className:"h-3.5 w-3.5"})}),e.jsx(p,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:307:15",variant:"ghost",size:"icon",className:"h-7 w-7 text-emerald-400 hover:text-emerald-300",title:"编辑",onClick:()=>a.onEdit?.(s.name),children:e.jsx(B,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:308:56",className:"h-3.5 w-3.5"})})]})})]},s.name)}}};function cs(){const{clusterCode:s,namespace:a}=ie(),o=de(),r=he(),{toast:h}=ee(),n=x.useMemo(()=>{const c=o.pathname.split("/"),i=c[c.length-1];if(i&&E[i])return i;if(c.length>=2){const k=c[c.length-2];if(k&&E[k])return k}return"deployments"},[o.pathname]),d=E[n],[g,R]=x.useState([]),[N,z]=x.useState([]),[se,V]=x.useState([]),[y,F]=x.useState(!1),[O,te]=x.useState(""),[v,Y]=x.useState(null),[w,_]=x.useState(null),[ae,H]=x.useState(!1),[$,U]=x.useState(null),[D,J]=x.useState(null);x.useEffect(()=>{l.getClusters().then(c=>{const i=c?.list||[];if(R(i),!s&&i.length>0){const k=i[0].code||String(i[0].id);r(`/kubernetes/${k}/namespace/${a||"default"}/${n}`,{replace:!0})}}).catch(()=>R([]))},[]),x.useEffect(()=>{s&&l.getNamespaces(s).then(c=>{const i=Array.isArray(c)?c:c?.list||c?.data||[];z(i),!a&&i.length>0&&r(`/kubernetes/${s}/namespace/${i[0]}/${n}`,{replace:!0})}).catch(()=>z([]))},[s]);const b=x.useCallback(async()=>{if(!(!s||!a)){F(!0);try{let c=[];switch(n){case"deployments":c=await l.getNamespaceDeployments(s,a).catch(()=>[]);break;case"pods":c=await l.getNamespacePods(s,a).catch(()=>[]);break;case"services":c=await l.getNamespaceServices(s,a).catch(()=>[]);break;case"ingresses":c=await l.getNamespaceIngresses(s,a).catch(()=>[]);break;case"configmaps":c=await l.getNamespaceConfigMaps(s,a).catch(()=>[]);break;case"secrets":c=await l.getNamespaceSecrets(s,a).catch(()=>[]);break;case"hpas":c=await l.getHPAs(s,a).catch(()=>[]);break;case"cronjobs":c=await l.getCronJobs(s,a).catch(()=>[]);break;case"pvcs":c=await l.getPVCs(s,a).catch(()=>[]);break;case"statefulsets":c=await l.getStatefulSets(s,a).catch(()=>[]);break;case"daemonsets":c=await l.getDaemonSets(s,a).catch(()=>[]);break;case"serviceaccounts":c=await l.getServiceAccounts(s,a).catch(()=>[]);break;case"roles":c=await l.getRoles(s,a).catch(()=>[]);break;case"rolebindings":c=await l.getRoleBindings(s,a).catch(()=>[]);break}V(Array.isArray(c)?c:c?.list||c?.data||[])}catch{V([])}finally{F(!1)}}},[s,a,n]);x.useEffect(()=>{b()},[b]);const f=se.filter(c=>(c.name||"").toLowerCase().includes(O.toLowerCase())),ce=c=>{n==="deployments"?r(`/kubernetes/${s}/namespace/${a}/workload/view/Deployment/${c.name}`):n==="statefulsets"?r(`/kubernetes/${s}/namespace/${a}/workload/view/StatefulSet/${c.name}`):n==="daemonsets"&&r(`/kubernetes/${s}/namespace/${a}/workload/view/DaemonSet/${c.name}`)},oe=c=>Y({resource:n,name:c}),ne=c=>{Z.includes(n)?_({resource:n,name:c}):Y({resource:n,name:c,editMode:!0})},re=()=>{if(n==="deployments"){r(`/kubernetes/${s}/namespace/${a}/workload/edit/Deployment/_create`);return}_({resource:n,name:"",isCreate:!0})},me=()=>l.exportAsCSV(`${n}-${s}-${a}.csv`,f),le=()=>l.exportAsJSON(`${n}-${s}-${a}.json`,f),pe=async()=>{if(!(!s||!a))try{await l.exportNamespaceResources(s,a),h({title:"导出完成",description:`${a} 资源 YAML 已开始下载`})}catch(c){h({title:"导出失败",description:c?.message||String(c),variant:"destructive"})}};return d?e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:439:5",className:"space-y-4",children:[v&&e.jsx(ve,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:441:9",clusterCode:s||"",namespace:a||"",resource:v.resource,name:v.name,onClose:()=>Y(null),onSaved:b,autoEdit:v.editMode===!0}),ae&&e.jsx(Te,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:452:9",clusterCode:s||"",onClose:()=>H(!1),onApplied:b}),w&&e.jsx(Ce,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:459:9",clusterCode:s||"",namespace:a||"",resource:w.resource,name:w.name,isCreate:w.isCreate,onClose:()=>_(null),onSaved:b}),e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:470:7",className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx(I,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:471:9",to:"/kubernetes",className:"hover:text-slate-300 transition-colors",children:"集群"}),s&&e.jsxs(e.Fragment,{children:[e.jsx(A,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:472:27",className:"h-3 w-3"}),e.jsx(I,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:472:63",to:`/kubernetes/${s}`,className:"hover:text-slate-300 transition-colors",children:s})]}),a&&e.jsxs(e.Fragment,{children:[e.jsx(A,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:473:25",className:"h-3 w-3"}),e.jsx(I,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:473:61",to:`/kubernetes/${s}/namespace/${a}`,className:"hover:text-slate-300 transition-colors",children:a})]}),e.jsx(A,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:474:9",className:"h-3 w-3"}),e.jsx("span",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:474:45",className:"text-slate-300",children:d.title})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:476:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:477:9",children:[e.jsx("h1",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:478:11",className:"text-2xl font-bold text-slate-100",children:d.title}),e.jsx("p",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:479:11",className:"text-sm text-slate-500 mt-1",children:d.subtitle})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:481:9",className:"flex items-center gap-2",children:[e.jsxs(X,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:482:11",value:s||"",onValueChange:c=>r(`/kubernetes/${c}/namespace/${a||"default"}/${n}`),children:[e.jsx(G,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:483:13",className:"w-48 h-9 bg-slate-800/50 border-slate-700 text-slate-200",children:e.jsx(K,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:483:97",placeholder:"选择集群"})}),e.jsx(q,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:484:13",className:"bg-slate-800 border-slate-700",children:g.map(c=>e.jsx(Q,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:484:91",value:c.code||String(c.id),children:c.name},c.id))})]}),e.jsxs(X,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:486:11",value:a||"",onValueChange:c=>r(`/kubernetes/${s}/namespace/${c}/${n}`),children:[e.jsx(G,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:487:13",className:"w-40 h-9 bg-slate-800/50 border-slate-700 text-slate-200",children:e.jsx(K,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:487:97",placeholder:"命名空间"})}),e.jsx(q,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:488:13",className:"bg-slate-800 border-slate-700 max-h-[300px]",children:N.map(c=>e.jsx(Q,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:488:108",value:c,children:c},c))})]}),e.jsx(p,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:490:11",variant:"outline",size:"icon",className:"h-9 w-9 border-slate-700 text-slate-400",onClick:b,disabled:y,children:y?e.jsx(M,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:491:24",className:"h-4 w-4 animate-spin"}):e.jsx(De,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:491:71",className:"h-4 w-4"})}),ze.includes(n)&&e.jsxs(e.Fragment,{children:[e.jsxs(p,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:495:15",variant:"outline",size:"sm",className:"h-9 border-slate-700 text-slate-400 text-xs",onClick:me,title:"导出CSV",children:[e.jsx(L,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:496:17",className:"h-3 w-3 mr-1"}),"CSV"]}),e.jsxs(p,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:498:15",variant:"outline",size:"sm",className:"h-9 border-slate-700 text-slate-400 text-xs",onClick:le,title:"导出JSON",children:[e.jsx(L,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:499:17",className:"h-3 w-3 mr-1"}),"JSON"]})]}),Be.includes(n)&&e.jsxs(p,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:504:13",variant:"outline",size:"sm",className:"h-9 border-slate-700 text-slate-400 text-xs",onClick:pe,title:"导出命名空间 YAML(tar.gz)",children:[e.jsx(L,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:505:15",className:"h-3 w-3 mr-1"}),"导出YAML"]}),(Z.includes(n)||Me.includes(n))&&e.jsxs(e.Fragment,{children:[e.jsxs(p,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:510:15",variant:"outline",size:"sm",className:"h-9 border-slate-700 text-slate-400 text-xs",onClick:()=>H(!0),children:[e.jsx(T,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:511:17",className:"h-3 w-3 mr-1"}),"导入"]}),e.jsxs(p,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:513:15",size:"sm",className:"h-9 text-xs bg-blue-600 hover:bg-blue-700",onClick:re,children:[e.jsx(Ie,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:514:17",className:"h-3 w-3 mr-1"}),"新建"]})]})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:520:7",className:"flex items-center gap-3 flex-wrap",children:e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:521:7",className:"relative w-56 flex-1 min-w-[200px] max-w-xs",children:[e.jsx(Ae,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:522:9",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-500"}),e.jsx(ge,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:523:9",placeholder:"搜索...",value:O,onChange:c=>te(c.target.value),className:"pl-9 h-9 bg-slate-800/50 border-slate-700 text-slate-200"})]})}),e.jsx(xe,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:526:7",className:"bg-slate-900 border-slate-800",children:e.jsx(ue,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:527:9",className:"p-0",children:e.jsxs(be,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:528:11",children:[e.jsx(Ne,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:529:13",children:e.jsx(u,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:529:26",className:"border-slate-800 hover:bg-transparent",children:d.columns.map(c=>e.jsx(ke,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:529:115",className:"text-slate-400",children:c},c))})}),e.jsx(Pe,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:530:13",children:y?e.jsx(u,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:532:17",children:e.jsxs(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:532:27",colSpan:d.columns.length,className:"text-center text-slate-500 py-12",children:[e.jsx(M,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:532:115",className:"h-5 w-5 animate-spin mx-auto mb-2"}),"加载中..."]})}):f.length===0?e.jsx(u,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:534:17",children:e.jsxs(t,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:534:27",colSpan:d.columns.length,className:"text-center text-slate-500 py-12",children:[e.jsx(d.icon,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:534:115",className:"h-8 w-8 mx-auto mb-2 opacity-50"}),"暂无 ",d.title]})}):f.map(c=>d.renderRow(c,{clusterCode:s||"",namespace:a||"",onDetail:ce,onYaml:oe,onEdit:ne,onTerminal:i=>U(i),onFileBrowser:i=>J(i)}))})]})})}),e.jsx(we,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:544:7",open:!!$,onOpenChange:c=>{c||U(null)},clusterId:g[0]?.id||g[0]?.code||s||"",namespace:a||"",podName:$?.name||"",containers:($?.containers||[]).map(c=>c.name).filter(Boolean)}),e.jsx(fe,{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:553:7",open:!!D,onOpenChange:c=>{c||J(null)},clusterCode:s||"",namespace:a||"",podName:D?.name||"",containers:(D?.containers||[]).map(c=>c.name).filter(Boolean)})]}):e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceResourcePage.tsx:436:23",className:"text-slate-400 p-8 text-center",children:["未知资源类型: ",n]})}export{cs as default}; diff --git a/backend/static/assets/NodeDetailPage-C77WC8d_.js b/backend/static/assets/NodeDetailPage-C77WC8d_.js deleted file mode 100644 index 035e9ec..0000000 --- a/backend/static/assets/NodeDetailPage-C77WC8d_.js +++ /dev/null @@ -1 +0,0 @@ -import{r as p,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{C as c,a as o}from"./card-BIfzBCEy.js";import{g as R,i as M,L as g,B as q}from"./index-Dungj95X.js";import{B as l}from"./badge-CGJlVD3L.js";import{T as B,a as L,b as k,c as n,d as S,e as r}from"./table-B2F10oba.js";import{k as F}from"./index-drGq01ok.js";import{f as j,h as U,L as P,R as A,l as D,I as E,A as I,C as f,N as z,k as H}from"./vendor-icons-DmqcWdzX.js";function X(){const{clusterCode:d,nodeName:i}=R();M();const[s,N]=p.useState(null),[h,u]=p.useState(!1),b=p.useCallback(async()=>{if(!(!d||!i)){u(!0);try{const t=await F.getNodeDetail(d,i);N(t)}catch{N(null)}finally{u(!1)}}},[d,i]);p.useEffect(()=>{b()},[b]);const x=({label:t,used:a,total:v,unit:w,pct:C,color:$})=>{const m=Math.min(Math.max(C||0,0),100),T=m>80?"bg-red-500":m>60?"bg-amber-500":"bg-emerald-500";return e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:53:7",className:"space-y-1.5",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:54:9",className:"flex items-center justify-between text-xs",children:[e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:55:11",className:"text-slate-400",children:t}),e.jsxs("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:56:11",className:"text-slate-300 font-medium",children:[a," / ",v," ",w]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:60:9",className:"flex items-center gap-2",children:[e.jsx("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:61:11",className:"flex-1 h-2 rounded-full bg-slate-700/50 overflow-hidden",children:e.jsx("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:62:13",className:`h-full rounded-full ${T} transition-all duration-500`,style:{width:`${m}%`}})}),e.jsxs("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:64:11",className:`text-xs font-semibold min-w-[40px] text-right ${$}`,children:[m.toFixed(0),"%"]})]})]})},_=(t,a)=>a==="True"?t==="Ready"?"bg-emerald-500/20 text-emerald-400":"bg-red-500/20 text-red-400":"bg-slate-500/20 text-slate-400",y=t=>t==="NoSchedule"?"bg-red-500/20 text-red-400 border-red-500/30":t==="NoExecute"?"bg-red-600/20 text-red-300 border-red-600/30":t==="PreferNoSchedule"?"bg-amber-500/20 text-amber-400 border-amber-500/30":"bg-slate-500/20 text-slate-400 border-slate-500/30";return e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:89:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:91:7",className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx(g,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:92:9",to:"/kubernetes",className:"hover:text-slate-300 transition-colors",children:"集群"}),e.jsx(j,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:93:9",className:"h-3 w-3"}),e.jsx(g,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:94:9",to:`/kubernetes/${d}`,className:"hover:text-slate-300 transition-colors",children:d}),e.jsx(j,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:95:9",className:"h-3 w-3"}),e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:96:9",className:"text-slate-300",children:i})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:100:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:101:9",className:"flex items-center gap-3",children:[e.jsx("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:102:11",className:"flex items-center justify-center w-12 h-12 rounded-xl bg-slate-800 border border-slate-700",children:e.jsx(U,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:103:13",className:"h-6 w-6 text-blue-400"})}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:105:11",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:106:13",className:"flex items-center gap-2",children:[e.jsx("h1",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:107:15",className:"text-2xl font-bold text-slate-100",children:i}),e.jsx(l,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:108:15",className:s?.role==="master"?"bg-blue-500/20 text-blue-400 border-blue-500/30":"bg-slate-500/20 text-slate-400 border-slate-500/30",children:s?.role||"worker"}),e.jsx(l,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:111:15",className:s?.status==="Ready"?"bg-emerald-500/20 text-emerald-400":"bg-red-500/20 text-red-400",children:s?.status||"Unknown"})]}),e.jsxs("p",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:115:13",className:"text-sm text-slate-500 mt-0.5",children:[s?.internal_ip&&`${s.internal_ip}`,s?.hostname&&` · ${s.hostname}`]})]})]}),e.jsx(q,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:121:9",variant:"outline",size:"icon",className:"h-9 w-9 border-slate-700 text-slate-400",onClick:b,disabled:h,children:h?e.jsx(P,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:123:22",className:"h-4 w-4 animate-spin"}):e.jsx(A,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:123:69",className:"h-4 w-4"})})]}),h&&!s?e.jsx(c,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:128:9",className:"bg-slate-900 border-slate-800",children:e.jsx(o,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:129:11",className:"py-16 flex items-center justify-center",children:e.jsx(P,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:130:13",className:"h-6 w-6 animate-spin text-slate-500"})})}):s?e.jsxs(e.Fragment,{children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:143:11",className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(c,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:145:13",className:"bg-slate-900 border-slate-800",children:e.jsxs(o,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:146:15",className:"p-4",children:[e.jsxs("h2",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:147:17",className:"text-sm font-semibold text-slate-200 mb-3 flex items-center gap-2",children:[e.jsx(E,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:148:19",className:"h-4 w-4 text-cyan-400"}),"系统信息"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:150:17",className:"space-y-2 text-xs",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:151:19",className:"flex items-center justify-between py-1.5 border-b border-slate-800/50",children:[e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:152:21",className:"text-slate-500",children:"容器运行时"}),e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:153:21",className:"text-slate-300 font-mono",children:s.container_runtime||"-"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:155:19",className:"flex items-center justify-between py-1.5 border-b border-slate-800/50",children:[e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:156:21",className:"text-slate-500",children:"Kubelet"}),e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:157:21",className:"text-slate-300 font-mono",children:s.kubelet_version||"-"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:159:19",className:"flex items-center justify-between py-1.5 border-b border-slate-800/50",children:[e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:160:21",className:"text-slate-500",children:"操作系统"}),e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:161:21",className:"text-slate-300",children:s.os_image||"-"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:163:19",className:"flex items-center justify-between py-1.5 border-b border-slate-800/50",children:[e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:164:21",className:"text-slate-500",children:"内核版本"}),e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:165:21",className:"text-slate-300 font-mono",children:s.kernel_version||"-"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:167:19",className:"flex items-center justify-between py-1.5 border-b border-slate-800/50",children:[e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:168:21",className:"text-slate-500",children:"架构"}),e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:169:21",className:"text-slate-300 font-mono",children:s.architecture||"-"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:171:19",className:"flex items-center justify-between py-1.5 border-b border-slate-800/50",children:[e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:172:21",className:"text-slate-500",children:"创建时间"}),e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:173:21",className:"text-slate-300",children:s.creation_time?new Date(s.creation_time).toLocaleString("zh-CN"):"-"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:175:19",className:"flex items-center justify-between py-1.5",children:[e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:176:21",className:"text-slate-500",children:"Pod CIDR"}),e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:177:21",className:"text-slate-300 font-mono",children:s.pod_cidr||"-"})]})]})]})}),e.jsx(c,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:184:13",className:"bg-slate-900 border-slate-800",children:e.jsxs(o,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:185:15",className:"p-4",children:[e.jsxs("h2",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:186:17",className:"text-sm font-semibold text-slate-200 mb-3 flex items-center gap-2",children:[e.jsx(I,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:187:19",className:"h-4 w-4 text-emerald-400"}),"资源分配率"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:189:17",className:"space-y-4 mt-4",children:[e.jsx(x,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:191:19",label:"CPU 已分配",used:`${(s.cpu_request_m/1e3).toFixed(2)} 核`,total:`${s.cpu_allocatable} 核`,unit:"",pct:s.cpu_alloc_pct,color:"text-emerald-400"}),s.cpu_usage_m&&e.jsx(x,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:201:21",label:"CPU 实时使用",used:s.cpu_usage_m,total:`${s.cpu_capacity} 核`,unit:"",pct:parseFloat(s.cpu_usage_m.replace("m",""))/(s.cpu_capacity*1e3)*100,color:"text-blue-400"}),e.jsx(x,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:211:19",label:"内存已分配",used:`${s.mem_request_mi} Mi`,total:`${s.mem_allocatable_mb} Mi`,unit:"",pct:s.mem_alloc_pct,color:"text-emerald-400"}),s.mem_usage_mi&&e.jsx(x,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:221:21",label:"内存实时使用",used:s.mem_usage_mi,total:`${s.mem_capacity_mb} Mi`,unit:"",pct:parseFloat(s.mem_usage_mi.replace("Mi","").replace("Ki","").replace("Gi",""))/s.mem_capacity_mb*100,color:"text-blue-400"}),e.jsx(x,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:231:19",label:"Pod 数量",used:`${s.pod_count}`,total:`${s.pod_allocatable}`,unit:"",pct:s.pod_alloc_pct,color:"text-emerald-400"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:241:17",className:"mt-4 pt-3 border-t border-slate-800/50 space-y-1 text-[11px] text-slate-500",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:242:19",className:"flex justify-between",children:[e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:243:21",children:"CPU 容量 / 可分配"}),e.jsxs("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:244:21",className:"font-mono",children:[s.cpu_capacity," / ",s.cpu_allocatable," 核"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:246:19",className:"flex justify-between",children:[e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:247:21",children:"内存容量 / 可分配"}),e.jsxs("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:248:21",className:"font-mono",children:[s.mem_capacity_mb," / ",s.mem_allocatable_mb," Mi"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:250:19",className:"flex justify-between",children:[e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:251:21",children:"Pod 容量 / 可分配"}),e.jsxs("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:252:21",className:"font-mono",children:[s.pod_capacity," / ",s.pod_allocatable]})]})]})]})})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:260:11",className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(c,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:262:13",className:"bg-slate-900 border-slate-800",children:e.jsxs(o,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:263:15",className:"p-4",children:[e.jsxs("h2",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:264:17",className:"text-sm font-semibold text-slate-200 mb-3 flex items-center gap-2",children:[e.jsx(f,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:265:19",className:"h-4 w-4 text-blue-400"}),"节点条件"]}),!s.conditions||s.conditions.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:268:19",className:"text-xs text-slate-500 py-4 text-center",children:"无条件数据"}):e.jsx("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:270:19",className:"space-y-2",children:s.conditions.map((t,a)=>e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:272:23",className:"flex items-start gap-2 text-xs py-1.5 border-b border-slate-800/30 last:border-0",children:[e.jsxs(l,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:273:25",className:_(t.type,t.status),children:[t.status==="True"?e.jsx(f,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:274:53",className:"h-3 w-3 mr-1"}):null,t.type]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:277:25",className:"flex-1 min-w-0",children:[t.reason&&e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:278:43",className:"text-slate-400 block",children:t.reason}),t.message&&e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:279:44",className:"text-slate-600 text-[11px] block truncate",children:t.message})]})]},a))})]})}),e.jsx(c,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:289:13",className:"bg-slate-900 border-slate-800",children:e.jsxs(o,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:290:15",className:"p-4",children:[e.jsxs("h2",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:291:17",className:"text-sm font-semibold text-slate-200 mb-3 flex items-center gap-2",children:[e.jsx(D,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:292:19",className:"h-4 w-4 text-amber-400"}),"污点 (Taints)"]}),!s.taints||s.taints.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:295:19",className:"text-xs text-slate-500 py-4 text-center",children:"无污点"}):e.jsx("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:297:19",className:"space-y-2",children:s.taints.map((t,a)=>e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:299:23",className:"flex items-center gap-2 text-xs",children:[e.jsx(l,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:300:25",className:y(t.effect),children:t.effect}),e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:301:25",className:"text-slate-300 font-mono",children:t.key}),t.value&&e.jsxs("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:302:37",className:"text-slate-500",children:["= ",t.value]})]},a))})]})})]}),s.labels&&s.labels.length>0&&e.jsx(c,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:313:13",className:"bg-slate-900 border-slate-800",children:e.jsxs(o,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:314:15",className:"p-4",children:[e.jsxs("h2",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:315:17",className:"text-sm font-semibold text-slate-200 mb-3 flex items-center gap-2",children:[e.jsx(z,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:316:19",className:"h-4 w-4 text-slate-400"}),"标签 (",s.labels.length,")"]}),e.jsx("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:318:17",className:"flex flex-wrap gap-1.5",children:s.labels.map((t,a)=>e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:320:21",className:"flex items-center gap-1 bg-slate-800/50 border border-slate-700/50 rounded px-2 py-0.5 text-[11px]",children:[e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:321:23",className:"text-slate-400",children:t.key}),e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:322:23",className:"text-slate-600",children:":"}),e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:323:23",className:"text-slate-300",children:t.value})]},a))})]})}),e.jsx(c,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:332:11",className:"bg-slate-900 border-slate-800",children:e.jsxs(o,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:333:13",className:"p-0",children:[e.jsx("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:334:15",className:"px-4 py-3 border-b border-slate-800",children:e.jsxs("h2",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:335:17",className:"text-sm font-semibold text-slate-200 flex items-center gap-2",children:[e.jsx(H,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:336:19",className:"h-4 w-4 text-cyan-400"}),"节点上的 Pod",e.jsx(l,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:338:19",className:"bg-slate-700/50 text-slate-300",children:s.pods?.length||0})]})}),!s.pods||s.pods.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:342:17",className:"text-xs text-slate-500 py-8 text-center",children:"该节点上暂无 Pod"}):e.jsxs(B,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:344:17",children:[e.jsx(L,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:345:19",children:e.jsxs(k,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:346:21",className:"border-slate-800 hover:bg-transparent",children:[e.jsx(n,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:347:23",className:"text-slate-400",children:"命名空间"}),e.jsx(n,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:348:23",className:"text-slate-400",children:"名称"}),e.jsx(n,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:349:23",className:"text-slate-400",children:"状态"}),e.jsx(n,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:350:23",className:"text-slate-400",children:"IP"}),e.jsx(n,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:351:23",className:"text-slate-400",children:"CPU 请求"}),e.jsx(n,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:352:23",className:"text-slate-400",children:"内存请求"}),e.jsx(n,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:353:23",className:"text-slate-400",children:"重启次数"})]})}),e.jsx(S,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:356:19",children:s.pods.map((t,a)=>e.jsxs(k,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:358:23",className:"border-slate-800 hover:bg-slate-800/30",children:[e.jsx(r,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:359:25",className:"text-sm text-slate-400",children:t.namespace}),e.jsx(r,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:360:25",className:"text-sm font-medium text-slate-200",children:t.name}),e.jsx(r,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:361:25",children:e.jsx(l,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:362:27",className:t.status==="Running"?"bg-emerald-500/20 text-emerald-400":t.status==="Pending"?"bg-amber-500/20 text-amber-400":"bg-red-500/20 text-red-400",children:t.status})}),e.jsx(r,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:368:25",className:"text-xs text-slate-400 font-mono",children:t.ip||"-"}),e.jsx(r,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:369:25",className:"text-xs text-slate-400",children:t.cpu_request_m>0?`${t.cpu_request_m}m`:"-"}),e.jsx(r,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:372:25",className:"text-xs text-slate-400",children:t.mem_request_mi>0?`${t.mem_request_mi}Mi`:"-"}),e.jsx(r,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:375:25",className:"text-xs",children:t.restart_count>0?e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:377:29",className:"text-amber-400",children:t.restart_count}):e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:379:29",className:"text-slate-600",children:"0"})})]},a))})]})]})})]}):e.jsx(c,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:134:9",className:"bg-slate-900 border-slate-800",children:e.jsxs(o,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:135:11",className:"py-16 text-center text-slate-500",children:[e.jsx(D,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:136:13",className:"h-8 w-8 mx-auto mb-2 opacity-50"}),"无法加载节点详情"]})})]})}export{X as default}; diff --git a/backend/static/assets/PipelineEditor-SgC_ThAp.js b/backend/static/assets/PipelineEditor-SgC_ThAp.js deleted file mode 100644 index fe7c913..0000000 --- a/backend/static/assets/PipelineEditor-SgC_ThAp.js +++ /dev/null @@ -1 +0,0 @@ -import{r as i,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{C as P,a as E}from"./card-BIfzBCEy.js";import{g as Qe,f as Xe,t as m,B as p,D as Ye,a as Ze,b as qe,c as es}from"./index-Dungj95X.js";import{I as u}from"./input-CXoUQQLm.js";import{B as j}from"./badge-CGJlVD3L.js";import{T as ss,a as ts,b as C,c as k}from"./tabs-D87nAyJR.js";import{S as $,a as O,b as V,c as B,d as h}from"./select-CiTqGGhE.js";import{T as os}from"./textarea-BxfjmLq5.js";import{S as G}from"./switch-Bxiq4EHp.js";import{L as y}from"./label-CMpUoC87.js";import{p as g}from"./pipeline-DO4lDm_n.js";import{d as ns}from"./config-BrfI0oO-.js";import{L as H,J as R,$ as cs,z as ds,j as je,P as D,Q as Pe,f as Ee,O as is,T as S,b as ue,a0 as ve,a1 as Ne,w as rs,X as as,a2 as be,F as ps,a3 as ls,V as xs,k as ms,o as hs,r as ys,a4 as gs,a5 as js,h as Ps,a6 as fe,a7 as Es}from"./vendor-icons-DmqcWdzX.js";import"./index-5FEebgvX.js";const us={source:"拉取代码",build:"构建",deploy:"部署",test:"测试",custom:"自定义"},we={GitBranch:R,Wrench:fe,Server:Ps,FlaskConical:js,Zap:gs,Terminal:ys,FileCode:hs,Container:ms};function vs(){return`tsk-${Date.now()}-${Math.random().toString(36).slice(2,7)}`}function Ce(r){if(!r)return"-";if(r<60)return`${r}s`;const d=Math.floor(r/60),c=r%60;return c>0?`${d}分${c}秒`:`${d}分`}function Ns({task:r,selected:d,onSelect:c,onDelete:v}){const a=we[r.icon]||fe;return e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:76:5",onClick:c,className:`flex items-center gap-3 p-3 rounded-md border cursor-pointer transition-all group ${d?"border-blue-500 bg-blue-500/10":"border-[var(--dg-border)] hover:border-slate-400 bg-[var(--dg-bg-secondary)]"}`,children:[e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:82:7",className:`p-1.5 rounded ${d?"bg-blue-100":"bg-slate-100 dark:bg-slate-800"}`,children:e.jsx(a,{"code-path":"src/components/deploy/PipelineEditor.tsx:83:9",className:`w-4 h-4 ${d?"text-blue-600":"text-[var(--dg-text-secondary)]"}`})}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:85:7",className:"flex-1 min-w-0",children:[e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:86:9",className:"text-sm font-medium text-[var(--dg-text-primary)] truncate",children:r.name}),e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:87:9",className:"text-xs text-[var(--dg-text-secondary)]",children:r.type})]}),e.jsx(p,{"code-path":"src/components/deploy/PipelineEditor.tsx:89:7",variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100",onClick:x=>{x.stopPropagation(),v()},children:e.jsx(S,{"code-path":"src/components/deploy/PipelineEditor.tsx:90:9",className:"w-3.5 h-3.5 text-red-500"})})]})}function bs({task:r,onUpdate:d}){return r?e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:100:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:101:7",className:"space-y-1",children:[e.jsx(y,{"code-path":"src/components/deploy/PipelineEditor.tsx:101:34",className:"text-xs",children:"任务名称"}),e.jsx(u,{"code-path":"src/components/deploy/PipelineEditor.tsx:101:73",value:r.name,onChange:c=>d({...r,name:c.target.value}),className:"h-8 text-sm"})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:102:7",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:103:9",className:"space-y-1",children:[e.jsx(y,{"code-path":"src/components/deploy/PipelineEditor.tsx:103:36",className:"text-xs",children:"类型"}),e.jsxs($,{"code-path":"src/components/deploy/PipelineEditor.tsx:104:11",value:r.type,onValueChange:c=>d({...r,type:c}),children:[e.jsx(O,{"code-path":"src/components/deploy/PipelineEditor.tsx:104:89",className:"h-8 text-sm",children:e.jsx(V,{"code-path":"src/components/deploy/PipelineEditor.tsx:104:128"})}),e.jsxs(B,{"code-path":"src/components/deploy/PipelineEditor.tsx:105:13",children:[e.jsx(h,{"code-path":"src/components/deploy/PipelineEditor.tsx:105:28",value:"build",children:"构建"}),e.jsx(h,{"code-path":"src/components/deploy/PipelineEditor.tsx:105:69",value:"deploy",children:"部署"}),e.jsx(h,{"code-path":"src/components/deploy/PipelineEditor.tsx:105:111",value:"test",children:"测试"}),e.jsx(h,{"code-path":"src/components/deploy/PipelineEditor.tsx:105:151",value:"custom",children:"自定义"})]})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:107:9",className:"space-y-1",children:[e.jsx(y,{"code-path":"src/components/deploy/PipelineEditor.tsx:107:36",className:"text-xs",children:"图标"}),e.jsxs($,{"code-path":"src/components/deploy/PipelineEditor.tsx:108:11",value:r.icon,onValueChange:c=>d({...r,icon:c}),children:[e.jsx(O,{"code-path":"src/components/deploy/PipelineEditor.tsx:108:89",className:"h-8 text-sm",children:e.jsx(V,{"code-path":"src/components/deploy/PipelineEditor.tsx:108:128"})}),e.jsx(B,{"code-path":"src/components/deploy/PipelineEditor.tsx:109:13",children:Object.entries(we).map(([c])=>e.jsx(h,{"code-path":"src/components/deploy/PipelineEditor.tsx:109:69",value:c,children:c},c))})]})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:112:7",className:"space-y-1",children:[e.jsx(y,{"code-path":"src/components/deploy/PipelineEditor.tsx:112:34",className:"text-xs",children:"脚本类型"}),e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:113:9",className:"flex gap-2",children:["shell","python"].map(c=>e.jsx(j,{"code-path":"src/components/deploy/PipelineEditor.tsx:113:68",variant:r.script_type===c?"default":"outline",className:"cursor-pointer text-xs",onClick:()=>d({...r,script_type:c}),children:c},c))})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:115:7",className:"space-y-1",children:[e.jsx(y,{"code-path":"src/components/deploy/PipelineEditor.tsx:115:34",className:"text-xs",children:"脚本内容"}),e.jsx(os,{"code-path":"src/components/deploy/PipelineEditor.tsx:116:9",value:r.script,onChange:c=>d({...r,script:c.target.value}),className:"font-mono text-xs min-h-[200px] bg-slate-950 text-green-400",placeholder:"#!/bin/bash\\nset -e\\necho 'hello'"})]})]}):e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:98:21",className:"p-6 text-center text-[var(--dg-text-secondary)] text-sm",children:"选择一个任务开始编辑"})}function fs({open:r,onClose:d,run:c,logs:v}){return e.jsx(Ye,{"code-path":"src/components/deploy/PipelineEditor.tsx:125:5",open:r,onOpenChange:d,children:e.jsxs(Ze,{"code-path":"src/components/deploy/PipelineEditor.tsx:126:7",className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[e.jsx(qe,{"code-path":"src/components/deploy/PipelineEditor.tsx:127:9",children:e.jsxs(es,{"code-path":"src/components/deploy/PipelineEditor.tsx:127:23",className:"flex items-center gap-2",children:[e.jsx(Es,{"code-path":"src/components/deploy/PipelineEditor.tsx:127:72",className:"w-5 h-5"}),"执行日志 #",c?.build_number||c?.id]})}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:128:9",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:129:11",className:"flex flex-wrap gap-3 text-sm text-[var(--dg-text-secondary)]",children:[e.jsxs("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:130:13",children:["触发方式: ",c?.triggered_by||"manual"]}),e.jsxs("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:131:13",children:["分支: ",c?.branch||"-"]}),e.jsxs("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:132:13",children:["耗时: ",Ce(c?.duration)]}),e.jsx("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:133:13",children:c?.created_at?new Date(c.created_at).toLocaleString("zh-CN"):"-"})]}),e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:135:11",className:"bg-slate-950 rounded-md p-3 max-h-[50vh] overflow-y-auto font-mono text-xs",children:v.length===0?e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:137:15",className:"text-slate-500 py-4 text-center",children:"暂无日志"}):v.map((a,x)=>e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:140:17",className:"flex gap-2 py-0.5",children:[e.jsxs("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:141:19",className:"text-slate-500 shrink-0",children:["[",a.time,"]"]}),e.jsxs("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:142:19",className:a.level==="error"?"text-red-400":a.level==="warn"?"text-yellow-400":a.level==="success"?"text-green-400":"text-slate-300",children:[a.level==="success"?"✓":a.level==="error"?"✗":a.level==="warn"?"!":">"," ",a.message]})]},x))})]})]})})}function Vs(){const{code:r}=Qe(),d=r||"",[c,v]=i.useState(null),[a,x]=i.useState([]),[_,T]=i.useState(null),[ke,I]=i.useState({}),[Se,_e]=i.useState("flow"),[Te,W]=i.useState(!0),[K,Q]=i.useState(!1),[F,X]=i.useState([]),[Y,Me]=i.useState([]),[J,Z]=i.useState([]),[Le,q]=i.useState(!1),[N,M]=i.useState("manual"),[ee,se]=i.useState(""),[te,oe]=i.useState(""),[ne,ce]=i.useState(""),[b,f]=i.useState([]),[L,de]=i.useState(""),[U,ie]=i.useState(""),[re,ze]=i.useState("editor"),[Ae,ae]=i.useState(!1),[De,Re]=i.useState(null),[$e,pe]=i.useState([]),le=Xe(),xe=i.useCallback(async()=>{try{const s=await ns.getEnvironments();Me(Array.isArray(s)?s:s?.list||[])}catch{}},[]),z=i.useCallback(async()=>{q(!0);try{const s=await g.getMembers(d);Z(Array.isArray(s)?s:s?.data||[])}catch{Z([])}finally{q(!1)}},[d]),A=i.useCallback(async()=>{try{const s=await g.getRuns(d);X(Array.isArray(s)?s:s?.list||[])}catch{X([])}},[d]);i.useEffect(()=>{(async()=>{W(!0);try{const s=await g.getPipelineDetail(d);if(!s||!s.id){v(null),W(!1);return}v(s),M(s.trigger_mode||"manual"),se(s.watch_branches||""),oe(s.cron_expr||""),ce(s.webhook_token||""),de(s.environment_id||"");try{const n=s.variables?JSON.parse(s.variables):{};f(Object.entries(n).map(([o,t])=>[o,String(t)]))}catch{f([])}try{const n=s.stages?JSON.parse(s.stages):[],o=Array.isArray(n)?n:[];x(o);const t={};o.forEach(l=>{t[l.id]=!0}),I(t)}catch{x([])}}catch{m.error("加载失败")}finally{W(!1)}})(),xe(),z(),A()},[d,xe,z,A]);const me=a.flatMap(s=>s.tasks).find(s=>s.id===_)||null,Oe=s=>{x(n=>n.map(o=>({...o,tasks:o.tasks.map(t=>t.id===s.id?s:t)})))},Ve=s=>{const n={id:vs(),name:"新任务",type:"build",icon:"Wrench",config:{},script:"",script_type:"shell"};x(o=>o.map((t,l)=>l===s?{...t,tasks:[...t.tasks,n]}:t))},Be=s=>{x(n=>n.map(o=>({...o,tasks:o.tasks.filter(t=>t.id!==s)}))),_===s&&T(null)},Ie=()=>{const s={id:`stg-${Date.now()}`,name:"新阶段",type:"custom",tasks:[]};x(n=>[...n,s])},We=s=>{x(n=>n.filter((o,t)=>t!==s))},he=(s,n)=>{const o=s+n;if(o<0||o>=a.length)return;const t=[...a];[t[s],t[o]]=[t[o],t[s]],x(t)},Fe=async()=>{Q(!0);try{await g.updatePipeline(d,{stages:JSON.stringify(a),trigger_mode:N,watch_branches:ee,cron_expr:te,webhook_token:ne,environment_id:L?Number(L):null,variables:JSON.stringify(Object.fromEntries(b.filter(([s])=>s.trim())))}),m.success("已保存")}catch{m.error("保存失败")}finally{Q(!1)}},Je=async()=>{try{await g.triggerPipeline(d),m.success("已触发"),A()}catch{m.error("触发失败")}},Ue=async s=>{if(await le({title:"停止运行",description:"确定要停止此运行吗?",variant:"destructive"}))try{await g.stopRun(d,s),m.success("已停止"),A()}catch{m.error("停止失败")}},Ge=async s=>{Re(s),ae(!0);try{const n=await g.getRunLog(d,s.id);pe(n?.logs||[])}catch{pe([])}},He=async()=>{if(!U.trim()){m.error("请输入用户名");return}try{await g.addMember(d,{username:U.trim(),role:re}),m.success("已添加成员"),ie(""),z()}catch(s){m.error(s?.message||"添加失败")}},ye=async s=>{if(await le({title:"移除成员",description:"确定要移除此成员吗?",variant:"destructive"}))try{await g.removeMember(d,s),m.success("已移除"),z()}catch{m.error("移除失败")}},w=Y.find(s=>String(s.id)===String(L));return Te?e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:326:23",className:"flex items-center justify-center py-20",children:e.jsx(H,{"code-path":"src/components/deploy/PipelineEditor.tsx:326:79",className:"w-6 h-6 animate-spin"})}):c?e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:330:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:332:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:333:9",children:[e.jsxs("h1",{"code-path":"src/components/deploy/PipelineEditor.tsx:334:11",className:"text-xl font-bold flex items-center gap-2 text-[var(--dg-text-primary)]",children:[e.jsx(R,{"code-path":"src/components/deploy/PipelineEditor.tsx:335:13",className:"w-5 h-5 text-blue-500"}),c.name,w&&e.jsx(j,{"code-path":"src/components/deploy/PipelineEditor.tsx:337:26",style:{backgroundColor:w.color+"20",color:w.color,borderColor:w.color+"40"},className:"text-xs ml-2",children:w.display_name})]}),e.jsxs("p",{"code-path":"src/components/deploy/PipelineEditor.tsx:339:11",className:"text-sm text-[var(--dg-text-secondary)] mt-1",children:["code: ",c.code," · ",c.description]})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:341:9",className:"flex items-center gap-2",children:[e.jsxs(p,{"code-path":"src/components/deploy/PipelineEditor.tsx:342:11",variant:"outline",onClick:Fe,disabled:K,children:[e.jsx(cs,{"code-path":"src/components/deploy/PipelineEditor.tsx:342:76",className:"w-4 h-4 mr-1"}),K?"保存中...":"保存"]}),e.jsxs(p,{"code-path":"src/components/deploy/PipelineEditor.tsx:343:11",variant:"default",onClick:Je,children:[e.jsx(ds,{"code-path":"src/components/deploy/PipelineEditor.tsx:343:61",className:"w-4 h-4 mr-1"}),"运行"]})]})]}),e.jsx(P,{"code-path":"src/components/deploy/PipelineEditor.tsx:348:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(E,{"code-path":"src/components/deploy/PipelineEditor.tsx:349:9",className:"p-3 flex items-center gap-3",children:[e.jsx(je,{"code-path":"src/components/deploy/PipelineEditor.tsx:350:11",className:"w-4 h-4 text-[var(--dg-text-secondary)]"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:351:11",className:"text-sm text-[var(--dg-text-secondary)]",children:"部署环境:"}),e.jsxs($,{"code-path":"src/components/deploy/PipelineEditor.tsx:352:11",value:String(L),onValueChange:s=>de(s==="__none"?"":s),children:[e.jsx(O,{"code-path":"src/components/deploy/PipelineEditor.tsx:353:13",className:"w-40 h-8 text-sm",children:e.jsx(V,{"code-path":"src/components/deploy/PipelineEditor.tsx:353:57",placeholder:"选择环境"})}),e.jsxs(B,{"code-path":"src/components/deploy/PipelineEditor.tsx:354:13",children:[e.jsx(h,{"code-path":"src/components/deploy/PipelineEditor.tsx:355:15",value:"__none",children:"未指定"}),Y.map(s=>e.jsx(h,{"code-path":"src/components/deploy/PipelineEditor.tsx:357:17",value:String(s.id),children:e.jsxs("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:358:19",className:"flex items-center gap-1.5",children:[e.jsx("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:359:21",className:"w-2 h-2 rounded-full inline-block",style:{backgroundColor:s.color}}),s.display_name]})},s.id))]})]}),e.jsx("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:366:11",className:"text-xs text-[var(--dg-text-secondary)] opacity-70",children:"选择后流水线执行记录会关联到对应环境"})]})}),e.jsxs(ss,{"code-path":"src/components/deploy/PipelineEditor.tsx:370:7",value:Se,onValueChange:_e,children:[e.jsxs(ts,{"code-path":"src/components/deploy/PipelineEditor.tsx:371:9",children:[e.jsx(C,{"code-path":"src/components/deploy/PipelineEditor.tsx:372:11",value:"flow",children:"流程配置"}),e.jsx(C,{"code-path":"src/components/deploy/PipelineEditor.tsx:373:11",value:"triggers",children:"触发设置"}),e.jsx(C,{"code-path":"src/components/deploy/PipelineEditor.tsx:374:11",value:"variables",children:"变量"}),e.jsxs(C,{"code-path":"src/components/deploy/PipelineEditor.tsx:375:11",value:"runs",children:["发布记录 (",F.length,")"]}),e.jsxs(C,{"code-path":"src/components/deploy/PipelineEditor.tsx:376:11",value:"members",children:["成员管理 (",J.length,")"]})]}),e.jsx(k,{"code-path":"src/components/deploy/PipelineEditor.tsx:380:9",value:"flow",className:"mt-3",children:e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:381:11",className:"flex gap-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:382:13",className:"flex-1 space-y-2",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:383:15",className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:384:17",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:["流水线阶段 (",a.length,")"]}),e.jsxs(p,{"code-path":"src/components/deploy/PipelineEditor.tsx:385:17",size:"sm",onClick:Ie,children:[e.jsx(D,{"code-path":"src/components/deploy/PipelineEditor.tsx:385:60",className:"w-3.5 h-3.5 mr-1"}),"添加阶段"]})]}),a.length===0?e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:388:17",className:"text-center py-12 border-2 border-dashed rounded-lg text-[var(--dg-text-secondary)]",children:"点击「添加阶段」开始"}):a.map((s,n)=>{const o=ke[s.id]!==!1;return e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:393:19",className:"space-y-1",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:394:21",className:"flex items-center gap-2 px-3 py-2 bg-[var(--dg-bg-tertiary)] rounded-t-md border border-b-0 border-[var(--dg-border)] cursor-pointer",onClick:()=>I(t=>({...t,[s.id]:!o})),children:[e.jsx(p,{"code-path":"src/components/deploy/PipelineEditor.tsx:398:23",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:t=>{t.stopPropagation(),I(l=>({...l,[s.id]:!o}))},children:o?e.jsx(Pe,{"code-path":"src/components/deploy/PipelineEditor.tsx:399:39",className:"w-3.5 h-3.5"}):e.jsx(Ee,{"code-path":"src/components/deploy/PipelineEditor.tsx:399:81",className:"w-3.5 h-3.5"})}),e.jsx(u,{"code-path":"src/components/deploy/PipelineEditor.tsx:401:23",value:s.name,onChange:t=>x(l=>l.map((ge,Ke)=>Ke===n?{...ge,name:t.target.value}:ge)),className:"h-7 text-sm font-medium border-none bg-transparent shadow-none flex-1 px-1",onClick:t=>t.stopPropagation()}),e.jsxs("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:407:23",className:"text-xs text-[var(--dg-text-secondary)]",children:[s.tasks.length," 任务"]}),e.jsx(j,{"code-path":"src/components/deploy/PipelineEditor.tsx:408:23",variant:"secondary",className:"text-xs",children:us[s.type]||s.type}),e.jsx(p,{"code-path":"src/components/deploy/PipelineEditor.tsx:409:23",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:t=>{t.stopPropagation(),he(n,-1)},disabled:n===0,children:e.jsx(is,{"code-path":"src/components/deploy/PipelineEditor.tsx:409:168",className:"w-3.5 h-3.5"})}),e.jsx(p,{"code-path":"src/components/deploy/PipelineEditor.tsx:410:23",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:t=>{t.stopPropagation(),he(n,1)},disabled:n===a.length-1,children:e.jsx(Pe,{"code-path":"src/components/deploy/PipelineEditor.tsx:410:183",className:"w-3.5 h-3.5"})}),e.jsx(p,{"code-path":"src/components/deploy/PipelineEditor.tsx:411:23",variant:"ghost",size:"icon",className:"h-6 w-6 text-red-500",onClick:t=>{t.stopPropagation(),We(n)},children:e.jsx(S,{"code-path":"src/components/deploy/PipelineEditor.tsx:411:158",className:"w-3.5 h-3.5"})})]}),o&&e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:414:21",className:"border border-[var(--dg-border)] rounded-b-md p-3 space-y-2",children:[s.tasks.map(t=>e.jsx(Ns,{"code-path":"src/components/deploy/PipelineEditor.tsx:415:46",task:t,selected:_===t.id,onSelect:()=>T(_===t.id?null:t.id),onDelete:()=>Be(t.id)},t.id)),e.jsxs(p,{"code-path":"src/components/deploy/PipelineEditor.tsx:416:23",variant:"outline",size:"sm",className:"w-full h-8 text-xs",onClick:()=>Ve(n),children:[e.jsx(D,{"code-path":"src/components/deploy/PipelineEditor.tsx:416:125",className:"w-3 h-3 mr-1"}),"添加任务"]})]}),nT(null),children:"关闭"})]}),e.jsx(bs,{"code-path":"src/components/deploy/PipelineEditor.tsx:427:15",task:me,onUpdate:Oe,onClose:()=>T(null)})]})]})}),e.jsx(k,{"code-path":"src/components/deploy/PipelineEditor.tsx:433:9",value:"triggers",className:"mt-3",children:e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:434:11",className:"space-y-4 max-w-lg",children:[e.jsx(P,{"code-path":"src/components/deploy/PipelineEditor.tsx:435:13",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(E,{"code-path":"src/components/deploy/PipelineEditor.tsx:435:85",className:"pt-6 space-y-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:436:15",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:436:66",className:"flex items-center gap-2 text-[var(--dg-text-primary)]",children:[e.jsx(R,{"code-path":"src/components/deploy/PipelineEditor.tsx:436:137",className:"w-5 h-5 text-blue-500"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:436:184",className:"font-medium",children:"Git Push 触发"})]}),e.jsx(G,{"code-path":"src/components/deploy/PipelineEditor.tsx:436:238",checked:N==="git_push",onCheckedChange:s=>M(s?"git_push":"manual")})]}),N==="git_push"&&e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:437:46",className:"space-y-1",children:[e.jsx(y,{"code-path":"src/components/deploy/PipelineEditor.tsx:437:73",children:"监听分支"}),e.jsx(u,{"code-path":"src/components/deploy/PipelineEditor.tsx:437:92",value:ee,onChange:s=>se(s.target.value),placeholder:"master, release/*",className:"h-9"})]})]})}),e.jsx(P,{"code-path":"src/components/deploy/PipelineEditor.tsx:439:13",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(E,{"code-path":"src/components/deploy/PipelineEditor.tsx:439:85",className:"pt-6 space-y-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:440:15",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:440:66",className:"flex items-center gap-2 text-[var(--dg-text-primary)]",children:[e.jsx(ue,{"code-path":"src/components/deploy/PipelineEditor.tsx:440:137",className:"w-5 h-5 text-blue-500"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:440:180",className:"font-medium",children:"定时触发"})]}),e.jsx(G,{"code-path":"src/components/deploy/PipelineEditor.tsx:440:227",checked:N==="cron",onCheckedChange:s=>M(s?"cron":"manual")})]}),N==="cron"&&e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:441:42",className:"space-y-1",children:[e.jsx(y,{"code-path":"src/components/deploy/PipelineEditor.tsx:441:69",children:"Cron 表达式"}),e.jsx(u,{"code-path":"src/components/deploy/PipelineEditor.tsx:441:92",value:te,onChange:s=>oe(s.target.value),placeholder:"0 2 * * *",className:"h-9 font-mono"})]})]})}),e.jsx(P,{"code-path":"src/components/deploy/PipelineEditor.tsx:443:13",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(E,{"code-path":"src/components/deploy/PipelineEditor.tsx:443:85",className:"pt-6 space-y-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:444:15",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:444:66",className:"flex items-center gap-2 text-[var(--dg-text-primary)]",children:[e.jsx(ve,{"code-path":"src/components/deploy/PipelineEditor.tsx:444:137",className:"w-5 h-5 text-blue-500"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:444:182",className:"font-medium",children:"Webhook 触发"})]}),e.jsx(G,{"code-path":"src/components/deploy/PipelineEditor.tsx:444:235",checked:N==="webhook",onCheckedChange:s=>M(s?"webhook":"manual")})]}),N==="webhook"&&e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:445:45",className:"space-y-1",children:[e.jsx(y,{"code-path":"src/components/deploy/PipelineEditor.tsx:445:72",children:"Secret Token"}),e.jsx(u,{"code-path":"src/components/deploy/PipelineEditor.tsx:445:99",value:ne,onChange:s=>ce(s.target.value),type:"password",placeholder:"输入签名密钥",className:"h-9"})]})]})}),e.jsx(P,{"code-path":"src/components/deploy/PipelineEditor.tsx:447:13",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsx(E,{"code-path":"src/components/deploy/PipelineEditor.tsx:447:85",className:"pt-6",children:e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:447:115",className:"flex items-center gap-2 text-[var(--dg-text-primary)]",children:[e.jsx(Ne,{"code-path":"src/components/deploy/PipelineEditor.tsx:447:186",className:"w-5 h-5 text-blue-500"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:447:228",className:"font-medium",children:"手动触发"}),e.jsx(j,{"code-path":"src/components/deploy/PipelineEditor.tsx:447:269",variant:"secondary",className:"text-xs",children:"默认启用"})]})})})]})}),e.jsx(k,{"code-path":"src/components/deploy/PipelineEditor.tsx:452:9",value:"variables",className:"mt-3",children:e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:453:11",className:"max-w-lg space-y-3",children:[b.map(([s,n],o)=>e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:455:15",className:"flex gap-2 items-center",children:[e.jsx(u,{"code-path":"src/components/deploy/PipelineEditor.tsx:456:17",value:s,onChange:t=>{const l=[...b];l[o][0]=t.target.value,f(l)},placeholder:"KEY",className:"h-9 w-40 font-mono text-sm"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:457:17",className:"text-[var(--dg-text-secondary)]",children:"="}),e.jsx(u,{"code-path":"src/components/deploy/PipelineEditor.tsx:458:17",value:n,onChange:t=>{const l=[...b];l[o][1]=t.target.value,f(l)},placeholder:"VALUE",className:"h-9 flex-1"}),e.jsx(p,{"code-path":"src/components/deploy/PipelineEditor.tsx:459:17",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-500",onClick:()=>f(b.filter((t,l)=>l!==o)),children:e.jsx(S,{"code-path":"src/components/deploy/PipelineEditor.tsx:459:152",className:"w-3.5 h-3.5"})})]},o)),e.jsxs(p,{"code-path":"src/components/deploy/PipelineEditor.tsx:462:13",variant:"outline",size:"sm",onClick:()=>f([...b,["",""]]),children:[e.jsx(D,{"code-path":"src/components/deploy/PipelineEditor.tsx:462:104",className:"w-3.5 h-3.5 mr-1"}),"添加变量"]})]})}),e.jsx(k,{"code-path":"src/components/deploy/PipelineEditor.tsx:467:9",value:"runs",className:"mt-3",children:F.length===0?e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:469:13",className:"text-center py-12 text-[var(--dg-text-secondary)]",children:"暂无执行记录"}):e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:471:13",className:"rounded-md border border-[var(--dg-border)] overflow-hidden",children:e.jsxs("table",{"code-path":"src/components/deploy/PipelineEditor.tsx:472:15",className:"w-full text-sm",children:[e.jsx("thead",{"code-path":"src/components/deploy/PipelineEditor.tsx:473:17",className:"bg-[var(--dg-bg-tertiary)] border-b border-[var(--dg-border)]",children:e.jsxs("tr",{"code-path":"src/components/deploy/PipelineEditor.tsx:474:19",children:[e.jsx("th",{"code-path":"src/components/deploy/PipelineEditor.tsx:475:21",className:"px-3 py-2 text-left text-[var(--dg-text-secondary)]",children:"#"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineEditor.tsx:476:21",className:"px-3 py-2 text-left text-[var(--dg-text-secondary)]",children:"状态"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineEditor.tsx:477:21",className:"px-3 py-2 text-left text-[var(--dg-text-secondary)]",children:"触发方式"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineEditor.tsx:478:21",className:"px-3 py-2 text-left text-[var(--dg-text-secondary)]",children:"触发人"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineEditor.tsx:479:21",className:"px-3 py-2 text-left text-[var(--dg-text-secondary)]",children:"分支"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineEditor.tsx:480:21",className:"px-3 py-2 text-left text-[var(--dg-text-secondary)]",children:"耗时"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineEditor.tsx:481:21",className:"px-3 py-2 text-left text-[var(--dg-text-secondary)]",children:"时间"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineEditor.tsx:482:21",className:"px-3 py-2 text-right text-[var(--dg-text-secondary)]",children:"操作"})]})}),e.jsx("tbody",{"code-path":"src/components/deploy/PipelineEditor.tsx:485:17",children:F.map(s=>e.jsxs("tr",{"code-path":"src/components/deploy/PipelineEditor.tsx:487:21",className:"border-b border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/50",children:[e.jsxs("td",{"code-path":"src/components/deploy/PipelineEditor.tsx:488:23",className:"px-3 py-2 font-medium text-[var(--dg-text-primary)]",children:["#",s.build_number||s.id]}),e.jsx("td",{"code-path":"src/components/deploy/PipelineEditor.tsx:489:23",className:"px-3 py-2",children:s.status==="success"?e.jsxs(j,{"code-path":"src/components/deploy/PipelineEditor.tsx:490:51",className:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",children:[e.jsx(rs,{"code-path":"src/components/deploy/PipelineEditor.tsx:490:127",className:"w-3 h-3 mr-0.5"}),"成功"]}):s.status==="failed"?e.jsxs(j,{"code-path":"src/components/deploy/PipelineEditor.tsx:491:50",className:"bg-red-500/20 text-red-400 border-red-500/30",children:[e.jsx(as,{"code-path":"src/components/deploy/PipelineEditor.tsx:491:114",className:"w-3 h-3 mr-0.5"}),"失败"]}):s.status==="running"?e.jsxs(j,{"code-path":"src/components/deploy/PipelineEditor.tsx:492:51",className:"bg-blue-500/20 text-blue-400 border-blue-500/30",children:[e.jsx(H,{"code-path":"src/components/deploy/PipelineEditor.tsx:492:118",className:"w-3 h-3 animate-spin mr-0.5"}),"执行中"]}):s.status==="cancelled"?e.jsxs(j,{"code-path":"src/components/deploy/PipelineEditor.tsx:493:53",className:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",children:[e.jsx(be,{"code-path":"src/components/deploy/PipelineEditor.tsx:493:126",className:"w-3 h-3 mr-0.5"}),"已停止"]}):e.jsx(j,{"code-path":"src/components/deploy/PipelineEditor.tsx:494:26",variant:"secondary",className:"text-[var(--dg-text-secondary)]",children:s.status})}),e.jsxs("td",{"code-path":"src/components/deploy/PipelineEditor.tsx:496:23",className:"px-3 py-2 text-[var(--dg-text-secondary)] text-xs",children:[s.trigger_mode==="manual"&&e.jsxs("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:497:57",className:"flex items-center gap-1",children:[e.jsx(Ne,{"code-path":"src/components/deploy/PipelineEditor.tsx:497:99",className:"w-3 h-3"}),"手动"]}),s.trigger_mode==="cron"&&e.jsxs("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:498:55",className:"flex items-center gap-1",children:[e.jsx(ue,{"code-path":"src/components/deploy/PipelineEditor.tsx:498:97",className:"w-3 h-3"}),"定时"]}),s.trigger_mode==="webhook"&&e.jsxs("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:499:58",className:"flex items-center gap-1",children:[e.jsx(ve,{"code-path":"src/components/deploy/PipelineEditor.tsx:499:100",className:"w-3 h-3"}),"Webhook"]}),s.trigger_mode==="git_push"&&e.jsxs("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:500:59",className:"flex items-center gap-1",children:[e.jsx(R,{"code-path":"src/components/deploy/PipelineEditor.tsx:500:101",className:"w-3 h-3"}),"Git Push"]}),!s.trigger_mode&&(s.triggered_by||"手动")]}),e.jsx("td",{"code-path":"src/components/deploy/PipelineEditor.tsx:503:23",className:"px-3 py-2 text-[var(--dg-text-secondary)] text-xs",children:s.triggered_by||"admin"}),e.jsx("td",{"code-path":"src/components/deploy/PipelineEditor.tsx:504:23",className:"px-3 py-2 text-[var(--dg-text-secondary)] font-mono text-xs",children:s.branch||"-"}),e.jsx("td",{"code-path":"src/components/deploy/PipelineEditor.tsx:505:23",className:"px-3 py-2 text-[var(--dg-text-secondary)]",children:Ce(s.duration)}),e.jsx("td",{"code-path":"src/components/deploy/PipelineEditor.tsx:506:23",className:"px-3 py-2 text-[var(--dg-text-secondary)] text-xs",children:s.created_at?new Date(s.created_at).toLocaleString("zh-CN"):"-"}),e.jsx("td",{"code-path":"src/components/deploy/PipelineEditor.tsx:507:23",className:"px-3 py-2 text-right",children:e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:508:25",className:"flex items-center justify-end gap-1",children:[e.jsxs(p,{"code-path":"src/components/deploy/PipelineEditor.tsx:509:27",variant:"ghost",size:"sm",className:"h-7 text-xs text-blue-400 hover:text-blue-300",onClick:()=>Ge(s),children:[e.jsx(ps,{"code-path":"src/components/deploy/PipelineEditor.tsx:509:152",className:"w-3.5 h-3.5 mr-1"}),"日志"]}),(s.status==="running"||s.status==="pending")&&e.jsxs(p,{"code-path":"src/components/deploy/PipelineEditor.tsx:511:29",variant:"ghost",size:"sm",className:"h-7 text-xs text-red-400 hover:text-red-300",onClick:()=>Ue(s.id),children:[e.jsx(be,{"code-path":"src/components/deploy/PipelineEditor.tsx:511:152",className:"w-3.5 h-3.5 mr-1"}),"停止"]})]})})]},s.id))})]})})}),e.jsx(k,{"code-path":"src/components/deploy/PipelineEditor.tsx:524:9",value:"members",className:"mt-3",children:e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:525:11",className:"max-w-xl space-y-4",children:[e.jsx(P,{"code-path":"src/components/deploy/PipelineEditor.tsx:527:13",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(E,{"code-path":"src/components/deploy/PipelineEditor.tsx:528:15",className:"p-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:529:17",className:"flex items-center gap-3",children:[e.jsx(ls,{"code-path":"src/components/deploy/PipelineEditor.tsx:530:19",className:"w-4 h-4 text-blue-500"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:531:19",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:"添加用户"})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:533:17",className:"flex items-end gap-3 mt-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:534:19",className:"flex-1 space-y-1",children:[e.jsx(y,{"code-path":"src/components/deploy/PipelineEditor.tsx:535:21",className:"text-xs",children:"用户名"}),e.jsx(u,{"code-path":"src/components/deploy/PipelineEditor.tsx:536:21",value:U,onChange:s=>ie(s.target.value),placeholder:"输入用户名",className:"h-9"})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:538:19",className:"space-y-1",children:[e.jsx(y,{"code-path":"src/components/deploy/PipelineEditor.tsx:539:21",className:"text-xs",children:"角色"}),e.jsxs($,{"code-path":"src/components/deploy/PipelineEditor.tsx:540:21",value:re,onValueChange:ze,children:[e.jsx(O,{"code-path":"src/components/deploy/PipelineEditor.tsx:541:23",className:"h-9 w-28",children:e.jsx(V,{"code-path":"src/components/deploy/PipelineEditor.tsx:541:59"})}),e.jsxs(B,{"code-path":"src/components/deploy/PipelineEditor.tsx:542:23",children:[e.jsx(h,{"code-path":"src/components/deploy/PipelineEditor.tsx:543:25",value:"owner",children:"拥有者"}),e.jsx(h,{"code-path":"src/components/deploy/PipelineEditor.tsx:544:25",value:"editor",children:"编辑者"}),e.jsx(h,{"code-path":"src/components/deploy/PipelineEditor.tsx:545:25",value:"viewer",children:"查看者"})]})]})]}),e.jsxs(p,{"code-path":"src/components/deploy/PipelineEditor.tsx:549:19",onClick:He,className:"h-9",children:[e.jsx(D,{"code-path":"src/components/deploy/PipelineEditor.tsx:549:69",className:"w-4 h-4 mr-1"}),"添加"]})]})]})}),(()=>{const s=J.filter(o=>o.username),n=J.filter(o=>o.group_id);return e.jsxs(e.Fragment,{children:[e.jsx(P,{"code-path":"src/components/deploy/PipelineEditor.tsx:561:19",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(E,{"code-path":"src/components/deploy/PipelineEditor.tsx:562:21",className:"p-0",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:563:23",className:"px-4 py-2 text-xs font-medium text-[var(--dg-text-secondary)] border-b border-[var(--dg-border)]",children:["👤 直接用户授权 (",s.length,")"]}),Le?e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:567:25",className:"flex items-center justify-center py-6",children:e.jsx(H,{"code-path":"src/components/deploy/PipelineEditor.tsx:567:80",className:"w-5 h-5 animate-spin text-[var(--dg-text-secondary)]"})}):s.length===0?e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:569:25",className:"py-4 text-center text-[var(--dg-text-secondary)] text-xs",children:"暂无直接用户"}):e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:571:25",className:"divide-y divide-[var(--dg-border)]",children:s.map(o=>e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:573:29",className:"flex items-center justify-between px-4 py-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:574:31",className:"flex items-center gap-3",children:[e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:575:33",className:"w-8 h-8 rounded-full bg-blue-500/20 flex items-center justify-center",children:e.jsx(xs,{"code-path":"src/components/deploy/PipelineEditor.tsx:575:119",className:"w-4 h-4 text-blue-400"})}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:576:33",children:[e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:577:35",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:o.username}),e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:578:35",className:"text-xs text-[var(--dg-text-secondary)]",children:o.role==="owner"?e.jsx("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:578:114",className:"text-amber-400",children:"拥有者"}):o.role==="editor"?e.jsx("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:578:182",className:"text-blue-400",children:"编辑者"}):e.jsx("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:578:227",className:"text-slate-400",children:"查看者"})})]})]}),e.jsxs(p,{"code-path":"src/components/deploy/PipelineEditor.tsx:581:31",variant:"ghost",size:"sm",className:"h-7 text-xs text-red-400 hover:text-red-300",onClick:()=>ye(o.id),children:[e.jsx(S,{"code-path":"src/components/deploy/PipelineEditor.tsx:581:162",className:"w-3.5 h-3.5 mr-1"}),"移除"]})]},o.id))})]})}),e.jsx(P,{"code-path":"src/components/deploy/PipelineEditor.tsx:590:19",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(E,{"code-path":"src/components/deploy/PipelineEditor.tsx:591:21",className:"p-0",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:592:23",className:"px-4 py-2 text-xs font-medium text-[var(--dg-text-secondary)] border-b border-[var(--dg-border)]",children:["👥 用户组授权 (",n.length,")"]}),n.length===0?e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:596:25",className:"py-4 text-center text-[var(--dg-text-secondary)] text-xs",children:["暂无组授权 — 在「",e.jsx("a",{"code-path":"src/components/deploy/PipelineEditor.tsx:597:37",href:"/deploy/groups",className:"text-blue-400 underline",children:"用户组管理"}),"」页面创建组后,可在此授权"]}):e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:600:25",className:"divide-y divide-[var(--dg-border)]",children:n.map(o=>e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:602:29",className:"flex items-center justify-between px-4 py-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:603:31",className:"flex items-center gap-3",children:[e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:604:33",className:"w-8 h-8 rounded-full bg-purple-500/20 flex items-center justify-center",children:e.jsx(je,{"code-path":"src/components/deploy/PipelineEditor.tsx:604:121",className:"w-4 h-4 text-purple-400"})}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:605:33",children:[e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:606:35",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:o.group?.name||`组 #${o.group_id}`}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:607:35",className:"text-xs text-[var(--dg-text-secondary)]",children:[o.role==="owner"?e.jsx("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:607:114",className:"text-amber-400",children:"拥有者"}):o.role==="editor"?e.jsx("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:607:182",className:"text-blue-400",children:"编辑者"}):e.jsx("span",{"code-path":"src/components/deploy/PipelineEditor.tsx:607:227",className:"text-slate-400",children:"查看者"})," · 组内全体成员"]})]})]}),e.jsxs(p,{"code-path":"src/components/deploy/PipelineEditor.tsx:610:31",variant:"ghost",size:"sm",className:"h-7 text-xs text-red-400 hover:text-red-300",onClick:()=>ye(o.id),children:[e.jsx(S,{"code-path":"src/components/deploy/PipelineEditor.tsx:610:162",className:"w-3.5 h-3.5 mr-1"}),"撤销授权"]})]},o.id))})]})})]})})()]})})]}),e.jsx(fs,{"code-path":"src/components/deploy/PipelineEditor.tsx:625:7",open:Ae,onClose:()=>ae(!1),run:De,logs:$e})]}):e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:327:25",className:"text-center py-20 text-[var(--dg-text-secondary)]",children:"流水线不存在"})}export{Vs as default}; diff --git a/backend/static/assets/PipelineManager-GqwxvUIC.js b/backend/static/assets/PipelineManager-GqwxvUIC.js deleted file mode 100644 index 2588fd0..0000000 --- a/backend/static/assets/PipelineManager-GqwxvUIC.js +++ /dev/null @@ -1 +0,0 @@ -import{j as e,r as o}from"./vendor-codemirror-B1SGo4xl.js";import{J as Ge,B as v,D as Me,a as Ee,b as Be,c as Te,t as N,i as Oe,f as Qe}from"./index-Dungj95X.js";import{I as f}from"./input-CXoUQQLm.js";import{p as L}from"./pipeline-DO4lDm_n.js";import{u as Ve,q as We,b as Je}from"./unwrap-DPwG25JA.js";import{u as ce}from"./useMutation-BkCR1EeO.js";import{C as Ke,a as Ie}from"./card-BIfzBCEy.js";import{B as D}from"./badge-CGJlVD3L.js";import{L as H,a as Y,y as ae,J as U,ad as He,k as ie,ao as Z,ax as Le,a2 as de,F as _e,b as ee,ae as I,aT as Ue,N as he,h as ye,G as ue,z as Xe,aw as Ye,Q as Ze,f as me,T as Fe,q as ea,P as xe,S as aa,aU as na,ac as sa,aV as ta}from"./vendor-icons-DmqcWdzX.js";import{T as oa}from"./textarea-BxfjmLq5.js";import{L as h}from"./label-CMpUoC87.js";import{S as se,a as te,b as oe,c as re,d as T}from"./select-CiTqGGhE.js";import{d as ra}from"./config-BrfI0oO-.js";import{c as la}from"./credential-Cu8tj7EE.js";import"./index-5FEebgvX.js";function ia(n={page:1,page_size:100}){return Ve({queryKey:We.pipelines(n),queryFn:async()=>{const p=await L.getPipelines(n);return Je(p)},staleTime:2e4})}function pa(){const n=Ge(),p=()=>n.invalidateQueries({queryKey:["pipelines"]}),P=ce({mutationFn:d=>L.triggerByCode(d),onSuccess:p}),b=ce({mutationFn:d=>L.deletePipeline(d),onSuccess:p}),j=ce({mutationFn:({code:d,runId:y})=>L.stopRunByCode(d,y)});return{triggerMutation:P,deleteMutation:b,stopRunMutation:j,invalidate:p}}function ca(n){return n.toLowerCase().replace(/[^a-z0-9]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||`pipeline-${Date.now()}`}function da(n){switch(n){case"success":return e.jsxs(D,{"code-path":"src/components/deploy/pipeline-helpers.tsx:50:9",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:[e.jsx(ae,{"code-path":"src/components/deploy/pipeline-helpers.tsx:51:11",className:"h-3 w-3 mr-1"}),"成功"]});case"failed":return e.jsxs(D,{"code-path":"src/components/deploy/pipeline-helpers.tsx:57:9",variant:"outline",className:"border-red-500/30 text-red-400 bg-red-500/10",children:[e.jsx(Y,{"code-path":"src/components/deploy/pipeline-helpers.tsx:58:11",className:"h-3 w-3 mr-1"}),"失败"]});case"running":return e.jsxs(D,{"code-path":"src/components/deploy/pipeline-helpers.tsx:64:9",variant:"outline",className:"border-blue-500/30 text-blue-400 bg-blue-500/10 animate-pulse",children:[e.jsx(H,{"code-path":"src/components/deploy/pipeline-helpers.tsx:65:11",className:"h-3 w-3 mr-1 animate-spin"}),"运行中"]});default:return e.jsx(D,{"code-path":"src/components/deploy/pipeline-helpers.tsx:71:9",variant:"outline",className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)]",children:"从未运行"})}}const le=[{key:"checkout",label:"代码检出",icon:U,color:"#6366F1",order:1,needs:["repo"],desc:"从 Git 仓库拉取代码"},{key:"build",label:"构建",icon:He,color:"#F59E0B",order:2,needs:[],desc:"编译/打包项目"},{key:"test",label:"测试",icon:ae,color:"#10B981",order:3,needs:[],desc:"运行单元/集成测试"},{key:"image",label:"镜像打包",icon:ie,color:"#06B6D4",order:4,needs:["registry"],desc:"Docker 构建 & 推送"},{key:"deploy",label:"部署",icon:Z,color:"#EF4444",order:5,needs:[],desc:"部署到目标环境"},{key:"verify",label:"验证",icon:Le,color:"#3B82F6",order:6,needs:[],desc:"部署后健康检查"}].sort((n,p)=>n.order-p.order);function ge(n){if(!n)return"-";if(n<60)return`${n}s`;const p=Math.floor(n/60),P=n%60;return P>0?`${p}分${P}秒`:`${p}分`}function ma(n){if(!n)return[];try{const p=typeof n=="string"?JSON.parse(n):n;return Array.isArray(p)?p:[]}catch{return[]}}function xa({pipeline:n}){const[p,P]=o.useState(null),[b,j]=o.useState(!1),d=n.code||n.id,y=async()=>{if(d){j(!0);try{const i=await L.getQueue(d);P(i?.data||i)}catch{P(null)}finally{j(!1)}}};o.useEffect(()=>{y();const i=setInterval(y,1e4);return()=>clearInterval(i)},[d]);const M=async i=>{try{await L.removeFromQueue(d,i),N.success("已取消"),y()}catch{N.error("取消失败")}},w=p?.running||0,u=p?.queued||0,C=p?.queue_ids||[],R=n.max_executors||2,t=p?.pending_runs||[];return b&&!p||w===0&&u===0?null:e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:69:5",className:"px-4 py-2 space-y-2",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:70:7",className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:71:9",className:"text-[var(--dg-text-secondary)]",children:"构建执行状态"}),e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:72:9",className:"font-bold text-[var(--dg-text-primary)]",children:[w,"/",R]}),u>0&&e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:74:11",className:"text-[var(--dg-text-secondary)] ml-2",children:["构建队列 ",e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:75:18",className:"font-bold text-amber-400",children:["(",u,")"]})]})]}),u>0&&t.length>0&&e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:81:9",className:"space-y-1",children:t.map(i=>e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:83:13",className:"flex items-center justify-between bg-[var(--dg-bg-tertiary)] rounded px-3 py-1.5",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:84:15",className:"flex items-center gap-2 text-xs",children:[e.jsx(ee,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:85:17",className:"h-3 w-3 text-amber-400"}),e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:86:17",className:"text-[var(--dg-text-secondary)] font-mono",children:["#",String(i.build_number??i.id??"")]}),e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:87:17",className:"text-[var(--dg-text-secondary)]",children:String(i.branch||"-")}),e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:88:17",className:"text-[var(--dg-text-secondary)] opacity-50",children:String(i.triggered_by||"-")})]}),e.jsxs(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:90:15",variant:"ghost",size:"sm",className:"h-6 text-xs text-red-400 hover:text-red-300",onClick:()=>M(i.id),children:[e.jsx(Y,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:91:17",className:"h-3 w-3 mr-1"}),"取消"]})]},i.id))}),u>0&&t.length===0&&C.length>0&&e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:99:9",className:"space-y-1",children:C.map(i=>e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:101:13",className:"flex items-center justify-between bg-[var(--dg-bg-tertiary)] rounded px-3 py-1.5",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:102:15",className:"flex items-center gap-2 text-xs",children:[e.jsx(ee,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:103:17",className:"h-3 w-3 text-amber-400"}),e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:104:17",className:"text-[var(--dg-text-muted)] font-mono",children:["Run #",i]})]}),e.jsxs(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:106:15",variant:"ghost",size:"sm",className:"h-6 text-xs text-red-400 hover:text-red-300",onClick:()=>M(i),children:[e.jsx(Y,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:107:17",className:"h-3 w-3 mr-1"}),"取消"]})]},i))})]})}function ga({pipeline:n,pipelineRuns:p,isLoadingRuns:P,onStopRun:b}){const[j,d]=o.useState(!1),[y,M]=o.useState(null),[w,u]=o.useState([]),C=n.code||n.id,R=async t=>{M(t),d(!0);try{const i=await L.getRunLog(C,t.id);u(i?.logs||[])}catch{u([])}};return e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:136:5",className:"border-t border-[var(--dg-border)]",children:[e.jsx(xa,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:137:7",pipeline:n}),P?e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:140:9",className:"flex items-center justify-center py-6",children:e.jsx(H,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:141:11",className:"h-5 w-5 animate-spin text-[var(--dg-text-secondary)]"})}):p.length===0?e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:144:9",className:"py-6 text-center text-[var(--dg-text-secondary)] text-sm",children:"暂无执行记录"}):e.jsxs("table",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:146:9",className:"w-full text-sm",children:[e.jsx("thead",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:147:11",className:"border-b border-[var(--dg-border)]",children:e.jsxs("tr",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:148:13",className:"bg-[var(--dg-bg-tertiary)]",children:[e.jsx("th",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:149:15",className:"px-4 py-2 text-left text-xs font-medium text-[var(--dg-text-secondary)]",children:"#"}),e.jsx("th",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:150:15",className:"px-4 py-2 text-left text-xs font-medium text-[var(--dg-text-secondary)]",children:"状态"}),e.jsx("th",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:151:15",className:"px-4 py-2 text-left text-xs font-medium text-[var(--dg-text-secondary)]",children:"触发人"}),e.jsx("th",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:152:15",className:"px-4 py-2 text-left text-xs font-medium text-[var(--dg-text-secondary)]",children:"耗时"}),e.jsx("th",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:153:15",className:"px-4 py-2 text-left text-xs font-medium text-[var(--dg-text-secondary)]",children:"时间"}),e.jsx("th",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:154:15",className:"px-4 py-2 text-right text-xs font-medium text-[var(--dg-text-secondary)]",children:"操作"})]})}),e.jsx("tbody",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:157:11",children:p.map(t=>e.jsxs("tr",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:159:15",className:"border-b border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/50",children:[e.jsxs("td",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:160:17",className:"px-4 py-2 font-medium text-[var(--dg-text-primary)]",children:["#",String(t.build_number??t.id??"")]}),e.jsx("td",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:161:17",className:"px-4 py-2",children:t.status==="success"?e.jsxs(D,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:163:21",className:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30 text-[11px]",children:[e.jsx(ae,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:164:23",className:"h-3 w-3 mr-0.5"}),"成功"]}):t.status==="failed"?e.jsxs(D,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:167:21",className:"bg-red-500/20 text-red-400 border-red-500/30 text-[11px]",children:[e.jsx(Y,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:168:23",className:"h-3 w-3 mr-0.5"}),"失败"]}):t.status==="running"?e.jsxs(D,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:171:21",className:"bg-blue-500/20 text-blue-400 border-blue-500/30 text-[11px]",children:[e.jsx(H,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:172:23",className:"h-3 w-3 animate-spin mr-0.5"}),"执行中"]}):t.status==="cancelled"?e.jsxs(D,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:175:21",className:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30 text-[11px]",children:[e.jsx(de,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:176:23",className:"h-3 w-3 mr-0.5"}),"已停止"]}):e.jsx(D,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:179:21",variant:"secondary",className:"text-[11px]",children:String(t.status)})}),e.jsx("td",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:182:17",className:"px-4 py-2 text-[var(--dg-text-secondary)] text-xs",children:String(t.triggered_by||"admin")}),e.jsx("td",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:183:17",className:"px-4 py-2 text-[var(--dg-text-secondary)] text-xs",children:ge(t.duration)}),e.jsx("td",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:184:17",className:"px-4 py-2 text-[var(--dg-text-secondary)] text-xs",children:t.created_at?new Date(t.created_at).toLocaleString("zh-CN"):"-"}),e.jsx("td",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:187:17",className:"px-4 py-2 text-right",children:e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:188:19",className:"flex items-center justify-end gap-1",children:[e.jsxs(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:189:21",variant:"ghost",size:"sm",className:"h-7 text-xs text-blue-400 hover:text-blue-300",onClick:()=>R(t),children:[e.jsx(_e,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:190:23",className:"h-3.5 w-3.5 mr-1"}),"日志"]}),(t.status==="running"||t.status==="pending")&&e.jsxs(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:193:23",variant:"ghost",size:"sm",className:"h-7 text-xs text-red-400 hover:text-red-300",onClick:()=>b(t.id),children:[e.jsx(de,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:194:25",className:"h-3.5 w-3.5 mr-1"}),"停止"]})]})})]},t.id))})]}),e.jsx(Me,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:205:7",open:j,onOpenChange:d,children:e.jsxs(Ee,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:206:9",className:"max-w-3xl max-h-[85vh] overflow-y-auto bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",children:[e.jsx(Be,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:207:11",children:e.jsxs(Te,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:208:13",className:"flex items-center gap-2",children:[e.jsx(_e,{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:209:15",className:"h-5 w-5"}),"执行日志 #",String(y?.build_number??y?.id??"")]})}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:212:11",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:213:13",className:"flex flex-wrap gap-3 text-sm text-[var(--dg-text-secondary)]",children:[e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:214:15",children:["触发方式: ",String(y?.triggered_by||"manual")]}),e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:215:15",children:["分支: ",String(y?.branch||"-")]}),e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:216:15",children:["耗时: ",ge(y?.duration)]})]}),e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:218:13",className:"bg-slate-950 rounded-md p-3 max-h-[50vh] overflow-y-auto font-mono text-xs",children:w.length===0?e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:220:17",className:"text-slate-500 py-4 text-center",children:"暂无日志"}):w.map((t,i)=>e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:223:19",className:"flex gap-2 py-0.5",children:[e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:224:21",className:"text-slate-500 shrink-0",children:["[",t.time,"]"]}),e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineRunPanel.tsx:225:21",className:t.level==="error"?"text-red-400":t.level==="warn"?"text-yellow-400":t.level==="success"?"text-green-400":"text-slate-300",children:[t.level==="success"?"✓":t.level==="error"?"✗":t.level==="warn"?"!":">"," ",t.message]})]},i))})]})]})})]})}function ha({pipeline:n,isExpanded:p,isLoadingRuns:P,pipelineRuns:b,onToggleExpand:j,onTrigger:d,onStopRunning:y,onDelete:M,onStopRun:w}){const u=Oe(),C=ma(n.stages),R=n.repo,t=n.registry,i=n.environment,A=n.code||n.id;return e.jsx(Ke,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:61:5",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] overflow-hidden",children:e.jsxs(Ie,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:62:7",className:"p-0",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:63:9",className:"px-4 py-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:64:11",className:"flex items-start justify-between",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:65:13",className:"flex-1 min-w-0",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:66:15",className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:67:17",className:"font-semibold text-[var(--dg-text-primary)]",children:String(n.name)}),n.run_count>0&&e.jsxs(D,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:69:19",variant:"outline",className:"text-[11px] text-[var(--dg-text-secondary)] border-[var(--dg-border)]",children:["#",String(n.run_count)]}),da(String(n.last_status)),i&&e.jsx(D,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:75:19",style:{backgroundColor:`${i.color}20`,color:i.color},className:"text-xs",children:String(i.display_name)}),n.job_name&&e.jsx(D,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:83:19",variant:"secondary",className:"text-xs font-mono opacity-60",children:String(n.job_name)})]}),e.jsx("p",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:86:15",className:"text-xs text-[var(--dg-text-secondary)] mt-1 line-clamp-1",children:String(n.description||"暂无描述")}),(n.last_run_branch||n.last_commit_id||n.last_image_tag)&&e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:91:17",className:"flex items-center gap-1 mt-1.5 text-xs font-mono",children:[n.last_run_branch&&e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:93:21",className:"flex items-center gap-0.5 text-indigo-400",children:[e.jsx(U,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:94:23",className:"h-3 w-3"}),String(n.last_run_branch)]}),n.last_run_branch&&n.last_commit_id&&e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:98:21",className:"text-[var(--dg-text-secondary)] opacity-50 text-[10px] mx-0.5",children:"+"}),n.last_commit_id&&e.jsx("code",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:101:21",className:"text-amber-400 bg-amber-400/10 px-1 py-0.5 rounded text-[11px]",children:String(n.last_commit_id).slice(0,8)}),(n.last_run_branch||n.last_commit_id)&&n.last_image_tag&&e.jsx(I,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:106:21",className:"h-3 w-3 text-[var(--dg-text-secondary)] opacity-40 mx-0.5"}),n.last_image_tag&&e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:109:21",className:"flex items-center gap-0.5 text-cyan-400",children:[e.jsx(Ue,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:110:23",className:"h-3 w-3"}),e.jsx("code",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:111:23",className:"bg-cyan-400/10 px-1 py-0.5 rounded text-[11px]",children:String(n.last_image_tag)})]}),n.last_duration>0&&e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:115:21",className:"flex items-center gap-0.5 ml-auto text-[var(--dg-text-secondary)] opacity-50",children:[e.jsx(ee,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:116:23",className:"h-3 w-3"}),ge(n.last_duration)]})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:121:15",className:"flex items-center gap-3 mt-1.5 text-xs text-[var(--dg-text-secondary)] opacity-60",children:[e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:122:17",className:"flex items-center gap-1",children:[e.jsx(U,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:123:19",className:"h-3 w-3"}),n.deploy_mode==="tag"?"Tag发版":String(n.branch||"main")]}),e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:126:17",className:"flex items-center gap-1",children:(n.deploy_target||"ssh")==="k8s"?e.jsxs(e.Fragment,{children:[e.jsx(he,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:128:23",className:"h-3 w-3"}),"Kubernetes"]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:130:23",className:"h-3 w-3"}),"SSH 主机"]})}),R&&e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:133:26",className:"flex items-center gap-1",children:[e.jsx(ue,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:133:68",className:"h-3 w-3"}),String(R.name)]}),t&&e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:134:30",className:"flex items-center gap-1",children:[e.jsx(ie,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:134:72",className:"h-3 w-3"}),String(t.name)]}),n.last_run_at&&e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:136:19",children:[e.jsx(ee,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:136:25",className:"h-3 w-3 inline mr-0.5"}),new Date(n.last_run_at).toLocaleString("zh-CN")]})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:140:13",className:"flex items-center gap-1 ml-4 shrink-0",children:[n.last_status==="running"?e.jsxs(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:142:17",variant:"destructive",size:"sm",className:"h-8",onClick:y,children:[e.jsx(de,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:143:19",className:"h-3.5 w-3.5 mr-1"}),"停止"]}):e.jsxs(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:146:17",variant:"default",size:"sm",className:"h-8",onClick:d,children:[e.jsx(Xe,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:147:19",className:"h-3.5 w-3.5 mr-1"}),"执行"]}),e.jsx(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:150:15",variant:"outline",size:"sm",className:"h-8",onClick:()=>u(`/pipelines/${A}`),children:"编辑"}),e.jsxs(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:151:15",variant:"outline",size:"sm",className:"h-8",onClick:()=>u(`/pipelines/${A}/runs`),children:[e.jsx(Ye,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:152:17",className:"h-3.5 w-3.5 mr-1"}),"记录"]}),e.jsx(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:154:15",variant:"ghost",size:"sm",className:"h-8",onClick:j,children:p?e.jsx(Ze,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:155:31",className:"h-4 w-4"}):e.jsx(me,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:155:69",className:"h-4 w-4"})}),e.jsx(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:157:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-500",onClick:M,children:e.jsx(Fe,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:158:17",className:"h-4 w-4"})})]})]}),C.length>0&&e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:164:13",className:"flex items-center mt-2.5",children:C.map((g,E)=>{const Q=le.find(z=>z.label===g.name);let _="";if(n.last_run_stages)try{const z=typeof n.last_run_stages=="string"?JSON.parse(n.last_run_stages):n.last_run_stages,X=Array.isArray(z)?z.find(J=>J.name===g.name||J.type===Q?.key):null;_=String(X?.status||"")}catch{}const F=_==="success"||_==="completed",q=_==="running"||_==="in_progress",G=_==="failed"||_==="error",$=G?"#EF4444":q?"#3B82F6":F?"#10B981":"#6B7280",V=G?"#EF444428":q?"#3B82F628":F?"#10B98128":"#6B728018",W=G?e.jsx(Y,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:186:19",className:"h-3 w-3"}):q?e.jsx(H,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:188:19",className:"h-3 w-3 animate-spin"}):F?e.jsx(ae,{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:190:19",className:"h-3 w-3"}):e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:192:19",className:"text-[10px] opacity-40",children:"○"});return e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:195:19",className:"flex items-center",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCard.tsx:196:21",className:"flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] font-semibold border shadow-sm",style:{backgroundColor:V,borderColor:`${$}70`,color:$,borderRadius:E===0?"8px 0 0 8px":E===C.length-1?"0 8px 8px 0":"0"},children:[W,String(g.name)]}),E{try{const[a,c]=await Promise.all([ra.getEnvironments().catch(()=>({list:[]})),la.list({page_size:100}).catch(()=>({list:[]}))]);ze(Array.isArray(a?.list)?a.list:[]);const x=c?.list||[];X(x.filter(m=>m.secret_type==="api")),ne(x.filter(m=>m.secret_type==="docker"))}catch{}},[]);o.useEffect(()=>{n&&Re()},[n,Re]);const Ae=()=>{j(""),y(""),w(""),C(""),t("main"),A(""),E(["checkout","build","image","deploy"]),_("branch"),q("ssh"),$(""),r(""),B(""),S("manual"),ve(""),be(""),pe(""),fe(""),K([]),we(""),Se(2)},qe=async()=>{if(!b.trim()){N.error("请输入流水线名称");return}if(g.includes("checkout")&&!u.trim()){N.error("代码检出阶段需要填写 Git URL");return}if(g.includes("image")&&!l){N.error("镜像打包阶段需要关联 Docker 凭证");return}W(!0);try{const a=g.map(x=>le.find(m=>m.key===x)?.label||x),c=JSON.stringify(a.map((x,m)=>({id:`stage-${m+1}`,name:x,type:g[m]||"custom",tasks:[]})));await L.createPipeline({name:b,code:ca(b),job_name:d||void 0,description:M,source:u,branch:R,dockerfile:i,type:"deploy",stages:c,deploy_mode:Q,deploy_target:F,environment_id:G?Number(G):null,repo_id:null,registry_id:null,git_credential_id:s?Number(s):null,registry_credential_id:l?Number(l):null,trigger_mode:k,watch_branches:Pe||void 0,exclude_branch:je||void 0,cron_expr:Ne||void 0,webhook_token:Ce||void 0,variables:O.length>0?JSON.stringify(O):void 0,cache_paths:De||void 0,max_executors:ke}),N.success("流水线已创建"),p(!1),Ae(),P()}catch{N.error("创建失败")}finally{W(!1)}};return e.jsx(Me,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:153:5",open:n,onOpenChange:p,children:e.jsxs(Ee,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:154:7",className:"max-w-2xl max-h-[85vh] overflow-y-auto bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",children:[e.jsx(Be,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:155:9",children:e.jsxs(Te,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:156:11",className:"flex items-center gap-2",children:[e.jsx(Z,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:156:60",className:"h-5 w-5"}),"新建流水线"]})}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:158:9",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:159:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:160:13",className:"space-y-1",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:161:15",children:["名称 ",e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:161:25",className:"text-red-400",children:"*"})]}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:162:15",value:b,onChange:a=>j(a.target.value),placeholder:"例如: demo-jar 后端部署",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] h-9"})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:164:13",className:"space-y-1",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:165:15",children:["Job 名称 ",e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:165:29",className:"text-xs text-[var(--dg-text-secondary)]",children:"(Webhook URL)"})]}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:166:15",value:d,onChange:a=>y(a.target.value),placeholder:"cex-admin-server",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] h-9 font-mono text-sm"}),d&&e.jsxs("p",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:167:30",className:"text-[10px] text-[var(--dg-text-secondary)] opacity-60",children:["Webhook: POST .../webhook/job/",e.jsx("b",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:167:130",children:d})]})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:170:11",className:"space-y-1",children:[e.jsx(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:171:13",children:"描述"}),e.jsx(oa,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:172:13",value:M,onChange:a=>w(a.target.value),placeholder:"流水线描述...",rows:2,className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]"})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:175:11",className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:176:13",className:"space-y-1",children:[e.jsx(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:177:15",children:"部署模式"}),e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:178:15",className:"flex gap-1 bg-[var(--dg-bg-secondary)] rounded-lg p-1 border border-[var(--dg-border)]",children:[{key:"branch",label:"分支",icon:U},{key:"tag",label:"Tag 发版",icon:ea}].map(a=>{const c=Q===a.key;return e.jsxs("button",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:185:21",onClick:()=>_(a.key),className:`flex-1 flex items-center justify-center gap-1 px-2 py-1.5 rounded-md text-xs font-medium transition-all ${c?"bg-blue-500 text-white":"text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)]"}`,children:[e.jsx(a.icon,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:192:23",className:"h-3.5 w-3.5"}),a.label]},a.key)})})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:198:13",className:"space-y-1",children:[e.jsx(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:199:15",children:"部署目标"}),e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:200:15",className:"flex gap-1 bg-[var(--dg-bg-secondary)] rounded-lg p-1 border border-[var(--dg-border)]",children:[{key:"ssh",label:"SSH 主机",icon:ye},{key:"k8s",label:"Kubernetes 集群",icon:he}].map(a=>{const c=F===a.key;return e.jsxs("button",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:207:21",onClick:()=>q(a.key),className:`flex-1 flex items-center justify-center gap-1 px-2 py-1.5 rounded-md text-xs font-medium transition-all ${c?"bg-green-500 text-white":"text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)]"}`,children:[e.jsx(a.icon,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:214:23",className:"h-3.5 w-3.5"}),a.label]},a.key)})})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:220:13",className:"space-y-1",children:[e.jsx(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:221:15",children:"环境分组"}),e.jsxs(se,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:222:15",value:String(G),onValueChange:a=>$(a==="__none"?"":a),children:[e.jsx(te,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:223:17",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] h-9",children:e.jsx(oe,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:223:102",placeholder:"选择环境"})}),e.jsxs(re,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:224:17",children:[e.jsx(T,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:225:19",value:"__none",children:"不指定"}),$e.map(a=>e.jsx(T,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:227:21",value:String(a.id),children:e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:228:23",className:"flex items-center gap-1.5",children:[e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:229:25",className:"w-2 h-2 rounded-full inline-block",style:{backgroundColor:a.color}}),String(a.display_name)]})},a.id))]})]})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:239:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:240:13",className:"space-y-1",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:241:15",children:["Git URL ",g.includes("checkout")&&e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:241:70",className:"text-red-400",children:"*"})]}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:242:15",value:u,onChange:a=>C(a.target.value),placeholder:"https://gitee.com/user/repo.git",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] h-9 font-mono text-xs"})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:244:13",className:"space-y-1",children:[e.jsx(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:245:15",children:"分支 / Tag"}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:246:15",value:R,onChange:a=>t(a.target.value),placeholder:Q==="tag"?"v1.0.0":"main",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] h-9"})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:248:13",className:"space-y-1",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:249:15",children:["Git 凭证 ",e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:249:29",className:"text-xs text-[var(--dg-text-secondary)] opacity-60",children:"(API Token)"})]}),e.jsxs(se,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:250:15",value:String(s),onValueChange:a=>r(a==="__none"?"":a),children:[e.jsx(te,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:251:17",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] h-9",children:e.jsx(oe,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:251:102",placeholder:"选择凭证"})}),e.jsxs(re,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:252:17",children:[e.jsx(T,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:253:19",value:"__none",children:"不关联"}),z.map(a=>e.jsx(T,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:255:21",value:String(a.id),children:e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:256:23",className:"flex items-center gap-1.5",children:[e.jsx(ue,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:257:25",className:"h-3 w-3 opacity-60"}),String(a.name)," ",a.summary&&e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:257:96",className:"text-[10px] opacity-50",children:["(",String(a.summary),")"]})]})},a.id))]})]}),!s&&g.includes("checkout")&&e.jsx("p",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:263:78",className:"text-xs text-amber-400",children:"建议关联凭证"})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:265:13",className:"space-y-1",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:266:15",children:["镜像仓库凭证 ",g.includes("image")&&e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:266:66",className:"text-red-400",children:"*"})]}),e.jsxs(se,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:267:15",value:String(l),onValueChange:a=>B(a==="__none"?"":a),children:[e.jsx(te,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:268:17",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] h-9",children:e.jsx(oe,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:268:102",placeholder:"选择 Docker 凭证"})}),e.jsxs(re,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:269:17",children:[e.jsx(T,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:270:19",value:"__none",children:"不关联"}),J.map(a=>e.jsx(T,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:272:21",value:String(a.id),children:e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:273:23",className:"flex items-center gap-1.5",children:[e.jsx(ie,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:274:25",className:"h-3 w-3 opacity-60"}),String(a.name)," ",a.summary&&e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:274:100",className:"text-[10px] opacity-50",children:["(",String(a.summary),")"]})]})},a.id))]})]}),!l&&g.includes("image")&&e.jsx("p",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:280:80",className:"text-xs text-amber-400",children:"需要关联 Docker 凭证"})]})]}),l&&d&&e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:285:13",className:"p-2.5 rounded-md bg-blue-500/5 border border-blue-500/20 text-xs text-[var(--dg-text-secondary)]",children:[e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:286:15",className:"text-blue-400",children:"镜像命名:"}),e.jsxs("code",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:287:15",className:"text-[var(--dg-text-primary)]",children:["{registry}","/","{namespace}","/","{","{JOB_BASE_NAME}","}",":","{","{tag}","}"]}),e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:288:15",className:"ml-2 opacity-60",children:"例:"}),e.jsxs("code",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:289:15",className:"opacity-60",children:["harbor.ast1001.com/test/",d,":latest"]})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:292:11",className:"space-y-1",children:[e.jsx(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:293:13",children:"Dockerfile 路径"}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:294:13",value:i,onChange:a=>A(a.target.value),placeholder:"jar/Dockerfile",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] h-9 font-mono text-xs"})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:297:11",className:"space-y-2",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:298:13",children:["发布流程 ",e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:298:25",className:"text-xs text-[var(--dg-text-secondary)] opacity-70 ml-1",children:"按顺序选择阶段"})]}),e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:299:13",className:"flex flex-wrap gap-2",children:le.map(a=>{const c=g.includes(a.key);return e.jsxs(D,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:303:19",className:`cursor-pointer transition-all text-xs px-3 py-1.5 ${c?"border-current":"border-[var(--dg-border)] opacity-50 hover:opacity-80"}`,style:c?{backgroundColor:`${a.color}20`,color:a.color,borderColor:a.color}:{},onClick:()=>E(c?g.filter(x=>x!==a.key):[...g,a.key]),title:a.desc,children:[e.jsx(a.icon,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:310:21",className:"h-3 w-3 mr-1"}),a.label," ",a.needs.includes("repo")?"🔗":"",a.needs.includes("registry")?"📦":""]},a.key)})}),g.length>0&&e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:316:15",className:"flex items-center mt-2",children:g.map((a,c)=>{const x=le.find(m=>m.key===a);return e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:320:21",className:"flex items-center",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:321:23",className:"flex items-center gap-1 px-2 py-1 text-[11px] font-medium border",style:{backgroundColor:`${x.color}20`,borderColor:`${x.color}40`,color:x.color,borderRadius:c===0?"6px 0 0 6px":c===g.length-1?"0 6px 6px 0":"0"},children:[e.jsx(x.icon,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:330:25",className:"h-3 w-3"}),x.label]}),c{const c=k===a.key;return e.jsx("button",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:355:19",onClick:()=>S(a.key),className:`flex-1 flex flex-col items-center gap-0.5 px-2 py-2 rounded-md text-xs font-medium transition-all ${c?"bg-blue-500 text-white":"text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)]"}`,title:a.desc,children:a.label},a.key)})}),k==="git_push"&&e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:370:15",className:"mt-3 space-y-2 p-3 rounded-md bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:371:17",className:"space-y-1",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:372:19",className:"text-xs",children:["监听分支 ",e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:372:51",className:"text-[var(--dg-text-secondary)] opacity-60",children:"(逗号分隔,支持 * 通配)"})]}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:373:19",value:Pe,onChange:a=>ve(a.target.value),placeholder:"release/*, main",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] h-8 font-mono text-xs"})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:375:17",className:"space-y-1",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:376:19",className:"text-xs",children:["排除分支 ",e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:376:51",className:"text-[var(--dg-text-secondary)] opacity-60",children:"(不触发构建)"})]}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:377:19",value:je,onChange:a=>be(a.target.value),placeholder:"wip/*, draft/*",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] h-8 font-mono text-xs"})]})]}),k==="cron"&&e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:383:15",className:"mt-3 space-y-2 p-3 rounded-md bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:384:17",className:"space-y-1",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:385:19",className:"text-xs",children:["Cron 表达式 ",e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:385:55",className:"text-[var(--dg-text-secondary)] opacity-60",children:"(标准 5 位)"})]}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:386:19",value:Ne,onChange:a=>pe(a.target.value),placeholder:"0 2 * * *",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] h-8 font-mono text-xs"})]}),e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:388:17",className:"flex flex-wrap gap-1.5",children:[{expr:"*/5 * * * *",label:"每5分钟"},{expr:"0 * * * *",label:"每小时"},{expr:"0 2 * * *",label:"每天2点"},{expr:"0 0 * * 0",label:"每周日"}].map(a=>e.jsx(D,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:395:21",variant:"outline",className:"cursor-pointer text-[10px] hover:bg-blue-500/10",onClick:()=>pe(a.expr),children:a.label},a.expr))})]}),k==="webhook"&&e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:404:15",className:"mt-3 space-y-2 p-3 rounded-md bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:405:17",className:"space-y-1",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:406:19",className:"text-xs",children:["Webhook Token ",e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:406:60",className:"text-[var(--dg-text-secondary)] opacity-60",children:"(签名验证,可选)"})]}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:407:19",value:Ce,onChange:a=>fe(a.target.value),placeholder:"随机字符串",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] h-8 font-mono text-xs"})]}),e.jsxs("p",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:409:17",className:"text-[10px] text-[var(--dg-text-secondary)] opacity-60",children:["Webhook URL: ",e.jsxs("code",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:410:32",className:"text-[var(--dg-blue)]",children:["POST /api/v1/webhook/pipeline/","{code}"]})]})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:416:11",className:"border-t border-[var(--dg-border)] pt-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:417:13",className:"flex items-center justify-between mb-2",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:418:15",children:["环境变量 ",e.jsxs("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:418:27",className:"text-xs text-[var(--dg-text-secondary)] opacity-60",children:["($","{VAR_NAME}"," 引用)"]})]}),e.jsxs(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:419:15",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>K([...O,{key:"",value:"",desc:""}]),children:[e.jsx(xe,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:420:17",className:"h-3 w-3 mr-1"}),"添加变量"]})]}),O.length===0?e.jsx("p",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:424:15",className:"text-xs text-[var(--dg-text-muted)] py-2",children:'暂无变量,点击"添加变量"新增'}):e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:426:15",className:"space-y-2",children:O.map((a,c)=>e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:428:19",className:"grid grid-cols-12 gap-2 items-start p-2 rounded-md bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)]",children:[e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:429:21",value:a.key,onChange:x=>{const m=[...O];m[c]={...m[c],key:x.target.value},K(m)},placeholder:"变量名",className:"col-span-3 h-8 text-xs font-mono bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:439:21",value:a.value,onChange:x=>{const m=[...O];m[c]={...m[c],value:x.target.value},K(m)},placeholder:"变量值",className:"col-span-4 h-8 text-xs font-mono bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:449:21",value:a.desc,onChange:x=>{const m=[...O];m[c]={...m[c],desc:x.target.value},K(m)},placeholder:"说明",className:"col-span-4 h-8 text-xs bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"}),e.jsx(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:459:21",variant:"ghost",size:"icon",className:"col-span-1 h-8 w-8 text-red-400",onClick:()=>K(O.filter((x,m)=>m!==c)),children:e.jsx(Fe,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:460:23",className:"h-3.5 w-3.5"})})]},c))})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:468:11",className:"border-t border-[var(--dg-border)] pt-4",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:469:13",className:"mb-2 block",children:["构建缓存 ",e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:469:48",className:"text-xs text-[var(--dg-text-secondary)] opacity-60",children:"(加速后续构建)"})]}),e.jsx(f,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:470:13",value:De,onChange:a=>we(a.target.value),placeholder:"node_modules, .m2, target",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] h-8 text-xs font-mono"}),e.jsx("p",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:471:13",className:"text-[10px] text-[var(--dg-text-secondary)] opacity-50 mt-1",children:"多个路径用逗号分隔,相同的 Key 会命中已有缓存"})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:474:11",className:"border-t border-[var(--dg-border)] pt-4",children:[e.jsxs(h,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:475:13",className:"mb-2 block",children:["并发执行数 ",e.jsx("span",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:475:49",className:"text-xs text-[var(--dg-text-secondary)] opacity-60",children:"(Number of executors)"})]}),e.jsx("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:476:13",className:"flex items-center gap-2",children:e.jsxs(se,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:477:15",value:String(ke),onValueChange:a=>Se(Number(a)),children:[e.jsx(te,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:478:17",className:"w-32 h-8 text-xs bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsx(oe,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:479:19"})}),e.jsxs(re,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:481:17",children:[e.jsx(T,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:482:19",value:"1",children:"1 — 串行"}),e.jsx(T,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:483:19",value:"2",children:"2"}),e.jsx(T,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:484:19",value:"3",children:"3"}),e.jsx(T,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:485:19",value:"4",children:"4"}),e.jsx(T,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:486:19",value:"5",children:"5"})]})]})}),e.jsx("p",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:490:13",className:"text-[10px] text-[var(--dg-text-secondary)] opacity-50 mt-1",children:"设为 1 则按顺序串行执行,默认 2 可并发构建"})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:493:9",className:"flex justify-end gap-2 mt-4 pt-4 border-t border-[var(--dg-border)]",children:[e.jsx(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:494:11",variant:"outline",onClick:()=>p(!1),children:"取消"}),e.jsxs(v,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:495:11",onClick:qe,disabled:V,children:[V?e.jsx(H,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:496:23",className:"h-4 w-4 animate-spin mr-1"}):e.jsx(Z,{"code-path":"src/components/deploy/pipeline-manager/PipelineCreateDialog.tsx:496:75",className:"h-4 w-4 mr-1"}),V?"创建中...":"创建流水线"]})]})]})})}function Ea(){const[n,p]=o.useState(""),{data:P=[],isLoading:b,refetch:j}=ia(),{triggerMutation:d,deleteMutation:y,stopRunMutation:M}=pa(),[w,u]=o.useState({}),[C,R]=o.useState({}),[t,i]=o.useState({}),[A,g]=o.useState("all"),[E,Q]=o.useState({}),[_,F]=o.useState(!1),q=Qe(),G=[{key:"all",label:"全部",icon:na,color:"#6B7280"},{key:"production",label:"生产",icon:Le,color:"#EF4444"},{key:"testing",label:"测试",icon:ae,color:"#F59E0B"},{key:"staging",label:"预发布",icon:ue,color:"#8B5CF6"},{key:"development",label:"开发",icon:sa,color:"#3B82F6"}];o.useEffect(()=>{P.forEach(s=>{const r=s.id;s.last_status==="running"&&!E[r]&&L.getRuns(s.code).then(l=>{const k=(l?.list||[]).find(S=>S.status==="running"||S.status==="pending");k&&Q(S=>({...S,[r]:k}))}).catch(()=>{})})},[P,E]);const $=async(s,r)=>{i(l=>({...l,[s]:!0}));try{const l=await L.getRuns(r);R(B=>({...B,[s]:l?.list||[]}))}catch{R(l=>({...l,[s]:[]}))}finally{i(l=>({...l,[s]:!1}))}},V=(s,r)=>{w[s]?u(l=>({...l,[s]:!1})):($(s,r),u(l=>({...l,[s]:!0})))},W=async(s,r)=>{try{await d.mutateAsync(r),N.success("已触发"),$(s,r),j()}catch{N.error("触发失败")}},z=async(s,r,l)=>{if(await q({title:"停止运行",description:"确定要停止此运行吗?",variant:"destructive"}))try{await M.mutateAsync({code:r,runId:l}),N.success("已停止"),$(s,r),Q(k=>{const S={...k};return delete S[s],S})}catch{N.error("停止失败")}},X=async(s,r)=>{const l=E[s];if(!l){try{const k=((await L.getRuns(r))?.list||[]).find(S=>S.status==="running"||S.status==="pending");k?await z(s,r,k.id):N.error("未找到运行中的任务")}catch{N.error("停止失败")}return}await z(s,r,l.id)},J=async s=>{if(await q({title:"删除流水线",description:`确定删除「${s.name}」?`,variant:"destructive"}))try{await y.mutateAsync(s.id),N.success("已删除"),j()}catch{N.error("删除失败")}},ne=P.filter(s=>{const r=String(s.name||"").toLowerCase().includes(n.toLowerCase())||String(s.description||"").toLowerCase().includes(n.toLowerCase()),l=s.environment,B=A==="all"||(l?.type||"")===A;return r&&B});return e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:157:5",className:"space-y-5",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:158:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:159:9",children:[e.jsx("h1",{"code-path":"src/components/deploy/PipelineManager.tsx:160:11",className:"text-2xl font-bold text-[var(--dg-text-primary)]",children:"流水线"}),e.jsx("p",{"code-path":"src/components/deploy/PipelineManager.tsx:161:11",className:"text-sm text-[var(--dg-text-secondary)] mt-1",children:"CI/CD 构建 · 部署 · 发布一体化"})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:163:9",className:"flex items-center gap-2",children:[e.jsxs(v,{"code-path":"src/components/deploy/PipelineManager.tsx:164:11",variant:"outline",className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)]",onClick:()=>j(),children:[e.jsx(ee,{"code-path":"src/components/deploy/PipelineManager.tsx:165:13",className:`h-4 w-4 mr-2 ${b?"animate-spin":""}`}),"刷新"]}),e.jsxs(v,{"code-path":"src/components/deploy/PipelineManager.tsx:167:11",onClick:()=>F(!0),children:[e.jsx(xe,{"code-path":"src/components/deploy/PipelineManager.tsx:167:52",className:"h-4 w-4 mr-2"}),"新建流水线"]})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:172:7",className:"flex items-stretch gap-3 px-4 py-3 rounded-lg bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:173:9",className:"flex-1 space-y-1.5",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:174:11",className:"flex items-center gap-1.5",children:[e.jsx(U,{"code-path":"src/components/deploy/PipelineManager.tsx:175:13",className:"h-3 w-3 text-indigo-400"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineManager.tsx:176:13",className:"text-[10px] font-semibold text-indigo-400",children:"构建"}),e.jsx(I,{"code-path":"src/components/deploy/PipelineManager.tsx:177:13",className:"h-2.5 w-2.5 text-[var(--dg-text-secondary)] opacity-30"}),e.jsx(Z,{"code-path":"src/components/deploy/PipelineManager.tsx:178:13",className:"h-3 w-3 text-red-400"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineManager.tsx:179:13",className:"text-[10px] font-semibold text-red-400",children:"部署"}),e.jsx(I,{"code-path":"src/components/deploy/PipelineManager.tsx:180:13",className:"h-2.5 w-2.5 text-[var(--dg-text-secondary)] opacity-30"}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:181:13",className:"flex items-center gap-1 px-2 py-0.5 rounded bg-blue-400/10 border border-blue-400/20",children:[e.jsx(ye,{"code-path":"src/components/deploy/PipelineManager.tsx:182:15",className:"h-3 w-3 text-blue-400"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineManager.tsx:183:15",className:"text-[10px] font-medium text-blue-400",children:"SSH 主机"})]})]}),e.jsx("p",{"code-path":"src/components/deploy/PipelineManager.tsx:186:11",className:"text-[9px] text-[var(--dg-text-secondary)] opacity-40 pl-1",children:"传统主机 SCP 部署 · 无需镜像仓库"})]}),e.jsx("div",{"code-path":"src/components/deploy/PipelineManager.tsx:188:9",className:"w-px bg-[var(--dg-border)]"}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:189:9",className:"flex-1 space-y-1.5",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:190:11",className:"flex items-center gap-1.5",children:[e.jsx(U,{"code-path":"src/components/deploy/PipelineManager.tsx:191:13",className:"h-3 w-3 text-indigo-400"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineManager.tsx:192:13",className:"text-[10px] font-semibold text-indigo-400",children:"构建"}),e.jsx(I,{"code-path":"src/components/deploy/PipelineManager.tsx:193:13",className:"h-2.5 w-2.5 text-[var(--dg-text-secondary)] opacity-30"}),e.jsx(ie,{"code-path":"src/components/deploy/PipelineManager.tsx:194:13",className:"h-3 w-3 text-cyan-400"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineManager.tsx:195:13",className:"text-[10px] font-semibold text-cyan-400",children:"镜像仓库"}),e.jsx(I,{"code-path":"src/components/deploy/PipelineManager.tsx:196:13",className:"h-2.5 w-2.5 text-[var(--dg-text-secondary)] opacity-30"}),e.jsx(Z,{"code-path":"src/components/deploy/PipelineManager.tsx:197:13",className:"h-3 w-3 text-red-400"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineManager.tsx:198:13",className:"text-[10px] font-semibold text-red-400",children:"部署"}),e.jsx(I,{"code-path":"src/components/deploy/PipelineManager.tsx:199:13",className:"h-2.5 w-2.5 text-[var(--dg-text-secondary)] opacity-30"}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:200:13",className:"flex items-center gap-1 px-2 py-0.5 rounded bg-emerald-400/10 border border-emerald-400/20",children:[e.jsx(he,{"code-path":"src/components/deploy/PipelineManager.tsx:201:15",className:"h-3 w-3 text-emerald-400"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineManager.tsx:202:15",className:"text-[10px] font-medium text-emerald-400",children:"Kubernetes"})]})]}),e.jsx("p",{"code-path":"src/components/deploy/PipelineManager.tsx:205:11",className:"text-[9px] text-[var(--dg-text-secondary)] opacity-40 pl-1",children:"容器化部署 · 需镜像仓库推送"})]}),e.jsx("span",{"code-path":"src/components/deploy/PipelineManager.tsx:207:9",className:"self-center ml-2 text-[10px] text-[var(--dg-text-secondary)] opacity-30 tracking-wide whitespace-nowrap",children:"全流程可视化"})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:210:7",className:"flex items-center gap-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:211:9",className:"relative max-w-md flex-1",children:[e.jsx(aa,{"code-path":"src/components/deploy/PipelineManager.tsx:212:11",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-[var(--dg-text-secondary)]"}),e.jsx(f,{"code-path":"src/components/deploy/PipelineManager.tsx:213:11",placeholder:"搜索流水线...",value:n,onChange:s=>p(s.target.value),className:"pl-10 bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),e.jsx("div",{"code-path":"src/components/deploy/PipelineManager.tsx:220:9",className:"flex items-center gap-1 bg-[var(--dg-bg-secondary)] rounded-lg p-1 border border-[var(--dg-border)]",children:G.map(s=>{const r=A===s.key,l=s.icon;return e.jsxs("button",{"code-path":"src/components/deploy/PipelineManager.tsx:225:15",onClick:()=>g(s.key),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-all ${r?"text-white shadow-sm":"text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)]"}`,style:r?{backgroundColor:s.color}:{},children:[e.jsx(l,{"code-path":"src/components/deploy/PipelineManager.tsx:233:17",className:"h-3.5 w-3.5"}),s.label]},s.key)})})]}),b?e.jsx("div",{"code-path":"src/components/deploy/PipelineManager.tsx:241:9",className:"flex items-center justify-center py-12",children:e.jsx(H,{"code-path":"src/components/deploy/PipelineManager.tsx:242:11",className:"h-6 w-6 text-[var(--dg-text-secondary)] animate-spin"})}):ne.length===0?e.jsxs("div",{"code-path":"src/components/deploy/PipelineManager.tsx:245:9",className:"text-center py-16 text-[var(--dg-text-secondary)]",children:[e.jsx(ta,{"code-path":"src/components/deploy/PipelineManager.tsx:246:11",className:"h-10 w-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{"code-path":"src/components/deploy/PipelineManager.tsx:247:11",className:"text-sm",children:"暂无流水线"}),e.jsxs(v,{"code-path":"src/components/deploy/PipelineManager.tsx:248:11",variant:"outline",className:"mt-4",onClick:()=>F(!0),children:[e.jsx(xe,{"code-path":"src/components/deploy/PipelineManager.tsx:249:13",className:"h-4 w-4 mr-1"}),"创建第一个流水线"]})]}):e.jsx("div",{"code-path":"src/components/deploy/PipelineManager.tsx:253:9",className:"space-y-3",children:ne.map(s=>{const r=s.id,l=s.code||s.id;return e.jsx(ha,{"code-path":"src/components/deploy/PipelineManager.tsx:258:15",pipeline:s,isExpanded:!!w[r],isLoadingRuns:!!t[r],pipelineRuns:C[r]||[],onToggleExpand:()=>V(r,l),onTrigger:()=>W(r,l),onStopRunning:()=>X(r,l),onDelete:()=>J(s),onStopRun:B=>z(r,l,B)},r)})}),e.jsx(ya,{"code-path":"src/components/deploy/PipelineManager.tsx:275:7",open:_,onOpenChange:F,onCreated:j})]})}export{Ea as PipelineManager}; diff --git a/backend/static/assets/PipelineRunDetail-D2Z0DKgo.js b/backend/static/assets/PipelineRunDetail-D2Z0DKgo.js deleted file mode 100644 index a106a35..0000000 --- a/backend/static/assets/PipelineRunDetail-D2Z0DKgo.js +++ /dev/null @@ -1,3 +0,0 @@ -import{r as n,j as e,R as me}from"./vendor-codemirror-B1SGo4xl.js";import{D as he,a as ue,m as ge,c as ye,d as be,o as fe,g as De,t as S,B as E}from"./index-Dungj95X.js";import{B as A}from"./badge-CGJlVD3L.js";import{C as je,b as ve,c as Ne,a as we}from"./card-BIfzBCEy.js";import{p as C}from"./pipeline-DO4lDm_n.js";import{as as J,at as Re,au as Pe,X as Be,av as Fe,f as ee,m as ke,F as Se,v as Ce,aw as Z,T as $e,R as ze,z as _e,J as Ee,ad as Ae,C as T,k as Le,ao as Te,ax as Ie,L as $,ab as Oe,b as te,a as G,U as Ue,ay as Me}from"./vendor-icons-DmqcWdzX.js";function We(s){return s===0?"-":s<1024?s+" B":s<1024*1024?(s/1024).toFixed(1)+" KB":(s/(1024*1024)).toFixed(1)+" MB"}function Je({open:s,onOpenChange:o,runId:u,buildNumber:c}){const[x,a]=n.useState(null),[P,B]=n.useState(!1),[v,L]=n.useState(""),[N,i]=n.useState(""),[w,z]=n.useState(!1),F=async r=>{if(u){B(!0),L("");try{const m=await C.listRunFiles(u,r||void 0);a(m),i(m?.current||"")}catch(m){L(m?.message||"加载失败"),a(null)}finally{B(!1)}}};n.useEffect(()=>{s&&u&&(i(""),F(""))},[s,u]);const y=async r=>{const m=fe.getState().token||"",b=`${location.protocol}//${location.host}/api/v1/pipelines/runs/${u}/files/download?path=${encodeURIComponent(r.path)}&token=${encodeURIComponent(m)}`;window.open(b,"_blank")},R=N?N.split("/").filter(Boolean):[],I=[""].concat(R.map((r,m)=>"/"+R.slice(0,m+1).join("/")));return e.jsx(he,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:104:5",open:s,onOpenChange:o,children:e.jsxs(ue,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:105:7",showCloseButton:!1,className:ge("bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] p-0 gap-0","!duration-0 !transition-none",w?"!max-w-none !w-screen !h-screen !rounded-none":""),style:w?{maxWidth:"100vw",width:"100vw",height:"100vh"}:{maxWidth:"700px",width:"85vw"},children:[e.jsxs(ye,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:116:9",className:"sr-only",children:["文件浏览器 #",c]}),e.jsx(be,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:117:9",className:"sr-only",children:"流水线构建目录文件浏览"}),e.jsxs("div",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:120:9",className:"flex items-center justify-between px-4 py-2.5 border-b border-[var(--dg-border)] shrink-0",children:[e.jsxs("div",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:121:11",className:"flex items-center gap-2 min-w-0",children:[e.jsx(J,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:122:13",className:"h-4 w-4 text-[var(--dg-text-secondary)] shrink-0"}),e.jsxs("span",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:123:13",className:"text-[var(--dg-text-primary)] font-medium text-sm",children:["#",c," 工作区文件"]})]}),e.jsxs("div",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:127:11",className:"flex items-center gap-1",children:[e.jsx("button",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:128:13",onClick:()=>z(!w),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",children:w?e.jsx(Re,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:132:29",className:"h-4 w-4"}):e.jsx(Pe,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:132:65",className:"h-4 w-4"})}),e.jsx("button",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:134:13",onClick:()=>o(!1),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",children:e.jsx(Be,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:138:15",className:"h-4 w-4"})})]})]}),e.jsx("div",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:144:9",className:"flex items-center gap-0.5 px-4 py-2 text-xs border-b border-[var(--dg-border)] bg-[var(--dg-bg-primary)] overflow-x-auto shrink-0",children:I.map((r,m)=>e.jsx("span",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:146:13",className:"flex items-center gap-0.5",children:m===0?e.jsx("button",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:148:17",onClick:()=>F(""),className:"text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)] p-0.5",children:e.jsx(Fe,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:152:19",className:"h-3.5 w-3.5"})}):e.jsxs(e.Fragment,{children:[e.jsx(ee,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:156:19",className:"h-3 w-3 text-[var(--dg-text-muted)] shrink-0"}),e.jsx("button",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:157:19",onClick:()=>F(r),className:"text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)] truncate max-w-[120px]",children:R[m-1]})]})},r))}),e.jsxs("div",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:170:9",className:"overflow-y-auto",style:{height:w?"calc(100vh - 110px)":"420px"},children:[P&&e.jsx("div",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:172:13",className:"flex items-center justify-center h-full text-[var(--dg-text-muted)] text-sm",children:"加载中..."}),v&&e.jsx("div",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:178:13",className:"flex items-center justify-center h-full text-red-400 text-sm",children:v}),x&&!P&&e.jsxs("table",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:184:13",className:"w-full text-sm",children:[e.jsx("thead",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:185:15",className:"sticky top-0 bg-[var(--dg-bg-primary)] border-b border-[var(--dg-border)]",children:e.jsxs("tr",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:186:17",className:"text-left text-[var(--dg-text-muted)] text-xs",children:[e.jsx("th",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:187:19",className:"py-2 pl-4 pr-2 font-medium",children:"名称"}),e.jsx("th",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:188:19",className:"py-2 px-2 font-medium w-24 text-right",children:"大小"}),e.jsx("th",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:189:19",className:"py-2 pr-4 pl-2 font-medium w-40 hidden sm:table-cell",children:"修改时间"}),e.jsx("th",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:190:19",className:"py-2 pr-4 pl-2 font-medium w-16"})]})}),e.jsxs("tbody",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:193:15",children:[N&&e.jsxs("tr",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:196:19",className:"border-b border-[var(--dg-border)] hover:bg-[var(--dg-bg-hover)] cursor-pointer",onClick:()=>{const r=N.split("/").slice(0,-1).join("/");F(r)},children:[e.jsxs("td",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:203:21",className:"py-2 pl-4 pr-2 flex items-center gap-2",children:[e.jsx(ke,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:204:23",className:"h-4 w-4 text-[var(--dg-text-secondary)]"}),e.jsx("span",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:205:23",className:"text-[var(--dg-text-secondary)]",children:".."})]}),e.jsx("td",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:207:21",className:"py-2 px-2 text-right"}),e.jsx("td",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:208:21",className:"py-2 pr-4 pl-2 hidden sm:table-cell"}),e.jsx("td",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:209:21",className:"py-2 pr-4 pl-2"})]}),x.dirs?.map(r=>e.jsxs("tr",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:215:19",className:"border-b border-[var(--dg-border)] hover:bg-[var(--dg-bg-hover)] cursor-pointer",onClick:()=>F(r.path),children:[e.jsxs("td",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:220:21",className:"py-2 pl-4 pr-2 flex items-center gap-2",children:[e.jsx(J,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:221:23",className:"h-4 w-4 text-amber-400 shrink-0"}),e.jsx("span",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:222:23",className:"text-[var(--dg-text-primary)]",children:r.name})]}),e.jsx("td",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:224:21",className:"py-2 px-2 text-right text-[var(--dg-text-muted)]",children:"-"}),e.jsx("td",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:225:21",className:"py-2 pr-4 pl-2 text-[var(--dg-text-muted)] hidden sm:table-cell",children:r.mod_time}),e.jsx("td",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:226:21",className:"py-2 pr-4 pl-2"})]},r.path)),x.files?.map(r=>e.jsxs("tr",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:232:19",className:"border-b border-[var(--dg-border)] hover:bg-[var(--dg-bg-hover)]",children:[e.jsxs("td",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:236:21",className:"py-2 pl-4 pr-2 flex items-center gap-2",children:[e.jsx(Se,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:237:23",className:"h-4 w-4 text-sky-400 shrink-0"}),e.jsx("span",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:238:23",className:"text-[var(--dg-text-primary)]",children:r.name})]}),e.jsx("td",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:240:21",className:"py-2 px-2 text-right text-[var(--dg-text-muted)]",children:We(r.size)}),e.jsx("td",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:241:21",className:"py-2 pr-4 pl-2 text-[var(--dg-text-muted)] hidden sm:table-cell",children:r.mod_time}),e.jsx("td",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:242:21",className:"py-2 pr-4 pl-2",children:e.jsx("button",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:243:23",onClick:m=>{m.stopPropagation(),y(r)},className:"p-1 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)] hover:text-white",title:"下载",children:e.jsx(Ce,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:248:25",className:"h-3.5 w-3.5"})})})]},r.path)),x.dirs?.length===0&&x.files?.length===0&&!N&&e.jsx("tr",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:256:19",children:e.jsx("td",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:257:21",colSpan:4,className:"py-8 text-center text-[var(--dg-text-muted)]",children:P?"加载中...":"目录为空"})})]})]})]})]})})}const j=[{key:"checkout",label:"代码检出",icon:Ee,color:"#6366F1",order:1},{key:"build",label:"构建",icon:Ae,color:"#F59E0B",order:2},{key:"test",label:"测试",icon:T,color:"#10B981",order:3},{key:"image",label:"镜像打包",icon:Le,color:"#06B6D4",order:4},{key:"deploy",label:"部署",icon:Te,color:"#EF4444",order:5},{key:"verify",label:"验证",icon:Ie,color:"#3B82F6",order:6}].sort((s,o)=>s.order-o.order),Ge={success:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",failed:"bg-red-500/20 text-red-400 border-red-500/30",running:"bg-blue-500/20 text-blue-400 border-blue-500/30",pending:"bg-slate-500/20 text-slate-400 border-slate-500/30",cancelled:"bg-amber-500/20 text-amber-400 border-amber-500/30"},He={success:T,failed:G,running:$,pending:te,cancelled:Oe};function Xe(s){if(!s)return"-";if(s<60)return`${s}秒`;const o=Math.floor(s/60),u=s%60;return`${o}分${u}秒`}function qe(s){return s?new Date(s).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):"-"}function Ke(s){if(!s)return[];try{const o=typeof s=="string"?JSON.parse(s):s;return Array.isArray(o)?o:[]}catch{return[]}}function Ve(s){const o=new Map;return s&&(Ke(s.stages).forEach(c=>{if(c.name||c.type){const x=c.type||j.find(a=>a.label===c.name)?.key;x&&o.set(x,c.status)}}),o.size===0&&s.status==="success"?j.forEach(c=>o.set(c.key,"success")):o.size===0&&s.status==="failed"?j.forEach((c,x)=>o.set(c.key,x===0?"success":"pending")):o.size===0&&s.status==="running"&&o.set("checkout","running")),o}function Qe(s,o){const u=s.find(x=>x.stage===o);if(u)return u.message;const c=j.find(x=>x.key===o);return c?`${c.label}...`:""}function nt(){const{code:s}=De(),[o,u]=n.useState(null),[c,x]=n.useState([]),[a,P]=n.useState(null),[B,v]=n.useState([]),[L,N]=n.useState(!1),[i,w]=n.useState(null),[z,F]=n.useState(10),[y,R]=n.useState(new Set),[I,r]=n.useState(!1),m=n.useRef(null),b=n.useRef(null),[se,H]=n.useState(!1),[X,oe]=n.useState(null),ne=n.useCallback(async()=>{try{const t=await C.getByCode(s);u(t?.data||t)}catch{}},[s]),f=n.useCallback(async()=>{N(!0);try{const d=(await C.getRunsByCode(s,z))?.list||[];x(d),!a&&d.length>0&&P(d[0])}catch{S.error("获取执行记录失败")}finally{N(!1)}},[s,z]);n.useEffect(()=>{ne(),f()},[]),n.useEffect(()=>{f()},[z]),n.useEffect(()=>{if(!c.some(l=>l.status==="running"))return;const d=setInterval(f,5e3);return()=>clearInterval(d)},[c,f]);const q=n.useCallback(async t=>{try{const d=await C.getRunLogStream(t.id);if(d?.logs){const l=typeof d.logs=="string"?JSON.parse(d.logs):d.logs;v(Array.isArray(l)?l:[])}else v([]);t.status==="running"&&ae(t.id)}catch{v([])}},[]),ae=t=>{b.current&&b.current.close();const d=window.location.protocol==="https:"?"wss:":"ws:",l=localStorage.getItem("token"),p=new WebSocket(`${d}//${window.location.host}/ws/pipeline/${t}/log?token=${l}`);p.onmessage=k=>{try{const h=JSON.parse(k.data);if(h.type==="init"&&h.logs){const g=typeof h.logs=="string"?JSON.parse(h.logs):h.logs;v(Array.isArray(g)?g:[])}else h.type==="done"?(p.close(),f()):h.time&&h.level&&v(g=>[...g,h])}catch{}},p.onclose=()=>{b.current=null},p.onerror=()=>{b.current=null},b.current=p};n.useEffect(()=>(a&&(q(a),w(null)),()=>{b.current&&b.current.close()}),[a,q]),n.useEffect(()=>{m.current?.scrollIntoView({behavior:"smooth"})},[B]);const le=async()=>{try{await C.triggerByCode(s),S.success("已触发"),f()}catch{S.error("触发失败")}},ce=async t=>{try{await C.stopRunByCode(s,t),S.success("已停止"),f()}catch{S.error("停止失败")}},re=async()=>{if(y.size!==0){r(!0);try{await C.batchDeleteRuns(s,Array.from(y)),S.success(`已删除 ${y.size} 条记录`),R(new Set),f()}catch{S.error("批量删除失败")}finally{r(!1)}}},ie=t=>{R(d=>{const l=new Set(d);return l.has(t)?l.delete(t):l.add(t),l})},de=()=>{y.size===c.length?R(new Set):R(new Set(c.map(t=>t.id)))},K=t=>t.triggered_by==="system"?"Cron":t.triggered_by==="git"?"Git Push":t.triggered_by||"Manual",O=Ve(a),V=i?B.filter(t=>t.stage===i):B,Q=i?Qe(B,i):"";return e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:294:5",className:"space-y-4 h-full flex flex-col",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:296:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:297:9",children:[e.jsxs("h2",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:298:11",className:"text-lg font-semibold text-[var(--dg-text-primary)]",children:[e.jsx(Z,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:299:13",className:"w-5 h-5 inline mr-2"}),"流水线详情"]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:302:11",className:"flex items-center gap-2 mt-0.5 flex-wrap",children:[o?.name&&e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:304:15",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:o.name}),o?.environment&&e.jsx(A,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:309:15",className:"text-xs",style:{backgroundColor:o.environment.color+"20",color:o.environment.color},children:o.environment.display_name}),a&&e.jsxs("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:317:15",className:"text-sm text-[var(--dg-text-secondary)]",children:["发布 #",a.build_number]})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:323:9",className:"flex gap-2 items-center",children:[y.size>0&&e.jsxs(E,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:325:13",variant:"destructive",size:"sm",onClick:re,disabled:I,children:[e.jsx($e,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:326:15",className:"w-4 h-4 mr-1"}),"删除 (",y.size,")"]}),e.jsxs("select",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:329:11",value:z,onChange:t=>F(Number(t.target.value)),className:"h-8 px-2 text-xs rounded border border-[var(--dg-border)] bg-[var(--dg-bg-secondary)] text-[var(--dg-text-primary)]",children:[e.jsx("option",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:334:13",value:10,children:"10条/页"}),e.jsx("option",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:335:13",value:20,children:"20条/页"}),e.jsx("option",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:336:13",value:30,children:"30条/页"})]}),e.jsxs(E,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:338:11",variant:"outline",size:"sm",onClick:f,children:[e.jsx(ze,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:339:13",className:"w-4 h-4 mr-1"}),"刷新"]}),e.jsxs(E,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:341:11",size:"sm",onClick:le,children:[e.jsx(_e,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:342:13",className:"w-4 h-4 mr-1"}),"立即执行"]})]})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:348:7",className:"flex items-center gap-0 px-4 py-3 rounded-lg bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] overflow-x-auto",children:[j.map((t,d)=>{const l=O.get(t.key)||"",p=l==="success"||l==="completed",k=l==="running"||l==="in_progress",h=l==="failed"||l==="error",g=i===t.key;t.key;const _=O.size>0,D=h?"#EF4444":k?"#3B82F6":p?"#207060":"#6B7280",U=h?"#EF444420":k?"#3B82F620":p?"#20706020":"#6B728010",M=g?D:D+"50",W=t.icon,pe=h?e.jsx(G,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:370:35",className:"h-3.5 w-3.5"}):k?e.jsx($,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:371:27",className:"h-3.5 w-3.5 animate-spin"}):p?e.jsx(T,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:372:27",className:"h-3.5 w-3.5"}):_?e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:373:25",className:"text-[10px] opacity-40",children:"○"}):e.jsx(W,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:374:15",className:"h-3.5 w-3.5 opacity-40"}),Y=d===j.length-1,xe=d===0?"8px 0 0 8px":Y?"0 8px 8px 0":"0";return e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:380:13",className:"flex items-center",children:[e.jsxs("button",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:381:15",onClick:()=>w(i===t.key?null:t.key),title:`${t.label}${l?` (${l})`:""} — 点击查看日志`,className:`flex items-center gap-1.5 px-3 py-2 text-[12px] font-semibold border shadow-sm transition-all cursor-pointer - ${g?"ring-1 ring-offset-0 scale-[1.02]":"hover:brightness-110"}`,style:{backgroundColor:U,borderColor:M,color:D,borderRadius:xe},children:[pe,e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:394:17",children:t.label})]}),!Y&&e.jsx("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:397:17",className:"flex items-center justify-center w-5 h-5 -mx-px z-10",children:e.jsx(ee,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:398:19",className:"h-3.5 w-3.5",style:{color:D+"99"}})})]},t.key)}),a&&e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:405:11",className:"ml-auto text-[10px] text-[var(--dg-text-secondary)] opacity-40 shrink-0 pl-3 whitespace-nowrap",children:i?j.find(t=>t.key===i)?.label:"全阶段"})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:412:7",className:"flex-1 flex flex-col min-h-0",children:[e.jsx("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:414:9",className:"rounded-md border border-[var(--dg-border)] overflow-hidden mb-4",children:L&&c.length===0?e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:416:13",className:"text-center py-12",children:[e.jsx($,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:417:15",className:"w-6 h-6 animate-spin mx-auto mb-2 text-[var(--dg-text-muted)]"}),"加载中..."]}):c.length===0?e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:421:13",className:"text-center py-12 border border-dashed border-[var(--dg-border)] rounded-lg m-4",children:[e.jsx(Z,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:422:15",className:"w-10 h-10 mx-auto mb-3 text-[var(--dg-text-muted)]"}),e.jsx("p",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:423:15",className:"text-[var(--dg-text-secondary)]",children:'暂无执行记录,点击"立即执行"触发构建'})]}):e.jsxs("table",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:426:13",className:"w-full text-sm",children:[e.jsx("thead",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:427:15",className:"bg-[var(--dg-bg-tertiary)] border-b border-[var(--dg-border)]",children:e.jsxs("tr",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:428:17",children:[e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:429:19",className:"px-2 py-2.5 w-10",children:e.jsx("input",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:430:21",type:"checkbox",checked:y.size===c.length&&c.length>0,onChange:de,className:"rounded"})}),e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:433:19",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)] w-16",children:"构建"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:434:19",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)] w-20",children:"状态"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:435:19",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)]",children:"触发方式"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:436:19",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)]",children:"用户"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:437:19",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)]",children:"耗时"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:438:19",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)] hidden md:table-cell",children:"时间"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:439:19",className:"px-3 py-2.5 text-right font-medium text-[var(--dg-text-secondary)] w-32",children:"操作"})]})}),e.jsx("tbody",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:442:15",children:c.map(t=>{const d=He[t.status]||te;return e.jsxs("tr",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:446:21",className:`border-b border-[var(--dg-border)] cursor-pointer transition-colors - ${a?.id===t.id?"bg-[var(--dg-blue)]/10":"hover:bg-[var(--dg-bg-tertiary)]/50"}`,onClick:()=>{P(t)},children:[e.jsx("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:450:23",className:"px-2 py-2.5",onClick:l=>l.stopPropagation(),children:e.jsx("input",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:451:25",type:"checkbox",checked:y.has(t.id),onChange:()=>ie(t.id),className:"rounded"})}),e.jsxs("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:454:23",className:"px-3 py-2.5 font-mono font-semibold text-[var(--dg-text-primary)]",children:["#",t.build_number]}),e.jsx("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:457:23",className:"px-3 py-2.5",children:e.jsxs(A,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:458:25",className:`text-xs ${Ge[t.status]||""} flex items-center gap-1 w-fit`,children:[e.jsx(d,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:459:27",className:`w-3 h-3 ${t.status==="running"?"animate-spin":""}`}),t.status==="success"?"成功":t.status==="failed"?"失败":t.status==="running"?"执行中":t.status==="cancelled"?"已取消":"待执行"]})}),e.jsx("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:467:23",className:"px-3 py-2.5",children:e.jsx(A,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:468:25",variant:"outline",className:"text-xs",children:K(t)})}),e.jsxs("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:470:23",className:"px-3 py-2.5 text-[var(--dg-text-secondary)] flex items-center gap-1",children:[e.jsx(Ue,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:471:25",className:"w-3 h-3"}),t.triggered_by||"admin"]}),e.jsx("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:474:23",className:"px-3 py-2.5 text-[var(--dg-text-secondary)] font-mono text-xs",children:t.status==="running"?e.jsxs("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:476:27",className:"flex items-center gap-1 text-blue-400",children:[e.jsx($,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:477:29",className:"w-3 h-3 animate-spin"}),"执行中..."]}):Xe(t.duration)}),e.jsx("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:481:23",className:"px-3 py-2.5 text-[var(--dg-text-muted)] text-xs hidden md:table-cell",children:qe(t.created_at)}),e.jsx("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:484:23",className:"px-3 py-2.5 text-right",onClick:l=>l.stopPropagation(),children:e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:485:25",className:"flex justify-end gap-1",children:[e.jsx(E,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:486:27",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>P(t),children:"日志"}),e.jsxs(E,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:490:27",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>{oe({id:t.id,buildNumber:t.build_number}),H(!0)},children:[e.jsx(J,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:492:29",className:"w-3.5 h-3.5 mr-1"}),"浏览"]}),t.status==="running"&&e.jsx(E,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:495:29",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-500",onClick:()=>ce(t.id),children:e.jsx(Me,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:497:31",className:"w-3.5 h-3.5"})})]})})]},t.id)})})]})}),a&&e.jsxs(je,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:512:11",className:"flex-1 flex flex-col min-h-0 border-[var(--dg-border)] bg-[var(--dg-bg-secondary)]",children:[e.jsxs(ve,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:513:13",className:"py-3 px-4 flex flex-row items-center justify-between border-b border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:514:15",className:"flex items-center gap-3",children:[e.jsxs(Ne,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:515:17",className:"text-sm font-mono",children:[o?.name||`#${s}`," #",a.build_number]}),a.status==="running"&&e.jsxs(A,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:519:19",className:"bg-blue-500/20 text-blue-400 border-blue-500/30 text-xs",children:[e.jsx($,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:520:21",className:"w-3 h-3 animate-spin mr-1"}),"实时"]}),i&&e.jsx(A,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:524:19",className:"text-xs border-[var(--dg-border)]",variant:"outline",children:j.find(t=>t.key===i)?.label||i})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:529:15",className:"flex items-center gap-2 text-xs text-[var(--dg-text-muted)]",children:[e.jsxs("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:530:17",children:["触发: ",K(a)," (",a.triggered_by||"admin",")"]}),e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:531:17",className:"opacity-40",children:"|"}),e.jsxs("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:532:17",children:["分支: ",a.branch||"-"]}),a.commit_id&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:535:21",className:"opacity-40",children:"|"}),e.jsx("code",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:536:21",className:"bg-amber-400/10 text-amber-400 px-1 py-0.5 rounded text-[10px]",children:a.commit_id.slice(0,8)})]}),a.image_tag&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:543:21",className:"opacity-40",children:"|"}),e.jsxs("code",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:544:21",className:"bg-cyan-400/10 text-cyan-400 px-1 py-0.5 rounded text-[10px]",children:["📦 ",a.image_tag]})]})]})]}),e.jsxs(we,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:551:13",className:"flex-1 p-0 overflow-hidden min-h-0",children:[i&&Q&&e.jsx("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:554:17",className:"px-4 py-2 border-b border-[var(--dg-border)] bg-[var(--dg-bg-tertiary)]/30",children:e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:555:19",className:"flex items-center gap-2",children:[e.jsxs("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:556:21",className:"text-[11px] font-semibold text-[var(--dg-text-secondary)]",children:["[",j.find(t=>t.key===i)?.label||i,"]"]}),(()=>{const t=O.get(i);return t==="success"||t==="completed"?e.jsx(T,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:561:74",className:"h-3.5 w-3.5 text-emerald-400"}):t==="failed"||t==="error"?e.jsx(G,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:562:69",className:"h-3.5 w-3.5 text-red-400"}):t==="running"||t==="in_progress"?e.jsx($,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:563:76",className:"h-3.5 w-3.5 text-blue-400 animate-spin"}):null})(),e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:566:21",className:"text-xs text-[var(--dg-text-muted)] truncate font-mono",children:Q})]})}),e.jsx("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:572:15",className:"h-full overflow-y-auto bg-[#0d1117] font-mono text-xs leading-5 p-4",style:{minHeight:280},children:V.length===0&&a.status!=="running"?e.jsx("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:574:19",className:"text-center py-12 text-slate-500",children:i?"该阶段暂无日志输出":"暂无日志输出"}):e.jsxs(e.Fragment,{children:[(()=>{let t="";const d={checkout:"border-indigo-500 bg-indigo-500/10",build:"border-amber-500 bg-amber-500/10",test:"border-emerald-500 bg-emerald-500/10",image:"border-cyan-500 bg-cyan-500/10",deploy:"border-red-500 bg-red-500/10",verify:"border-blue-500 bg-blue-500/10"},l={checkout:"⬇",build:"⚙",test:"✓",image:"📦",deploy:"🚀",verify:"🛡"};return V.map((p,k)=>{const h=!i&&p.stage&&p.stage!==t;h&&(t=p.stage||"");const g=p.level==="error",_=p.level==="warn",D=p.level==="success",U=g?"border-l-2 border-red-500 bg-red-500/10":_?"border-l-2 border-amber-500 bg-amber-500/10":D?"border-l-2 border-emerald-500 bg-emerald-500/5":"",M=g?"text-red-200":_?"text-amber-200":D?"text-emerald-200":"text-slate-300",W=g?e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:606:29",className:"shrink-0 px-1.5 py-px rounded text-[10px] font-bold bg-red-600/40 text-red-200",children:"ERR"}):_?e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:608:29",className:"shrink-0 px-1.5 py-px rounded text-[10px] font-bold bg-amber-600/40 text-amber-200",children:"WARN"}):D?e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:610:29",className:"shrink-0 px-1.5 py-px rounded text-[10px] font-bold bg-emerald-600/30 text-emerald-200",children:" OK "}):e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:611:29",className:"shrink-0 px-1.5 py-px rounded text-[10px] bg-slate-600/30 text-slate-400",children:"INFO"});return e.jsxs(me.Fragment,{children:[h&&e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:615:31",className:`flex items-center gap-2 my-2 py-1 px-2 border-l-4 rounded-r ${d[p.stage||""]||"border-slate-500 bg-slate-500/10"}`,children:[e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:616:33",className:"text-xs",children:l[p.stage||""]||"▸"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:617:33",className:"text-[11px] font-semibold tracking-wider text-slate-200",children:p.stage}),e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:618:33",className:"flex-1 border-t border-slate-700/50"})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:621:29",className:`flex items-start gap-2 px-2 py-0.5 -mx-1 rounded-sm ${U} ${!g&&!_&&!D?"hover:bg-white/[0.03]":""}`,children:[e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:622:31",className:"text-slate-600 shrink-0 w-14 text-right text-[10px] pt-px",children:p.time}),W,e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:624:31",className:`break-all ${M}`,children:p.message})]})]},k)})})(),a.status==="running"&&e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:631:23",className:"flex items-center gap-2 mt-2 py-1.5 px-3 bg-blue-500/10 border-l-4 border-blue-500 rounded-r",children:[e.jsx($,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:632:25",className:"w-3 h-3 animate-spin text-blue-400 shrink-0"}),e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:633:25",className:"text-[11px] text-blue-300 font-medium",children:"流水线执行中,实时输出..."}),e.jsxs("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:634:25",className:"flex gap-1 ml-1",children:[e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:635:27",className:"w-1 h-1 rounded-full bg-blue-400 animate-bounce",style:{animationDelay:"0ms"}}),e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:636:27",className:"w-1 h-1 rounded-full bg-blue-400 animate-bounce",style:{animationDelay:"150ms"}}),e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:637:27",className:"w-1 h-1 rounded-full bg-blue-400 animate-bounce",style:{animationDelay:"300ms"}})]})]}),e.jsx("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:641:21",ref:m})]})})]})]})]}),e.jsx(Je,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:651:7",open:se,onOpenChange:H,runId:X?.id??null,buildNumber:X?.buildNumber??0})]})}export{nt as default}; diff --git a/backend/static/assets/PlatformManager-DX8QfUd6.js b/backend/static/assets/PlatformManager-DX8QfUd6.js deleted file mode 100644 index 4edafed..0000000 --- a/backend/static/assets/PlatformManager-DX8QfUd6.js +++ /dev/null @@ -1 +0,0 @@ -import{r as t,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{B as d,D as k,a as L,b as E,c as I,d as T,e as B}from"./index-Dungj95X.js";import{I as m}from"./input-CXoUQQLm.js";import{L as r}from"./label-CMpUoC87.js";import{B as j}from"./badge-CGJlVD3L.js";import{S as P,a as M,b as v,c as b,d as o}from"./select-CiTqGGhE.js";import{p as x}from"./platform-BwZ5CngP.js";import{S as K,P as U,L as O,e as V,E as W,d as Y,T as Z,C as $,a as ee}from"./vendor-icons-DmqcWdzX.js";import"./index-5FEebgvX.js";const ae={public:"公有云",private:"私有云",hybrid:"混合云"},se={public:"text-blue-400",private:"text-purple-400",hybrid:"text-cyan-400"};function ie(){const[F,N]=t.useState([]),[Q,y]=t.useState(!0),[h,A]=t.useState(""),[u,H]=t.useState("all"),[R,l]=t.useState(!1),[n,w]=t.useState(null),[C,S]=t.useState(!1),[s,c]=t.useState({name:"",code:"",type:"public",status:"active",website:"",description:""}),p=t.useCallback(async()=>{y(!0);try{const f=(await x.list())?.list||[];N(f)}catch{N([])}finally{y(!1)}},[]);t.useEffect(()=>{p()},[p]);const D=F.filter(a=>{const f=a.name?.toLowerCase().includes(h.toLowerCase())||a.code?.toLowerCase().includes(h.toLowerCase()),J=u==="all"||a.type===u;return f&&J}),X=()=>{w(null),c({name:"",code:"",type:"public",status:"active",website:"",description:""}),l(!0)},_=a=>{w(a),c({name:a.name||"",code:a.code||"",type:a.type||"public",status:a.status||"active",website:a.website||"",description:a.description||""}),l(!0)},q=async()=>{if(!(!s.name.trim()||!s.code.trim())){S(!0);try{n?await x.update(n.id,s):await x.create(s),l(!1),p()}catch{}finally{S(!1)}}},[g,i]=t.useState(null),z=a=>i(a),G=async()=>{g!==null&&(await x.delete(g),i(null),p())};return e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:125:5",className:"p-6 space-y-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:127:7",className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:128:9",className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:129:11",className:"relative w-72",children:[e.jsx(K,{"code-path":"src/components/cloud/PlatformManager.tsx:130:13",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-500"}),e.jsx(m,{"code-path":"src/components/cloud/PlatformManager.tsx:131:13",placeholder:"搜索平台名称或编码...",value:h,onChange:a=>A(a.target.value),className:"pl-9 h-9 bg-slate-800/50 border-slate-700"})]}),e.jsxs(P,{"code-path":"src/components/cloud/PlatformManager.tsx:138:11",value:u,onValueChange:H,children:[e.jsx(M,{"code-path":"src/components/cloud/PlatformManager.tsx:139:13",className:"w-32 h-9 bg-slate-800/50 border-slate-700",children:e.jsx(v,{"code-path":"src/components/cloud/PlatformManager.tsx:140:15"})}),e.jsxs(b,{"code-path":"src/components/cloud/PlatformManager.tsx:142:13",children:[e.jsx(o,{"code-path":"src/components/cloud/PlatformManager.tsx:143:15",value:"all",children:"全部类型"}),e.jsx(o,{"code-path":"src/components/cloud/PlatformManager.tsx:144:15",value:"public",children:"公有云"}),e.jsx(o,{"code-path":"src/components/cloud/PlatformManager.tsx:145:15",value:"private",children:"私有云"}),e.jsx(o,{"code-path":"src/components/cloud/PlatformManager.tsx:146:15",value:"hybrid",children:"混合云"})]})]})]}),e.jsxs(d,{"code-path":"src/components/cloud/PlatformManager.tsx:150:9",onClick:X,className:"gap-2",children:[e.jsx(U,{"code-path":"src/components/cloud/PlatformManager.tsx:151:11",className:"h-4 w-4"}),"添加平台"]})]}),Q?e.jsx("div",{"code-path":"src/components/cloud/PlatformManager.tsx:158:9",className:"flex justify-center py-20",children:e.jsx(O,{"code-path":"src/components/cloud/PlatformManager.tsx:159:11",className:"h-6 w-6 animate-spin text-slate-500"})}):D.length===0?e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:162:9",className:"text-center py-20 text-slate-500",children:[e.jsx(V,{"code-path":"src/components/cloud/PlatformManager.tsx:163:11",className:"h-12 w-12 mx-auto mb-3 opacity-40"}),e.jsx("p",{"code-path":"src/components/cloud/PlatformManager.tsx:164:11",children:"暂无云平台数据"})]}):e.jsx("div",{"code-path":"src/components/cloud/PlatformManager.tsx:167:9",className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:D.map(a=>e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:169:13",className:"bg-slate-800/30 rounded-lg p-4 hover:bg-slate-800/50 transition-colors group",children:[e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:173:15",className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:174:17",className:"flex items-center gap-3",children:[e.jsx("div",{"code-path":"src/components/cloud/PlatformManager.tsx:175:19",className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:e.jsx(V,{"code-path":"src/components/cloud/PlatformManager.tsx:176:21",className:"h-5 w-5 text-blue-400"})}),e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:178:19",children:[e.jsx("h3",{"code-path":"src/components/cloud/PlatformManager.tsx:179:21",className:"font-medium text-slate-100",children:a.name}),e.jsx("span",{"code-path":"src/components/cloud/PlatformManager.tsx:180:21",className:"text-xs text-slate-500 font-mono",children:a.code})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:183:17",className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[a.website&&e.jsx("a",{"code-path":"src/components/cloud/PlatformManager.tsx:185:21",href:a.website,target:"_blank",rel:"noreferrer",className:"p-1.5 rounded hover:bg-slate-700 text-slate-400 hover:text-slate-200",children:e.jsx(W,{"code-path":"src/components/cloud/PlatformManager.tsx:186:23",className:"h-3.5 w-3.5"})}),e.jsx("button",{"code-path":"src/components/cloud/PlatformManager.tsx:189:19",onClick:()=>_(a),className:"p-1.5 rounded hover:bg-slate-700 text-slate-400 hover:text-slate-200",children:e.jsx(Y,{"code-path":"src/components/cloud/PlatformManager.tsx:190:21",className:"h-3.5 w-3.5"})}),e.jsx("button",{"code-path":"src/components/cloud/PlatformManager.tsx:192:19",onClick:()=>z(a.id),className:"p-1.5 rounded hover:bg-slate-700 text-slate-400 hover:text-red-400",children:e.jsx(Z,{"code-path":"src/components/cloud/PlatformManager.tsx:193:21",className:"h-3.5 w-3.5"})})]})]}),a.description&&e.jsx("p",{"code-path":"src/components/cloud/PlatformManager.tsx:199:17",className:"text-sm text-slate-400 mb-3 line-clamp-2",children:a.description}),e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:202:15",className:"flex items-center gap-2 flex-wrap",children:[e.jsx(j,{"code-path":"src/components/cloud/PlatformManager.tsx:203:17",variant:"outline",className:se[a.type]||"text-slate-400",children:ae[a.type]||a.type}),a.status==="active"?e.jsxs(j,{"code-path":"src/components/cloud/PlatformManager.tsx:207:19",className:"bg-emerald-500/20 text-emerald-400 gap-1",children:[e.jsx($,{"code-path":"src/components/cloud/PlatformManager.tsx:208:21",className:"h-3 w-3"})," 启用"]}):e.jsxs(j,{"code-path":"src/components/cloud/PlatformManager.tsx:211:19",className:"bg-slate-500/20 text-slate-400 gap-1",children:[e.jsx(ee,{"code-path":"src/components/cloud/PlatformManager.tsx:212:21",className:"h-3 w-3"})," 禁用"]})]})]},a.id))}),e.jsx(k,{"code-path":"src/components/cloud/PlatformManager.tsx:222:7",open:R,onOpenChange:l,children:e.jsxs(L,{"code-path":"src/components/cloud/PlatformManager.tsx:223:9",children:[e.jsxs(E,{"code-path":"src/components/cloud/PlatformManager.tsx:224:11",children:[e.jsx(I,{"code-path":"src/components/cloud/PlatformManager.tsx:225:13",children:n?"编辑云平台":"添加云平台"}),e.jsx(T,{"code-path":"src/components/cloud/PlatformManager.tsx:226:13",className:"sr-only",children:"描述"})]}),e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:228:11",className:"space-y-4 py-2",children:[e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:229:13",className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:230:15",className:"space-y-1.5",children:[e.jsx(r,{"code-path":"src/components/cloud/PlatformManager.tsx:231:17",children:"平台名称 *"}),e.jsx(m,{"code-path":"src/components/cloud/PlatformManager.tsx:232:17",value:s.name,onChange:a=>c({...s,name:a.target.value}),placeholder:"如:阿里云",className:"bg-slate-800/50 border-slate-700"})]}),e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:239:15",className:"space-y-1.5",children:[e.jsx(r,{"code-path":"src/components/cloud/PlatformManager.tsx:240:17",children:"编码 *"}),e.jsx(m,{"code-path":"src/components/cloud/PlatformManager.tsx:241:17",value:s.code,onChange:a=>c({...s,code:a.target.value}),placeholder:"如:aliyun",className:"bg-slate-800/50 border-slate-700",disabled:!!n})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:250:13",className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:251:15",className:"space-y-1.5",children:[e.jsx(r,{"code-path":"src/components/cloud/PlatformManager.tsx:252:17",children:"类型"}),e.jsxs(P,{"code-path":"src/components/cloud/PlatformManager.tsx:253:17",value:s.type,onValueChange:a=>c({...s,type:a}),children:[e.jsx(M,{"code-path":"src/components/cloud/PlatformManager.tsx:254:19",className:"bg-slate-800/50 border-slate-700",children:e.jsx(v,{"code-path":"src/components/cloud/PlatformManager.tsx:255:21"})}),e.jsxs(b,{"code-path":"src/components/cloud/PlatformManager.tsx:257:19",children:[e.jsx(o,{"code-path":"src/components/cloud/PlatformManager.tsx:258:21",value:"public",children:"公有云"}),e.jsx(o,{"code-path":"src/components/cloud/PlatformManager.tsx:259:21",value:"private",children:"私有云"}),e.jsx(o,{"code-path":"src/components/cloud/PlatformManager.tsx:260:21",value:"hybrid",children:"混合云"})]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:264:15",className:"space-y-1.5",children:[e.jsx(r,{"code-path":"src/components/cloud/PlatformManager.tsx:265:17",children:"状态"}),e.jsxs(P,{"code-path":"src/components/cloud/PlatformManager.tsx:266:17",value:s.status,onValueChange:a=>c({...s,status:a}),children:[e.jsx(M,{"code-path":"src/components/cloud/PlatformManager.tsx:267:19",className:"bg-slate-800/50 border-slate-700",children:e.jsx(v,{"code-path":"src/components/cloud/PlatformManager.tsx:268:21"})}),e.jsxs(b,{"code-path":"src/components/cloud/PlatformManager.tsx:270:19",children:[e.jsx(o,{"code-path":"src/components/cloud/PlatformManager.tsx:271:21",value:"active",children:"启用"}),e.jsx(o,{"code-path":"src/components/cloud/PlatformManager.tsx:272:21",value:"inactive",children:"禁用"})]})]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:277:13",className:"space-y-1.5",children:[e.jsx(r,{"code-path":"src/components/cloud/PlatformManager.tsx:278:15",children:"官网地址"}),e.jsx(m,{"code-path":"src/components/cloud/PlatformManager.tsx:279:15",value:s.website,onChange:a=>c({...s,website:a.target.value}),placeholder:"https://...",className:"bg-slate-800/50 border-slate-700"})]}),e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:286:13",className:"space-y-1.5",children:[e.jsx(r,{"code-path":"src/components/cloud/PlatformManager.tsx:287:15",children:"描述"}),e.jsx(m,{"code-path":"src/components/cloud/PlatformManager.tsx:288:15",value:s.description,onChange:a=>c({...s,description:a.target.value}),placeholder:"平台描述...",className:"bg-slate-800/50 border-slate-700"})]})]}),e.jsxs(B,{"code-path":"src/components/cloud/PlatformManager.tsx:296:11",children:[e.jsx(d,{"code-path":"src/components/cloud/PlatformManager.tsx:297:13",variant:"ghost",onClick:()=>l(!1),children:"取消"}),e.jsxs(d,{"code-path":"src/components/cloud/PlatformManager.tsx:298:13",onClick:q,disabled:C||!s.name.trim()||!s.code.trim(),children:[C&&e.jsx(O,{"code-path":"src/components/cloud/PlatformManager.tsx:299:30",className:"h-4 w-4 mr-1 animate-spin"}),n?"保存":"创建"]})]})]})}),e.jsx(k,{"code-path":"src/components/cloud/PlatformManager.tsx:307:7",open:g!==null,onOpenChange:a=>!a&&i(null),children:e.jsxs(L,{"code-path":"src/components/cloud/PlatformManager.tsx:308:9",className:"max-w-sm",children:[e.jsxs(E,{"code-path":"src/components/cloud/PlatformManager.tsx:309:11",children:[e.jsx(I,{"code-path":"src/components/cloud/PlatformManager.tsx:310:13",children:"确认删除"}),e.jsx(T,{"code-path":"src/components/cloud/PlatformManager.tsx:311:13",className:"sr-only",children:"描述"})]}),e.jsx("p",{"code-path":"src/components/cloud/PlatformManager.tsx:313:11",className:"text-sm text-slate-400",children:"确定删除此云平台?此操作不可撤销。"}),e.jsxs(B,{"code-path":"src/components/cloud/PlatformManager.tsx:314:11",children:[e.jsx(d,{"code-path":"src/components/cloud/PlatformManager.tsx:315:13",variant:"ghost",onClick:()=>i(null),children:"取消"}),e.jsx(d,{"code-path":"src/components/cloud/PlatformManager.tsx:316:13",variant:"destructive",onClick:G,children:"删除"})]})]})})]})}export{ie as PlatformManager}; diff --git a/backend/static/assets/PodFileBrowser-B-U8iHmY.js b/backend/static/assets/PodFileBrowser-B-U8iHmY.js deleted file mode 100644 index 32f4deb..0000000 --- a/backend/static/assets/PodFileBrowser-B-U8iHmY.js +++ /dev/null @@ -1,13 +0,0 @@ -import{j as t,r as a,y as Pe,E as J,a as Ee,o as Ne}from"./vendor-codemirror-B1SGo4xl.js";import{$ as Se,ah as ue,B as Y,D as Te,a as Fe,m as re,c as Be,d as Ce}from"./index-Dungj95X.js";import{u as me}from"./use-toast-DNZLibQY.js";import{k as O,d as Ye}from"./index-drGq01ok.js";import{c as xe}from"./k8s-yaml-utils-4KZB_Bq_.js";import{w as Ae,az as Re,v as pe,d as Me,L as z,$ as De,X as I,r as Oe,ad as $e,am as _e,at as Le,au as Ve,H as ze,m as Ie,f as Ue,ah as We,R as He,aX as Je,aY as Ke}from"./vendor-icons-DmqcWdzX.js";import{S as oe,a as ne,b as ae,c as ce,d as le}from"./select-CiTqGGhE.js";import{x as Ge,a as Xe}from"./vendor-xterm-20M9KZE1.js";import{B as qe}from"./badge-CGJlVD3L.js";function Qe({onClose:e,children:s,zIndex:r=100}){return Se.createPortal(t.jsx("div",{"code-path":"src/components/ui/modal-overlay.tsx:13:5",className:"fixed inset-0 overflow-y-auto bg-black/60",style:{zIndex:r},onClick:e,children:t.jsx("div",{"code-path":"src/components/ui/modal-overlay.tsx:18:7",className:"flex min-h-full items-center justify-center p-4",children:s})}),document.body)}const Ze=new Set(["kubectl.kubernetes.io/last-applied-configuration","kubectl.kubernetes.io/change-cause","kubectl.kubernetes.io/restartedAt","deployment.kubernetes.io/revision","deployment.kubernetes.io/desired-replicas","deployment.kubernetes.io/max-replicas","control-plane.alpha.kubernetes.io/leader","autoscaling.alpha.kubernetes.io/conditions","kubernetes.io/config.hash","kubeadm.kubernetes.io/etcd.advertise-client-urls","pv.kubernetes.io/bind-completed","pv.kubernetes.io/bound-by-controller"]),et=["managedFields","resourceVersion","uid","creationTimestamp","generation","selfLink","deletionTimestamp","ownerReferences","finalizers","clusterName","generateName"],tt=new Set(["pod-template-hash","controller-revision-hash"]),st=["kube-api-access-","default-token-","kube-root-ca.crt"],rt=["/var/run/secrets/kubernetes.io/serviceaccount","/var/run/secrets/sa"],ot={dnsPolicy:"ClusterFirst",restartPolicy:"Always",schedulerName:"default-scheduler",terminationGracePeriodSeconds:30,enableServiceLinks:!0,serviceAccountName:"default",automountServiceAccountToken:!0,priority:0,preemptionPolicy:"PreemptLowerPriority"},nt={progressDeadlineSeconds:600,revisionHistoryLimit:10},at={terminationMessagePath:"/dev/termination-log",terminationMessagePolicy:"File",stdin:!1,tty:!1,stdinOnce:!1},ct={sessionAffinity:"None",externalTrafficPolicy:"Cluster",internalTrafficPolicy:"Cluster",ipFamilyPolicy:"SingleStack",allocateLoadBalancerNodePorts:!0},lt=["clusterIP","clusterIPs","ipFamilies","healthCheckNodePort"];function U(e){return Array.isArray(e)?e.length===0:e&&typeof e=="object"?Object.keys(e).length===0:!1}function it(e,s){return s===e||typeof s=="number"&&typeof e=="string"&&String(s)===e?!0:typeof s=="boolean"&&typeof e=="string"?s&&e==="true"||!s&&e==="false":!1}function K(e){if(!(!e||typeof e!="object")){for(const s of et)delete e[s];if(e.annotations){for(const s of Object.keys(e.annotations))Ze.has(s)&&delete e.annotations[s];Object.keys(e.annotations).length===0&&delete e.annotations}if(e.labels){for(const s of tt)delete e.labels[s];Object.keys(e.labels).length===0&&delete e.labels}}}function G(e){if(!e||typeof e!="object")return;if(Array.isArray(e)){for(let r=e.length-1;r>=0;r--)G(e[r]),U(e[r])&&e.splice(r,1);return}const s=e;for(const r of Object.keys(s)){const n=s[r];n&&typeof n=="object"&&G(n),U(n)&&delete s[r]}}function W(e,s){if(!(!e||typeof e!="object"))for(const[r,n]of Object.entries(s))r in e&&it(e[r],n)&&delete e[r]}function ie(e){return st.some(s=>e.startsWith(s)||e===s)}function dt(e){return rt.some(s=>e===s||e.startsWith(`${s}/`))}function ut(e){if(!e||typeof e!="object")return;const s=e.volumes;if(Array.isArray(s)){const r=new Set(s.filter(c=>c?.name&&ie(c.name)).map(c=>c.name));e.volumes=s.filter(c=>!c?.name||!ie(c.name)),e.volumes.length===0&&delete e.volumes;const n=c=>{if(Array.isArray(c))for(const m of c)Array.isArray(m.volumeMounts)&&(m.volumeMounts=m.volumeMounts.filter(j=>!(j?.name&&r.has(j.name)||j?.mountPath&&dt(String(j.mountPath)))),m.volumeMounts.length===0&&delete m.volumeMounts)};n(e.containers),n(e.initContainers),n(e.ephemeralContainers)}}function mt(e){if(!(!e||typeof e!="object")){if(W(e,at),e.imagePullPolicy){const s=String(e.image||"").split(":").pop()||"",n=!String(e.image||"").includes(":")||s==="latest"?"Always":"IfNotPresent";e.imagePullPolicy===n&&delete e.imagePullPolicy}e.resources&&U(e.resources)&&delete e.resources,e.securityContext&&U(e.securityContext)&&delete e.securityContext}}function fe(e){if(!(!e||typeof e!="object")){W(e,ot),"serviceAccount"in e&&delete e.serviceAccount,e.nodeName&&delete e.nodeName,ut(e);for(const s of["containers","initContainers","ephemeralContainers"]){const r=e[s];if(Array.isArray(r))for(const n of r)mt(n)}}}function xt(e){if(!e?.strategy||e.strategy.type!=="RollingUpdate")return;const s=e.strategy.rollingUpdate;if(!s||typeof s!="object")return;const r=s.maxUnavailable,n=s.maxSurge;(r==="25%"||r===0||r==="0")&&(n==="25%"||n===1||n==="1")&&Object.keys(s).length<=2&&delete e.strategy}function pt(e){if(!e||typeof e!="object")return;for(const r of lt)delete e[r];W(e,ct);const s=e.type||"ClusterIP";if(Array.isArray(e.ports))for(const r of e.ports)!r||typeof r!="object"||((s==="ClusterIP"||r.nodePort===0)&&delete r.nodePort,r.protocol==="TCP"&&Object.keys(r).length===3&&delete r.protocol)}function ft(e){!e||typeof e!="object"||e.ingressClassName||delete e.ingressClassName}function ht(e){if(!e?.template||typeof e.template!="object")return;e.template.metadata&&K(e.template.metadata);const s=e.template.spec;s&&fe(s)}function bt(e){const s=String(e.kind||"").toLowerCase();e.spec&&((s==="deployment"||s==="statefulset"||s==="daemonset")&&(W(e.spec,nt),s==="deployment"&&xt(e.spec),ht(e.spec)),s==="service"&&pt(e.spec),s==="ingress"&&ft(e.spec),s==="pod"&&fe(e.spec))}function q(e){const s=JSON.parse(JSON.stringify(e));delete s.status,K(s.metadata);const r=s.spec?.template;return r?.metadata&&K(r.metadata),bt(s),G(s),s}async function wt(e){return(await H(e))[0]||null}async function H(e){if(!e?.trim())return[];try{const s=JSON.parse(e);return s&&typeof s=="object"?[s]:[]}catch{}try{return(await ue(()=>import("./js-yaml-37NdyH6G.js"),[])).loadAll(e).filter(n=>!!n&&typeof n=="object")}catch{return[]}}async function he(e){return(await ue(()=>import("./js-yaml-37NdyH6G.js"),[])).dump(e,{lineWidth:120,noRefs:!0,sortKeys:!1})}async function Q(e){const s=q(e),r=await he(s);return xe(r)}async function Z(e){const s=await H(e);if(s.length===0)return{manifests:[],yaml:e};const r=s.map(c=>q(c)),n=[];for(const c of r)n.push(await Q(c));return{manifests:r,yaml:n.join(` ---- -`)}}async function be(e){const{manifests:s,yaml:r}=await Z(e);return{manifest:s[0]||null,yaml:r}}async function X(e){return Q(e)}async function we(e){const s=await H(e);if(s.length===0)return xe(e);if(s.length===1)return X(s[0]);const r=[];for(const n of s)r.push(await X(n));return r.join(` ---- -`)}const At=Object.freeze(Object.defineProperty({__proto__:null,dumpManifest:he,manifestToEditableYaml:Q,parseEditableManifest:be,parseEditableManifests:Z,parseManifest:wt,parseManifests:H,prepareManifestForSave:X,prepareYamlForSave:we,stripRuntimeFields:q},Symbol.toStringTag,{value:"Module"})),kt={deployments:{label:"Deployment",exportFolder:"deployments",readOnly:!1,visualEdit:!1},pods:{label:"Pod",exportFolder:"pods",readOnly:!0,visualEdit:!1},services:{label:"Service",exportFolder:"services",readOnly:!1,visualEdit:!0},ingresses:{label:"Ingress",exportFolder:"ingresses",readOnly:!1,visualEdit:!0}};function ke(e){const s=e.replace(/\/$/,"").toLowerCase();return kt[s]??{label:s,exportFolder:s,readOnly:!1,visualEdit:!1}}function de(e,s,r){const n=ke(e);return`${s}-${n.exportFolder}-${r}.yaml`}function yt({editing:e,saving:s=!1,copied:r=!1,showRaw:n=!1,compact:c=!1,readOnly:m=!1,showRawToggle:j=!0,onCopy:w,onDownload:g,onEdit:d,onCancel:p,onSave:N,onToggleRaw:P}){const f=c?"h-7 text-xs":"h-8";return t.jsxs("div",{"code-path":"src/components/kubernetes/YamlEditorToolbar.tsx:28:5",className:"flex items-center gap-2 flex-wrap",children:[t.jsxs(Y,{"code-path":"src/components/kubernetes/YamlEditorToolbar.tsx:29:7",variant:"outline",size:"sm",className:`${f} border-slate-700 text-slate-300`,onClick:w,children:[r?t.jsx(Ae,{"code-path":"src/components/kubernetes/YamlEditorToolbar.tsx:30:19",className:"h-3 w-3 mr-1 text-emerald-400"}):t.jsx(Re,{"code-path":"src/components/kubernetes/YamlEditorToolbar.tsx:30:73",className:"h-3 w-3 mr-1"}),r?"已复制":"复制"]}),g&&t.jsxs(Y,{"code-path":"src/components/kubernetes/YamlEditorToolbar.tsx:34:9",variant:"outline",size:"sm",className:`${f} border-slate-700 text-slate-300`,onClick:g,children:[t.jsx(pe,{"code-path":"src/components/kubernetes/YamlEditorToolbar.tsx:35:11",className:"h-3 w-3 mr-1"}),"下载"]}),!m&&(e?t.jsxs(t.Fragment,{children:[t.jsx(Y,{"code-path":"src/components/kubernetes/YamlEditorToolbar.tsx:45:13",variant:"outline",size:"sm",className:`${f} border-slate-700 text-slate-300`,onClick:p,children:"取消"}),t.jsxs(Y,{"code-path":"src/components/kubernetes/YamlEditorToolbar.tsx:46:13",size:"sm",className:`${f} bg-blue-600 hover:bg-blue-700`,onClick:N,disabled:s,children:[s?t.jsx(z,{"code-path":"src/components/kubernetes/YamlEditorToolbar.tsx:47:25",className:"h-3 w-3 animate-spin mr-1"}):t.jsx(De,{"code-path":"src/components/kubernetes/YamlEditorToolbar.tsx:47:77",className:"h-3 w-3 mr-1"}),"保存"]})]}):t.jsxs(Y,{"code-path":"src/components/kubernetes/YamlEditorToolbar.tsx:40:11",variant:"outline",size:"sm",className:`${f} border-slate-700 text-slate-300`,onClick:d,children:[t.jsx(Me,{"code-path":"src/components/kubernetes/YamlEditorToolbar.tsx:41:13",className:"h-3 w-3 mr-1"}),"编辑"]})),j&&P&&t.jsx("button",{"code-path":"src/components/kubernetes/YamlEditorToolbar.tsx:54:9",type:"button",onClick:P,className:"text-[11px] text-slate-500 hover:text-slate-300 underline-offset-2 hover:underline",children:n?"精简视图":"原始 YAML"})]})}const gt=J.theme({"&":{height:"100%"},".cm-scroller":{overflow:"auto"}});function vt({value:e,onChange:s,editing:r=!0,fill:n=!1,height:c="480px",className:m="",fontSize:j="13px"}){const w=a.useRef(null),[g,d]=a.useState(400);a.useEffect(()=>{if(!n||!w.current)return;const f=w.current,y=()=>d(Math.max(200,f.clientHeight)),S=new ResizeObserver(y);return S.observe(f),y(),()=>S.disconnect()},[n]);const p=a.useMemo(()=>[Pe(),J.lineWrapping,gt,...r?[]:[J.editable.of(!1)]],[r]),N=n?`${g}px`:c,P=t.jsx(Ee,{"code-path":"src/components/kubernetes/YamlCodeMirror.tsx:57:5",value:e,height:N,theme:Ne,extensions:p,onChange:s,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:r,highlightActiveLineGutter:r,autocompletion:r,bracketMatching:!0,closeBrackets:r,indentOnInput:r},style:{fontSize:j}});return n?t.jsx("div",{"code-path":"src/components/kubernetes/YamlCodeMirror.tsx:79:7",ref:w,className:`flex-1 min-h-0 h-full overflow-hidden rounded-lg border border-slate-700 ${m}`,children:P}):t.jsx("div",{"code-path":"src/components/kubernetes/YamlCodeMirror.tsx:86:5",className:`overflow-auto rounded-lg border border-slate-700 ${m}`,children:P})}function Rt({clusterCode:e,namespace:s,resource:r,name:n,onClose:c,onSaved:m,autoEdit:j=!1,inline:w=!1,initialYaml:g,readOnly:d,loadYamlFn:p,saveYamlFn:N,resourceHint:P}){const{toast:f}=me(),y=ke(r),S=d??y.readOnly,[F,A]=a.useState(g||""),[v,D]=a.useState(""),[C,R]=a.useState(""),[M,T]=a.useState(!g),[_,L]=a.useState(!1),[i,B]=a.useState(j&&!S),[E,k]=a.useState(!1),[u,o]=a.useState(!1),l=a.useCallback(async x=>{const{yaml:$}=x.includes(` ----`)?await Z(x):await be(x);return D($),R($),$},[]),h=a.useCallback(async()=>{if(g){A(g),await l(g),T(!1);return}T(!0);try{const x=p?await p():await O.getResourceYaml(e,s,r,n);A(x),await l(x)}catch(x){f({title:"获取YAML失败",description:x.message,variant:"destructive"});const $=`# Error: ${x.message}`;A($),D($),R($)}finally{T(!1)}},[e,s,r,n,g,p,l,f]);a.useEffect(()=>{h()},[h]);const V=()=>{R(v),B(!0),o(!1)},b=async()=>{B(!1),await h()},ye=async()=>{L(!0);try{const x=await we(C);N?await N(x):await O.updateResourceYaml(e,s,r,n,x),f({title:"保存成功",description:N?"多文档 YAML 已应用":`${r}/${n} 已更新`}),B(!1),A(x),D(x),R(x),m?.()}catch(x){f({title:"保存失败",description:x?.message||String(x),variant:"destructive"})}finally{L(!1)}},ee=()=>i?C:u?F:v,ge=async()=>{await navigator.clipboard.writeText(ee()),k(!0),setTimeout(()=>k(!1),2e3)},ve=()=>{Ye(de(r,s,n),ee()),f({title:"已下载",description:de(r,s,n)})},je=i?C:u?F:v,te=t.jsx(yt,{"code-path":"src/components/kubernetes/YamlViewer.tsx:133:5",editing:i,saving:_,copied:E,showRaw:u,compact:w,readOnly:S,onCopy:ge,onDownload:ve,onEdit:V,onCancel:b,onSave:ye,onToggleRaw:()=>o(x=>!x)}),se=M?t.jsx("div",{"code-path":"src/components/kubernetes/YamlViewer.tsx:150:5",className:"flex items-center justify-center h-full min-h-[200px]",children:t.jsx(z,{"code-path":"src/components/kubernetes/YamlViewer.tsx:151:7",className:"h-6 w-6 animate-spin text-slate-500"})}):t.jsx(vt,{"code-path":"src/components/kubernetes/YamlViewer.tsx:154:5",value:je,editing:i,fill:!0,fontSize:w?"12px":"13px",onChange:x=>i&&R(x)});return w?t.jsxs("div",{"code-path":"src/components/kubernetes/YamlViewer.tsx:165:7",className:"flex flex-col gap-3 min-h-[400px] h-[calc(100vh-220px)] max-h-[720px]",children:[t.jsxs("div",{"code-path":"src/components/kubernetes/YamlViewer.tsx:166:9",className:"flex items-center justify-between gap-3 flex-wrap shrink-0",children:[t.jsxs("p",{"code-path":"src/components/kubernetes/YamlViewer.tsx:167:11",className:"text-xs text-slate-500",children:[t.jsxs("code",{"code-path":"src/components/kubernetes/YamlViewer.tsx:168:13",className:"text-slate-400",children:[r,"/",n]}),P?t.jsxs("span",{"code-path":"src/components/kubernetes/YamlViewer.tsx:169:29",className:"text-slate-600",children:[" · ",P]}):null," · ",s]}),te]}),t.jsx("div",{"code-path":"src/components/kubernetes/YamlViewer.tsx:174:9",className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:se})]}):t.jsx(Qe,{"code-path":"src/components/kubernetes/YamlViewer.tsx:180:5",onClose:c,children:t.jsxs("div",{"code-path":"src/components/kubernetes/YamlViewer.tsx:181:7",className:"bg-slate-900 border border-slate-700 rounded-xl w-[92vw] max-w-5xl h-[85vh] flex flex-col shadow-2xl",onClick:x=>x.stopPropagation(),children:[t.jsxs("div",{"code-path":"src/components/kubernetes/YamlViewer.tsx:185:9",className:"flex items-center justify-between p-4 border-b border-slate-700 gap-3 shrink-0",children:[t.jsxs("div",{"code-path":"src/components/kubernetes/YamlViewer.tsx:186:11",className:"min-w-0 flex-1",children:[t.jsxs("h2",{"code-path":"src/components/kubernetes/YamlViewer.tsx:187:13",className:"text-lg font-bold text-slate-100 truncate",title:`${y.label} YAML — ${n}`,children:[y.label," YAML — ",n,S&&t.jsx("span",{"code-path":"src/components/kubernetes/YamlViewer.tsx:189:28",className:"ml-2 text-xs font-normal text-slate-500",children:"只读"})]}),t.jsxs("p",{"code-path":"src/components/kubernetes/YamlViewer.tsx:191:13",className:"text-xs text-slate-500 truncate",title:`${s} · ${e}`,children:[s," · ",e]})]}),t.jsxs("div",{"code-path":"src/components/kubernetes/YamlViewer.tsx:193:11",className:"flex items-center gap-2 shrink-0",children:[te,t.jsx(Y,{"code-path":"src/components/kubernetes/YamlViewer.tsx:195:13",variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400",onClick:c,children:t.jsx(I,{"code-path":"src/components/kubernetes/YamlViewer.tsx:195:102",className:"h-4 w-4"})})]})]}),t.jsx("div",{"code-path":"src/components/kubernetes/YamlViewer.tsx:198:9",className:"flex-1 min-h-0 flex flex-col overflow-hidden p-4",children:se})]})})}const jt=[{value:"sh",label:"/bin/sh"},{value:"bash",label:"/bin/bash"}];function Mt({open:e,onOpenChange:s,clusterId:r,namespace:n,podName:c,containers:m=[],initialContainer:j}){const{toast:w}=me(),g=a.useRef(null),d=a.useRef(null),p=a.useRef(null),N=a.useRef(null),P=a.useRef(!1),f=a.useRef(!1),[y,S]=a.useState("idle"),[F,A]=a.useState(!1),[v,D]=a.useState(j||m[0]||""),[C,R]=a.useState("sh");a.useEffect(()=>{e||(A(!1),P.current=!1)},[e]),a.useEffect(()=>{e&&!v&&m.length>0&&D(j||m[0])},[e,m,j,v]);const M=a.useCallback(()=>{if(!d.current){console.error("[PodExec:connect] ABORT: termRef.current is null");return}const i=d.current;if(p.current){try{p.current.close()}catch{}p.current=null}S("connecting"),i.clear(),i.writeln(`\x1B[36m[正在连接 ${c}${v?"/"+v:""} shell=${C} ...]\x1B[0m`);const B=O.buildPodExecWsUrl(r,n,c,v||void 0,C),E=new WebSocket(B);p.current=E,E.onopen=()=>{S("connected"),i.reset();try{const{cols:u,rows:o}=i;E.send(JSON.stringify({status:1,cols:u,rows:o}))}catch(u){console.error("[PodExec:connect] resize error:",u)}const k=()=>{try{i.focus()}catch{}};k(),setTimeout(k,100),setTimeout(k,300)},E.onmessage=k=>{try{const u=JSON.parse(k.data);if(u.status===0&&typeof u.data=="string")i.write(u.data);else if(u.status===2||u.error){const o=u.data||u.message||u.error||"执行错误";if(o.includes("not found")&&C==="bash"){i.writeln(`\r -\x1B[33m⚠ bash 不可用,请切换 /bin/sh 后重连。\x1B[0m`),f.current=!0;return}i.write(o.includes("\x1B")?o:`\r -\x1B[31m${o}\x1B[0m\r -`)}}catch{typeof k.data=="string"&&i.write(k.data)}},E.onclose=k=>{S(u=>u==="error"?u:"closed"),f.current||i.write(`\r -\x1B[33m[连接已关闭]\x1B[0m\r -`)},E.onerror=k=>{console.error("[PodExec:connect] WS error event fired, readyState=",E.readyState,"type=",k.type),S("error"),i.write(`\r -\x1B[31m[连接发生错误]\x1B[0m\r -`)}},[r,n,c,v,C]);a.useEffect(()=>{if(!e)return;if(!r){console.error("[PodExec:initEffect] ABORT: clusterId is falsy:",r);return}if(!c){console.error("[PodExec:initEffect] ABORT: podName is falsy:",c);return}let i=!1,B=0;const E=performance.now(),k=()=>{if(i)return;const u=g.current;if(!u){B++,B<20?requestAnimationFrame(k):console.error("[PodExec:tryInit] FAILED: containerRef still null after 20 retries (",Math.round(performance.now()-E),"ms)");return}const o=new Ge.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,scrollback:5e3,theme:{background:"#0f172a",foreground:"#e2e8f0",cursor:"#38bdf8",selectionBackground:"#1e40af",black:"#1e293b",red:"#ef4444",green:"#10b981",yellow:"#f59e0b",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#e2e8f0",brightBlack:"#475569",brightRed:"#f87171",brightGreen:"#34d399",brightYellow:"#fbbf24",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#f8fafc"}}),l=new Xe.FitAddon;o.loadAddon(l),d.current=o,N.current=l,o.onData(h=>{p.current&&p.current.readyState===WebSocket.OPEN?p.current.send(JSON.stringify({status:0,data:h})):console.warn("[PodExec:term] TX dropped — WS not open, readyState=",p.current?.readyState)}),o.open(u),requestAnimationFrame(()=>{try{l.fit()}catch{}}),P.current=!0,M()};return requestAnimationFrame(k),()=>{i=!0}},[e,r,c]),a.useEffect(()=>{if(!e){try{p.current?.close()}catch{}try{d.current?.dispose()}catch{}d.current=null,p.current=null,N.current=null,P.current=!1,S("idle")}},[e]),a.useEffect(()=>{e&&d.current&&P.current&&M()},[v,C]),a.useEffect(()=>{if(!e)return;const i=g.current;if(!i)return;let B;const E=new ResizeObserver(()=>{clearTimeout(B),B=setTimeout(()=>{if(N.current&&d.current)try{N.current.fit(),d.current.focus();const{cols:k,rows:u}=d.current;p.current?.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({status:1,cols:k,rows:u}))}catch{}},60)});return E.observe(i),()=>{clearTimeout(B),E.disconnect()}},[e,F]);const T=y==="connected"?"bg-emerald-400":y==="error"?"bg-red-400":y==="closed"?"bg-slate-500":"bg-amber-400",_=y==="connected"?"已连接":y==="connecting"?"连接中":y==="error"?"连接错误":y==="closed"?"已断开":"空闲",L=a.useCallback(()=>{try{d.current?.focus()}catch{}},[]);return t.jsx(Te,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:279:5",open:e,onOpenChange:s,children:t.jsxs(Fe,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:280:7",showCloseButton:!1,className:re("bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] p-0 gap-0","!duration-0 !transition-none",F?"!max-w-none !w-screen !h-screen !rounded-none !translate-x-0 !translate-y-0 !left-0 !top-0":""),style:F?{maxWidth:"100vw",width:"100vw",height:"100vh"}:{maxWidth:"960px",width:"92vw"},children:[t.jsxs(Be,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:289:9",className:"sr-only",children:["exec — ",c]}),t.jsx(Ce,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:290:9",className:"sr-only",children:"进入 Pod 容器执行命令"}),t.jsxs("div",{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:293:9",className:"flex items-center justify-between gap-2 px-4 py-2 border-b border-[var(--dg-border)] flex-wrap",children:[t.jsxs("div",{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:294:11",className:"flex items-center gap-2 text-sm min-w-0",children:[t.jsx("div",{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:295:13",className:re("w-2 h-2 rounded-full shrink-0",T),title:_}),t.jsx(Oe,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:296:13",className:"h-4 w-4 text-blue-400 shrink-0"}),t.jsxs("span",{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:297:13",className:"text-[var(--dg-text-primary)] font-medium truncate",children:["exec — ",c]}),y==="connecting"&&t.jsx(z,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:298:44",className:"h-3 w-3 animate-spin text-[var(--dg-text-muted)]"}),t.jsx("span",{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:299:13",className:"text-xs text-[var(--dg-text-muted)]",children:_})]}),t.jsxs("div",{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:301:11",className:"flex items-center gap-2",children:[m.length>0&&t.jsxs(oe,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:303:15",value:v,onValueChange:D,children:[t.jsxs(ne,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:304:17",className:"h-8 w-[150px] text-xs bg-[var(--dg-bg-hover)] border-[var(--dg-border)]",children:[t.jsx($e,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:305:19",className:"h-3 w-3 mr-1 text-[var(--dg-text-muted)]"}),t.jsx(ae,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:306:19",placeholder:"容器"})]}),t.jsx(ce,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:308:17",children:m.map(i=>t.jsx(le,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:308:55",value:i,children:i},i))})]}),t.jsxs(oe,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:311:13",value:C,onValueChange:R,children:[t.jsx(ne,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:312:15",className:"h-8 w-[110px] text-xs bg-[var(--dg-bg-hover)] border-[var(--dg-border)]",children:t.jsx(ae,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:313:17"})}),t.jsx(ce,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:315:15",children:jt.map(i=>t.jsx(le,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:315:47",value:i.value,children:i.label},i.value))})]}),t.jsx(Y,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:317:13",variant:"ghost",size:"sm",className:"h-8 px-2 text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)]",onClick:()=>{M(),w({title:"正在重连…"})},title:"重连",children:t.jsx(_e,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:319:15",className:"h-3.5 w-3.5"})}),t.jsx("button",{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:321:13",onClick:()=>A(!F),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",title:F?"退出全屏":"全屏",children:F?t.jsx(Le,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:322:29",className:"h-4 w-4"}):t.jsx(Ve,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:322:65",className:"h-4 w-4"})}),t.jsx("button",{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:324:13",onClick:()=>s(!1),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",title:"关闭",children:t.jsx(I,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:325:15",className:"h-4 w-4"})})]})]}),t.jsx("div",{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:331:9",ref:g,className:"bg-[#0f172a] cursor-text",style:{height:F?"calc(100vh - 49px)":"480px"},onClick:L})]})})}function Dt({open:e,onOpenChange:s,clusterCode:r,namespace:n,podName:c,containers:m=[],initialContainer:j}){const[w,g]=a.useState(j||m[0]||""),[d,p]=a.useState("/"),[N,P]=a.useState([]),[f,y]=a.useState(!1),[S,F]=a.useState(""),[A,v]=a.useState(null),[D,C]=a.useState(!1),R=a.useRef(null),M=a.useRef(!1),T=a.useCallback(async o=>{y(!0),F(""),v(null);try{const l=await O.listPodFiles(r,n,c,o,w||void 0),V=(l?.entries||l?.files||l?.data?.entries||l?.data?.files||(Array.isArray(l)?l:[])).map(b=>({name:b.name??b.Name??"",isDir:!!(b.isDir??b.is_dir??b.IsDir??b.dir??b.directory),size:typeof b.size=="number"?b.size:b.Size?Number(b.Size):void 0,modTime:b.modTime??b.mod_time??b.ModTime??b.mtime??b.modified})).filter(b=>b.name&&b.name!==".");P(V),p(o)}catch(l){F(l.message||"加载文件列表失败"),P([])}finally{y(!1)}},[r,n,c,w]);a.useEffect(()=>{e?(async()=>{if(M.current){T(d);return}y(!0);try{const l=await O.execPod(r,n,c,["pwd"],w||void 0),h=(l?.stdout||l?.data?.stdout||"").trim(),V=h&&h.startsWith("/")?h:"/";M.current=!0,p(V),T(V)}catch{M.current=!0,T("/")}})():M.current=!1},[e,w]);const _=o=>{if(o.isDir){const l=d==="/"?`/${o.name}`:`${d}/${o.name}`;T(l)}else L(o.name)},L=async o=>{const l=d==="/"?`/${o}`:`${d}/${o}`;try{const h=await O.readPodFileText(r,n,c,l,w||void 0);v({file:o,content:h})}catch(h){v({file:o,content:`读取失败: ${h.message}`})}},i=o=>{const l=d==="/"?`/${o}`:`${d}/${o}`,h=O.buildPodFileDownloadUrl(r,n,c,l,w||void 0);window.open(h,"_blank")},B=async o=>{const l=o.target.files?.[0];if(l){C(!0);try{await O.uploadPodFile(r,n,c,d,l,w||void 0),T(d)}catch(h){F(`上传失败: ${h.message}`)}finally{C(!1),R.current&&(R.current.value="")}}},E=()=>{if(d==="/")return;const o=d.split("/").filter(Boolean);o.pop(),T(o.length===0?"/":`/${o.join("/")}`)},k=o=>o==null?"-":o<1024?`${o} B`:o<1024*1024?`${(o/1024).toFixed(1)} KB`:`${(o/(1024*1024)).toFixed(1)} MB`,u=d.split("/").filter(Boolean);return e?t.jsx("div",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:164:5",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70",onClick:()=>s(!1),children:t.jsxs("div",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:165:7",className:"bg-slate-900 border border-slate-700 rounded-xl w-[90vw] max-w-5xl h-[80vh] flex flex-col shadow-2xl",onClick:o=>o.stopPropagation(),children:[t.jsxs("div",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:170:9",className:"flex items-center justify-between p-3 border-b border-slate-700 shrink-0 gap-3",children:[t.jsxs("div",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:171:11",className:"flex items-center gap-2 min-w-0 flex-1",children:[t.jsx(ze,{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:172:13",className:"h-4 w-4 shrink-0 text-amber-400"}),t.jsxs("span",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:173:13",className:"text-sm font-semibold text-slate-200 truncate",title:c,children:["文件: ",c]}),t.jsx(qe,{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:174:13",variant:"outline",className:"border-slate-700 text-slate-400 text-[10px] shrink-0",children:n})]}),t.jsxs("div",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:176:11",className:"flex items-center gap-2",children:[m.length>0&&t.jsx("select",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:178:15",value:w,onChange:o=>{g(o.target.value)},className:"bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-2 py-1",children:m.map(o=>t.jsx("option",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:183:40",value:o,children:o},o))}),t.jsx(Y,{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:186:13",variant:"ghost",size:"icon",className:"h-7 w-7 text-slate-400",onClick:()=>s(!1),children:t.jsx(I,{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:187:15",className:"h-4 w-4"})})]})]}),t.jsxs("div",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:193:9",className:"flex items-center justify-between p-2 border-b border-slate-800 shrink-0",children:[t.jsxs("div",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:194:11",className:"flex items-center gap-1 text-xs text-slate-400",children:[t.jsx(Y,{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:195:13",variant:"ghost",size:"icon",className:"h-6 w-6 text-slate-500",onClick:E,disabled:d==="/",children:t.jsx(Ie,{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:196:15",className:"h-3.5 w-3.5"})}),t.jsx("button",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:198:13",className:"hover:text-slate-200",onClick:()=>T("/"),children:"root"}),u.map((o,l)=>{const h=`/${u.slice(0,l+1).join("/")}`;return t.jsxs("span",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:202:17",className:"flex items-center gap-1",children:[t.jsx(Ue,{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:203:19",className:"h-3 w-3"}),t.jsx("button",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:204:19",className:"hover:text-slate-200",onClick:()=>T(h),children:o})]},h)})]}),t.jsxs("div",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:209:11",className:"flex items-center gap-2",children:[t.jsx("input",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:210:13",type:"file",ref:R,className:"hidden",onChange:B}),t.jsxs(Y,{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:211:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:()=>R.current?.click(),disabled:D,children:[D?t.jsx(z,{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:212:28",className:"h-3 w-3 animate-spin mr-1"}):t.jsx(We,{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:212:80",className:"h-3 w-3 mr-1"}),"上传"]}),t.jsx(Y,{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:214:13",size:"sm",variant:"outline",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:()=>T(d),disabled:f,children:f?t.jsx(z,{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:215:26",className:"h-3 w-3 animate-spin"}):t.jsx(He,{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:215:73",className:"h-3 w-3"})})]})]}),t.jsxs("div",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:221:9",className:"flex-1 overflow-hidden flex",children:[t.jsxs("div",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:223:11",className:`${A?"w-1/2":"w-full"} overflow-auto p-2 border-r border-slate-800`,children:[S&&t.jsx("p",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:224:23",className:"text-xs text-red-400 p-2",children:S}),f?t.jsx("div",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:226:15",className:"flex items-center justify-center h-32",children:t.jsx(z,{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:226:70",className:"h-5 w-5 animate-spin text-slate-500"})}):N.length===0?t.jsx("p",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:228:15",className:"text-xs text-slate-500 p-4 text-center",children:"空目录"}):t.jsx("div",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:230:15",className:"space-y-0.5",children:N.sort((o,l)=>o.isDir===l.isDir?o.name.localeCompare(l.name):o.isDir?-1:1).map(o=>t.jsxs("div",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:232:19",className:"flex items-center gap-2 px-2 py-1.5 rounded hover:bg-slate-800/50 cursor-pointer group",onClick:()=>_(o),children:[o.isDir?t.jsx(Je,{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:238:23",className:"h-4 w-4 text-blue-400 shrink-0"}):t.jsx(Ke,{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:240:23",className:"h-4 w-4 text-slate-500 shrink-0"}),t.jsx("span",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:242:21",className:`text-xs truncate ${o.isDir?"text-blue-300":"text-slate-300"}`,children:o.name}),!o.isDir&&t.jsx("span",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:246:23",className:"text-[10px] text-slate-600 ml-auto shrink-0",children:k(o.size)}),!o.isDir&&t.jsx(Y,{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:249:23",variant:"ghost",size:"icon",className:"h-5 w-5 opacity-0 group-hover:opacity-100 text-slate-400 hover:text-emerald-400 shrink-0",onClick:l=>{l.stopPropagation(),i(o.name)},title:"下载",children:t.jsx(pe,{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:254:25",className:"h-3 w-3"})})]},o.name))})]}),A&&t.jsxs("div",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:265:13",className:"w-1/2 flex flex-col overflow-hidden",children:[t.jsxs("div",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:266:15",className:"flex items-center justify-between p-2 border-b border-slate-800 shrink-0",children:[t.jsx("span",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:267:17",className:"text-xs text-slate-300 font-mono",children:A.file}),t.jsx(Y,{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:268:17",variant:"ghost",size:"icon",className:"h-6 w-6 text-slate-400",onClick:()=>v(null),children:t.jsx(I,{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:269:19",className:"h-3.5 w-3.5"})})]}),t.jsx("div",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:272:15",className:"flex-1 overflow-auto p-3",children:t.jsx("pre",{"code-path":"src/components/kubernetes/PodFileBrowser.tsx:273:17",className:"text-xs text-slate-300 font-mono whitespace-pre-wrap break-all bg-slate-950 rounded p-3",children:A.content||"(空文件)"})})]})]})]})}):null}export{Qe as M,Mt as P,Rt as Y,Dt as a,vt as b,be as c,yt as d,wt as e,we as f,ke as g,Z as h,he as i,At as k,Q as m,X as p,de as y}; diff --git a/backend/static/assets/PodMetricsPage-B8c-1jY7.js b/backend/static/assets/PodMetricsPage-B8c-1jY7.js deleted file mode 100644 index d9b4b7a..0000000 --- a/backend/static/assets/PodMetricsPage-B8c-1jY7.js +++ /dev/null @@ -1 +0,0 @@ -import{r as c,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{C as i,a as x}from"./card-BIfzBCEy.js";import{g as H,i as L,L as N,B as U}from"./index-Dungj95X.js";import{B as V}from"./badge-CGJlVD3L.js";import{S as f,a as v,b as C,c as y,d as P}from"./select-CiTqGGhE.js";import{T as W,a as F,b as u,c as d,d as z,e as n}from"./table-B2F10oba.js";import{k as b}from"./index-drGq01ok.js";import{f as S,A as D,R as G,g as K,H as q}from"./vendor-icons-DmqcWdzX.js";import"./index-5FEebgvX.js";function te(){const{clusterCode:w}=H(),g=L(),[m,M]=c.useState(!1),[p,k]=c.useState([]),[A,T]=c.useState([]),[$,E]=c.useState([]),[l,B]=c.useState("all"),[a,j]=c.useState(w||"");c.useEffect(()=>{b.getClusters().then(s=>{const t=s?.list||[];if(T(t),!a&&t.length>0){const r=t[0].code||String(t[0].id);j(r),g(`/kubernetes/${r}/metrics/pods`,{replace:!0})}}).catch(()=>{})},[]),c.useEffect(()=>{a&&b.getNamespaces(a).then(s=>{E(Array.isArray(s)?s:s?.list||s?.data||[])}).catch(()=>{})},[a]);const h=c.useCallback(async()=>{if(a){M(!0);try{const s=l==="all"?void 0:l,t=await b.getPodMetrics(a,s);k(Array.isArray(t)?t:t?.list||[])}catch{k([])}finally{M(!1)}}},[a,l]);c.useEffect(()=>{h()},[h]);const o=c.useMemo(()=>p.flatMap(s=>(s.containers||[]).map(t=>({pod:s.name,namespace:s.namespace,container:t.name,cpu:t.cpu||"0m",memory:t.memory||"0Mi"}))),[p]),I=c.useMemo(()=>o.reduce((s,t)=>s+(parseInt(t.cpu)||0),0),[o]),R=c.useMemo(()=>{let s=0;return o.forEach(t=>{const r=t.memory;r.endsWith("Mi")?s+=parseInt(r):r.endsWith("Ki")?s+=parseInt(r)/1024:r.endsWith("Gi")&&(s+=parseInt(r)*1024)}),s},[o]);return e.jsxs("div",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:82:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:83:7",className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx(N,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:84:9",to:"/kubernetes",className:"hover:text-slate-300",children:"集群"}),a&&e.jsxs(e.Fragment,{children:[e.jsx(S,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:85:29",className:"h-3 w-3"}),e.jsx(N,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:85:65",to:`/kubernetes/${a}`,className:"hover:text-slate-300",children:a})]}),e.jsx(S,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:86:9",className:"h-3 w-3"}),e.jsx("span",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:86:45",className:"text-slate-300",children:"Pod 资源用量"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:89:7",className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("h2",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:90:9",className:"text-lg font-semibold text-slate-100 flex items-center gap-2",children:[e.jsx(D,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:90:86",className:"h-5 w-5 text-blue-400"}),"Pod 资源用量"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:91:9",className:"flex items-center gap-2",children:[e.jsxs(f,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:92:11",value:a,onValueChange:s=>{j(s),g(`/kubernetes/${s}/metrics/pods`)},children:[e.jsx(v,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:93:13",className:"w-44 h-8 text-xs bg-slate-800 border-slate-700",children:e.jsx(C,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:93:87"})}),e.jsx(y,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:94:13",className:"bg-slate-800 border-slate-700",children:A.map(s=>e.jsx(P,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:95:46",value:s.code||String(s.id),className:"text-xs",children:s.name||s.code},s.id))})]}),e.jsxs(f,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:98:11",value:l,onValueChange:B,children:[e.jsx(v,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:99:13",className:"w-36 h-8 text-xs bg-slate-800 border-slate-700",children:e.jsx(C,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:99:87",placeholder:"所有命名空间"})}),e.jsxs(y,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:100:13",className:"bg-slate-800 border-slate-700",children:[e.jsx(P,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:101:15",value:"all",className:"text-xs",children:"所有命名空间"}),$.map(s=>e.jsx(P,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:102:36",value:s,className:"text-xs",children:s},s))]})]}),e.jsxs(U,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:105:11",variant:"outline",size:"sm",className:"h-8 border-slate-700 text-slate-300 text-xs",onClick:h,disabled:m,children:[e.jsx(G,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:106:13",className:`h-3 w-3 mr-1 ${m?"animate-spin":""}`}),"刷新"]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:112:7",className:"grid grid-cols-3 gap-3",children:[e.jsx(i,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:113:9",className:"bg-slate-900 border-slate-800",children:e.jsxs(x,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:113:57",className:"p-3 text-center",children:[e.jsx("p",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:114:11",className:"text-xs text-slate-500",children:"Pod 数"}),e.jsx("p",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:114:58",className:"text-xl font-bold text-slate-200",children:p.length})]})}),e.jsx(i,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:116:9",className:"bg-slate-900 border-slate-800",children:e.jsxs(x,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:116:57",className:"p-3 text-center",children:[e.jsx("p",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:117:11",className:"text-xs text-slate-500",children:"总 CPU"}),e.jsxs("p",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:117:58",className:"text-xl font-bold text-blue-400",children:[I,"m"]})]})}),e.jsx(i,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:119:9",className:"bg-slate-900 border-slate-800",children:e.jsxs(x,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:119:57",className:"p-3 text-center",children:[e.jsx("p",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:120:11",className:"text-xs text-slate-500",children:"总内存"}),e.jsxs("p",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:120:56",className:"text-xl font-bold text-emerald-400",children:[R.toFixed(0),"Mi"]})]})})]}),e.jsx(i,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:124:7",className:"bg-slate-900 border-slate-800",children:e.jsx(x,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:125:9",className:"p-0",children:e.jsxs(W,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:126:11",children:[e.jsx(F,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:127:13",children:e.jsxs(u,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:127:26",className:"border-slate-800 hover:bg-transparent",children:[e.jsx(d,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:128:15",className:"text-slate-400",children:"Pod"}),e.jsx(d,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:129:15",className:"text-slate-400",children:"命名空间"}),e.jsx(d,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:130:15",className:"text-slate-400",children:"容器"}),e.jsxs(d,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:131:15",className:"text-slate-400",children:[e.jsx(K,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:131:53",className:"h-3 w-3 inline mr-1"}),"CPU"]}),e.jsxs(d,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:132:15",className:"text-slate-400",children:[e.jsx(q,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:132:53",className:"h-3 w-3 inline mr-1"}),"Memory"]})]})}),e.jsx(z,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:134:13",children:o.length===0?e.jsx(u,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:136:17",children:e.jsxs(n,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:136:27",colSpan:5,className:"text-center text-slate-500 py-8",children:["暂无数据",m?e.jsx("span",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:136:109",className:"animate-spin inline-block ml-2",children:"⏳"}):""]})}):o.map((s,t)=>e.jsxs(u,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:138:17",className:"border-slate-800 hover:bg-slate-800/30",children:[e.jsx(n,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:139:19",className:"font-medium text-slate-200 text-sm",children:s.pod}),e.jsx(n,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:140:19",children:e.jsx(V,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:140:30",variant:"outline",className:"border-slate-700 text-slate-400 text-xs",children:s.namespace})}),e.jsx(n,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:141:19",className:"text-sm text-slate-400",children:s.container}),e.jsx(n,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:142:19",className:"text-sm text-blue-400",children:s.cpu}),e.jsx(n,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:143:19",className:"text-sm text-emerald-400",children:s.memory})]},`${s.pod}-${s.container}-${t}`))})]})})})]})}export{te as default}; diff --git a/backend/static/assets/ProfilePage-CG_6vD9d.js b/backend/static/assets/ProfilePage-CG_6vD9d.js deleted file mode 100644 index 1097252..0000000 --- a/backend/static/assets/ProfilePage-CG_6vD9d.js +++ /dev/null @@ -1,5 +0,0 @@ -import{r as c,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{C as z,b as F,c as H,d as oe,a as R}from"./card-BIfzBCEy.js";import{f as je,r as q,u as v,B as l,m as Q,s as ve,D as W,a as Y,b as Z,c as ee,d as se,e as te,v as ce,o as be}from"./index-Dungj95X.js";import{I as k}from"./input-CXoUQQLm.js";import{L as C}from"./label-CMpUoC87.js";import{B as _}from"./badge-CGJlVD3L.js";import{u as ne}from"./use-toast-DNZLibQY.js";import{C as I}from"./code-snippet-block-E9P2jHS4.js";import{aj as ae,P as re,L as D,ak as Se,x as Ne,al as Pe,am as Ke,an as we,b as ke,A as Ce,ao as _e,U as De,j as Te}from"./vendor-icons-DmqcWdzX.js";function B(t){if(!t)return"—";const a=new Date(t);return Number.isNaN(a.getTime())?"—":a.toLocaleString()}function T(t=12){const a=new Date;return a.setMonth(a.getMonth()+t),a.toISOString().slice(0,10)}function Le(t){if(!t)return T();const a=new Date(t);return Number.isNaN(a.getTime())?T():a.toISOString().slice(0,10)}function $e(t,a){if(!t||!a)return{pct:0,daysLeft:null};const n=new Date(t).getTime(),s=new Date(a).getTime(),x=Date.now();if(s<=n)return{pct:0,daysLeft:0};const y=Math.max(0,Math.ceil((s-x)/864e5));return{pct:Math.min(100,Math.max(0,(x-n)/(s-n)*100)),daysLeft:y}}function Oe(t){return t?t.length<=10?t:`${t.slice(0,6)}…${t.slice(-4)}`:"—"}function Me(){const{toast:t}=ne(),a=je(),n=ve(),[s,x]=c.useState(null),[y,u]=c.useState(!0),[p,d]=c.useState(!1),[A,N]=c.useState(!1),[P,f]=c.useState(""),[K,m]=c.useState(!1),[j,r]=c.useState("create"),[L,$]=c.useState(""),[w,O]=c.useState(T()),[ie,M]=c.useState(!1),[de,pe]=c.useState(""),U=c.useCallback(async()=>{u(!0);try{const i=q();i&&f(i);const S=await v.getApiAccessKey().catch(()=>({has_token:!1}));x(S)}finally{u(!1)}},[]);c.useEffect(()=>{U()},[U]);const h=P||q(),le=s?.access_key_mask||(s?.prefix?`${s.prefix}.•••••••••••••••••••••••••••••••••`:""),{pct:xe,daysLeft:me}=c.useMemo(()=>$e(s?.created_at,s?.expires_at),[s?.created_at,s?.expires_at]),g=s?.days_left??me,b=!!s?.expired||s?.status==="expired"||g!=null&&g<=0,E=()=>{r("create"),$(""),O(T()),m(!0)},ue=()=>{r("edit"),$(s?.description||""),O(Le(s?.expires_at)),m(!0)},he=async()=>{if(j==="edit"){d(!0);try{const o=await v.updateApiAccessKey({description:L,expires_at:w});x(o),m(!1),t({title:"凭证信息已更新"})}catch(o){t({title:"更新失败",description:o?.message||String(o),variant:"destructive"})}finally{d(!1)}return}const i=!!s?.has_token;if(await a({title:i?"轮换凭证":"签发凭证",description:i?"旧凭证将立即作废,是否继续?":"凭证明文仅显示一次,请妥善保存。",confirmText:i?"轮换":"签发",variant:i?"destructive":"default"})){d(!0);try{const o=await v.regenerateApiAccessKey({description:L,expires_at:w});f(o.token),ce(o.token),pe(o.token),M(!0),m(!1),x({has_token:!0,key_id:o.key_id,prefix:o.prefix,access_key_mask:`${o.prefix}.•••••••••••••••••••••••••••••••••`,description:o.description,created_at:o.created_at,expires_at:o.expires_at,status:"active",expired:!1,days_left:Math.ceil((new Date(o.expires_at).getTime()-Date.now())/864e5)}),t({title:"凭证已签发",description:"已保存至本浏览器,请立即复制"})}catch(o){t({title:"签发失败",description:o?.message||String(o),variant:"destructive"})}finally{d(!1)}}},ge=async()=>{if(await a({title:"吊销凭证",description:"吊销后 Pipeline / curl 调用将全部失败,是否继续?",confirmText:"吊销",variant:"destructive"})){d(!0);try{await v.revokeApiAccessKey(),f(""),ce(""),x({has_token:!1}),t({title:"凭证已吊销"})}catch(S){t({title:"吊销失败",description:S?.message||String(S),variant:"destructive"})}finally{d(!1)}}},X=h?`X-AIOps-Access-Key: ${h}`:"X-AIOps-Access-Key: <你的访问凭证>",G="test-k8s",J="default",V="demo-jar",ye=`curl -X POST '${n}/kubernetes/${G}/namespace/${J}/deployments/${V}/update-image' \\ - -H '${X}' \\ - -H 'Content-Type: application/json' \\ - -d '{"image":"harbor.example.com/app:v1.0","container_name":"main"}'`,Ae=`curl -X POST '${n}/kubernetes/${G}/namespace/${J}/deployments/${V}/restart' \\ - -H '${X}'`,fe=b?"bg-red-500":g!=null&&g<=30?"bg-amber-400":"bg-[var(--dg-blue)]";return e.jsxs(e.Fragment,{children:[e.jsxs(z,{"code-path":"src/components/user/ApiAccessKeySection.tsx:229:7",className:"dg-card border-[var(--dg-blue)]/20",children:[e.jsxs(F,{"code-path":"src/components/user/ApiAccessKeySection.tsx:230:9",className:"flex flex-row items-start justify-between gap-4 space-y-0",children:[e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:231:11",children:[e.jsxs(H,{"code-path":"src/components/user/ApiAccessKeySection.tsx:232:13",className:"text-base flex items-center gap-2 text-[var(--dg-text-primary)]",children:[e.jsx(ae,{"code-path":"src/components/user/ApiAccessKeySection.tsx:233:15",className:"h-4 w-4 text-[var(--dg-blue)]"}),"CI/CD 访问凭证",e.jsx(_,{"code-path":"src/components/user/ApiAccessKeySection.tsx:235:15",className:"text-[10px] bg-[var(--dg-blue)]/15 text-[var(--dg-blue)] border-[var(--dg-blue)]/30",children:"长期有效"})]}),e.jsx(oe,{"code-path":"src/components/user/ApiAccessKeySection.tsx:237:13",className:"text-xs mt-1",children:"每人唯一凭证,Deployment 发布脚本自动引用,不随登录会话过期。"})]}),!y&&!s?.has_token&&e.jsxs(l,{"code-path":"src/components/user/ApiAccessKeySection.tsx:242:13",size:"sm",onClick:E,disabled:p,children:[e.jsx(re,{"code-path":"src/components/user/ApiAccessKeySection.tsx:243:15",className:"h-4 w-4 mr-1"}),"签发凭证"]})]}),e.jsxs(R,{"code-path":"src/components/user/ApiAccessKeySection.tsx:247:9",className:"space-y-4",children:[y?e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:249:13",className:"flex items-center gap-2 py-8 text-sm text-[var(--dg-text-muted)] justify-center",children:[e.jsx(D,{"code-path":"src/components/user/ApiAccessKeySection.tsx:250:15",className:"h-4 w-4 animate-spin"}),"加载中…"]}):s?.has_token?e.jsx("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:253:13",className:"rounded-xl border border-[var(--dg-border)] bg-[var(--dg-bg-tertiary)]/40 overflow-hidden",children:e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:255:15",className:"flex",children:[e.jsx("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:256:17",className:Q("w-1 shrink-0",b?"bg-red-500":g!=null&&g<=30?"bg-amber-400":"bg-gradient-to-b from-[var(--dg-blue)] to-[var(--dg-purple)]")}),e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:260:17",className:"flex-1 p-4 space-y-4",children:[e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:261:19",className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:262:21",className:"space-y-1 min-w-0 flex-1",children:[e.jsx("p",{"code-path":"src/components/user/ApiAccessKeySection.tsx:263:23",className:"text-[10px] uppercase tracking-wider text-[var(--dg-text-muted)]",children:"凭证字符串"}),e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:264:23",className:"flex items-center gap-2",children:[e.jsx("code",{"code-path":"src/components/user/ApiAccessKeySection.tsx:265:25",className:"flex-1 min-w-0 text-xs font-mono text-[var(--dg-text-primary)] bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded-md px-3 py-2 truncate block",children:A&&h?h:le}),h&&e.jsx(l,{"code-path":"src/components/user/ApiAccessKeySection.tsx:269:27",variant:"outline",size:"icon",className:"h-9 w-9 shrink-0 border-[var(--dg-border)]",onClick:()=>N(!A),title:A?"隐藏":"显示",children:A?e.jsx(Se,{"code-path":"src/components/user/ApiAccessKeySection.tsx:276:42",className:"h-3.5 w-3.5"}):e.jsx(Ne,{"code-path":"src/components/user/ApiAccessKeySection.tsx:276:79",className:"h-3.5 w-3.5"})})]})]}),e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:281:21",className:"flex flex-wrap gap-1.5 shrink-0",children:[e.jsxs(l,{"code-path":"src/components/user/ApiAccessKeySection.tsx:282:23",variant:"outline",size:"sm",className:"h-8 text-xs border-[var(--dg-border)]",onClick:ue,disabled:p,children:[e.jsx(Pe,{"code-path":"src/components/user/ApiAccessKeySection.tsx:283:25",className:"h-3 w-3 mr-1"}),"调整"]}),e.jsxs(l,{"code-path":"src/components/user/ApiAccessKeySection.tsx:285:23",variant:"outline",size:"sm",className:"h-8 text-xs border-[var(--dg-border)]",onClick:E,disabled:p,children:[e.jsx(Ke,{"code-path":"src/components/user/ApiAccessKeySection.tsx:286:25",className:"h-3 w-3 mr-1"}),"轮换"]}),e.jsxs(l,{"code-path":"src/components/user/ApiAccessKeySection.tsx:288:23",variant:"outline",size:"sm",className:"h-8 text-xs border-red-500/30 text-red-400",onClick:ge,disabled:p,children:[e.jsx(we,{"code-path":"src/components/user/ApiAccessKeySection.tsx:289:25",className:"h-3 w-3 mr-1"}),"吊销"]})]})]}),e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:294:19",className:"grid grid-cols-2 sm:grid-cols-3 gap-x-6 gap-y-3 text-xs",children:[e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:295:21",children:[e.jsx("p",{"code-path":"src/components/user/ApiAccessKeySection.tsx:296:23",className:"text-[var(--dg-text-muted)] mb-0.5",children:"用途说明"}),e.jsx("p",{"code-path":"src/components/user/ApiAccessKeySection.tsx:297:23",className:"text-[var(--dg-text-secondary)]",children:s.description||"未填写"})]}),e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:299:21",children:[e.jsx("p",{"code-path":"src/components/user/ApiAccessKeySection.tsx:300:23",className:"text-[var(--dg-text-muted)] mb-0.5",children:"凭证标识"}),e.jsx("p",{"code-path":"src/components/user/ApiAccessKeySection.tsx:301:23",className:"font-mono text-[var(--dg-text-secondary)]",title:s.key_id,children:Oe(s.key_id)})]}),e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:303:21",children:[e.jsx("p",{"code-path":"src/components/user/ApiAccessKeySection.tsx:304:23",className:"text-[var(--dg-text-muted)] mb-0.5",children:"签发时间"}),e.jsx("p",{"code-path":"src/components/user/ApiAccessKeySection.tsx:305:23",className:"text-[var(--dg-text-secondary)]",children:B(s.created_at)})]})]}),e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:310:19",className:"space-y-1.5",children:[e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:311:21",className:"flex items-center justify-between text-[11px]",children:[e.jsxs("span",{"code-path":"src/components/user/ApiAccessKeySection.tsx:312:23",className:"flex items-center gap-1 text-[var(--dg-text-muted)]",children:[e.jsx(ke,{"code-path":"src/components/user/ApiAccessKeySection.tsx:313:25",className:"h-3 w-3"}),b?"已过期":g!=null?`剩余 ${g} 天`:"有效期"]}),e.jsxs("span",{"code-path":"src/components/user/ApiAccessKeySection.tsx:316:23",className:"text-[var(--dg-text-muted)]",children:["有效至 ",B(s.expires_at)]})]}),e.jsx("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:320:21",className:"h-1.5 rounded-full bg-[var(--dg-bg-secondary)] overflow-hidden",children:e.jsx("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:321:23",className:Q("h-full rounded-full transition-all",fe),style:{width:`${b?100:100-xe}%`}})})]}),e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:328:19",className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-[var(--dg-text-muted)] pt-1 border-t border-[var(--dg-border)]/60",children:[e.jsxs("span",{"code-path":"src/components/user/ApiAccessKeySection.tsx:329:21",className:"inline-flex items-center gap-1",children:[e.jsx(Ce,{"code-path":"src/components/user/ApiAccessKeySection.tsx:330:23",className:"h-3 w-3"}),"最近调用 ",B(s.last_used_at)]}),s.prefix&&e.jsxs("span",{"code-path":"src/components/user/ApiAccessKeySection.tsx:334:23",children:["前缀 ",e.jsx("code",{"code-path":"src/components/user/ApiAccessKeySection.tsx:334:32",className:"text-[var(--dg-text-secondary)]",children:s.prefix})]}),b&&e.jsx(_,{"code-path":"src/components/user/ApiAccessKeySection.tsx:337:23",variant:"outline",className:"text-[10px] border-red-500/40 text-red-400",children:"需续期或轮换"})]})]})]})}):e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:344:13",className:"rounded-xl border border-dashed border-[var(--dg-border)] bg-[var(--dg-bg-tertiary)]/30 px-6 py-12 text-center",children:[e.jsx("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:345:15",className:"mx-auto mb-3 h-12 w-12 rounded-full bg-[var(--dg-blue)]/10 flex items-center justify-center",children:e.jsx(ae,{"code-path":"src/components/user/ApiAccessKeySection.tsx:346:17",className:"h-6 w-6 text-[var(--dg-blue)]"})}),e.jsx("p",{"code-path":"src/components/user/ApiAccessKeySection.tsx:348:15",className:"text-sm text-[var(--dg-text-secondary)]",children:"尚未签发 CI/CD 访问凭证"}),e.jsx("p",{"code-path":"src/components/user/ApiAccessKeySection.tsx:349:15",className:"text-xs text-[var(--dg-text-muted)] mt-1 mb-4",children:"签发后可用于 Pipeline 触发镜像更新、滚动重启等操作"}),e.jsxs(l,{"code-path":"src/components/user/ApiAccessKeySection.tsx:350:15",size:"sm",onClick:E,disabled:p,children:[e.jsx(re,{"code-path":"src/components/user/ApiAccessKeySection.tsx:351:17",className:"h-4 w-4 mr-1"}),"立即签发"]})]}),s?.has_token&&!h&&e.jsx("p",{"code-path":"src/components/user/ApiAccessKeySection.tsx:357:13",className:"text-[11px] text-amber-400/90",children:"本机未缓存凭证明文,请点击「轮换」重新签发一次;签发后将自动填入 Deployment 发布 curl。"}),e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:360:11",className:"rounded-lg bg-[var(--dg-bg-tertiary)]/60 p-4 space-y-3",children:[e.jsxs("p",{"code-path":"src/components/user/ApiAccessKeySection.tsx:361:13",className:"text-xs font-medium text-[var(--dg-text-secondary)] flex items-center gap-1.5",children:[e.jsx(_e,{"code-path":"src/components/user/ApiAccessKeySection.tsx:362:15",className:"h-3.5 w-3.5 text-purple-400"}),"调用示例"]}),e.jsx(I,{"code-path":"src/components/user/ApiAccessKeySection.tsx:364:13",label:"更新镜像",code:ye,copyLabel:"curl 已复制",copyDisabled:!h,copyDisabledTitle:"请先签发访问凭证"}),e.jsx(I,{"code-path":"src/components/user/ApiAccessKeySection.tsx:371:13",label:"滚动重启",code:Ae,copyLabel:"curl 已复制",copyDisabled:!h,copyDisabledTitle:"请先签发访问凭证"})]})]})]}),e.jsx(W,{"code-path":"src/components/user/ApiAccessKeySection.tsx:382:7",open:K,onOpenChange:m,children:e.jsxs(Y,{"code-path":"src/components/user/ApiAccessKeySection.tsx:383:9",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] sm:max-w-md",children:[e.jsxs(Z,{"code-path":"src/components/user/ApiAccessKeySection.tsx:384:11",children:[e.jsx(ee,{"code-path":"src/components/user/ApiAccessKeySection.tsx:385:13",className:"text-[var(--dg-text-primary)]",children:j==="edit"?"调整凭证":s?.has_token?"轮换凭证":"签发凭证"}),e.jsx(se,{"code-path":"src/components/user/ApiAccessKeySection.tsx:388:13",className:"text-xs text-[var(--dg-text-muted)]",children:j==="edit"?"修改用途说明与有效期限,凭证字符串不变。":"填写用途并设定有效期,签发后请立即保存明文。"})]}),e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:392:11",className:"space-y-3 py-2",children:[e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:393:13",children:[e.jsx(C,{"code-path":"src/components/user/ApiAccessKeySection.tsx:394:15",className:"text-xs text-[var(--dg-text-muted)]",children:"用途说明"}),e.jsx(k,{"code-path":"src/components/user/ApiAccessKeySection.tsx:395:15",value:L,onChange:i=>$(i.target.value),placeholder:"如 Jenkins 流水线、GitLab CI",className:"mt-1 h-9 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"})]}),e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:402:13",children:[e.jsx(C,{"code-path":"src/components/user/ApiAccessKeySection.tsx:403:15",className:"text-xs text-[var(--dg-text-muted)]",children:"有效至"}),e.jsx(k,{"code-path":"src/components/user/ApiAccessKeySection.tsx:404:15",type:"date",value:w,onChange:i=>O(i.target.value),className:"mt-1 h-9 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"})]})]}),e.jsxs(te,{"code-path":"src/components/user/ApiAccessKeySection.tsx:412:11",children:[e.jsx(l,{"code-path":"src/components/user/ApiAccessKeySection.tsx:413:13",variant:"outline",onClick:()=>m(!1),className:"border-[var(--dg-border)]",children:"取消"}),e.jsxs(l,{"code-path":"src/components/user/ApiAccessKeySection.tsx:414:13",onClick:he,disabled:p||!w,children:[p?e.jsx(D,{"code-path":"src/components/user/ApiAccessKeySection.tsx:415:32",className:"h-4 w-4 animate-spin mr-1"}):null,j==="edit"?"保存":s?.has_token?"轮换":"签发"]})]})]})}),e.jsx(W,{"code-path":"src/components/user/ApiAccessKeySection.tsx:422:7",open:ie,onOpenChange:M,children:e.jsxs(Y,{"code-path":"src/components/user/ApiAccessKeySection.tsx:423:9",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] sm:max-w-lg",children:[e.jsxs(Z,{"code-path":"src/components/user/ApiAccessKeySection.tsx:424:11",children:[e.jsx(ee,{"code-path":"src/components/user/ApiAccessKeySection.tsx:425:13",className:"text-[var(--dg-text-primary)]",children:"请保存凭证明文"}),e.jsx(se,{"code-path":"src/components/user/ApiAccessKeySection.tsx:426:13",className:"text-xs text-[var(--dg-text-muted)]",children:"仅此一次机会查看完整字符串,关闭后无法再次获取。"})]}),e.jsx(I,{"code-path":"src/components/user/ApiAccessKeySection.tsx:430:11",label:"访问凭证",code:de,copyLabel:"凭证已复制",className:"mt-2"}),e.jsx(te,{"code-path":"src/components/user/ApiAccessKeySection.tsx:436:11",children:e.jsx(l,{"code-path":"src/components/user/ApiAccessKeySection.tsx:437:13",onClick:()=>M(!1),children:"我已保存"})})]})})]})}function Ge(){const{toast:t}=ne(),a=be(r=>r.user),[n,s]=c.useState(null),[x,y]=c.useState(!0),[u,p]=c.useState(""),[d,A]=c.useState(""),[N,P]=c.useState(!1),f=c.useCallback(async()=>{y(!0);try{const r=await v.getProfile();s(r)}finally{y(!1)}},[]);c.useEffect(()=>{f()},[f]);const K=n?.real_name||n?.nickname||a?.nickname||a?.username||"用户",m=n?.username||a?.username||"",j=async()=>{if(!(!u||d.length<6)){P(!0);try{await v.changePassword({old_password:u,new_password:d}),t({title:"密码已修改"}),p(""),A("")}catch(r){t({title:"修改失败",description:r?.message||String(r),variant:"destructive"})}finally{P(!1)}}};return x?e.jsxs("div",{"code-path":"src/components/user/ProfilePage.tsx:57:7",className:"flex items-center justify-center py-24 text-[var(--dg-text-muted)]",children:[e.jsx(D,{"code-path":"src/components/user/ProfilePage.tsx:58:9",className:"h-6 w-6 animate-spin mr-2"}),"加载中..."]}):e.jsxs("div",{"code-path":"src/components/user/ProfilePage.tsx:64:5",className:"max-w-5xl mx-auto space-y-6 pb-8",children:[e.jsxs("div",{"code-path":"src/components/user/ProfilePage.tsx:65:7",className:"flex items-center gap-4",children:[e.jsx("div",{"code-path":"src/components/user/ProfilePage.tsx:66:9",className:"h-16 w-16 rounded-2xl bg-gradient-to-br from-[var(--dg-blue)] to-[var(--dg-purple)] flex items-center justify-center text-white text-2xl font-bold shadow-lg",children:K.charAt(0).toUpperCase()}),e.jsxs("div",{"code-path":"src/components/user/ProfilePage.tsx:69:9",children:[e.jsx("h1",{"code-path":"src/components/user/ProfilePage.tsx:70:11",className:"text-2xl font-bold text-[var(--dg-text-primary)]",children:K}),e.jsxs("p",{"code-path":"src/components/user/ProfilePage.tsx:71:11",className:"text-sm text-[var(--dg-text-muted)]",children:["@",m," · ",n?.email||"—"]}),e.jsx("div",{"code-path":"src/components/user/ProfilePage.tsx:72:11",className:"flex gap-2 mt-2",children:(n?.roles||[]).map(r=>e.jsx(_,{"code-path":"src/components/user/ProfilePage.tsx:74:15",variant:"outline",className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)] text-xs",children:r.name||r},r.id||r.name))})]})]}),e.jsxs("div",{"code-path":"src/components/user/ProfilePage.tsx:82:7",className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(z,{"code-path":"src/components/user/ProfilePage.tsx:83:9",className:"dg-card",children:[e.jsx(F,{"code-path":"src/components/user/ProfilePage.tsx:84:11",className:"pb-3",children:e.jsxs(H,{"code-path":"src/components/user/ProfilePage.tsx:85:13",className:"text-base flex items-center gap-2 text-[var(--dg-text-primary)]",children:[e.jsx(De,{"code-path":"src/components/user/ProfilePage.tsx:86:15",className:"h-4 w-4 text-[var(--dg-blue)]"}),"基本信息"]})}),e.jsxs(R,{"code-path":"src/components/user/ProfilePage.tsx:89:11",className:"space-y-3 text-sm",children:[e.jsxs("div",{"code-path":"src/components/user/ProfilePage.tsx:90:13",className:"flex justify-between",children:[e.jsx("span",{"code-path":"src/components/user/ProfilePage.tsx:90:51",className:"text-[var(--dg-text-muted)]",children:"用户名"}),e.jsx("span",{"code-path":"src/components/user/ProfilePage.tsx:90:107",className:"font-mono",children:m})]}),e.jsxs("div",{"code-path":"src/components/user/ProfilePage.tsx:91:13",className:"flex justify-between",children:[e.jsx("span",{"code-path":"src/components/user/ProfilePage.tsx:91:51",className:"text-[var(--dg-text-muted)]",children:"邮箱"}),e.jsx("span",{"code-path":"src/components/user/ProfilePage.tsx:91:106",children:n?.email||"—"})]}),e.jsxs("div",{"code-path":"src/components/user/ProfilePage.tsx:92:13",className:"flex justify-between",children:[e.jsx("span",{"code-path":"src/components/user/ProfilePage.tsx:92:51",className:"text-[var(--dg-text-muted)]",children:"手机"}),e.jsx("span",{"code-path":"src/components/user/ProfilePage.tsx:92:106",children:n?.phone||"—"})]}),e.jsxs("div",{"code-path":"src/components/user/ProfilePage.tsx:93:13",className:"flex justify-between",children:[e.jsx("span",{"code-path":"src/components/user/ProfilePage.tsx:93:51",className:"text-[var(--dg-text-muted)]",children:"账号来源"}),e.jsx(_,{"code-path":"src/components/user/ProfilePage.tsx:94:15",variant:"outline",className:"text-xs",children:n?.auth_source==="ldap"?"LDAP":"本地"})]})]})]}),e.jsxs(z,{"code-path":"src/components/user/ProfilePage.tsx:99:9",className:"dg-card",children:[e.jsxs(F,{"code-path":"src/components/user/ProfilePage.tsx:100:11",className:"pb-3",children:[e.jsxs(H,{"code-path":"src/components/user/ProfilePage.tsx:101:13",className:"text-base flex items-center gap-2 text-[var(--dg-text-primary)]",children:[e.jsx(Te,{"code-path":"src/components/user/ProfilePage.tsx:102:15",className:"h-4 w-4 text-emerald-400"}),"安全设置"]}),e.jsx(oe,{"code-path":"src/components/user/ProfilePage.tsx:104:13",className:"text-xs",children:"修改登录密码"})]}),e.jsxs(R,{"code-path":"src/components/user/ProfilePage.tsx:106:11",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/user/ProfilePage.tsx:107:13",children:[e.jsx(C,{"code-path":"src/components/user/ProfilePage.tsx:108:15",className:"text-xs text-[var(--dg-text-muted)]",children:"当前密码"}),e.jsx(k,{"code-path":"src/components/user/ProfilePage.tsx:109:15",type:"password",value:u,onChange:r=>p(r.target.value),className:"mt-1 h-9 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"})]}),e.jsxs("div",{"code-path":"src/components/user/ProfilePage.tsx:111:13",children:[e.jsx(C,{"code-path":"src/components/user/ProfilePage.tsx:112:15",className:"text-xs text-[var(--dg-text-muted)]",children:"新密码"}),e.jsx(k,{"code-path":"src/components/user/ProfilePage.tsx:113:15",type:"password",value:d,onChange:r=>A(r.target.value),className:"mt-1 h-9 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"})]}),e.jsxs(l,{"code-path":"src/components/user/ProfilePage.tsx:115:13",size:"sm",onClick:j,disabled:N||!u||d.length<6,children:[N?e.jsx(D,{"code-path":"src/components/user/ProfilePage.tsx:116:28",className:"h-4 w-4 animate-spin mr-1"}):null,"保存密码"]})]})]})]}),e.jsx(Me,{"code-path":"src/components/user/ProfilePage.tsx:123:7"})]})}export{Ge as default}; diff --git a/backend/static/assets/RegionManager-SQdvSTOO.js b/backend/static/assets/RegionManager-SQdvSTOO.js deleted file mode 100644 index c709c4d..0000000 --- a/backend/static/assets/RegionManager-SQdvSTOO.js +++ /dev/null @@ -1 +0,0 @@ -import{r as t,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{f as ee,B as u,D as se,a as ae,b as oe,c as te,d as ce,e as ne,t as N}from"./index-Dungj95X.js";import{I as j}from"./input-CXoUQQLm.js";import{L as i}from"./label-CMpUoC87.js";import{B as O}from"./badge-CGJlVD3L.js";import{C as A}from"./checkbox-Bu55mX0G.js";import{T as re,a as le,b as V,c as r,d as de,e as l}from"./table-B2F10oba.js";import{S as y,a as C,b as w,c as S,d as R}from"./select-CiTqGGhE.js";import{r as M}from"./region-CNZ3vwAq.js";import{S as ie,P as pe,T as H,L as $,M as ge,C as xe,a as he,d as me}from"./vendor-icons-DmqcWdzX.js";import"./index-5FEebgvX.js";const k={aws:"AWS",aliyun:"阿里云",tencent:"腾讯云",huawei:"华为云",azure:"Azure"},ue={aws:"text-orange-400",aliyun:"text-orange-400",tencent:"text-blue-400",huawei:"text-red-400",azure:"text-blue-400"};function ke(){const D=ee(),[T,L]=t.useState([]),[F,I]=t.useState(!0),[b,Q]=t.useState(""),[f,W]=t.useState("all"),[c,d]=t.useState([]),[X,p]=t.useState(!1),[g,P]=t.useState(null),[B,z]=t.useState(!1),[a,n]=t.useState({name:"",code:"",provider:"aliyun",location:"",status:"active",endpoint:""}),x=t.useCallback(async()=>{I(!0);try{const o=(await M.list())?.list||[];L(o)}catch{L([])}finally{I(!1)}},[]);t.useEffect(()=>{x()},[x]);const h=T.filter(s=>{const o=s.name?.toLowerCase().includes(b.toLowerCase())||s.code?.toLowerCase().includes(b.toLowerCase()),v=f==="all"||s.provider===f;return o&&v}),E=h.length>0&&h.every(s=>c.includes(s.id)),q=()=>{d(E?[]:h.map(s=>s.id))},G=s=>{d(o=>o.includes(s)?o.filter(v=>v!==s):[...o,s])},J=()=>{P(null),n({name:"",code:"",provider:"aliyun",location:"",status:"active",endpoint:""}),p(!0)},K=s=>{P(s),n({name:s.name||"",code:s.code||"",provider:s.provider||"aliyun",location:s.location||"",status:s.status||"active",endpoint:s.endpoint||""}),p(!0)},U=async()=>{if(!(!a.name.trim()||!a.code.trim())){z(!0);try{g?await M.update(g.id,a):await M.create(a),p(!1),x()}catch{}finally{z(!1)}}},Y=async s=>{const o=T.find(m=>m.id===s);if(await D({title:"删除区域",description:`确定删除「${o?.name||s}」吗?此操作不可撤销。`,confirmText:"删除",variant:"destructive"}))try{await M.delete(s),N.success("区域已删除"),d(m=>m.filter(_=>_!==s)),x()}catch(m){console.error("删除区域失败:",m),N.error("删除失败")}},Z=async()=>{if(!(c.length===0||!await D({title:"批量删除区域",description:`确定删除选中的 ${c.length} 个区域吗?此操作不可撤销。`,confirmText:"批量删除",variant:"destructive"})))try{await M.batchDelete(c),N.success(`已删除 ${c.length} 个区域`),d([]),x()}catch(o){console.error("批量删除失败:",o),N.error("批量删除失败")}};return e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:186:5",className:"p-6 space-y-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:188:7",className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:189:9",className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:190:11",className:"relative w-72",children:[e.jsx(ie,{"code-path":"src/components/cloud/RegionManager.tsx:191:13",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/cloud/RegionManager.tsx:192:13",placeholder:"搜索区域名称或编码...",value:b,onChange:s=>Q(s.target.value),className:"pl-9 h-9 bg-slate-800/50 border-slate-700"})]}),e.jsxs(y,{"code-path":"src/components/cloud/RegionManager.tsx:199:11",value:f,onValueChange:W,children:[e.jsx(C,{"code-path":"src/components/cloud/RegionManager.tsx:200:13",className:"w-32 h-9 bg-slate-800/50 border-slate-700",children:e.jsx(w,{"code-path":"src/components/cloud/RegionManager.tsx:201:15"})}),e.jsxs(S,{"code-path":"src/components/cloud/RegionManager.tsx:203:13",children:[e.jsx(R,{"code-path":"src/components/cloud/RegionManager.tsx:204:15",value:"all",children:"全部云商"}),Object.entries(k).map(([s,o])=>e.jsx(R,{"code-path":"src/components/cloud/RegionManager.tsx:206:17",value:s,children:o},s))]})]})]}),e.jsxs(u,{"code-path":"src/components/cloud/RegionManager.tsx:211:9",onClick:J,className:"gap-2",children:[e.jsx(pe,{"code-path":"src/components/cloud/RegionManager.tsx:212:11",className:"h-4 w-4"}),"添加区域"]})]}),c.length>0&&e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:219:9",className:"flex items-center justify-between gap-4 px-4 py-2.5 rounded-lg bg-slate-800/50 border border-slate-700",children:[e.jsxs("span",{"code-path":"src/components/cloud/RegionManager.tsx:220:11",className:"text-sm text-slate-300",children:["已选择 ",e.jsx("span",{"code-path":"src/components/cloud/RegionManager.tsx:221:17",className:"font-semibold text-slate-100",children:c.length})," 个区域"]}),e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:223:11",className:"flex items-center gap-2",children:[e.jsx(u,{"code-path":"src/components/cloud/RegionManager.tsx:224:13",variant:"ghost",size:"sm",onClick:()=>d([]),className:"text-slate-400 hover:text-slate-200",children:"取消选择"}),e.jsxs(u,{"code-path":"src/components/cloud/RegionManager.tsx:227:13",variant:"outline",size:"sm",className:"border-red-500/30 text-red-400 hover:bg-red-500/10",onClick:Z,children:[e.jsx(H,{"code-path":"src/components/cloud/RegionManager.tsx:233:15",className:"h-4 w-4 mr-1.5"}),"批量删除"]})]})]}),F?e.jsx("div",{"code-path":"src/components/cloud/RegionManager.tsx:242:9",className:"flex justify-center py-20",children:e.jsx($,{"code-path":"src/components/cloud/RegionManager.tsx:243:11",className:"h-6 w-6 animate-spin text-slate-500"})}):h.length===0?e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:246:9",className:"text-center py-20 text-slate-500",children:[e.jsx(ge,{"code-path":"src/components/cloud/RegionManager.tsx:247:11",className:"h-12 w-12 mx-auto mb-3 opacity-40"}),e.jsx("p",{"code-path":"src/components/cloud/RegionManager.tsx:248:11",children:"暂无区域数据"})]}):e.jsx("div",{"code-path":"src/components/cloud/RegionManager.tsx:251:9",className:"rounded-lg overflow-hidden",children:e.jsxs(re,{"code-path":"src/components/cloud/RegionManager.tsx:252:11",children:[e.jsx(le,{"code-path":"src/components/cloud/RegionManager.tsx:253:13",children:e.jsxs(V,{"code-path":"src/components/cloud/RegionManager.tsx:254:15",className:"border-slate-800 hover:bg-transparent",children:[e.jsx(r,{"code-path":"src/components/cloud/RegionManager.tsx:255:17",className:"w-10",children:e.jsx(A,{"code-path":"src/components/cloud/RegionManager.tsx:256:19",checked:E,onCheckedChange:q,className:"border-slate-600"})}),e.jsx(r,{"code-path":"src/components/cloud/RegionManager.tsx:262:17",className:"text-slate-400",children:"区域名称"}),e.jsx(r,{"code-path":"src/components/cloud/RegionManager.tsx:263:17",className:"text-slate-400",children:"编码"}),e.jsx(r,{"code-path":"src/components/cloud/RegionManager.tsx:264:17",className:"text-slate-400",children:"云商"}),e.jsx(r,{"code-path":"src/components/cloud/RegionManager.tsx:265:17",className:"text-slate-400",children:"位置"}),e.jsx(r,{"code-path":"src/components/cloud/RegionManager.tsx:266:17",className:"text-slate-400",children:"接入端点"}),e.jsx(r,{"code-path":"src/components/cloud/RegionManager.tsx:267:17",className:"text-slate-400",children:"状态"}),e.jsx(r,{"code-path":"src/components/cloud/RegionManager.tsx:268:17",className:"text-slate-400 text-right",children:"操作"})]})}),e.jsx(de,{"code-path":"src/components/cloud/RegionManager.tsx:271:13",children:h.map(s=>e.jsxs(V,{"code-path":"src/components/cloud/RegionManager.tsx:273:17",className:"border-slate-800/50 group",children:[e.jsx(l,{"code-path":"src/components/cloud/RegionManager.tsx:274:19",children:e.jsx(A,{"code-path":"src/components/cloud/RegionManager.tsx:275:21",checked:c.includes(s.id),onCheckedChange:()=>G(s.id),className:"border-slate-600"})}),e.jsx(l,{"code-path":"src/components/cloud/RegionManager.tsx:281:19",className:"font-medium text-slate-200",children:s.name}),e.jsx(l,{"code-path":"src/components/cloud/RegionManager.tsx:282:19",className:"font-mono text-sm text-slate-400",children:s.code}),e.jsx(l,{"code-path":"src/components/cloud/RegionManager.tsx:283:19",children:e.jsx("span",{"code-path":"src/components/cloud/RegionManager.tsx:284:21",className:ue[s.provider]||"text-slate-400",children:k[s.provider]||s.provider})}),e.jsx(l,{"code-path":"src/components/cloud/RegionManager.tsx:288:19",className:"text-slate-400",children:s.location||"-"}),e.jsx(l,{"code-path":"src/components/cloud/RegionManager.tsx:289:19",className:"max-w-[200px] truncate font-mono text-xs text-slate-400",title:s.endpoint,children:s.endpoint||"-"}),e.jsx(l,{"code-path":"src/components/cloud/RegionManager.tsx:290:19",children:s.status==="active"?e.jsxs(O,{"code-path":"src/components/cloud/RegionManager.tsx:292:23",className:"bg-emerald-500/20 text-emerald-400 gap-1",children:[e.jsx(xe,{"code-path":"src/components/cloud/RegionManager.tsx:293:25",className:"h-3 w-3"})," 启用"]}):e.jsxs(O,{"code-path":"src/components/cloud/RegionManager.tsx:296:23",className:"bg-slate-500/20 text-slate-400 gap-1",children:[e.jsx(he,{"code-path":"src/components/cloud/RegionManager.tsx:297:25",className:"h-3 w-3"})," 禁用"]})}),e.jsx(l,{"code-path":"src/components/cloud/RegionManager.tsx:301:19",children:e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:302:21",className:"flex justify-end gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{"code-path":"src/components/cloud/RegionManager.tsx:303:23",onClick:()=>K(s),className:"p-1.5 rounded hover:bg-slate-700 text-slate-400 hover:text-slate-200",children:e.jsx(me,{"code-path":"src/components/cloud/RegionManager.tsx:304:25",className:"h-3.5 w-3.5"})}),e.jsx("button",{"code-path":"src/components/cloud/RegionManager.tsx:306:23",onClick:()=>Y(s.id),className:"p-1.5 rounded hover:bg-slate-700 text-slate-400 hover:text-red-400",children:e.jsx(H,{"code-path":"src/components/cloud/RegionManager.tsx:307:25",className:"h-3.5 w-3.5"})})]})})]},s.id))})]})}),e.jsx(se,{"code-path":"src/components/cloud/RegionManager.tsx:319:7",open:X,onOpenChange:p,children:e.jsxs(ae,{"code-path":"src/components/cloud/RegionManager.tsx:320:9",children:[e.jsxs(oe,{"code-path":"src/components/cloud/RegionManager.tsx:321:11",children:[e.jsx(te,{"code-path":"src/components/cloud/RegionManager.tsx:322:13",children:g?"编辑区域":"添加区域"}),e.jsx(ce,{"code-path":"src/components/cloud/RegionManager.tsx:323:13",className:"sr-only",children:"描述"})]}),e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:325:11",className:"space-y-4 py-2",children:[e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:326:13",className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:327:15",className:"space-y-1.5",children:[e.jsx(i,{"code-path":"src/components/cloud/RegionManager.tsx:328:17",children:"区域名称 *"}),e.jsx(j,{"code-path":"src/components/cloud/RegionManager.tsx:329:17",value:a.name,onChange:s=>n({...a,name:s.target.value}),placeholder:"如:华北-北京",className:"bg-slate-800/50 border-slate-700"})]}),e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:336:15",className:"space-y-1.5",children:[e.jsx(i,{"code-path":"src/components/cloud/RegionManager.tsx:337:17",children:"编码 *"}),e.jsx(j,{"code-path":"src/components/cloud/RegionManager.tsx:338:17",value:a.code,onChange:s=>n({...a,code:s.target.value}),placeholder:"如:cn-north-1",className:"bg-slate-800/50 border-slate-700 font-mono",disabled:!!g})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:347:13",className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:348:15",className:"space-y-1.5",children:[e.jsx(i,{"code-path":"src/components/cloud/RegionManager.tsx:349:17",children:"云商"}),e.jsxs(y,{"code-path":"src/components/cloud/RegionManager.tsx:350:17",value:a.provider,onValueChange:s=>n({...a,provider:s}),children:[e.jsx(C,{"code-path":"src/components/cloud/RegionManager.tsx:351:19",className:"bg-slate-800/50 border-slate-700",children:e.jsx(w,{"code-path":"src/components/cloud/RegionManager.tsx:352:21"})}),e.jsx(S,{"code-path":"src/components/cloud/RegionManager.tsx:354:19",children:Object.entries(k).map(([s,o])=>e.jsx(R,{"code-path":"src/components/cloud/RegionManager.tsx:356:23",value:s,children:o},s))})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:361:15",className:"space-y-1.5",children:[e.jsx(i,{"code-path":"src/components/cloud/RegionManager.tsx:362:17",children:"状态"}),e.jsxs(y,{"code-path":"src/components/cloud/RegionManager.tsx:363:17",value:a.status,onValueChange:s=>n({...a,status:s}),children:[e.jsx(C,{"code-path":"src/components/cloud/RegionManager.tsx:364:19",className:"bg-slate-800/50 border-slate-700",children:e.jsx(w,{"code-path":"src/components/cloud/RegionManager.tsx:365:21"})}),e.jsxs(S,{"code-path":"src/components/cloud/RegionManager.tsx:367:19",children:[e.jsx(R,{"code-path":"src/components/cloud/RegionManager.tsx:368:21",value:"active",children:"启用"}),e.jsx(R,{"code-path":"src/components/cloud/RegionManager.tsx:369:21",value:"inactive",children:"禁用"})]})]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:374:13",className:"space-y-1.5",children:[e.jsx(i,{"code-path":"src/components/cloud/RegionManager.tsx:375:15",children:"地理位置"}),e.jsx(j,{"code-path":"src/components/cloud/RegionManager.tsx:376:15",value:a.location,onChange:s=>n({...a,location:s.target.value}),placeholder:"如:中国北京",className:"bg-slate-800/50 border-slate-700"})]}),e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:383:13",className:"space-y-1.5",children:[e.jsx(i,{"code-path":"src/components/cloud/RegionManager.tsx:384:15",children:"接入端点"}),e.jsx(j,{"code-path":"src/components/cloud/RegionManager.tsx:385:15",value:a.endpoint,onChange:s=>n({...a,endpoint:s.target.value}),placeholder:"如:ecs.cn-north-1.aliyuncs.com",className:"bg-slate-800/50 border-slate-700 font-mono text-sm"})]})]}),e.jsxs(ne,{"code-path":"src/components/cloud/RegionManager.tsx:393:11",children:[e.jsx(u,{"code-path":"src/components/cloud/RegionManager.tsx:394:13",variant:"ghost",onClick:()=>p(!1),children:"取消"}),e.jsxs(u,{"code-path":"src/components/cloud/RegionManager.tsx:395:13",onClick:U,disabled:B||!a.name.trim()||!a.code.trim(),children:[B&&e.jsx($,{"code-path":"src/components/cloud/RegionManager.tsx:396:30",className:"h-4 w-4 mr-1 animate-spin"}),g?"保存":"创建"]})]})]})})]})}export{ke as RegionManager}; diff --git a/backend/static/assets/ResourceVisualEditor-BN2gGuH7.js b/backend/static/assets/ResourceVisualEditor-BN2gGuH7.js deleted file mode 100644 index 4ee6beb..0000000 --- a/backend/static/assets/ResourceVisualEditor-BN2gGuH7.js +++ /dev/null @@ -1 +0,0 @@ -import{r as i,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{B as E}from"./index-Dungj95X.js";import{p as F,c as ee,g as le,M as ue,d as xe,b as me,e as pe,f as he,y as be}from"./PodFileBrowser-B-U8iHmY.js";import{I as f}from"./input-CXoUQQLm.js";import{L as T}from"./label-CMpUoC87.js";import{T as te}from"./textarea-BxfjmLq5.js";import{S as G,a as W,b as U,c as H,d as Y}from"./select-CiTqGGhE.js";import{u as ge}from"./use-toast-DNZLibQY.js";import{k as $,d as ve}from"./index-drGq01ok.js";import{D as ke,f as Re,N as Ee,j as je,F as Ve,X as fe,L as A,P as L,T as O,$ as B}from"./vendor-icons-DmqcWdzX.js";function se(n,l,a){switch(n){case"services":return{apiVersion:"v1",kind:"Service",metadata:{name:a,namespace:l},spec:{type:"ClusterIP",selector:{},ports:[{name:"http",port:80,targetPort:80,protocol:"TCP"}]}};case"ingresses":return{apiVersion:"networking.k8s.io/v1",kind:"Ingress",metadata:{name:a,namespace:l},spec:{ingressClassName:"nginx",rules:[{host:"",http:{paths:[{path:"/",pathType:"Prefix",backend:{service:{name:"",port:{number:80}}}}]}}]}};case"configmaps":return{apiVersion:"v1",kind:"ConfigMap",metadata:{name:a,namespace:l},data:{}};case"secrets":return{apiVersion:"v1",kind:"Secret",metadata:{name:a,namespace:l},type:"Opaque",data:{}};case"pvcs":return{apiVersion:"v1",kind:"PersistentVolumeClaim",metadata:{name:a,namespace:l},spec:{accessModes:["ReadWriteOnce"],resources:{requests:{storage:"1Gi"}}}};case"deployments":return{apiVersion:"apps/v1",kind:"Deployment",metadata:{name:a||"my-app",namespace:l,labels:{app:a||"my-app"}},spec:{replicas:1,selector:{matchLabels:{app:a||"my-app"}},template:{metadata:{labels:{app:a||"my-app"}},spec:{containers:[{name:"main",image:"nginx:latest",ports:[{containerPort:80,protocol:"TCP"}],resources:{requests:{cpu:"100m",memory:"128Mi"},limits:{cpu:"500m",memory:"512Mi"}}}]}}}};default:return{apiVersion:"v1",kind:"Unknown",metadata:{name:a,namespace:l}}}}function Ae({clusterCode:n,namespace:l,resource:a,name:k,onClose:j,onSaved:y,isCreate:h=!1}){const{toast:u}=ge(),[R,g]=i.useState(!0),[v,V]=i.useState(!1),[N,w]=i.useState(""),[b,t]=i.useState(null),[c,m]=i.useState("visual"),[C,M]=i.useState(""),[I,o]=i.useState(""),[x,s]=i.useState(!1),[r,p]=i.useState(!1),[S,P]=i.useState(!1),X=i.useCallback(async()=>{g(!0);try{if(h){const Q=se(a,l,k||""),Z=await F(Q);t(Q),M(Z),o(Z),w(""),s(!0);return}const d=await $.getResourceYaml(n,l,a,k);w(d);const{manifest:z,yaml:_}=await ee(d);M(_),o(_),s(!1),p(!1),t(z),z||(m("yaml"),u({title:"可视化编辑不可用",description:"无法解析资源结构,已切换到 YAML 编辑模式"}))}catch(d){u({title:"加载失败",description:d.message,variant:"destructive"})}finally{g(!1)}},[n,l,a,k,h]);i.useEffect(()=>{X()},[X]);const D=async d=>{V(!0);try{const z=await F(d),_=d?.metadata?.name||k;if(h){if(!_?.trim()){u({title:"请填写名称",variant:"destructive"});return}await $.applyYAML(n,z),u({title:"创建成功",description:`${a}/${_}`})}else await $.updateResourceYaml(n,l,a,k,z),u({title:"保存成功",description:`${a}/${k} 已更新`});y?.(),j()}catch(z){u({title:h?"创建失败":"保存失败",description:z.message,variant:"destructive"})}finally{V(!1)}},re=async()=>{V(!0);try{const d=await he(I);h?(await $.applyYAML(n,d),u({title:"创建成功",description:"YAML 已应用"})):(await $.updateResourceYaml(n,l,a,k,d),u({title:"保存成功",description:`${a}/${k} 已更新`})),s(!1),M(d),o(d),h||w(d),y?.(),j()}catch(d){u({title:"保存失败",description:d.message,variant:"destructive"})}finally{V(!1)}},oe=async()=>{const d=await pe(I);if(!d){u({title:"无法解析 YAML",description:"请检查语法后继续用 YAML 模式",variant:"destructive"});return}t(d),m("visual")},ae=async()=>{if(b){const d=await F(b);M(d),o(d)}s(!1),p(!1),m("yaml")},J=()=>x?I:r?N:C,ce=async()=>{await navigator.clipboard.writeText(J()),P(!0),setTimeout(()=>P(!1),2e3)},ne=()=>{const d=be(a,l,k||b?.metadata?.name||"resource");ve(d,J()),u({title:"已下载",description:d})},de=le(a),K={configmaps:{title:"ConfigMap",icon:Ve,color:"text-blue-400"},secrets:{title:"Secret",icon:je,color:"text-amber-400"},services:{title:"Service",icon:Ee,color:"text-cyan-400"},ingresses:{title:"Ingress",icon:Re,color:"text-purple-400"},pvcs:{title:"PersistentVolumeClaim",icon:ke,color:"text-emerald-400"}},q=K[a]||K.configmaps,ie=q.icon;return e.jsx(ue,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:169:5",onClose:j,children:e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:170:7",className:"bg-[var(--dg-bg-primary)] border border-[var(--dg-border)] rounded-xl w-[90vw] max-w-3xl h-[85vh] flex flex-col shadow-2xl",onClick:d=>d.stopPropagation(),children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:175:9",className:"flex items-center justify-between p-4 border-b border-[var(--dg-border)] gap-3 shrink-0",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:176:11",className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(ie,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:177:13",className:`h-5 w-5 shrink-0 ${q.color}`}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:178:13",className:"min-w-0",children:[e.jsx("h2",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:179:15",className:"text-lg font-bold text-[var(--dg-text-primary)] truncate",children:h?`新建 ${q.title}`:`${q.title} 编辑`}),e.jsx("p",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:182:15",className:"text-xs text-[var(--dg-text-muted)] truncate",title:h?`${l} · ${n}`:`${k} · ${l} · ${n}`,children:h?`${l} · ${n}`:`${k} · ${l} · ${n}`})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:190:11",className:"flex items-center gap-2 shrink-0",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:192:13",className:"flex rounded-lg border border-[var(--dg-border)] overflow-hidden",children:[e.jsx("button",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:193:15",className:`px-3 py-1.5 text-xs font-medium transition-colors ${c==="visual"?"bg-blue-600 text-white":"bg-transparent text-[var(--dg-text-secondary)] hover:bg-[var(--dg-bg-tertiary)]"}`,onClick:()=>{c==="yaml"?oe():m("visual")},disabled:!b&&c!=="yaml",children:"可视化编辑"}),e.jsx("button",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:198:15",className:`px-3 py-1.5 text-xs font-medium transition-colors ${c==="yaml"?"bg-blue-600 text-white":"bg-transparent text-[var(--dg-text-secondary)] hover:bg-[var(--dg-bg-tertiary)]"}`,onClick:()=>{c==="visual"?ae():m("yaml")},children:"YAML 编辑"})]}),e.jsx(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:203:13",variant:"ghost",size:"icon",className:"h-8 w-8 text-[var(--dg-text-secondary)]",onClick:j,children:e.jsx(fe,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:203:119",className:"h-4 w-4"})})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:208:9",className:"flex-1 min-h-0 p-4 flex flex-col overflow-hidden",children:R?e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:210:13",className:"flex items-center justify-center h-full py-20",children:e.jsx(A,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:210:76",className:"h-6 w-6 animate-spin text-[var(--dg-text-muted)]"})}):c==="yaml"?e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:212:13",className:"flex flex-col flex-1 min-h-0 gap-3",children:[e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:213:15",className:"flex justify-end shrink-0",children:e.jsx(xe,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:214:17",editing:x,saving:v,copied:S,showRaw:r,compact:!0,readOnly:de.readOnly,showRawToggle:!h&&!!N,onCopy:ce,onDownload:ne,onEdit:()=>{o(C),s(!0),p(!1)},onCancel:async()=>{if(s(!1),h){const z=se(a,l,k||""),_=await F(z);M(_),o(_);return}const{yaml:d}=await ee(N);M(d),o(d)},onSave:re,onToggleRaw:()=>p(d=>!d)})}),e.jsx(me,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:242:15",value:x?I:r?N:C,editing:x,fill:!0,fontSize:"12px",onChange:d=>x&&o(d)})]}):b?e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:251:13",className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[a==="configmaps"&&e.jsx(ye,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:252:45",manifest:b,onSave:D,saving:v,isCreate:h}),a==="secrets"&&e.jsx(Ne,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:253:42",manifest:b,onSave:D,saving:v,isCreate:h}),a==="services"&&e.jsx(we,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:254:43",manifest:b,onSave:D,saving:v,isCreate:h}),a==="ingresses"&&e.jsx(Se,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:255:44",manifest:b,clusterCode:n,onSave:D,saving:v,isCreate:h}),a==="pvcs"&&e.jsx(Ce,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:256:39",manifest:b,onSave:D,saving:v,isCreate:h}),!["configmaps","secrets","services","ingresses","pvcs"].includes(a)&&e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:258:17",className:"flex-1 flex items-center justify-center text-center text-[var(--dg-text-muted)]",children:e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:259:19",children:[e.jsx("p",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:260:21",children:"该资源类型暂不支持可视化编辑"}),e.jsx(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:261:21",variant:"outline",size:"sm",className:"mt-4",onClick:()=>m("yaml"),children:"切换到 YAML 编辑"})]})})]}):e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:267:13",className:"text-center py-12 text-[var(--dg-text-muted)]",children:[e.jsx("p",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:268:15",children:"无法解析资源结构"}),e.jsx(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:269:15",variant:"outline",size:"sm",className:"mt-4",onClick:()=>m("yaml"),children:"切换到 YAML 编辑"})]})})]})})}function ye({manifest:n,onSave:l,saving:a,isCreate:k}){const j=n?.data||{},[y,h]=i.useState(n?.metadata?.name||""),[u,R]=i.useState(Object.entries(j).map(([t,c])=>({key:t,value:String(c)}))),[g,v]=i.useState(!1),V=(t,c,m)=>{const C=[...u];C[t]={...C[t],[c]:m},R(C)},N=()=>R([...u,{key:"",value:""}]),w=t=>R(u.filter((c,m)=>m!==t)),b=()=>{const t={};u.forEach(c=>{c.key.trim()&&(t[c.key.trim()]=c.value)}),l({...n,metadata:{...n.metadata,name:y.trim()},data:t})};return e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:307:5",className:"flex flex-col h-full",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:308:7",className:"shrink-0",children:[e.jsx(T,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:309:9",className:"text-[var(--dg-text-secondary)] text-xs",children:"名称"}),e.jsx(f,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:310:9",value:y,onChange:t=>h(t.target.value),readOnly:!k,className:"mt-1 font-mono text-xs bg-[var(--dg-bg-tertiary)]"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:313:7",className:"flex-1 min-h-0 flex flex-col mt-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:314:9",className:"flex items-center justify-between mb-2 shrink-0",children:[e.jsx(T,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:315:11",className:"text-[var(--dg-text-secondary)] text-sm",children:"配置数据 (键值对)"}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:316:11",className:"flex gap-1",children:[e.jsx(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:317:13",variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>v(!g),children:g?"折叠全部":"展开全部"}),e.jsxs(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:320:13",variant:"outline",size:"sm",className:"h-7 text-xs",onClick:N,children:[e.jsx(L,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:320:90",className:"h-3 w-3 mr-1"}),"添加"]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:323:9",className:"flex-1 min-h-0 overflow-y-auto pr-1 space-y-2 border border-[var(--dg-border)] rounded-lg bg-[var(--dg-bg-secondary)] p-2",children:[u.map((t,c)=>e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:325:13",className:"flex items-start gap-2 p-2 rounded-lg border border-[var(--dg-border)] bg-[var(--dg-bg-tertiary)]",children:[e.jsx(f,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:326:15",value:t.key,onChange:m=>V(c,"key",m.target.value),placeholder:"键名 (如 LOG_LEVEL)",className:"flex-1 font-mono text-xs h-8 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"}),e.jsx(te,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:332:15",value:t.value,onChange:m=>V(c,"value",m.target.value),placeholder:"值",rows:g||t.value.length>300?10:t.value.length>100?6:3,className:"flex-[2] font-mono text-xs min-h-[70px] max-h-[420px] resize-y bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] leading-relaxed"}),e.jsx(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:339:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400 hover:text-red-300 shrink-0",onClick:()=>w(c),children:e.jsx(O,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:340:17",className:"h-3.5 w-3.5"})})]},c)),u.length===0&&e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:345:13",className:"text-center py-8 text-[var(--dg-text-muted)] text-xs",children:"暂无配置数据,点击「添加」创建"})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:350:7",className:"shrink-0 flex justify-end gap-2 pt-3 mt-2 border-t border-[var(--dg-border)]",children:e.jsxs(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:351:9",size:"sm",className:"bg-blue-600 hover:bg-blue-700",onClick:b,disabled:a,children:[a?e.jsx(A,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:352:21",className:"h-3.5 w-3.5 animate-spin mr-1"}):e.jsx(B,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:352:77",className:"h-3.5 w-3.5 mr-1"}),"保存配置"]})})]})}function Ne({manifest:n,onSave:l,saving:a,isCreate:k}){const j=n?.data||{},[y,h]=i.useState(n?.metadata?.name||""),[u,R]=i.useState(!1),[g,v]=i.useState(Object.entries(j).map(([t,c])=>{const m=String(c);try{const C=atob(m);return{key:t,value:C,encoded:!0}}catch{return{key:t,value:m,encoded:!1}}})),V=(t,c,m)=>{const C=[...g];C[t]={...C[t],[c]:m},v(C)},N=()=>v([...g,{key:"",value:"",encoded:!0}]),w=t=>v(g.filter((c,m)=>m!==t)),b=()=>{const t={};g.forEach(c=>{c.key.trim()&&(t[c.key.trim()]=c.encoded?btoa(c.value):c.value)}),l({...n,metadata:{...n.metadata,name:y.trim()},data:t})};return e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:402:5",className:"flex flex-col h-full",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:403:7",className:"shrink-0 grid grid-cols-2 gap-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:404:9",children:[e.jsx(T,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:405:11",className:"text-[var(--dg-text-secondary)] text-xs",children:"名称"}),e.jsx(f,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:406:11",value:y,onChange:t=>h(t.target.value),readOnly:!k,className:"mt-1 font-mono text-xs bg-[var(--dg-bg-tertiary)]"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:408:9",children:[e.jsx(T,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:409:11",className:"text-[var(--dg-text-secondary)] text-xs",children:"类型"}),e.jsx(f,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:410:11",value:n?.type||"Opaque",readOnly:!0,className:"mt-1 font-mono text-xs bg-[var(--dg-bg-tertiary)]"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:414:7",className:"flex-1 min-h-0 flex flex-col mt-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:415:9",className:"flex items-center justify-between mb-2 shrink-0",children:[e.jsx(T,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:416:11",className:"text-[var(--dg-text-secondary)] text-sm",children:"密钥数据 (已自动解码 Base64)"}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:417:11",className:"flex gap-1",children:[e.jsx(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:418:13",variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>R(!u),children:u?"折叠全部":"展开全部"}),e.jsxs(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:421:13",variant:"outline",size:"sm",className:"h-7 text-xs",onClick:N,children:[e.jsx(L,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:421:90",className:"h-3 w-3 mr-1"}),"添加"]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:424:9",className:"flex-1 min-h-0 overflow-y-auto pr-1 space-y-2 border border-[var(--dg-border)] rounded-lg bg-[var(--dg-bg-secondary)] p-2",children:[g.map((t,c)=>e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:426:13",className:"flex items-start gap-2 p-2 rounded-lg border border-[var(--dg-border)] bg-[var(--dg-bg-tertiary)]",children:[e.jsx(f,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:427:15",value:t.key,onChange:m=>V(c,"key",m.target.value),placeholder:"键名 (如 password)",className:"flex-1 font-mono text-xs h-8 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"}),e.jsx(te,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:433:15",value:t.value,onChange:m=>V(c,"value",m.target.value),placeholder:"明文值",rows:u||t.value.length>300?10:t.value.length>100?6:3,className:"flex-[2] font-mono text-xs min-h-[70px] max-h-[420px] resize-y bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] leading-relaxed"}),e.jsx(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:440:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400 hover:text-red-300 shrink-0",onClick:()=>w(c),children:e.jsx(O,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:441:17",className:"h-3.5 w-3.5"})})]},c)),g.length===0&&e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:446:13",className:"text-center py-8 text-[var(--dg-text-muted)] text-xs",children:"暂无密钥数据,点击「添加」创建"})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:451:7",className:"shrink-0 flex justify-end gap-2 pt-3 mt-2 border-t border-[var(--dg-border)]",children:e.jsxs(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:452:9",size:"sm",className:"bg-blue-600 hover:bg-blue-700",onClick:b,disabled:a,children:[a?e.jsx(A,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:453:21",className:"h-3.5 w-3.5 animate-spin mr-1"}):e.jsx(B,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:453:77",className:"h-3.5 w-3.5 mr-1"}),"保存密钥"]})})]})}function we({manifest:n,onSave:l,saving:a,isCreate:k}){const j=n?.spec||{},[y,h]=i.useState(n?.metadata?.name||""),[u,R]=i.useState(j.type||"ClusterIP"),[g,v]=i.useState((j.ports||[]).map(o=>({name:o.name||"",port:String(o.port||""),targetPort:String(o.targetPort||""),protocol:o.protocol||"TCP",nodePort:o.nodePort?String(o.nodePort):""}))),[V,N]=i.useState(Object.entries(j.selector||{}).map(([o,x])=>({key:o,value:String(x)}))),w=(o,x,s)=>{const r=[...g];r[o]={...r[o],[x]:s},v(r)},b=()=>v([...g,{name:"",port:"",targetPort:"",protocol:"TCP",nodePort:""}]),t=o=>v(g.filter((x,s)=>s!==o)),c=(o,x,s)=>{const r=[...V];r[o]={...r[o],[x]:s},N(r)},m=()=>N([...V,{key:"",value:""}]),C=o=>N(V.filter((x,s)=>s!==o)),M=()=>{const o={...j};o.type=u,o.ports=g.map(s=>{const r={port:parseInt(s.port)||80,targetPort:parseInt(s.targetPort)||parseInt(s.port)||80,protocol:s.protocol};return s.name&&(r.name=s.name),s.nodePort&&u==="NodePort"&&(r.nodePort=parseInt(s.nodePort)),r});const x={};V.forEach(s=>{s.key.trim()&&(x[s.key.trim()]=s.value)}),o.selector=x,l({...n,metadata:{...n.metadata,name:y.trim()},spec:o})},I=[{value:"ClusterIP",label:"ClusterIP"},{value:"NodePort",label:"NodePort"},{value:"LoadBalancer",label:"LoadBalancer"}];return e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:523:5",className:"flex flex-col h-full",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:524:7",className:"shrink-0",children:[e.jsx(T,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:525:9",className:"text-[var(--dg-text-secondary)] text-xs",children:"服务名称"}),e.jsx(f,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:526:9",value:y,onChange:o=>h(o.target.value),readOnly:!k,className:"mt-1 font-mono text-xs bg-[var(--dg-bg-tertiary)]"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:528:7",className:"shrink-0 mt-3",children:[e.jsx(T,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:529:9",className:"text-[var(--dg-text-secondary)] text-xs mb-2 block",children:"服务类型"}),e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:530:9",className:"flex rounded-lg border border-[var(--dg-border)] overflow-hidden w-fit",children:I.map(o=>e.jsx("button",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:532:13",type:"button",className:`px-3 py-1.5 text-xs transition-colors ${u===o.value?"bg-blue-600 text-white":"text-[var(--dg-text-secondary)] hover:bg-[var(--dg-bg-tertiary)]"}`,onClick:()=>R(o.value),children:o.label},o.value))})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:545:7",className:"flex-1 min-h-0 overflow-y-auto mt-3 pr-1 space-y-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:546:9",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:547:11",className:"flex items-center justify-between mb-2",children:[e.jsx(T,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:548:13",className:"text-[var(--dg-text-secondary)] text-sm",children:"端口映射"}),e.jsxs(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:549:13",variant:"outline",size:"sm",className:"h-7 text-xs",onClick:b,children:[e.jsx(L,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:549:91",className:"h-3 w-3 mr-1"}),"添加端口"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:551:11",className:"space-y-2 border border-[var(--dg-border)] rounded-lg p-2 bg-[var(--dg-bg-secondary)]",children:[g.map((o,x)=>e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:553:13",className:"overflow-x-auto",children:e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:554:13",className:"grid grid-cols-[minmax(80px,1fr)_80px_80px_80px_80px_32px] gap-2 items-center min-w-[480px]",children:[e.jsx(f,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:555:15",value:o.name,onChange:s=>w(x,"name",s.target.value),placeholder:"名称",className:"font-mono text-xs h-7 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"}),e.jsx(f,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:556:15",value:o.port,onChange:s=>w(x,"port",s.target.value),placeholder:"端口",type:"number",className:"font-mono text-xs h-7 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"}),e.jsx(f,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:557:15",value:o.targetPort,onChange:s=>w(x,"targetPort",s.target.value),placeholder:"目标",type:"number",className:"font-mono text-xs h-7 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"}),e.jsxs(G,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:558:15",value:o.protocol,onValueChange:s=>w(x,"protocol",s),children:[e.jsx(W,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:559:17",className:"h-7 text-xs bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",children:e.jsx(U,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:559:139"})}),e.jsxs(H,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:560:17",children:[e.jsx(Y,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:560:32",value:"TCP",children:"TCP"}),e.jsx(Y,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:560:72",value:"UDP",children:"UDP"})]})]}),u==="NodePort"?e.jsx(f,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:563:17",value:o.nodePort,onChange:s=>w(x,"nodePort",s.target.value),placeholder:"NodePort",type:"number",className:"font-mono text-xs h-7 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"}):e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:564:19"}),e.jsx(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:565:15",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-400 hover:text-red-300",onClick:()=>t(x),children:e.jsx(O,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:565:133",className:"h-3 w-3"})})]})},x)),g.length===0&&e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:569:34",className:"text-center py-4 text-[var(--dg-text-muted)] text-xs",children:"暂无端口,点击「添加端口」"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:574:9",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:575:11",className:"flex items-center justify-between mb-2",children:[e.jsx(T,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:576:13",className:"text-[var(--dg-text-secondary)] text-sm",children:"选择器 (Selector)"}),e.jsxs(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:577:13",variant:"outline",size:"sm",className:"h-7 text-xs",onClick:m,children:[e.jsx(L,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:577:95",className:"h-3 w-3 mr-1"}),"添加标签"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:579:11",className:"space-y-2",children:[V.map((o,x)=>e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:581:15",className:"flex items-center gap-2 min-w-0",children:[e.jsx(f,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:582:17",value:o.key,onChange:s=>c(x,"key",s.target.value),placeholder:"键 (如 app)",className:"flex-1 min-w-0 font-mono text-xs h-7 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"}),e.jsx("span",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:583:17",className:"text-[var(--dg-text-muted)] text-xs shrink-0",children:"="}),e.jsx(f,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:584:17",value:o.value,onChange:s=>c(x,"value",s.target.value),placeholder:"值 (如 nginx)",className:"flex-1 min-w-0 font-mono text-xs h-7 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"}),e.jsx(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:585:17",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-red-400 hover:text-red-300",onClick:()=>C(x),children:e.jsx(O,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:585:148",className:"h-3 w-3"})})]},x)),V.length===0&&e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:588:39",className:"text-center py-4 text-[var(--dg-text-muted)] text-xs",children:"暂无选择器"})]})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:593:7",className:"shrink-0 flex justify-end gap-2 pt-3 mt-2 border-t border-[var(--dg-border)]",children:e.jsxs(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:594:9",size:"sm",className:"bg-blue-600 hover:bg-blue-700",onClick:M,disabled:a,children:[a?e.jsx(A,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:595:21",className:"h-3.5 w-3.5 animate-spin mr-1"}):e.jsx(B,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:595:77",className:"h-3.5 w-3.5 mr-1"}),"保存 Service"]})})]})}function Se({manifest:n,clusterCode:l,onSave:a,saving:k,isCreate:j}){const y=n?.spec||{},[h,u]=i.useState(n?.metadata?.name||""),[R,g]=i.useState(y.ingressClassName||"nginx"),[v,V]=i.useState([]),[N,w]=i.useState(!1);i.useEffect(()=>{l&&(w(!0),$.getIngressClasses(l).then(s=>{const r=Array.isArray(s)?s:s?.list||s||[];if(V(r),j&&(!y.ingressClassName||y.ingressClassName==="nginx")&&r.length>0){const p=r.find(S=>S.name?.toLowerCase().includes("nginx"))||r[0];p?.name&&g(p.name)}}).catch(()=>{}).finally(()=>w(!1)))},[l]);const[b,t]=i.useState((y.rules||[]).map(s=>({host:s.host||"",paths:s.http?.backend?.servicePort!=null?[{path:"/",pathType:"Prefix",serviceName:s.http?.backend?.serviceName||"",servicePort:String(s.http?.backend?.servicePort||"80")}]:(s.http?.paths||[]).map(r=>({path:r.path||"/",pathType:r.pathType||"Prefix",serviceName:r.backend?.service?.name||r.backend?.serviceName||"",servicePort:String(r.backend?.service?.port?.number??r.backend?.servicePort??"80")}))}))),c=(s,r)=>{const p=[...b];p[s]={...p[s],host:r},t(p)},m=()=>t([...b,{host:"",paths:[{path:"/",pathType:"Prefix",serviceName:"",servicePort:"80"}]}]),C=s=>t(b.filter((r,p)=>p!==s)),M=(s,r,p,S)=>{const P=[...b];P[s].paths[r]={...P[s].paths[r],[p]:S},t(P)},I=s=>{const r=[...b];r[s].paths.push({path:"/",pathType:"Prefix",serviceName:"",servicePort:"80"}),t(r)},o=(s,r)=>{const p=[...b];p[s].paths=p[s].paths.filter((S,P)=>P!==r),t(p)},x=()=>{const s=b.map(p=>({host:p.host,http:{paths:p.paths.map(S=>({path:S.path,pathType:S.pathType,backend:{service:{name:S.serviceName,port:{number:parseInt(S.servicePort)||80}}}}))}})),r={...y,rules:s};R.trim()?r.ingressClassName=R.trim():delete r.ingressClassName,a({...n,metadata:{...n.metadata,name:h.trim()},spec:r})};return e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:687:5",className:"flex flex-col h-full min-h-0",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:688:7",className:"shrink-0 grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:689:9",className:"min-w-0",children:[e.jsx(T,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:690:11",className:"text-[var(--dg-text-secondary)] text-xs",children:"名称"}),e.jsx(f,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:691:11",value:h,onChange:s=>u(s.target.value),readOnly:!j,className:"mt-1 font-mono text-xs bg-[var(--dg-bg-tertiary)]"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:693:9",className:"min-w-0",children:[e.jsxs(T,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:694:11",className:"text-[var(--dg-text-secondary)] text-xs flex items-center gap-1",children:["Ingress Class",e.jsx("span",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:696:13",className:"text-[10px] text-[var(--dg-text-muted)]",children:"(可选)"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:699:11",className:"space-y-1 mt-1",children:[e.jsxs(G,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:700:13",value:R||"",onValueChange:s=>{s&&s!=="__manual__"&&g(s)},children:[e.jsx(W,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:708:15",className:"h-8 text-xs bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",children:e.jsx(U,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:709:17",placeholder:N?"加载中...":"选择或输入 IngressClass"})}),e.jsxs(H,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:711:15",children:[v.length>0?v.map(s=>e.jsxs(Y,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:714:21",value:s.name,children:[s.name," ",s.controller?e.jsxs("span",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:715:50",className:"text-[var(--dg-text-muted)] text-[10px]",children:["(",s.controller,")"]}):""]},s.name)):!N&&e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:719:38",className:"px-2 py-1.5 text-xs text-[var(--dg-text-muted)]",children:"未发现 IngressClass,请手动输入"}),R&&!v.some(s=>s.name===R)&&e.jsxs(Y,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:723:19",value:R,children:[R," (手动输入)"]}),e.jsx(Y,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:725:17",value:"__manual__",children:"—— 继续手动输入 ——"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:730:13",className:"text-[10px] text-[var(--dg-text-muted)] flex items-center gap-1",children:["手工输入:",e.jsx(f,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:732:15",value:R,onChange:s=>g(s.target.value),placeholder:"alb / nginx / my-ingress-class",className:"flex-1 font-mono text-xs h-7 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:741:13",className:"text-[10px] text-[var(--dg-text-muted)] leading-tight",children:["您的集群中可能有多个 IngressController,您可在此指定当前 Ingress 对应哪个 IngressController。",e.jsx("br",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:742:84"}),"从 IngressClass 列表选择,或手工输入名称。"]}),(v.length===0||R)&&e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:747:15",className:"text-[10px] text-[var(--dg-text-muted)]",children:["常见:",e.jsx("span",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:748:20",className:"font-mono",children:"alb"})," → ingress.k8s.alibabacloud/alb    ",e.jsx("span",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:748:103",className:"font-mono",children:"nginx"})," → k8s.io/ingress-nginx"]})]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:754:7",className:"flex-1 min-h-0 flex flex-col mt-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:755:9",className:"flex items-center justify-between mb-2 shrink-0",children:[e.jsx(T,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:756:11",className:"text-[var(--dg-text-secondary)] text-sm",children:"路由规则"}),e.jsxs(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:757:11",variant:"outline",size:"sm",className:"h-7 text-xs",onClick:m,children:[e.jsx(L,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:757:89",className:"h-3 w-3 mr-1"}),"添加 Host"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:759:9",className:"flex-1 min-h-0 overflow-y-auto pr-1 space-y-3 border border-[var(--dg-border)] rounded-lg p-2 bg-[var(--dg-bg-secondary)]",children:[b.map((s,r)=>e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:761:13",className:"p-3 rounded-lg border border-[var(--dg-border)] bg-[var(--dg-bg-tertiary)] space-y-2 min-w-0",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:762:15",className:"flex items-center gap-2 min-w-0",children:[e.jsx(f,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:763:17",value:s.host,onChange:p=>c(r,p.target.value),placeholder:"域名 (如 api.example.com)",className:"flex-1 min-w-0 font-mono text-xs h-7 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",title:s.host}),e.jsx(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:770:17",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-red-400 hover:text-red-300",onClick:()=>C(r),children:e.jsx(O,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:770:145",className:"h-3 w-3"})})]}),s.paths.map((p,S)=>e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:773:17",className:"overflow-x-auto pl-4",children:e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:774:19",className:"grid grid-cols-[minmax(80px,1fr)_100px_minmax(80px,1fr)_60px_28px] gap-1.5 items-center min-w-[420px]",children:[e.jsx(f,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:775:21",value:p.path,onChange:P=>M(r,S,"path",P.target.value),placeholder:"路径 /",className:"font-mono text-xs h-7 min-w-0 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"}),e.jsxs(G,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:776:21",value:p.pathType,onValueChange:P=>M(r,S,"pathType",P),children:[e.jsx(W,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:777:23",className:"h-7 text-xs bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",children:e.jsx(U,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:777:145"})}),e.jsxs(H,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:778:23",children:[e.jsx(Y,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:778:38",value:"Prefix",children:"Prefix"}),e.jsx(Y,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:778:84",value:"Exact",children:"Exact"})]})]}),e.jsx(f,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:780:21",value:p.serviceName,onChange:P=>M(r,S,"serviceName",P.target.value),placeholder:"Service",className:"font-mono text-xs h-7 min-w-0 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"}),e.jsx(f,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:781:21",value:p.servicePort,onChange:P=>M(r,S,"servicePort",P.target.value),placeholder:"端口",type:"number",className:"font-mono text-xs h-7 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"}),e.jsx(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:782:21",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-400 hover:text-red-300",onClick:()=>o(r,S),children:e.jsx(O,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:782:144",className:"h-3 w-3"})})]})},S)),e.jsxs(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:786:15",variant:"ghost",size:"sm",className:"h-6 text-xs text-[var(--dg-text-muted)]",onClick:()=>I(r),children:[e.jsx(L,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:786:129",className:"h-3 w-3 mr-1"}),"添加路径"]})]},r)),b.length===0&&e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:789:34",className:"text-center py-4 text-[var(--dg-text-muted)] text-xs",children:"暂无路由规则,点击「添加 Host」"})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:792:7",className:"shrink-0 flex justify-end gap-2 pt-3 mt-2 border-t border-[var(--dg-border)]",children:e.jsxs(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:793:9",size:"sm",className:"bg-blue-600 hover:bg-blue-700",onClick:x,disabled:k,children:[k?e.jsx(A,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:794:21",className:"h-3.5 w-3.5 animate-spin mr-1"}):e.jsx(B,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:794:77",className:"h-3.5 w-3.5 mr-1"}),"保存 Ingress"]})})]})}function Ce({manifest:n,onSave:l,saving:a,isCreate:k}){const j=n?.spec||{},y=j.resources?.requests||{},[h,u]=i.useState(n?.metadata?.name||""),[R,g]=i.useState(y.storage||"1Gi"),[v,V]=i.useState(j.accessModes?.[0]||"ReadWriteOnce"),[N,w]=i.useState(j.storageClassName||""),b=()=>{l({...n,metadata:{...n.metadata,name:h.trim()},spec:{...j,accessModes:[v],storageClassName:N||void 0,resources:{requests:{storage:R}}}})};return e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:827:5",className:"flex flex-col h-full",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:828:7",className:"shrink-0",children:[e.jsx(T,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:829:9",className:"text-[var(--dg-text-secondary)] text-xs",children:"名称"}),e.jsx(f,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:830:9",value:h,onChange:t=>u(t.target.value),readOnly:!k,className:"mt-1 font-mono text-xs bg-[var(--dg-bg-tertiary)]"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:832:7",className:"grid grid-cols-2 gap-4 mt-3 shrink-0",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:833:9",children:[e.jsx(T,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:834:11",className:"text-[var(--dg-text-secondary)] text-xs",children:"存储大小"}),e.jsx(f,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:835:11",value:R,onChange:t=>g(t.target.value),placeholder:"如 10Gi",className:"mt-1 font-mono text-xs h-8 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"}),e.jsx("p",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:841:11",className:"text-[10px] text-[var(--dg-text-muted)] mt-1",children:"单位:Gi (GiB), Mi (MiB), Ti (TiB)"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:843:9",children:[e.jsx(T,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:844:11",className:"text-[var(--dg-text-secondary)] text-xs",children:"访问模式"}),e.jsxs(G,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:845:11",value:v,onValueChange:V,children:[e.jsx(W,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:846:13",className:"mt-1 h-8 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] text-xs",children:e.jsx(U,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:847:15"})}),e.jsxs(H,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:849:13",children:[e.jsx(Y,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:850:15",value:"ReadWriteOnce",children:"ReadWriteOnce (单节点读写)"}),e.jsx(Y,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:851:15",value:"ReadOnlyMany",children:"ReadOnlyMany (多节点只读)"}),e.jsx(Y,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:852:15",value:"ReadWriteMany",children:"ReadWriteMany (多节点读写)"})]})]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:857:7",className:"shrink-0 mt-1",children:[e.jsx(T,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:858:9",className:"text-[var(--dg-text-secondary)] text-xs",children:"StorageClass"}),e.jsx(f,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:859:9",value:N,onChange:t=>w(t.target.value),placeholder:"留空使用默认 StorageClass",className:"mt-1 font-mono text-xs h-8 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:867:7",className:"flex-1"}),e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:869:7",className:"shrink-0 flex justify-end gap-2 pt-3 mt-2 border-t border-[var(--dg-border)]",children:e.jsxs(E,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:870:9",size:"sm",className:"bg-blue-600 hover:bg-blue-700",onClick:b,disabled:a,children:[a?e.jsx(A,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:871:21",className:"h-3.5 w-3.5 animate-spin mr-1"}):e.jsx(B,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:871:77",className:"h-3.5 w-3.5 mr-1"}),"保存 PVC"]})})]})}export{Ae as R,se as c}; diff --git a/backend/static/assets/ScriptManager-B_bCZqNG.js b/backend/static/assets/ScriptManager-B_bCZqNG.js deleted file mode 100644 index 9ef701d..0000000 --- a/backend/static/assets/ScriptManager-B_bCZqNG.js +++ /dev/null @@ -1,17 +0,0 @@ -import{j as t,r as i}from"./vendor-codemirror-B1SGo4xl.js";import{D as $,a as B,b as P,c as O,d as A,e as I,B as p,q as Z,f as Lt,t as l}from"./index-Dungj95X.js";import{I as D}from"./input-CXoUQQLm.js";import{S as tt,a as et,b as ot,c as st,d as z}from"./select-CiTqGGhE.js";import{T as _t,a as zt,b as G,c as K}from"./tabs-D87nAyJR.js";import{C as at}from"./checkbox-Bu55mX0G.js";import{s as j,t as $t}from"./automation-C9TdY9Jc.js";import{B as N}from"./badge-CGJlVD3L.js";import{a as Bt,y as ct,L as V,b as Pt,o as nt,aJ as rt,x as Ot,z as At,az as It,T as it,n as pt,r as Vt,S as qt,P as Rt}from"./vendor-icons-DmqcWdzX.js";import{L as v}from"./label-CMpUoC87.js";import{T as Ht}from"./textarea-BxfjmLq5.js";import{C as lt,b as Qt,c as Jt,d as Ut,a as mt}from"./card-BIfzBCEy.js";import"./index-5FEebgvX.js";function Xt(o){return{id:o.id,name:o.name,code:o.code||"",description:o.description||"",type:o.type||"shell",content:o.content||"",timeout:o.timeout||300,version:o.version||1,run_count:o.run_count||0,created_at:o.created_at,updated_at:o.updated_at}}const w=[{value:"shell",label:"Shell",sample:`#!/bin/bash -# 系统巡检脚本 -echo "===== 系统信息 =====" -uname -a -echo "" -echo "===== 磁盘使用 =====" -df -h -echo "" -echo "===== 内存使用 =====" -free -h -`},{value:"python",label:"Python",sample:`#!/usr/bin/env python3 -# 主机信息采集 -import platform, socket -print("主机名:", socket.gethostname()) -print("系统:", platform.platform()) -print("Python:", platform.python_version()) -`}],W={shell:"border-green-500/30 text-green-500 bg-green-500/10",bash:"border-green-500/30 text-green-500 bg-green-500/10",python:"border-blue-500/30 text-blue-500 bg-blue-500/10",powershell:"border-cyan-500/30 text-cyan-500 bg-cyan-500/10",yaml:"border-purple-500/30 text-purple-500 bg-purple-500/10"},dt=o=>t.jsx(N,{"code-path":"src/components/automation/script-helpers.tsx:67:3",variant:"outline",className:W[o]||W.shell,children:(o||"shell").toUpperCase()}),Y=()=>`sc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`;function xt(o){switch(o){case"pending":return t.jsxs(N,{"code-path":"src/components/automation/script-helpers.tsx:79:14",variant:"outline",className:"gap-1",children:[t.jsx(Pt,{"code-path":"src/components/automation/script-helpers.tsx:79:57",className:"w-3 h-3"}),"等待中"]});case"running":return t.jsxs(N,{"code-path":"src/components/automation/script-helpers.tsx:81:14",variant:"default",className:"bg-blue-500 gap-1",children:[t.jsx(V,{"code-path":"src/components/automation/script-helpers.tsx:81:69",className:"w-3 h-3 animate-spin"}),"执行中"]});case"success":return t.jsxs(N,{"code-path":"src/components/automation/script-helpers.tsx:83:14",variant:"default",className:"bg-green-600 gap-1",children:[t.jsx(ct,{"code-path":"src/components/automation/script-helpers.tsx:83:70",className:"w-3 h-3"}),"成功"]});case"failed":return t.jsxs(N,{"code-path":"src/components/automation/script-helpers.tsx:85:14",variant:"destructive",className:"gap-1",children:[t.jsx(Bt,{"code-path":"src/components/automation/script-helpers.tsx:85:61",className:"w-3 h-3"}),"失败"]});default:return t.jsx(N,{"code-path":"src/components/automation/script-helpers.tsx:87:14",variant:"secondary",children:o||"未知"})}}const Gt=o=>{if(!o)return"-";const a=new Date(o);return Number.isNaN(a.getTime())?"-":a.toLocaleString("zh-CN",{hour12:!1})},Kt=({open:o,onOpenChange:a,editingId:s,editingCode:n,formData:m,setFormData:x,onTypeChange:f,onSave:y})=>t.jsx($,{"code-path":"src/components/automation/ScriptFormDialog.tsx:38:5",open:o,onOpenChange:a,children:t.jsxs(B,{"code-path":"src/components/automation/ScriptFormDialog.tsx:39:7",className:"max-w-4xl max-h-[90vh]",children:[t.jsxs(P,{"code-path":"src/components/automation/ScriptFormDialog.tsx:40:9",children:[t.jsx(O,{"code-path":"src/components/automation/ScriptFormDialog.tsx:41:11",children:s!==null?"编辑脚本":"新建脚本"}),t.jsx(A,{"code-path":"src/components/automation/ScriptFormDialog.tsx:42:11",children:"编写运维脚本,支持 Shell / Python / PowerShell"})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:44:9",className:"space-y-4 overflow-y-auto max-h-[60vh] pr-1",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:45:11",className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:46:13",children:[t.jsx(v,{"code-path":"src/components/automation/ScriptFormDialog.tsx:47:15",children:"名称"}),t.jsx(D,{"code-path":"src/components/automation/ScriptFormDialog.tsx:48:15",value:m.name,onChange:r=>x({...m,name:r.target.value}),placeholder:"如:系统巡检脚本"})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:54:13",children:[t.jsx(v,{"code-path":"src/components/automation/ScriptFormDialog.tsx:55:15",children:"类型"}),t.jsxs(tt,{"code-path":"src/components/automation/ScriptFormDialog.tsx:56:15",value:m.type,onValueChange:f,children:[t.jsx(et,{"code-path":"src/components/automation/ScriptFormDialog.tsx:57:17",children:t.jsx(ot,{"code-path":"src/components/automation/ScriptFormDialog.tsx:57:32"})}),t.jsx(st,{"code-path":"src/components/automation/ScriptFormDialog.tsx:58:17",children:w.map(r=>t.jsx(z,{"code-path":"src/components/automation/ScriptFormDialog.tsx:60:21",value:r.value,children:r.label},r.value))})]})]})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:66:11",children:[t.jsx(v,{"code-path":"src/components/automation/ScriptFormDialog.tsx:67:13",children:"描述"}),t.jsx(D,{"code-path":"src/components/automation/ScriptFormDialog.tsx:68:13",value:m.description,onChange:r=>x({...m,description:r.target.value}),placeholder:"脚本用途说明"})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:74:11",className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:75:13",children:[t.jsx(v,{"code-path":"src/components/automation/ScriptFormDialog.tsx:76:15",children:"超时(秒)"}),t.jsx(D,{"code-path":"src/components/automation/ScriptFormDialog.tsx:77:15",type:"number",value:m.timeout,onChange:r=>x({...m,timeout:Number(r.target.value)}),placeholder:"300"})]}),s!==null&&t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:85:15",children:[t.jsx(v,{"code-path":"src/components/automation/ScriptFormDialog.tsx:86:17",children:"编码"}),t.jsx(D,{"code-path":"src/components/automation/ScriptFormDialog.tsx:87:17",value:n,disabled:!0,className:"font-mono text-xs"})]})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:91:11",children:[t.jsx(v,{"code-path":"src/components/automation/ScriptFormDialog.tsx:92:13",children:"脚本内容"}),t.jsx(Ht,{"code-path":"src/components/automation/ScriptFormDialog.tsx:93:13",value:m.content,onChange:r=>x({...m,content:r.target.value}),className:"min-h-[360px] font-mono text-sm",placeholder:"在此编写脚本内容..."})]})]}),t.jsxs(I,{"code-path":"src/components/automation/ScriptFormDialog.tsx:101:9",children:[t.jsx(p,{"code-path":"src/components/automation/ScriptFormDialog.tsx:102:11",variant:"outline",onClick:()=>a(!1),children:"取消"}),t.jsxs(p,{"code-path":"src/components/automation/ScriptFormDialog.tsx:103:11",onClick:y,children:[t.jsx(ct,{"code-path":"src/components/automation/ScriptFormDialog.tsx:104:13",className:"w-4 h-4 mr-2"}),s!==null?"保存":"创建"]})]})]})}),Wt=({open:o,onOpenChange:a,script:s,onEdit:n})=>t.jsx($,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:20:5",open:o,onOpenChange:a,children:t.jsxs(B,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:21:7",className:"max-w-4xl max-h-[90vh]",children:[t.jsxs(P,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:22:9",children:[t.jsxs(O,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:23:11",className:"flex items-center gap-2",children:[t.jsx(nt,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:24:13",className:"w-5 h-5 text-purple-500"}),s?.name,s&&dt(s.type)]}),t.jsx(A,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:28:11",children:s?.description})]}),t.jsx(Z,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:30:9",className:"h-[500px] w-full rounded-md border bg-black",children:t.jsx("pre",{"code-path":"src/components/automation/ScriptDetailDialog.tsx:31:11",className:"p-4 font-mono text-sm text-green-400 whitespace-pre-wrap",children:s?.content||"(空)"})}),t.jsxs(I,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:35:9",children:[t.jsx(p,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:36:11",variant:"outline",onClick:()=>a(!1),children:"关闭"}),s&&t.jsxs(p,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:38:13",onClick:()=>n(s),children:[t.jsx(rt,{"code-path":"src/components/automation/ScriptDetailDialog.tsx:39:15",className:"w-4 h-4 mr-2"}),"编辑"]})]})]})}),Yt=({open:o,onOpenChange:a,exec:s})=>t.jsx($,{"code-path":"src/components/automation/ScriptLogsDialog.tsx:18:5",open:o,onOpenChange:a,children:t.jsxs(B,{"code-path":"src/components/automation/ScriptLogsDialog.tsx:19:7",className:"max-w-4xl max-h-[90vh]",children:[t.jsxs(P,{"code-path":"src/components/automation/ScriptLogsDialog.tsx:20:9",children:[t.jsx(O,{"code-path":"src/components/automation/ScriptLogsDialog.tsx:21:11",children:"执行日志"}),t.jsxs(A,{"code-path":"src/components/automation/ScriptLogsDialog.tsx:22:11",children:[s?.task_name," · ",xt(s?.status||"")]})]}),t.jsx(Z,{"code-path":"src/components/automation/ScriptLogsDialog.tsx:26:9",className:"h-[480px] w-full rounded-md border bg-black",children:t.jsx("pre",{"code-path":"src/components/automation/ScriptLogsDialog.tsx:27:11",className:"p-4 font-mono text-sm text-green-400 whitespace-pre-wrap",children:s?.output||"暂无日志输出..."})}),t.jsx(I,{"code-path":"src/components/automation/ScriptLogsDialog.tsx:31:9",children:t.jsx(p,{"code-path":"src/components/automation/ScriptLogsDialog.tsx:32:11",variant:"outline",onClick:()=>a(!1),children:"关闭"})})]})});function Zt({script:o,selected:a,executing:s,onToggleSelect:n,onView:m,onExecute:x,onEdit:f,onClone:y,onDelete:r}){return t.jsxs(lt,{"code-path":"src/components/automation/ScriptCard.tsx:26:5",className:"hover:shadow-md transition-shadow",children:[t.jsxs(Qt,{"code-path":"src/components/automation/ScriptCard.tsx:27:7",className:"pb-3",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptCard.tsx:28:9",className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptCard.tsx:29:11",className:"flex items-center gap-2 min-w-0",children:[t.jsx(at,{"code-path":"src/components/automation/ScriptCard.tsx:30:13",checked:a,onCheckedChange:n,className:"border-[var(--dg-border)]"}),t.jsx(nt,{"code-path":"src/components/automation/ScriptCard.tsx:35:13",className:"w-5 h-5 text-purple-500 shrink-0"}),t.jsx(Jt,{"code-path":"src/components/automation/ScriptCard.tsx:36:13",className:"text-base truncate",children:o.name})]}),dt(o.type)]}),t.jsx(Ut,{"code-path":"src/components/automation/ScriptCard.tsx:40:9",className:"line-clamp-2",children:o.description||"暂无描述"})]}),t.jsxs(mt,{"code-path":"src/components/automation/ScriptCard.tsx:42:7",className:"pt-0",children:[t.jsx("div",{"code-path":"src/components/automation/ScriptCard.tsx:43:9",className:"bg-muted/40 rounded-md p-2 mb-3 font-mono text-xs text-muted-foreground overflow-hidden",children:t.jsx("pre",{"code-path":"src/components/automation/ScriptCard.tsx:44:11",className:"whitespace-pre-wrap line-clamp-3",children:o.content})}),t.jsxs("div",{"code-path":"src/components/automation/ScriptCard.tsx:46:9",className:"flex items-center justify-between text-xs text-muted-foreground mb-3",children:[t.jsxs("span",{"code-path":"src/components/automation/ScriptCard.tsx:47:11",children:["执行 ",o.run_count," 次 · v",o.version]}),t.jsxs("span",{"code-path":"src/components/automation/ScriptCard.tsx:48:11",children:["超时 ",o.timeout,"s"]})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptCard.tsx:50:9",className:"flex items-center gap-1",children:[t.jsx(p,{"code-path":"src/components/automation/ScriptCard.tsx:51:11",variant:"ghost",size:"sm",title:"查看内容",onClick:m,children:t.jsx(Ot,{"code-path":"src/components/automation/ScriptCard.tsx:52:13",className:"w-4 h-4"})}),t.jsx(p,{"code-path":"src/components/automation/ScriptCard.tsx:54:11",variant:"ghost",size:"sm",title:"执行",disabled:s,onClick:x,children:s?t.jsx(V,{"code-path":"src/components/automation/ScriptCard.tsx:56:17",className:"w-4 h-4 animate-spin text-blue-600"}):t.jsx(At,{"code-path":"src/components/automation/ScriptCard.tsx:57:17",className:"w-4 h-4 text-green-600"})}),t.jsx(p,{"code-path":"src/components/automation/ScriptCard.tsx:59:11",variant:"ghost",size:"sm",title:"编辑",onClick:f,children:t.jsx(rt,{"code-path":"src/components/automation/ScriptCard.tsx:60:13",className:"w-4 h-4"})}),t.jsx(p,{"code-path":"src/components/automation/ScriptCard.tsx:62:11",variant:"ghost",size:"sm",title:"复制",onClick:y,children:t.jsx(It,{"code-path":"src/components/automation/ScriptCard.tsx:63:13",className:"w-4 h-4"})}),t.jsx(p,{"code-path":"src/components/automation/ScriptCard.tsx:65:11",variant:"ghost",size:"sm",title:"删除",onClick:r,children:t.jsx(it,{"code-path":"src/components/automation/ScriptCard.tsx:66:13",className:"w-4 h-4 text-red-600"})})]})]})]})}function te({executions:o,onRefresh:a,onViewLogs:s}){return t.jsxs("div",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:16:5",className:"space-y-4",children:[t.jsx("div",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:17:7",className:"flex justify-end",children:t.jsxs(p,{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:18:9",variant:"outline",onClick:a,children:[t.jsx(pt,{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:19:11",className:"w-4 h-4 mr-2"}),"刷新"]})}),t.jsx(lt,{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:23:7",children:t.jsx(mt,{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:24:9",className:"p-0",children:t.jsx("div",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:25:11",className:"overflow-x-auto",children:t.jsxs("table",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:26:13",className:"w-full",children:[t.jsx("thead",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:27:15",className:"bg-muted/50",children:t.jsxs("tr",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:28:17",children:[t.jsx("th",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:29:19",className:"px-4 py-3 text-left text-sm font-medium",children:"#"}),t.jsx("th",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:30:19",className:"px-4 py-3 text-left text-sm font-medium",children:"脚本"}),t.jsx("th",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:31:19",className:"px-4 py-3 text-left text-sm font-medium",children:"状态"}),t.jsx("th",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:32:19",className:"px-4 py-3 text-left text-sm font-medium",children:"开始时间"}),t.jsx("th",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:33:19",className:"px-4 py-3 text-left text-sm font-medium",children:"耗时"}),t.jsx("th",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:34:19",className:"px-4 py-3 text-left text-sm font-medium",children:"操作"})]})}),t.jsx("tbody",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:37:15",className:"divide-y",children:o.length===0?t.jsx("tr",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:39:19",children:t.jsx("td",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:40:21",colSpan:6,className:"px-4 py-8 text-center text-muted-foreground",children:"暂无执行记录"})}):o.map(n=>t.jsxs("tr",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:46:21",className:"hover:bg-muted/50",children:[t.jsx("td",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:47:23",className:"px-4 py-3 text-sm text-muted-foreground",children:n.id}),t.jsx("td",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:48:23",className:"px-4 py-3 text-sm",children:n.task_name}),t.jsx("td",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:49:23",className:"px-4 py-3",children:xt(n.status)}),t.jsx("td",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:50:23",className:"px-4 py-3 text-sm text-muted-foreground",children:Gt(n.started_at)}),t.jsx("td",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:51:23",className:"px-4 py-3 text-sm",children:n.duration?`${(n.duration/1e3).toFixed(1)}s`:"-"}),t.jsx("td",{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:54:23",className:"px-4 py-3",children:t.jsx(p,{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:55:25",variant:"ghost",size:"sm",title:"查看日志",onClick:()=>s(n),children:t.jsx(Vt,{"code-path":"src/components/automation/ScriptExecutionsTable.tsx:56:27",className:"w-4 h-4"})})})]},n.id))})]})})})})]})}function he(){const o=Lt(),[a,s]=i.useState([]),[n,m]=i.useState([]),[x,f]=i.useState(!1),[y,r]=i.useState(!1),[q,ht]=i.useState(""),[F,ut]=i.useState("all"),[gt,St]=i.useState("scripts"),[h,T]=i.useState([]),[jt,E]=i.useState(!1),[ft,L]=i.useState(!1),[bt,R]=i.useState(!1),[C,H]=i.useState(null),[Q,J]=i.useState(null),[vt,Nt]=i.useState(null),[u,M]=i.useState({name:"",description:"",content:"",type:"shell",timeout:300}),S=async()=>{f(!0);try{const c=(await j.getScripts({page_size:100}))?.list||[];s(c.map(Xt))}catch{l.error("获取脚本列表失败")}finally{f(!1)}},k=async()=>{try{const c=(await $t.getExecutions({task_type:"script",page_size:50}))?.list||[];m(c)}catch{}};i.useEffect(()=>{S(),k()},[]);const yt=()=>{H(null),M({name:"",description:"",content:w[0].sample,type:"shell",timeout:300}),E(!0)},U=e=>{H(e.id),J(e),M({name:e.name,description:e.description,content:e.content,type:e.type,timeout:e.timeout}),E(!0),L(!1)},Ct=e=>{M(c=>{const g=w.some(_=>_.sample===c.content)||c.content==="",d=w.find(_=>_.value===e);return{...c,type:e,content:C===null&&g&&d?d.sample:c.content}})},Dt=async()=>{if(!u.name.trim()||!u.content.trim()){l.error("请填写名称和脚本内容");return}const e={name:u.name.trim(),code:Y(),description:u.description,type:u.type,content:u.content,timeout:Number(u.timeout)||300};try{C!==null?(await j.updateScript(C,e),l.success("脚本更新成功")):(await j.createScript(e),l.success("脚本创建成功")),E(!1),S()}catch{l.error(C!==null?"更新失败":"创建失败")}},wt=async e=>{try{await j.createScript({name:`${e.name} (副本)`,code:Y(),description:e.description,type:e.type,content:e.content,timeout:e.timeout}),l.success("复制成功"),S()}catch{l.error("复制失败")}},Tt=async e=>{if(await o({title:"删除脚本",description:`确定删除「${e.name}」吗?此操作不可恢复。`,confirmText:"删除",variant:"destructive"}))try{await j.deleteScript(e.id),l.success("删除成功"),S()}catch{l.error("删除失败")}},Et=async e=>{if(await o({title:"执行脚本",description:`将在 AIOps 主机上本地执行「${e.name}」(${e.type})。`,confirmText:"开始执行"})){r(!0);try{const g=await j.executeScript(e.id),d=g?.data??g;d?.status==="success"?l.success(`执行成功,耗时 ${d.duration??0}ms`):l.error(`执行失败,耗时 ${d?.duration??0}ms`,{description:(d?.output||"").slice(0,120)}),S(),k()}catch{l.error("执行请求失败")}finally{r(!1)}}},b=a.filter(e=>{const c=q.toLowerCase(),g=e.name.toLowerCase().includes(c)||e.description.toLowerCase().includes(c)||e.code.toLowerCase().includes(c),d=F==="all"||e.type===F;return g&&d}),Mt=e=>{T(c=>c.includes(e)?c.filter(g=>g!==e):[...c,e])},X=b.length>0&&h.length===b.length,kt=()=>{T(X?[]:b.map(e=>e.id))},Ft=async()=>{if(!(h.length===0||!await o({title:"批量删除脚本",description:`确定删除选中的 ${h.length} 个脚本吗?此操作不可恢复。`,confirmText:"批量删除",variant:"destructive"})))try{await j.batchDelete(h),l.success(`已删除 ${h.length} 个脚本`),T([]),S()}catch{l.error("批量删除失败")}};return t.jsxs("div",{"code-path":"src/components/automation/ScriptManager.tsx:253:5",className:"space-y-6",children:[t.jsxs(_t,{"code-path":"src/components/automation/ScriptManager.tsx:255:7",value:gt,onValueChange:e=>{St(e),e==="jobs"&&k()},children:[t.jsxs(zt,{"code-path":"src/components/automation/ScriptManager.tsx:256:9",className:"grid w-full grid-cols-2 lg:w-[360px]",children:[t.jsx(G,{"code-path":"src/components/automation/ScriptManager.tsx:257:11",value:"scripts",children:"脚本库"}),t.jsx(G,{"code-path":"src/components/automation/ScriptManager.tsx:258:11",value:"jobs",children:"执行记录"})]}),t.jsxs(K,{"code-path":"src/components/automation/ScriptManager.tsx:262:9",value:"scripts",className:"space-y-4",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptManager.tsx:263:11",className:"flex flex-wrap items-center justify-between gap-4",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptManager.tsx:264:13",className:"flex items-center gap-2 flex-1 min-w-[300px]",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptManager.tsx:265:15",className:"relative flex-1",children:[t.jsx(qt,{"code-path":"src/components/automation/ScriptManager.tsx:266:17",className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),t.jsx(D,{"code-path":"src/components/automation/ScriptManager.tsx:267:17",placeholder:"搜索名称、编码、描述...",value:q,onChange:e=>ht(e.target.value),className:"pl-10"})]}),t.jsxs(tt,{"code-path":"src/components/automation/ScriptManager.tsx:274:15",value:F,onValueChange:ut,children:[t.jsx(et,{"code-path":"src/components/automation/ScriptManager.tsx:275:17",className:"w-[140px]",children:t.jsx(ot,{"code-path":"src/components/automation/ScriptManager.tsx:276:19",placeholder:"类型"})}),t.jsxs(st,{"code-path":"src/components/automation/ScriptManager.tsx:278:17",children:[t.jsx(z,{"code-path":"src/components/automation/ScriptManager.tsx:279:19",value:"all",children:"全部类型"}),w.map(e=>t.jsx(z,{"code-path":"src/components/automation/ScriptManager.tsx:281:21",value:e.value,children:e.label},e.value))]})]})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptManager.tsx:286:13",className:"flex items-center gap-2",children:[t.jsxs(p,{"code-path":"src/components/automation/ScriptManager.tsx:287:15",variant:"outline",onClick:S,children:[t.jsx(pt,{"code-path":"src/components/automation/ScriptManager.tsx:288:17",className:"w-4 h-4 mr-2"}),"刷新"]}),t.jsxs(p,{"code-path":"src/components/automation/ScriptManager.tsx:291:15",onClick:yt,children:[t.jsx(Rt,{"code-path":"src/components/automation/ScriptManager.tsx:292:17",className:"w-4 h-4 mr-2"}),"新建脚本"]})]})]}),h.length>0&&t.jsxs("div",{"code-path":"src/components/automation/ScriptManager.tsx:300:13",className:"flex items-center justify-between gap-4 px-4 py-2.5 rounded-lg border border-[var(--dg-border)] bg-[var(--dg-bg-secondary)]",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptManager.tsx:301:15",className:"flex items-center gap-3",children:[t.jsx(at,{"code-path":"src/components/automation/ScriptManager.tsx:302:17",checked:X,onCheckedChange:kt,className:"border-[var(--dg-border)]"}),t.jsxs("span",{"code-path":"src/components/automation/ScriptManager.tsx:307:17",className:"text-sm text-[var(--dg-text-secondary)]",children:["已选择 ",h.length," 项 / 共 ",b.length," 项"]})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptManager.tsx:311:15",className:"flex items-center gap-2",children:[t.jsx(p,{"code-path":"src/components/automation/ScriptManager.tsx:312:17",variant:"outline",size:"sm",onClick:()=>T([]),children:"取消选择"}),t.jsxs(p,{"code-path":"src/components/automation/ScriptManager.tsx:315:17",variant:"outline",size:"sm",className:"border-red-500/30 text-red-400 hover:bg-red-500/10",onClick:Ft,children:[t.jsx(it,{"code-path":"src/components/automation/ScriptManager.tsx:321:19",className:"w-4 h-4 mr-2"}),"批量删除"]})]})]}),t.jsx("div",{"code-path":"src/components/automation/ScriptManager.tsx:329:11",className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:x?t.jsxs("div",{"code-path":"src/components/automation/ScriptManager.tsx:331:15",className:"col-span-full text-center py-8 text-muted-foreground",children:[t.jsx(V,{"code-path":"src/components/automation/ScriptManager.tsx:332:17",className:"w-5 h-5 animate-spin inline mr-2"}),"加载中..."]}):b.length===0?t.jsx("div",{"code-path":"src/components/automation/ScriptManager.tsx:336:15",className:"col-span-full text-center py-8 text-muted-foreground",children:a.length===0?"暂无脚本,点击「新建脚本」创建第一个":"未匹配到符合条件的脚本"}):b.map(e=>t.jsx(Zt,{"code-path":"src/components/automation/ScriptManager.tsx:341:17",script:e,selected:h.includes(e.id),executing:y,onToggleSelect:()=>Mt(e.id),onView:()=>{J(e),L(!0)},onExecute:()=>Et(e),onEdit:()=>U(e),onClone:()=>wt(e),onDelete:()=>Tt(e)},e.id))})]}),t.jsx(K,{"code-path":"src/components/automation/ScriptManager.tsx:359:9",value:"jobs",children:t.jsx(te,{"code-path":"src/components/automation/ScriptManager.tsx:360:11",executions:n,onRefresh:k,onViewLogs:e=>{Nt(e),R(!0)}})})]}),t.jsx(Kt,{"code-path":"src/components/automation/ScriptManager.tsx:369:7",open:jt,onOpenChange:E,editingId:C,editingCode:Q?.code||"",formData:u,setFormData:M,onTypeChange:Ct,onSave:Dt}),t.jsx(Wt,{"code-path":"src/components/automation/ScriptManager.tsx:381:7",open:ft,onOpenChange:L,script:Q,onEdit:U}),t.jsx(Yt,{"code-path":"src/components/automation/ScriptManager.tsx:389:7",open:bt,onOpenChange:R,exec:vt})]})}export{he as ScriptManager}; diff --git a/backend/static/assets/ServerManager-DRO89iT_.js b/backend/static/assets/ServerManager-DRO89iT_.js deleted file mode 100644 index 58751de..0000000 --- a/backend/static/assets/ServerManager-DRO89iT_.js +++ /dev/null @@ -1,11 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-38xDxc7G.js","assets/index-Dungj95X.js","assets/vendor-codemirror-B1SGo4xl.js","assets/vendor-icons-DmqcWdzX.js","assets/index-GY9Szy-F.css","assets/dashboard-D0JujfHp.js","assets/server-P3fi-cmJ.js","assets/region-CNZ3vwAq.js","assets/index-drGq01ok.js","assets/pipeline-DO4lDm_n.js","assets/config-BrfI0oO-.js","assets/credential-Cu8tj7EE.js","assets/automation-C9TdY9Jc.js","assets/alert-v1WaPeEX.js","assets/alert-center-Dr8niqD0.js","assets/site-Cslo2fp0.js","assets/trace-L8uY5gM3.js","assets/grafana-DTc3taUi.js","assets/datasource-DsDBrwno.js","assets/log-center-ELxahGiS.js","assets/metrics-DW1ylkmD.js","assets/agent-CZzlLHxR.js","assets/account--x8iUlBA.js","assets/platform-BwZ5CngP.js","assets/billing-DhtxUWwz.js","assets/audit-BpVBSeA1.js","assets/terminal-D5kNzib0.js","assets/approval-BY_CqGOr.js","assets/ai-D8ZhLQOB.js"])))=>i.map(i=>d[i]); -import{j as e,r as t}from"./vendor-codemirror-B1SGo4xl.js";import{J as xr,ah as Ar,D as Ie,a as Fe,b as Ke,c as ke,d as Ee,B as y,e as Qe,o as ir,m as ie,t as W,y as $r,w as Or,O as Dr,x as Je,A as Lr,P as zr,z as Hr,Z as Ur,i as Vr,ax as vr,ab as hr,ac as gr,ad as ur,ae as br,af as qe,ag as he,f as Wr}from"./index-Dungj95X.js";import{C as fe,a as we}from"./card-BIfzBCEy.js";import{I as V}from"./input-CXoUQQLm.js";import{C as ge}from"./checkbox-Bu55mX0G.js";import{b as Be,e as Z,T as qr,a as Gr,c as ne,d as Kr}from"./table-B2F10oba.js";import{S as $e,a as Oe,b as De,c as Le,d as G}from"./select-CiTqGGhE.js";import{u as Qr,q as Sr,a as Jr,b as Xr}from"./unwrap-DPwG25JA.js";import{u as Me}from"./useMutation-BkCR1EeO.js";import{s as ee}from"./server-P3fi-cmJ.js";import{S as Yr}from"./stat-strip-BSQFwFzG.js";import{B as O}from"./badge-CGJlVD3L.js";import{c as ye}from"./account--x8iUlBA.js";import{i as jr,ag as Pe,M as We,y as cr,w as ue,f as Ce,R as de,S as Nr,ab as Ae,h as ze,b8 as Xe,at as yr,au as fr,X as be,j as wr,as as Cr,L as He,ah as Ye,b9 as Zr,av as es,aX as nr,m as rs,aY as ss,v as Ze,T as er,ba as Ge,Q as ts,$ as os,N as as,H as cs,r as dr,aP as ns,aJ as ds,P as ls}from"./vendor-icons-DmqcWdzX.js";import{x as ps,a as ms}from"./vendor-xterm-20M9KZE1.js";import{m as xs,a as is,f as vs}from"./xterm-utils-slbfdUHf.js";import{c as rr,s as hs}from"./credential-Cu8tj7EE.js";import{r as gs}from"./region-CNZ3vwAq.js";import{L as X}from"./label-CMpUoC87.js";import{T as us}from"./textarea-BxfjmLq5.js";import"./index-5FEebgvX.js";function bs(r={page:1,page_size:100}){return Qr({queryKey:Sr.servers(r),queryFn:async()=>{const p=await ee.getServers(r);return{list:Xr(p),total:Jr(p)}},staleTime:3e4})}function Ss(){const r=xr(),p=()=>r.invalidateQueries({queryKey:["servers"]}),c=Me({mutationFn:b=>ee.createServer(b),onSuccess:p}),a=Me({mutationFn:({id:b,data:g})=>ee.updateServer(b,g),onSuccess:p}),o=Me({mutationFn:b=>ee.deleteServer(b),onSuccess:p}),v=Me({mutationFn:b=>ee.batchDelete(b),onSuccess:p});return{createMutation:c,updateMutation:a,deleteMutation:o,batchDeleteMutation:v,invalidate:p}}function js({servers:r}){const p=r.filter(o=>o.status==="running").length,c=r.filter(o=>o.status==="maintenance").length,a=r.filter(o=>o.status==="stopped").length;return e.jsx(Yr,{"code-path":"src/components/server/ServerStatsStrip.tsx:15:5",items:[{label:"服务器",value:r.length,color:"blue"},{label:"运行中",value:p,color:"emerald"},{label:"维护中",value:c,color:"amber"},{label:"已停止",value:a,color:"muted"}]})}const Ns=[{id:"aws",name:"AWS",color:"bg-orange-500",icon:"AWS"},{id:"aliyun",name:"阿里云",color:"bg-orange-600",icon:"AL"},{id:"tencent",name:"腾讯云",color:"bg-blue-500",icon:"TX"},{id:"huawei",name:"华为云",color:"bg-red-500",icon:"HW"},{id:"azure",name:"Azure",color:"bg-blue-600",icon:"AZ"}];function ys({open:r,onClose:p}){const[c,a]=t.useState([]),[o,v]=t.useState(1),[b,g]=t.useState(""),[x,_]=t.useState(null),[j,C]=t.useState([]),[u,I]=t.useState([]),[l,N]=t.useState(""),[f,i]=t.useState(!1),[h,F]=t.useState([]),[k,H]=t.useState([]),[D,w]=t.useState(!1),[L,m]=t.useState([]),[S,M]=t.useState(!1),[E,A]=t.useState(null),[Y,U]=t.useState("22"),[re,d]=t.useState([]),[$,K]=t.useState(""),Q=async()=>{try{const s=await ye.getAccounts();a(s?.list||[])}catch(s){console.error("加载云账号失败:",s)}};t.useEffect(()=>{r&&(Q(),Ar(async()=>{const{credentialApi:s}=await import("./index-38xDxc7G.js");return{credentialApi:s}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28])).then(({credentialApi:s})=>{s.list().then(R=>d(R?.list||[])).catch(()=>d([]))}))},[r]);const B=c.filter(s=>s.provider===b&&s.status==="active"),J=t.useCallback(async s=>{try{return(await ye.getAccountRegions(s))?.list||[]}catch{return[]}},[]),q=t.useCallback(async s=>{i(!0);try{await ye.syncRegions(s);const R=await J(s);C(R)}catch(R){throw console.error("同步区域失败:",R),R}finally{i(!1)}},[J]),P=t.useCallback(async()=>{if(!x)return;const s=await J(x.id);if(C(s),s.length===0)try{await q(x.id)}catch{}},[x,J,q]),me=t.useCallback(async()=>{if(!(!x||u.length===0)){w(!0),m([]),F([]),H([]);try{const s=await ye.discoverInstances(x.id,u);F(s?.list||[]),m(s?.errors||[])}catch(s){console.error("发现主机失败:",s),m([s?.message||"发现主机失败"])}finally{w(!1)}}},[x,u]),se=async()=>{if(!(!x||k.length===0)){M(!0);try{const s=h.filter(ae=>k.includes(ae.instance_id)),R=await ye.importInstances(x.id,s,{default_port:Number(Y)||22,credential_id:$?Number($):void 0});A(R||{imported:0,skipped:0})}catch(s){console.error("导入失败:",s)}finally{M(!1)}}},z=()=>{o===2&&x&&o<4?(v(3),P()):o<4&&v(o+1)},Se=()=>{o>1&&v(o-1)},Te=()=>{u.length===j.length&&j.length>0?I([]):I(j.map(s=>s.code))},Ve=s=>{H(R=>R.includes(s)?R.filter(ae=>ae!==s):[...R,s])},Re=()=>{k.length===h.length&&h.length>0?H([]):H(h.map(s=>s.instance_id))},je=()=>{p(),v(1),g(""),_(null),I([]),C([]),F([]),H([]),N(""),m([]),A(null),U("22"),K("")},oe=j.filter(s=>!l||s.name?.toLowerCase().includes(l.toLowerCase())||s.code?.toLowerCase().includes(l.toLowerCase())),ve=[{id:1,title:"公有云",icon:jr},{id:2,title:"访问凭据",icon:Pe},{id:3,title:"选择区域",icon:We},{id:4,title:"导入确认",icon:cr}];return e.jsx(Ie,{"code-path":"src/components/server/CloudServerImport.tsx:232:5",open:r,onOpenChange:je,children:e.jsxs(Fe,{"code-path":"src/components/server/CloudServerImport.tsx:233:7",className:"max-w-3xl bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",children:[e.jsxs(Ke,{"code-path":"src/components/server/CloudServerImport.tsx:234:9",children:[e.jsx(ke,{"code-path":"src/components/server/CloudServerImport.tsx:235:11",className:"text-xl",children:"导入云主机"}),e.jsx(Ee,{"code-path":"src/components/server/CloudServerImport.tsx:236:11",className:"sr-only",children:"从云平台批量导入主机资产"})]}),e.jsx("div",{"code-path":"src/components/server/CloudServerImport.tsx:240:9",className:"flex items-center justify-center mb-6 flex-wrap gap-1",children:ve.map((s,R)=>e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:242:13",className:"flex items-center",children:[e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:243:15",className:`flex items-center gap-2 px-3 py-2 rounded-lg text-sm ${o===s.id?"bg-blue-600 text-white":o>s.id?"bg-emerald-600/20 text-emerald-400":"bg-[var(--dg-bg-secondary)] text-[var(--dg-text-muted)]"}`,children:[e.jsx(s.icon,{"code-path":"src/components/server/CloudServerImport.tsx:250:17",className:"h-4 w-4"}),e.jsx("span",{"code-path":"src/components/server/CloudServerImport.tsx:251:17",className:"font-medium hidden sm:inline",children:s.title}),o>s.id&&e.jsx(ue,{"code-path":"src/components/server/CloudServerImport.tsx:252:33",className:"h-3 w-3 ml-1"})]}),Re.jsx(fe,{"code-path":"src/components/server/CloudServerImport.tsx:267:17",className:`cursor-pointer transition-all ${b===s.id?"border-blue-500 ring-2 ring-blue-500/30 bg-[var(--dg-bg-secondary)]":"border-[var(--dg-border)] hover:border-blue-500 bg-[var(--dg-bg-secondary)]"}`,onClick:()=>g(s.id),children:e.jsxs(we,{"code-path":"src/components/server/CloudServerImport.tsx:276:19",className:"p-4 flex items-center gap-3",children:[e.jsx("div",{"code-path":"src/components/server/CloudServerImport.tsx:277:21",className:`w-10 h-10 rounded-lg ${s.color} flex items-center justify-center text-white font-bold text-sm`,children:s.icon}),e.jsx("span",{"code-path":"src/components/server/CloudServerImport.tsx:280:21",className:"font-medium text-[var(--dg-text-primary)]",children:s.name})]})},s.id))})]}),o===2&&e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:290:11",className:"space-y-4",children:[e.jsx("p",{"code-path":"src/components/server/CloudServerImport.tsx:291:13",className:"text-[var(--dg-text-secondary)] text-sm",children:"请选择访问凭据(AccessKey)"}),B.length>0?e.jsx("div",{"code-path":"src/components/server/CloudServerImport.tsx:293:15",className:"space-y-2 max-h-[300px] overflow-y-auto",children:B.map(s=>e.jsx(fe,{"code-path":"src/components/server/CloudServerImport.tsx:295:19",className:`cursor-pointer transition-all ${x?.id===s.id?"border-blue-500 ring-1 ring-blue-500/30 bg-[var(--dg-bg-secondary)]":"border-[var(--dg-border)] hover:border-blue-500 bg-[var(--dg-bg-secondary)]"}`,onClick:()=>_(s),children:e.jsxs(we,{"code-path":"src/components/server/CloudServerImport.tsx:304:21",className:"p-3 flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:305:23",className:"flex items-center gap-3",children:[e.jsx(Pe,{"code-path":"src/components/server/CloudServerImport.tsx:306:25",className:"h-5 w-5 text-blue-400"}),e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:307:25",children:[e.jsx("p",{"code-path":"src/components/server/CloudServerImport.tsx:308:27",className:"font-medium text-[var(--dg-text-primary)]",children:s.name}),e.jsxs("p",{"code-path":"src/components/server/CloudServerImport.tsx:309:27",className:"text-xs text-[var(--dg-text-muted)]",children:[(s.access_key||s.accessKey||"******").slice(0,20),"..."]})]})]}),e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:314:23",className:"text-right",children:[e.jsxs(O,{"code-path":"src/components/server/CloudServerImport.tsx:315:25",className:"bg-emerald-500/20 text-emerald-400 border-0",children:[s.region_count??s.regionCount??0," 区域"]}),e.jsxs("p",{"code-path":"src/components/server/CloudServerImport.tsx:318:25",className:"text-xs text-[var(--dg-text-muted)] mt-1",children:[s.server_count??s.serverCount??0," 服务器"]})]})]})},s.id))}):e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:325:15",className:"text-center py-8 text-[var(--dg-text-muted)]",children:[e.jsx(Pe,{"code-path":"src/components/server/CloudServerImport.tsx:326:17",className:"h-12 w-12 mx-auto mb-3 opacity-50"}),e.jsx("p",{"code-path":"src/components/server/CloudServerImport.tsx:327:17",children:"该云平台暂无有效的访问凭据"})]})]}),o===3&&e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:335:11",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:336:13",className:"flex items-center justify-between",children:[e.jsxs("p",{"code-path":"src/components/server/CloudServerImport.tsx:337:15",className:"text-[var(--dg-text-secondary)] text-sm",children:["请选择要同步的区域",j.length>0&&e.jsxs("span",{"code-path":"src/components/server/CloudServerImport.tsx:340:19",className:"ml-2 text-[var(--dg-text-muted)]",children:["(共 ",j.length," 个区域,已选 ",u.length," 个)"]})]}),e.jsxs(y,{"code-path":"src/components/server/CloudServerImport.tsx:343:15",variant:"outline",size:"sm",className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)]",onClick:()=>x&&q(x.id),disabled:f,children:[e.jsx(de,{"code-path":"src/components/server/CloudServerImport.tsx:350:17",className:`h-3 w-3 mr-1 ${f?"animate-spin":""}`}),f?"同步中...":"刷新区域"]})]}),f?e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:356:15",className:"text-center py-12",children:[e.jsx(de,{"code-path":"src/components/server/CloudServerImport.tsx:357:17",className:"h-8 w-8 mx-auto mb-3 animate-spin text-blue-400"}),e.jsx("p",{"code-path":"src/components/server/CloudServerImport.tsx:358:17",className:"text-[var(--dg-text-secondary)]",children:"正在从云平台同步区域列表..."})]}):j.length===0?e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:361:15",className:"text-center py-8 text-[var(--dg-text-muted)]",children:[e.jsx(We,{"code-path":"src/components/server/CloudServerImport.tsx:362:17",className:"h-10 w-10 mx-auto mb-3 opacity-50"}),e.jsx("p",{"code-path":"src/components/server/CloudServerImport.tsx:363:17",children:"暂无区域数据"}),e.jsxs(y,{"code-path":"src/components/server/CloudServerImport.tsx:364:17",variant:"outline",size:"sm",className:"mt-3 border-[var(--dg-border)] text-blue-400",onClick:()=>x&&q(x.id),children:[e.jsx(de,{"code-path":"src/components/server/CloudServerImport.tsx:370:19",className:"h-3 w-3 mr-1"}),"立即同步"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:377:17",className:"flex items-center gap-2",children:[e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:378:19",className:"relative flex-1",children:[e.jsx(Nr,{"code-path":"src/components/server/CloudServerImport.tsx:379:21",className:"h-4 w-4 absolute left-3 top-1/2 -translate-y-1/2 text-[var(--dg-text-muted)]"}),e.jsx(V,{"code-path":"src/components/server/CloudServerImport.tsx:380:21",placeholder:"搜索区域名称或编码...",value:l,onChange:s=>N(s.target.value),className:"pl-9 bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]"})]}),e.jsx(y,{"code-path":"src/components/server/CloudServerImport.tsx:387:19",variant:"outline",size:"sm",onClick:Te,className:"border-[var(--dg-border)]",children:u.length===j.length&&j.length>0?"取消全选":"全选"})]}),e.jsx("div",{"code-path":"src/components/server/CloudServerImport.tsx:393:17",className:"border rounded-lg border-[var(--dg-border)] overflow-hidden max-h-[300px] overflow-y-auto",children:e.jsxs("table",{"code-path":"src/components/server/CloudServerImport.tsx:394:19",className:"w-full",children:[e.jsx("thead",{"code-path":"src/components/server/CloudServerImport.tsx:395:21",className:"bg-[var(--dg-bg-secondary)] sticky top-0",children:e.jsxs("tr",{"code-path":"src/components/server/CloudServerImport.tsx:396:23",children:[e.jsx("th",{"code-path":"src/components/server/CloudServerImport.tsx:397:25",className:"px-3 py-2 text-left text-xs font-medium text-[var(--dg-text-secondary)] w-10",children:e.jsx(ge,{"code-path":"src/components/server/CloudServerImport.tsx:398:27",checked:u.length===j.length&&j.length>0,onCheckedChange:Te})}),e.jsx("th",{"code-path":"src/components/server/CloudServerImport.tsx:403:25",className:"px-3 py-2 text-left text-xs font-medium text-[var(--dg-text-secondary)]",children:"区域编码"}),e.jsx("th",{"code-path":"src/components/server/CloudServerImport.tsx:404:25",className:"px-3 py-2 text-left text-xs font-medium text-[var(--dg-text-secondary)]",children:"区域名称"}),e.jsx("th",{"code-path":"src/components/server/CloudServerImport.tsx:405:25",className:"px-3 py-2 text-left text-xs font-medium text-[var(--dg-text-secondary)]",children:"Endpoint"})]})}),e.jsx("tbody",{"code-path":"src/components/server/CloudServerImport.tsx:408:21",className:"divide-y divide-[var(--dg-border)]",children:oe.map(s=>e.jsxs("tr",{"code-path":"src/components/server/CloudServerImport.tsx:410:25",className:`cursor-pointer hover:bg-[var(--dg-bg-hover)] ${u.includes(s.code)?"bg-blue-500/10":""}`,onClick:()=>{I(R=>R.includes(s.code)?R.filter(ae=>ae!==s.code):[...R,s.code])},children:[e.jsx("td",{"code-path":"src/components/server/CloudServerImport.tsx:421:27",className:"px-3 py-2",children:e.jsx(ge,{"code-path":"src/components/server/CloudServerImport.tsx:422:29",checked:u.includes(s.code)})}),e.jsx("td",{"code-path":"src/components/server/CloudServerImport.tsx:424:27",className:"px-3 py-2 text-sm text-blue-400 font-mono",children:s.code}),e.jsx("td",{"code-path":"src/components/server/CloudServerImport.tsx:425:27",className:"px-3 py-2 text-sm text-[var(--dg-text-primary)]",children:s.name}),e.jsx("td",{"code-path":"src/components/server/CloudServerImport.tsx:426:27",className:"px-3 py-2 text-xs text-[var(--dg-text-muted)] font-mono truncate max-w-[200px]",children:s.endpoint||"-"})]},s.id||s.code))})]})})]})]}),o===4&&e.jsx("div",{"code-path":"src/components/server/CloudServerImport.tsx:439:11",className:"space-y-4",children:E?e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:442:15",className:"text-center py-12",children:[e.jsx(cr,{"code-path":"src/components/server/CloudServerImport.tsx:443:17",className:"h-12 w-12 mx-auto mb-3 text-emerald-400"}),e.jsx("p",{"code-path":"src/components/server/CloudServerImport.tsx:444:17",className:"text-lg font-medium text-[var(--dg-text-primary)]",children:"导入完成"}),e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:445:17",className:"flex items-center justify-center gap-6 mt-4",children:[e.jsxs(O,{"code-path":"src/components/server/CloudServerImport.tsx:446:19",className:"bg-emerald-500/20 text-emerald-400 border-0 text-base px-4 py-1",children:["成功导入 ",E.imported," 台"]}),E.skipped>0&&e.jsxs(O,{"code-path":"src/components/server/CloudServerImport.tsx:450:21",className:"bg-amber-500/20 text-amber-400 border-0 text-base px-4 py-1",children:["跳过 ",E.skipped," 台(已存在)"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:458:17",className:"flex items-center justify-between",children:[e.jsxs("p",{"code-path":"src/components/server/CloudServerImport.tsx:459:19",className:"text-[var(--dg-text-secondary)] text-sm",children:["已选 ",u.length," 个区域",h.length>0&&e.jsxs("span",{"code-path":"src/components/server/CloudServerImport.tsx:462:23",className:"ml-2",children:["· 发现 ",h.length," 台主机"]})]}),e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:465:19",className:"flex items-center gap-2",children:[h.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(y,{"code-path":"src/components/server/CloudServerImport.tsx:468:25",variant:"outline",size:"sm",onClick:Re,className:"border-[var(--dg-border)]",children:k.length===h.length&&h.length>0?"取消全选":"全选"}),e.jsxs(O,{"code-path":"src/components/server/CloudServerImport.tsx:471:25",className:"bg-blue-500/20 text-blue-400 border-0",children:["已选 ",k.length," 台"]})]}),e.jsxs(y,{"code-path":"src/components/server/CloudServerImport.tsx:476:21",variant:"outline",size:"sm",onClick:me,disabled:D||u.length===0,className:"border-[var(--dg-border)] text-blue-400",children:[e.jsx(de,{"code-path":"src/components/server/CloudServerImport.tsx:483:23",className:`h-3 w-3 mr-1 ${D?"animate-spin":""}`}),D?"发现中...":h.length>0?"重新发现":"发现主机"]})]})]}),e.jsx("div",{"code-path":"src/components/server/CloudServerImport.tsx:490:17",className:"flex flex-wrap gap-1",children:u.map(s=>{const R=j.find(ae=>ae.code===s);return e.jsxs(O,{"code-path":"src/components/server/CloudServerImport.tsx:494:23",className:"bg-[var(--dg-bg-secondary)] text-[var(--dg-text-muted)] border border-[var(--dg-border)] text-xs",children:[e.jsx(We,{"code-path":"src/components/server/CloudServerImport.tsx:495:25",className:"h-3 w-3 mr-1"}),R?.name||s]},s)})}),L.length>0&&e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:504:19",className:"flex items-start gap-2 p-3 rounded-lg bg-amber-500/10 border border-amber-500/30 text-amber-400 text-sm",children:[e.jsx(Ae,{"code-path":"src/components/server/CloudServerImport.tsx:505:21",className:"h-4 w-4 mt-0.5 flex-shrink-0"}),e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:506:21",children:[e.jsx("p",{"code-path":"src/components/server/CloudServerImport.tsx:507:23",className:"font-medium",children:"部分区域发现失败:"}),L.map((s,R)=>e.jsx("p",{"code-path":"src/components/server/CloudServerImport.tsx:509:25",className:"text-xs mt-1 opacity-80",children:s},R))]})]}),D?e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:517:19",className:"text-center py-12",children:[e.jsx(de,{"code-path":"src/components/server/CloudServerImport.tsx:518:21",className:"h-8 w-8 mx-auto mb-3 animate-spin text-blue-400"}),e.jsx("p",{"code-path":"src/components/server/CloudServerImport.tsx:519:21",className:"text-[var(--dg-text-secondary)]",children:"正在发现云主机,请稍候..."}),e.jsx("p",{"code-path":"src/components/server/CloudServerImport.tsx:520:21",className:"text-xs text-[var(--dg-text-muted)] mt-1",children:"正在逐区域查询,可能需要数秒"})]}):h.length===0&&!D?e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:523:19",className:"text-center py-8 text-[var(--dg-text-muted)]",children:[e.jsx(ze,{"code-path":"src/components/server/CloudServerImport.tsx:524:21",className:"h-10 w-10 mx-auto mb-3 opacity-50"}),e.jsx("p",{"code-path":"src/components/server/CloudServerImport.tsx:525:21",children:'点击"发现主机"按钮,开始扫描所选区域'})]}):e.jsx("div",{"code-path":"src/components/server/CloudServerImport.tsx:528:19",className:"border rounded-lg border-[var(--dg-border)] overflow-hidden max-h-[300px] overflow-y-auto",children:e.jsxs("table",{"code-path":"src/components/server/CloudServerImport.tsx:529:21",className:"w-full",children:[e.jsx("thead",{"code-path":"src/components/server/CloudServerImport.tsx:530:23",className:"bg-[var(--dg-bg-secondary)] sticky top-0",children:e.jsxs("tr",{"code-path":"src/components/server/CloudServerImport.tsx:531:25",children:[e.jsx("th",{"code-path":"src/components/server/CloudServerImport.tsx:532:27",className:"px-3 py-2 text-left text-xs font-medium text-[var(--dg-text-secondary)] w-10",children:e.jsx(ge,{"code-path":"src/components/server/CloudServerImport.tsx:533:29",checked:k.length===h.length&&h.length>0,onCheckedChange:Re})}),e.jsx("th",{"code-path":"src/components/server/CloudServerImport.tsx:538:27",className:"px-3 py-2 text-left text-xs font-medium text-[var(--dg-text-secondary)]",children:"主机名"}),e.jsx("th",{"code-path":"src/components/server/CloudServerImport.tsx:539:27",className:"px-3 py-2 text-left text-xs font-medium text-[var(--dg-text-secondary)]",children:"IP地址"})]})}),e.jsx("tbody",{"code-path":"src/components/server/CloudServerImport.tsx:542:23",className:"divide-y divide-[var(--dg-border)]",children:h.map(s=>e.jsxs("tr",{"code-path":"src/components/server/CloudServerImport.tsx:544:27",className:`cursor-pointer hover:bg-[var(--dg-bg-hover)] ${k.includes(s.instance_id)?"bg-blue-500/10":""}`,onClick:()=>Ve(s.instance_id),children:[e.jsx("td",{"code-path":"src/components/server/CloudServerImport.tsx:549:29",className:"px-3 py-2",children:e.jsx(ge,{"code-path":"src/components/server/CloudServerImport.tsx:550:31",checked:k.includes(s.instance_id)})}),e.jsx("td",{"code-path":"src/components/server/CloudServerImport.tsx:552:29",className:"px-3 py-2 text-sm text-[var(--dg-text-primary)]",children:s.instance_name||s.hostname||"-"}),e.jsx("td",{"code-path":"src/components/server/CloudServerImport.tsx:553:29",className:"px-3 py-2 text-sm text-[var(--dg-text-secondary)]",children:s.private_ip||s.public_ip||"-"})]},s.instance_id))})]})}),h.length>0&&k.length>0&&e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:565:19",className:"grid grid-cols-2 gap-4 p-4 rounded-lg bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:566:21",children:[e.jsxs("label",{"code-path":"src/components/server/CloudServerImport.tsx:567:23",className:"block text-xs font-medium text-[var(--dg-text-secondary)] mb-1",children:["SSH 端口",e.jsx("span",{"code-path":"src/components/server/CloudServerImport.tsx:569:25",className:"text-[var(--dg-text-muted)] ml-1",children:"(导入时统一设置)"})]}),e.jsx(V,{"code-path":"src/components/server/CloudServerImport.tsx:571:23",type:"number",placeholder:"22",value:Y,onChange:s=>U(s.target.value),className:"w-32 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),e.jsxs("div",{"code-path":"src/components/server/CloudServerImport.tsx:579:21",children:[e.jsxs("label",{"code-path":"src/components/server/CloudServerImport.tsx:580:23",className:"block text-xs font-medium text-[var(--dg-text-secondary)] mb-1",children:["关联凭证",e.jsx("span",{"code-path":"src/components/server/CloudServerImport.tsx:582:25",className:"text-[var(--dg-text-muted)] ml-1",children:"(可选,用于SSH远程管理)"})]}),e.jsxs("select",{"code-path":"src/components/server/CloudServerImport.tsx:584:23",value:$,onChange:s=>K(s.target.value),className:"w-full px-3 py-1.5 bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] rounded-md text-[var(--dg-text-primary)] text-xs",children:[e.jsx("option",{"code-path":"src/components/server/CloudServerImport.tsx:589:25",value:"",children:"不使用凭据"}),re.map(s=>e.jsxs("option",{"code-path":"src/components/server/CloudServerImport.tsx:591:27",value:String(s.id),children:[s.type==="ssh_key"?"🔑":"🔒"," ",s.name]},s.id))]})]})]})]})}),e.jsxs(Qe,{"code-path":"src/components/server/CloudServerImport.tsx:605:9",className:"flex justify-between items-center",children:[e.jsx("div",{"code-path":"src/components/server/CloudServerImport.tsx:606:11",children:o>1&&!E&&e.jsxs(y,{"code-path":"src/components/server/CloudServerImport.tsx:608:15",variant:"outline",onClick:Se,className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)]",children:[e.jsx(Xe,{"code-path":"src/components/server/CloudServerImport.tsx:609:17",className:"h-4 w-4 mr-1"}),"上一步"]})}),e.jsx("div",{"code-path":"src/components/server/CloudServerImport.tsx:614:11",className:"flex gap-2",children:E?e.jsx(y,{"code-path":"src/components/server/CloudServerImport.tsx:616:15",onClick:je,className:"bg-blue-600 hover:bg-blue-700",children:"完成"}):e.jsxs(e.Fragment,{children:[e.jsx(y,{"code-path":"src/components/server/CloudServerImport.tsx:621:17",variant:"outline",onClick:je,className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)]",children:"取消"}),o<4?e.jsxs(y,{"code-path":"src/components/server/CloudServerImport.tsx:625:19",onClick:z,disabled:o===1&&!b||o===2&&!x||o===3&&u.length===0,className:"bg-blue-600 hover:bg-blue-700",children:["下一步",e.jsx(Ce,{"code-path":"src/components/server/CloudServerImport.tsx:635:21",className:"h-4 w-4 ml-1"})]}):e.jsx(y,{"code-path":"src/components/server/CloudServerImport.tsx:638:19",onClick:se,disabled:k.length===0||S,className:"bg-emerald-600 hover:bg-emerald-700",children:S?e.jsxs(e.Fragment,{children:[e.jsx(de,{"code-path":"src/components/server/CloudServerImport.tsx:645:25",className:"h-4 w-4 mr-1 animate-spin"}),"导入中..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{"code-path":"src/components/server/CloudServerImport.tsx:650:25",className:"h-4 w-4 mr-1"}),"确认导入 (",k.length,")"]})})]})})]})]})})}function fs({open:r,onOpenChange:p,serverId:c,serverName:a,serverIp:o,hasAuth:v=!0}){const b=t.useRef(null),g=t.useRef(null),x=t.useRef(null),_=t.useRef(null),[j,C]=t.useState(!1),[u,I]=t.useState(!1),[l,N]=t.useState([]),[f,i]=t.useState(""),[h,F]=t.useState(!1),[k,H]=t.useState(v);t.useEffect(()=>{!r||v||rr.list().then(w=>N(w?.list||[])).catch(()=>{})},[r,v]);const D=async()=>{if(!(!f||!c))try{F(!0),await hs.assign(c,Number(f)),W.success("凭据已关联"),H(!0)}catch(w){W.error(w?.message||"关联失败")}finally{F(!1)}};return t.useEffect(()=>{r||(H(v),i(""))},[r,v]),t.useEffect(()=>{if(!r||!c||!k)return;const w=new ps.Terminal({cursorBlink:!0,fontSize:13,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,theme:{background:"#0a0e14",foreground:"#d6d6d6",cursor:"#d6d6d6",selectionBackground:"rgba(255,255,255,0.2)"}}),L=new ms.FitAddon;w.loadAddon(L),g.current=w,_.current=L;const m=location.protocol==="https:"?"wss":"ws",S=ir.getState().token||"",M=`${m}://${location.host}/ws/terminal?id=${c}&cols=80&rows=24&token=${encodeURIComponent(S)}`,E=new WebSocket(M);return x.current=E,w.onData(A=>{E.readyState===WebSocket.OPEN&&E.send(JSON.stringify({status:0,data:A}))}),E.onmessage=A=>{try{const Y=JSON.parse(A.data);Y.status===0&&typeof Y.data=="string"&&w.write(Y.data)}catch{w.write(typeof A.data=="string"?A.data:"")}},E.onopen=()=>{C(!0),xs(w,L,()=>b.current,E)},E.onclose=()=>{C(!1),w.write(`\r -\x1B[31m[连接已关闭]\x1B[0m\r -`)},E.onerror=()=>{w.write(`\r -\x1B[31m[连接发生错误]\x1B[0m\r -`)},()=>{try{E.close(),w.dispose()}catch{}g.current=null,x.current=null,C(!1)}},[r,c,k]),t.useEffect(()=>{if(!r||!k)return;let w,L=0;const m=()=>{const S=b.current,M=_.current,E=g.current,A=x.current;if(!S||!M||!E){L++<30&&requestAnimationFrame(m);return}w=is(S,M,E,A);try{vs(M,E,A)}catch{}};return m(),()=>w?.()},[r,k,u]),e.jsx(Ie,{"code-path":"src/components/server/TerminalDialog.tsx:185:5",open:r,onOpenChange:p,children:e.jsxs(Fe,{"code-path":"src/components/server/TerminalDialog.tsx:186:7",showCloseButton:!1,className:ie("bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] p-0 gap-0","!duration-0 !transition-none",u?"!max-w-none !w-screen !h-screen !rounded-none !translate-x-0 !translate-y-0 !left-0 !top-0":""),style:u?{maxWidth:"100vw",width:"100vw",height:"100vh"}:{maxWidth:"960px",width:"92vw"},children:[e.jsxs(ke,{"code-path":"src/components/server/TerminalDialog.tsx:198:9",className:"sr-only",children:["终端 - ",a]}),e.jsx(Ee,{"code-path":"src/components/server/TerminalDialog.tsx:199:9",className:"sr-only",children:"SSH 终端连接"}),e.jsxs("div",{"code-path":"src/components/server/TerminalDialog.tsx:201:9",className:"flex items-center justify-between px-4 py-2 border-b border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/server/TerminalDialog.tsx:202:11",className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{"code-path":"src/components/server/TerminalDialog.tsx:203:13",className:ie("w-2 h-2 rounded-full",j?"bg-emerald-400":"bg-red-400")}),e.jsx("span",{"code-path":"src/components/server/TerminalDialog.tsx:204:13",className:"text-[var(--dg-text-primary)] font-medium",children:a}),e.jsxs("span",{"code-path":"src/components/server/TerminalDialog.tsx:205:13",className:"text-[var(--dg-text-muted)]",children:["(",o,")"]})]}),e.jsxs("div",{"code-path":"src/components/server/TerminalDialog.tsx:207:11",className:"flex items-center gap-1",children:[e.jsx("button",{"code-path":"src/components/server/TerminalDialog.tsx:208:13",onClick:()=>I(!u),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",children:u?e.jsx(yr,{"code-path":"src/components/server/TerminalDialog.tsx:212:29",className:"h-4 w-4"}):e.jsx(fr,{"code-path":"src/components/server/TerminalDialog.tsx:212:65",className:"h-4 w-4"})}),e.jsx("button",{"code-path":"src/components/server/TerminalDialog.tsx:214:13",onClick:()=>p(!1),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",children:e.jsx(be,{"code-path":"src/components/server/TerminalDialog.tsx:218:15",className:"h-4 w-4"})})]})]}),!k&&e.jsxs("div",{"code-path":"src/components/server/TerminalDialog.tsx:224:11",className:"p-6 flex flex-col items-center justify-center gap-4",style:{height:"480px"},children:[e.jsx(wr,{"code-path":"src/components/server/TerminalDialog.tsx:225:13",className:"h-12 w-12 text-amber-400"}),e.jsxs("div",{"code-path":"src/components/server/TerminalDialog.tsx:226:13",className:"text-center",children:[e.jsx("p",{"code-path":"src/components/server/TerminalDialog.tsx:227:15",className:"text-[var(--dg-text-primary)] font-medium mb-1",children:"服务器未配置认证凭据"}),e.jsx("p",{"code-path":"src/components/server/TerminalDialog.tsx:228:15",className:"text-sm text-[var(--dg-text-muted)]",children:"请选择一个凭据用于 SSH 连接"})]}),l.length===0?e.jsx("p",{"code-path":"src/components/server/TerminalDialog.tsx:231:15",className:"text-xs text-[var(--dg-text-muted)]",children:"暂无可用凭据,请先去「凭证配置」添加"}):e.jsxs("select",{"code-path":"src/components/server/TerminalDialog.tsx:233:15",value:f,onChange:w=>i(w.target.value),className:"w-64 px-3 py-2 bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] rounded-md text-[var(--dg-text-primary)] text-sm",children:[e.jsx("option",{"code-path":"src/components/server/TerminalDialog.tsx:238:17",value:"",children:"-- 选择凭据 --"}),l.map(w=>e.jsxs("option",{"code-path":"src/components/server/TerminalDialog.tsx:240:19",value:String(w.id),children:[w.type==="ssh_key"?"🔑":"🔒"," ",w.name]},w.id))]}),e.jsx(y,{"code-path":"src/components/server/TerminalDialog.tsx:246:13",onClick:D,disabled:!f||h,className:"bg-[var(--dg-blue)] hover:opacity-90 text-white",children:h?"关联中...":"确认连接"})]}),k&&e.jsx("div",{"code-path":"src/components/server/TerminalDialog.tsx:257:11",ref:b,className:"xterm-terminal-host",style:{height:u?"calc(100vh - 49px)":"520px"}})]})})}const ws=r=>r<1024?`${r} B`:r<1048576?`${(r/1024).toFixed(1)} KB`:`${(r/1048576).toFixed(2)} MB`;function Cs({open:r,onOpenChange:p,serverId:c,serverName:a}){const[o,v]=t.useState([]),[b,g]=t.useState([]),[x,_]=t.useState("/"),[j,C]=t.useState(!1),[u,I]=t.useState(""),[l,N]=t.useState(!1),[f,i]=t.useState(!1),h=t.useRef(null),F=t.useCallback(async m=>{if(c){C(!0),I("");try{const S=await ee.listFiles(c,m),M=S?.data||S;v(M.items||[]),g(M.breadcrumbs||[]),_(M.path||m)}catch(S){I(S?.message||"加载目录失败"),v([])}finally{C(!1)}}},[c]);t.useEffect(()=>{r&&c&&(i(!1),F("/"))},[r,c,F]);const k=async m=>{if(c)try{await ee.downloadFile(c,m)}catch(S){I("下载失败: "+(S?.message||""))}},H=async m=>{const S=m.target.files?.[0];if(!(!S||!c)){N(!0);try{await ee.uploadFile(c,x,S),await F(x)}catch(M){I(M?.message||"上传失败")}finally{N(!1),h.current&&(h.current.value="")}}},D=async(m,S)=>{if(!(!c||!confirm(`确认删除 ${S?"目录":"文件"} "${m}"?`)))try{await ee.deleteFile(c,m),await F(x)}catch(M){I(M?.message||"删除失败")}},w=async()=>{const m=prompt("输入目录名:");if(!m||!c)return;const S=x==="/"?`/${m}`:`${x}/${m}`;try{await ee.mkdir(c,S),await F(x)}catch(M){I(M?.message||"创建失败")}},L=[...o].sort((m,S)=>m.is_dir!==S.is_dir?m.is_dir?-1:1:m.name.localeCompare(S.name));return e.jsx(Ie,{"code-path":"src/components/server/ServerFileBrowser.tsx:146:5",open:r,onOpenChange:p,children:e.jsxs(Fe,{"code-path":"src/components/server/ServerFileBrowser.tsx:147:7",showCloseButton:!1,onInteractOutside:m=>{l&&m.preventDefault()},className:ie("bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] p-0 gap-0","!duration-0 !transition-none",f?"!max-w-none !w-screen !h-screen !rounded-none":""),style:f?{maxWidth:"100vw",width:"100vw",height:"100vh"}:{maxWidth:"95vw",width:"1100px",maxHeight:"92vh"},children:[e.jsxs(ke,{"code-path":"src/components/server/ServerFileBrowser.tsx:165:9",className:"sr-only",children:["文件浏览 — ",a]}),e.jsx(Ee,{"code-path":"src/components/server/ServerFileBrowser.tsx:166:9",className:"sr-only",children:"SFTP 文件管理 · 上传 · 下载 · 删除"}),e.jsxs("div",{"code-path":"src/components/server/ServerFileBrowser.tsx:169:9",className:"flex items-center justify-between px-4 py-2.5 border-b border-[var(--dg-border)] shrink-0",children:[e.jsxs("div",{"code-path":"src/components/server/ServerFileBrowser.tsx:170:11",className:"flex items-center gap-2 min-w-0",children:[e.jsx(Cr,{"code-path":"src/components/server/ServerFileBrowser.tsx:171:13",className:"h-4 w-4 text-[var(--dg-blue)] shrink-0"}),e.jsx("span",{"code-path":"src/components/server/ServerFileBrowser.tsx:172:13",className:"text-[var(--dg-text-primary)] font-medium text-sm truncate",children:a}),e.jsx("span",{"code-path":"src/components/server/ServerFileBrowser.tsx:175:13",className:"text-[var(--dg-text-muted)] text-xs",children:"· SFTP 文件管理"})]}),e.jsxs("div",{"code-path":"src/components/server/ServerFileBrowser.tsx:177:11",className:"flex items-center gap-1",children:[e.jsx("button",{"code-path":"src/components/server/ServerFileBrowser.tsx:178:13",onClick:()=>i(!f),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",title:f?"退出全屏":"全屏",children:f?e.jsx(yr,{"code-path":"src/components/server/ServerFileBrowser.tsx:183:29",className:"h-4 w-4"}):e.jsx(fr,{"code-path":"src/components/server/ServerFileBrowser.tsx:183:65",className:"h-4 w-4"})}),e.jsx("button",{"code-path":"src/components/server/ServerFileBrowser.tsx:185:13",onClick:()=>p(!1),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",children:e.jsx(be,{"code-path":"src/components/server/ServerFileBrowser.tsx:189:15",className:"h-4 w-4"})})]})]}),e.jsxs("div",{"code-path":"src/components/server/ServerFileBrowser.tsx:195:9",className:"flex items-center gap-2 px-4 py-2 border-b border-[var(--dg-border)] bg-[var(--dg-bg-primary)] shrink-0",children:[e.jsxs(y,{"code-path":"src/components/server/ServerFileBrowser.tsx:196:11",variant:"outline",size:"sm",className:"border-[var(--dg-border)] h-8",onClick:()=>F(x),children:[e.jsx(de,{"code-path":"src/components/server/ServerFileBrowser.tsx:198:13",className:"h-3.5 w-3.5 mr-1"}),"刷新"]}),e.jsxs("label",{"code-path":"src/components/server/ServerFileBrowser.tsx:200:11",children:[e.jsxs(y,{"code-path":"src/components/server/ServerFileBrowser.tsx:201:13",variant:"outline",size:"sm",className:"border-[var(--dg-border)] h-8 cursor-pointer",onClick:()=>h.current?.click(),disabled:l,children:[l?e.jsx(He,{"code-path":"src/components/server/ServerFileBrowser.tsx:203:28",className:"h-3.5 w-3.5 mr-1 animate-spin"}):e.jsx(Ye,{"code-path":"src/components/server/ServerFileBrowser.tsx:203:84",className:"h-3.5 w-3.5 mr-1"}),"上传"]}),e.jsx("input",{"code-path":"src/components/server/ServerFileBrowser.tsx:206:13",ref:h,type:"file",className:"hidden",onChange:H})]}),e.jsxs(y,{"code-path":"src/components/server/ServerFileBrowser.tsx:208:11",variant:"outline",size:"sm",className:"border-[var(--dg-border)] h-8",onClick:w,children:[e.jsx(Zr,{"code-path":"src/components/server/ServerFileBrowser.tsx:210:13",className:"h-3.5 w-3.5 mr-1"}),"新建目录"]}),u&&e.jsxs(O,{"code-path":"src/components/server/ServerFileBrowser.tsx:213:13",variant:"outline",className:"border-red-500/30 text-red-400 ml-auto",children:[e.jsx(be,{"code-path":"src/components/server/ServerFileBrowser.tsx:214:15",className:"h-3 w-3 mr-1 cursor-pointer",onClick:()=>I("")}),u]})]}),e.jsx("div",{"code-path":"src/components/server/ServerFileBrowser.tsx:221:9",className:"flex items-center gap-0.5 px-4 py-2 text-xs border-b border-[var(--dg-border)] bg-[var(--dg-bg-tertiary)] overflow-x-auto shrink-0",children:b.map((m,S)=>e.jsxs("span",{"code-path":"src/components/server/ServerFileBrowser.tsx:223:13",className:"flex items-center gap-0.5",children:[S===0?e.jsx("button",{"code-path":"src/components/server/ServerFileBrowser.tsx:225:17",onClick:()=>F("/"),className:"text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)] p-0.5",children:e.jsx(es,{"code-path":"src/components/server/ServerFileBrowser.tsx:229:19",className:"h-3.5 w-3.5"})}):e.jsx("button",{"code-path":"src/components/server/ServerFileBrowser.tsx:232:17",onClick:()=>F(m.path),className:"text-[var(--dg-blue)] hover:underline truncate max-w-[150px]",children:m.name}),S