"use strict";

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

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

var _companies = require("@opentripplanner/icons/lib/companies");

var _styledComponents = _interopRequireDefault(require("styled-components"));

var _icon = _interopRequireDefault(require("../util/icon"));

var _state = require("../../util/state");

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

const IssueContainer = _styledComponents.default.div`
  border-top: 1px solid grey;
  display: flex;
  padding: 10px;
`;
const IssueIconContainer = _styledComponents.default.div`
  font-size: 18px;
  height: 24px;
  width: 24px;
`;
const IssueContents = _styledComponents.default.div`
  font-size: 14px;
  margin-left: 10px;
  text-align: left;
`;

function NarrativeItinerariesErrors({
  errorMessages,
  errors
}) {
  return errors.map((error, idx) => {
    let icon = /*#__PURE__*/_react.default.createElement(_icon.default, {
      className: "text-warning",
      type: "exclamation-triangle"
    });

    if (error.network) {
      const CompanyIcon = (0, _companies.getCompanyIcon)(error.network); // check if company icon exists to avoid rendering undefined

      if (CompanyIcon) {
        icon = /*#__PURE__*/_react.default.createElement(CompanyIcon, null);
      }
    }

    return /*#__PURE__*/_react.default.createElement(IssueContainer, {
      key: idx
    }, /*#__PURE__*/_react.default.createElement(IssueIconContainer, null, icon), /*#__PURE__*/_react.default.createElement(IssueContents, null, (0, _state.getErrorMessage)(error, errorMessages)));
  });
}

module.exports = exports.default;

//# sourceMappingURL=narrative-itineraries-errors.js