import * as _vue from "vue";
import { inject } from 'vue';
import PropTypes from '../_util/vue-types';
import { hasProp, getComponent, getSlot } from '../_util/props-util';
import { ConfigConsumerProps } from '../config-provider';
import DropDown from '../dropdown/dropdown';
import DownOutlined from '@ant-design/icons-vue/DownOutlined';
export default {
  name: 'ABreadcrumbItem',
  __ANT_BREADCRUMB_ITEM: true,
  props: {
    prefixCls: PropTypes.string,
    href: PropTypes.string,
    separator: PropTypes.any.def('/'),
    overlay: PropTypes.any
  },
  setup: function setup() {
    return {
      configProvider: inject('configProvider', ConfigConsumerProps)
    };
  },
  methods: {
    /**
     * if overlay is have
     * Wrap a DropDown
     */
    renderBreadcrumbNode: function renderBreadcrumbNode(breadcrumbItem, prefixCls) {
      var overlay = getComponent(this, 'overlay');

      if (overlay) {
        return _vue.createVNode(DropDown, {
          "overlay": overlay,
          "placement": "bottomCenter"
        }, {
          default: function _default() {
            return [_vue.createVNode("span", {
              "class": "".concat(prefixCls, "-overlay-link")
            }, [breadcrumbItem, _vue.createVNode(DownOutlined, null, null)])];
          }
        });
      }

      return breadcrumbItem;
    }
  },
  render: function render() {
    var customizePrefixCls = this.prefixCls;
    var getPrefixCls = this.configProvider.getPrefixCls;
    var prefixCls = getPrefixCls('breadcrumb', customizePrefixCls);
    var separator = getComponent(this, 'separator');
    var children = getSlot(this);
    var link;

    if (hasProp(this, 'href')) {
      link = _vue.createVNode("a", {
        "class": "".concat(prefixCls, "-link")
      }, [children]);
    } else {
      link = _vue.createVNode("span", {
        "class": "".concat(prefixCls, "-link")
      }, [children]);
    } // wrap to dropDown


    link = this.renderBreadcrumbNode(link, prefixCls);

    if (children) {
      return _vue.createVNode("span", null, [link, separator && separator !== '' && _vue.createVNode("span", {
        "class": "".concat(prefixCls, "-separator")
      }, [separator])]);
    }

    return null;
  }
};