"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = RoomModal;
const contexts_1 = require("../../../contexts/index.js");
const hooks_1 = require("../../../hooks/index.js");
const react_1 = __importStar(require("react"));
const react_i18next_1 = require("react-i18next");
const Translation_1 = require("translations/Translation");
const Headline_1 = __importDefault(require("../../generic/Headline"));
const HtmlContentViewer_1 = require("../../generic/HtmlContentViewer");
const Icon_1 = __importStar(require("../../generic/Icon/Icon"));
const LineBreak_1 = __importDefault(require("../../generic/LineBreak"));
const SimpleModal_1 = __importStar(require("../../generic/modal/SimpleModal"));
const Text_1 = __importStar(require("../../generic/Text"));
const ImageGallerySlider_1 = __importDefault(require("./ImageGallerySlider"));
const RoomDetailsBedsBlock_1 = require("./roomDetails/RoomDetailsBedsBlock");
const RoomRates_1 = __importDefault(require("./roomDetails/roomRates/RoomRates"));
const Color_1 = require("../../../util/Color");
const RoomModalPerkRow_1 = __importDefault(require("./RoomModalPerkRow"));
function RoomModal(props) {
    var _a;
    const { roomModalDescSideBySide } = (0, react_1.useContext)(contexts_1.HotelOverridesContext);
    const { t } = (0, react_i18next_1.useTranslation)();
    const { hotel } = (0, hooks_1.useCurrentHotel)();
    const { rooms } = hotel;
    const { roomPerks, prePerkDisclaimer } = props.room.getRoomPerks({ hotel: hotel, room: props.room });
    const extraRoomData = rooms === null || rooms === void 0 ? void 0 : rooms[props.room.code];
    // Explode otherwise original data gets overwritten.
    const amenities = (extraRoomData === null || extraRoomData === void 0 ? void 0 : extraRoomData.amenities) ? [...extraRoomData.amenities] : [];
    if ((_a = extraRoomData === null || extraRoomData === void 0 ? void 0 : extraRoomData.features) === null || _a === void 0 ? void 0 : _a.length) {
        extraRoomData.features.forEach((feature) => {
            amenities.push(feature);
        });
    }
    const cleanPerkDisclaimer = (prePerkDisclaimer === null || prePerkDisclaimer === void 0 ? void 0 : prePerkDisclaimer.replace(/<br(\/|)>/g, '')) || '';
    const LongDescription = () => {
        return (react_1.default.createElement("div", { className: "u-marg-bottom--heavy rs-room-modal-long-description" },
            react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small, color: Color_1.Color.Graphite, asDiv: true },
                react_1.default.createElement(HtmlContentViewer_1.HtmlContentViewer, { content: props.room.getLongDescription() || '' }))));
    };
    return (react_1.default.createElement(SimpleModal_1.default, { title: props.room.name + ' ' + t(Translation_1.Translation.Step.Room.RoomInfo.Information), open: props.open, size: SimpleModal_1.SimpleModalSize.Small, onClose: props.onClose },
        react_1.default.createElement("div", { className: "rs-room-modal" },
            react_1.default.createElement("div", { style: { height: '350px' } },
                react_1.default.createElement(ImageGallerySlider_1.default, { images: props.room.getImages() })),
            react_1.default.createElement("div", { className: "u-marg-heavy u-marg@m- rs-room-modal-container" },
                react_1.default.createElement("div", { className: "u-marg-bottom--light rs-room-modal-headline" },
                    react_1.default.createElement(Headline_1.default, { bold: true, size: "large" }, props.room.name)),
                react_1.default.createElement(RoomDetailsBedsBlock_1.RoomDetailsBedsBlock, { room: props.room }),
                react_1.default.createElement("div", { className: "u-marg-bottom--heavy rs-room-modal-short-description" },
                    react_1.default.createElement(Text_1.default, { color: Color_1.Color.DarkGrey, type: Text_1.TextType.Small },
                        react_1.default.createElement("span", { dangerouslySetInnerHTML: { __html: props.room.getShortDescription(false) || '' } }))),
                roomModalDescSideBySide ? (react_1.default.createElement(react_1.default.Fragment, null,
                    react_1.default.createElement(LongDescription, null),
                    react_1.default.createElement(LineBreak_1.default, null))) : null,
                !(hotel === null || hotel === void 0 ? void 0 : hotel.perksHideOnRoomDetail) && roomPerks && (react_1.default.createElement("div", { className: "u-marg-bottom--heavy rs-room-modal-perks" },
                    react_1.default.createElement("div", { className: "row" },
                        react_1.default.createElement(RoomModalPerkRow_1.default, { hotel: hotel, room: props.room, roomPerks: roomPerks })),
                    (hotel === null || hotel === void 0 ? void 0 : hotel.perksShowDisclaimer) && (react_1.default.createElement("div", { className: "row u-marg-top--lighter" },
                        react_1.default.createElement("small", { className: "col-12" }, t(Translation_1.Translation.Misc.PerksDisclaimer)))))),
                !!(amenities === null || amenities === void 0 ? void 0 : amenities.length) && (react_1.default.createElement(react_1.default.Fragment, null,
                    react_1.default.createElement("div", { className: "u-marg-bottom" },
                        react_1.default.createElement(Text_1.default, { color: Color_1.Color.Accent, type: Text_1.TextType.Small },
                            react_1.default.createElement("strong", null, t(Translation_1.Translation.Step.Room.RoomInfo.RoomAmenities)))),
                    react_1.default.createElement("div", { className: "row" }, amenities.map((amenity) => {
                        return (react_1.default.createElement("div", { key: amenity.description, className: "col-sm-6 u-marg-bottom--light u-flex justify-content-start" },
                            react_1.default.createElement(Icon_1.default, { icon: Icon_1.IconType.Check, color: Color_1.Color.White, backgroundColor: Color_1.Color.Navy, borderRadius: "round", noPadding: true, size: "16px" }),
                            react_1.default.createElement("div", { className: "u-marg-left--light u-flex" },
                                react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small, inline: true }, amenity.description))));
                    })))),
                react_1.default.createElement(LineBreak_1.default, null),
                !roomModalDescSideBySide ? react_1.default.createElement(LongDescription, null) : null,
                !!cleanPerkDisclaimer && (react_1.default.createElement("div", { className: "u-marg-bottom--heavy rs-room-modal-disclaimer" },
                    react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small },
                        react_1.default.createElement("strong", null, t(Translation_1.Translation.Step.Room.RoomInfo.Disclaimer))),
                    react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small },
                        react_1.default.createElement("span", { dangerouslySetInnerHTML: { __html: cleanPerkDisclaimer } }))))),
            react_1.default.createElement(RoomRates_1.default, { featuredRates: props.featuredRates, rates: props.rates, roomCode: props.room.code }))));
}
//# sourceMappingURL=RoomModal.js.map