import "../../../node_modules/element-plus/es/index.mjs";
/* empty css                                                       */
/* empty css                                                           */
/* empty css                                                            */
import { computed, createElementBlock, openBlock, createBlock, unref, withCtx, createTextVNode, createElementVNode, Fragment, renderList, createVNode } from "vue";
import { Plus as plus_default, Delete as delete_default } from "../../../node_modules/@element-plus/icons-vue/dist/index.mjs";
import ValueSelector from "./ValueSelector.vue.mjs";
/* empty css                  */
import _export_sfc from "../../../_virtual/_plugin-vue_export-helper.mjs";
import { ElButton } from "../../../node_modules/element-plus/es/components/button/index.mjs";
import { ElInput } from "../../../node_modules/element-plus/es/components/input/index.mjs";
const _hoisted_1 = { class: "params-config-container" };
const _hoisted_2 = {
  key: 1,
  class: "params-table"
};
const _hoisted_3 = { class: "params-body" };
const _hoisted_4 = { class: "params-cell key-params" };
const _hoisted_5 = { class: "params-cell value-params" };
const _hoisted_6 = { class: "params-cell action-cell" };
const _hoisted_7 = { class: "params-footer" };
const _sfc_main = {
  __name: "ParamsConfig",
  props: {
    modelValue: {
      type: Array,
      default: () => []
    },
    availableFields: {
      type: Array,
      default: () => []
    }
  },
  emits: ["update:modelValue"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const params = computed({
      get: () => props.modelValue,
      set: (val) => emit("update:modelValue", val)
    });
    const emit = __emit;
    function addParam() {
      params.value.push({
        id: Date.now(),
        key: "",
        value: ""
      });
    }
    function removeParam(index) {
      params.value.splice(index, 1);
    }
    return (_ctx, _cache) => {
      const _component_el_button = ElButton;
      const _component_el_input = ElInput;
      return openBlock(), createElementBlock("div", _hoisted_1, [
        unref(params).length === 0 ? (openBlock(), createBlock(_component_el_button, {
          key: 0,
          type: "primary",
          size: "small",
          icon: unref(plus_default),
          link: "",
          onClick: addParam
        }, {
          default: withCtx(() => _cache[0] || (_cache[0] = [
            createTextVNode(" 新增参数 ")
          ])),
          _: 1
        }, 8, ["icon"])) : (openBlock(), createElementBlock("div", _hoisted_2, [
          _cache[2] || (_cache[2] = createElementVNode("div", { class: "params-header" }, [
            createElementVNode("div", { class: "params-cell key-header" }, "键名"),
            createElementVNode("div", { class: "params-cell value-header" }, "值"),
            createElementVNode("div", { class: "params-cell action-header" })
          ], -1)),
          createElementVNode("div", _hoisted_3, [
            (openBlock(true), createElementBlock(Fragment, null, renderList(unref(params), (item, index) => {
              return openBlock(), createElementBlock("div", {
                key: item.id,
                class: "params-row"
              }, [
                createElementVNode("div", _hoisted_4, [
                  createVNode(_component_el_input, {
                    modelValue: item.key,
                    "onUpdate:modelValue": ($event) => item.key = $event,
                    placeholder: "参数名",
                    size: "small"
                  }, null, 8, ["modelValue", "onUpdate:modelValue"])
                ]),
                createElementVNode("div", _hoisted_5, [
                  createVNode(ValueSelector, {
                    modelValue: item.value,
                    "onUpdate:modelValue": ($event) => item.value = $event,
                    placeholder: "参数值",
                    size: "small"
                  }, null, 8, ["modelValue", "onUpdate:modelValue"])
                ]),
                createElementVNode("div", _hoisted_6, [
                  createVNode(_component_el_button, {
                    type: "danger",
                    size: "small",
                    icon: unref(delete_default),
                    text: "",
                    onClick: ($event) => removeParam(index)
                  }, null, 8, ["icon", "onClick"])
                ])
              ]);
            }), 128))
          ]),
          createElementVNode("div", _hoisted_7, [
            createVNode(_component_el_button, {
              type: "primary",
              size: "small",
              icon: unref(plus_default),
              link: "",
              onClick: addParam
            }, {
              default: withCtx(() => _cache[1] || (_cache[1] = [
                createTextVNode(" 新增参数 ")
              ])),
              _: 1
            }, 8, ["icon"])
          ])
        ]))
      ]);
    };
  }
};
const ParamsConfig = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-097f1353"]]);
export {
  ParamsConfig as default
};
