const removePatterns = ()=>$.each($.payment.cards, (function(n, t) {
    "elo" !== t.type && "visaelectron" !== t.type || (t.patterns = [])
}
));
removePatterns(),
function() {
    $((function() {
        var n, t, e, r, a, i, c, o, u, d, l, s, f, p, m, _, v, h, g, b, y, w, x, T, k, C, E, L, S, q, N, F, A, P, V, H, O, R, W;
        return e = $("#cc_form"),
        b = $("#select_authentication_method"),
        w = $("#user_info"),
        Array("cc_number", "cc_holder_name", "cc_expiration_date", "cc_verification"),
        c = $("#edit_customer_details"),
        s = function(n) {
            var t, e, r, a;
            for (e = 0,
            r = (a = n.attr("class").split(" ")).length; e < r; e++)
                if ((t = a[e]).match(/^cc_|user_id|personal_code|phone_number|corporate_id/))
                    return t
        }
        ,
        g = function(n) {
            n.parents(".input").removeClass("has-error")
        }
        ,
        n = function(n, t, e) {
            var r, a;
            n.parents(".input").addClass("has-error"),
            0 === (r = (a = n.parents(".input").find("input").parent()).find(".input-error")).length && (r = $("<div>").addClass("input-error"),
            a.append(r)),
            e && r.php(f(n, t)).removeClass("hide")
        }
        ,
        F = function(t, e) {
            var r;
            return g(t),
            (r = !t.val()) && n(t, "blank", e),
            r
        }
        ,
        _ = function(n) {
            var t, e;
            return t = XRegExp("^[\\pL'd,. \t-]*$"),
            -1 !== (e = n.replace(/(^\s+)|(\s+$)/g, "").replace(/\s+/g, " ")).search(t) && e.length >= 2
        }
        ,
        y = function(t, e, r) {
            return e || n(t, "invalid", r),
            e
        }
        ,
        L = function(n, t) {
            var e, r;
            return !F(n, t) && (e = n.val(),
            r = _(e),
            y(n, r, t))
        }
        ,
        S = function(n, t) {
            var e, r, a;
            return !F(n, t) && (e = n.val(),
            r = $.payment.validateCardNumber(e),
            a = $.payment.cardType(e),
            r && (r = "visa" === a || "mastercard" === a),
            y(n, r, t))
        }
        ,
        E = function(n, t) {
            var e, r;
            return !F(n, t) && (e = $.payment.cardExpiryVal(n.val()),
            r = $.payment.validateCardExpiry(e.month, e.year) && W(e.year),
            y(n, r, t))
        }
        ,
        W = function(n) {
            var t, e;
            return (t = (new Date).getFullYear()) <= (e = parseInt(n)) && e <= t + 20
        }
        ,
        C = function(n, t) {
            var e, r, a, i;
            return !F(n, t) && (r = $("#transaction_request_cc_number").val(),
            i = $.payment.cardType(r),
            e = n.val(),
            a = $.payment.validateCardCVC(e, i),
            y(n, a, t))
        }
        ,
        function() {
            $(".form-group.has-error:first").find("input").focus()
        }
        ,
        f = function(n, t) {
            var e;
            return e = s(n),
            (window.translations ? JSON.parse(window.translations) : window.$translations)[window.$locale][e][t]
        }
        ,
        function(n, t) {
            switch (n) {
            case "cc_number":
                return S(e.find(".cc_number"), t);
            case "cc_holder_name":
                return L(e.find(".cc_holder_name"), t);
            case "cc_expiration_date":
                return E(e.find(".cc_expiration_date"), t);
            case "cc_verification":
                return C(e.find(".cc_verification"), t)
            }
        }
        ,
        p = e.find(".cc_holder_name"),
        m = !1,
        p.on("change", (function(n) {
            m = !0,
            L($(n.currentTarget), !1)
        }
        )),
        p.on("focusin input", (function(n) {
            m && L($(n.currentTarget), !0)
        }
        )),
        p.on("focusout", (function(n) {
            L($(n.currentTarget), !0)
        }
        )),
        (r = e.find(".cc_number")).payment("formatCardNumber"),
        a = !1,
        r.on("change", (function(n) {
            a = !0,
            S($(n.currentTarget), !1)
        }
        )),
        r.on("focusin input", (function(n) {
            a && S($(n.currentTarget), !0)
        }
        )),
        r.on("focusout", (function(n) {
            r.payment("formatCardNumber"),
            a && S($(n.currentTarget), !0)
        }
        )),
        d = e.find(".cc_expiration_date"),
        l = !1,
        d.on("change", (function(n) {
            l = !0,
            g($(n.currentTarget)),
            E($(n.currentTarget), !1)
        }
        )),
        d.on("focusin input", (function(n) {
            d.attr("placeholder", " "),
            $(".cc_exp_date .placeholder").text(d.data("placeholder")),
            l && E($(n.currentTarget), !0)
        }
        )),
        d.on("focusout input", (function(n) {
            d.attr("placeholder", d.data("placeholder")),
            $(".cc_exp_date .placeholder").text(""),
            l && E($(n.currentTarget), !0)
        }
        )),
        o = e.find(".cc_verification"),
        u = !1,
        o.on("change", (function(n) {
            u = !0,
            C($(n.currentTarget), !1)
        }
        )),
        o.on("focusin input", (function(n) {
            u && C($(n.currentTarget), !0)
        }
        )),
        o.on("focusout", (function(n) {
            u && C($(n.currentTarget), !0)
        }
        )),
        c.find("input:not([type='submit'])").on("change", (function(n) {
            g($(n.currentTarget))
        }
        )),
        b.find("input:not([type='submit'])").on("change", (function(n) {
            g($(n.currentTarget))
        }
        )),
        t = function() {
            var n;
            n = r.val().length > 0 && p.val().length > 0 && d.val().length > 0 && o.val().length > 0,
            e.find("#cc_submit").prop("disabled", !n)
        }
        ,
        h = function() {
            var n, t, r, a;
            return a = L(e.find(".cc_holder_name"), !0),
            n = S(e.find(".cc_number"), !0),
            r = E(e.find(".cc_expiration_date"), !0),
            t = C(e.find(".cc_verification"), !0),
            a && n && r && t
        }
        ,
        function() {
            return C(cvc_form.find(".cc_verification"), !1)
        }
        ,
        O = function(n, t) {
            return !F(n, t)
        }
        ,
        V = function(n, t) {
            return !F(n, t)
        }
        ,
        A = function(n, t) {
            return !F(n, t)
        }
        ,
        T = function(n, t) {
            return !F(n, t)
        }
        ,
        q = function(n, t) {
            return !F(n, t)
        }
        ,
        R = function(n) {
            return null == n && (n = b),
            O(n.find('input[name="link_transaction[user_id]"]:visible'), !0)
        }
        ,
        P = function() {
            return A(b.find('input[name="link_transaction[personal_code]"]:visible'), !0)
        }
        ,
        H = function() {
            return V(b.find('input[name="link_transaction[phone_number]"]:visible'), !0)
        }
        ,
        k = function() {
            return T(b.find('input[name="link_transaction[calculator_code]"]:visible'), !0)
        }
        ,
        N = function() {
            return q(b.find('input[name="link_transaction[corporate_id]"]:visible'), !0)
        }
        ,
        x = function() {
            var n;
            return n = !0,
            1 === b.find('input[name="link_transaction[phone_number]"]:visible').length && (H() || (n = !1)),
            1 === b.find('input[name="link_transaction[calculator_code]"]:visible').length && (k() || (n = !1)),
            1 === b.find('input[name="link_transaction[personal_code]"]:visible').length && (P() || (n = !1)),
            1 === b.find('input[name="link_transaction[user_id]"]:visible').length && (R() || (n = !1)),
            1 === b.find('input[name="link_transaction[corporate_id]"]:visible').length && (N() || (n = !1)),
            n
        }
        ,
        window.ccFieldsFilled = t,
        window.reValidateForm = h,
        e.on("submit", (function() {
            var n;
            return (n = h()) && ($("#payment-validation-errors").hide(),
            e.hide(),
            $("#back-section").hide(),
            $("#transaction-processing-container").show()),
            n
        }
        )),
        w.on("submit", (function() {
            return R(w)
        }
        )),
        b.on("submit", (function() {
            var n;
            return (n = x()) && $(".btn-cancel-payment, .btn-back-payment").attr("submitted", !0),
            n
        }
        )),
        i = function(n) {
            var t;
            (t = document.querySelector("[data-country-flag]")).className = "",
            t.classList.add("flag"),
            t.dataset.flag = n,
            document.querySelector("[data-country-options]").dataset.countryOptions = n
        }
        ,
        v = function(n) {
            return n.scrollHeight > n.clientHeight || n.scrollWidth > n.clientWidth
        }
        ,
        document.addEventListener("input", (function(n) {
            "country" === n.target.id && i(n.target.value)
        }
        ), !1),
        document.addEventListener("input", (function(n) {
            var t;
            "locale" === n.target.id && ((t = new URL(window.location.href)).searchParams.set("locale", n.target.value),
            window.location = t.href)
        }
        ), !1),
        document.querySelectorAll("[data-expandable]").forEach((function(n) {
            var t;
            v(n) && (n.dataset.expandable = !0,
            (t = document.createElement("a")).addClass("show-more"),
            n.appendChild(t),
            t.addEventListener("click", (function() {
                n.dataset.expandable = "expanded" === n.dataset.expandable || "expanded"
            }
            ), !1))
        }
        )),
        document.querySelectorAll("[data-tooltip]").forEach((function(n) {
            n.addEventListener("click", (function() {
                n.dataset.tooltipShow = "true" !== n.dataset.tooltipShow
            }
            ), !1)
        }
        ))
    }
    ))
}
.call(this);
