"use strict";

exports.__esModule = true;
exports.default = void 0;

var _classnames = _interopRequireDefault(require("classnames"));

var _react = _interopRequireWildcard(require("react"));

var _meetReactComponentOne = require("@alifd/meet-react-component-one");

var _utils = require("../utils");

var _view = _interopRequireDefault(require("../view"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }

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

var BreadCrumb = function (props, ref) {
  var _classNames, _classNames2;

  var _props$className = props.className,
      className = _props$className === void 0 ? '' : _props$className,
      _props$prefix = props.prefix,
      prefix = _props$prefix === void 0 ? 'mt-' : _props$prefix,
      _props$size = props.size,
      size = _props$size === void 0 ? 'medium' : _props$size,
      _props$maxNode = props.maxNode,
      maxNode = _props$maxNode === void 0 ? 100 : _props$maxNode,
      _props$disabled = props.disabled,
      disabled = _props$disabled === void 0 ? false : _props$disabled,
      _props$onClick = props.onClick,
      onClick = _props$onClick === void 0 ? function () {} : _props$onClick,
      separator = props.separator,
      children = props.children;

  var count = _react.Children.count(children);

  var clsPrefix = prefix + "breadcrumb";
  return /*#__PURE__*/(0, _react.createElement)(_meetReactComponentOne.ScrollView, {
    ref: ref,
    className: (0, _classnames.default)(className, clsPrefix, (_classNames = {}, _classNames[clsPrefix + "--" + size] = _utils.isStrictWechatMiniProgram, _classNames)),
    showsHorizontalScrollIndicator: false,
    horizontal: true
  }, /*#__PURE__*/(0, _react.createElement)(_view.default, {
    className: (0, _classnames.default)(clsPrefix + "-container", (_classNames2 = {}, _classNames2[clsPrefix + "-container--" + size] = _utils.isStrictWechatMiniProgram, _classNames2))
  }, _react.Children.map(children, function (child, index) {
    if (!(0, _react.isValidElement)(child)) {
      return null;
    }

    return (0, _react.cloneElement)(child, {
      key: index,
      index: index,
      size: size,
      last: index === count - 1 && (0, _react.isValidElement)(child),
      disabledAll: disabled,
      maxNode: maxNode,
      count: count,
      onClick: onClick,
      separator: separator
    });
  })));
};

var _default = /*#__PURE__*/(0, _react.forwardRef)(BreadCrumb);

exports.default = _default;