import _extends from "@babel/runtime/helpers/extends";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import React from 'react';
import isFunction from "lodash/isFunction";
var WebLinkBar = /*#__PURE__*/function (_React$Component) {
  _inheritsLoose(WebLinkBar, _React$Component);
  function WebLinkBar() {
    return _React$Component.apply(this, arguments) || this;
  }
  var _proto = WebLinkBar.prototype;
  _proto.renderActionButton = function renderActionButton(item, index) {
    var _this$props = this.props,
      nextTablePrefix = _this$props.nextTablePrefix,
      onActionClick = _this$props.onActionClick;
    var content;
    var itemProps = {
      onClick: function onClick() {
        onActionClick && onActionClick(item, index);
      }
    };
    if (item.render && isFunction(item.render)) {
      content = /*#__PURE__*/React.createElement("div", _extends({
        className: nextTablePrefix + "link-div"
      }, itemProps), item.render(item.title));
    } else {
      content = /*#__PURE__*/React.createElement("a", _extends({
        className: nextTablePrefix + "link-a"
      }, itemProps), item.title);
    }
    return /*#__PURE__*/React.createElement("div", {
      className: nextTablePrefix + "link-item",
      key: index
    }, content, index === 0 ? null : /*#__PURE__*/React.createElement("div", {
      className: nextTablePrefix + "link-sp"
    }));
  };
  _proto.render = function render() {
    var _this = this;
    var _this$props2 = this.props,
      nextTablePrefix = _this$props2.nextTablePrefix,
      _this$props2$linkBar = _this$props2.linkBar,
      linkBar = _this$props2$linkBar === void 0 ? [] : _this$props2$linkBar;
    return /*#__PURE__*/React.createElement("div", {
      className: nextTablePrefix + "link-wrap"
    }, linkBar.slice(0).reverse().map(function (link, index) {
      return link ? _this.renderActionButton(link, index) : null;
    }));
  };
  return WebLinkBar;
}(React.Component);
export { WebLinkBar as default };