"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                                                                          */
const Vue = require("vue");
const common = require("../../../utils/common.js");
const index = require("../../../../../../node_modules/element-plus/es/components/radio/index.js");
const _sfc_main = /* @__PURE__ */ Object.assign({
  inheritAttrs: false
}, {
  __name: "Radio",
  props: {
    config: {
      type: Object,
      required: true
    },
    modelValue: {
      type: null,
      default: ""
    },
    disabled: {
      type: Boolean,
      default: false
    },
    readonly: {
      type: Boolean,
      default: false
    },
    options: {
      type: Array,
      default: () => []
    },
    optionConfig: {
      type: Object,
      default: () => ({})
    }
  },
  emits: ["update:modelValue", "change"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const formData = Vue.inject("formData", null);
    const fieldsData = Vue.inject("fieldsData", []);
    const hiddenFields = Vue.inject("hiddenFields", []);
    const emit = __emit;
    const inputValue = Vue.computed({
      get: () => props.modelValue,
      set: (val) => {
        emit("update:modelValue", val);
        emit("change", val);
      }
    });
    const options = Vue.computed(() => {
      var _a;
      return ((_a = props.optionConfig) == null ? void 0 : _a.options) || [];
    });
    function handlerChange(val) {
      common.setFormDataByFieldMapping(
        val,
        false,
        options.value,
        props.optionConfig.fieldMapping,
        formData,
        [...fieldsData.value, ...hiddenFields.value]
      );
    }
    return (_ctx, _cache) => {
      const _component_el_radio = index.ElRadio;
      const _component_el_radio_group = index.ElRadioGroup;
      return Vue.openBlock(), Vue.createBlock(_component_el_radio_group, Vue.mergeProps({
        modelValue: inputValue.value,
        "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputValue.value = $event)
      }, Vue.toHandlers(__props.config.eventHandlers), {
        disabled: __props.disabled,
        style: {
          pointerEvents: __props.readonly ? "none" : "auto"
        },
        onChange: handlerChange
      }), {
        default: Vue.withCtx(() => [
          (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(options.value, (option) => {
            return Vue.openBlock(), Vue.createBlock(_component_el_radio, {
              value: option.value,
              label: option.label
            }, null, 8, ["value", "label"]);
          }), 256))
        ]),
        _: 1
      }, 16, ["modelValue", "disabled", "style"]);
    };
  }
});
exports.default = _sfc_main;
