"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const MockAPI_1 = __importDefault(require("mockApi/MockAPI"));
const Addon_1 = require("../models/Addon/Addon");
const RoomstayThemeEngine_1 = __importDefault(require("../providers/RoomstayThemeEngine"));
class AddonAPI extends MockAPI_1.default {
    constructor() {
        super(...arguments);
        this.storedAddons = {};
        this.findAddons = (basketRows) => new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
            var _a;
            const basketRow = basketRows[0];
            const rate = (_a = basketRow.getRate()) === null || _a === void 0 ? void 0 : _a.code;
            const adults = basketRow.getAdults();
            const children = basketRow.getChildren();
            const checkInDate = basketRow.getStartDate().format('YYYY-MM-DD');
            const checkOutDate = basketRow.getEndDate().format('YYYY-MM-DD');
            const language = RoomstayThemeEngine_1.default.selectedLang;
            const upgrade = new Addon_1.Addon();
            const upgradeData = {
                code: 'TEST1',
                name: 'Room Upgrade',
                description: 'Upgrade your room for a more luxurious stay. Treat yourself!',
                image: 'https://unsplash.com/photos/lG1Gc-IW6f0/download?w:1920',
                pricingType: 'Per Night',
                availability: {},
                category: '',
                inclusive: false,
                ratePlanCode: '',
            };
            const champagne = new Addon_1.Addon();
            const champagneData = {
                code: 'TEST2',
                name: 'Champagne in Room',
                description: 'Enjoy a chilled glass of premium champagne served in an ice bucket, ready for you in your room upon arrival.',
                image: 'https://unsplash.com/photos/RhBnqwZwtbU/download?w:1920',
                pricingType: 'Per Night',
                availability: {},
                category: '',
                inclusive: false,
                ratePlanCode: '',
            };
            const lateCheckout = new Addon_1.Addon();
            const lateCheckoutData = {
                code: 'TEST3',
                name: 'Late Checkout',
                description: 'Planning for a late night? Why not sleep in a little longer? Book a late checkout to give you more time to relax before your flight home.',
                image: 'https://unsplash.com/photos/kHHwYNA1lnM/download?w:1920',
                pricingType: 'Per Night',
                availability: {},
                category: '',
                inclusive: false,
                ratePlanCode: '',
            };
            const daysBetween = basketRow.getEndDate().diff(basketRow.getStartDate(), 'day');
            for (let i = 0; i < daysBetween; i++) {
                const addonDate = basketRow.getStartDate().add(i, 'day').format('YYYY-MM-DD');
                upgradeData.availability[addonDate] = { price: 50, quantity: 1 };
                champagneData.availability[addonDate] = { price: 75, quantity: 1 };
                lateCheckoutData.availability[addonDate] = { price: 25, quantity: 1 };
            }
            upgrade.applyData(upgradeData);
            champagne.applyData(champagneData);
            lateCheckout.applyData(lateCheckoutData);
            return resolve([upgrade, champagne, lateCheckout]);
        }));
    }
}
exports.default = AddonAPI;
//# sourceMappingURL=AddonAPI.js.map