"use strict";

require("core-js/modules/web.dom.iterable");

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

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

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

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

var apiActions = _interopRequireWildcard(require("../../actions/api"));

var formActions = _interopRequireWildcard(require("../../actions/form"));

var _batchSettings = _interopRequireDefault(require("../form/batch-settings"));

var _connectedLocationField = _interopRequireDefault(require("../form/connected-location-field"));

var _narrativeItineraries = _interopRequireDefault(require("../narrative/narrative-itineraries"));

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

var _viewerContainer = _interopRequireDefault(require("../viewers/viewer-container"));

var _switchButton = _interopRequireDefault(require("../form/switch-button"));

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

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }

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

// Style for setting the top of the narrative itineraries based on the width of the window.
// If the window width is less than 1200px (Bootstrap's "large" size), the
// mode buttons will be shown on their own row, meaning that the
// top position of this component needs to be lower (higher value
// equals lower position on the page).
// TODO: figure out a better way to use flex rendering for accommodating the mode button overflow.
const NarrativeContainer = _styledComponents.default.div`
  & .options.itinerary {
    @media (min-width: 1200px) {
      top: 160px;
    }
    @media (max-width: 1199px) {
      top: 210px;
    }
  }
`;
/**
 * Main panel for the batch/trip comparison form.
 */

class BatchRoutingPanel extends _react.Component {
  render() {
    const {
      mobile
    } = this.props;
    const actionText = mobile ? 'tap' : 'click';
    return /*#__PURE__*/_react.default.createElement(_viewerContainer.default, {
      className: "batch-routing-panel"
    }, /*#__PURE__*/_react.default.createElement("div", {
      className: "locations"
    }, /*#__PURE__*/_react.default.createElement(_connectedLocationField.default, {
      inputPlaceholder: `Enter start location or ${actionText} on map...`,
      locationType: "from",
      showClearButton: true
    }), /*#__PURE__*/_react.default.createElement(_connectedLocationField.default, {
      inputPlaceholder: `Enter destination or ${actionText} on map...`,
      locationType: "to",
      showClearButton: !mobile
    }), /*#__PURE__*/_react.default.createElement("div", {
      className: "switch-button-container"
    }, /*#__PURE__*/_react.default.createElement(_switchButton.default, {
      content: /*#__PURE__*/_react.default.createElement("i", {
        className: "fa fa-exchange fa-rotate-90"
      })
    }))), /*#__PURE__*/_react.default.createElement(_batchSettings.default, null), /*#__PURE__*/_react.default.createElement(NarrativeContainer, {
      className: "desktop-narrative-container"
    }, /*#__PURE__*/_react.default.createElement(_narrativeItineraries.default, {
      containerStyle: {
        bottom: '0',
        display: 'flex',
        flexDirection: 'column',
        left: '0',
        position: 'absolute',
        right: '0'
      }
    })));
  }

} // connect to the redux store


const mapStateToProps = (state, ownProps) => {
  const showUserSettings = (0, _state.getShowUserSettings)(state);
  return {
    activeSearch: (0, _state.getActiveSearch)(state),
    config: state.otp.config,
    currentQuery: state.otp.currentQuery,
    expandAdvanced: state.otp.user.expandAdvanced,
    possibleCombinations: state.otp.config.modes.combinations,
    showUserSettings
  };
};

const mapDispatchToProps = {
  routingQuery: apiActions.routingQuery,
  setQueryParam: formActions.setQueryParam
};

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

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

//# sourceMappingURL=batch-routing-panel.js