@saasquatch/squatch-js 2.7.0-3 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/dist/squatch.cjs.js +2119 -7
- package/dist/squatch.cjs.js.map +1 -1
- package/dist/squatch.esm.js +2161 -0
- package/dist/squatch.esm.js.map +1 -0
- package/dist/squatch.js +2125 -9
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +6 -0
- package/package.json +10 -9
- package/vite.config.ts +10 -3
- package/coverage/clover.xml +0 -917
- package/coverage/coverage-final.json +0 -21
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov.info +0 -1669
- package/dist/squatch.es.js +0 -1623
- package/dist/squatch.es.js.map +0 -1
- package/dist copy/api/AnalyticsApi.d.ts +0 -32
- package/dist copy/api/EventsApi.d.ts +0 -52
- package/dist copy/api/WidgetApi.d.ts +0 -64
- package/dist copy/api/graphql.d.ts +0 -1
- package/dist copy/async.d.ts +0 -20
- package/dist copy/docs.d.ts +0 -1
- package/dist copy/globals.d.ts +0 -4
- package/dist copy/squatch.cjs.js +0 -48
- package/dist copy/squatch.d.ts +0 -122
- package/dist copy/squatch.es.js +0 -1622
- package/dist copy/squatch.esm.js +0 -2317
- package/dist copy/squatch.esm.js.map +0 -1
- package/dist copy/squatch.js +0 -2337
- package/dist copy/squatch.js.map +0 -1
- package/dist copy/types.d.ts +0 -109
- package/dist copy/utils/cookieUtils.d.ts +0 -3
- package/dist copy/utils/decodeUserJwt.d.ts +0 -2
- package/dist copy/utils/domready.d.ts +0 -6
- package/dist copy/utils/io.d.ts +0 -5
- package/dist copy/utils/utmUtils.d.ts +0 -14
- package/dist copy/utils/validate.d.ts +0 -12
- package/dist copy/widgets/EmbedWidget.d.ts +0 -25
- package/dist copy/widgets/PopupWidget.d.ts +0 -30
- package/dist copy/widgets/Widget.d.ts +0 -57
- package/dist copy/widgets/Widgets.d.ts +0 -112
- package/dist copy/widgets/declarative/DeclarativeWidget.d.ts +0 -100
- package/dist copy/widgets/declarative/DeclarativeWidgets.d.ts +0 -35
package/dist/squatch.es.js
DELETED
|
@@ -1,1623 +0,0 @@
|
|
|
1
|
-
var ve = Object.defineProperty;
|
|
2
|
-
var Ae = (i, n, t) => n in i ? ve(i, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[n] = t;
|
|
3
|
-
var p = (i, n, t) => Ae(i, typeof n != "symbol" ? n + "" : n, t);
|
|
4
|
-
function Ie(i) {
|
|
5
|
-
return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
|
|
6
|
-
}
|
|
7
|
-
var U = { exports: {} }, z, oe;
|
|
8
|
-
function _e() {
|
|
9
|
-
if (oe) return z;
|
|
10
|
-
oe = 1;
|
|
11
|
-
var i = 1e3, n = i * 60, t = n * 60, e = t * 24, o = e * 7, r = e * 365.25;
|
|
12
|
-
z = function(s, c) {
|
|
13
|
-
c = c || {};
|
|
14
|
-
var l = typeof s;
|
|
15
|
-
if (l === "string" && s.length > 0)
|
|
16
|
-
return a(s);
|
|
17
|
-
if (l === "number" && isFinite(s))
|
|
18
|
-
return c.long ? u(s) : d(s);
|
|
19
|
-
throw new Error(
|
|
20
|
-
"val is not a non-empty string or a valid number. val=" + JSON.stringify(s)
|
|
21
|
-
);
|
|
22
|
-
};
|
|
23
|
-
function a(s) {
|
|
24
|
-
if (s = String(s), !(s.length > 100)) {
|
|
25
|
-
var c = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
26
|
-
s
|
|
27
|
-
);
|
|
28
|
-
if (c) {
|
|
29
|
-
var l = parseFloat(c[1]), m = (c[2] || "ms").toLowerCase();
|
|
30
|
-
switch (m) {
|
|
31
|
-
case "years":
|
|
32
|
-
case "year":
|
|
33
|
-
case "yrs":
|
|
34
|
-
case "yr":
|
|
35
|
-
case "y":
|
|
36
|
-
return l * r;
|
|
37
|
-
case "weeks":
|
|
38
|
-
case "week":
|
|
39
|
-
case "w":
|
|
40
|
-
return l * o;
|
|
41
|
-
case "days":
|
|
42
|
-
case "day":
|
|
43
|
-
case "d":
|
|
44
|
-
return l * e;
|
|
45
|
-
case "hours":
|
|
46
|
-
case "hour":
|
|
47
|
-
case "hrs":
|
|
48
|
-
case "hr":
|
|
49
|
-
case "h":
|
|
50
|
-
return l * t;
|
|
51
|
-
case "minutes":
|
|
52
|
-
case "minute":
|
|
53
|
-
case "mins":
|
|
54
|
-
case "min":
|
|
55
|
-
case "m":
|
|
56
|
-
return l * n;
|
|
57
|
-
case "seconds":
|
|
58
|
-
case "second":
|
|
59
|
-
case "secs":
|
|
60
|
-
case "sec":
|
|
61
|
-
case "s":
|
|
62
|
-
return l * i;
|
|
63
|
-
case "milliseconds":
|
|
64
|
-
case "millisecond":
|
|
65
|
-
case "msecs":
|
|
66
|
-
case "msec":
|
|
67
|
-
case "ms":
|
|
68
|
-
return l;
|
|
69
|
-
default:
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function d(s) {
|
|
76
|
-
var c = Math.abs(s);
|
|
77
|
-
return c >= e ? Math.round(s / e) + "d" : c >= t ? Math.round(s / t) + "h" : c >= n ? Math.round(s / n) + "m" : c >= i ? Math.round(s / i) + "s" : s + "ms";
|
|
78
|
-
}
|
|
79
|
-
function u(s) {
|
|
80
|
-
var c = Math.abs(s);
|
|
81
|
-
return c >= e ? h(s, c, e, "day") : c >= t ? h(s, c, t, "hour") : c >= n ? h(s, c, n, "minute") : c >= i ? h(s, c, i, "second") : s + " ms";
|
|
82
|
-
}
|
|
83
|
-
function h(s, c, l, m) {
|
|
84
|
-
var f = c >= l * 1.5;
|
|
85
|
-
return Math.round(s / l) + " " + m + (f ? "s" : "");
|
|
86
|
-
}
|
|
87
|
-
return z;
|
|
88
|
-
}
|
|
89
|
-
var H, ie;
|
|
90
|
-
function Fe() {
|
|
91
|
-
if (ie) return H;
|
|
92
|
-
ie = 1;
|
|
93
|
-
function i(n) {
|
|
94
|
-
e.debug = e, e.default = e, e.coerce = h, e.disable = d, e.enable = a, e.enabled = u, e.humanize = _e(), Object.keys(n).forEach(function(s) {
|
|
95
|
-
e[s] = n[s];
|
|
96
|
-
}), e.instances = [], e.names = [], e.skips = [], e.formatters = {};
|
|
97
|
-
function t(s) {
|
|
98
|
-
for (var c = 0, l = 0; l < s.length; l++)
|
|
99
|
-
c = (c << 5) - c + s.charCodeAt(l), c |= 0;
|
|
100
|
-
return e.colors[Math.abs(c) % e.colors.length];
|
|
101
|
-
}
|
|
102
|
-
e.selectColor = t;
|
|
103
|
-
function e(s) {
|
|
104
|
-
var c;
|
|
105
|
-
function l() {
|
|
106
|
-
if (l.enabled) {
|
|
107
|
-
for (var m = arguments.length, f = new Array(m), b = 0; b < m; b++)
|
|
108
|
-
f[b] = arguments[b];
|
|
109
|
-
var w = l, y = Number(/* @__PURE__ */ new Date()), ye = y - (c || y);
|
|
110
|
-
w.diff = ye, w.prev = c, w.curr = y, c = y, f[0] = e.coerce(f[0]), typeof f[0] != "string" && f.unshift("%O");
|
|
111
|
-
var x = 0;
|
|
112
|
-
f[0] = f[0].replace(/%([a-zA-Z%])/g, function(R, Ee) {
|
|
113
|
-
if (R === "%%")
|
|
114
|
-
return R;
|
|
115
|
-
x++;
|
|
116
|
-
var ne = e.formatters[Ee];
|
|
117
|
-
if (typeof ne == "function") {
|
|
118
|
-
var be = f[x];
|
|
119
|
-
R = ne.call(w, be), f.splice(x, 1), x--;
|
|
120
|
-
}
|
|
121
|
-
return R;
|
|
122
|
-
}), e.formatArgs.call(w, f);
|
|
123
|
-
var Ce = w.log || e.log;
|
|
124
|
-
Ce.apply(w, f);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return l.namespace = s, l.enabled = e.enabled(s), l.useColors = e.useColors(), l.color = t(s), l.destroy = o, l.extend = r, typeof e.init == "function" && e.init(l), e.instances.push(l), l;
|
|
128
|
-
}
|
|
129
|
-
function o() {
|
|
130
|
-
var s = e.instances.indexOf(this);
|
|
131
|
-
return s !== -1 ? (e.instances.splice(s, 1), !0) : !1;
|
|
132
|
-
}
|
|
133
|
-
function r(s, c) {
|
|
134
|
-
return e(this.namespace + (typeof c > "u" ? ":" : c) + s);
|
|
135
|
-
}
|
|
136
|
-
function a(s) {
|
|
137
|
-
e.save(s), e.names = [], e.skips = [];
|
|
138
|
-
var c, l = (typeof s == "string" ? s : "").split(/[\s,]+/), m = l.length;
|
|
139
|
-
for (c = 0; c < m; c++)
|
|
140
|
-
l[c] && (s = l[c].replace(/\*/g, ".*?"), s[0] === "-" ? e.skips.push(new RegExp("^" + s.substr(1) + "$")) : e.names.push(new RegExp("^" + s + "$")));
|
|
141
|
-
for (c = 0; c < e.instances.length; c++) {
|
|
142
|
-
var f = e.instances[c];
|
|
143
|
-
f.enabled = e.enabled(f.namespace);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
function d() {
|
|
147
|
-
e.enable("");
|
|
148
|
-
}
|
|
149
|
-
function u(s) {
|
|
150
|
-
if (s[s.length - 1] === "*")
|
|
151
|
-
return !0;
|
|
152
|
-
var c, l;
|
|
153
|
-
for (c = 0, l = e.skips.length; c < l; c++)
|
|
154
|
-
if (e.skips[c].test(s))
|
|
155
|
-
return !1;
|
|
156
|
-
for (c = 0, l = e.names.length; c < l; c++)
|
|
157
|
-
if (e.names[c].test(s))
|
|
158
|
-
return !0;
|
|
159
|
-
return !1;
|
|
160
|
-
}
|
|
161
|
-
function h(s) {
|
|
162
|
-
return s instanceof Error ? s.stack || s.message : s;
|
|
163
|
-
}
|
|
164
|
-
return e.enable(e.load()), e;
|
|
165
|
-
}
|
|
166
|
-
return H = i, H;
|
|
167
|
-
}
|
|
168
|
-
var re;
|
|
169
|
-
function ke() {
|
|
170
|
-
return re || (re = 1, function(i, n) {
|
|
171
|
-
function t(s) {
|
|
172
|
-
return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? t = function(l) {
|
|
173
|
-
return typeof l;
|
|
174
|
-
} : t = function(l) {
|
|
175
|
-
return l && typeof Symbol == "function" && l.constructor === Symbol && l !== Symbol.prototype ? "symbol" : typeof l;
|
|
176
|
-
}, t(s);
|
|
177
|
-
}
|
|
178
|
-
n.log = r, n.formatArgs = o, n.save = a, n.load = d, n.useColors = e, n.storage = u(), n.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"];
|
|
179
|
-
function e() {
|
|
180
|
-
return typeof window < "u" && window.process && (window.process.type === "renderer" || window.process.__nwjs) ? !0 : typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/) ? !1 : typeof document < "u" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
|
181
|
-
typeof window < "u" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
|
182
|
-
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
183
|
-
typeof navigator < "u" && 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
|
|
184
|
-
typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
185
|
-
}
|
|
186
|
-
function o(s) {
|
|
187
|
-
if (s[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + s[0] + (this.useColors ? "%c " : " ") + "+" + i.exports.humanize(this.diff), !!this.useColors) {
|
|
188
|
-
var c = "color: " + this.color;
|
|
189
|
-
s.splice(1, 0, c, "color: inherit");
|
|
190
|
-
var l = 0, m = 0;
|
|
191
|
-
s[0].replace(/%[a-zA-Z%]/g, function(f) {
|
|
192
|
-
f !== "%%" && (l++, f === "%c" && (m = l));
|
|
193
|
-
}), s.splice(m, 0, c);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
function r() {
|
|
197
|
-
var s;
|
|
198
|
-
return (typeof console > "u" ? "undefined" : t(console)) === "object" && console.log && (s = console).log.apply(s, arguments);
|
|
199
|
-
}
|
|
200
|
-
function a(s) {
|
|
201
|
-
try {
|
|
202
|
-
s ? n.storage.setItem("debug", s) : n.storage.removeItem("debug");
|
|
203
|
-
} catch {
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
function d() {
|
|
207
|
-
var s;
|
|
208
|
-
try {
|
|
209
|
-
s = n.storage.getItem("debug");
|
|
210
|
-
} catch {
|
|
211
|
-
}
|
|
212
|
-
return !s && typeof process < "u" && "env" in process && (s = process.env.DEBUG), s;
|
|
213
|
-
}
|
|
214
|
-
function u() {
|
|
215
|
-
try {
|
|
216
|
-
return localStorage;
|
|
217
|
-
} catch {
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
i.exports = Fe()(n);
|
|
221
|
-
var h = i.exports.formatters;
|
|
222
|
-
h.j = function(s) {
|
|
223
|
-
try {
|
|
224
|
-
return JSON.stringify(s);
|
|
225
|
-
} catch (c) {
|
|
226
|
-
return "[UnexpectedJSONParseError]: " + c.message;
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
}(U, U.exports)), U.exports;
|
|
230
|
-
}
|
|
231
|
-
var g = ke();
|
|
232
|
-
const qe = /* @__PURE__ */ Ie(g);
|
|
233
|
-
/*! js-cookie v3.0.5 | MIT */
|
|
234
|
-
function T(i) {
|
|
235
|
-
for (var n = 1; n < arguments.length; n++) {
|
|
236
|
-
var t = arguments[n];
|
|
237
|
-
for (var e in t)
|
|
238
|
-
i[e] = t[e];
|
|
239
|
-
}
|
|
240
|
-
return i;
|
|
241
|
-
}
|
|
242
|
-
var xe = {
|
|
243
|
-
read: function(i) {
|
|
244
|
-
return i[0] === '"' && (i = i.slice(1, -1)), i.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
|
245
|
-
},
|
|
246
|
-
write: function(i) {
|
|
247
|
-
return encodeURIComponent(i).replace(
|
|
248
|
-
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
|
|
249
|
-
decodeURIComponent
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
function X(i, n) {
|
|
254
|
-
function t(o, r, a) {
|
|
255
|
-
if (!(typeof document > "u")) {
|
|
256
|
-
a = T({}, n, a), typeof a.expires == "number" && (a.expires = new Date(Date.now() + a.expires * 864e5)), a.expires && (a.expires = a.expires.toUTCString()), o = encodeURIComponent(o).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
|
|
257
|
-
var d = "";
|
|
258
|
-
for (var u in a)
|
|
259
|
-
a[u] && (d += "; " + u, a[u] !== !0 && (d += "=" + a[u].split(";")[0]));
|
|
260
|
-
return document.cookie = o + "=" + i.write(r, o) + d;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
function e(o) {
|
|
264
|
-
if (!(typeof document > "u" || arguments.length && !o)) {
|
|
265
|
-
for (var r = document.cookie ? document.cookie.split("; ") : [], a = {}, d = 0; d < r.length; d++) {
|
|
266
|
-
var u = r[d].split("="), h = u.slice(1).join("=");
|
|
267
|
-
try {
|
|
268
|
-
var s = decodeURIComponent(u[0]);
|
|
269
|
-
if (a[s] = i.read(h, s), o === s)
|
|
270
|
-
break;
|
|
271
|
-
} catch {
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
return o ? a[o] : a;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
return Object.create(
|
|
278
|
-
{
|
|
279
|
-
set: t,
|
|
280
|
-
get: e,
|
|
281
|
-
remove: function(o, r) {
|
|
282
|
-
t(
|
|
283
|
-
o,
|
|
284
|
-
"",
|
|
285
|
-
T({}, r, {
|
|
286
|
-
expires: -1
|
|
287
|
-
})
|
|
288
|
-
);
|
|
289
|
-
},
|
|
290
|
-
withAttributes: function(o) {
|
|
291
|
-
return X(this.converter, T({}, this.attributes, o));
|
|
292
|
-
},
|
|
293
|
-
withConverter: function(o) {
|
|
294
|
-
return X(T({}, this.converter, o), this.attributes);
|
|
295
|
-
}
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
attributes: { value: Object.freeze(n) },
|
|
299
|
-
converter: { value: Object.freeze(i) }
|
|
300
|
-
}
|
|
301
|
-
);
|
|
302
|
-
}
|
|
303
|
-
var P = X(xe, { path: "/" });
|
|
304
|
-
const I = "https://app.referralsaasquatch.com", Q = "https://fast.ssqt.io/npm", S = "squatch", G = "impact";
|
|
305
|
-
function J(i) {
|
|
306
|
-
if (typeof i != "object") throw new Error("config must be an object");
|
|
307
|
-
const n = window.squatchTenant, t = K(), e = {
|
|
308
|
-
tenantAlias: (i == null ? void 0 : i.tenantAlias) || n,
|
|
309
|
-
domain: (i == null ? void 0 : i.domain) || (t == null ? void 0 : t.domain),
|
|
310
|
-
npmCdn: (i == null ? void 0 : i.npmCdn) || (t == null ? void 0 : t.npmCdn),
|
|
311
|
-
debug: (i == null ? void 0 : i.debug) || (t == null ? void 0 : t.debug)
|
|
312
|
-
};
|
|
313
|
-
if (typeof e.tenantAlias != "string")
|
|
314
|
-
throw new Error("tenantAlias not provided");
|
|
315
|
-
const o = e.tenantAlias, r = typeof e.domain == "string" && e.domain || I, a = typeof e.debug == "boolean" && e.debug || !1, d = typeof e.npmCdn == "string" && e.npmCdn || Q;
|
|
316
|
-
return {
|
|
317
|
-
tenantAlias: o,
|
|
318
|
-
domain: r,
|
|
319
|
-
debug: a,
|
|
320
|
-
npmCdn: d
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
function _(i) {
|
|
324
|
-
return typeof i == "object" && !Array.isArray(i) && i !== null;
|
|
325
|
-
}
|
|
326
|
-
function Re(i) {
|
|
327
|
-
if (i && /^[a-z]{2}_(?:[A-Z]{2}|[0-9]{3})$/.test(i))
|
|
328
|
-
return i;
|
|
329
|
-
}
|
|
330
|
-
function le(i) {
|
|
331
|
-
if (!_(i)) throw new Error("Widget properties must be an object");
|
|
332
|
-
if (!(i != null && i.user)) throw new Error("Required properties missing.");
|
|
333
|
-
return i;
|
|
334
|
-
}
|
|
335
|
-
function ue(i) {
|
|
336
|
-
if (!_(i)) throw new Error("Widget properties must be an object");
|
|
337
|
-
return i;
|
|
338
|
-
}
|
|
339
|
-
function q() {
|
|
340
|
-
return window.impactToken || window.squatchToken;
|
|
341
|
-
}
|
|
342
|
-
function K() {
|
|
343
|
-
return window.impactConfig || window.squatchConfig;
|
|
344
|
-
}
|
|
345
|
-
g.debug("squatch-js:io");
|
|
346
|
-
async function Ue(i, n, t, e) {
|
|
347
|
-
const o = e || q(), r = {
|
|
348
|
-
Accept: "application/json",
|
|
349
|
-
"Content-Type": "application/json",
|
|
350
|
-
...o ? { Authorization: `Bearer ${o}` } : {},
|
|
351
|
-
"X-SaaSquatch-Referrer": window ? window.location.href : ""
|
|
352
|
-
};
|
|
353
|
-
try {
|
|
354
|
-
const a = await fetch(i, {
|
|
355
|
-
method: "POST",
|
|
356
|
-
body: JSON.stringify({ query: n, variables: t }),
|
|
357
|
-
headers: r
|
|
358
|
-
});
|
|
359
|
-
if (!a.ok) throw new Error(await a.text());
|
|
360
|
-
return await a.json();
|
|
361
|
-
} catch (a) {
|
|
362
|
-
throw a;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
async function Te(i, n = "") {
|
|
366
|
-
const t = {
|
|
367
|
-
Accept: "application/json",
|
|
368
|
-
"Content-Type": "application/json"
|
|
369
|
-
}, e = n || q();
|
|
370
|
-
e && (t["X-SaaSquatch-User-Token"] = e);
|
|
371
|
-
try {
|
|
372
|
-
const o = await fetch(i, {
|
|
373
|
-
method: "GET",
|
|
374
|
-
credentials: "include",
|
|
375
|
-
headers: t
|
|
376
|
-
}), r = await o.text();
|
|
377
|
-
if (!o.ok) throw new Error(r);
|
|
378
|
-
return r && JSON.parse(r);
|
|
379
|
-
} catch (o) {
|
|
380
|
-
throw o;
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
async function Y(i, n, t) {
|
|
384
|
-
const e = {
|
|
385
|
-
Accept: "application/json",
|
|
386
|
-
"Content-Type": "application/json"
|
|
387
|
-
}, o = t || q();
|
|
388
|
-
o && (e["X-SaaSquatch-User-Token"] = o);
|
|
389
|
-
try {
|
|
390
|
-
const r = await fetch(i, {
|
|
391
|
-
method: "POST",
|
|
392
|
-
body: n,
|
|
393
|
-
headers: e
|
|
394
|
-
}), a = await r.text();
|
|
395
|
-
if (!r.ok) throw new Error(a);
|
|
396
|
-
return a && JSON.parse(a);
|
|
397
|
-
} catch (r) {
|
|
398
|
-
throw r;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
async function Se(i, n, t) {
|
|
402
|
-
const e = {
|
|
403
|
-
Accept: "application/json",
|
|
404
|
-
"Content-Type": "application/json",
|
|
405
|
-
"X-SaaSquatch-Referrer": window ? window.location.href : ""
|
|
406
|
-
}, o = t || q();
|
|
407
|
-
o && (e["X-SaaSquatch-User-Token"] = o);
|
|
408
|
-
try {
|
|
409
|
-
const r = await fetch(i, {
|
|
410
|
-
headers: e,
|
|
411
|
-
method: "PUT",
|
|
412
|
-
credentials: "include",
|
|
413
|
-
body: n
|
|
414
|
-
}), a = await r.text();
|
|
415
|
-
if (!r.ok) throw new Error(a);
|
|
416
|
-
return a && JSON.parse(a);
|
|
417
|
-
} catch (r) {
|
|
418
|
-
throw r;
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
const Me = `
|
|
422
|
-
query renderWidget ($user: UserIdInput, $engagementMedium: UserEngagementMedium, $widgetType: WidgetType, $locale: RSLocale) {
|
|
423
|
-
renderWidget(user: $user, engagementMedium: $engagementMedium, widgetType: $widgetType, locale: $locale) {
|
|
424
|
-
template
|
|
425
|
-
user {
|
|
426
|
-
id
|
|
427
|
-
accountId
|
|
428
|
-
}
|
|
429
|
-
jsOptions
|
|
430
|
-
widgetConfig {
|
|
431
|
-
values
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
`;
|
|
436
|
-
class ee {
|
|
437
|
-
/**
|
|
438
|
-
* Initialize a new {@link WidgetApi} instance.
|
|
439
|
-
*
|
|
440
|
-
* @param {ConfigOptions} config Config details
|
|
441
|
-
*
|
|
442
|
-
* @example <caption>Browser example</caption>
|
|
443
|
-
* var squatchApi = new squatch.WidgetApi({tenantAlias:'test_12b5bo1b25125'});
|
|
444
|
-
*
|
|
445
|
-
* @example <caption>Browserify/Webpack example</caption>
|
|
446
|
-
* var WidgetApi = require('@saasquatch/squatch-js').WidgetApi;
|
|
447
|
-
* var squatchApi = new WidgetApi({tenantAlias:'test_12b5bo1b25125'});
|
|
448
|
-
*
|
|
449
|
-
* @example <caption>Babel+Browserify/Webpack example</caption>
|
|
450
|
-
* import {WidgetApi} from '@saasquatch/squatch-js';
|
|
451
|
-
* let squatchApi = new WidgetApi({tenantAlias:'test_12b5bo1b25125'});
|
|
452
|
-
*/
|
|
453
|
-
constructor(n) {
|
|
454
|
-
p(this, "tenantAlias");
|
|
455
|
-
p(this, "domain");
|
|
456
|
-
p(this, "npmCdn");
|
|
457
|
-
p(this, "referralCookie", this.squatchReferralCookie);
|
|
458
|
-
const e = J(n);
|
|
459
|
-
this.tenantAlias = e.tenantAlias, this.domain = e.domain, this.npmCdn = e.npmCdn;
|
|
460
|
-
}
|
|
461
|
-
/**
|
|
462
|
-
* Creates/upserts user, requests widget template.
|
|
463
|
-
*
|
|
464
|
-
* @param {Object} params Parameters for request
|
|
465
|
-
* @param {Object?} params.user The user details
|
|
466
|
-
* @param {string} params.user.id The user id
|
|
467
|
-
* @param {string} params.user.accountId The user account id
|
|
468
|
-
* @param {WidgetType} params.widgetType The content of the widget.
|
|
469
|
-
* @param {EngagementMedium?} params.engagementMedium How to display the widget.
|
|
470
|
-
* @param {string?} params.jwt the JSON Web Token (JWT) that is used
|
|
471
|
-
* to validate the data (can be disabled)
|
|
472
|
-
*
|
|
473
|
-
* @return {Promise} string if true, with the widget template, jsOptions and user details.
|
|
474
|
-
*/
|
|
475
|
-
upsertUser(n) {
|
|
476
|
-
const e = le(n), {
|
|
477
|
-
widgetType: o,
|
|
478
|
-
engagementMedium: r = "POPUP",
|
|
479
|
-
jwt: a,
|
|
480
|
-
locale: d,
|
|
481
|
-
user: u
|
|
482
|
-
} = e, h = encodeURIComponent(this.tenantAlias), s = u.accountId ? encodeURIComponent(u.accountId) : null, c = u.id ? encodeURIComponent(u.id) : null, l = Pe({
|
|
483
|
-
widgetType: o,
|
|
484
|
-
engagementMedium: r,
|
|
485
|
-
locale: d
|
|
486
|
-
}), m = `/api/v1/${h}/widget/account/${s}/user/${c}/upsert${l}`, f = this.domain + m, b = (P || window.Cookies).get("_saasquatch");
|
|
487
|
-
return b && (u.cookies = b), Se(f, JSON.stringify(u), a);
|
|
488
|
-
}
|
|
489
|
-
/**
|
|
490
|
-
* Requests widget template
|
|
491
|
-
*
|
|
492
|
-
* @param {Object} params Parameters for request
|
|
493
|
-
* @param {Object} params.user The user details
|
|
494
|
-
* @param {string} params.user.id The user id
|
|
495
|
-
* @param {string} params.user.accountId The user account id
|
|
496
|
-
* @param {WidgetType} params.widgetType The content of the widget.
|
|
497
|
-
* @param {EngagementMedium} params.engagementMedium How to display the widget.
|
|
498
|
-
* @param {string} params.jwt the JSON Web Token (JWT) that is used
|
|
499
|
-
* to validate the data (can be disabled)
|
|
500
|
-
* @return {Promise} template html if true.
|
|
501
|
-
*/
|
|
502
|
-
render(n) {
|
|
503
|
-
const e = ue(n), { widgetType: o, engagementMedium: r = "POPUP", jwt: a, user: d } = e, u = encodeURIComponent(this.tenantAlias), h = d != null && d.accountId ? encodeURIComponent(d.accountId) : null, s = d != null && d.id ? encodeURIComponent(d.id) : null, c = e.locale ?? Re(navigator.language.replace(/\-/g, "_")), l = `/api/v1/${u}/graphql`, m = this.domain + l;
|
|
504
|
-
return new Promise(async (f, b) => {
|
|
505
|
-
var w;
|
|
506
|
-
try {
|
|
507
|
-
const y = await Ue(
|
|
508
|
-
m,
|
|
509
|
-
Me,
|
|
510
|
-
{
|
|
511
|
-
user: s && h ? { id: s, accountId: h } : null,
|
|
512
|
-
engagementMedium: r,
|
|
513
|
-
widgetType: o,
|
|
514
|
-
locale: c
|
|
515
|
-
},
|
|
516
|
-
a
|
|
517
|
-
);
|
|
518
|
-
f((w = y == null ? void 0 : y.data) == null ? void 0 : w.renderWidget);
|
|
519
|
-
} catch (y) {
|
|
520
|
-
b(y);
|
|
521
|
-
}
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
/**
|
|
525
|
-
* Looks up the referral code of the current user, if there is any.
|
|
526
|
-
*
|
|
527
|
-
* @return {Promise<ReferralCookie>} code referral code if true.
|
|
528
|
-
*/
|
|
529
|
-
async squatchReferralCookie() {
|
|
530
|
-
const n = encodeURIComponent(this.tenantAlias), t = (P || window.Cookies).get("_saasquatch") || "", e = t ? `?cookies=${encodeURIComponent(t)}` : "", o = `${this.domain}/a/${n}/widgets/squatchcookiejson${e}`, r = await Te(o);
|
|
531
|
-
return Promise.resolve({
|
|
532
|
-
...r,
|
|
533
|
-
encodedCookie: t
|
|
534
|
-
});
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
function Pe({
|
|
538
|
-
widgetType: i,
|
|
539
|
-
engagementMedium: n,
|
|
540
|
-
locale: t
|
|
541
|
-
}) {
|
|
542
|
-
const e = new URLSearchParams();
|
|
543
|
-
return e.append("engagementMedium", n), i && e.append("widgetType", i), t && e.append("locale", t), `?${e.toString()}`;
|
|
544
|
-
}
|
|
545
|
-
class he {
|
|
546
|
-
/**
|
|
547
|
-
* Initialize a new {@link AnalyticsApi} instance.
|
|
548
|
-
*
|
|
549
|
-
* @param {Object} config Config details
|
|
550
|
-
* @param {string} [config.domain='https://app.referralsaasquatch.com'] The server domain.
|
|
551
|
-
*
|
|
552
|
-
*/
|
|
553
|
-
constructor(n) {
|
|
554
|
-
p(this, "domain");
|
|
555
|
-
var o;
|
|
556
|
-
const e = $e(n);
|
|
557
|
-
this.domain = (e == null ? void 0 : e.domain) || ((o = K()) == null ? void 0 : o.domain) || I;
|
|
558
|
-
}
|
|
559
|
-
pushAnalyticsLoadEvent(n) {
|
|
560
|
-
if (!n.externalUserId || !n.externalAccountId) return;
|
|
561
|
-
const t = encodeURIComponent(n.tenantAlias), e = encodeURIComponent(n.externalAccountId), o = encodeURIComponent(n.externalUserId), r = encodeURIComponent(n.engagementMedium), a = n.programId ? `&programId=${encodeURIComponent(n.programId)}` : "", d = `/a/${t}/widgets/analytics/loaded?externalAccountId=${e}&externalUserId=${o}&engagementMedium=${r}${a}`, u = this.domain + d;
|
|
562
|
-
return Y(u, JSON.stringify({}));
|
|
563
|
-
}
|
|
564
|
-
pushAnalyticsShareClickedEvent(n) {
|
|
565
|
-
const t = encodeURIComponent(n.tenantAlias), e = encodeURIComponent(n.externalAccountId), o = encodeURIComponent(n.externalUserId), r = encodeURIComponent(n.engagementMedium), a = encodeURIComponent(n.shareMedium), d = `/a/${t}/widgets/analytics/shared?externalAccountId=${e}&externalUserId=${o}&engagementMedium=${r}&shareMedium=${a}`, u = this.domain + d;
|
|
566
|
-
return Y(u, JSON.stringify({}));
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
function $e(i) {
|
|
570
|
-
if (!_(i)) throw new Error("'options' should be an object");
|
|
571
|
-
return i;
|
|
572
|
-
}
|
|
573
|
-
const C = g.debug("squatch-js:widget");
|
|
574
|
-
class pe {
|
|
575
|
-
constructor(n) {
|
|
576
|
-
p(this, "type");
|
|
577
|
-
p(this, "content");
|
|
578
|
-
p(this, "analyticsApi");
|
|
579
|
-
p(this, "widgetApi");
|
|
580
|
-
p(this, "context");
|
|
581
|
-
p(this, "npmCdn");
|
|
582
|
-
p(this, "container");
|
|
583
|
-
p(this, "loadEventListener", null);
|
|
584
|
-
var t;
|
|
585
|
-
C("widget initializing ..."), this.content = n.content === "error" ? this._error(n.rsCode) : n.content, this.type = n.type, this.widgetApi = n.api, this.npmCdn = n.npmCdn, this.analyticsApi = new he({ domain: n.domain }), this.context = n.context, this.container = ((t = n.context) == null ? void 0 : t.container) || n.container;
|
|
586
|
-
}
|
|
587
|
-
_findElement() {
|
|
588
|
-
let n;
|
|
589
|
-
if (typeof this.container == "string" ? (n = document.querySelector(this.container), C("loading widget with selector", n)) : this.container instanceof HTMLElement ? (n = this.container, C("loading widget with container", n)) : this.container ? (n = null, C("container must be an HTMLElement or string", this.container)) : (n = document.querySelector("#squatchembed") || document.querySelector(".squatchembed") || document.querySelector("#impactembed") || document.querySelector(".impactembed"), C("loading widget with default selector", n)), !(n instanceof HTMLElement))
|
|
590
|
-
throw new Error(
|
|
591
|
-
`element with selector '${this.container || "#squatchembed, .squatchembed, #impactembed, or .impactembed"}' not found.'`
|
|
592
|
-
);
|
|
593
|
-
return n;
|
|
594
|
-
}
|
|
595
|
-
_createFrame() {
|
|
596
|
-
const n = document.createElement("iframe");
|
|
597
|
-
return n.squatchJsApi = this, n.id = "squatchFrame", n.width = "100%", n.src = "about:blank", n.scrolling = "no", n.setAttribute(
|
|
598
|
-
"style",
|
|
599
|
-
"border: 0; background-color: none; width: 1px; min-width: 100%;"
|
|
600
|
-
), n;
|
|
601
|
-
}
|
|
602
|
-
_findFrame() {
|
|
603
|
-
const n = this.container ? this._findElement() : document.body;
|
|
604
|
-
return (n.shadowRoot || n).querySelector(
|
|
605
|
-
"iframe#squatchFrame"
|
|
606
|
-
);
|
|
607
|
-
}
|
|
608
|
-
_detachLoadEventListener(n) {
|
|
609
|
-
this.loadEventListener && (n.removeEventListener(
|
|
610
|
-
"sq:user-registration",
|
|
611
|
-
this.loadEventListener
|
|
612
|
-
), this.loadEventListener = null);
|
|
613
|
-
}
|
|
614
|
-
_attachLoadEventListener(n, t) {
|
|
615
|
-
this.loadEventListener === null && (this.loadEventListener = (e) => {
|
|
616
|
-
this._loadEvent({
|
|
617
|
-
...t,
|
|
618
|
-
userId: e.detail.userId,
|
|
619
|
-
accountId: e.detail.accountId
|
|
620
|
-
});
|
|
621
|
-
}, n.addEventListener("sq:user-registration", this.loadEventListener));
|
|
622
|
-
}
|
|
623
|
-
_loadEvent(n) {
|
|
624
|
-
var e;
|
|
625
|
-
if (!n) return;
|
|
626
|
-
if (!_(n))
|
|
627
|
-
throw new Error("Widget Load event identity property is not an object");
|
|
628
|
-
let t;
|
|
629
|
-
if ("programId" in n) {
|
|
630
|
-
if (!n.tenantAlias || !n.accountId || !n.userId || !n.engagementMedium)
|
|
631
|
-
throw new Error("Widget Load event missing required properties");
|
|
632
|
-
t = {
|
|
633
|
-
tenantAlias: n.tenantAlias,
|
|
634
|
-
externalAccountId: n.accountId,
|
|
635
|
-
externalUserId: n.userId,
|
|
636
|
-
engagementMedium: n.engagementMedium,
|
|
637
|
-
programId: n.programId
|
|
638
|
-
};
|
|
639
|
-
} else {
|
|
640
|
-
const { analytics: o, mode: r } = n;
|
|
641
|
-
t = {
|
|
642
|
-
tenantAlias: o.attributes.tenant,
|
|
643
|
-
externalAccountId: o.attributes.accountId,
|
|
644
|
-
externalUserId: o.attributes.userId,
|
|
645
|
-
engagementMedium: r.widgetMode
|
|
646
|
-
};
|
|
647
|
-
}
|
|
648
|
-
(e = this.analyticsApi.pushAnalyticsLoadEvent(t)) == null || e.then((o) => {
|
|
649
|
-
C(`${t.engagementMedium} loaded event recorded.`);
|
|
650
|
-
}).catch((o) => {
|
|
651
|
-
C(`ERROR: pushAnalyticsLoadEvent() ${o}`);
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
_shareEvent(n, t) {
|
|
655
|
-
n && this.analyticsApi.pushAnalyticsShareClickedEvent({
|
|
656
|
-
tenantAlias: n.analytics.attributes.tenant,
|
|
657
|
-
externalAccountId: n.analytics.attributes.accountId,
|
|
658
|
-
externalUserId: n.analytics.attributes.userId,
|
|
659
|
-
engagementMedium: n.mode.widgetMode,
|
|
660
|
-
shareMedium: t
|
|
661
|
-
}).then((e) => {
|
|
662
|
-
C(
|
|
663
|
-
`${n.mode.widgetMode} share ${t} event recorded. ${e}`
|
|
664
|
-
);
|
|
665
|
-
}).catch((e) => {
|
|
666
|
-
C(`ERROR: pushAnalyticsShareClickedEvent() ${e}`);
|
|
667
|
-
});
|
|
668
|
-
}
|
|
669
|
-
_error(n, t = "modal", e = "") {
|
|
670
|
-
return `<!DOCTYPE html>
|
|
671
|
-
<!--[if IE 7]><html class="ie7 oldie" lang="en"><![endif]-->
|
|
672
|
-
<!--[if IE 8]><html class="ie8 oldie" lang="en"><![endif]-->
|
|
673
|
-
<!--[if gt IE 8]><!--><html lang="en"><!--<![endif]-->
|
|
674
|
-
<head>
|
|
675
|
-
<link rel="stylesheet" media="all" href="https://fast.ssqt.io/assets/css/widget/errorpage.css">
|
|
676
|
-
<style>
|
|
677
|
-
${e}
|
|
678
|
-
</style>
|
|
679
|
-
</head>
|
|
680
|
-
<body>
|
|
681
|
-
|
|
682
|
-
<div class="squatch-container ${t}" style="width:100%">
|
|
683
|
-
<div class="errorheader">
|
|
684
|
-
<button type="button" class="close" onclick="window.frameElement.squatchJsApi.close();">×</button>
|
|
685
|
-
<p class="errortitle">Error</p>
|
|
686
|
-
</div>
|
|
687
|
-
<div class="errorbody">
|
|
688
|
-
<div class="sadface"><img src="https://fast.ssqt.io/assets/images/face.png"></div>
|
|
689
|
-
<h4>Our referral program is temporarily unavailable.</h4><br>
|
|
690
|
-
<p>Please reload the page or check back later.</p>
|
|
691
|
-
<p>If the persists please contact our support team.</p>
|
|
692
|
-
<br>
|
|
693
|
-
<br>
|
|
694
|
-
<div class="right-align errtxt">
|
|
695
|
-
Error Code: ${n}
|
|
696
|
-
</div>
|
|
697
|
-
</div>
|
|
698
|
-
</div>
|
|
699
|
-
</body>
|
|
700
|
-
</html>`;
|
|
701
|
-
}
|
|
702
|
-
async _findInnerContainer(n) {
|
|
703
|
-
const { contentWindow: t } = n;
|
|
704
|
-
if (!t)
|
|
705
|
-
throw new Error("Squatch.js frame inner frame is empty");
|
|
706
|
-
const e = t.document;
|
|
707
|
-
function o() {
|
|
708
|
-
const a = e.getElementsByTagName("sqh-global-container"), d = e.getElementsByClassName("squatch-container");
|
|
709
|
-
return a.length > 0 ? a[0] : d.length > 0 ? d[0] : null;
|
|
710
|
-
}
|
|
711
|
-
let r = null;
|
|
712
|
-
for (let a = 0; a < 5 && (r = o(), !r); a++)
|
|
713
|
-
await Oe(100);
|
|
714
|
-
return r || e.body;
|
|
715
|
-
}
|
|
716
|
-
/**
|
|
717
|
-
* Reloads the current widget, makes updated request to API and renders result.
|
|
718
|
-
* Primarily for Classic widgets with registration
|
|
719
|
-
* @param param0 Form field values
|
|
720
|
-
* @param jwt JWT for API authentication
|
|
721
|
-
*/
|
|
722
|
-
reload({ email: n, firstName: t, lastName: e }, o) {
|
|
723
|
-
const r = this._findFrame();
|
|
724
|
-
if (!r) throw new Error("Could not find widget iframe");
|
|
725
|
-
const a = r.contentWindow, d = this.context.engagementMedium || "POPUP";
|
|
726
|
-
if (!a)
|
|
727
|
-
throw new Error("Frame needs a content window");
|
|
728
|
-
let u;
|
|
729
|
-
if (this.context.type === "upsert") {
|
|
730
|
-
if (!this.context.user) throw new Error("Can't reload without user ids");
|
|
731
|
-
let h = {
|
|
732
|
-
email: n || null,
|
|
733
|
-
firstName: t || null,
|
|
734
|
-
lastName: e || null,
|
|
735
|
-
id: this.context.user.id,
|
|
736
|
-
accountId: this.context.user.accountId
|
|
737
|
-
};
|
|
738
|
-
u = this.widgetApi.upsertUser({
|
|
739
|
-
user: h,
|
|
740
|
-
engagementMedium: d,
|
|
741
|
-
widgetType: this.type,
|
|
742
|
-
jwt: o
|
|
743
|
-
});
|
|
744
|
-
} else if (this.context.type === "passwordless")
|
|
745
|
-
u = this.widgetApi.render({
|
|
746
|
-
user: void 0,
|
|
747
|
-
engagementMedium: d,
|
|
748
|
-
widgetType: this.type,
|
|
749
|
-
jwt: void 0
|
|
750
|
-
});
|
|
751
|
-
else
|
|
752
|
-
throw new Error("can't reload an error widget");
|
|
753
|
-
u.then(({ template: h }) => {
|
|
754
|
-
h && (this.content = h, this.__deprecated__register(
|
|
755
|
-
r,
|
|
756
|
-
{ email: n, engagementMedium: d },
|
|
757
|
-
() => {
|
|
758
|
-
this.load(), d === "POPUP" && this.open();
|
|
759
|
-
}
|
|
760
|
-
));
|
|
761
|
-
}).catch(({ message: h }) => {
|
|
762
|
-
C(`${h}`);
|
|
763
|
-
});
|
|
764
|
-
}
|
|
765
|
-
__deprecated__register(n, t, e) {
|
|
766
|
-
const r = n.contentWindow.document, a = r.createElement("button"), d = r.getElementsByClassName("squatch-register")[0];
|
|
767
|
-
if (d) {
|
|
768
|
-
a.className = "btn btn-primary", a.id = "show-stats-btn", a.textContent = this.type === "REFERRER_WIDGET" ? "Show Stats" : "Show Reward";
|
|
769
|
-
const u = t.engagementMedium === "POPUP" ? "margin-top: 10px; max-width: 130px; width: 100%;" : "margin-top: 10px;";
|
|
770
|
-
a.setAttribute("style", u), a.onclick = e, d.style.paddingTop = "30px", d.innerHTML = `<p><strong>${t.email}</strong><br>Has been successfully registered</p>`, d.appendChild(a);
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
function Oe(i) {
|
|
775
|
-
return new Promise((n) => {
|
|
776
|
-
setTimeout(n, i);
|
|
777
|
-
});
|
|
778
|
-
}
|
|
779
|
-
/*!
|
|
780
|
-
* domready (c) Dustin Diaz 2014 - License MIT
|
|
781
|
-
*
|
|
782
|
-
*/
|
|
783
|
-
function Z(i, n) {
|
|
784
|
-
let t = [], e, o = i, r = o.documentElement.doScroll, a = "DOMContentLoaded", d = (r ? /^loaded|^c/ : /^loaded|^i|^c/).test(o.readyState);
|
|
785
|
-
return d || o.addEventListener(
|
|
786
|
-
a,
|
|
787
|
-
e = () => {
|
|
788
|
-
for (o.removeEventListener(a, e), d = !0; e = t.shift(); ) e();
|
|
789
|
-
}
|
|
790
|
-
), d ? setTimeout(n, 0) : t.push(n);
|
|
791
|
-
}
|
|
792
|
-
const A = g.debug("squatch-js:EMBEDwidget");
|
|
793
|
-
class $ extends pe {
|
|
794
|
-
constructor(t, e) {
|
|
795
|
-
super(t);
|
|
796
|
-
p(this, "show", this.open);
|
|
797
|
-
p(this, "hide", this.close);
|
|
798
|
-
e && (this.container = e);
|
|
799
|
-
}
|
|
800
|
-
async load() {
|
|
801
|
-
var a, d;
|
|
802
|
-
const t = this._createFrame(), e = this._findElement();
|
|
803
|
-
(a = this.context) != null && a.container && (e.style.visibility = "hidden", e.style.height = "0", e.style["overflow-y"] = "hidden"), this.container ? e.shadowRoot ? ((d = e.shadowRoot.lastChild) == null ? void 0 : d.nodeName) === "IFRAME" ? e.shadowRoot.replaceChild(t, e.shadowRoot.lastChild) : e.shadowRoot.appendChild(t) : e.firstChild ? e.replaceChild(t, e.firstChild) : e.appendChild(t) : (!e.firstChild || e.firstChild.nodeName === "#text") && e.appendChild(t);
|
|
804
|
-
const { contentWindow: o } = t;
|
|
805
|
-
if (!o)
|
|
806
|
-
throw new Error("Frame needs a content window");
|
|
807
|
-
const r = o.document;
|
|
808
|
-
r.open(), r.write(this.content), r.write(
|
|
809
|
-
`<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>`
|
|
810
|
-
), r.close(), Z(r, async () => {
|
|
811
|
-
const u = o.squatch || o.widgetIdent;
|
|
812
|
-
t.height = r.body.scrollHeight;
|
|
813
|
-
const h = new o.ResizeObserver((c) => {
|
|
814
|
-
for (const l of c) {
|
|
815
|
-
const { height: m } = l.contentRect;
|
|
816
|
-
t.height = m;
|
|
817
|
-
}
|
|
818
|
-
}), s = await this._findInnerContainer(t);
|
|
819
|
-
h.observe(s), this._shouldFireLoadEvent() ? (this._loadEvent(u), A("loaded")) : r && this._attachLoadEventListener(r, u);
|
|
820
|
-
});
|
|
821
|
-
}
|
|
822
|
-
/**
|
|
823
|
-
* Un-hide if element is available and refresh data
|
|
824
|
-
*/
|
|
825
|
-
open() {
|
|
826
|
-
const t = this._findFrame();
|
|
827
|
-
if (!t) return A("no target element to open");
|
|
828
|
-
if (!t.contentWindow) return A("Frame needs a content window");
|
|
829
|
-
const e = this._findElement();
|
|
830
|
-
e.style.visibility = "unset", e.style.height = "auto", e.style["overflow-y"] = "auto", t.contentWindow.document.dispatchEvent(new CustomEvent("sq:refresh"));
|
|
831
|
-
const o = t.contentWindow.squatch || t.contentWindow.widgetIdent;
|
|
832
|
-
if (this.context.user)
|
|
833
|
-
this._loadEvent(o), A("loaded");
|
|
834
|
-
else {
|
|
835
|
-
if (!t.contentDocument) return;
|
|
836
|
-
this._attachLoadEventListener(t.contentDocument, o);
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
close() {
|
|
840
|
-
const t = this._findFrame();
|
|
841
|
-
if (!t) return A("no target element to close");
|
|
842
|
-
t.contentDocument && this._detachLoadEventListener(t.contentDocument);
|
|
843
|
-
const e = this._findElement();
|
|
844
|
-
e.style.visibility = "hidden", e.style.height = "0", e.style["overflow-y"] = "hidden", A("Embed widget closed");
|
|
845
|
-
}
|
|
846
|
-
_error(t, e = "embed", o = "") {
|
|
847
|
-
return super._error(t, e, o);
|
|
848
|
-
}
|
|
849
|
-
_shouldFireLoadEvent() {
|
|
850
|
-
const t = !this.container, e = this.container instanceof HTMLElement && (this.container.tagName.startsWith("SQUATCH-") || this.container.tagName.startsWith("IMPACT-"));
|
|
851
|
-
return !!this.context.user && (t || e);
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
const F = g.debug("squatch-js:POPUPwidget");
|
|
855
|
-
let M = 0;
|
|
856
|
-
class O extends pe {
|
|
857
|
-
constructor(t, e = ".squatchpop") {
|
|
858
|
-
super(t);
|
|
859
|
-
p(this, "trigger");
|
|
860
|
-
p(this, "id");
|
|
861
|
-
p(this, "show", this.open);
|
|
862
|
-
p(this, "hide", this.close);
|
|
863
|
-
this.trigger = e, this.container ? this.id = "squatchModal" : (this.id = M === 0 ? "squatchModal" : `squatchModal__${M}`, M = M + 1), document.head.insertAdjacentHTML(
|
|
864
|
-
"beforeend",
|
|
865
|
-
`<style>#${this.id}::-webkit-scrollbar { display: none; }</style>`
|
|
866
|
-
);
|
|
867
|
-
}
|
|
868
|
-
_initialiseCTA() {
|
|
869
|
-
if (!this.trigger) return;
|
|
870
|
-
let t;
|
|
871
|
-
try {
|
|
872
|
-
t = document.querySelector(this.trigger) || document.querySelector(".impactpop"), this.trigger && !t && F("No element found with trigger selector", this.trigger);
|
|
873
|
-
} catch {
|
|
874
|
-
F("Not a valid selector", this.trigger);
|
|
875
|
-
}
|
|
876
|
-
t && (t.onclick = () => {
|
|
877
|
-
this.open();
|
|
878
|
-
});
|
|
879
|
-
}
|
|
880
|
-
_createPopupDialog() {
|
|
881
|
-
const t = document.createElement("dialog");
|
|
882
|
-
t.id = this.id, t.setAttribute(
|
|
883
|
-
"style",
|
|
884
|
-
"width: 100%; max-width: 500px; border: none; padding: 0;"
|
|
885
|
-
);
|
|
886
|
-
const e = (o) => {
|
|
887
|
-
o.stopPropagation(), o.target === t && t.close();
|
|
888
|
-
};
|
|
889
|
-
return t.addEventListener("click", e), t;
|
|
890
|
-
}
|
|
891
|
-
async load() {
|
|
892
|
-
var u;
|
|
893
|
-
const t = this._createFrame();
|
|
894
|
-
this._initialiseCTA();
|
|
895
|
-
const e = this.container ? this._findElement() : document.body, o = e.shadowRoot || e, r = this._createPopupDialog();
|
|
896
|
-
r.appendChild(t), ((u = o.lastChild) == null ? void 0 : u.nodeName) === "DIALOG" ? o.replaceChild(r, o.lastChild) : o.appendChild(r);
|
|
897
|
-
const { contentWindow: a } = t;
|
|
898
|
-
if (!a)
|
|
899
|
-
throw new Error("Frame needs a content window");
|
|
900
|
-
const d = a.document;
|
|
901
|
-
d.open(), d.write(this.content), d.write(
|
|
902
|
-
`<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>`
|
|
903
|
-
), d.close(), F("Popup template loaded into iframe"), await this._setupResizeHandler(t);
|
|
904
|
-
}
|
|
905
|
-
async _setupResizeHandler(t) {
|
|
906
|
-
const { contentWindow: e } = t;
|
|
907
|
-
if (!e)
|
|
908
|
-
throw new Error("Frame needs a content window");
|
|
909
|
-
const o = e.document;
|
|
910
|
-
Z(o, async () => {
|
|
911
|
-
o.body.style.overflowY = "hidden", t.height = `${o.body.offsetHeight}px`, new e.ResizeObserver((a) => {
|
|
912
|
-
for (const d of a) {
|
|
913
|
-
const { top: u, bottom: h } = d.contentRect, s = h + u;
|
|
914
|
-
t.height = s + "", d.target.style = "";
|
|
915
|
-
}
|
|
916
|
-
}).observe(await this._findInnerContainer(t));
|
|
917
|
-
});
|
|
918
|
-
}
|
|
919
|
-
open() {
|
|
920
|
-
const t = this.container ? this._findElement() : document.body, o = (t.shadowRoot || t).querySelector(`#${this.id}`);
|
|
921
|
-
if (!o) throw new Error("Could not determine container div");
|
|
922
|
-
o.showModal();
|
|
923
|
-
const r = this._findFrame();
|
|
924
|
-
if (!r) throw new Error("Could not find iframe");
|
|
925
|
-
const { contentWindow: a } = r;
|
|
926
|
-
if (!a) throw new Error("Squatch.js has an empty iframe");
|
|
927
|
-
const d = a.document;
|
|
928
|
-
Z(d, () => {
|
|
929
|
-
var h;
|
|
930
|
-
const u = a.squatch || a.widgetIdent;
|
|
931
|
-
(h = r.contentDocument) == null || h.dispatchEvent(new CustomEvent("sq:refresh")), this.context.user ? (this._loadEvent(u), F("Popup opened")) : this._attachLoadEventListener(d, u);
|
|
932
|
-
});
|
|
933
|
-
}
|
|
934
|
-
close() {
|
|
935
|
-
const t = this._findFrame();
|
|
936
|
-
t != null && t.contentDocument && this._detachLoadEventListener(t.contentDocument);
|
|
937
|
-
const e = this.container ? this._findElement() : document.body, r = (e.shadowRoot || e).querySelector(`#${this.id}`);
|
|
938
|
-
if (!r) throw new Error("Could not determine container div");
|
|
939
|
-
r.close(), F("Popup closed");
|
|
940
|
-
}
|
|
941
|
-
_clickedOutside({ target: t }) {
|
|
942
|
-
}
|
|
943
|
-
_error(t, e = "modal", o = "") {
|
|
944
|
-
return super._error(t, e, o || "body { margin: 0; } .modal { box-shadow: none; border: 0; }");
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
const E = g.debug("squatch-js:widgets");
|
|
948
|
-
class W {
|
|
949
|
-
/**
|
|
950
|
-
* Initialize a new {@link Widgets} instance.
|
|
951
|
-
*
|
|
952
|
-
* @param {ConfigOptions} config Config details
|
|
953
|
-
*
|
|
954
|
-
* @example <caption>Browser example</caption>
|
|
955
|
-
* var widgets = new squatch.Widgets({tenantAlias:'test_12b5bo1b25125'});
|
|
956
|
-
*
|
|
957
|
-
* @example <caption>Browserify/Webpack example</caption>
|
|
958
|
-
* var Widgets = require('@saasquatch/squatch-js').Widgets;
|
|
959
|
-
* var widgets = new Widgets({tenantAlias:'test_12b5bo1b25125'});
|
|
960
|
-
*
|
|
961
|
-
* @example <caption>Babel+Browserify/Webpack example</caption>
|
|
962
|
-
* import {Widgets} from '@saasquatch/squatch-js';
|
|
963
|
-
* let widgets = new Widgets({tenantAlias:'test_12b5bo1b25125'});
|
|
964
|
-
*/
|
|
965
|
-
constructor(n) {
|
|
966
|
-
/**
|
|
967
|
-
* Instance of {@link WidgetApi}
|
|
968
|
-
*/
|
|
969
|
-
p(this, "api");
|
|
970
|
-
/**
|
|
971
|
-
* Tenant alias of SaaSquatch tenant
|
|
972
|
-
*/
|
|
973
|
-
p(this, "tenantAlias");
|
|
974
|
-
/**
|
|
975
|
-
* SaaSquatch domain for API requests
|
|
976
|
-
* @default "https://app.referralsaasquatch.com"
|
|
977
|
-
*/
|
|
978
|
-
p(this, "domain");
|
|
979
|
-
/**
|
|
980
|
-
* Hosted CDN for npm packages
|
|
981
|
-
* @default "https://fast.ssqt.io/npm"
|
|
982
|
-
*/
|
|
983
|
-
p(this, "npmCdn");
|
|
984
|
-
const t = J(n);
|
|
985
|
-
this.tenantAlias = t.tenantAlias, this.domain = t.domain, this.npmCdn = t.npmCdn, this.api = new ee(t);
|
|
986
|
-
}
|
|
987
|
-
/**
|
|
988
|
-
* This function calls the {@link WidgetApi.upsertUser} method, and it renders
|
|
989
|
-
* the widget if it is successful. Otherwise it shows the "error" widget.
|
|
990
|
-
*
|
|
991
|
-
* @param {Object} config Config details
|
|
992
|
-
* @param {Object} config.user The user details
|
|
993
|
-
* @param {string} config.user.id The user id
|
|
994
|
-
* @param {string} config.user.accountId The user account id
|
|
995
|
-
* @param {WidgetType} config.widgetType The content of the widget
|
|
996
|
-
* @param {EngagementMedium} config.engagementMedium How to display the widget
|
|
997
|
-
* @param {string} config.jwt the JSON Web Token (JWT) that is used to validate the data (can be disabled)
|
|
998
|
-
* @param {HTMLElement | string | undefined} config.container Element to load the widget into
|
|
999
|
-
* @param {string | undefined} config.trigger Trigger element for opening the popup widget
|
|
1000
|
-
*
|
|
1001
|
-
* @return {Promise<WidgetResult>} json object if true, with a Widget and user details
|
|
1002
|
-
*/
|
|
1003
|
-
async upsertUser(n) {
|
|
1004
|
-
const e = le(n);
|
|
1005
|
-
try {
|
|
1006
|
-
const o = await this.api.upsertUser(e);
|
|
1007
|
-
return {
|
|
1008
|
-
widget: this._renderWidget(o, e, {
|
|
1009
|
-
type: "upsert",
|
|
1010
|
-
user: e.user,
|
|
1011
|
-
engagementMedium: n.engagementMedium,
|
|
1012
|
-
container: n.container,
|
|
1013
|
-
trigger: n.trigger
|
|
1014
|
-
}),
|
|
1015
|
-
user: o.user
|
|
1016
|
-
};
|
|
1017
|
-
} catch (o) {
|
|
1018
|
-
throw E(o), o.apiErrorCode && this._renderErrorWidget(o, n.engagementMedium), new Error(o);
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
/**
|
|
1022
|
-
* This function calls the {@link WidgetApi.render} method, and it renders
|
|
1023
|
-
* the widget if it is successful. Otherwise it shows the "error" widget.
|
|
1024
|
-
*
|
|
1025
|
-
* @param {Object} config Config details
|
|
1026
|
-
* @param {Object} config.user The user details
|
|
1027
|
-
* @param {string} config.user.id The user id
|
|
1028
|
-
* @param {string} config.user.accountId The user account id
|
|
1029
|
-
* @param {WidgetType} config.widgetType The content of the widget
|
|
1030
|
-
* @param {EngagementMedium} config.engagementMedium How to display the widget
|
|
1031
|
-
* @param {string} config.jwt the JSON Web Token (JWT) that is used
|
|
1032
|
-
* to validate the data (can be disabled)
|
|
1033
|
-
*
|
|
1034
|
-
* @return {Promise<WidgetResult>} json object if true, with a Widget and user details
|
|
1035
|
-
*/
|
|
1036
|
-
async render(n) {
|
|
1037
|
-
const e = ue(n);
|
|
1038
|
-
try {
|
|
1039
|
-
const o = await this.api.render(e);
|
|
1040
|
-
return {
|
|
1041
|
-
widget: this._renderWidget(o, e, {
|
|
1042
|
-
type: "passwordless",
|
|
1043
|
-
engagementMedium: e.engagementMedium,
|
|
1044
|
-
container: e.container,
|
|
1045
|
-
trigger: e.trigger
|
|
1046
|
-
}),
|
|
1047
|
-
user: o.user
|
|
1048
|
-
};
|
|
1049
|
-
} catch (o) {
|
|
1050
|
-
throw o.apiErrorCode && this._renderErrorWidget(o, e.engagementMedium), new Error(o);
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
/**
|
|
1054
|
-
* Autofills a referral code into an element when someone has been referred.
|
|
1055
|
-
* Uses {@link WidgetApi.squatchReferralCookie} behind the scenes.
|
|
1056
|
-
*
|
|
1057
|
-
* @param selector Element class/id selector, or a callback function
|
|
1058
|
-
* @returns
|
|
1059
|
-
*/
|
|
1060
|
-
async autofill(n) {
|
|
1061
|
-
const t = n;
|
|
1062
|
-
if (typeof t == "function") {
|
|
1063
|
-
try {
|
|
1064
|
-
const r = await this.api.squatchReferralCookie();
|
|
1065
|
-
t(r);
|
|
1066
|
-
} catch (r) {
|
|
1067
|
-
throw E("Autofill error", r), new Error(r);
|
|
1068
|
-
}
|
|
1069
|
-
return;
|
|
1070
|
-
}
|
|
1071
|
-
if (typeof t != "string")
|
|
1072
|
-
throw new Error("Autofill accepts a string or function");
|
|
1073
|
-
let e = document.querySelectorAll(t), o;
|
|
1074
|
-
if (e.length > 0)
|
|
1075
|
-
o = e[0];
|
|
1076
|
-
else
|
|
1077
|
-
throw E("Element id/class or function missing"), new Error("Element id/class or function missing");
|
|
1078
|
-
try {
|
|
1079
|
-
const r = await this.api.squatchReferralCookie();
|
|
1080
|
-
o.value = r.codes[0];
|
|
1081
|
-
} catch (r) {
|
|
1082
|
-
throw new Error(r);
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
/**
|
|
1086
|
-
* @hidden
|
|
1087
|
-
* @param {Object} response The json object return from the WidgetApi
|
|
1088
|
-
* @param {Object} config Config details
|
|
1089
|
-
* @param {string} config.widgetType The widget type (REFERRER_WIDGET, CONVERSION_WIDGET)
|
|
1090
|
-
* @param {string} config.engagementMedium (POPUP, EMBED)
|
|
1091
|
-
* @returns {Widget} widget (PopupWidget or EmbedWidget)
|
|
1092
|
-
*/
|
|
1093
|
-
_renderWidget(n, t, e) {
|
|
1094
|
-
var u;
|
|
1095
|
-
if (E("Rendering Widget..."), !n) throw new Error("Unable to get a response");
|
|
1096
|
-
let o, r = !!t.displayOnLoad;
|
|
1097
|
-
const a = n.jsOptions || {}, d = {
|
|
1098
|
-
content: n.template,
|
|
1099
|
-
type: t.widgetType || ((u = a.widget) == null ? void 0 : u.defaultWidgetType),
|
|
1100
|
-
api: this.api,
|
|
1101
|
-
domain: this.domain,
|
|
1102
|
-
npmCdn: this.npmCdn,
|
|
1103
|
-
context: e
|
|
1104
|
-
};
|
|
1105
|
-
return a.widgetUrlMappings && a.widgetUrlMappings.forEach((h) => {
|
|
1106
|
-
var s, c;
|
|
1107
|
-
W._matchesUrl(h.url) && (h.widgetType !== "CONVERSION_WIDGET" || (c = (s = n.user) == null ? void 0 : s.referredBy) != null && c.code ? (r = h.displayOnLoad, E(`Display ${h.widgetType} on ${h.url}`)) : E(
|
|
1108
|
-
`Don't display ${h.widgetType} when no referral on widget rule match ${h.url}`
|
|
1109
|
-
));
|
|
1110
|
-
}), a.fuelTankAutofillUrls && (E("We found a fuel tank autofill!"), a.fuelTankAutofillUrls.forEach(({ url: h, formSelector: s }) => {
|
|
1111
|
-
var c, l, m;
|
|
1112
|
-
if (W._matchesUrl(h) && (E("Fuel Tank URL matches"), (l = (c = n.user) == null ? void 0 : c.referredBy) != null && l.code)) {
|
|
1113
|
-
const f = document.querySelector(s);
|
|
1114
|
-
f ? f.value = ((m = n.user.referredBy.referredReward) == null ? void 0 : m.fuelTankCode) || "" : E(
|
|
1115
|
-
new Error(
|
|
1116
|
-
`Element with id/class ${s} was not found.`
|
|
1117
|
-
)
|
|
1118
|
-
);
|
|
1119
|
-
}
|
|
1120
|
-
})), t.engagementMedium === "EMBED" ? o = this._renderEmbedWidget(d) : (o = this._renderPopupWidget(d), r && o.open()), o;
|
|
1121
|
-
}
|
|
1122
|
-
_renderPopupWidget(n) {
|
|
1123
|
-
const t = new O(n, n.context.trigger);
|
|
1124
|
-
return t.load(), t;
|
|
1125
|
-
}
|
|
1126
|
-
_renderEmbedWidget(n) {
|
|
1127
|
-
const t = new $(n, n.context.container);
|
|
1128
|
-
return t.load(), t;
|
|
1129
|
-
}
|
|
1130
|
-
/**
|
|
1131
|
-
* @hidden
|
|
1132
|
-
* @param {Object} error The json object containing the error details
|
|
1133
|
-
* @param {string} em The engagementMedium
|
|
1134
|
-
* @returns {void}
|
|
1135
|
-
*/
|
|
1136
|
-
_renderErrorWidget(n, t = "POPUP") {
|
|
1137
|
-
const { apiErrorCode: e, rsCode: o, message: r } = n;
|
|
1138
|
-
E(new Error(`${e} (${o}) ${r}`));
|
|
1139
|
-
const a = {
|
|
1140
|
-
content: "error",
|
|
1141
|
-
rsCode: o,
|
|
1142
|
-
api: this.api,
|
|
1143
|
-
domain: this.domain,
|
|
1144
|
-
npmCdn: this.npmCdn,
|
|
1145
|
-
type: "ERROR_WIDGET",
|
|
1146
|
-
context: { type: "error" }
|
|
1147
|
-
};
|
|
1148
|
-
let d;
|
|
1149
|
-
t === "EMBED" ? (d = new $(a), d.load()) : t === "POPUP" && (d = new O(a), d.load());
|
|
1150
|
-
}
|
|
1151
|
-
/**
|
|
1152
|
-
* @hidden
|
|
1153
|
-
* @param {string} rule A regular expression
|
|
1154
|
-
* @returns {boolean} true if rule matches Url, false otherwise
|
|
1155
|
-
*/
|
|
1156
|
-
static _matchesUrl(n) {
|
|
1157
|
-
return !!window.location.href.match(new RegExp(n));
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
class We {
|
|
1161
|
-
/**
|
|
1162
|
-
* Initialize a new {@link EventsApi} instance.
|
|
1163
|
-
*
|
|
1164
|
-
* @param {ConfigOptions} config Config details
|
|
1165
|
-
*
|
|
1166
|
-
* @example <caption>Browser example</caption>
|
|
1167
|
-
* var squatchApi = new squatch.EventsApi({tenantAlias:'test_12b5bo1b25125'});
|
|
1168
|
-
*
|
|
1169
|
-
* @example <caption>Browserify/Webpack example</caption>
|
|
1170
|
-
* var EventsApi = require('@saasquatch/squatch-js').EventsApi;
|
|
1171
|
-
* var squatchApi = new EventsApi({tenantAlias:'test_12b5bo1b25125'});
|
|
1172
|
-
*
|
|
1173
|
-
* @example <caption>Babel+Browserify/Webpack example</caption>
|
|
1174
|
-
* import {EventsApi} from '@saasquatch/squatch-js';
|
|
1175
|
-
* let squatchApi = new EventsApi({tenantAlias:'test_12b5bo1b25125'});
|
|
1176
|
-
*/
|
|
1177
|
-
constructor(n) {
|
|
1178
|
-
p(this, "tenantAlias");
|
|
1179
|
-
p(this, "domain");
|
|
1180
|
-
const e = J(n);
|
|
1181
|
-
this.tenantAlias = e.tenantAlias, this.domain = e.domain;
|
|
1182
|
-
}
|
|
1183
|
-
/**
|
|
1184
|
-
* Track an event for a user
|
|
1185
|
-
*
|
|
1186
|
-
* @param params Parameters for request
|
|
1187
|
-
* @param options.jwt the JSON Web Token (JWT) that is used to authenticate the user
|
|
1188
|
-
*
|
|
1189
|
-
* @return An ID to confirm the event has been accepted for asynchronous processing
|
|
1190
|
-
*/
|
|
1191
|
-
track(n, t) {
|
|
1192
|
-
const e = n, o = t, r = Le(e), { jwt: a } = De(o), d = encodeURIComponent(this.tenantAlias), u = encodeURIComponent(r.userId), h = encodeURIComponent(r.accountId), s = `/api/v1/${d}/open/account/${h}/user/${u}/events`, c = this.domain + s;
|
|
1193
|
-
return Y(c, JSON.stringify(r), a);
|
|
1194
|
-
}
|
|
1195
|
-
}
|
|
1196
|
-
function Le(i) {
|
|
1197
|
-
if (!_(i)) throw new Error("tracking parameter must be an object");
|
|
1198
|
-
if (!(i != null && i.accountId)) throw new Error("accountId field is required");
|
|
1199
|
-
if (!(i != null && i.events)) throw new Error("events field is required");
|
|
1200
|
-
if (!(i != null && i.userId)) throw new Error("userId field is required");
|
|
1201
|
-
const n = i;
|
|
1202
|
-
if (!Array.isArray(n.events))
|
|
1203
|
-
throw new Error("'events' should be an array");
|
|
1204
|
-
return n;
|
|
1205
|
-
}
|
|
1206
|
-
function De(i) {
|
|
1207
|
-
if (!_(i)) throw new Error("'options' should be an object");
|
|
1208
|
-
return i;
|
|
1209
|
-
}
|
|
1210
|
-
function je() {
|
|
1211
|
-
var o;
|
|
1212
|
-
const i = window[G] ? G : S, n = ((o = window["_" + i]) == null ? void 0 : o.ready) || [], t = window.impactOnReady || window.squatchOnReady, e = [...n, t].filter((r) => !!r);
|
|
1213
|
-
setTimeout(() => {
|
|
1214
|
-
window[S] && (window[G] = window[S], e.forEach((r) => r()), window[S]._auto(), window["_" + i] = void 0, delete window["_" + i]);
|
|
1215
|
-
}, 0);
|
|
1216
|
-
}
|
|
1217
|
-
const v = g.debug("squatch-js"), se = (i) => typeof i == "object" && !Array.isArray(i), fe = (i, n) => {
|
|
1218
|
-
const t = (o) => se(n[o]) && i.hasOwnProperty(o) && se(i[o]), e = Object.getOwnPropertyNames(n).map((o) => ({
|
|
1219
|
-
[o]: t(o) ? fe(i[o], n[o]) : n[o]
|
|
1220
|
-
})).reduce((o, r) => ({ ...o, ...r }), {});
|
|
1221
|
-
return {
|
|
1222
|
-
...i,
|
|
1223
|
-
...e
|
|
1224
|
-
};
|
|
1225
|
-
};
|
|
1226
|
-
function L(i) {
|
|
1227
|
-
const n = atob(i.replace(/_/g, "/").replace(/-/g, "+")), t = new Uint8Array(n.length);
|
|
1228
|
-
for (let e = 0; e < n.length; e++)
|
|
1229
|
-
t[e] = n.charCodeAt(e);
|
|
1230
|
-
return new TextDecoder("utf8").decode(t);
|
|
1231
|
-
}
|
|
1232
|
-
function ae(i) {
|
|
1233
|
-
const n = new TextEncoder().encode(i), t = Array.from(
|
|
1234
|
-
n,
|
|
1235
|
-
(e) => String.fromCodePoint(e)
|
|
1236
|
-
).join("");
|
|
1237
|
-
return btoa(t).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
1238
|
-
}
|
|
1239
|
-
function Ne() {
|
|
1240
|
-
var i, n, t = "weird_get_top_level_domain=cookie", e = document.location.hostname.split(".");
|
|
1241
|
-
for (i = e.length - 1; i >= 0; i--)
|
|
1242
|
-
if (n = e.slice(i).join("."), document.cookie = t + ";domain=." + n + ";", document.cookie.indexOf(t) > -1)
|
|
1243
|
-
return document.cookie = t.split("=")[0] + "=;domain=." + n + ";expires=Thu, 01 Jan 1970 00:00:01 GMT;", n;
|
|
1244
|
-
}
|
|
1245
|
-
function Je() {
|
|
1246
|
-
const i = window.location.search, t = new URLSearchParams(i).get("_saasquatch") || "";
|
|
1247
|
-
if (t) {
|
|
1248
|
-
let e = "", o = "", r = "";
|
|
1249
|
-
try {
|
|
1250
|
-
e = JSON.parse(L(t));
|
|
1251
|
-
} catch (a) {
|
|
1252
|
-
v("Unable to decode params", a);
|
|
1253
|
-
return;
|
|
1254
|
-
}
|
|
1255
|
-
try {
|
|
1256
|
-
o = JSON.parse(L(P.get("_saasquatch"))), v("existing cookie", o);
|
|
1257
|
-
} catch (a) {
|
|
1258
|
-
v("Unable to retrieve cookie", a);
|
|
1259
|
-
}
|
|
1260
|
-
try {
|
|
1261
|
-
const a = Ne();
|
|
1262
|
-
if (v("domain retrieved:", a), o) {
|
|
1263
|
-
const d = fe(o, e);
|
|
1264
|
-
r = ae(JSON.stringify(d)), v("cookie to store:", d);
|
|
1265
|
-
} else
|
|
1266
|
-
r = ae(JSON.stringify(e)), v("cookie to store:", e);
|
|
1267
|
-
P.set("_saasquatch", r, {
|
|
1268
|
-
expires: 365,
|
|
1269
|
-
secure: !1,
|
|
1270
|
-
sameSite: "Lax",
|
|
1271
|
-
domain: a,
|
|
1272
|
-
path: "/"
|
|
1273
|
-
});
|
|
1274
|
-
} catch (a) {
|
|
1275
|
-
v("Unable to set cookie", a);
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
const V = g.debug("squatch-js");
|
|
1280
|
-
function Be(i) {
|
|
1281
|
-
const n = window.location.search, e = new URLSearchParams(n).get("_saasquatchExtra") || "";
|
|
1282
|
-
if (!e) {
|
|
1283
|
-
V("No _saasquatchExtra param");
|
|
1284
|
-
return;
|
|
1285
|
-
}
|
|
1286
|
-
let o;
|
|
1287
|
-
try {
|
|
1288
|
-
o = JSON.parse(L(e));
|
|
1289
|
-
} catch {
|
|
1290
|
-
V("Unable to decode _saasquatchExtra config");
|
|
1291
|
-
return;
|
|
1292
|
-
}
|
|
1293
|
-
const { domain: r, tenantAlias: a, widgetConfig: d } = ze(o);
|
|
1294
|
-
if (!r || !a || !d) {
|
|
1295
|
-
V("_saasquatchExtra did not have an expected structure");
|
|
1296
|
-
return;
|
|
1297
|
-
}
|
|
1298
|
-
const { autoPopupWidgetType: u, ...h } = d;
|
|
1299
|
-
return {
|
|
1300
|
-
widgetConfig: {
|
|
1301
|
-
widgetType: u,
|
|
1302
|
-
displayOnLoad: !0,
|
|
1303
|
-
...h
|
|
1304
|
-
},
|
|
1305
|
-
squatchConfig: {
|
|
1306
|
-
...i ? { configIn: i } : {},
|
|
1307
|
-
domain: r,
|
|
1308
|
-
tenantAlias: a
|
|
1309
|
-
}
|
|
1310
|
-
};
|
|
1311
|
-
}
|
|
1312
|
-
function ze(i) {
|
|
1313
|
-
var r;
|
|
1314
|
-
const n = Object.keys(i || {})[0], t = Object.keys((i == null ? void 0 : i[n]) || {})[0], e = (r = i == null ? void 0 : i[n]) == null ? void 0 : r[t];
|
|
1315
|
-
return { domain: n ? `https://${n}` : void 0, tenantAlias: t, widgetConfig: e };
|
|
1316
|
-
}
|
|
1317
|
-
const He = g.debug("squatch-js:decodeUserJwt");
|
|
1318
|
-
function Ge(i) {
|
|
1319
|
-
var n;
|
|
1320
|
-
try {
|
|
1321
|
-
const t = i.split(".")[1];
|
|
1322
|
-
if (t === void 0) return null;
|
|
1323
|
-
const e = L(t);
|
|
1324
|
-
return (n = JSON.parse(e)) == null ? void 0 : n.user;
|
|
1325
|
-
} catch (t) {
|
|
1326
|
-
return He(t), null;
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
const ce = qe("squatch-js:DeclarativeWidget");
|
|
1330
|
-
class me extends HTMLElement {
|
|
1331
|
-
constructor() {
|
|
1332
|
-
super();
|
|
1333
|
-
/**
|
|
1334
|
-
* Configuration overrides
|
|
1335
|
-
* @default window.squatchConfig
|
|
1336
|
-
*/
|
|
1337
|
-
p(this, "config");
|
|
1338
|
-
/**
|
|
1339
|
-
* Signed JWT containing user information
|
|
1340
|
-
* @default window.squatchToken
|
|
1341
|
-
*/
|
|
1342
|
-
p(this, "token");
|
|
1343
|
-
/**
|
|
1344
|
-
* Tenant alias of SaaSquatch tenant
|
|
1345
|
-
* @default window.squatchTenant
|
|
1346
|
-
*/
|
|
1347
|
-
p(this, "tenant");
|
|
1348
|
-
/**
|
|
1349
|
-
* widgetType of widget to load
|
|
1350
|
-
*/
|
|
1351
|
-
p(this, "widgetType");
|
|
1352
|
-
/**
|
|
1353
|
-
* Locale to render the widget in
|
|
1354
|
-
*/
|
|
1355
|
-
p(this, "locale");
|
|
1356
|
-
/**
|
|
1357
|
-
* Instance of {@link WidgetApi}
|
|
1358
|
-
*/
|
|
1359
|
-
p(this, "widgetApi");
|
|
1360
|
-
/**
|
|
1361
|
-
* Instance of {@link AnalyticsApi}
|
|
1362
|
-
*/
|
|
1363
|
-
p(this, "analyticsApi");
|
|
1364
|
-
/**
|
|
1365
|
-
* Instance of {@link EmbedWidget} or {@link PopupWidget}
|
|
1366
|
-
*/
|
|
1367
|
-
p(this, "widgetInstance");
|
|
1368
|
-
/**
|
|
1369
|
-
* Determines whether to render the widget as an embedding widget or popup widget
|
|
1370
|
-
*/
|
|
1371
|
-
p(this, "type");
|
|
1372
|
-
/**
|
|
1373
|
-
* Container element to contain the widget iframe
|
|
1374
|
-
* @default this
|
|
1375
|
-
*/
|
|
1376
|
-
p(this, "container");
|
|
1377
|
-
p(this, "element");
|
|
1378
|
-
/**
|
|
1379
|
-
* Flag for if the component has been loaded or not
|
|
1380
|
-
* @hidden
|
|
1381
|
-
*/
|
|
1382
|
-
p(this, "loaded");
|
|
1383
|
-
p(this, "_setWidget", (t, e) => {
|
|
1384
|
-
var r;
|
|
1385
|
-
const o = {
|
|
1386
|
-
api: this.widgetApi,
|
|
1387
|
-
content: t,
|
|
1388
|
-
context: {
|
|
1389
|
-
type: e.type,
|
|
1390
|
-
user: e.user,
|
|
1391
|
-
container: this.container || void 0,
|
|
1392
|
-
engagementMedium: this.type
|
|
1393
|
-
},
|
|
1394
|
-
type: this.widgetType,
|
|
1395
|
-
domain: ((r = this.config) == null ? void 0 : r.domain) || I,
|
|
1396
|
-
npmCdn: Q,
|
|
1397
|
-
container: this
|
|
1398
|
-
};
|
|
1399
|
-
if (this.type === "EMBED")
|
|
1400
|
-
return new $(o);
|
|
1401
|
-
{
|
|
1402
|
-
const a = this.firstChild ? null : void 0;
|
|
1403
|
-
return new O(o, a);
|
|
1404
|
-
}
|
|
1405
|
-
});
|
|
1406
|
-
/**
|
|
1407
|
-
* Builds a Widget instance for the default error widget
|
|
1408
|
-
* @returns Instance of either {@link EmbedWidget} or {@link PopupWidget} depending on `this.type`
|
|
1409
|
-
*/
|
|
1410
|
-
p(this, "setErrorWidget", (t) => {
|
|
1411
|
-
var o;
|
|
1412
|
-
const e = {
|
|
1413
|
-
api: this.widgetApi,
|
|
1414
|
-
content: "error",
|
|
1415
|
-
context: {
|
|
1416
|
-
type: "error",
|
|
1417
|
-
container: this.container || void 0
|
|
1418
|
-
},
|
|
1419
|
-
type: "ERROR_WIDGET",
|
|
1420
|
-
domain: ((o = this.config) == null ? void 0 : o.domain) || I,
|
|
1421
|
-
npmCdn: Q,
|
|
1422
|
-
container: this
|
|
1423
|
-
};
|
|
1424
|
-
if (this.type === "EMBED")
|
|
1425
|
-
return new $(e);
|
|
1426
|
-
{
|
|
1427
|
-
const r = this.firstChild ? null : void 0;
|
|
1428
|
-
return new O(e, r);
|
|
1429
|
-
}
|
|
1430
|
-
});
|
|
1431
|
-
p(this, "reload", this.renderWidget);
|
|
1432
|
-
p(this, "show", this.open);
|
|
1433
|
-
p(this, "hide", this.close);
|
|
1434
|
-
this.attachShadow({
|
|
1435
|
-
mode: "open"
|
|
1436
|
-
}).innerHTML = "<style>:host { display: block; }</style><slot></slot>", this.config = K(), this.token = q(), this.tenant = window.squatchTenant, this.container = this;
|
|
1437
|
-
}
|
|
1438
|
-
_setupApis(t) {
|
|
1439
|
-
var e, o;
|
|
1440
|
-
if (!this.tenant) throw new Error("tenantAlias not provided");
|
|
1441
|
-
this.widgetApi = new ee({
|
|
1442
|
-
tenantAlias: (t == null ? void 0 : t.tenantAlias) || this.tenant,
|
|
1443
|
-
domain: (t == null ? void 0 : t.domain) || ((e = this.config) == null ? void 0 : e.domain) || I
|
|
1444
|
-
}), this.analyticsApi = new he({
|
|
1445
|
-
domain: (t == null ? void 0 : t.domain) || ((o = this.config) == null ? void 0 : o.domain) || I
|
|
1446
|
-
});
|
|
1447
|
-
}
|
|
1448
|
-
async renderPasswordlessVariant() {
|
|
1449
|
-
return this._setupApis(), ce("Rendering as an Instant Access widget"), await this.widgetApi.render({
|
|
1450
|
-
engagementMedium: this.type,
|
|
1451
|
-
widgetType: this.widgetType,
|
|
1452
|
-
locale: this.locale
|
|
1453
|
-
}).then((t) => this._setWidget(t.template, { type: "passwordless" })).catch(this.setErrorWidget);
|
|
1454
|
-
}
|
|
1455
|
-
async renderUserUpsertVariant() {
|
|
1456
|
-
this._setupApis();
|
|
1457
|
-
const t = Ge(this.token);
|
|
1458
|
-
return t ? (ce("Rendering as a Verified widget"), await this.widgetApi.upsertUser({
|
|
1459
|
-
user: t,
|
|
1460
|
-
locale: this.locale,
|
|
1461
|
-
engagementMedium: this.type,
|
|
1462
|
-
widgetType: this.widgetType,
|
|
1463
|
-
jwt: this.token
|
|
1464
|
-
}).then(
|
|
1465
|
-
(o) => this._setWidget(o.template, { type: "upsert", user: t })
|
|
1466
|
-
).catch(this.setErrorWidget)) : this.setErrorWidget(Error("No user object in token."));
|
|
1467
|
-
}
|
|
1468
|
-
/**
|
|
1469
|
-
* Fetches widget content from SaaSquatch and builds a Widget instance to support rendering the widget in the DOM
|
|
1470
|
-
* @returns Instance of either {@link EmbedWidget} or {@link PopupWidget} depending on `this.type`
|
|
1471
|
-
* @throws Throws an Error if `widgetType` is undefined
|
|
1472
|
-
*/
|
|
1473
|
-
async getWidgetInstance() {
|
|
1474
|
-
let t;
|
|
1475
|
-
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");
|
|
1476
|
-
return this.token ? t = await this.renderUserUpsertVariant() : t = await this.renderPasswordlessVariant(), this.widgetInstance = t, this.widgetInstance && this.dispatchEvent(new CustomEvent("sq:widget-loaded")), t;
|
|
1477
|
-
}
|
|
1478
|
-
/**
|
|
1479
|
-
* Calls {@link getWidgetInstance} to build the Widget instance and loads the widget iframe into the DOM
|
|
1480
|
-
*/
|
|
1481
|
-
async renderWidget() {
|
|
1482
|
-
await this.getWidgetInstance(), await this.widgetInstance.load();
|
|
1483
|
-
}
|
|
1484
|
-
/**
|
|
1485
|
-
* Calls `open` method of `widgetInstance`
|
|
1486
|
-
* @throws Throws an Error if called before the widget has loaded
|
|
1487
|
-
*/
|
|
1488
|
-
open() {
|
|
1489
|
-
if (!this.widgetInstance) throw new Error("Widget has not loaded yet");
|
|
1490
|
-
this.widgetInstance.open();
|
|
1491
|
-
}
|
|
1492
|
-
/**
|
|
1493
|
-
* Calls `close` method of `widgetInstance`
|
|
1494
|
-
* @throws Throws an Error if called before the widget has loaded
|
|
1495
|
-
*/
|
|
1496
|
-
close() {
|
|
1497
|
-
if (!this.widgetInstance) throw new Error("Widget has not loaded yet");
|
|
1498
|
-
this.widgetInstance.close();
|
|
1499
|
-
}
|
|
1500
|
-
}
|
|
1501
|
-
class ge extends me {
|
|
1502
|
-
constructor() {
|
|
1503
|
-
super(), this.type = "EMBED", this.loaded = !1;
|
|
1504
|
-
}
|
|
1505
|
-
static get observedAttributes() {
|
|
1506
|
-
return ["widget", "locale"];
|
|
1507
|
-
}
|
|
1508
|
-
attributeChangedCallback(n, t, e) {
|
|
1509
|
-
if (!(t === e || !this.loaded))
|
|
1510
|
-
switch (n) {
|
|
1511
|
-
case "locale":
|
|
1512
|
-
case "widget":
|
|
1513
|
-
this.connectedCallback();
|
|
1514
|
-
break;
|
|
1515
|
-
}
|
|
1516
|
-
}
|
|
1517
|
-
async connectedCallback() {
|
|
1518
|
-
var t, e;
|
|
1519
|
-
this.loaded = !0, this.container = this.getAttribute("container"), await this.renderWidget();
|
|
1520
|
-
const n = (t = this.shadowRoot && Array.from(this.shadowRoot.children)) == null ? void 0 : t.find((o) => o.tagName === "SLOT");
|
|
1521
|
-
n && ((e = this.shadowRoot) == null || e.removeChild(n)), this.getAttribute("open") !== null && this.open();
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
class we extends me {
|
|
1525
|
-
constructor() {
|
|
1526
|
-
super(), this.type = "POPUP", this.loaded = !1, this.addEventListener("click", (n) => {
|
|
1527
|
-
n.stopPropagation(), this.open();
|
|
1528
|
-
});
|
|
1529
|
-
}
|
|
1530
|
-
static get observedAttributes() {
|
|
1531
|
-
return ["widget", "locale"];
|
|
1532
|
-
}
|
|
1533
|
-
attributeChangedCallback(n, t, e) {
|
|
1534
|
-
if (!(t === e || !this.loaded))
|
|
1535
|
-
switch (n) {
|
|
1536
|
-
case "locale":
|
|
1537
|
-
case "widget":
|
|
1538
|
-
this.connectedCallback();
|
|
1539
|
-
break;
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
async connectedCallback() {
|
|
1543
|
-
this.loaded = !0, this.container = this.getAttribute("container"), await this.renderWidget(), this.getAttribute("open") !== null && this.open();
|
|
1544
|
-
}
|
|
1545
|
-
}
|
|
1546
|
-
class Ve extends ge {
|
|
1547
|
-
}
|
|
1548
|
-
class Xe extends we {
|
|
1549
|
-
}
|
|
1550
|
-
class Qe extends ge {
|
|
1551
|
-
}
|
|
1552
|
-
class Ye extends we {
|
|
1553
|
-
}
|
|
1554
|
-
window.customElements.get("squatch-embed") || window.customElements.define("squatch-embed", Ve);
|
|
1555
|
-
window.customElements.get("impact-embed") || window.customElements.define("impact-embed", Qe);
|
|
1556
|
-
window.customElements.get("squatch-popup") || window.customElements.define("squatch-popup", Xe);
|
|
1557
|
-
window.customElements.get("impact-popup") || window.customElements.define("impact-popup", Ye);
|
|
1558
|
-
function et() {
|
|
1559
|
-
console.log(
|
|
1560
|
-
"Having trouble using Squatch.js? Go to https://docs.referralsaasquatch.com/developer/ for tutorials, references and error codes."
|
|
1561
|
-
);
|
|
1562
|
-
}
|
|
1563
|
-
const k = g.debug("squatch-js");
|
|
1564
|
-
let D = null, j = null, N = null;
|
|
1565
|
-
function tt() {
|
|
1566
|
-
return D || B({}), D;
|
|
1567
|
-
}
|
|
1568
|
-
function te() {
|
|
1569
|
-
return j || B({}), j;
|
|
1570
|
-
}
|
|
1571
|
-
function nt() {
|
|
1572
|
-
return N || B({}), N;
|
|
1573
|
-
}
|
|
1574
|
-
function ot(i) {
|
|
1575
|
-
var n;
|
|
1576
|
-
return (n = te()) == null ? void 0 : n.render(i);
|
|
1577
|
-
}
|
|
1578
|
-
function it(i) {
|
|
1579
|
-
var t;
|
|
1580
|
-
const n = Be(i);
|
|
1581
|
-
if (n) {
|
|
1582
|
-
const { squatchConfig: e, widgetConfig: o } = n;
|
|
1583
|
-
return B(e), (t = te()) == null ? void 0 : t.render(o);
|
|
1584
|
-
}
|
|
1585
|
-
}
|
|
1586
|
-
function B(i) {
|
|
1587
|
-
const t = J(i);
|
|
1588
|
-
t.tenantAlias.match("^test") || t.debug ? g.debug.enable("squatch-js*") : g.debug.disable(), k("initializing ..."), D = new ee(t), j = new W(t), N = new We(t), k("Widget API instance", D), k("Widgets instance", j), k("Events API instance", N);
|
|
1589
|
-
}
|
|
1590
|
-
function rt(i) {
|
|
1591
|
-
i();
|
|
1592
|
-
}
|
|
1593
|
-
function st(i) {
|
|
1594
|
-
te().autofill(i);
|
|
1595
|
-
}
|
|
1596
|
-
function Ze() {
|
|
1597
|
-
Je();
|
|
1598
|
-
}
|
|
1599
|
-
typeof document < "u" && !window.SaaSquatchDoNotAutoDrop && Ze();
|
|
1600
|
-
var de;
|
|
1601
|
-
(de = window.squatch) != null && de.init && k(
|
|
1602
|
-
"Squatchjs is being loaded more than once. This may lead to multiple load events being sent, duplicated widgets, and inaccurate analytics."
|
|
1603
|
-
);
|
|
1604
|
-
typeof document < "u" && je();
|
|
1605
|
-
export {
|
|
1606
|
-
ge as DeclarativeEmbedWidget,
|
|
1607
|
-
we as DeclarativePopupWidget,
|
|
1608
|
-
$ as EmbedWidget,
|
|
1609
|
-
O as PopupWidget,
|
|
1610
|
-
ee as WidgetApi,
|
|
1611
|
-
W as Widgets,
|
|
1612
|
-
it as _auto,
|
|
1613
|
-
tt as api,
|
|
1614
|
-
st as autofill,
|
|
1615
|
-
nt as events,
|
|
1616
|
-
et as help,
|
|
1617
|
-
B as init,
|
|
1618
|
-
Ze as pushCookie,
|
|
1619
|
-
rt as ready,
|
|
1620
|
-
ot as widget,
|
|
1621
|
-
te as widgets
|
|
1622
|
-
};
|
|
1623
|
-
//# sourceMappingURL=squatch.es.js.map
|