"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
require("../../../../node_modules/element-plus/es/index.js");
;/* empty css                                                          */
;/* empty css                                                                  */
;/* empty css                                                               */
;/* empty css                                                            */
;/* empty css                                                               */
;/* empty css                                                                     */
;/* empty css                                                               */
const Vue = require("vue");
const index$1 = require("../../../../node_modules/@vueuse/core/dist/index.js");
const common = require("../utils/common.js");
;/* empty css             */
const _pluginVue_exportHelper = require("../../../../_virtual/_plugin-vue_export-helper.js");
const index = require("../../../../node_modules/element-plus/es/components/select/index.js");
const _sfc_main = {
  __name: "Trigger",
  props: {
    modelValue: [String, Number, null],
    options: Array,
    filterRules: Object
  },
  emits: ["update:modelValue"],
  setup(__props, { emit: __emit }) {
    const $props = __props;
    const $emits = __emit;
    const data = index$1.useVModel($props, "modelValue", $emits);
    const hiddenFieldsData = Vue.computed(() => {
      const editConfigData = common.getEditConfigData();
      return (editConfigData == null ? void 0 : editConfigData.hiddenFields) || [];
    });
    const groupedOptions = Vue.computed(() => {
      const formFields = $props.options.filter((item) => !item.isHidden);
      const hiddenFields = hiddenFieldsData.value.map((item) => ({
        id: item.id,
        label: item.label,
        fieldName: item.fieldName,
        type: "input",
        // 隐藏域默认为 input 类型
        value: item.value || "",
        options: [],
        isHidden: true
      }));
      const result = [];
      if (formFields.length > 0) {
        result.push({
          label: "表单字段",
          options: formFields.map((item) => ({
            id: item.id + "",
            label: item.label,
            value: item.id + ""
          }))
        });
      }
      if (hiddenFields.length > 0) {
        result.push({
          label: "隐藏域",
          options: hiddenFields.map((item) => ({
            id: item.id + "",
            label: item.label,
            value: item.id + ""
          }))
        });
      }
      return result;
    });
    return (_ctx, _cache) => {
      const _component_el_option = index.ElOption;
      const _component_el_option_group = index.ElOptionGroup;
      const _component_el_select = index.ElSelect;
      return Vue.openBlock(), Vue.createBlock(_component_el_select, {
        class: "trigger-container",
        modelValue: Vue.unref(data),
        "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => Vue.isRef(data) ? data.value = $event : null),
        filterable: "",
        placeholder: "选择字段"
      }, {
        default: Vue.withCtx(() => [
          (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(groupedOptions.value, (group) => {
            return Vue.openBlock(), Vue.createBlock(_component_el_option_group, {
              key: group.label,
              label: group.label
            }, {
              default: Vue.withCtx(() => [
                (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(group.options, (item) => {
                  return Vue.openBlock(), Vue.createBlock(_component_el_option, {
                    key: item.id,
                    label: item.label,
                    value: item.id
                  }, null, 8, ["label", "value"]);
                }), 128))
              ]),
              _: 2
            }, 1032, ["label"]);
          }), 128))
        ]),
        _: 1
      }, 8, ["modelValue"]);
    };
  }
};
const Trigger = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-8d97037c"]]);
exports.default = Trigger;
