"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                                                                       */
;/* empty css                                                                     */
;/* empty css                                                                  */
;/* empty css                                                               */
;/* empty css                                                                  */
;/* empty css                                                                        */
;/* empty css                                                                  */
;/* empty css                                                                 */
;/* empty css                                                                          */
;/* empty css                                                                    */
;/* empty css                                                                  */
;/* empty css                                                                             */
require("../../../../../node_modules/element-plus/theme-chalk/el-date-picker.css.js");
require("../../../../../node_modules/element-plus/theme-chalk/el-tooltip.css.js");
;/* empty css                                                                */
const Vue = require("vue");
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/form/index.js");
const index$1 = require("../../../../../node_modules/element-plus/es/components/input/index.js");
const index$2 = require("../../../../../node_modules/element-plus/es/components/button/index.js");
const index$3 = require("../../../../../node_modules/element-plus/es/components/date-picker/index.js");
const index$4 = require("../../../../../node_modules/element-plus/es/components/cascader/index.js");
const index$5 = require("../../../../../node_modules/element-plus/es/components/select/index.js");
const index$6 = require("../../../../../node_modules/element-plus/es/components/radio/index.js");
const index$7 = require("../../../../../node_modules/element-plus/es/components/checkbox/index.js");
const index$8 = require("../../../../../node_modules/element-plus/es/components/switch/index.js");
const index$9 = require("../../../../../node_modules/element-plus/es/components/link/index.js");
const index$a = require("../../../../../node_modules/element-plus/es/components/tooltip/index.js");
const _hoisted_1 = { class: "component-preview" };
const _hoisted_2 = {
  key: 0,
  class: "iconfont icon-iconZheng credit-icon"
};
const _hoisted_3 = {
  key: 1,
  class: "iconfont icon-iconJian regulation-icon"
};
const _hoisted_4 = { key: 3 };
const _hoisted_5 = { class: "prefix-content" };
const _hoisted_6 = { class: "suffix-content" };
const _hoisted_7 = { class: "prefix-content" };
const _hoisted_8 = { class: "suffix-content" };
const _sfc_main = {
  __name: "ComponentPreviewWrapper",
  props: {
    componentData: {
      type: Object,
      required: true
    }
  },
  setup(__props) {
    const currentInstance = Vue.getCurrentInstance();
    const ctx = currentInstance.proxy;
    const props = __props;
    const commProps = Vue.computed(() => {
      return {
        disabled: props.componentData.disabled,
        readonly: props.componentData.readOnly,
        placeholder: props.componentData.placeholder || "",
        modelValue: props.componentData.defaultValue,
        maxlength: props.componentData.maxLength,
        showWordLimit: props.componentData.showWordCount || false
      };
    });
    const { options } = optionLoader.useOptions(ctx, props.componentData);
    const cascaderPropsDataValue = Vue.computed(() => {
      let propsData = props.componentData.propsData || {};
      if (props.componentData.fieldType == "area" || props.componentData.fieldType == "industry") {
        propsData = {
          value: "optCode",
          label: "optName"
        };
      }
      return {
        ...propsData,
        multiple: props.componentData.multiple,
        checkStrictly: props.componentData.checkStrictly
      };
    });
    const cascaderOptions = Vue.computed(() => {
      var _a, _b;
      let oriOptions = options.value;
      let idField = (_a = props.componentData.optionConfig) == null ? void 0 : _a.idField;
      let pidField = (_b = props.componentData.optionConfig) == null ? void 0 : _b.pidField;
      if (props.componentData.fieldType == "area" || props.componentData.fieldType == "industry") {
        idField = "dicId";
        pidField = "pdicId";
      }
      const treeData = flatToTree(
        oriOptions,
        idField,
        pidField,
        props.componentData.maxLevel
      );
      return treeData;
    });
    function flatToTree(list, idKey = "id", pidKey = "pid", maxLevel = 10) {
      const data = JSON.parse(JSON.stringify(list));
      const nodeMap = {};
      data.forEach((node) => {
        nodeMap[node[idKey]] = node;
        node.children = node.children || [];
        node.level = 1;
      });
      const tree = [];
      data.forEach((node) => {
        const parentId = node[pidKey];
        const parentNode = nodeMap[parentId];
        if (parentNode && parentNode.level < maxLevel) {
          node.level = parentNode.level + 1;
          parentNode.children.push(node);
        } else {
          tree.push(node);
        }
      });
      return tree;
    }
    const computedFormat = Vue.computed(() => {
      const formatMap = {
        date: "YYYY-MM-DD",
        week: "YYYY年第w周",
        month: "YYYY-MM",
        year: "YYYY",
        datetime: "YYYY-MM-DD HH:mm:ss"
      };
      return formatMap[props.componentData.dateType] || "YYYY-MM-DD";
    });
    return (_ctx, _cache) => {
      const _component_el_link = index$9.ElLink;
      const _component_el_tooltip = index$a.ElTooltip;
      const _component_el_button = index$2.ElButton;
      const _component_el_input = index$1.ElInput;
      const _component_el_date_picker = index$3.ElDatePicker;
      const _component_el_cascader = index$4.ElCascader;
      const _component_el_option = index$5.ElOption;
      const _component_el_select = index$5.ElSelect;
      const _component_el_radio = index$6.ElRadio;
      const _component_el_radio_group = index$6.ElRadioGroup;
      const _component_el_checkbox = index$7.ElCheckbox;
      const _component_el_checkbox_group = index$7.ElCheckboxGroup;
      const _component_el_switch = index$8.ElSwitch;
      const _component_el_form_item = index.ElFormItem;
      return Vue.openBlock(), Vue.createElementBlock("div", _hoisted_1, [
        __props.componentData.fieldType != "blank" ? (Vue.openBlock(), Vue.createBlock(_component_el_form_item, {
          key: 0,
          placeholder: __props.componentData.placeholder,
          required: __props.componentData.required,
          class: "preview-form-item"
        }, Vue.createSlots({
          default: Vue.withCtx(() => [
            __props.componentData.labelMode != "label" ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 0 }, [
              __props.componentData.fieldType == "text" ? (Vue.openBlock(), Vue.createBlock(_component_el_input, Vue.normalizeProps(Vue.mergeProps({ key: 0 }, commProps.value)), Vue.createSlots({ _: 2 }, [
                __props.componentData.prefix ? {
                  name: "prefix",
                  fn: Vue.withCtx(() => [
                    Vue.createElementVNode("span", _hoisted_5, Vue.toDisplayString(__props.componentData.prefix), 1)
                  ]),
                  key: "0"
                } : void 0,
                __props.componentData.suffix ? {
                  name: "suffix",
                  fn: Vue.withCtx(() => [
                    Vue.createElementVNode("span", _hoisted_6, Vue.toDisplayString(__props.componentData.suffix), 1)
                  ]),
                  key: "1"
                } : void 0,
                !__props.componentData.disabled && __props.componentData.suffixButton && __props.componentData.suffixButton != "none" ? {
                  name: "append",
                  fn: Vue.withCtx(() => [
                    Vue.createVNode(_component_el_button, { class: "suffixButton" }, {
                      default: Vue.withCtx(() => [
                        Vue.createTextVNode(Vue.toDisplayString(__props.componentData.suffixButton == "dialog" ? __props.componentData.suffixDialogName ? __props.componentData.suffixDialogName : "选择" : __props.componentData.suffixButtonName), 1)
                      ]),
                      _: 1
                    })
                  ]),
                  key: "2"
                } : void 0
              ]), 1040)) : __props.componentData.fieldType == "userSelect" || __props.componentData.fieldType == "roleSelect" || __props.componentData.fieldType == "orgSelect" ? (Vue.openBlock(), Vue.createBlock(_component_el_input, Vue.normalizeProps(Vue.mergeProps({ key: 1 }, commProps.value)), Vue.createSlots({ _: 2 }, [
                !__props.componentData.readOnly && !__props.componentData.disabled ? {
                  name: "append",
                  fn: Vue.withCtx(() => [
                    Vue.createVNode(_component_el_button, { class: "suffixButton" }, {
                      default: Vue.withCtx(() => _cache[1] || (_cache[1] = [
                        Vue.createTextVNode("选择")
                      ])),
                      _: 1
                    })
                  ]),
                  key: "0"
                } : void 0
              ]), 1040)) : __props.componentData.fieldType == "textarea" ? (Vue.openBlock(), Vue.createBlock(_component_el_input, Vue.mergeProps({
                key: 2,
                rows: 4,
                type: "textarea"
              }, commProps.value, {
                resize: "none",
                style: { "height": "100%" }
              }), null, 16)) : Vue.createCommentVNode("", true),
              __props.componentData.fieldType == "number" ? (Vue.openBlock(), Vue.createBlock(_component_el_input, Vue.mergeProps({ key: 3 }, commProps.value, { controls: false }), Vue.createSlots({ _: 2 }, [
                __props.componentData.prefix ? {
                  name: "prefix",
                  fn: Vue.withCtx(() => [
                    Vue.createElementVNode("span", _hoisted_7, Vue.toDisplayString(__props.componentData.prefix), 1)
                  ]),
                  key: "0"
                } : void 0,
                __props.componentData.suffix ? {
                  name: "suffix",
                  fn: Vue.withCtx(() => [
                    Vue.createElementVNode("span", _hoisted_8, Vue.toDisplayString(__props.componentData.suffix), 1)
                  ]),
                  key: "1"
                } : void 0,
                !__props.componentData.disabled && __props.componentData.suffixButton && __props.componentData.suffixButton != "none" ? {
                  name: "append",
                  fn: Vue.withCtx(() => [
                    Vue.createVNode(_component_el_button, { class: "suffixButton" }, {
                      default: Vue.withCtx(() => [
                        Vue.createTextVNode(Vue.toDisplayString(__props.componentData.suffixButton == "dialog" ? __props.componentData.suffixDialogName ? __props.componentData.suffixDialogName : "选择" : __props.componentData.suffixButtonName), 1)
                      ]),
                      _: 1
                    })
                  ]),
                  key: "2"
                } : void 0
              ]), 1040)) : __props.componentData.fieldType == "date" ? (Vue.openBlock(), Vue.createBlock(_component_el_date_picker, Vue.mergeProps({ key: 4 }, commProps.value, {
                type: __props.componentData.dateType || "date",
                format: computedFormat.value,
                style: { "width": "100%" }
              }), null, 16, ["type", "format"])) : __props.componentData.fieldType == "cascader" || __props.componentData.fieldType == "area" || __props.componentData.fieldType == "industry" ? (Vue.openBlock(), Vue.createBlock(_component_el_cascader, Vue.mergeProps({ key: 5 }, commProps.value, {
                options: cascaderOptions.value,
                props: cascaderPropsDataValue.value,
                "show-all-levels": __props.componentData.showFullPath,
                style: { "width": "100%" }
              }), null, 16, ["options", "props", "show-all-levels"])) : __props.componentData.fieldType == "select" || __props.componentData.fieldType == "multipleSelection" ? (Vue.openBlock(), Vue.createBlock(_component_el_select, Vue.mergeProps({ key: 6 }, commProps.value, {
                multiple: __props.componentData.fieldType == "multipleSelection"
              }), {
                default: Vue.withCtx(() => [
                  (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(Vue.unref(options), (option) => {
                    return Vue.openBlock(), Vue.createBlock(_component_el_option, {
                      key: option.value,
                      label: option.label,
                      value: option.value
                    }, null, 8, ["label", "value"]);
                  }), 128))
                ]),
                _: 1
              }, 16, ["multiple"])) : __props.componentData.fieldType == "radio" ? (Vue.openBlock(), Vue.createBlock(_component_el_radio_group, Vue.normalizeProps(Vue.mergeProps({ key: 7 }, commProps.value)), {
                default: Vue.withCtx(() => [
                  (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(Vue.unref(options), (option) => {
                    return Vue.openBlock(), Vue.createBlock(_component_el_radio, {
                      key: option.value,
                      value: option.value
                    }, {
                      default: Vue.withCtx(() => [
                        Vue.createTextVNode(Vue.toDisplayString(option.label), 1)
                      ]),
                      _: 2
                    }, 1032, ["value"]);
                  }), 128))
                ]),
                _: 1
              }, 16)) : __props.componentData.fieldType == "checkbox" ? (Vue.openBlock(), Vue.createBlock(_component_el_checkbox_group, Vue.normalizeProps(Vue.mergeProps({ key: 8 }, commProps.value)), {
                default: Vue.withCtx(() => [
                  (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(Vue.unref(options), (option) => {
                    return Vue.openBlock(), Vue.createBlock(_component_el_checkbox, {
                      key: option.value,
                      value: option.value
                    }, {
                      default: Vue.withCtx(() => [
                        Vue.createTextVNode(Vue.toDisplayString(option.label), 1)
                      ]),
                      _: 2
                    }, 1032, ["value"]);
                  }), 128))
                ]),
                _: 1
              }, 16)) : Vue.createCommentVNode("", true),
              __props.componentData.fieldType == "switch" ? (Vue.openBlock(), Vue.createBlock(_component_el_switch, Vue.normalizeProps(Vue.mergeProps({ key: 9 }, commProps.value)), null, 16)) : Vue.createCommentVNode("", true),
              __props.componentData.fieldType == "upload" ? (Vue.openBlock(), Vue.createBlock(_component_el_input, Vue.normalizeProps(Vue.mergeProps({ key: 10 }, commProps.value)), null, 16)) : Vue.createCommentVNode("", true)
            ], 64)) : Vue.createCommentVNode("", true)
          ]),
          _: 2
        }, [
          __props.componentData.labelMode != "input" ? {
            name: "label",
            fn: Vue.withCtx(() => {
              var _a;
              return [
                __props.componentData.credit ? (Vue.openBlock(), Vue.createElementBlock("i", _hoisted_2)) : Vue.createCommentVNode("", true),
                __props.componentData.regulation ? (Vue.openBlock(), Vue.createElementBlock("i", _hoisted_3)) : Vue.createCommentVNode("", true),
                __props.componentData.labelLink ? (Vue.openBlock(), Vue.createBlock(_component_el_link, {
                  key: 2,
                  type: "primary"
                }, {
                  default: Vue.withCtx(() => [
                    Vue.createTextVNode(Vue.toDisplayString(__props.componentData.label), 1)
                  ]),
                  _: 1
                })) : (Vue.openBlock(), Vue.createElementBlock("span", _hoisted_4, Vue.toDisplayString(__props.componentData.label), 1)),
                ((_a = __props.componentData.tooltip) == null ? void 0 : _a.trim()) ? (Vue.openBlock(), Vue.createBlock(_component_el_tooltip, {
                  key: 4,
                  content: __props.componentData.tooltip,
                  placement: "top"
                }, {
                  default: Vue.withCtx(() => _cache[0] || (_cache[0] = [
                    Vue.createElementVNode("i", { class: "iconfont icon-tooltip info-icon" }, null, -1)
                  ])),
                  _: 1
                }, 8, ["content"])) : Vue.createCommentVNode("", true)
              ];
            }),
            key: "0"
          } : void 0
        ]), 1032, ["placeholder", "required"])) : Vue.createCommentVNode("", true)
      ]);
    };
  }
};
const ComponentPreviewWrapper = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-3fc3e6c0"]]);
exports.default = ComponentPreviewWrapper;
