(function () { var t, e, n, r, a, i, l, o, c, h, u, s, p, f, g, d, v, m, y, C = [].slice, w = [].indexOf || function (t) { for (var e = 0, n = this.length; e < n; e++)if (e in this && this[e] === t) return e; return -1 }; (t = jQuery).payment = {}, t.payment.fn = {}, t.fn.payment = function () { var e, n; return n = arguments[0], e = 2 <= arguments.length ? C.call(arguments, 1) : [], t.payment.fn[n].apply(this, e) }, r = [{ type: "maestro", pattern: /^(5018|5020|5038|6304|6759|676[1-3])/, format: a = /(\d{1,4})/g, length: [12, 13, 14, 15, 16, 17, 18, 19], cvcLength: [3], luhn: !0 }, { type: "dinersclub", pattern: /^(36|38|30[0-5])/, format: a, length: [14], cvcLength: [3], luhn: !0 }, { type: "laser", pattern: /^(6706|6771|6709)/, format: a, length: [16, 17, 18, 19], cvcLength: [3], luhn: !0 }, { type: "jcb", pattern: /^35/, format: a, length: [16], cvcLength: [3], luhn: !0 }, { type: "unionpay", pattern: /^62/, format: a, length: [16, 17, 18, 19], cvcLength: [3], luhn: !1 }, { type: "discover", pattern: /^(6011|65|64[4-9]|622)/, format: a, length: [16], cvcLength: [3], luhn: !0 }, { type: "mastercard", pattern: /^5[1-5]/, format: a, length: [16], cvcLength: [3], luhn: !0 }, { type: "amex", pattern: /^3[47]/, format: /(\d{1,4})(\d{1,6})?(\d{1,5})?/, length: [15], cvcLength: [3, 4], luhn: !0 }, { type: "visa", pattern: /^4/, format: a, length: [13, 14, 15, 16], cvcLength: [3], luhn: !0 }], e = function (t) { var e, n, a; for (t = (t + "").replace(/\D/g, ""), n = 0, a = r.length; n < a; n++)if ((e = r[n]).pattern.test(t)) return e }, n = function (t) { var e, n, a; for (n = 0, a = r.length; n < a; n++)if ((e = r[n]).type === t) return e }, p = function (t) { var e, n, r, a, i, l; for (r = !0, a = 0, i = 0, l = (n = (t + "").split("").reverse()).length; i < l; i++)e = n[i], e = parseInt(e, 10), (r = !r) && (e *= 2), e > 9 && (e -= 9), a += e; return a % 10 == 0 }, s = function (t) { var e; return null != t.prop("selectionStart") && t.prop("selectionStart") !== t.prop("selectionEnd") || !("undefined" == typeof document || null === document || null == (e = document.selection) || "function" != typeof e.createRange || !e.createRange().text) }, f = function (e) { return setTimeout(function () { var n, r; return r = (n = t(e.currentTarget)).val(), r = t.payment.formatCardNumber(r), n.val(r) }) }, o = function (n) { var r, a, i, l, o, c, h; if (i = String.fromCharCode(n.which), /^\d+$/.test(i) && (h = (r = t(n.currentTarget)).val(), a = e(h + i), l = (h.replace(/\D/g, "") + i).length, c = 16, a && (c = a.length[a.length.length - 1]), !(l >= c || null != r.prop("selectionStart") && r.prop("selectionStart") !== h.length))) return (o = a && "amex" === a.type ? /^(\d{4}|\d{4}\s\d{6})$/ : /(?:^|\s)(\d{4})$/).test(h) ? (n.preventDefault(), r.val(h + " " + i)) : o.test(h + i) ? (n.preventDefault(), r.val(h + i + " ")) : void 0 }, i = function (e) { var n, r; if (r = (n = t(e.currentTarget)).val(), !e.meta && (null == n.prop("selectionStart") || n.prop("selectionStart") === r.length)) return 8 === e.which && /\s\d?$/.test(r) ? (e.preventDefault(), n.val(r.replace(/\s\d?$/, ""))) : void 0 }, c = function (e) { var n, r, a; if (r = String.fromCharCode(e.which), /^\d+$/.test(r)) return a = (n = t(e.currentTarget)).val() + r, /^\d$/.test(a) && "0" !== a && "1" !== a ? (e.preventDefault(), n.val("0" + a + " / ")) : /^\d\d$/.test(a) ? (e.preventDefault(), n.val(a + " / ")) : void 0 }, h = function (e) { var n, r, a; if (r = String.fromCharCode(e.which), /^\d+$/.test(r)) return a = (n = t(e.currentTarget)).val(), /^\d\d$/.test(a) ? n.val(a + " / ") : void 0 }, u = function (e) { var n, r; if ("/" === String.fromCharCode(e.which)) return r = (n = t(e.currentTarget)).val(), /^\d$/.test(r) && "0" !== r ? n.val("0" + r + " / ") : void 0 }, l = function (e) { var n, r; if (!e.meta && (r = (n = t(e.currentTarget)).val(), 8 === e.which && (null == n.prop("selectionStart") || n.prop("selectionStart") === r.length))) return /\s\/\s?\d?$/.test(r) ? (e.preventDefault(), n.val(r.replace(/\s\/\s?\d?$/, ""))) : void 0 }, m = function (t) { var e; return !(!t.metaKey && !t.ctrlKey) || 32 !== t.which && (0 === t.which || (t.which < 33 || (e = String.fromCharCode(t.which), !!/[\d\s]/.test(e)))) }, d = function (n) { var r, a, i, l; if (r = t(n.currentTarget), i = String.fromCharCode(n.which), /^\d+$/.test(i) && !s(r)) return l = (r.val() + i).replace(/\D/g, ""), (a = e(l)) ? l.length <= a.length[a.length.length - 1] : l.length <= 16 }, v = function (e) { var n, r; if (n = t(e.currentTarget), r = String.fromCharCode(e.which), /^\d+$/.test(r) && !s(n)) return !((n.val() + r).replace(/\D/g, "").length > 6) && void 0 }, g = function (e) { var n, r; if (n = t(e.currentTarget), r = String.fromCharCode(e.which), /^\d+$/.test(r)) return (n.val() + r).length <= 4 }, y = function (e) { var n, a, i, l, o; if (o = (n = t(e.currentTarget)).val(), l = t.payment.cardType(o) || "unknown", !n.hasClass(l)) return a = function () { var t, e, n; for (n = [], t = 0, e = r.length; t < e; t++)i = r[t], n.push(i.type); return n }(), n.removeClass("unknown"), n.removeClass(a.join(" ")), n.addClass(l), n.toggleClass("identified", "unknown" !== l), n.trigger("payment.cardType", l) }, t.payment.fn.formatCardCVC = function () { return this.payment("restrictNumeric"), this.on("keypress", g), this }, t.payment.fn.formatCardExpiry = function () { return this.payment("restrictNumeric"), this.on("keypress", v), this.on("keypress", c), this.on("keypress", u), this.on("keypress", h), this.on("keydown", l), this }, t.payment.fn.formatCardNumber = function () { return this.payment("restrictNumeric"), this.on("keypress", d), this.on("keypress", o), this.on("keydown", i), this.on("keyup", y), this.on("paste", f), this }, t.payment.fn.restrictNumeric = function () { return this.on("keypress", m), this }, t.payment.fn.cardExpiryVal = function () { return t.payment.cardExpiryVal(t(this).val()) }, t.payment.cardExpiryVal = function (t) { var e, n, r; return e = (r = (t = t.replace(/\s/g, "")).split("/", 2))[0], 2 === (null != (n = r[1]) ? n.length : void 0) && /^\d+$/.test(n) && (n = (new Date).getFullYear().toString().slice(0, 2) + n), { month: e = parseInt(e, 10), year: n = parseInt(n, 10) } }, t.payment.validateCardNumber = function (t) { var n, r; return t = (t + "").replace(/\s+|-/g, ""), !!/^\d+$/.test(t) && (!!(n = e(t)) && (r = t.length, w.call(n.length, r) >= 0 && (!1 === n.luhn || p(t)))) }, t.payment.validateCardExpiry = function (e, n) { var r, a, i; return "object" == typeof e && "month" in e && (e = (i = e).month, n = i.year), !(!e || !n) && (e = t.trim(e), n = t.trim(n), !!/^\d+$/.test(e) && (!!/^\d+$/.test(n) && (parseInt(e, 10) <= 12 && (2 === n.length && (n = (new Date).getFullYear().toString().slice(0, 2) + n), a = new Date(n, e), r = new Date, a.setMonth(a.getMonth() - 1), a.setMonth(a.getMonth() + 1, 1), a > r)))) }, t.payment.validateCardCVC = function (e, r) { var a, i; return e = t.trim(e), !!/^\d+$/.test(e) && (r ? (a = e.length, w.call(null != (i = n(r)) ? i.cvcLength : void 0, a) >= 0) : e.length >= 3 && e.length <= 4) }, t.payment.cardType = function (t) { var n; return t && (null != (n = e(t)) ? n.type : void 0) || null }, t.payment.formatCardNumber = function (t) { var n, r, a, i; return (n = e(t)) ? (a = n.length[n.length.length - 1], t = (t = t.replace(/\D/g, "")).slice(0, +a + 1 || 9e9), n.format.global ? null != (i = t.match(n.format)) ? i.join(" ") : void 0 : (null != (r = n.format.exec(t)) && r.shift(), null != r ? r.join(" ") : void 0)) : t } }).call(this);