@saasquatch/squatch-js 2.8.3-3 → 2.8.3-30
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/CHANGELOG.md +1 -1
- package/babelregister.js +0 -1
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/clover.xml +996 -0
- package/coverage/coverage-final.json +26 -0
- package/coverage/favicon.png +0 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +210 -0
- package/demo/perf-benchmark.ts +363 -0
- package/demo/perf-compare.html +870 -0
- package/demo/perf-deploy/vercel.json +17 -0
- package/demo/perf-frame.html +417 -0
- package/demo/perf-server.ts +131 -0
- package/dist/ErrorTemplate-DUNm11h9.js +124 -0
- package/dist/ErrorTemplate-DUNm11h9.js.map +1 -0
- package/dist/ErrorTemplate-DumOlC5f.cjs +109 -0
- package/dist/ErrorTemplate-DumOlC5f.cjs.map +1 -0
- package/dist/SkeletonTemplate-B3Bk4NFu.cjs +243 -0
- package/dist/SkeletonTemplate-B3Bk4NFu.cjs.map +1 -0
- package/dist/SkeletonTemplate-Day_0iMM.js +246 -0
- package/dist/SkeletonTemplate-Day_0iMM.js.map +1 -0
- package/dist/squatch.cjs.js +33 -2523
- package/dist/squatch.cjs.js.map +1 -1
- package/dist/squatch.esm.js +928 -1956
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +227 -2373
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +4 -5
- package/dist/types.d.ts +134 -1
- package/dist/utils/cookieUtils.d.ts +1 -0
- package/dist/utils/logger.d.ts +23 -0
- package/dist/widgets/EmbedWidget.d.ts +1 -1
- package/dist/widgets/ErrorTemplate.d.ts +9 -0
- package/dist/widgets/PopupWidget.d.ts +3 -5
- package/dist/widgets/SkeletonTemplate.d.ts +1 -4
- package/dist/widgets/Widget.d.ts +29 -2
- package/dist/widgets/declarative/DeclarativeWidget.d.ts +9 -1
- package/dist/widgets/declarative/DeclarativeWidgets.d.ts +0 -6
- package/package.json +11 -15
- package/vite-env.d.ts +2 -1
- package/vite.config.ts +17 -0
- package/babel.config.js +0 -8
- package/jest.config.ts +0 -200
package/dist/squatch.esm.js
CHANGED
|
@@ -1,608 +1,235 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
function
|
|
6
|
-
|
|
1
|
+
var Ae = Object.defineProperty;
|
|
2
|
+
var Ie = (o, t, e) => t in o ? Ae(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
|
+
var l = (o, t, e) => Ie(o, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
let _ = null;
|
|
5
|
+
function ve(o) {
|
|
6
|
+
const e = o.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
|
|
7
|
+
_ = new RegExp(`^${e}$`);
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var hasRequiredMs;
|
|
11
|
-
function requireMs() {
|
|
12
|
-
if (hasRequiredMs) return ms;
|
|
13
|
-
hasRequiredMs = 1;
|
|
14
|
-
var s = 1e3;
|
|
15
|
-
var m = s * 60;
|
|
16
|
-
var h = m * 60;
|
|
17
|
-
var d = h * 24;
|
|
18
|
-
var w = d * 7;
|
|
19
|
-
var y = d * 365.25;
|
|
20
|
-
ms = function(val, options) {
|
|
21
|
-
options = options || {};
|
|
22
|
-
var type = typeof val;
|
|
23
|
-
if (type === "string" && val.length > 0) {
|
|
24
|
-
return parse(val);
|
|
25
|
-
} else if (type === "number" && isFinite(val)) {
|
|
26
|
-
return options.long ? fmtLong(val) : fmtShort(val);
|
|
27
|
-
}
|
|
28
|
-
throw new Error(
|
|
29
|
-
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
function parse(str) {
|
|
33
|
-
str = String(str);
|
|
34
|
-
if (str.length > 100) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
38
|
-
str
|
|
39
|
-
);
|
|
40
|
-
if (!match) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
var n = parseFloat(match[1]);
|
|
44
|
-
var type = (match[2] || "ms").toLowerCase();
|
|
45
|
-
switch (type) {
|
|
46
|
-
case "years":
|
|
47
|
-
case "year":
|
|
48
|
-
case "yrs":
|
|
49
|
-
case "yr":
|
|
50
|
-
case "y":
|
|
51
|
-
return n * y;
|
|
52
|
-
case "weeks":
|
|
53
|
-
case "week":
|
|
54
|
-
case "w":
|
|
55
|
-
return n * w;
|
|
56
|
-
case "days":
|
|
57
|
-
case "day":
|
|
58
|
-
case "d":
|
|
59
|
-
return n * d;
|
|
60
|
-
case "hours":
|
|
61
|
-
case "hour":
|
|
62
|
-
case "hrs":
|
|
63
|
-
case "hr":
|
|
64
|
-
case "h":
|
|
65
|
-
return n * h;
|
|
66
|
-
case "minutes":
|
|
67
|
-
case "minute":
|
|
68
|
-
case "mins":
|
|
69
|
-
case "min":
|
|
70
|
-
case "m":
|
|
71
|
-
return n * m;
|
|
72
|
-
case "seconds":
|
|
73
|
-
case "second":
|
|
74
|
-
case "secs":
|
|
75
|
-
case "sec":
|
|
76
|
-
case "s":
|
|
77
|
-
return n * s;
|
|
78
|
-
case "milliseconds":
|
|
79
|
-
case "millisecond":
|
|
80
|
-
case "msecs":
|
|
81
|
-
case "msec":
|
|
82
|
-
case "ms":
|
|
83
|
-
return n;
|
|
84
|
-
default:
|
|
85
|
-
return void 0;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function fmtShort(ms2) {
|
|
89
|
-
var msAbs = Math.abs(ms2);
|
|
90
|
-
if (msAbs >= d) {
|
|
91
|
-
return Math.round(ms2 / d) + "d";
|
|
92
|
-
}
|
|
93
|
-
if (msAbs >= h) {
|
|
94
|
-
return Math.round(ms2 / h) + "h";
|
|
95
|
-
}
|
|
96
|
-
if (msAbs >= m) {
|
|
97
|
-
return Math.round(ms2 / m) + "m";
|
|
98
|
-
}
|
|
99
|
-
if (msAbs >= s) {
|
|
100
|
-
return Math.round(ms2 / s) + "s";
|
|
101
|
-
}
|
|
102
|
-
return ms2 + "ms";
|
|
103
|
-
}
|
|
104
|
-
function fmtLong(ms2) {
|
|
105
|
-
var msAbs = Math.abs(ms2);
|
|
106
|
-
if (msAbs >= d) {
|
|
107
|
-
return plural(ms2, msAbs, d, "day");
|
|
108
|
-
}
|
|
109
|
-
if (msAbs >= h) {
|
|
110
|
-
return plural(ms2, msAbs, h, "hour");
|
|
111
|
-
}
|
|
112
|
-
if (msAbs >= m) {
|
|
113
|
-
return plural(ms2, msAbs, m, "minute");
|
|
114
|
-
}
|
|
115
|
-
if (msAbs >= s) {
|
|
116
|
-
return plural(ms2, msAbs, s, "second");
|
|
117
|
-
}
|
|
118
|
-
return ms2 + " ms";
|
|
119
|
-
}
|
|
120
|
-
function plural(ms2, msAbs, n, name) {
|
|
121
|
-
var isPlural = msAbs >= n * 1.5;
|
|
122
|
-
return Math.round(ms2 / n) + " " + name + (isPlural ? "s" : "");
|
|
123
|
-
}
|
|
124
|
-
return ms;
|
|
9
|
+
function _e() {
|
|
10
|
+
_ = null;
|
|
125
11
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
createDebug.default = createDebug;
|
|
134
|
-
createDebug.coerce = coerce;
|
|
135
|
-
createDebug.disable = disable;
|
|
136
|
-
createDebug.enable = enable;
|
|
137
|
-
createDebug.enabled = enabled;
|
|
138
|
-
createDebug.humanize = requireMs();
|
|
139
|
-
Object.keys(env).forEach(function(key) {
|
|
140
|
-
createDebug[key] = env[key];
|
|
141
|
-
});
|
|
142
|
-
createDebug.instances = [];
|
|
143
|
-
createDebug.names = [];
|
|
144
|
-
createDebug.skips = [];
|
|
145
|
-
createDebug.formatters = {};
|
|
146
|
-
function selectColor(namespace) {
|
|
147
|
-
var hash = 0;
|
|
148
|
-
for (var i = 0; i < namespace.length; i++) {
|
|
149
|
-
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
150
|
-
hash |= 0;
|
|
151
|
-
}
|
|
152
|
-
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
153
|
-
}
|
|
154
|
-
createDebug.selectColor = selectColor;
|
|
155
|
-
function createDebug(namespace) {
|
|
156
|
-
var prevTime;
|
|
157
|
-
function debug2() {
|
|
158
|
-
if (!debug2.enabled) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
162
|
-
args[_key] = arguments[_key];
|
|
163
|
-
}
|
|
164
|
-
var self = debug2;
|
|
165
|
-
var curr = Number(/* @__PURE__ */ new Date());
|
|
166
|
-
var ms2 = curr - (prevTime || curr);
|
|
167
|
-
self.diff = ms2;
|
|
168
|
-
self.prev = prevTime;
|
|
169
|
-
self.curr = curr;
|
|
170
|
-
prevTime = curr;
|
|
171
|
-
args[0] = createDebug.coerce(args[0]);
|
|
172
|
-
if (typeof args[0] !== "string") {
|
|
173
|
-
args.unshift("%O");
|
|
174
|
-
}
|
|
175
|
-
var index = 0;
|
|
176
|
-
args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
|
|
177
|
-
if (match === "%%") {
|
|
178
|
-
return match;
|
|
179
|
-
}
|
|
180
|
-
index++;
|
|
181
|
-
var formatter = createDebug.formatters[format];
|
|
182
|
-
if (typeof formatter === "function") {
|
|
183
|
-
var val = args[index];
|
|
184
|
-
match = formatter.call(self, val);
|
|
185
|
-
args.splice(index, 1);
|
|
186
|
-
index--;
|
|
187
|
-
}
|
|
188
|
-
return match;
|
|
189
|
-
});
|
|
190
|
-
createDebug.formatArgs.call(self, args);
|
|
191
|
-
var logFn = self.log || createDebug.log;
|
|
192
|
-
logFn.apply(self, args);
|
|
193
|
-
}
|
|
194
|
-
debug2.namespace = namespace;
|
|
195
|
-
debug2.enabled = createDebug.enabled(namespace);
|
|
196
|
-
debug2.useColors = createDebug.useColors();
|
|
197
|
-
debug2.color = selectColor(namespace);
|
|
198
|
-
debug2.destroy = destroy;
|
|
199
|
-
debug2.extend = extend;
|
|
200
|
-
if (typeof createDebug.init === "function") {
|
|
201
|
-
createDebug.init(debug2);
|
|
202
|
-
}
|
|
203
|
-
createDebug.instances.push(debug2);
|
|
204
|
-
return debug2;
|
|
205
|
-
}
|
|
206
|
-
function destroy() {
|
|
207
|
-
var index = createDebug.instances.indexOf(this);
|
|
208
|
-
if (index !== -1) {
|
|
209
|
-
createDebug.instances.splice(index, 1);
|
|
210
|
-
return true;
|
|
211
|
-
}
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
function extend(namespace, delimiter) {
|
|
215
|
-
return createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
216
|
-
}
|
|
217
|
-
function enable(namespaces) {
|
|
218
|
-
createDebug.save(namespaces);
|
|
219
|
-
createDebug.names = [];
|
|
220
|
-
createDebug.skips = [];
|
|
221
|
-
var i;
|
|
222
|
-
var split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/);
|
|
223
|
-
var len = split.length;
|
|
224
|
-
for (i = 0; i < len; i++) {
|
|
225
|
-
if (!split[i]) {
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
228
|
-
namespaces = split[i].replace(/\*/g, ".*?");
|
|
229
|
-
if (namespaces[0] === "-") {
|
|
230
|
-
createDebug.skips.push(new RegExp("^" + namespaces.substr(1) + "$"));
|
|
231
|
-
} else {
|
|
232
|
-
createDebug.names.push(new RegExp("^" + namespaces + "$"));
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
for (i = 0; i < createDebug.instances.length; i++) {
|
|
236
|
-
var instance = createDebug.instances[i];
|
|
237
|
-
instance.enabled = createDebug.enabled(instance.namespace);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
function disable() {
|
|
241
|
-
createDebug.enable("");
|
|
242
|
-
}
|
|
243
|
-
function enabled(name) {
|
|
244
|
-
if (name[name.length - 1] === "*") {
|
|
245
|
-
return true;
|
|
246
|
-
}
|
|
247
|
-
var i;
|
|
248
|
-
var len;
|
|
249
|
-
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
|
250
|
-
if (createDebug.skips[i].test(name)) {
|
|
251
|
-
return false;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
|
255
|
-
if (createDebug.names[i].test(name)) {
|
|
256
|
-
return true;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
return false;
|
|
260
|
-
}
|
|
261
|
-
function coerce(val) {
|
|
262
|
-
if (val instanceof Error) {
|
|
263
|
-
return val.stack || val.message;
|
|
264
|
-
}
|
|
265
|
-
return val;
|
|
12
|
+
function C(o) {
|
|
13
|
+
const t = (...e) => {
|
|
14
|
+
_ && _.test(o) && console.log(`[${o}]`, ...e);
|
|
15
|
+
};
|
|
16
|
+
return Object.defineProperty(t, "enabled", {
|
|
17
|
+
get() {
|
|
18
|
+
return !!(_ && _.test(o));
|
|
266
19
|
}
|
|
267
|
-
|
|
268
|
-
return createDebug;
|
|
269
|
-
}
|
|
270
|
-
common = setup;
|
|
271
|
-
return common;
|
|
20
|
+
}), t;
|
|
272
21
|
}
|
|
273
|
-
|
|
274
|
-
function
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
return typeof obj2;
|
|
282
|
-
};
|
|
283
|
-
} else {
|
|
284
|
-
_typeof = function _typeof2(obj2) {
|
|
285
|
-
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
return _typeof(obj);
|
|
289
|
-
}
|
|
290
|
-
exports.log = log;
|
|
291
|
-
exports.formatArgs = formatArgs;
|
|
292
|
-
exports.save = save;
|
|
293
|
-
exports.load = load;
|
|
294
|
-
exports.useColors = useColors;
|
|
295
|
-
exports.storage = localstorage();
|
|
296
|
-
exports.colors = ["#0000CC", "#0000FF", "#0033CC", "#0033FF", "#0066CC", "#0066FF", "#0099CC", "#0099FF", "#00CC00", "#00CC33", "#00CC66", "#00CC99", "#00CCCC", "#00CCFF", "#3300CC", "#3300FF", "#3333CC", "#3333FF", "#3366CC", "#3366FF", "#3399CC", "#3399FF", "#33CC00", "#33CC33", "#33CC66", "#33CC99", "#33CCCC", "#33CCFF", "#6600CC", "#6600FF", "#6633CC", "#6633FF", "#66CC00", "#66CC33", "#9900CC", "#9900FF", "#9933CC", "#9933FF", "#99CC00", "#99CC33", "#CC0000", "#CC0033", "#CC0066", "#CC0099", "#CC00CC", "#CC00FF", "#CC3300", "#CC3333", "#CC3366", "#CC3399", "#CC33CC", "#CC33FF", "#CC6600", "#CC6633", "#CC9900", "#CC9933", "#CCCC00", "#CCCC33", "#FF0000", "#FF0033", "#FF0066", "#FF0099", "#FF00CC", "#FF00FF", "#FF3300", "#FF3333", "#FF3366", "#FF3399", "#FF33CC", "#FF33FF", "#FF6600", "#FF6633", "#FF9900", "#FF9933", "#FFCC00", "#FFCC33"];
|
|
297
|
-
function useColors() {
|
|
298
|
-
if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
|
|
299
|
-
return true;
|
|
300
|
-
}
|
|
301
|
-
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
302
|
-
return false;
|
|
303
|
-
}
|
|
304
|
-
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
|
305
|
-
typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
|
306
|
-
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
307
|
-
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
|
308
|
-
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
309
|
-
}
|
|
310
|
-
function formatArgs(args) {
|
|
311
|
-
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
|
|
312
|
-
if (!this.useColors) {
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
var c = "color: " + this.color;
|
|
316
|
-
args.splice(1, 0, c, "color: inherit");
|
|
317
|
-
var index = 0;
|
|
318
|
-
var lastC = 0;
|
|
319
|
-
args[0].replace(/%[a-zA-Z%]/g, function(match) {
|
|
320
|
-
if (match === "%%") {
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
index++;
|
|
324
|
-
if (match === "%c") {
|
|
325
|
-
lastC = index;
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
args.splice(lastC, 0, c);
|
|
329
|
-
}
|
|
330
|
-
function log() {
|
|
331
|
-
var _console;
|
|
332
|
-
return (typeof console === "undefined" ? "undefined" : _typeof(console)) === "object" && console.log && (_console = console).log.apply(_console, arguments);
|
|
333
|
-
}
|
|
334
|
-
function save(namespaces) {
|
|
335
|
-
try {
|
|
336
|
-
if (namespaces) {
|
|
337
|
-
exports.storage.setItem("debug", namespaces);
|
|
338
|
-
} else {
|
|
339
|
-
exports.storage.removeItem("debug");
|
|
340
|
-
}
|
|
341
|
-
} catch (error) {
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
function load() {
|
|
345
|
-
var r;
|
|
346
|
-
try {
|
|
347
|
-
r = exports.storage.getItem("debug");
|
|
348
|
-
} catch (error) {
|
|
349
|
-
}
|
|
350
|
-
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
351
|
-
r = process.env.DEBUG;
|
|
352
|
-
}
|
|
353
|
-
return r;
|
|
354
|
-
}
|
|
355
|
-
function localstorage() {
|
|
356
|
-
try {
|
|
357
|
-
return localStorage;
|
|
358
|
-
} catch (error) {
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
module.exports = requireCommon()(exports);
|
|
362
|
-
var formatters = module.exports.formatters;
|
|
363
|
-
formatters.j = function(v) {
|
|
364
|
-
try {
|
|
365
|
-
return JSON.stringify(v);
|
|
366
|
-
} catch (error) {
|
|
367
|
-
return "[UnexpectedJSONParseError]: " + error.message;
|
|
368
|
-
}
|
|
369
|
-
};
|
|
370
|
-
})(browser, browser.exports);
|
|
371
|
-
return browser.exports;
|
|
22
|
+
const A = C("squatch-js");
|
|
23
|
+
function V(o) {
|
|
24
|
+
const t = document.cookie.match(
|
|
25
|
+
new RegExp(
|
|
26
|
+
"(?:^|; )" + o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + "=([^;]*)"
|
|
27
|
+
)
|
|
28
|
+
);
|
|
29
|
+
return t ? decodeURIComponent(t[1]) : void 0;
|
|
372
30
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
var source = arguments[i];
|
|
379
|
-
for (var key in source) {
|
|
380
|
-
target[key] = source[key];
|
|
381
|
-
}
|
|
31
|
+
function ke(o, t, e) {
|
|
32
|
+
let n = `${encodeURIComponent(o)}=${encodeURIComponent(t)}`;
|
|
33
|
+
{
|
|
34
|
+
const i = /* @__PURE__ */ new Date();
|
|
35
|
+
i.setTime(i.getTime() + e.expires * 864e5), n += `; expires=${i.toUTCString()}`;
|
|
382
36
|
}
|
|
383
|
-
|
|
37
|
+
e.path && (n += `; path=${e.path}`), e.domain && (n += `; domain=${e.domain}`), e.sameSite && (n += `; SameSite=${e.sameSite}`), document.cookie = n;
|
|
384
38
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
return encodeURIComponent(value).replace(
|
|
394
|
-
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
|
|
395
|
-
decodeURIComponent
|
|
396
|
-
);
|
|
397
|
-
}
|
|
39
|
+
const se = (o) => typeof o == "object" && !Array.isArray(o), ce = (o, t) => {
|
|
40
|
+
const e = (i) => se(t[i]) && o.hasOwnProperty(i) && se(o[i]), n = Object.getOwnPropertyNames(t).map((i) => ({
|
|
41
|
+
[i]: e(i) ? ce(o[i], t[i]) : t[i]
|
|
42
|
+
})).reduce((i, s) => ({ ...i, ...s }), {});
|
|
43
|
+
return {
|
|
44
|
+
...o,
|
|
45
|
+
...n
|
|
46
|
+
};
|
|
398
47
|
};
|
|
399
|
-
function
|
|
400
|
-
|
|
401
|
-
|
|
48
|
+
function L(o) {
|
|
49
|
+
const t = atob(o.replace(/_/g, "/").replace(/-/g, "+")), e = new Uint8Array(t.length);
|
|
50
|
+
for (let n = 0; n < t.length; n++)
|
|
51
|
+
e[n] = t.charCodeAt(n);
|
|
52
|
+
return new TextDecoder("utf8").decode(e);
|
|
53
|
+
}
|
|
54
|
+
function re(o) {
|
|
55
|
+
const t = new TextEncoder().encode(o), e = Array.from(
|
|
56
|
+
t,
|
|
57
|
+
(n) => String.fromCodePoint(n)
|
|
58
|
+
).join("");
|
|
59
|
+
return btoa(e).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
60
|
+
}
|
|
61
|
+
function Se() {
|
|
62
|
+
var o, t, e = "weird_get_top_level_domain=cookie", n = document.location.hostname.split(".");
|
|
63
|
+
for (o = n.length - 1; o >= 0; o--)
|
|
64
|
+
if (t = n.slice(o).join("."), document.cookie = e + ";domain=." + t + ";", document.cookie.indexOf(e) > -1)
|
|
65
|
+
return document.cookie = e.split("=")[0] + "=;domain=." + t + ";expires=Thu, 01 Jan 1970 00:00:01 GMT;", t;
|
|
66
|
+
}
|
|
67
|
+
function Te() {
|
|
68
|
+
const o = window.location.search, e = new URLSearchParams(o).get("_saasquatch") || "";
|
|
69
|
+
if (e) {
|
|
70
|
+
let n = "", i = "", s = "";
|
|
71
|
+
try {
|
|
72
|
+
n = JSON.parse(L(e));
|
|
73
|
+
} catch (r) {
|
|
74
|
+
A("Unable to decode params", r);
|
|
402
75
|
return;
|
|
403
76
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
if (attributes.expires) {
|
|
409
|
-
attributes.expires = attributes.expires.toUTCString();
|
|
77
|
+
try {
|
|
78
|
+
i = JSON.parse(L(V("_saasquatch"))), A("existing cookie", i);
|
|
79
|
+
} catch (r) {
|
|
80
|
+
A("Unable to retrieve cookie", r);
|
|
410
81
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
82
|
+
try {
|
|
83
|
+
const r = Se();
|
|
84
|
+
if (A("domain retrieved:", r), i) {
|
|
85
|
+
const a = ce(i, n);
|
|
86
|
+
s = re(JSON.stringify(a)), A("cookie to store:", a);
|
|
87
|
+
} else
|
|
88
|
+
s = re(JSON.stringify(n)), A("cookie to store:", n);
|
|
89
|
+
ke("_saasquatch", s, {
|
|
90
|
+
expires: 365,
|
|
91
|
+
secure: !1,
|
|
92
|
+
sameSite: "Lax",
|
|
93
|
+
domain: r,
|
|
94
|
+
path: "/"
|
|
95
|
+
});
|
|
96
|
+
} catch (r) {
|
|
97
|
+
A("Unable to set cookie", r);
|
|
422
98
|
}
|
|
423
|
-
return document.cookie = name + "=" + converter.write(value, name) + stringifiedAttributes;
|
|
424
99
|
}
|
|
425
|
-
function get(name) {
|
|
426
|
-
if (typeof document === "undefined" || arguments.length && !name) {
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
var cookies = document.cookie ? document.cookie.split("; ") : [];
|
|
430
|
-
var jar = {};
|
|
431
|
-
for (var i = 0; i < cookies.length; i++) {
|
|
432
|
-
var parts = cookies[i].split("=");
|
|
433
|
-
var value = parts.slice(1).join("=");
|
|
434
|
-
try {
|
|
435
|
-
var found = decodeURIComponent(parts[0]);
|
|
436
|
-
jar[found] = converter.read(value, found);
|
|
437
|
-
if (name === found) {
|
|
438
|
-
break;
|
|
439
|
-
}
|
|
440
|
-
} catch (e) {
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
return name ? jar[name] : jar;
|
|
444
|
-
}
|
|
445
|
-
return Object.create(
|
|
446
|
-
{
|
|
447
|
-
set,
|
|
448
|
-
get,
|
|
449
|
-
remove: function(name, attributes) {
|
|
450
|
-
set(
|
|
451
|
-
name,
|
|
452
|
-
"",
|
|
453
|
-
assign({}, attributes, {
|
|
454
|
-
expires: -1
|
|
455
|
-
})
|
|
456
|
-
);
|
|
457
|
-
},
|
|
458
|
-
withAttributes: function(attributes) {
|
|
459
|
-
return init$1(this.converter, assign({}, this.attributes, attributes));
|
|
460
|
-
},
|
|
461
|
-
withConverter: function(converter2) {
|
|
462
|
-
return init$1(assign({}, this.converter, converter2), this.attributes);
|
|
463
|
-
}
|
|
464
|
-
},
|
|
465
|
-
{
|
|
466
|
-
attributes: { value: Object.freeze(defaultAttributes) },
|
|
467
|
-
converter: { value: Object.freeze(converter) }
|
|
468
|
-
}
|
|
469
|
-
);
|
|
470
100
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
const config = getConfig();
|
|
480
|
-
const raw = {
|
|
481
|
-
tenantAlias: (_raw == null ? void 0 : _raw["tenantAlias"]) || tenant,
|
|
482
|
-
domain: (_raw == null ? void 0 : _raw["domain"]) || (config == null ? void 0 : config.domain),
|
|
483
|
-
npmCdn: (_raw == null ? void 0 : _raw["npmCdn"]) || (config == null ? void 0 : config.npmCdn),
|
|
484
|
-
debug: (_raw == null ? void 0 : _raw["debug"]) || (config == null ? void 0 : config.debug)
|
|
101
|
+
const k = "https://app.referralsaasquatch.com", X = "https://fast.ssqt.io/npm", M = "squatch", z = "impact";
|
|
102
|
+
function q(o) {
|
|
103
|
+
if (typeof o != "object") throw new Error("config must be an object");
|
|
104
|
+
const t = window.squatchTenant, e = Y(), n = {
|
|
105
|
+
tenantAlias: (o == null ? void 0 : o.tenantAlias) || t,
|
|
106
|
+
domain: (o == null ? void 0 : o.domain) || (e == null ? void 0 : e.domain),
|
|
107
|
+
npmCdn: (o == null ? void 0 : o.npmCdn) || (e == null ? void 0 : e.npmCdn),
|
|
108
|
+
debug: (o == null ? void 0 : o.debug) || (e == null ? void 0 : e.debug)
|
|
485
109
|
};
|
|
486
|
-
if (typeof
|
|
110
|
+
if (typeof n.tenantAlias != "string")
|
|
487
111
|
throw new Error("tenantAlias not provided");
|
|
488
|
-
const tenantAlias =
|
|
489
|
-
const domain = typeof raw.domain === "string" && raw.domain || DEFAULT_DOMAIN;
|
|
490
|
-
const debug2 = typeof raw.debug === "boolean" && raw.debug || false;
|
|
491
|
-
const npmCdn = typeof raw.npmCdn === "string" && raw.npmCdn || DEFAULT_NPM_CDN;
|
|
112
|
+
const i = n.tenantAlias, s = typeof n.domain == "string" && n.domain || k, r = typeof n.debug == "boolean" && n.debug || !1, a = typeof n.npmCdn == "string" && n.npmCdn || X;
|
|
492
113
|
return {
|
|
493
|
-
tenantAlias,
|
|
494
|
-
domain,
|
|
495
|
-
debug:
|
|
496
|
-
npmCdn
|
|
114
|
+
tenantAlias: i,
|
|
115
|
+
domain: s,
|
|
116
|
+
debug: r,
|
|
117
|
+
npmCdn: a
|
|
497
118
|
};
|
|
498
119
|
}
|
|
499
|
-
function
|
|
500
|
-
return typeof
|
|
120
|
+
function S(o) {
|
|
121
|
+
return typeof o == "object" && !Array.isArray(o) && o !== null;
|
|
501
122
|
}
|
|
502
|
-
function
|
|
503
|
-
if (
|
|
504
|
-
return
|
|
505
|
-
}
|
|
123
|
+
function $e(o) {
|
|
124
|
+
if (o && /^[a-z]{2}_(?:[A-Z]{2}|[0-9]{3})$/.test(o))
|
|
125
|
+
return o;
|
|
506
126
|
}
|
|
507
|
-
function
|
|
508
|
-
if (!
|
|
509
|
-
if (!(
|
|
510
|
-
return
|
|
127
|
+
function de(o) {
|
|
128
|
+
if (!S(o)) throw new Error("Widget properties must be an object");
|
|
129
|
+
if (!(o != null && o.user)) throw new Error("Required properties missing.");
|
|
130
|
+
return o;
|
|
511
131
|
}
|
|
512
|
-
function
|
|
513
|
-
if (!
|
|
514
|
-
return
|
|
132
|
+
function le(o) {
|
|
133
|
+
if (!S(o)) throw new Error("Widget properties must be an object");
|
|
134
|
+
return o;
|
|
515
135
|
}
|
|
516
|
-
function
|
|
136
|
+
function W() {
|
|
517
137
|
return window.impactToken || window.squatchToken;
|
|
518
138
|
}
|
|
519
|
-
function
|
|
139
|
+
function Y() {
|
|
520
140
|
return window.impactConfig || window.squatchConfig;
|
|
521
141
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
142
|
+
const he = C("squatch-js:io");
|
|
143
|
+
function B(o) {
|
|
144
|
+
let t, e, n, i = o;
|
|
145
|
+
try {
|
|
146
|
+
const r = JSON.parse(o);
|
|
147
|
+
r && typeof r == "object" && (t = r.apiErrorCode, e = r.rsCode, n = r.statusCode, i = r.message || o);
|
|
148
|
+
} catch {
|
|
149
|
+
}
|
|
150
|
+
const s = new Error(i);
|
|
151
|
+
return t && (s.apiErrorCode = t), e && (s.rsCode = e), n !== void 0 && (s.statusCode = n), s;
|
|
152
|
+
}
|
|
153
|
+
async function xe(o, t, e, n) {
|
|
154
|
+
const i = n || W(), s = {
|
|
526
155
|
Accept: "application/json",
|
|
527
156
|
"Content-Type": "application/json",
|
|
528
|
-
...
|
|
157
|
+
...i ? { Authorization: `Bearer ${i}` } : {},
|
|
529
158
|
"X-SaaSquatch-Referrer": window ? window.location.href : ""
|
|
530
159
|
};
|
|
531
160
|
try {
|
|
532
|
-
const
|
|
161
|
+
const r = await fetch(o, {
|
|
533
162
|
method: "POST",
|
|
534
|
-
body: JSON.stringify({ query, variables }),
|
|
535
|
-
headers
|
|
163
|
+
body: JSON.stringify({ query: t, variables: e }),
|
|
164
|
+
headers: s
|
|
536
165
|
});
|
|
537
|
-
if (!
|
|
538
|
-
return await
|
|
539
|
-
} catch (
|
|
540
|
-
throw
|
|
166
|
+
if (!r.ok) throw B(await r.text());
|
|
167
|
+
return await r.json();
|
|
168
|
+
} catch (r) {
|
|
169
|
+
throw r;
|
|
541
170
|
}
|
|
542
171
|
}
|
|
543
|
-
async function
|
|
544
|
-
const
|
|
172
|
+
async function qe(o, t = "") {
|
|
173
|
+
const e = {
|
|
545
174
|
Accept: "application/json",
|
|
546
175
|
"Content-Type": "application/json"
|
|
547
|
-
};
|
|
548
|
-
|
|
549
|
-
|
|
176
|
+
}, n = t || W();
|
|
177
|
+
n ? e["X-SaaSquatch-User-Token"] = n : he(
|
|
178
|
+
"[DEBUG] doGet - No token found, proceeding without authentication header."
|
|
179
|
+
);
|
|
550
180
|
try {
|
|
551
|
-
const
|
|
181
|
+
const i = await fetch(o, {
|
|
552
182
|
method: "GET",
|
|
553
183
|
credentials: "include",
|
|
554
|
-
headers
|
|
555
|
-
});
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
throw e;
|
|
184
|
+
headers: e
|
|
185
|
+
}), s = await i.text();
|
|
186
|
+
if (!i.ok) throw B(s);
|
|
187
|
+
return s && JSON.parse(s);
|
|
188
|
+
} catch (i) {
|
|
189
|
+
throw i;
|
|
561
190
|
}
|
|
562
191
|
}
|
|
563
|
-
async function
|
|
564
|
-
const
|
|
192
|
+
async function Q(o, t, e) {
|
|
193
|
+
const n = {
|
|
565
194
|
Accept: "application/json",
|
|
566
195
|
"Content-Type": "application/json"
|
|
567
|
-
};
|
|
568
|
-
|
|
569
|
-
|
|
196
|
+
}, i = e || W();
|
|
197
|
+
i ? n["X-SaaSquatch-User-Token"] = i : he(
|
|
198
|
+
"[DEBUG] doPost - No token found, proceeding without authentication header."
|
|
199
|
+
);
|
|
570
200
|
try {
|
|
571
|
-
const
|
|
201
|
+
const s = await fetch(o, {
|
|
572
202
|
method: "POST",
|
|
573
|
-
body:
|
|
574
|
-
headers
|
|
575
|
-
});
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
throw e;
|
|
203
|
+
body: t,
|
|
204
|
+
headers: n
|
|
205
|
+
}), r = await s.text();
|
|
206
|
+
if (!s.ok) throw B(r);
|
|
207
|
+
return r && JSON.parse(r);
|
|
208
|
+
} catch (s) {
|
|
209
|
+
throw s;
|
|
581
210
|
}
|
|
582
211
|
}
|
|
583
|
-
async function
|
|
584
|
-
const
|
|
212
|
+
async function We(o, t, e) {
|
|
213
|
+
const n = {
|
|
585
214
|
Accept: "application/json",
|
|
586
215
|
"Content-Type": "application/json",
|
|
587
216
|
"X-SaaSquatch-Referrer": window ? window.location.href : ""
|
|
588
|
-
};
|
|
589
|
-
|
|
590
|
-
if (token) headers["X-SaaSquatch-User-Token"] = token;
|
|
217
|
+
}, i = e || W();
|
|
218
|
+
i && (n["X-SaaSquatch-User-Token"] = i);
|
|
591
219
|
try {
|
|
592
|
-
const
|
|
593
|
-
headers,
|
|
220
|
+
const s = await fetch(o, {
|
|
221
|
+
headers: n,
|
|
594
222
|
method: "PUT",
|
|
595
223
|
credentials: "include",
|
|
596
|
-
body:
|
|
597
|
-
});
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
throw e;
|
|
224
|
+
body: t
|
|
225
|
+
}), r = await s.text();
|
|
226
|
+
if (!s.ok) throw B(r);
|
|
227
|
+
return r && JSON.parse(r);
|
|
228
|
+
} catch (s) {
|
|
229
|
+
throw s;
|
|
603
230
|
}
|
|
604
231
|
}
|
|
605
|
-
const
|
|
232
|
+
const Me = `
|
|
606
233
|
query renderWidget ($user: UserIdInput, $engagementMedium: UserEngagementMedium, $widgetType: WidgetType, $locale: RSLocale) {
|
|
607
234
|
renderWidget(user: $user, engagementMedium: $engagementMedium, widgetType: $widgetType, locale: $locale) {
|
|
608
235
|
template
|
|
@@ -617,7 +244,7 @@ const RENDER_WIDGET_QUERY = `
|
|
|
617
244
|
}
|
|
618
245
|
}
|
|
619
246
|
`;
|
|
620
|
-
class
|
|
247
|
+
class Z {
|
|
621
248
|
/**
|
|
622
249
|
* Initialize a new {@link WidgetApi} instance.
|
|
623
250
|
*
|
|
@@ -634,16 +261,13 @@ class WidgetApi {
|
|
|
634
261
|
* import {WidgetApi} from '@saasquatch/squatch-js';
|
|
635
262
|
* let squatchApi = new WidgetApi({tenantAlias:'test_12b5bo1b25125'});
|
|
636
263
|
*/
|
|
637
|
-
constructor(
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
const
|
|
643
|
-
|
|
644
|
-
this.tenantAlias = clean.tenantAlias;
|
|
645
|
-
this.domain = clean.domain;
|
|
646
|
-
this.npmCdn = clean.npmCdn;
|
|
264
|
+
constructor(t) {
|
|
265
|
+
l(this, "tenantAlias");
|
|
266
|
+
l(this, "domain");
|
|
267
|
+
l(this, "npmCdn");
|
|
268
|
+
l(this, "referralCookie", this.squatchReferralCookie);
|
|
269
|
+
const n = q(t);
|
|
270
|
+
this.tenantAlias = n.tenantAlias, this.domain = n.domain, this.npmCdn = n.npmCdn;
|
|
647
271
|
}
|
|
648
272
|
/**
|
|
649
273
|
* Creates/upserts user, requests widget template.
|
|
@@ -659,29 +283,19 @@ class WidgetApi {
|
|
|
659
283
|
*
|
|
660
284
|
* @return {Promise} string if true, with the widget template, jsOptions and user details.
|
|
661
285
|
*/
|
|
662
|
-
upsertUser(
|
|
663
|
-
const
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
const optionalParams = _buildParams({
|
|
676
|
-
widgetType,
|
|
677
|
-
engagementMedium,
|
|
678
|
-
locale
|
|
679
|
-
});
|
|
680
|
-
const path = `/api/v1/${tenantAlias}/widget/account/${accountId}/user/${userId}/upsert${optionalParams}`;
|
|
681
|
-
const url = this.domain + path;
|
|
682
|
-
const cookies = (api$1 || window.Cookies).get("_saasquatch");
|
|
683
|
-
if (cookies) user["cookies"] = cookies;
|
|
684
|
-
return doPut(url, JSON.stringify(user), jwt);
|
|
286
|
+
upsertUser(t) {
|
|
287
|
+
const n = de(t), {
|
|
288
|
+
widgetType: i,
|
|
289
|
+
engagementMedium: s = "POPUP",
|
|
290
|
+
jwt: r,
|
|
291
|
+
locale: a,
|
|
292
|
+
user: c
|
|
293
|
+
} = n, d = encodeURIComponent(this.tenantAlias), h = c.accountId ? encodeURIComponent(c.accountId) : null, u = c.id ? encodeURIComponent(c.id) : null, m = Ue({
|
|
294
|
+
widgetType: i,
|
|
295
|
+
engagementMedium: s,
|
|
296
|
+
locale: a
|
|
297
|
+
}), p = `/api/v1/${d}/widget/account/${h}/user/${u}/upsert${m}`, g = this.domain + p, f = V("_saasquatch");
|
|
298
|
+
return f && (c.cookies = f), We(g, JSON.stringify(c), r);
|
|
685
299
|
}
|
|
686
300
|
/**
|
|
687
301
|
* Requests widget template
|
|
@@ -696,34 +310,25 @@ class WidgetApi {
|
|
|
696
310
|
* to validate the data (can be disabled)
|
|
697
311
|
* @return {Promise} template html if true.
|
|
698
312
|
*/
|
|
699
|
-
render(
|
|
700
|
-
const
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
console.log({ params });
|
|
704
|
-
const tenantAlias = encodeURIComponent(this.tenantAlias);
|
|
705
|
-
const accountId = (user == null ? void 0 : user.accountId) ? encodeURIComponent(user.accountId) : null;
|
|
706
|
-
const userId = (user == null ? void 0 : user.id) ? encodeURIComponent(user.id) : null;
|
|
707
|
-
const locale = clean.locale ?? validateLocale(navigator.language.replace(/\-/g, "_"));
|
|
708
|
-
const path = `/api/v1/${tenantAlias}/graphql`;
|
|
709
|
-
const url = this.domain + path;
|
|
710
|
-
return new Promise(async (resolve, reject) => {
|
|
711
|
-
var _a2;
|
|
313
|
+
render(t) {
|
|
314
|
+
const n = le(t), { widgetType: i, engagementMedium: s = "POPUP", jwt: r, user: a } = n, c = encodeURIComponent(this.tenantAlias), d = a != null && a.accountId ? encodeURIComponent(a.accountId) : null, h = a != null && a.id ? encodeURIComponent(a.id) : null, u = n.locale ?? $e(navigator.language.replace(/\-/g, "_")), m = `/api/v1/${c}/graphql`, p = this.domain + m;
|
|
315
|
+
return new Promise(async (g, f) => {
|
|
316
|
+
var b;
|
|
712
317
|
try {
|
|
713
|
-
const
|
|
714
|
-
|
|
715
|
-
|
|
318
|
+
const w = await xe(
|
|
319
|
+
p,
|
|
320
|
+
Me,
|
|
716
321
|
{
|
|
717
|
-
user:
|
|
718
|
-
engagementMedium,
|
|
719
|
-
widgetType,
|
|
720
|
-
locale
|
|
322
|
+
user: h && d ? { id: h, accountId: d } : null,
|
|
323
|
+
engagementMedium: s,
|
|
324
|
+
widgetType: i,
|
|
325
|
+
locale: u
|
|
721
326
|
},
|
|
722
|
-
|
|
327
|
+
r
|
|
723
328
|
);
|
|
724
|
-
|
|
725
|
-
} catch (
|
|
726
|
-
|
|
329
|
+
g((b = w == null ? void 0 : w.data) == null ? void 0 : b.renderWidget);
|
|
330
|
+
} catch (w) {
|
|
331
|
+
f(w);
|
|
727
332
|
}
|
|
728
333
|
});
|
|
729
334
|
}
|
|
@@ -733,64 +338,48 @@ class WidgetApi {
|
|
|
733
338
|
* @return {Promise<ReferralCookie>} code referral code if true.
|
|
734
339
|
*/
|
|
735
340
|
async squatchReferralCookie() {
|
|
736
|
-
const
|
|
737
|
-
const _saasquatch = (api$1 || window.Cookies).get("_saasquatch") || "";
|
|
738
|
-
const cookie = _saasquatch ? `?cookies=${encodeURIComponent(_saasquatch)}` : ``;
|
|
739
|
-
const url = `${this.domain}/a/${tenantAlias}/widgets/squatchcookiejson${cookie}`;
|
|
740
|
-
const response = await doGet(url);
|
|
341
|
+
const t = encodeURIComponent(this.tenantAlias), e = V("_saasquatch") || "", n = e ? `?cookies=${encodeURIComponent(e)}` : "", i = `${this.domain}/a/${t}/widgets/squatchcookiejson${n}`, s = await qe(i);
|
|
741
342
|
return Promise.resolve({
|
|
742
|
-
...
|
|
743
|
-
encodedCookie:
|
|
343
|
+
...s,
|
|
344
|
+
encodedCookie: e
|
|
744
345
|
});
|
|
745
346
|
}
|
|
746
347
|
}
|
|
747
|
-
function
|
|
748
|
-
widgetType,
|
|
749
|
-
engagementMedium,
|
|
750
|
-
locale
|
|
348
|
+
function Ue({
|
|
349
|
+
widgetType: o,
|
|
350
|
+
engagementMedium: t,
|
|
351
|
+
locale: e
|
|
751
352
|
}) {
|
|
752
|
-
const
|
|
753
|
-
|
|
754
|
-
if (widgetType) queryParams.append("widgetType", widgetType);
|
|
755
|
-
if (locale) queryParams.append("locale", locale);
|
|
756
|
-
return `?${queryParams.toString()}`;
|
|
353
|
+
const n = new URLSearchParams();
|
|
354
|
+
return n.append("engagementMedium", t), o && n.append("widgetType", o), e && n.append("locale", e), `?${n.toString()}`;
|
|
757
355
|
}
|
|
758
356
|
/*!
|
|
759
357
|
* domready (c) Dustin Diaz 2014 - License MIT
|
|
760
358
|
*
|
|
761
359
|
*/
|
|
762
|
-
function
|
|
763
|
-
let
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
doc.addEventListener(
|
|
771
|
-
domContentLoaded,
|
|
772
|
-
listener = () => {
|
|
773
|
-
doc.removeEventListener(domContentLoaded, listener);
|
|
774
|
-
loaded = true;
|
|
775
|
-
while (listener = fns.shift()) listener();
|
|
776
|
-
}
|
|
777
|
-
);
|
|
778
|
-
return loaded ? setTimeout(fn, 0) : fns.push(fn);
|
|
360
|
+
function x(o, t) {
|
|
361
|
+
let e = [], n, i = o, s = i.documentElement.doScroll, r = "DOMContentLoaded", a = (s ? /^loaded|^c/ : /^loaded|^i|^c/).test(i.readyState);
|
|
362
|
+
return a || i.addEventListener(
|
|
363
|
+
r,
|
|
364
|
+
n = () => {
|
|
365
|
+
for (i.removeEventListener(r, n), a = !0; n = e.shift(); ) n();
|
|
366
|
+
}
|
|
367
|
+
), a ? setTimeout(t, 0) : e.push(t);
|
|
779
368
|
}
|
|
780
|
-
function
|
|
781
|
-
value,
|
|
782
|
-
unit
|
|
369
|
+
function O({
|
|
370
|
+
value: o,
|
|
371
|
+
unit: t
|
|
783
372
|
}) {
|
|
784
|
-
switch (
|
|
373
|
+
switch (t) {
|
|
785
374
|
case "px":
|
|
786
|
-
return `${
|
|
375
|
+
return `${o}px`;
|
|
787
376
|
case "%":
|
|
788
|
-
return `${
|
|
377
|
+
return `${o}%`;
|
|
789
378
|
default:
|
|
790
|
-
return `${
|
|
379
|
+
return `${o}px`;
|
|
791
380
|
}
|
|
792
381
|
}
|
|
793
|
-
class
|
|
382
|
+
class ue {
|
|
794
383
|
/**
|
|
795
384
|
* Initialize a new {@link AnalyticsApi} instance.
|
|
796
385
|
*
|
|
@@ -798,234 +387,191 @@ class AnalyticsApi {
|
|
|
798
387
|
* @param {string} [config.domain='https://app.referralsaasquatch.com'] The server domain.
|
|
799
388
|
*
|
|
800
389
|
*/
|
|
801
|
-
constructor(
|
|
802
|
-
|
|
803
|
-
var
|
|
804
|
-
const
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
const engagementMedium = encodeURIComponent(
|
|
814
|
-
|
|
815
|
-
const path = `/a/${tenantAlias}/widgets/analytics/loaded?externalAccountId=${accountId}&externalUserId=${userId}&engagementMedium=${engagementMedium}${programId}`;
|
|
816
|
-
const url = this.domain + path;
|
|
817
|
-
return doPost(url, JSON.stringify({}));
|
|
818
|
-
}
|
|
819
|
-
pushAnalyticsShareClickedEvent(params) {
|
|
820
|
-
const tenantAlias = encodeURIComponent(params.tenantAlias);
|
|
821
|
-
const accountId = encodeURIComponent(params.externalAccountId);
|
|
822
|
-
const userId = encodeURIComponent(params.externalUserId);
|
|
823
|
-
const engagementMedium = encodeURIComponent(params.engagementMedium);
|
|
824
|
-
const shareMedium = encodeURIComponent(params.shareMedium);
|
|
825
|
-
const path = `/a/${tenantAlias}/widgets/analytics/shared?externalAccountId=${accountId}&externalUserId=${userId}&engagementMedium=${engagementMedium}&shareMedium=${shareMedium}`;
|
|
826
|
-
const url = this.domain + path;
|
|
827
|
-
return doPost(url, JSON.stringify({}));
|
|
390
|
+
constructor(t) {
|
|
391
|
+
l(this, "domain");
|
|
392
|
+
var i;
|
|
393
|
+
const n = Re(t);
|
|
394
|
+
this.domain = (n == null ? void 0 : n.domain) || ((i = Y()) == null ? void 0 : i.domain) || k;
|
|
395
|
+
}
|
|
396
|
+
pushAnalyticsLoadEvent(t) {
|
|
397
|
+
if (!t.externalUserId || !t.externalAccountId) return;
|
|
398
|
+
const e = window.location.search, n = new URLSearchParams(e), i = n == null ? void 0 : n.get("rsShareMedium"), s = encodeURIComponent(t.tenantAlias), r = encodeURIComponent(t.externalAccountId), a = encodeURIComponent(t.externalUserId), c = encodeURIComponent(t.engagementMedium), d = t.programId ? `&programId=${encodeURIComponent(t.programId)}` : "", h = i ? `&shareMedium=${encodeURIComponent(i)}` : "", u = `/a/${s}/widgets/analytics/loaded?externalAccountId=${r}&externalUserId=${a}&engagementMedium=${c}${h}${d}`, m = this.domain + u;
|
|
399
|
+
return Q(m, JSON.stringify({}));
|
|
400
|
+
}
|
|
401
|
+
pushAnalyticsShareClickedEvent(t) {
|
|
402
|
+
const e = encodeURIComponent(t.tenantAlias), n = encodeURIComponent(t.externalAccountId), i = encodeURIComponent(t.externalUserId), s = encodeURIComponent(t.engagementMedium), r = encodeURIComponent(t.shareMedium), a = `/a/${e}/widgets/analytics/shared?externalAccountId=${n}&externalUserId=${i}&engagementMedium=${s}&shareMedium=${r}`, c = this.domain + a;
|
|
403
|
+
return Q(c, JSON.stringify({}));
|
|
828
404
|
}
|
|
829
405
|
}
|
|
830
|
-
function
|
|
831
|
-
if (!
|
|
832
|
-
return
|
|
406
|
+
function Re(o) {
|
|
407
|
+
if (!S(o)) throw new Error("'options' should be an object");
|
|
408
|
+
return o;
|
|
833
409
|
}
|
|
834
|
-
const
|
|
835
|
-
class
|
|
836
|
-
constructor(
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
this.context =
|
|
853
|
-
this.container = ((_a2 = params.context) == null ? void 0 : _a2.container) || params.container;
|
|
410
|
+
const y = C("squatch-js:widget");
|
|
411
|
+
class me {
|
|
412
|
+
constructor(t) {
|
|
413
|
+
l(this, "type");
|
|
414
|
+
l(this, "content");
|
|
415
|
+
l(this, "analyticsApi");
|
|
416
|
+
l(this, "widgetApi");
|
|
417
|
+
l(this, "context");
|
|
418
|
+
l(this, "npmCdn");
|
|
419
|
+
l(this, "container");
|
|
420
|
+
l(this, "loadEventListener", null);
|
|
421
|
+
l(this, "errorInfo");
|
|
422
|
+
var e;
|
|
423
|
+
y("widget initializing ..."), t.content === "error" ? (this.content = "error", this.errorInfo = {
|
|
424
|
+
rsCode: t.rsCode,
|
|
425
|
+
apiErrorCode: t.apiErrorCode,
|
|
426
|
+
statusCode: t.statusCode,
|
|
427
|
+
message: t.errorMessage
|
|
428
|
+
}) : this.content = t.content, this.type = t.type, this.widgetApi = t.api, this.npmCdn = t.npmCdn, this.analyticsApi = new ue({ domain: t.domain }), this.context = t.context, this.container = ((e = t.context) == null ? void 0 : e.container) || t.container;
|
|
854
429
|
}
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
430
|
+
/**
|
|
431
|
+
* Returns the widget content, dynamically loading the error template if needed.
|
|
432
|
+
*/
|
|
433
|
+
async _getContent() {
|
|
434
|
+
if (this.content === "error" && this.errorInfo) {
|
|
435
|
+
const { getErrorTemplate: t } = await import("./ErrorTemplate-DUNm11h9.js");
|
|
436
|
+
return t({
|
|
437
|
+
rsCode: this.errorInfo.rsCode,
|
|
438
|
+
apiErrorCode: this.errorInfo.apiErrorCode,
|
|
439
|
+
statusCode: this.errorInfo.statusCode,
|
|
440
|
+
mode: this._getErrorMode(),
|
|
441
|
+
style: this._getErrorStyle(),
|
|
442
|
+
message: this.errorInfo.message
|
|
443
|
+
});
|
|
869
444
|
}
|
|
870
|
-
|
|
445
|
+
return this.content;
|
|
446
|
+
}
|
|
447
|
+
/** Override in subclasses to customize error template mode */
|
|
448
|
+
_getErrorMode() {
|
|
449
|
+
return "modal";
|
|
450
|
+
}
|
|
451
|
+
/** Override in subclasses to customize error template styles */
|
|
452
|
+
_getErrorStyle() {
|
|
453
|
+
return "";
|
|
454
|
+
}
|
|
455
|
+
_findElement() {
|
|
456
|
+
let t;
|
|
457
|
+
if (typeof this.container == "string" ? (t = document.querySelector(this.container), y("loading widget with selector", t)) : this.container instanceof HTMLElement ? (t = this.container, y("loading widget with container", t)) : this.container ? (t = null, y("container must be an HTMLElement or string", this.container)) : (t = document.querySelector("#squatchembed") || document.querySelector(".squatchembed") || document.querySelector("#impactembed") || document.querySelector(".impactembed"), y("loading widget with default selector", t)), !(t instanceof HTMLElement))
|
|
871
458
|
throw new Error(
|
|
872
459
|
`element with selector '${this.container || "#squatchembed, .squatchembed, #impactembed, or .impactembed"}' not found.'`
|
|
873
460
|
);
|
|
874
|
-
return
|
|
875
|
-
}
|
|
876
|
-
_createFrame(
|
|
877
|
-
const
|
|
878
|
-
|
|
879
|
-
frame.id = "squatchFrame";
|
|
880
|
-
frame.width = "100%";
|
|
881
|
-
frame.src = "about:blank";
|
|
882
|
-
frame.scrolling = "no";
|
|
883
|
-
frame.setAttribute(
|
|
461
|
+
return t;
|
|
462
|
+
}
|
|
463
|
+
_createFrame(t) {
|
|
464
|
+
const e = document.createElement("iframe");
|
|
465
|
+
return e.squatchJsApi = this, e.id = "squatchFrame", e.width = "100%", e.src = "about:blank", e.scrolling = "no", e.setAttribute(
|
|
884
466
|
"style",
|
|
885
|
-
"border: 0; background-color: none; width: 1px; min-width: 100%;"
|
|
886
|
-
);
|
|
887
|
-
if (options == null ? void 0 : options.minWidth) frame.style.minWidth = options.minWidth;
|
|
888
|
-
if (options == null ? void 0 : options.maxWidth) frame.style.maxWidth = options.maxWidth;
|
|
889
|
-
if ((options == null ? void 0 : options.maxWidth) || (options == null ? void 0 : options.minWidth)) {
|
|
890
|
-
frame.style.width = "100%";
|
|
891
|
-
}
|
|
892
|
-
if (options == null ? void 0 : options.initialHeight) {
|
|
893
|
-
frame.height = options.initialHeight;
|
|
894
|
-
}
|
|
895
|
-
return frame;
|
|
467
|
+
"border: 0; background-color: none; width: 1px; min-width: 100%; display: block;"
|
|
468
|
+
), t != null && t.minWidth && (e.style.minWidth = t.minWidth), t != null && t.maxWidth && (e.style.maxWidth = t.maxWidth), (t != null && t.maxWidth || t != null && t.minWidth) && (e.style.width = "100%"), t != null && t.initialHeight && (e.height = String(t.initialHeight)), e;
|
|
896
469
|
}
|
|
897
470
|
_findFrame() {
|
|
898
|
-
const
|
|
899
|
-
|
|
900
|
-
return parent.querySelector(
|
|
471
|
+
const t = this.container ? this._findElement() : document.body;
|
|
472
|
+
return (t.shadowRoot || t).querySelector(
|
|
901
473
|
"iframe#squatchFrame"
|
|
902
474
|
);
|
|
903
475
|
}
|
|
904
|
-
_detachLoadEventListener(
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
userId: e.detail.userId,
|
|
919
|
-
accountId: e.detail.accountId
|
|
920
|
-
});
|
|
921
|
-
};
|
|
922
|
-
frameDoc.addEventListener("sq:user-registration", this.loadEventListener);
|
|
923
|
-
}
|
|
476
|
+
_detachLoadEventListener(t) {
|
|
477
|
+
this.loadEventListener && (t.removeEventListener(
|
|
478
|
+
"sq:user-registration",
|
|
479
|
+
this.loadEventListener
|
|
480
|
+
), this.loadEventListener = null);
|
|
481
|
+
}
|
|
482
|
+
_attachLoadEventListener(t, e) {
|
|
483
|
+
this.loadEventListener === null && (this.loadEventListener = (n) => {
|
|
484
|
+
this._loadEvent({
|
|
485
|
+
...e,
|
|
486
|
+
userId: n.detail.userId,
|
|
487
|
+
accountId: n.detail.accountId
|
|
488
|
+
});
|
|
489
|
+
}, t.addEventListener("sq:user-registration", this.loadEventListener));
|
|
924
490
|
}
|
|
925
|
-
_loadEvent(
|
|
926
|
-
var
|
|
927
|
-
if (!
|
|
928
|
-
if (!
|
|
491
|
+
_loadEvent(t) {
|
|
492
|
+
var n;
|
|
493
|
+
if (!t) return;
|
|
494
|
+
if (!S(t))
|
|
929
495
|
throw new Error("Widget Load event identity property is not an object");
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
if (!sqh.tenantAlias || !sqh.accountId || !sqh.userId || !sqh.engagementMedium)
|
|
496
|
+
let e;
|
|
497
|
+
if ("programId" in t) {
|
|
498
|
+
if (!t.tenantAlias || !t.accountId || !t.userId || !t.engagementMedium)
|
|
934
499
|
throw new Error("Widget Load event missing required properties");
|
|
935
|
-
|
|
936
|
-
tenantAlias:
|
|
937
|
-
externalAccountId:
|
|
938
|
-
externalUserId:
|
|
939
|
-
engagementMedium:
|
|
940
|
-
programId:
|
|
500
|
+
e = {
|
|
501
|
+
tenantAlias: t.tenantAlias,
|
|
502
|
+
externalAccountId: t.accountId,
|
|
503
|
+
externalUserId: t.userId,
|
|
504
|
+
engagementMedium: t.engagementMedium,
|
|
505
|
+
programId: t.programId
|
|
941
506
|
};
|
|
942
507
|
} else {
|
|
943
|
-
const { analytics, mode } =
|
|
944
|
-
|
|
945
|
-
tenantAlias:
|
|
946
|
-
externalAccountId:
|
|
947
|
-
externalUserId:
|
|
948
|
-
engagementMedium:
|
|
508
|
+
const { analytics: i, mode: s } = t;
|
|
509
|
+
e = {
|
|
510
|
+
tenantAlias: i.attributes.tenant,
|
|
511
|
+
externalAccountId: i.attributes.accountId,
|
|
512
|
+
externalUserId: i.attributes.userId,
|
|
513
|
+
engagementMedium: s.widgetMode
|
|
949
514
|
};
|
|
950
515
|
}
|
|
951
|
-
(
|
|
952
|
-
|
|
953
|
-
}).catch((
|
|
954
|
-
|
|
516
|
+
(n = this.analyticsApi.pushAnalyticsLoadEvent(e)) == null || n.then((i) => {
|
|
517
|
+
y(`${e.engagementMedium} loaded event recorded.`);
|
|
518
|
+
}).catch((i) => {
|
|
519
|
+
y(`ERROR: pushAnalyticsLoadEvent() ${i}`);
|
|
955
520
|
});
|
|
956
521
|
}
|
|
957
|
-
_shareEvent(
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
});
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
_error(rs, mode = "modal", style = "") {
|
|
975
|
-
const errorTemplate = `<!DOCTYPE html>
|
|
976
|
-
<!--[if IE 7]><html class="ie7 oldie" lang="en"><![endif]-->
|
|
977
|
-
<!--[if IE 8]><html class="ie8 oldie" lang="en"><![endif]-->
|
|
978
|
-
<!--[if gt IE 8]><!--><html lang="en"><!--<![endif]-->
|
|
979
|
-
<head>
|
|
980
|
-
<link rel="stylesheet" media="all" href="https://fast.ssqt.io/assets/css/widget/errorpage.css">
|
|
981
|
-
<style>
|
|
982
|
-
${style}
|
|
983
|
-
</style>
|
|
984
|
-
</head>
|
|
985
|
-
<body>
|
|
986
|
-
|
|
987
|
-
<div class="squatch-container ${mode}" style="width:100%">
|
|
988
|
-
<div class="errorheader">
|
|
989
|
-
<button type="button" class="close" onclick="window.frameElement.squatchJsApi.close();">×</button>
|
|
990
|
-
<p class="errortitle">Error</p>
|
|
991
|
-
</div>
|
|
992
|
-
<div class="errorbody">
|
|
993
|
-
<div class="sadface"><img src="https://fast.ssqt.io/assets/images/face.png"></div>
|
|
994
|
-
<h4>Our referral program is temporarily unavailable.</h4><br>
|
|
995
|
-
<p>Please reload the page or check back later.</p>
|
|
996
|
-
<p>If the persists please contact our support team.</p>
|
|
997
|
-
<br>
|
|
998
|
-
<br>
|
|
999
|
-
<div class="right-align errtxt">
|
|
1000
|
-
Error Code: ${rs}
|
|
1001
|
-
</div>
|
|
1002
|
-
</div>
|
|
1003
|
-
</div>
|
|
1004
|
-
</body>
|
|
1005
|
-
</html>`;
|
|
1006
|
-
return errorTemplate;
|
|
522
|
+
_shareEvent(t, e) {
|
|
523
|
+
t && this.analyticsApi.pushAnalyticsShareClickedEvent({
|
|
524
|
+
tenantAlias: t.analytics.attributes.tenant,
|
|
525
|
+
externalAccountId: t.analytics.attributes.accountId,
|
|
526
|
+
externalUserId: t.analytics.attributes.userId,
|
|
527
|
+
engagementMedium: t.mode.widgetMode,
|
|
528
|
+
shareMedium: e
|
|
529
|
+
}).then((n) => {
|
|
530
|
+
y(
|
|
531
|
+
`${t.mode.widgetMode} share ${e} event recorded. ${n}`
|
|
532
|
+
);
|
|
533
|
+
}).catch((n) => {
|
|
534
|
+
y(`ERROR: pushAnalyticsShareClickedEvent() ${n}`);
|
|
535
|
+
});
|
|
1007
536
|
}
|
|
1008
|
-
async _findInnerContainer(
|
|
1009
|
-
const { contentWindow } =
|
|
1010
|
-
if (!
|
|
537
|
+
async _findInnerContainer(t) {
|
|
538
|
+
const { contentWindow: e } = t;
|
|
539
|
+
if (!e)
|
|
1011
540
|
throw new Error("Squatch.js frame inner frame is empty");
|
|
1012
|
-
const
|
|
1013
|
-
function
|
|
1014
|
-
const
|
|
1015
|
-
|
|
1016
|
-
const fallback = containers.length > 0 ? containers[0] : legacyContainers.length > 0 ? legacyContainers[0] : null;
|
|
1017
|
-
return fallback;
|
|
1018
|
-
}
|
|
1019
|
-
let found = null;
|
|
1020
|
-
for (let i = 0; i < 5; i++) {
|
|
1021
|
-
found = search();
|
|
1022
|
-
if (found) break;
|
|
1023
|
-
await delay(100);
|
|
1024
|
-
}
|
|
1025
|
-
if (!found) {
|
|
1026
|
-
return frameDoc.body;
|
|
541
|
+
const n = e.document;
|
|
542
|
+
function i() {
|
|
543
|
+
const r = n.getElementsByTagName("sqh-global-container"), a = n.getElementsByClassName("squatch-container");
|
|
544
|
+
return r.length > 0 ? r[0] : a.length > 0 ? a[0] : null;
|
|
1027
545
|
}
|
|
1028
|
-
|
|
546
|
+
let s = null;
|
|
547
|
+
for (let r = 0; r < 5 && (s = i(), !s); r++)
|
|
548
|
+
await Pe(100);
|
|
549
|
+
return s || n.body;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Returns HTML for an in-iframe skeleton preload overlay that is removed
|
|
553
|
+
* once all custom elements in the widget are defined.
|
|
554
|
+
*
|
|
555
|
+
* Uses `customElements.whenDefined()` to wait for all custom element tags,
|
|
556
|
+
* then removes the skeleton after two animation frames. Includes a 10s
|
|
557
|
+
* timeout fallback.
|
|
558
|
+
*
|
|
559
|
+
* Only generates content for mint-components widgets; returns empty string otherwise.
|
|
560
|
+
*/
|
|
561
|
+
async _getSkeletonPreloadHTML(t, e) {
|
|
562
|
+
if (!t) return "";
|
|
563
|
+
const { getSkeleton: n } = await import("./SkeletonTemplate-Day_0iMM.js"), i = this.context.type === "passwordless" ? "instant-access" : "verified-access", s = n({
|
|
564
|
+
type: i
|
|
565
|
+
}), r = /* @__PURE__ */ new Set(), a = /<([a-z][\w]*-[\w-]*)/gi;
|
|
566
|
+
let c;
|
|
567
|
+
for (; c = a.exec(this.content); ) r.add(c[1].toLowerCase());
|
|
568
|
+
const d = JSON.stringify([...r]);
|
|
569
|
+
return `
|
|
570
|
+
<div id="sq-preload" style="visibility: visible; position: absolute; top: 0; left: 0; width: 100%; z-index: 9999; background: ${(e || "white").replace(/[^a-zA-Z0-9#(),.\s%-]/g, "")};">
|
|
571
|
+
${s}
|
|
572
|
+
</div>
|
|
573
|
+
<script>(${Le.toString()})(${d})<\/script>
|
|
574
|
+
`;
|
|
1029
575
|
}
|
|
1030
576
|
/**
|
|
1031
577
|
* Reloads the current widget, makes updated request to API and renders result.
|
|
@@ -1033,365 +579,287 @@ class Widget {
|
|
|
1033
579
|
* @param param0 Form field values
|
|
1034
580
|
* @param jwt JWT for API authentication
|
|
1035
581
|
*/
|
|
1036
|
-
reload({ email, firstName, lastName },
|
|
1037
|
-
const
|
|
1038
|
-
if (!
|
|
1039
|
-
const
|
|
1040
|
-
|
|
1041
|
-
if (!frameWindow) {
|
|
582
|
+
reload({ email: t, firstName: e, lastName: n }, i) {
|
|
583
|
+
const s = this._findFrame();
|
|
584
|
+
if (!s) throw new Error("Could not find widget iframe");
|
|
585
|
+
const r = s.contentWindow, a = this.context.engagementMedium || "POPUP";
|
|
586
|
+
if (!r)
|
|
1042
587
|
throw new Error("Frame needs a content window");
|
|
1043
|
-
|
|
1044
|
-
let response;
|
|
588
|
+
let c;
|
|
1045
589
|
if (this.context.type === "upsert") {
|
|
1046
590
|
if (!this.context.user) throw new Error("Can't reload without user ids");
|
|
1047
|
-
let
|
|
1048
|
-
email:
|
|
1049
|
-
firstName:
|
|
1050
|
-
lastName:
|
|
591
|
+
let d = {
|
|
592
|
+
email: t || null,
|
|
593
|
+
firstName: e || null,
|
|
594
|
+
lastName: n || null,
|
|
1051
595
|
id: this.context.user.id,
|
|
1052
596
|
accountId: this.context.user.accountId
|
|
1053
597
|
};
|
|
1054
|
-
|
|
1055
|
-
user:
|
|
1056
|
-
engagementMedium,
|
|
598
|
+
c = this.widgetApi.upsertUser({
|
|
599
|
+
user: d,
|
|
600
|
+
engagementMedium: a,
|
|
1057
601
|
widgetType: this.type,
|
|
1058
|
-
jwt
|
|
602
|
+
jwt: i
|
|
1059
603
|
});
|
|
1060
|
-
} else if (this.context.type === "passwordless")
|
|
1061
|
-
|
|
604
|
+
} else if (this.context.type === "passwordless")
|
|
605
|
+
c = this.widgetApi.render({
|
|
1062
606
|
user: void 0,
|
|
1063
|
-
engagementMedium,
|
|
607
|
+
engagementMedium: a,
|
|
1064
608
|
widgetType: this.type,
|
|
1065
609
|
jwt: void 0
|
|
1066
610
|
});
|
|
1067
|
-
|
|
611
|
+
else
|
|
1068
612
|
throw new Error("can't reload an error widget");
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
}
|
|
1080
|
-
);
|
|
1081
|
-
}
|
|
1082
|
-
}).catch(({ message }) => {
|
|
1083
|
-
_log$8(`${message}`);
|
|
613
|
+
c.then(({ template: d }) => {
|
|
614
|
+
d && (this.content = d, this.__deprecated__register(
|
|
615
|
+
s,
|
|
616
|
+
{ email: t, engagementMedium: a },
|
|
617
|
+
() => {
|
|
618
|
+
this.load(), a === "POPUP" && this.open();
|
|
619
|
+
}
|
|
620
|
+
));
|
|
621
|
+
}).catch(({ message: d }) => {
|
|
622
|
+
y(`${d}`);
|
|
1084
623
|
});
|
|
1085
624
|
}
|
|
1086
|
-
__deprecated__register(
|
|
1087
|
-
const
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
showStatsBtn.className = "btn btn-primary";
|
|
1093
|
-
showStatsBtn.id = "show-stats-btn";
|
|
1094
|
-
showStatsBtn.textContent = this.type === "REFERRER_WIDGET" ? "Show Stats" : "Show Reward";
|
|
1095
|
-
const widgetStyle = params.engagementMedium === "POPUP" ? "margin-top: 10px; max-width: 130px; width: 100%;" : "margin-top: 10px;";
|
|
1096
|
-
showStatsBtn.setAttribute("style", widgetStyle);
|
|
1097
|
-
showStatsBtn.onclick = onClick;
|
|
1098
|
-
registerForm.style.paddingTop = "30px";
|
|
1099
|
-
registerForm.innerHTML = `<p><strong>${params.email}</strong><br>Has been successfully registered</p>`;
|
|
1100
|
-
registerForm.appendChild(showStatsBtn);
|
|
625
|
+
__deprecated__register(t, e, n) {
|
|
626
|
+
const s = t.contentWindow.document, r = s.createElement("button"), a = s.getElementsByClassName("squatch-register")[0];
|
|
627
|
+
if (a) {
|
|
628
|
+
r.className = "btn btn-primary", r.id = "show-stats-btn", r.textContent = this.type === "REFERRER_WIDGET" ? "Show Stats" : "Show Reward";
|
|
629
|
+
const c = e.engagementMedium === "POPUP" ? "margin-top: 10px; max-width: 130px; width: 100%;" : "margin-top: 10px;";
|
|
630
|
+
r.setAttribute("style", c), r.onclick = n, a.style.paddingTop = "30px", a.innerHTML = `<p><strong>${e.email}</strong><br>Has been successfully registered</p>`, a.appendChild(r);
|
|
1101
631
|
}
|
|
1102
632
|
}
|
|
1103
633
|
}
|
|
1104
|
-
function
|
|
1105
|
-
return new Promise((
|
|
1106
|
-
setTimeout(
|
|
634
|
+
function Pe(o) {
|
|
635
|
+
return new Promise((t) => {
|
|
636
|
+
setTimeout(t, o);
|
|
1107
637
|
});
|
|
1108
638
|
}
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
639
|
+
function Le(o) {
|
|
640
|
+
var t = setTimeout(e, 1e4);
|
|
641
|
+
function e() {
|
|
642
|
+
var i = document.getElementById("sq-preload");
|
|
643
|
+
i && i.remove(), clearTimeout(t);
|
|
644
|
+
}
|
|
645
|
+
function n() {
|
|
646
|
+
if (!o || !o.length) return e();
|
|
647
|
+
Promise.all(
|
|
648
|
+
o.map(function(i) {
|
|
649
|
+
return customElements.whenDefined(i);
|
|
650
|
+
})
|
|
651
|
+
).then(function() {
|
|
652
|
+
requestAnimationFrame(function() {
|
|
653
|
+
requestAnimationFrame(e);
|
|
654
|
+
});
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", n) : setTimeout(n, 0);
|
|
658
|
+
}
|
|
659
|
+
const I = C("squatch-js:EMBEDwidget");
|
|
660
|
+
class D extends me {
|
|
661
|
+
constructor(e, n) {
|
|
662
|
+
super(e);
|
|
663
|
+
l(this, "show", this.open);
|
|
664
|
+
l(this, "hide", this.close);
|
|
665
|
+
n && (this.container = n);
|
|
1118
666
|
}
|
|
1119
667
|
async load() {
|
|
1120
|
-
var
|
|
1121
|
-
const
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
initialHeight
|
|
1130
|
-
});
|
|
1131
|
-
const element = this._findElement();
|
|
1132
|
-
if ((_d = this.context) == null ? void 0 : _d.container) {
|
|
1133
|
-
element.style.visibility = "hidden";
|
|
1134
|
-
element.style.height = "0";
|
|
1135
|
-
element.style["overflow-y"] = "hidden";
|
|
1136
|
-
}
|
|
1137
|
-
if (this.container) {
|
|
1138
|
-
if (element.shadowRoot) {
|
|
1139
|
-
if (((_e = element.shadowRoot.lastChild) == null ? void 0 : _e.nodeName) === "IFRAME") {
|
|
1140
|
-
element.shadowRoot.replaceChild(frame, element.shadowRoot.lastChild);
|
|
1141
|
-
} else {
|
|
1142
|
-
element.shadowRoot.appendChild(frame);
|
|
1143
|
-
}
|
|
1144
|
-
} else if (element.firstChild) {
|
|
1145
|
-
element.replaceChild(frame, element.firstChild);
|
|
1146
|
-
} else {
|
|
1147
|
-
element.appendChild(frame);
|
|
1148
|
-
}
|
|
1149
|
-
} else if (!element.firstChild || element.firstChild.nodeName === "#text") {
|
|
1150
|
-
element.appendChild(frame);
|
|
1151
|
-
}
|
|
1152
|
-
const { contentWindow } = frame;
|
|
1153
|
-
if (!contentWindow) {
|
|
668
|
+
var g, f, b, w, T, ee, te, ne, ie;
|
|
669
|
+
const e = (f = (g = this.context.widgetConfig) == null ? void 0 : g.values) == null ? void 0 : f.brandingConfig, n = (b = this.content) == null ? void 0 : b.includes("mint-components"), i = (e == null ? void 0 : e.loadingHeight) || 500, s = (w = e == null ? void 0 : e.widgetSize) == null ? void 0 : w.embeddedWidgets, r = s != null && s.maxWidth ? O(s.maxWidth) : "", a = s != null && s.minWidth ? O(s.minWidth) : "", c = this._createFrame({
|
|
670
|
+
minWidth: a,
|
|
671
|
+
maxWidth: r,
|
|
672
|
+
initialHeight: i
|
|
673
|
+
}), d = this._findElement();
|
|
674
|
+
(T = this.context) != null && T.container && (d.style.visibility = "hidden", d.style.height = "0", d.style["overflow-y"] = "hidden"), this.container ? d.shadowRoot ? ((ee = d.shadowRoot.lastChild) == null ? void 0 : ee.nodeName) === "IFRAME" ? d.shadowRoot.replaceChild(c, d.shadowRoot.lastChild) : d.shadowRoot.appendChild(c) : d.firstChild ? d.replaceChild(c, d.firstChild) : d.appendChild(c) : (!d.firstChild || d.firstChild.nodeName === "#text") && d.appendChild(c);
|
|
675
|
+
const { contentWindow: h } = c;
|
|
676
|
+
if (!h)
|
|
1154
677
|
throw new Error("Frame needs a content window");
|
|
678
|
+
const u = h.document;
|
|
679
|
+
if (u.open(), this.content === "error") {
|
|
680
|
+
u.write(await this._getContent()), u.close(), x(u, () => {
|
|
681
|
+
c.height = u.body.scrollHeight;
|
|
682
|
+
});
|
|
683
|
+
return;
|
|
1155
684
|
}
|
|
1156
|
-
const
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
<link rel="preconnect" href="https://fast${domain === "https://staging.referralsaasquatch.com" && "-staging"}.ssqt.io">
|
|
1162
|
-
<link rel="preconnect" href="https://fonts.gstatic.com">
|
|
685
|
+
const p = this.widgetApi.domain === "https://staging.referralsaasquatch.com" ? "-staging" : "";
|
|
686
|
+
u.write(`
|
|
687
|
+
${(te = e == null ? void 0 : e.main) != null && te.brandFont ? `
|
|
688
|
+
<link rel="preconnect" href="https://fast${p}.ssqt.io">
|
|
689
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
1163
690
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
1164
691
|
<link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
|
|
1165
|
-
(
|
|
692
|
+
(ne = e == null ? void 0 : e.main) == null ? void 0 : ne.brandFont
|
|
1166
693
|
)}" as="style">` : ""}
|
|
1167
|
-
<
|
|
694
|
+
<link rel="dns-prefetch" href="https://res.cloudinary.com">
|
|
695
|
+
<link rel="preconnect" href="https://res.cloudinary.com" crossorigin>
|
|
696
|
+
${n ? `
|
|
1168
697
|
<style data-styles>
|
|
1169
|
-
html { visibility:hidden;}
|
|
1170
|
-
</style
|
|
1171
|
-
${this.
|
|
1172
|
-
|
|
1173
|
-
`)
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
const
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
for (const entry of entries) {
|
|
1181
|
-
const { height } = entry.contentRect;
|
|
1182
|
-
frame.height = height;
|
|
698
|
+
html { visibility: hidden; }
|
|
699
|
+
</style>` : ""}
|
|
700
|
+
${await this._getSkeletonPreloadHTML(n, (ie = e == null ? void 0 : e.color) == null ? void 0 : ie.backgroundColor)}
|
|
701
|
+
${await this._getContent()}
|
|
702
|
+
`), u.close(), x(u, async () => {
|
|
703
|
+
const oe = h.squatch || h.widgetIdent;
|
|
704
|
+
c.height = i;
|
|
705
|
+
const fe = new h.ResizeObserver((Ee) => {
|
|
706
|
+
for (const Ce of Ee) {
|
|
707
|
+
const { height: be } = Ce.contentRect;
|
|
708
|
+
c.height = be;
|
|
1183
709
|
}
|
|
1184
|
-
});
|
|
1185
|
-
|
|
1186
|
-
ro.observe(container);
|
|
1187
|
-
if (this._shouldFireLoadEvent()) {
|
|
1188
|
-
this._loadEvent(_sqh);
|
|
1189
|
-
_log$7("loaded");
|
|
1190
|
-
} else if (frameDoc) {
|
|
1191
|
-
this._attachLoadEventListener(frameDoc, _sqh);
|
|
1192
|
-
}
|
|
710
|
+
}), ye = await this._findInnerContainer(c);
|
|
711
|
+
fe.observe(ye), this._shouldFireLoadEvent() ? (this._loadEvent(oe), I("loaded")) : u && this._attachLoadEventListener(u, oe);
|
|
1193
712
|
});
|
|
1194
713
|
}
|
|
1195
714
|
/**
|
|
1196
715
|
* Un-hide if element is available and refresh data
|
|
1197
716
|
*/
|
|
1198
717
|
open() {
|
|
1199
|
-
const
|
|
1200
|
-
if (!
|
|
1201
|
-
if (!
|
|
1202
|
-
const
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
this.
|
|
1210
|
-
_log$7("loaded");
|
|
1211
|
-
} else {
|
|
1212
|
-
if (!frame.contentDocument) return;
|
|
1213
|
-
this._attachLoadEventListener(frame.contentDocument, _sqh);
|
|
718
|
+
const e = this._findFrame();
|
|
719
|
+
if (!e) return I("no target element to open");
|
|
720
|
+
if (!e.contentWindow) return I("Frame needs a content window");
|
|
721
|
+
const n = this._findElement();
|
|
722
|
+
n.style.visibility = "unset", n.style.height = "auto", n.style["overflow-y"] = "auto", e.contentWindow.document.dispatchEvent(new CustomEvent("sq:refresh"));
|
|
723
|
+
const i = e.contentWindow.squatch || e.contentWindow.widgetIdent;
|
|
724
|
+
if (this.context.user)
|
|
725
|
+
this._loadEvent(i), I("loaded");
|
|
726
|
+
else {
|
|
727
|
+
if (!e.contentDocument) return;
|
|
728
|
+
this._attachLoadEventListener(e.contentDocument, i);
|
|
1214
729
|
}
|
|
1215
730
|
}
|
|
1216
731
|
close() {
|
|
1217
|
-
const
|
|
1218
|
-
if (!
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
_log$7("Embed widget closed");
|
|
1226
|
-
}
|
|
1227
|
-
_error(rs, mode = "embed", style = "") {
|
|
1228
|
-
return super._error(rs, mode, style);
|
|
732
|
+
const e = this._findFrame();
|
|
733
|
+
if (!e) return I("no target element to close");
|
|
734
|
+
e.contentDocument && this._detachLoadEventListener(e.contentDocument);
|
|
735
|
+
const n = this._findElement();
|
|
736
|
+
n.style.visibility = "hidden", n.style.height = "0", n.style["overflow-y"] = "hidden", I("Embed widget closed");
|
|
737
|
+
}
|
|
738
|
+
_getErrorMode() {
|
|
739
|
+
return "embed";
|
|
1229
740
|
}
|
|
1230
741
|
_shouldFireLoadEvent() {
|
|
1231
|
-
const
|
|
1232
|
-
|
|
1233
|
-
const isVerified = !!this.context.user;
|
|
1234
|
-
return isVerified && (noContainer || isComponent);
|
|
742
|
+
const e = !this.container, n = this.container instanceof HTMLElement && (this.container.tagName.startsWith("SQUATCH-") || this.container.tagName.startsWith("IMPACT-"));
|
|
743
|
+
return !!this.context.user && (e || n);
|
|
1235
744
|
}
|
|
1236
745
|
}
|
|
1237
|
-
const
|
|
1238
|
-
let
|
|
1239
|
-
class
|
|
1240
|
-
constructor(
|
|
1241
|
-
super(
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
this.trigger =
|
|
1247
|
-
if (this.container) {
|
|
1248
|
-
this.id = "squatchModal";
|
|
1249
|
-
} else {
|
|
1250
|
-
this.id = popupId === 0 ? `squatchModal` : `squatchModal__${popupId}`;
|
|
1251
|
-
popupId = popupId + 1;
|
|
1252
|
-
}
|
|
1253
|
-
document.head.insertAdjacentHTML(
|
|
746
|
+
const v = C("squatch-js:POPUPwidget");
|
|
747
|
+
let U = 0;
|
|
748
|
+
class j extends me {
|
|
749
|
+
constructor(e, n = ".squatchpop") {
|
|
750
|
+
super(e);
|
|
751
|
+
l(this, "trigger");
|
|
752
|
+
l(this, "id");
|
|
753
|
+
l(this, "show", this.open);
|
|
754
|
+
l(this, "hide", this.close);
|
|
755
|
+
this.trigger = n, this.container ? this.id = "squatchModal" : (this.id = U === 0 ? "squatchModal" : `squatchModal__${U}`, U = U + 1), document.head.insertAdjacentHTML(
|
|
1254
756
|
"beforeend",
|
|
1255
757
|
`<style>#${this.id}::-webkit-scrollbar { display: none; }</style>`
|
|
1256
758
|
);
|
|
1257
759
|
}
|
|
1258
760
|
_initialiseCTA() {
|
|
1259
761
|
if (!this.trigger) return;
|
|
1260
|
-
let
|
|
762
|
+
let e;
|
|
1261
763
|
try {
|
|
1262
|
-
|
|
1263
|
-
if (this.trigger && !triggerElement)
|
|
1264
|
-
_log$6("No element found with trigger selector", this.trigger);
|
|
764
|
+
e = document.querySelector(this.trigger) || document.querySelector(".impactpop"), this.trigger && !e && v("No element found with trigger selector", this.trigger);
|
|
1265
765
|
} catch {
|
|
1266
|
-
|
|
1267
|
-
}
|
|
1268
|
-
if (triggerElement) {
|
|
1269
|
-
triggerElement.onclick = () => {
|
|
1270
|
-
this.open();
|
|
1271
|
-
};
|
|
766
|
+
v("Not a valid selector", this.trigger);
|
|
1272
767
|
}
|
|
768
|
+
e && (e.onclick = () => {
|
|
769
|
+
this.open();
|
|
770
|
+
});
|
|
1273
771
|
}
|
|
1274
|
-
_createPopupDialog() {
|
|
1275
|
-
var
|
|
1276
|
-
const
|
|
1277
|
-
|
|
1278
|
-
const sizes = (_c = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _c.popupWidgets;
|
|
1279
|
-
const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "auto";
|
|
1280
|
-
const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "500px";
|
|
1281
|
-
dialog.id = this.id;
|
|
1282
|
-
dialog.setAttribute(
|
|
772
|
+
_createPopupDialog(e) {
|
|
773
|
+
var c;
|
|
774
|
+
const n = document.createElement("dialog"), i = (c = e == null ? void 0 : e.widgetSize) == null ? void 0 : c.popupWidgets, s = i != null && i.minWidth ? O(i.minWidth) : "auto", r = i != null && i.maxWidth ? O(i.maxWidth) : "500px";
|
|
775
|
+
n.id = this.id, n.setAttribute(
|
|
1283
776
|
"style",
|
|
1284
|
-
`width: 100%; min-width: ${
|
|
777
|
+
`width: 100%; min-width: ${s}; max-width: ${r}; border: none; padding: 0;`
|
|
1285
778
|
);
|
|
1286
|
-
const
|
|
1287
|
-
|
|
1288
|
-
if (e.target === dialog) dialog.close();
|
|
779
|
+
const a = (d) => {
|
|
780
|
+
d.stopPropagation(), d.target === n && n.close();
|
|
1289
781
|
};
|
|
1290
|
-
|
|
1291
|
-
return dialog;
|
|
782
|
+
return n.addEventListener("click", a), n;
|
|
1292
783
|
}
|
|
1293
784
|
async load() {
|
|
1294
|
-
var
|
|
1295
|
-
const
|
|
1296
|
-
this._initialiseCTA();
|
|
1297
|
-
const
|
|
1298
|
-
|
|
1299
|
-
const
|
|
1300
|
-
|
|
1301
|
-
if (((_a2 = dialogParent.lastChild) == null ? void 0 : _a2.nodeName) === "DIALOG") {
|
|
1302
|
-
dialogParent.replaceChild(dialog, dialogParent.lastChild);
|
|
1303
|
-
} else {
|
|
1304
|
-
dialogParent.appendChild(dialog);
|
|
1305
|
-
}
|
|
1306
|
-
const { contentWindow } = frame;
|
|
1307
|
-
if (!contentWindow) {
|
|
785
|
+
var m, p, g, f, b, w, T;
|
|
786
|
+
const e = (p = (m = this.context.widgetConfig) == null ? void 0 : m.values) == null ? void 0 : p.brandingConfig, n = (e == null ? void 0 : e.loadingHeight) || 500, i = (g = this.content) == null ? void 0 : g.includes("mint-components"), s = this._createFrame();
|
|
787
|
+
s.style.height = n + "px", this._initialiseCTA();
|
|
788
|
+
const r = this.container ? this._findElement() : document.body, a = (r == null ? void 0 : r.shadowRoot) || r, c = this._createPopupDialog(e);
|
|
789
|
+
c.appendChild(s), ((f = a.lastChild) == null ? void 0 : f.nodeName) === "DIALOG" ? a.replaceChild(c, a.lastChild) : a.appendChild(c);
|
|
790
|
+
const { contentWindow: d } = s;
|
|
791
|
+
if (!d)
|
|
1308
792
|
throw new Error("Frame needs a content window");
|
|
793
|
+
const h = d.document;
|
|
794
|
+
if (h.open(), this.content === "error") {
|
|
795
|
+
h.write(await this._getContent()), h.close(), x(h, () => {
|
|
796
|
+
s.height = h.body.scrollHeight;
|
|
797
|
+
}), v("Popup error template loaded into iframe");
|
|
798
|
+
return;
|
|
1309
799
|
}
|
|
1310
|
-
const
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
}
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
async _setupResizeHandler(frame) {
|
|
1333
|
-
const { contentWindow } = frame;
|
|
1334
|
-
if (!contentWindow) {
|
|
800
|
+
const u = this.widgetApi.domain;
|
|
801
|
+
h.write(`
|
|
802
|
+
${(b = e == null ? void 0 : e.main) != null && b.brandFont ? `
|
|
803
|
+
<link rel="preconnect" href="https://fast${u === "https://staging.referralsaasquatch.com" ? "-staging" : ""}.ssqt.io">
|
|
804
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
805
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
806
|
+
<link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
|
|
807
|
+
(w = e == null ? void 0 : e.main) == null ? void 0 : w.brandFont
|
|
808
|
+
)}" as="style">` : ""}
|
|
809
|
+
<link rel="dns-prefetch" href="https://res.cloudinary.com">
|
|
810
|
+
<link rel="preconnect" href="https://res.cloudinary.com" crossorigin>
|
|
811
|
+
${i ? `
|
|
812
|
+
<style data-styles>
|
|
813
|
+
html { visibility: hidden; }
|
|
814
|
+
</style>` : ""}
|
|
815
|
+
${await this._getSkeletonPreloadHTML(i, (T = e == null ? void 0 : e.color) == null ? void 0 : T.backgroundColor)}
|
|
816
|
+
${await this._getContent()}
|
|
817
|
+
`), h.close(), v("Popup template loaded into iframe"), await this._setupResizeHandler(s);
|
|
818
|
+
}
|
|
819
|
+
async _setupResizeHandler(e) {
|
|
820
|
+
const { contentWindow: n } = e;
|
|
821
|
+
if (!n)
|
|
1335
822
|
throw new Error("Frame needs a content window");
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
const computedHeight = bottom + top;
|
|
1345
|
-
frame.height = computedHeight + "";
|
|
1346
|
-
entry.target.style = ``;
|
|
823
|
+
const i = n.document;
|
|
824
|
+
x(i, async () => {
|
|
825
|
+
i.body.style.overflowY = "hidden";
|
|
826
|
+
let s = !0;
|
|
827
|
+
new n.ResizeObserver((a) => {
|
|
828
|
+
for (const c of a) {
|
|
829
|
+
const { top: d, bottom: h } = c.contentRect, u = h + d;
|
|
830
|
+
u <= 0 || (s ? (s = !1, e.style.height = "0", e.height = i.body.scrollHeight + "", e.style.height = "") : e.height = u + "", c.target.style = "");
|
|
1347
831
|
}
|
|
1348
|
-
});
|
|
1349
|
-
ro.observe(await this._findInnerContainer(frame));
|
|
832
|
+
}).observe(await this._findInnerContainer(e));
|
|
1350
833
|
});
|
|
1351
834
|
}
|
|
1352
835
|
open() {
|
|
1353
|
-
const
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
const
|
|
1359
|
-
if (!
|
|
1360
|
-
const
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
const _sqh = contentWindow.squatch || contentWindow.widgetIdent;
|
|
1366
|
-
(_a2 = frame.contentDocument) == null ? void 0 : _a2.dispatchEvent(new CustomEvent("sq:refresh"));
|
|
1367
|
-
if (this.context.user) {
|
|
1368
|
-
this._loadEvent(_sqh);
|
|
1369
|
-
_log$6("Popup opened");
|
|
1370
|
-
} else {
|
|
1371
|
-
this._attachLoadEventListener(frameDoc, _sqh);
|
|
1372
|
-
}
|
|
836
|
+
const e = this.container ? this._findElement() : document.body, i = (e.shadowRoot || e).querySelector(`#${this.id}`);
|
|
837
|
+
if (!i) throw new Error("Could not determine container div");
|
|
838
|
+
i.showModal();
|
|
839
|
+
const s = this._findFrame();
|
|
840
|
+
if (!s) throw new Error("Could not find iframe");
|
|
841
|
+
const { contentWindow: r } = s;
|
|
842
|
+
if (!r) throw new Error("Squatch.js has an empty iframe");
|
|
843
|
+
const a = r.document;
|
|
844
|
+
x(a, () => {
|
|
845
|
+
var d;
|
|
846
|
+
const c = r.squatch || r.widgetIdent;
|
|
847
|
+
(d = s.contentDocument) == null || d.dispatchEvent(new CustomEvent("sq:refresh")), this.context.user ? (this._loadEvent(c), v("Popup opened")) : this._attachLoadEventListener(a, c);
|
|
1373
848
|
});
|
|
1374
849
|
}
|
|
1375
850
|
close() {
|
|
1376
|
-
const
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
_log$6("Popup closed");
|
|
1385
|
-
}
|
|
1386
|
-
_clickedOutside({ target }) {
|
|
1387
|
-
}
|
|
1388
|
-
_error(rs, mode = "modal", style = "") {
|
|
1389
|
-
const _style = "body { margin: 0; } .modal { box-shadow: none; border: 0; }";
|
|
1390
|
-
return super._error(rs, mode, style || _style);
|
|
851
|
+
const e = this._findFrame();
|
|
852
|
+
e != null && e.contentDocument && this._detachLoadEventListener(e.contentDocument);
|
|
853
|
+
const n = this.container ? this._findElement() : document.body, s = (n.shadowRoot || n).querySelector(`#${this.id}`);
|
|
854
|
+
if (!s) throw new Error("Could not determine container div");
|
|
855
|
+
s.close(), v("Popup closed");
|
|
856
|
+
}
|
|
857
|
+
_getErrorStyle() {
|
|
858
|
+
return "body { margin: 0; } .modal { box-shadow: none; border: 0; }";
|
|
1391
859
|
}
|
|
1392
860
|
}
|
|
1393
|
-
const
|
|
1394
|
-
class
|
|
861
|
+
const E = C("squatch-js:widgets");
|
|
862
|
+
class N {
|
|
1395
863
|
/**
|
|
1396
864
|
* Initialize a new {@link Widgets} instance.
|
|
1397
865
|
*
|
|
@@ -1408,30 +876,27 @@ class Widgets {
|
|
|
1408
876
|
* import {Widgets} from '@saasquatch/squatch-js';
|
|
1409
877
|
* let widgets = new Widgets({tenantAlias:'test_12b5bo1b25125'});
|
|
1410
878
|
*/
|
|
1411
|
-
constructor(
|
|
879
|
+
constructor(t) {
|
|
1412
880
|
/**
|
|
1413
881
|
* Instance of {@link WidgetApi}
|
|
1414
882
|
*/
|
|
1415
|
-
|
|
883
|
+
l(this, "api");
|
|
1416
884
|
/**
|
|
1417
885
|
* Tenant alias of SaaSquatch tenant
|
|
1418
886
|
*/
|
|
1419
|
-
|
|
887
|
+
l(this, "tenantAlias");
|
|
1420
888
|
/**
|
|
1421
889
|
* SaaSquatch domain for API requests
|
|
1422
890
|
* @default "https://app.referralsaasquatch.com"
|
|
1423
891
|
*/
|
|
1424
|
-
|
|
892
|
+
l(this, "domain");
|
|
1425
893
|
/**
|
|
1426
894
|
* Hosted CDN for npm packages
|
|
1427
895
|
* @default "https://fast.ssqt.io/npm"
|
|
1428
896
|
*/
|
|
1429
|
-
|
|
1430
|
-
const
|
|
1431
|
-
this.tenantAlias =
|
|
1432
|
-
this.domain = config.domain;
|
|
1433
|
-
this.npmCdn = config.npmCdn;
|
|
1434
|
-
this.api = new WidgetApi(config);
|
|
897
|
+
l(this, "npmCdn");
|
|
898
|
+
const e = q(t);
|
|
899
|
+
this.tenantAlias = e.tenantAlias, this.domain = e.domain, this.npmCdn = e.npmCdn, this.api = new Z(e);
|
|
1435
900
|
}
|
|
1436
901
|
/**
|
|
1437
902
|
* This function calls the {@link WidgetApi.upsertUser} method, and it renders
|
|
@@ -1449,32 +914,27 @@ class Widgets {
|
|
|
1449
914
|
*
|
|
1450
915
|
* @return {Promise<WidgetResult>} json object if true, with a Widget and user details
|
|
1451
916
|
*/
|
|
1452
|
-
async upsertUser(
|
|
1453
|
-
const
|
|
1454
|
-
const clean = validateWidgetConfig(raw);
|
|
917
|
+
async upsertUser(t) {
|
|
918
|
+
const n = de(t);
|
|
1455
919
|
try {
|
|
1456
|
-
const
|
|
920
|
+
const i = await this.api.upsertUser(n);
|
|
1457
921
|
return {
|
|
1458
|
-
widget: this._renderWidget(
|
|
922
|
+
widget: this._renderWidget(i, n, {
|
|
1459
923
|
type: "upsert",
|
|
1460
|
-
user:
|
|
1461
|
-
engagementMedium:
|
|
1462
|
-
container:
|
|
1463
|
-
trigger:
|
|
924
|
+
user: n.user,
|
|
925
|
+
engagementMedium: t.engagementMedium,
|
|
926
|
+
container: t.container,
|
|
927
|
+
trigger: t.trigger,
|
|
1464
928
|
widgetConfig: {
|
|
1465
929
|
values: {
|
|
1466
|
-
brandingConfig:
|
|
930
|
+
brandingConfig: i == null ? void 0 : i.brandingConfig
|
|
1467
931
|
}
|
|
1468
932
|
}
|
|
1469
933
|
}),
|
|
1470
|
-
user:
|
|
934
|
+
user: i.user
|
|
1471
935
|
};
|
|
1472
|
-
} catch (
|
|
1473
|
-
|
|
1474
|
-
if (err.apiErrorCode) {
|
|
1475
|
-
this._renderErrorWidget(err, config.engagementMedium);
|
|
1476
|
-
}
|
|
1477
|
-
throw new Error(err);
|
|
936
|
+
} catch (i) {
|
|
937
|
+
throw E(i), i.apiErrorCode && this._renderErrorWidget(i, t.engagementMedium), new Error(i);
|
|
1478
938
|
}
|
|
1479
939
|
}
|
|
1480
940
|
/**
|
|
@@ -1492,30 +952,22 @@ class Widgets {
|
|
|
1492
952
|
*
|
|
1493
953
|
* @return {Promise<WidgetResult>} json object if true, with a Widget and user details
|
|
1494
954
|
*/
|
|
1495
|
-
async render(
|
|
1496
|
-
const
|
|
1497
|
-
const clean = validatePasswordlessConfig(raw);
|
|
955
|
+
async render(t) {
|
|
956
|
+
const n = le(t);
|
|
1498
957
|
try {
|
|
1499
|
-
const
|
|
958
|
+
const i = await this.api.render(n);
|
|
1500
959
|
return {
|
|
1501
|
-
widget: this._renderWidget(
|
|
960
|
+
widget: this._renderWidget(i, n, {
|
|
1502
961
|
type: "passwordless",
|
|
1503
|
-
engagementMedium:
|
|
1504
|
-
container:
|
|
1505
|
-
trigger:
|
|
1506
|
-
widgetConfig:
|
|
1507
|
-
values: {
|
|
1508
|
-
brandingConfig: response == null ? void 0 : response.brandingConfig
|
|
1509
|
-
}
|
|
1510
|
-
}
|
|
962
|
+
engagementMedium: n.engagementMedium,
|
|
963
|
+
container: n.container,
|
|
964
|
+
trigger: n.trigger,
|
|
965
|
+
widgetConfig: i == null ? void 0 : i.widgetConfig
|
|
1511
966
|
}),
|
|
1512
|
-
user:
|
|
967
|
+
user: i.user
|
|
1513
968
|
};
|
|
1514
|
-
} catch (
|
|
1515
|
-
|
|
1516
|
-
this._renderErrorWidget(err, clean.engagementMedium);
|
|
1517
|
-
}
|
|
1518
|
-
throw new Error(err);
|
|
969
|
+
} catch (i) {
|
|
970
|
+
throw i.apiErrorCode && this._renderErrorWidget(i, n.engagementMedium), new Error(i);
|
|
1519
971
|
}
|
|
1520
972
|
}
|
|
1521
973
|
/**
|
|
@@ -1525,33 +977,29 @@ class Widgets {
|
|
|
1525
977
|
* @param selector Element class/id selector, or a callback function
|
|
1526
978
|
* @returns
|
|
1527
979
|
*/
|
|
1528
|
-
async autofill(
|
|
1529
|
-
const
|
|
1530
|
-
if (typeof
|
|
980
|
+
async autofill(t) {
|
|
981
|
+
const e = t;
|
|
982
|
+
if (typeof e == "function") {
|
|
1531
983
|
try {
|
|
1532
|
-
const
|
|
1533
|
-
|
|
1534
|
-
} catch (
|
|
1535
|
-
|
|
1536
|
-
throw new Error(e);
|
|
984
|
+
const s = await this.api.squatchReferralCookie();
|
|
985
|
+
e(s);
|
|
986
|
+
} catch (s) {
|
|
987
|
+
throw E("Autofill error", s), new Error(s);
|
|
1537
988
|
}
|
|
1538
989
|
return;
|
|
1539
990
|
}
|
|
1540
|
-
if (typeof
|
|
991
|
+
if (typeof e != "string")
|
|
1541
992
|
throw new Error("Autofill accepts a string or function");
|
|
1542
|
-
let
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
_log$5("Element id/class or function missing");
|
|
1548
|
-
throw new Error("Element id/class or function missing");
|
|
1549
|
-
}
|
|
993
|
+
let n = document.querySelectorAll(e), i;
|
|
994
|
+
if (n.length > 0)
|
|
995
|
+
i = n[0];
|
|
996
|
+
else
|
|
997
|
+
throw E("Element id/class or function missing"), new Error("Element id/class or function missing");
|
|
1550
998
|
try {
|
|
1551
|
-
const
|
|
1552
|
-
|
|
1553
|
-
} catch (
|
|
1554
|
-
throw new Error(
|
|
999
|
+
const s = await this.api.squatchReferralCookie();
|
|
1000
|
+
i.value = s.codes[0];
|
|
1001
|
+
} catch (s) {
|
|
1002
|
+
throw new Error(s);
|
|
1555
1003
|
}
|
|
1556
1004
|
}
|
|
1557
1005
|
/**
|
|
@@ -1562,74 +1010,42 @@ class Widgets {
|
|
|
1562
1010
|
* @param {string} config.engagementMedium (POPUP, EMBED)
|
|
1563
1011
|
* @returns {Widget} widget (PopupWidget or EmbedWidget)
|
|
1564
1012
|
*/
|
|
1565
|
-
_renderWidget(
|
|
1566
|
-
var
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
const params = {
|
|
1573
|
-
content: response.template,
|
|
1574
|
-
type: config.widgetType || ((_a2 = opts.widget) == null ? void 0 : _a2.defaultWidgetType),
|
|
1013
|
+
_renderWidget(t, e, n) {
|
|
1014
|
+
var c;
|
|
1015
|
+
if (E("Rendering Widget..."), !t) throw new Error("Unable to get a response");
|
|
1016
|
+
let i, s = !!e.displayOnLoad;
|
|
1017
|
+
const r = t.jsOptions || {}, a = {
|
|
1018
|
+
content: t.template,
|
|
1019
|
+
type: e.widgetType || ((c = r.widget) == null ? void 0 : c.defaultWidgetType),
|
|
1575
1020
|
api: this.api,
|
|
1576
1021
|
domain: this.domain,
|
|
1577
1022
|
npmCdn: this.npmCdn,
|
|
1578
|
-
context
|
|
1023
|
+
context: n
|
|
1579
1024
|
};
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
_log$5("We found a fuel tank autofill!");
|
|
1597
|
-
opts.fuelTankAutofillUrls.forEach(({ url, formSelector }) => {
|
|
1598
|
-
var _a3, _b, _c;
|
|
1599
|
-
if (Widgets._matchesUrl(url)) {
|
|
1600
|
-
_log$5("Fuel Tank URL matches");
|
|
1601
|
-
if ((_b = (_a3 = response.user) == null ? void 0 : _a3.referredBy) == null ? void 0 : _b.code) {
|
|
1602
|
-
const formAutofill = document.querySelector(formSelector);
|
|
1603
|
-
if (formAutofill) {
|
|
1604
|
-
formAutofill.value = ((_c = response.user.referredBy.referredReward) == null ? void 0 : _c.fuelTankCode) || "";
|
|
1605
|
-
} else {
|
|
1606
|
-
_log$5(
|
|
1607
|
-
new Error(
|
|
1608
|
-
`Element with id/class ${formSelector} was not found.`
|
|
1609
|
-
)
|
|
1610
|
-
);
|
|
1611
|
-
}
|
|
1612
|
-
}
|
|
1613
|
-
}
|
|
1614
|
-
});
|
|
1615
|
-
}
|
|
1616
|
-
if (config.engagementMedium === "EMBED") {
|
|
1617
|
-
widget2 = this._renderEmbedWidget(params);
|
|
1618
|
-
} else {
|
|
1619
|
-
widget2 = this._renderPopupWidget(params);
|
|
1620
|
-
if (displayOnLoad) widget2.open();
|
|
1621
|
-
}
|
|
1622
|
-
return widget2;
|
|
1025
|
+
return r.widgetUrlMappings && r.widgetUrlMappings.forEach((d) => {
|
|
1026
|
+
var h, u;
|
|
1027
|
+
N._matchesUrl(d.url) && (d.widgetType !== "CONVERSION_WIDGET" || (u = (h = t.user) == null ? void 0 : h.referredBy) != null && u.code ? (s = d.displayOnLoad, E(`Display ${d.widgetType} on ${d.url}`)) : E(
|
|
1028
|
+
`Don't display ${d.widgetType} when no referral on widget rule match ${d.url}`
|
|
1029
|
+
));
|
|
1030
|
+
}), r.fuelTankAutofillUrls && (E("We found a fuel tank autofill!"), r.fuelTankAutofillUrls.forEach(({ url: d, formSelector: h }) => {
|
|
1031
|
+
var u, m, p;
|
|
1032
|
+
if (N._matchesUrl(d) && (E("Fuel Tank URL matches"), (m = (u = t.user) == null ? void 0 : u.referredBy) != null && m.code)) {
|
|
1033
|
+
const g = document.querySelector(h);
|
|
1034
|
+
g ? g.value = ((p = t.user.referredBy.referredReward) == null ? void 0 : p.fuelTankCode) || "" : E(
|
|
1035
|
+
new Error(
|
|
1036
|
+
`Element with id/class ${h} was not found.`
|
|
1037
|
+
)
|
|
1038
|
+
);
|
|
1039
|
+
}
|
|
1040
|
+
})), e.engagementMedium === "EMBED" ? i = this._renderEmbedWidget(a) : (i = this._renderPopupWidget(a), s && i.open()), i;
|
|
1623
1041
|
}
|
|
1624
|
-
_renderPopupWidget(
|
|
1625
|
-
const
|
|
1626
|
-
|
|
1627
|
-
return widget2;
|
|
1042
|
+
_renderPopupWidget(t) {
|
|
1043
|
+
const e = new j(t, t.context.trigger);
|
|
1044
|
+
return e.load(), e;
|
|
1628
1045
|
}
|
|
1629
|
-
_renderEmbedWidget(
|
|
1630
|
-
const
|
|
1631
|
-
|
|
1632
|
-
return widget2;
|
|
1046
|
+
_renderEmbedWidget(t) {
|
|
1047
|
+
const e = new D(t, t.context.container);
|
|
1048
|
+
return e.load(), e;
|
|
1633
1049
|
}
|
|
1634
1050
|
/**
|
|
1635
1051
|
* @hidden
|
|
@@ -1637,37 +1053,34 @@ class Widgets {
|
|
|
1637
1053
|
* @param {string} em The engagementMedium
|
|
1638
1054
|
* @returns {void}
|
|
1639
1055
|
*/
|
|
1640
|
-
_renderErrorWidget(
|
|
1641
|
-
const { apiErrorCode, rsCode, message } =
|
|
1642
|
-
|
|
1643
|
-
const
|
|
1056
|
+
_renderErrorWidget(t, e = "POPUP") {
|
|
1057
|
+
const { apiErrorCode: n, rsCode: i, statusCode: s, message: r } = t;
|
|
1058
|
+
E(new Error(`${n} (${i}) ${r}`));
|
|
1059
|
+
const a = {
|
|
1644
1060
|
content: "error",
|
|
1645
|
-
rsCode,
|
|
1061
|
+
rsCode: i,
|
|
1062
|
+
apiErrorCode: n,
|
|
1063
|
+
statusCode: s,
|
|
1064
|
+
errorMessage: r,
|
|
1646
1065
|
api: this.api,
|
|
1647
1066
|
domain: this.domain,
|
|
1648
1067
|
npmCdn: this.npmCdn,
|
|
1649
1068
|
type: "ERROR_WIDGET",
|
|
1650
1069
|
context: { type: "error" }
|
|
1651
1070
|
};
|
|
1652
|
-
let
|
|
1653
|
-
|
|
1654
|
-
widget2 = new EmbedWidget(params);
|
|
1655
|
-
widget2.load();
|
|
1656
|
-
} else if (em === "POPUP") {
|
|
1657
|
-
widget2 = new PopupWidget(params);
|
|
1658
|
-
widget2.load();
|
|
1659
|
-
}
|
|
1071
|
+
let c;
|
|
1072
|
+
e === "EMBED" ? (c = new D(a), c.load()) : e === "POPUP" && (c = new j(a), c.load());
|
|
1660
1073
|
}
|
|
1661
1074
|
/**
|
|
1662
1075
|
* @hidden
|
|
1663
1076
|
* @param {string} rule A regular expression
|
|
1664
1077
|
* @returns {boolean} true if rule matches Url, false otherwise
|
|
1665
1078
|
*/
|
|
1666
|
-
static _matchesUrl(
|
|
1667
|
-
return window.location.href.match(new RegExp(
|
|
1079
|
+
static _matchesUrl(t) {
|
|
1080
|
+
return !!window.location.href.match(new RegExp(t));
|
|
1668
1081
|
}
|
|
1669
1082
|
}
|
|
1670
|
-
class
|
|
1083
|
+
class Oe {
|
|
1671
1084
|
/**
|
|
1672
1085
|
* Initialize a new {@link EventsApi} instance.
|
|
1673
1086
|
*
|
|
@@ -1684,13 +1097,11 @@ class EventsApi {
|
|
|
1684
1097
|
* import {EventsApi} from '@saasquatch/squatch-js';
|
|
1685
1098
|
* let squatchApi = new EventsApi({tenantAlias:'test_12b5bo1b25125'});
|
|
1686
1099
|
*/
|
|
1687
|
-
constructor(
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
const
|
|
1691
|
-
|
|
1692
|
-
this.tenantAlias = clean.tenantAlias;
|
|
1693
|
-
this.domain = clean.domain;
|
|
1100
|
+
constructor(t) {
|
|
1101
|
+
l(this, "tenantAlias");
|
|
1102
|
+
l(this, "domain");
|
|
1103
|
+
const n = q(t);
|
|
1104
|
+
this.tenantAlias = n.tenantAlias, this.domain = n.domain;
|
|
1694
1105
|
}
|
|
1695
1106
|
/**
|
|
1696
1107
|
* Track an event for a user
|
|
@@ -1700,531 +1111,172 @@ class EventsApi {
|
|
|
1700
1111
|
*
|
|
1701
1112
|
* @return An ID to confirm the event has been accepted for asynchronous processing
|
|
1702
1113
|
*/
|
|
1703
|
-
track(
|
|
1704
|
-
const
|
|
1705
|
-
|
|
1706
|
-
const body = _validateEvent(raw);
|
|
1707
|
-
const { jwt } = _validateTrackOptions(rawOpts);
|
|
1708
|
-
const ta = encodeURIComponent(this.tenantAlias);
|
|
1709
|
-
const userId = encodeURIComponent(body.userId);
|
|
1710
|
-
const accountId = encodeURIComponent(body.accountId);
|
|
1711
|
-
const path = `/api/v1/${ta}/open/account/${accountId}/user/${userId}/events`;
|
|
1712
|
-
const url = this.domain + path;
|
|
1713
|
-
return doPost(url, JSON.stringify(body), jwt);
|
|
1114
|
+
track(t, e) {
|
|
1115
|
+
const n = t, i = e, s = De(n), { jwt: r } = je(i), a = encodeURIComponent(this.tenantAlias), c = encodeURIComponent(s.userId), d = encodeURIComponent(s.accountId), h = `/api/v1/${a}/open/account/${d}/user/${c}/events`, u = this.domain + h;
|
|
1116
|
+
return Q(u, JSON.stringify(s), r);
|
|
1714
1117
|
}
|
|
1715
1118
|
}
|
|
1716
|
-
function
|
|
1717
|
-
if (!
|
|
1718
|
-
if (!(
|
|
1719
|
-
if (!(
|
|
1720
|
-
if (!(
|
|
1721
|
-
const
|
|
1722
|
-
if (!Array.isArray(
|
|
1119
|
+
function De(o) {
|
|
1120
|
+
if (!S(o)) throw new Error("tracking parameter must be an object");
|
|
1121
|
+
if (!(o != null && o.accountId)) throw new Error("accountId field is required");
|
|
1122
|
+
if (!(o != null && o.events)) throw new Error("events field is required");
|
|
1123
|
+
if (!(o != null && o.userId)) throw new Error("userId field is required");
|
|
1124
|
+
const t = o;
|
|
1125
|
+
if (!Array.isArray(t.events))
|
|
1723
1126
|
throw new Error("'events' should be an array");
|
|
1724
|
-
return
|
|
1127
|
+
return t;
|
|
1725
1128
|
}
|
|
1726
|
-
function
|
|
1727
|
-
if (!
|
|
1728
|
-
return
|
|
1129
|
+
function je(o) {
|
|
1130
|
+
if (!S(o)) throw new Error("'options' should be an object");
|
|
1131
|
+
return o;
|
|
1729
1132
|
}
|
|
1730
|
-
function
|
|
1731
|
-
var
|
|
1732
|
-
const
|
|
1733
|
-
const cached = ((_a2 = window["_" + namespace]) == null ? void 0 : _a2.ready) || [];
|
|
1734
|
-
const declarativeCache = window.impactOnReady || window.squatchOnReady;
|
|
1735
|
-
const readyFns = [...cached, declarativeCache].filter((a) => !!a);
|
|
1133
|
+
function Ne() {
|
|
1134
|
+
var i;
|
|
1135
|
+
const o = window[z] ? z : M, t = ((i = window["_" + o]) == null ? void 0 : i.ready) || [], e = window.impactOnReady || window.squatchOnReady, n = [...t, e].filter((s) => !!s);
|
|
1736
1136
|
setTimeout(() => {
|
|
1737
|
-
|
|
1738
|
-
window[IMPACT_NAMESPACE] = window[DEFAULT_NAMESPACE];
|
|
1739
|
-
readyFns.forEach((cb) => cb());
|
|
1740
|
-
window[DEFAULT_NAMESPACE]._auto();
|
|
1741
|
-
window["_" + namespace] = void 0;
|
|
1742
|
-
delete window["_" + namespace];
|
|
1137
|
+
window[M] && (window[z] = window[M], n.forEach((s) => s()), window[M]._auto(), window["_" + o] = void 0, delete window["_" + o]);
|
|
1743
1138
|
}, 0);
|
|
1744
1139
|
}
|
|
1745
|
-
const
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
const
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
})).reduce((a, b) => ({ ...a, ...b }), {});
|
|
1752
|
-
return {
|
|
1753
|
-
...target,
|
|
1754
|
-
...replaced
|
|
1755
|
-
};
|
|
1756
|
-
};
|
|
1757
|
-
function b64decode(input) {
|
|
1758
|
-
const binary = atob(input.replace(/_/g, "/").replace(/-/g, "+"));
|
|
1759
|
-
const bytes = new Uint8Array(binary.length);
|
|
1760
|
-
for (let i = 0; i < binary.length; i++) {
|
|
1761
|
-
bytes[i] = binary.charCodeAt(i);
|
|
1762
|
-
}
|
|
1763
|
-
return new TextDecoder("utf8").decode(bytes);
|
|
1764
|
-
}
|
|
1765
|
-
function b64encode(input) {
|
|
1766
|
-
const encodedInput = new TextEncoder().encode(input);
|
|
1767
|
-
const binary = Array.from(
|
|
1768
|
-
encodedInput,
|
|
1769
|
-
(byte) => String.fromCodePoint(byte)
|
|
1770
|
-
).join("");
|
|
1771
|
-
return btoa(binary).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
1772
|
-
}
|
|
1773
|
-
function getTopDomain() {
|
|
1774
|
-
var i, h, weird_cookie = "weird_get_top_level_domain=cookie", hostname = document.location.hostname.split(".");
|
|
1775
|
-
for (i = hostname.length - 1; i >= 0; i--) {
|
|
1776
|
-
h = hostname.slice(i).join(".");
|
|
1777
|
-
document.cookie = weird_cookie + ";domain=." + h + ";";
|
|
1778
|
-
if (document.cookie.indexOf(weird_cookie) > -1) {
|
|
1779
|
-
document.cookie = weird_cookie.split("=")[0] + "=;domain=." + h + ";expires=Thu, 01 Jan 1970 00:00:01 GMT;";
|
|
1780
|
-
return h;
|
|
1781
|
-
}
|
|
1782
|
-
}
|
|
1783
|
-
}
|
|
1784
|
-
function _pushCookie() {
|
|
1785
|
-
const queryString = window.location.search;
|
|
1786
|
-
const urlParams = new URLSearchParams(queryString);
|
|
1787
|
-
const refParam = urlParams.get("_saasquatch") || "";
|
|
1788
|
-
if (refParam) {
|
|
1789
|
-
let paramsJSON = "", existingCookie = "", reEncodedCookie = "";
|
|
1790
|
-
try {
|
|
1791
|
-
paramsJSON = JSON.parse(b64decode(refParam));
|
|
1792
|
-
} catch (error) {
|
|
1793
|
-
_log$4("Unable to decode params", error);
|
|
1794
|
-
return;
|
|
1795
|
-
}
|
|
1796
|
-
try {
|
|
1797
|
-
existingCookie = JSON.parse(b64decode(api$1.get("_saasquatch")));
|
|
1798
|
-
_log$4("existing cookie", existingCookie);
|
|
1799
|
-
} catch (error) {
|
|
1800
|
-
_log$4("Unable to retrieve cookie", error);
|
|
1801
|
-
}
|
|
1802
|
-
try {
|
|
1803
|
-
const domain = getTopDomain();
|
|
1804
|
-
_log$4("domain retrieved:", domain);
|
|
1805
|
-
if (existingCookie) {
|
|
1806
|
-
const newCookie = deepMerge(existingCookie, paramsJSON);
|
|
1807
|
-
reEncodedCookie = b64encode(JSON.stringify(newCookie));
|
|
1808
|
-
_log$4("cookie to store:", newCookie);
|
|
1809
|
-
} else {
|
|
1810
|
-
reEncodedCookie = b64encode(JSON.stringify(paramsJSON));
|
|
1811
|
-
_log$4("cookie to store:", paramsJSON);
|
|
1812
|
-
}
|
|
1813
|
-
api$1.set("_saasquatch", reEncodedCookie, {
|
|
1814
|
-
expires: 365,
|
|
1815
|
-
secure: false,
|
|
1816
|
-
sameSite: "Lax",
|
|
1817
|
-
domain,
|
|
1818
|
-
path: "/"
|
|
1819
|
-
});
|
|
1820
|
-
} catch (error) {
|
|
1821
|
-
_log$4("Unable to set cookie", error);
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
}
|
|
1825
|
-
const _log$3 = browserExports.debug("squatch-js");
|
|
1826
|
-
function _getAutoConfig() {
|
|
1827
|
-
var _a2;
|
|
1828
|
-
const queryString = window.location.search;
|
|
1829
|
-
const urlParams = new URLSearchParams(queryString);
|
|
1830
|
-
const refParam = urlParams.get("_saasquatchExtra") || "";
|
|
1831
|
-
if (!refParam) {
|
|
1832
|
-
_log$3("No _saasquatchExtra param");
|
|
1140
|
+
const R = C("squatch-js");
|
|
1141
|
+
function Fe() {
|
|
1142
|
+
var u;
|
|
1143
|
+
const o = window.location.search, e = new URLSearchParams(o).get("_saasquatchExtra") || "";
|
|
1144
|
+
if (!e) {
|
|
1145
|
+
R("No _saasquatchExtra param");
|
|
1833
1146
|
return;
|
|
1834
1147
|
}
|
|
1835
|
-
const
|
|
1148
|
+
const n = q({
|
|
1836
1149
|
tenantAlias: "UNKNOWN"
|
|
1837
1150
|
});
|
|
1838
|
-
if (!
|
|
1839
|
-
|
|
1151
|
+
if (!n.domain) {
|
|
1152
|
+
R("domain must be provided in config to use _saasquatchExtra");
|
|
1840
1153
|
return;
|
|
1841
1154
|
}
|
|
1842
|
-
let
|
|
1155
|
+
let i;
|
|
1843
1156
|
try {
|
|
1844
|
-
|
|
1845
|
-
} catch
|
|
1846
|
-
|
|
1157
|
+
i = JSON.parse(L(e));
|
|
1158
|
+
} catch {
|
|
1159
|
+
R("Unable to decode _saasquatchExtra config");
|
|
1847
1160
|
return;
|
|
1848
1161
|
}
|
|
1849
|
-
function
|
|
1850
|
-
return
|
|
1162
|
+
function s(m) {
|
|
1163
|
+
return m.replace(/^https?:\/\//, "");
|
|
1851
1164
|
}
|
|
1852
|
-
const
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
_log$3("_saasquatchExtra did not have an expected structure");
|
|
1857
|
-
return void 0;
|
|
1165
|
+
const r = s(n.domain), a = Object.keys((i == null ? void 0 : i[r]) || {})[0], c = (u = i == null ? void 0 : i[r]) == null ? void 0 : u[a];
|
|
1166
|
+
if (!c) {
|
|
1167
|
+
R("_saasquatchExtra did not have an expected structure");
|
|
1168
|
+
return;
|
|
1858
1169
|
}
|
|
1859
|
-
const { autoPopupWidgetType, ...
|
|
1170
|
+
const { autoPopupWidgetType: d, ...h } = c;
|
|
1860
1171
|
return {
|
|
1861
1172
|
widgetConfig: {
|
|
1862
|
-
widgetType:
|
|
1863
|
-
displayOnLoad:
|
|
1864
|
-
...
|
|
1173
|
+
widgetType: d,
|
|
1174
|
+
displayOnLoad: !0,
|
|
1175
|
+
...h
|
|
1865
1176
|
},
|
|
1866
1177
|
squatchConfig: {
|
|
1867
|
-
...
|
|
1868
|
-
tenantAlias
|
|
1178
|
+
...n,
|
|
1179
|
+
tenantAlias: a
|
|
1869
1180
|
}
|
|
1870
1181
|
};
|
|
1871
1182
|
}
|
|
1872
|
-
const
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
skeletonBackgroundColor = "#e0e0e0",
|
|
1876
|
-
skeletonShimmerColor = "#f5f5f5"
|
|
1877
|
-
}) => {
|
|
1878
|
-
const referrerHTML = `
|
|
1879
|
-
<div class="hero-section">
|
|
1880
|
-
<div class="hero-content">
|
|
1881
|
-
<div class="skeleton sk-title-lg"></div>
|
|
1882
|
-
<div class="skeleton sk-text"></div>
|
|
1883
|
-
<div class="skeleton sk-text sk-text-short"></div>
|
|
1884
|
-
</div>
|
|
1885
|
-
<div class="skeleton hero-image"></div>
|
|
1886
|
-
</div>
|
|
1887
|
-
|
|
1888
|
-
<div class="share-section">
|
|
1889
|
-
<div class="skeleton sk-label"></div>
|
|
1890
|
-
<div class="skeleton sk-input"></div>
|
|
1891
|
-
<div class="social-buttons">
|
|
1892
|
-
<div class="skeleton sk-btn-social"></div>
|
|
1893
|
-
<div class="skeleton sk-btn-social"></div>
|
|
1894
|
-
<div class="skeleton sk-btn-social"></div>
|
|
1895
|
-
<div class="skeleton sk-btn-social"></div>
|
|
1896
|
-
</div>
|
|
1897
|
-
</div>
|
|
1898
|
-
|
|
1899
|
-
<div class="skeleton sk-title-md" style="margin-top: 0; width: 30%; margin-left: auto; margin-right: auto"></div>
|
|
1900
|
-
<div class="skeleton sk-text" style="width: 60%; margin-left: auto; margin-right: auto"></div>
|
|
1901
|
-
|
|
1902
|
-
<div class="stats-section">
|
|
1903
|
-
<div class="stat-card">
|
|
1904
|
-
<div class="skeleton sk-stat-num"></div>
|
|
1905
|
-
<div class="skeleton sk-stat-label"></div>
|
|
1906
|
-
</div>
|
|
1907
|
-
<div class="stat-card stat-divider">
|
|
1908
|
-
<div class="skeleton sk-stat-num"></div>
|
|
1909
|
-
<div class="skeleton sk-stat-label"></div>
|
|
1910
|
-
</div>
|
|
1911
|
-
</div>
|
|
1912
|
-
|
|
1913
|
-
<div class="skeleton sk-title-md"></div>
|
|
1914
|
-
|
|
1915
|
-
<div class="table-header">
|
|
1916
|
-
<div class="skeleton sk-th col-user"></div>
|
|
1917
|
-
<div class="skeleton sk-th col-status"></div>
|
|
1918
|
-
<div class="skeleton sk-th col-reward"></div>
|
|
1919
|
-
<div class="skeleton sk-th col-date"></div>
|
|
1920
|
-
</div>
|
|
1921
|
-
|
|
1922
|
-
<div class="table-row">
|
|
1923
|
-
<div class="col-user"><div class="skeleton sk-text" style="width: 70%; margin: 0"></div></div>
|
|
1924
|
-
<div class="col-status"><div class="skeleton sk-badge" style="margin: 0"></div></div>
|
|
1925
|
-
<div class="col-reward"><div class="skeleton sk-reward-block" style="margin: 0"></div></div>
|
|
1926
|
-
<div class="col-date"><div class="skeleton sk-text" style="width: 80%; margin: 0"></div></div>
|
|
1927
|
-
</div>
|
|
1928
|
-
|
|
1929
|
-
<div class="table-row">
|
|
1930
|
-
<div class="col-user"><div class="skeleton sk-text" style="width: 60%; margin: 0"></div></div>
|
|
1931
|
-
<div class="col-status"><div class="skeleton sk-badge" style="margin: 0"></div></div>
|
|
1932
|
-
<div class="col-reward"><div class="skeleton sk-reward-block" style="margin: 0"></div></div>
|
|
1933
|
-
<div class="col-date"><div class="skeleton sk-text" style="width: 80%; margin: 0"></div></div>
|
|
1934
|
-
</div>
|
|
1935
|
-
|
|
1936
|
-
<div class="table-row">
|
|
1937
|
-
<div class="col-user"><div class="skeleton sk-text" style="width: 75%; margin: 0"></div></div>
|
|
1938
|
-
<div class="col-status"><div class="skeleton sk-badge" style="margin: 0"></div></div>
|
|
1939
|
-
<div class="col-reward"><div class="skeleton sk-reward-block" style="margin: 0"></div></div>
|
|
1940
|
-
<div class="col-date"><div class="skeleton sk-text" style="width: 80%; margin: 0"></div></div>
|
|
1941
|
-
</div>
|
|
1942
|
-
|
|
1943
|
-
<div class="pagination">
|
|
1944
|
-
<div class="skeleton sk-btn-page"></div>
|
|
1945
|
-
<div class="skeleton sk-btn-page"></div>
|
|
1946
|
-
</div>
|
|
1947
|
-
`;
|
|
1948
|
-
const instantAccessHTML = `
|
|
1949
|
-
<div class="hero-section instant-access-layout">
|
|
1950
|
-
<div class="skeleton hero-image ia-image"></div>
|
|
1951
|
-
|
|
1952
|
-
<div class="hero-content ia-content">
|
|
1953
|
-
<div class="skeleton sk-title-lg ia-center"></div>
|
|
1954
|
-
<div class="skeleton sk-text ia-center"></div>
|
|
1955
|
-
|
|
1956
|
-
<div class="skeleton sk-btn-action"></div>
|
|
1957
|
-
|
|
1958
|
-
<div class="skeleton sk-label"></div>
|
|
1959
|
-
<div class="input-group">
|
|
1960
|
-
<div class="skeleton sk-input"></div>
|
|
1961
|
-
<div class="skeleton sk-btn-copy"></div>
|
|
1962
|
-
</div>
|
|
1963
|
-
|
|
1964
|
-
<div class="skeleton sk-text-short ia-center" style="margin-top: 20px; width: 30%"></div>
|
|
1965
|
-
<div class="skeleton sk-text-short ia-center" style="width: 20%"></div>
|
|
1966
|
-
</div>
|
|
1967
|
-
</div>
|
|
1968
|
-
`;
|
|
1969
|
-
return `
|
|
1970
|
-
<style>
|
|
1971
|
-
* {
|
|
1972
|
-
box-sizing: border-box;
|
|
1973
|
-
padding: 0;
|
|
1974
|
-
margin: 0;
|
|
1975
|
-
}
|
|
1976
|
-
|
|
1977
|
-
.widget-container {
|
|
1978
|
-
background: white;
|
|
1979
|
-
width: 100%;
|
|
1980
|
-
padding: 40px;
|
|
1981
|
-
box-sizing: border-box;
|
|
1982
|
-
overflow: hidden;
|
|
1983
|
-
}
|
|
1984
|
-
|
|
1985
|
-
@keyframes shimmer {
|
|
1986
|
-
0% { background-position: -100% 0; }
|
|
1987
|
-
100% { background-position: 100% 0; }
|
|
1988
|
-
}
|
|
1989
|
-
|
|
1990
|
-
.skeleton {
|
|
1991
|
-
background: ${skeletonBackgroundColor};
|
|
1992
|
-
background: linear-gradient(
|
|
1993
|
-
90deg,
|
|
1994
|
-
${skeletonBackgroundColor} 25%,
|
|
1995
|
-
${skeletonShimmerColor} 50%,
|
|
1996
|
-
${skeletonBackgroundColor} 75%
|
|
1997
|
-
);
|
|
1998
|
-
background-size: 200% 100%;
|
|
1999
|
-
animation: shimmer 1.5s infinite linear;
|
|
2000
|
-
border-radius: 6px;
|
|
2001
|
-
margin-bottom: 12px;
|
|
2002
|
-
}
|
|
2003
|
-
|
|
2004
|
-
/* Typography Skeletons */
|
|
2005
|
-
.sk-title-lg { height: 36px; width: 80%; margin-bottom: 16px; }
|
|
2006
|
-
.sk-title-md { height: 28px; width: 30%; margin-bottom: 20px; margin-top: 40px; }
|
|
2007
|
-
.sk-text { height: 16px; width: 90%; margin-bottom: 8px; }
|
|
2008
|
-
.sk-text-short { width: 40%; }
|
|
2009
|
-
.sk-label { height: 14px; width: 25%; margin-bottom: 10px; }
|
|
2010
|
-
|
|
2011
|
-
/* Layouts */
|
|
2012
|
-
.hero-section {
|
|
2013
|
-
display: flex;
|
|
2014
|
-
gap: 40px;
|
|
2015
|
-
margin-bottom: 40px;
|
|
2016
|
-
padding-bottom: 40px;
|
|
2017
|
-
flex-direction: row;
|
|
2018
|
-
height: 100%;
|
|
2019
|
-
/* Removed border-bottom */
|
|
2020
|
-
}
|
|
2021
|
-
|
|
2022
|
-
.hero-content {
|
|
2023
|
-
flex: 1;
|
|
2024
|
-
display: flex;
|
|
2025
|
-
flex-direction: column;
|
|
2026
|
-
justify-content: center;
|
|
2027
|
-
}
|
|
2028
|
-
|
|
2029
|
-
.hero-image {
|
|
2030
|
-
flex: 1;
|
|
2031
|
-
height: 300px;
|
|
2032
|
-
border-radius: 12px;
|
|
2033
|
-
}
|
|
2034
|
-
|
|
2035
|
-
/* -- Specific Instant Access Overrides -- */
|
|
2036
|
-
.instant-access-layout {
|
|
2037
|
-
margin-bottom: 0;
|
|
2038
|
-
padding-bottom: 0;
|
|
2039
|
-
align-items: center;
|
|
2040
|
-
}
|
|
2041
|
-
.ia-image {
|
|
2042
|
-
height: 400px;
|
|
2043
|
-
}
|
|
2044
|
-
.ia-center {
|
|
2045
|
-
margin-left: auto;
|
|
2046
|
-
margin-right: auto;
|
|
2047
|
-
}
|
|
2048
|
-
.ia-content {
|
|
2049
|
-
align-items: center;
|
|
2050
|
-
text-align: center;
|
|
2051
|
-
}
|
|
2052
|
-
.sk-btn-action {
|
|
2053
|
-
height: 45px;
|
|
2054
|
-
width: 140px;
|
|
2055
|
-
border-radius: 6px;
|
|
2056
|
-
margin: 24px auto;
|
|
2057
|
-
}
|
|
2058
|
-
.input-group {
|
|
2059
|
-
display: flex;
|
|
2060
|
-
gap: 10px;
|
|
2061
|
-
width: 100%;
|
|
2062
|
-
max-width: 400px;
|
|
2063
|
-
}
|
|
2064
|
-
.sk-btn-copy {
|
|
2065
|
-
height: 50px;
|
|
2066
|
-
width: 120px;
|
|
2067
|
-
border-radius: 8px;
|
|
2068
|
-
}
|
|
2069
|
-
/* ------------------------------------- */
|
|
2070
|
-
|
|
2071
|
-
.share-section { margin-bottom: 40px; }
|
|
2072
|
-
.sk-input { height: 50px; width: 100%; border-radius: 8px; margin-bottom: 16px; }
|
|
2073
|
-
|
|
2074
|
-
.social-buttons { display: flex; gap: 12px; }
|
|
2075
|
-
.sk-btn-social { flex: 1; height: 50px; border-radius: 8px; }
|
|
2076
|
-
|
|
2077
|
-
.stats-section {
|
|
2078
|
-
display: flex;
|
|
2079
|
-
gap: 24px;
|
|
2080
|
-
margin-bottom: 40px;
|
|
2081
|
-
padding: 30px 0;
|
|
2082
|
-
/* Removed border-top and border-bottom */
|
|
2083
|
-
}
|
|
2084
|
-
.stat-card { flex: 1; display: flex; flex-direction: column; align-items: center; }
|
|
2085
|
-
.stat-divider { padding-left: 24px; }
|
|
2086
|
-
.sk-stat-num { height: 48px; width: 120px; margin-bottom: 8px; }
|
|
2087
|
-
.sk-stat-label { height: 18px; width: 80px; }
|
|
2088
|
-
|
|
2089
|
-
/* Table Styles */
|
|
2090
|
-
.table-header { display: flex; gap: 16px; margin-bottom: 16px; }
|
|
2091
|
-
.sk-th { height: 16px; }
|
|
2092
|
-
.table-row {
|
|
2093
|
-
display: flex;
|
|
2094
|
-
align-items: center;
|
|
2095
|
-
gap: 16px;
|
|
2096
|
-
padding: 16px 0;
|
|
2097
|
-
/* Removed border-bottom */
|
|
2098
|
-
}
|
|
2099
|
-
|
|
2100
|
-
.col-user { flex: 2; }
|
|
2101
|
-
.col-status { flex: 1; }
|
|
2102
|
-
.col-reward { flex: 2; }
|
|
2103
|
-
.col-date { flex: 1; }
|
|
2104
|
-
|
|
2105
|
-
.sk-badge { height: 28px; width: 90px; border-radius: 14px; }
|
|
2106
|
-
.sk-reward-block { height: 36px; width: 100%; border-radius: 6px; }
|
|
2107
|
-
|
|
2108
|
-
.pagination { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
|
|
2109
|
-
.sk-btn-page { height: 36px; width: 64px; border-radius: 6px; margin-bottom: 0; }
|
|
2110
|
-
|
|
2111
|
-
@media (max-width: 768px) {
|
|
2112
|
-
body { padding: 20px; }
|
|
2113
|
-
.widget-container { padding: 24px; }
|
|
2114
|
-
|
|
2115
|
-
.hero-section { flex-direction: column-reverse; gap: 24px; }
|
|
2116
|
-
.instant-access-layout { flex-direction: column; }
|
|
2117
|
-
|
|
2118
|
-
.hero-image { height: 220px; width: 100%; }
|
|
2119
|
-
.sk-title-lg { width: 100%; }
|
|
2120
|
-
|
|
2121
|
-
.col-date { display: none; }
|
|
2122
|
-
}
|
|
2123
|
-
</style>
|
|
2124
|
-
|
|
2125
|
-
<div class="widget-container">
|
|
2126
|
-
${type === "verified-access" ? referrerHTML : instantAccessHTML}
|
|
2127
|
-
</div>
|
|
2128
|
-
`;
|
|
2129
|
-
};
|
|
2130
|
-
const _log$2 = browserExports.debug("squatch-js:decodeUserJwt");
|
|
2131
|
-
function decodeUserJwt(tokenStr) {
|
|
2132
|
-
var _a2;
|
|
1183
|
+
const He = C("squatch-js:decodeUserJwt");
|
|
1184
|
+
function Je(o) {
|
|
1185
|
+
var t;
|
|
2133
1186
|
try {
|
|
2134
|
-
const
|
|
2135
|
-
if (
|
|
2136
|
-
const
|
|
2137
|
-
return (
|
|
1187
|
+
const e = o.split(".")[1];
|
|
1188
|
+
if (e === void 0) return null;
|
|
1189
|
+
const n = L(e);
|
|
1190
|
+
return (t = JSON.parse(n)) == null ? void 0 : t.user;
|
|
2138
1191
|
} catch (e) {
|
|
2139
|
-
|
|
2140
|
-
return null;
|
|
1192
|
+
return He(e), null;
|
|
2141
1193
|
}
|
|
2142
1194
|
}
|
|
2143
|
-
const
|
|
2144
|
-
class
|
|
1195
|
+
const P = C("squatch-js:DeclarativeWidget");
|
|
1196
|
+
class ge extends HTMLElement {
|
|
2145
1197
|
constructor() {
|
|
2146
1198
|
super();
|
|
2147
1199
|
/**
|
|
2148
1200
|
* Configuration overrides
|
|
2149
1201
|
* @default window.squatchConfig
|
|
2150
1202
|
*/
|
|
2151
|
-
|
|
1203
|
+
l(this, "config");
|
|
2152
1204
|
/**
|
|
2153
1205
|
* Signed JWT containing user information
|
|
2154
1206
|
* @default window.squatchToken
|
|
2155
1207
|
*/
|
|
2156
|
-
|
|
1208
|
+
l(this, "token");
|
|
2157
1209
|
/**
|
|
2158
1210
|
* Tenant alias of SaaSquatch tenant
|
|
2159
1211
|
* @default window.squatchTenant
|
|
2160
1212
|
*/
|
|
2161
|
-
|
|
1213
|
+
l(this, "tenant");
|
|
2162
1214
|
/**
|
|
2163
1215
|
* widgetType of widget to load
|
|
2164
1216
|
*/
|
|
2165
|
-
|
|
1217
|
+
l(this, "widgetType");
|
|
2166
1218
|
/**
|
|
2167
1219
|
* Locale to render the widget in
|
|
2168
1220
|
*/
|
|
2169
|
-
|
|
1221
|
+
l(this, "locale");
|
|
2170
1222
|
/**
|
|
2171
1223
|
* Instance of {@link WidgetApi}
|
|
2172
1224
|
*/
|
|
2173
|
-
|
|
1225
|
+
l(this, "widgetApi");
|
|
2174
1226
|
/**
|
|
2175
1227
|
* Instance of {@link AnalyticsApi}
|
|
2176
1228
|
*/
|
|
2177
|
-
|
|
1229
|
+
l(this, "analyticsApi");
|
|
2178
1230
|
/**
|
|
2179
1231
|
* Instance of {@link EmbedWidget} or {@link PopupWidget}
|
|
2180
1232
|
*/
|
|
2181
|
-
|
|
1233
|
+
l(this, "widgetInstance");
|
|
2182
1234
|
/**
|
|
2183
1235
|
* Determines whether to render the widget as an embedding widget or popup widget
|
|
2184
1236
|
*/
|
|
2185
|
-
|
|
1237
|
+
l(this, "type");
|
|
2186
1238
|
/**
|
|
2187
1239
|
* Container element to contain the widget iframe
|
|
2188
1240
|
* @default this
|
|
2189
1241
|
*/
|
|
2190
|
-
|
|
2191
|
-
|
|
1242
|
+
l(this, "container");
|
|
1243
|
+
l(this, "element");
|
|
2192
1244
|
/**
|
|
2193
1245
|
* Flag for if the component has been loaded or not
|
|
2194
1246
|
* @hidden
|
|
2195
1247
|
*/
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
var
|
|
2199
|
-
const
|
|
1248
|
+
l(this, "loaded");
|
|
1249
|
+
l(this, "_setWidget", (e, n) => {
|
|
1250
|
+
var s;
|
|
1251
|
+
const i = {
|
|
2200
1252
|
api: this.widgetApi,
|
|
2201
|
-
content:
|
|
1253
|
+
content: e.template,
|
|
2202
1254
|
context: {
|
|
2203
|
-
type:
|
|
2204
|
-
user:
|
|
1255
|
+
type: n.type,
|
|
1256
|
+
user: n.user,
|
|
2205
1257
|
container: this.container || void 0,
|
|
2206
1258
|
engagementMedium: this.type,
|
|
2207
|
-
widgetConfig:
|
|
1259
|
+
widgetConfig: e.widgetConfig
|
|
2208
1260
|
},
|
|
2209
1261
|
type: this.widgetType,
|
|
2210
|
-
domain: ((
|
|
2211
|
-
npmCdn:
|
|
1262
|
+
domain: ((s = this.config) == null ? void 0 : s.domain) || k,
|
|
1263
|
+
npmCdn: X,
|
|
2212
1264
|
container: this
|
|
2213
1265
|
};
|
|
2214
|
-
if (this.type === "EMBED")
|
|
2215
|
-
return new
|
|
2216
|
-
|
|
2217
|
-
const
|
|
2218
|
-
return new
|
|
1266
|
+
if (this.type === "EMBED")
|
|
1267
|
+
return new D(i);
|
|
1268
|
+
{
|
|
1269
|
+
const r = this.firstChild ? null : void 0;
|
|
1270
|
+
return new j(i, r);
|
|
2219
1271
|
}
|
|
2220
1272
|
});
|
|
2221
1273
|
/**
|
|
2222
1274
|
* Builds a Widget instance for the default error widget
|
|
2223
1275
|
* @returns Instance of either {@link EmbedWidget} or {@link PopupWidget} depending on `this.type`
|
|
2224
1276
|
*/
|
|
2225
|
-
|
|
2226
|
-
var
|
|
2227
|
-
const
|
|
1277
|
+
l(this, "setErrorWidget", (e) => {
|
|
1278
|
+
var c;
|
|
1279
|
+
const n = e instanceof Error ? e.message : e == null ? void 0 : e.message, i = e == null ? void 0 : e.apiErrorCode, s = e == null ? void 0 : e.rsCode, r = e == null ? void 0 : e.statusCode, a = {
|
|
2228
1280
|
api: this.widgetApi,
|
|
2229
1281
|
content: "error",
|
|
2230
1282
|
context: {
|
|
@@ -2232,76 +1284,72 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
2232
1284
|
container: this.container || void 0
|
|
2233
1285
|
},
|
|
2234
1286
|
type: "ERROR_WIDGET",
|
|
2235
|
-
domain: ((
|
|
2236
|
-
npmCdn:
|
|
2237
|
-
container: this
|
|
1287
|
+
domain: ((c = this.config) == null ? void 0 : c.domain) || k,
|
|
1288
|
+
npmCdn: X,
|
|
1289
|
+
container: this,
|
|
1290
|
+
apiErrorCode: i,
|
|
1291
|
+
rsCode: s,
|
|
1292
|
+
statusCode: r,
|
|
1293
|
+
errorMessage: n
|
|
2238
1294
|
};
|
|
2239
|
-
if (this.type === "EMBED")
|
|
2240
|
-
return new
|
|
2241
|
-
|
|
2242
|
-
const
|
|
2243
|
-
return new
|
|
1295
|
+
if (this.type === "EMBED")
|
|
1296
|
+
return new D(a);
|
|
1297
|
+
{
|
|
1298
|
+
const d = this.firstChild ? null : void 0;
|
|
1299
|
+
return new j(a, d);
|
|
2244
1300
|
}
|
|
2245
1301
|
});
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
1302
|
+
l(this, "reload", this.renderWidget);
|
|
1303
|
+
l(this, "show", this.open);
|
|
1304
|
+
l(this, "hide", this.close);
|
|
2249
1305
|
this.attachShadow({
|
|
2250
1306
|
mode: "open"
|
|
2251
|
-
}).innerHTML =
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
this.container = this;
|
|
2256
|
-
}
|
|
2257
|
-
_setupApis(config) {
|
|
2258
|
-
var _a2, _b;
|
|
1307
|
+
}).innerHTML = "<style>:host { display: block; }</style><slot></slot>", this.config = Y(), this.token = W(), this.tenant = window.squatchTenant, this.container = this;
|
|
1308
|
+
}
|
|
1309
|
+
_setupApis(e) {
|
|
1310
|
+
var n, i;
|
|
2259
1311
|
if (!this.tenant) throw new Error("tenantAlias not provided");
|
|
2260
|
-
this.widgetApi = new
|
|
2261
|
-
tenantAlias: (
|
|
2262
|
-
domain: (
|
|
2263
|
-
})
|
|
2264
|
-
|
|
2265
|
-
domain: (config == null ? void 0 : config.domain) || ((_b = this.config) == null ? void 0 : _b.domain) || DEFAULT_DOMAIN
|
|
1312
|
+
this.widgetApi = new Z({
|
|
1313
|
+
tenantAlias: (e == null ? void 0 : e.tenantAlias) || this.tenant,
|
|
1314
|
+
domain: (e == null ? void 0 : e.domain) || ((n = this.config) == null ? void 0 : n.domain) || k
|
|
1315
|
+
}), this.analyticsApi = new ue({
|
|
1316
|
+
domain: (e == null ? void 0 : e.domain) || ((i = this.config) == null ? void 0 : i.domain) || k
|
|
2266
1317
|
});
|
|
2267
1318
|
}
|
|
2268
|
-
getWidgetType(
|
|
2269
|
-
|
|
2270
|
-
return "instant-access";
|
|
2271
|
-
}
|
|
2272
|
-
return "verified-access";
|
|
1319
|
+
getWidgetType(e) {
|
|
1320
|
+
return e && e.includes("friendWidget") ? "instant-access" : "verified-access";
|
|
2273
1321
|
}
|
|
2274
1322
|
async renderPasswordlessVariant() {
|
|
2275
|
-
this._setupApis()
|
|
2276
|
-
_log$1("Rendering as an Instant Access widget");
|
|
2277
|
-
return await this.widgetApi.render({
|
|
1323
|
+
return this._setupApis(), P("Rendering as an Instant Access widget"), await this.widgetApi.render({
|
|
2278
1324
|
engagementMedium: this.type,
|
|
2279
1325
|
widgetType: this.widgetType,
|
|
2280
1326
|
locale: this.locale
|
|
2281
|
-
}).then((
|
|
1327
|
+
}).then((e) => this._setWidget(e, { type: "passwordless" })).catch(this.setErrorWidget);
|
|
2282
1328
|
}
|
|
2283
1329
|
async renderUserUpsertVariant() {
|
|
2284
1330
|
this._setupApis();
|
|
2285
|
-
const
|
|
2286
|
-
if (!
|
|
1331
|
+
const e = Je(this.token);
|
|
1332
|
+
if (!e)
|
|
2287
1333
|
return this.setErrorWidget(Error("No user object in token."));
|
|
1334
|
+
!this.locale && e.locale && (this.locale = e.locale), P("Rendering as a Verified widget");
|
|
1335
|
+
try {
|
|
1336
|
+
await this.widgetApi.upsertUser({
|
|
1337
|
+
user: e,
|
|
1338
|
+
locale: this.locale,
|
|
1339
|
+
engagementMedium: this.type,
|
|
1340
|
+
widgetType: this.widgetType,
|
|
1341
|
+
jwt: this.token
|
|
1342
|
+
});
|
|
1343
|
+
} catch (i) {
|
|
1344
|
+
return this.setErrorWidget(
|
|
1345
|
+
i
|
|
1346
|
+
);
|
|
2288
1347
|
}
|
|
2289
|
-
|
|
2290
|
-
await this.widgetApi.upsertUser({
|
|
2291
|
-
user: userObj,
|
|
2292
|
-
locale: this.locale,
|
|
2293
|
-
engagementMedium: this.type,
|
|
2294
|
-
widgetType: this.widgetType,
|
|
2295
|
-
jwt: this.token
|
|
2296
|
-
});
|
|
2297
|
-
const widgetInstance = await this.widgetApi.render({
|
|
1348
|
+
return await this.widgetApi.render({
|
|
2298
1349
|
locale: this.locale,
|
|
2299
1350
|
engagementMedium: this.type,
|
|
2300
1351
|
widgetType: this.widgetType
|
|
2301
|
-
}).then((
|
|
2302
|
-
return this._setWidget(res, { type: "upsert", user: userObj });
|
|
2303
|
-
}).catch(this.setErrorWidget);
|
|
2304
|
-
return widgetInstance;
|
|
1352
|
+
}).then((i) => this._setWidget(i, { type: "upsert", user: e })).catch(this.setErrorWidget);
|
|
2305
1353
|
}
|
|
2306
1354
|
/**
|
|
2307
1355
|
* Fetches widget content from SaaSquatch and builds a Widget instance to support rendering the widget in the DOM
|
|
@@ -2309,26 +1357,19 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
2309
1357
|
* @throws Throws an Error if `widgetType` is undefined
|
|
2310
1358
|
*/
|
|
2311
1359
|
async getWidgetInstance() {
|
|
2312
|
-
let
|
|
2313
|
-
this.widgetType = this.getAttribute("widget") || void 0;
|
|
2314
|
-
|
|
1360
|
+
let e;
|
|
1361
|
+
this.widgetType = this.getAttribute("widget") || void 0, this.locale = this.getAttribute("locale") || this.locale;
|
|
1362
|
+
const n = this.getWidgetType(this.widgetType);
|
|
2315
1363
|
if (!this.widgetType) throw new Error("No widget has been specified");
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
widgetInstance = await this.renderUserUpsertVariant();
|
|
2320
|
-
}
|
|
2321
|
-
this.widgetInstance = widgetInstance;
|
|
2322
|
-
if (this.widgetInstance)
|
|
2323
|
-
this.dispatchEvent(new CustomEvent("sq:widget-loaded"));
|
|
2324
|
-
return widgetInstance;
|
|
1364
|
+
return !this.token && n === "verified-access" && P(
|
|
1365
|
+
"[SquatchJS] Authentication token is required for this widget type."
|
|
1366
|
+
), this.token ? e = await this.renderUserUpsertVariant() : e = await this.renderPasswordlessVariant(), this.widgetInstance = e, this.widgetInstance && this.dispatchEvent(new CustomEvent("sq:widget-loaded")), e;
|
|
2325
1367
|
}
|
|
2326
1368
|
/**
|
|
2327
1369
|
* Calls {@link getWidgetInstance} to build the Widget instance and loads the widget iframe into the DOM
|
|
2328
1370
|
*/
|
|
2329
1371
|
async renderWidget() {
|
|
2330
|
-
await this.getWidgetInstance();
|
|
2331
|
-
await this.widgetInstance.load();
|
|
1372
|
+
await this.getWidgetInstance(), await this.widgetInstance.load();
|
|
2332
1373
|
}
|
|
2333
1374
|
/**
|
|
2334
1375
|
* Calls `open` method of `widgetInstance`
|
|
@@ -2346,197 +1387,128 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
2346
1387
|
if (!this.widgetInstance) throw new Error("Widget has not loaded yet");
|
|
2347
1388
|
this.widgetInstance.close();
|
|
2348
1389
|
}
|
|
2349
|
-
}
|
|
2350
|
-
class DeclarativeEmbedWidget extends DeclarativeWidget {
|
|
2351
|
-
constructor() {
|
|
2352
|
-
super();
|
|
2353
|
-
this.type = "EMBED";
|
|
2354
|
-
this.loaded = false;
|
|
2355
|
-
}
|
|
2356
1390
|
static get observedAttributes() {
|
|
2357
1391
|
return ["widget", "locale"];
|
|
2358
1392
|
}
|
|
2359
|
-
attributeChangedCallback(
|
|
2360
|
-
if (
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
1393
|
+
attributeChangedCallback(e, n, i) {
|
|
1394
|
+
if (!(n === i || !this.loaded))
|
|
1395
|
+
switch (e) {
|
|
1396
|
+
case "locale":
|
|
1397
|
+
case "widget":
|
|
1398
|
+
this.connectedCallback();
|
|
1399
|
+
break;
|
|
1400
|
+
}
|
|
2367
1401
|
}
|
|
2368
1402
|
async connectedCallback() {
|
|
2369
|
-
this.loaded =
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
const
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
loadingElement.remove();
|
|
1403
|
+
this.loaded = !0, this.container = this.getAttribute("container"), this.widgetType = this.getAttribute("widget") || void 0;
|
|
1404
|
+
const e = this.getWidgetType(this.widgetType), { getSkeleton: n } = await import("./SkeletonTemplate-Day_0iMM.js"), i = n({
|
|
1405
|
+
type: e
|
|
1406
|
+
}), s = document.createElement("div");
|
|
1407
|
+
s.id = "loading-skeleton", s.innerHTML = i;
|
|
1408
|
+
const r = this.shadowRoot || this.attachShadow({ mode: "open" });
|
|
1409
|
+
if (this.type === "POPUP") {
|
|
1410
|
+
const a = r.getElementById("squatchModal");
|
|
1411
|
+
a ? (a.innerHTML = "", a.appendChild(s)) : r.appendChild(s);
|
|
1412
|
+
} else
|
|
1413
|
+
r.innerHTML = "", r.appendChild(s);
|
|
1414
|
+
try {
|
|
1415
|
+
await this.renderWidget();
|
|
1416
|
+
} catch (a) {
|
|
1417
|
+
P("Failed to render widget", a);
|
|
1418
|
+
} finally {
|
|
1419
|
+
const a = r.getElementById("loading-skeleton");
|
|
1420
|
+
a && a.remove();
|
|
2388
1421
|
}
|
|
2389
|
-
|
|
1422
|
+
this.getAttribute("open") !== null && this.open();
|
|
2390
1423
|
}
|
|
2391
1424
|
}
|
|
2392
|
-
class
|
|
1425
|
+
class pe extends ge {
|
|
2393
1426
|
constructor() {
|
|
2394
|
-
super();
|
|
2395
|
-
this.type = "POPUP";
|
|
2396
|
-
this.loaded = false;
|
|
2397
|
-
this.addEventListener("click", (e) => {
|
|
2398
|
-
e.stopPropagation();
|
|
2399
|
-
this.open();
|
|
2400
|
-
});
|
|
2401
|
-
}
|
|
2402
|
-
static get observedAttributes() {
|
|
2403
|
-
return ["widget", "locale"];
|
|
1427
|
+
super(), this.type = "EMBED", this.loaded = !1;
|
|
2404
1428
|
}
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
this.connectedCallback();
|
|
2411
|
-
break;
|
|
2412
|
-
}
|
|
2413
|
-
}
|
|
2414
|
-
async connectedCallback() {
|
|
2415
|
-
this.loaded = true;
|
|
2416
|
-
this.container = this.getAttribute("container");
|
|
2417
|
-
this.widgetType = this.getAttribute("widget") || void 0;
|
|
2418
|
-
const skeletonWidgetType = this.getWidgetType(this.widgetType);
|
|
2419
|
-
const skeletonHTML = getSkeleton({
|
|
2420
|
-
height: "100%",
|
|
2421
|
-
type: skeletonWidgetType
|
|
1429
|
+
}
|
|
1430
|
+
class we extends ge {
|
|
1431
|
+
constructor() {
|
|
1432
|
+
super(), this.type = "POPUP", this.loaded = !1, this.addEventListener("click", (t) => {
|
|
1433
|
+
t.stopPropagation(), this.open();
|
|
2422
1434
|
});
|
|
2423
|
-
const skeletonContainer = document.createElement("div");
|
|
2424
|
-
skeletonContainer.id = "loading-skeleton";
|
|
2425
|
-
skeletonContainer.innerHTML = skeletonHTML;
|
|
2426
|
-
const root = this.shadowRoot || this.attachShadow({ mode: "open" });
|
|
2427
|
-
const container = root.getElementById("#squatchModal");
|
|
2428
|
-
console.log("Container is ", container);
|
|
2429
|
-
if (container) {
|
|
2430
|
-
container.innerHTML = "";
|
|
2431
|
-
container.appendChild(skeletonContainer);
|
|
2432
|
-
}
|
|
2433
|
-
await this.renderWidget();
|
|
2434
|
-
const loadingElement = root.getElementById("loading-skeleton");
|
|
2435
|
-
if (loadingElement) {
|
|
2436
|
-
loadingElement.remove();
|
|
2437
|
-
}
|
|
2438
|
-
if (this.getAttribute("open") !== null) this.open();
|
|
2439
1435
|
}
|
|
2440
1436
|
}
|
|
2441
|
-
class
|
|
1437
|
+
class Be extends pe {
|
|
2442
1438
|
}
|
|
2443
|
-
class
|
|
1439
|
+
class Ge extends we {
|
|
2444
1440
|
}
|
|
2445
|
-
class
|
|
1441
|
+
class ze extends pe {
|
|
2446
1442
|
}
|
|
2447
|
-
class
|
|
1443
|
+
class Ve extends we {
|
|
2448
1444
|
}
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
window.customElements.define("squatch-popup", SquatchPopup);
|
|
2455
|
-
if (!window.customElements.get("impact-popup"))
|
|
2456
|
-
window.customElements.define("impact-popup", ImpactPopup);
|
|
2457
|
-
function help() {
|
|
1445
|
+
window.customElements.get("squatch-embed") || window.customElements.define("squatch-embed", Be);
|
|
1446
|
+
window.customElements.get("impact-embed") || window.customElements.define("impact-embed", ze);
|
|
1447
|
+
window.customElements.get("squatch-popup") || window.customElements.define("squatch-popup", Ge);
|
|
1448
|
+
window.customElements.get("impact-popup") || window.customElements.define("impact-popup", Ve);
|
|
1449
|
+
function Ye() {
|
|
2458
1450
|
console.log(
|
|
2459
|
-
|
|
1451
|
+
"Having trouble using Squatch.js? Go to https://docs.referralsaasquatch.com/developer/ for tutorials, references and error codes."
|
|
2460
1452
|
);
|
|
2461
1453
|
}
|
|
2462
|
-
const
|
|
2463
|
-
let
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
function api() {
|
|
2467
|
-
if (!_api) init({});
|
|
2468
|
-
return _api;
|
|
1454
|
+
const $ = C("squatch-js");
|
|
1455
|
+
let F = null, H = null, J = null;
|
|
1456
|
+
function Ze() {
|
|
1457
|
+
return F || G({}), F;
|
|
2469
1458
|
}
|
|
2470
|
-
function
|
|
2471
|
-
|
|
2472
|
-
return _widgets;
|
|
1459
|
+
function K() {
|
|
1460
|
+
return H || G({}), H;
|
|
2473
1461
|
}
|
|
2474
|
-
function
|
|
2475
|
-
|
|
2476
|
-
return _events;
|
|
1462
|
+
function Ke() {
|
|
1463
|
+
return J || G({}), J;
|
|
2477
1464
|
}
|
|
2478
|
-
function
|
|
2479
|
-
var
|
|
2480
|
-
return (
|
|
1465
|
+
function et(o) {
|
|
1466
|
+
var t;
|
|
1467
|
+
return (t = K()) == null ? void 0 : t.render(o);
|
|
2481
1468
|
}
|
|
2482
|
-
function
|
|
2483
|
-
var
|
|
2484
|
-
const
|
|
2485
|
-
if (
|
|
2486
|
-
const { squatchConfig, widgetConfig } =
|
|
2487
|
-
|
|
2488
|
-
return (_a2 = widgets()) == null ? void 0 : _a2.render(widgetConfig);
|
|
1469
|
+
function tt() {
|
|
1470
|
+
var t;
|
|
1471
|
+
const o = Fe();
|
|
1472
|
+
if (o) {
|
|
1473
|
+
const { squatchConfig: e, widgetConfig: n } = o;
|
|
1474
|
+
return G(e), (t = K()) == null ? void 0 : t.render(n);
|
|
2489
1475
|
}
|
|
2490
1476
|
}
|
|
2491
|
-
function
|
|
2492
|
-
const
|
|
2493
|
-
|
|
2494
|
-
if (config.tenantAlias.match("^test") || config.debug) {
|
|
2495
|
-
browserExports.debug.enable("squatch-js*");
|
|
2496
|
-
} else {
|
|
2497
|
-
browserExports.debug.disable();
|
|
2498
|
-
}
|
|
2499
|
-
_log("initializing ...");
|
|
2500
|
-
_api = new WidgetApi(config);
|
|
2501
|
-
_widgets = new Widgets(config);
|
|
2502
|
-
_events = new EventsApi(config);
|
|
2503
|
-
_log("Widget API instance", _api);
|
|
2504
|
-
_log("Widgets instance", _widgets);
|
|
2505
|
-
_log("Events API instance", _events);
|
|
1477
|
+
function G(o) {
|
|
1478
|
+
const e = q(o);
|
|
1479
|
+
e.tenantAlias.match("^test") || e.debug ? ve("squatch-js*") : _e(), $("initializing ..."), F = new Z(e), H = new N(e), J = new Oe(e), $("Widget API instance", F), $("Widgets instance", H), $("Events API instance", J);
|
|
2506
1480
|
}
|
|
2507
|
-
function
|
|
2508
|
-
|
|
1481
|
+
function nt(o) {
|
|
1482
|
+
o();
|
|
2509
1483
|
}
|
|
2510
|
-
function
|
|
2511
|
-
|
|
1484
|
+
function it(o) {
|
|
1485
|
+
K().autofill(o);
|
|
2512
1486
|
}
|
|
2513
|
-
function
|
|
2514
|
-
|
|
1487
|
+
function Xe() {
|
|
1488
|
+
Te();
|
|
2515
1489
|
}
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
);
|
|
2523
|
-
if (typeof document !== "undefined") asyncLoad();
|
|
1490
|
+
typeof document < "u" && !window.SaaSquatchDoNotAutoDrop && Xe();
|
|
1491
|
+
var ae;
|
|
1492
|
+
(ae = window.squatch) != null && ae.init && $(
|
|
1493
|
+
"Squatchjs is being loaded more than once. This may lead to multiple load events being sent, duplicated widgets, and inaccurate analytics."
|
|
1494
|
+
);
|
|
1495
|
+
typeof document < "u" && Ne();
|
|
2524
1496
|
export {
|
|
2525
|
-
DeclarativeEmbedWidget,
|
|
2526
|
-
DeclarativePopupWidget,
|
|
2527
|
-
EmbedWidget,
|
|
2528
|
-
PopupWidget,
|
|
2529
|
-
WidgetApi,
|
|
2530
|
-
Widgets,
|
|
2531
|
-
_auto,
|
|
2532
|
-
api,
|
|
2533
|
-
autofill,
|
|
2534
|
-
events,
|
|
2535
|
-
help,
|
|
2536
|
-
init,
|
|
2537
|
-
pushCookie,
|
|
2538
|
-
ready,
|
|
2539
|
-
widget,
|
|
2540
|
-
widgets
|
|
1497
|
+
pe as DeclarativeEmbedWidget,
|
|
1498
|
+
we as DeclarativePopupWidget,
|
|
1499
|
+
D as EmbedWidget,
|
|
1500
|
+
j as PopupWidget,
|
|
1501
|
+
Z as WidgetApi,
|
|
1502
|
+
N as Widgets,
|
|
1503
|
+
tt as _auto,
|
|
1504
|
+
Ze as api,
|
|
1505
|
+
it as autofill,
|
|
1506
|
+
Ke as events,
|
|
1507
|
+
Ye as help,
|
|
1508
|
+
G as init,
|
|
1509
|
+
Xe as pushCookie,
|
|
1510
|
+
nt as ready,
|
|
1511
|
+
et as widget,
|
|
1512
|
+
K as widgets
|
|
2541
1513
|
};
|
|
2542
1514
|
//# sourceMappingURL=squatch.esm.js.map
|