import { n as e } from "./chunk-TYymryXo.mjs";
import { n as t, t as n } from "./selectedInfo-CT8ehCR8.mjs";
import { t as r } from "./drawerExpand-BHNJ9pB5.mjs";
import { computed as i, createBlock as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, createTextVNode as l, createVNode as u, defineComponent as d, inject as f, openBlock as p, ref as m, unref as h, watch as g, withCtx as _ } from "vue";
import { Button as v, Space as y, Table as b } from "ant-design-vue/es";
//#region src/pages/flow-create/flow-model/createComponents/flow/right-panel/components/expandAttribute.vue?vue&type=script&setup=true&lang.ts
var x = ["onClick"], S = ["onClick"], C = /* @__PURE__ */ d({
	name: "ExpandAttribute",
	__name: "expandAttribute",
	setup(e) {
		let d = m(), C = f("lf"), w = t(), T = n(), E = i(() => w.getElementById(T.selectId) || {}), D = m([]);
		g(E, (e) => {
			D.value = e.properties || [];
		}, { immediate: !0 });
		let O = [
			{
				title: "序号",
				key: "index",
				customRender: (e) => `${e.index + 1}`
			},
			{
				title: "属性名",
				dataIndex: "name",
				key: "name"
			},
			{
				title: "属性值",
				dataIndex: "value",
				key: "value"
			},
			{
				title: "操作",
				key: "action"
			}
		];
		function k(e, t, n) {
			e === "add" ? d.value?.open("add") : e === "edit" && t && n !== void 0 ? d.value?.open("edit", t, n) : e === "delete" && n !== void 0 && n >= 0 && D.value.splice(n, 1);
		}
		function A(e) {
			let t = e.index === void 0 ? -1 : e.index;
			t < 0 ? D.value.push({
				name: e.name,
				value: e.value
			}) : D.value[t] = {
				name: e.name,
				value: e.value
			};
		}
		return g(() => D.value, () => {
			w.updateElement(T.selectId, { properties: D.value }), C.value.setProperties(T.selectId, { properties: D.value });
		}, { deep: !0 }), (e, t) => {
			let n = v, i = y, f = b;
			return p(), s("div", null, [
				u(i, { "mb-10px": "" }, {
					default: _(() => [u(n, {
						size: "small",
						type: "primary",
						onClick: t[0] ||= (e) => k("add")
					}, {
						default: _(() => [...t[1] ||= [l(" 添加属性 ", -1)]]),
						_: 1
					})]),
					_: 1
				}),
				u(f, {
					size: "small",
					columns: O,
					"data-source": h(D),
					pagination: !1,
					"row-key": "key"
				}, {
					bodyCell: _(({ column: e, record: t, index: n }) => [e.key === "action" ? (p(), a(i, { key: 0 }, {
						default: _(() => [c("a", { onClick: (e) => k("edit", t, n) }, "编辑", 8, x), c("a", {
							style: {
								"margin-left": "8px",
								color: "red"
							},
							onClick: (e) => k("delete", t, n)
						}, "删除", 8, S)]),
						_: 2
					}, 1024)) : o("", !0)]),
					_: 1
				}, 8, ["data-source"]),
				u(r, {
					ref_key: "drawerExpandRef",
					ref: d,
					onSubmit: A
				}, null, 512)
			]);
		};
	}
}), w = /* @__PURE__ */ e({ default: () => T }), T = C;
//#endregion
export { w as n, T as t };
