"use strict";
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
    return cooked;
};
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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = __importStar(require("react"));
var react_apollo_1 = require("react-apollo");
var graphql_tag_1 = __importDefault(require("graphql-tag"));
var TokensTextComponents_1 = require("../TokensTextComponents");
var AirswapBuyCVL_1 = require("./AirswapBuyCVL");
var TokenPurchaseSummary_1 = require("../TokenPurchaseSummary");
var cvlPriceQuery = graphql_tag_1.default(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n  query($usdToSpend: Float!) {\n    storefrontEthPrice\n    storefrontCvlPrice\n    storefrontCvlQuoteUsd(usdToSpend: $usdToSpend)\n  }\n"], ["\n  query($usdToSpend: Float!) {\n    storefrontEthPrice\n    storefrontCvlPrice\n    storefrontCvlQuoteUsd(usdToSpend: $usdToSpend)\n  }\n"])));
exports.AirswapBuySection = function (props) {
    var usdToSpend = props.usdToSpend, onBuyComplete = props.onBuyComplete, foundationAddress = props.foundationAddress, network = props.network;
    return (React.createElement(React.Fragment, null,
        React.createElement(react_apollo_1.Query, { query: cvlPriceQuery, variables: { usdToSpend: usdToSpend } }, function (_a) {
            var loading = _a.loading, error = _a.error, data = _a.data;
            if (error) {
                return React.createElement("div", null, "error loading data");
            }
            var totalTokens = data.storefrontCvlQuoteUsd;
            var pricePer = usdToSpend / data.storefrontCvlQuoteUsd;
            return (React.createElement(React.Fragment, null,
                React.createElement(TokenPurchaseSummary_1.TokenPurchaseSummary, { mode: "buy", currencyCode: "CVL", pricePer: pricePer, totalTokens: totalTokens, totalPrice: usdToSpend }),
                React.createElement(AirswapBuyCVL_1.AirswapBuyCVL, { network: network, buyCVLBtnText: React.createElement(TokensTextComponents_1.TokenBuyFoundationBtnText, null), buyFromAddress: foundationAddress, onComplete: onBuyComplete, amount: totalTokens }),
                React.createElement(TokensTextComponents_1.TokenAirswapExchangeTermsOfSaleText, null)));
        })));
};
var templateObject_1;
//# sourceMappingURL=AirswapBuySection.js.map