@saasquatch/squatch-js 2.8.3-9 → 2.8.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/CHANGELOG.md +9 -2
- package/babelregister.js +0 -1
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/clover.xml +996 -0
- package/coverage/coverage-final.json +26 -0
- package/coverage/favicon.png +0 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +210 -0
- package/demo/perf-benchmark.ts +363 -0
- package/demo/perf-compare.html +870 -0
- package/demo/perf-deploy/vercel.json +17 -0
- package/demo/perf-frame.html +417 -0
- package/demo/perf-server.ts +131 -0
- package/dist/ErrorTemplate-DUNm11h9.js +124 -0
- package/dist/ErrorTemplate-DUNm11h9.js.map +1 -0
- package/dist/ErrorTemplate-DumOlC5f.cjs +109 -0
- package/dist/ErrorTemplate-DumOlC5f.cjs.map +1 -0
- package/dist/SkeletonTemplate-B3Bk4NFu.cjs +243 -0
- package/dist/SkeletonTemplate-B3Bk4NFu.cjs.map +1 -0
- package/dist/SkeletonTemplate-Day_0iMM.js +246 -0
- package/dist/SkeletonTemplate-Day_0iMM.js.map +1 -0
- package/dist/squatch.cjs.js +20 -329
- package/dist/squatch.cjs.js.map +1 -1
- package/dist/squatch.esm.js +417 -764
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +149 -110
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +2 -2
- package/dist/utils/cookieUtils.d.ts +1 -0
- package/dist/widgets/EmbedWidget.d.ts +1 -1
- package/dist/widgets/ErrorTemplate.d.ts +9 -0
- package/dist/widgets/PopupWidget.d.ts +1 -4
- package/dist/widgets/SkeletonTemplate.d.ts +1 -2
- package/dist/widgets/Widget.d.ts +19 -11
- package/package.json +11 -15
- package/vite-env.d.ts +2 -1
- package/vite.config.ts +17 -0
- package/babel.config.js +0 -8
- package/jest.config.ts +0 -200
package/dist/squatch.esm.js
CHANGED
|
@@ -1,99 +1,107 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var l = (o, t, e) =>
|
|
4
|
-
let
|
|
5
|
-
function
|
|
1
|
+
var Ae = Object.defineProperty;
|
|
2
|
+
var Ie = (o, t, e) => t in o ? Ae(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
|
+
var l = (o, t, e) => Ie(o, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
let _ = null;
|
|
5
|
+
function ve(o) {
|
|
6
6
|
const e = o.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
|
|
7
|
-
|
|
7
|
+
_ = new RegExp(`^${e}$`);
|
|
8
8
|
}
|
|
9
9
|
function _e() {
|
|
10
|
-
|
|
10
|
+
_ = null;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function C(o) {
|
|
13
13
|
const t = (...e) => {
|
|
14
|
-
|
|
14
|
+
_ && _.test(o) && console.log(`[${o}]`, ...e);
|
|
15
15
|
};
|
|
16
16
|
return Object.defineProperty(t, "enabled", {
|
|
17
17
|
get() {
|
|
18
|
-
return !!(
|
|
18
|
+
return !!(_ && _.test(o));
|
|
19
19
|
}
|
|
20
20
|
}), t;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return
|
|
22
|
+
const A = C("squatch-js");
|
|
23
|
+
function V(o) {
|
|
24
|
+
const t = document.cookie.match(
|
|
25
|
+
new RegExp(
|
|
26
|
+
"(?:^|; )" + o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + "=([^;]*)"
|
|
27
|
+
)
|
|
28
|
+
);
|
|
29
|
+
return t ? decodeURIComponent(t[1]) : void 0;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return encodeURIComponent(o).replace(
|
|
37
|
-
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
|
|
38
|
-
decodeURIComponent
|
|
39
|
-
);
|
|
31
|
+
function ke(o, t, e) {
|
|
32
|
+
let n = `${encodeURIComponent(o)}=${encodeURIComponent(t)}`;
|
|
33
|
+
{
|
|
34
|
+
const i = /* @__PURE__ */ new Date();
|
|
35
|
+
i.setTime(i.getTime() + e.expires * 864e5), n += `; expires=${i.toUTCString()}`;
|
|
40
36
|
}
|
|
37
|
+
e.path && (n += `; path=${e.path}`), e.domain && (n += `; domain=${e.domain}`), e.sameSite && (n += `; SameSite=${e.sameSite}`), document.cookie = n;
|
|
38
|
+
}
|
|
39
|
+
const se = (o) => typeof o == "object" && !Array.isArray(o), ce = (o, t) => {
|
|
40
|
+
const e = (i) => se(t[i]) && o.hasOwnProperty(i) && se(o[i]), n = Object.getOwnPropertyNames(t).map((i) => ({
|
|
41
|
+
[i]: e(i) ? ce(o[i], t[i]) : t[i]
|
|
42
|
+
})).reduce((i, s) => ({ ...i, ...s }), {});
|
|
43
|
+
return {
|
|
44
|
+
...o,
|
|
45
|
+
...n
|
|
46
|
+
};
|
|
41
47
|
};
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
function L(o) {
|
|
49
|
+
const t = atob(o.replace(/_/g, "/").replace(/-/g, "+")), e = new Uint8Array(t.length);
|
|
50
|
+
for (let n = 0; n < t.length; n++)
|
|
51
|
+
e[n] = t.charCodeAt(n);
|
|
52
|
+
return new TextDecoder("utf8").decode(e);
|
|
53
|
+
}
|
|
54
|
+
function re(o) {
|
|
55
|
+
const t = new TextEncoder().encode(o), e = Array.from(
|
|
56
|
+
t,
|
|
57
|
+
(n) => String.fromCodePoint(n)
|
|
58
|
+
).join("");
|
|
59
|
+
return btoa(e).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
60
|
+
}
|
|
61
|
+
function Se() {
|
|
62
|
+
var o, t, e = "weird_get_top_level_domain=cookie", n = document.location.hostname.split(".");
|
|
63
|
+
for (o = n.length - 1; o >= 0; o--)
|
|
64
|
+
if (t = n.slice(o).join("."), document.cookie = e + ";domain=." + t + ";", document.cookie.indexOf(e) > -1)
|
|
65
|
+
return document.cookie = e.split("=")[0] + "=;domain=." + t + ";expires=Thu, 01 Jan 1970 00:00:01 GMT;", t;
|
|
66
|
+
}
|
|
67
|
+
function Te() {
|
|
68
|
+
const o = window.location.search, e = new URLSearchParams(o).get("_saasquatch") || "";
|
|
69
|
+
if (e) {
|
|
70
|
+
let n = "", i = "", s = "";
|
|
71
|
+
try {
|
|
72
|
+
n = JSON.parse(L(e));
|
|
73
|
+
} catch (r) {
|
|
74
|
+
A("Unable to decode params", r);
|
|
75
|
+
return;
|
|
50
76
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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 {
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return i ? r[i] : r;
|
|
77
|
+
try {
|
|
78
|
+
i = JSON.parse(L(V("_saasquatch"))), A("existing cookie", i);
|
|
79
|
+
} catch (r) {
|
|
80
|
+
A("Unable to retrieve cookie", r);
|
|
64
81
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
},
|
|
82
|
-
withConverter: function(i) {
|
|
83
|
-
return V(q({}, this.converter, i), this.attributes);
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
attributes: { value: Object.freeze(t) },
|
|
88
|
-
converter: { value: Object.freeze(o) }
|
|
82
|
+
try {
|
|
83
|
+
const r = Se();
|
|
84
|
+
if (A("domain retrieved:", r), i) {
|
|
85
|
+
const a = ce(i, n);
|
|
86
|
+
s = re(JSON.stringify(a)), A("cookie to store:", a);
|
|
87
|
+
} else
|
|
88
|
+
s = re(JSON.stringify(n)), A("cookie to store:", n);
|
|
89
|
+
ke("_saasquatch", s, {
|
|
90
|
+
expires: 365,
|
|
91
|
+
secure: !1,
|
|
92
|
+
sameSite: "Lax",
|
|
93
|
+
domain: r,
|
|
94
|
+
path: "/"
|
|
95
|
+
});
|
|
96
|
+
} catch (r) {
|
|
97
|
+
A("Unable to set cookie", r);
|
|
89
98
|
}
|
|
90
|
-
|
|
99
|
+
}
|
|
91
100
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
function U(o) {
|
|
101
|
+
const k = "https://app.referralsaasquatch.com", X = "https://fast.ssqt.io/npm", M = "squatch", z = "impact";
|
|
102
|
+
function q(o) {
|
|
95
103
|
if (typeof o != "object") throw new Error("config must be an object");
|
|
96
|
-
const t = window.squatchTenant, e =
|
|
104
|
+
const t = window.squatchTenant, e = Y(), n = {
|
|
97
105
|
tenantAlias: (o == null ? void 0 : o.tenantAlias) || t,
|
|
98
106
|
domain: (o == null ? void 0 : o.domain) || (e == null ? void 0 : e.domain),
|
|
99
107
|
npmCdn: (o == null ? void 0 : o.npmCdn) || (e == null ? void 0 : e.npmCdn),
|
|
@@ -101,7 +109,7 @@ function U(o) {
|
|
|
101
109
|
};
|
|
102
110
|
if (typeof n.tenantAlias != "string")
|
|
103
111
|
throw new Error("tenantAlias not provided");
|
|
104
|
-
const i = n.tenantAlias, s = typeof n.domain == "string" && n.domain ||
|
|
112
|
+
const i = n.tenantAlias, s = typeof n.domain == "string" && n.domain || k, r = typeof n.debug == "boolean" && n.debug || !1, a = typeof n.npmCdn == "string" && n.npmCdn || X;
|
|
105
113
|
return {
|
|
106
114
|
tenantAlias: i,
|
|
107
115
|
domain: s,
|
|
@@ -109,43 +117,40 @@ function U(o) {
|
|
|
109
117
|
npmCdn: a
|
|
110
118
|
};
|
|
111
119
|
}
|
|
112
|
-
function
|
|
120
|
+
function S(o) {
|
|
113
121
|
return typeof o == "object" && !Array.isArray(o) && o !== null;
|
|
114
122
|
}
|
|
115
123
|
function $e(o) {
|
|
116
124
|
if (o && /^[a-z]{2}_(?:[A-Z]{2}|[0-9]{3})$/.test(o))
|
|
117
125
|
return o;
|
|
118
126
|
}
|
|
119
|
-
function
|
|
120
|
-
if (!
|
|
127
|
+
function de(o) {
|
|
128
|
+
if (!S(o)) throw new Error("Widget properties must be an object");
|
|
121
129
|
if (!(o != null && o.user)) throw new Error("Required properties missing.");
|
|
122
130
|
return o;
|
|
123
131
|
}
|
|
124
|
-
function
|
|
125
|
-
if (!
|
|
132
|
+
function le(o) {
|
|
133
|
+
if (!S(o)) throw new Error("Widget properties must be an object");
|
|
126
134
|
return o;
|
|
127
135
|
}
|
|
128
136
|
function W() {
|
|
129
137
|
return window.impactToken || window.squatchToken;
|
|
130
138
|
}
|
|
131
|
-
function
|
|
139
|
+
function Y() {
|
|
132
140
|
return window.impactConfig || window.squatchConfig;
|
|
133
141
|
}
|
|
134
|
-
|
|
135
|
-
|
|
142
|
+
const he = C("squatch-js:io");
|
|
143
|
+
function B(o) {
|
|
144
|
+
let t, e, n, i = o;
|
|
136
145
|
try {
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
} catch (t) {
|
|
144
|
-
console.log("[DEBUG] parseErrorResponse - JSON parse failed:", t);
|
|
145
|
-
}
|
|
146
|
-
return { message: o };
|
|
146
|
+
const r = JSON.parse(o);
|
|
147
|
+
r && typeof r == "object" && (t = r.apiErrorCode, e = r.rsCode, n = r.statusCode, i = r.message || o);
|
|
148
|
+
} catch {
|
|
149
|
+
}
|
|
150
|
+
const s = new Error(i);
|
|
151
|
+
return t && (s.apiErrorCode = t), e && (s.rsCode = e), n !== void 0 && (s.statusCode = n), s;
|
|
147
152
|
}
|
|
148
|
-
async function
|
|
153
|
+
async function xe(o, t, e, n) {
|
|
149
154
|
const i = n || W(), s = {
|
|
150
155
|
Accept: "application/json",
|
|
151
156
|
"Content-Type": "application/json",
|
|
@@ -158,18 +163,18 @@ async function Ue(o, t, e, n) {
|
|
|
158
163
|
body: JSON.stringify({ query: t, variables: e }),
|
|
159
164
|
headers: s
|
|
160
165
|
});
|
|
161
|
-
if (!r.ok) throw
|
|
166
|
+
if (!r.ok) throw B(await r.text());
|
|
162
167
|
return await r.json();
|
|
163
168
|
} catch (r) {
|
|
164
169
|
throw r;
|
|
165
170
|
}
|
|
166
171
|
}
|
|
167
|
-
async function
|
|
172
|
+
async function qe(o, t = "") {
|
|
168
173
|
const e = {
|
|
169
174
|
Accept: "application/json",
|
|
170
175
|
"Content-Type": "application/json"
|
|
171
176
|
}, n = t || W();
|
|
172
|
-
n ?
|
|
177
|
+
n ? e["X-SaaSquatch-User-Token"] = n : he(
|
|
173
178
|
"[DEBUG] doGet - No token found, proceeding without authentication header."
|
|
174
179
|
);
|
|
175
180
|
try {
|
|
@@ -178,7 +183,7 @@ async function We(o, t = "") {
|
|
|
178
183
|
credentials: "include",
|
|
179
184
|
headers: e
|
|
180
185
|
}), s = await i.text();
|
|
181
|
-
if (!i.ok) throw
|
|
186
|
+
if (!i.ok) throw B(s);
|
|
182
187
|
return s && JSON.parse(s);
|
|
183
188
|
} catch (i) {
|
|
184
189
|
throw i;
|
|
@@ -189,7 +194,7 @@ async function Q(o, t, e) {
|
|
|
189
194
|
Accept: "application/json",
|
|
190
195
|
"Content-Type": "application/json"
|
|
191
196
|
}, i = e || W();
|
|
192
|
-
i ?
|
|
197
|
+
i ? n["X-SaaSquatch-User-Token"] = i : he(
|
|
193
198
|
"[DEBUG] doPost - No token found, proceeding without authentication header."
|
|
194
199
|
);
|
|
195
200
|
try {
|
|
@@ -198,13 +203,13 @@ async function Q(o, t, e) {
|
|
|
198
203
|
body: t,
|
|
199
204
|
headers: n
|
|
200
205
|
}), r = await s.text();
|
|
201
|
-
if (!s.ok) throw
|
|
206
|
+
if (!s.ok) throw B(r);
|
|
202
207
|
return r && JSON.parse(r);
|
|
203
208
|
} catch (s) {
|
|
204
209
|
throw s;
|
|
205
210
|
}
|
|
206
211
|
}
|
|
207
|
-
async function
|
|
212
|
+
async function We(o, t, e) {
|
|
208
213
|
const n = {
|
|
209
214
|
Accept: "application/json",
|
|
210
215
|
"Content-Type": "application/json",
|
|
@@ -218,13 +223,13 @@ async function qe(o, t, e) {
|
|
|
218
223
|
credentials: "include",
|
|
219
224
|
body: t
|
|
220
225
|
}), r = await s.text();
|
|
221
|
-
if (!s.ok) throw
|
|
226
|
+
if (!s.ok) throw B(r);
|
|
222
227
|
return r && JSON.parse(r);
|
|
223
228
|
} catch (s) {
|
|
224
229
|
throw s;
|
|
225
230
|
}
|
|
226
231
|
}
|
|
227
|
-
const
|
|
232
|
+
const Me = `
|
|
228
233
|
query renderWidget ($user: UserIdInput, $engagementMedium: UserEngagementMedium, $widgetType: WidgetType, $locale: RSLocale) {
|
|
229
234
|
renderWidget(user: $user, engagementMedium: $engagementMedium, widgetType: $widgetType, locale: $locale) {
|
|
230
235
|
template
|
|
@@ -261,7 +266,7 @@ class Z {
|
|
|
261
266
|
l(this, "domain");
|
|
262
267
|
l(this, "npmCdn");
|
|
263
268
|
l(this, "referralCookie", this.squatchReferralCookie);
|
|
264
|
-
const n =
|
|
269
|
+
const n = q(t);
|
|
265
270
|
this.tenantAlias = n.tenantAlias, this.domain = n.domain, this.npmCdn = n.npmCdn;
|
|
266
271
|
}
|
|
267
272
|
/**
|
|
@@ -279,18 +284,18 @@ class Z {
|
|
|
279
284
|
* @return {Promise} string if true, with the widget template, jsOptions and user details.
|
|
280
285
|
*/
|
|
281
286
|
upsertUser(t) {
|
|
282
|
-
const n =
|
|
287
|
+
const n = de(t), {
|
|
283
288
|
widgetType: i,
|
|
284
289
|
engagementMedium: s = "POPUP",
|
|
285
290
|
jwt: r,
|
|
286
291
|
locale: a,
|
|
287
|
-
user:
|
|
288
|
-
} = n,
|
|
292
|
+
user: c
|
|
293
|
+
} = n, d = encodeURIComponent(this.tenantAlias), h = c.accountId ? encodeURIComponent(c.accountId) : null, u = c.id ? encodeURIComponent(c.id) : null, m = Ue({
|
|
289
294
|
widgetType: i,
|
|
290
295
|
engagementMedium: s,
|
|
291
296
|
locale: a
|
|
292
|
-
}),
|
|
293
|
-
return
|
|
297
|
+
}), p = `/api/v1/${d}/widget/account/${h}/user/${u}/upsert${m}`, g = this.domain + p, f = V("_saasquatch");
|
|
298
|
+
return f && (c.cookies = f), We(g, JSON.stringify(c), r);
|
|
294
299
|
}
|
|
295
300
|
/**
|
|
296
301
|
* Requests widget template
|
|
@@ -306,24 +311,24 @@ class Z {
|
|
|
306
311
|
* @return {Promise} template html if true.
|
|
307
312
|
*/
|
|
308
313
|
render(t) {
|
|
309
|
-
const n =
|
|
310
|
-
return new Promise(async (g,
|
|
314
|
+
const n = le(t), { widgetType: i, engagementMedium: s = "POPUP", jwt: r, user: a } = n, c = encodeURIComponent(this.tenantAlias), d = a != null && a.accountId ? encodeURIComponent(a.accountId) : null, h = a != null && a.id ? encodeURIComponent(a.id) : null, u = n.locale ?? $e(navigator.language.replace(/\-/g, "_")), m = `/api/v1/${c}/graphql`, p = this.domain + m;
|
|
315
|
+
return new Promise(async (g, f) => {
|
|
311
316
|
var b;
|
|
312
317
|
try {
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
|
|
318
|
+
const w = await xe(
|
|
319
|
+
p,
|
|
320
|
+
Me,
|
|
316
321
|
{
|
|
317
|
-
user: h &&
|
|
322
|
+
user: h && d ? { id: h, accountId: d } : null,
|
|
318
323
|
engagementMedium: s,
|
|
319
324
|
widgetType: i,
|
|
320
325
|
locale: u
|
|
321
326
|
},
|
|
322
327
|
r
|
|
323
328
|
);
|
|
324
|
-
g((b =
|
|
325
|
-
} catch (
|
|
326
|
-
w
|
|
329
|
+
g((b = w == null ? void 0 : w.data) == null ? void 0 : b.renderWidget);
|
|
330
|
+
} catch (w) {
|
|
331
|
+
f(w);
|
|
327
332
|
}
|
|
328
333
|
});
|
|
329
334
|
}
|
|
@@ -333,14 +338,14 @@ class Z {
|
|
|
333
338
|
* @return {Promise<ReferralCookie>} code referral code if true.
|
|
334
339
|
*/
|
|
335
340
|
async squatchReferralCookie() {
|
|
336
|
-
const t = encodeURIComponent(this.tenantAlias), e = (
|
|
341
|
+
const t = encodeURIComponent(this.tenantAlias), e = V("_saasquatch") || "", n = e ? `?cookies=${encodeURIComponent(e)}` : "", i = `${this.domain}/a/${t}/widgets/squatchcookiejson${n}`, s = await qe(i);
|
|
337
342
|
return Promise.resolve({
|
|
338
343
|
...s,
|
|
339
344
|
encodedCookie: e
|
|
340
345
|
});
|
|
341
346
|
}
|
|
342
347
|
}
|
|
343
|
-
function
|
|
348
|
+
function Ue({
|
|
344
349
|
widgetType: o,
|
|
345
350
|
engagementMedium: t,
|
|
346
351
|
locale: e
|
|
@@ -352,7 +357,7 @@ function Re({
|
|
|
352
357
|
* domready (c) Dustin Diaz 2014 - License MIT
|
|
353
358
|
*
|
|
354
359
|
*/
|
|
355
|
-
function
|
|
360
|
+
function x(o, t) {
|
|
356
361
|
let e = [], n, i = o, s = i.documentElement.doScroll, r = "DOMContentLoaded", a = (s ? /^loaded|^c/ : /^loaded|^i|^c/).test(i.readyState);
|
|
357
362
|
return a || i.addEventListener(
|
|
358
363
|
r,
|
|
@@ -361,7 +366,7 @@ function Y(o, t) {
|
|
|
361
366
|
}
|
|
362
367
|
), a ? setTimeout(t, 0) : e.push(t);
|
|
363
368
|
}
|
|
364
|
-
function
|
|
369
|
+
function O({
|
|
365
370
|
value: o,
|
|
366
371
|
unit: t
|
|
367
372
|
}) {
|
|
@@ -385,282 +390,25 @@ class ue {
|
|
|
385
390
|
constructor(t) {
|
|
386
391
|
l(this, "domain");
|
|
387
392
|
var i;
|
|
388
|
-
const n =
|
|
389
|
-
this.domain = (n == null ? void 0 : n.domain) || ((i =
|
|
393
|
+
const n = Re(t);
|
|
394
|
+
this.domain = (n == null ? void 0 : n.domain) || ((i = Y()) == null ? void 0 : i.domain) || k;
|
|
390
395
|
}
|
|
391
396
|
pushAnalyticsLoadEvent(t) {
|
|
392
397
|
if (!t.externalUserId || !t.externalAccountId) return;
|
|
393
|
-
const e = encodeURIComponent(t.tenantAlias),
|
|
394
|
-
return Q(
|
|
398
|
+
const e = window.location.search, n = new URLSearchParams(e), i = n == null ? void 0 : n.get("rsShareMedium"), s = encodeURIComponent(t.tenantAlias), r = encodeURIComponent(t.externalAccountId), a = encodeURIComponent(t.externalUserId), c = encodeURIComponent(t.engagementMedium), d = t.programId ? `&programId=${encodeURIComponent(t.programId)}` : "", h = i ? `&shareMedium=${encodeURIComponent(i)}` : "", u = `/a/${s}/widgets/analytics/loaded?externalAccountId=${r}&externalUserId=${a}&engagementMedium=${c}${h}${d}`, m = this.domain + u;
|
|
399
|
+
return Q(m, JSON.stringify({}));
|
|
395
400
|
}
|
|
396
401
|
pushAnalyticsShareClickedEvent(t) {
|
|
397
|
-
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}`,
|
|
398
|
-
return Q(
|
|
402
|
+
const e = encodeURIComponent(t.tenantAlias), n = encodeURIComponent(t.externalAccountId), i = encodeURIComponent(t.externalUserId), s = encodeURIComponent(t.engagementMedium), r = encodeURIComponent(t.shareMedium), a = `/a/${e}/widgets/analytics/shared?externalAccountId=${n}&externalUserId=${i}&engagementMedium=${s}&shareMedium=${r}`, c = this.domain + a;
|
|
403
|
+
return Q(c, JSON.stringify({}));
|
|
399
404
|
}
|
|
400
405
|
}
|
|
401
|
-
function
|
|
402
|
-
if (!
|
|
406
|
+
function Re(o) {
|
|
407
|
+
if (!S(o)) throw new Error("'options' should be an object");
|
|
403
408
|
return o;
|
|
404
409
|
}
|
|
405
|
-
const
|
|
406
|
-
|
|
407
|
-
height: t = "500px"
|
|
408
|
-
}) => {
|
|
409
|
-
const e = "#e0e0e0";
|
|
410
|
-
return `
|
|
411
|
-
<style>
|
|
412
|
-
* {
|
|
413
|
-
box-sizing: border-box;
|
|
414
|
-
padding: 0;
|
|
415
|
-
margin: 0;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
.widget-container {
|
|
419
|
-
background: white;
|
|
420
|
-
width: 100%;
|
|
421
|
-
padding: 40px;
|
|
422
|
-
box-sizing: border-box;
|
|
423
|
-
overflow: hidden;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
@keyframes shimmer {
|
|
427
|
-
0% { background-position: -100% 0; }
|
|
428
|
-
100% { background-position: 100% 0; }
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
.skeleton {
|
|
432
|
-
background: ${e};
|
|
433
|
-
background: linear-gradient(
|
|
434
|
-
90deg,
|
|
435
|
-
${e} 25%,
|
|
436
|
-
#f5f5f5 50%,
|
|
437
|
-
${e} 75%
|
|
438
|
-
);
|
|
439
|
-
background-size: 200% 100%;
|
|
440
|
-
animation: shimmer 1.5s infinite linear;
|
|
441
|
-
border-radius: 6px;
|
|
442
|
-
margin-bottom: 12px;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
/* Typography Skeletons */
|
|
446
|
-
.sk-title-lg { height: 36px; width: 80%; margin-bottom: 16px; }
|
|
447
|
-
.sk-title-md { height: 28px; width: 30%; margin-bottom: 20px; margin-top: 40px; }
|
|
448
|
-
.sk-text { height: 16px; width: 90%; margin-bottom: 8px; }
|
|
449
|
-
.sk-text-short { width: 40%; }
|
|
450
|
-
.sk-label { height: 14px; width: 25%; margin-bottom: 10px; }
|
|
451
|
-
|
|
452
|
-
/* Layouts */
|
|
453
|
-
.hero-section {
|
|
454
|
-
display: flex;
|
|
455
|
-
gap: 40px;
|
|
456
|
-
margin-bottom: 40px;
|
|
457
|
-
padding-bottom: 40px;
|
|
458
|
-
flex-direction: row;
|
|
459
|
-
height: 100%;
|
|
460
|
-
/* Removed border-bottom */
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
.hero-content {
|
|
464
|
-
flex: 1;
|
|
465
|
-
display: flex;
|
|
466
|
-
flex-direction: column;
|
|
467
|
-
justify-content: center;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
.hero-image {
|
|
471
|
-
flex: 1;
|
|
472
|
-
height: 300px;
|
|
473
|
-
border-radius: 12px;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
/* -- Specific Instant Access Overrides -- */
|
|
477
|
-
.instant-access-layout {
|
|
478
|
-
margin-bottom: 0;
|
|
479
|
-
padding-bottom: 0;
|
|
480
|
-
align-items: center;
|
|
481
|
-
}
|
|
482
|
-
.ia-image {
|
|
483
|
-
height: 400px;
|
|
484
|
-
}
|
|
485
|
-
.ia-center {
|
|
486
|
-
margin-left: auto;
|
|
487
|
-
margin-right: auto;
|
|
488
|
-
}
|
|
489
|
-
.ia-content {
|
|
490
|
-
align-items: center;
|
|
491
|
-
text-align: center;
|
|
492
|
-
}
|
|
493
|
-
.sk-btn-action {
|
|
494
|
-
height: 45px;
|
|
495
|
-
width: 140px;
|
|
496
|
-
border-radius: 6px;
|
|
497
|
-
margin: 24px auto;
|
|
498
|
-
}
|
|
499
|
-
.input-group {
|
|
500
|
-
display: flex;
|
|
501
|
-
gap: 10px;
|
|
502
|
-
width: 100%;
|
|
503
|
-
max-width: 400px;
|
|
504
|
-
}
|
|
505
|
-
.sk-btn-copy {
|
|
506
|
-
height: 50px;
|
|
507
|
-
width: 120px;
|
|
508
|
-
border-radius: 8px;
|
|
509
|
-
}
|
|
510
|
-
/* ------------------------------------- */
|
|
511
|
-
|
|
512
|
-
.share-section { margin-bottom: 40px; }
|
|
513
|
-
.sk-input { height: 50px; width: 100%; border-radius: 8px; margin-bottom: 16px; }
|
|
514
|
-
|
|
515
|
-
.social-buttons { display: flex; gap: 12px; }
|
|
516
|
-
.sk-btn-social { flex: 1; height: 50px; border-radius: 8px; }
|
|
517
|
-
|
|
518
|
-
.stats-section {
|
|
519
|
-
display: flex;
|
|
520
|
-
gap: 24px;
|
|
521
|
-
margin-bottom: 40px;
|
|
522
|
-
padding: 30px 0;
|
|
523
|
-
/* Removed border-top and border-bottom */
|
|
524
|
-
}
|
|
525
|
-
.stat-card { flex: 1; display: flex; flex-direction: column; align-items: center; }
|
|
526
|
-
.stat-divider { padding-left: 24px; }
|
|
527
|
-
.sk-stat-num { height: 48px; width: 120px; margin-bottom: 8px; }
|
|
528
|
-
.sk-stat-label { height: 18px; width: 80px; }
|
|
529
|
-
|
|
530
|
-
/* Table Styles */
|
|
531
|
-
.table-header { display: flex; gap: 16px; margin-bottom: 16px; }
|
|
532
|
-
.sk-th { height: 16px; }
|
|
533
|
-
.table-row {
|
|
534
|
-
display: flex;
|
|
535
|
-
align-items: center;
|
|
536
|
-
gap: 16px;
|
|
537
|
-
padding: 16px 0;
|
|
538
|
-
/* Removed border-bottom */
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
.col-user { flex: 2; }
|
|
542
|
-
.col-status { flex: 1; }
|
|
543
|
-
.col-reward { flex: 2; }
|
|
544
|
-
.col-date { flex: 1; }
|
|
545
|
-
|
|
546
|
-
.sk-badge { height: 28px; width: 90px; border-radius: 14px; }
|
|
547
|
-
.sk-reward-block { height: 36px; width: 100%; border-radius: 6px; }
|
|
548
|
-
|
|
549
|
-
.pagination { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
|
|
550
|
-
.sk-btn-page { height: 36px; width: 64px; border-radius: 6px; margin-bottom: 0; }
|
|
551
|
-
|
|
552
|
-
@media (max-width: 768px) {
|
|
553
|
-
body { padding: 20px; }
|
|
554
|
-
.widget-container { padding: 24px; }
|
|
555
|
-
|
|
556
|
-
.hero-section { flex-direction: column-reverse; gap: 24px; }
|
|
557
|
-
.instant-access-layout { flex-direction: column; }
|
|
558
|
-
|
|
559
|
-
.hero-image { height: 220px; width: 100%; }
|
|
560
|
-
.sk-title-lg { width: 100%; }
|
|
561
|
-
|
|
562
|
-
.col-date { display: none; }
|
|
563
|
-
}
|
|
564
|
-
</style>
|
|
565
|
-
|
|
566
|
-
<div class="widget-container">
|
|
567
|
-
${o === "verified-access" ? `
|
|
568
|
-
<div class="hero-section">
|
|
569
|
-
<div class="hero-content">
|
|
570
|
-
<div class="skeleton sk-title-lg"></div>
|
|
571
|
-
<div class="skeleton sk-text"></div>
|
|
572
|
-
<div class="skeleton sk-text sk-text-short"></div>
|
|
573
|
-
</div>
|
|
574
|
-
<div class="skeleton hero-image"></div>
|
|
575
|
-
</div>
|
|
576
|
-
|
|
577
|
-
<div class="share-section">
|
|
578
|
-
<div class="skeleton sk-label"></div>
|
|
579
|
-
<div class="skeleton sk-input"></div>
|
|
580
|
-
<div class="social-buttons">
|
|
581
|
-
<div class="skeleton sk-btn-social"></div>
|
|
582
|
-
<div class="skeleton sk-btn-social"></div>
|
|
583
|
-
<div class="skeleton sk-btn-social"></div>
|
|
584
|
-
<div class="skeleton sk-btn-social"></div>
|
|
585
|
-
</div>
|
|
586
|
-
</div>
|
|
587
|
-
|
|
588
|
-
<div class="skeleton sk-title-md" style="margin-top: 0; width: 30%; margin-left: auto; margin-right: auto"></div>
|
|
589
|
-
<div class="skeleton sk-text" style="width: 60%; margin-left: auto; margin-right: auto"></div>
|
|
590
|
-
|
|
591
|
-
<div class="stats-section">
|
|
592
|
-
<div class="stat-card">
|
|
593
|
-
<div class="skeleton sk-stat-num"></div>
|
|
594
|
-
<div class="skeleton sk-stat-label"></div>
|
|
595
|
-
</div>
|
|
596
|
-
<div class="stat-card stat-divider">
|
|
597
|
-
<div class="skeleton sk-stat-num"></div>
|
|
598
|
-
<div class="skeleton sk-stat-label"></div>
|
|
599
|
-
</div>
|
|
600
|
-
</div>
|
|
601
|
-
|
|
602
|
-
<div class="skeleton sk-title-md"></div>
|
|
603
|
-
|
|
604
|
-
<div class="table-header">
|
|
605
|
-
<div class="skeleton sk-th col-user"></div>
|
|
606
|
-
<div class="skeleton sk-th col-status"></div>
|
|
607
|
-
<div class="skeleton sk-th col-reward"></div>
|
|
608
|
-
<div class="skeleton sk-th col-date"></div>
|
|
609
|
-
</div>
|
|
610
|
-
|
|
611
|
-
<div class="table-row">
|
|
612
|
-
<div class="col-user"><div class="skeleton sk-text" style="width: 70%; 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: 60%; 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="table-row">
|
|
626
|
-
<div class="col-user"><div class="skeleton sk-text" style="width: 75%; margin: 0"></div></div>
|
|
627
|
-
<div class="col-status"><div class="skeleton sk-badge" style="margin: 0"></div></div>
|
|
628
|
-
<div class="col-reward"><div class="skeleton sk-reward-block" style="margin: 0"></div></div>
|
|
629
|
-
<div class="col-date"><div class="skeleton sk-text" style="width: 80%; margin: 0"></div></div>
|
|
630
|
-
</div>
|
|
631
|
-
|
|
632
|
-
<div class="pagination">
|
|
633
|
-
<div class="skeleton sk-btn-page"></div>
|
|
634
|
-
<div class="skeleton sk-btn-page"></div>
|
|
635
|
-
</div>
|
|
636
|
-
` : `
|
|
637
|
-
<div class="hero-section instant-access-layout">
|
|
638
|
-
<div class="skeleton hero-image ia-image"></div>
|
|
639
|
-
|
|
640
|
-
<div class="hero-content ia-content">
|
|
641
|
-
<div class="skeleton sk-title-lg ia-center"></div>
|
|
642
|
-
<div class="skeleton sk-text ia-center"></div>
|
|
643
|
-
|
|
644
|
-
<div class="skeleton sk-btn-action"></div>
|
|
645
|
-
|
|
646
|
-
<div class="skeleton sk-label"></div>
|
|
647
|
-
<div class="input-group">
|
|
648
|
-
<div class="skeleton sk-input"></div>
|
|
649
|
-
<div class="skeleton sk-btn-copy"></div>
|
|
650
|
-
</div>
|
|
651
|
-
|
|
652
|
-
<div class="skeleton sk-text-short ia-center" style="margin-top: 20px; width: 30%"></div>
|
|
653
|
-
<div class="skeleton sk-text-short ia-center" style="width: 20%"></div>
|
|
654
|
-
</div>
|
|
655
|
-
</div>
|
|
656
|
-
`}
|
|
657
|
-
</div>
|
|
658
|
-
`;
|
|
659
|
-
}, Pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
660
|
-
__proto__: null,
|
|
661
|
-
getSkeleton: pe
|
|
662
|
-
}, Symbol.toStringTag, { value: "Module" })), y = k("squatch-js:widget");
|
|
663
|
-
class ge {
|
|
410
|
+
const y = C("squatch-js:widget");
|
|
411
|
+
class me {
|
|
664
412
|
constructor(t) {
|
|
665
413
|
l(this, "type");
|
|
666
414
|
l(this, "content");
|
|
@@ -670,13 +418,39 @@ class ge {
|
|
|
670
418
|
l(this, "npmCdn");
|
|
671
419
|
l(this, "container");
|
|
672
420
|
l(this, "loadEventListener", null);
|
|
421
|
+
l(this, "errorInfo");
|
|
673
422
|
var e;
|
|
674
|
-
y("widget initializing ..."),
|
|
423
|
+
y("widget initializing ..."), t.content === "error" ? (this.content = "error", this.errorInfo = {
|
|
675
424
|
rsCode: t.rsCode,
|
|
676
425
|
apiErrorCode: t.apiErrorCode,
|
|
677
426
|
statusCode: t.statusCode,
|
|
678
427
|
message: t.errorMessage
|
|
679
|
-
}) : 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;
|
|
428
|
+
}) : this.content = t.content, this.type = t.type, this.widgetApi = t.api, this.npmCdn = t.npmCdn, this.analyticsApi = new ue({ domain: t.domain }), this.context = t.context, this.container = ((e = t.context) == null ? void 0 : e.container) || t.container;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Returns the widget content, dynamically loading the error template if needed.
|
|
432
|
+
*/
|
|
433
|
+
async _getContent() {
|
|
434
|
+
if (this.content === "error" && this.errorInfo) {
|
|
435
|
+
const { getErrorTemplate: t } = await import("./ErrorTemplate-DUNm11h9.js");
|
|
436
|
+
return t({
|
|
437
|
+
rsCode: this.errorInfo.rsCode,
|
|
438
|
+
apiErrorCode: this.errorInfo.apiErrorCode,
|
|
439
|
+
statusCode: this.errorInfo.statusCode,
|
|
440
|
+
mode: this._getErrorMode(),
|
|
441
|
+
style: this._getErrorStyle(),
|
|
442
|
+
message: this.errorInfo.message
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
return this.content;
|
|
446
|
+
}
|
|
447
|
+
/** Override in subclasses to customize error template mode */
|
|
448
|
+
_getErrorMode() {
|
|
449
|
+
return "modal";
|
|
450
|
+
}
|
|
451
|
+
/** Override in subclasses to customize error template styles */
|
|
452
|
+
_getErrorStyle() {
|
|
453
|
+
return "";
|
|
680
454
|
}
|
|
681
455
|
_findElement() {
|
|
682
456
|
let t;
|
|
@@ -717,7 +491,7 @@ class ge {
|
|
|
717
491
|
_loadEvent(t) {
|
|
718
492
|
var n;
|
|
719
493
|
if (!t) return;
|
|
720
|
-
if (!
|
|
494
|
+
if (!S(t))
|
|
721
495
|
throw new Error("Widget Load event identity property is not an object");
|
|
722
496
|
let e;
|
|
723
497
|
if ("programId" in t) {
|
|
@@ -760,69 +534,6 @@ class ge {
|
|
|
760
534
|
y(`ERROR: pushAnalyticsShareClickedEvent() ${n}`);
|
|
761
535
|
});
|
|
762
536
|
}
|
|
763
|
-
_error(t, e = "modal", n = "") {
|
|
764
|
-
const { rsCode: i, apiErrorCode: s, statusCode: r, message: a } = t || {};
|
|
765
|
-
return `<!DOCTYPE html>
|
|
766
|
-
<!--[if IE 7]><html class="ie7 oldie" lang="en"><![endif]-->
|
|
767
|
-
<!--[if IE 8]><html class="ie8 oldie" lang="en"><![endif]-->
|
|
768
|
-
<!--[if gt IE 8]><!--><html lang="en"><!--<![endif]-->
|
|
769
|
-
<head>
|
|
770
|
-
<link rel="stylesheet" media="all" href="https://fast.ssqt.io/assets/css/widget/errorpage.css">
|
|
771
|
-
<style>
|
|
772
|
-
${n}
|
|
773
|
-
.error-details {
|
|
774
|
-
margin-top: 16px;
|
|
775
|
-
padding: 12px;
|
|
776
|
-
background: #f8f8f8;
|
|
777
|
-
border-radius: 4px;
|
|
778
|
-
text-align: left;
|
|
779
|
-
font-size: 13px;
|
|
780
|
-
color: #666;
|
|
781
|
-
}
|
|
782
|
-
.error-details dt {
|
|
783
|
-
font-weight: 600;
|
|
784
|
-
color: #333;
|
|
785
|
-
margin-top: 8px;
|
|
786
|
-
}
|
|
787
|
-
.error-details dt:first-child {
|
|
788
|
-
margin-top: 0;
|
|
789
|
-
}
|
|
790
|
-
.error-details dd {
|
|
791
|
-
margin: 4px 0 0 0;
|
|
792
|
-
word-break: break-word;
|
|
793
|
-
font-family: monospace;
|
|
794
|
-
}
|
|
795
|
-
.error-details dd.message {
|
|
796
|
-
font-family: inherit;
|
|
797
|
-
}
|
|
798
|
-
</style>
|
|
799
|
-
</head>
|
|
800
|
-
<body>
|
|
801
|
-
|
|
802
|
-
<div class="squatch-container ${e}" style="width:100%">
|
|
803
|
-
<div class="errorheader">
|
|
804
|
-
<button type="button" class="close" onclick="window.frameElement.squatchJsApi.close();">×</button>
|
|
805
|
-
<p class="errortitle">Error</p>
|
|
806
|
-
</div>
|
|
807
|
-
<div class="errorbody">
|
|
808
|
-
<div class="sadface"><img src="https://res.cloudinary.com/saasquatch-staging/image/upload/v1774538373/whoops-error-image_km94z1.svg"></div>
|
|
809
|
-
<h4>Our referral program is temporarily unavailable.</h4>
|
|
810
|
-
<p>Please reload the page or check back later.</p>
|
|
811
|
-
<p>If the problem persists please contact our support team.</p>
|
|
812
|
-
|
|
813
|
-
${r || s || i || a ? `
|
|
814
|
-
<dl class="error-details">
|
|
815
|
-
${r ? `<dt>Status Code</dt><dd>${r}</dd>` : ""}
|
|
816
|
-
${s ? `<dt>API Error Code</dt><dd>${s}</dd>` : ""}
|
|
817
|
-
${i ? `<dt>RS Code</dt><dd>${i}</dd>` : ""}
|
|
818
|
-
${a ? `<dt>Message</dt><dd class="message">${a}</dd>` : ""}
|
|
819
|
-
</dl>
|
|
820
|
-
` : ""}
|
|
821
|
-
</div>
|
|
822
|
-
</div>
|
|
823
|
-
</body>
|
|
824
|
-
</html>`;
|
|
825
|
-
}
|
|
826
537
|
async _findInnerContainer(t) {
|
|
827
538
|
const { contentWindow: e } = t;
|
|
828
539
|
if (!e)
|
|
@@ -834,30 +545,32 @@ class ge {
|
|
|
834
545
|
}
|
|
835
546
|
let s = null;
|
|
836
547
|
for (let r = 0; r < 5 && (s = i(), !s); r++)
|
|
837
|
-
await
|
|
548
|
+
await Pe(100);
|
|
838
549
|
return s || n.body;
|
|
839
550
|
}
|
|
840
551
|
/**
|
|
841
552
|
* Returns HTML for an in-iframe skeleton preload overlay that is removed
|
|
842
|
-
* once all
|
|
553
|
+
* once all custom elements in the widget are defined.
|
|
843
554
|
*
|
|
844
|
-
* Uses
|
|
845
|
-
*
|
|
846
|
-
*
|
|
555
|
+
* Uses `customElements.whenDefined()` to wait for all custom element tags,
|
|
556
|
+
* then removes the skeleton after two animation frames. Includes a 10s
|
|
557
|
+
* timeout fallback.
|
|
847
558
|
*
|
|
848
559
|
* Only generates content for mint-components widgets; returns empty string otherwise.
|
|
849
560
|
*/
|
|
850
|
-
_getSkeletonPreloadHTML(t, e) {
|
|
561
|
+
async _getSkeletonPreloadHTML(t, e) {
|
|
851
562
|
if (!t) return "";
|
|
852
|
-
const n = this.context.type === "passwordless" ? "instant-access" : "verified-access",
|
|
853
|
-
type:
|
|
854
|
-
|
|
855
|
-
|
|
563
|
+
const { getSkeleton: n } = await import("./SkeletonTemplate-Day_0iMM.js"), i = this.context.type === "passwordless" ? "instant-access" : "verified-access", s = n({
|
|
564
|
+
type: i
|
|
565
|
+
}), r = /* @__PURE__ */ new Set(), a = /<([a-z][\w]*-[\w-]*)/gi;
|
|
566
|
+
let c;
|
|
567
|
+
for (; c = a.exec(this.content); ) r.add(c[1].toLowerCase());
|
|
568
|
+
const d = JSON.stringify([...r]);
|
|
856
569
|
return `
|
|
857
|
-
<div id="sq-preload" style="visibility: visible; position: absolute; top: 0; left: 0; width: 100%; z-index: 9999; background: ${e || "white"};">
|
|
858
|
-
${
|
|
570
|
+
<div id="sq-preload" style="visibility: visible; position: absolute; top: 0; left: 0; width: 100%; z-index: 9999; background: ${(e || "white").replace(/[^a-zA-Z0-9#(),.\s%-]/g, "")};">
|
|
571
|
+
${s}
|
|
859
572
|
</div>
|
|
860
|
-
<script>(${
|
|
573
|
+
<script>(${Le.toString()})(${d})<\/script>
|
|
861
574
|
`;
|
|
862
575
|
}
|
|
863
576
|
/**
|
|
@@ -872,24 +585,24 @@ class ge {
|
|
|
872
585
|
const r = s.contentWindow, a = this.context.engagementMedium || "POPUP";
|
|
873
586
|
if (!r)
|
|
874
587
|
throw new Error("Frame needs a content window");
|
|
875
|
-
let
|
|
588
|
+
let c;
|
|
876
589
|
if (this.context.type === "upsert") {
|
|
877
590
|
if (!this.context.user) throw new Error("Can't reload without user ids");
|
|
878
|
-
let
|
|
591
|
+
let d = {
|
|
879
592
|
email: t || null,
|
|
880
593
|
firstName: e || null,
|
|
881
594
|
lastName: n || null,
|
|
882
595
|
id: this.context.user.id,
|
|
883
596
|
accountId: this.context.user.accountId
|
|
884
597
|
};
|
|
885
|
-
|
|
886
|
-
user:
|
|
598
|
+
c = this.widgetApi.upsertUser({
|
|
599
|
+
user: d,
|
|
887
600
|
engagementMedium: a,
|
|
888
601
|
widgetType: this.type,
|
|
889
602
|
jwt: i
|
|
890
603
|
});
|
|
891
604
|
} else if (this.context.type === "passwordless")
|
|
892
|
-
|
|
605
|
+
c = this.widgetApi.render({
|
|
893
606
|
user: void 0,
|
|
894
607
|
engagementMedium: a,
|
|
895
608
|
widgetType: this.type,
|
|
@@ -897,57 +610,54 @@ class ge {
|
|
|
897
610
|
});
|
|
898
611
|
else
|
|
899
612
|
throw new Error("can't reload an error widget");
|
|
900
|
-
|
|
901
|
-
|
|
613
|
+
c.then(({ template: d }) => {
|
|
614
|
+
d && (this.content = d, this.__deprecated__register(
|
|
902
615
|
s,
|
|
903
616
|
{ email: t, engagementMedium: a },
|
|
904
617
|
() => {
|
|
905
618
|
this.load(), a === "POPUP" && this.open();
|
|
906
619
|
}
|
|
907
620
|
));
|
|
908
|
-
}).catch(({ message:
|
|
909
|
-
y(`${
|
|
621
|
+
}).catch(({ message: d }) => {
|
|
622
|
+
y(`${d}`);
|
|
910
623
|
});
|
|
911
624
|
}
|
|
912
625
|
__deprecated__register(t, e, n) {
|
|
913
626
|
const s = t.contentWindow.document, r = s.createElement("button"), a = s.getElementsByClassName("squatch-register")[0];
|
|
914
627
|
if (a) {
|
|
915
628
|
r.className = "btn btn-primary", r.id = "show-stats-btn", r.textContent = this.type === "REFERRER_WIDGET" ? "Show Stats" : "Show Reward";
|
|
916
|
-
const
|
|
917
|
-
r.setAttribute("style",
|
|
629
|
+
const c = e.engagementMedium === "POPUP" ? "margin-top: 10px; max-width: 130px; width: 100%;" : "margin-top: 10px;";
|
|
630
|
+
r.setAttribute("style", c), r.onclick = n, a.style.paddingTop = "30px", a.innerHTML = `<p><strong>${e.email}</strong><br>Has been successfully registered</p>`, a.appendChild(r);
|
|
918
631
|
}
|
|
919
632
|
}
|
|
920
633
|
}
|
|
921
|
-
function
|
|
634
|
+
function Pe(o) {
|
|
922
635
|
return new Promise((t) => {
|
|
923
636
|
setTimeout(t, o);
|
|
924
637
|
});
|
|
925
638
|
}
|
|
926
|
-
function
|
|
927
|
-
var
|
|
928
|
-
function t() {
|
|
929
|
-
var n = document.getElementById("sq-preload");
|
|
930
|
-
n && n.remove(), clearTimeout(o);
|
|
931
|
-
}
|
|
639
|
+
function Le(o) {
|
|
640
|
+
var t = setTimeout(e, 1e4);
|
|
932
641
|
function e() {
|
|
933
|
-
var
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
642
|
+
var i = document.getElementById("sq-preload");
|
|
643
|
+
i && i.remove(), clearTimeout(t);
|
|
644
|
+
}
|
|
645
|
+
function n() {
|
|
646
|
+
if (!o || !o.length) return e();
|
|
937
647
|
Promise.all(
|
|
938
|
-
|
|
648
|
+
o.map(function(i) {
|
|
939
649
|
return customElements.whenDefined(i);
|
|
940
650
|
})
|
|
941
651
|
).then(function() {
|
|
942
652
|
requestAnimationFrame(function() {
|
|
943
|
-
requestAnimationFrame(
|
|
653
|
+
requestAnimationFrame(e);
|
|
944
654
|
});
|
|
945
655
|
});
|
|
946
656
|
}
|
|
947
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
657
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", n) : setTimeout(n, 0);
|
|
948
658
|
}
|
|
949
|
-
const
|
|
950
|
-
class
|
|
659
|
+
const I = C("squatch-js:EMBEDwidget");
|
|
660
|
+
class D extends me {
|
|
951
661
|
constructor(e, n) {
|
|
952
662
|
super(e);
|
|
953
663
|
l(this, "show", this.open);
|
|
@@ -955,26 +665,31 @@ class O extends ge {
|
|
|
955
665
|
n && (this.container = n);
|
|
956
666
|
}
|
|
957
667
|
async load() {
|
|
958
|
-
var g,
|
|
959
|
-
const e = (
|
|
668
|
+
var g, f, b, w, T, ee, te, ne, ie;
|
|
669
|
+
const e = (f = (g = this.context.widgetConfig) == null ? void 0 : g.values) == null ? void 0 : f.brandingConfig, n = (b = this.content) == null ? void 0 : b.includes("mint-components"), i = (e == null ? void 0 : e.loadingHeight) || 500, s = (w = e == null ? void 0 : e.widgetSize) == null ? void 0 : w.embeddedWidgets, r = s != null && s.maxWidth ? O(s.maxWidth) : "", a = s != null && s.minWidth ? O(s.minWidth) : "", c = this._createFrame({
|
|
960
670
|
minWidth: a,
|
|
961
671
|
maxWidth: r,
|
|
962
672
|
initialHeight: i
|
|
963
|
-
}),
|
|
964
|
-
(
|
|
965
|
-
const { contentWindow: h } =
|
|
673
|
+
}), d = this._findElement();
|
|
674
|
+
(T = this.context) != null && T.container && (d.style.visibility = "hidden", d.style.height = "0", d.style["overflow-y"] = "hidden"), this.container ? d.shadowRoot ? ((ee = d.shadowRoot.lastChild) == null ? void 0 : ee.nodeName) === "IFRAME" ? d.shadowRoot.replaceChild(c, d.shadowRoot.lastChild) : d.shadowRoot.appendChild(c) : d.firstChild ? d.replaceChild(c, d.firstChild) : d.appendChild(c) : (!d.firstChild || d.firstChild.nodeName === "#text") && d.appendChild(c);
|
|
675
|
+
const { contentWindow: h } = c;
|
|
966
676
|
if (!h)
|
|
967
677
|
throw new Error("Frame needs a content window");
|
|
968
678
|
const u = h.document;
|
|
969
|
-
u.open()
|
|
970
|
-
|
|
679
|
+
if (u.open(), this.content === "error") {
|
|
680
|
+
u.write(await this._getContent()), u.close(), x(u, () => {
|
|
681
|
+
c.height = u.body.scrollHeight;
|
|
682
|
+
});
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
const p = this.widgetApi.domain === "https://staging.referralsaasquatch.com" ? "-staging" : "";
|
|
971
686
|
u.write(`
|
|
972
|
-
${(
|
|
973
|
-
<link rel="preconnect" href="https://fast${
|
|
974
|
-
<link rel="preconnect" href="https://fonts.gstatic.com">
|
|
975
|
-
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
687
|
+
${(te = e == null ? void 0 : e.main) != null && te.brandFont ? `
|
|
688
|
+
<link rel="preconnect" href="https://fast${p}.ssqt.io">
|
|
689
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
690
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" crossorigin>
|
|
976
691
|
<link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
|
|
977
|
-
(
|
|
692
|
+
(ne = e == null ? void 0 : e.main) == null ? void 0 : ne.brandFont
|
|
978
693
|
)}" as="style">` : ""}
|
|
979
694
|
<link rel="dns-prefetch" href="https://res.cloudinary.com">
|
|
980
695
|
<link rel="preconnect" href="https://res.cloudinary.com" crossorigin>
|
|
@@ -982,19 +697,18 @@ class O extends ge {
|
|
|
982
697
|
<style data-styles>
|
|
983
698
|
html { visibility: hidden; }
|
|
984
699
|
</style>` : ""}
|
|
985
|
-
${this._getSkeletonPreloadHTML(n, (
|
|
986
|
-
${this.
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
d.height = xe;
|
|
700
|
+
${await this._getSkeletonPreloadHTML(n, (ie = e == null ? void 0 : e.color) == null ? void 0 : ie.backgroundColor)}
|
|
701
|
+
${await this._getContent()}
|
|
702
|
+
`), u.close(), x(u, async () => {
|
|
703
|
+
const oe = h.squatch || h.widgetIdent;
|
|
704
|
+
c.height = i;
|
|
705
|
+
const fe = new h.ResizeObserver((Ee) => {
|
|
706
|
+
for (const Ce of Ee) {
|
|
707
|
+
const { height: be } = Ce.contentRect;
|
|
708
|
+
c.height = be;
|
|
995
709
|
}
|
|
996
|
-
}),
|
|
997
|
-
|
|
710
|
+
}), ye = await this._findInnerContainer(c);
|
|
711
|
+
fe.observe(ye), this._shouldFireLoadEvent() ? (this._loadEvent(oe), I("loaded")) : u && this._attachLoadEventListener(u, oe);
|
|
998
712
|
});
|
|
999
713
|
}
|
|
1000
714
|
/**
|
|
@@ -1002,13 +716,13 @@ class O extends ge {
|
|
|
1002
716
|
*/
|
|
1003
717
|
open() {
|
|
1004
718
|
const e = this._findFrame();
|
|
1005
|
-
if (!e) return
|
|
1006
|
-
if (!e.contentWindow) return
|
|
719
|
+
if (!e) return I("no target element to open");
|
|
720
|
+
if (!e.contentWindow) return I("Frame needs a content window");
|
|
1007
721
|
const n = this._findElement();
|
|
1008
722
|
n.style.visibility = "unset", n.style.height = "auto", n.style["overflow-y"] = "auto", e.contentWindow.document.dispatchEvent(new CustomEvent("sq:refresh"));
|
|
1009
723
|
const i = e.contentWindow.squatch || e.contentWindow.widgetIdent;
|
|
1010
724
|
if (this.context.user)
|
|
1011
|
-
this._loadEvent(i),
|
|
725
|
+
this._loadEvent(i), I("loaded");
|
|
1012
726
|
else {
|
|
1013
727
|
if (!e.contentDocument) return;
|
|
1014
728
|
this._attachLoadEventListener(e.contentDocument, i);
|
|
@@ -1016,29 +730,29 @@ class O extends ge {
|
|
|
1016
730
|
}
|
|
1017
731
|
close() {
|
|
1018
732
|
const e = this._findFrame();
|
|
1019
|
-
if (!e) return
|
|
733
|
+
if (!e) return I("no target element to close");
|
|
1020
734
|
e.contentDocument && this._detachLoadEventListener(e.contentDocument);
|
|
1021
735
|
const n = this._findElement();
|
|
1022
|
-
n.style.visibility = "hidden", n.style.height = "0", n.style["overflow-y"] = "hidden",
|
|
736
|
+
n.style.visibility = "hidden", n.style.height = "0", n.style["overflow-y"] = "hidden", I("Embed widget closed");
|
|
1023
737
|
}
|
|
1024
|
-
|
|
1025
|
-
return
|
|
738
|
+
_getErrorMode() {
|
|
739
|
+
return "embed";
|
|
1026
740
|
}
|
|
1027
741
|
_shouldFireLoadEvent() {
|
|
1028
742
|
const e = !this.container, n = this.container instanceof HTMLElement && (this.container.tagName.startsWith("SQUATCH-") || this.container.tagName.startsWith("IMPACT-"));
|
|
1029
743
|
return !!this.context.user && (e || n);
|
|
1030
744
|
}
|
|
1031
745
|
}
|
|
1032
|
-
const
|
|
1033
|
-
let
|
|
1034
|
-
class
|
|
746
|
+
const v = C("squatch-js:POPUPwidget");
|
|
747
|
+
let U = 0;
|
|
748
|
+
class j extends me {
|
|
1035
749
|
constructor(e, n = ".squatchpop") {
|
|
1036
750
|
super(e);
|
|
1037
751
|
l(this, "trigger");
|
|
1038
752
|
l(this, "id");
|
|
1039
753
|
l(this, "show", this.open);
|
|
1040
754
|
l(this, "hide", this.close);
|
|
1041
|
-
this.trigger = n, this.container ? this.id = "squatchModal" : (this.id =
|
|
755
|
+
this.trigger = n, this.container ? this.id = "squatchModal" : (this.id = U === 0 ? "squatchModal" : `squatchModal__${U}`, U = U + 1), document.head.insertAdjacentHTML(
|
|
1042
756
|
"beforeend",
|
|
1043
757
|
`<style>#${this.id}::-webkit-scrollbar { display: none; }</style>`
|
|
1044
758
|
);
|
|
@@ -1047,45 +761,50 @@ class D extends ge {
|
|
|
1047
761
|
if (!this.trigger) return;
|
|
1048
762
|
let e;
|
|
1049
763
|
try {
|
|
1050
|
-
e = document.querySelector(this.trigger) || document.querySelector(".impactpop"), this.trigger && !e &&
|
|
764
|
+
e = document.querySelector(this.trigger) || document.querySelector(".impactpop"), this.trigger && !e && v("No element found with trigger selector", this.trigger);
|
|
1051
765
|
} catch {
|
|
1052
|
-
|
|
766
|
+
v("Not a valid selector", this.trigger);
|
|
1053
767
|
}
|
|
1054
768
|
e && (e.onclick = () => {
|
|
1055
769
|
this.open();
|
|
1056
770
|
});
|
|
1057
771
|
}
|
|
1058
772
|
_createPopupDialog(e) {
|
|
1059
|
-
var
|
|
1060
|
-
const n = document.createElement("dialog"), i = (
|
|
773
|
+
var c;
|
|
774
|
+
const n = document.createElement("dialog"), i = (c = e == null ? void 0 : e.widgetSize) == null ? void 0 : c.popupWidgets, s = i != null && i.minWidth ? O(i.minWidth) : "auto", r = i != null && i.maxWidth ? O(i.maxWidth) : "500px";
|
|
1061
775
|
n.id = this.id, n.setAttribute(
|
|
1062
776
|
"style",
|
|
1063
777
|
`width: 100%; min-width: ${s}; max-width: ${r}; border: none; padding: 0;`
|
|
1064
778
|
);
|
|
1065
|
-
const a = (
|
|
1066
|
-
|
|
779
|
+
const a = (d) => {
|
|
780
|
+
d.stopPropagation(), d.target === n && n.close();
|
|
1067
781
|
};
|
|
1068
782
|
return n.addEventListener("click", a), n;
|
|
1069
783
|
}
|
|
1070
784
|
async load() {
|
|
1071
|
-
var
|
|
1072
|
-
const e = (
|
|
785
|
+
var m, p, g, f, b, w, T;
|
|
786
|
+
const e = (p = (m = this.context.widgetConfig) == null ? void 0 : m.values) == null ? void 0 : p.brandingConfig, n = (e == null ? void 0 : e.loadingHeight) || 500, i = (g = this.content) == null ? void 0 : g.includes("mint-components"), s = this._createFrame();
|
|
1073
787
|
s.style.height = n + "px", this._initialiseCTA();
|
|
1074
|
-
const r = this.container ? this._findElement() : document.body, a = (r == null ? void 0 : r.shadowRoot) || r,
|
|
1075
|
-
|
|
1076
|
-
const { contentWindow:
|
|
1077
|
-
if (!
|
|
788
|
+
const r = this.container ? this._findElement() : document.body, a = (r == null ? void 0 : r.shadowRoot) || r, c = this._createPopupDialog(e);
|
|
789
|
+
c.appendChild(s), ((f = a.lastChild) == null ? void 0 : f.nodeName) === "DIALOG" ? a.replaceChild(c, a.lastChild) : a.appendChild(c);
|
|
790
|
+
const { contentWindow: d } = s;
|
|
791
|
+
if (!d)
|
|
1078
792
|
throw new Error("Frame needs a content window");
|
|
1079
|
-
const h =
|
|
1080
|
-
h.open()
|
|
793
|
+
const h = d.document;
|
|
794
|
+
if (h.open(), this.content === "error") {
|
|
795
|
+
h.write(await this._getContent()), h.close(), x(h, () => {
|
|
796
|
+
s.height = h.body.scrollHeight;
|
|
797
|
+
}), v("Popup error template loaded into iframe");
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
1081
800
|
const u = this.widgetApi.domain;
|
|
1082
801
|
h.write(`
|
|
1083
802
|
${(b = e == null ? void 0 : e.main) != null && b.brandFont ? `
|
|
1084
803
|
<link rel="preconnect" href="https://fast${u === "https://staging.referralsaasquatch.com" ? "-staging" : ""}.ssqt.io">
|
|
1085
|
-
<link rel="preconnect" href="https://fonts.gstatic.com">
|
|
804
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
1086
805
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
1087
806
|
<link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
|
|
1088
|
-
(
|
|
807
|
+
(w = e == null ? void 0 : e.main) == null ? void 0 : w.brandFont
|
|
1089
808
|
)}" as="style">` : ""}
|
|
1090
809
|
<link rel="dns-prefetch" href="https://res.cloudinary.com">
|
|
1091
810
|
<link rel="preconnect" href="https://res.cloudinary.com" crossorigin>
|
|
@@ -1093,23 +812,22 @@ class D extends ge {
|
|
|
1093
812
|
<style data-styles>
|
|
1094
813
|
html { visibility: hidden; }
|
|
1095
814
|
</style>` : ""}
|
|
1096
|
-
${this._getSkeletonPreloadHTML(i, (
|
|
1097
|
-
${this.
|
|
1098
|
-
|
|
1099
|
-
`), h.close(), T("Popup template loaded into iframe"), await this._setupResizeHandler(s);
|
|
815
|
+
${await this._getSkeletonPreloadHTML(i, (T = e == null ? void 0 : e.color) == null ? void 0 : T.backgroundColor)}
|
|
816
|
+
${await this._getContent()}
|
|
817
|
+
`), h.close(), v("Popup template loaded into iframe"), await this._setupResizeHandler(s);
|
|
1100
818
|
}
|
|
1101
819
|
async _setupResizeHandler(e) {
|
|
1102
820
|
const { contentWindow: n } = e;
|
|
1103
821
|
if (!n)
|
|
1104
822
|
throw new Error("Frame needs a content window");
|
|
1105
823
|
const i = n.document;
|
|
1106
|
-
|
|
824
|
+
x(i, async () => {
|
|
1107
825
|
i.body.style.overflowY = "hidden";
|
|
1108
826
|
let s = !0;
|
|
1109
827
|
new n.ResizeObserver((a) => {
|
|
1110
|
-
for (const
|
|
1111
|
-
const { top:
|
|
1112
|
-
u <= 0 || (s ? (s = !1, e.style.height = "0", e.height = i.body.scrollHeight + "", e.style.height = "") : e.height = u + "",
|
|
828
|
+
for (const c of a) {
|
|
829
|
+
const { top: d, bottom: h } = c.contentRect, u = h + d;
|
|
830
|
+
u <= 0 || (s ? (s = !1, e.style.height = "0", e.height = i.body.scrollHeight + "", e.style.height = "") : e.height = u + "", c.target.style = "");
|
|
1113
831
|
}
|
|
1114
832
|
}).observe(await this._findInnerContainer(e));
|
|
1115
833
|
});
|
|
@@ -1123,10 +841,10 @@ class D extends ge {
|
|
|
1123
841
|
const { contentWindow: r } = s;
|
|
1124
842
|
if (!r) throw new Error("Squatch.js has an empty iframe");
|
|
1125
843
|
const a = r.document;
|
|
1126
|
-
|
|
1127
|
-
var
|
|
1128
|
-
const
|
|
1129
|
-
(
|
|
844
|
+
x(a, () => {
|
|
845
|
+
var d;
|
|
846
|
+
const c = r.squatch || r.widgetIdent;
|
|
847
|
+
(d = s.contentDocument) == null || d.dispatchEvent(new CustomEvent("sq:refresh")), this.context.user ? (this._loadEvent(c), v("Popup opened")) : this._attachLoadEventListener(a, c);
|
|
1130
848
|
});
|
|
1131
849
|
}
|
|
1132
850
|
close() {
|
|
@@ -1134,16 +852,14 @@ class D extends ge {
|
|
|
1134
852
|
e != null && e.contentDocument && this._detachLoadEventListener(e.contentDocument);
|
|
1135
853
|
const n = this.container ? this._findElement() : document.body, s = (n.shadowRoot || n).querySelector(`#${this.id}`);
|
|
1136
854
|
if (!s) throw new Error("Could not determine container div");
|
|
1137
|
-
s.close(),
|
|
1138
|
-
}
|
|
1139
|
-
_clickedOutside({ target: e }) {
|
|
855
|
+
s.close(), v("Popup closed");
|
|
1140
856
|
}
|
|
1141
|
-
|
|
1142
|
-
return
|
|
857
|
+
_getErrorStyle() {
|
|
858
|
+
return "body { margin: 0; } .modal { box-shadow: none; border: 0; }";
|
|
1143
859
|
}
|
|
1144
860
|
}
|
|
1145
|
-
const
|
|
1146
|
-
class
|
|
861
|
+
const E = C("squatch-js:widgets");
|
|
862
|
+
class N {
|
|
1147
863
|
/**
|
|
1148
864
|
* Initialize a new {@link Widgets} instance.
|
|
1149
865
|
*
|
|
@@ -1179,7 +895,7 @@ class j {
|
|
|
1179
895
|
* @default "https://fast.ssqt.io/npm"
|
|
1180
896
|
*/
|
|
1181
897
|
l(this, "npmCdn");
|
|
1182
|
-
const e =
|
|
898
|
+
const e = q(t);
|
|
1183
899
|
this.tenantAlias = e.tenantAlias, this.domain = e.domain, this.npmCdn = e.npmCdn, this.api = new Z(e);
|
|
1184
900
|
}
|
|
1185
901
|
/**
|
|
@@ -1199,7 +915,7 @@ class j {
|
|
|
1199
915
|
* @return {Promise<WidgetResult>} json object if true, with a Widget and user details
|
|
1200
916
|
*/
|
|
1201
917
|
async upsertUser(t) {
|
|
1202
|
-
const n =
|
|
918
|
+
const n = de(t);
|
|
1203
919
|
try {
|
|
1204
920
|
const i = await this.api.upsertUser(n);
|
|
1205
921
|
return {
|
|
@@ -1218,13 +934,7 @@ class j {
|
|
|
1218
934
|
user: i.user
|
|
1219
935
|
};
|
|
1220
936
|
} catch (i) {
|
|
1221
|
-
throw
|
|
1222
|
-
"[DEBUG] Widgets.upsertUser catch - err.apiErrorCode:",
|
|
1223
|
-
i.apiErrorCode
|
|
1224
|
-
), console.log(
|
|
1225
|
-
"[DEBUG] Widgets.upsertUser catch - err keys:",
|
|
1226
|
-
Object.keys(i || {})
|
|
1227
|
-
), v(i), i.apiErrorCode && (console.log("[DEBUG] Widgets.upsertUser - calling _renderErrorWidget"), this._renderErrorWidget(i, t.engagementMedium)), new Error(i);
|
|
937
|
+
throw E(i), i.apiErrorCode && this._renderErrorWidget(i, t.engagementMedium), new Error(i);
|
|
1228
938
|
}
|
|
1229
939
|
}
|
|
1230
940
|
/**
|
|
@@ -1243,7 +953,7 @@ class j {
|
|
|
1243
953
|
* @return {Promise<WidgetResult>} json object if true, with a Widget and user details
|
|
1244
954
|
*/
|
|
1245
955
|
async render(t) {
|
|
1246
|
-
const n =
|
|
956
|
+
const n = le(t);
|
|
1247
957
|
try {
|
|
1248
958
|
const i = await this.api.render(n);
|
|
1249
959
|
return {
|
|
@@ -1274,7 +984,7 @@ class j {
|
|
|
1274
984
|
const s = await this.api.squatchReferralCookie();
|
|
1275
985
|
e(s);
|
|
1276
986
|
} catch (s) {
|
|
1277
|
-
throw
|
|
987
|
+
throw E("Autofill error", s), new Error(s);
|
|
1278
988
|
}
|
|
1279
989
|
return;
|
|
1280
990
|
}
|
|
@@ -1284,7 +994,7 @@ class j {
|
|
|
1284
994
|
if (n.length > 0)
|
|
1285
995
|
i = n[0];
|
|
1286
996
|
else
|
|
1287
|
-
throw
|
|
997
|
+
throw E("Element id/class or function missing"), new Error("Element id/class or function missing");
|
|
1288
998
|
try {
|
|
1289
999
|
const s = await this.api.squatchReferralCookie();
|
|
1290
1000
|
i.value = s.codes[0];
|
|
@@ -1301,27 +1011,27 @@ class j {
|
|
|
1301
1011
|
* @returns {Widget} widget (PopupWidget or EmbedWidget)
|
|
1302
1012
|
*/
|
|
1303
1013
|
_renderWidget(t, e, n) {
|
|
1304
|
-
var
|
|
1305
|
-
if (
|
|
1014
|
+
var c;
|
|
1015
|
+
if (E("Rendering Widget..."), !t) throw new Error("Unable to get a response");
|
|
1306
1016
|
let i, s = !!e.displayOnLoad;
|
|
1307
1017
|
const r = t.jsOptions || {}, a = {
|
|
1308
1018
|
content: t.template,
|
|
1309
|
-
type: e.widgetType || ((
|
|
1019
|
+
type: e.widgetType || ((c = r.widget) == null ? void 0 : c.defaultWidgetType),
|
|
1310
1020
|
api: this.api,
|
|
1311
1021
|
domain: this.domain,
|
|
1312
1022
|
npmCdn: this.npmCdn,
|
|
1313
1023
|
context: n
|
|
1314
1024
|
};
|
|
1315
|
-
return r.widgetUrlMappings && r.widgetUrlMappings.forEach((
|
|
1025
|
+
return r.widgetUrlMappings && r.widgetUrlMappings.forEach((d) => {
|
|
1316
1026
|
var h, u;
|
|
1317
|
-
|
|
1318
|
-
`Don't display ${
|
|
1027
|
+
N._matchesUrl(d.url) && (d.widgetType !== "CONVERSION_WIDGET" || (u = (h = t.user) == null ? void 0 : h.referredBy) != null && u.code ? (s = d.displayOnLoad, E(`Display ${d.widgetType} on ${d.url}`)) : E(
|
|
1028
|
+
`Don't display ${d.widgetType} when no referral on widget rule match ${d.url}`
|
|
1319
1029
|
));
|
|
1320
|
-
}), r.fuelTankAutofillUrls && (
|
|
1321
|
-
var u,
|
|
1322
|
-
if (
|
|
1030
|
+
}), r.fuelTankAutofillUrls && (E("We found a fuel tank autofill!"), r.fuelTankAutofillUrls.forEach(({ url: d, formSelector: h }) => {
|
|
1031
|
+
var u, m, p;
|
|
1032
|
+
if (N._matchesUrl(d) && (E("Fuel Tank URL matches"), (m = (u = t.user) == null ? void 0 : u.referredBy) != null && m.code)) {
|
|
1323
1033
|
const g = document.querySelector(h);
|
|
1324
|
-
g ? g.value = ((
|
|
1034
|
+
g ? g.value = ((p = t.user.referredBy.referredReward) == null ? void 0 : p.fuelTankCode) || "" : E(
|
|
1325
1035
|
new Error(
|
|
1326
1036
|
`Element with id/class ${h} was not found.`
|
|
1327
1037
|
)
|
|
@@ -1330,11 +1040,11 @@ class j {
|
|
|
1330
1040
|
})), e.engagementMedium === "EMBED" ? i = this._renderEmbedWidget(a) : (i = this._renderPopupWidget(a), s && i.open()), i;
|
|
1331
1041
|
}
|
|
1332
1042
|
_renderPopupWidget(t) {
|
|
1333
|
-
const e = new
|
|
1043
|
+
const e = new j(t, t.context.trigger);
|
|
1334
1044
|
return e.load(), e;
|
|
1335
1045
|
}
|
|
1336
1046
|
_renderEmbedWidget(t) {
|
|
1337
|
-
const e = new
|
|
1047
|
+
const e = new D(t, t.context.container);
|
|
1338
1048
|
return e.load(), e;
|
|
1339
1049
|
}
|
|
1340
1050
|
/**
|
|
@@ -1345,7 +1055,7 @@ class j {
|
|
|
1345
1055
|
*/
|
|
1346
1056
|
_renderErrorWidget(t, e = "POPUP") {
|
|
1347
1057
|
const { apiErrorCode: n, rsCode: i, statusCode: s, message: r } = t;
|
|
1348
|
-
|
|
1058
|
+
E(new Error(`${n} (${i}) ${r}`));
|
|
1349
1059
|
const a = {
|
|
1350
1060
|
content: "error",
|
|
1351
1061
|
rsCode: i,
|
|
@@ -1358,8 +1068,8 @@ class j {
|
|
|
1358
1068
|
type: "ERROR_WIDGET",
|
|
1359
1069
|
context: { type: "error" }
|
|
1360
1070
|
};
|
|
1361
|
-
let
|
|
1362
|
-
e === "EMBED" ? (
|
|
1071
|
+
let c;
|
|
1072
|
+
e === "EMBED" ? (c = new D(a), c.load()) : e === "POPUP" && (c = new j(a), c.load());
|
|
1363
1073
|
}
|
|
1364
1074
|
/**
|
|
1365
1075
|
* @hidden
|
|
@@ -1370,7 +1080,7 @@ class j {
|
|
|
1370
1080
|
return !!window.location.href.match(new RegExp(t));
|
|
1371
1081
|
}
|
|
1372
1082
|
}
|
|
1373
|
-
class
|
|
1083
|
+
class Oe {
|
|
1374
1084
|
/**
|
|
1375
1085
|
* Initialize a new {@link EventsApi} instance.
|
|
1376
1086
|
*
|
|
@@ -1390,7 +1100,7 @@ class De {
|
|
|
1390
1100
|
constructor(t) {
|
|
1391
1101
|
l(this, "tenantAlias");
|
|
1392
1102
|
l(this, "domain");
|
|
1393
|
-
const n =
|
|
1103
|
+
const n = q(t);
|
|
1394
1104
|
this.tenantAlias = n.tenantAlias, this.domain = n.domain;
|
|
1395
1105
|
}
|
|
1396
1106
|
/**
|
|
@@ -1402,12 +1112,12 @@ class De {
|
|
|
1402
1112
|
* @return An ID to confirm the event has been accepted for asynchronous processing
|
|
1403
1113
|
*/
|
|
1404
1114
|
track(t, e) {
|
|
1405
|
-
const n = t, i = e, s =
|
|
1115
|
+
const n = t, i = e, s = De(n), { jwt: r } = je(i), a = encodeURIComponent(this.tenantAlias), c = encodeURIComponent(s.userId), d = encodeURIComponent(s.accountId), h = `/api/v1/${a}/open/account/${d}/user/${c}/events`, u = this.domain + h;
|
|
1406
1116
|
return Q(u, JSON.stringify(s), r);
|
|
1407
1117
|
}
|
|
1408
1118
|
}
|
|
1409
|
-
function
|
|
1410
|
-
if (!
|
|
1119
|
+
function De(o) {
|
|
1120
|
+
if (!S(o)) throw new Error("tracking parameter must be an object");
|
|
1411
1121
|
if (!(o != null && o.accountId)) throw new Error("accountId field is required");
|
|
1412
1122
|
if (!(o != null && o.events)) throw new Error("events field is required");
|
|
1413
1123
|
if (!(o != null && o.userId)) throw new Error("userId field is required");
|
|
@@ -1416,113 +1126,51 @@ function je(o) {
|
|
|
1416
1126
|
throw new Error("'events' should be an array");
|
|
1417
1127
|
return t;
|
|
1418
1128
|
}
|
|
1419
|
-
function
|
|
1420
|
-
if (!
|
|
1129
|
+
function je(o) {
|
|
1130
|
+
if (!S(o)) throw new Error("'options' should be an object");
|
|
1421
1131
|
return o;
|
|
1422
1132
|
}
|
|
1423
|
-
function
|
|
1133
|
+
function Ne() {
|
|
1424
1134
|
var i;
|
|
1425
|
-
const o = window[z] ? z :
|
|
1135
|
+
const o = window[z] ? z : M, t = ((i = window["_" + o]) == null ? void 0 : i.ready) || [], e = window.impactOnReady || window.squatchOnReady, n = [...t, e].filter((s) => !!s);
|
|
1426
1136
|
setTimeout(() => {
|
|
1427
|
-
window[
|
|
1137
|
+
window[M] && (window[z] = window[M], n.forEach((s) => s()), window[M]._auto(), window["_" + o] = void 0, delete window["_" + o]);
|
|
1428
1138
|
}, 0);
|
|
1429
1139
|
}
|
|
1430
|
-
const
|
|
1431
|
-
|
|
1432
|
-
[i]: e(i) ? me(o[i], t[i]) : t[i]
|
|
1433
|
-
})).reduce((i, s) => ({ ...i, ...s }), {});
|
|
1434
|
-
return {
|
|
1435
|
-
...o,
|
|
1436
|
-
...n
|
|
1437
|
-
};
|
|
1438
|
-
};
|
|
1439
|
-
function N(o) {
|
|
1440
|
-
const t = atob(o.replace(/_/g, "/").replace(/-/g, "+")), e = new Uint8Array(t.length);
|
|
1441
|
-
for (let n = 0; n < t.length; n++)
|
|
1442
|
-
e[n] = t.charCodeAt(n);
|
|
1443
|
-
return new TextDecoder("utf8").decode(e);
|
|
1444
|
-
}
|
|
1445
|
-
function ae(o) {
|
|
1446
|
-
const t = new TextEncoder().encode(o), e = Array.from(
|
|
1447
|
-
t,
|
|
1448
|
-
(n) => String.fromCodePoint(n)
|
|
1449
|
-
).join("");
|
|
1450
|
-
return btoa(e).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
1451
|
-
}
|
|
1452
|
-
function Be() {
|
|
1453
|
-
var o, t, e = "weird_get_top_level_domain=cookie", n = document.location.hostname.split(".");
|
|
1454
|
-
for (o = n.length - 1; o >= 0; o--)
|
|
1455
|
-
if (t = n.slice(o).join("."), document.cookie = e + ";domain=." + t + ";", document.cookie.indexOf(e) > -1)
|
|
1456
|
-
return document.cookie = e.split("=")[0] + "=;domain=." + t + ";expires=Thu, 01 Jan 1970 00:00:01 GMT;", t;
|
|
1457
|
-
}
|
|
1458
|
-
function He() {
|
|
1459
|
-
const o = window.location.search, e = new URLSearchParams(o).get("_saasquatch") || "";
|
|
1460
|
-
if (e) {
|
|
1461
|
-
let n = "", i = "", s = "";
|
|
1462
|
-
try {
|
|
1463
|
-
n = JSON.parse(N(e));
|
|
1464
|
-
} catch (r) {
|
|
1465
|
-
E("Unable to decode params", r);
|
|
1466
|
-
return;
|
|
1467
|
-
}
|
|
1468
|
-
try {
|
|
1469
|
-
i = JSON.parse(N(P.get("_saasquatch"))), E("existing cookie", i);
|
|
1470
|
-
} catch (r) {
|
|
1471
|
-
E("Unable to retrieve cookie", r);
|
|
1472
|
-
}
|
|
1473
|
-
try {
|
|
1474
|
-
const r = Be();
|
|
1475
|
-
if (E("domain retrieved:", r), i) {
|
|
1476
|
-
const a = me(i, n);
|
|
1477
|
-
s = ae(JSON.stringify(a)), E("cookie to store:", a);
|
|
1478
|
-
} else
|
|
1479
|
-
s = ae(JSON.stringify(n)), E("cookie to store:", n);
|
|
1480
|
-
P.set("_saasquatch", s, {
|
|
1481
|
-
expires: 365,
|
|
1482
|
-
secure: !1,
|
|
1483
|
-
sameSite: "Lax",
|
|
1484
|
-
domain: r,
|
|
1485
|
-
path: "/"
|
|
1486
|
-
});
|
|
1487
|
-
} catch (r) {
|
|
1488
|
-
E("Unable to set cookie", r);
|
|
1489
|
-
}
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
const M = k("squatch-js");
|
|
1493
|
-
function Ge() {
|
|
1140
|
+
const R = C("squatch-js");
|
|
1141
|
+
function Fe() {
|
|
1494
1142
|
var u;
|
|
1495
1143
|
const o = window.location.search, e = new URLSearchParams(o).get("_saasquatchExtra") || "";
|
|
1496
1144
|
if (!e) {
|
|
1497
|
-
|
|
1145
|
+
R("No _saasquatchExtra param");
|
|
1498
1146
|
return;
|
|
1499
1147
|
}
|
|
1500
|
-
const n =
|
|
1148
|
+
const n = q({
|
|
1501
1149
|
tenantAlias: "UNKNOWN"
|
|
1502
1150
|
});
|
|
1503
1151
|
if (!n.domain) {
|
|
1504
|
-
|
|
1152
|
+
R("domain must be provided in config to use _saasquatchExtra");
|
|
1505
1153
|
return;
|
|
1506
1154
|
}
|
|
1507
1155
|
let i;
|
|
1508
1156
|
try {
|
|
1509
|
-
i = JSON.parse(
|
|
1157
|
+
i = JSON.parse(L(e));
|
|
1510
1158
|
} catch {
|
|
1511
|
-
|
|
1159
|
+
R("Unable to decode _saasquatchExtra config");
|
|
1512
1160
|
return;
|
|
1513
1161
|
}
|
|
1514
|
-
function s(
|
|
1515
|
-
return
|
|
1162
|
+
function s(m) {
|
|
1163
|
+
return m.replace(/^https?:\/\//, "");
|
|
1516
1164
|
}
|
|
1517
|
-
const r = s(n.domain), a = Object.keys((i == null ? void 0 : i[r]) || {})[0],
|
|
1518
|
-
if (!
|
|
1519
|
-
|
|
1165
|
+
const r = s(n.domain), a = Object.keys((i == null ? void 0 : i[r]) || {})[0], c = (u = i == null ? void 0 : i[r]) == null ? void 0 : u[a];
|
|
1166
|
+
if (!c) {
|
|
1167
|
+
R("_saasquatchExtra did not have an expected structure");
|
|
1520
1168
|
return;
|
|
1521
1169
|
}
|
|
1522
|
-
const { autoPopupWidgetType:
|
|
1170
|
+
const { autoPopupWidgetType: d, ...h } = c;
|
|
1523
1171
|
return {
|
|
1524
1172
|
widgetConfig: {
|
|
1525
|
-
widgetType:
|
|
1173
|
+
widgetType: d,
|
|
1526
1174
|
displayOnLoad: !0,
|
|
1527
1175
|
...h
|
|
1528
1176
|
},
|
|
@@ -1532,20 +1180,20 @@ function Ge() {
|
|
|
1532
1180
|
}
|
|
1533
1181
|
};
|
|
1534
1182
|
}
|
|
1535
|
-
const
|
|
1536
|
-
function
|
|
1183
|
+
const He = C("squatch-js:decodeUserJwt");
|
|
1184
|
+
function Je(o) {
|
|
1537
1185
|
var t;
|
|
1538
1186
|
try {
|
|
1539
1187
|
const e = o.split(".")[1];
|
|
1540
1188
|
if (e === void 0) return null;
|
|
1541
|
-
const n =
|
|
1189
|
+
const n = L(e);
|
|
1542
1190
|
return (t = JSON.parse(n)) == null ? void 0 : t.user;
|
|
1543
1191
|
} catch (e) {
|
|
1544
|
-
return
|
|
1192
|
+
return He(e), null;
|
|
1545
1193
|
}
|
|
1546
1194
|
}
|
|
1547
|
-
const
|
|
1548
|
-
class
|
|
1195
|
+
const P = C("squatch-js:DeclarativeWidget");
|
|
1196
|
+
class ge extends HTMLElement {
|
|
1549
1197
|
constructor() {
|
|
1550
1198
|
super();
|
|
1551
1199
|
/**
|
|
@@ -1611,15 +1259,15 @@ class fe extends HTMLElement {
|
|
|
1611
1259
|
widgetConfig: e.widgetConfig
|
|
1612
1260
|
},
|
|
1613
1261
|
type: this.widgetType,
|
|
1614
|
-
domain: ((s = this.config) == null ? void 0 : s.domain) ||
|
|
1262
|
+
domain: ((s = this.config) == null ? void 0 : s.domain) || k,
|
|
1615
1263
|
npmCdn: X,
|
|
1616
1264
|
container: this
|
|
1617
1265
|
};
|
|
1618
1266
|
if (this.type === "EMBED")
|
|
1619
|
-
return new
|
|
1267
|
+
return new D(i);
|
|
1620
1268
|
{
|
|
1621
1269
|
const r = this.firstChild ? null : void 0;
|
|
1622
|
-
return new
|
|
1270
|
+
return new j(i, r);
|
|
1623
1271
|
}
|
|
1624
1272
|
});
|
|
1625
1273
|
/**
|
|
@@ -1627,8 +1275,8 @@ class fe extends HTMLElement {
|
|
|
1627
1275
|
* @returns Instance of either {@link EmbedWidget} or {@link PopupWidget} depending on `this.type`
|
|
1628
1276
|
*/
|
|
1629
1277
|
l(this, "setErrorWidget", (e) => {
|
|
1630
|
-
var
|
|
1631
|
-
const n = e instanceof Error ? e.message : e == null ? void 0 : e.message, i = e
|
|
1278
|
+
var c;
|
|
1279
|
+
const n = e instanceof Error ? e.message : e == null ? void 0 : e.message, i = e == null ? void 0 : e.apiErrorCode, s = e == null ? void 0 : e.rsCode, r = e == null ? void 0 : e.statusCode, a = {
|
|
1632
1280
|
api: this.widgetApi,
|
|
1633
1281
|
content: "error",
|
|
1634
1282
|
context: {
|
|
@@ -1636,7 +1284,7 @@ class fe extends HTMLElement {
|
|
|
1636
1284
|
container: this.container || void 0
|
|
1637
1285
|
},
|
|
1638
1286
|
type: "ERROR_WIDGET",
|
|
1639
|
-
domain: ((
|
|
1287
|
+
domain: ((c = this.config) == null ? void 0 : c.domain) || k,
|
|
1640
1288
|
npmCdn: X,
|
|
1641
1289
|
container: this,
|
|
1642
1290
|
apiErrorCode: i,
|
|
@@ -1645,10 +1293,10 @@ class fe extends HTMLElement {
|
|
|
1645
1293
|
errorMessage: n
|
|
1646
1294
|
};
|
|
1647
1295
|
if (this.type === "EMBED")
|
|
1648
|
-
return new
|
|
1296
|
+
return new D(a);
|
|
1649
1297
|
{
|
|
1650
|
-
const
|
|
1651
|
-
return new
|
|
1298
|
+
const d = this.firstChild ? null : void 0;
|
|
1299
|
+
return new j(a, d);
|
|
1652
1300
|
}
|
|
1653
1301
|
});
|
|
1654
1302
|
l(this, "reload", this.renderWidget);
|
|
@@ -1656,23 +1304,23 @@ class fe extends HTMLElement {
|
|
|
1656
1304
|
l(this, "hide", this.close);
|
|
1657
1305
|
this.attachShadow({
|
|
1658
1306
|
mode: "open"
|
|
1659
|
-
}).innerHTML = "<style>:host { display: block; }</style><slot></slot>", this.config =
|
|
1307
|
+
}).innerHTML = "<style>:host { display: block; }</style><slot></slot>", this.config = Y(), this.token = W(), this.tenant = window.squatchTenant, this.container = this;
|
|
1660
1308
|
}
|
|
1661
1309
|
_setupApis(e) {
|
|
1662
1310
|
var n, i;
|
|
1663
1311
|
if (!this.tenant) throw new Error("tenantAlias not provided");
|
|
1664
1312
|
this.widgetApi = new Z({
|
|
1665
1313
|
tenantAlias: (e == null ? void 0 : e.tenantAlias) || this.tenant,
|
|
1666
|
-
domain: (e == null ? void 0 : e.domain) || ((n = this.config) == null ? void 0 : n.domain) ||
|
|
1314
|
+
domain: (e == null ? void 0 : e.domain) || ((n = this.config) == null ? void 0 : n.domain) || k
|
|
1667
1315
|
}), this.analyticsApi = new ue({
|
|
1668
|
-
domain: (e == null ? void 0 : e.domain) || ((i = this.config) == null ? void 0 : i.domain) ||
|
|
1316
|
+
domain: (e == null ? void 0 : e.domain) || ((i = this.config) == null ? void 0 : i.domain) || k
|
|
1669
1317
|
});
|
|
1670
1318
|
}
|
|
1671
1319
|
getWidgetType(e) {
|
|
1672
|
-
return e &&
|
|
1320
|
+
return e && e.includes("friendWidget") ? "instant-access" : "verified-access";
|
|
1673
1321
|
}
|
|
1674
1322
|
async renderPasswordlessVariant() {
|
|
1675
|
-
return this._setupApis(),
|
|
1323
|
+
return this._setupApis(), P("Rendering as an Instant Access widget"), await this.widgetApi.render({
|
|
1676
1324
|
engagementMedium: this.type,
|
|
1677
1325
|
widgetType: this.widgetType,
|
|
1678
1326
|
locale: this.locale
|
|
@@ -1680,10 +1328,10 @@ class fe extends HTMLElement {
|
|
|
1680
1328
|
}
|
|
1681
1329
|
async renderUserUpsertVariant() {
|
|
1682
1330
|
this._setupApis();
|
|
1683
|
-
const e =
|
|
1331
|
+
const e = Je(this.token);
|
|
1684
1332
|
if (!e)
|
|
1685
1333
|
return this.setErrorWidget(Error("No user object in token."));
|
|
1686
|
-
|
|
1334
|
+
!this.locale && e.locale && (this.locale = e.locale), P("Rendering as a Verified widget");
|
|
1687
1335
|
try {
|
|
1688
1336
|
await this.widgetApi.upsertUser({
|
|
1689
1337
|
user: e,
|
|
@@ -1713,9 +1361,9 @@ class fe extends HTMLElement {
|
|
|
1713
1361
|
this.widgetType = this.getAttribute("widget") || void 0, this.locale = this.getAttribute("locale") || this.locale;
|
|
1714
1362
|
const n = this.getWidgetType(this.widgetType);
|
|
1715
1363
|
if (!this.widgetType) throw new Error("No widget has been specified");
|
|
1716
|
-
return !this.token && n === "verified-access"
|
|
1717
|
-
|
|
1718
|
-
)
|
|
1364
|
+
return !this.token && n === "verified-access" && P(
|
|
1365
|
+
"[SquatchJS] Authentication token is required for this widget type."
|
|
1366
|
+
), this.token ? e = await this.renderUserUpsertVariant() : e = await this.renderPasswordlessVariant(), this.widgetInstance = e, this.widgetInstance && this.dispatchEvent(new CustomEvent("sq:widget-loaded")), e;
|
|
1719
1367
|
}
|
|
1720
1368
|
/**
|
|
1721
1369
|
* Calls {@link getWidgetInstance} to build the Widget instance and loads the widget iframe into the DOM
|
|
@@ -1753,109 +1401,114 @@ class fe extends HTMLElement {
|
|
|
1753
1401
|
}
|
|
1754
1402
|
async connectedCallback() {
|
|
1755
1403
|
this.loaded = !0, this.container = this.getAttribute("container"), this.widgetType = this.getAttribute("widget") || void 0;
|
|
1756
|
-
const e = this.getWidgetType(this.widgetType), { getSkeleton: n } = await
|
|
1757
|
-
height: "100%",
|
|
1404
|
+
const e = this.getWidgetType(this.widgetType), { getSkeleton: n } = await import("./SkeletonTemplate-Day_0iMM.js"), i = n({
|
|
1758
1405
|
type: e
|
|
1759
1406
|
}), s = document.createElement("div");
|
|
1760
1407
|
s.id = "loading-skeleton", s.innerHTML = i;
|
|
1761
1408
|
const r = this.shadowRoot || this.attachShadow({ mode: "open" });
|
|
1762
1409
|
if (this.type === "POPUP") {
|
|
1763
|
-
const
|
|
1764
|
-
|
|
1410
|
+
const a = r.getElementById("squatchModal");
|
|
1411
|
+
a && (a.innerHTML = "", a.appendChild(s));
|
|
1765
1412
|
} else
|
|
1766
1413
|
r.innerHTML = "", r.appendChild(s);
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1414
|
+
try {
|
|
1415
|
+
await this.renderWidget();
|
|
1416
|
+
} catch (a) {
|
|
1417
|
+
P("Failed to render widget", a);
|
|
1418
|
+
} finally {
|
|
1419
|
+
const a = r.getElementById("loading-skeleton");
|
|
1420
|
+
a && a.remove();
|
|
1421
|
+
}
|
|
1422
|
+
this.getAttribute("open") !== null && this.open();
|
|
1770
1423
|
}
|
|
1771
1424
|
}
|
|
1772
|
-
class
|
|
1425
|
+
class pe extends ge {
|
|
1773
1426
|
constructor() {
|
|
1774
1427
|
super(), this.type = "EMBED", this.loaded = !1;
|
|
1775
1428
|
}
|
|
1776
1429
|
}
|
|
1777
|
-
class
|
|
1430
|
+
class we extends ge {
|
|
1778
1431
|
constructor() {
|
|
1779
1432
|
super(), this.type = "POPUP", this.loaded = !1, this.addEventListener("click", (t) => {
|
|
1780
1433
|
t.stopPropagation(), this.open();
|
|
1781
1434
|
});
|
|
1782
1435
|
}
|
|
1783
1436
|
}
|
|
1784
|
-
class
|
|
1437
|
+
class Be extends pe {
|
|
1785
1438
|
}
|
|
1786
|
-
class
|
|
1439
|
+
class Ge extends we {
|
|
1787
1440
|
}
|
|
1788
|
-
class
|
|
1441
|
+
class ze extends pe {
|
|
1789
1442
|
}
|
|
1790
|
-
class
|
|
1443
|
+
class Ve extends we {
|
|
1791
1444
|
}
|
|
1792
|
-
window.customElements.get("squatch-embed") || window.customElements.define("squatch-embed",
|
|
1793
|
-
window.customElements.get("impact-embed") || window.customElements.define("impact-embed",
|
|
1794
|
-
window.customElements.get("squatch-popup") || window.customElements.define("squatch-popup",
|
|
1795
|
-
window.customElements.get("impact-popup") || window.customElements.define("impact-popup",
|
|
1796
|
-
function
|
|
1445
|
+
window.customElements.get("squatch-embed") || window.customElements.define("squatch-embed", Be);
|
|
1446
|
+
window.customElements.get("impact-embed") || window.customElements.define("impact-embed", ze);
|
|
1447
|
+
window.customElements.get("squatch-popup") || window.customElements.define("squatch-popup", Ge);
|
|
1448
|
+
window.customElements.get("impact-popup") || window.customElements.define("impact-popup", Ve);
|
|
1449
|
+
function Ye() {
|
|
1797
1450
|
console.log(
|
|
1798
1451
|
"Having trouble using Squatch.js? Go to https://docs.referralsaasquatch.com/developer/ for tutorials, references and error codes."
|
|
1799
1452
|
);
|
|
1800
1453
|
}
|
|
1801
|
-
const $ =
|
|
1802
|
-
let F = null,
|
|
1803
|
-
function
|
|
1804
|
-
return F ||
|
|
1454
|
+
const $ = C("squatch-js");
|
|
1455
|
+
let F = null, H = null, J = null;
|
|
1456
|
+
function Ze() {
|
|
1457
|
+
return F || G({}), F;
|
|
1805
1458
|
}
|
|
1806
|
-
function
|
|
1807
|
-
return
|
|
1459
|
+
function K() {
|
|
1460
|
+
return H || G({}), H;
|
|
1808
1461
|
}
|
|
1809
|
-
function
|
|
1810
|
-
return
|
|
1462
|
+
function Ke() {
|
|
1463
|
+
return J || G({}), J;
|
|
1811
1464
|
}
|
|
1812
|
-
function
|
|
1465
|
+
function et(o) {
|
|
1813
1466
|
var t;
|
|
1814
|
-
return (t =
|
|
1467
|
+
return (t = K()) == null ? void 0 : t.render(o);
|
|
1815
1468
|
}
|
|
1816
|
-
function
|
|
1469
|
+
function tt() {
|
|
1817
1470
|
var t;
|
|
1818
|
-
const o =
|
|
1471
|
+
const o = Fe();
|
|
1819
1472
|
if (o) {
|
|
1820
1473
|
const { squatchConfig: e, widgetConfig: n } = o;
|
|
1821
|
-
return
|
|
1474
|
+
return G(e), (t = K()) == null ? void 0 : t.render(n);
|
|
1822
1475
|
}
|
|
1823
1476
|
}
|
|
1824
|
-
function
|
|
1825
|
-
const e =
|
|
1826
|
-
e.tenantAlias.match("^test") || e.debug ?
|
|
1477
|
+
function G(o) {
|
|
1478
|
+
const e = q(o);
|
|
1479
|
+
e.tenantAlias.match("^test") || e.debug ? ve("squatch-js*") : _e(), $("initializing ..."), F = new Z(e), H = new N(e), J = new Oe(e), $("Widget API instance", F), $("Widgets instance", H), $("Events API instance", J);
|
|
1827
1480
|
}
|
|
1828
|
-
function
|
|
1481
|
+
function nt(o) {
|
|
1829
1482
|
o();
|
|
1830
1483
|
}
|
|
1831
|
-
function
|
|
1832
|
-
|
|
1484
|
+
function it(o) {
|
|
1485
|
+
K().autofill(o);
|
|
1833
1486
|
}
|
|
1834
|
-
function
|
|
1835
|
-
|
|
1487
|
+
function Xe() {
|
|
1488
|
+
Te();
|
|
1836
1489
|
}
|
|
1837
|
-
typeof document < "u" && !window.SaaSquatchDoNotAutoDrop &&
|
|
1838
|
-
var
|
|
1839
|
-
(
|
|
1490
|
+
typeof document < "u" && !window.SaaSquatchDoNotAutoDrop && Xe();
|
|
1491
|
+
var ae;
|
|
1492
|
+
(ae = window.squatch) != null && ae.init && $(
|
|
1840
1493
|
"Squatchjs is being loaded more than once. This may lead to multiple load events being sent, duplicated widgets, and inaccurate analytics."
|
|
1841
1494
|
);
|
|
1842
|
-
typeof document < "u" &&
|
|
1495
|
+
typeof document < "u" && Ne();
|
|
1843
1496
|
export {
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1497
|
+
pe as DeclarativeEmbedWidget,
|
|
1498
|
+
we as DeclarativePopupWidget,
|
|
1499
|
+
D as EmbedWidget,
|
|
1500
|
+
j as PopupWidget,
|
|
1848
1501
|
Z as WidgetApi,
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1502
|
+
N as Widgets,
|
|
1503
|
+
tt as _auto,
|
|
1504
|
+
Ze as api,
|
|
1505
|
+
it as autofill,
|
|
1506
|
+
Ke as events,
|
|
1507
|
+
Ye as help,
|
|
1508
|
+
G as init,
|
|
1509
|
+
Xe as pushCookie,
|
|
1510
|
+
nt as ready,
|
|
1511
|
+
et as widget,
|
|
1512
|
+
K as widgets
|
|
1860
1513
|
};
|
|
1861
1514
|
//# sourceMappingURL=squatch.esm.js.map
|