"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const index = require("../../../hooks/use-namespace/index.js");
const checkbox = require("./checkbox.js");
const useCheckbox = require("./composables/use-checkbox.js");
const Vue = require("vue");
const _hoisted_1 = [
  "id",
  "indeterminate",
  "name",
  "tabindex",
  "disabled"
];
var checkbox_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ Vue.defineComponent({
  name: "ElCheckbox",
  __name: "checkbox",
  props: checkbox.checkboxProps,
  emits: checkbox.checkboxEmits,
  setup(__props) {
    const props = __props;
    const { inputId, isLabeledByFormItem, isChecked, isDisabled, isFocused, checkboxSize, hasOwnLabel, model, actualValue, handleChange, onClickRoot } = useCheckbox.useCheckbox(props, Vue.useSlots());
    const inputBindings = Vue.computed(() => {
      if (props.trueValue || props.falseValue || props.trueLabel || props.falseLabel) return {
        "true-value": props.trueValue ?? props.trueLabel ?? true,
        "false-value": props.falseValue ?? props.falseLabel ?? false
      };
      return { value: actualValue.value };
    });
    const ns = index.useNamespace("checkbox");
    const compKls = Vue.computed(() => {
      return [
        ns.b(),
        ns.m(checkboxSize.value),
        ns.is("disabled", isDisabled.value),
        ns.is("bordered", props.border),
        ns.is("checked", isChecked.value)
      ];
    });
    const spanKls = Vue.computed(() => {
      return [
        ns.e("input"),
        ns.is("disabled", isDisabled.value),
        ns.is("checked", isChecked.value),
        ns.is("indeterminate", props.indeterminate),
        ns.is("focus", isFocused.value)
      ];
    });
    return (_ctx, _cache) => {
      return Vue.openBlock(), Vue.createBlock(Vue.resolveDynamicComponent(!Vue.unref(hasOwnLabel) && Vue.unref(isLabeledByFormItem) ? "span" : "label"), {
        for: !Vue.unref(hasOwnLabel) && Vue.unref(isLabeledByFormItem) ? null : Vue.unref(inputId),
        class: Vue.normalizeClass(compKls.value),
        "aria-controls": __props.indeterminate ? __props.ariaControls : null,
        "aria-checked": __props.indeterminate ? "mixed" : void 0,
        "aria-label": __props.ariaLabel,
        onClick: Vue.unref(onClickRoot)
      }, {
        default: Vue.withCtx(() => [Vue.createElementVNode("span", { class: Vue.normalizeClass(spanKls.value) }, [Vue.withDirectives(Vue.createElementVNode("input", Vue.mergeProps({
          id: Vue.unref(inputId),
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => Vue.isRef(model) ? model.value = $event : null),
          class: Vue.unref(ns).e("original"),
          type: "checkbox",
          indeterminate: __props.indeterminate,
          name: __props.name,
          tabindex: __props.tabindex,
          disabled: Vue.unref(isDisabled)
        }, inputBindings.value, {
          onChange: _cache[1] || (_cache[1] = (...args) => Vue.unref(handleChange) && Vue.unref(handleChange)(...args)),
          onFocus: _cache[2] || (_cache[2] = ($event) => isFocused.value = true),
          onBlur: _cache[3] || (_cache[3] = ($event) => isFocused.value = false),
          onClick: _cache[4] || (_cache[4] = Vue.withModifiers(() => {
          }, ["stop"]))
        }), null, 16, _hoisted_1), [[Vue.vModelCheckbox, Vue.unref(model)]]), Vue.createElementVNode("span", { class: Vue.normalizeClass(Vue.unref(ns).e("inner")) }, null, 2)], 2), Vue.unref(hasOwnLabel) ? (Vue.openBlock(), Vue.createElementBlock("span", {
          key: 0,
          class: Vue.normalizeClass(Vue.unref(ns).e("label"))
        }, [Vue.renderSlot(_ctx.$slots, "default"), !_ctx.$slots.default ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 0 }, [Vue.createTextVNode(Vue.toDisplayString(__props.label), 1)], 64)) : Vue.createCommentVNode("v-if", true)], 2)) : Vue.createCommentVNode("v-if", true)]),
        _: 3
      }, 8, [
        "for",
        "class",
        "aria-controls",
        "aria-checked",
        "aria-label",
        "onClick"
      ]);
    };
  }
});
exports.default = checkbox_vue_vue_type_script_setup_true_lang_default;
