"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = NumberOfInfantsPicker;
const hooks_1 = require("../../../../hooks/index.js");
const react_1 = __importDefault(require("react"));
const react_i18next_1 = require("react-i18next");
const Translation_1 = require("translations/Translation");
const Select_1 = require("../../../generic/Select/Select");
const StringHelper_1 = __importDefault(require("../../../../util/StringHelper"));
function NumberOfInfantsPicker(props) {
    var _a, _b, _c;
    const { hotel } = (0, hooks_1.useCurrentHotel)();
    const { t } = (0, react_i18next_1.useTranslation)();
    const selectedValue = (_b = (_a = props.row) === null || _a === void 0 ? void 0 : _a.getInfants()) !== null && _b !== void 0 ? _b : 1;
    let maxOccupancy = Math.max((hotel === null || hotel === void 0 ? void 0 : hotel.maxOccupancy) + 1 - ((_c = props.row) === null || _c === void 0 ? void 0 : _c.getAdults()));
    // Just in Case
    if (maxOccupancy < 1 || isNaN(maxOccupancy)) {
        maxOccupancy = 1;
    }
    return (react_1.default.createElement(Select_1.Select, { nativeOnMobile: true, options: [...Array(maxOccupancy)].map((v, value) => {
            return {
                text: StringHelper_1.default.pluralWithDictAndCount(value, Translation_1.Translation.Step.Date.Infant, t),
                value: value.toString(),
            };
        }), value: selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.toString(), onChange: props.onChange, keyName: "value", labelName: "text", inputLabelColor: props.labelColor }));
}
//# sourceMappingURL=NumberOfInfantsPicker.js.map