@konnectio/core
Version:
Konnectio Core Frontend Integration.
587 lines (586 loc) • 18.4 kB
JavaScript
import { g as j } from "./_commonjsHelpers-DaMA6jEr.js";
var b = { exports: {} }, y = { exports: {} }, U = y.exports, P;
function V() {
return P || (P = 1, function(e, t) {
(function(o, r) {
e.exports = r();
})(U, function() {
function o(a) {
return !isNaN(parseFloat(a)) && isFinite(a);
}
function r(a) {
return a.charAt(0).toUpperCase() + a.substring(1);
}
function s(a) {
return function() {
return this[a];
};
}
var f = ["isConstructor", "isEval", "isNative", "isToplevel"], d = ["columnNumber", "lineNumber"], l = ["fileName", "functionName", "source"], i = ["args"], m = ["evalOrigin"], n = f.concat(d, l, i, m);
function c(a) {
if (a)
for (var p = 0; p < n.length; p++)
a[n[p]] !== void 0 && this["set" + r(n[p])](a[n[p]]);
}
c.prototype = {
getArgs: function() {
return this.args;
},
setArgs: function(a) {
if (Object.prototype.toString.call(a) !== "[object Array]")
throw new TypeError("Args must be an Array");
this.args = a;
},
getEvalOrigin: function() {
return this.evalOrigin;
},
setEvalOrigin: function(a) {
if (a instanceof c)
this.evalOrigin = a;
else if (a instanceof Object)
this.evalOrigin = new c(a);
else
throw new TypeError("Eval Origin must be an Object or StackFrame");
},
toString: function() {
var a = this.getFileName() || "", p = this.getLineNumber() || "", v = this.getColumnNumber() || "", E = this.getFunctionName() || "";
return this.getIsEval() ? a ? "[eval] (" + a + ":" + p + ":" + v + ")" : "[eval]:" + p + ":" + v : E ? E + " (" + a + ":" + p + ":" + v + ")" : a + ":" + p + ":" + v;
}
}, c.fromString = function(p) {
var v = p.indexOf("("), E = p.lastIndexOf(")"), A = p.substring(0, v), F = p.substring(v + 1, E).split(","), k = p.substring(E + 1);
if (k.indexOf("@") === 0)
var x = /@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(k, ""), I = x[1], T = x[2], q = x[3];
return new c({
functionName: A,
args: F || void 0,
fileName: I,
lineNumber: T || void 0,
columnNumber: q || void 0
});
};
for (var u = 0; u < f.length; u++)
c.prototype["get" + r(f[u])] = s(f[u]), c.prototype["set" + r(f[u])] = /* @__PURE__ */ function(a) {
return function(p) {
this[a] = !!p;
};
}(f[u]);
for (var h = 0; h < d.length; h++)
c.prototype["get" + r(d[h])] = s(d[h]), c.prototype["set" + r(d[h])] = /* @__PURE__ */ function(a) {
return function(p) {
if (!o(p))
throw new TypeError(a + " must be a Number");
this[a] = Number(p);
};
}(d[h]);
for (var g = 0; g < l.length; g++)
c.prototype["get" + r(l[g])] = s(l[g]), c.prototype["set" + r(l[g])] = /* @__PURE__ */ function(a) {
return function(p) {
this[a] = String(p);
};
}(l[g]);
return c;
});
}(y)), y.exports;
}
var B = b.exports, $;
function J() {
return $ || ($ = 1, function(e, t) {
(function(o, r) {
e.exports = r(V());
})(B, function(r) {
var s = /(^|@)\S+:\d+/, f = /^\s*at .*(\S+:\d+|\(native\))/m, d = /^(eval@)?(\[native code])?$/;
return {
/**
* Given an Error object, extract the most information from it.
*
* @param {Error} error object
* @return {Array} of StackFrames
*/
parse: function(i) {
if (typeof i.stacktrace < "u" || typeof i["opera#sourceloc"] < "u")
return this.parseOpera(i);
if (i.stack && i.stack.match(f))
return this.parseV8OrIE(i);
if (i.stack)
return this.parseFFOrSafari(i);
throw new Error("Cannot parse given Error object");
},
// Separate line and column numbers from a string of the form: (URI:Line:Column)
extractLocation: function(i) {
if (i.indexOf(":") === -1)
return [i];
var m = /(.+?)(?::(\d+))?(?::(\d+))?$/, n = m.exec(i.replace(/[()]/g, ""));
return [n[1], n[2] || void 0, n[3] || void 0];
},
parseV8OrIE: function(i) {
var m = i.stack.split(`
`).filter(function(n) {
return !!n.match(f);
}, this);
return m.map(function(n) {
n.indexOf("(eval ") > -1 && (n = n.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, ""));
var c = n.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, ""), u = c.match(/ (\(.+\)$)/);
c = u ? c.replace(u[0], "") : c;
var h = this.extractLocation(u ? u[1] : c), g = u && c || void 0, a = ["eval", "<anonymous>"].indexOf(h[0]) > -1 ? void 0 : h[0];
return new r({
functionName: g,
fileName: a,
lineNumber: h[1],
columnNumber: h[2],
source: n
});
}, this);
},
parseFFOrSafari: function(i) {
var m = i.stack.split(`
`).filter(function(n) {
return !n.match(d);
}, this);
return m.map(function(n) {
if (n.indexOf(" > eval") > -1 && (n = n.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1")), n.indexOf("@") === -1 && n.indexOf(":") === -1)
return new r({
functionName: n
});
var c = /((.*".+"[^@]*)?[^@]*)(?:@)/, u = n.match(c), h = u && u[1] ? u[1] : void 0, g = this.extractLocation(n.replace(c, ""));
return new r({
functionName: h,
fileName: g[0],
lineNumber: g[1],
columnNumber: g[2],
source: n
});
}, this);
},
parseOpera: function(i) {
return !i.stacktrace || i.message.indexOf(`
`) > -1 && i.message.split(`
`).length > i.stacktrace.split(`
`).length ? this.parseOpera9(i) : i.stack ? this.parseOpera11(i) : this.parseOpera10(i);
},
parseOpera9: function(i) {
for (var m = /Line (\d+).*script (?:in )?(\S+)/i, n = i.message.split(`
`), c = [], u = 2, h = n.length; u < h; u += 2) {
var g = m.exec(n[u]);
g && c.push(new r({
fileName: g[2],
lineNumber: g[1],
source: n[u]
}));
}
return c;
},
parseOpera10: function(i) {
for (var m = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i, n = i.stacktrace.split(`
`), c = [], u = 0, h = n.length; u < h; u += 2) {
var g = m.exec(n[u]);
g && c.push(
new r({
functionName: g[3] || void 0,
fileName: g[2],
lineNumber: g[1],
source: n[u]
})
);
}
return c;
},
// Opera 10.65+ Error.stack very similar to FF/Safari
parseOpera11: function(i) {
var m = i.stack.split(`
`).filter(function(n) {
return !!n.match(s) && !n.match(/^Error created at/);
}, this);
return m.map(function(n) {
var c = n.split("@"), u = this.extractLocation(c.pop()), h = c.shift() || "", g = h.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0, a;
h.match(/\(([^)]*)\)/) && (a = h.replace(/^[^(]+\(([^)]*)\)$/, "$1"));
var p = a === void 0 || a === "[arguments not available]" ? void 0 : a.split(",");
return new r({
functionName: g,
args: p,
fileName: u[0],
lineNumber: u[1],
columnNumber: u[2],
source: n
});
}, this);
}
};
});
}(b)), b.exports;
}
var D = J();
const G = /* @__PURE__ */ j(D);
var N = '"1.1.0"', L = "5pqzBljrmDvquWZYSrSUKldIUREtPyB3", M = '"4.3.3"';
function w(e, t, o) {
return o && !e && console.error(`Flare JavaScript client v${N}: ${t}`), !!e;
}
function X(e, t) {
return w(
e,
"The client was not yet initialised with an API key. Run client.light('<flare-project-key>') when you initialise your app. If you are running in dev mode and didn't run the light command on purpose, you can ignore this error.",
t
);
}
function H(e, t) {
return w("canSolve" in e, "A solution provider without a [canSolve] property was added.", t) && w(
"getSolutions" in e,
"A solution provider without a [getSolutions] property was added.",
t
);
}
function K(e) {
let t = [];
const o = JSON.stringify(e, function(r, s) {
if (typeof s == "object" && s !== null) {
if (t.indexOf(s) !== -1)
try {
return JSON.parse(JSON.stringify(s));
} catch {
return;
}
t.push(s);
}
return s;
});
return t = null, o;
}
function z(e) {
return e.reduce((t, o) => t.concat(o), []);
}
function O() {
return Math.round(Date.now() / 1e3);
}
var Q = class {
report(e, t, o, r) {
return fetch(t, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Api-Token": o ?? "",
"X-Requested-With": "XMLHttpRequest",
"X-Report-Browser-Extension-Errors": JSON.stringify(r)
},
body: K({
...e,
key: o
})
}).then(
(s) => {
s.status !== 204 && console.error(`Received response with status ${s.status} from Flare`);
},
(s) => console.error(s)
);
}
};
function W() {
return window.document.cookie ? {
cookies: window.document.cookie.split("; ").reduce(
(e, t) => {
const [o, r] = t.split(/=/);
return e[o] = r, e;
},
{}
)
} : {};
}
function Y() {
return {
request: {
url: window.document.location.href,
useragent: window.navigator.userAgent,
referrer: window.document.referrer,
readyState: window.document.readyState
}
};
}
function Z() {
if (!window.location.search)
return {};
const e = {};
return new URLSearchParams(window.location.search).forEach((t, o) => {
e[o] = t;
}), { request_data: { queryString: e } };
}
function _(e) {
return typeof window > "u" ? e : {
...W(),
...Y(),
...Z(),
...e
};
}
function ee(e, t, o = {}) {
return new Promise((r) => {
const s = e.reduce(
(f, d) => (f.push(Promise.resolve(d.canSolve(t, o))), f),
[]
);
Promise.all(s).then((f) => {
const d = [];
f.forEach((l, i) => {
l && d.push(
Promise.resolve(e[i].getSolutions(t, o))
);
}), Promise.all(d).then((l) => {
r(z(l));
});
});
});
}
var R = {};
function re(e, t, o) {
return new Promise((r) => {
if (!e || !t)
return r({
codeSnippet: {
0: `Could not read from file: missing file URL or line number. URL: ${e} lineNumber: ${t}`
},
trimmedColumnNumber: null
});
te(e).then((s) => r(s ? ne(s, t, o) : {
codeSnippet: {
0: `Could not read from file: Error while opening file at URL ${e}`
},
trimmedColumnNumber: null
}));
});
}
function te(e) {
return R[e] ? Promise.resolve(R[e]) : fetch(e).then((t) => t.status !== 200 ? null : t.text()).catch(() => null);
}
function ne(e, t, o, r = 1e3, s = 40) {
const f = {};
let d = null;
const l = e.split(`
`);
for (let i = -s / 2; i <= s / 2; i++) {
const m = t + i;
if (m >= 0 && l[m]) {
const n = m + 1;
if (l[m].length > r) {
if (o && o + r / 2 > r) {
f[n] = l[m].substr(
o - Math.round(r / 2),
r
), n === t && (d = Math.round(r / 2));
continue;
}
f[n] = l[m].substr(0, r) + "…";
continue;
}
f[n] = l[m];
}
}
return { codeSnippet: f, trimmedColumnNumber: d };
}
function C(e, t) {
return new Promise((o) => {
if (!oe(e))
return w(!1, "Couldn't generate stacktrace of below error:", t), t && console.error(e), o([
{
line_number: 0,
column_number: 0,
method: "unknown",
file: "unknown",
code_snippet: {
0: "Could not read from file: stacktrace missing"
},
trimmed_column_number: null,
class: "unknown"
}
]);
Promise.all(
G.parse(e).map((r) => new Promise((s) => {
re(r.fileName, r.lineNumber, r.columnNumber).then((f) => {
s({
line_number: r.lineNumber || 1,
column_number: r.columnNumber || 1,
method: r.functionName || "Anonymous or unknown function",
file: r.fileName || "Unknown file",
code_snippet: f.codeSnippet,
trimmed_column_number: f.trimmedColumnNumber,
class: ""
});
});
}))
).then(o);
});
}
function oe(e) {
return !!e && (!!e.stack || !!e.stacktrace || !!e["opera#sourceloc"]) && typeof (e.stack || e.stacktrace || e["opera#sourceloc"]) == "string" && e.stack !== `${e.name}: ${e.message}`;
}
var ie = class {
constructor(e = new Q()) {
this.api = e, this.config = {
key: null,
version: N,
sourcemapVersion: M,
stage: "",
maxGlowsPerReport: 30,
reportingUrl: "https://reporting.flareapp.io/api/reports",
reportBrowserExtensionErrors: !1,
debug: !1,
beforeEvaluate: (t) => t,
beforeSubmit: (t) => t
}, this.glows = [], this.context = { context: {} }, this.solutionProviders = [];
}
light(e = L, t = !1) {
return this.config.key = e, this.config.debug = t, this;
}
configure(e) {
return this.config = { ...this.config, ...e }, this;
}
test() {
return this.report(new Error("The Flare client is set up correctly!"));
}
glow(e, t = "info", o = []) {
const r = O();
return this.glows.push({
name: e,
message_level: t,
meta_data: o,
time: r,
microtime: r
}), this.glows.length > this.config.maxGlowsPerReport && (this.glows = this.glows.slice(this.glows.length - this.config.maxGlowsPerReport)), this;
}
clearGlows() {
return this.glows = [], this;
}
addContext(e, t) {
return this.context.context[e] = t, this;
}
addContextGroup(e, t) {
return this.context[e] = t, this;
}
registerSolutionProvider(e) {
return H(e, this.config.debug) ? (this.solutionProviders.push(e), this) : this;
}
async report(e, t = {}, o = {}) {
if (!await this.config.beforeEvaluate(e))
return;
const s = await this.createReportFromError(e, t, o);
if (s)
return this.sendReport(s);
}
async reportMessage(e, t = {}, o = "Log") {
const r = await C(Error(), this.config.debug);
r.shift(), this.sendReport({
notifier: `Flare JavaScript client v${N}`,
exception_class: o,
seen_at: O(),
message: e,
language: "javascript",
glows: this.glows,
context: _({ ...t, ...this.context }),
stacktrace: r,
sourcemap_version_id: this.config.sourcemapVersion,
solutions: [],
stage: this.config.stage
});
}
createReportFromError(e, t = {}, o = {}) {
if (!w(e, "No error provided.", this.config.debug))
return Promise.resolve(!1);
const r = O();
return Promise.all([
ee(this.solutionProviders, e, o),
C(e, this.config.debug)
]).then((s) => {
const [f, d] = s;
return w(d.length, "Couldn't generate stacktrace of this error: " + e, this.config.debug), {
notifier: `Flare JavaScript client v${N}`,
exception_class: e.constructor && e.constructor.name ? e.constructor.name : "undefined",
seen_at: r,
message: e.message,
language: "javascript",
glows: this.glows,
context: _({ ...t, ...this.context }),
stacktrace: d,
sourcemap_version_id: this.config.sourcemapVersion,
solutions: f,
stage: this.config.stage
};
});
}
async sendReport(e) {
if (!X(this.config.key, this.config.debug))
return;
const t = await this.config.beforeSubmit(e);
if (t)
return this.api.report(
t,
this.config.reportingUrl,
this.config.key,
this.config.reportBrowserExtensionErrors
);
}
// Deprecated, the following methods exist for backwards compatibility.
set beforeEvaluate(e) {
this.config.beforeEvaluate = e ?? "";
}
set beforeSubmit(e) {
this.config.beforeSubmit = e ?? "";
}
set stage(e) {
this.config.stage = e ?? "";
}
};
function ae() {
if (typeof window > "u")
return;
const e = window.flare;
if (!window || !e)
return;
const t = window.onerror, o = window.onunhandledrejection;
window.onerror = (r, s, f, d, l) => {
l && e.report(l), typeof t == "function" && t(r, s, f, d, l);
}, window.onunhandledrejection = (r) => {
r.reason instanceof Error && e.report(r.reason), typeof o == "function" && o(r);
};
}
var S = new ie();
typeof window < "u" && window && (window.flare = S, ae());
const se = [
"fancybox",
".fancybox",
"jQuery",
"Modernizr",
"cssua",
"ScrollTrigger",
"calcSelectArrowDimensions",
"this.elements.$menu.smartmenus",
"woocommerce",
"elementor",
"avadaAddQuantityBoxes",
"fusion",
"FLBuilderAccordion",
"_initLayerSlider",
"Divi",
"gsap",
"Swiper",
"$(...).fancybox",
"imagesLoaded",
"jQuery(...).tooltip",
"jQuery(...).scrollspy"
];
S.light("5pqzBljrmDvquWZYSrSUKldIUREtPyB3"), S.addContext("version", "4.3.3"), S.beforeEvaluate = (e) => (se.forEach((t) => {
if (e.message.includes(t))
return !1;
}), e);
function ue(e) {
const t = e.config.errorHandler;
e.config.errorHandler = (o, r, s) => {
const f = r && r.$options && r.$options.name ? r.$options.name : "AnonymousComponent", d = {
vue: { info: s, componentName: f }
};
if (S.report(o, d, { vue: { vm: r, info: s } }), typeof t == "function") {
t(o, r, s);
return;
}
throw o;
};
}
export {
ue as f
};
//# sourceMappingURL=index-Dp94FdK7.js.map