'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../../../constants/index2.js');
require('../../../utils/index2.js');
require('../../../hooks/index2.js');
var checkbox = require('./checkbox4.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var index = require('../../../hooks/use-common-props/index2.js');
var index$1 = require('../../../hooks/use-namespace/index2.js');
var event = require('../../../constants/event2.js');
var error = require('../../../utils/error2.js');

const __default__ = {
  name: "ElCheckboxGroup"
};
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  ...__default__,
  props: checkbox.useCheckboxGroupProps,
  emits: checkbox.checkboxEmits,
  setup(__props, { emit }) {
    const props = __props;
    const { elFormItem } = checkbox.useCheckboxGroup();
    const { groupId, isLabeledByFormItem } = checkbox.useCheckboxGroupId(props, {
      elFormItem
    });
    const checkboxGroupSize = index.useSize();
    const ns = index$1.useNamespace("checkbox");
    const changeEvent = (value) => {
      emit(event.UPDATE_MODEL_EVENT, value);
      vue.nextTick(() => {
        emit("change", value);
      });
    };
    const modelValue = vue.computed({
      get() {
        return props.modelValue;
      },
      set(val) {
        changeEvent(val);
      }
    });
    vue.provide("CheckboxGroup", {
      name: "ElCheckboxGroup",
      modelValue,
      ...vue.toRefs(props),
      checkboxGroupSize,
      changeEvent
    });
    vue.watch(() => props.modelValue, () => {
      var _a;
      (_a = elFormItem.validate) == null ? void 0 : _a.call(elFormItem, "change").catch((err) => error.debugWarn(err));
    });
    return (_ctx, _cache) => {
      return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.tag), {
        id: vue.unref(groupId),
        class: vue.normalizeClass(vue.unref(ns).b("group")),
        role: "group",
        "aria-label": !vue.unref(isLabeledByFormItem) ? _ctx.label || "checkbox-group" : void 0,
        "aria-labelledby": vue.unref(isLabeledByFormItem) ? vue.unref(elFormItem).labelId : void 0
      }, {
        default: vue.withCtx(() => [
          vue.renderSlot(_ctx.$slots, "default")
        ]),
        _: 3
      }, 8, ["id", "class", "aria-label", "aria-labelledby"]);
    };
  }
});
var CheckboxGroup = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "/Users/wyf/work/element-plus/packages/components/checkbox/src/checkbox-group.vue"]]);

exports["default"] = CheckboxGroup;
//# sourceMappingURL=checkbox-group2.js.map
