"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _react = _interopRequireDefault(require("react"));
require("./index.scss");
var _noticeBarItem = _interopRequireDefault(require("./notice-bar-item"));
var _arr = _interopRequireDefault(require("../../assets/icon/teletext-list/arr.png"));
var _excluded = ["dataList", "onClick", "icon", "children", "handleMoreClick", "moreText"];
var NoticeBar = function NoticeBar(_ref) {
  var dataList = _ref.dataList,
    _ref$onClick = _ref.onClick,
    onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
    icon = _ref.icon,
    children = _ref.children,
    handleMoreClick = _ref.handleMoreClick,
    moreText = _ref.moreText,
    otherProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
  var _otherProps = otherProps || {};
  var stickyItems = (dataList || []).filter(function (item) {
    return (item === null || item === void 0 ? void 0 : item.isTop) === 1;
  });
  var loopItems = (dataList || []).filter(function (item) {
    return (item === null || item === void 0 ? void 0 : item.isTop) === 0;
  });
  return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({
    className: "notice-bar__panel"
  }, _otherProps), /*#__PURE__*/_react["default"].createElement("img", {
    className: "notice-bar__panel__item-img",
    src: icon,
    alt: ""
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "notice-bar__panel__item-list"
  }, stickyItems ? stickyItems.map(function (item, index) {
    return /*#__PURE__*/_react["default"].createElement(_noticeBarItem["default"], (0, _extends2["default"])({
      key: index,
      onClick: onClick
    }, item), children);
  }) : /*#__PURE__*/_react["default"].createElement("div", null), /*#__PURE__*/_react["default"].createElement("div", {
    className: "notice-bar__panel__item-loop"
  }, /*#__PURE__*/_react["default"].createElement("div", null, loopItems.length > 0 ? loopItems.map(function (item, index) {
    return /*#__PURE__*/_react["default"].createElement(_noticeBarItem["default"], (0, _extends2["default"])({
      key: index,
      onClick: onClick
    }, item), children);
  }) : /*#__PURE__*/_react["default"].createElement("div", null, "No items to display")))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "notice-bar__panel__item-more"
  }, moreText ? /*#__PURE__*/_react["default"].createElement("div", {
    className: "notice-bar__panel__item-more-more"
  }, /*#__PURE__*/_react["default"].createElement("span", {
    className: "notice-bar__panel__item-more-more-text",
    onClick: handleMoreClick
  }, moreText), /*#__PURE__*/_react["default"].createElement("img", {
    src: _arr["default"],
    className: "notice-bar__panel__item-more-more-img"
  })) : ''));
};
NoticeBar.displayName = 'NoticeBar';
var _default = exports["default"] = NoticeBar;