import { createVNode as _createVNode } from "vue";
// Styles
import "./VIcon.sass"; // Composables

import { makeSizeProps, useSize } from "../../composables/size.mjs";
import { makeTagProps } from "../../composables/tag.mjs";
import { useIcon } from "../../composables/icons.mjs";
import { useTextColor } from "../../composables/color.mjs"; // Utilities

import { computed, defineComponent, toRef } from 'vue';
import { convertToUnit, flattenFragments, makeProps } from "../../util/index.mjs"; // Types

export default defineComponent({
  name: 'VIcon',
  props: makeProps({
    color: String,
    disabled: Boolean,
    left: Boolean,
    right: Boolean,
    icon: {
      type: [String, Object]
    },
    ...makeSizeProps(),
    ...makeTagProps({
      tag: 'i'
    })
  }),

  setup(props, {
    slots
  }) {
    let slotIcon;

    if (slots.default) {
      slotIcon = computed(() => {
        var _flattenFragments$fil;

        const slot = slots.default == null ? void 0 : slots.default();
        if (!slot) return;
        return (_flattenFragments$fil = flattenFragments(slot).filter(node => node.children && typeof node.children === 'string')[0]) == null ? void 0 : _flattenFragments$fil.children;
      });
    }

    const {
      iconData
    } = useIcon(slotIcon || props);
    const {
      sizeClasses
    } = useSize(props, 'v-icon');
    const {
      textColorClasses,
      textColorStyles
    } = useTextColor(toRef(props, 'color'));
    return () => {
      return _createVNode(iconData.value.component, {
        "tag": props.tag,
        "icon": iconData.value.icon,
        "class": ['v-icon', 'notranslate', sizeClasses.value, textColorClasses.value, {
          'v-icon--disabled': props.disabled,
          'v-icon--left': props.left,
          'v-icon--right': props.right
        }],
        "style": [!sizeClasses.value ? {
          fontSize: convertToUnit(props.size),
          width: convertToUnit(props.size),
          height: convertToUnit(props.size)
        } : undefined, textColorStyles.value],
        "aria-hidden": "true"
      }, null, 8, ["tag", "icon", "class", "style"]);
    };
  }

});
//# sourceMappingURL=VIcon.mjs.map