@brainfish-ai/widgets-initiator 1.11.0 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/initBrainfishAnalytics.d.ts +1 -1
- package/dist/web.cjs.js +5 -5
- package/dist/web.js +115 -115
- package/package.json +1 -1
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/web.cjs.js.map +0 -1
- package/dist/web.js.map +0 -1
package/dist/web.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
var je = Object.defineProperty, Le = Object.defineProperties;
|
|
2
2
|
var Fe = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var me = Object.getOwnPropertySymbols;
|
|
4
|
-
var He = Object.prototype.hasOwnProperty,
|
|
4
|
+
var He = Object.prototype.hasOwnProperty, Re = Object.prototype.propertyIsEnumerable;
|
|
5
5
|
var L = (r, t, n) => t in r ? je(r, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[t] = n, F = (r, t) => {
|
|
6
6
|
for (var n in t || (t = {}))
|
|
7
7
|
He.call(t, n) && L(r, n, t[n]);
|
|
8
8
|
if (me)
|
|
9
9
|
for (var n of me(t))
|
|
10
|
-
|
|
10
|
+
Re.call(t, n) && L(r, n, t[n]);
|
|
11
11
|
return r;
|
|
12
12
|
}, H = (r, t) => Le(r, Fe(t));
|
|
13
13
|
var E = (r, t, n) => L(r, typeof t != "symbol" ? t + "" : t, n);
|
|
14
|
-
var
|
|
14
|
+
var b = (r, t, n) => new Promise((d, i) => {
|
|
15
15
|
var a = (l) => {
|
|
16
16
|
try {
|
|
17
17
|
s(n.next(l));
|
|
@@ -27,16 +27,16 @@ var v = (r, t, n) => new Promise((d, i) => {
|
|
|
27
27
|
}, s = (l) => l.done ? d(l.value) : Promise.resolve(l.value).then(a, e);
|
|
28
28
|
s((n = n.apply(r, t)).next());
|
|
29
29
|
});
|
|
30
|
-
var
|
|
30
|
+
var _, z;
|
|
31
31
|
(function() {
|
|
32
32
|
try {
|
|
33
33
|
var r = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : {}, t = new r.Error().stack;
|
|
34
|
-
t && (r._sentryDebugIds = r._sentryDebugIds || {}, r._sentryDebugIds[t] = "
|
|
34
|
+
t && (r._sentryDebugIds = r._sentryDebugIds || {}, r._sentryDebugIds[t] = "6de2cd43-b3af-4d15-9ef2-a2f84e7a12f6", r._sentryDebugIdIdentifier = "sentry-dbid-6de2cd43-b3af-4d15-9ef2-a2f84e7a12f6");
|
|
35
35
|
} catch (n) {
|
|
36
36
|
}
|
|
37
|
-
})(), (typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : {}).SENTRY_RELEASE = { id: "
|
|
37
|
+
})(), (typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : {}).SENTRY_RELEASE = { id: "e0b207633e908a9f78a2323f67f306a8adab15ee" }, function(r) {
|
|
38
38
|
r.Sidebar = "sidebar", r.Searchbar = "searchbar", r.Popup = "popup";
|
|
39
|
-
}(
|
|
39
|
+
}(_ || (_ = {})), _.Sidebar, _.Searchbar, _.Popup;
|
|
40
40
|
class le extends Error {
|
|
41
41
|
constructor(n, d) {
|
|
42
42
|
super(n, d);
|
|
@@ -51,7 +51,7 @@ Caused by: ` + this.cause.stack);
|
|
|
51
51
|
(function(r) {
|
|
52
52
|
r.LINK = "link", r.CALLBACK = "callback", r.EMAIL = "email", r.PHONE = "phone";
|
|
53
53
|
})(z || (z = {}));
|
|
54
|
-
const
|
|
54
|
+
const C = (r, t, n, d) => {
|
|
55
55
|
let i = n, a = {};
|
|
56
56
|
if (t instanceof Error) try {
|
|
57
57
|
a = JSON.parse(t.message), i += ` - ${a.message || t.message}`;
|
|
@@ -62,12 +62,12 @@ const _ = (r, t, n, d) => {
|
|
|
62
62
|
((e, s, l) => {
|
|
63
63
|
if (!navigator || navigator.userAgent.toLowerCase().includes("headless")) return;
|
|
64
64
|
const o = s.toJSON();
|
|
65
|
-
fetch(`${e || "https://app.brainfi.sh"}/api/trackError.widget.create`, { method: "POST", headers: { "Content-Type": "application/json", "api-key": l }, body: JSON.stringify({ error: `WebWidgetVersion: 1.11.
|
|
65
|
+
fetch(`${e || "https://app.brainfi.sh"}/api/trackError.widget.create`, { method: "POST", headers: { "Content-Type": "application/json", "api-key": l }, body: JSON.stringify({ error: `WebWidgetVersion: 1.11.1. ${s.message}`, stack: s.stack, cause: { message: o.message, stack: o.stack, cause: o.cause } }) });
|
|
66
66
|
})(r, new le(i, { cause: a }), d);
|
|
67
|
-
},
|
|
67
|
+
}, $e = (r) => b(void 0, null, function* () {
|
|
68
68
|
let { widgetKey: t, apiHost: n } = r;
|
|
69
69
|
return function(d, i, a) {
|
|
70
|
-
return
|
|
70
|
+
return b(this, null, function* () {
|
|
71
71
|
let e, s = 0;
|
|
72
72
|
for (; s < 3; ) try {
|
|
73
73
|
const l = yield fetch(`${d}${i}`, { method: "POST", headers: { "Content-Type": "application/json", "api-key": a } });
|
|
@@ -76,7 +76,7 @@ const _ = (r, t, n, d) => {
|
|
|
76
76
|
if (!o) throw new Error("Error loading config: empty response");
|
|
77
77
|
return o;
|
|
78
78
|
} catch (l) {
|
|
79
|
-
if (e = l, s++, s >= 3) throw
|
|
79
|
+
if (e = l, s++, s >= 3) throw C(d, l, "Error fetching config", a), e;
|
|
80
80
|
yield new Promise((o) => setTimeout(o, 500));
|
|
81
81
|
}
|
|
82
82
|
});
|
|
@@ -87,34 +87,34 @@ const _ = (r, t, n, d) => {
|
|
|
87
87
|
return ["bodyActionButtons", "footerActionButtons", "nextBestActions"].forEach((a) => {
|
|
88
88
|
i[a] && (i[a] = i[a].map((e) => e.type === z.CALLBACK && e.value ? H(F({}, e), { value: new Function(`return ${e.value}`)() }) : e));
|
|
89
89
|
}), H(F({}, t), { settings: i, apiHost: d, widgetMode: t.widgetType, apiKey: n });
|
|
90
|
-
}, ue = (r) => (r == null ? void 0 : r.apiHost) || "https://app.brainfi.sh",
|
|
90
|
+
}, ue = (r) => (r == null ? void 0 : r.apiHost) || "https://app.brainfi.sh", R = (() => {
|
|
91
91
|
if (typeof window == "undefined") return;
|
|
92
92
|
const r = window.navigator.userAgent;
|
|
93
93
|
if (!(r.match(/iPad/i) || r.match(/iPhone/i))) return !1;
|
|
94
94
|
const t = r.match(/OS (\d+)_/i);
|
|
95
95
|
return t && parseInt(t[1], 10) <= 14;
|
|
96
|
-
})(), ze = (r) =>
|
|
96
|
+
})(), ze = (r) => b(void 0, null, function* () {
|
|
97
97
|
let { apiHost: t, widgetKey: n, version: d } = r;
|
|
98
98
|
try {
|
|
99
|
-
const i = `https://cdn.jsdelivr.net/npm/@brainfish-ai/search-widget@${d}/dist/web.js`, a =
|
|
100
|
-
return { widget: yield ((s) =>
|
|
99
|
+
const i = `https://cdn.jsdelivr.net/npm/@brainfish-ai/search-widget@${d}/dist/web.js`, a = R ? i.replace("web.js", "web.umd.js") : i;
|
|
100
|
+
return { widget: yield ((s) => b(void 0, null, function* () {
|
|
101
101
|
return document.getElementById("brainfish-widget") ? window.Brainfish : new Promise((l, o) => {
|
|
102
102
|
const u = document.createElement("script");
|
|
103
|
-
u.id = "brainfish-widget", u.src = s, u.type =
|
|
103
|
+
u.id = "brainfish-widget", u.src = s, u.type = R ? "text/javascript" : "module", u.async = !0, u.crossOrigin = "anonymous", u.onload = () => {
|
|
104
104
|
setTimeout(() => {
|
|
105
105
|
const c = window.Brainfish;
|
|
106
106
|
c ? l(c) : o(new Error("Failed to load Brainfish module"));
|
|
107
107
|
}, 200);
|
|
108
108
|
}, u.onerror = (c) => {
|
|
109
|
-
const f = c,
|
|
110
|
-
o(new Error(JSON.stringify(
|
|
111
|
-
},
|
|
109
|
+
const f = c, h = { message: `Failed to load script: ${s}`, type: f.type, fileName: f.filename, lineNumber: f.lineno, columnNumber: f.colno, error: f.error ? f.error.toString() : "Unknown error" };
|
|
110
|
+
o(new Error(JSON.stringify(h)));
|
|
111
|
+
}, R || document.head.appendChild(u);
|
|
112
112
|
});
|
|
113
113
|
}))(a) };
|
|
114
114
|
} catch (i) {
|
|
115
|
-
|
|
115
|
+
C(t, i, i.message, n);
|
|
116
116
|
}
|
|
117
|
-
}), be = /* @__PURE__ */ new Set(), Ne = (r, t) =>
|
|
117
|
+
}), be = /* @__PURE__ */ new Set(), Ne = (r, t) => b(void 0, null, function* () {
|
|
118
118
|
const n = ue(r.overrides);
|
|
119
119
|
try {
|
|
120
120
|
if (be.has(r.widgetKey)) return;
|
|
@@ -129,32 +129,32 @@ const _ = (r, t, n, d) => {
|
|
|
129
129
|
return o.forEach((c) => u.set(c.label, c)), Array.from(u.values());
|
|
130
130
|
}(t.settings[s], l));
|
|
131
131
|
}), function(e, s) {
|
|
132
|
-
s.widgetType ===
|
|
132
|
+
s.widgetType === _.Searchbar || s.widgetType === "Search" ? e.SearchWidget.initStandard(s) : e.HelpWidget.initPopup(s);
|
|
133
133
|
}(i, a), be.add(r.widgetKey), i;
|
|
134
134
|
}
|
|
135
135
|
} catch (d) {
|
|
136
|
-
|
|
136
|
+
C(n, d, d.message, r.widgetKey);
|
|
137
137
|
}
|
|
138
138
|
});
|
|
139
139
|
let ve = !1;
|
|
140
140
|
const qe = function(d, i, a) {
|
|
141
|
-
return
|
|
142
|
-
let e = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "", s = arguments.length > 4 && arguments[4] !== void 0 && arguments[4], l = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : [], o = arguments.length > 6 ? arguments[6] : void 0;
|
|
143
|
-
if (t ||
|
|
144
|
-
const
|
|
141
|
+
return b(this, arguments, function* (r, t, n) {
|
|
142
|
+
let e = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "", s = arguments.length > 4 && arguments[4] !== void 0 && arguments[4], l = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : [], o = arguments.length > 6 ? arguments[6] : void 0, u = arguments.length > 7 ? arguments[7] : void 0;
|
|
143
|
+
if (t || C(n, new Error("Access key is required"), "Access key is required", r), !ve) try {
|
|
144
|
+
const c = (() => {
|
|
145
145
|
if (typeof window == "undefined" || typeof navigator == "undefined") return !1;
|
|
146
|
-
const
|
|
146
|
+
const f = navigator, h = window, g = (f.doNotTrack || h.doNotTrack || f.msDoNotTrack || "0").toString().toLowerCase();
|
|
147
147
|
return ["1", "yes", "true"].includes(g);
|
|
148
148
|
})();
|
|
149
|
-
window.BrainfishAnalytics("init", { apiUrl: e, accessKey: t, trackScreenViews: !0, trackAttributes: !
|
|
149
|
+
window.BrainfishAnalytics("init", { apiUrl: e, accessKey: t, trackScreenViews: !0, trackAttributes: !c, trackOutgoingLinks: !c, enableRecording: !c && s, recordingBlocklist: l, _allowLocalhostRecording: o, _allowScreenRecording: u }), ve = !0, yield ((f, h) => b(this, null, function* () {
|
|
150
150
|
if (document.getElementById("brainfish-analytics")) return window.BrainfishAnalytics;
|
|
151
151
|
const g = document.createElement("script");
|
|
152
152
|
g.id = "brainfish-analytics", g.src = "https://cdn.jsdelivr.net/npm/@brainfish-ai/web-tracker@latest/dist/tracker.js", g.type = "module", g.async = !0, g.crossOrigin = "anonymous", g.onerror = () => {
|
|
153
|
-
|
|
153
|
+
C(f, new Error(`Failed to load script: ${g.src}`), `Failed to load script: ${g.src}`, h);
|
|
154
154
|
}, document.head.appendChild(g);
|
|
155
155
|
}))(n, r);
|
|
156
|
-
} catch (
|
|
157
|
-
|
|
156
|
+
} catch (c) {
|
|
157
|
+
C(n, c, "Failed to initialize BrainfishAnalytics", r);
|
|
158
158
|
}
|
|
159
159
|
});
|
|
160
160
|
};
|
|
@@ -167,7 +167,7 @@ function k(r, t) {
|
|
|
167
167
|
}), d;
|
|
168
168
|
}
|
|
169
169
|
const P = "bf-iframe-container", j = "bf-trigger-button";
|
|
170
|
-
class
|
|
170
|
+
class w {
|
|
171
171
|
static get isWidgetOpen() {
|
|
172
172
|
return this.isOpen;
|
|
173
173
|
}
|
|
@@ -208,7 +208,7 @@ class y {
|
|
|
208
208
|
(t = this.button) === null || t === void 0 || t.classList.add("hidden");
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
E(
|
|
211
|
+
E(w, "isOpen", !1), E(w, "button", null), E(w, "icon", null), E(w, "isButtonHidden", !1);
|
|
212
212
|
function De(r) {
|
|
213
213
|
let { widgetHost: t, apiHost: n, widgetKey: d, signal: i } = r;
|
|
214
214
|
window.addEventListener("message", (a) => {
|
|
@@ -222,14 +222,14 @@ function De(r) {
|
|
|
222
222
|
const { eventName: s, data: l } = a.data;
|
|
223
223
|
window.BrainfishAnalytics("track", s, l);
|
|
224
224
|
}
|
|
225
|
-
if (e === "CLOSE_WIDGET" && (window.BrainfishAnalytics("track", "Close Widget"),
|
|
225
|
+
if (e === "CLOSE_WIDGET" && (window.BrainfishAnalytics("track", "Close Widget"), w.toggleIframeVisibility()), e === "NEXT_BEST_ACTION_CLICKED") {
|
|
226
226
|
const { action: s, searchQueryId: l, query: o, answer: u } = a.data, c = { action: s, searchQueryId: l };
|
|
227
227
|
if (!["function", "callback"].includes(s.type)) return void console.error("Invalid action type", s);
|
|
228
228
|
if (window.__bfCallbacks = window.__bfCallbacks || {}, window.__bfCallbacks[s.id]) return void window.__bfCallbacks[s.id](o, u, c);
|
|
229
|
-
const f = `${n}/api/searchWidgets.callback.codeblocks?apiKey=${d}&codeblockId=${s.id}`,
|
|
230
|
-
|
|
229
|
+
const f = `${n}/api/searchWidgets.callback.codeblocks?apiKey=${d}&codeblockId=${s.id}`, h = document.createElement("script");
|
|
230
|
+
h.src = f, document.head.appendChild(h), h.onload = () => {
|
|
231
231
|
window.__bfCallbacks[s.id](o, u, c), setTimeout(() => {
|
|
232
|
-
document.head.removeChild(
|
|
232
|
+
document.head.removeChild(h);
|
|
233
233
|
}, 300);
|
|
234
234
|
};
|
|
235
235
|
}
|
|
@@ -248,10 +248,10 @@ var N = { exports: {} }, q = { exports: {} }, D = { exports: {} };
|
|
|
248
248
|
}
|
|
249
249
|
t.__esModule = !0, t.default = void 0, t.default = function(i, a, e, s) {
|
|
250
250
|
if (s === void 0 && (s = d), a === 0) return s(e, e, e);
|
|
251
|
-
var l = (i % 360 + 360) % 360 / 60, o = (1 - Math.abs(2 * e - 1)) * a, u = o * (1 - Math.abs(l % 2 - 1)), c = 0, f = 0,
|
|
252
|
-
l >= 0 && l < 1 ? (c = o, f = u) : l >= 1 && l < 2 ? (c = u, f = o) : l >= 2 && l < 3 ? (f = o,
|
|
253
|
-
var
|
|
254
|
-
return s(c +
|
|
251
|
+
var l = (i % 360 + 360) % 360 / 60, o = (1 - Math.abs(2 * e - 1)) * a, u = o * (1 - Math.abs(l % 2 - 1)), c = 0, f = 0, h = 0;
|
|
252
|
+
l >= 0 && l < 1 ? (c = o, f = u) : l >= 1 && l < 2 ? (c = u, f = o) : l >= 2 && l < 3 ? (f = o, h = u) : l >= 3 && l < 4 ? (f = u, h = o) : l >= 4 && l < 5 ? (c = u, h = o) : l >= 5 && l < 6 && (c = o, h = u);
|
|
253
|
+
var g = e - o / 2;
|
|
254
|
+
return s(c + g, f + g, h + g);
|
|
255
255
|
}, r.exports = t.default;
|
|
256
256
|
})(D, D.exports);
|
|
257
257
|
var ce = D.exports, U = { exports: {} };
|
|
@@ -272,7 +272,7 @@ var Ue = U.exports, J = { exports: {} };
|
|
|
272
272
|
if (u === null || !function(f) {
|
|
273
273
|
try {
|
|
274
274
|
return Function.toString.call(f).indexOf("[native code]") !== -1;
|
|
275
|
-
} catch (
|
|
275
|
+
} catch (h) {
|
|
276
276
|
return typeof f == "function";
|
|
277
277
|
}
|
|
278
278
|
}(u)) return u;
|
|
@@ -282,12 +282,12 @@ var Ue = U.exports, J = { exports: {} };
|
|
|
282
282
|
o.set(u, c);
|
|
283
283
|
}
|
|
284
284
|
function c() {
|
|
285
|
-
return function(f,
|
|
285
|
+
return function(f, h, g) {
|
|
286
286
|
if (d()) return Reflect.construct.apply(null, arguments);
|
|
287
287
|
var p = [null];
|
|
288
|
-
p.push.apply(p,
|
|
288
|
+
p.push.apply(p, h);
|
|
289
289
|
var m = new (f.bind.apply(f, p))();
|
|
290
|
-
return
|
|
290
|
+
return g && i(m, g.prototype), m;
|
|
291
291
|
}(u, arguments, a(this).constructor);
|
|
292
292
|
}
|
|
293
293
|
return c.prototype = Object.create(u.prototype, { constructor: { value: c, enumerable: !1, writable: !0, configurable: !0 } }), i(c, u);
|
|
@@ -465,34 +465,34 @@ To pass a single animation please supply them in simple values, e.g. animation('
|
|
|
465
465
|
` };
|
|
466
466
|
function s() {
|
|
467
467
|
for (var l = arguments.length, o = new Array(l), u = 0; u < l; u++) o[u] = arguments[u];
|
|
468
|
-
var c, f = o[0],
|
|
469
|
-
for (c = 1; c < o.length; c += 1)
|
|
470
|
-
return
|
|
471
|
-
f = f.replace(/%[a-z]/,
|
|
468
|
+
var c, f = o[0], h = [];
|
|
469
|
+
for (c = 1; c < o.length; c += 1) h.push(o[c]);
|
|
470
|
+
return h.forEach(function(g) {
|
|
471
|
+
f = f.replace(/%[a-z]/, g);
|
|
472
472
|
}), f;
|
|
473
473
|
}
|
|
474
474
|
t.default = function(l) {
|
|
475
475
|
var o, u;
|
|
476
476
|
function c(f) {
|
|
477
|
-
var
|
|
478
|
-
if (process.env.NODE_ENV === "production")
|
|
477
|
+
var h;
|
|
478
|
+
if (process.env.NODE_ENV === "production") h = l.call(this, "An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#" + f + " for more information.") || this;
|
|
479
479
|
else {
|
|
480
|
-
for (var
|
|
481
|
-
|
|
480
|
+
for (var g = arguments.length, p = new Array(g > 1 ? g - 1 : 0), m = 1; m < g; m++) p[m - 1] = arguments[m];
|
|
481
|
+
h = l.call(this, s.apply(void 0, [e[f]].concat(p))) || this;
|
|
482
482
|
}
|
|
483
|
-
return function(
|
|
484
|
-
if (
|
|
485
|
-
return
|
|
486
|
-
}(
|
|
483
|
+
return function(v) {
|
|
484
|
+
if (v === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
485
|
+
return v;
|
|
486
|
+
}(h);
|
|
487
487
|
}
|
|
488
488
|
return u = l, (o = c).prototype = Object.create(u.prototype), o.prototype.constructor = o, i(o, u), c;
|
|
489
489
|
}(n(Error)), r.exports = t.default;
|
|
490
490
|
})(J, J.exports);
|
|
491
491
|
var B = J.exports;
|
|
492
492
|
(function(r, t) {
|
|
493
|
-
t.__esModule = !0, t.default = function(
|
|
494
|
-
if (typeof
|
|
495
|
-
var p = (0, d.default)(
|
|
493
|
+
t.__esModule = !0, t.default = function(g) {
|
|
494
|
+
if (typeof g != "string") throw new i.default(3);
|
|
495
|
+
var p = (0, d.default)(g);
|
|
496
496
|
if (p.match(e)) return { red: parseInt("" + p[1] + p[2], 16), green: parseInt("" + p[3] + p[4], 16), blue: parseInt("" + p[5] + p[6], 16) };
|
|
497
497
|
if (p.match(s)) {
|
|
498
498
|
var m = parseFloat((parseInt("" + p[7] + p[8], 16) / 255).toFixed(2));
|
|
@@ -500,32 +500,32 @@ var B = J.exports;
|
|
|
500
500
|
}
|
|
501
501
|
if (p.match(l)) return { red: parseInt("" + p[1] + p[1], 16), green: parseInt("" + p[2] + p[2], 16), blue: parseInt("" + p[3] + p[3], 16) };
|
|
502
502
|
if (p.match(o)) {
|
|
503
|
-
var
|
|
504
|
-
return { red: parseInt("" + p[1] + p[1], 16), green: parseInt("" + p[2] + p[2], 16), blue: parseInt("" + p[3] + p[3], 16), alpha:
|
|
503
|
+
var v = parseFloat((parseInt("" + p[4] + p[4], 16) / 255).toFixed(2));
|
|
504
|
+
return { red: parseInt("" + p[1] + p[1], 16), green: parseInt("" + p[2] + p[2], 16), blue: parseInt("" + p[3] + p[3], 16), alpha: v };
|
|
505
505
|
}
|
|
506
|
-
var
|
|
507
|
-
if (
|
|
508
|
-
var
|
|
509
|
-
if (
|
|
506
|
+
var y = u.exec(p);
|
|
507
|
+
if (y) return { red: parseInt("" + y[1], 10), green: parseInt("" + y[2], 10), blue: parseInt("" + y[3], 10) };
|
|
508
|
+
var x = c.exec(p.substring(0, 50));
|
|
509
|
+
if (x) return { red: parseInt("" + x[1], 10), green: parseInt("" + x[2], 10), blue: parseInt("" + x[3], 10), alpha: parseFloat("" + x[4]) > 1 ? parseFloat("" + x[4]) / 100 : parseFloat("" + x[4]) };
|
|
510
510
|
var I = f.exec(p);
|
|
511
511
|
if (I) {
|
|
512
512
|
var Ie = parseInt("" + I[1], 10), Oe = parseInt("" + I[2], 10) / 100, Te = parseInt("" + I[3], 10) / 100, ge = "rgb(" + (0, n.default)(Ie, Oe, Te) + ")", O = u.exec(ge);
|
|
513
513
|
if (!O) throw new i.default(4, p, ge);
|
|
514
514
|
return { red: parseInt("" + O[1], 10), green: parseInt("" + O[2], 10), blue: parseInt("" + O[3], 10) };
|
|
515
515
|
}
|
|
516
|
-
var
|
|
517
|
-
if (
|
|
518
|
-
var Me = parseInt("" +
|
|
516
|
+
var S = h.exec(p.substring(0, 50));
|
|
517
|
+
if (S) {
|
|
518
|
+
var Me = parseInt("" + S[1], 10), We = parseInt("" + S[2], 10) / 100, Pe = parseInt("" + S[3], 10) / 100, he = "rgb(" + (0, n.default)(Me, We, Pe) + ")", T = u.exec(he);
|
|
519
519
|
if (!T) throw new i.default(4, p, he);
|
|
520
|
-
return { red: parseInt("" + T[1], 10), green: parseInt("" + T[2], 10), blue: parseInt("" + T[3], 10), alpha: parseFloat("" +
|
|
520
|
+
return { red: parseInt("" + T[1], 10), green: parseInt("" + T[2], 10), blue: parseInt("" + T[3], 10), alpha: parseFloat("" + S[4]) > 1 ? parseFloat("" + S[4]) / 100 : parseFloat("" + S[4]) };
|
|
521
521
|
}
|
|
522
522
|
throw new i.default(5);
|
|
523
523
|
};
|
|
524
524
|
var n = a(ce), d = a(Ue), i = a(B);
|
|
525
|
-
function a(
|
|
526
|
-
return
|
|
525
|
+
function a(g) {
|
|
526
|
+
return g && g.__esModule ? g : { default: g };
|
|
527
527
|
}
|
|
528
|
-
var e = /^#[a-fA-F0-9]{6}$/, s = /^#[a-fA-F0-9]{8}$/, l = /^#[a-fA-F0-9]{3}$/, o = /^#[a-fA-F0-9]{4}$/, u = /^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i, c = /^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i, f = /^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,
|
|
528
|
+
var e = /^#[a-fA-F0-9]{6}$/, s = /^#[a-fA-F0-9]{8}$/, l = /^#[a-fA-F0-9]{3}$/, o = /^#[a-fA-F0-9]{4}$/, u = /^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i, c = /^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i, f = /^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i, h = /^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
|
|
529
529
|
r.exports = t.default;
|
|
530
530
|
})(q, q.exports);
|
|
531
531
|
var pe = q.exports;
|
|
@@ -558,7 +558,7 @@ var ye, M, xe = G.exports, V = { exports: {} };
|
|
|
558
558
|
ye = V, (M = V.exports).__esModule = !0, M.default = void 0, M.default = function(r, t, n) {
|
|
559
559
|
return Math.max(r, Math.min(t, n));
|
|
560
560
|
}, ye.exports = M.default;
|
|
561
|
-
var
|
|
561
|
+
var Se = V.exports, Z = { exports: {} }, Q = { exports: {} };
|
|
562
562
|
(function(r, t) {
|
|
563
563
|
t.__esModule = !0, t.default = void 0, t.default = function(n) {
|
|
564
564
|
var d, i = n.red / 255, a = n.green / 255, e = n.blue / 255, s = Math.max(i, a, e), l = Math.min(i, a, e), o = (s + l) / 2;
|
|
@@ -588,7 +588,7 @@ var Ye = Q.exports;
|
|
|
588
588
|
}
|
|
589
589
|
r.exports = t.default;
|
|
590
590
|
})(Z, Z.exports);
|
|
591
|
-
var
|
|
591
|
+
var ke = Z.exports, X = { exports: {} }, ee = { exports: {} }, te = { exports: {} }, ne = { exports: {} };
|
|
592
592
|
(function(r, t) {
|
|
593
593
|
t.__esModule = !0, t.default = void 0, t.default = function(n) {
|
|
594
594
|
return n.length === 7 && n[1] === n[2] && n[3] === n[4] && n[5] === n[6] ? "#" + n[1] + n[3] + n[5] : n;
|
|
@@ -702,7 +702,7 @@ var Ze = oe.exports;
|
|
|
702
702
|
var Ae = X.exports;
|
|
703
703
|
(function(r, t) {
|
|
704
704
|
t.__esModule = !0, t.default = void 0;
|
|
705
|
-
var n = e(xe), d = e(
|
|
705
|
+
var n = e(xe), d = e(Se), i = e(ke), a = e(Ae);
|
|
706
706
|
function e(o) {
|
|
707
707
|
return o && o.__esModule ? o : { default: o };
|
|
708
708
|
}
|
|
@@ -726,7 +726,7 @@ const Qe = fe(Y.exports);
|
|
|
726
726
|
var se = { exports: {} };
|
|
727
727
|
(function(r, t) {
|
|
728
728
|
t.__esModule = !0, t.default = void 0;
|
|
729
|
-
var n = e(xe), d = e(
|
|
729
|
+
var n = e(xe), d = e(Se), i = e(ke), a = e(Ae);
|
|
730
730
|
function e(o) {
|
|
731
731
|
return o && o.__esModule ? o : { default: o };
|
|
732
732
|
}
|
|
@@ -784,7 +784,7 @@ function nt(r, t) {
|
|
|
784
784
|
((a) => {
|
|
785
785
|
var e;
|
|
786
786
|
const s = { type: "UPDATE_BODY_CLASS", isMobile: a };
|
|
787
|
-
(e = r.contentWindow) === null || e === void 0 || e.postMessage(s, "*"), a && (
|
|
787
|
+
(e = r.contentWindow) === null || e === void 0 || e.postMessage(s, "*"), a && (w.isWidgetOpen ? w.hideTriggerButton() : w.showTriggerButton());
|
|
788
788
|
})(document.body.clientWidth <= 576);
|
|
789
789
|
}, i = () => {
|
|
790
790
|
n && clearTimeout(n), n = window.setTimeout(d, 300);
|
|
@@ -794,7 +794,7 @@ function nt(r, t) {
|
|
|
794
794
|
a.observe(document.body), t.addEventListener("abort", () => a.disconnect());
|
|
795
795
|
})();
|
|
796
796
|
}
|
|
797
|
-
function
|
|
797
|
+
function $(r) {
|
|
798
798
|
const t = new TextEncoder().encode(r);
|
|
799
799
|
if (typeof window != "undefined" && typeof window.btoa == "function") {
|
|
800
800
|
const n = Array.from(t, (d) => String.fromCharCode(d)).join("");
|
|
@@ -807,11 +807,11 @@ const we = /* @__PURE__ */ new Set();
|
|
|
807
807
|
function rt(r, t, n) {
|
|
808
808
|
let { isButtonHidden: d, triggerButtonIcon: i } = n;
|
|
809
809
|
const a = document.createDocumentFragment();
|
|
810
|
-
if (d)
|
|
810
|
+
if (d) w.initialize({ isButtonHidden: d });
|
|
811
811
|
else {
|
|
812
812
|
const { button: l, icon: o } = function(u, c) {
|
|
813
|
-
const f = k("button", j, { id: `trigger-button-${u}`, "aria-controls": P, "aria-expanded": "false", "data-name": j }),
|
|
814
|
-
return
|
|
813
|
+
const f = k("button", j, { id: `trigger-button-${u}`, "aria-controls": P, "aria-expanded": "false", "data-name": j }), h = k("div", "trigger-button-icon", { "aria-hidden": "true" });
|
|
814
|
+
return h.innerHTML = c ? `
|
|
815
815
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256" class="close-icon">
|
|
816
816
|
<path d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"></path>
|
|
817
817
|
</svg>
|
|
@@ -823,9 +823,9 @@ function rt(r, t, n) {
|
|
|
823
823
|
<svg width="24" height="14" viewBox="0 0 24 14" fill="none" xmlns="http://www.w3.org/2000/svg" class="fish-icon visible">
|
|
824
824
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M1.71844 10.3882L4.60606 6.98384L1.71844 3.58375C1.4014 3.21362 1.44424 2.65841 1.81269 2.33993C1.97978 2.1979 2.65242 1.98701 3.04657 2.43461L5.78425 5.65824C6.14281 5.29523 6.51693 4.95924 6.90479 4.65114C8.88976 3.07437 11.2345 2.22803 13.6931 2.22803C16.9492 2.22803 20.0039 3.71718 22.2917 6.41142C22.5702 6.74282 22.5702 7.22916 22.2917 7.56056C20.0039 10.2591 16.9492 11.744 13.6931 11.744C11.2348 11.744 8.89035 10.8948 6.90554 9.31995C6.51741 9.01199 6.14304 8.67628 5.78425 8.31374L3.04657 11.5374C2.72953 11.9075 2.18114 11.9505 1.81269 11.632C1.44852 11.3179 1.40568 10.7584 1.71844 10.3882ZM5.93026 10.4683C8.17161 12.2599 10.8546 13.25 13.6931 13.25C17.4881 13.25 21.019 11.4034 23.4447 8.52942C24.1873 7.64571 24.1843 6.31801 23.4397 5.43663C20.8944 2.43919 17.4337 0.722025 13.6931 0.722025C10.8555 0.722025 8.17194 1.70845 5.92952 3.50276L4.17682 1.43933C3.57943 0.760929 2.79325 0.630009 2.25286 0.662947C1.98116 0.679506 1.73125 0.736852 1.51895 0.811846C1.26839 0.900352 1.03017 1.02718 0.827835 1.20058C-0.165283 2.05903 -0.283916 3.561 0.574656 4.56345L2.63075 6.98445L0.568104 9.41623C-0.272133 10.4106 -0.166523 11.9125 0.827835 12.7714C1.81372 13.6243 3.34308 13.5062 4.19036 12.5171L5.93026 10.4683Z" fill="currentColor"/>
|
|
825
825
|
</svg>
|
|
826
|
-
`, f.setAttribute("aria-label", "Open Brainfish widget"), f.appendChild(
|
|
826
|
+
`, f.setAttribute("aria-label", "Open Brainfish widget"), f.appendChild(h), { button: f, icon: h };
|
|
827
827
|
}(r, i);
|
|
828
|
-
a.appendChild(l),
|
|
828
|
+
a.appendChild(l), w.initialize({ button: l, icon: o });
|
|
829
829
|
}
|
|
830
830
|
const { iframeContainer: e, iframe: s } = function(l) {
|
|
831
831
|
const o = k("div", P, { id: P, "aria-live": "polite", "aria-hidden": "true" }), u = k("div", "iframe-loading-indicator"), c = k("div", "spinner");
|
|
@@ -833,10 +833,10 @@ function rt(r, t, n) {
|
|
|
833
833
|
const f = k("iframe", "trigger-iframe", { src: l, sandbox: "allow-scripts allow-same-origin allow-popups allow-forms", allow: "clipboard-write", role: "dialog" });
|
|
834
834
|
return f.style.opacity = "0", f.addEventListener("load", () => {
|
|
835
835
|
u.style.display = "none", f.style.opacity = "1";
|
|
836
|
-
}), f.addEventListener("error", (
|
|
837
|
-
console.error("Error loading iframe:",
|
|
838
|
-
const
|
|
839
|
-
u.appendChild(
|
|
836
|
+
}), f.addEventListener("error", (h) => {
|
|
837
|
+
console.error("Error loading iframe:", h), u.innerHTML = "";
|
|
838
|
+
const g = k("div", "loading-error");
|
|
839
|
+
u.appendChild(g), u.setAttribute("aria-label", "Failed to load content");
|
|
840
840
|
}), o.appendChild(f), { iframeContainer: o, iframe: f };
|
|
841
841
|
}(t);
|
|
842
842
|
return a.appendChild(e), { fragment: a, iframe: s };
|
|
@@ -845,34 +845,34 @@ const at = (r, t) => {
|
|
|
845
845
|
var n;
|
|
846
846
|
const d = ue(r.overrides), i = ((a = r.overrides) == null ? void 0 : a.widgetHost) || "https://agent.brainfi.sh";
|
|
847
847
|
var a;
|
|
848
|
-
const { theme: e, settings: s } = t, l =
|
|
848
|
+
const { theme: e, settings: s } = t, l = $(JSON.stringify((n = r.overrides) === null || n === void 0 ? void 0 : n.redirectRules)), o = `${i}/?widgetKey=${r.widgetKey}#${new URLSearchParams({ theme: $(JSON.stringify(e)), settings: $(JSON.stringify(s)), redirectRules: l }).toString()}`, u = s == null ? void 0 : s.hideTriggerButton, c = s == null ? void 0 : s.triggerButtonIcon;
|
|
849
849
|
try {
|
|
850
|
-
if (f = r.widgetKey, we.has(f) || function(
|
|
851
|
-
return !!document.getElementById(`trigger-button-${
|
|
850
|
+
if (f = r.widgetKey, we.has(f) || function(y) {
|
|
851
|
+
return !!document.getElementById(`trigger-button-${y}`);
|
|
852
852
|
}(r.widgetKey)) return;
|
|
853
853
|
et(t);
|
|
854
|
-
const { fragment:
|
|
855
|
-
|
|
854
|
+
const { fragment: h, iframe: g } = rt(r.widgetKey, o, { isButtonHidden: u || !1, triggerButtonIcon: c || "" }), p = new AbortController(), { signal: m } = p;
|
|
855
|
+
g.onload = () => {
|
|
856
856
|
setTimeout(() => {
|
|
857
|
-
tt(
|
|
857
|
+
tt(g, m), De({ widgetHost: i, apiHost: d, widgetKey: r.widgetKey, signal: m }), nt(g, m);
|
|
858
858
|
}, 0);
|
|
859
|
-
}, document.body.appendChild(
|
|
860
|
-
const
|
|
861
|
-
p.abort(), window.removeEventListener("beforeunload",
|
|
859
|
+
}, document.body.appendChild(h), we.add(r.widgetKey);
|
|
860
|
+
const v = () => {
|
|
861
|
+
p.abort(), window.removeEventListener("beforeunload", v);
|
|
862
862
|
};
|
|
863
|
-
return void window.addEventListener("beforeunload",
|
|
864
|
-
} catch (
|
|
865
|
-
(function(
|
|
866
|
-
|
|
867
|
-
})(d,
|
|
863
|
+
return void window.addEventListener("beforeunload", v);
|
|
864
|
+
} catch (h) {
|
|
865
|
+
(function(g, p, m) {
|
|
866
|
+
C(g, p, p.message, m);
|
|
867
|
+
})(d, h, r.widgetKey);
|
|
868
868
|
}
|
|
869
869
|
var f;
|
|
870
870
|
};
|
|
871
871
|
var de = ((r) => (r.FRESHCHAT = "freshchat", r.INTERCOM = "intercom", r.ZENDESK = "zendesk", r.HELPSCOUT = "helpscout", r))(de || {});
|
|
872
|
-
const it = (r) =>
|
|
873
|
-
if (r.widgetType ===
|
|
872
|
+
const it = (r) => b(void 0, null, function* () {
|
|
873
|
+
if (r.widgetType === _.Popup) {
|
|
874
874
|
const t = window.fcWidget ? de.FRESHCHAT : null;
|
|
875
|
-
t && t === de.FRESHCHAT && (yield
|
|
875
|
+
t && t === de.FRESHCHAT && (yield b(void 0, null, function* () {
|
|
876
876
|
window.fcWidget || (yield new Promise((n) => setTimeout(n, 100))), window.fcWidget.hide(), window.fcWidget.on("widget:closed", () => {
|
|
877
877
|
window.fcWidget.hide();
|
|
878
878
|
});
|
|
@@ -922,7 +922,7 @@ const A = typeof window != "undefined" && window.Brainfish ? window.Brainfish :
|
|
|
922
922
|
let K = null;
|
|
923
923
|
A.Widgets.isReady = !1, A.Widgets.identify = (r) => {
|
|
924
924
|
window.BrainfishAnalytics("identify", r);
|
|
925
|
-
}, A.Widgets.init = (r) =>
|
|
925
|
+
}, A.Widgets.init = (r) => b(void 0, null, function* () {
|
|
926
926
|
window && (window.BrainfishAnalytics = window.BrainfishAnalytics || function() {
|
|
927
927
|
for (var a = arguments.length, e = new Array(a), s = 0; s < a; s++) e[s] = arguments[s];
|
|
928
928
|
(window.BrainfishAnalytics.q = window.BrainfishAnalytics.q || []).push(e);
|
|
@@ -940,16 +940,16 @@ A.Widgets.isReady = !1, A.Widgets.identify = (r) => {
|
|
|
940
940
|
throw new Error("[utils.base64Decode]: Unsupported environment");
|
|
941
941
|
})(r.config));
|
|
942
942
|
else {
|
|
943
|
-
const { config: a } = yield
|
|
943
|
+
const { config: a } = yield $e({ widgetKey: r.widgetKey, apiHost: t });
|
|
944
944
|
i = a;
|
|
945
945
|
}
|
|
946
946
|
K || (K = function(a, e, s, l) {
|
|
947
|
-
return
|
|
948
|
-
var o, u, c, f, g;
|
|
949
|
-
const
|
|
950
|
-
|
|
951
|
-
const [
|
|
952
|
-
|
|
947
|
+
return b(this, null, function* () {
|
|
948
|
+
var o, u, c, f, h, g;
|
|
949
|
+
const p = ((o = a.overrides) === null || o === void 0 ? void 0 : o.enableRecording) || (e == null || (u = e.settings) === null || u === void 0 ? void 0 : u.enableRecording) || !1, m = ((c = a.overrides) === null || c === void 0 ? void 0 : c.version) || (e == null ? void 0 : e.version), v = [];
|
|
950
|
+
m != null && m.startsWith("2.") ? at(a, e) : v.push(Ne(a, e)), v.push(qe(a.widgetKey, e.trackingToken || "", s, l, p, (e == null || (f = e.settings) === null || f === void 0 ? void 0 : f.recordingBlocklist) || [], e == null || (h = e.settings) === null || h === void 0 ? void 0 : h._allowLocalhostRecording, e == null || (g = e.settings) === null || g === void 0 ? void 0 : g._allowScreenRecording));
|
|
951
|
+
const [y] = yield Promise.allSettled(v);
|
|
952
|
+
y && y.status === "fulfilled" && y.value && A._setRealBrainfish(y.value);
|
|
953
953
|
});
|
|
954
954
|
}(r, i, t, n)), yield K, yield it(i), A.Widgets.isReady = !0, window.dispatchEvent(new Event("onBrainfishReady"));
|
|
955
955
|
});
|
package/package.json
CHANGED
package/dist/index.cjs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|