"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var framepay_error_1 = __importDefault(require("../../framepay-error"));
var base_element_1 = __importDefault(require("./base-element"));
var PaypalElement = /** @class */ (function (_super) {
    __extends(PaypalElement, _super);
    function PaypalElement() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    PaypalElement.prototype.setupElement = function () {
        var _this = this;
        var Framepay = this.props.Framepay;
        var makeElement = function () {
            // elementNode already checked in BaseElement.handleSetupElement
            // just ts checks fix
            if (!_this.elementNode) {
                throw (0, framepay_error_1.default)({
                    code: framepay_error_1.default.codes.elementMountError,
                    details: "PaypalElement invalid elementNode",
                });
            }
            try {
                return Framepay.paypal.mount(_this.elementNode);
            }
            catch (e) {
                throw (0, framepay_error_1.default)({
                    code: framepay_error_1.default.codes.elementMountError,
                    details: "PaypalElement error in remote api call",
                    trace: e,
                });
            }
        };
        var element = makeElement();
        this.setState({ element: element });
    };
    return PaypalElement;
}(base_element_1.default));
exports.default = PaypalElement;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGF5cGFsLWVsZW1lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvbGliL2NvbXBvbmVudHMvZWxlbWVudHMvcGF5cGFsLWVs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