"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.parseCommon = void 0;
var _locale = require("@mirai/locale");
var _helpers = require("../../../../../components/helpers");
var _Core = require("../../../../../Core.constants");
const parseCommon = function () {
  let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
    _ref$calendar = _ref.calendar,
    calendar = _ref$calendar === void 0 ? [] : _ref$calendar,
    id = _ref.id,
    _ref$occupation = _ref.occupation,
    occupation = _ref$occupation === void 0 ? [] : _ref$occupation,
    _ref$promocode = _ref.promocode,
    promocode = _ref$promocode === void 0 ? '' : _ref$promocode,
    type = _ref.type;
  const _getOccupationTotals = (0, _helpers.getOccupationTotals)({
      occupation
    }),
    _getOccupationTotals$ = _getOccupationTotals.adults,
    adults = _getOccupationTotals$ === void 0 ? 0 : _getOccupationTotals$,
    _getOccupationTotals$2 = _getOccupationTotals.children,
    children = _getOccupationTotals$2 === void 0 ? 0 : _getOccupationTotals$2;
  return {
    chainId: type === _Core.TYPE.CHAIN ? id : undefined,
    checkin: (0, _locale.dateFormat)(calendar[0], {
      format: 'DD/MM/YYYY'
    }),
    checkout: (0, _locale.dateFormat)(calendar[1], {
      format: 'DD/MM/YYYY'
    }),
    coupon: promocode,
    hotelId: type === _Core.TYPE.HOTEL ? id : undefined,
    occupation: adults + children
  };
};
exports.parseCommon = parseCommon;
//# sourceMappingURL=parseCommon.js.map