"use strict";
var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importStar(require("react"));
var Fiat_1 = require("./Fiat");
var TopUpWithCrypto_1 = require("./TopUpWithCrypto");
var FooterSection_1 = require("../commons/FooterSection");
var TopUpProviderSupportService_1 = require("../../core/services/TopUpProviderSupportService");
var countries_1 = require("../../core/utils/countries");
var PayButton_1 = require("./PayButton");
var getPayButtonState_1 = require("../../app/TopUp/getPayButtonState");
var ChooseTopUpMethodWrapper_1 = require("./ChooseTopUpMethodWrapper");
var ChooseTopUpMethodHeader_1 = require("./ChooseTopUpMethodHeader");
exports.ChooseTopUpMethod = function (_a) {
    var walletService = _a.walletService, onPayClick = _a.onPayClick, topUpClassName = _a.topUpClassName, logoColor = _a.logoColor;
    var _b = __read(react_1.useState(undefined), 2), topUpMethod = _b[0], setTopUpMethod = _b[1];
    var _c = __read(react_1.useState(function () { return new TopUpProviderSupportService_1.TopUpProviderSupportService(countries_1.countries); }), 1), topUpProviderSupportService = _c[0];
    var _d = __read(react_1.useState(''), 2), amount = _d[0], setAmount = _d[1];
    var _e = __read(react_1.useState(undefined), 2), paymentMethod = _e[0], setPaymentMethod = _e[1];
    return (react_1.default.createElement(ChooseTopUpMethodWrapper_1.ChooseTopUpMethodWrapper, { className: topUpClassName, topUpMethod: topUpMethod },
        react_1.default.createElement(ChooseTopUpMethodHeader_1.ChooseTopUpMethodHeader, { topUpMethod: topUpMethod, setTopUpMethod: setTopUpMethod }),
        topUpMethod === 'crypto' && react_1.default.createElement(TopUpWithCrypto_1.TopUpWithCrypto, { walletService: walletService }),
        topUpMethod === 'fiat' && react_1.default.createElement(Fiat_1.TopUpWithFiat, { walletService: walletService, topUpProviderSupportService: topUpProviderSupportService, amount: amount, onAmountChange: setAmount, paymentMethod: paymentMethod, onPaymentMethodChange: setPaymentMethod, logoColor: logoColor }),
        topUpMethod && react_1.default.createElement(FooterSection_1.FooterSection, { className: topUpClassName },
            react_1.default.createElement(PayButton_1.PayButton, { onClick: function () { return onPayClick(paymentMethod, amount); }, state: getPayButtonState_1.getPayButtonState(paymentMethod, topUpProviderSupportService, amount, topUpMethod) }))));
};
//# sourceMappingURL=ChooseTopUpMethod.js.map