"use strict";

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

var _stopsOverlay = _interopRequireDefault(require("@opentripplanner/stops-overlay"));

var _reactRedux = require("react-redux");

var _api = require("../../actions/api");

var _connectedStopMarker = _interopRequireDefault(require("./connected-stop-marker"));

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

// connect to the redux store
const mapStateToProps = (state, ownProps) => {
  const {
    viewedRoute
  } = state.otp.ui;
  let {
    stops
  } = state.otp.overlay.transit;
  let minZoom = 15; // If a pattern is being shown, show only the pattern's stops and show them large

  if ((viewedRoute === null || viewedRoute === void 0 ? void 0 : viewedRoute.patternId) && state.otp.transitIndex.routes) {
    var _state$otp$transitInd, _state$otp$transitInd2;

    stops = (_state$otp$transitInd = state.otp.transitIndex.routes[viewedRoute.routeId]) === null || _state$otp$transitInd === void 0 ? void 0 : (_state$otp$transitInd2 = _state$otp$transitInd.patterns) === null || _state$otp$transitInd2 === void 0 ? void 0 : _state$otp$transitInd2[viewedRoute.patternId].stops;
    minZoom = 2;
  }

  return {
    stops: stops || [],
    symbols: [{
      minZoom,
      symbol: _connectedStopMarker.default
    }]
  };
};

const mapDispatchToProps = {
  refreshStops: _api.findStopsWithinBBox
};

var _default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_stopsOverlay.default);

exports.default = _default;
module.exports = exports.default;

//# sourceMappingURL=connected-stops-overlay.js