"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useRateDetails = void 0;
const contexts_1 = require("../contexts/index.js");
const react_1 = require("react");
const react_i18next_1 = require("react-i18next");
const Translation_1 = require("../translations/Translation");
const useRateDetails = (rate, isLocked) => {
    const { t } = (0, react_i18next_1.useTranslation)();
    const basketContext = (0, react_1.useContext)(contexts_1.BasketContext);
    const selectedRow = basketContext.selectedBasketRow;
    const { rateName, shortDescription, longDescription } = (0, react_1.useMemo)(() => {
        var _a, _b;
        if (isLocked) {
            return { rateName: t(Translation_1.Translation.Step.Room.RoomInfo.MemberOnlyDeal), rateDescription: t(Translation_1.Translation.Step.Room.RoomInfo.DealForMemberOnly) };
        }
        const overwrites = rate.getPossiblyOverwrittenDetails({ startDate: selectedRow === null || selectedRow === void 0 ? void 0 : selectedRow.getStartDate(), endDate: selectedRow === null || selectedRow === void 0 ? void 0 : selectedRow.getEndDate() });
        return { rateName: overwrites.name, shortDescription: (_a = overwrites.shortDescription) !== null && _a !== void 0 ? _a : '', longDescription: (_b = overwrites.longDescription) !== null && _b !== void 0 ? _b : '' };
    }, [rate, selectedRow, isLocked]);
    return { rateName, shortDescription, longDescription };
};
exports.useRateDetails = useRateDetails;
//# sourceMappingURL=useRateDetails.js.map