import { warn as i } from "vue";
import { VALIDATION_MESSAGE_TYPES as r } from "../constants/index.js";
import { validationMessageValidator as n } from "../validators/index.js";
import { formatMessages as l } from "../utils/index.js";
const s = {
  inheritAttrs: !1,
  props: {
    /**
     * A provided label for the input
     */
    label: {
      type: String,
      default: ""
    },
    /**
     * The name of the input
     */
    name: {
      type: String,
      default: ""
    },
    /**
     * The value of the input
     */
    value: {
      type: [String, Number, Boolean, Object],
      default: null
    },
    /**
     * Describes the input
     */
    description: {
      type: String,
      default: ""
    },
    /**
     * Disables the input
     */
    disabled: {
      type: Boolean,
      default: !1
    },
    /**
     * The validation state of the input
     */
    validationState: {
      type: String,
      default: "",
      validator: (e) => e ? Object.values(r).includes(e) : !0
    },
    /**
     * Used to customize the input element
     */
    inputClass: {
      type: [String, Array, Object],
      default: ""
    },
    /**
     * Used to customize the label container
     */
    labelClass: {
      type: [String, Array, Object],
      default: ""
    },
    /**
     * Used to customize the description container
     */
    descriptionClass: {
      type: [String, Array, Object],
      default: ""
    },
    /**
     * A set of props that are passed into the label container
     */
    labelChildProps: {
      type: Object,
      default: () => ({})
    },
    /**
     * A set of props that are passed into the description container
     */
    descriptionChildProps: {
      type: Object,
      default: () => ({})
    },
    /**
     * Additional class name for the root element.
     * Can accept all of: String, Object, and Array, i.e. has the
     * same api as Vue's built-in handling of the class attribute.
     */
    rootClass: {
      type: [String, Object, Array],
      default: ""
    }
  },
  data() {
    return {
      internalDisabled: this.disabled,
      internalValidationState: this.validationState
    };
  },
  watch: {
    disabled(e) {
      this.internalDisabled = e;
    },
    validationState(e) {
      this.internalValidationState = e;
    }
  },
  methods: {
    /**
     * @param {Boolean | String} hasLabelOrLabel either a boolean indicating the label exists or the label itself
     * @param {String} ariaLabel the aria-label passed (null/undefined if it's not passed)
     */
    validateInputLabels(e, t) {
      !e && !t && i(
        "You must provide an aria-label when there is no label passed",
        this
      );
    }
  }
}, o = {
  props: {
    /**
     * Used to set the checked state of the checkable input
     * @model modelValue
     */
    modelValue: {
      type: Boolean,
      default: !1
    },
    /**
     * Indeterminate State, toggling indeterminate checkbox will uncheck
     */
    indeterminate: {
      type: Boolean,
      default: !1
    },
    /**
     * The value of the input
     */
    value: {
      type: [String, Number, Boolean],
      default: null
    }
  },
  data() {
    return {
      internalChecked: this.modelValue,
      internalIndeterminate: this.indeterminate
    };
  },
  watch: {
    modelValue(e) {
      this.internalChecked = e;
    },
    indeterminate(e) {
      this.internalIndeterminate = e;
    }
  }
}, u = {
  inject: {
    // Object used to pass data from the group
    groupContext: {
      default: {}
    },
    // Method used to update the group value
    setGroupValue: {
      default: () => () => {
      }
    }
  },
  data() {
    return {
      internalValue: this.value
    };
  },
  computed: {
    hasGroup() {
      return Object.prototype.hasOwnProperty.call(this.groupContext, "name");
    },
    groupName() {
      var e;
      return ((e = this.groupContext) == null ? void 0 : e.name) ?? "";
    },
    groupValue() {
      var e;
      return (e = this.groupContext) == null ? void 0 : e.value;
    },
    groupDisabled() {
      var e;
      return ((e = this.groupContext) == null ? void 0 : e.disabled) ?? !1;
    },
    groupValidationState() {
      var e;
      return ((e = this.groupContext) == null ? void 0 : e.validationState) ?? null;
    },
    internalName() {
      return this.name || this.groupName;
    }
  },
  watch: {
    value(e) {
      this.internalValue = e;
    },
    groupValue: {
      immediate: !0,
      handler(e) {
        this.hasGroup && (this.internalValue = e);
      }
    },
    groupDisabled: {
      immediate: !0,
      handler(e) {
        this.hasGroup && (this.internalDisabled = this.disabled || e);
      }
    },
    groupValidationState: {
      immediate: !0,
      handler(e) {
        this.hasGroup && (this.internalValidationState = e || this.validationState);
      }
    }
  },
  created() {
    var a;
    const e = Object.prototype.hasOwnProperty.call(this.groupContext, "name"), t = (a = this.groupContext) == null ? void 0 : a.name;
    this.name && e && t !== this.name && i(
      `Component is being used inside a Group. Did you mean to override the name prop value (${t}) with (${this.name})? It is recommended to only set name at the Group level.`,
      this
    );
  }
}, d = {
  props: {
    /**
     * Used to customize the validation messages component
     */
    messagesClass: {
      type: [String, Array, Object],
      default: ""
    },
    /**
     * A set of props that are passed into the validation messages component
     */
    messagesChildProps: {
      type: Object,
      default: () => ({})
    },
    /**
     * Used to hide / show the validation messages
     * @values true, false
     */
    showMessages: {
      type: Boolean,
      default: !0
    },
    /**
     * Validation messages
     */
    messages: {
      type: Array,
      default: () => [],
      validator: (e) => n(e)
    }
  },
  computed: {
    formattedMessages() {
      return l(this.messages);
    }
  }
}, c = {
  InputMixin: s,
  CheckableMixin: o,
  GroupableMixin: u,
  MessagesMixin: d
};
export {
  o as CheckableMixin,
  u as GroupableMixin,
  s as InputMixin,
  d as MessagesMixin,
  c as default
};
//# sourceMappingURL=input.js.map
