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