"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const icon = require("../../../utils/vue/icon.js");
const shared_esmBundler = require("../../../../../@vue/shared/dist/shared.esm-bundler.js");
const index = require("../../../hooks/use-attrs/index.js");
const index$1 = require("../../../hooks/use-calc-input-width/index.js");
const index$4 = require("../../icon/index.js");
const useFormItem = require("../../form/src/hooks/use-form-item.js");
const index$3 = require("../../tooltip/index.js");
const index$2 = require("../../tag/index.js");
const inputTag = require("./input-tag.js");
const useDragTag = require("./composables/use-drag-tag.js");
const useHovering = require("./composables/use-hovering.js");
const useInputTag = require("./composables/use-input-tag.js");
const useInputTagDom = require("./composables/use-input-tag-dom.js");
const vue = require("vue");
const _hoisted_1 = [
  "id",
  "minlength",
  "maxlength",
  "disabled",
  "readonly",
  "autocomplete",
  "tabindex",
  "placeholder",
  "autofocus",
  "ariaLabel"
];
const _hoisted_2 = ["textContent"];
var input_tag_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ vue.defineComponent({
  name: "ElInputTag",
  inheritAttrs: false,
  __name: "input-tag",
  props: inputTag.inputTagProps,
  emits: inputTag.inputTagEmits,
  setup(__props, { expose: __expose, emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const attrs = index.useAttrs();
    const slots = vue.useSlots();
    const { form, formItem } = useFormItem.useFormItem();
    const { inputId } = useFormItem.useFormItemInputId(props, { formItemContext: formItem });
    const needStatusIcon = vue.computed(() => (form == null ? void 0 : form.statusIcon) ?? false);
    const validateState = vue.computed(() => (formItem == null ? void 0 : formItem.validateState) || "");
    const validateIcon = vue.computed(() => {
      return validateState.value && icon.ValidateComponentsMap[validateState.value];
    });
    const { inputRef, wrapperRef, tagTooltipRef, isFocused, inputValue, size, tagSize, placeholder, closable, disabled, showTagList, collapseTagList, handleDragged, handlePaste, handleInput, handleKeydown, handleKeyup, handleRemoveTag, handleClear, handleCompositionStart, handleCompositionUpdate, handleCompositionEnd, focus, blur } = useInputTag.useInputTag({
      props,
      emit,
      formItem
    });
    const { hovering, handleMouseEnter, handleMouseLeave } = useHovering.useHovering();
    const { calculatorRef, inputStyle } = index$1.useCalcInputWidth();
    const { dropIndicatorRef, showDropIndicator, handleDragStart, handleDragOver, handleDragEnd } = useDragTag.useDragTag({
      wrapperRef,
      handleDragged,
      afterDragged: focus
    });
    const { ns, nsInput, containerKls, containerStyle, innerKls, showClear, showSuffix, tagStyle, collapseItemRef, innerRef } = useInputTagDom.useInputTagDom({
      props,
      hovering,
      isFocused,
      inputValue,
      disabled,
      size,
      validateState,
      validateIcon,
      needStatusIcon
    });
    __expose({
      focus,
      blur
    });
    return (_ctx, _cache) => {
      return vue.openBlock(), vue.createElementBlock("div", {
        ref_key: "wrapperRef",
        ref: wrapperRef,
        class: vue.normalizeClass(vue.unref(containerKls)),
        style: vue.normalizeStyle(vue.unref(containerStyle)),
        onMouseenter: _cache[9] || (_cache[9] = (...args) => vue.unref(handleMouseEnter) && vue.unref(handleMouseEnter)(...args)),
        onMouseleave: _cache[10] || (_cache[10] = (...args) => vue.unref(handleMouseLeave) && vue.unref(handleMouseLeave)(...args))
      }, [
        vue.unref(slots).prefix ? (vue.openBlock(), vue.createElementBlock("div", {
          key: 0,
          class: vue.normalizeClass(vue.unref(ns).e("prefix"))
        }, [vue.renderSlot(_ctx.$slots, "prefix")], 2)) : vue.createCommentVNode("v-if", true),
        vue.createElementVNode("div", {
          ref_key: "innerRef",
          ref: innerRef,
          class: vue.normalizeClass(vue.unref(innerKls))
        }, [
          (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(showTagList), (item, index2) => {
            return vue.openBlock(), vue.createBlock(vue.unref(index$2.ElTag), {
              key: index2,
              size: vue.unref(tagSize),
              closable: vue.unref(closable),
              type: __props.tagType,
              effect: __props.tagEffect,
              draggable: vue.unref(closable) && __props.draggable,
              style: vue.normalizeStyle(vue.unref(tagStyle)),
              "disable-transitions": "",
              onClose: ($event) => vue.unref(handleRemoveTag)(index2),
              onDragstart: (event) => vue.unref(handleDragStart)(event, index2),
              onDragover: (event) => vue.unref(handleDragOver)(event, index2),
              onDragend: vue.unref(handleDragEnd),
              onDrop: _cache[0] || (_cache[0] = vue.withModifiers(() => {
              }, ["stop"]))
            }, {
              default: vue.withCtx(() => [vue.renderSlot(_ctx.$slots, "tag", {
                value: item,
                index: index2
              }, () => [vue.createTextVNode(vue.toDisplayString(item), 1)])]),
              _: 2
            }, 1032, [
              "size",
              "closable",
              "type",
              "effect",
              "draggable",
              "style",
              "onClose",
              "onDragstart",
              "onDragover",
              "onDragend"
            ]);
          }), 128)),
          __props.collapseTags && __props.modelValue && __props.modelValue.length > __props.maxCollapseTags ? (vue.openBlock(), vue.createBlock(vue.unref(index$3.ElTooltip), {
            key: 0,
            ref_key: "tagTooltipRef",
            ref: tagTooltipRef,
            disabled: !__props.collapseTagsTooltip,
            "fallback-placements": [
              "bottom",
              "top",
              "right",
              "left"
            ],
            effect: __props.effect,
            placement: "bottom"
          }, {
            default: vue.withCtx(() => [vue.createElementVNode("div", {
              ref_key: "collapseItemRef",
              ref: collapseItemRef,
              class: vue.normalizeClass(vue.unref(ns).e("collapse-tag"))
            }, [vue.createVNode(vue.unref(index$2.ElTag), {
              closable: false,
              size: vue.unref(tagSize),
              type: __props.tagType,
              effect: __props.tagEffect,
              "disable-transitions": ""
            }, {
              default: vue.withCtx(() => [vue.createTextVNode(" + " + vue.toDisplayString(__props.modelValue.length - __props.maxCollapseTags), 1)]),
              _: 1
            }, 8, [
              "size",
              "type",
              "effect"
            ])], 2)]),
            content: vue.withCtx(() => [vue.createElementVNode("div", { class: vue.normalizeClass(vue.unref(ns).e("input-tag-list")) }, [(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(collapseTagList), (item, index2) => {
              return vue.openBlock(), vue.createBlock(vue.unref(index$2.ElTag), {
                key: index2,
                size: vue.unref(tagSize),
                closable: vue.unref(closable),
                type: __props.tagType,
                effect: __props.tagEffect,
                "disable-transitions": "",
                onClose: ($event) => vue.unref(handleRemoveTag)(index2 + __props.maxCollapseTags)
              }, {
                default: vue.withCtx(() => [vue.renderSlot(_ctx.$slots, "tag", {
                  value: item,
                  index: index2 + __props.maxCollapseTags
                }, () => [vue.createTextVNode(vue.toDisplayString(item), 1)])]),
                _: 2
              }, 1032, [
                "size",
                "closable",
                "type",
                "effect",
                "onClose"
              ]);
            }), 128))], 2)]),
            _: 3
          }, 8, ["disabled", "effect"])) : vue.createCommentVNode("v-if", true),
          vue.createElementVNode("div", { class: vue.normalizeClass(vue.unref(ns).e("input-wrapper")) }, [vue.withDirectives(vue.createElementVNode("input", vue.mergeProps({
            id: vue.unref(inputId),
            ref_key: "inputRef",
            ref: inputRef,
            "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => vue.isRef(inputValue) ? inputValue.value = $event : null)
          }, vue.unref(attrs), {
            type: "text",
            minlength: __props.minlength,
            maxlength: __props.maxlength,
            disabled: vue.unref(disabled),
            readonly: __props.readonly,
            autocomplete: __props.autocomplete,
            tabindex: __props.tabindex,
            placeholder: vue.unref(placeholder),
            autofocus: __props.autofocus,
            ariaLabel: __props.ariaLabel,
            class: vue.unref(ns).e("input"),
            style: vue.unref(inputStyle),
            onCompositionstart: _cache[2] || (_cache[2] = (...args) => vue.unref(handleCompositionStart) && vue.unref(handleCompositionStart)(...args)),
            onCompositionupdate: _cache[3] || (_cache[3] = (...args) => vue.unref(handleCompositionUpdate) && vue.unref(handleCompositionUpdate)(...args)),
            onCompositionend: _cache[4] || (_cache[4] = (...args) => vue.unref(handleCompositionEnd) && vue.unref(handleCompositionEnd)(...args)),
            onPaste: _cache[5] || (_cache[5] = (...args) => vue.unref(handlePaste) && vue.unref(handlePaste)(...args)),
            onInput: _cache[6] || (_cache[6] = (...args) => vue.unref(handleInput) && vue.unref(handleInput)(...args)),
            onKeydown: _cache[7] || (_cache[7] = (...args) => vue.unref(handleKeydown) && vue.unref(handleKeydown)(...args)),
            onKeyup: _cache[8] || (_cache[8] = (...args) => vue.unref(handleKeyup) && vue.unref(handleKeyup)(...args))
          }), null, 16, _hoisted_1), [[vue.vModelText, vue.unref(inputValue)]]), vue.createElementVNode("span", {
            ref_key: "calculatorRef",
            ref: calculatorRef,
            "aria-hidden": "true",
            class: vue.normalizeClass(vue.unref(ns).e("input-calculator")),
            textContent: vue.toDisplayString(vue.unref(inputValue))
          }, null, 10, _hoisted_2)], 2),
          vue.withDirectives(vue.createElementVNode("div", {
            ref_key: "dropIndicatorRef",
            ref: dropIndicatorRef,
            class: vue.normalizeClass(vue.unref(ns).e("drop-indicator"))
          }, null, 2), [[vue.vShow, vue.unref(showDropIndicator)]])
        ], 2),
        vue.unref(showSuffix) ? (vue.openBlock(), vue.createElementBlock("div", {
          key: 1,
          class: vue.normalizeClass(vue.unref(ns).e("suffix"))
        }, [
          vue.renderSlot(_ctx.$slots, "suffix"),
          vue.unref(showClear) ? (vue.openBlock(), vue.createBlock(vue.unref(index$4.ElIcon), {
            key: 0,
            class: vue.normalizeClass([vue.unref(ns).e("icon"), vue.unref(ns).e("clear")]),
            onMousedown: vue.withModifiers(vue.unref(shared_esmBundler.NOOP), ["prevent"]),
            onClick: vue.unref(handleClear)
          }, {
            default: vue.withCtx(() => [(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(__props.clearIcon)))]),
            _: 1
          }, 8, [
            "class",
            "onMousedown",
            "onClick"
          ])) : vue.createCommentVNode("v-if", true),
          validateState.value && validateIcon.value && needStatusIcon.value ? (vue.openBlock(), vue.createBlock(vue.unref(index$4.ElIcon), {
            key: 1,
            class: vue.normalizeClass([
              vue.unref(nsInput).e("icon"),
              vue.unref(nsInput).e("validateIcon"),
              vue.unref(nsInput).is("loading", validateState.value === "validating")
            ])
          }, {
            default: vue.withCtx(() => [(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(validateIcon.value)))]),
            _: 1
          }, 8, ["class"])) : vue.createCommentVNode("v-if", true)
        ], 2)) : vue.createCommentVNode("v-if", true)
      ], 38);
    };
  }
});
exports.default = input_tag_vue_vue_type_script_setup_true_lang_default;
