import { n as e, r as t } from "./component-AqiMonitor-BUy1MSaP.mjs";
import { ElLoadingDirective as n, ElOption as r, ElSelect as i } from "element-plus/es";
import { Fragment as a, computed as o, createBlock as s, createCommentVNode as c, createElementBlock as l, createElementVNode as u, createTextVNode as d, createVNode as f, defineComponent as p, normalizeClass as m, onBeforeUnmount as h, onMounted as g, openBlock as _, ref as v, renderList as y, toDisplayString as b, withCtx as x, withDirectives as S } from "vue";
import "element-plus/es/components/loading/style/css";
import "element-plus/es/components/select/style/css";
import "element-plus/es/components/option/style/css";
//#region src/components/HighWayFreeze/HighWayFreeze.vue?vue&type=script&setup=true&lang.ts
var C = {
	class: "HighWayFreeze",
	"element-loading-background": "rgba(0, 0, 0, 0.4)"
}, w = { class: "HighWayFreeze-row" }, T = { class: "HighWayFreeze-row" }, E = { class: "HighWayFreeze-table" }, D = { class: "HighWayFreeze-table-head" }, O = { class: "metric-head" }, k = { class: "label" }, A = {
	key: 0,
	class: "warn-count"
}, j = { class: "HighWayFreeze-table-body" }, M = /* @__PURE__ */ e(/* @__PURE__ */ p({
	__name: "HighWayFreeze",
	props: {
		appKey: {
			type: String,
			default: ""
		},
		appSalt: {
			type: String,
			default: ""
		},
		baseHttp: {
			type: String,
			default: ""
		},
		ids: {
			type: Object,
			default: () => ({})
		}
	},
	emits: [
		"close",
		"addLine",
		"removeLine",
		"toMapView"
	],
	setup(e, { emit: p }) {
		let M = e, N = p, P = v(!1), F = v(""), I = v("上段"), L = v([]), R = v([
			"上段",
			"中段",
			"下段"
		]), z = v([]), B = v(null), V = o(() => J((z.value.find((e) => e.road_name === F.value && e.name === I.value)?.pointds || []).map((e, t) => ({
			pileNo: `路线${t + 1}`,
			temperature: q(e?.zdzds?.temperature),
			isWarn: e?.zdzds?.iswarntemp === 1
		})), (e) => e.isWarn)), H = o(() => V.value.filter((e) => e.isWarn).length);
		g(() => {
			U(), B.value = setInterval(() => {
				U();
			}, 1e3 * 60 * 10);
		}), h(() => {
			clearInterval(B.value);
		});
		let U = async () => {
			await K();
		}, W = () => {
			N("close", "HighWayFreeze");
		}, G = (e) => {
			F.value = e;
			let t = z.value.filter((e) => e.road_name === F.value);
			t.some((e) => e.name === I.value) || (I.value = t[0]?.name || R.value[0]);
		}, K = async () => {
			P.value = !0;
			let e = (await t({
				appKey: M.appKey,
				appSalt: M.appSalt,
				id: M.ids.data.id,
				variables: {},
				baseHttp: M.baseHttp,
				reqType: M.ids.data.reqType,
				isFormData: M.ids.data.isFormData
			})).data.result.ds || [];
			console.log("道路结冰", e), z.value = e, L.value = [...new Set(e.map((e) => e.road_name))].filter(Boolean).map((e) => ({ name: e })), L.value.some((e) => e.name === F.value) || (F.value = L.value[0]?.name || "");
			let n = e.filter((e) => e.road_name === F.value);
			n.some((e) => e.name === I.value) || (I.value = n[0]?.name || R.value[0]), Y(), P.value = !1;
		}, q = (e) => e == null || e === "" ? "--" : String(e), J = (e, t) => [...e].sort((e, n) => Number(t(n)) - Number(t(e))), Y = () => {
			N("removeLine", "line_HighWayFreeze");
			let e = { lineArr: [] };
			if (z.value.forEach((t) => {
				let n = t?.pointds || [], r = n.filter((e) => e?.zdzds?.iswarntemp === 1);
				if (r.length >= 2) {
					for (let t = 0; t < r.length - 1; t++) {
						let n = [r[t], r[t + 1]].map((e) => ({
							lng: Number(e.x),
							lat: Number(e.y)
						})).filter((e) => Number.isFinite(e.lng) && Number.isFinite(e.lat));
						n.length === 2 && e.lineArr.push({
							bAni: !1,
							color: "#ff4d4f",
							weight: 6,
							lineJson: n,
							otherData: { lineId: "line_HighWayFreeze" }
						});
					}
					return;
				}
				if (r.length !== 1) return;
				let i = r[0], a = n.findIndex((e) => e.id === i.id), o = (a === n.length - 1 ? [n[a - 1], i] : [i, n[a + 1]]).filter(Boolean).map((e) => ({
					lng: Number(e.x),
					lat: Number(e.y)
				})).filter((e) => Number.isFinite(e.lng) && Number.isFinite(e.lat));
				o.length === 2 && e.lineArr.push({
					bAni: !1,
					color: "#ff4d4f",
					weight: 4,
					lineJson: o,
					otherData: { lineId: "line_HighWayFreeze" }
				});
			}), !e.lineArr.length) return N("removeLine", "line_HighWayFreeze");
			N("addLine", {
				removeLine: "line_HighWayFreeze",
				mapLine: e
			});
		}, X = () => {
			let e = z.value.find((e) => e.road_name === F.value && e.name === I.value)?.pointds?.[0];
			e && N("toMapView", {
				lng: Number(e.x),
				lat: Number(e.y),
				zoom: 11
			});
		};
		return (e, t) => {
			let o = r, p = i, h = n;
			return S((_(), l("div", C, [
				u("div", { class: "HighWayFreeze-head" }, [u("div", { class: "HighWayFreeze-head-top" }, [t[2] ||= u("div", null, "隐患路段道路结冰实况报警", -1), u("div", {
					class: "closeBtn",
					onClick: W,
					title: "关闭"
				})]), t[3] ||= u("img", {
					class: "HighWayFreeze-head-line",
					src: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAbsAAAASBAMAAAAwI22/AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAwUExURQAAAAem/wem/wem/wem/wem/wem/wem/wem/wem/wem/wem/wem/wem/wem/wem/5bu5GYAAAAPdFJOUwAFwAwc2M8ULQYDn/hGXGnV2UoAAAGZSURBVEjH7ZM/S8NAGId/JYGmmeLspptThurk0CHWRXGo0Nk/S50y6CYSHMRF7Efo4uQXEIpbwUnM6OhnEIeChXjv5ZLLXdLtLCX68vDCe0eGJ7/3AJN1VcL+UImB/SruVJwYTqSAW5V3LLyaPR1c+IIdH12OPZiLcyTAjccZEdccZ0Nn4bXpC3KpCuFu5tkdziX3FJxBSBZZdFk9HempCduMk4xSitJTpOgJSSIPrx10YAUB0tYOwrQ1g12k7ZyODIYXZmQpppLV26rtbDFOXVhua2Fn7WTWwUEyAe5Zc2hiLWTTC3jjk8Hw+jrSM9/Z8raKOAtZVmyr9jbpee4lU9hvSUStw6YvOpqwiXlK9d8IL0Oq5tuqvc3KLMs7q9uyCC0y22aKvDVp4u2SjnJ1c+Wecg7h9gV4CFV8NHpEaw7yF2wVGcIa6OBx/Ax3PI6pRWx6Am98alBbpSODNVTxgAbQUpF3KeVv0s80xMUow8N//YVaqWEV9BJDdby2PBUZ1/te0uU0YzeLa623jjrrvaLOep/+str9ACyAtv25BhHcAAAAAElFTkSuQmCC",
					alt: ""
				}, null, -1)]),
				u("div", w, [t[4] ||= u("span", { class: "HighWayFreeze-label" }, "路线选择：", -1), f(p, {
					modelValue: F.value,
					"onUpdate:modelValue": t[0] ||= (e) => F.value = e,
					placeholder: "请选择路线",
					class: "dark-select",
					onChange: G,
					"no-data-text": "暂无数据"
				}, {
					default: x(() => [(_(!0), l(a, null, y(L.value, (e) => (_(), s(o, {
						key: e.name,
						label: e.name,
						value: e.name
					}, null, 8, ["label", "value"]))), 128))]),
					_: 1
				}, 8, ["modelValue"])]),
				u("div", T, [
					t[5] ||= u("span", { class: "HighWayFreeze-label" }, "路段选择：", -1),
					f(p, {
						modelValue: I.value,
						"onUpdate:modelValue": t[1] ||= (e) => I.value = e,
						placeholder: "请选择路段",
						class: "dark-select",
						"no-data-text": "暂无数据"
					}, {
						default: x(() => [(_(!0), l(a, null, y(R.value, (e) => (_(), s(o, {
							key: e,
							label: e,
							value: e
						}, null, 8, ["label", "value"]))), 128))]),
						_: 1
					}, 8, ["modelValue"]),
					u("button", {
						type: "button",
						class: "locate-btn",
						onClick: X
					}, "定位")
				]),
				u("div", E, [u("div", D, [t[7] ||= u("span", null, "路段", -1), u("span", O, [u("span", k, [t[6] ||= d(" 温度 ", -1), H.value > 0 ? (_(), l("span", A, "报警：" + b(H.value) + "条", 1)) : c("", !0)])])]), u("div", j, [(_(!0), l(a, null, y(V.value, (e) => (_(), l("div", {
					class: m(["HighWayFreeze-table-row", { "is-warn": e.isWarn }]),
					key: e.pileNo
				}, [u("span", null, b(e.pileNo), 1), u("span", null, b(e.temperature), 1)], 2))), 128))])])
			])), [[h, P.value]]);
		};
	}
}), [["__scopeId", "data-v-706cd106"]]);
//#endregion
export { M as t };
