"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 });
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 BEButton_1 = __importDefault(require("../../generic/BEButton"));
const Currency_1 = __importDefault(require("../../generic/Currency"));
const Headline_1 = __importDefault(require("../../generic/Headline"));
const Icon_1 = __importStar(require("../../generic/Icon/Icon"));
const TaxInclusionNotice_1 = require("../../generic/TaxInclusionNotice/TaxInclusionNotice");
const Text_1 = __importStar(require("../../generic/Text"));
const Tooltip_1 = __importDefault(require("../../generic/Tooltip/Tooltip"));
const ImageGallerySlider_1 = __importDefault(require("./ImageGallerySlider"));
const Color_1 = require("../../../util/Color");
const HotelPerkHelper_1 = require("../../../util/HotelPerkHelper");
const ScreenSize_1 = __importDefault(require("../../../util/ScreenSize"));
const LargeRoomCard = (props) => {
    var _a, _b, _c, _d, _e, _f, _g, _h;
    const beContext = (0, react_1.useContext)(contexts_1.BookingEngineContext);
    const { hotel } = (0, hooks_1.useCurrentHotel)();
    const { t } = (0, react_i18next_1.useTranslation)();
    const extraRoomData = hotel === null || hotel === void 0 ? void 0 : hotel.rooms[(_a = props.rate) === null || _a === void 0 ? void 0 : _a.getRoom().code];
    const roomSize = (_b = hotel === null || hotel === void 0 ? void 0 : hotel.overwrites) === null || _b === void 0 ? void 0 : _b[(_c = props.rate) === null || _c === void 0 ? void 0 : _c.getRoom().code];
    const trimmedDescription = (_d = props.rate) === null || _d === void 0 ? void 0 : _d.getRoom().getShortDescription();
    const petFriendly = !!(extraRoomData === null || extraRoomData === void 0 ? void 0 : extraRoomData.petFriendly);
    const room = props.rate.getRoom();
    const { roomPerks, prePerkDisclaimer } = room.getRoomPerks({
        hotel: hotel,
        room: room,
        perksLimitNumber: 4,
    });
    const updateRate = () => {
        props.onSelectRate();
    };
    const roomInfo = [
        {
            icon: Icon_1.IconType.People,
            text: t(Translation_1.Translation.Step.Room.Sleeps, {
                maxOccupancy: extraRoomData === null || extraRoomData === void 0 ? void 0 : extraRoomData.maxOccupancy,
            }),
        },
        {
            icon: Icon_1.IconType.Bed,
            text: (extraRoomData === null || extraRoomData === void 0 ? void 0 : extraRoomData.bedTypeOverride) ? extraRoomData === null || extraRoomData === void 0 ? void 0 : extraRoomData.bedTypeOverride : `${extraRoomData === null || extraRoomData === void 0 ? void 0 : extraRoomData.bedType} ${extraRoomData === null || extraRoomData === void 0 ? void 0 : extraRoomData.bedQuantity}`,
        },
        {
            icon: Icon_1.IconType.RoomSize,
            text: roomSize === null || roomSize === void 0 ? void 0 : roomSize.RoomDimensions,
        },
    ];
    if (petFriendly) {
        roomInfo.push({
            icon: Icon_1.IconType.PetFriendly,
            text: t(Translation_1.Translation.Step.Room.PetFriendly),
        });
    }
    return (react_1.default.createElement("div", { className: "upgrade-card upgrade-card--room u-border-rounded" },
        react_1.default.createElement("div", { className: "upgrade-card__image" },
            react_1.default.createElement(ImageGallerySlider_1.default, { images: (_e = props.rate) === null || _e === void 0 ? void 0 : _e.getRoom().getImages() })),
        react_1.default.createElement("div", { className: "u-pad container" },
            react_1.default.createElement(Text_1.default, { bold: true }, (_f = props.rate) === null || _f === void 0 ? void 0 : _f.getRoom().name),
            react_1.default.createElement("div", { className: "u-flex u-marg-top-bottom" }, roomInfo.map((item, index) => {
                return (react_1.default.createElement("div", { className: "u-flex", key: index },
                    react_1.default.createElement(Icon_1.default, { icon: item.icon }),
                    react_1.default.createElement(Text_1.default, { className: "u-marg-left--light", type: Text_1.TextType.Label }, item.text)));
            })),
            react_1.default.createElement("div", { className: "u-marg-bottom--light description" },
                react_1.default.createElement(Text_1.default, { className: "text", type: Text_1.TextType.Small },
                    react_1.default.createElement("span", { dangerouslySetInnerHTML: { __html: (trimmedDescription === null || trimmedDescription === void 0 ? void 0 : trimmedDescription.replace(/<br(\/|)>/g, '')) || '' } }))),
            (prePerkDisclaimer === null || prePerkDisclaimer === void 0 ? void 0 : prePerkDisclaimer.replace(/<br(\/|)>/g, '')) && (react_1.default.createElement("div", { className: "u-marg-bottom--heavy" },
                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.Disclaimer))),
                react_1.default.createElement(Text_1.default, { color: Color_1.Color.DarkGrey, type: Text_1.TextType.Small },
                    react_1.default.createElement("span", { className: "u-text-overflow-ellipsis-2", dangerouslySetInnerHTML: { __html: (prePerkDisclaimer === null || prePerkDisclaimer === void 0 ? void 0 : prePerkDisclaimer.replace(/<br(\/|)>/g, '')) || '' } })))),
            react_1.default.createElement(Text_1.default, { className: "u-marg-bottom", bold: true, type: Text_1.TextType.Label, color: Color_1.Color.Accent }, t(Translation_1.Translation.Step.Room.YouWillGetThisAllForFree)),
            react_1.default.createElement("div", { className: "u-flex u-flex-align-center row justify-content-center" },
                react_1.default.createElement("div", { className: "u-flex col-md-12 flex-wrap justify-content-start" }, roomPerks === null || roomPerks === void 0 ? void 0 : roomPerks.map((perk) => {
                    const isAllPerksOpened = beContext.screenSize < ScreenSize_1.default.ExtraLarge;
                    const perkIconElement = (0, HotelPerkHelper_1.getPerkIconElement)(perk, Color_1.Color.Snow);
                    return (react_1.default.createElement("div", { className: "u-flex justify-content-start u-flex-align-center u-marg-bottom u-w-48@l- u-pad-left--light u-pad-right--light", key: perk.name },
                        react_1.default.createElement(Tooltip_1.default, { title: perk.name },
                            react_1.default.createElement("div", null, perkIconElement)),
                        react_1.default.createElement("div", { className: `u-marg-left u-marg-right ${isAllPerksOpened ? '' : 'u-none'}` },
                            react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small }, (perk === null || perk === void 0 ? void 0 : perk.perkNameRenderer)
                                ? perk.perkNameRenderer({
                                    hotel,
                                    room,
                                })
                                : perk.name))));
                }))),
            react_1.default.createElement("div", { className: "u-flex flex-column no-gutters" },
                react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small, color: Color_1.Color.Navy, inline: true }, t(Translation_1.Translation.Misc.From)),
                react_1.default.createElement("div", { className: "u-flex u-flex-flex-start u-flex-align-center flex-row" },
                    react_1.default.createElement(Headline_1.default, { bold: true },
                        react_1.default.createElement("span", { className: "u-flex align-items-center" },
                            "+",
                            react_1.default.createElement(Currency_1.default, { hideDecimals: true }, ((_g = props.rate) === null || _g === void 0 ? void 0 : _g.getAveragePrice()) - ((_h = props.selectedRate) === null || _h === void 0 ? void 0 : _h.getAveragePrice())))),
                    react_1.default.createElement(Text_1.default, { color: Color_1.Color.DarkGrey, inline: true },
                        "/",
                        t(Translation_1.Translation.Misc.Night))),
                react_1.default.createElement("div", { className: "u-marg-bottom" },
                    react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small, color: Color_1.Color.Grey, inline: true, className: "u-nowrap" },
                        react_1.default.createElement(TaxInclusionNotice_1.TaxInclusionNotice, { rate: props.rate }))),
                react_1.default.createElement("div", { className: "u-marg-top--light u-flex justify-content-end u-w-100@m-" },
                    react_1.default.createElement(BEButton_1.default, { onClick: updateRate, name: "ViewRatesNowButton", primary: true, filled: true, wide: true }, t(Translation_1.Translation.Step.Room.Upgrade)))))));
};
exports.default = LargeRoomCard;
//# sourceMappingURL=LargeRoomCard.js.map