"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
require("../../../../../node_modules/element-plus/es/index.js");
;/* empty css                                                             */
;/* empty css                                                                 */
const Vue = require("vue");
const common = require("../../utils/common.js");
const optionLoader = require("../../../utils/optionLoader.js");
;/* empty css                         */
const _pluginVue_exportHelper = require("../../../../../_virtual/_plugin-vue_export-helper.js");
const index = require("../../../../../node_modules/element-plus/es/components/input/index.js");
const _hoisted_1 = { class: "default-value-editor" };
const _sfc_main = {
  __name: "DefaultValueEditor",
  props: {
    config: {
      type: Object,
      required: true
    },
    modelValue: {
      type: [String, Number, Boolean, Array, Object],
      default: ""
    }
  },
  emits: ["update:modelValue", "change"],
  setup(__props, { emit: __emit }) {
    const currentInstance = Vue.getCurrentInstance();
    const ctx = currentInstance.proxy;
    const props = __props;
    const emit = __emit;
    const instance = Vue.getCurrentInstance();
    const localValue = Vue.ref(props.modelValue);
    Vue.watch(
      () => props.modelValue,
      (newValue) => {
        localValue.value = newValue;
      }
    );
    Vue.watch(
      () => localValue.value,
      (newValue) => {
        emit("update:modelValue", newValue);
        emit("change", newValue);
      }
    );
    const componentType = Vue.computed(() => {
      var _a, _b;
      if (!props.config.fieldType) return null;
      const key = props.config.fieldType.charAt(0).toUpperCase() + props.config.fieldType.slice(1);
      const component = (_b = (_a = instance == null ? void 0 : instance.appContext) == null ? void 0 : _a.components) == null ? void 0 : _b[`Fec${key}`];
      if (!component) {
        console.warn(`未找到对应的组件: Fec${key}，将使用 el-input 代替`);
        return null;
      }
      return component;
    });
    const { options: optionData } = optionLoader.useOptions(ctx, props.config);
    const componentProps = Vue.computed(() => {
      const fieldProps = common.cloneDeep(props.config);
      fieldProps.disabled = false;
      fieldProps.readonly = false;
      fieldProps.suffixButton = "none";
      if (fieldProps.optionConfig) {
        fieldProps.optionConfig.options = optionData.value;
      }
      delete fieldProps.id;
      return fieldProps;
    });
    return (_ctx, _cache) => {
      const _component_el_input = index.ElInput;
      return Vue.openBlock(), Vue.createElementBlock("div", _hoisted_1, [
        __props.config.fieldType && __props.config.fieldType !== "userSelect" && __props.config.fieldType !== "roleSelect" && __props.config.fieldType !== "orgSelect" ? (Vue.openBlock(), Vue.createBlock(Vue.resolveDynamicComponent(componentType.value), Vue.mergeProps({
          key: 0,
          modelValue: localValue.value,
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => localValue.value = $event)
        }, componentProps.value, {
          config: __props.config,
          formMode: "edit",
          placeholder: "默认值"
        }), null, 16, ["modelValue", "config"])) : (Vue.openBlock(), Vue.createBlock(_component_el_input, {
          key: 1,
          modelValue: localValue.value,
          "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => localValue.value = $event),
          placeholder: "请默认值"
        }, null, 8, ["modelValue"]))
      ]);
    };
  }
};
const DefaultValueEditor = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-7742453a"]]);
exports.default = DefaultValueEditor;
