"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _vue = _interopRequireWildcard(require("vue"));

var _vueTypes = _interopRequireDefault(require("../_util/vue-types"));

var _propsUtil = require("../_util/props-util");

var _configProvider = require("../config-provider");

var _dropdown = _interopRequireDefault(require("../dropdown/dropdown"));

var _DownOutlined = _interopRequireDefault(require("@ant-design/icons-vue/DownOutlined"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var _default2 = {
  name: 'ABreadcrumbItem',
  __ANT_BREADCRUMB_ITEM: true,
  props: {
    prefixCls: _vueTypes.default.string,
    href: _vueTypes.default.string,
    separator: _vueTypes.default.any.def('/'),
    overlay: _vueTypes.default.any
  },
  setup: function setup() {
    return {
      configProvider: (0, _vue.inject)('configProvider', _configProvider.ConfigConsumerProps)
    };
  },
  methods: {
    /**
     * if overlay is have
     * Wrap a DropDown
     */
    renderBreadcrumbNode: function renderBreadcrumbNode(breadcrumbItem, prefixCls) {
      var overlay = (0, _propsUtil.getComponent)(this, 'overlay');

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

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

    if ((0, _propsUtil.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;
  }
};
exports.default = _default2;