"use client"; import { Target, TriangleAlert, X } from "lucide-react"; import Image from "next/image"; import { useMemo } from "react"; import { cn } from "@/lib/utils"; import { SCADA_ICON_PATHS } from "../map/scada"; import type { DetailFeature } from "../types"; import { formatFeaturePropertyValue, getLocalizedFeatureProperties } from "../utils/feature-properties"; type FeatureInsightPanelProps = { feature: DetailFeature | null; onClose: () => void; }; export function FeatureInsightPanel({ feature, onClose }: FeatureInsightPanelProps) { const metrics = useMemo(() => { if (!feature) { return []; } switch (feature.layer) { case "conduits": return [ ["管径", formatFeaturePropertyValue("diameter", feature.properties.diameter)], ["长度", formatFeaturePropertyValue("length", feature.properties.length)], ["粗糙系数", formatFeaturePropertyValue("roughness", feature.properties.roughness)], ["状态", formatFeaturePropertyValue("status", feature.properties.status)] ]; case "junctions": return [ ["最大深度", formatFeaturePropertyValue("max_depth", feature.properties.max_depth)], ["井底高程", formatFeaturePropertyValue("invert_elevation", feature.properties.invert_elevation)], ["对象类型", "检查井"], ["状态", "在线"] ]; case "orifices": return [ ["孔口类型", formatFeaturePropertyValue("orifice_type", feature.properties.orifice_type)], ["断面形状", formatFeaturePropertyValue("shape", feature.properties.shape)], ["流量系数", formatFeaturePropertyValue("discharge_coeff", feature.properties.discharge_coeff)], ["闸门", formatFeaturePropertyValue("gated", feature.properties.gated)] ]; case "pumps": return [ ["状态", formatFeaturePropertyValue("status", feature.properties.status)], ["泵曲线", formatFeaturePropertyValue("pump_curve", feature.properties.pump_curve)], ["启动水深", formatFeaturePropertyValue("startup_depth", feature.properties.startup_depth)], ["停泵水深", formatFeaturePropertyValue("shutoff_depth", feature.properties.shutoff_depth)] ]; case "outfalls": return [ ["排放类型", formatFeaturePropertyValue("outfall_type", feature.properties.outfall_type)], ["井底高程", formatFeaturePropertyValue("invert_elevation", feature.properties.invert_elevation)], ["阶段数据", formatFeaturePropertyValue("stage_data", feature.properties.stage_data)], ["状态", "在线"] ]; case "scada": return [ ["设备类型", formatFeaturePropertyValue("device_type_name", feature.properties.device_type_name)], ["运行状态", formatFeaturePropertyValue("active", feature.properties.active)], ["关联检查井", formatFeaturePropertyValue("junction_id", feature.properties.junction_id)], ["同步时间", formatFeaturePropertyValue("synced_at", feature.properties.synced_at)] ]; } }, [feature]); const propertyEntries = useMemo(() => { if (!feature) { return []; } return getLocalizedFeatureProperties(feature.properties); }, [feature]); return ( ); } function getScadaPresentation(rawTypeId: unknown) { const typeId = Number(rawTypeId); if (typeId === 72) return { iconPath: SCADA_ICON_PATHS.waterQuality, sectionClassName: "glass-normal border-teal-200", labelClassName: "text-teal-800" }; if (typeId === 58) return { iconPath: SCADA_ICON_PATHS.radarLevel, sectionClassName: "glass-info border-blue-200", labelClassName: "text-blue-800" }; if (typeId === 45) return { iconPath: SCADA_ICON_PATHS.ultrasonicFlow, sectionClassName: "glass-warning border-orange-200", labelClassName: "text-orange-800" }; return { iconPath: SCADA_ICON_PATHS.unknown, sectionClassName: "border-slate-200 bg-slate-50", labelClassName: "text-slate-800" }; }