"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getOccupation = void 0;
var _helpers = require("../../../helpers");
const {
  ADULT,
  CHILD,
  GUEST
} = _helpers.OCCUPATION_TYPE;
const getOccupation = propGuests => {
  const {
    adults = 0,
    children = 0,
    guests = 0
  } = Array.isArray(propGuests) ? {
    adults: propGuests.reduce(function (total) {
      let {
        amount = 0,
        type
      } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
      return total + (type === ADULT ? amount : 0);
    }, 0),
    children: propGuests.flat().reduce(function (total) {
      let {
        amount = 0,
        type
      } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
      return total + (type === CHILD ? amount : 0);
    }, 0),
    guests: propGuests.reduce(function (total) {
      let {
        amount = 0,
        type
      } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
      return total + (type === GUEST ? amount : 0);
    }, 0)
  } : {
    adults: propGuests !== null && propGuests !== void 0 ? propGuests : 0
  };
  return {
    adults,
    children,
    guests
  };
};
exports.getOccupation = getOccupation;
//# sourceMappingURL=getOccupation.js.map