function(e) {
try {
var i, a, d, h, y, b;
return e.preventDefault(), $.now() - l < s ? void r(t.error, t.interval) : (d = [], f.each(function(e) {
try {
var n;
if ("checkbox-input" === g.fields[e].type ? g.fields[e].value = $(this).find("input").prop("checked") ? c : u : "radio-list" === g.fields[e].type ? g.fields[e].value = $(this).find("[type=radio]:checked").val() || "" : "select-menu" === g.fields[e].type ? g.fields[e].value = $(this).find("select").val() : "hidden" === g.fields[e].type ? (g.fields[e].name = g.fields[e].id, g.fields[e].value = $(this).find("input").val()) : "file" === g.fields[e].type ? g.fields[e].value = $(this).data("result") || "" : (n = $(this).find(".form-control").data("placeholder"), g.fields[e].value = n ? "" : $(this).find(".form-control").val()), g.fields[e].required && "" === g.fields[e].value && d.push(t.required.replace("%field%", g.fields[e].name)), "" === g.fields[e].value) return;
if ("email" !== g.fields[e].type || /.+@.+\..+/.test(g.fields[e].value) || d.push(t.email.replace("%field%", g.fields[e].name)), "phone" === g.fields[e].type && !/.*\d.*\d.*\d.*\d.*/.test(g.fields[e].value)) return d.push(t.phone.replace("%field%", g.fields[e].name))
} catch (r) {
error_handler(r, "red libs 21", arguments.callee)
}
}), "checkbox" === m.privacy && (i = p.closest(".body").find(".agreement-checkbox input").prop("checked"), h = m.privacy_checkbox.replace(/[<>]/g, ""), i === !1 && d.push(t.required.replace("%field%", h))), d.length > 0 ? (p.trigger("error"), void r(t.validate, d.join("\n"))) : (b = {
name: "",
phone: "",
email: "",
count: "",
fields: {},
item: {},
send: g,
items: []
}, _.each(g.fields, function(e) {
try {
var t;
if ("" === b[e.type] && (b[t = e.type] || (b[t] = e.value)), !b.fields[e.name]) return b.fields[e.name] = e.value
} catch (n) {
error_handler(n, "red libs 22", arguments.callee)
}
}), _.each(g.item, function(e) {
try {
var t, n;
return (t = b.item)[n = e.type] || (t[n] = _.escape(e.value))
} catch (r) {
error_handler(r, "red libs 23", arguments.callee)
}
}), _.each(g.items, function(e, t) {
try {
return b.items[t] = {}, _.each(e, function(e) {
try {
var n, r, i, o;
"amount" === e.type || "photo" === e.type ? (n = b.items[t])[i = e.type] || (n[i] = e.value) : (r = b.items[t])[o = e.type] || (r[o] = _.escape(e.value))
} catch (a) {
error_handler(a, "red libs 25", arguments.callee)
}
})
} catch (n) {
error_handler(n, "red libs 24", arguments.callee)
}
}), m.payPrice && !b.items.length && b.items.push({
amount: 1,
price: m.payPrice,
title: m.payTitle
}), n.prop("disabled", !0), y = function(e, i, a) {
try {
var l, u, c, d;
return _.defaults(e, b), console.log("Данные формы", {
time: e.time,
name: e.name,
email: e.email,
phone: e.phone,
count: e.count,
fields: e.fields,
item: e.item,
items: e.items
}), n.prop("disabled", !1), 0 === e.result ? (r(t.error, e.errors), p.trigger("error")) : 1 === e.result ? (p.trigger("done"), d = n.data("ym_goal"), window.yaCounter && yaCounter.reachGoal(d), u = n.data("ga_category"), l = n.data("ga_action"), window.ga && ga("send", "event", u, l), "msg" === m.after ? o(_.template(m.msg, e), null) : "url" === m.after ? location.href = _.template(m.url, e) : "addhtml" === m.after ? $("body").append(_.template(m.addhtml, e)) : "pay" === m.after ? e.url ? location.href = e.url : e.form && $(e.form).hide().appendTo("body").submit() : "msg+url" === m.after ? o(_.template(m.msg, e), null, function() {
try {
return location.href = _.template(m.url, e)
} catch (t) {
error_handler(t, "red libs 27", arguments.callee)
}
}) : "msg+pay" === m.after ? o(_.template(m.msg, e), null, function() {
try {
if (e.url) return location.href = e.url;
if (e.form) return $(e.form).hide().appendTo("body").submit()
} catch (t) {
error_handler(t, "red libs 28", arguments.callee)
}
}) : "msg+addhtml" === m.after ? o(_.template(m.msg, e), null, function() {
try {
return $("body").append(_.template(m.addhtml, e))
} catch (t) {
error_handler(t, "red libs 29", arguments.callee)
}
}) : "js" === m.after && (c = "(function () { var time = <%= time %>; var name = '<%- name %>'; var email = '<%- email %>'; var phone = '<%- phone %>'; var count = '<%- count %>'; var fields = <%= JSON.stringify(fields) %>; var item = <%= JSON.stringify(item) %>; var items = <%= JSON.stringify(items) %>; var send = <%= JSON.stringify(send) %>;" + m.js + "})();", $.globalEval(_.template(c, e)))) : (r(t.error, null), p.trigger("error")), p.trigger("reset").find("[data-placeholder]").data("placeholder", !0), v.length && plp.cart.empty(), plp.modal.closeAll(), s = $.now()
} catch (f) {
error_handler(f, "red libs 26", arguments.callee)
}
}, a = function(e, i, o) {
try {
return p.trigger("error"), n.prop("disabled", !1), r(t.error, 400 === e.status ? e.responseText : null), s = $.now()
} catch (a) {
error_handler(a, "red libs 30", arguments.callee)
}
}, $.ajax("/app/c.php", {
type: "POST",
data: JSON.stringify(g),
dataType: "json",
contentType: "application/json",
processData: !1,
success: y,
error: y
})))
}