@brainfish-ai/widgets-initiator 1.13.0 → 1.13.3
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/index.cjs.js +1 -1
- package/dist/index.js +9 -8
- package/dist/types/web.d.ts +1 -1
- package/dist/web.cjs.js +1 -169
- package/dist/web.js +1974 -937
- package/package.json +2 -6
- package/dist/types/utils/isIOS14OrBelow.d.ts +0 -1
- package/dist/types/utils/isIOS14OrBelow.test.d.ts +0 -1
package/dist/web.js
CHANGED
|
@@ -1,1035 +1,2072 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
s(n.next(l));
|
|
18
|
-
} catch (d) {
|
|
19
|
-
i(d);
|
|
20
|
-
}
|
|
21
|
-
}, e = (l) => {
|
|
22
|
-
try {
|
|
23
|
-
s(n.throw(l));
|
|
24
|
-
} catch (d) {
|
|
25
|
-
i(d);
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
26
16
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
(
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
+
var __async = (__this, __arguments, generator) => {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
var fulfilled = (value) => {
|
|
24
|
+
try {
|
|
25
|
+
step(generator.next(value));
|
|
26
|
+
} catch (e) {
|
|
27
|
+
reject(e);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
var rejected = (value) => {
|
|
31
|
+
try {
|
|
32
|
+
step(generator.throw(value));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
38
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
;
|
|
42
|
+
!function() {
|
|
31
43
|
try {
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
} catch (
|
|
44
|
+
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
45
|
+
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "4c902d45-6288-4dce-9403-d4bbb45dd48a", e._sentryDebugIdIdentifier = "sentry-dbid-4c902d45-6288-4dce-9403-d4bbb45dd48a");
|
|
46
|
+
} catch (e2) {
|
|
35
47
|
}
|
|
36
|
-
}
|
|
37
|
-
class
|
|
48
|
+
}();
|
|
49
|
+
class InvalidTokenError extends Error {
|
|
50
|
+
}
|
|
51
|
+
InvalidTokenError.prototype.name = "InvalidTokenError";
|
|
52
|
+
function b64DecodeUnicode(str) {
|
|
53
|
+
return decodeURIComponent(atob(str).replace(/(.)/g, (m, p) => {
|
|
54
|
+
let code = p.charCodeAt(0).toString(16).toUpperCase();
|
|
55
|
+
if (code.length < 2) {
|
|
56
|
+
code = "0" + code;
|
|
57
|
+
}
|
|
58
|
+
return "%" + code;
|
|
59
|
+
}));
|
|
38
60
|
}
|
|
39
|
-
function
|
|
40
|
-
let
|
|
41
|
-
switch (
|
|
61
|
+
function base64UrlDecode(str) {
|
|
62
|
+
let output = str.replace(/-/g, "+").replace(/_/g, "/");
|
|
63
|
+
switch (output.length % 4) {
|
|
42
64
|
case 0:
|
|
43
65
|
break;
|
|
44
66
|
case 2:
|
|
45
|
-
|
|
67
|
+
output += "==";
|
|
46
68
|
break;
|
|
47
69
|
case 3:
|
|
48
|
-
|
|
70
|
+
output += "=";
|
|
49
71
|
break;
|
|
50
72
|
default:
|
|
51
73
|
throw new Error("base64 string is not of the correct length");
|
|
52
74
|
}
|
|
53
75
|
try {
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return r.length < 2 && (r = "0" + r), "%" + r;
|
|
58
|
-
}));
|
|
59
|
-
}(t);
|
|
60
|
-
} catch (n) {
|
|
61
|
-
return atob(t);
|
|
76
|
+
return b64DecodeUnicode(output);
|
|
77
|
+
} catch (err) {
|
|
78
|
+
return atob(output);
|
|
62
79
|
}
|
|
63
80
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
81
|
+
function jwtDecode(token, options) {
|
|
82
|
+
if (typeof token !== "string") {
|
|
83
|
+
throw new InvalidTokenError("Invalid token specified: must be a string");
|
|
84
|
+
}
|
|
85
|
+
options || (options = {});
|
|
86
|
+
const pos = options.header === true ? 0 : 1;
|
|
87
|
+
const part = token.split(".")[pos];
|
|
88
|
+
if (typeof part !== "string") {
|
|
89
|
+
throw new InvalidTokenError(`Invalid token specified: missing part #${pos + 1}`);
|
|
90
|
+
}
|
|
91
|
+
let decoded;
|
|
92
|
+
try {
|
|
93
|
+
decoded = base64UrlDecode(part);
|
|
94
|
+
} catch (e) {
|
|
95
|
+
throw new InvalidTokenError(`Invalid token specified: invalid base64 for part #${pos + 1} (${e.message})`);
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
return JSON.parse(decoded);
|
|
99
|
+
} catch (e) {
|
|
100
|
+
throw new InvalidTokenError(`Invalid token specified: invalid json for part #${pos + 1} (${e.message})`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
var _global = typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : {};
|
|
104
|
+
_global.SENTRY_RELEASE = { id: "06dbf75fbc795d0ab939f089be07de1c0e11ea76" };
|
|
105
|
+
var WidgetType;
|
|
106
|
+
(function(WidgetType2) {
|
|
107
|
+
WidgetType2["Sidebar"] = "sidebar";
|
|
108
|
+
WidgetType2["Searchbar"] = "searchbar";
|
|
109
|
+
WidgetType2["Popup"] = "popup";
|
|
110
|
+
})(WidgetType || (WidgetType = {}));
|
|
111
|
+
({
|
|
112
|
+
[WidgetType.Sidebar]: "brainfish-sidebar-widget",
|
|
113
|
+
[WidgetType.Searchbar]: "brainfish-searchbar-widget",
|
|
114
|
+
[WidgetType.Popup]: "brainfish-popup-widget"
|
|
115
|
+
});
|
|
116
|
+
class BrainfishWidgetError extends Error {
|
|
117
|
+
constructor(message, options) {
|
|
118
|
+
super(message, options);
|
|
119
|
+
__publicField(this, "cause");
|
|
120
|
+
this.name = "BrainfishWidgetError";
|
|
121
|
+
this.cause = options == null ? void 0 : options.cause;
|
|
122
|
+
if (Error.captureStackTrace) {
|
|
123
|
+
Error.captureStackTrace(this, BrainfishWidgetError);
|
|
124
|
+
}
|
|
125
|
+
if (this.cause instanceof Error && this.cause.stack) {
|
|
126
|
+
this.stack = this.stack + "\nCaused by: " + this.cause.stack;
|
|
127
|
+
}
|
|
74
128
|
}
|
|
75
129
|
toJSON() {
|
|
76
|
-
return {
|
|
130
|
+
return {
|
|
131
|
+
name: this.name,
|
|
132
|
+
message: this.message,
|
|
133
|
+
stack: this.stack,
|
|
134
|
+
cause: this.cause instanceof Error ? {
|
|
135
|
+
name: this.cause.name,
|
|
136
|
+
message: this.cause.message,
|
|
137
|
+
stack: this.cause.stack
|
|
138
|
+
} : this.cause
|
|
139
|
+
};
|
|
77
140
|
}
|
|
78
141
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
142
|
+
var ActionType;
|
|
143
|
+
(function(ActionType2) {
|
|
144
|
+
ActionType2["LINK"] = "link";
|
|
145
|
+
ActionType2["CALLBACK"] = "callback";
|
|
146
|
+
ActionType2["EMAIL"] = "email";
|
|
147
|
+
ActionType2["PHONE"] = "phone";
|
|
148
|
+
})(ActionType || (ActionType = {}));
|
|
149
|
+
const sendErrors = (apiHost, error, widgetKey) => {
|
|
150
|
+
if (!navigator || navigator.userAgent.toLowerCase().includes("headless")) {
|
|
151
|
+
return;
|
|
88
152
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (!d) throw new Error("Error loading config: empty response");
|
|
105
|
-
return d;
|
|
106
|
-
} catch (l) {
|
|
107
|
-
if (e = l, s++, s >= 3) throw x(o, l, "Error fetching config", r), e;
|
|
108
|
-
yield new Promise((d) => setTimeout(d, 500));
|
|
153
|
+
const errorData = error.toJSON();
|
|
154
|
+
const API_HOST = apiHost || "https://app.brainfi.sh";
|
|
155
|
+
fetch(`${API_HOST}/api/trackError.widget.create`, {
|
|
156
|
+
method: "POST",
|
|
157
|
+
headers: {
|
|
158
|
+
"Content-Type": "application/json",
|
|
159
|
+
"api-key": widgetKey
|
|
160
|
+
},
|
|
161
|
+
body: JSON.stringify({
|
|
162
|
+
error: `WebWidgetVersion: ${"1.13.3"}. ${error.message}`,
|
|
163
|
+
stack: error.stack,
|
|
164
|
+
cause: {
|
|
165
|
+
message: errorData.message,
|
|
166
|
+
stack: errorData.stack,
|
|
167
|
+
cause: errorData.cause
|
|
109
168
|
}
|
|
110
|
-
})
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
169
|
+
})
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
const sendBrainfishWidgetError = (apiHost, error, message, widgetKey) => {
|
|
173
|
+
let errorMessage = message;
|
|
174
|
+
let errorDetails = {};
|
|
175
|
+
if (error instanceof Error) {
|
|
176
|
+
try {
|
|
177
|
+
errorDetails = JSON.parse(error.message);
|
|
178
|
+
errorMessage += ` - ${errorDetails.message || error.message}`;
|
|
179
|
+
} catch (e) {
|
|
180
|
+
errorMessage += ` - ${error.message}`;
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
errorMessage += ` - ${String(error)}`;
|
|
184
|
+
}
|
|
185
|
+
const err = new BrainfishWidgetError(errorMessage, {
|
|
186
|
+
cause: errorDetails
|
|
187
|
+
});
|
|
188
|
+
sendErrors(apiHost, err, widgetKey);
|
|
189
|
+
};
|
|
190
|
+
function fetchWithErrorHandling(apiHost, endpoint, widgetKey) {
|
|
191
|
+
return __async(this, null, function* () {
|
|
192
|
+
const maxRetries = 3;
|
|
193
|
+
const delay = 500;
|
|
194
|
+
let attempt = 0;
|
|
195
|
+
let lastError;
|
|
196
|
+
while (attempt < maxRetries) {
|
|
197
|
+
try {
|
|
198
|
+
const response = yield fetch(`${apiHost}${endpoint}`, {
|
|
199
|
+
method: "POST",
|
|
200
|
+
headers: {
|
|
201
|
+
"Content-Type": "application/json",
|
|
202
|
+
"api-key": widgetKey
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
if (!response.ok) {
|
|
206
|
+
throw new Error(`API call failed with status: ${response.status}`);
|
|
207
|
+
}
|
|
208
|
+
const data = yield response.json();
|
|
209
|
+
if (!data) {
|
|
210
|
+
throw new Error("Error loading config: empty response");
|
|
211
|
+
}
|
|
212
|
+
return data;
|
|
213
|
+
} catch (error) {
|
|
214
|
+
lastError = error;
|
|
215
|
+
attempt++;
|
|
216
|
+
if (attempt >= maxRetries) {
|
|
217
|
+
sendBrainfishWidgetError(
|
|
218
|
+
apiHost,
|
|
219
|
+
error,
|
|
220
|
+
"Error fetching config",
|
|
221
|
+
widgetKey
|
|
222
|
+
);
|
|
223
|
+
throw lastError;
|
|
224
|
+
}
|
|
225
|
+
yield new Promise((resolve) => setTimeout(resolve, delay));
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
const getConfigByKey = (_0) => __async(null, [_0], function* ({
|
|
231
|
+
widgetKey,
|
|
232
|
+
apiHost
|
|
233
|
+
}) {
|
|
234
|
+
const endpoint = `/api/searchWidgets.getConfigByKey`;
|
|
235
|
+
return fetchWithErrorHandling(apiHost, endpoint, widgetKey);
|
|
236
|
+
});
|
|
237
|
+
const mapActionButtons = (actionButtons) => actionButtons.map(
|
|
238
|
+
(action) => action.type === ActionType.CALLBACK && action.value ? __spreadProps(__spreadValues({}, action), { value: new Function(`return ${action.value}`)() }) : action
|
|
239
|
+
);
|
|
240
|
+
const updateActions = (configActions = [], overrideActions) => {
|
|
241
|
+
const actionMap = new Map(
|
|
242
|
+
configActions.map((action) => [action.label, action])
|
|
243
|
+
);
|
|
244
|
+
overrideActions.forEach((action) => actionMap.set(action.label, action));
|
|
245
|
+
return Array.from(actionMap.values());
|
|
246
|
+
};
|
|
247
|
+
const transformConfig = ({
|
|
248
|
+
config,
|
|
249
|
+
apiKey,
|
|
250
|
+
apiHost
|
|
251
|
+
}) => {
|
|
252
|
+
const settings = config.settings || {};
|
|
253
|
+
["bodyActionButtons", "footerActionButtons", "nextBestActions"].forEach((key) => {
|
|
254
|
+
if (settings[key]) {
|
|
255
|
+
settings[key] = mapActionButtons(
|
|
256
|
+
settings[key]
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
return __spreadProps(__spreadValues({}, config), {
|
|
261
|
+
settings,
|
|
262
|
+
apiHost,
|
|
263
|
+
widgetMode: config.widgetType,
|
|
264
|
+
apiKey
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
const getApiHost = (overrides) => {
|
|
268
|
+
return (overrides == null ? void 0 : overrides.apiHost) || "https://app.brainfi.sh";
|
|
269
|
+
};
|
|
270
|
+
const getWidgetHost = (overrides) => {
|
|
271
|
+
return (overrides == null ? void 0 : overrides.widgetHost) || "https://agent.brainfi.sh";
|
|
272
|
+
};
|
|
273
|
+
const getAnalyticsApiHost = (overrides) => {
|
|
274
|
+
return (overrides == null ? void 0 : overrides.analyticsApiHost) || "";
|
|
275
|
+
};
|
|
276
|
+
const loadSearchWidgetScript = (url) => __async(null, null, function* () {
|
|
277
|
+
if (document.getElementById("brainfish-widget")) {
|
|
278
|
+
return window.Brainfish;
|
|
279
|
+
}
|
|
280
|
+
return new Promise((resolve, reject) => {
|
|
281
|
+
const script = document.createElement("script");
|
|
282
|
+
script.id = "brainfish-widget";
|
|
283
|
+
script.src = url;
|
|
284
|
+
script.type = "module";
|
|
285
|
+
script.async = true;
|
|
286
|
+
script.crossOrigin = "anonymous";
|
|
287
|
+
script.onload = () => {
|
|
288
|
+
setTimeout(() => {
|
|
289
|
+
const module = window.Brainfish;
|
|
290
|
+
module ? resolve(module) : reject(new Error("Failed to load Brainfish module"));
|
|
291
|
+
}, 200);
|
|
292
|
+
};
|
|
293
|
+
script.onerror = (event) => {
|
|
294
|
+
const errorEvent = event;
|
|
295
|
+
const errorDetails = {
|
|
296
|
+
message: `Failed to load script: ${url}`,
|
|
297
|
+
type: errorEvent.type,
|
|
298
|
+
fileName: errorEvent.filename,
|
|
299
|
+
lineNumber: errorEvent.lineno,
|
|
300
|
+
columnNumber: errorEvent.colno,
|
|
301
|
+
error: errorEvent.error ? errorEvent.error.toString() : "Unknown error"
|
|
302
|
+
};
|
|
303
|
+
reject(new Error(JSON.stringify(errorDetails)));
|
|
304
|
+
};
|
|
305
|
+
document.head.appendChild(script);
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
const init = (_0) => __async(null, [_0], function* ({
|
|
309
|
+
apiHost,
|
|
310
|
+
widgetKey,
|
|
311
|
+
version
|
|
312
|
+
}) {
|
|
313
|
+
try {
|
|
314
|
+
const url = `https://cdn.jsdelivr.net/npm/@brainfish-ai/search-widget@${version}/dist/web.js`;
|
|
315
|
+
const widget = yield loadSearchWidgetScript(url);
|
|
316
|
+
return { widget };
|
|
317
|
+
} catch (error) {
|
|
318
|
+
sendBrainfishWidgetError(
|
|
319
|
+
apiHost,
|
|
320
|
+
error,
|
|
321
|
+
error.message,
|
|
322
|
+
widgetKey
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
function initializeWidget(widget, config) {
|
|
327
|
+
if (config.widgetType === WidgetType.Searchbar || config.widgetType === "Search") {
|
|
328
|
+
widget.SearchWidget.initStandard(config);
|
|
329
|
+
} else {
|
|
330
|
+
widget.HelpWidget.initPopup(config);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
const initializedWidgets$1 = /* @__PURE__ */ new Set();
|
|
334
|
+
const initSearchWidget = (options, config) => __async(null, null, function* () {
|
|
335
|
+
const apiHost = getApiHost(options.overrides);
|
|
126
336
|
try {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
337
|
+
if (initializedWidgets$1.has(options.widgetKey)) {
|
|
338
|
+
return void 0;
|
|
339
|
+
}
|
|
340
|
+
const result = yield init({
|
|
341
|
+
apiHost,
|
|
342
|
+
widgetKey: options.widgetKey,
|
|
343
|
+
version: config.version || "latest"
|
|
344
|
+
});
|
|
345
|
+
if (result) {
|
|
346
|
+
const { widget } = result;
|
|
347
|
+
const transformedConfig = transformConfig({
|
|
348
|
+
config,
|
|
349
|
+
apiKey: options.widgetKey,
|
|
350
|
+
apiHost
|
|
140
351
|
});
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
352
|
+
if (options.overrides && config.settings) {
|
|
353
|
+
Object.entries(options.overrides).forEach(([key, value]) => {
|
|
354
|
+
if (config.settings && key in config.settings) {
|
|
355
|
+
config.settings[key] = updateActions(
|
|
356
|
+
config.settings[key],
|
|
357
|
+
value
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
initializeWidget(widget, transformedConfig);
|
|
363
|
+
initializedWidgets$1.add(options.widgetKey);
|
|
364
|
+
return widget;
|
|
365
|
+
}
|
|
366
|
+
} catch (error) {
|
|
367
|
+
sendBrainfishWidgetError(
|
|
368
|
+
apiHost,
|
|
369
|
+
error,
|
|
370
|
+
error.message,
|
|
371
|
+
options.widgetKey
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
return void 0;
|
|
375
|
+
});
|
|
376
|
+
const ANALYTICS_API_HOST = "";
|
|
377
|
+
let isTrackerInitialized = false;
|
|
378
|
+
const loadTrackerScript = (apiHost, widgetKey) => __async(null, null, function* () {
|
|
379
|
+
if (document.getElementById("brainfish-analytics")) {
|
|
380
|
+
return window.BrainfishAnalytics;
|
|
381
|
+
}
|
|
382
|
+
const script = document.createElement("script");
|
|
383
|
+
script.id = "brainfish-analytics";
|
|
384
|
+
script.src = `https://cdn.jsdelivr.net/npm/@brainfish-ai/web-tracker@latest/dist/tracker.js`;
|
|
385
|
+
script.type = "module";
|
|
386
|
+
script.async = true;
|
|
387
|
+
script.crossOrigin = "anonymous";
|
|
388
|
+
script.onerror = () => {
|
|
389
|
+
sendBrainfishWidgetError(
|
|
390
|
+
apiHost,
|
|
391
|
+
new Error(`Failed to load script: ${script.src}`),
|
|
392
|
+
`Failed to load script: ${script.src}`,
|
|
393
|
+
widgetKey
|
|
394
|
+
);
|
|
395
|
+
};
|
|
396
|
+
document.head.appendChild(script);
|
|
397
|
+
});
|
|
398
|
+
const isDoNotTrackEnabled = () => {
|
|
399
|
+
if (typeof window === "undefined" || typeof navigator === "undefined") {
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
const dntEnabledValues = ["1", "yes", "true"];
|
|
403
|
+
const nav = navigator;
|
|
404
|
+
const win = window;
|
|
405
|
+
const dnt = (nav.doNotTrack || // Standard
|
|
406
|
+
win.doNotTrack || // IE11, Edge
|
|
407
|
+
nav.msDoNotTrack || // IE9, IE10
|
|
408
|
+
"0").toString().toLowerCase();
|
|
409
|
+
return dntEnabledValues.includes(dnt);
|
|
410
|
+
};
|
|
411
|
+
const initBrainfishAnalytics = (_0, _1, _2, ..._3) => __async(null, [_0, _1, _2, ..._3], function* (widgetKey, accessKey, apiHost, analyticsApiHost = ANALYTICS_API_HOST, enableRecording = false, recordingBlocklist = [], _allowLocalhostRecording, _allowScreenRecording) {
|
|
412
|
+
if (!accessKey) {
|
|
413
|
+
sendBrainfishWidgetError(
|
|
414
|
+
apiHost,
|
|
415
|
+
new Error("Access key is required"),
|
|
416
|
+
"Access key is required",
|
|
417
|
+
widgetKey
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
if (isTrackerInitialized) {
|
|
421
|
+
return;
|
|
144
422
|
}
|
|
145
|
-
}), ve = /* @__PURE__ */ new Set(), Ye = (a, t) => b(void 0, null, function* () {
|
|
146
|
-
const n = ce(a.overrides);
|
|
147
423
|
try {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
424
|
+
const isDNTEnabled = isDoNotTrackEnabled();
|
|
425
|
+
window.BrainfishAnalytics("init", {
|
|
426
|
+
apiUrl: analyticsApiHost,
|
|
427
|
+
accessKey,
|
|
428
|
+
trackScreenViews: true,
|
|
429
|
+
trackAttributes: !isDNTEnabled,
|
|
430
|
+
trackOutgoingLinks: !isDNTEnabled,
|
|
431
|
+
enableRecording: !isDNTEnabled && enableRecording,
|
|
432
|
+
recordingBlocklist,
|
|
433
|
+
_allowLocalhostRecording,
|
|
434
|
+
_allowScreenRecording
|
|
435
|
+
});
|
|
436
|
+
isTrackerInitialized = true;
|
|
437
|
+
yield loadTrackerScript(apiHost, widgetKey);
|
|
438
|
+
} catch (error) {
|
|
439
|
+
sendBrainfishWidgetError(
|
|
440
|
+
apiHost,
|
|
441
|
+
error,
|
|
442
|
+
"Failed to initialize BrainfishAnalytics",
|
|
443
|
+
widgetKey
|
|
444
|
+
);
|
|
165
445
|
}
|
|
166
446
|
});
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}))(n, a);
|
|
184
|
-
} catch (f) {
|
|
185
|
-
x(n, f, "Failed to initialize BrainfishAnalytics", a);
|
|
447
|
+
function createBrainfishQueue() {
|
|
448
|
+
let queue = [];
|
|
449
|
+
let realBrainfish = null;
|
|
450
|
+
function queueOrExecute(method, args) {
|
|
451
|
+
if (realBrainfish) {
|
|
452
|
+
const parts = method.split(".");
|
|
453
|
+
let obj = realBrainfish;
|
|
454
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
455
|
+
obj = obj[parts[i]];
|
|
456
|
+
}
|
|
457
|
+
const fn = obj[parts[parts.length - 1]];
|
|
458
|
+
if (typeof fn === "function") {
|
|
459
|
+
return fn.apply(obj, args);
|
|
460
|
+
}
|
|
461
|
+
} else {
|
|
462
|
+
queue.push([method, args]);
|
|
186
463
|
}
|
|
187
|
-
}
|
|
464
|
+
}
|
|
465
|
+
const brainfishQueue = {
|
|
466
|
+
Widgets: {
|
|
467
|
+
init: (...args) => queueOrExecute("Widgets.init", args),
|
|
468
|
+
identify: (...args) => queueOrExecute("Widgets.identify", args),
|
|
469
|
+
setSignedAttributes: (...args) => queueOrExecute("Widgets.setSignedAttributes", args),
|
|
470
|
+
open: () => queueOrExecute("Widgets.open", []),
|
|
471
|
+
close: () => queueOrExecute("Widgets.close", []),
|
|
472
|
+
isReady: false
|
|
473
|
+
},
|
|
474
|
+
SearchWidget: {
|
|
475
|
+
initStandard: (...args) => queueOrExecute("SearchWidget.initStandard", args)
|
|
476
|
+
},
|
|
477
|
+
HelpWidget: {
|
|
478
|
+
initPopup: (...args) => queueOrExecute("HelpWidget.initPopup", args),
|
|
479
|
+
close: (...args) => queueOrExecute("HelpWidget.close", args),
|
|
480
|
+
open: (...args) => queueOrExecute("HelpWidget.open", args),
|
|
481
|
+
toggle: (...args) => queueOrExecute("HelpWidget.toggle", args)
|
|
482
|
+
},
|
|
483
|
+
_setRealBrainfish: function(bf) {
|
|
484
|
+
realBrainfish = bf;
|
|
485
|
+
while (queue.length > 0) {
|
|
486
|
+
const [method, args] = queue.shift();
|
|
487
|
+
queueOrExecute(method, args);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
return brainfishQueue;
|
|
492
|
+
}
|
|
493
|
+
const createQueues = () => {
|
|
494
|
+
if (window) {
|
|
495
|
+
window.BrainfishAnalytics = window.BrainfishAnalytics || function(...args) {
|
|
496
|
+
(window.BrainfishAnalytics.q = window.BrainfishAnalytics.q || []).push(
|
|
497
|
+
args
|
|
498
|
+
);
|
|
499
|
+
};
|
|
500
|
+
}
|
|
188
501
|
};
|
|
189
|
-
function
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
502
|
+
function createElementWithClass(tagName, className, attributes = {}) {
|
|
503
|
+
const element = document.createElement(tagName);
|
|
504
|
+
element.className = className;
|
|
505
|
+
Object.entries(attributes).forEach(([key, value]) => {
|
|
506
|
+
element.setAttribute(key, value);
|
|
507
|
+
});
|
|
508
|
+
return element;
|
|
196
509
|
}
|
|
197
|
-
const
|
|
198
|
-
|
|
510
|
+
const IFRAME_CONTAINER_CLASS = "bf-iframe-container";
|
|
511
|
+
const TRIGGER_BUTTON_CLASS = "bf-trigger-button";
|
|
512
|
+
function createTriggerButton(widgetKey, triggerButtonIcon) {
|
|
513
|
+
const button = createElementWithClass("button", TRIGGER_BUTTON_CLASS, {
|
|
514
|
+
id: `trigger-button-${widgetKey}`,
|
|
515
|
+
"aria-controls": IFRAME_CONTAINER_CLASS,
|
|
516
|
+
"aria-expanded": "false",
|
|
517
|
+
"data-name": TRIGGER_BUTTON_CLASS
|
|
518
|
+
});
|
|
519
|
+
const icon = createElementWithClass("div", "trigger-button-icon", {
|
|
520
|
+
"aria-hidden": "true"
|
|
521
|
+
});
|
|
522
|
+
if (!triggerButtonIcon) {
|
|
523
|
+
icon.innerHTML = `
|
|
524
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256" class="close-icon">
|
|
525
|
+
<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>
|
|
526
|
+
</svg>
|
|
527
|
+
<svg width="24" height="14" viewBox="0 0 24 14" fill="none" xmlns="http://www.w3.org/2000/svg" class="fish-icon visible">
|
|
528
|
+
<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"/>
|
|
529
|
+
</svg>
|
|
530
|
+
`;
|
|
531
|
+
} else {
|
|
532
|
+
icon.innerHTML = `
|
|
533
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256" class="close-icon">
|
|
534
|
+
<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>
|
|
535
|
+
</svg>
|
|
536
|
+
<img src="${triggerButtonIcon}" class="fish-icon visible" alt="Trigger button icon" height="32" width="32" aria-hidden="true" aria-label="help button icon" />
|
|
537
|
+
`;
|
|
538
|
+
}
|
|
539
|
+
button.setAttribute("aria-label", "Open Brainfish widget");
|
|
540
|
+
button.appendChild(icon);
|
|
541
|
+
return { button, icon };
|
|
542
|
+
}
|
|
543
|
+
function createIframeContainer(widgetUrl) {
|
|
544
|
+
const iframeContainer = createElementWithClass(
|
|
545
|
+
"div",
|
|
546
|
+
IFRAME_CONTAINER_CLASS,
|
|
547
|
+
{
|
|
548
|
+
id: IFRAME_CONTAINER_CLASS,
|
|
549
|
+
"aria-live": "polite",
|
|
550
|
+
"aria-hidden": "true"
|
|
551
|
+
}
|
|
552
|
+
);
|
|
553
|
+
const loadingIndicator = createElementWithClass("div", "iframe-loading-indicator");
|
|
554
|
+
const spinner = createElementWithClass("div", "spinner");
|
|
555
|
+
loadingIndicator.setAttribute("aria-label", "Loading content");
|
|
556
|
+
loadingIndicator.setAttribute("role", "status");
|
|
557
|
+
loadingIndicator.appendChild(spinner);
|
|
558
|
+
iframeContainer.appendChild(loadingIndicator);
|
|
559
|
+
const iframe = createElementWithClass("iframe", "trigger-iframe", {
|
|
560
|
+
src: widgetUrl,
|
|
561
|
+
sandbox: "allow-scripts allow-same-origin allow-popups allow-forms",
|
|
562
|
+
allow: "clipboard-write",
|
|
563
|
+
role: "dialog"
|
|
564
|
+
});
|
|
565
|
+
iframe.style.opacity = "0";
|
|
566
|
+
iframe.addEventListener("load", () => {
|
|
567
|
+
loadingIndicator.style.display = "none";
|
|
568
|
+
iframe.style.opacity = "1";
|
|
569
|
+
});
|
|
570
|
+
iframe.addEventListener("error", (error) => {
|
|
571
|
+
console.error("Error loading iframe:", error);
|
|
572
|
+
loadingIndicator.innerHTML = "";
|
|
573
|
+
const errorIcon = createElementWithClass("div", "loading-error");
|
|
574
|
+
loadingIndicator.appendChild(errorIcon);
|
|
575
|
+
loadingIndicator.setAttribute("aria-label", "Failed to load content");
|
|
576
|
+
});
|
|
577
|
+
iframeContainer.appendChild(iframe);
|
|
578
|
+
return { iframeContainer, iframe };
|
|
579
|
+
}
|
|
580
|
+
function toggleIframeSize() {
|
|
581
|
+
const iframeContainer = document.querySelector(
|
|
582
|
+
`.${IFRAME_CONTAINER_CLASS}`
|
|
583
|
+
);
|
|
584
|
+
if (iframeContainer.classList.contains("expanded")) {
|
|
585
|
+
iframeContainer.classList.remove("expanded");
|
|
586
|
+
} else {
|
|
587
|
+
iframeContainer.classList.add("expanded");
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
const MOBILE_BREAKPOINT = 576;
|
|
591
|
+
class IframeStateManager {
|
|
199
592
|
static get isWidgetOpen() {
|
|
200
593
|
return this.isOpen;
|
|
201
594
|
}
|
|
202
|
-
static initialize(
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
595
|
+
static initialize({
|
|
596
|
+
button,
|
|
597
|
+
icon,
|
|
598
|
+
isButtonHidden
|
|
599
|
+
}) {
|
|
600
|
+
var _a, _b;
|
|
601
|
+
this.button = button || null;
|
|
602
|
+
this.icon = icon || null;
|
|
603
|
+
this.isButtonHidden = isButtonHidden || false;
|
|
604
|
+
if (button) {
|
|
605
|
+
button.addEventListener("click", () => this.toggleIframeVisibility());
|
|
606
|
+
}
|
|
607
|
+
if ((_a = window.Brainfish) == null ? void 0 : _a.HelpWidget) {
|
|
608
|
+
window.Brainfish.HelpWidget.close = () => this.closeWidget();
|
|
609
|
+
window.Brainfish.HelpWidget.open = () => this.openWidget();
|
|
610
|
+
}
|
|
611
|
+
if ((_b = window.Brainfish) == null ? void 0 : _b.Widgets) {
|
|
612
|
+
window.Brainfish.Widgets.open = () => this.openWidget();
|
|
613
|
+
window.Brainfish.Widgets.close = () => this.closeWidget();
|
|
614
|
+
}
|
|
206
615
|
}
|
|
207
616
|
static toggleIframeVisibility() {
|
|
208
|
-
this.isOpen = !this.isOpen
|
|
617
|
+
this.isOpen = !this.isOpen;
|
|
618
|
+
if (this.isOpen) {
|
|
619
|
+
this.openWidget();
|
|
620
|
+
} else {
|
|
621
|
+
this.closeWidget();
|
|
622
|
+
}
|
|
209
623
|
}
|
|
624
|
+
// Open the widget programmatically
|
|
210
625
|
static openWidget() {
|
|
211
|
-
var
|
|
212
|
-
this.isOpen =
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
|
|
626
|
+
var _a;
|
|
627
|
+
this.isOpen = true;
|
|
628
|
+
const iframeContainer = document.querySelector(".bf-iframe-container");
|
|
629
|
+
const iframe = iframeContainer == null ? void 0 : iframeContainer.querySelector("iframe");
|
|
630
|
+
iframeContainer == null ? void 0 : iframeContainer.classList.add("open");
|
|
631
|
+
iframeContainer == null ? void 0 : iframeContainer.setAttribute("aria-hidden", "false");
|
|
632
|
+
(_a = iframe == null ? void 0 : iframe.contentWindow) == null ? void 0 : _a.postMessage({ type: "FOCUS_SEARCH_FIELD" }, "*");
|
|
633
|
+
if (this.button && this.icon) {
|
|
634
|
+
const fishIconSVG = this.icon.querySelector(".fish-icon");
|
|
635
|
+
const closeIconSVG = this.icon.querySelector(".close-icon");
|
|
636
|
+
this.button.setAttribute("aria-expanded", "true");
|
|
637
|
+
fishIconSVG.classList.remove("visible");
|
|
638
|
+
closeIconSVG.classList.add("visible");
|
|
639
|
+
if (document.body.clientWidth <= MOBILE_BREAKPOINT) {
|
|
640
|
+
this.hideTriggerButton();
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
window.dispatchEvent(new Event("onBrainfishWidgetOpen"));
|
|
644
|
+
window.BrainfishAnalytics("track", "Open Widget");
|
|
219
645
|
}
|
|
646
|
+
// Close the widget programmatically
|
|
220
647
|
static closeWidget() {
|
|
221
|
-
this.isOpen =
|
|
222
|
-
const
|
|
223
|
-
|
|
648
|
+
this.isOpen = false;
|
|
649
|
+
const iframeContainer = document.querySelector(".bf-iframe-container");
|
|
650
|
+
iframeContainer == null ? void 0 : iframeContainer.classList.remove("open");
|
|
651
|
+
iframeContainer == null ? void 0 : iframeContainer.setAttribute("aria-hidden", "true");
|
|
652
|
+
if (this.button && this.icon) {
|
|
224
653
|
this.button.setAttribute("aria-expanded", "false");
|
|
225
|
-
const
|
|
226
|
-
|
|
654
|
+
const fishIconSVG = this.icon.querySelector(".fish-icon");
|
|
655
|
+
const closeIconSVG = this.icon.querySelector(".close-icon");
|
|
656
|
+
fishIconSVG.classList.add("visible");
|
|
657
|
+
closeIconSVG.classList.remove("visible");
|
|
658
|
+
if (document.body.clientWidth <= MOBILE_BREAKPOINT) {
|
|
659
|
+
this.showTriggerButton();
|
|
660
|
+
}
|
|
227
661
|
}
|
|
228
|
-
window.dispatchEvent(new Event("onBrainfishWidgetClose"))
|
|
662
|
+
window.dispatchEvent(new Event("onBrainfishWidgetClose"));
|
|
663
|
+
window.BrainfishAnalytics("track", "Close Widget");
|
|
229
664
|
}
|
|
230
665
|
static showTriggerButton() {
|
|
231
|
-
var
|
|
232
|
-
(
|
|
666
|
+
var _a;
|
|
667
|
+
(_a = this.button) == null ? void 0 : _a.classList.remove("hidden");
|
|
233
668
|
}
|
|
234
669
|
static hideTriggerButton() {
|
|
235
|
-
var
|
|
236
|
-
(
|
|
670
|
+
var _a;
|
|
671
|
+
(_a = this.button) == null ? void 0 : _a.classList.add("hidden");
|
|
237
672
|
}
|
|
238
673
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
674
|
+
__publicField(IframeStateManager, "isOpen", false);
|
|
675
|
+
__publicField(IframeStateManager, "button", null);
|
|
676
|
+
__publicField(IframeStateManager, "icon", null);
|
|
677
|
+
__publicField(IframeStateManager, "isButtonHidden", false);
|
|
678
|
+
function initMessageListener({
|
|
679
|
+
widgetHost,
|
|
680
|
+
apiHost,
|
|
681
|
+
widgetKey,
|
|
682
|
+
signal
|
|
683
|
+
}) {
|
|
684
|
+
const messageHandler = (event) => {
|
|
685
|
+
if (event.origin !== widgetHost) return;
|
|
686
|
+
const { type } = event.data;
|
|
687
|
+
if (type === "TOGGLE_WIDGET_SIZE") {
|
|
688
|
+
toggleIframeSize();
|
|
689
|
+
}
|
|
690
|
+
if (type === "TRACK_EVENT") {
|
|
249
691
|
if (!window.BrainfishAnalytics) return;
|
|
250
|
-
const { eventName
|
|
251
|
-
window.BrainfishAnalytics("track",
|
|
252
|
-
}
|
|
253
|
-
if (
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
692
|
+
const { eventName, data } = event.data;
|
|
693
|
+
window.BrainfishAnalytics("track", eventName, data);
|
|
694
|
+
}
|
|
695
|
+
if (type === "CLOSE_WIDGET") {
|
|
696
|
+
window.BrainfishAnalytics("track", "Close Widget");
|
|
697
|
+
IframeStateManager.toggleIframeVisibility();
|
|
698
|
+
}
|
|
699
|
+
if (type === "NEXT_BEST_ACTION_CLICKED") {
|
|
700
|
+
const { action, searchQueryId, query, answer } = event.data;
|
|
701
|
+
const context = { action, searchQueryId };
|
|
702
|
+
if (!["function", "callback"].includes(action.type)) {
|
|
703
|
+
console.error("Invalid action type", action);
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
window.__bfCallbacks = window.__bfCallbacks || {};
|
|
707
|
+
if (window.__bfCallbacks[action.id]) {
|
|
708
|
+
window.__bfCallbacks[action.id](query, answer, context);
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
const scriptUrl = `${apiHost}/api/searchWidgets.callback.codeblocks?apiKey=${widgetKey}&codeblockId=${action.id}`;
|
|
712
|
+
const script = document.createElement("script");
|
|
713
|
+
script.src = scriptUrl;
|
|
714
|
+
document.head.appendChild(script);
|
|
715
|
+
script.onload = () => {
|
|
716
|
+
window.__bfCallbacks[action.id](query, answer, context);
|
|
717
|
+
setTimeout(() => {
|
|
718
|
+
document.head.removeChild(script);
|
|
261
719
|
}, 300);
|
|
262
720
|
};
|
|
263
721
|
}
|
|
264
|
-
}
|
|
722
|
+
};
|
|
723
|
+
window.addEventListener("message", messageHandler, { signal });
|
|
265
724
|
}
|
|
266
|
-
|
|
267
|
-
|
|
725
|
+
const styles = '.bf-trigger-button{position:fixed;bottom:16px;right:16px;width:36px;height:36px;border-radius:50%;border:none;box-shadow:0 1px 6px #0000000f,0 2px 32px #00000029;transition:transform 167ms cubic-bezier(.33,0,0,1);box-sizing:content-box;display:flex;align-items:center;justify-content:center;cursor:pointer;z-index:1000;padding:12px;gap:10px;overflow:hidden}.bf-trigger-button.hidden{display:none}.trigger-button-icon{display:flex;align-items:center;justify-content:center;width:36px;height:36px;position:relative}.trigger-button-icon svg{width:100%;height:100%;position:absolute;inset:0}.trigger-button-icon>svg>path{transition:transform .3s ease,opacity .3s ease;transform:scale(.5);transform-origin:center;opacity:0}.trigger-button-icon .fish-icon{display:none}.trigger-button-icon .fish-icon.visible{display:block}.trigger-button-icon svg.visible{display:block}.trigger-button-icon>svg.visible>path{opacity:1;transform:scale(1)}.trigger-iframe{position:relative;width:100%;height:100%;border:none;outline:none;transform:translateZ(0)}.bf-iframe-container{display:none;position:fixed;z-index:2147483000000;background-color:#fff;bottom:0;right:0;width:100vw;height:100vh;border:none;overflow:hidden;opacity:0;pointer-events:none;transform:translateY(20px);transition:opacity .3s ease,transform .3s ease,width .2s ease-in-out,height .2s ease-in-out}.bf-iframe-container.open{display:block;opacity:1;transform:translateY(0);pointer-events:auto;top:0;left:0}@media (min-width: 576px){.bf-iframe-container{bottom:80px;right:24px;width:448px;height:min(750px,calc(100vh - 80px));border-radius:8px;border:1px solid var(--Dark-300, #D4D4D4);box-shadow:0 20px 25px -5px #1212171a,0 10px 10px -5px #1212170a}.bf-iframe-container.open{top:unset;left:unset}.bf-iframe-container.expanded{width:min(calc(448px * 1.35),calc(100vw - 16px));height:min(calc(750px * 1.35),calc(100vh - 80px))}}.iframe-loading-indicator{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);display:flex;align-items:center;justify-content:center;z-index:10}.spinner{width:24px;height:24px;border:2px solid rgba(0,0,0,.1);border-radius:50%;border-top-color:#3498db;animation:spin 1s ease-in-out infinite}@keyframes spin{to{transform:rotate(360deg)}}.loading-error{width:24px;height:24px;position:relative;display:flex;align-items:center;justify-content:center}.loading-error:before,.loading-error:after{content:"";position:absolute;width:16px;height:2px;background-color:#e74c3c;border-radius:2px}.loading-error:before{transform:rotate(45deg)}.loading-error:after{transform:rotate(-45deg)}';
|
|
726
|
+
function getDefaultExportFromCjs(x) {
|
|
727
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
268
728
|
}
|
|
269
|
-
var
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
(
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
var
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
729
|
+
var getLuminance$1 = { exports: {} };
|
|
730
|
+
var parseToRgb = { exports: {} };
|
|
731
|
+
var _hslToRgb = { exports: {} };
|
|
732
|
+
var hasRequired_hslToRgb;
|
|
733
|
+
function require_hslToRgb() {
|
|
734
|
+
if (hasRequired_hslToRgb) return _hslToRgb.exports;
|
|
735
|
+
hasRequired_hslToRgb = 1;
|
|
736
|
+
(function(module, exports) {
|
|
737
|
+
exports.__esModule = true;
|
|
738
|
+
exports["default"] = void 0;
|
|
739
|
+
function colorToInt(color) {
|
|
740
|
+
return Math.round(color * 255);
|
|
741
|
+
}
|
|
742
|
+
function convertToInt(red, green, blue) {
|
|
743
|
+
return colorToInt(red) + "," + colorToInt(green) + "," + colorToInt(blue);
|
|
744
|
+
}
|
|
745
|
+
function hslToRgb(hue, saturation, lightness, convert) {
|
|
746
|
+
if (convert === void 0) {
|
|
747
|
+
convert = convertToInt;
|
|
748
|
+
}
|
|
749
|
+
if (saturation === 0) {
|
|
750
|
+
return convert(lightness, lightness, lightness);
|
|
751
|
+
}
|
|
752
|
+
var huePrime = (hue % 360 + 360) % 360 / 60;
|
|
753
|
+
var chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
|
|
754
|
+
var secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
|
|
755
|
+
var red = 0;
|
|
756
|
+
var green = 0;
|
|
757
|
+
var blue = 0;
|
|
758
|
+
if (huePrime >= 0 && huePrime < 1) {
|
|
759
|
+
red = chroma;
|
|
760
|
+
green = secondComponent;
|
|
761
|
+
} else if (huePrime >= 1 && huePrime < 2) {
|
|
762
|
+
red = secondComponent;
|
|
763
|
+
green = chroma;
|
|
764
|
+
} else if (huePrime >= 2 && huePrime < 3) {
|
|
765
|
+
green = chroma;
|
|
766
|
+
blue = secondComponent;
|
|
767
|
+
} else if (huePrime >= 3 && huePrime < 4) {
|
|
768
|
+
green = secondComponent;
|
|
769
|
+
blue = chroma;
|
|
770
|
+
} else if (huePrime >= 4 && huePrime < 5) {
|
|
771
|
+
red = secondComponent;
|
|
772
|
+
blue = chroma;
|
|
773
|
+
} else if (huePrime >= 5 && huePrime < 6) {
|
|
774
|
+
red = chroma;
|
|
775
|
+
blue = secondComponent;
|
|
776
|
+
}
|
|
777
|
+
var lightnessModification = lightness - chroma / 2;
|
|
778
|
+
var finalRed = red + lightnessModification;
|
|
779
|
+
var finalGreen = green + lightnessModification;
|
|
780
|
+
var finalBlue = blue + lightnessModification;
|
|
781
|
+
return convert(finalRed, finalGreen, finalBlue);
|
|
782
|
+
}
|
|
783
|
+
exports["default"] = hslToRgb;
|
|
784
|
+
module.exports = exports.default;
|
|
785
|
+
})(_hslToRgb, _hslToRgb.exports);
|
|
786
|
+
return _hslToRgb.exports;
|
|
787
|
+
}
|
|
788
|
+
var _nameToHex = { exports: {} };
|
|
789
|
+
var hasRequired_nameToHex;
|
|
790
|
+
function require_nameToHex() {
|
|
791
|
+
if (hasRequired_nameToHex) return _nameToHex.exports;
|
|
792
|
+
hasRequired_nameToHex = 1;
|
|
793
|
+
(function(module, exports) {
|
|
794
|
+
exports.__esModule = true;
|
|
795
|
+
exports["default"] = void 0;
|
|
796
|
+
var namedColorMap = {
|
|
797
|
+
aliceblue: "f0f8ff",
|
|
798
|
+
antiquewhite: "faebd7",
|
|
799
|
+
aqua: "00ffff",
|
|
800
|
+
aquamarine: "7fffd4",
|
|
801
|
+
azure: "f0ffff",
|
|
802
|
+
beige: "f5f5dc",
|
|
803
|
+
bisque: "ffe4c4",
|
|
804
|
+
black: "000",
|
|
805
|
+
blanchedalmond: "ffebcd",
|
|
806
|
+
blue: "0000ff",
|
|
807
|
+
blueviolet: "8a2be2",
|
|
808
|
+
brown: "a52a2a",
|
|
809
|
+
burlywood: "deb887",
|
|
810
|
+
cadetblue: "5f9ea0",
|
|
811
|
+
chartreuse: "7fff00",
|
|
812
|
+
chocolate: "d2691e",
|
|
813
|
+
coral: "ff7f50",
|
|
814
|
+
cornflowerblue: "6495ed",
|
|
815
|
+
cornsilk: "fff8dc",
|
|
816
|
+
crimson: "dc143c",
|
|
817
|
+
cyan: "00ffff",
|
|
818
|
+
darkblue: "00008b",
|
|
819
|
+
darkcyan: "008b8b",
|
|
820
|
+
darkgoldenrod: "b8860b",
|
|
821
|
+
darkgray: "a9a9a9",
|
|
822
|
+
darkgreen: "006400",
|
|
823
|
+
darkgrey: "a9a9a9",
|
|
824
|
+
darkkhaki: "bdb76b",
|
|
825
|
+
darkmagenta: "8b008b",
|
|
826
|
+
darkolivegreen: "556b2f",
|
|
827
|
+
darkorange: "ff8c00",
|
|
828
|
+
darkorchid: "9932cc",
|
|
829
|
+
darkred: "8b0000",
|
|
830
|
+
darksalmon: "e9967a",
|
|
831
|
+
darkseagreen: "8fbc8f",
|
|
832
|
+
darkslateblue: "483d8b",
|
|
833
|
+
darkslategray: "2f4f4f",
|
|
834
|
+
darkslategrey: "2f4f4f",
|
|
835
|
+
darkturquoise: "00ced1",
|
|
836
|
+
darkviolet: "9400d3",
|
|
837
|
+
deeppink: "ff1493",
|
|
838
|
+
deepskyblue: "00bfff",
|
|
839
|
+
dimgray: "696969",
|
|
840
|
+
dimgrey: "696969",
|
|
841
|
+
dodgerblue: "1e90ff",
|
|
842
|
+
firebrick: "b22222",
|
|
843
|
+
floralwhite: "fffaf0",
|
|
844
|
+
forestgreen: "228b22",
|
|
845
|
+
fuchsia: "ff00ff",
|
|
846
|
+
gainsboro: "dcdcdc",
|
|
847
|
+
ghostwhite: "f8f8ff",
|
|
848
|
+
gold: "ffd700",
|
|
849
|
+
goldenrod: "daa520",
|
|
850
|
+
gray: "808080",
|
|
851
|
+
green: "008000",
|
|
852
|
+
greenyellow: "adff2f",
|
|
853
|
+
grey: "808080",
|
|
854
|
+
honeydew: "f0fff0",
|
|
855
|
+
hotpink: "ff69b4",
|
|
856
|
+
indianred: "cd5c5c",
|
|
857
|
+
indigo: "4b0082",
|
|
858
|
+
ivory: "fffff0",
|
|
859
|
+
khaki: "f0e68c",
|
|
860
|
+
lavender: "e6e6fa",
|
|
861
|
+
lavenderblush: "fff0f5",
|
|
862
|
+
lawngreen: "7cfc00",
|
|
863
|
+
lemonchiffon: "fffacd",
|
|
864
|
+
lightblue: "add8e6",
|
|
865
|
+
lightcoral: "f08080",
|
|
866
|
+
lightcyan: "e0ffff",
|
|
867
|
+
lightgoldenrodyellow: "fafad2",
|
|
868
|
+
lightgray: "d3d3d3",
|
|
869
|
+
lightgreen: "90ee90",
|
|
870
|
+
lightgrey: "d3d3d3",
|
|
871
|
+
lightpink: "ffb6c1",
|
|
872
|
+
lightsalmon: "ffa07a",
|
|
873
|
+
lightseagreen: "20b2aa",
|
|
874
|
+
lightskyblue: "87cefa",
|
|
875
|
+
lightslategray: "789",
|
|
876
|
+
lightslategrey: "789",
|
|
877
|
+
lightsteelblue: "b0c4de",
|
|
878
|
+
lightyellow: "ffffe0",
|
|
879
|
+
lime: "0f0",
|
|
880
|
+
limegreen: "32cd32",
|
|
881
|
+
linen: "faf0e6",
|
|
882
|
+
magenta: "f0f",
|
|
883
|
+
maroon: "800000",
|
|
884
|
+
mediumaquamarine: "66cdaa",
|
|
885
|
+
mediumblue: "0000cd",
|
|
886
|
+
mediumorchid: "ba55d3",
|
|
887
|
+
mediumpurple: "9370db",
|
|
888
|
+
mediumseagreen: "3cb371",
|
|
889
|
+
mediumslateblue: "7b68ee",
|
|
890
|
+
mediumspringgreen: "00fa9a",
|
|
891
|
+
mediumturquoise: "48d1cc",
|
|
892
|
+
mediumvioletred: "c71585",
|
|
893
|
+
midnightblue: "191970",
|
|
894
|
+
mintcream: "f5fffa",
|
|
895
|
+
mistyrose: "ffe4e1",
|
|
896
|
+
moccasin: "ffe4b5",
|
|
897
|
+
navajowhite: "ffdead",
|
|
898
|
+
navy: "000080",
|
|
899
|
+
oldlace: "fdf5e6",
|
|
900
|
+
olive: "808000",
|
|
901
|
+
olivedrab: "6b8e23",
|
|
902
|
+
orange: "ffa500",
|
|
903
|
+
orangered: "ff4500",
|
|
904
|
+
orchid: "da70d6",
|
|
905
|
+
palegoldenrod: "eee8aa",
|
|
906
|
+
palegreen: "98fb98",
|
|
907
|
+
paleturquoise: "afeeee",
|
|
908
|
+
palevioletred: "db7093",
|
|
909
|
+
papayawhip: "ffefd5",
|
|
910
|
+
peachpuff: "ffdab9",
|
|
911
|
+
peru: "cd853f",
|
|
912
|
+
pink: "ffc0cb",
|
|
913
|
+
plum: "dda0dd",
|
|
914
|
+
powderblue: "b0e0e6",
|
|
915
|
+
purple: "800080",
|
|
916
|
+
rebeccapurple: "639",
|
|
917
|
+
red: "f00",
|
|
918
|
+
rosybrown: "bc8f8f",
|
|
919
|
+
royalblue: "4169e1",
|
|
920
|
+
saddlebrown: "8b4513",
|
|
921
|
+
salmon: "fa8072",
|
|
922
|
+
sandybrown: "f4a460",
|
|
923
|
+
seagreen: "2e8b57",
|
|
924
|
+
seashell: "fff5ee",
|
|
925
|
+
sienna: "a0522d",
|
|
926
|
+
silver: "c0c0c0",
|
|
927
|
+
skyblue: "87ceeb",
|
|
928
|
+
slateblue: "6a5acd",
|
|
929
|
+
slategray: "708090",
|
|
930
|
+
slategrey: "708090",
|
|
931
|
+
snow: "fffafa",
|
|
932
|
+
springgreen: "00ff7f",
|
|
933
|
+
steelblue: "4682b4",
|
|
934
|
+
tan: "d2b48c",
|
|
935
|
+
teal: "008080",
|
|
936
|
+
thistle: "d8bfd8",
|
|
937
|
+
tomato: "ff6347",
|
|
938
|
+
turquoise: "40e0d0",
|
|
939
|
+
violet: "ee82ee",
|
|
940
|
+
wheat: "f5deb3",
|
|
941
|
+
white: "fff",
|
|
942
|
+
whitesmoke: "f5f5f5",
|
|
943
|
+
yellow: "ff0",
|
|
944
|
+
yellowgreen: "9acd32"
|
|
945
|
+
};
|
|
946
|
+
function nameToHex(color) {
|
|
947
|
+
if (typeof color !== "string") return color;
|
|
948
|
+
var normalizedColorName = color.toLowerCase();
|
|
949
|
+
return namedColorMap[normalizedColorName] ? "#" + namedColorMap[normalizedColorName] : color;
|
|
950
|
+
}
|
|
951
|
+
exports["default"] = nameToHex;
|
|
952
|
+
module.exports = exports.default;
|
|
953
|
+
})(_nameToHex, _nameToHex.exports);
|
|
954
|
+
return _nameToHex.exports;
|
|
955
|
+
}
|
|
956
|
+
var _errors = { exports: {} };
|
|
957
|
+
var hasRequired_errors;
|
|
958
|
+
function require_errors() {
|
|
959
|
+
if (hasRequired_errors) return _errors.exports;
|
|
960
|
+
hasRequired_errors = 1;
|
|
961
|
+
(function(module, exports) {
|
|
962
|
+
exports.__esModule = true;
|
|
963
|
+
exports["default"] = void 0;
|
|
964
|
+
function _assertThisInitialized(self2) {
|
|
965
|
+
if (self2 === void 0) {
|
|
966
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
967
|
+
}
|
|
968
|
+
return self2;
|
|
969
|
+
}
|
|
970
|
+
function _inheritsLoose(subClass, superClass) {
|
|
971
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
972
|
+
subClass.prototype.constructor = subClass;
|
|
973
|
+
_setPrototypeOf(subClass, superClass);
|
|
974
|
+
}
|
|
975
|
+
function _wrapNativeSuper(Class) {
|
|
976
|
+
var _cache = typeof Map === "function" ? /* @__PURE__ */ new Map() : void 0;
|
|
977
|
+
_wrapNativeSuper = function _wrapNativeSuper2(Class2) {
|
|
978
|
+
if (Class2 === null || !_isNativeFunction(Class2)) return Class2;
|
|
979
|
+
if (typeof Class2 !== "function") {
|
|
980
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
981
|
+
}
|
|
982
|
+
if (typeof _cache !== "undefined") {
|
|
983
|
+
if (_cache.has(Class2)) return _cache.get(Class2);
|
|
984
|
+
_cache.set(Class2, Wrapper);
|
|
985
|
+
}
|
|
986
|
+
function Wrapper() {
|
|
987
|
+
return _construct(Class2, arguments, _getPrototypeOf(this).constructor);
|
|
305
988
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
989
|
+
Wrapper.prototype = Object.create(Class2.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } });
|
|
990
|
+
return _setPrototypeOf(Wrapper, Class2);
|
|
991
|
+
};
|
|
992
|
+
return _wrapNativeSuper(Class);
|
|
993
|
+
}
|
|
994
|
+
function _construct(t, e, r) {
|
|
995
|
+
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
|
996
|
+
var o = [null];
|
|
997
|
+
o.push.apply(o, e);
|
|
998
|
+
var p = new (t.bind.apply(t, o))();
|
|
999
|
+
return r && _setPrototypeOf(p, r.prototype), p;
|
|
1000
|
+
}
|
|
1001
|
+
function _isNativeReflectConstruct() {
|
|
1002
|
+
try {
|
|
1003
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
1004
|
+
}));
|
|
1005
|
+
} catch (t2) {
|
|
311
1006
|
}
|
|
312
|
-
function
|
|
313
|
-
return
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
1007
|
+
return (_isNativeReflectConstruct = function _isNativeReflectConstruct2() {
|
|
1008
|
+
return !!t;
|
|
1009
|
+
})();
|
|
1010
|
+
}
|
|
1011
|
+
function _isNativeFunction(fn) {
|
|
1012
|
+
try {
|
|
1013
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
1014
|
+
} catch (e) {
|
|
1015
|
+
return typeof fn === "function";
|
|
320
1016
|
}
|
|
321
|
-
return f.prototype = Object.create(u.prototype, { constructor: { value: f, enumerable: !1, writable: !0, configurable: !0 } }), i(f, u);
|
|
322
|
-
}, n(l);
|
|
323
|
-
}
|
|
324
|
-
function o() {
|
|
325
|
-
try {
|
|
326
|
-
var l = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
327
|
-
}));
|
|
328
|
-
} catch (d) {
|
|
329
1017
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
return
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
`, 44: `Invalid value passed as base to modularScale, expected number or em/rem string but got %s.
|
|
427
|
-
|
|
428
|
-
`, 45: `Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.
|
|
429
|
-
|
|
430
|
-
`, 46: `Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.
|
|
431
|
-
|
|
432
|
-
`, 47: `minScreen and maxScreen must be provided as stringified numbers with the same units.
|
|
433
|
-
|
|
434
|
-
`, 48: `fromSize and toSize must be provided as stringified numbers with the same units.
|
|
435
|
-
|
|
436
|
-
`, 49: `Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.
|
|
437
|
-
|
|
438
|
-
`, 50: `Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.
|
|
439
|
-
|
|
440
|
-
`, 51: `Expects the first argument object to have the properties prop, fromSize, and toSize.
|
|
441
|
-
|
|
442
|
-
`, 52: `fontFace expects either the path to the font file(s) or a name of a local copy.
|
|
443
|
-
|
|
444
|
-
`, 53: `fontFace expects localFonts to be an array.
|
|
445
|
-
|
|
446
|
-
`, 54: `fontFace expects fileFormats to be an array.
|
|
447
|
-
|
|
448
|
-
`, 55: `fontFace expects a name of a font-family.
|
|
449
|
-
|
|
450
|
-
`, 56: `linearGradient requries at least 2 color-stops to properly render.
|
|
451
|
-
|
|
452
|
-
`, 57: `radialGradient requries at least 2 color-stops to properly render.
|
|
453
|
-
|
|
454
|
-
`, 58: `Please supply a filename to retinaImage() as the first argument.
|
|
455
|
-
|
|
456
|
-
`, 59: `Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.
|
|
457
|
-
|
|
458
|
-
`, 60: "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n", 61: `Property must be a string value.
|
|
459
|
-
|
|
460
|
-
`, 62: `borderRadius expects a radius value as a string or number as the second argument.
|
|
461
|
-
|
|
462
|
-
`, 63: `borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.
|
|
463
|
-
|
|
464
|
-
`, 64: `The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.
|
|
465
|
-
|
|
466
|
-
`, 65: `To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').
|
|
467
|
-
|
|
468
|
-
`, 66: `The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.
|
|
469
|
-
|
|
470
|
-
`, 67: `You must provide a template to this method.
|
|
471
|
-
|
|
472
|
-
`, 68: `You passed an unsupported selector state to this method.
|
|
473
|
-
|
|
474
|
-
`, 69: `Expected a string ending in "px" or a number passed as the first argument to %s(), got %s instead.
|
|
475
|
-
|
|
476
|
-
`, 70: `Expected a string ending in "px" or a number passed as the second argument to %s(), got %s instead.
|
|
477
|
-
|
|
478
|
-
`, 71: `Passed invalid pixel value %s to %s(), please pass a value like "12px" or 12.
|
|
479
|
-
|
|
480
|
-
`, 72: `Passed invalid base value %s to %s(), please pass a value like "12px" or 12.
|
|
481
|
-
|
|
482
|
-
`, 73: `Please provide a valid CSS variable.
|
|
483
|
-
|
|
484
|
-
`, 74: `CSS variable not found and no default was provided.
|
|
485
|
-
|
|
486
|
-
`, 75: `important requires a valid style object, got a %s instead.
|
|
487
|
-
|
|
488
|
-
`, 76: `fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.
|
|
489
|
-
|
|
490
|
-
`, 77: `remToPx expects a value in "rem" but you provided it in "%s".
|
|
491
|
-
|
|
492
|
-
`, 78: `base must be set in "px" or "%" but you set it in "%s".
|
|
493
|
-
` };
|
|
494
|
-
function s() {
|
|
495
|
-
for (var l = arguments.length, d = new Array(l), u = 0; u < l; u++) d[u] = arguments[u];
|
|
496
|
-
var f, c = d[0], h = [];
|
|
497
|
-
for (f = 1; f < d.length; f += 1) h.push(d[f]);
|
|
498
|
-
return h.forEach(function(g) {
|
|
499
|
-
c = c.replace(/%[a-z]/, g);
|
|
500
|
-
}), c;
|
|
501
|
-
}
|
|
502
|
-
t.default = function(l) {
|
|
503
|
-
var d, u;
|
|
504
|
-
function f(c) {
|
|
505
|
-
var h;
|
|
506
|
-
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#" + c + " for more information.") || this;
|
|
507
|
-
else {
|
|
508
|
-
for (var g = arguments.length, p = new Array(g > 1 ? g - 1 : 0), m = 1; m < g; m++) p[m - 1] = arguments[m];
|
|
509
|
-
h = l.call(this, s.apply(void 0, [e[c]].concat(p))) || this;
|
|
1018
|
+
function _setPrototypeOf(o, p) {
|
|
1019
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o2, p2) {
|
|
1020
|
+
o2.__proto__ = p2;
|
|
1021
|
+
return o2;
|
|
1022
|
+
};
|
|
1023
|
+
return _setPrototypeOf(o, p);
|
|
1024
|
+
}
|
|
1025
|
+
function _getPrototypeOf(o) {
|
|
1026
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf2(o2) {
|
|
1027
|
+
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
1028
|
+
};
|
|
1029
|
+
return _getPrototypeOf(o);
|
|
1030
|
+
}
|
|
1031
|
+
var ERRORS = {
|
|
1032
|
+
"1": "Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).\n\n",
|
|
1033
|
+
"2": "Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).\n\n",
|
|
1034
|
+
"3": "Passed an incorrect argument to a color function, please pass a string representation of a color.\n\n",
|
|
1035
|
+
"4": "Couldn't generate valid rgb string from %s, it returned %s.\n\n",
|
|
1036
|
+
"5": "Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.\n\n",
|
|
1037
|
+
"6": "Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).\n\n",
|
|
1038
|
+
"7": "Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).\n\n",
|
|
1039
|
+
"8": "Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.\n\n",
|
|
1040
|
+
"9": "Please provide a number of steps to the modularScale helper.\n\n",
|
|
1041
|
+
"10": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
|
|
1042
|
+
"11": 'Invalid value passed as base to modularScale, expected number or em string but got "%s"\n\n',
|
|
1043
|
+
"12": 'Expected a string ending in "px" or a number passed as the first argument to %s(), got "%s" instead.\n\n',
|
|
1044
|
+
"13": 'Expected a string ending in "px" or a number passed as the second argument to %s(), got "%s" instead.\n\n',
|
|
1045
|
+
"14": 'Passed invalid pixel value ("%s") to %s(), please pass a value like "12px" or 12.\n\n',
|
|
1046
|
+
"15": 'Passed invalid base value ("%s") to %s(), please pass a value like "12px" or 12.\n\n',
|
|
1047
|
+
"16": "You must provide a template to this method.\n\n",
|
|
1048
|
+
"17": "You passed an unsupported selector state to this method.\n\n",
|
|
1049
|
+
"18": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
|
|
1050
|
+
"19": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
|
|
1051
|
+
"20": "expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
|
|
1052
|
+
"21": "expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
|
|
1053
|
+
"22": "expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
|
|
1054
|
+
"23": "fontFace expects a name of a font-family.\n\n",
|
|
1055
|
+
"24": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
|
|
1056
|
+
"25": "fontFace expects localFonts to be an array.\n\n",
|
|
1057
|
+
"26": "fontFace expects fileFormats to be an array.\n\n",
|
|
1058
|
+
"27": "radialGradient requries at least 2 color-stops to properly render.\n\n",
|
|
1059
|
+
"28": "Please supply a filename to retinaImage() as the first argument.\n\n",
|
|
1060
|
+
"29": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
|
|
1061
|
+
"30": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
|
|
1062
|
+
"31": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation\n\n",
|
|
1063
|
+
"32": "To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')\n\n",
|
|
1064
|
+
"33": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation\n\n",
|
|
1065
|
+
"34": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
|
|
1066
|
+
"35": 'borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.\n\n',
|
|
1067
|
+
"36": "Property must be a string value.\n\n",
|
|
1068
|
+
"37": "Syntax Error at %s.\n\n",
|
|
1069
|
+
"38": "Formula contains a function that needs parentheses at %s.\n\n",
|
|
1070
|
+
"39": "Formula is missing closing parenthesis at %s.\n\n",
|
|
1071
|
+
"40": "Formula has too many closing parentheses at %s.\n\n",
|
|
1072
|
+
"41": "All values in a formula must have the same unit or be unitless.\n\n",
|
|
1073
|
+
"42": "Please provide a number of steps to the modularScale helper.\n\n",
|
|
1074
|
+
"43": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
|
|
1075
|
+
"44": "Invalid value passed as base to modularScale, expected number or em/rem string but got %s.\n\n",
|
|
1076
|
+
"45": "Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.\n\n",
|
|
1077
|
+
"46": "Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.\n\n",
|
|
1078
|
+
"47": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
|
|
1079
|
+
"48": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
|
|
1080
|
+
"49": "Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
|
|
1081
|
+
"50": "Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.\n\n",
|
|
1082
|
+
"51": "Expects the first argument object to have the properties prop, fromSize, and toSize.\n\n",
|
|
1083
|
+
"52": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
|
|
1084
|
+
"53": "fontFace expects localFonts to be an array.\n\n",
|
|
1085
|
+
"54": "fontFace expects fileFormats to be an array.\n\n",
|
|
1086
|
+
"55": "fontFace expects a name of a font-family.\n\n",
|
|
1087
|
+
"56": "linearGradient requries at least 2 color-stops to properly render.\n\n",
|
|
1088
|
+
"57": "radialGradient requries at least 2 color-stops to properly render.\n\n",
|
|
1089
|
+
"58": "Please supply a filename to retinaImage() as the first argument.\n\n",
|
|
1090
|
+
"59": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
|
|
1091
|
+
"60": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
|
|
1092
|
+
"61": "Property must be a string value.\n\n",
|
|
1093
|
+
"62": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
|
|
1094
|
+
"63": 'borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.\n\n',
|
|
1095
|
+
"64": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.\n\n",
|
|
1096
|
+
"65": "To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').\n\n",
|
|
1097
|
+
"66": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.\n\n",
|
|
1098
|
+
"67": "You must provide a template to this method.\n\n",
|
|
1099
|
+
"68": "You passed an unsupported selector state to this method.\n\n",
|
|
1100
|
+
"69": 'Expected a string ending in "px" or a number passed as the first argument to %s(), got %s instead.\n\n',
|
|
1101
|
+
"70": 'Expected a string ending in "px" or a number passed as the second argument to %s(), got %s instead.\n\n',
|
|
1102
|
+
"71": 'Passed invalid pixel value %s to %s(), please pass a value like "12px" or 12.\n\n',
|
|
1103
|
+
"72": 'Passed invalid base value %s to %s(), please pass a value like "12px" or 12.\n\n',
|
|
1104
|
+
"73": "Please provide a valid CSS variable.\n\n",
|
|
1105
|
+
"74": "CSS variable not found and no default was provided.\n\n",
|
|
1106
|
+
"75": "important requires a valid style object, got a %s instead.\n\n",
|
|
1107
|
+
"76": "fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.\n\n",
|
|
1108
|
+
"77": 'remToPx expects a value in "rem" but you provided it in "%s".\n\n',
|
|
1109
|
+
"78": 'base must be set in "px" or "%" but you set it in "%s".\n'
|
|
1110
|
+
};
|
|
1111
|
+
function format() {
|
|
1112
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1113
|
+
args[_key] = arguments[_key];
|
|
510
1114
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
}
|
|
559
|
-
var
|
|
560
|
-
(
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
1115
|
+
var a = args[0];
|
|
1116
|
+
var b = [];
|
|
1117
|
+
var c;
|
|
1118
|
+
for (c = 1; c < args.length; c += 1) {
|
|
1119
|
+
b.push(args[c]);
|
|
1120
|
+
}
|
|
1121
|
+
b.forEach(function(d) {
|
|
1122
|
+
a = a.replace(/%[a-z]/, d);
|
|
1123
|
+
});
|
|
1124
|
+
return a;
|
|
1125
|
+
}
|
|
1126
|
+
exports["default"] = /* @__PURE__ */ function(_Error) {
|
|
1127
|
+
_inheritsLoose(PolishedError, _Error);
|
|
1128
|
+
function PolishedError(code) {
|
|
1129
|
+
var _this;
|
|
1130
|
+
if (process.env.NODE_ENV === "production") {
|
|
1131
|
+
_this = _Error.call(this, "An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#" + code + " for more information.") || this;
|
|
1132
|
+
} else {
|
|
1133
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
1134
|
+
args[_key2 - 1] = arguments[_key2];
|
|
1135
|
+
}
|
|
1136
|
+
_this = _Error.call(this, format.apply(void 0, [ERRORS[code]].concat(args))) || this;
|
|
1137
|
+
}
|
|
1138
|
+
return _assertThisInitialized(_this);
|
|
1139
|
+
}
|
|
1140
|
+
return PolishedError;
|
|
1141
|
+
}(/* @__PURE__ */ _wrapNativeSuper(Error));
|
|
1142
|
+
module.exports = exports.default;
|
|
1143
|
+
})(_errors, _errors.exports);
|
|
1144
|
+
return _errors.exports;
|
|
1145
|
+
}
|
|
1146
|
+
var hasRequiredParseToRgb;
|
|
1147
|
+
function requireParseToRgb() {
|
|
1148
|
+
if (hasRequiredParseToRgb) return parseToRgb.exports;
|
|
1149
|
+
hasRequiredParseToRgb = 1;
|
|
1150
|
+
(function(module, exports) {
|
|
1151
|
+
exports.__esModule = true;
|
|
1152
|
+
exports["default"] = parseToRgb2;
|
|
1153
|
+
var _hslToRgb2 = _interopRequireDefault(/* @__PURE__ */ require_hslToRgb());
|
|
1154
|
+
var _nameToHex2 = _interopRequireDefault(/* @__PURE__ */ require_nameToHex());
|
|
1155
|
+
var _errors2 = _interopRequireDefault(/* @__PURE__ */ require_errors());
|
|
1156
|
+
function _interopRequireDefault(obj) {
|
|
1157
|
+
return obj && obj.__esModule ? obj : { "default": obj };
|
|
1158
|
+
}
|
|
1159
|
+
var hexRegex = /^#[a-fA-F0-9]{6}$/;
|
|
1160
|
+
var hexRgbaRegex = /^#[a-fA-F0-9]{8}$/;
|
|
1161
|
+
var reducedHexRegex = /^#[a-fA-F0-9]{3}$/;
|
|
1162
|
+
var reducedRgbaHexRegex = /^#[a-fA-F0-9]{4}$/;
|
|
1163
|
+
var rgbRegex = /^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i;
|
|
1164
|
+
var rgbaRegex = /^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
|
|
1165
|
+
var hslRegex = /^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i;
|
|
1166
|
+
var hslaRegex = /^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;
|
|
1167
|
+
function parseToRgb2(color) {
|
|
1168
|
+
if (typeof color !== "string") {
|
|
1169
|
+
throw new _errors2["default"](3);
|
|
1170
|
+
}
|
|
1171
|
+
var normalizedColor = (0, _nameToHex2["default"])(color);
|
|
1172
|
+
if (normalizedColor.match(hexRegex)) {
|
|
1173
|
+
return {
|
|
1174
|
+
red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
|
|
1175
|
+
green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
|
|
1176
|
+
blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16)
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
1179
|
+
if (normalizedColor.match(hexRgbaRegex)) {
|
|
1180
|
+
var alpha = parseFloat((parseInt("" + normalizedColor[7] + normalizedColor[8], 16) / 255).toFixed(2));
|
|
1181
|
+
return {
|
|
1182
|
+
red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
|
|
1183
|
+
green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
|
|
1184
|
+
blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16),
|
|
1185
|
+
alpha
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
if (normalizedColor.match(reducedHexRegex)) {
|
|
1189
|
+
return {
|
|
1190
|
+
red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
|
|
1191
|
+
green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
|
|
1192
|
+
blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16)
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
if (normalizedColor.match(reducedRgbaHexRegex)) {
|
|
1196
|
+
var _alpha = parseFloat((parseInt("" + normalizedColor[4] + normalizedColor[4], 16) / 255).toFixed(2));
|
|
1197
|
+
return {
|
|
1198
|
+
red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
|
|
1199
|
+
green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
|
|
1200
|
+
blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16),
|
|
1201
|
+
alpha: _alpha
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
var rgbMatched = rgbRegex.exec(normalizedColor);
|
|
1205
|
+
if (rgbMatched) {
|
|
1206
|
+
return {
|
|
1207
|
+
red: parseInt("" + rgbMatched[1], 10),
|
|
1208
|
+
green: parseInt("" + rgbMatched[2], 10),
|
|
1209
|
+
blue: parseInt("" + rgbMatched[3], 10)
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
var rgbaMatched = rgbaRegex.exec(normalizedColor.substring(0, 50));
|
|
1213
|
+
if (rgbaMatched) {
|
|
1214
|
+
return {
|
|
1215
|
+
red: parseInt("" + rgbaMatched[1], 10),
|
|
1216
|
+
green: parseInt("" + rgbaMatched[2], 10),
|
|
1217
|
+
blue: parseInt("" + rgbaMatched[3], 10),
|
|
1218
|
+
alpha: parseFloat("" + rgbaMatched[4]) > 1 ? parseFloat("" + rgbaMatched[4]) / 100 : parseFloat("" + rgbaMatched[4])
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
var hslMatched = hslRegex.exec(normalizedColor);
|
|
1222
|
+
if (hslMatched) {
|
|
1223
|
+
var hue = parseInt("" + hslMatched[1], 10);
|
|
1224
|
+
var saturation = parseInt("" + hslMatched[2], 10) / 100;
|
|
1225
|
+
var lightness = parseInt("" + hslMatched[3], 10) / 100;
|
|
1226
|
+
var rgbColorString = "rgb(" + (0, _hslToRgb2["default"])(hue, saturation, lightness) + ")";
|
|
1227
|
+
var hslRgbMatched = rgbRegex.exec(rgbColorString);
|
|
1228
|
+
if (!hslRgbMatched) {
|
|
1229
|
+
throw new _errors2["default"](4, normalizedColor, rgbColorString);
|
|
1230
|
+
}
|
|
1231
|
+
return {
|
|
1232
|
+
red: parseInt("" + hslRgbMatched[1], 10),
|
|
1233
|
+
green: parseInt("" + hslRgbMatched[2], 10),
|
|
1234
|
+
blue: parseInt("" + hslRgbMatched[3], 10)
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
var hslaMatched = hslaRegex.exec(normalizedColor.substring(0, 50));
|
|
1238
|
+
if (hslaMatched) {
|
|
1239
|
+
var _hue = parseInt("" + hslaMatched[1], 10);
|
|
1240
|
+
var _saturation = parseInt("" + hslaMatched[2], 10) / 100;
|
|
1241
|
+
var _lightness = parseInt("" + hslaMatched[3], 10) / 100;
|
|
1242
|
+
var _rgbColorString = "rgb(" + (0, _hslToRgb2["default"])(_hue, _saturation, _lightness) + ")";
|
|
1243
|
+
var _hslRgbMatched = rgbRegex.exec(_rgbColorString);
|
|
1244
|
+
if (!_hslRgbMatched) {
|
|
1245
|
+
throw new _errors2["default"](4, normalizedColor, _rgbColorString);
|
|
1246
|
+
}
|
|
1247
|
+
return {
|
|
1248
|
+
red: parseInt("" + _hslRgbMatched[1], 10),
|
|
1249
|
+
green: parseInt("" + _hslRgbMatched[2], 10),
|
|
1250
|
+
blue: parseInt("" + _hslRgbMatched[3], 10),
|
|
1251
|
+
alpha: parseFloat("" + hslaMatched[4]) > 1 ? parseFloat("" + hslaMatched[4]) / 100 : parseFloat("" + hslaMatched[4])
|
|
1252
|
+
};
|
|
1253
|
+
}
|
|
1254
|
+
throw new _errors2["default"](5);
|
|
1255
|
+
}
|
|
1256
|
+
module.exports = exports.default;
|
|
1257
|
+
})(parseToRgb, parseToRgb.exports);
|
|
1258
|
+
return parseToRgb.exports;
|
|
1259
|
+
}
|
|
1260
|
+
var hasRequiredGetLuminance;
|
|
1261
|
+
function requireGetLuminance() {
|
|
1262
|
+
if (hasRequiredGetLuminance) return getLuminance$1.exports;
|
|
1263
|
+
hasRequiredGetLuminance = 1;
|
|
1264
|
+
(function(module, exports) {
|
|
1265
|
+
exports.__esModule = true;
|
|
1266
|
+
exports["default"] = getLuminance2;
|
|
1267
|
+
var _parseToRgb = _interopRequireDefault(/* @__PURE__ */ requireParseToRgb());
|
|
1268
|
+
function _interopRequireDefault(obj) {
|
|
1269
|
+
return obj && obj.__esModule ? obj : { "default": obj };
|
|
1270
|
+
}
|
|
1271
|
+
function getLuminance2(color) {
|
|
1272
|
+
if (color === "transparent") return 0;
|
|
1273
|
+
var rgbColor = (0, _parseToRgb["default"])(color);
|
|
1274
|
+
var _Object$keys$map = Object.keys(rgbColor).map(function(key) {
|
|
1275
|
+
var channel = rgbColor[key] / 255;
|
|
1276
|
+
return channel <= 0.03928 ? channel / 12.92 : Math.pow((channel + 0.055) / 1.055, 2.4);
|
|
1277
|
+
}), r = _Object$keys$map[0], g = _Object$keys$map[1], b = _Object$keys$map[2];
|
|
1278
|
+
return parseFloat((0.2126 * r + 0.7152 * g + 0.0722 * b).toFixed(3));
|
|
1279
|
+
}
|
|
1280
|
+
module.exports = exports.default;
|
|
1281
|
+
})(getLuminance$1, getLuminance$1.exports);
|
|
1282
|
+
return getLuminance$1.exports;
|
|
1283
|
+
}
|
|
1284
|
+
var getLuminanceExports = /* @__PURE__ */ requireGetLuminance();
|
|
1285
|
+
const getLuminance = /* @__PURE__ */ getDefaultExportFromCjs(getLuminanceExports);
|
|
1286
|
+
var darken$1 = { exports: {} };
|
|
1287
|
+
var _curry = { exports: {} };
|
|
1288
|
+
var hasRequired_curry;
|
|
1289
|
+
function require_curry() {
|
|
1290
|
+
if (hasRequired_curry) return _curry.exports;
|
|
1291
|
+
hasRequired_curry = 1;
|
|
1292
|
+
(function(module, exports) {
|
|
1293
|
+
exports.__esModule = true;
|
|
1294
|
+
exports["default"] = curry;
|
|
1295
|
+
function curried(f, length, acc) {
|
|
1296
|
+
return function fn() {
|
|
1297
|
+
var combined = acc.concat(Array.prototype.slice.call(arguments));
|
|
1298
|
+
return combined.length >= length ? f.apply(this, combined) : curried(f, length, combined);
|
|
1299
|
+
};
|
|
1300
|
+
}
|
|
1301
|
+
function curry(f) {
|
|
1302
|
+
return curried(f, f.length, []);
|
|
1303
|
+
}
|
|
1304
|
+
module.exports = exports.default;
|
|
1305
|
+
})(_curry, _curry.exports);
|
|
1306
|
+
return _curry.exports;
|
|
1307
|
+
}
|
|
1308
|
+
var _guard = { exports: {} };
|
|
1309
|
+
var hasRequired_guard;
|
|
1310
|
+
function require_guard() {
|
|
1311
|
+
if (hasRequired_guard) return _guard.exports;
|
|
1312
|
+
hasRequired_guard = 1;
|
|
1313
|
+
(function(module, exports) {
|
|
1314
|
+
exports.__esModule = true;
|
|
1315
|
+
exports["default"] = void 0;
|
|
1316
|
+
function guard(lowerBoundary, upperBoundary, value) {
|
|
1317
|
+
return Math.max(lowerBoundary, Math.min(upperBoundary, value));
|
|
1318
|
+
}
|
|
1319
|
+
exports["default"] = guard;
|
|
1320
|
+
module.exports = exports.default;
|
|
1321
|
+
})(_guard, _guard.exports);
|
|
1322
|
+
return _guard.exports;
|
|
1323
|
+
}
|
|
1324
|
+
var parseToHsl = { exports: {} };
|
|
1325
|
+
var _rgbToHsl = { exports: {} };
|
|
1326
|
+
var hasRequired_rgbToHsl;
|
|
1327
|
+
function require_rgbToHsl() {
|
|
1328
|
+
if (hasRequired_rgbToHsl) return _rgbToHsl.exports;
|
|
1329
|
+
hasRequired_rgbToHsl = 1;
|
|
1330
|
+
(function(module, exports) {
|
|
1331
|
+
exports.__esModule = true;
|
|
1332
|
+
exports["default"] = void 0;
|
|
1333
|
+
function rgbToHsl(color) {
|
|
1334
|
+
var red = color.red / 255;
|
|
1335
|
+
var green = color.green / 255;
|
|
1336
|
+
var blue = color.blue / 255;
|
|
1337
|
+
var max = Math.max(red, green, blue);
|
|
1338
|
+
var min = Math.min(red, green, blue);
|
|
1339
|
+
var lightness = (max + min) / 2;
|
|
1340
|
+
if (max === min) {
|
|
1341
|
+
if (color.alpha !== void 0) {
|
|
1342
|
+
return {
|
|
1343
|
+
hue: 0,
|
|
1344
|
+
saturation: 0,
|
|
1345
|
+
lightness,
|
|
1346
|
+
alpha: color.alpha
|
|
1347
|
+
};
|
|
1348
|
+
} else {
|
|
1349
|
+
return {
|
|
1350
|
+
hue: 0,
|
|
1351
|
+
saturation: 0,
|
|
1352
|
+
lightness
|
|
1353
|
+
};
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
var hue;
|
|
1357
|
+
var delta = max - min;
|
|
1358
|
+
var saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);
|
|
1359
|
+
switch (max) {
|
|
1360
|
+
case red:
|
|
1361
|
+
hue = (green - blue) / delta + (green < blue ? 6 : 0);
|
|
1362
|
+
break;
|
|
1363
|
+
case green:
|
|
1364
|
+
hue = (blue - red) / delta + 2;
|
|
1365
|
+
break;
|
|
1366
|
+
default:
|
|
1367
|
+
hue = (red - green) / delta + 4;
|
|
1368
|
+
break;
|
|
1369
|
+
}
|
|
1370
|
+
hue *= 60;
|
|
1371
|
+
if (color.alpha !== void 0) {
|
|
1372
|
+
return {
|
|
1373
|
+
hue,
|
|
1374
|
+
saturation,
|
|
1375
|
+
lightness,
|
|
1376
|
+
alpha: color.alpha
|
|
1377
|
+
};
|
|
1378
|
+
}
|
|
1379
|
+
return {
|
|
1380
|
+
hue,
|
|
1381
|
+
saturation,
|
|
1382
|
+
lightness
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
exports["default"] = rgbToHsl;
|
|
1386
|
+
module.exports = exports.default;
|
|
1387
|
+
})(_rgbToHsl, _rgbToHsl.exports);
|
|
1388
|
+
return _rgbToHsl.exports;
|
|
1389
|
+
}
|
|
1390
|
+
var hasRequiredParseToHsl;
|
|
1391
|
+
function requireParseToHsl() {
|
|
1392
|
+
if (hasRequiredParseToHsl) return parseToHsl.exports;
|
|
1393
|
+
hasRequiredParseToHsl = 1;
|
|
1394
|
+
(function(module, exports) {
|
|
1395
|
+
exports.__esModule = true;
|
|
1396
|
+
exports["default"] = parseToHsl2;
|
|
1397
|
+
var _parseToRgb = _interopRequireDefault(/* @__PURE__ */ requireParseToRgb());
|
|
1398
|
+
var _rgbToHsl2 = _interopRequireDefault(/* @__PURE__ */ require_rgbToHsl());
|
|
1399
|
+
function _interopRequireDefault(obj) {
|
|
1400
|
+
return obj && obj.__esModule ? obj : { "default": obj };
|
|
1401
|
+
}
|
|
1402
|
+
function parseToHsl2(color) {
|
|
1403
|
+
return (0, _rgbToHsl2["default"])((0, _parseToRgb["default"])(color));
|
|
1404
|
+
}
|
|
1405
|
+
module.exports = exports.default;
|
|
1406
|
+
})(parseToHsl, parseToHsl.exports);
|
|
1407
|
+
return parseToHsl.exports;
|
|
1408
|
+
}
|
|
1409
|
+
var toColorString = { exports: {} };
|
|
1410
|
+
var hsl = { exports: {} };
|
|
1411
|
+
var _hslToHex = { exports: {} };
|
|
1412
|
+
var _reduceHexValue = { exports: {} };
|
|
1413
|
+
var hasRequired_reduceHexValue;
|
|
1414
|
+
function require_reduceHexValue() {
|
|
1415
|
+
if (hasRequired_reduceHexValue) return _reduceHexValue.exports;
|
|
1416
|
+
hasRequired_reduceHexValue = 1;
|
|
1417
|
+
(function(module, exports) {
|
|
1418
|
+
exports.__esModule = true;
|
|
1419
|
+
exports["default"] = void 0;
|
|
1420
|
+
var reduceHexValue = function reduceHexValue2(value) {
|
|
1421
|
+
if (value.length === 7 && value[1] === value[2] && value[3] === value[4] && value[5] === value[6]) {
|
|
1422
|
+
return "#" + value[1] + value[3] + value[5];
|
|
1423
|
+
}
|
|
1424
|
+
return value;
|
|
579
1425
|
};
|
|
1426
|
+
exports["default"] = reduceHexValue;
|
|
1427
|
+
module.exports = exports.default;
|
|
1428
|
+
})(_reduceHexValue, _reduceHexValue.exports);
|
|
1429
|
+
return _reduceHexValue.exports;
|
|
1430
|
+
}
|
|
1431
|
+
var _numberToHex = { exports: {} };
|
|
1432
|
+
var hasRequired_numberToHex;
|
|
1433
|
+
function require_numberToHex() {
|
|
1434
|
+
if (hasRequired_numberToHex) return _numberToHex.exports;
|
|
1435
|
+
hasRequired_numberToHex = 1;
|
|
1436
|
+
(function(module, exports) {
|
|
1437
|
+
exports.__esModule = true;
|
|
1438
|
+
exports["default"] = void 0;
|
|
1439
|
+
function numberToHex(value) {
|
|
1440
|
+
var hex = value.toString(16);
|
|
1441
|
+
return hex.length === 1 ? "0" + hex : hex;
|
|
1442
|
+
}
|
|
1443
|
+
exports["default"] = numberToHex;
|
|
1444
|
+
module.exports = exports.default;
|
|
1445
|
+
})(_numberToHex, _numberToHex.exports);
|
|
1446
|
+
return _numberToHex.exports;
|
|
1447
|
+
}
|
|
1448
|
+
var hasRequired_hslToHex;
|
|
1449
|
+
function require_hslToHex() {
|
|
1450
|
+
if (hasRequired_hslToHex) return _hslToHex.exports;
|
|
1451
|
+
hasRequired_hslToHex = 1;
|
|
1452
|
+
(function(module, exports) {
|
|
1453
|
+
exports.__esModule = true;
|
|
1454
|
+
exports["default"] = void 0;
|
|
1455
|
+
var _hslToRgb2 = _interopRequireDefault(/* @__PURE__ */ require_hslToRgb());
|
|
1456
|
+
var _reduceHexValue2 = _interopRequireDefault(/* @__PURE__ */ require_reduceHexValue());
|
|
1457
|
+
var _numberToHex2 = _interopRequireDefault(/* @__PURE__ */ require_numberToHex());
|
|
1458
|
+
function _interopRequireDefault(obj) {
|
|
1459
|
+
return obj && obj.__esModule ? obj : { "default": obj };
|
|
1460
|
+
}
|
|
1461
|
+
function colorToHex(color) {
|
|
1462
|
+
return (0, _numberToHex2["default"])(Math.round(color * 255));
|
|
1463
|
+
}
|
|
1464
|
+
function convertToHex(red, green, blue) {
|
|
1465
|
+
return (0, _reduceHexValue2["default"])("#" + colorToHex(red) + colorToHex(green) + colorToHex(blue));
|
|
1466
|
+
}
|
|
1467
|
+
function hslToHex(hue, saturation, lightness) {
|
|
1468
|
+
return (0, _hslToRgb2["default"])(hue, saturation, lightness, convertToHex);
|
|
1469
|
+
}
|
|
1470
|
+
exports["default"] = hslToHex;
|
|
1471
|
+
module.exports = exports.default;
|
|
1472
|
+
})(_hslToHex, _hslToHex.exports);
|
|
1473
|
+
return _hslToHex.exports;
|
|
1474
|
+
}
|
|
1475
|
+
var hasRequiredHsl;
|
|
1476
|
+
function requireHsl() {
|
|
1477
|
+
if (hasRequiredHsl) return hsl.exports;
|
|
1478
|
+
hasRequiredHsl = 1;
|
|
1479
|
+
(function(module, exports) {
|
|
1480
|
+
exports.__esModule = true;
|
|
1481
|
+
exports["default"] = hsl2;
|
|
1482
|
+
var _hslToHex2 = _interopRequireDefault(/* @__PURE__ */ require_hslToHex());
|
|
1483
|
+
var _errors2 = _interopRequireDefault(/* @__PURE__ */ require_errors());
|
|
1484
|
+
function _interopRequireDefault(obj) {
|
|
1485
|
+
return obj && obj.__esModule ? obj : { "default": obj };
|
|
1486
|
+
}
|
|
1487
|
+
function hsl2(value, saturation, lightness) {
|
|
1488
|
+
if (typeof value === "number" && typeof saturation === "number" && typeof lightness === "number") {
|
|
1489
|
+
return (0, _hslToHex2["default"])(value, saturation, lightness);
|
|
1490
|
+
} else if (typeof value === "object" && saturation === void 0 && lightness === void 0) {
|
|
1491
|
+
return (0, _hslToHex2["default"])(value.hue, value.saturation, value.lightness);
|
|
1492
|
+
}
|
|
1493
|
+
throw new _errors2["default"](1);
|
|
1494
|
+
}
|
|
1495
|
+
module.exports = exports.default;
|
|
1496
|
+
})(hsl, hsl.exports);
|
|
1497
|
+
return hsl.exports;
|
|
1498
|
+
}
|
|
1499
|
+
var hsla = { exports: {} };
|
|
1500
|
+
var hasRequiredHsla;
|
|
1501
|
+
function requireHsla() {
|
|
1502
|
+
if (hasRequiredHsla) return hsla.exports;
|
|
1503
|
+
hasRequiredHsla = 1;
|
|
1504
|
+
(function(module, exports) {
|
|
1505
|
+
exports.__esModule = true;
|
|
1506
|
+
exports["default"] = hsla2;
|
|
1507
|
+
var _hslToHex2 = _interopRequireDefault(/* @__PURE__ */ require_hslToHex());
|
|
1508
|
+
var _hslToRgb2 = _interopRequireDefault(/* @__PURE__ */ require_hslToRgb());
|
|
1509
|
+
var _errors2 = _interopRequireDefault(/* @__PURE__ */ require_errors());
|
|
1510
|
+
function _interopRequireDefault(obj) {
|
|
1511
|
+
return obj && obj.__esModule ? obj : { "default": obj };
|
|
1512
|
+
}
|
|
1513
|
+
function hsla2(value, saturation, lightness, alpha) {
|
|
1514
|
+
if (typeof value === "number" && typeof saturation === "number" && typeof lightness === "number" && typeof alpha === "number") {
|
|
1515
|
+
return alpha >= 1 ? (0, _hslToHex2["default"])(value, saturation, lightness) : "rgba(" + (0, _hslToRgb2["default"])(value, saturation, lightness) + "," + alpha + ")";
|
|
1516
|
+
} else if (typeof value === "object" && saturation === void 0 && lightness === void 0 && alpha === void 0) {
|
|
1517
|
+
return value.alpha >= 1 ? (0, _hslToHex2["default"])(value.hue, value.saturation, value.lightness) : "rgba(" + (0, _hslToRgb2["default"])(value.hue, value.saturation, value.lightness) + "," + value.alpha + ")";
|
|
1518
|
+
}
|
|
1519
|
+
throw new _errors2["default"](2);
|
|
1520
|
+
}
|
|
1521
|
+
module.exports = exports.default;
|
|
1522
|
+
})(hsla, hsla.exports);
|
|
1523
|
+
return hsla.exports;
|
|
1524
|
+
}
|
|
1525
|
+
var rgb = { exports: {} };
|
|
1526
|
+
var hasRequiredRgb;
|
|
1527
|
+
function requireRgb() {
|
|
1528
|
+
if (hasRequiredRgb) return rgb.exports;
|
|
1529
|
+
hasRequiredRgb = 1;
|
|
1530
|
+
(function(module, exports) {
|
|
1531
|
+
exports.__esModule = true;
|
|
1532
|
+
exports["default"] = rgb2;
|
|
1533
|
+
var _reduceHexValue2 = _interopRequireDefault(/* @__PURE__ */ require_reduceHexValue());
|
|
1534
|
+
var _numberToHex2 = _interopRequireDefault(/* @__PURE__ */ require_numberToHex());
|
|
1535
|
+
var _errors2 = _interopRequireDefault(/* @__PURE__ */ require_errors());
|
|
1536
|
+
function _interopRequireDefault(obj) {
|
|
1537
|
+
return obj && obj.__esModule ? obj : { "default": obj };
|
|
1538
|
+
}
|
|
1539
|
+
function rgb2(value, green, blue) {
|
|
1540
|
+
if (typeof value === "number" && typeof green === "number" && typeof blue === "number") {
|
|
1541
|
+
return (0, _reduceHexValue2["default"])("#" + (0, _numberToHex2["default"])(value) + (0, _numberToHex2["default"])(green) + (0, _numberToHex2["default"])(blue));
|
|
1542
|
+
} else if (typeof value === "object" && green === void 0 && blue === void 0) {
|
|
1543
|
+
return (0, _reduceHexValue2["default"])("#" + (0, _numberToHex2["default"])(value.red) + (0, _numberToHex2["default"])(value.green) + (0, _numberToHex2["default"])(value.blue));
|
|
1544
|
+
}
|
|
1545
|
+
throw new _errors2["default"](6);
|
|
1546
|
+
}
|
|
1547
|
+
module.exports = exports.default;
|
|
1548
|
+
})(rgb, rgb.exports);
|
|
1549
|
+
return rgb.exports;
|
|
1550
|
+
}
|
|
1551
|
+
var rgba = { exports: {} };
|
|
1552
|
+
var hasRequiredRgba;
|
|
1553
|
+
function requireRgba() {
|
|
1554
|
+
if (hasRequiredRgba) return rgba.exports;
|
|
1555
|
+
hasRequiredRgba = 1;
|
|
1556
|
+
(function(module, exports) {
|
|
1557
|
+
exports.__esModule = true;
|
|
1558
|
+
exports["default"] = rgba2;
|
|
1559
|
+
var _parseToRgb = _interopRequireDefault(/* @__PURE__ */ requireParseToRgb());
|
|
1560
|
+
var _rgb = _interopRequireDefault(/* @__PURE__ */ requireRgb());
|
|
1561
|
+
var _errors2 = _interopRequireDefault(/* @__PURE__ */ require_errors());
|
|
1562
|
+
function _interopRequireDefault(obj) {
|
|
1563
|
+
return obj && obj.__esModule ? obj : { "default": obj };
|
|
1564
|
+
}
|
|
1565
|
+
function rgba2(firstValue, secondValue, thirdValue, fourthValue) {
|
|
1566
|
+
if (typeof firstValue === "string" && typeof secondValue === "number") {
|
|
1567
|
+
var rgbValue = (0, _parseToRgb["default"])(firstValue);
|
|
1568
|
+
return "rgba(" + rgbValue.red + "," + rgbValue.green + "," + rgbValue.blue + "," + secondValue + ")";
|
|
1569
|
+
} else if (typeof firstValue === "number" && typeof secondValue === "number" && typeof thirdValue === "number" && typeof fourthValue === "number") {
|
|
1570
|
+
return fourthValue >= 1 ? (0, _rgb["default"])(firstValue, secondValue, thirdValue) : "rgba(" + firstValue + "," + secondValue + "," + thirdValue + "," + fourthValue + ")";
|
|
1571
|
+
} else if (typeof firstValue === "object" && secondValue === void 0 && thirdValue === void 0 && fourthValue === void 0) {
|
|
1572
|
+
return firstValue.alpha >= 1 ? (0, _rgb["default"])(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
|
|
1573
|
+
}
|
|
1574
|
+
throw new _errors2["default"](7);
|
|
1575
|
+
}
|
|
1576
|
+
module.exports = exports.default;
|
|
1577
|
+
})(rgba, rgba.exports);
|
|
1578
|
+
return rgba.exports;
|
|
1579
|
+
}
|
|
1580
|
+
var hasRequiredToColorString;
|
|
1581
|
+
function requireToColorString() {
|
|
1582
|
+
if (hasRequiredToColorString) return toColorString.exports;
|
|
1583
|
+
hasRequiredToColorString = 1;
|
|
1584
|
+
(function(module, exports) {
|
|
1585
|
+
exports.__esModule = true;
|
|
1586
|
+
exports["default"] = toColorString2;
|
|
1587
|
+
var _hsl = _interopRequireDefault(/* @__PURE__ */ requireHsl());
|
|
1588
|
+
var _hsla = _interopRequireDefault(/* @__PURE__ */ requireHsla());
|
|
1589
|
+
var _rgb = _interopRequireDefault(/* @__PURE__ */ requireRgb());
|
|
1590
|
+
var _rgba = _interopRequireDefault(/* @__PURE__ */ requireRgba());
|
|
1591
|
+
var _errors2 = _interopRequireDefault(/* @__PURE__ */ require_errors());
|
|
1592
|
+
function _interopRequireDefault(obj) {
|
|
1593
|
+
return obj && obj.__esModule ? obj : { "default": obj };
|
|
1594
|
+
}
|
|
1595
|
+
var isRgb = function isRgb2(color) {
|
|
1596
|
+
return typeof color.red === "number" && typeof color.green === "number" && typeof color.blue === "number" && (typeof color.alpha !== "number" || typeof color.alpha === "undefined");
|
|
1597
|
+
};
|
|
1598
|
+
var isRgba = function isRgba2(color) {
|
|
1599
|
+
return typeof color.red === "number" && typeof color.green === "number" && typeof color.blue === "number" && typeof color.alpha === "number";
|
|
1600
|
+
};
|
|
1601
|
+
var isHsl = function isHsl2(color) {
|
|
1602
|
+
return typeof color.hue === "number" && typeof color.saturation === "number" && typeof color.lightness === "number" && (typeof color.alpha !== "number" || typeof color.alpha === "undefined");
|
|
1603
|
+
};
|
|
1604
|
+
var isHsla = function isHsla2(color) {
|
|
1605
|
+
return typeof color.hue === "number" && typeof color.saturation === "number" && typeof color.lightness === "number" && typeof color.alpha === "number";
|
|
1606
|
+
};
|
|
1607
|
+
function toColorString2(color) {
|
|
1608
|
+
if (typeof color !== "object") throw new _errors2["default"](8);
|
|
1609
|
+
if (isRgba(color)) return (0, _rgba["default"])(color);
|
|
1610
|
+
if (isRgb(color)) return (0, _rgb["default"])(color);
|
|
1611
|
+
if (isHsla(color)) return (0, _hsla["default"])(color);
|
|
1612
|
+
if (isHsl(color)) return (0, _hsl["default"])(color);
|
|
1613
|
+
throw new _errors2["default"](8);
|
|
1614
|
+
}
|
|
1615
|
+
module.exports = exports.default;
|
|
1616
|
+
})(toColorString, toColorString.exports);
|
|
1617
|
+
return toColorString.exports;
|
|
1618
|
+
}
|
|
1619
|
+
var hasRequiredDarken;
|
|
1620
|
+
function requireDarken() {
|
|
1621
|
+
if (hasRequiredDarken) return darken$1.exports;
|
|
1622
|
+
hasRequiredDarken = 1;
|
|
1623
|
+
(function(module, exports) {
|
|
1624
|
+
exports.__esModule = true;
|
|
1625
|
+
exports["default"] = void 0;
|
|
1626
|
+
var _curry2 = _interopRequireDefault(/* @__PURE__ */ require_curry());
|
|
1627
|
+
var _guard2 = _interopRequireDefault(/* @__PURE__ */ require_guard());
|
|
1628
|
+
var _parseToHsl = _interopRequireDefault(/* @__PURE__ */ requireParseToHsl());
|
|
1629
|
+
var _toColorString = _interopRequireDefault(/* @__PURE__ */ requireToColorString());
|
|
1630
|
+
function _interopRequireDefault(obj) {
|
|
1631
|
+
return obj && obj.__esModule ? obj : { "default": obj };
|
|
1632
|
+
}
|
|
1633
|
+
function _extends() {
|
|
1634
|
+
_extends = Object.assign ? Object.assign.bind() : function(target) {
|
|
1635
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1636
|
+
var source = arguments[i];
|
|
1637
|
+
for (var key in source) {
|
|
1638
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1639
|
+
target[key] = source[key];
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
return target;
|
|
1644
|
+
};
|
|
1645
|
+
return _extends.apply(this, arguments);
|
|
1646
|
+
}
|
|
1647
|
+
function darken2(amount, color) {
|
|
1648
|
+
if (color === "transparent") return color;
|
|
1649
|
+
var hslColor = (0, _parseToHsl["default"])(color);
|
|
1650
|
+
return (0, _toColorString["default"])(_extends({}, hslColor, {
|
|
1651
|
+
lightness: (0, _guard2["default"])(0, 1, hslColor.lightness - parseFloat(amount))
|
|
1652
|
+
}));
|
|
1653
|
+
}
|
|
1654
|
+
var curriedDarken = (0, _curry2["default"])(darken2);
|
|
1655
|
+
exports["default"] = curriedDarken;
|
|
1656
|
+
module.exports = exports.default;
|
|
1657
|
+
})(darken$1, darken$1.exports);
|
|
1658
|
+
return darken$1.exports;
|
|
1659
|
+
}
|
|
1660
|
+
var darkenExports = /* @__PURE__ */ requireDarken();
|
|
1661
|
+
const darken = /* @__PURE__ */ getDefaultExportFromCjs(darkenExports);
|
|
1662
|
+
var lighten$1 = { exports: {} };
|
|
1663
|
+
var hasRequiredLighten;
|
|
1664
|
+
function requireLighten() {
|
|
1665
|
+
if (hasRequiredLighten) return lighten$1.exports;
|
|
1666
|
+
hasRequiredLighten = 1;
|
|
1667
|
+
(function(module, exports) {
|
|
1668
|
+
exports.__esModule = true;
|
|
1669
|
+
exports["default"] = void 0;
|
|
1670
|
+
var _curry2 = _interopRequireDefault(/* @__PURE__ */ require_curry());
|
|
1671
|
+
var _guard2 = _interopRequireDefault(/* @__PURE__ */ require_guard());
|
|
1672
|
+
var _parseToHsl = _interopRequireDefault(/* @__PURE__ */ requireParseToHsl());
|
|
1673
|
+
var _toColorString = _interopRequireDefault(/* @__PURE__ */ requireToColorString());
|
|
1674
|
+
function _interopRequireDefault(obj) {
|
|
1675
|
+
return obj && obj.__esModule ? obj : { "default": obj };
|
|
1676
|
+
}
|
|
1677
|
+
function _extends() {
|
|
1678
|
+
_extends = Object.assign ? Object.assign.bind() : function(target) {
|
|
1679
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1680
|
+
var source = arguments[i];
|
|
1681
|
+
for (var key in source) {
|
|
1682
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1683
|
+
target[key] = source[key];
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
return target;
|
|
1688
|
+
};
|
|
1689
|
+
return _extends.apply(this, arguments);
|
|
1690
|
+
}
|
|
1691
|
+
function lighten2(amount, color) {
|
|
1692
|
+
if (color === "transparent") return color;
|
|
1693
|
+
var hslColor = (0, _parseToHsl["default"])(color);
|
|
1694
|
+
return (0, _toColorString["default"])(_extends({}, hslColor, {
|
|
1695
|
+
lightness: (0, _guard2["default"])(0, 1, hslColor.lightness + parseFloat(amount))
|
|
1696
|
+
}));
|
|
1697
|
+
}
|
|
1698
|
+
var curriedLighten = (0, _curry2["default"])(lighten2);
|
|
1699
|
+
exports["default"] = curriedLighten;
|
|
1700
|
+
module.exports = exports.default;
|
|
1701
|
+
})(lighten$1, lighten$1.exports);
|
|
1702
|
+
return lighten$1.exports;
|
|
1703
|
+
}
|
|
1704
|
+
var lightenExports = /* @__PURE__ */ requireLighten();
|
|
1705
|
+
const lighten = /* @__PURE__ */ getDefaultExportFromCjs(lightenExports);
|
|
1706
|
+
function insertStyles(primaryColor = "#000", foreground = "FFF") {
|
|
1707
|
+
const style = document.createElement("style");
|
|
1708
|
+
style.attributes.setNamedItem(document.createAttribute("data-widget-styles"));
|
|
1709
|
+
const isLightButtonColor = getLuminance(primaryColor) > 0.5;
|
|
1710
|
+
style.textContent = `
|
|
1711
|
+
${styles}
|
|
1712
|
+
.${TRIGGER_BUTTON_CLASS} { background: ${primaryColor}; }
|
|
1713
|
+
.${TRIGGER_BUTTON_CLASS}:hover {
|
|
1714
|
+
background: ${isLightButtonColor ? darken(0.05, primaryColor) : lighten(0.05, primaryColor)};
|
|
1715
|
+
}
|
|
1716
|
+
.trigger-button-icon { color: ${foreground}; }
|
|
1717
|
+
`;
|
|
1718
|
+
document.head.appendChild(style);
|
|
1719
|
+
}
|
|
1720
|
+
function insertStylesIfNeeded(config) {
|
|
1721
|
+
var _a, _b;
|
|
1722
|
+
if (!document.querySelector("style[data-widget-styles]")) {
|
|
1723
|
+
const buttonColor = ((_a = config == null ? void 0 : config.theme) == null ? void 0 : _a.inputButtonBgColor) || "#007bff";
|
|
1724
|
+
const iconColor = ((_b = config == null ? void 0 : config.theme) == null ? void 0 : _b.textBaseColor) || "#ffffff";
|
|
1725
|
+
insertStyles(buttonColor, iconColor);
|
|
580
1726
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
var Ee = Z.exports, Q = { exports: {} }, X = { exports: {} };
|
|
590
|
-
(function(a, t) {
|
|
591
|
-
t.__esModule = !0, t.default = void 0, t.default = function(n) {
|
|
592
|
-
var o, i = n.red / 255, r = n.green / 255, e = n.blue / 255, s = Math.max(i, r, e), l = Math.min(i, r, e), d = (s + l) / 2;
|
|
593
|
-
if (s === l) return n.alpha !== void 0 ? { hue: 0, saturation: 0, lightness: d, alpha: n.alpha } : { hue: 0, saturation: 0, lightness: d };
|
|
594
|
-
var u = s - l, f = d > 0.5 ? u / (2 - s - l) : u / (s + l);
|
|
595
|
-
switch (s) {
|
|
596
|
-
case i:
|
|
597
|
-
o = (r - e) / u + (r < e ? 6 : 0);
|
|
598
|
-
break;
|
|
599
|
-
case r:
|
|
600
|
-
o = (e - i) / u + 2;
|
|
601
|
-
break;
|
|
602
|
-
default:
|
|
603
|
-
o = (i - r) / u + 4;
|
|
604
|
-
}
|
|
605
|
-
return o *= 60, n.alpha !== void 0 ? { hue: o, saturation: f, lightness: d, alpha: n.alpha } : { hue: o, saturation: f, lightness: d };
|
|
606
|
-
}, a.exports = t.default;
|
|
607
|
-
})(X, X.exports);
|
|
608
|
-
var Xe = X.exports;
|
|
609
|
-
(function(a, t) {
|
|
610
|
-
t.__esModule = !0, t.default = function(r) {
|
|
611
|
-
return (0, o.default)((0, n.default)(r));
|
|
1727
|
+
}
|
|
1728
|
+
function initColorSchemeListener(iframe, signal) {
|
|
1729
|
+
const updateIframeBodyClass = (isDarkMode) => {
|
|
1730
|
+
var _a;
|
|
1731
|
+
(_a = iframe.contentWindow) == null ? void 0 : _a.postMessage(
|
|
1732
|
+
{ type: "UPDATE_BODY_CLASS", isDarkMode },
|
|
1733
|
+
"*"
|
|
1734
|
+
);
|
|
612
1735
|
};
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
}
|
|
617
|
-
a.exports = t.default;
|
|
618
|
-
})(Q, Q.exports);
|
|
619
|
-
var Ae = Q.exports, ee = { exports: {} }, te = { exports: {} }, ne = { exports: {} }, re = { exports: {} };
|
|
620
|
-
(function(a, t) {
|
|
621
|
-
t.__esModule = !0, t.default = void 0, t.default = function(n) {
|
|
622
|
-
return n.length === 7 && n[1] === n[2] && n[3] === n[4] && n[5] === n[6] ? "#" + n[1] + n[3] + n[5] : n;
|
|
623
|
-
}, a.exports = t.default;
|
|
624
|
-
})(re, re.exports);
|
|
625
|
-
var Be = re.exports, ae = { exports: {} };
|
|
626
|
-
(function(a, t) {
|
|
627
|
-
t.__esModule = !0, t.default = void 0, t.default = function(n) {
|
|
628
|
-
var o = n.toString(16);
|
|
629
|
-
return o.length === 1 ? "0" + o : o;
|
|
630
|
-
}, a.exports = t.default;
|
|
631
|
-
})(ae, ae.exports);
|
|
632
|
-
var Ie = ae.exports;
|
|
633
|
-
(function(a, t) {
|
|
634
|
-
t.__esModule = !0, t.default = void 0;
|
|
635
|
-
var n = r(pe), o = r(Be), i = r(Ie);
|
|
636
|
-
function r(l) {
|
|
637
|
-
return l && l.__esModule ? l : { default: l };
|
|
638
|
-
}
|
|
639
|
-
function e(l) {
|
|
640
|
-
return (0, i.default)(Math.round(255 * l));
|
|
641
|
-
}
|
|
642
|
-
function s(l, d, u) {
|
|
643
|
-
return (0, o.default)("#" + e(l) + e(d) + e(u));
|
|
644
|
-
}
|
|
645
|
-
t.default = function(l, d, u) {
|
|
646
|
-
return (0, n.default)(l, d, u, s);
|
|
647
|
-
}, a.exports = t.default;
|
|
648
|
-
})(ne, ne.exports);
|
|
649
|
-
var Oe = ne.exports;
|
|
650
|
-
(function(a, t) {
|
|
651
|
-
t.__esModule = !0, t.default = function(r, e, s) {
|
|
652
|
-
if (typeof r == "number" && typeof e == "number" && typeof s == "number") return (0, n.default)(r, e, s);
|
|
653
|
-
if (typeof r == "object" && e === void 0 && s === void 0) return (0, n.default)(r.hue, r.saturation, r.lightness);
|
|
654
|
-
throw new o.default(1);
|
|
1736
|
+
const checkAndUpdateDarkMode = () => {
|
|
1737
|
+
const isDarkMode = document.body.classList.contains("dark");
|
|
1738
|
+
updateIframeBodyClass(isDarkMode);
|
|
655
1739
|
};
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
})
|
|
662
|
-
|
|
663
|
-
(function(a, t) {
|
|
664
|
-
t.__esModule = !0, t.default = function(e, s, l, d) {
|
|
665
|
-
if (typeof e == "number" && typeof s == "number" && typeof l == "number" && typeof d == "number") return d >= 1 ? (0, n.default)(e, s, l) : "rgba(" + (0, o.default)(e, s, l) + "," + d + ")";
|
|
666
|
-
if (typeof e == "object" && s === void 0 && l === void 0 && d === void 0) return e.alpha >= 1 ? (0, n.default)(e.hue, e.saturation, e.lightness) : "rgba(" + (0, o.default)(e.hue, e.saturation, e.lightness) + "," + e.alpha + ")";
|
|
667
|
-
throw new i.default(2);
|
|
1740
|
+
const observeBodyClassChanges = () => {
|
|
1741
|
+
const observer = new MutationObserver(checkAndUpdateDarkMode);
|
|
1742
|
+
observer.observe(document.body, {
|
|
1743
|
+
attributes: true,
|
|
1744
|
+
attributeFilter: ["class"]
|
|
1745
|
+
});
|
|
1746
|
+
signal.addEventListener("abort", () => observer.disconnect());
|
|
668
1747
|
};
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
(
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
1748
|
+
checkAndUpdateDarkMode();
|
|
1749
|
+
observeBodyClassChanges();
|
|
1750
|
+
}
|
|
1751
|
+
function observeColorSchemeChanges(iframe, signal) {
|
|
1752
|
+
const updateIframeBodyClass = (isMobile) => {
|
|
1753
|
+
var _a;
|
|
1754
|
+
const message = { type: "UPDATE_BODY_CLASS", isMobile };
|
|
1755
|
+
(_a = iframe.contentWindow) == null ? void 0 : _a.postMessage(message, "*");
|
|
1756
|
+
if (isMobile) {
|
|
1757
|
+
if (IframeStateManager.isWidgetOpen) {
|
|
1758
|
+
IframeStateManager.hideTriggerButton();
|
|
1759
|
+
} else {
|
|
1760
|
+
IframeStateManager.showTriggerButton();
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
681
1763
|
};
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
a.exports = t.default;
|
|
687
|
-
})(oe, oe.exports);
|
|
688
|
-
var Te = oe.exports, se = { exports: {} };
|
|
689
|
-
(function(a, t) {
|
|
690
|
-
t.__esModule = !0, t.default = function(e, s, l, d) {
|
|
691
|
-
if (typeof e == "string" && typeof s == "number") {
|
|
692
|
-
var u = (0, n.default)(e);
|
|
693
|
-
return "rgba(" + u.red + "," + u.green + "," + u.blue + "," + s + ")";
|
|
694
|
-
}
|
|
695
|
-
if (typeof e == "number" && typeof s == "number" && typeof l == "number" && typeof d == "number") return d >= 1 ? (0, o.default)(e, s, l) : "rgba(" + e + "," + s + "," + l + "," + d + ")";
|
|
696
|
-
if (typeof e == "object" && s === void 0 && l === void 0 && d === void 0) return e.alpha >= 1 ? (0, o.default)(e.red, e.green, e.blue) : "rgba(" + e.red + "," + e.green + "," + e.blue + "," + e.alpha + ")";
|
|
697
|
-
throw new i.default(7);
|
|
1764
|
+
let resizeTimeout;
|
|
1765
|
+
const checkAndUpdateIsMobile = () => {
|
|
1766
|
+
const isMobile = document.body.clientWidth <= MOBILE_BREAKPOINT;
|
|
1767
|
+
updateIframeBodyClass(isMobile);
|
|
698
1768
|
};
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
})(se, se.exports);
|
|
705
|
-
var nt = se.exports;
|
|
706
|
-
(function(a, t) {
|
|
707
|
-
t.__esModule = !0, t.default = function(c) {
|
|
708
|
-
if (typeof c != "object") throw new e.default(8);
|
|
709
|
-
if (d(c)) return (0, r.default)(c);
|
|
710
|
-
if (l(c)) return (0, i.default)(c);
|
|
711
|
-
if (f(c)) return (0, o.default)(c);
|
|
712
|
-
if (u(c)) return (0, n.default)(c);
|
|
713
|
-
throw new e.default(8);
|
|
1769
|
+
const debouncedCheckAndUpdateIsMobile = () => {
|
|
1770
|
+
if (resizeTimeout) {
|
|
1771
|
+
clearTimeout(resizeTimeout);
|
|
1772
|
+
}
|
|
1773
|
+
resizeTimeout = window.setTimeout(checkAndUpdateIsMobile, 300);
|
|
714
1774
|
};
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
var l = function(c) {
|
|
720
|
-
return typeof c.red == "number" && typeof c.green == "number" && typeof c.blue == "number" && (typeof c.alpha != "number" || c.alpha === void 0);
|
|
721
|
-
}, d = function(c) {
|
|
722
|
-
return typeof c.red == "number" && typeof c.green == "number" && typeof c.blue == "number" && typeof c.alpha == "number";
|
|
723
|
-
}, u = function(c) {
|
|
724
|
-
return typeof c.hue == "number" && typeof c.saturation == "number" && typeof c.lightness == "number" && (typeof c.alpha != "number" || c.alpha === void 0);
|
|
725
|
-
}, f = function(c) {
|
|
726
|
-
return typeof c.hue == "number" && typeof c.saturation == "number" && typeof c.lightness == "number" && typeof c.alpha == "number";
|
|
1775
|
+
const observeBodyResize = () => {
|
|
1776
|
+
const resizeObserver = new ResizeObserver(debouncedCheckAndUpdateIsMobile);
|
|
1777
|
+
resizeObserver.observe(document.body);
|
|
1778
|
+
signal.addEventListener("abort", () => resizeObserver.disconnect());
|
|
727
1779
|
};
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
var f = arguments[u];
|
|
741
|
-
for (var c in f) Object.prototype.hasOwnProperty.call(f, c) && (d[c] = f[c]);
|
|
742
|
-
}
|
|
743
|
-
return d;
|
|
744
|
-
}, s.apply(this, arguments);
|
|
1780
|
+
checkAndUpdateIsMobile();
|
|
1781
|
+
observeBodyResize();
|
|
1782
|
+
}
|
|
1783
|
+
function base64Encode(text) {
|
|
1784
|
+
const encoder = new TextEncoder();
|
|
1785
|
+
const uint8Array = encoder.encode(text);
|
|
1786
|
+
if (typeof window !== "undefined" && typeof window.btoa === "function") {
|
|
1787
|
+
const binaryString = Array.from(
|
|
1788
|
+
uint8Array,
|
|
1789
|
+
(byte) => String.fromCharCode(byte)
|
|
1790
|
+
).join("");
|
|
1791
|
+
return btoa(binaryString);
|
|
745
1792
|
}
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
var f = (0, i.default)(u);
|
|
749
|
-
return (0, r.default)(s({}, f, { lightness: (0, o.default)(0, 1, f.lightness - parseFloat(d)) }));
|
|
750
|
-
});
|
|
751
|
-
t.default = l, a.exports = t.default;
|
|
752
|
-
})(G, G.exports);
|
|
753
|
-
const rt = fe(G.exports);
|
|
754
|
-
var de = { exports: {} };
|
|
755
|
-
(function(a, t) {
|
|
756
|
-
t.__esModule = !0, t.default = void 0;
|
|
757
|
-
var n = e(Ce), o = e(Ee), i = e(Ae), r = e(We);
|
|
758
|
-
function e(d) {
|
|
759
|
-
return d && d.__esModule ? d : { default: d };
|
|
1793
|
+
if (typeof Buffer !== "undefined") {
|
|
1794
|
+
return Buffer.from(uint8Array).toString("base64");
|
|
760
1795
|
}
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
1796
|
+
throw new Error("[utils.base64Encode]: Unsupported environment");
|
|
1797
|
+
}
|
|
1798
|
+
const base64Decode = (text) => {
|
|
1799
|
+
if (typeof window !== "undefined" && typeof window.atob === "function") {
|
|
1800
|
+
const binaryString = atob(text);
|
|
1801
|
+
const len = binaryString.length;
|
|
1802
|
+
const bytes = new Uint8Array(len);
|
|
1803
|
+
for (let i = 0; i < len; i++) {
|
|
1804
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
1805
|
+
}
|
|
1806
|
+
const decoder = new TextDecoder();
|
|
1807
|
+
return decoder.decode(bytes);
|
|
769
1808
|
}
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
var f = (0, i.default)(u);
|
|
773
|
-
return (0, r.default)(s({}, f, { lightness: (0, o.default)(0, 1, f.lightness + parseFloat(d)) }));
|
|
774
|
-
});
|
|
775
|
-
t.default = l, a.exports = t.default;
|
|
776
|
-
})(de, de.exports);
|
|
777
|
-
const at = fe(de.exports);
|
|
778
|
-
function it(a) {
|
|
779
|
-
if (!document.querySelector("style[data-widget-styles]")) {
|
|
780
|
-
var t, n;
|
|
781
|
-
(function() {
|
|
782
|
-
let o = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "#000", i = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "FFF";
|
|
783
|
-
const r = document.createElement("style");
|
|
784
|
-
r.attributes.setNamedItem(document.createAttribute("data-widget-styles"));
|
|
785
|
-
const e = Qe(o) > 0.5;
|
|
786
|
-
r.textContent = `
|
|
787
|
-
.bf-trigger-button{position:fixed;bottom:16px;right:16px;width:36px;height:36px;border-radius:50%;border:none;box-shadow:0 1px 6px #0000000f,0 2px 32px #00000029;transition:transform 167ms cubic-bezier(.33,0,0,1);box-sizing:content-box;display:flex;align-items:center;justify-content:center;cursor:pointer;z-index:1000;padding:12px;gap:10px;overflow:hidden}.bf-trigger-button.hidden{display:none}.trigger-button-icon{display:flex;align-items:center;justify-content:center;width:36px;height:36px;position:relative}.trigger-button-icon svg{width:100%;height:100%;position:absolute;inset:0}.trigger-button-icon>svg>path{transition:transform .3s ease,opacity .3s ease;transform:scale(.5);transform-origin:center;opacity:0}.trigger-button-icon .fish-icon{display:none}.trigger-button-icon .fish-icon.visible{display:block}.trigger-button-icon svg.visible{display:block}.trigger-button-icon>svg.visible>path{opacity:1;transform:scale(1)}.trigger-iframe{position:relative;width:100%;height:100%;border:none;outline:none;transform:translateZ(0)}.bf-iframe-container{display:none;position:fixed;z-index:2147483000000;background-color:#fff;bottom:0;right:0;width:100vw;height:100vh;border:none;overflow:hidden;opacity:0;pointer-events:none;transform:translateY(20px);transition:opacity .3s ease,transform .3s ease,width .2s ease-in-out,height .2s ease-in-out}.bf-iframe-container.open{display:block;opacity:1;transform:translateY(0);pointer-events:auto;top:0;left:0}@media (min-width: 576px){.bf-iframe-container{bottom:80px;right:24px;width:448px;height:min(750px,calc(100vh - 80px));border-radius:8px;border:1px solid var(--Dark-300, #D4D4D4);box-shadow:0 20px 25px -5px #1212171a,0 10px 10px -5px #1212170a}.bf-iframe-container.open{top:unset;left:unset}.bf-iframe-container.expanded{width:min(calc(448px * 1.35),calc(100vw - 16px));height:min(calc(750px * 1.35),calc(100vh - 80px))}}.iframe-loading-indicator{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);display:flex;align-items:center;justify-content:center;z-index:10}.spinner{width:24px;height:24px;border:2px solid rgba(0,0,0,.1);border-radius:50%;border-top-color:#3498db;animation:spin 1s ease-in-out infinite}@keyframes spin{to{transform:rotate(360deg)}}.loading-error{width:24px;height:24px;position:relative;display:flex;align-items:center;justify-content:center}.loading-error:before,.loading-error:after{content:"";position:absolute;width:16px;height:2px;background-color:#e74c3c;border-radius:2px}.loading-error:before{transform:rotate(45deg)}.loading-error:after{transform:rotate(-45deg)}
|
|
788
|
-
.${L} { background: ${o}; }
|
|
789
|
-
.${L}:hover {
|
|
790
|
-
background: ${e ? rt(0.05, o) : at(0.05, o)};
|
|
791
|
-
}
|
|
792
|
-
.trigger-button-icon { color: ${i}; }
|
|
793
|
-
`, document.head.appendChild(r);
|
|
794
|
-
})((a == null || (t = a.theme) === null || t === void 0 ? void 0 : t.inputButtonBgColor) || "#007bff", (a == null || (n = a.theme) === null || n === void 0 ? void 0 : n.textBaseColor) || "#ffffff");
|
|
1809
|
+
if (typeof Buffer !== "undefined") {
|
|
1810
|
+
return Buffer.from(text, "base64").toString("utf-8");
|
|
795
1811
|
}
|
|
1812
|
+
throw new Error("[utils.base64Decode]: Unsupported environment");
|
|
1813
|
+
};
|
|
1814
|
+
const initializedWidgets = /* @__PURE__ */ new Set();
|
|
1815
|
+
function isWidgetInitialized(widgetKey) {
|
|
1816
|
+
return initializedWidgets.has(widgetKey);
|
|
796
1817
|
}
|
|
797
|
-
function
|
|
798
|
-
|
|
799
|
-
((o) => {
|
|
800
|
-
var i;
|
|
801
|
-
(i = a.contentWindow) === null || i === void 0 || i.postMessage({ type: "UPDATE_BODY_CLASS", isDarkMode: o }, "*");
|
|
802
|
-
})(document.body.classList.contains("dark"));
|
|
803
|
-
};
|
|
804
|
-
n(), (() => {
|
|
805
|
-
const o = new MutationObserver(n);
|
|
806
|
-
o.observe(document.body, { attributes: !0, attributeFilter: ["class"] }), t.addEventListener("abort", () => o.disconnect());
|
|
807
|
-
})();
|
|
808
|
-
}
|
|
809
|
-
function st(a, t) {
|
|
810
|
-
let n;
|
|
811
|
-
const o = () => {
|
|
812
|
-
((r) => {
|
|
813
|
-
var e;
|
|
814
|
-
const s = { type: "UPDATE_BODY_CLASS", isMobile: r };
|
|
815
|
-
(e = a.contentWindow) === null || e === void 0 || e.postMessage(s, "*"), r && (w.isWidgetOpen ? w.hideTriggerButton() : w.showTriggerButton());
|
|
816
|
-
})(document.body.clientWidth <= 576);
|
|
817
|
-
}, i = () => {
|
|
818
|
-
n && clearTimeout(n), n = window.setTimeout(o, 300);
|
|
819
|
-
};
|
|
820
|
-
o(), (() => {
|
|
821
|
-
const r = new ResizeObserver(i);
|
|
822
|
-
r.observe(document.body), t.addEventListener("abort", () => r.disconnect());
|
|
823
|
-
})();
|
|
1818
|
+
function isButtonExisting(widgetKey) {
|
|
1819
|
+
return !!document.getElementById(`trigger-button-${widgetKey}`);
|
|
824
1820
|
}
|
|
825
|
-
function
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
1821
|
+
function createWidgetWithButton(widgetKey, widgetUrl, {
|
|
1822
|
+
isButtonHidden,
|
|
1823
|
+
triggerButtonIcon
|
|
1824
|
+
}) {
|
|
1825
|
+
const fragment = document.createDocumentFragment();
|
|
1826
|
+
if (!isButtonHidden) {
|
|
1827
|
+
const { button, icon } = createTriggerButton(widgetKey, triggerButtonIcon);
|
|
1828
|
+
fragment.appendChild(button);
|
|
1829
|
+
IframeStateManager.initialize({ button, icon });
|
|
1830
|
+
} else {
|
|
1831
|
+
IframeStateManager.initialize({ isButtonHidden });
|
|
830
1832
|
}
|
|
831
|
-
|
|
832
|
-
|
|
1833
|
+
const { iframeContainer, iframe } = createIframeContainer(widgetUrl);
|
|
1834
|
+
fragment.appendChild(iframeContainer);
|
|
1835
|
+
return { fragment, iframe };
|
|
833
1836
|
}
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
let { isButtonHidden: o, triggerButtonIcon: i } = n;
|
|
837
|
-
const r = document.createDocumentFragment();
|
|
838
|
-
if (o) w.initialize({ isButtonHidden: o });
|
|
839
|
-
else {
|
|
840
|
-
const { button: l, icon: d } = function(u, f) {
|
|
841
|
-
const c = _("button", L, { id: `trigger-button-${u}`, "aria-controls": P, "aria-expanded": "false", "data-name": L }), h = _("div", "trigger-button-icon", { "aria-hidden": "true" });
|
|
842
|
-
return h.innerHTML = f ? `
|
|
843
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256" class="close-icon">
|
|
844
|
-
<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>
|
|
845
|
-
</svg>
|
|
846
|
-
<img src="${f}" class="fish-icon visible" alt="Trigger button icon" height="32" width="32" aria-hidden="true" aria-label="help button icon" />
|
|
847
|
-
` : `
|
|
848
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256" class="close-icon">
|
|
849
|
-
<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>
|
|
850
|
-
</svg>
|
|
851
|
-
<svg width="24" height="14" viewBox="0 0 24 14" fill="none" xmlns="http://www.w3.org/2000/svg" class="fish-icon visible">
|
|
852
|
-
<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"/>
|
|
853
|
-
</svg>
|
|
854
|
-
`, c.setAttribute("aria-label", "Open Brainfish widget"), c.appendChild(h), { button: c, icon: h };
|
|
855
|
-
}(a, i);
|
|
856
|
-
r.appendChild(l), w.initialize({ button: l, icon: d });
|
|
857
|
-
}
|
|
858
|
-
const { iframeContainer: e, iframe: s } = function(l) {
|
|
859
|
-
const d = _("div", P, { id: P, "aria-live": "polite", "aria-hidden": "true" }), u = _("div", "iframe-loading-indicator"), f = _("div", "spinner");
|
|
860
|
-
u.setAttribute("aria-label", "Loading content"), u.setAttribute("role", "status"), u.appendChild(f), d.appendChild(u);
|
|
861
|
-
const c = _("iframe", "trigger-iframe", { src: l, sandbox: "allow-scripts allow-same-origin allow-popups allow-forms", allow: "clipboard-write", role: "dialog" });
|
|
862
|
-
return c.style.opacity = "0", c.addEventListener("load", () => {
|
|
863
|
-
u.style.display = "none", c.style.opacity = "1";
|
|
864
|
-
}), c.addEventListener("error", (h) => {
|
|
865
|
-
console.error("Error loading iframe:", h), u.innerHTML = "";
|
|
866
|
-
const g = _("div", "loading-error");
|
|
867
|
-
u.appendChild(g), u.setAttribute("aria-label", "Failed to load content");
|
|
868
|
-
}), d.appendChild(c), { iframeContainer: d, iframe: c };
|
|
869
|
-
}(t);
|
|
870
|
-
return r.appendChild(e), { fragment: r, iframe: s };
|
|
1837
|
+
function handleInitializationError(apiHost, error, widgetKey) {
|
|
1838
|
+
sendBrainfishWidgetError(apiHost, error, error.message, widgetKey);
|
|
871
1839
|
}
|
|
872
|
-
const
|
|
873
|
-
var
|
|
874
|
-
const
|
|
875
|
-
|
|
876
|
-
const { theme
|
|
1840
|
+
const initIframeTrigger = (options, config) => {
|
|
1841
|
+
var _a;
|
|
1842
|
+
const apiHost = getApiHost(options.overrides);
|
|
1843
|
+
const widgetHost = getWidgetHost(options.overrides);
|
|
1844
|
+
const { theme, settings } = config;
|
|
1845
|
+
const encodedRules = base64Encode(
|
|
1846
|
+
JSON.stringify((_a = options.overrides) == null ? void 0 : _a.redirectRules)
|
|
1847
|
+
);
|
|
1848
|
+
const widgetUrl = `${widgetHost}/?widgetKey=${options.widgetKey}#${new URLSearchParams({
|
|
1849
|
+
theme: base64Encode(JSON.stringify(theme)),
|
|
1850
|
+
settings: base64Encode(JSON.stringify(settings)),
|
|
1851
|
+
redirectRules: encodedRules
|
|
1852
|
+
}).toString()}`;
|
|
1853
|
+
const isButtonHidden = settings == null ? void 0 : settings.hideTriggerButton;
|
|
1854
|
+
const triggerButtonIcon = settings == null ? void 0 : settings.triggerButtonIcon;
|
|
877
1855
|
try {
|
|
878
|
-
if (
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
1856
|
+
if (isWidgetInitialized(options.widgetKey)) return void 0;
|
|
1857
|
+
if (isButtonExisting(options.widgetKey)) return void 0;
|
|
1858
|
+
insertStylesIfNeeded(config);
|
|
1859
|
+
const { fragment, iframe } = createWidgetWithButton(
|
|
1860
|
+
options.widgetKey,
|
|
1861
|
+
widgetUrl,
|
|
1862
|
+
{
|
|
1863
|
+
isButtonHidden: isButtonHidden || false,
|
|
1864
|
+
triggerButtonIcon: triggerButtonIcon || ""
|
|
1865
|
+
}
|
|
1866
|
+
);
|
|
1867
|
+
const controller = new AbortController();
|
|
1868
|
+
const { signal } = controller;
|
|
1869
|
+
iframe.onload = () => {
|
|
884
1870
|
setTimeout(() => {
|
|
885
|
-
|
|
1871
|
+
initColorSchemeListener(iframe, signal);
|
|
1872
|
+
initMessageListener({
|
|
1873
|
+
widgetHost,
|
|
1874
|
+
apiHost,
|
|
1875
|
+
widgetKey: options.widgetKey,
|
|
1876
|
+
signal
|
|
1877
|
+
});
|
|
1878
|
+
observeColorSchemeChanges(iframe, signal);
|
|
886
1879
|
}, 0);
|
|
887
|
-
}, document.body.appendChild(h), xe.add(a.widgetKey);
|
|
888
|
-
const v = () => {
|
|
889
|
-
p.abort(), window.removeEventListener("beforeunload", v);
|
|
890
1880
|
};
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
1881
|
+
document.body.appendChild(fragment);
|
|
1882
|
+
initializedWidgets.add(options.widgetKey);
|
|
1883
|
+
const cleanup = () => {
|
|
1884
|
+
controller.abort();
|
|
1885
|
+
window.removeEventListener("beforeunload", cleanup);
|
|
1886
|
+
};
|
|
1887
|
+
window.addEventListener("beforeunload", cleanup);
|
|
1888
|
+
return void 0;
|
|
1889
|
+
} catch (error) {
|
|
1890
|
+
handleInitializationError(apiHost, error, options.widgetKey);
|
|
896
1891
|
}
|
|
897
|
-
|
|
1892
|
+
return void 0;
|
|
898
1893
|
};
|
|
899
|
-
var
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
1894
|
+
var HandOffType = /* @__PURE__ */ ((HandOffType2) => {
|
|
1895
|
+
HandOffType2["FRESHCHAT"] = "freshchat";
|
|
1896
|
+
HandOffType2["INTERCOM"] = "intercom";
|
|
1897
|
+
HandOffType2["ZENDESK"] = "zendesk";
|
|
1898
|
+
HandOffType2["HELPSCOUT"] = "helpscout";
|
|
1899
|
+
return HandOffType2;
|
|
1900
|
+
})(HandOffType || {});
|
|
1901
|
+
const detectHandoff = (config) => {
|
|
1902
|
+
const usesFreshChat = !!window.fcWidget;
|
|
1903
|
+
if (usesFreshChat) {
|
|
1904
|
+
return HandOffType.FRESHCHAT;
|
|
908
1905
|
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
}
|
|
919
|
-
|
|
1906
|
+
return null;
|
|
1907
|
+
};
|
|
1908
|
+
const initFreshChat = () => __async(null, null, function* () {
|
|
1909
|
+
if (!window.fcWidget) {
|
|
1910
|
+
yield new Promise((resolve) => setTimeout(resolve, 100));
|
|
1911
|
+
}
|
|
1912
|
+
window.fcWidget.hide();
|
|
1913
|
+
window.fcWidget.on("widget:closed", () => {
|
|
1914
|
+
window.fcWidget.hide();
|
|
1915
|
+
});
|
|
1916
|
+
});
|
|
1917
|
+
const initHandOffs = (config) => __async(null, null, function* () {
|
|
1918
|
+
if (config.widgetType === WidgetType.Popup) {
|
|
1919
|
+
const handoffType = detectHandoff();
|
|
1920
|
+
if (handoffType && handoffType === HandOffType.FRESHCHAT) {
|
|
1921
|
+
yield initFreshChat();
|
|
1922
|
+
}
|
|
920
1923
|
}
|
|
921
1924
|
});
|
|
922
|
-
|
|
923
|
-
const
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
if (t) {
|
|
927
|
-
const e = i.split(".");
|
|
928
|
-
let s = t;
|
|
929
|
-
for (let d = 0; d < e.length - 1; d++) s = s[e[d]];
|
|
930
|
-
const l = s[e[e.length - 1]];
|
|
931
|
-
if (typeof l == "function") return l.apply(s, r);
|
|
932
|
-
} else a.push([i, r]);
|
|
1925
|
+
const scriptElementId = "brainfish-nudges";
|
|
1926
|
+
const loadNudgeWidgetScript = (apiHost, widgetKey) => __async(null, null, function* () {
|
|
1927
|
+
if (document.getElementById(scriptElementId)) {
|
|
1928
|
+
return;
|
|
933
1929
|
}
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
return n("HelpWidget.close", r);
|
|
952
|
-
}, open: function() {
|
|
953
|
-
for (var i = arguments.length, r = new Array(i), e = 0; e < i; e++) r[e] = arguments[e];
|
|
954
|
-
return n("HelpWidget.open", r);
|
|
955
|
-
}, toggle: function() {
|
|
956
|
-
for (var i = arguments.length, r = new Array(i), e = 0; e < i; e++) r[e] = arguments[e];
|
|
957
|
-
return n("HelpWidget.toggle", r);
|
|
958
|
-
} }, _setRealBrainfish: function(i) {
|
|
959
|
-
for (t = i; a.length > 0; ) {
|
|
960
|
-
const [r, e] = a.shift();
|
|
961
|
-
n(r, e);
|
|
962
|
-
}
|
|
963
|
-
} };
|
|
964
|
-
}(), typeof window != "undefined" && (window.Brainfish = M)), M);
|
|
965
|
-
let z = null;
|
|
966
|
-
A.Widgets.isReady = !1, A.Widgets.identify = (a) => {
|
|
967
|
-
window.BrainfishAnalytics("identify", a);
|
|
968
|
-
}, A.Widgets.setSignedAttributes = (a) => {
|
|
1930
|
+
const script = document.createElement("script");
|
|
1931
|
+
script.id = scriptElementId;
|
|
1932
|
+
script.src = `https://cdn.jsdelivr.net/npm/@brainfish-ai/nudge-widget@latest/dist/index.js`;
|
|
1933
|
+
script.type = "module";
|
|
1934
|
+
script.async = true;
|
|
1935
|
+
script.crossOrigin = "anonymous";
|
|
1936
|
+
script.onerror = () => {
|
|
1937
|
+
sendBrainfishWidgetError(
|
|
1938
|
+
apiHost,
|
|
1939
|
+
new Error(`Failed to load script: ${script.src}`),
|
|
1940
|
+
`Failed to load script: ${script.src}`,
|
|
1941
|
+
widgetKey
|
|
1942
|
+
);
|
|
1943
|
+
};
|
|
1944
|
+
document.head.appendChild(script);
|
|
1945
|
+
});
|
|
1946
|
+
const initNudgeWidget = (apiHost, widgetKey) => __async(null, null, function* () {
|
|
969
1947
|
try {
|
|
970
|
-
(
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
} catch (s) {
|
|
979
|
-
throw new I(`Invalid token specified: invalid base64 for part #${i + 1} (${s.message})`);
|
|
980
|
-
}
|
|
981
|
-
try {
|
|
982
|
-
return JSON.parse(e);
|
|
983
|
-
} catch (s) {
|
|
984
|
-
throw new I(`Invalid token specified: invalid json for part #${i + 1} (${s.message})`);
|
|
985
|
-
}
|
|
986
|
-
})(a);
|
|
987
|
-
} catch (n) {
|
|
988
|
-
return void console.error("[Brainfish] Invalid JWT provided to setSignedAttributes:", n);
|
|
1948
|
+
yield loadNudgeWidgetScript(apiHost, widgetKey);
|
|
1949
|
+
} catch (error) {
|
|
1950
|
+
sendBrainfishWidgetError(
|
|
1951
|
+
apiHost,
|
|
1952
|
+
error,
|
|
1953
|
+
"Failed to initialize Nudge widget",
|
|
1954
|
+
widgetKey
|
|
1955
|
+
);
|
|
989
1956
|
}
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
1957
|
+
});
|
|
1958
|
+
let globalBrainfish = null;
|
|
1959
|
+
function getBrainfishInstance() {
|
|
1960
|
+
if (typeof window !== "undefined" && window.Brainfish) {
|
|
1961
|
+
return window.Brainfish;
|
|
1962
|
+
}
|
|
1963
|
+
if (!globalBrainfish) {
|
|
1964
|
+
globalBrainfish = createBrainfishQueue();
|
|
1965
|
+
if (typeof window !== "undefined") {
|
|
1966
|
+
window.Brainfish = globalBrainfish;
|
|
1967
|
+
}
|
|
996
1968
|
}
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1969
|
+
return globalBrainfish;
|
|
1970
|
+
}
|
|
1971
|
+
const Brainfish = getBrainfishInstance();
|
|
1972
|
+
let initializationPromise = null;
|
|
1973
|
+
function initializeBrainfish(options, config, apiHost, analyticsApiHost) {
|
|
1974
|
+
return __async(this, null, function* () {
|
|
1975
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1976
|
+
const enableRecording = ((_a = options.overrides) == null ? void 0 : _a.enableRecording) || ((_b = config == null ? void 0 : config.settings) == null ? void 0 : _b.enableRecording) || false;
|
|
1977
|
+
const requestedVersion = ((_c = options.overrides) == null ? void 0 : _c.version) || (config == null ? void 0 : config.version);
|
|
1978
|
+
const initPromises = [];
|
|
1979
|
+
if (requestedVersion == null ? void 0 : requestedVersion.startsWith("2.")) {
|
|
1980
|
+
initIframeTrigger(options, config);
|
|
1981
|
+
} else {
|
|
1982
|
+
initPromises.push(initSearchWidget(options, config));
|
|
1983
|
+
}
|
|
1984
|
+
initPromises.push(
|
|
1985
|
+
initBrainfishAnalytics(
|
|
1986
|
+
options.widgetKey,
|
|
1987
|
+
config.trackingToken || "",
|
|
1988
|
+
apiHost,
|
|
1989
|
+
analyticsApiHost,
|
|
1990
|
+
enableRecording,
|
|
1991
|
+
((_d = config == null ? void 0 : config.settings) == null ? void 0 : _d.recordingBlocklist) || [],
|
|
1992
|
+
(_e = config == null ? void 0 : config.settings) == null ? void 0 : _e._allowLocalhostRecording,
|
|
1993
|
+
(_f = config == null ? void 0 : config.settings) == null ? void 0 : _f._allowScreenRecording
|
|
1994
|
+
)
|
|
1995
|
+
// Even if this fails, it won't block the widget
|
|
1996
|
+
);
|
|
1997
|
+
initPromises.push(initNudgeWidget(apiHost, options.widgetKey));
|
|
1998
|
+
const [widgetPromise] = yield Promise.allSettled(initPromises);
|
|
1999
|
+
if (widgetPromise && widgetPromise.status === "fulfilled" && widgetPromise.value) {
|
|
2000
|
+
Brainfish._setRealBrainfish(widgetPromise.value);
|
|
2001
|
+
}
|
|
1001
2002
|
});
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
2003
|
+
}
|
|
2004
|
+
Brainfish.Widgets.isReady = false;
|
|
2005
|
+
Brainfish.Widgets.identify = (userData) => {
|
|
2006
|
+
window.BrainfishAnalytics("identify", userData);
|
|
2007
|
+
};
|
|
2008
|
+
Brainfish.Widgets.setSignedAttributes = (jwt) => {
|
|
2009
|
+
try {
|
|
2010
|
+
jwtDecode(jwt);
|
|
2011
|
+
} catch (error) {
|
|
2012
|
+
console.error("[Brainfish] Invalid JWT provided to setSignedAttributes:", error);
|
|
2013
|
+
return;
|
|
2014
|
+
}
|
|
2015
|
+
const iframe = document.querySelector(
|
|
2016
|
+
"#bf-iframe-container .trigger-iframe"
|
|
2017
|
+
);
|
|
2018
|
+
if (iframe) {
|
|
2019
|
+
const sendMessage = () => {
|
|
2020
|
+
if (iframe.contentWindow) {
|
|
2021
|
+
iframe.contentWindow.postMessage(
|
|
2022
|
+
{
|
|
2023
|
+
type: "SET_SIGNED_ATTRIBUTES",
|
|
2024
|
+
jwt
|
|
2025
|
+
},
|
|
2026
|
+
"*"
|
|
2027
|
+
);
|
|
2028
|
+
}
|
|
2029
|
+
};
|
|
2030
|
+
if (iframe.contentWindow) {
|
|
2031
|
+
sendMessage();
|
|
2032
|
+
}
|
|
2033
|
+
iframe.addEventListener("load", sendMessage);
|
|
1017
2034
|
}
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
2035
|
+
};
|
|
2036
|
+
Brainfish.Widgets.init = (options) => __async(null, null, function* () {
|
|
2037
|
+
createQueues();
|
|
2038
|
+
const apiHost = getApiHost(options.overrides);
|
|
2039
|
+
const analyticsApiHost = getAnalyticsApiHost(options.overrides);
|
|
2040
|
+
let config;
|
|
2041
|
+
if (options.config) {
|
|
2042
|
+
config = JSON.parse(base64Decode(options.config));
|
|
2043
|
+
} else {
|
|
2044
|
+
const { config: fetchedConfig } = yield getConfigByKey({
|
|
2045
|
+
widgetKey: options.widgetKey,
|
|
2046
|
+
apiHost
|
|
1025
2047
|
});
|
|
1026
|
-
|
|
2048
|
+
config = fetchedConfig;
|
|
2049
|
+
}
|
|
2050
|
+
if (!initializationPromise) {
|
|
2051
|
+
initializationPromise = initializeBrainfish(
|
|
2052
|
+
options,
|
|
2053
|
+
config,
|
|
2054
|
+
apiHost,
|
|
2055
|
+
analyticsApiHost
|
|
2056
|
+
);
|
|
2057
|
+
}
|
|
2058
|
+
yield initializationPromise;
|
|
2059
|
+
yield initHandOffs(config);
|
|
2060
|
+
Brainfish.Widgets.isReady = true;
|
|
2061
|
+
window.dispatchEvent(new Event("onBrainfishReady"));
|
|
1027
2062
|
});
|
|
1028
|
-
const
|
|
1029
|
-
typeof window
|
|
2063
|
+
const BrainfishAnalytics = (...args) => {
|
|
2064
|
+
if (typeof window !== "undefined" && window.BrainfishAnalytics) {
|
|
2065
|
+
window.BrainfishAnalytics(...args);
|
|
2066
|
+
}
|
|
1030
2067
|
};
|
|
1031
2068
|
export {
|
|
1032
|
-
|
|
1033
|
-
|
|
2069
|
+
BrainfishAnalytics,
|
|
2070
|
+
Brainfish as default
|
|
1034
2071
|
};
|
|
1035
2072
|
//# sourceMappingURL=web.js.map
|